// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
// #endregion
/**
 * The `ColorEditorShadeSliderElementValueAccessor` class provides form value accessor
 * functionality for the `ColorEditorShadeSliderElement`, enabling two-way binding
 * between the shade slider and form controls.
 *
 * @public
 */
export class ColorEditorShadeSliderElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * Called when the host element is connected to the DOM.
     * Sets up event listeners for shade changes.
     *
     * @public
     */
    hostConnected() {
        this.host.on('change', (e) => this.writeValue(e.detail.shade));
        this.host.on('blur', () => this.onTouched());
        // we need to set the value here because the host element may have a value before the accessor is connected
        void this.host.updateComplete.then(() => {
            this.value = this.host.shade;
        });
    }
    /**
     * Writes a value to the host element.
     *
     * @public
     * @override
     * @param value - The shade value to write (0-100).
     */
    writeValue(value) {
        super.writeValue(value);
        this.host.shade = value ?? 0;
    }
    /**
     * Resets the host element to its default value.
     *
     * @public
     * @override
     */
    resetValue() {
        super.resetValue();
        this.host.shade = 0;
    }
}
/**
 * Factory function to create a `ColorEditorShadeSliderElementValueAccessor` instance.
 *
 * @public
 */
export const colorEditorShadeSliderElementValueAccessor = (host) => new ColorEditorShadeSliderElementValueAccessor(host);
//# sourceMappingURL=ColorEditorShadeSliderElementValueAccessor.js.map