var e=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function t(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function n(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function r(e,...n){if(!t(e))throw Error(`Uint8Array expected`);if(n.length>0&&!n.includes(e.length))throw Error(`Uint8Array expected of length `+n+`, got length=`+e.length)}function i(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);n(e.outputLen),n(e.blockLen)}function a(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function o(e,t){r(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function s(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function c(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function l(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function u(e,t){return e<<32-t|e>>>t}var d=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function f(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function p(e){for(let t=0;t<e.length;t++)e[t]=f(e[t]);return e}var m=d?e=>e:p,h=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,g=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function _(e){if(r(e),h)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=g[e[n]];return t}var v={_0:48,_9:57,A:65,F:70,a:97,f:102};function y(e){if(e>=v._0&&e<=v._9)return e-v._0;if(e>=v.A&&e<=v.F)return e-(v.A-10);if(e>=v.a&&e<=v.f)return e-(v.a-10)}function b(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(h)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=y(e.charCodeAt(i)),a=y(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function x(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function S(e){return typeof e==`string`&&(e=x(e)),r(e),e}function C(...e){let t=0;for(let n=0;n<e.length;n++){let i=e[n];r(i),t+=i.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}var w=class{};function T(e){let t=t=>e().update(S(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function E(t=32){if(e&&typeof e.getRandomValues==`function`)return e.getRandomValues(new Uint8Array(t));if(e&&typeof e.randomBytes==`function`)return Uint8Array.from(e.randomBytes(t));throw Error(`crypto.getRandomValues must be defined`)}export{S as _,n as a,c,l as d,b as f,m as g,u as h,i,C as l,E as m,r as n,o,t as p,a as r,_ as s,w as t,T as u,s as v};