//#region rolldown:runtime
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
	if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
		key = keys[i];
		if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
			get: ((k) => from[k]).bind(null, key),
			enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
		});
	}
	return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
	value: mod,
	enumerable: true
}) : target, mod));

//#endregion
let node_crypto = require("node:crypto");
node_crypto = __toESM(node_crypto);

//#region src/index.ts
const algorithms = [
	"md5",
	"sha1",
	"sha256",
	"sha512"
];
const encodings = ["base64", "hex"];
const hashFunctions = algorithms.map((algorithm) => ({
	name: `hash.${algorithm}`,
	description: "Hash a value to its hexadecimal representation",
	args: [{
		type: "text",
		name: "input",
		label: "Input",
		placeholder: "input text",
		multiLine: true
	}, {
		type: "select",
		name: "encoding",
		label: "Encoding",
		defaultValue: "base64",
		options: encodings.map((encoding) => ({
			label: capitalize(encoding),
			value: encoding
		}))
	}],
	async onRender(_ctx, args) {
		const input = String(args.values.input);
		const encoding = String(args.values.encoding);
		return (0, node_crypto.createHash)(algorithm).update(input, "utf-8").digest(encoding);
	}
}));
const hmacFunctions = algorithms.map((algorithm) => ({
	name: `hmac.${algorithm}`,
	description: "Compute the HMAC of a value",
	args: [
		{
			type: "text",
			name: "input",
			label: "Input",
			placeholder: "input text",
			multiLine: true
		},
		{
			type: "text",
			name: "key",
			label: "Key",
			password: true
		},
		{
			type: "select",
			name: "encoding",
			label: "Encoding",
			defaultValue: "base64",
			options: encodings.map((encoding) => ({
				value: encoding,
				label: capitalize(encoding)
			}))
		}
	],
	async onRender(_ctx, args) {
		const input = String(args.values.input);
		const key = String(args.values.key);
		const encoding = String(args.values.encoding);
		return (0, node_crypto.createHmac)(algorithm, key, {}).update(input).digest(encoding);
	}
}));
const plugin = { templateFunctions: [...hashFunctions, ...hmacFunctions] };
function capitalize(str) {
	return str.charAt(0).toUpperCase() + str.slice(1);
}

//#endregion
exports.plugin = plugin;