import { r as registerInstance, h, H as Host, g as getElement } from './index-090d31ca.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { c as MapToComponentField, M as MapToComponentMethod, 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 ChangeManager } from './change-manager-6a7eb88c.js';
import { d as FIELD_ERROR_MESSAGE_CHANGE } from './static-subject-title-52f93124.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;
};
/** The `VegaFieldErrorMessageController` class is a TypeScript class that extends `VegaSlimmer` and is responsible for handling error messages for a field in a Vega component. */
class VegaFieldErrorMessageController extends VegaSlimmer {
  /**
   * call the method when the component prop message change
   */
  handleMessageChange() {
    this.notifyMessageUpdate();
  }
  /**
   * call the method when componentDidLoad
   */
  handleComponentDidLoad() {
    this.notifyMessageUpdate();
  }
  /**
   * The function `notifyMessageUpdate` notifies the change manager about a field error message change, providing the host and message as parameters.
   */
  notifyMessageUpdate() {
    ChangeManager.notify(FIELD_ERROR_MESSAGE_CHANGE, {
      host: this.host,
      message: this.message,
      isValid: !this.message,
    });
  }
}
__decorate$1([
  MapToComponentField()
], VegaFieldErrorMessageController.prototype, "host", void 0);
__decorate$1([
  MapToComponentField()
], VegaFieldErrorMessageController.prototype, "message", void 0);
__decorate$1([
  MapToComponentMethod('watchMessage')
], VegaFieldErrorMessageController.prototype, "handleMessageChange", null);
__decorate$1([
  MapToComponentMethod('componentDidLoad')
], VegaFieldErrorMessageController.prototype, "handleComponentDidLoad", null);

const vegaFieldErrorCss = ":host{display:block}";

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 VegaFieldError = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.globalSlimmers = {};
    this.messageController = new VegaFieldErrorMessageController();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Specifies the error message when the input field should display an error.
     *    The input field will clear the error status when the message is empty.
     *
     * @vegaVersion 1.45.0
     */
    this.message = '';
  }
  watchMessage() {
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, h("slot", null)), this.host);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "message": ["watchMessage"]
  }; }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaFieldError.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFieldError.prototype, "messageController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaFieldError.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaFieldError.style = vegaFieldErrorCss;

export { VegaFieldError as vega_field_error };
