

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

//#region src/modules/vc/models/credential/W3cIssuer.ts
var W3cIssuer = class {
	constructor(options) {
		if (options) this.id = options.id;
	}
};
__decorate([IsUri(), __decorateMetadata("design:type", String)], W3cIssuer.prototype, "id", void 0);
function W3cIssuerTransformer() {
	return Transform(({ value, type }) => {
		if (type === TransformationType.PLAIN_TO_CLASS) {
			if (isString(value)) return value;
			return plainToInstance(W3cIssuer, value);
		}
		if (type === TransformationType.CLASS_TO_PLAIN) {
			if (isString(value)) return value;
			return instanceToPlain(value);
		}
		return value;
	});
}
function IsW3cIssuer(validationOptions) {
	return ValidateBy({
		name: "IsW3cIssuer",
		validator: {
			validate: (value) => {
				if (typeof value === "string") return isUri(value);
				if (isInstance(value, W3cIssuer)) return isUri(value.id);
				return false;
			},
			defaultMessage: buildMessage((eachPrefix) => `${eachPrefix}$property must be an URI or an object with an id property which is an URI`, validationOptions)
		}
	}, validationOptions);
}

//#endregion
export { IsW3cIssuer, W3cIssuer, W3cIssuerTransformer };
//# sourceMappingURL=W3cIssuer.mjs.map