function n(n){return n>=0?n:-n}function t(n){if("number"==typeof n&&(n=BigInt(n)),1n===n)return 1;let t=1;do{t++}while((n>>=1n)>1n);return t}function r(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),n<=0n||t<=0n)throw new RangeError("a and b MUST be > 0");let r=0n,e=1n,u=1n,f=0n;for(;0n!==n;){const o=t/n,i=t%n,g=r-u*o,c=e-f*o;t=n,n=i,r=u,e=f,u=g,f=c}return{g:t,x:r,y:e}}function e(t,r){let e="number"==typeof t?BigInt(n(t)):n(t),u="number"==typeof r?BigInt(n(r)):n(r);if(0n===e)return u;if(0n===u)return e;let f=0n;for(;0n===(1n&(e|u));)e>>=1n,u>>=1n,f++;for(;0n===(1n&e);)e>>=1n;do{for(;0n===(1n&u);)u>>=1n;if(e>u){const n=e;e=u,u=n}u-=e}while(0n!==u);return e<=t?n:t}function o(n,t){return n>=t?t:n}function i(n,t){if("number"==typeof n&&(n=BigInt(n)),"number"==typeof t&&(t=BigInt(t)),t<=0n)return NaN;const r=n%t;return r<0n?r+t:r}function g(n,t){try{const e=r(i(n,t),t);return 1n!==e.g?NaN:i(e.x,t)}catch(n){return NaN}}function c(t,r,e){if("number"==typeof t&&(t=BigInt(t)),"number"==typeof r&&(r=BigInt(r)),"number"==typeof e&&(e=BigInt(e)),e<=0n)return NaN;if(1n===e)return BigInt(0);if(t=i(t,e),r<0n)return g(c(t,n(r),e),e);let u=1n;for(;r>0;)r%2n===1n&&(u=u*t%e),r/=2n,t=t**2n%e;return u}export{n as abs,t as bitLength,r as eGcd,e as gcd,u as lcm,f as max,o as min,g as modInv,c as modPow,i as toZn};