/* esm.sh - @noble/curves@1.9.7/utils */
import{abytes as E,bytesToHex as w,concatBytes as T,hexToBytes as d,isBytes as x}from"/@noble/hashes@1.8.0/es2022/utils.mjs";import{abytes as tt,anumber as et,bytesToHex as rt,bytesToUtf8 as nt,concatBytes as ot,hexToBytes as it,isBytes as st,randomBytes as ft,utf8ToBytes as ct}from"/@noble/hashes@1.8.0/es2022/utils.mjs";var b=BigInt(0),p=BigInt(1);function v(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function O(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}"`;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function k(t,e,r=""){let n=x(t),i=t?.length,o=e!==void 0;if(!n||o&&i!==e){let u=r&&`"${r}" `,f=o?` of length ${e}`:"",c=n?`length=${i}`:`type=${typeof t}`;throw new Error(u+"expected Uint8Array"+f+", got "+c)}return t}function A(t){let e=t.toString(16);return e.length&1?"0"+e:e}function m(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?b:BigInt("0x"+t)}function H(t){return m(w(t))}function N(t){return E(t),m(w(Uint8Array.from(t).reverse()))}function I(t,e){return d(t.toString(16).padStart(e*2,"0"))}function j(t,e){return I(t,e).reverse()}function F(t){return d(A(t))}function C(t,e,r){let n;if(typeof e=="string")try{n=d(e)}catch(o){throw new Error(t+" must be hex string or Uint8Array, cause: "+o)}else if(x(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}function V(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function L(t){return Uint8Array.from(t)}function M(t){return Uint8Array.from(t,(e,r)=>{let n=e.charCodeAt(0);if(e.length!==1||n>127)throw new Error(`string contains non-ASCII character "${t[r]}" with code ${n} at position ${r}`);return n})}var g=t=>typeof t=="bigint"&&b<=t;function U(t,e,r){return g(t)&&g(e)&&g(r)&&e<=t&&t<r}function R(t,e,r,n){if(!U(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function z(t){let e;for(e=0;t>b;t>>=p,e+=1);return e}function D(t,e){return t>>BigInt(e)&p}function G(t,e,r){return t|(r?p:b)<<BigInt(e)}var P=t=>(p<<BigInt(t))-p;function W(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=s=>new Uint8Array(s),i=s=>Uint8Array.of(s),o=n(t),u=n(t),f=0,c=()=>{o.fill(1),u.fill(0),f=0},a=(...s)=>r(u,o,...s),h=(s=n(0))=>{u=a(i(0),s),o=a(),s.length!==0&&(u=a(i(1),s),o=a())},B=()=>{if(f++>=1e3)throw new Error("drbg: tried 1000 values");let s=0,y=[];for(;s<e;){o=a();let l=o.slice();y.push(l),s+=o.length}return T(...y)};return(s,y)=>{c(),h(s);let l;for(;!(l=y(B()));)h();return c(),l}}var $={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||x(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function q(t,e,r={}){let n=(i,o,u)=>{let f=$[o];if(typeof f!="function")throw new Error("invalid validator function");let c=t[i];if(!(u&&c===void 0)&&!f(c,t))throw new Error("param "+String(i)+" is invalid. Expected "+o+", got "+c)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}function J(t){return typeof t=="function"&&Number.isSafeInteger(t.outputLen)}function K(t,e,r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,o,u){let f=t[i];if(u&&f===void 0)return;let c=typeof f;if(c!==o||f===null)throw new Error(`param "${i}" is invalid: expected ${o}, got ${c}`)}Object.entries(e).forEach(([i,o])=>n(i,o,!1)),Object.entries(r).forEach(([i,o])=>n(i,o,!0))}var Q=()=>{throw new Error("not implemented")};function X(t){let e=new WeakMap;return(r,...n)=>{let i=e.get(r);if(i!==void 0)return i;let o=t(r,...n);return e.set(r,o),o}}export{O as _abool2,k as _abytes2,K as _validateObject,R as aInRange,v as abool,tt as abytes,et as anumber,M as asciiToBytes,D as bitGet,z as bitLen,P as bitMask,G as bitSet,rt as bytesToHex,H as bytesToNumberBE,N as bytesToNumberLE,nt as bytesToUtf8,ot as concatBytes,L as copyBytes,W as createHmacDrbg,C as ensureBytes,V as equalBytes,it as hexToBytes,m as hexToNumber,U as inRange,st as isBytes,J as isHash,X as memoized,Q as notImplemented,I as numberToBytesBE,j as numberToBytesLE,A as numberToHexUnpadded,F as numberToVarBytesBE,ft as randomBytes,ct as utf8ToBytes,q as validateObject};
/*! Bundled license information:

@noble/curves/esm/utils.js:
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
*/
//# sourceMappingURL=utils.mjs.map