/*!
 * KoliBri - The accessible HTML-Standard
 */
'use strict';

var common = require('./common-DAAt5YQ7.js');
var autoComplete = require('./auto-complete-ByyIPPbm.js');
var maxLengthBehavior = require('./max-length-behavior-BjqOHcK6.js');
var placeholder = require('./placeholder-B7I3KNtq.js');
var readOnly = require('./read-only-BFoDOTZu.js');
var required = require('./required-QyEHP_gi.js');
var variantClassName = require('./variant-class-name-DsZdGPeK.js');
var controllerIcon = require('./controller-icon-BfIYzDZs.js');

const validatePattern = (component, value, options = {}) => {
    common.watchString(component, '_pattern', value, options);
};

const validateVisibilityToggle = (component, value, hooks) => {
    common.watchBoolean(component, '_visibilityToggle', value, hooks);
};

class InputPasswordController extends controllerIcon.InputIconController {
    constructor(component, name, host) {
        super(component, name, host);
        this.afterSyncCharCounter = () => {
            if (typeof this.component._value === 'string') {
                this.component.state._currentLength = this.component._value.length;
                this.updateCurrentLengthDebounced(this.component._value.length);
            }
        };
        this.component = component;
    }
    validateAutoComplete(value) {
        autoComplete.validateAutoComplete(this.component, value);
    }
    validateHasCounter(value) {
        maxLengthBehavior.validateHasCounter(this.component, value);
    }
    validateMaxLengthBehavior(value) {
        maxLengthBehavior.validateMaxLengthBehavior(this.component, value);
    }
    validateMaxLength(value) {
        maxLengthBehavior.validateMaxLength(this.component, value, {
            hooks: { afterPatch: this.afterSyncCharCounter },
        });
    }
    validatePattern(value) {
        validatePattern(this.component, value);
    }
    validatePlaceholder(value) {
        placeholder.validatePlaceholder(this.component, value);
    }
    validateReadOnly(value) {
        readOnly.validateReadOnly(this.component, value);
    }
    validateRequired(value) {
        required.validateRequired(this.component, value);
    }
    validateValue(value) {
        common.watchString(this.component, '_value', value, {
            hooks: {
                afterPatch: this.afterSyncCharCounter,
            },
        });
        this.setFormAssociatedValue(this.component.state._value);
    }
    validateVariant(value) {
        variantClassName.validateVariantClassName(this.component, value);
    }
    validateVisibilityToggle(value) {
        validateVisibilityToggle(this.component, value);
    }
    componentWillLoad() {
        super.componentWillLoad();
        this.validateAutoComplete(this.component._autoComplete);
        this.validateHasCounter(this.component._hasCounter);
        this.validateMaxLengthBehavior(this.component._maxLengthBehavior);
        this.validateMaxLength(this.component._maxLength);
        this.validatePattern(this.component._pattern);
        this.validatePlaceholder(this.component._placeholder);
        this.validateReadOnly(this.component._readOnly);
        this.validateRequired(this.component._required);
        this.validateValue(this.component._value);
        this.validateVariant(this.component._variant);
        this.validateVisibilityToggle(this.component._visibilityToggle);
    }
}

exports.InputPasswordController = InputPasswordController;
//# sourceMappingURL=controller-3DispTOw.js.map

//# sourceMappingURL=controller-3DispTOw.js.map