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 { MapToComponentField, MapToComponentMethod, VegaSlimmer } from 'vega-slimmer/core';
import changeManager from '../../../../helpers/change-manager/change-manager';
import { FIELD_ERROR_MESSAGE_CHANGE } from '../../../../helpers/change-manager/subject/static-subject/static-subject-title';
/** The `VegaFieldErrorMessageController` class is a TypeScript class that extends `VegaSlimmer` and is responsible for handling error messages for a field in a Vega component. */
export 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([
  MapToComponentField()
], VegaFieldErrorMessageController.prototype, "host", void 0);
__decorate([
  MapToComponentField()
], VegaFieldErrorMessageController.prototype, "message", void 0);
__decorate([
  MapToComponentMethod('watchMessage')
], VegaFieldErrorMessageController.prototype, "handleMessageChange", null);
__decorate([
  MapToComponentMethod('componentDidLoad')
], VegaFieldErrorMessageController.prototype, "handleComponentDidLoad", null);
