

const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
const require_base58 = require('./base58.js');
const require_base64 = require('./base64.js');
let buffer = require("buffer");
buffer = require_rolldown_runtime.__toESM(buffer);

//#region src/utils/TypedArrayEncoder.ts
var TypedArrayEncoder = class TypedArrayEncoder {
	/**
	* Encode buffer into base64 string.
	*
	* @param buffer the buffer to encode into base64 string
	*/
	static toBase64(buffer$1) {
		return buffer.Buffer.from(buffer$1).toString("base64");
	}
	/**
	* Encode buffer into base64url string.
	*
	* @param buffer the buffer to encode into base64url string
	*/
	static toBase64URL(buffer$1) {
		return require_base64.base64ToBase64URL(TypedArrayEncoder.toBase64(buffer$1));
	}
	/**
	* Encode buffer into base58 string.
	*
	* @param buffer the buffer to encode into base58 string
	*/
	static toBase58(buffer$1) {
		return require_base58.encodeToBase58(buffer$1);
	}
	/**
	* Decode base64 string into buffer. Also supports base64url
	*
	* @param base64 the base64 or base64url string to decode into buffer format
	*/
	static fromBase64(base64) {
		return buffer.Buffer.from(base64, "base64");
	}
	/**
	* Decode base58 string into buffer
	*
	* @param base58 the base58 string to decode into buffer format
	*/
	static fromBase58(base58) {
		return buffer.Buffer.from(require_base58.decodeFromBase58(base58));
	}
	/**
	* Encode buffer into base64 string.
	*
	* @param buffer the buffer to encode into base64 string
	*/
	static toHex(buffer$1) {
		return buffer.Buffer.from(buffer$1).toString("hex");
	}
	/**
	* Decode hex string into buffer
	*
	* @param hex the hex string to decode into buffer format
	*/
	static fromHex(hex) {
		return buffer.Buffer.from(hex, "hex");
	}
	/**
	* Decode string into buffer.
	*
	* @param str the string to decode into buffer format
	*/
	static fromString(str) {
		return buffer.Buffer.from(str);
	}
	static toUtf8String(buffer$1) {
		return buffer.Buffer.from(buffer$1).toString();
	}
	static concat(entries) {
		return buffer.Buffer.concat(entries);
	}
	static equals(firstBuffer, otherBuffer) {
		return buffer.Buffer.from(firstBuffer).equals(otherBuffer);
	}
	/**
	* Check whether an array is byte, or typed, array
	*
	* @param array unknown The array that has to be checked
	*
	* @returns A boolean if the array is a byte array
	*/
	static isTypedArray(array) {
		return "BYTES_PER_ELEMENT" in array;
	}
};

//#endregion
exports.TypedArrayEncoder = TypedArrayEncoder;