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