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 { FORM_ELEMENT_VALUE_CHANGE } from '../../../../../helpers/change-manager/subject/static-subject/static-subject-title';
import changeManager from '../../../../../helpers/change-manager/change-manager';
/**
 * Controller for managing the value state of the color swatch picker.
 */
export class ColorSwatchPickerValueController extends VegaSlimmer {
  /**
   * Update the value of the color swatch picker.
   *
   * @param {string} newValue - The new color value to set.
   */
  updateValue(newValue) {
    this.value = newValue;
  }
  /**
   * Update the internal color state of the color swatch picker.
   *
   * @param {string} newValue - The new internal color value to set.
   */
  updateInternalColor(newValue) {
    this.internalColor = newValue;
  }
  /**
   * Initializes the `internalColor` state with the initial value of the `value` prop when the component loads.
   */
  initializeInternalColor() {
    this.internalColor = this.value;
  }
  /**
   * Listens to changes in the `value` prop and updates the `internalColor` state accordingly.
   */
  listenToValueChange() {
    this.internalColor = this.value;
    this.changeEventEmitter.emit(this.value);
    changeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
}
__decorate([
  MapToComponentField()
], ColorSwatchPickerValueController.prototype, "host", void 0);
__decorate([
  MapToComponentField({ writable: true })
], ColorSwatchPickerValueController.prototype, "value", void 0);
__decorate([
  MapToComponentField({ writable: true })
], ColorSwatchPickerValueController.prototype, "internalColor", void 0);
__decorate([
  MapToComponentField()
], ColorSwatchPickerValueController.prototype, "changeEventEmitter", void 0);
__decorate([
  MapToComponentMethod('componentWillLoad')
], ColorSwatchPickerValueController.prototype, "initializeInternalColor", null);
__decorate([
  MapToComponentMethod('watchValue')
], ColorSwatchPickerValueController.prototype, "listenToValueChange", null);
