import * as i0 from '@angular/core';
import { input, output, inject, ElementRef, Injector, runInInjectionContext, effect, ChangeDetectionStrategy, Component } from '@angular/core';
import '@ui5/webcomponents/dist/DynamicDateRange.js';

class DynamicDateRange {
    constructor() {
        /**
         * Defines the value object.
         */
        this.value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : []));
        /**
         * Defines the options listed as a string, separated by commas and using capital case.
      Example: "TODAY, YESTERDAY, DATERANGE"
         */
        this.options = input("", ...(ngDevMode ? [{ debugName: "options" }] : [])); // className is now passed
        /**
         * Fired when the input operation has finished by pressing Enter or on focusout or a value is selected in the popover.
         */
        this.ui5Change = output();
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
    }
    get element() {
        return this.elementRef.nativeElement;
    }
    ngAfterViewInit() {
        const wcElement = this.element;
        const inputsToSync = [
            'value',
            'options',
        ];
        // Synchronize inputs (properties)
        for (const inputName of inputsToSync) {
            // Find the corresponding camelCase signal property on the Angular component
            const signalName = inputName.replace(/-./g, (x) => x[1].toUpperCase());
            // Use the Injector to run the effect in the correct context
            if (this[signalName] && typeof this[signalName] === 'function') {
                runInInjectionContext(this.injector, () => {
                    effect(() => {
                        // Read the signal value
                        const value = this[signalName]();
                        if (wcElement) {
                            // Write the value to the Web Component's property
                            wcElement[inputName] = value;
                        }
                    });
                });
            }
        }
        const outputsToSync = [
            'ui5Change',
        ];
        // Synchronize outputs (events)
        for (const outputName of outputsToSync) {
            // Map Angular output name to UI5 web component event name
            const eventName = outputName.replace('ui5', '').replace(/([A-Z])/g, '-$1').toLowerCase().substring(1);
            // Ensure the output property exists and has an emit function before adding listener
            if (this[outputName] && typeof this[outputName].emit === 'function' && wcElement.addEventListener) {
                // Cast the listener to the correct type to satisfy TypeScript
                wcElement.addEventListener(eventName, (e) => {
                    this[outputName].emit(e);
                });
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DynamicDateRange, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.4", type: DynamicDateRange, isStandalone: true, selector: "ui5-dynamic-date-range, [ui5-dynamic-date-range]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ui5Change: "ui5Change" }, exportAs: ["ui5DynamicDateRange"], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DynamicDateRange, decorators: [{
            type: Component,
            args: [{
                    standalone: true,
                    selector: 'ui5-dynamic-date-range, [ui5-dynamic-date-range]',
                    template: '<ng-content></ng-content>',
                    exportAs: 'ui5DynamicDateRange',
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }] });

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

export { DynamicDateRange };
//# sourceMappingURL=fundamental-ngx-ui5-webcomponents-dynamic-date-range.mjs.map
