

const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.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_JsonTransformer = require('../../../../utils/JsonTransformer.js');
const require_array = require('../../../../utils/array.js');
const require_validators = require('../../../../utils/validators.js');
require('../../../../utils/index.js');
const require_constants = require('../../constants.js');
const require_validators$1 = require('../../validators.js');
const require_W3cCredentialSchema = require('./W3cCredentialSchema.js');
const require_W3cCredentialStatus = require('./W3cCredentialStatus.js');
const require_W3cCredentialSubject = require('./W3cCredentialSubject.js');
const require_W3cIssuer = require('./W3cIssuer.js');
let class_transformer = require("class-transformer");
class_transformer = require_rolldown_runtime.__toESM(class_transformer);
let class_validator = require("class-validator");
class_validator = require_rolldown_runtime.__toESM(class_validator);

//#region src/modules/vc/models/credential/W3cCredential.ts
var _ref, _ref2, _ref3;
var W3cCredential = class W3cCredential {
	constructor(options) {
		if (options) {
			this.context = options.context ?? [require_constants.CREDENTIALS_CONTEXT_V1_URL];
			this.id = options.id;
			this.type = options.type || ["VerifiableCredential"];
			this.issuer = typeof options.issuer === "string" || options.issuer instanceof require_W3cIssuer.W3cIssuer ? options.issuer : new require_W3cIssuer.W3cIssuer(options.issuer);
			this.issuanceDate = options.issuanceDate;
			this.expirationDate = options.expirationDate;
			this.credentialSubject = require_array.mapSingleOrArray(options.credentialSubject, (subject) => subject instanceof require_W3cCredentialSubject.W3cCredentialSubject ? subject : new require_W3cCredentialSubject.W3cCredentialSubject(subject));
			if (options.credentialStatus) this.credentialStatus = options.credentialStatus instanceof require_W3cCredentialStatus.W3cCredentialStatus ? options.credentialStatus : new require_W3cCredentialStatus.W3cCredentialStatus(options.credentialStatus);
			if (options.credentialSchema) this.credentialSchema = require_array.mapSingleOrArray(options.credentialSchema, (schema) => schema instanceof require_W3cCredentialSchema.W3cCredentialSchema ? schema : new require_W3cCredentialSchema.W3cCredentialSchema(schema));
		}
	}
	get issuerId() {
		return this.issuer instanceof require_W3cIssuer.W3cIssuer ? this.issuer.id : this.issuer;
	}
	get credentialSchemaIds() {
		if (!this.credentialSchema) return [];
		if (Array.isArray(this.credentialSchema)) return this.credentialSchema.map((credentialSchema) => credentialSchema.id);
		return [this.credentialSchema.id];
	}
	get credentialSubjectIds() {
		if (Array.isArray(this.credentialSubject)) return this.credentialSubject.map((credentialSubject) => credentialSubject.id).filter((v) => v !== void 0);
		return this.credentialSubject.id ? [this.credentialSubject.id] : [];
	}
	get contexts() {
		return require_array.asArray(this.context);
	}
	static fromJson(json) {
		return require_JsonTransformer.JsonTransformer.fromJSON(json, W3cCredential);
	}
};
require_decorate.__decorate([
	(0, class_transformer.Expose)({ name: "@context" }),
	require_validators$1.IsCredentialJsonLdContext(),
	require_decorateMetadata.__decorateMetadata("design:type", typeof (_ref = typeof Array !== "undefined" && Array) === "function" ? _ref : Object)
], W3cCredential.prototype, "context", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	require_validators.IsUri(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], W3cCredential.prototype, "id", void 0);
require_decorate.__decorate([require_validators$1.IsCredentialType(), require_decorateMetadata.__decorateMetadata("design:type", typeof (_ref2 = typeof Array !== "undefined" && Array) === "function" ? _ref2 : Object)], W3cCredential.prototype, "type", void 0);
require_decorate.__decorate([
	require_W3cIssuer.W3cIssuerTransformer(),
	require_W3cIssuer.IsW3cIssuer(),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cCredential.prototype, "issuer", void 0);
require_decorate.__decorate([(0, class_validator.IsRFC3339)(), require_decorateMetadata.__decorateMetadata("design:type", String)], W3cCredential.prototype, "issuanceDate", void 0);
require_decorate.__decorate([
	(0, class_validator.IsRFC3339)(),
	(0, class_validator.IsOptional)(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], W3cCredential.prototype, "expirationDate", void 0);
require_decorate.__decorate([
	require_W3cCredentialSubject.IsW3cCredentialSubject({ each: true }),
	require_W3cCredentialSubject.W3cCredentialSubjectTransformer(),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cCredential.prototype, "credentialSubject", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	(0, class_transformer.Type)(() => require_W3cCredentialSchema.W3cCredentialSchema),
	(0, class_validator.ValidateNested)({ each: true }),
	require_validators.IsInstanceOrArrayOfInstances({
		classType: require_W3cCredentialSchema.W3cCredentialSchema,
		allowEmptyArray: true
	}),
	require_decorateMetadata.__decorateMetadata("design:type", Object)
], W3cCredential.prototype, "credentialSchema", void 0);
require_decorate.__decorate([
	(0, class_validator.IsOptional)(),
	(0, class_transformer.Type)(() => require_W3cCredentialStatus.W3cCredentialStatus),
	(0, class_validator.ValidateNested)({ each: true }),
	(0, class_validator.IsInstance)(require_W3cCredentialStatus.W3cCredentialStatus),
	require_decorateMetadata.__decorateMetadata("design:type", typeof (_ref3 = typeof require_W3cCredentialStatus.W3cCredentialStatus !== "undefined" && require_W3cCredentialStatus.W3cCredentialStatus) === "function" ? _ref3 : Object)
], W3cCredential.prototype, "credentialStatus", void 0);

//#endregion
exports.W3cCredential = W3cCredential;