import * as i0 from '@angular/core';
import { EventEmitter, Directive, Input, Output } from '@angular/core';

class TextareaBaseComponent {
    constructor() {
        this.modelChange = new EventEmitter();
        // Implement ControlValueAccessor methods
        /**
         * Method to call when value has changes.
         */
        this.propagateChange = (_) => { };
        /**
         * Method to call when the component is touched (when it was is clicked).
         */
        this.propagateTouched = () => { };
    }
    ngOnInit() {
        this.resize = typeof this.resize === 'undefined' ? false : this.resize;
        this.model = this.model || '';
        this.placeholder = this.placeholder || '';
        this.error = this.error || '';
    }
    onChange(event) {
        this.propagateTouched();
        this.model = event;
        this.propagateChange(event);
        this.modelChange.emit(this.model);
    }
    /**
     * update value from model to the component
     */
    writeValue(value) {
        if (value === undefined || value === null) {
            this.model = '';
        }
        else {
            this.model = value;
        }
    }
    /**
     * Informs the outside world about changes.
     * see method propagateChange call - this.propagateChange(this.model);
     */
    registerOnChange(fn) {
        this.propagateChange = fn;
    }
    /**
     * on click
     */
    registerOnTouched(fn) {
        this.propagateTouched = fn;
    }
    /**
     * on set form controll enabled / disabled
     * also do UI Component enabled / disabled
     */
    setDisabledState(isDisabled) {
        this.isDisabled = isDisabled;
    }
    static { this.ɵfac = function TextareaBaseComponent_Factory(t) { return new (t || TextareaBaseComponent)(); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TextareaBaseComponent, inputs: { placeholder: "placeholder", error: "error", readonly: "readonly", required: "required", resize: "resize", name: "name", isDisabled: "isDisabled", model: "model" }, outputs: { modelChange: "modelChange" } }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TextareaBaseComponent, [{
        type: Directive
    }], null, { placeholder: [{
            type: Input
        }], error: [{
            type: Input
        }], readonly: [{
            type: Input
        }], required: [{
            type: Input
        }], resize: [{
            type: Input
        }], name: [{
            type: Input
        }], isDisabled: [{
            type: Input
        }], model: [{
            type: Input
        }], modelChange: [{
            type: Output
        }] }); })();

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

export { TextareaBaseComponent };
//# sourceMappingURL=ironsource-fusion-ui-components-textarea-common-base.mjs.map
