import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { g as genId, a as getHostAttrs } from './index2.js';
import { d as defineCustomElement$4 } from './bs-field-details2.js';
import { d as defineCustomElement$3 } from './bs-input2.js';
import { d as defineCustomElement$2 } from './bs-label2.js';

const bsInputFieldCss = ":where(bs-input-field){display:block;width:100%}";

const BsInputField$1 = /*@__PURE__*/ proxyCustomElement(class BsInputField extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    /** Native attributes to pass through to the input element. */
    this.attrs = {};
    this.disabled = false;
    this.error = undefined;
    this.errorMsg = undefined;
    this.hint = undefined;
    this.hints = undefined;
    this.inputId = undefined;
    this.label = undefined;
    this.passAttrs = '';
    this.placeholder = undefined;
    this.required = undefined;
    this.type = 'text';
    this.value = undefined;
    this.hintId = null;
  }
  get hintMsg() {
    return this.errorMsg || this.hint || this.hintDeprecated || undefined;
  }
  // Temporary holdover; removing this very soon
  get hintDeprecated() {
    var _a, _b;
    return ((_b = (_a = this.hints) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '\n')) || this.hints;
  }
  get inputIdAttr() {
    return this.inputId || this.inputIdGen;
  }
  componentWillLoad() {
    this.inputIdGen = this.inputId || genId();
    this.hintId = this.hintMsg ? genId() : null;
    this.attrs = getHostAttrs(this.hostEl, [
      'autocomplete',
      'max',
      'min',
      'maxlength',
      'minlength',
      'name',
      ...this.passAttrs.split(',')
    ]);
  }
  render() {
    return (h(Host, null, this.label && (h("bs-label", { for: this.inputIdAttr, disabled: this.disabled, required: this.required }, this.label)), h("bs-input", Object.assign({ disabled: this.disabled, error: this.error, "hint-id": this.hintId, "input-id": this.inputIdAttr, "pass-attrs": this.passAttrs, placeholder: this.placeholder, required: this.required, type: this.type, value: this.value }, this.attrs)), this.hintMsg && (h("bs-field-details", { error: this.error, "error-msg": this.errorMsg, hint: this.hint || this.hintDeprecated, "hint-id": this.hintId }))));
  }
  get hostEl() { return this; }
  static get style() { return bsInputFieldCss; }
}, [0, "bs-input-field", {
    "disabled": [4],
    "error": [4],
    "errorMsg": [1, "error-msg"],
    "hint": [1],
    "hints": [1],
    "inputId": [1, "input-id"],
    "label": [1],
    "passAttrs": [1, "pass-attrs"],
    "placeholder": [1],
    "required": [4],
    "type": [1],
    "value": [8],
    "hintId": [32]
  }]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["bs-input-field", "bs-field-details", "bs-input", "bs-label"];
  components.forEach(tagName => { switch (tagName) {
    case "bs-input-field":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, BsInputField$1);
      }
      break;
    case "bs-field-details":
      if (!customElements.get(tagName)) {
        defineCustomElement$4();
      }
      break;
    case "bs-input":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "bs-label":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
  } });
}

const BsInputField = BsInputField$1;
const defineCustomElement = defineCustomElement$1;

export { BsInputField, defineCustomElement };

//# sourceMappingURL=bs-input-field.js.map