import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-090d31ca.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { c as MapToComponentField, V as VegaSlimmer, I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-697ad0b7.js';
import { a as VegaClick, y as VegaLabelButtonClick } from './vega-event-id-578c6c6d.js';
import { c as createEnterKeyHandlerToTriggerClick } from './accessibility-6af5cf2e.js';
import './dynamic-slimmer-90b8af32.js';
import './change-manager-6a7eb88c.js';
import './dom-node-subject-observer-factory-3897e95b.js';
import './observer-3959f9dd.js';
import './ui-64815a12.js';
import './internal-vega-event-manager-1ac5ee9a.js';
import './try-get-document-bef0f526.js';

var __decorate$1 = (undefined && undefined.__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;
};
/** Render the suffix button in a field label component. */
class VegaFieldLabelSuffixElementRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    /**
     * Stop click event propagation and emit an event.
     *
     * @param {MouseEvent} e click event object
     */
    this.handleSuffixButtonClick = (e) => {
      e.stopPropagation();
      this.suffixButtonClickEventEmitter.emit();
    };
  }
  /**
   * Render a suffix button if the property is not empty.
   *
   * @returns {Nullable<HTMLElement>}
   */
  render() {
    if (this.suffixButtonConfig || this.suffixButtonProps) {
      const { icon, text, size, minWidth, maxWidth, placement = 'right', alignment = 'start', trigger = 'hover', } = this.suffixButtonConfig ||
        (this.suffixButtonProps && {
          icon: this.suffixButtonProps.icon,
          text: this.suffixButtonProps.tooltipText,
          trigger: this.suffixButtonProps.trigger,
        });
      return (h("div", { class: "label-suffix-button", role: "button", tabIndex: 0, onClick: this.handleSuffixButtonClick, onKeyDown: createEnterKeyHandlerToTriggerClick() }, text ? (h("vega-tooltip", { trigger: trigger, text: text, size: size, minWidth: minWidth, maxWidth: maxWidth, alignment: alignment, placement: placement }, this.renderSuffixButton(icon))) : (this.renderSuffixButton(icon))));
    }
  }
  /**
   * Render a vega button circle component.
   *
   * @param {string} icon the button icon name
   * @returns {HTMLVegaButtonCircleElement} vega button circle component
   */
  renderSuffixButton(icon) {
    return (h("vega-button-circle", { size: "extra-small", variant: "icon-only", iconColor: "text-link", showTooltip: false, icon: icon }));
  }
}
__decorate$1([
  MapToComponentField()
], VegaFieldLabelSuffixElementRenderer.prototype, "suffixButtonProps", void 0);
__decorate$1([
  MapToComponentField()
], VegaFieldLabelSuffixElementRenderer.prototype, "suffixButtonConfig", void 0);
__decorate$1([
  MapToComponentField()
], VegaFieldLabelSuffixElementRenderer.prototype, "suffixButtonClickEventEmitter", void 0);

const vegaFieldLabelCss = ":host{display:inline-block}:host(.disabled){pointer-events:none}:host(.hidden){display:none}label:first-of-type{color:rgba(var(--v-text-primary, 32, 54, 69, 1));font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;word-break:break-word}@media screen and (min-width: 768px) and (max-width: 1023px){label:first-of-type{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){label:first-of-type{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){label:first-of-type{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host(.disabled)>label>span.vega-field-label{color:rgba(var(--v-text-secondary, 107, 116, 125, 1))}.vega-field-label-required{color:rgba(var(--v-text-error, 189, 41, 71, 1));margin-left:4px}.vega-field-label-required.hidden{display:none}.label-suffix-button{display:inline-block;margin-left:4px;vertical-align:top}";

var __decorate = (undefined && undefined.__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;
};
const VegaFieldLabel = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaClick = createEvent(this, "vegaClick", 7);
    this.vegaLabelButtonClick = createEvent(this, "vegaLabelButtonClick", 1);
    this.labelButtonClick = createEvent(this, "labelButtonClick", 1);
    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);
  }
  get host() { return getElement(this); }
};
__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);
VegaFieldLabel.style = vegaFieldLabelCss;

export { VegaFieldLabel as vega_field_label };
