

import { __decorateMetadata } from "../../../../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorateMetadata.mjs";
import { __decorate } from "../../../../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.mjs";
import { IsUri, isUri } from "../../../../utils/validators.mjs";
import "../../../../utils/index.mjs";
import { Transform, TransformationType, instanceToPlain, plainToClassFromExist, plainToInstance } from "class-transformer";
import { ValidateBy, buildMessage, isInstance, isString } from "class-validator";

//#region src/modules/vc/models/presentation/W3cV2Holder.ts
/**
* Represents a credential holder.
*
* @see https://www.w3.org/TR/vc-data-model-2.0/#holder
*/
var W3cV2Holder = class {
	constructor(options) {
		if (options) {
			const { id,...rest } = options;
			plainToClassFromExist(this, rest);
			this.id = id;
		}
	}
};
__decorate([IsUri(), __decorateMetadata("design:type", String)], W3cV2Holder.prototype, "id", void 0);
function W3cV2HolderTransformer() {
	return Transform(({ value, type }) => {
		if (type === TransformationType.PLAIN_TO_CLASS) {
			if (isString(value)) return value;
			return plainToInstance(W3cV2Holder, value);
		}
		if (type === TransformationType.CLASS_TO_PLAIN) {
			if (isString(value)) return value;
			return instanceToPlain(value);
		}
		return value;
	});
}
function IsW3cV2Holder(validationOptions) {
	return ValidateBy({
		name: "IsW3cV2Holder",
		validator: {
			validate: (value) => {
				return typeof value === "string" && isUri(value) || isInstance(value, W3cV2Holder) && isUri(value.id);
			},
			defaultMessage: buildMessage((eachPrefix) => `${eachPrefix}$property must be an URL or a valid W3cV2Holder instance`, validationOptions)
		}
	}, validationOptions);
}

//#endregion
export { IsW3cV2Holder, W3cV2Holder, W3cV2HolderTransformer };
//# sourceMappingURL=W3cV2Holder.mjs.map