

const require_CredoError = require('../../../../error/CredoError.js');
require('../../../../error/index.js');
const require_PublicJwk = require('../../../kms/jwk/PublicJwk.js');
require('../../../kms/index.js');
const require_JsonWebKey2020 = require('../verificationMethod/JsonWebKey2020.js');
const require_Multikey = require('../verificationMethod/Multikey.js');
require('../verificationMethod/index.js');
const require_ed25519 = require('./ed25519.js');
const require_keyDidJsonWebKey = require('./keyDidJsonWebKey.js');
const require_secp256k1 = require('./secp256k1.js');
const require_x25519 = require('./x25519.js');

//#region src/modules/dids/domain/key-type/keyDidMapping.ts
const supportedKeyDids = [
	require_ed25519.keyDidEd25519,
	require_x25519.keyDidX25519,
	require_keyDidJsonWebKey.keyDidJsonWebKey,
	require_secp256k1.keyDidSecp256k1
];
function getVerificationMethodsForPublicJwk(publicJwk, did) {
	const { getVerificationMethods } = getKeyDidMappingByPublicJwk(publicJwk);
	return getVerificationMethods(did, publicJwk);
}
function getSupportedVerificationMethodTypesForPublicJwk(publicJwk) {
	const { supportedVerificationMethodTypes } = getKeyDidMappingByPublicJwk(publicJwk);
	return supportedVerificationMethodTypes;
}
function getPublicJwkFromVerificationMethod(verificationMethod) {
	if (require_JsonWebKey2020.isJsonWebKey2020(verificationMethod)) return require_JsonWebKey2020.getPublicJwkFromJsonWebKey2020(verificationMethod);
	if (require_Multikey.isMultikey(verificationMethod)) return require_Multikey.getPublicJwkFromMultikey(verificationMethod);
	const keyDid = supportedKeyDids.find((keyDid$1) => keyDid$1.supportedVerificationMethodTypes.includes(verificationMethod.type));
	if (!keyDid) throw new require_CredoError.CredoError(`Unsupported key did from verification method type '${verificationMethod.type}'`);
	return keyDid.getPublicJwkFromVerificationMethod(verificationMethod);
}
function getKeyDidMappingByPublicJwk(jwk) {
	const jwkTypeClass = jwk instanceof require_PublicJwk.PublicJwk ? jwk.JwkClass : jwk;
	const keyDid = supportedKeyDids.find((supportedKeyDid) => supportedKeyDid.PublicJwkTypes.includes(jwkTypeClass));
	if (!keyDid) throw new require_CredoError.CredoError(`Unsupported did mapping for jwk '${jwk instanceof require_PublicJwk.PublicJwk ? jwk.jwkTypehumanDescription : jwk.name}'`);
	return keyDid;
}

//#endregion
exports.getPublicJwkFromVerificationMethod = getPublicJwkFromVerificationMethod;
exports.getSupportedVerificationMethodTypesForPublicJwk = getSupportedVerificationMethodTypesForPublicJwk;
exports.getVerificationMethodsForPublicJwk = getVerificationMethodsForPublicJwk;