const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.js');
const require_index = require('../../../../../../node_modules/.pnpm/class-validator@0.14.1/node_modules/class-validator/cjs/index.js');
const require_decorateMetadata = require('../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.js');
const require_decorate = require('../../../../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js');
let __credo_ts_core = require("@credo-ts/core");
__credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);

//#region ../didcomm/src/modules/oob/domain/OutOfBandDidCommService.ts
var import_cjs = /* @__PURE__ */ require_rolldown_runtime.__toESM(require_index.require_cjs());
var OutOfBandDidCommService = class OutOfBandDidCommService extends __credo_ts_core.DidDocumentService {
	constructor(options) {
		super({
			...options,
			type: OutOfBandDidCommService.type
		});
		if (options) {
			this.recipientKeys = options.recipientKeys;
			this.routingKeys = options.routingKeys;
			this.accept = options.accept;
		}
	}
	get resolvedDidCommService() {
		return {
			id: this.id,
			recipientKeys: this.recipientKeys.map((didKey) => {
				const publicJwk = __credo_ts_core.DidKey.fromDid(didKey).publicJwk;
				if (!publicJwk.is(__credo_ts_core.Kms.Ed25519PublicJwk)) throw new __credo_ts_core.CredoError("Expected recipient key for didcomm service to be of type Ed25519");
				return publicJwk;
			}),
			routingKeys: this.routingKeys?.map((didKey) => {
				const publicJwk = __credo_ts_core.DidKey.fromDid(didKey).publicJwk;
				if (!publicJwk.is(__credo_ts_core.Kms.Ed25519PublicJwk)) throw new __credo_ts_core.CredoError("Expected recipient key for didcomm service to be of type Ed25519");
				return publicJwk;
			}) ?? [],
			serviceEndpoint: this.serviceEndpoint
		};
	}
	static fromResolvedDidCommService(service) {
		return new OutOfBandDidCommService({
			id: service.id,
			recipientKeys: service.recipientKeys.map((key) => new __credo_ts_core.DidKey(key).did),
			routingKeys: service.routingKeys.map((key) => new __credo_ts_core.DidKey(key).did),
			serviceEndpoint: service.serviceEndpoint
		});
	}
};
OutOfBandDidCommService.type = "did-communication";
require_decorate.__decorate([
	(0, import_cjs.IsString)(),
	(0, __credo_ts_core.IsUri)(),
	require_decorateMetadata.__decorateMetadata("design:type", String)
], OutOfBandDidCommService.prototype, "serviceEndpoint", void 0);
require_decorate.__decorate([
	(0, import_cjs.ArrayNotEmpty)(),
	IsDidKeyString({ each: true }),
	require_decorateMetadata.__decorateMetadata("design:type", Array)
], OutOfBandDidCommService.prototype, "recipientKeys", void 0);
require_decorate.__decorate([
	IsDidKeyString({ each: true }),
	(0, import_cjs.IsOptional)(),
	require_decorateMetadata.__decorateMetadata("design:type", Array)
], OutOfBandDidCommService.prototype, "routingKeys", void 0);
require_decorate.__decorate([
	(0, import_cjs.IsString)({ each: true }),
	(0, import_cjs.IsOptional)(),
	require_decorateMetadata.__decorateMetadata("design:type", Array)
], OutOfBandDidCommService.prototype, "accept", void 0);
/**
* Checks if a given value is a did:key did string
*/
function IsDidKeyString(validationOptions) {
	return (0, import_cjs.ValidateBy)({
		name: "isDidKeyString",
		validator: {
			validate: (value) => (0, import_cjs.isString)(value) && (0, __credo_ts_core.isDid)(value, "key"),
			defaultMessage: (0, import_cjs.buildMessage)((eachPrefix) => `${eachPrefix}$property must be a did:key string`, validationOptions)
		}
	}, validationOptions);
}

//#endregion
exports.OutOfBandDidCommService = OutOfBandDidCommService;