import { __decorateMetadata } from "../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.mjs";
import { __decorate } from "../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.mjs";
import { DidCommModuleConfig } from "../../../DidCommModuleConfig.mjs";
import { DidCommRoutingEventTypes } from "../DidCommRoutingEvents.mjs";
import { DidCommMediationRecipientService } from "./DidCommMediationRecipientService.mjs";
import { EventEmitter, Kms, injectable } from "@credo-ts/core";

//#region ../didcomm/src/modules/routing/services/DidCommRoutingService.ts
var _ref, _ref2;
let DidCommRoutingService = class DidCommRoutingService$1 {
	constructor(mediationRecipientService, eventEmitter) {
		this.mediationRecipientService = mediationRecipientService;
		this.eventEmitter = eventEmitter;
	}
	async getRouting(agentContext, { mediatorId, useDefaultMediator = true } = {}) {
		const kms = agentContext.resolve(Kms.KeyManagementApi);
		const didcommConfig = agentContext.resolve(DidCommModuleConfig);
		const recipientKey = await kms.createKey({ type: {
			kty: "OKP",
			crv: "Ed25519"
		} });
		let routing = {
			endpoints: didcommConfig.endpoints,
			routingKeys: [],
			recipientKey: Kms.PublicJwk.fromPublicJwk(recipientKey.publicJwk)
		};
		routing = await this.mediationRecipientService.addMediationRouting(agentContext, routing, {
			mediatorId,
			useDefaultMediator
		});
		this.eventEmitter.emit(agentContext, {
			type: DidCommRoutingEventTypes.RoutingCreatedEvent,
			payload: { routing }
		});
		return routing;
	}
	async removeRouting(agentContext, options) {
		await this.mediationRecipientService.removeMediationRouting(agentContext, options);
	}
};
DidCommRoutingService = __decorate([injectable(), __decorateMetadata("design:paramtypes", [typeof (_ref = typeof DidCommMediationRecipientService !== "undefined" && DidCommMediationRecipientService) === "function" ? _ref : Object, typeof (_ref2 = typeof EventEmitter !== "undefined" && EventEmitter) === "function" ? _ref2 : Object])], DidCommRoutingService);

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