!function(n,e){"object"==typeofexports&&"undefined"!=typeofmodule?e(exports):"function"==typeofdefine&&define.amd?define(["exports"],e):e((n="undefined"!=typeofglobalThis?globalThis:n||self).bigintModArith={})}(this,(function(n){"use strict";functione(n){returnn>=0?n:-n}functiont(n,e){if("number"==typeofn&&(n=BigInt(n)),"number"==typeofe&&(e=BigInt(e)),n<=0n||e<=0n)thrownewRangeError("a and b MUST be > 0");lett=0n,r=1n,o=1n,i=0n;for(;0n!==n;){constf=e/n,u=e%n,g=t-o*f,b=r-i*f;e=n,n=u,t=o,r=i,o=g,i=b}return{g:e,x:t,y:r}}functionr(n,t){letr="number"==typeofn?BigInt(e(n)):e(n),o="number"==typeoft?BigInt(e(t)):e(t);if(0n===r)returno;if(0n===o)returnr;leti=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){constn=r;r=o,o=n}o-=r}while(0n!==o);returnr<<i}functiono(n,e){if("number"==typeofn&&(n=BigInt(n)),"number"==typeofe&&(e=BigInt(e)),e<=0n)thrownewRangeError("n must be > 0");constt=n%e;returnt<0n?t+e:t}functioni(n,e){constr=t(o(n,e),e);if(1n!==r.g)thrownewRangeError(`${n.toString()} does not have inverse modulo ${e.toString()}`);returno(r.x,e)}n.abs=e,n.bitLength=function(n){if("number"==typeofn&&(n=BigInt(n)),1n===n)return1;lete=1;do{e++}while((n>>=1n)>1n);returne},n.eGcd=t,n.gcd=r,n.lcm=function(n,t){return"number"==typeofn&&(n=BigInt(n)),"number"==typeoft&&(t=BigInt(t)),0n===n&&0n===t?BigInt(0):e(n*t)/r(n,t)},n.max=function(n,e){returnn>=e?n:e},n.min=function(n,e){returnn>=e?e:n},n.modInv=i,n.modPow=functionn(t,r,f){if("number"==typeoft&&(t=BigInt(t)),"number"==typeofr&&(r=BigInt(r)),"number"==typeoff&&(f=BigInt(f)),f<=0n)thrownewRangeError("n must be > 0");if(1n===f)return0n;if(t=o(t,f),r<0n)returni(n(t,e(r),f),f);letu=1n;for(;r>0;)r%2n===1n&&(u=u*t%f),r/=2n,t=t**2n%f;returnu},n.toZn=o,Object.defineProperty(n,"__esModule",{value:!0})}));