import { getFileHeader } from './chunk-EYM3ANAG.js';
import { __name } from './chunk-6AXVLTU5.js';

// src/prepare/runtime/runtime/node/event.ts
function writeEvent(_context) {
  return `${getFileHeader()}

import type { IStormEvent } from "@storm-stack/types/node/event";
import { StormRequest } from "./request";
import { useStorm } from "./context";

/**
 * A base event class used by the Storm Stack runtime.
 */
export class StormEvent<TEventType extends string = string, TEventData = any>
  extends StormRequest<TEventData> implements IStormEvent<TEventType, TEventData> {
  /**
   * The request identifier.
   */
  public readonly requestId: string = useStorm().request.id;

  /**
   * The event type.
   */
  public readonly type: TEventType;

  /**
   * The event version.
   */
  public readonly version: string = "1.0";

  /**
   * The event label.
   *
   * @remarks
   * The label format is "{type}-v{version}"
   */
  public get label(): string {
    return \`\${this.type}-v\${this.version}\`;
  }

  /**
   * Creates a new event.
   *
   * @param type - The event type.
   * @param data - The event data.
   */
  public constructor(
    type: TEventType,
    data: TEventData
  ) {
    super(data);
    this.type = type;
  }
}`;
}
__name(writeEvent, "writeEvent");

export { writeEvent };
//# sourceMappingURL=chunk-KZHNONBH.js.map
//# sourceMappingURL=chunk-KZHNONBH.js.map