

const require_decorateMetadata = require('../../../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorateMetadata.js');
const require_decorate = require('../../../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.js');
const require_array = require('../../../utils/array.js');
const require_JsonTransformer = require('../../../utils/JsonTransformer.js');
require('../../../utils/index.js');
const require_BaseRecord = require('../../../storage/BaseRecord.js');
const require_uuid = require('../../../utils/uuid.js');
const require_ClaimFormat = require('../models/ClaimFormat.js');
const require_W3cV2EnvelopedVerifiableCredential = require('../models/credential/W3cV2EnvelopedVerifiableCredential.js');
const require_W3cV2VerifiableCredential = require('../models/credential/W3cV2VerifiableCredential.js');
require('../models/index.js');

//#region src/modules/vc/repository/W3cV2CredentialRecord.ts
var W3cV2CredentialRecord = class W3cV2CredentialRecord extends require_BaseRecord.BaseRecord {
	constructor(props) {
		super();
		this.type = W3cV2CredentialRecord.type;
		if (props) {
			this.id = props.id ?? require_uuid.uuid();
			this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
			this.credential = props.credential;
		}
	}
	getTags() {
		const resolvedCredential = this.credential.resolvedCredential;
		const stringContexts = resolvedCredential.contexts.filter((ctx) => typeof ctx === "string");
		const tags = {
			...this._tags,
			issuerId: resolvedCredential.issuerId,
			subjectIds: resolvedCredential.credentialSubjectIds,
			schemaIds: resolvedCredential.credentialSchemaIds,
			contexts: stringContexts,
			givenId: resolvedCredential.id,
			claimFormat: this.credential.claimFormat,
			types: require_array.asArray(resolvedCredential.type)
		};
		if (this.credential instanceof require_W3cV2EnvelopedVerifiableCredential.W3cV2EnvelopedVerifiableCredential) {
			const enveloped = this.credential.envelopedCredential;
			if (enveloped.claimFormat === require_ClaimFormat.ClaimFormat.JwtW3cVc) tags.algs = [enveloped.jwt.header.alg];
			else if (enveloped.claimFormat === require_ClaimFormat.ClaimFormat.SdJwtW3cVc) tags.algs = [enveloped.sdJwt.header.alg];
		}
		return tags;
	}
	/**
	* This overwrites the default `clone` method for records, as the W3cV3CredentialRecord
	* has issues with the default clone method due to the way the JWT and SD-JWT
	* records are implemented. This is a temporary way to make sure the clone still works, but ideally
	* we find an alternative.
	*/
	clone() {
		return require_JsonTransformer.JsonTransformer.fromJSON(require_JsonTransformer.JsonTransformer.toJSON(this), this.constructor);
	}
	/**
	* encoded is convenience method added to all credential records
	*/
	get encoded() {
		return this.credential.encoded;
	}
};
W3cV2CredentialRecord.type = "W3cV2CredentialRecord";
require_decorate.__decorate([require_W3cV2VerifiableCredential.W3cV2VerifiableCredentialTransformer(), require_decorateMetadata.__decorateMetadata("design:type", Object)], W3cV2CredentialRecord.prototype, "credential", void 0);

//#endregion
exports.W3cV2CredentialRecord = W3cV2CredentialRecord;