"use strict";
const vue = require("vue");
const useDefaults = require("./useDefaults-YXpmugKp.js");
const useFormInput = require("./useFormInput-CSIV1X5N.js");
const keys = require("./keys-D70E9HED.js");
const _hoisted_1 = ["id", "value", "name", "form", "type", "disabled", "placeholder", "required", "autocomplete", "readonly", "min", "max", "step", "list", "aria-required", "aria-invalid"];
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "BFormInput",
  props: /* @__PURE__ */ vue.mergeModels({
    max: { default: void 0 },
    min: { default: void 0 },
    step: { default: void 0 },
    type: { default: "text" },
    ariaInvalid: { type: [Boolean, String], default: void 0 },
    autocomplete: { default: void 0 },
    autofocus: { type: Boolean, default: false },
    disabled: { type: Boolean, default: false },
    form: { default: void 0 },
    formatter: { type: Function, default: void 0 },
    id: { default: void 0 },
    lazyFormatter: { type: Boolean, default: false },
    list: { default: void 0 },
    name: { default: void 0 },
    placeholder: { default: void 0 },
    plaintext: { type: Boolean, default: false },
    readonly: { type: Boolean, default: false },
    required: { type: Boolean, default: false },
    size: { default: void 0 },
    state: { type: [Boolean, null], default: void 0 },
    debounce: { default: 0 },
    debounceMaxWait: { default: Number.NaN }
  }, {
    "modelValue": {
      default: ""
    },
    "modelModifiers": {}
  }),
  emits: ["update:modelValue"],
  setup(__props, { expose: __expose }) {
    const _props = __props;
    const props = useDefaults.useDefaults(_props, "BFormInput");
    const [modelValue, modelModifiers] = vue.useModel(__props, "modelValue", {
      set: (v) => useFormInput.normalizeInput(v, modelModifiers)
    });
    const input = vue.useTemplateRef("_input");
    const inInputGroup = vue.inject(keys.inputGroupKey, false);
    const {
      computedId,
      computedAriaInvalid,
      onInput,
      onChange,
      onBlur,
      stateClass,
      focus,
      blur,
      isDisabled
    } = useFormInput.useFormInput(props, input, modelValue, modelModifiers);
    const computedClasses = vue.computed(() => {
      const isRange = props.type === "range";
      const isColor = props.type === "color";
      return [
        stateClass.value,
        {
          "form-range": isRange,
          "form-control": isColor || !props.plaintext && !isRange || isRange && inInputGroup,
          "form-control-color": isColor,
          "form-control-plaintext": props.plaintext && !isRange && !isColor,
          [`form-control-${props.size}`]: !!props.size
        }
      ];
    });
    __expose({
      blur,
      element: input,
      flushDebounce: onBlur,
      focus
    });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("input", {
        id: vue.unref(computedId),
        ref: "_input",
        value: vue.unref(modelValue),
        class: vue.normalizeClass(computedClasses.value),
        name: vue.unref(props).name || void 0,
        form: vue.unref(props).form || void 0,
        type: vue.unref(props).type,
        disabled: vue.unref(isDisabled),
        placeholder: vue.unref(props).placeholder,
        required: vue.unref(props).required || void 0,
        autocomplete: vue.unref(props).autocomplete || void 0,
        readonly: vue.unref(props).readonly || vue.unref(props).plaintext,
        min: vue.unref(props).min,
        max: vue.unref(props).max,
        step: vue.unref(props).step,
        list: vue.unref(props).type !== "password" ? vue.unref(props).list : void 0,
        "aria-required": vue.unref(props).required || void 0,
        "aria-invalid": vue.unref(computedAriaInvalid),
        onInput: _cache[0] || (_cache[0] = //@ts-ignore
        (...args) => vue.unref(onInput) && vue.unref(onInput)(...args)),
        onChange: _cache[1] || (_cache[1] = //@ts-ignore
        (...args) => vue.unref(onChange) && vue.unref(onChange)(...args)),
        onBlur: _cache[2] || (_cache[2] = //@ts-ignore
        (...args) => vue.unref(onBlur) && vue.unref(onBlur)(...args))
      }, null, 42, _hoisted_1);
    };
  }
});
exports._sfc_main = _sfc_main;
//# sourceMappingURL=BFormInput.vue_vue_type_script_setup_true_lang-CW9OISbw.js.map
