import { __decorateMetadata } from "../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.mjs";
import { __decorate } from "../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.mjs";
import { CredoError, JsonTransformer } from "@credo-ts/core";
import { Expose } from "class-transformer";
import { IsString } from "class-validator";

//#region ../didcomm/src/models/features/DidCommFeature.ts
var DidCommFeature = class DidCommFeature {
	constructor(props) {
		if (props) {
			this.id = props.id;
			this.type = props.type;
		}
	}
	/**
	* Combine this feature with another one, provided both are from the same type
	* and have the same id
	*
	* @param feature object to combine with this one
	* @returns a new object resulting from the combination between this and feature
	*/
	combine(feature) {
		if (feature.id !== this.id) throw new CredoError("Can only combine with a feature with the same id");
		const obj1 = JsonTransformer.toJSON(this);
		const obj2 = JsonTransformer.toJSON(feature);
		for (const key in obj2) try {
			if (Array.isArray(obj2[key])) obj1[key] = [...new Set([...obj1[key], ...obj2[key]])];
			else obj1[key] = obj2[key];
		} catch (_e) {
			obj1[key] = obj2[key];
		}
		return JsonTransformer.fromJSON(obj1, DidCommFeature);
	}
	toJSON() {
		return JsonTransformer.toJSON(this);
	}
};
__decorate([
	IsString(),
	Expose({ name: "feature-type" }),
	__decorateMetadata("design:type", String)
], DidCommFeature.prototype, "type", void 0);

//#endregion
export { DidCommFeature };
//# sourceMappingURL=DidCommFeature.mjs.map