// #region Imports
import { ElementValueAccessorBase } from '../../../../../Forms/Accessors/Abstracts/ElementValueAccessorBase';
// #endregion
/**
 * The `AvatarElementValueAccessor` class.
 *
 * @public
 */
export class AvatarElementValueAccessor extends ElementValueAccessorBase {
    // #region Methods
    /**
     * @public
     */
    hostConnected() {
        this.host.on('changed', (e) => {
            if (e.detail.propertyName === 'src') {
                this.writeValue(e.target.src);
            }
        });
        // 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.src;
        });
    }
    /**
     * @public
     * @override
     */
    writeValue(value) {
        super.writeValue(value);
        this.host.src = value ?? '';
    }
    /**
     * @public
     * @override
     */
    resetValue() {
        super.resetValue();
        this.host.src = '';
    }
}
/**
 * @public
 */
export const avatarElementValueAccessor = (host) => new AvatarElementValueAccessor(host);
//# sourceMappingURL=AvatarElementValueAccessor.js.map