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-label2.js';
import { d as defineCustomElement$2 } from './bs-textarea2.js';

const bsTextareaFieldCss = "bs-textarea-field{display:block;width:100%}";

const BsTextareaField$1 = /*@__PURE__*/ proxyCustomElement(class BsTextareaField extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    /** Native attributes to pass through to the input element. */
    this.attrs = {};
    this.charMax = undefined;
    this.disabled = false;
    this.error = undefined;
    this.errorMsg = undefined;
    this.hint = undefined;
    this.hints = undefined;
    this.inputId = undefined;
    this.label = undefined;
    this.placeholder = undefined;
    this.required = undefined;
    this.rows = 6;
    this.value = '';
    this.passAttrs = '';
    this.hintId = null;
  }
  get charCount() {
    var _a;
    return ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) || 0;
  }
  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',
      'cols',
      '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-textarea", 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, rows: this.rows, value: this.value }, this.attrs)), (this.hintMsg || this.charMax) && (h("bs-field-details", { "char-count": this.charCount, "char-max": this.charMax, error: this.error, "error-msg": this.errorMsg, hint: this.hint || this.hintDeprecated, "hint-id": this.hintId }))));
  }
  get hostEl() { return this; }
  static get style() { return bsTextareaFieldCss; }
}, [0, "bs-textarea-field", {
    "charMax": [2, "char-max"],
    "disabled": [4],
    "error": [4],
    "errorMsg": [1, "error-msg"],
    "hint": [1],
    "hints": [1],
    "inputId": [1, "input-id"],
    "label": [1],
    "placeholder": [1],
    "required": [4],
    "rows": [2],
    "value": [1],
    "passAttrs": [1, "pass-attrs"],
    "hintId": [32]
  }]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["bs-textarea-field", "bs-field-details", "bs-label", "bs-textarea"];
  components.forEach(tagName => { switch (tagName) {
    case "bs-textarea-field":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, BsTextareaField$1);
      }
      break;
    case "bs-field-details":
      if (!customElements.get(tagName)) {
        defineCustomElement$4();
      }
      break;
    case "bs-label":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "bs-textarea":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
  } });
}

const BsTextareaField = BsTextareaField$1;
const defineCustomElement = defineCustomElement$1;

export { BsTextareaField, defineCustomElement };

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