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

class Slider {
    constructor() {
        /**
         * Current value of the slider
         */
        this.value = input(0, ...(ngDevMode ? [{ debugName: "value" }] : []));
        /**
         * Defines the minimum value of the slider.
         */
        this.min = input(0, ...(ngDevMode ? [{ debugName: "min" }] : []));
        /**
         * Defines the maximum value of the slider.
         */
        this.max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : []));
        /**
         * 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 size of the slider's selection intervals (e.g. min = 0, max = 10, step = 5 would result in possible selection of the values 0, 5, 10).
      
      **Note:** If set to 0 the slider handle movement is disabled. When negative number or value other than a number, the component fallbacks to its default value.
         */
        this.step = input(1, ...(ngDevMode ? [{ debugName: "step" }] : []));
        /**
         * Displays a label with a value on every N-th step.
      
      **Note:** The step and tickmarks properties must be enabled.
      Example - if the step value is set to 2 and the label interval is also specified to 2 - then every second
      tickmark will be labelled, which means every 4th value number.
         */
        this.labelInterval = input(0, ...(ngDevMode ? [{ debugName: "labelInterval" }] : []));
        /**
         * Enables tickmarks visualization for each step.
      
      **Note:** The step must be a positive number.
         */
        this.showTickmarks = input(false, ...(ngDevMode ? [{ debugName: "showTickmarks", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Enables handle tooltip displaying the current value.
         */
        this.showTooltip = input(false, ...(ngDevMode ? [{ debugName: "showTooltip", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         *
      Indicates whether input fields should be used as tooltips for the handles.
      
      **Note:** Setting this option to true will only work if showTooltip is set to true.
      **Note:** In order for the component to comply with the accessibility standard, it is recommended to set the editableTooltip property to true.
         */
        this.editableTooltip = input(false, ...(ngDevMode ? [{ debugName: "editableTooltip", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines whether the slider is in disabled state.
         */
        this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines the accessible ARIA name of the component.
         */
        this.accessibleName = input(...(ngDevMode ? [undefined, { debugName: "accessibleName" }] : [])); // className is now passed
        /**
         * Fired when the value changes and the user has finished interacting with the slider.
         */
        this.ui5Change = output();
        /**
         * Fired when the value changes due to user interaction that is not yet finished - during mouse/touch dragging.
         */
        this.ui5Input = output();
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
    }
    get element() {
        return this.elementRef.nativeElement;
    }
    ngAfterViewInit() {
        const wcElement = this.element;
        const inputsToSync = [
            'value',
            'min',
            'max',
            'name',
            'step',
            'labelInterval',
            'showTickmarks',
            'showTooltip',
            'editableTooltip',
            'disabled',
            'accessibleName',
        ];
        // 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',
            'ui5Input',
        ];
        // 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: Slider, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.4", type: Slider, isStandalone: true, selector: "ui5-slider, [ui5-slider]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, labelInterval: { classPropertyName: "labelInterval", publicName: "labelInterval", isSignal: true, isRequired: false, transformFunction: null }, showTickmarks: { classPropertyName: "showTickmarks", publicName: "showTickmarks", isSignal: true, isRequired: false, transformFunction: null }, showTooltip: { classPropertyName: "showTooltip", publicName: "showTooltip", isSignal: true, isRequired: false, transformFunction: null }, editableTooltip: { classPropertyName: "editableTooltip", publicName: "editableTooltip", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, accessibleName: { classPropertyName: "accessibleName", publicName: "accessibleName", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ui5Change: "ui5Change", ui5Input: "ui5Input" }, exportAs: ["ui5Slider"], 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: Slider, decorators: [{
            type: Component,
            args: [{
                    standalone: true,
                    selector: 'ui5-slider, [ui5-slider]',
                    template: '<ng-content></ng-content>',
                    exportAs: 'ui5Slider',
                    hostDirectives: [GenericControlValueAccessor],
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }] });

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

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