

const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.js');
const require_Hasher = require('../../../crypto/hashes/Hasher.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');
require('../../../crypto/index.js');
const require_decodeSdJwtVc = require('../decodeSdJwtVc.js');
let __sd_jwt_decode = require("@sd-jwt/decode");
__sd_jwt_decode = require_rolldown_runtime.__toESM(__sd_jwt_decode);

//#region src/modules/sd-jwt-vc/repository/SdJwtVcRecord.ts
var SdJwtVcRecord = class SdJwtVcRecord extends require_BaseRecord.BaseRecord {
	constructor(props) {
		super();
		this.type = SdJwtVcRecord.type;
		if (props) {
			this.id = props.id ?? require_uuid.uuid();
			this.createdAt = props.createdAt ?? /* @__PURE__ */ new Date();
			this.compactSdJwtVc = props.compactSdJwtVc;
			this.typeMetadata = props.typeMetadata;
			this._tags = props.tags ?? {};
		}
	}
	get sdJwtVc() {
		return require_decodeSdJwtVc.decodeSdJwtVc(this.compactSdJwtVc, this.typeMetadata);
	}
	getTags() {
		const sdjwt = (0, __sd_jwt_decode.decodeSdJwtSync)(this.compactSdJwtVc, require_Hasher.Hasher.hash);
		const vct = sdjwt.jwt.payload.vct;
		const sdAlg = sdjwt.jwt.payload._sd_alg;
		const alg = sdjwt.jwt.header.alg;
		return {
			...this._tags,
			vct,
			sdAlg: sdAlg ?? "sha-256",
			alg
		};
	}
	clone() {
		return require_JsonTransformer.JsonTransformer.fromJSON(require_JsonTransformer.JsonTransformer.toJSON(this), this.constructor);
	}
	/**
	* credential is convenience method added to all credential records
	*/
	get credential() {
		return require_decodeSdJwtVc.decodeSdJwtVc(this.compactSdJwtVc, this.typeMetadata);
	}
	/**
	* encoded is convenience method added to all credential records
	*/
	get encoded() {
		return this.compactSdJwtVc;
	}
};
SdJwtVcRecord.type = "SdJwtVcRecord";

//#endregion
exports.SdJwtVcRecord = SdJwtVcRecord;