const require_rolldown_runtime = require('../../../../../../../../_virtual/rolldown_runtime.js');
const require_index = require('../../../../../../../../node_modules/.pnpm/class-transformer@0.5.1/node_modules/class-transformer/cjs/index.js');
const require_index$1 = require('../../../../../../../../node_modules/.pnpm/class-validator@0.14.1/node_modules/class-validator/cjs/index.js');
const require_decorateMetadata = require('../../../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.js');
const require_decorate = require('../../../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js');
const require_messageType = require('../../../../../util/messageType.js');
const require_DidCommCredentialPreviewAttribute = require('../../../models/DidCommCredentialPreviewAttribute.js');
let __credo_ts_core = require("@credo-ts/core");
__credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);

//#region ../didcomm/src/modules/credentials/protocol/v2/messages/DidCommCredentialV2Preview.ts
var import_cjs = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_index.require_cjs());
var import_cjs$1 = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_index$1.require_cjs());
/**
* Credential preview inner message class.
*
* This is not a message but an inner object for other messages in this protocol. It is used construct a preview of the data for the credential.
*
* @see https://github.com/hyperledger/aries-rfcs/tree/main/features/0453-issue-credential-v2#preview-credential
*/
var DidCommCredentialV2Preview = class DidCommCredentialV2Preview {
	constructor(options) {
		this.type = DidCommCredentialV2Preview.type.messageTypeUri;
		if (options) this.attributes = options.attributes.map((a) => new require_DidCommCredentialPreviewAttribute.DidCommCredentialPreviewAttribute(a));
	}
	toJSON() {
		return __credo_ts_core.JsonTransformer.toJSON(this);
	}
	/**
	* Create a credential preview from a record with name and value entries.
	*
	* @example
	* const preview = CredentialPreview.fromRecord({
	*   name: "Bob",
	*   age: "20"
	* })
	*/
	static fromRecord(record) {
		return new DidCommCredentialV2Preview({ attributes: Object.entries(record).map(([name, value]) => new require_DidCommCredentialPreviewAttribute.DidCommCredentialPreviewAttribute({
			name,
			mimeType: "text/plain",
			value
		})) });
	}
};
DidCommCredentialV2Preview.type = require_messageType.parseMessageType("https://didcomm.org/issue-credential/2.0/credential-preview");
require_decorate.__decorate([
	(0, import_cjs.Expose)({ name: "@type" }),
	require_messageType.IsValidMessageType(DidCommCredentialV2Preview.type),
	(0, import_cjs.Transform)(({ value }) => require_messageType.replaceLegacyDidSovPrefix(value), { toClassOnly: true }),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], DidCommCredentialV2Preview.prototype, "type", void 0);
require_decorate.__decorate([
	(0, import_cjs.Type)(() => require_DidCommCredentialPreviewAttribute.DidCommCredentialPreviewAttribute),
	(0, import_cjs$1.ValidateNested)({ each: true }),
	(0, import_cjs$1.IsInstance)(require_DidCommCredentialPreviewAttribute.DidCommCredentialPreviewAttribute, { each: true }),
	require_decorateMetadata.__decorateMetadata("design:type", Array)
], DidCommCredentialV2Preview.prototype, "attributes", void 0);

//#endregion
exports.DidCommCredentialV2Preview = DidCommCredentialV2Preview;