const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.js');
let __credo_ts_core = require("@credo-ts/core");
__credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);

//#region ../didcomm/src/util/attachment.ts
/**
* Encodes an attachment based on the `data` property
*
* @param attachment The attachment that needs to be encoded
* @param hashAlgorithm The hashing algorithm that is going to be used
* @param baseName The base encoding name that is going to be used
* @returns A hashlink based on the attachment data
*/
function encodeAttachment(attachment, hashAlgorithm = "sha-256", baseName = "base58btc") {
	if (attachment.data.sha256) return `hl:${attachment.data.sha256}`;
	if (attachment.data.base64) return __credo_ts_core.HashlinkEncoder.encode(__credo_ts_core.TypedArrayEncoder.fromBase64(attachment.data.base64), hashAlgorithm, baseName);
	if (attachment.data.json) throw new __credo_ts_core.CredoError(`Attachment: (${attachment.id}) has json encoded data. This is currently not supported`);
	throw new __credo_ts_core.CredoError(`Attachment: (${attachment.id}) has no data to create a link with`);
}

//#endregion
exports.encodeAttachment = encodeAttachment;