import { BaseRecord, CredoError, utils } from "@credo-ts/core";

//#region ../didcomm/src/modules/proofs/repository/DidCommProofExchangeRecord.ts
var DidCommProofExchangeRecord = class DidCommProofExchangeRecord extends BaseRecord {
	constructor(props) {
		super();
		this.type = DidCommProofExchangeRecord.type;
		if (props) {
			this.id = props.id ?? utils.uuid();
			this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
			this.protocolVersion = props.protocolVersion;
			this.isVerified = props.isVerified;
			this.state = props.state;
			this.role = props.role;
			this.connectionId = props.connectionId;
			this.threadId = props.threadId;
			this.parentThreadId = props.parentThreadId;
			this.autoAcceptProof = props.autoAcceptProof;
			this._tags = props.tags ?? {};
			this.errorMessage = props.errorMessage;
		}
	}
	getTags() {
		return {
			...this._tags,
			threadId: this.threadId,
			parentThreadId: this.parentThreadId,
			connectionId: this.connectionId,
			state: this.state,
			role: this.role
		};
	}
	assertState(expectedStates) {
		if (!Array.isArray(expectedStates)) expectedStates = [expectedStates];
		if (!expectedStates.includes(this.state)) throw new CredoError(`Proof record is in invalid state ${this.state}. Valid states are: ${expectedStates.join(", ")}.`);
	}
	assertProtocolVersion(version) {
		if (this.protocolVersion !== version) throw new CredoError(`Proof record has invalid protocol version ${this.protocolVersion}. Expected version ${version}`);
	}
	assertConnection(currentConnectionId) {
		if (!this.connectionId) throw new CredoError("Proof record is not associated with any connection. This is often the case with connection-less presentation exchange");
		if (this.connectionId !== currentConnectionId) throw new CredoError(`Proof record is associated with connection '${this.connectionId}'. Current connection is '${currentConnectionId}'`);
	}
};
DidCommProofExchangeRecord.type = "ProofRecord";

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