

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 { Expose, Transform, TransformationType, instanceToPlain, plainToClassFromExist, plainToInstance } from "class-transformer";
import { IsEnum, IsOptional, IsString, isString } from "class-validator";

//#region src/modules/vc/models/credential/W3cV2LocalizedValue.ts
/**
* Represents a localized string.
*
* @see https://www.w3.org/TR/vc-data-model-2.0/#internationalization-considerations
*/
var W3cV2LocalizedValue = class {
	constructor(options) {
		if (options) {
			const { value, language, direction, ...rest } = options;
			plainToClassFromExist(this, rest);
			this.value = value;
			this.language = language;
			this.direction = direction;
		}
	}
};
__decorate([
	Expose({ name: "@value" }),
	IsString(),
	__decorateMetadata("design:type", String)
], W3cV2LocalizedValue.prototype, "value", void 0);
__decorate([
	Expose({ name: "@language" }),
	IsOptional(),
	IsString(),
	__decorateMetadata("design:type", Object)
], W3cV2LocalizedValue.prototype, "language", void 0);
__decorate([
	Expose({ name: "@direction" }),
	IsOptional(),
	IsEnum([
		"ltr",
		"rtl",
		null
	]),
	__decorateMetadata("design:type", Object)
], W3cV2LocalizedValue.prototype, "direction", void 0);
function W3cV2LocalizedValueTransformer() {
	return Transform(({ value, type }) => {
		if (type === TransformationType.PLAIN_TO_CLASS) {
			if (isString(value)) return value;
			if (Array.isArray(value)) return value.map((v) => plainToInstance(W3cV2LocalizedValue, v));
			return plainToInstance(W3cV2LocalizedValue, value);
		}
		if (type === TransformationType.CLASS_TO_PLAIN) {
			if (isString(value)) return value;
			if (Array.isArray(value)) return value.map((v) => instanceToPlain(W3cV2LocalizedValue, v));
			return instanceToPlain(value);
		}
		return value;
	});
}

//#endregion
export { W3cV2LocalizedValue, W3cV2LocalizedValueTransformer };
//# sourceMappingURL=W3cV2LocalizedValue.mjs.map