const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
const require_forge$1 = require('./forge.cjs');
const require_util$1 = require('./util.cjs');
const require_aes$1 = require('./aes.cjs');
const require_sha256$1 = require('./sha256.cjs');
const require_prng$1 = require('./prng.cjs');

//#region ../../node_modules/node-forge/lib/random.js
var require_random = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/node-forge/lib/random.js": ((exports, module) => {
	/**
	* An API for getting cryptographically-secure random bytes. The bytes are
	* generated using the Fortuna algorithm devised by Bruce Schneier and
	* Niels Ferguson.
	*
	* Getting strong random bytes is not yet easy to do in javascript. The only
	* truish random entropy that can be collected is from the mouse, keyboard, or
	* from timing with respect to page loads, etc. This generator makes a poor
	* attempt at providing random bytes when those sources haven't yet provided
	* enough entropy to initially seed or to reseed the PRNG.
	*
	* @author Dave Longley
	*
	* Copyright (c) 2009-2014 Digital Bazaar, Inc.
	*/
	var forge = require_forge$1.default;
	require_aes$1.default;
	require_sha256$1.default;
	require_prng$1.default;
	require_util$1.default;
	(function() {
		if (forge.random && forge.random.getBytes) {
			module.exports = forge.random;
			return;
		}
		(function(jQuery$1) {
			var prng_aes = {};
			var _prng_aes_output = new Array(4);
			var _prng_aes_buffer = forge.util.createBuffer();
			prng_aes.formatKey = function(key$1) {
				var tmp = forge.util.createBuffer(key$1);
				key$1 = new Array(4);
				key$1[0] = tmp.getInt32();
				key$1[1] = tmp.getInt32();
				key$1[2] = tmp.getInt32();
				key$1[3] = tmp.getInt32();
				return forge.aes._expandKey(key$1, false);
			};
			prng_aes.formatSeed = function(seed) {
				var tmp = forge.util.createBuffer(seed);
				seed = new Array(4);
				seed[0] = tmp.getInt32();
				seed[1] = tmp.getInt32();
				seed[2] = tmp.getInt32();
				seed[3] = tmp.getInt32();
				return seed;
			};
			prng_aes.cipher = function(key$1, seed) {
				forge.aes._updateBlock(key$1, seed, _prng_aes_output, false);
				_prng_aes_buffer.putInt32(_prng_aes_output[0]);
				_prng_aes_buffer.putInt32(_prng_aes_output[1]);
				_prng_aes_buffer.putInt32(_prng_aes_output[2]);
				_prng_aes_buffer.putInt32(_prng_aes_output[3]);
				return _prng_aes_buffer.getBytes();
			};
			prng_aes.increment = function(seed) {
				++seed[3];
				return seed;
			};
			prng_aes.md = forge.md.sha256;
			/**
			* Creates a new PRNG.
			*/
			function spawnPrng() {
				var ctx = forge.prng.create(prng_aes);
				/**
				* Gets random bytes. If a native secure crypto API is unavailable, this
				* method tries to make the bytes more unpredictable by drawing from data that
				* can be collected from the user of the browser, eg: mouse movement.
				*
				* If a callback is given, this method will be called asynchronously.
				*
				* @param count the number of random bytes to get.
				* @param [callback(err, bytes)] called once the operation completes.
				*
				* @return the random bytes in a string.
				*/
				ctx.getBytes = function(count, callback) {
					return ctx.generate(count, callback);
				};
				/**
				* Gets random bytes asynchronously. If a native secure crypto API is
				* unavailable, this method tries to make the bytes more unpredictable by
				* drawing from data that can be collected from the user of the browser,
				* eg: mouse movement.
				*
				* @param count the number of random bytes to get.
				*
				* @return the random bytes in a string.
				*/
				ctx.getBytesSync = function(count) {
					return ctx.generate(count);
				};
				return ctx;
			}
			var _ctx = spawnPrng();
			var getRandomValues = null;
			var globalScope = forge.util.globalScope;
			var _crypto = globalScope.crypto || globalScope.msCrypto;
			if (_crypto && _crypto.getRandomValues) getRandomValues = function(arr) {
				return _crypto.getRandomValues(arr);
			};
			if (forge.options.usePureJavaScript || !forge.util.isNodejs && !getRandomValues) {
				if (typeof window === "undefined" || window.document === void 0) {}
				_ctx.collectInt(+/* @__PURE__ */ new Date(), 32);
				if (typeof navigator !== "undefined") {
					var _navBytes = "";
					for (var key in navigator) try {
						if (typeof navigator[key] == "string") _navBytes += navigator[key];
					} catch (e) {}
					_ctx.collect(_navBytes);
					_navBytes = null;
				}
				if (jQuery$1) {
					jQuery$1().mousemove(function(e) {
						_ctx.collectInt(e.clientX, 16);
						_ctx.collectInt(e.clientY, 16);
					});
					jQuery$1().keypress(function(e) {
						_ctx.collectInt(e.charCode, 8);
					});
				}
			}
			if (!forge.random) forge.random = _ctx;
			else for (var key in _ctx) forge.random[key] = _ctx[key];
			forge.random.createInstance = spawnPrng;
			module.exports = forge.random;
		})(typeof jQuery !== "undefined" ? jQuery : null);
	})();
}) });

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_random();
  }
});
//# sourceMappingURL=random.cjs.map