// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
// #endregion
/**
 * The `ListElementValueAccessor` class.
 *
 * @public
 */
export class ListElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * @public
     */
    hostConnected() {
        this.host.on('selectionChanged', (e) => this.writeValue(e.detail.newValue?.value ?? null));
        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.value;
        });
    }
    /**
     * @public
     * @override
     */
    writeValue(value) {
        super.writeValue(value);
        this.host.value = value;
    }
    /**
     * @public
     * @override
     */
    resetValue() {
        super.resetValue();
        this.host.value = null;
        this.host.resetSelection();
    }
}
/**
 * The `listElementValueAccessor` function for the `ListElement`.
 * This accessor can be bind to form field controls.
 *
 * @public
 */
export const listElementValueAccessor = (host) => new ListElementValueAccessor(host);
//# sourceMappingURL=ListElementValueAccessor.js.map