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 { DidCommOutOfBandInvitation } from "../messages/DidCommOutOfBandInvitation.mjs";
import "../messages/index.mjs";
import { getThreadIdFromPlainTextMessage } from "../../../util/thread.mjs";
import { BaseRecord, CredoError, utils } from "@credo-ts/core";
import { Type } from "class-transformer";

//#region ../didcomm/src/modules/oob/repository/DidCommOutOfBandRecord.ts
var _ref;
var DidCommOutOfBandRecord = class DidCommOutOfBandRecord extends BaseRecord {
	constructor(props) {
		super();
		this.type = DidCommOutOfBandRecord.type;
		if (props) {
			this.id = props.id ?? utils.uuid();
			this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
			this.outOfBandInvitation = props.outOfBandInvitation;
			this.role = props.role;
			this.state = props.state;
			this.alias = props.alias;
			this.autoAcceptConnection = props.autoAcceptConnection;
			this.reusable = props.reusable ?? false;
			this.mediatorId = props.mediatorId;
			this.reuseConnectionId = props.reuseConnectionId;
			this.invitationInlineServiceKeys = props.invitationInlineServiceKeys;
			this._tags = props.tags ?? { recipientKeyFingerprints: [] };
		}
	}
	getTags() {
		return {
			...this._tags,
			role: this.role,
			state: this.state,
			invitationId: this.outOfBandInvitation.id,
			threadId: this.outOfBandInvitation.threadId,
			invitationRequestsThreadIds: this.outOfBandInvitation.getRequests()?.map((r) => getThreadIdFromPlainTextMessage(r))
		};
	}
	assertRole(expectedRole) {
		if (this.role !== expectedRole) throw new CredoError(`Invalid out-of-band record role ${this.role}, expected is ${expectedRole}.`);
	}
	assertState(expectedStates) {
		if (!Array.isArray(expectedStates)) expectedStates = [expectedStates];
		if (!expectedStates.includes(this.state)) throw new CredoError(`Invalid out-of-band record state ${this.state}, valid states are: ${expectedStates.join(", ")}.`);
	}
};
DidCommOutOfBandRecord.type = "OutOfBandRecord";
__decorate([Type(() => DidCommOutOfBandInvitation), __decorateMetadata("design:type", typeof (_ref = typeof DidCommOutOfBandInvitation !== "undefined" && DidCommOutOfBandInvitation) === "function" ? _ref : Object)], DidCommOutOfBandRecord.prototype, "outOfBandInvitation", void 0);

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