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, VegaSlimmer } from 'vega-slimmer/core';
/** The `VegaEventEmitHandlerSlimmer` class is a TypeScript class that handles the emission of Vega events based on the availability of the 'emit' function and the event semantics namespace. */
export class VegaEventEmitHandlerSlimmer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    /**
     * The function determines whether a Vega event should be emitted based on the namespace and the availability of the 'emit' function.
     *
     * @param {EventSemantics} namespace the event semantics namespace
     * @returns {boolean} a boolean value.
     */
    this.canHandle = ({ namespace }) => {
      return namespace === 'vega' || !this.nativeEvent || typeof this.nativeEvent['emit'] !== 'function';
    };
    /**
     * The function emits a Vega event with a given detail.
     *
     * @param {unknown} detail - The "detail" parameter is a generic type parameter that represents the data or
     * information that you want to emit with the event. It can be any type of data, such as a string,
     * number, object, or custom class.
     * @returns {CustomEvent} The emitted event.
     */
    this.handle = (detail) => {
      return this.vegaEvent.emit(detail);
    };
  }
}
__decorate([
  MapToComponentField()
], VegaEventEmitHandlerSlimmer.prototype, "vegaEvent", void 0);
__decorate([
  MapToComponentField()
], VegaEventEmitHandlerSlimmer.prototype, "nativeEvent", void 0);
