//#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 node_modules/uuid/dist-node/regex.js
var regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;

//#endregion
//#region node_modules/uuid/dist-node/validate.js
function validate(uuid) {
	return typeof uuid === "string" && regex_default.test(uuid);
}
var validate_default = validate;

//#endregion
//#region node_modules/uuid/dist-node/parse.js
function parse(uuid) {
	if (!validate_default(uuid)) throw TypeError("Invalid UUID");
	let v;
	return Uint8Array.of((v = parseInt(uuid.slice(0, 8), 16)) >>> 24, v >>> 16 & 255, v >>> 8 & 255, v & 255, (v = parseInt(uuid.slice(9, 13), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(14, 18), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(19, 23), 16)) >>> 8, v & 255, (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255, v / 4294967296 & 255, v >>> 24 & 255, v >>> 16 & 255, v >>> 8 & 255, v & 255);
}
var parse_default = parse;

//#endregion
//#region node_modules/uuid/dist-node/stringify.js
const byteToHex = [];
for (let i = 0; i < 256; ++i) byteToHex.push((i + 256).toString(16).slice(1));
function unsafeStringify(arr, offset = 0) {
	return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
}

//#endregion
//#region node_modules/uuid/dist-node/rng.js
const rnds8 = new Uint8Array(16);
function rng() {
	return crypto.getRandomValues(rnds8);
}

//#endregion
//#region node_modules/uuid/dist-node/v1.js
const _state$1 = {};
function v1(options, buf, offset) {
	let bytes;
	const isV6 = options?._v6 ?? false;
	if (options) {
		const optionsKeys = Object.keys(options);
		if (optionsKeys.length === 1 && optionsKeys[0] === "_v6") options = void 0;
	}
	if (options) bytes = v1Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.nsecs, options.clockseq, options.node, buf, offset);
	else {
		const now = Date.now();
		const rnds = rng();
		updateV1State(_state$1, now, rnds);
		bytes = v1Bytes(rnds, _state$1.msecs, _state$1.nsecs, isV6 ? void 0 : _state$1.clockseq, isV6 ? void 0 : _state$1.node, buf, offset);
	}
	return buf ?? unsafeStringify(bytes);
}
function updateV1State(state, now, rnds) {
	state.msecs ??= -Infinity;
	state.nsecs ??= 0;
	if (now === state.msecs) {
		state.nsecs++;
		if (state.nsecs >= 1e4) {
			state.node = void 0;
			state.nsecs = 0;
		}
	} else if (now > state.msecs) state.nsecs = 0;
	else if (now < state.msecs) state.node = void 0;
	if (!state.node) {
		state.node = rnds.slice(10, 16);
		state.node[0] |= 1;
		state.clockseq = (rnds[8] << 8 | rnds[9]) & 16383;
	}
	state.msecs = now;
	return state;
}
function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
	if (rnds.length < 16) throw new Error("Random bytes length must be >= 16");
	if (!buf) {
		buf = new Uint8Array(16);
		offset = 0;
	} else if (offset < 0 || offset + 16 > buf.length) throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
	msecs ??= Date.now();
	nsecs ??= 0;
	clockseq ??= (rnds[8] << 8 | rnds[9]) & 16383;
	node ??= rnds.slice(10, 16);
	msecs += 0xb1d069b5400;
	const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
	buf[offset++] = tl >>> 24 & 255;
	buf[offset++] = tl >>> 16 & 255;
	buf[offset++] = tl >>> 8 & 255;
	buf[offset++] = tl & 255;
	const tmh = msecs / 4294967296 * 1e4 & 268435455;
	buf[offset++] = tmh >>> 8 & 255;
	buf[offset++] = tmh & 255;
	buf[offset++] = tmh >>> 24 & 15 | 16;
	buf[offset++] = tmh >>> 16 & 255;
	buf[offset++] = clockseq >>> 8 | 128;
	buf[offset++] = clockseq & 255;
	for (let n = 0; n < 6; ++n) buf[offset++] = node[n];
	return buf;
}
var v1_default = v1;

//#endregion
//#region node_modules/uuid/dist-node/v1ToV6.js
function v1ToV6(uuid) {
	const v6Bytes = _v1ToV6(typeof uuid === "string" ? parse_default(uuid) : uuid);
	return typeof uuid === "string" ? unsafeStringify(v6Bytes) : v6Bytes;
}
function _v1ToV6(v1Bytes$1) {
	return Uint8Array.of((v1Bytes$1[6] & 15) << 4 | v1Bytes$1[7] >> 4 & 15, (v1Bytes$1[7] & 15) << 4 | (v1Bytes$1[4] & 240) >> 4, (v1Bytes$1[4] & 15) << 4 | (v1Bytes$1[5] & 240) >> 4, (v1Bytes$1[5] & 15) << 4 | (v1Bytes$1[0] & 240) >> 4, (v1Bytes$1[0] & 15) << 4 | (v1Bytes$1[1] & 240) >> 4, (v1Bytes$1[1] & 15) << 4 | (v1Bytes$1[2] & 240) >> 4, 96 | v1Bytes$1[2] & 15, v1Bytes$1[3], v1Bytes$1[8], v1Bytes$1[9], v1Bytes$1[10], v1Bytes$1[11], v1Bytes$1[12], v1Bytes$1[13], v1Bytes$1[14], v1Bytes$1[15]);
}

//#endregion
//#region node_modules/uuid/dist-node/md5.js
function md5(bytes) {
	if (Array.isArray(bytes)) bytes = Buffer.from(bytes);
	else if (typeof bytes === "string") bytes = Buffer.from(bytes, "utf8");
	return (0, node_crypto.createHash)("md5").update(bytes).digest();
}
var md5_default = md5;

//#endregion
//#region node_modules/uuid/dist-node/v35.js
function stringToBytes(str) {
	str = unescape(encodeURIComponent(str));
	const bytes = new Uint8Array(str.length);
	for (let i = 0; i < str.length; ++i) bytes[i] = str.charCodeAt(i);
	return bytes;
}
const DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
const URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
function v35(version, hash, value, namespace, buf, offset) {
	const valueBytes = typeof value === "string" ? stringToBytes(value) : value;
	const namespaceBytes = typeof namespace === "string" ? parse_default(namespace) : namespace;
	if (typeof namespace === "string") namespace = parse_default(namespace);
	if (namespace?.length !== 16) throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
	let bytes = new Uint8Array(16 + valueBytes.length);
	bytes.set(namespaceBytes);
	bytes.set(valueBytes, namespaceBytes.length);
	bytes = hash(bytes);
	bytes[6] = bytes[6] & 15 | version;
	bytes[8] = bytes[8] & 63 | 128;
	if (buf) {
		offset ??= 0;
		if (offset < 0 || offset + 16 > buf.length) throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
		for (let i = 0; i < 16; ++i) buf[offset + i] = bytes[i];
		return buf;
	}
	return unsafeStringify(bytes);
}

//#endregion
//#region node_modules/uuid/dist-node/v3.js
function v3(value, namespace, buf, offset) {
	return v35(48, md5_default, value, namespace, buf, offset);
}
v3.DNS = DNS;
v3.URL = URL;
var v3_default = v3;

//#endregion
//#region node_modules/uuid/dist-node/v4.js
function v4(options, buf, offset) {
	if (!buf && !options && crypto.randomUUID) return crypto.randomUUID();
	return _v4(options, buf, offset);
}
function _v4(options, buf, offset) {
	options = options || {};
	const rnds = options.random ?? options.rng?.() ?? rng();
	if (rnds.length < 16) throw new Error("Random bytes length must be >= 16");
	rnds[6] = rnds[6] & 15 | 64;
	rnds[8] = rnds[8] & 63 | 128;
	if (buf) {
		offset = offset || 0;
		if (offset < 0 || offset + 16 > buf.length) throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
		for (let i = 0; i < 16; ++i) buf[offset + i] = rnds[i];
		return buf;
	}
	return unsafeStringify(rnds);
}
var v4_default = v4;

//#endregion
//#region node_modules/uuid/dist-node/sha1.js
function sha1(bytes) {
	if (Array.isArray(bytes)) bytes = Buffer.from(bytes);
	else if (typeof bytes === "string") bytes = Buffer.from(bytes, "utf8");
	return (0, node_crypto.createHash)("sha1").update(bytes).digest();
}
var sha1_default = sha1;

//#endregion
//#region node_modules/uuid/dist-node/v5.js
function v5(value, namespace, buf, offset) {
	return v35(80, sha1_default, value, namespace, buf, offset);
}
v5.DNS = DNS;
v5.URL = URL;
var v5_default = v5;

//#endregion
//#region node_modules/uuid/dist-node/v6.js
function v6(options, buf, offset) {
	options ??= {};
	offset ??= 0;
	let bytes = v1_default({
		...options,
		_v6: true
	}, new Uint8Array(16));
	bytes = v1ToV6(bytes);
	if (buf) {
		if (offset < 0 || offset + 16 > buf.length) throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
		for (let i = 0; i < 16; i++) buf[offset + i] = bytes[i];
		return buf;
	}
	return unsafeStringify(bytes);
}
var v6_default = v6;

//#endregion
//#region node_modules/uuid/dist-node/v7.js
const _state = {};
function v7(options, buf, offset) {
	let bytes;
	if (options) bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset);
	else {
		const now = Date.now();
		const rnds = rng();
		updateV7State(_state, now, rnds);
		bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
	}
	return buf ?? unsafeStringify(bytes);
}
function updateV7State(state, now, rnds) {
	state.msecs ??= -Infinity;
	state.seq ??= 0;
	if (now > state.msecs) {
		state.seq = rnds[6] << 23 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
		state.msecs = now;
	} else {
		state.seq = state.seq + 1 | 0;
		if (state.seq === 0) state.msecs++;
	}
	return state;
}
function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
	if (rnds.length < 16) throw new Error("Random bytes length must be >= 16");
	if (!buf) {
		buf = new Uint8Array(16);
		offset = 0;
	} else if (offset < 0 || offset + 16 > buf.length) throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
	msecs ??= Date.now();
	seq ??= rnds[6] * 127 << 24 | rnds[7] << 16 | rnds[8] << 8 | rnds[9];
	buf[offset++] = msecs / 1099511627776 & 255;
	buf[offset++] = msecs / 4294967296 & 255;
	buf[offset++] = msecs / 16777216 & 255;
	buf[offset++] = msecs / 65536 & 255;
	buf[offset++] = msecs / 256 & 255;
	buf[offset++] = msecs & 255;
	buf[offset++] = 112 | seq >>> 28 & 15;
	buf[offset++] = seq >>> 20 & 255;
	buf[offset++] = 128 | seq >>> 14 & 63;
	buf[offset++] = seq >>> 6 & 255;
	buf[offset++] = seq << 2 & 255 | rnds[10] & 3;
	buf[offset++] = rnds[11];
	buf[offset++] = rnds[12];
	buf[offset++] = rnds[13];
	buf[offset++] = rnds[14];
	buf[offset++] = rnds[15];
	return buf;
}
var v7_default = v7;

//#endregion
//#region src/index.ts
const plugin = { templateFunctions: [
	{
		name: "uuid.v1",
		description: "Generate a UUID V1",
		args: [],
		async onRender() {
			return v1_default();
		}
	},
	{
		name: "uuid.v3",
		description: "Generate a UUID V3",
		args: [{
			type: "text",
			name: "name",
			label: "Name"
		}, {
			type: "text",
			name: "namespace",
			label: "Namespace UUID",
			description: "A valid UUID to use as the namespace",
			placeholder: "24ced880-3bf4-11f0-8329-cd053d577f0e"
		}],
		async onRender(_ctx, args) {
			return v3_default(String(args.values.name), String(args.values.namespace));
		}
	},
	{
		name: "uuid.v4",
		description: "Generate a UUID V4",
		args: [],
		async onRender() {
			return v4_default();
		}
	},
	{
		name: "uuid.v5",
		description: "Generate a UUID V5",
		args: [{
			type: "text",
			name: "name",
			label: "Name"
		}, {
			type: "text",
			name: "namespace",
			label: "Namespace"
		}],
		async onRender(_ctx, args) {
			return v5_default(String(args.values.name), String(args.values.namespace));
		}
	},
	{
		name: "uuid.v6",
		description: "Generate a UUID V6",
		args: [{
			type: "text",
			name: "timestamp",
			label: "Timestamp",
			optional: true,
			description: "Can be any format that can be parsed by JavaScript new Date(...)",
			placeholder: "2025-05-28T11:15:00Z"
		}],
		async onRender(_ctx, args) {
			return v6_default({ msecs: new Date(String(args.values.timestamp)).getTime() });
		}
	},
	{
		name: "uuid.v7",
		description: "Generate a UUID V7",
		args: [],
		async onRender() {
			return v7_default();
		}
	}
] };

//#endregion
exports.plugin = plugin;