import * as i0 from '@angular/core';
import { input, booleanAttribute, output, inject, ElementRef, Injector, runInInjectionContext, effect, ChangeDetectionStrategy, Component } from '@angular/core';
import '@ui5/webcomponents/dist/Switch.js';
import * as i1 from '@fundamental-ngx/ui5-webcomponents/utils';
import { GenericControlValueAccessor } from '@fundamental-ngx/ui5-webcomponents/utils';

class Switch {
    constructor() {
        /**
         * Defines the component design.
      
      **Note:** If `Graphical` type is set,
      positive and negative icons will replace the `textOn` and `textOff`.
         */
        this.design = input("Textual", ...(ngDevMode ? [{ debugName: "design" }] : []));
        /**
         * Defines if the component is checked.
      
      **Note:** The property can be changed with user interaction,
      either by cliking the component, or by pressing the `Enter` or `Space` key.
         */
        this.checked = input(false, ...(ngDevMode ? [{ debugName: "checked", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines whether the component is disabled.
      
      **Note:** A disabled component is noninteractive.
         */
        this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines the text, displayed when the component is checked.
      
      **Note:** We recommend using short texts, up to 3 letters (larger texts would be cut off).
         */
        this.textOn = input(...(ngDevMode ? [undefined, { debugName: "textOn" }] : []));
        /**
         * Defines the text, displayed when the component is not checked.
      
      **Note:** We recommend using short texts, up to 3 letters (larger texts would be cut off).
         */
        this.textOff = input(...(ngDevMode ? [undefined, { debugName: "textOff" }] : []));
        /**
         * Sets the accessible ARIA name of the component.
      
      **Note**: We recommend that you set an accessibleNameRef pointing to an external label or at least an `accessibleName`.
      Providing an `accessibleNameRef` or an `accessibleName` is mandatory in the cases when `textOn` and `textOff` properties aren't set.
         */
        this.accessibleName = input(...(ngDevMode ? [undefined, { debugName: "accessibleName" }] : []));
        /**
         * Receives id(or many ids) of the elements that label the component.
      
      **Note**: We recommend that you set an accessibleNameRef pointing to an external label or at least an `accessibleName`.
      Providing an `accessibleNameRef` or an `accessibleName` is mandatory in the cases when `textOn` and `textOff` properties aren't set.
         */
        this.accessibleNameRef = input(...(ngDevMode ? [undefined, { debugName: "accessibleNameRef" }] : []));
        /**
         * Defines the tooltip of the component.
      
      **Note:** If applicable an external label reference should always be the preferred option to provide context to the `ui5-switch` component over a tooltip.
         */
        this.tooltip = input(...(ngDevMode ? [undefined, { debugName: "tooltip" }] : []));
        /**
         * Defines whether the component is required.
         */
        this.required = input(false, ...(ngDevMode ? [{ debugName: "required", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Determines the name by which the component will be identified upon submission in an HTML form.
      
      **Note:** This property is only applicable within the context of an HTML Form element.
         */
        this.name = input(...(ngDevMode ? [undefined, { debugName: "name" }] : []));
        /**
         * Defines the form value of the component.
         */
        this.value = input("", ...(ngDevMode ? [{ debugName: "value" }] : [])); // className is now passed
        /**
         * Fired when the component checked state changes.
         */
        this.ui5Change = output();
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
    }
    get element() {
        return this.elementRef.nativeElement;
    }
    ngAfterViewInit() {
        const wcElement = this.element;
        const inputsToSync = [
            'design',
            'checked',
            'disabled',
            'textOn',
            'textOff',
            'accessibleName',
            'accessibleNameRef',
            'tooltip',
            'required',
            'name',
            'value',
        ];
        // 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: Switch, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.4", type: Switch, isStandalone: true, selector: "ui5-switch, [ui5-switch]", inputs: { design: { classPropertyName: "design", publicName: "design", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, textOn: { classPropertyName: "textOn", publicName: "textOn", isSignal: true, isRequired: false, transformFunction: null }, textOff: { classPropertyName: "textOff", publicName: "textOff", isSignal: true, isRequired: false, transformFunction: null }, accessibleName: { classPropertyName: "accessibleName", publicName: "accessibleName", isSignal: true, isRequired: false, transformFunction: null }, accessibleNameRef: { classPropertyName: "accessibleNameRef", publicName: "accessibleNameRef", isSignal: true, isRequired: false, transformFunction: null }, tooltip: { classPropertyName: "tooltip", publicName: "tooltip", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ui5Change: "ui5Change" }, exportAs: ["ui5Switch"], hostDirectives: [{ directive: i1.GenericControlValueAccessor }], 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: Switch, decorators: [{
            type: Component,
            args: [{
                    standalone: true,
                    selector: 'ui5-switch, [ui5-switch]',
                    template: '<ng-content></ng-content>',
                    exportAs: 'ui5Switch',
                    hostDirectives: [GenericControlValueAccessor],
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }] });

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

export { Switch };
//# sourceMappingURL=fundamental-ngx-ui5-webcomponents-switch.mjs.map
