import * as i0 from '@angular/core';
import { inject, DestroyRef, ViewContainerRef, Component, ViewChild, Input, ElementRef, NgModule } from '@angular/core';
import * as i1 from '@angular/forms';
import { FormGroup, FormsModule } from '@angular/forms';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { delay, first } from 'rxjs/operators';
import { LocaleService } from '@seniorsistemas/angular-components/locale';
import { InfoSignDirective } from '@seniorsistemas/angular-components/info-sign';
import { ButtonComponent } from '@seniorsistemas/angular-components/button';
import { ControlErrorsComponent } from '@seniorsistemas/angular-components/control-errors';
import { TranslatePipe } from '@ngx-translate/core';
import { DatepickerComponent } from '@seniorsistemas/angular-components/datepicker';
import { NgClass } from '@angular/common';
import { InputMaskDirective } from '@seniorsistemas/angular-components/input-mask';
import { InputText } from 'primeng/inputtext';
import { TooltipDirective } from '@seniorsistemas/angular-components/tooltip';
import { BignumberInputDirective } from '@seniorsistemas/angular-components/bignumber-input';
import { Textarea } from 'primeng/textarea';
import { KeyFilter } from 'primeng/keyfilter';
import { DeprecatedSelectorDirective } from '@seniorsistemas/angular-components/common/deprecated-selector';
import { ContentGeneratorComponent } from '@seniorsistemas/angular-components/content-generator';

class InlineEditField {
    label;
    name;
    tooltip;
    errorMessages;
    constructor(options) {
        this.label = options.label;
        this.name = options.name;
        this.tooltip = options.tooltip;
        this.errorMessages = options.errorMessages;
    }
}

class InlineEditCalendarField extends InlineEditField {
    view;
    appendTo;
    minDate;
    maxDate;
    defaultDate;
    showOnFocus;
    onBlur;
    onFocus;
    onSelect;
    onInput;
    onClose;
    onTodayClick;
    onClearClick;
    onMonthChange;
    onYearChange;
    selectionMode;
    rangeSeparator;
    showSeconds;
    placeholder;
    constructor(options) {
        super(options);
        this.view = options.view || "date";
        this.minDate = options.minDate;
        this.maxDate = options.maxDate;
        this.defaultDate = options.defaultDate;
        this.appendTo = options.appendTo;
        this.showOnFocus = typeof options.showOnFocus === "boolean" ? options.showOnFocus : true;
        this.onBlur = options.onBlur;
        this.onFocus = options.onFocus;
        this.onSelect = options.onSelect;
        this.onInput = options.onInput;
        this.onClose = options.onClose;
        this.onTodayClick = options.onTodayClick;
        this.onClearClick = options.onClearClick;
        this.onMonthChange = options.onMonthChange;
        this.onYearChange = options.onYearChange;
        this.selectionMode = options.selectionMode || "single";
        this.rangeSeparator = options.rangeSeparator || "-";
        this.showSeconds = options.showSeconds;
        this.placeholder = options.placeholder;
    }
}

class InlineEditLookupField extends InlineEditField {
    multiple = false;
    showSearch = true;
    searchFields = [];
    searchGridFields = [];
    lookupSuggestions = [];
    suggestionsObservable = null;
    searchObservable = null;
    dataKey = '';
    lookupDisplayField = '';
    searchTitle = '';
    searchEmptyTitle = '';
    filterTitle = '';
    emptyMessage = '';
    appendTo;
    autocompleteForceSelection = true;
    maxlength = null;
    showAddOption = false;
    showEditOption = false;
    showRemoveOption = false;
    defaultFilter = [];
    onLookupRequest;
    onSearchRequest;
    onClear;
    onBlur;
    onAdd;
    onEdit;
    onRemove;
    placeholder;
    _gridData = [];
    _searchTotalRecords = 0;
    _searchTotalRecordsLabel = '';
    onSelect = (event) => { };
    onUnselect = (event) => { };
    get gridData() {
        return this._gridData;
    }
    get searchTotalRecords() {
        return this._searchTotalRecords;
    }
    get searchTotalRecordsLabel() {
        return this._searchTotalRecordsLabel;
    }
    constructor(options) {
        super(options);
        Object.assign(this, options);
        if (this.suggestionsObservable) {
            this.suggestionsObservable.subscribe((suggestions) => (this.lookupSuggestions = suggestions));
        }
        if (this.searchObservable) {
            this.searchObservable.pipe(delay(0)).subscribe(({ totalRecords, gridData, searchTotalRecordsLabel }) => {
                this._gridData = gridData;
                this._searchTotalRecords = totalRecords;
                this._searchTotalRecordsLabel = searchTotalRecordsLabel;
            });
        }
    }
}

class InlineEditNumberField extends InlineEditField {
    allowNegative;
    numberLocaleOptions;
    browserAutocomplete;
    precision;
    scale;
    alignTo;
    mask;
    leftAddon;
    rightAddon;
    placeholder;
    autoClear;
    onBlur;
    onFocus;
    onComplete;
    onInput;
    constructor(options) {
        super(options);
        this.allowNegative = options.allowNegative ?? true;
        this.numberLocaleOptions = options.numberLocaleOptions;
        this.browserAutocomplete = options.browserAutocomplete;
        this.precision = options.precision;
        this.scale = options.scale ?? 2;
        this.alignTo = this.scale ? 'right' : 'left';
        this.mask = options.mask;
        this.leftAddon = options.leftAddon;
        this.rightAddon = options.rightAddon;
        this.onBlur = options.onBlur;
        this.onFocus = options.onFocus;
        this.onComplete = options.onComplete;
        this.onInput = options.onInput;
        this.autoClear = options.autoClear ?? true;
        this.placeholder = options.placeholder ?? "";
    }
}

class InlineEditTextAreaField extends InlineEditField {
    cols;
    rows;
    keyFilter;
    readonly;
    constructor(options) {
        super(options);
        this.cols = options.cols;
        this.rows = options.rows;
        this.keyFilter = options.keyFilter;
        this.readonly = options.readonly;
    }
}

class InlineEditTextField extends InlineEditField {
    constructor(options) {
        super(options);
    }
}

class InlineEditContentGeneratorField extends InlineEditField {
    constructor(options) {
        super(options);
    }
}

class InlineEditItemComponent {
    localeService = inject(LocaleService);
    _destroyRef = inject(DestroyRef);
    viewContainerRef = null;
    label;
    formGroup;
    field;
    errorMessages;
    isEditing = false;
    _locale;
    dynamicComponentRef = null;
    ngOnInit() {
        this._getCalendarLocaleOptions();
    }
    get showEmptyValueButton() {
        return !this.isEditing && !this.formGroup.get(this.field.name)?.value;
    }
    get showEditButton() {
        return !this.isEditing && this.formGroup.get(this.field.name)?.value;
    }
    get showValue() {
        return !this.isEditing && this.formGroup.get(this.field.name)?.value;
    }
    onEdit() {
        this.isEditing = !this.isEditing;
    }
    onCancel() {
        this.isEditing = !this.isEditing;
    }
    onSave() {
        if (this.dynamicComponentRef && this.dynamicComponentRef.instance.saveValue) {
            const control = this.formGroup.get(this.field.name);
            if (control) {
                control.markAsDirty({ onlySelf: true });
            }
            this.dynamicComponentRef.instance.saveValue();
        }
        if (this.formGroup.get(this.field.name)?.valid) {
            this.isEditing = !this.isEditing;
        }
    }
    setDynamicComponentRef(ref) {
        this.dynamicComponentRef = ref;
    }
    getErrorMessages(errorMessages) {
        if (errorMessages)
            return errorMessages instanceof Function
                ? { ...this.errorMessages, ...errorMessages() }
                : { ...this.errorMessages, ...errorMessages };
        return this.errorMessages;
    }
    getFormattedValue(value) {
        if (this.field instanceof InlineEditCalendarField) {
            return (this.dynamicComponentRef?.instance).getValueAsText();
        }
        if (this.field instanceof InlineEditLookupField) {
            const lookupField = this.field;
            return this.field.multiple
                ? value.map((val) => val[lookupField.lookupDisplayField]).join(' - ')
                : value[lookupField.lookupDisplayField];
        }
        return value;
    }
    _getCalendarLocaleOptions() {
        this.localeService
            .get()
            .pipe(first(), takeUntilDestroyed(this._destroyRef))
            .subscribe((localeOptions) => {
            this._locale = localeOptions.locale;
        });
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: InlineEditItemComponent, isStandalone: true, selector: "s-inline-edit-item", inputs: { label: "label", formGroup: "formGroup", field: "field", errorMessages: "errorMessages" }, viewQueries: [{ propertyName: "viewContainerRef", first: true, predicate: ["formContainer"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<div class=\"inline-edit-item\">\r\n    <label\r\n        class=\"label\"\r\n        *sInfoSign=\"field.tooltip ? field.tooltip : ''\"\r\n    >\r\n        {{ label }}:\r\n    </label>\r\n\r\n    <div class=\"content\">\r\n        @if (showValue) {\r\n            <span class=\"value\">\r\n                {{ getFormattedValue(formGroup.get(field.name)?.value) }}\r\n            </span>\r\n        }\r\n\r\n        @if (showEmptyValueButton) {\r\n            <s-button\r\n                style=\"margin-left: -8px\"\r\n                priority=\"link\"\r\n                [label]=\"'platform.angular_components.add_information' | translate\"\r\n                (clicked)=\"onEdit()\"\r\n            >\r\n            </s-button>\r\n        }\r\n\r\n        <div\r\n            [hidden]=\"!isEditing\"\r\n            class=\"form-container\"\r\n        >\r\n            <ng-container #formContainer></ng-container>\r\n        </div>\r\n\r\n        <div class=\"options\">\r\n            @if (showEditButton) {\r\n                <s-button\r\n                    [tooltip]=\"'platform.angular_components.edit' | translate\"\r\n                    (clicked)=\"onEdit()\"\r\n                    priority=\"link\"\r\n                    [auxiliary]=\"true\"\r\n                    iconClass=\"fas fa-edit\"\r\n                >\r\n                </s-button>\r\n            }\r\n            @if (isEditing) {\r\n                <s-button\r\n                    [tooltip]=\"'platform.angular_components.save' | translate\"\r\n                    (clicked)=\"onSave()\"\r\n                    priority=\"default\"\r\n                    [auxiliary]=\"true\"\r\n                    iconClass=\"fas fa-check\"\r\n                    styleClass=\"save-option\"\r\n                    iconColor=\"#428bca\"\r\n                >\r\n                </s-button>\r\n            }\r\n            @if (isEditing) {\r\n                <s-button\r\n                    [tooltip]=\"'platform.angular_components.cancel' | translate\"\r\n                    (clicked)=\"onCancel()\"\r\n                    priority=\"default\"\r\n                    [auxiliary]=\"true\"\r\n                    iconClass=\"fas fa-times\"\r\n                    iconColor=\"#c13018\"\r\n                >\r\n                </s-button>\r\n            }\r\n        </div>\r\n    </div>\r\n    <s-control-errors\r\n        [form]=\"formGroup\"\r\n        [control]=\"formGroup.controls[field.name]\"\r\n        [errorMessages]=\"getErrorMessages(field.errorMessages)\"\r\n    >\r\n    </s-control-errors>\r\n</div>\r\n", styles: [".inline-edit-item{align-items:flex-start;display:flex;flex-direction:column}.inline-edit-item .label{color:#333;font-family:\"Open Sans\" sans-serif;font-size:14px;font-weight:700;margin-bottom:0}.inline-edit-item .content{align-items:center;display:flex;gap:16px}.inline-edit-item .content .value{color:#999;font-family:\"Open Sans\" sans-serif;font-size:14px}.inline-edit-item .content .options{display:flex}\n"], dependencies: [{ kind: "directive", type: InfoSignDirective, selector: "[sInfoSign]", inputs: ["sInfoSign", "sInfoSignDisplayTime", "sInfoSignFocusedInputRef", "sInfoSignUseFocusedInputRef"] }, { kind: "component", type: ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor", "menuAriaLabel", "ariaLabel"], outputs: ["clicked"] }, { kind: "component", type: ControlErrorsComponent, selector: "s-control-errors", inputs: ["id", "control", "errorMessages", "form"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditItemComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-inline-edit-item', standalone: true, imports: [InfoSignDirective, ButtonComponent, ControlErrorsComponent, TranslatePipe], template: "<div class=\"inline-edit-item\">\r\n    <label\r\n        class=\"label\"\r\n        *sInfoSign=\"field.tooltip ? field.tooltip : ''\"\r\n    >\r\n        {{ label }}:\r\n    </label>\r\n\r\n    <div class=\"content\">\r\n        @if (showValue) {\r\n            <span class=\"value\">\r\n                {{ getFormattedValue(formGroup.get(field.name)?.value) }}\r\n            </span>\r\n        }\r\n\r\n        @if (showEmptyValueButton) {\r\n            <s-button\r\n                style=\"margin-left: -8px\"\r\n                priority=\"link\"\r\n                [label]=\"'platform.angular_components.add_information' | translate\"\r\n                (clicked)=\"onEdit()\"\r\n            >\r\n            </s-button>\r\n        }\r\n\r\n        <div\r\n            [hidden]=\"!isEditing\"\r\n            class=\"form-container\"\r\n        >\r\n            <ng-container #formContainer></ng-container>\r\n        </div>\r\n\r\n        <div class=\"options\">\r\n            @if (showEditButton) {\r\n                <s-button\r\n                    [tooltip]=\"'platform.angular_components.edit' | translate\"\r\n                    (clicked)=\"onEdit()\"\r\n                    priority=\"link\"\r\n                    [auxiliary]=\"true\"\r\n                    iconClass=\"fas fa-edit\"\r\n                >\r\n                </s-button>\r\n            }\r\n            @if (isEditing) {\r\n                <s-button\r\n                    [tooltip]=\"'platform.angular_components.save' | translate\"\r\n                    (clicked)=\"onSave()\"\r\n                    priority=\"default\"\r\n                    [auxiliary]=\"true\"\r\n                    iconClass=\"fas fa-check\"\r\n                    styleClass=\"save-option\"\r\n                    iconColor=\"#428bca\"\r\n                >\r\n                </s-button>\r\n            }\r\n            @if (isEditing) {\r\n                <s-button\r\n                    [tooltip]=\"'platform.angular_components.cancel' | translate\"\r\n                    (clicked)=\"onCancel()\"\r\n                    priority=\"default\"\r\n                    [auxiliary]=\"true\"\r\n                    iconClass=\"fas fa-times\"\r\n                    iconColor=\"#c13018\"\r\n                >\r\n                </s-button>\r\n            }\r\n        </div>\r\n    </div>\r\n    <s-control-errors\r\n        [form]=\"formGroup\"\r\n        [control]=\"formGroup.controls[field.name]\"\r\n        [errorMessages]=\"getErrorMessages(field.errorMessages)\"\r\n    >\r\n    </s-control-errors>\r\n</div>\r\n", styles: [".inline-edit-item{align-items:flex-start;display:flex;flex-direction:column}.inline-edit-item .label{color:#333;font-family:\"Open Sans\" sans-serif;font-size:14px;font-weight:700;margin-bottom:0}.inline-edit-item .content{align-items:center;display:flex;gap:16px}.inline-edit-item .content .value{color:#999;font-family:\"Open Sans\" sans-serif;font-size:14px}.inline-edit-item .content .options{display:flex}\n"] }]
        }], propDecorators: { viewContainerRef: [{
                type: ViewChild,
                args: ['formContainer', { read: ViewContainerRef, static: true }]
            }], label: [{
                type: Input,
                args: [{ required: true }]
            }], formGroup: [{
                type: Input,
                args: [{ required: true }]
            }], field: [{
                type: Input,
                args: [{ required: true }]
            }], errorMessages: [{
                type: Input
            }] } });

class InlineEditCalendarComponent {
    localeService = inject(LocaleService);
    _destroyRef = inject(DestroyRef);
    field;
    formGroup = new FormGroup({});
    datepickerEl = null;
    tempValue = null;
    calendarLocaleOptions = null;
    get resolvedHourFormat() {
        return this.calendarLocaleOptions?.hourFormat === '12' ? '12' : '24';
    }
    get resolvedMode() {
        if (this.field.view === 'month')
            return 'month';
        if (this.field.view === 'year')
            return 'year';
        return 'date';
    }
    ngOnInit() {
        this._getLocaleOptions();
        if (this.formGroup && this.field) {
            this.tempValue = this.formGroup.get(this.field.name)?.value || null;
        }
    }
    saveValue() {
        if (this.formGroup && this.field) {
            this.formGroup.get(this.field.name)?.setValue(this.tempValue);
        }
    }
    getValueAsText() {
        return this.datepickerEl?.nativeElement?.querySelector('input')?.value ?? '';
    }
    _getLocaleOptions() {
        this.localeService
            .get()
            .pipe(first(), takeUntilDestroyed(this._destroyRef))
            .subscribe((locale) => {
            this.calendarLocaleOptions = locale.calendar;
        });
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditCalendarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: InlineEditCalendarComponent, isStandalone: true, selector: "ng-component", inputs: { field: "field", formGroup: "formGroup" }, viewQueries: [{ propertyName: "datepickerEl", first: true, predicate: DatepickerComponent, descendants: true, read: ElementRef }], ngImport: i0, template: "<s-datepicker\n    #datepicker\n    [inputId]=\"field.name\"\n    [name]=\"field.name\"\n    [showIcon]=\"true\"\n    [mode]=\"resolvedMode\"\n    [rangeSeparator]=\"field.rangeSeparator ?? ' \u2014 '\"\n    [showSeconds]=\"field.showSeconds ?? false\"\n    icon=\"fas fa-calendar\"\n    [min]=\"field.minDate ?? null\"\n    [max]=\"field.maxDate ?? null\"\n    [dateFormat]=\"calendarLocaleOptions?.dateFormat ?? 'dd/MM/yyyy'\"\n    [hourFormat]=\"resolvedHourFormat\"\n    [defaultDate]=\"field.defaultDate ?? null\"\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    (closed)=\"field.onClose ? field.onClose($event) : 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    [(ngModel)]=\"tempValue\">\n</s-datepicker>\n", styles: [""], dependencies: [{ 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: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditCalendarComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [DatepickerComponent, FormsModule], template: "<s-datepicker\n    #datepicker\n    [inputId]=\"field.name\"\n    [name]=\"field.name\"\n    [showIcon]=\"true\"\n    [mode]=\"resolvedMode\"\n    [rangeSeparator]=\"field.rangeSeparator ?? ' \u2014 '\"\n    [showSeconds]=\"field.showSeconds ?? false\"\n    icon=\"fas fa-calendar\"\n    [min]=\"field.minDate ?? null\"\n    [max]=\"field.maxDate ?? null\"\n    [dateFormat]=\"calendarLocaleOptions?.dateFormat ?? 'dd/MM/yyyy'\"\n    [hourFormat]=\"resolvedHourFormat\"\n    [defaultDate]=\"field.defaultDate ?? null\"\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    (closed)=\"field.onClose ? field.onClose($event) : 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    [(ngModel)]=\"tempValue\">\n</s-datepicker>\n" }]
        }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formGroup: [{
                type: Input
            }], datepickerEl: [{
                type: ViewChild,
                args: [DatepickerComponent, { read: ElementRef }]
            }] } });

class InlineEditLookupComponent {
    field;
    formGroup = new FormGroup({});
    tempValue = '';
    ngOnInit() {
        if (this.formGroup && this.field) {
            this.tempValue = this.formGroup.get(this.field.name)?.value || '';
        }
    }
    saveValue() {
        if (this.formGroup && this.field) {
            this.formGroup.get(this.field.name)?.setValue(this.tempValue);
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditLookupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: InlineEditLookupComponent, isStandalone: true, selector: "ng-component", inputs: { field: "field", formGroup: "formGroup" }, ngImport: i0, template: "<!--\nTODO: ativar campo novamente\n<s-lookup\n    [id]=\"field.name\"\n    [multiple]=\"field.multiple\"\n    [lookupSuggestions]=\"field.lookupSuggestions\"\n    [dataKey]=\"field.dataKey\"\n    [placeholder]=\"field.placeholder\"\n    [showSearch]=\"field.showSearch\"\n    [searchFields]=\"field.searchFields\"\n    [searchGridFields]=\"field.searchGridFields\"\n    [searchGridData]=\"field.gridData\"\n    (onLookupRequest)=\"field.onLookupRequest ? field.onLookupRequest($event) : null\"\n    (onSearchRequest)=\"field.onSearchRequest ? field.onSearchRequest($event) : null\"\n    [lookupDisplayField]=\"field.lookupDisplayField\"\n    [searchTotalRecords]=\"field.searchTotalRecords\"\n    [labelOptions]=\"{\n            filterTitle: field.filterTitle,[\n            searchTotalRecordsLabel: field.searchTotalRecordsLabel,\n            searchEmptyTitle: field.searchEmptyTitle,\n            searchTitle: field.searchTitle,\n\n    }\"\n    (onSelect)=\"field.onSelect($event)\"\n    (onUnselect)=\"field.onUnselect($event)\"\n    (onClear)=\"field.onClear ? field.onClear($event) : null\"\n    (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n    [lookupAppendTo]=\"field.appendTo\"\n    [lookupEmptyMessage]=\"field.emptyMessage\"\n    [defaultFilter]=\"field.defaultFilter\"\n    [autocompleteForceSelection]=\"field.autocompleteForceSelection\"\n    [maxlength]=\"field.maxlength\"\n    [showAddOption]=\"field.showAddOption\"\n    [showEditOption]=\"field.showEditOption\"\n    [showRemoveOption]=\"field.showRemoveOption\"\n    (onAdd)=\"field.onAdd ? field.onAdd() : null\"\n    (onEdit)=\"field.onEdit ? field.onEdit($event) : null\"\n    (onRemove)=\"field.onRemove ? field.onRemove($event) : null\"\n    [(ngModel)]=\"tempValue\">\n</s-lookup> -->\n\n", styles: [""] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditLookupComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, template: "<!--\nTODO: ativar campo novamente\n<s-lookup\n    [id]=\"field.name\"\n    [multiple]=\"field.multiple\"\n    [lookupSuggestions]=\"field.lookupSuggestions\"\n    [dataKey]=\"field.dataKey\"\n    [placeholder]=\"field.placeholder\"\n    [showSearch]=\"field.showSearch\"\n    [searchFields]=\"field.searchFields\"\n    [searchGridFields]=\"field.searchGridFields\"\n    [searchGridData]=\"field.gridData\"\n    (onLookupRequest)=\"field.onLookupRequest ? field.onLookupRequest($event) : null\"\n    (onSearchRequest)=\"field.onSearchRequest ? field.onSearchRequest($event) : null\"\n    [lookupDisplayField]=\"field.lookupDisplayField\"\n    [searchTotalRecords]=\"field.searchTotalRecords\"\n    [labelOptions]=\"{\n            filterTitle: field.filterTitle,[\n            searchTotalRecordsLabel: field.searchTotalRecordsLabel,\n            searchEmptyTitle: field.searchEmptyTitle,\n            searchTitle: field.searchTitle,\n\n    }\"\n    (onSelect)=\"field.onSelect($event)\"\n    (onUnselect)=\"field.onUnselect($event)\"\n    (onClear)=\"field.onClear ? field.onClear($event) : null\"\n    (onBlur)=\"field.onBlur ? field.onBlur($event) : null\"\n    [lookupAppendTo]=\"field.appendTo\"\n    [lookupEmptyMessage]=\"field.emptyMessage\"\n    [defaultFilter]=\"field.defaultFilter\"\n    [autocompleteForceSelection]=\"field.autocompleteForceSelection\"\n    [maxlength]=\"field.maxlength\"\n    [showAddOption]=\"field.showAddOption\"\n    [showEditOption]=\"field.showEditOption\"\n    [showRemoveOption]=\"field.showRemoveOption\"\n    (onAdd)=\"field.onAdd ? field.onAdd() : null\"\n    (onEdit)=\"field.onEdit ? field.onEdit($event) : null\"\n    (onRemove)=\"field.onRemove ? field.onRemove($event) : null\"\n    [(ngModel)]=\"tempValue\">\n</s-lookup> -->\n\n" }]
        }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formGroup: [{
                type: Input
            }] } });

class InlineEditNumberComponent {
    localeService = inject(LocaleService);
    _destroyRef = inject(DestroyRef);
    field;
    formGroup = new FormGroup({});
    tempValue = '';
    ngOnInit() {
        this._onLocaleService();
        if (this.formGroup && this.field) {
            this.tempValue = this.formGroup.get(this.field.name)?.value || '';
        }
    }
    saveValue() {
        if (this.formGroup && this.field) {
            this.formGroup.get(this.field.name)?.setValue(this.tempValue);
        }
    }
    get mask() {
        return typeof this.field.mask === 'function' ? this.field.mask() : this.field.mask;
    }
    get leftAddonDisabled() {
        return typeof this.field.leftAddon?.disabled === 'function'
            ? this.field.leftAddon.disabled()
            : this.field.leftAddon?.disabled;
    }
    get rightAddonDisabled() {
        return typeof this.field.rightAddon?.disabled === 'function'
            ? this.field.rightAddon.disabled()
            : this.field.rightAddon?.disabled;
    }
    get precision() {
        return typeof this.field.precision === 'function' ? this.field.precision() : this.field.precision;
    }
    get scale() {
        return typeof this.field.scale === 'function' ? this.field.scale() : this.field.scale;
    }
    _onLocaleService() {
        this.localeService
            .getLocale()
            .pipe(first(), takeUntilDestroyed(this._destroyRef))
            .subscribe({
            next: () => {
                if (!this.field.numberLocaleOptions?.decimalSeparator) {
                    this.field.numberLocaleOptions = {
                        ...this.field.numberLocaleOptions,
                        decimalSeparator: this.localeService.getDecimalSeparator(),
                    };
                }
                if (!this.field.numberLocaleOptions?.thousandsSeparator) {
                    this.field.numberLocaleOptions = {
                        ...this.field.numberLocaleOptions,
                        thousandsSeparator: this.localeService.getGroupingSeparator(),
                    };
                }
            },
            error: () => (this.field.numberLocaleOptions = {
                thousandsSeparator: '.',
                decimalSeparator: ',',
                currencySymbol: '',
            }),
        });
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditNumberComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: InlineEditNumberComponent, isStandalone: true, selector: "ng-component", inputs: { field: "field", formGroup: "formGroup" }, ngImport: i0, template: "@if (field.mask) {\r\n    <input\r\n        pInputText\r\n        class=\"mousetrap\"\r\n        type=\"text\"\r\n        [id]=\"field.name\"\r\n        [name]=\"field.name\"\r\n        [sInputMask]=\"mask\"\r\n        [placeholder]=\"field.placeholder\"\r\n        slotChar=\"_\"\r\n        [sTooltip]=\"field.tooltip\"\r\n        tooltipPosition=\"top\"\r\n        [showDelay]=\"500\"\r\n        [autoClear]=\"field.autoClear ?? false\"\r\n        (blur)=\"field.onBlur ? field.onBlur($event) : null\"\r\n        (focus)=\"field.onFocus ? field.onFocus($event) : null\"\r\n        (maskComplete)=\"field.onComplete ? field.onComplete($event) : null\"\r\n        (input)=\"field.onInput ? field.onInput($event) : null\"\r\n        [(ngModel)]=\"tempValue\"\r\n    />\r\n} @else {\r\n    <ng-container>\r\n        <div class=\"ui-inputgroup\">\r\n            @if (field.leftAddon) {\r\n                @if (field.leftAddon.callback) {\r\n                    <span class=\"addon-button addon-button--left\">\r\n                        <s-button\r\n                            [label]=\"field.leftAddon.label\"\r\n                            [iconClass]=\"field.leftAddon.icon\"\r\n                            [priority]=\"field.leftAddon.priority\"\r\n                            [disabled]=\"leftAddonDisabled\"\r\n                            (clicked)=\"field.leftAddon.callback()\"\r\n                        >\r\n                        </s-button>\r\n                    </span>\r\n                }\r\n                @if (!field.leftAddon.callback) {\r\n                    <span class=\"ui-inputgroup-addon\">\r\n                        @if (field.leftAddon.label) {\r\n                            <span>{{ field.leftAddon.label }}</span>\r\n                        }\r\n                        @if (!field.leftAddon.label) {\r\n                            <span [ngClass]=\"field.leftAddon.icon\"></span>\r\n                        }\r\n                    </span>\r\n                }\r\n            }\r\n            <input\r\n                [id]=\"field.name\"\r\n                type=\"text\"\r\n                [name]=\"field.name\"\r\n                sBignumberInput\r\n                [allowNegative]=\"field.allowNegative ?? false\"\r\n                [precision]=\"precision\"\r\n                [scale]=\"scale\"\r\n                [alignTo]=\"field.alignTo\"\r\n                [sTooltip]=\"field.tooltip\"\r\n                tooltipPosition=\"top\"\r\n                [placeholder]=\"field.placeholder\"\r\n                [showDelay]=\"500\"\r\n                pInputText\r\n                [autocomplete]=\"field.browserAutocomplete ? 'on' : 'off'\"\r\n                [ngClass]=\"'mousetrap'\"\r\n                (blur)=\"field.onBlur ? field.onBlur($event) : null\"\r\n                (focus)=\"field.onFocus ? field.onFocus($event) : null\"\r\n                [(ngModel)]=\"tempValue\"\r\n            />\r\n            @if (field.rightAddon) {\r\n                @if (field.rightAddon.callback) {\r\n                    <span class=\"addon-button addon-button--right\">\r\n                        <s-button\r\n                            [label]=\"field.rightAddon.label\"\r\n                            [iconClass]=\"field.rightAddon.icon\"\r\n                            [priority]=\"field.rightAddon.priority\"\r\n                            [disabled]=\"rightAddonDisabled\"\r\n                            (clicked)=\"field.rightAddon.callback()\"\r\n                        >\r\n                        </s-button>\r\n                    </span>\r\n                }\r\n                @if (!field.rightAddon.callback) {\r\n                    <span class=\"ui-inputgroup-addon\">\r\n                        @if (field.rightAddon.label) {\r\n                            <span>{{ field.rightAddon.label }}</span>\r\n                        }\r\n                        @if (!field.rightAddon.label) {\r\n                            <span [ngClass]=\"field.rightAddon.icon\"></span>\r\n                        }\r\n                    </span>\r\n                }\r\n            }\r\n        </div>\r\n    </ng-container>\r\n}\r\n", styles: [""], dependencies: [{ kind: "directive", type: InputMaskDirective, selector: "input[sInputMask]", inputs: ["sInputMask", "slotChar", "unmask", "characterPattern", "autoClear"], outputs: ["maskComplete"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: InputText, selector: "[pInputText]", inputs: ["variant", "fluid", "pSize"] }, { kind: "directive", type: TooltipDirective, selector: "[sTooltip]", inputs: ["sTooltip", "tooltipPosition", "showDelay", "displayTime", "tooltipEvent", "escape", "visible", "mobileBehavior", "focusedInputRef", "checkTruncatedText"] }, { kind: "component", type: ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor", "menuAriaLabel", "ariaLabel"], outputs: ["clicked"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: BignumberInputDirective, selector: "input[sBignumberInput]", inputs: ["precision", "scale", "minDecimalPlaces", "maxDecimalPlaces", "decimalSeparator", "thousandsSeparator", "thousandSeparator", "alignTo", "allowNegative", "placeholder"], outputs: ["minDecimalPlacesChange", "maxDecimalPlacesChange", "decimalSeparatorChange", "thousandSeparatorChange", "placeholderChange", "pasteRejected"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditNumberComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [
                        InputMaskDirective,
                        FormsModule,
                        InputText,
                        TooltipDirective,
                        ButtonComponent,
                        NgClass,
                        BignumberInputDirective,
                    ], template: "@if (field.mask) {\r\n    <input\r\n        pInputText\r\n        class=\"mousetrap\"\r\n        type=\"text\"\r\n        [id]=\"field.name\"\r\n        [name]=\"field.name\"\r\n        [sInputMask]=\"mask\"\r\n        [placeholder]=\"field.placeholder\"\r\n        slotChar=\"_\"\r\n        [sTooltip]=\"field.tooltip\"\r\n        tooltipPosition=\"top\"\r\n        [showDelay]=\"500\"\r\n        [autoClear]=\"field.autoClear ?? false\"\r\n        (blur)=\"field.onBlur ? field.onBlur($event) : null\"\r\n        (focus)=\"field.onFocus ? field.onFocus($event) : null\"\r\n        (maskComplete)=\"field.onComplete ? field.onComplete($event) : null\"\r\n        (input)=\"field.onInput ? field.onInput($event) : null\"\r\n        [(ngModel)]=\"tempValue\"\r\n    />\r\n} @else {\r\n    <ng-container>\r\n        <div class=\"ui-inputgroup\">\r\n            @if (field.leftAddon) {\r\n                @if (field.leftAddon.callback) {\r\n                    <span class=\"addon-button addon-button--left\">\r\n                        <s-button\r\n                            [label]=\"field.leftAddon.label\"\r\n                            [iconClass]=\"field.leftAddon.icon\"\r\n                            [priority]=\"field.leftAddon.priority\"\r\n                            [disabled]=\"leftAddonDisabled\"\r\n                            (clicked)=\"field.leftAddon.callback()\"\r\n                        >\r\n                        </s-button>\r\n                    </span>\r\n                }\r\n                @if (!field.leftAddon.callback) {\r\n                    <span class=\"ui-inputgroup-addon\">\r\n                        @if (field.leftAddon.label) {\r\n                            <span>{{ field.leftAddon.label }}</span>\r\n                        }\r\n                        @if (!field.leftAddon.label) {\r\n                            <span [ngClass]=\"field.leftAddon.icon\"></span>\r\n                        }\r\n                    </span>\r\n                }\r\n            }\r\n            <input\r\n                [id]=\"field.name\"\r\n                type=\"text\"\r\n                [name]=\"field.name\"\r\n                sBignumberInput\r\n                [allowNegative]=\"field.allowNegative ?? false\"\r\n                [precision]=\"precision\"\r\n                [scale]=\"scale\"\r\n                [alignTo]=\"field.alignTo\"\r\n                [sTooltip]=\"field.tooltip\"\r\n                tooltipPosition=\"top\"\r\n                [placeholder]=\"field.placeholder\"\r\n                [showDelay]=\"500\"\r\n                pInputText\r\n                [autocomplete]=\"field.browserAutocomplete ? 'on' : 'off'\"\r\n                [ngClass]=\"'mousetrap'\"\r\n                (blur)=\"field.onBlur ? field.onBlur($event) : null\"\r\n                (focus)=\"field.onFocus ? field.onFocus($event) : null\"\r\n                [(ngModel)]=\"tempValue\"\r\n            />\r\n            @if (field.rightAddon) {\r\n                @if (field.rightAddon.callback) {\r\n                    <span class=\"addon-button addon-button--right\">\r\n                        <s-button\r\n                            [label]=\"field.rightAddon.label\"\r\n                            [iconClass]=\"field.rightAddon.icon\"\r\n                            [priority]=\"field.rightAddon.priority\"\r\n                            [disabled]=\"rightAddonDisabled\"\r\n                            (clicked)=\"field.rightAddon.callback()\"\r\n                        >\r\n                        </s-button>\r\n                    </span>\r\n                }\r\n                @if (!field.rightAddon.callback) {\r\n                    <span class=\"ui-inputgroup-addon\">\r\n                        @if (field.rightAddon.label) {\r\n                            <span>{{ field.rightAddon.label }}</span>\r\n                        }\r\n                        @if (!field.rightAddon.label) {\r\n                            <span [ngClass]=\"field.rightAddon.icon\"></span>\r\n                        }\r\n                    </span>\r\n                }\r\n            }\r\n        </div>\r\n    </ng-container>\r\n}\r\n" }]
        }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formGroup: [{
                type: Input
            }] } });

class InlineEditTextAreaComponent {
    field;
    formGroup = new FormGroup({});
    tempValue = '';
    ngOnInit() {
        if (this.formGroup && this.field) {
            this.tempValue = this.formGroup.get(this.field.name)?.value || '';
        }
    }
    saveValue() {
        if (this.formGroup && this.field) {
            this.formGroup.get(this.field.name)?.setValue(this.tempValue);
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditTextAreaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: InlineEditTextAreaComponent, isStandalone: true, selector: "ng-component", inputs: { field: "field", formGroup: "formGroup" }, ngImport: i0, template: "@if(field.keyFilter) {\n    <textarea\n        [id]=\"field.name\"\n        pTextarea\n        class=\"textarea-input\"\n        [rows]=\"field.rows\"\n        [cols]=\"field.cols\"\n        [readonly]=\"field.readonly ? field.readonly() : false\"\n        [(ngModel)]=\"tempValue\"\n        [pKeyFilter]=\"field.keyFilter\">\n    </textarea>\n}@else {\n    <textarea\n        [id]=\"field.name\"\n        pTextarea\n        class=\"textarea-input\"\n        [rows]=\"field.rows\"\n        [cols]=\"field.cols\"\n        [readonly]=\"field.readonly ? field.readonly() : false\"\n        [(ngModel)]=\"tempValue\">\n    </textarea>\n\n}\n", styles: [".textarea-input{resize:vertical}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: Textarea, selector: "[pTextarea]", inputs: ["autoResize", "variant", "fluid", "pSize"], outputs: ["onResize"] }, { kind: "directive", type: KeyFilter, selector: "[pKeyFilter]", inputs: ["pValidateOnly", "pKeyFilter"], outputs: ["ngModelChange"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditTextAreaComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [FormsModule, Textarea, KeyFilter], template: "@if(field.keyFilter) {\n    <textarea\n        [id]=\"field.name\"\n        pTextarea\n        class=\"textarea-input\"\n        [rows]=\"field.rows\"\n        [cols]=\"field.cols\"\n        [readonly]=\"field.readonly ? field.readonly() : false\"\n        [(ngModel)]=\"tempValue\"\n        [pKeyFilter]=\"field.keyFilter\">\n    </textarea>\n}@else {\n    <textarea\n        [id]=\"field.name\"\n        pTextarea\n        class=\"textarea-input\"\n        [rows]=\"field.rows\"\n        [cols]=\"field.cols\"\n        [readonly]=\"field.readonly ? field.readonly() : false\"\n        [(ngModel)]=\"tempValue\">\n    </textarea>\n\n}\n", styles: [".textarea-input{resize:vertical}\n"] }]
        }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formGroup: [{
                type: Input
            }] } });

class InlineEditTextComponent {
    field;
    formGroup = new FormGroup({});
    tempValue;
    ngOnInit() {
        if (this.formGroup && this.field) {
            this.tempValue = this.formGroup.get(this.field.name)?.value || '';
        }
    }
    saveValue() {
        if (this.formGroup && this.field) {
            this.formGroup.get(this.field.name)?.setValue(this.tempValue);
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditTextComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: InlineEditTextComponent, isStandalone: true, selector: "ng-component", inputs: { field: "field", formGroup: "formGroup" }, ngImport: i0, template: "<input\n    type=\"text\"\n    pInputText\n    [(ngModel)]=\"tempValue\" />", styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: InputText, selector: "[pInputText]", inputs: ["variant", "fluid", "pSize"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditTextComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [FormsModule, InputText], template: "<input\n    type=\"text\"\n    pInputText\n    [(ngModel)]=\"tempValue\" />" }]
        }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formGroup: [{
                type: Input
            }] } });

class InlineEditContentGeneratorComponent {
    field;
    formGroup = new FormGroup({});
    tempValue = '';
    ngOnInit() {
        if (this.formGroup && this.field) {
            this.tempValue = this.formGroup.get(this.field.name)?.value || '';
        }
    }
    saveValue() {
        if (this.formGroup && this.field) {
            this.formGroup.get(this.field.name)?.setValue(this.tempValue);
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditContentGeneratorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: InlineEditContentGeneratorComponent, isStandalone: true, selector: "ng-component", inputs: { field: "field", formGroup: "formGroup" }, ngImport: i0, template: "<s-content-generator [(ngModel)]=\"tempValue\"></s-content-generator>", styles: [""], dependencies: [{ kind: "component", type: ContentGeneratorComponent, selector: "s-content-generator, s-text-area-ia", inputs: ["id", "label", "placeholder", "prompt", "readonly", "rows", "cols", "speechRecognition", "keepContext", "speechRecognitionPlaceholder", "maxLength", "textAreaStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditContentGeneratorComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [DeprecatedSelectorDirective, ContentGeneratorComponent, FormsModule], template: "<s-content-generator [(ngModel)]=\"tempValue\"></s-content-generator>" }]
        }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formGroup: [{
                type: Input
            }] } });

/**
 * @description Componente de edição inline que renderiza dinamicamente campos editáveis
 * (texto, número, data, textarea, lookup e gerador de conteúdo) a partir de uma lista
 * de configurações `InlineEditField[]`. Integrado a um `FormGroup` Angular fornecido externamente.
 *
 * @example
 * ```html
 * <s-inline-edit [formGroup]="form" [fields]="camposEditaveis" />
 * ```
 *
 * @category Inputs
 */
class InlineEditComponent {
    /** @description `FormGroup` Angular ao qual os campos inline serão vinculados. @default new FormGroup({}) */
    formGroup = new FormGroup({});
    /** @description Lista de configurações dos campos inline a serem renderizados. @default [] */
    fields = [];
    /** @description Mapa de mensagens de erro customizadas por nome de validador. */
    errorMessages;
    container = null;
    ngOnInit() {
        this._createFields();
    }
    _componentMap = {
        [InlineEditCalendarField.name]: InlineEditCalendarComponent,
        [InlineEditLookupField.name]: InlineEditLookupComponent,
        [InlineEditTextField.name]: InlineEditTextComponent,
        [InlineEditNumberField.name]: InlineEditNumberComponent,
        [InlineEditTextAreaField.name]: InlineEditTextAreaComponent,
        [InlineEditContentGeneratorField.name]: InlineEditContentGeneratorComponent,
    };
    _createFields() {
        if (!this.container) {
            return;
        }
        this.container.clear();
        const createComponent = (componentClass, field) => {
            const componentRef = this.container.createComponent(componentClass);
            componentRef.instance.field = field;
            componentRef.instance.formGroup = this.formGroup;
            return componentRef;
        };
        for (let field of this.fields) {
            let componentClass = this._componentMap[field.constructor.name];
            if (componentClass) {
                const inlineEditItemRef = this.container.createComponent(InlineEditItemComponent);
                inlineEditItemRef.instance.label = field.label;
                inlineEditItemRef.instance.formGroup = this.formGroup;
                inlineEditItemRef.instance.field = field;
                inlineEditItemRef.instance.errorMessages = this.errorMessages;
                const dynamicComponentRef = createComponent(componentClass, field);
                const inlineEditItemInstance = inlineEditItemRef.instance;
                if (inlineEditItemInstance.viewContainerRef) {
                    inlineEditItemInstance.viewContainerRef.insert(dynamicComponentRef.hostView);
                    inlineEditItemInstance.setDynamicComponentRef(dynamicComponentRef);
                }
            }
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: InlineEditComponent, isStandalone: true, selector: "s-inline-edit", inputs: { formGroup: "formGroup", fields: "fields", errorMessages: "errorMessages" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["formContainer"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<div class=\"inline-edit\">\n    <ng-template #formContainer></ng-template>\n</div>\n", styles: [".inline-edit{display:flex;flex-direction:column;gap:8px}\n"] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-inline-edit', standalone: true, template: "<div class=\"inline-edit\">\n    <ng-template #formContainer></ng-template>\n</div>\n", styles: [".inline-edit{display:flex;flex-direction:column;gap:8px}\n"] }]
        }], propDecorators: { formGroup: [{
                type: Input
            }], fields: [{
                type: Input
            }], errorMessages: [{
                type: Input
            }], container: [{
                type: ViewChild,
                args: ['formContainer', { read: ViewContainerRef, static: true }]
            }] } });

class InlineEditModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: InlineEditModule, imports: [InlineEditComponent], exports: [InlineEditComponent] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditModule });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: InlineEditModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [InlineEditComponent],
                    exports: [InlineEditComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { InlineEditCalendarField, InlineEditComponent, InlineEditContentGeneratorField, InlineEditField, InlineEditLookupField, InlineEditModule, InlineEditNumberField, InlineEditTextAreaField, InlineEditTextField };
//# sourceMappingURL=seniorsistemas-angular-components-inline-edit.mjs.map
