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

var tslib_es6 = require('./tslib.es6-Cm0ytgPY.js');
var index = require('./index-DBbl8tEq.js');
var Input = require('./Input-BmS5OT6F.js');
var dev_utils = require('./dev.utils-Cdn-EtYb.js');
var FormFieldStateWrapper = require('./FormFieldStateWrapper-C93KLp60.js');

const SuggestionsFc = (_a) => {
    var { id, suggestions } = _a, other = tslib_es6.__rest(_a, ["id", "suggestions"]);
    if (!suggestions) {
        return null;
    }
    return (index.h("datalist", Object.assign({ id: dev_utils.createRelatedUniqueId(id, 'list') }, other), suggestions.map((option) => (index.h("option", { value: option })))));
};

function getInputProps(state, other, customSuggestions) {
    var _a;
    const renderStates = FormFieldStateWrapper.getRenderStates(state);
    const ariaDescribedBy = [...renderStates.ariaDescribedBy, ...((_a = other.ariaDescribedBy) !== null && _a !== void 0 ? _a : [])];
    const props = {
        id: state._id,
        hideLabel: state._hideLabel,
        label: state._label,
        disabled: state._disabled,
        name: state._name,
    };
    if ('_accessKey' in state)
        props.accessKey = state._accessKey;
    if ('_type' in state)
        props.type = state._type;
    if ('_value' in state)
        props.value = state._value;
    if ('_required' in state)
        props.required = state._required;
    if ('_maxLength' in state && '_maxLengthBehavior' in state && state._maxLengthBehavior === 'hard')
        props.maxlength = state._maxLength;
    if ('_placeholder' in state)
        props.placeholder = state._placeholder;
    if ('_autoComplete' in state)
        props.autoComplete = state._autoComplete;
    if ('_spellCheck' in state)
        props.spellcheck = state._spellCheck;
    if ('_pattern' in state)
        props.pattern = state._pattern;
    if ('_readOnly' in state)
        props.readonly = state._readOnly;
    if ('_min' in state)
        props.min = state._min;
    if ('_max' in state)
        props.max = state._max;
    if ('_step' in state)
        props.step = state._step;
    if ('_multiple' in state)
        props.multiple = state._multiple;
    if ('_checked' in state)
        props.checked = state._checked;
    if ('_indeterminate' in state)
        props.indeterminate = state._indeterminate;
    if ('_touched' in state)
        props.touched = state._touched;
    if ('_msg' in state)
        props.msg = state._msg;
    if ('_shortKey' in state)
        props['aria-keyshortcuts'] = state._shortKey;
    if ('_suggestions' in state && !customSuggestions) {
        const hasSuggestions = Array.isArray(state._suggestions) && state._suggestions.length > 0;
        if (hasSuggestions) {
            props.suggestions = (index.h(SuggestionsFc, { id: state._id, suggestions: state._suggestions }));
        }
    }
    return Object.assign(Object.assign(Object.assign({}, props), other), { ariaDescribedBy });
}
const InputStateWrapper = (_a) => {
    var { state, customSuggestions } = _a, other = tslib_es6.__rest(_a, ["state", "customSuggestions"]);
    return index.h(Input.InputFc, Object.assign({}, getInputProps(state, other, customSuggestions)));
};

exports.InputStateWrapper = InputStateWrapper;
exports.SuggestionsFc = SuggestionsFc;
//# sourceMappingURL=InputStateWrapper-79jr7rz8.js.map

//# sourceMappingURL=InputStateWrapper-79jr7rz8.js.map