

const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.js');
const require_JsonTransformer = require('../../../../utils/JsonTransformer.js');
require('../../../../utils/index.js');
const require_DidDocumentService = require('./DidDocumentService.js');
const require_DidCommV1Service = require('./DidCommV1Service.js');
const require_DidCommV2Service = require('./DidCommV2Service.js');
const require_IndyAgentService = require('./IndyAgentService.js');
const require_LegacyDidCommV2Service = require('./LegacyDidCommV2Service.js');
let class_transformer = require("class-transformer");
class_transformer = require_rolldown_runtime.__toESM(class_transformer);

//#region src/modules/dids/domain/service/ServiceTransformer.ts
const serviceTypes = {
	[require_IndyAgentService.IndyAgentService.type]: require_IndyAgentService.IndyAgentService,
	[require_DidCommV1Service.DidCommV1Service.type]: require_DidCommV1Service.DidCommV1Service,
	[require_DidCommV2Service.DidCommV2Service.type]: require_DidCommV2Service.DidCommV2Service,
	[require_LegacyDidCommV2Service.LegacyDidCommV2Service.type]: require_LegacyDidCommV2Service.LegacyDidCommV2Service
};
/**
* Decorator that transforms service json to corresponding class instances. See {@link serviceTypes}
*
* @example
* class Example {
*   ServiceTransformer()
*   private service: Service
* }
*/
function ServiceTransformer() {
	return (0, class_transformer.Transform)(({ value }) => {
		return value?.map((serviceJson) => {
			let serviceClass = serviceTypes[serviceJson.type] ?? require_DidDocumentService.DidDocumentService;
			if (serviceJson.type === require_DidCommV2Service.DidCommV2Service.type && "serviceEndpoint" in serviceJson && typeof serviceJson.serviceEndpoint === "string") serviceClass = require_LegacyDidCommV2Service.LegacyDidCommV2Service;
			return require_JsonTransformer.JsonTransformer.fromJSON(serviceJson, serviceClass);
		});
	}, { toClassOnly: true });
}

//#endregion
exports.ServiceTransformer = ServiceTransformer;
exports.serviceTypes = serviceTypes;