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 { DidCommOutboundMessageContext } from "../../models/DidCommOutboundMessageContext.mjs";
import "../../models/index.mjs";
import { DidCommConnectionService } from "../connections/services/DidCommConnectionService.mjs";
import { DidCommMessageSender } from "../../DidCommMessageSender.mjs";
import "../connections/index.mjs";
import { DidCommMediatorModuleConfig } from "./DidCommMediatorModuleConfig.mjs";
import { DidCommMediatorService } from "./services/DidCommMediatorService.mjs";
import { AgentContext, injectable } from "@credo-ts/core";

//#region ../didcomm/src/modules/routing/DidCommMediatorApi.ts
var _ref, _ref2, _ref3, _ref4, _ref5;
let DidCommMediatorApi = class DidCommMediatorApi$1 {
	constructor(mediationService, messageSender, agentContext, connectionService, config) {
		this.mediatorService = mediationService;
		this.messageSender = messageSender;
		this.connectionService = connectionService;
		this.agentContext = agentContext;
		this.config = config;
	}
	async grantRequestedMediation(mediationRecordId) {
		const record = await this.mediatorService.getById(this.agentContext, mediationRecordId);
		const connectionRecord = await this.connectionService.getById(this.agentContext, record.connectionId);
		const { message, mediationRecord } = await this.mediatorService.createGrantMediationMessage(this.agentContext, record);
		const outboundMessageContext = new DidCommOutboundMessageContext(message, {
			agentContext: this.agentContext,
			connection: connectionRecord,
			associatedRecord: mediationRecord
		});
		await this.messageSender.sendMessage(outboundMessageContext);
		return mediationRecord;
	}
};
DidCommMediatorApi = __decorate([injectable(), __decorateMetadata("design:paramtypes", [
	typeof (_ref = typeof DidCommMediatorService !== "undefined" && DidCommMediatorService) === "function" ? _ref : Object,
	typeof (_ref2 = typeof DidCommMessageSender !== "undefined" && DidCommMessageSender) === "function" ? _ref2 : Object,
	typeof (_ref3 = typeof AgentContext !== "undefined" && AgentContext) === "function" ? _ref3 : Object,
	typeof (_ref4 = typeof DidCommConnectionService !== "undefined" && DidCommConnectionService) === "function" ? _ref4 : Object,
	typeof (_ref5 = typeof DidCommMediatorModuleConfig !== "undefined" && DidCommMediatorModuleConfig) === "function" ? _ref5 : Object
])], DidCommMediatorApi);

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