import { Build, Component, Element, Host, Prop, State, h } from '@stencil/core';
/** @slot default text slot for badge text */
export class Badge {
  constructor() {
    /** Sets badge color options. */
    this.palette = 'basic';
    /** Sets height and padding of badge. */
    this.size = 'base';
    /** Sets badge width to auto fit content or full. */
    this.width = 'auto';
    //--------------------------------------------------------------------------
    //
    //  Private Methods
    //
    //--------------------------------------------------------------------------
    this.setHasContent = () => {
      this.hasContent = this.host.textContent.trim().length > 0 || this.host.childNodes.length > 0;
    };
    //--------------------------------------------------------------------------
    //
    //  Private State
    //
    //--------------------------------------------------------------------------
    /** determine if slotted content present for styling purposes */
    this.hasContent = false;
  }
  //--------------------------------------------------------------------------
  //
  //  Lifecycle Methods
  //
  //--------------------------------------------------------------------------
  componentWillLoad() {
    if (Build.isBrowser) {
      this.setHasContent();
    }
  }
  connectedCallback() {
    if (Build.isBrowser) {
      this.textObserver = new MutationObserver(() => {
        this.setHasContent();
      });
      this.textObserver.observe(this.host, { childList: true, subtree: true });
    }
  }
  disconnectedCallback() {
    this.textObserver.disconnect();
  }
  render() {
    const { hasContent, iconEnd, iconStart } = this;
    return (h(Host, null,
      iconStart && h("abds-icon", { icon: iconStart, size: "sm", "stroke-width": "semibold" }),
      hasContent && (h("div", { class: "text-wrapper" },
        h("slot", null))),
      iconEnd && h("abds-icon", { icon: iconEnd, size: "sm", "stroke-width": "semibold" })));
  }
  static get is() { return "abds-badge"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["badge.css"]
  }; }
  static get styleUrls() { return {
    "$": ["badge.css"]
  }; }
  static get properties() { return {
    "iconEnd": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Adds an abds-icon to end of badge text."
      },
      "attribute": "icon-end",
      "reflect": true
    },
    "iconStart": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Adds an abds-icon to beginning of badge text."
      },
      "attribute": "icon-start",
      "reflect": true
    },
    "palette": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "BadgePalette",
        "resolved": "\"basic\" | \"dark\" | \"error\" | \"light\" | \"success\" | \"warning\"",
        "references": {
          "BadgePalette": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Sets badge color options."
      },
      "attribute": "palette",
      "reflect": true,
      "defaultValue": "'basic'"
    },
    "size": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "BadgeSize",
        "resolved": "\"base\" | \"sm\"",
        "references": {
          "BadgeSize": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Sets height and padding of badge."
      },
      "attribute": "size",
      "reflect": true,
      "defaultValue": "'base'"
    },
    "width": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "Width",
        "resolved": "\"auto\" | \"full\"",
        "references": {
          "Width": {
            "location": "import",
            "path": "../types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Sets badge width to auto fit content or full."
      },
      "attribute": "width",
      "reflect": true,
      "defaultValue": "'auto'"
    }
  }; }
  static get states() { return {
    "hasContent": {}
  }; }
  static get elementRef() { return "host"; }
}
//# sourceMappingURL=badge.js.map