var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component, Host, h, Element, Prop, Event } from '@stencil/core';
import { sanitizeVegaComponent } from '../../utils/component';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer } from 'vega-slimmer/core';
import { createEventEmitSlimmer, } from '../../helpers/event-manager/slimmers/event-emit-slimmer';
import { VegaClick, VegaLabelButtonClick } from '../../helpers/event-manager/event-id/vega-event-id';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../helpers/slimmers/component-usage-runtime-metrics';
import { VegaFieldLabelSuffixElementRenderer } from './slimmers/renderers/vega-field-label-suffix-element-renderer';
/**
 * @vegaVersion 1.10.0
 */
/**
 * This is an internal used component and shouldn't be used by clients,
 *    it doesn't show up in storybook either.
 */
export class VegaFieldLabel {
  constructor() {
    this.globalSlimmers = {};
    this.clickEventEmitter = createEventEmitSlimmer(VegaFieldLabel, VegaClick);
    this.suffixButtonClickEventEmitter = createEventEmitSlimmer(VegaFieldLabel, VegaLabelButtonClick);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.suffixElementRenderer = new VegaFieldLabelSuffixElementRenderer();
    /**
     * @deprecated Please use `suffixButtonConfig` instead
     *
     * Specifies the properties for the suffix button associated with the input.
     *
     * It provides essential information and functionality related to
     *    the suffix button's role and behavior.
     *
     * @vegaVersion 2.25.0
     */
    this.suffixButtonProps = null;
    /**
     * Specifies the properties for the suffix button associated with the input.
     *
     * It provides essential information and functionality related to
     *    the suffix button's role and behavior.
     *
     * @vegaVersion 2.68.0
     */
    this.suffixButtonConfig = null;
    /**
     * Specifies the label or title for the field.
     *
     * It provides descriptive text that helps identify the
     *    purpose or content expected in the field.
     *
     * @vegaVersion 1.10.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.label = '';
    /**
     * Determines whether the input field is required.
     *
     * Specifies whether the field must be filled in to pass form validation.
     *
     * @vegaVersion 1.10.0
     */
    this.isFieldRequired = false;
    /**
     * Specifies whether the field is disabled.
     *
     * @vegaVersion 1.10.0
     */
    this.disabled = false;
    /*
     * The below method is e2e-test covered in
     * @see{module:vega-field-label-vegaClick-event}
     */
    /* istanbul ignore next */
    this.handleClick = (e) => {
      this.clickEventEmitter.emit(undefined, e);
    };
  }
  componentWillLoad() {
    if (this.label === '') {
      this.label = this.host.textContent;
      this.host.textContent = '';
    }
  }
  render() {
    return sanitizeVegaComponent(h(Host, { class: {
        hidden: this.label === '',
        disabled: this.disabled,
      }, onClick: this.handleClick },
      h("label", null,
        h("span", { class: "vega-field-label" }, this.label),
        h("span", { class: {
            'vega-field-label-required': true,
            'hidden': !this.isFieldRequired,
          } }, "*")),
      this.suffixElementRenderer.render()), this.host);
  }
  static get is() { return "vega-field-label"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-field-label.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-field-label.css"]
  }; }
  static get properties() { return {
    "suffixButtonProps": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "LabelSuffixButtonProps",
        "resolved": "{ icon: string; tooltipText?: string; trigger?: \"click\" | \"hover\"; }",
        "references": {
          "LabelSuffixButtonProps": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "deprecated",
            "text": "Please use `suffixButtonConfig` instead\n\nSpecifies the properties for the suffix button associated with the input.\n\nIt provides essential information and functionality related to\nthe suffix button's role and behavior."
          }, {
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": ""
      },
      "defaultValue": "null"
    },
    "suffixButtonConfig": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Nullable<LabelSuffixButtonConfig>",
        "resolved": "{ icon: string; } & Partial<Pick<HTMLVegaTooltipElement, \"size\" | \"trigger\" | \"minWidth\" | \"maxWidth\" | \"text\" | \"placement\" | \"alignment\">>",
        "references": {
          "Nullable": {
            "location": "import",
            "path": "../../types/general"
          },
          "LabelSuffixButtonConfig": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.68.0"
          }],
        "text": "Specifies the properties for the suffix button associated with the input.\n\nIt provides essential information and functionality related to\n   the suffix button's role and behavior."
      },
      "defaultValue": "null"
    },
    "label": {
      "type": "string",
      "mutable": true,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.10.0"
          }],
        "text": "Specifies the label or title for the field.\n\nIt provides descriptive text that helps identify the\n   purpose or content expected in the field."
      },
      "attribute": "label",
      "reflect": false,
      "defaultValue": "''"
    },
    "isFieldRequired": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.10.0"
          }],
        "text": "Determines whether the input field is required.\n\nSpecifies whether the field must be filled in to pass form validation."
      },
      "attribute": "is-field-required",
      "reflect": false,
      "defaultValue": "false"
    },
    "disabled": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.10.0"
          }],
        "text": "Specifies whether the field is disabled."
      },
      "attribute": "disabled",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
  static get events() { return [{
      "method": "vegaClick",
      "name": "vegaClick",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "1.43.0"
          }],
        "text": "An event emitter notifying that the field label has been clicked."
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "vegaLabelButtonClick",
      "name": "vegaLabelButtonClick",
      "bubbles": false,
      "cancelable": true,
      "composed": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying that the suffix button associated with the field label has been clicked."
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "labelButtonClick",
      "name": "labelButtonClick",
      "bubbles": false,
      "cancelable": true,
      "composed": false,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.25.0"
          }],
        "text": "An event emitter notifying that the suffix button associated with the field label has been clicked."
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
  static get elementRef() { return "host"; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaFieldLabel.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFieldLabel.prototype, "clickEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFieldLabel.prototype, "suffixButtonClickEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFieldLabel.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFieldLabel.prototype, "suffixElementRenderer", void 0);
