import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { v as v4, b as getHostAttrsWithId } from './index2.js';
import { d as defineCustomElement$6 } from './bs-character-count2.js';
import { d as defineCustomElement$5 } from './bs-field-layout2.js';
import { d as defineCustomElement$4 } from './bs-hint2.js';
import { d as defineCustomElement$3 } from './bs-label2.js';
import { d as defineCustomElement$2 } from './bs-select2.js';

const bsSelectFieldCss = "bs-select-field{display:block;width:100%}bs-label+bs-select select{margin-top:0.25rem}:where(.box) bs-select :where(input,textarea,select):focus{--offset-color:var(--bs-bg-subtle)}:where(.box[data-invert]) bs-select :where(input,textarea,select):focus{--offset-color:var(--bs-bg-invert)}";

const BsSelectField$1 = /*@__PURE__*/ proxyCustomElement(class BsSelectField extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    /** Native attributes to pass through to the select element. */
    this.attrs = {};
    this.disabled = false;
    this.error = undefined;
    this.required = undefined;
    this.label = undefined;
    this.hints = undefined;
    this.placeholder = '';
    this.value = undefined;
    this.passAttrs = '';
    this.data = [];
    this.hintId = null;
  }
  componentWillLoad() {
    this.hintId = this.hints ? v4() : null;
    this.attrs = getHostAttrsWithId(this.hostEl, [
      'autocomplete',
      'max',
      'min',
      'maxlength',
      'minlength',
      'name',
      'placeholder',
      ...this.passAttrs.split(',')
    ]);
  }
  get validValue() {
    return this.value;
  }
  render() {
    return (h(Host, null, h("bs-field-layout", { disabled: this.disabled, error: this.error, hints: this.hints, label: this.label, "label-for": this.attrs.id, required: this.required, hintId: this.hintId }, h("bs-select", Object.assign({ disabled: this.disabled, error: this.error, required: this.required, value: this.validValue, hintId: this.hintId }, this.attrs), h("option", { selected: !this.validValue, disabled: false }, this.placeholder), this.data.map(option => (h("option", { value: option.value, selected: this.validValue === option.value, disabled: option.disabled }, option.label)))))));
  }
  get hostEl() { return this; }
  static get style() { return bsSelectFieldCss; }
}, [0, "bs-select-field", {
    "disabled": [4],
    "error": [4],
    "required": [4],
    "label": [1],
    "hints": [1],
    "placeholder": [1],
    "value": [8],
    "passAttrs": [1, "pass-attrs"],
    "data": [16],
    "hintId": [32]
  }]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["bs-select-field", "bs-character-count", "bs-field-layout", "bs-hint", "bs-label", "bs-select"];
  components.forEach(tagName => { switch (tagName) {
    case "bs-select-field":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, BsSelectField$1);
      }
      break;
    case "bs-character-count":
      if (!customElements.get(tagName)) {
        defineCustomElement$6();
      }
      break;
    case "bs-field-layout":
      if (!customElements.get(tagName)) {
        defineCustomElement$5();
      }
      break;
    case "bs-hint":
      if (!customElements.get(tagName)) {
        defineCustomElement$4();
      }
      break;
    case "bs-label":
      if (!customElements.get(tagName)) {
        defineCustomElement$3();
      }
      break;
    case "bs-select":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
  } });
}

const BsSelectField = BsSelectField$1;
const defineCustomElement = defineCustomElement$1;

export { BsSelectField, defineCustomElement };

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