

import { InjectionSymbols } from "../constants.mjs";
import { inject, injectable } from "../plugins/index.mjs";
import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorateMetadata.mjs";
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.mjs";
import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorateParam.mjs";
import { Subject, fromEventPattern } from "rxjs";
import { takeUntil } from "rxjs/operators";

//#region src/agent/EventEmitter.ts
var _ref;
let EventEmitter = class EventEmitter$1 {
	constructor(agentDependencies, stop$) {
		this.eventEmitter = new agentDependencies.EventEmitterClass();
		this.stop$ = stop$;
	}
	emit(agentContext, data) {
		this.eventEmitter.emit(data.type, {
			...data,
			metadata: { contextCorrelationId: agentContext.contextCorrelationId }
		});
	}
	on(event, listener) {
		this.eventEmitter.on(event, listener);
	}
	off(event, listener) {
		this.eventEmitter.off(event, listener);
	}
	observable(event) {
		return fromEventPattern((handler) => this.on(event, handler), (handler) => this.off(event, handler)).pipe(takeUntil(this.stop$));
	}
};
EventEmitter = __decorate([
	injectable(),
	__decorateParam(0, inject(InjectionSymbols.AgentDependencies)),
	__decorateParam(1, inject(InjectionSymbols.Stop$)),
	__decorateMetadata("design:paramtypes", [Object, typeof (_ref = typeof Subject !== "undefined" && Subject) === "function" ? _ref : Object])
], EventEmitter);

//#endregion
export { EventEmitter };
//# sourceMappingURL=EventEmitter.mjs.map