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

class TableGrowing {
    constructor() {
        /**
         * Defines the mode of the <code>ui5-table</code> growing.
      
      Available options are:
      
      Button - Shows a More button at the bottom of the table, pressing it will load more rows.
      
      Scroll - The rows are loaded automatically by scrolling to the bottom of the table. If the table is not scrollable,
      a growing button will be rendered instead to ensure growing functionality.
         */
        this.mode = input("Button", ...(ngDevMode ? [{ debugName: "mode" }] : []));
        /**
         * Defines the text that will be displayed inside the growing button.
      Has no effect when mode is set to `Scroll`.
      
      **Note:** When not provided and the mode is set to Button, a default text is displayed, corresponding to the
      current language.
         */
        this.text = input(...(ngDevMode ? [undefined, { debugName: "text" }] : []));
        /**
         * Defines the text that will be displayed below the `text` inside the growing button.
      Has no effect when mode is set to Scroll.
         */
        this.subtext = input(...(ngDevMode ? [undefined, { debugName: "subtext" }] : [])); // className is now passed
        /**
         * Fired when the growing button is pressed or the user scrolls to the end of the table.
         */
        this.ui5LoadMore = output();
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
    }
    get element() {
        return this.elementRef.nativeElement;
    }
    ngAfterViewInit() {
        const wcElement = this.element;
        const inputsToSync = [
            'mode',
            'text',
            'subtext',
        ];
        // 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 = [
            'ui5LoadMore',
        ];
        // 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: TableGrowing, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.4", type: TableGrowing, isStandalone: true, selector: "ui5-table-growing, [ui5-table-growing]", inputs: { mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, subtext: { classPropertyName: "subtext", publicName: "subtext", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ui5LoadMore: "ui5LoadMore" }, exportAs: ["ui5TableGrowing"], 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: TableGrowing, decorators: [{
            type: Component,
            args: [{
                    standalone: true,
                    selector: 'ui5-table-growing, [ui5-table-growing]',
                    template: '<ng-content></ng-content>',
                    exportAs: 'ui5TableGrowing',
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }] });

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

export { TableGrowing };
//# sourceMappingURL=fundamental-ngx-ui5-webcomponents-table-growing.mjs.map
