dns-worker 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +3 -3
  2. package/dist/serverfull.mjs +73 -69
  3. package/dist/serverfull.mjs.map +4 -4
  4. package/package.json +3 -1
  5. package/static/assets/AccountView-p5jSjMAE.js +4 -0
  6. package/static/assets/{AnalyticsView-C_g_jz14.js → AnalyticsView-BywwDzah.js} +2 -2
  7. package/static/assets/AuthView-qoUKd5PS.js +2 -0
  8. package/static/assets/{DestinationMap-jSW7gimP.js → DestinationMap-9Yc54Mdj.js} +1 -1
  9. package/static/assets/FilteringView-Bs3__NpV.js +1 -0
  10. package/static/assets/LogsView-B-U9oaxB.js +5 -0
  11. package/static/assets/{QRCodeCanvas-Cu_-aNyM.js → QRCodeCanvas-DQ-xNuwF.js} +2 -2
  12. package/static/assets/{RulesView-CfVeQv0-.js → RulesView-B2kL1QhI.js} +1 -1
  13. package/static/assets/SettingsView-DTGI6eSd.js +1 -0
  14. package/static/assets/SetupView-DE9MM-32.js +1 -0
  15. package/static/assets/{SwipeableDrawer-BrmEzhuP.js → SwipeableDrawer-B81ANpsc.js} +1 -1
  16. package/static/assets/{TrendChart-Dc5yJndv.js → TrendChart-CCR1W3fC.js} +3 -3
  17. package/static/assets/browser-Dc5iKjY4.js +1 -0
  18. package/static/assets/date-CpvuBM37.js +1 -0
  19. package/static/assets/{de-DE-CA3VPcoz.js → de-DE-kDnumQOF.js} +1 -1
  20. package/static/assets/{es-ES-CHvRWwd-.js → es-ES-CqKS7vHl.js} +1 -1
  21. package/static/assets/{fr-FR-CqGOuepx.js → fr-FR-BRcdpT35.js} +1 -1
  22. package/static/assets/getFlagEmoji-DRubsb7D.js +1 -0
  23. package/static/assets/index-Bheo8y3N.css +2 -0
  24. package/static/assets/index-dXN_pYn1.js +16 -0
  25. package/static/assets/{ja-JP-BJSbUSmh.js → ja-JP-C5jk6SuH.js} +1 -1
  26. package/static/assets/{ko-KR-Chzg6jwO.js → ko-KR-z38NtMFa.js} +1 -1
  27. package/static/assets/{ru-RU-CSyCGGPn.js → ru-RU-Bicx52lz.js} +1 -1
  28. package/static/assets/services-BVnEJBDq.js +1 -0
  29. package/static/assets/vendor-i18next-BKUzkAKP.js +1 -0
  30. package/static/assets/vendor-react-BmoHsW1x.js +11 -0
  31. package/static/assets/{vendor-ui-core-sfZn2C08.js → vendor-ui-core-CY_WyMIf.js} +1 -1
  32. package/static/assets/{vendor-utils-CnB7BG7m.js → vendor-utils-BWSB0jGn.js} +1 -1
  33. package/static/assets/{vi-VN-D7rcA1IX.js → vi-VN-CvS_mTAu.js} +1 -1
  34. package/static/assets/{zh-CN-CSPdaOkF.js → zh-CN-B0nRgJTD.js} +1 -1
  35. package/static/assets/{zh-TW-DETA1X3X.js → zh-TW-lc_SSoVI.js} +1 -1
  36. package/static/index.html +6 -6
  37. package/static/sw.js +1 -1
  38. package/static/assets/AccountView-CGRwz6ae.js +0 -4
  39. package/static/assets/AuthView-BQzmEyvO.js +0 -2
  40. package/static/assets/FilteringView-CQ7sX3Rp.js +0 -1
  41. package/static/assets/LogsView-eLfZMRVo.js +0 -5
  42. package/static/assets/SettingsView-agJiYEt5.js +0 -1
  43. package/static/assets/SetupView-CTgCUAgk.js +0 -1
  44. package/static/assets/browser-DPi2BX_1.js +0 -1
  45. package/static/assets/date-IKj2stuv.js +0 -1
  46. package/static/assets/getFlagEmoji-_Wxhq0lT.js +0 -1
  47. package/static/assets/index-919BqnYI.css +0 -2
  48. package/static/assets/index-CbTjGMTZ.js +0 -16
  49. package/static/assets/services-Cwvmit1q.js +0 -1
  50. package/static/assets/vendor-i18next-cO7FDf_e.js +0 -1
  51. package/static/assets/vendor-react-CHk5ngkq.js +0 -11
@@ -1,4 +1,4 @@
1
- import{i as e,t}from"./rolldown-runtime-C4Xdq4VV.js";import{Qt as n,a as r,c as i,h as a,l as o,o as s,s as c}from"./vendor-react-CHk5ngkq.js";import{S as l}from"./vendor-icons-other-Bme3ywH9.js";function u(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var d=e=>e?`"${e}" `:``;function f(e,t=``){if(typeof e!=`number`)throw TypeError(d(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(d(t)+`expected integer >= 0, got `+e);return e}function p(e,t=``){if(typeof e!=`boolean`)throw TypeError(d(t)+`expected boolean, got type=`+typeof e);return e}function m(e,t,n=``){if(u(e)&&(t===void 0||e.length===t))return e;t!==void 0&&f(t,`length`);let r=u(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=d(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function h(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(f(e.outputLen),f(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var g=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},_=(e,t)=>{g(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function v(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function y(e,t){m(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function b(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function x(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function S(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function C(e,t){return e<<32-t|e>>>t}const w=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function T(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function E(e){for(let t=0;t<e.length;t++)e[t]=T(e[t]);return e}const D=w?e=>e:E;var O=(()=>typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`)(),k=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function A(e){if(m(e),O)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=k[e[n]];return t}function ee(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function j(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(O)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`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=ee(e.charCodeAt(i)),a=ee(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function M(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];m(r),t+=r.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}function te(e,t,n=`opts`){return _(e,`defaults`),t!==void 0&&_(t,n),Object.assign(Object.create(null),e,t)}function ne(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=te({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function re(e=32){f(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const ie=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function ae(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}const N=(e,t,n)=>m(e,t,n),oe=f;function se(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function ce(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function le(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}const ue=A,de=(...e)=>M(...e),fe=e=>j(e),pe=u,me=e=>re(e);var he=BigInt(0),ge=BigInt(1),_e=e=>e?`"${e}" `:``;function ve(e,t=``){if(typeof e!=`boolean`)throw TypeError(_e(t)+`expected boolean, got type=`+typeof e);return e}function ye(e){if(typeof e==`bigint`){if(!ke(e))throw RangeError(`positive bigint expected, got `+e)}else oe(e);return e}function be(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function xe(e){let t=ye(e).toString(16);return t.length&1?`0`+t:t}function Se(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?he:BigInt(`0x`+e)}function Ce(e){return Se(A(e))}function we(e){return Se(A(De(m(e)).reverse()))}function Te(e,t){if(f(t),t===0)throw Error(`zero output length is invalid`);e=ye(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return j(r.padStart(n,`0`))}function Ee(e,t){return Te(e,t).reverse()}function De(e){return Uint8Array.from(N(e))}function Oe(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}function ke(e){return typeof e==`bigint`&&he<=e}function Ae(e,t,n){return ke(e)&&ke(t)&&ke(n)&&t<=e&&e<n}function je(e,t,n,r){if(!Ae(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Me(e){if(e<he)throw Error(`expected non-negative bigint, got `+e);return e===he?0:e.toString(2).length}const Ne=e=>(be(e,`n`),(ge<<BigInt(e))-ge);function Pe(e,t,n){if(f(e,`hashLen`),f(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,de(s,...e)),p=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},m=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return de(...n)};return(e,t)=>{u(),p(e);let n;for(;(n=t(m()))===void 0;)p();return u(),n}}function Fe(e,t={},n={},r=`object`){ce(e,r),ce(t,`fields`),ce(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var P=BigInt(0),F=BigInt(1),Ie=BigInt(2),Le=BigInt(3),Re=BigInt(4),ze=BigInt(5),Be=BigInt(7),Ve=BigInt(8),He=BigInt(9),Ue=BigInt(15),We=BigInt(16),Ge=BigInt(`0x10000000000000000`);function I(e,t){if(t<=P)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=P?n:t+n}function Ke(e,t,n){if(n<=F)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<P)throw Error(`invalid exponent, negatives unsupported`);if(t===P)return F;if(t===F)return e;let r=e%n;if(r<P&&(r+=n),t<Ge){let e=F;for(;t>P;)t&F&&(e=e*r%n),r=r*r%n,t>>=F;return e}let i=[];for(;t>P;)i.push(Number(t&Ue)),t>>=Re;let a=Array(16);a[0]=F,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function qe(e,t){if(e===P)throw Error(`invert: expected non-zero number`);if(t<=F)throw Error(`invert: expected modulus > 1, got `+t);let n=I(e,t),r=t,i=P,a=F;for(;n!==P;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==F)throw Error(`invert: does not exist`);return I(i,t)}function Je(e,t){if(t<=F)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=I(e,t);if(n===P)throw Error(`invertCt: expected non-zero number`);let r=Ke(n,t-Ie,t);if(I(n*r,t)!==F)throw Error(`invertCt: does not exist`);return r}function Ye(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Xe(e,t){if((e&F)===P)throw Error(t+`: expected odd modulus, got `+e)}function Ze(e,t){let n=e,r=(n.ORDER+F)/Re,i=n.pow(t,r);return Ye(n,i,t),i}function Qe(e,t){let n=e,r=(n.ORDER-ze)/Ve,i=n.mul(t,Ie),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Ie),a),c=n.mul(o,n.sub(s,n.ONE));return Ye(n,c,t),c}function $e(e){let t=lt(e),n=et(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Be)/We;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return Ye(n,m,t),m})}function et(e){if(e<Le)throw Error(`sqrt is not defined for small field`);Xe(e,`tonelliShanks`);let t=e-F,n=0;for(;t%Ie===P;)t/=Ie,n++;let r=Ie,i=lt(e);for(;at(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Ze;let a=i.pow(r,t),o=(t+F)/Ie;return function(e,r){let i=e;if(i.is0(r))return r;if(at(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=F<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function tt(e){return Xe(e,`Fp.sqrt`),e%Re===Le?Ze:e%Ve===ze?Qe:e%We===He?$e(e):et(e)}var nt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function rt(e){if(ce(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);be(e.BYTES,`BYTES`),be(e.BITS,`BITS`);for(let t of nt)le(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=F)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function it(e,t,n=!1){rt(e),ae(t,`nums`),ve(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function at(e,t){rt(e);let n=e;Xe(n.ORDER,`FpLegendre`);let r=(n.ORDER-F)/Ie,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function ot(e,t){if(t!==void 0&&oe(t),e<=P)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=Me(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var st=new WeakMap,ct=class{ORDER;BITS;BYTES;isLE;ZERO=P;ONE=F;_lengths;_mod;constructor(e,t={}){if(e<=F)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,`sqrt`,{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=ot(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return I(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return P<=e&&e<this.ORDER}is0(e){return e===P}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&F)===F}neg(e){return I(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return I(e*e,this.ORDER)}add(e,t){return I(e+t,this.ORDER)}sub(e,t){return I(e-t,this.ORDER)}mul(e,t){return I(e*t,this.ORDER)}pow(e,t){return Ke(e,t,this.ORDER)}div(e,t){return I(e*qe(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return qe(e,this.ORDER)}sqrt(e){let t=st.get(this);return t||st.set(this,t=tt(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?Ee(e,this.BYTES):Te(e,this.BYTES)}fromBytes(e,t=!1){N(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?we(e):Ce(e);if(o&&(s=I(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return it(this,e,!0)}cmov(e,t,n){return ve(n,`condition`),n?t:e}};function lt(e,t={}){return Object.freeze(ct.prototype),new ct(e,t)}function ut(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=F)throw Error(`field order must be greater than 1`);let t=Me(e-F);return Math.ceil(t/8)}function dt(e){let t=ut(e);return t+Math.ceil(t/2)}function ft(e,t,n=!1){N(e);let r=e.length,i=ut(t),a=Math.max(dt(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=I(n?we(e):Ce(e),t-F)+F;return n?Ee(o,i):Te(o,i)}var pt=BigInt(0),mt=BigInt(1),ht=BigInt(4),gt=16,_t=128,vt=5,yt=(()=>2**31)();function bt(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);le(t.fromAffine,`Point.fromAffine`),le(t.fromBytes,`Point.fromBytes`),le(t.fromHex,`Point.fromHex`),ce(t.BASE,`Point.BASE`),ce(t.ZERO,`Point.ZERO`),rt(t.Fp),rt(t.Fn)}function xt(e,t){bt(e),Tt(t,e);let n=it(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function St(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function Ct(e,t){let n=e*(4*t+128);if(n>yt)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+yt/2**20+` MiB`)}function wt(e,t){if(e!==void 0){le(e,`randomBytes`);try{let n=e(t);if(!pe(n)||n.length!==t)return}catch{return}return e}}function Tt(e,t){ae(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function Et(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):ke(e)&&e<n))throw Error(`invalid scalar at index `+r)})}var Dt=new WeakMap;function Ot(e){return Dt.get(e)||1}function kt(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function At(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>pt;){let t=0;e&mt&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=mt}return a}function jt(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=mt),s.push(t)}if(e!==pt)throw Error(`invalid wnaf`);return s}function Mt(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var Nt=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){bt(e),this.randomBytes=wt(t,gt),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=jt(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!Ae(t,mt,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Ot(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+_t,i=this.randomBytes(gt);if(!pe(i)||i.length!==gt)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+Ce(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=vt,i=1<<r,a=Ne(r),o=Array(i);o[0]=this.ZERO;for(let t=1;t<i;t++)o[t]=o[t-1].add(e);let s=Math.ceil(n/r),c=this.ZERO;for(let e=s-1;e>=0;e--){if(e!==s-1)for(let e=0;e<r;e++)c=c.double();let n=Number(t>>BigInt(e*r)&a),l=o[0];for(let e=1;e<i;e++)l=e===n?o[e]:l;c=c.add(l)}return{p:c,f:c}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===mt?!0:e===this.BASE?(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded):!1}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!ke(t))throw Error(`invalid scalar`);let r=Ot(e);if(r===1||t>=this.Point.Fn.ORDER)return Pt(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),St(t,this.bits),Ct((Math.ceil((this.bits+_t)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Dt.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Ot(e)!==1}};function Pt(e,t,n,r=!1){if(bt(e),Tt(t,e),ve(r,`allowOversized`),Et(n,e.Fn,r?e.Fn.ORDER**ht:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>kt(e,4)),a=n.map(e=>At(e,4));return Mt(e.ZERO,i,a)}function Ft(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return rt(t),t}else return lt(e,{isLE:n})}function It(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);Fe(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(ke(n)&&n!==pt))throw Error(`CURVE.${e} must be positive bigint`)}let i=Ft(t.p,n.Fp,r),a=Ft(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Lt(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Rt=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(h(e),m(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),x(r)}update(e){return v(this),this.iHash.update(e),this}digestInto(e){v(this),y(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const zt=(()=>{let e=((e,t,n)=>new Rt(e,t).update(n).digest());return e.create=(e,t)=>new Rt(e,t),e})();var Bt=BigInt(0),Vt={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=Vt;if(be(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(se(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=xe(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?xe(i.length/2|128):``;return xe(e)+a+i+t},decode(e,t){let{Err:n}=Vt;t=N(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=Vt;if(ye(e),e<Bt)throw new t(`integer: negative integers are not allowed`);let n=xe(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=Vt;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return Ce(e)}},toSig(e,t){let{Err:n,_int:r,_tlv:i}=Vt;if(t!==void 0&&(be(t,`maxScalarBytes`),t<1))throw new n(`invalid signature: maxScalarBytes must be positive`);let a=N(e,void 0,`signature`),{v:o,l:s}=i.decode(48,a);if(s.length)throw new n(`invalid signature: left bytes after parsing`);let{v:c,l}=i.decode(2,o),{v:u,l:d}=i.decode(2,l);if(d.length)throw new n(`invalid signature: left bytes after parsing`);if(t!==void 0&&(c.length>t||u.length>t))throw new n(`invalid signature: integer too large`);return{r:r.decode(c),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:n}=Vt;Fe(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};const Ht=(()=>(Object.freeze(Vt._tlv),Object.freeze(Vt._int),Object.freeze(Vt)))();var Ut=(e,t)=>(e+(e>=0?t:-t)/Yt)/t;function Wt(e,t,n){je(`scalar`,e,qt,n);let[[r,i],[a,o]]=t,s=Ut(o*e,n),c=Ut(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<qt,f=u<qt;d&&(l=-l),f&&(u=-u);let p=Ne(Math.ceil(Me(n)/2))+Jt;if(l<qt||l>=p||u<qt||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Gt(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Kt(e,t){Fe(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return ve(n.lowS,`lowS`),ve(n.prehash,`prehash`),n.format!==void 0&&Gt(n.format),n}var qt=BigInt(0),Jt=BigInt(1),Yt=BigInt(2),Xt=BigInt(3),Zt=BigInt(4);function Qt(e,t={}){let n=It(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;Fe(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l,clearCofactor:u,isTorsionFree:d,fromBytes:f,toBytes:p}=t,m=t.randomBytes===void 0?me:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let h=c?{beta:c.beta,basises:c.basises.map(e=>[...e])}:void 0,g=en(r,i);function _(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function v(e,t,n){if(t.is0()){if(!l)throw Error(`bad point: ZERO`);return Uint8Array.of(0)}let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return ve(n,`isCompressed`),n?(_(),de($t(!r.isOdd(a)),o)):de(Uint8Array.of(4),o,r.toBytes(a))}function y(e){N(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=g,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=w(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}_();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!T(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let b=p===void 0?v:p,x=f===void 0?y:f,S=r.mul(a.b,Xt),C=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function w(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function T(e,t){let n=r.sqr(t),i=w(e);return r.eql(n,i)}if(!T(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let E=r.mul(r.pow(a.a,Xt),Zt),D=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(E,D)))throw Error(`bad curve params: a or b`);function O(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return typeof t==`object`&&t?r.create(t):t}function k(e){if(!(e instanceof M))throw Error(`Weierstrass Point expected`)}function A(e){if(!h||!h.basises)throw Error(`no endo`);return Wt(e,h.basises,i.ORDER)}function ee(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(h){let{k1neg:i,k1:o,k2neg:s,k2:c}=A(a),l=new M(r.mul(n.X,h.beta),n.Y,n.Z);e.push(i?n.negate():n,s?l.negate():l),t.push(o,c)}else e.push(n),t.push(a)}let j=new WeakSet;class M{static BASE=new M(a.Gx,a.Gy,r.ONE);static ZERO=new M(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=O(`x`,e),this.Y=O(`y`,t,!0),this.Z=O(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof M)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?M.ZERO:new M(t,n,r.ONE)}static fromBytes(e){let t=M.fromAffine(x(N(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return M.fromBytes(fe(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return ne.setWindowSize(this,e),t||this.multiply(Xt),this}assertValidity(){let e=this;if(e.is0()){if(l&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(j.has(e))return;let{x:t,y:n}=e.toAffine();if(!r.isValid(t)||!r.isValid(n))throw Error(`bad point: x or y not field elements`);if(!T(t,n))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);j.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){k(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new M(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=C(o),a=r.mul(S,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(S,o),l=C(l),u=r.sub(s,l),u=C(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new M(i,a,o)}add(e){k(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=C(h),c=r.mul(S,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=C(p),h=r.mul(S,h),f=r.add(f,p),p=r.sub(d,p),p=C(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new M(c,l,u)}subtract(e){return k(e),this.add(e.negate())}is0(){return this.equals(M.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=ne.mulSecret(this,e,o,te);return te([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===qt||t.is0())return M.ZERO;if(n===Jt)return t;if(ne.hasWindowSize(this))return ne.mulUnsafe(t,n,te);let r=[],a=[];return ee(r,a,t,n),Pt(M,r,a)}mulAddUnsafe(e,t,n){k(t);let r=[],i=[];return ee(r,i,this,e),ee(r,i,t,n),Pt(M,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){return o===Jt?!0:d?d(M,this):ne.mulUnsafe(this,s).is0()}clearCofactor(){return o===Jt?this:u?u(M,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===Jt?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return ve(e,`isCompressed`),this.assertValidity(),b(M,this,e)}toHex(e=!0){return ue(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let te=e=>xt(M,e),ne=new Nt(M,m);return ne.bits>=6&&M.BASE.precompute(6),Object.freeze(M.prototype),Object.freeze(M),M}function $t(e){return Uint8Array.of(e?2:3)}function en(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function tn(e,t={}){bt(e);let{Fn:n}=e,r=t.randomBytes===void 0?me:t.randomBytes,i=Object.assign(en(e.Fp,n),{seed:Math.max(dt(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!e.fromBytes(t).is0()}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,ft(N(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!pe(e))return;let s=N(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t),o=e.fromBytes(r);if(o.is0())throw Error(`invalid public key: point at infinity`);return o.multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Lt(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function nn(e,t,n={}){bt(e);let r=t;h(r),Fe(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?me:i.randomBytes,o=i.hmac===void 0?(e,t)=>zt(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=dt(l),f=wt(a,d),{keygen:p,getPublicKey:m,getSharedSecret:g,utils:_,lengths:v}=tn(e,i),y={prehash:!0,lowS:typeof i.lowS==`boolean`?i.lowS:!0,format:`compact`,extraEntropy:!1},b=l*Yt+Jt<s.ORDER;function x(e){return e>l>>Jt}function S(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function C(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function w(e,t,n){return C(),(e===n?0:2)|Number(s.isOdd(t))}function T(){if(b)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function E(e,t){Gt(t);let n=v.signature;return N(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class D{r;s;recovery;constructor(e,t,n){if(this.r=S(`r`,e),this.s=S(`s`,t),n!=null){if(T(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=y.format){E(e,t);let n;if(t===`der`){if(e.length>2*c.BYTES+16)throw new Ht.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=Ht.toSig(N(e),c.BYTES+1);return new D(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=v.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new D(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(fe(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new D(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+l:n;if(!s.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=s.toBytes(a),u=e.fromBytes(de($t((i&1)==0),o)),d=c.inv(a),f=k(N(t,void 0,`msgHash`)),p=c.create(-f*d),m=c.create(r*d),h=e.BASE.mulAddUnsafe(p,u,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return x(this.s)}toBytes(e=y.format){if(Gt(e),e===`der`)return fe(Ht.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(T(),de(Uint8Array.of(this.assertRecovery()),r,i)):de(r,i)}toHex(e){return ue(this.toBytes(e))}}Object.freeze(D.prototype),Object.freeze(D);let O=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Ce(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,k=i.bits2int_modN===void 0?function(e){return c.create(O(e))}:i.bits2int_modN,A=Ne(u);function ee(e){return je(`num < 2^`+u,e,qt,A),c.toBytes(e)}function j(e,t){return N(e,void 0,`message`),t?N(r(e),void 0,`prehashed message`):e}function M(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=Kt(r,y);t=j(t,o);let u=k(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[ee(p),ee(u)];if(s!=null&&s!==!1){let e=s===!0?a(v.secretKey):s;m.push(N(e,void 0,`extraEntropy`))}let h=de(...m),g=u;function _(t){let n=O(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===qt)return;let o;if(f!==void 0){let e=Ce(ft(f(d),l)),t=c.inv(c.mul(e,n)),r=c.mul(e,g),i=c.mul(e,p);o=c.create(t*c.create(r+i*a))}else{let e=Je(n,l);o=c.create(e*c.create(g+a*p))}if(o===qt)return;let s=w(r.x,r.y,a),u=o;return i&&x(o)&&(u=c.neg(o),s^=1),new D(a,u,b?void 0:s)}return{seed:h,k2sig:_}}function te(e,t,n={}){let{seed:i,k2sig:a}=M(e,t,n);return Pe(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function ne(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Kt(i,y);if(r=N(r,void 0,`publicKey`),n=j(n,o),!pe(t)){let e=t instanceof D?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}E(t,s);try{let i=D.fromBytes(t,s),o=e.fromBytes(r);if(o.is0()||a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=k(n),f=c.inv(u),p=c.create(d*f),m=c.create(l*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(c.create(g.x)!==l||s===`recovered`&&i.recovery!==w(g.x,g.y,l))}catch{return!1}}function re(e,t,n={}){let{prehash:r}=Kt(n,y);return t=j(t,r),D.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:m,getSharedSecret:g,utils:_,lengths:v,Point:e,sign:te,verify:ne,recoverPublicKey:re,Signature:D,hash:r})}var rn=(()=>BigInt(2**32-1))(),an=BigInt(32);function on(e,t=!1){return t?{h:Number(e&rn),l:Number(e>>an&rn)}:{h:Number(e>>an&rn)|0,l:Number(e&rn)|0}}function sn(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=on(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var cn=e=>e/2**32|0,ln=e=>e>>>0;function un(e,t,n,r){let i=cn(n),a=ln(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function dn(e,t,n){return e&t^~e&n}function fn(e,t,n){return e&t^e&n^t&n}var pn=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=S(this.buffer)}update(e){v(this),m(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=S(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0;continue}n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){v(this),y(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),un(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:S(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}};const mn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var hn=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),gn=new Uint32Array(64),_n=class extends pn{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)gn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=gn[e-15],n=gn[e-2],r=C(t,7)^C(t,18)^t>>>3;gn[e]=(C(n,17)^C(n,19)^n>>>10)+gn[e-7]+r+gn[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=C(o,6)^C(o,11)^C(o,25),u=l+t+dn(o,s,c)+hn[e]+gn[e]|0,d=(C(n,2)^C(n,13)^C(n,22))+fn(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){x(gn)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),x(this.buffer)}},vn=class extends _n{constructor(){super(32,mn)}};const yn=ne(()=>new vn,ie(1));function bn(e,t=`n`){if(typeof e!=`number`)throw TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function xn(e){return bn(e,`x`),(e&e-1)==0&&e!==0}function Sn(e,t){if(bn(e),typeof t!=`number`)throw TypeError(`"bits" expected number, got type=`+typeof t);if(!Number.isSafeInteger(t)||t<0||t>32)throw Error(`expected integer 0 <= bits <= 32, got ${t}`);let n=0;for(let r=0;r<t;r++,e>>>=1)n=n<<1|e&1;return n>>>0}function Cn(e){return bn(e),31-Math.clz32(e)}function wn(e){if(!e||typeof e!=`object`||typeof e.length!=`number`)throw TypeError(`"values" expected array-like, got type=`+typeof e);let t=e.length;if(!xn(t))throw Error(`expected positive power-of-two length, got `+t);let n=Cn(t);for(let r=0;r<t;r++){let t=Sn(r,n);if(r<t){let n=e[r];e[r]=e[t],e[t]=n}}return e}const Tn=(e,t)=>{Fe(t,{N:`number`,roots:`object`,dit:`boolean`},{invertButterflies:`boolean`,skipStages:`number`,brp:`boolean`},`coreOpts`);let{N:n,roots:r,dit:i,invertButterflies:a=!1,skipStages:o=0,brp:s=!0}=t;bn(n,`coreOpts.N`);let c=Cn(n);if(!xn(n))throw Error(`FFT: Polynomial size should be power of two`);bn(o,`coreOpts.skipStages`);let l=c===0?0:c-1;if(o>l)throw Error(`FFT: wrong skipStages: expected 0 <= skipStages <= ${l}`);if(r.length!==n)throw Error(`FFT: wrong roots length: expected ${n}, got ${r.length}`);let u=i!==a;return t=>{if(t.length!==n)throw Error(`FFT: wrong Polynomial length`);i&&s&&wn(t);for(let s=0,l=1;s<c-o;s++){let d=i?s+1+o:c-s,f=1<<d,p=f>>1,m=n>>d;for(let o=0;o<n;o+=f)for(let s=0,c=l++;s<p;s++){let l=a?i?n-c:c:s*m,d=o+s,f=o+s+p,h=r[l],g=t[f],_=t[d];if(u){let n=e.mul(g,h);t[d]=e.add(_,n),t[f]=e.sub(_,n)}else a?(t[d]=e.add(g,_),t[f]=e.mul(e.sub(g,_),h)):(t[d]=e.add(_,g),t[f]=e.mul(e.sub(_,g),h))}}return!i&&s&&wn(t),t}},En=nn(Qt((()=>({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}))()),yn);var Dn=BigInt(0),On=BigInt(1),kn=BigInt(2),An=BigInt(7),jn=BigInt(256),Mn=BigInt(113),Nn=[],Pn=[],Fn=[];for(let e=0,t=On,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Nn.push(2*(5*r+n)),Pn.push((e+1)*(e+2)/2%64);let i=Dn;for(let e=0;e<7;e++)t=(t<<On^(t>>An)*Mn)%jn,t&kn&&(i^=On<<(On<<BigInt(e))-On);Fn.push(i)}var In=sn(Fn,!0),Ln=In[0],Rn=In[1],zn=(e,t,n)=>e<<n|t>>>32-n,Bn=(e,t,n)=>t<<n|e>>>32-n,Vn=(e,t,n)=>t<<n-32|e>>>64-n,Hn=(e,t,n)=>e<<n-32|t>>>64-n,Un=(e,t,n)=>n>32?Vn(e,t,n):zn(e,t,n),Wn=(e,t,n)=>n>32?Hn(e,t,n):Bn(e,t,n),Gn=new Uint32Array(10);function Kn(e,t=24){if(!(e instanceof Uint32Array))throw TypeError(`"s" expected Uint32Array(50), got type=`+typeof e);if(e.length!==50)throw RangeError(`"s" expected Uint32Array(50), got length=`+e.length);if(f(t,`rounds`),t<1||t>24)throw Error(`"rounds" expected integer 1..24`);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)Gn[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,r=(t+2)%10,i=Gn[r],a=Gn[r+1],o=Un(i,a,1)^Gn[n],s=Wn(i,a,1)^Gn[n+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=s}let t=e[2],r=e[3];for(let n=0;n<24;n++){let i=Pn[n],a=Un(t,r,i),o=Wn(t,r,i),s=Nn[n];t=e[s],r=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3];e[t]^=~e[t+2]&e[t+4],e[t+1]^=~e[t+3]&e[t+5],e[t+2]^=~e[t+4]&e[t+6],e[t+3]^=~e[t+5]&e[t+7],e[t+4]^=~e[t+6]&e[t+8],e[t+5]^=~e[t+7]&e[t+9],e[t+6]^=~e[t+8]&n,e[t+7]^=~e[t+9]&r,e[t+8]^=~n&i,e[t+9]^=~r&a}e[0]^=Ln[n],e[1]^=Rn[n]}x(Gn)}var qn=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,t,n,r=!1,i=24){if(f(e,`blockLen`),f(t,`suffix`),f(i,`rounds`),p(r,`enableXOF`),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.canXOF=r,this.rounds=i,f(n,`outputLen`),!(0<e&&e<200))throw Error(`"blockLen" must be 1..199`);this.state=new Uint8Array(200),this.state32=b(this.state)}clone(){return this._cloneInto()}keccak(){D(this.state32),Kn(this.state32,this.rounds),D(this.state32),this.posOut=0,this.pos=0}update(e){v(this),m(e);let{blockLen:t,state:n,state32:r}=this,i=e.length,a=t%4==0&&e.byteOffset%4==0,o=t/4,s=a&&i>=t?b(e):void 0;for(let a=0;a<i;){if(s!==void 0&&this.pos===0&&a%4==0&&i-a>=t){for(let e=0,t=a/4;e<o;e++)r[e]^=s[t+e];a+=t,this.pos=t,this.keccak();continue}let c=Math.min(t-this.pos,i-a);for(let t=0;t<c;t++)n[this.pos++]^=e[a++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){v(this,!1),m(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not enabled`);return this.writeInto(e)}xof(e){return f(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(y(e,this),this.finished)throw Error(`digest() was already called`);this.writeInto(e.length===this.outputLen?e:e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,x(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}},Jn=(e,t,n,r={})=>ne(()=>new qn(t,e,n),r);const Yn=Jn(6,136,32,ie(8)),Xn=Jn(6,72,64,ie(10));var Zn=(e,t,n,r={})=>ne((r={})=>(r=te({},r),new qn(t,e,r.dkLen===void 0?n:r.dkLen,!0)),r);const Qn=Zn(31,168,16,ie(11)),$n=Zn(31,136,32,ie(12));var er=m;const tr=re;function nr(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}function rr(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function ir(e,t){if(e=m(e),t=m(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function ar(e){return new Uint8Array(m(e))}function or(e,...t){let n=e=>typeof e==`number`?e:e.bytesLen,r=t.reduce((e,t)=>e+n(t),0);return{bytesLen:r,encode:i=>{let a=new Uint8Array(r);for(let r=0,o=0;r<t.length;r++){let s=t[r],c=n(s),l=typeof s==`number`?i[r]:s.encode(i[r]);m(l,c,e),a.set(l,o),typeof s!=`number`&&l.fill(0),o+=c}return a},decode:i=>{m(i,r,e);let a=[];for(let e of t){let t=n(e),r=i.subarray(0,t);a.push(typeof e==`number`?r:e.decode(r)),i=i.subarray(t)}return a}}}function sr(e,t){let n=e,r=t*n.bytesLen;return{bytesLen:r,encode:e=>{let i=nr(e,`u`);if(i.length!==t)throw RangeError(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);let a=new Uint8Array(r);for(let e=0,t=0;e<i.length;e++){let r=n.encode(i[e]);a.set(r,t),r.fill(0),t+=r.length}return a},decode:e=>{m(e,r);let t=[];for(let r=0;r<e.length;r+=n.bytesLen)t.push(n.decode(e.subarray(r,r+n.bytesLen)));return t}}}function L(...e){for(let t of e)if(Array.isArray(t))for(let e of t)e.fill(0);else t.fill(0)}function cr(e){if(f(e,`bits`),e>32)throw RangeError(`"bits" expected <= 32, got `+e);return e===32?4294967295:~(-1<<e)>>>0}const lr=e=>{let{newPoly:t,N:n,Q:r,F:i,ROOT_OF_UNITY:a,brvBits:o,isKyber:s}=e,c=(e,t=r)=>{let n=e%t|0;return(n>=0?n|0:t+n|0)|0},l=(e,t=r)=>{let n=c(e,t)|0;return(n>t>>1?n-t|0:n)|0};function u(){let e=t(n);for(let t=0;t<n;t++){let n=Sn(t,o),i=BigInt(a)**BigInt(n)%BigInt(r);e[t]=Number(i)|0}return e}let d=u(),f=e=>{throw Error(`not implemented`)},p=s?{add:(e,t)=>{let n=e+t|0;return n>=r?n-r|0:n},sub:(e,t)=>{let n=e-t|0;return n<0?n+r|0:n},mul:(e,t)=>c((e|0)*(t|0))|0,inv:f}:{add:(e,t)=>c((e|0)+(t|0))|0,sub:(e,t)=>c((e|0)-(t|0))|0,mul:(e,t)=>c((e|0)*(t|0))|0,inv:f},m={N:n,roots:d,invertButterflies:!0,skipStages:s?1:0,brp:!1},h=Tn(p,{dit:!1,...m}),g=Tn(p,{dit:!0,...m}),_={encode:e=>h(e),decode:e=>{g(e);for(let t=0;t<e.length;t++)e[t]=c(i*e[t]);return e}};return{mod:c,smod:l,nttZetas:d,NTT:{encode:e=>_.encode(e),decode:e=>_.decode(e)},bitsCoder:(e,r)=>{for(let t=0,r=0;t<n;t++)r+=e,r>32&&cr(r),r%=8;let i=cr(e),a=n/8*e;return{bytesLen:a,encode:t=>{let n=t,o=new Uint8Array(a);for(let t=0,a=0,s=0,c=0;t<n.length;t++)for(a|=(r.encode(n[t])&i)<<s,s+=e;s>=8;s-=8,a>>=8)o[c++]=a&255;return o},decode:a=>{let o=t(n);for(let t=0,n=0,s=0,c=0;t<a.length;t++)for(n|=a[t]<<s,s+=8;s>=e;s-=e,n>>=e)o[c++]=r.decode(n&i);return o}}}}},ur=(e=>(t,n)=>{n||=e.blockLen;let r=new Uint8Array(t.length+2);r.set(t);let i=t.length,a=new Uint8Array(n),o=e.create({}),s=0,c=0;return{stats:()=>({calls:s,xofs:c}),get:(t,n)=>(r[i+0]=t,r[i+1]=n,o.destroy(),o=e.create({}).update(r),s++,()=>(c++,o.xofInto(a))),clean:()=>{o.destroy(),L(a,r)}}})(Qn);var R=256,z=3329,B=lr({N:R,Q:z,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0});const dr=(()=>Object.freeze({512:Object.freeze({N:R,Q:z,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128}),768:Object.freeze({N:R,Q:z,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}),1024:Object.freeze({N:R,Q:z,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256})}))();var fr=e=>{if(e>=12)return{encode:e=>e,decode:e=>e>=z?e-z:e};let t=2**(e-1);return{encode:t=>((t<<e)+z/2)/z,decode:n=>n*z+t>>>e}},pr=e=>B.bitsCoder(e,e===12?{encode:e=>e,decode:e=>e>=z?e-z:e}:{encode:e=>e,decode:e=>e}),mr=e=>e===12?pr(12):B.bitsCoder(e,fr(e));function hr(e,t){let n=e,r=t;for(let e=0;e<R;e++){let t=n[e]+r[e];n[e]=t>=z?t-z:t}}function gr(e,t){let n=e,r=t;for(let e=0;e<R;e++){let t=n[e]-r[e];n[e]=t<0?t+z:t}}function _r(e,t,n,r,i){return{c0:B.mod(B.mod(t*r)*i+e*n),c1:B.mod(e*r+t*n)}}function vr(e,t){let n=e,r=t;for(let e=0;e<R/2;e++){let t=B.nttZetas[64+(e>>1)];e&1&&(t=-t);let{c0:i,c1:a}=_r(n[2*e+0],n[2*e+1],r[2*e+0],r[2*e+1],t);n[2*e+0]=i,n[2*e+1]=a}return n}function yr(e){let t=e,n=new Uint16Array(R);for(let e=0;e<R;){let r=t();if(r.length%3)throw Error(`SampleNTT: unaligned block`);for(let t=0;e<R&&t+3<=r.length;t+=3){let i=(r[t+0]>>0|r[t+1]<<8)&4095,a=(r[t+1]>>4|r[t+2]<<4)&4095;i<z&&(n[e++]=i),e<R&&a<z&&(n[e++]=a)}}return n}var br=(e,t)=>{let n=new Uint16Array(R),r=b(e);D(r);let i=0;for(let e=0,a=0,o=0,s=0;e<r.length;e++){let c=r[e];for(let e=0;e<32;e++)o+=c&1,c>>=1,i+=1,i===t?(s=o,o=0):i===2*t&&(n[a++]=B.mod(s-o),o=0,i=0)}if(D(r),i)throw Error(`sampleCBD: leftover bits: ${i}`);return n};function xr(e,t,n,r){return br(e(r*R/4,t,n),r)}var Sr=e=>{let{K:t,PRF:n,XOF:r,HASH512:i,ETA1:a,ETA2:o,du:s,dv:c}=e,l=mr(1),u=mr(c),d=mr(s),f=or(`publicKey`,sr(mr(12),t),32),p=sr(mr(12),t),m=or(`ciphertext`,sr(d,t),u),h=or(`seed`,32,32),g=(e,r,i,s)=>{let c=[];for(let e=0;e<t;e++)c.push(B.NTT.encode(xr(n,s,e,a)));let u=new Uint16Array(R),d=[];for(let i=0;i<t;i++){let a=xr(n,s,t+i,o),l=new Uint16Array(R);for(let e=0;e<t;e++)hr(l,vr(r(i,e),c[e]));hr(a,B.NTT.decode(l)),d.push(a),hr(u,vr(e[i],c[i])),L(l)}let f=xr(n,s,2*t,o);hr(f,B.NTT.decode(u));let p=l.decode(i);return hr(p,f),L(e,c,u,f),m.encode([d,p])};return{secretCoder:p,lengths:{secretKey:p.bytesLen,publicKey:f.bytesLen,cipherText:m.bytesLen},keygen:e=>{er(e,32,`seed`);let o=new Uint8Array(33);o.set(e),o[32]=t;let s=i(o),[c,l]=h.decode(s),u=[],d=[];for(let e=0;e<t;e++)u.push(B.NTT.encode(xr(n,l,e,a)));let m=r(c);for(let e=0;e<t;e++){let r=B.NTT.encode(xr(n,l,t+e,a));for(let n=0;n<t;n++)hr(r,vr(yr(m.get(n,e)),u[n]));d.push(r)}m.clean();let g={publicKey:f.encode([d,c]),secretKey:p.encode(u)};return L(c,l,u,d,o,s),g},encrypt:(e,t,n)=>{let[i,a]=f.decode(e),o=r(a),s=g(i,(e,t)=>yr(o.get(e,t)),t,n);return o.clean(),s},prepare:e=>{let[n,i]=f.decode(e),a=r(i),o=[];for(let e=0;e<t;e++)for(let n=0;n<t;n++)o.push(yr(a.get(e,n)));return a.clean(),{encrypt:(e,r)=>g(n.map(e=>e.slice()),(e,n)=>o[e*t+n].slice(),e,r),clean:()=>L(n,o)}},decrypt:(e,n)=>{let[r,i]=m.decode(e),a=p.decode(n),o=new Uint16Array(R);for(let e=0;e<t;e++)hr(o,vr(a[e],B.NTT.encode(r[e])));gr(i,B.NTT.decode(o));let s=l.encode(i);return L(o,a,r,i),s}}};function Cr(e){let t=e,n=Sr(t),{HASH256:r,HASH512:i,KDF:a}=t,{secretCoder:o,lengths:s}=n,c=or(`secretKey`,s.secretKey,s.publicKey,32,32),l=(e,n)=>{let r=e.subarray(0,384*t.K),i=o.encode(o.decode(ar(r))),a=ir(i,r);if(L(i),!a)throw Error(`ML-KEM.${n}: wrong publicKey modulus`)},u=Object.freeze({...s,seed:64,msg:32,msgRand:32,secretKey:c.bytesLen});return Object.freeze({info:Object.freeze({type:`ml-kem`}),lengths:u,keygen:e=>{let t=e===void 0,i=t?tr(64):e,a,o;try{er(i,64,`seed`);let e=n.keygen(i.subarray(0,32)),t=e.publicKey;return a=e.secretKey,o=r(t),{publicKey:t,secretKey:c.encode([a,t,o,i.subarray(32)])}}finally{a!==void 0&&L(a),o!==void 0&&L(o),t&&L(i)}},getPublicKey:e=>{let[t,n,r,i]=c.decode(e);return Uint8Array.from(n)},encapsulate:(e,t)=>{let a=t===void 0,o=a?tr(32):t,c;try{return er(e,s.publicKey,`publicKey`),er(o,32,`message`),l(e,`encapsulate`),c=i.create().update(o).update(r(e)).digest(),{cipherText:n.encrypt(e,o,c.subarray(32,64)),sharedSecret:c.subarray(0,32)}}finally{c!==void 0&&L(c.subarray(32)),a&&L(o)}},decapsulate:(e,t)=>{er(t,c.bytesLen,`secretKey`),er(e,s.cipherText,`cipherText`);let o=c.bytesLen-96,l=o+32;if(!ir(r(t.subarray(o/2,l)),t.subarray(l,l+32)))throw Error(`invalid secretKey: hash check failed`);let[u,d,f,p]=c.decode(t),m=n.decrypt(e,u),h=i.create().update(m).update(f).digest(),g=h.subarray(0,32),_=n.encrypt(d,m,h.subarray(32,64)),v=ir(e,_),y=a.create({dkLen:32}).update(p).update(e).digest();return L(m,_,h.subarray(32),v?y:g),v?g:y},prepare:e=>{er(e,s.publicKey,`publicKey`),l(e,`prepare`);let t=ar(e),o=r(t),u=n.prepare(t);return Object.freeze({publicKey:t,encapsulate:e=>{let t=e===void 0,n=t?tr(32):e,r;try{return er(n,32,`message`),r=i.create().update(n).update(o).digest(),{cipherText:u.encrypt(n,r.subarray(32,64)),sharedSecret:r.subarray(0,32)}}finally{r!==void 0&&L(r.subarray(32)),t&&L(n)}},decapsulate:(e,r)=>{er(r,c.bytesLen,`secretKey`),er(e,s.cipherText,`cipherText`);let[l,d,f,p]=c.decode(r);if(!ir(d,t)||!ir(f,o))throw Error(`ML-KEM.decapsulate: secretKey does not match prepared publicKey`);let m=n.decrypt(e,l),h=i.create().update(m).update(o).digest(),g=h.subarray(0,32),_=u.encrypt(m,h.subarray(32,64)),v=ir(e,_),y=a.create({dkLen:32}).update(p).update(e).digest();return L(m,_,h.subarray(32),v?y:g),v?g:y},clean:u.clean})}})}function wr(e,t,n){return $n.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}var Tr=(()=>({HASH256:Yn,HASH512:Xn,KDF:$n,XOF:ur,PRF:wr}))(),Er=e=>Cr({...Tr,...e});const Dr=(()=>Er(dr[768]))();var Or=(e,t)=>{let n=rr(e,t);return rr(n.lengths,`${t}.lengths`),le(n.keygen,`${t}.keygen`),le(n.getPublicKey,`${t}.getPublicKey`),le(n.encapsulate,`${t}.encapsulate`),le(n.decapsulate,`${t}.decapsulate`),n};function kr(e,t){let n=f(e,t);if(n===0)throw RangeError(`"${t}" expected integer greater than 0, got 0`);return n}function Ar(e,t){let n=or(t,...e.map(e=>{if(typeof e.lengths[t]!=`number`)throw Error(`wrong length: `+t);return kr(e.lengths[t],t)}));return kr(n.bytesLen,t),n}function jr(e,t,...n){let r=t,i=n,a=Ar(i,`seed`),o=Ar(i,`publicKey`),s=kr(e===void 0?a.bytesLen:e,`realSeedLen`);function c(e){m(e,s);let t=r(e,a.bytesLen),n=t.buffer===e.buffer?ar(t):t,o=[],c=[],l=[],u=[],d=!1;try{for(let e of a.decode(n))o.push(ar(e));for(let e=0;e<i.length;e++){let t=i[e].keygen(o[e]);c.push(t.secretKey),l.push(ar(t.secretKey)),u.push(t.publicKey)}return d=!0,{secretKey:l,publicKey:u}}finally{L(n,o,c),d||L(l)}}let l=e=>{let t=e===void 0?tr(s):ar(e),n;try{let{publicKey:e,secretKey:r}=c(t);try{n={secretKey:t,publicKey:o.encode(e)}}finally{L(e,r)}return n}finally{n||L(t)}};return{info:{lengths:{seed:s,publicKey:o.bytesLen,secretKey:s}},getPublicKey:e=>{let t=l(e);return L(t.secretKey),t.publicKey},keygen:l,expandDecapsulationKey:c,realSeedLen:s}}function Mr(e,t,n,r,...i){if(e!==void 0&&kr(e,`realSeedLen`),t!==void 0&&kr(t,`realMsgLen`),typeof n!=`function`)throw TypeError(`"expandSeed" expected function, got type=`+typeof n);if(typeof r!=`function`)throw TypeError(`"combiner" expected function, got type=`+typeof r);let a=r,o=i;if(o.length===0)throw RangeError(`combineKEMS requires at least one KEM`);for(let e=0;e<o.length;e++)Or(o[e],`kems[${e}]`);let s=jr(e,n,...o),c=Ar(o,`cipherText`),l=Ar(o,`publicKey`),d=Ar(o,`msg`),f=kr(t===void 0?d.bytesLen:t,`realMsgLen`),p=Object.freeze({...s.info.lengths,msg:f,msgRand:d.bytesLen,cipherText:c.bytesLen}),h=(e,t,n)=>{let r=a(e,t,n);try{return ar(m(r,f,`sharedSecret`))}catch(n){if(u(r)){let n=e=>r.buffer===e.buffer&&r.byteOffset<e.byteOffset+e.byteLength&&e.byteOffset<r.byteOffset+r.byteLength;e.some(n)||t.some(n)||L(r)}throw n}};return Object.freeze({lengths:p,getPublicKey:s.getPublicKey,keygen:s.keygen,encapsulate(e,t=tr(d.bytesLen)){let n=l.decode(e),r=d.decode(t),i=[],a=[];try{for(let e=0;e<o.length;e++){let t=o[e].encapsulate(n[e],r[e]);i.push(t.sharedSecret),a.push(t.cipherText)}let e=c.encode(a);return{sharedSecret:h(n,a,i),cipherText:e}}finally{L(i,a)}},decapsulate(e,t){let n=c.decode(e),{publicKey:r,secretKey:i}=s.expandDecapsulationKey(t),a=[];try{for(let e=0;e<o.length;e++)a.push(o[e].decapsulate(n[e],i[e]));return h(r,n,a)}finally{L(i,a)}}})}function Nr(e,t,n,r){let i=e.Point.Fn;if(!i)throw Error(`no Point.Fn`);function a(n){let r;for(let e=0,a=t;;e=a,a+=t){if(a>n.length)throw Error(`rejection sampling failed`);if(r=i.fromBytes(n.subarray(e,a),!0),i.isValidNot0(r))break}let a=i.toBytes(i.create(r));return{secretKey:a,publicKey:e.getPublicKey(a,!1)}}let o=(t,n)=>e.getSharedSecret(n,t).subarray(1);return{lengths:{secretKey:t,publicKey:n,seed:r,msg:r,cipherText:n},keygen(e=tr(r)){return m(e,r,`seed`),a(e)},getPublicKey(t){return e.getPublicKey(t,!1)},encapsulate(t,n=tr(r)){m(n,r,`rand`);let i;try{return i=a(n).secretKey,{sharedSecret:o(t,i),cipherText:e.getPublicKey(i,!1)}}finally{i&&L(i)}},decapsulate:o}}function Pr(e,t,n,r){let{secretKey:i,publicKeyUncompressed:a}=n.lengths;if(!i||!a)throw Error(`wrong curve`);let o=Nr(n,i,a,r),s=64+r;return Mr(32,32,e=>(m(e,32),$n(e,{dkLen:s})),(t,n,r)=>Yn(de(r[0],r[1],n[1],t[1],Oe(e))),t,o)}const Fr=(()=>Pr(`MLKEM768-P256`,Dr,En,128))();function Ir(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ir(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Lr(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ir(e))&&(r&&(r+=` `),r+=t);return r}var Rr=Lr,zr=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Br=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),Vr=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Hr=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ur=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Wr=t((e=>{var t=Br().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Gr=t((e=>{var t=Br().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Kr=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),qr=t((e=>{var t=Vr(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Jr=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Yr=t((e=>{var t=Jr();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Xr=t(((e,t)=>{var n=Yr();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Zr=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Qr=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
1
+ import{i as e,t}from"./rolldown-runtime-C4Xdq4VV.js";import{$t as n,a as r,c as i,h as a,l as o,o as s,s as c}from"./vendor-react-BmoHsW1x.js";import{S as l}from"./vendor-icons-other-Bme3ywH9.js";function u(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var d=e=>e?`"${e}" `:``;function f(e,t=``){if(typeof e!=`number`)throw TypeError(d(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(d(t)+`expected integer >= 0, got `+e);return e}function p(e,t=``){if(typeof e!=`boolean`)throw TypeError(d(t)+`expected boolean, got type=`+typeof e);return e}function m(e,t,n=``){if(u(e)&&(t===void 0||e.length===t))return e;t!==void 0&&f(t,`length`);let r=u(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=d(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function h(e){if(typeof e!=`function`||typeof e.create!=`function`)throw TypeError(`expected hash wrapped by utils.createHasher`);if(f(e.outputLen),f(e.blockLen),e.outputLen<1||e.blockLen<1)throw Error(`hash blockLen / outputLen must be >= 1`)}var g=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},_=(e,t)=>{g(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function v(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function y(e,t){m(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function b(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function x(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function S(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function C(e,t){return e<<32-t|e>>>t}const w=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function T(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function E(e){for(let t=0;t<e.length;t++)e[t]=T(e[t]);return e}const D=w?e=>e:E;var O=(()=>typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`)(),k=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function A(e){if(m(e),O)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=k[e[n]];return t}function ee(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function j(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);if(O)try{return Uint8Array.fromHex(e)}catch(e){throw e instanceof SyntaxError?RangeError(e.message):e}let t=e.length,n=t/2;if(t%2)throw RangeError(`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=ee(e.charCodeAt(i)),a=ee(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw RangeError(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function M(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];m(r),t+=r.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}function te(e,t,n=`opts`){return _(e,`defaults`),t!==void 0&&_(t,n),Object.assign(Object.create(null),e,t)}function ne(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=te({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}function re(e=32){f(e,`bytesLength`);let t=typeof globalThis==`object`?globalThis.crypto:null;if(typeof t?.getRandomValues!=`function`)throw Error(`crypto.getRandomValues must be defined`);if(e>65536)throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const ie=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function ae(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}const N=(e,t,n)=>m(e,t,n),oe=f;function se(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function ce(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function le(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}const ue=A,de=(...e)=>M(...e),fe=e=>j(e),pe=u,me=e=>re(e);var he=BigInt(0),ge=BigInt(1),_e=e=>e?`"${e}" `:``;function ve(e,t=``){if(typeof e!=`boolean`)throw TypeError(_e(t)+`expected boolean, got type=`+typeof e);return e}function ye(e){if(typeof e==`bigint`){if(!ke(e))throw RangeError(`positive bigint expected, got `+e)}else oe(e);return e}function be(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function xe(e){let t=ye(e).toString(16);return t.length&1?`0`+t:t}function Se(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?he:BigInt(`0x`+e)}function Ce(e){return Se(A(e))}function we(e){return Se(A(De(m(e)).reverse()))}function Te(e,t){if(f(t),t===0)throw Error(`zero output length is invalid`);e=ye(e);let n=t*2,r=e.toString(16);if(r.length>n)throw RangeError(`number is too large`);return j(r.padStart(n,`0`))}function Ee(e,t){return Te(e,t).reverse()}function De(e){return Uint8Array.from(N(e))}function Oe(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}function ke(e){return typeof e==`bigint`&&he<=e}function Ae(e,t,n){return ke(e)&&ke(t)&&ke(n)&&t<=e&&e<n}function je(e,t,n,r){if(!Ae(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Me(e){if(e<he)throw Error(`expected non-negative bigint, got `+e);return e===he?0:e.toString(2).length}const Ne=e=>(be(e,`n`),(ge<<BigInt(e))-ge);function Pe(e,t,n){if(f(e,`hashLen`),f(t,`qByteLen`),typeof n!=`function`)throw TypeError(`hmacFn must be a function`);let r=e=>new Uint8Array(e),i=Uint8Array.of(),a=Uint8Array.of(0),o=Uint8Array.of(1),s=r(e),c=r(e),l=0,u=()=>{s.fill(1),c.fill(0),l=0},d=(...e)=>n(c,de(s,...e)),p=(e=i)=>{c=d(a,e),s=d(),e.length!==0&&(c=d(o,e),s=d())},m=()=>{if(l++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,n=[];for(;e<t;){s=d();let t=s.slice();n.push(t),e+=s.length}return de(...n)};return(e,t)=>{u(),p(e);let n;for(;(n=t(m()))===void 0;)p();return u(),n}}function Fe(e,t={},n={},r=`object`){ce(e,r),ce(t,`fields`),ce(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}var P=BigInt(0),F=BigInt(1),Ie=BigInt(2),Le=BigInt(3),Re=BigInt(4),ze=BigInt(5),Be=BigInt(7),Ve=BigInt(8),He=BigInt(9),Ue=BigInt(15),We=BigInt(16),Ge=BigInt(`0x10000000000000000`);function I(e,t){if(t<=P)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=P?n:t+n}function Ke(e,t,n){if(n<=F)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<P)throw Error(`invalid exponent, negatives unsupported`);if(t===P)return F;if(t===F)return e;let r=e%n;if(r<P&&(r+=n),t<Ge){let e=F;for(;t>P;)t&F&&(e=e*r%n),r=r*r%n,t>>=F;return e}let i=[];for(;t>P;)i.push(Number(t&Ue)),t>>=Re;let a=Array(16);a[0]=F,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function qe(e,t){if(e===P)throw Error(`invert: expected non-zero number`);if(t<=F)throw Error(`invert: expected modulus > 1, got `+t);let n=I(e,t),r=t,i=P,a=F;for(;n!==P;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==F)throw Error(`invert: does not exist`);return I(i,t)}function Je(e,t){if(t<=F)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=I(e,t);if(n===P)throw Error(`invertCt: expected non-zero number`);let r=Ke(n,t-Ie,t);if(I(n*r,t)!==F)throw Error(`invertCt: does not exist`);return r}function Ye(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function Xe(e,t){if((e&F)===P)throw Error(t+`: expected odd modulus, got `+e)}function Ze(e,t){let n=e,r=(n.ORDER+F)/Re,i=n.pow(t,r);return Ye(n,i,t),i}function Qe(e,t){let n=e,r=(n.ORDER-ze)/Ve,i=n.mul(t,Ie),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Ie),a),c=n.mul(o,n.sub(s,n.ONE));return Ye(n,c,t),c}function $e(e){let t=lt(e),n=et(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Be)/We;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return Ye(n,m,t),m})}function et(e){if(e<Le)throw Error(`sqrt is not defined for small field`);Xe(e,`tonelliShanks`);let t=e-F,n=0;for(;t%Ie===P;)t/=Ie,n++;let r=Ie,i=lt(e);for(;at(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return Ze;let a=i.pow(r,t),o=(t+F)/Ie;return function(e,r){let i=e;if(i.is0(r))return r;if(at(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=F<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function tt(e){return Xe(e,`Fp.sqrt`),e%Re===Le?Ze:e%Ve===ze?Qe:e%We===He?$e(e):et(e)}var nt=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function rt(e){if(ce(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);be(e.BYTES,`BYTES`),be(e.BITS,`BITS`);for(let t of nt)le(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=F)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function it(e,t,n=!1){rt(e),ae(t,`nums`),ve(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function at(e,t){rt(e);let n=e;Xe(n.ORDER,`FpLegendre`);let r=(n.ORDER-F)/Ie,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function ot(e,t){if(t!==void 0&&oe(t),e<=P)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=Me(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}var st=new WeakMap,ct=class{ORDER;BITS;BYTES;isLE;ZERO=P;ONE=F;_lengths;_mod;constructor(e,t={}){if(e<=F)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,`sqrt`,{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=ot(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return I(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return P<=e&&e<this.ORDER}is0(e){return e===P}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&F)===F}neg(e){return I(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return I(e*e,this.ORDER)}add(e,t){return I(e+t,this.ORDER)}sub(e,t){return I(e-t,this.ORDER)}mul(e,t){return I(e*t,this.ORDER)}pow(e,t){return Ke(e,t,this.ORDER)}div(e,t){return I(e*qe(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return qe(e,this.ORDER)}sqrt(e){let t=st.get(this);return t||st.set(this,t=tt(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?Ee(e,this.BYTES):Te(e,this.BYTES)}fromBytes(e,t=!1){N(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?we(e):Ce(e);if(o&&(s=I(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return it(this,e,!0)}cmov(e,t,n){return ve(n,`condition`),n?t:e}};function lt(e,t={}){return Object.freeze(ct.prototype),new ct(e,t)}function ut(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=F)throw Error(`field order must be greater than 1`);let t=Me(e-F);return Math.ceil(t/8)}function dt(e){let t=ut(e);return t+Math.ceil(t/2)}function ft(e,t,n=!1){N(e);let r=e.length,i=ut(t),a=Math.max(dt(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=I(n?we(e):Ce(e),t-F)+F;return n?Ee(o,i):Te(o,i)}var pt=BigInt(0),mt=BigInt(1),ht=BigInt(4),gt=16,_t=128,vt=5,yt=(()=>2**31)();function bt(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);le(t.fromAffine,`Point.fromAffine`),le(t.fromBytes,`Point.fromBytes`),le(t.fromHex,`Point.fromHex`),ce(t.BASE,`Point.BASE`),ce(t.ZERO,`Point.ZERO`),rt(t.Fp),rt(t.Fn)}function xt(e,t){bt(e),Tt(t,e);let n=it(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function St(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function Ct(e,t){let n=e*(4*t+128);if(n>yt)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+yt/2**20+` MiB`)}function wt(e,t){if(e!==void 0){le(e,`randomBytes`);try{let n=e(t);if(!pe(n)||n.length!==t)return}catch{return}return e}}function Tt(e,t){ae(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function Et(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):ke(e)&&e<n))throw Error(`invalid scalar at index `+r)})}var Dt=new WeakMap;function Ot(e){return Dt.get(e)||1}function kt(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function At(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>pt;){let t=0;e&mt&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=mt}return a}function jt(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=mt),s.push(t)}if(e!==pt)throw Error(`invalid wnaf`);return s}function Mt(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var Nt=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){bt(e),this.randomBytes=wt(t,gt),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=jt(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!Ae(t,mt,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=Ot(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+_t,i=this.randomBytes(gt);if(!pe(i)||i.length!==gt)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+Ce(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=vt,i=1<<r,a=Ne(r),o=Array(i);o[0]=this.ZERO;for(let t=1;t<i;t++)o[t]=o[t-1].add(e);let s=Math.ceil(n/r),c=this.ZERO;for(let e=s-1;e>=0;e--){if(e!==s-1)for(let e=0;e<r;e++)c=c.double();let n=Number(t>>BigInt(e*r)&a),l=o[0];for(let e=1;e<i;e++)l=e===n?o[e]:l;c=c.add(l)}return{p:c,f:c}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===mt?!0:e===this.BASE?(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded):!1}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!ke(t))throw Error(`invalid scalar`);let r=Ot(e);if(r===1||t>=this.Point.Fn.ORDER)return Pt(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),St(t,this.bits),Ct((Math.ceil((this.bits+_t)/t)+1)*2**(t-1),this.Point.Fp.BYTES),Dt.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Ot(e)!==1}};function Pt(e,t,n,r=!1){if(bt(e),Tt(t,e),ve(r,`allowOversized`),Et(n,e.Fn,r?e.Fn.ORDER**ht:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>kt(e,4)),a=n.map(e=>At(e,4));return Mt(e.ZERO,i,a)}function Ft(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return rt(t),t}else return lt(e,{isLE:n})}function It(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);Fe(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(ke(n)&&n!==pt))throw Error(`CURVE.${e} must be positive bigint`)}let i=Ft(t.p,n.Fp,r),a=Ft(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function Lt(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}var Rt=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(h(e),m(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),x(r)}update(e){return v(this),this.iHash.update(e),this}digestInto(e){v(this),y(e,this),this.finished=!0;let t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const zt=(()=>{let e=((e,t,n)=>new Rt(e,t).update(n).digest());return e.create=(e,t)=>new Rt(e,t),e})();var Bt=BigInt(0),Vt={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=Vt;if(be(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(se(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=xe(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?xe(i.length/2|128):``;return xe(e)+a+i+t},decode(e,t){let{Err:n}=Vt;t=N(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=Vt;if(ye(e),e<Bt)throw new t(`integer: negative integers are not allowed`);let n=xe(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=Vt;if(e.length<1)throw new t(`invalid signature integer: empty`);if(e[0]&128)throw new t(`invalid signature integer: negative`);if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t(`invalid signature integer: unnecessary leading zero`);return Ce(e)}},toSig(e,t){let{Err:n,_int:r,_tlv:i}=Vt;if(t!==void 0&&(be(t,`maxScalarBytes`),t<1))throw new n(`invalid signature: maxScalarBytes must be positive`);let a=N(e,void 0,`signature`),{v:o,l:s}=i.decode(48,a);if(s.length)throw new n(`invalid signature: left bytes after parsing`);let{v:c,l}=i.decode(2,o),{v:u,l:d}=i.decode(2,l);if(d.length)throw new n(`invalid signature: left bytes after parsing`);if(t!==void 0&&(c.length>t||u.length>t))throw new n(`invalid signature: integer too large`);return{r:r.decode(c),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:n}=Vt;Fe(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}};const Ht=(()=>(Object.freeze(Vt._tlv),Object.freeze(Vt._int),Object.freeze(Vt)))();var Ut=(e,t)=>(e+(e>=0?t:-t)/Yt)/t;function Wt(e,t,n){je(`scalar`,e,qt,n);let[[r,i],[a,o]]=t,s=Ut(o*e,n),c=Ut(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<qt,f=u<qt;d&&(l=-l),f&&(u=-u);let p=Ne(Math.ceil(Me(n)/2))+Jt;if(l<qt||l>=p||u<qt||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Gt(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Kt(e,t){Fe(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return ve(n.lowS,`lowS`),ve(n.prehash,`prehash`),n.format!==void 0&&Gt(n.format),n}var qt=BigInt(0),Jt=BigInt(1),Yt=BigInt(2),Xt=BigInt(3),Zt=BigInt(4);function Qt(e,t={}){let n=It(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;Fe(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l,clearCofactor:u,isTorsionFree:d,fromBytes:f,toBytes:p}=t,m=t.randomBytes===void 0?me:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let h=c?{beta:c.beta,basises:c.basises.map(e=>[...e])}:void 0,g=en(r,i);function _(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function v(e,t,n){if(t.is0()){if(!l)throw Error(`bad point: ZERO`);return Uint8Array.of(0)}let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);return ve(n,`isCompressed`),n?(_(),de($t(!r.isOdd(a)),o)):de(Uint8Array.of(4),o,r.toBytes(a))}function y(e){N(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=g,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=w(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}_();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}else if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!T(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}else throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let b=p===void 0?v:p,x=f===void 0?y:f,S=r.mul(a.b,Xt),C=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function w(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function T(e,t){let n=r.sqr(t),i=w(e);return r.eql(n,i)}if(!T(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let E=r.mul(r.pow(a.a,Xt),Zt),D=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(E,D)))throw Error(`bad curve params: a or b`);function O(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return typeof t==`object`&&t?r.create(t):t}function k(e){if(!(e instanceof M))throw Error(`Weierstrass Point expected`)}function A(e){if(!h||!h.basises)throw Error(`no endo`);return Wt(e,h.basises,i.ORDER)}function ee(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(h){let{k1neg:i,k1:o,k2neg:s,k2:c}=A(a),l=new M(r.mul(n.X,h.beta),n.Y,n.Z);e.push(i?n.negate():n,s?l.negate():l),t.push(o,c)}else e.push(n),t.push(a)}let j=new WeakSet;class M{static BASE=new M(a.Gx,a.Gy,r.ONE);static ZERO=new M(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=O(`x`,e),this.Y=O(`y`,t,!0),this.Z=O(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof M)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?M.ZERO:new M(t,n,r.ONE)}static fromBytes(e){let t=M.fromAffine(x(N(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return M.fromBytes(fe(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return ne.setWindowSize(this,e),t||this.multiply(Xt),this}assertValidity(){let e=this;if(e.is0()){if(l&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(j.has(e))return;let{x:t,y:n}=e.toAffine();if(!r.isValid(t)||!r.isValid(n))throw Error(`bad point: x or y not field elements`);if(!T(t,n))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);j.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){k(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new M(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=C(o),a=r.mul(S,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(S,o),l=C(l),u=r.sub(s,l),u=C(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new M(i,a,o)}add(e){k(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=C(h),c=r.mul(S,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=C(p),h=r.mul(S,h),f=r.add(f,p),p=r.sub(d,p),p=C(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new M(c,l,u)}subtract(e){return k(e),this.add(e.negate())}is0(){return this.equals(M.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=ne.mulSecret(this,e,o,te);return te([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===qt||t.is0())return M.ZERO;if(n===Jt)return t;if(ne.hasWindowSize(this))return ne.mulUnsafe(t,n,te);let r=[],a=[];return ee(r,a,t,n),Pt(M,r,a)}mulAddUnsafe(e,t,n){k(t);let r=[],i=[];return ee(r,i,this,e),ee(r,i,t,n),Pt(M,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){return o===Jt?!0:d?d(M,this):ne.mulUnsafe(this,s).is0()}clearCofactor(){return o===Jt?this:u?u(M,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===Jt?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return ve(e,`isCompressed`),this.assertValidity(),b(M,this,e)}toHex(e=!0){return ue(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let te=e=>xt(M,e),ne=new Nt(M,m);return ne.bits>=6&&M.BASE.precompute(6),Object.freeze(M.prototype),Object.freeze(M),M}function $t(e){return Uint8Array.of(e?2:3)}function en(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function tn(e,t={}){bt(e);let{Fn:n}=e,r=t.randomBytes===void 0?me:t.randomBytes,i=Object.assign(en(e.Fp,n),{seed:Math.max(dt(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!e.fromBytes(t).is0()}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,ft(N(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!pe(e))return;let s=N(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t),o=e.fromBytes(r);if(o.is0())throw Error(`invalid public key: point at infinity`);return o.multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=Lt(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function nn(e,t,n={}){bt(e);let r=t;h(r),Fe(n,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let i=Object.assign({},n),a=i.randomBytes===void 0?me:i.randomBytes,o=i.hmac===void 0?(e,t)=>zt(r,e,t):i.hmac,{Fp:s,Fn:c}=e,{ORDER:l,BITS:u}=c,d=dt(l),f=wt(a,d),{keygen:p,getPublicKey:m,getSharedSecret:g,utils:_,lengths:v}=tn(e,i),y={prehash:!0,lowS:typeof i.lowS==`boolean`?i.lowS:!0,format:`compact`,extraEntropy:!1},b=l*Yt+Jt<s.ORDER;function x(e){return e>l>>Jt}function S(e,t){if(!c.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function C(){if(!s.isOdd)throw Error(`Field doesn't support isOdd`)}function w(e,t,n){return C(),(e===n?0:2)|Number(s.isOdd(t))}function T(){if(b)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function E(e,t){Gt(t);let n=v.signature;return N(e,t===`compact`?n:t===`recovered`?n+1:void 0)}class D{r;s;recovery;constructor(e,t,n){if(this.r=S(`r`,e),this.s=S(`s`,t),n!=null){if(T(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=y.format){E(e,t);let n;if(t===`der`){if(e.length>2*c.BYTES+16)throw new Ht.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=Ht.toSig(N(e),c.BYTES+1);return new D(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=v.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new D(c.fromBytes(i),c.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(fe(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new D(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+l:n;if(!s.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=s.toBytes(a),u=e.fromBytes(de($t((i&1)==0),o)),d=c.inv(a),f=k(N(t,void 0,`msgHash`)),p=c.create(-f*d),m=c.create(r*d),h=e.BASE.mulAddUnsafe(p,u,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return x(this.s)}toBytes(e=y.format){if(Gt(e),e===`der`)return fe(Ht.hexFromSig(this));let{r:t,s:n}=this,r=c.toBytes(t),i=c.toBytes(n);return e===`recovered`?(T(),de(Uint8Array.of(this.assertRecovery()),r,i)):de(r,i)}toHex(e){return ue(this.toBytes(e))}}Object.freeze(D.prototype),Object.freeze(D);let O=i.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Ce(e),n=e.length*8-u;return n>0?t>>BigInt(n):t}:i.bits2int,k=i.bits2int_modN===void 0?function(e){return c.create(O(e))}:i.bits2int_modN,A=Ne(u);function ee(e){return je(`num < 2^`+u,e,qt,A),c.toBytes(e)}function j(e,t){return N(e,void 0,`message`),t?N(r(e),void 0,`prehashed message`):e}function M(t,n,r){let{lowS:i,prehash:o,extraEntropy:s}=Kt(r,y);t=j(t,o);let u=k(t),p=c.fromBytes(n);if(!c.isValidNot0(p))throw Error(`invalid private key`);let m=[ee(p),ee(u)];if(s!=null&&s!==!1){let e=s===!0?a(v.secretKey):s;m.push(N(e,void 0,`extraEntropy`))}let h=de(...m),g=u;function _(t){let n=O(t);if(!c.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=c.create(r.x);if(a===qt)return;let o;if(f!==void 0){let e=Ce(ft(f(d),l)),t=c.inv(c.mul(e,n)),r=c.mul(e,g),i=c.mul(e,p);o=c.create(t*c.create(r+i*a))}else{let e=Je(n,l);o=c.create(e*c.create(g+a*p))}if(o===qt)return;let s=w(r.x,r.y,a),u=o;return i&&x(o)&&(u=c.neg(o),s^=1),new D(a,u,b?void 0:s)}return{seed:h,k2sig:_}}function te(e,t,n={}){let{seed:i,k2sig:a}=M(e,t,n);return Pe(r.outputLen,c.BYTES,o)(i,a).toBytes(n.format)}function ne(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Kt(i,y);if(r=N(r,void 0,`publicKey`),n=j(n,o),!pe(t)){let e=t instanceof D?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}E(t,s);try{let i=D.fromBytes(t,s),o=e.fromBytes(r);if(o.is0()||a&&i.hasHighS())return!1;let{r:l,s:u}=i,d=k(n),f=c.inv(u),p=c.create(d*f),m=c.create(l*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(c.create(g.x)!==l||s===`recovered`&&i.recovery!==w(g.x,g.y,l))}catch{return!1}}function re(e,t,n={}){let{prehash:r}=Kt(n,y);return t=j(t,r),D.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:p,getPublicKey:m,getSharedSecret:g,utils:_,lengths:v,Point:e,sign:te,verify:ne,recoverPublicKey:re,Signature:D,hash:r})}var rn=(()=>BigInt(2**32-1))(),an=BigInt(32);function on(e,t=!1){return t?{h:Number(e&rn),l:Number(e>>an&rn)}:{h:Number(e>>an&rn)|0,l:Number(e&rn)|0}}function sn(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=on(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var cn=e=>e/2**32|0,ln=e=>e>>>0;function un(e,t,n,r){let i=cn(n),a=ln(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function dn(e,t,n){return e&t^~e&n}function fn(e,t,n){return e&t^e&n^t&n}var pn=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=S(this.buffer)}update(e){v(this),m(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=S(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0;continue}n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){v(this),y(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),un(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:S(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}};const mn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var hn=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),gn=new Uint32Array(64),_n=class extends pn{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)gn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=gn[e-15],n=gn[e-2],r=C(t,7)^C(t,18)^t>>>3;gn[e]=(C(n,17)^C(n,19)^n>>>10)+gn[e-7]+r+gn[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=C(o,6)^C(o,11)^C(o,25),u=l+t+dn(o,s,c)+hn[e]+gn[e]|0,d=(C(n,2)^C(n,13)^C(n,22))+fn(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){x(gn)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),x(this.buffer)}},vn=class extends _n{constructor(){super(32,mn)}};const yn=ne(()=>new vn,ie(1));function bn(e,t=`n`){if(typeof e!=`number`)throw TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);return e}function xn(e){return bn(e,`x`),(e&e-1)==0&&e!==0}function Sn(e,t){if(bn(e),typeof t!=`number`)throw TypeError(`"bits" expected number, got type=`+typeof t);if(!Number.isSafeInteger(t)||t<0||t>32)throw Error(`expected integer 0 <= bits <= 32, got ${t}`);let n=0;for(let r=0;r<t;r++,e>>>=1)n=n<<1|e&1;return n>>>0}function Cn(e){return bn(e),31-Math.clz32(e)}function wn(e){if(!e||typeof e!=`object`||typeof e.length!=`number`)throw TypeError(`"values" expected array-like, got type=`+typeof e);let t=e.length;if(!xn(t))throw Error(`expected positive power-of-two length, got `+t);let n=Cn(t);for(let r=0;r<t;r++){let t=Sn(r,n);if(r<t){let n=e[r];e[r]=e[t],e[t]=n}}return e}const Tn=(e,t)=>{Fe(t,{N:`number`,roots:`object`,dit:`boolean`},{invertButterflies:`boolean`,skipStages:`number`,brp:`boolean`},`coreOpts`);let{N:n,roots:r,dit:i,invertButterflies:a=!1,skipStages:o=0,brp:s=!0}=t;bn(n,`coreOpts.N`);let c=Cn(n);if(!xn(n))throw Error(`FFT: Polynomial size should be power of two`);bn(o,`coreOpts.skipStages`);let l=c===0?0:c-1;if(o>l)throw Error(`FFT: wrong skipStages: expected 0 <= skipStages <= ${l}`);if(r.length!==n)throw Error(`FFT: wrong roots length: expected ${n}, got ${r.length}`);let u=i!==a;return t=>{if(t.length!==n)throw Error(`FFT: wrong Polynomial length`);i&&s&&wn(t);for(let s=0,l=1;s<c-o;s++){let d=i?s+1+o:c-s,f=1<<d,p=f>>1,m=n>>d;for(let o=0;o<n;o+=f)for(let s=0,c=l++;s<p;s++){let l=a?i?n-c:c:s*m,d=o+s,f=o+s+p,h=r[l],g=t[f],_=t[d];if(u){let n=e.mul(g,h);t[d]=e.add(_,n),t[f]=e.sub(_,n)}else a?(t[d]=e.add(g,_),t[f]=e.mul(e.sub(g,_),h)):(t[d]=e.add(_,g),t[f]=e.mul(e.sub(_,g),h))}}return!i&&s&&wn(t),t}},En=nn(Qt((()=>({p:BigInt(`0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff`),n:BigInt(`0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551`),h:BigInt(1),a:BigInt(`0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc`),b:BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`),Gx:BigInt(`0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296`),Gy:BigInt(`0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5`)}))()),yn);var Dn=BigInt(0),On=BigInt(1),kn=BigInt(2),An=BigInt(7),jn=BigInt(256),Mn=BigInt(113),Nn=[],Pn=[],Fn=[];for(let e=0,t=On,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Nn.push(2*(5*r+n)),Pn.push((e+1)*(e+2)/2%64);let i=Dn;for(let e=0;e<7;e++)t=(t<<On^(t>>An)*Mn)%jn,t&kn&&(i^=On<<(On<<BigInt(e))-On);Fn.push(i)}var In=sn(Fn,!0),Ln=In[0],Rn=In[1],zn=(e,t,n)=>e<<n|t>>>32-n,Bn=(e,t,n)=>t<<n|e>>>32-n,Vn=(e,t,n)=>t<<n-32|e>>>64-n,Hn=(e,t,n)=>e<<n-32|t>>>64-n,Un=(e,t,n)=>n>32?Vn(e,t,n):zn(e,t,n),Wn=(e,t,n)=>n>32?Hn(e,t,n):Bn(e,t,n),Gn=new Uint32Array(10);function Kn(e,t=24){if(!(e instanceof Uint32Array))throw TypeError(`"s" expected Uint32Array(50), got type=`+typeof e);if(e.length!==50)throw RangeError(`"s" expected Uint32Array(50), got length=`+e.length);if(f(t,`rounds`),t<1||t>24)throw Error(`"rounds" expected integer 1..24`);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)Gn[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,r=(t+2)%10,i=Gn[r],a=Gn[r+1],o=Un(i,a,1)^Gn[n],s=Wn(i,a,1)^Gn[n+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=s}let t=e[2],r=e[3];for(let n=0;n<24;n++){let i=Pn[n],a=Un(t,r,i),o=Wn(t,r,i),s=Nn[n];t=e[s],r=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3];e[t]^=~e[t+2]&e[t+4],e[t+1]^=~e[t+3]&e[t+5],e[t+2]^=~e[t+4]&e[t+6],e[t+3]^=~e[t+5]&e[t+7],e[t+4]^=~e[t+6]&e[t+8],e[t+5]^=~e[t+7]&e[t+9],e[t+6]^=~e[t+8]&n,e[t+7]^=~e[t+9]&r,e[t+8]^=~n&i,e[t+9]^=~r&a}e[0]^=Ln[n],e[1]^=Rn[n]}x(Gn)}var qn=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,t,n,r=!1,i=24){if(f(e,`blockLen`),f(t,`suffix`),f(i,`rounds`),p(r,`enableXOF`),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.canXOF=r,this.rounds=i,f(n,`outputLen`),!(0<e&&e<200))throw Error(`"blockLen" must be 1..199`);this.state=new Uint8Array(200),this.state32=b(this.state)}clone(){return this._cloneInto()}keccak(){D(this.state32),Kn(this.state32,this.rounds),D(this.state32),this.posOut=0,this.pos=0}update(e){v(this),m(e);let{blockLen:t,state:n,state32:r}=this,i=e.length,a=t%4==0&&e.byteOffset%4==0,o=t/4,s=a&&i>=t?b(e):void 0;for(let a=0;a<i;){if(s!==void 0&&this.pos===0&&a%4==0&&i-a>=t){for(let e=0,t=a/4;e<o;e++)r[e]^=s[t+e];a+=t,this.pos=t,this.keccak();continue}let c=Math.min(t-this.pos,i-a);for(let t=0;t<c;t++)n[this.pos++]^=e[a++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){v(this,!1),m(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not enabled`);return this.writeInto(e)}xof(e){return f(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(y(e,this),this.finished)throw Error(`digest() was already called`);this.writeInto(e.length===this.outputLen?e:e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,x(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}},Jn=(e,t,n,r={})=>ne(()=>new qn(t,e,n),r);const Yn=Jn(6,136,32,ie(8)),Xn=Jn(6,72,64,ie(10));var Zn=(e,t,n,r={})=>ne((r={})=>(r=te({},r),new qn(t,e,r.dkLen===void 0?n:r.dkLen,!0)),r);const Qn=Zn(31,168,16,ie(11)),$n=Zn(31,136,32,ie(12));var er=m;const tr=re;function nr(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}function rr(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function ir(e,t){if(e=m(e),t=m(t),e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function ar(e){return new Uint8Array(m(e))}function or(e,...t){let n=e=>typeof e==`number`?e:e.bytesLen,r=t.reduce((e,t)=>e+n(t),0);return{bytesLen:r,encode:i=>{let a=new Uint8Array(r);for(let r=0,o=0;r<t.length;r++){let s=t[r],c=n(s),l=typeof s==`number`?i[r]:s.encode(i[r]);m(l,c,e),a.set(l,o),typeof s!=`number`&&l.fill(0),o+=c}return a},decode:i=>{m(i,r,e);let a=[];for(let e of t){let t=n(e),r=i.subarray(0,t);a.push(typeof e==`number`?r:e.decode(r)),i=i.subarray(t)}return a}}}function sr(e,t){let n=e,r=t*n.bytesLen;return{bytesLen:r,encode:e=>{let i=nr(e,`u`);if(i.length!==t)throw RangeError(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);let a=new Uint8Array(r);for(let e=0,t=0;e<i.length;e++){let r=n.encode(i[e]);a.set(r,t),r.fill(0),t+=r.length}return a},decode:e=>{m(e,r);let t=[];for(let r=0;r<e.length;r+=n.bytesLen)t.push(n.decode(e.subarray(r,r+n.bytesLen)));return t}}}function L(...e){for(let t of e)if(Array.isArray(t))for(let e of t)e.fill(0);else t.fill(0)}function cr(e){if(f(e,`bits`),e>32)throw RangeError(`"bits" expected <= 32, got `+e);return e===32?4294967295:~(-1<<e)>>>0}const lr=e=>{let{newPoly:t,N:n,Q:r,F:i,ROOT_OF_UNITY:a,brvBits:o,isKyber:s}=e,c=(e,t=r)=>{let n=e%t|0;return(n>=0?n|0:t+n|0)|0},l=(e,t=r)=>{let n=c(e,t)|0;return(n>t>>1?n-t|0:n)|0};function u(){let e=t(n);for(let t=0;t<n;t++){let n=Sn(t,o),i=BigInt(a)**BigInt(n)%BigInt(r);e[t]=Number(i)|0}return e}let d=u(),f=e=>{throw Error(`not implemented`)},p=s?{add:(e,t)=>{let n=e+t|0;return n>=r?n-r|0:n},sub:(e,t)=>{let n=e-t|0;return n<0?n+r|0:n},mul:(e,t)=>c((e|0)*(t|0))|0,inv:f}:{add:(e,t)=>c((e|0)+(t|0))|0,sub:(e,t)=>c((e|0)-(t|0))|0,mul:(e,t)=>c((e|0)*(t|0))|0,inv:f},m={N:n,roots:d,invertButterflies:!0,skipStages:s?1:0,brp:!1},h=Tn(p,{dit:!1,...m}),g=Tn(p,{dit:!0,...m}),_={encode:e=>h(e),decode:e=>{g(e);for(let t=0;t<e.length;t++)e[t]=c(i*e[t]);return e}};return{mod:c,smod:l,nttZetas:d,NTT:{encode:e=>_.encode(e),decode:e=>_.decode(e)},bitsCoder:(e,r)=>{for(let t=0,r=0;t<n;t++)r+=e,r>32&&cr(r),r%=8;let i=cr(e),a=n/8*e;return{bytesLen:a,encode:t=>{let n=t,o=new Uint8Array(a);for(let t=0,a=0,s=0,c=0;t<n.length;t++)for(a|=(r.encode(n[t])&i)<<s,s+=e;s>=8;s-=8,a>>=8)o[c++]=a&255;return o},decode:a=>{let o=t(n);for(let t=0,n=0,s=0,c=0;t<a.length;t++)for(n|=a[t]<<s,s+=8;s>=e;s-=e,n>>=e)o[c++]=r.decode(n&i);return o}}}}},ur=(e=>(t,n)=>{n||=e.blockLen;let r=new Uint8Array(t.length+2);r.set(t);let i=t.length,a=new Uint8Array(n),o=e.create({}),s=0,c=0;return{stats:()=>({calls:s,xofs:c}),get:(t,n)=>(r[i+0]=t,r[i+1]=n,o.destroy(),o=e.create({}).update(r),s++,()=>(c++,o.xofInto(a))),clean:()=>{o.destroy(),L(a,r)}}})(Qn);var R=256,z=3329,B=lr({N:R,Q:z,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0});const dr=(()=>Object.freeze({512:Object.freeze({N:R,Q:z,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128}),768:Object.freeze({N:R,Q:z,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192}),1024:Object.freeze({N:R,Q:z,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256})}))();var fr=e=>{if(e>=12)return{encode:e=>e,decode:e=>e>=z?e-z:e};let t=2**(e-1);return{encode:t=>((t<<e)+z/2)/z,decode:n=>n*z+t>>>e}},pr=e=>B.bitsCoder(e,e===12?{encode:e=>e,decode:e=>e>=z?e-z:e}:{encode:e=>e,decode:e=>e}),mr=e=>e===12?pr(12):B.bitsCoder(e,fr(e));function hr(e,t){let n=e,r=t;for(let e=0;e<R;e++){let t=n[e]+r[e];n[e]=t>=z?t-z:t}}function gr(e,t){let n=e,r=t;for(let e=0;e<R;e++){let t=n[e]-r[e];n[e]=t<0?t+z:t}}function _r(e,t,n,r,i){return{c0:B.mod(B.mod(t*r)*i+e*n),c1:B.mod(e*r+t*n)}}function vr(e,t){let n=e,r=t;for(let e=0;e<R/2;e++){let t=B.nttZetas[64+(e>>1)];e&1&&(t=-t);let{c0:i,c1:a}=_r(n[2*e+0],n[2*e+1],r[2*e+0],r[2*e+1],t);n[2*e+0]=i,n[2*e+1]=a}return n}function yr(e){let t=e,n=new Uint16Array(R);for(let e=0;e<R;){let r=t();if(r.length%3)throw Error(`SampleNTT: unaligned block`);for(let t=0;e<R&&t+3<=r.length;t+=3){let i=(r[t+0]>>0|r[t+1]<<8)&4095,a=(r[t+1]>>4|r[t+2]<<4)&4095;i<z&&(n[e++]=i),e<R&&a<z&&(n[e++]=a)}}return n}var br=(e,t)=>{let n=new Uint16Array(R),r=b(e);D(r);let i=0;for(let e=0,a=0,o=0,s=0;e<r.length;e++){let c=r[e];for(let e=0;e<32;e++)o+=c&1,c>>=1,i+=1,i===t?(s=o,o=0):i===2*t&&(n[a++]=B.mod(s-o),o=0,i=0)}if(D(r),i)throw Error(`sampleCBD: leftover bits: ${i}`);return n};function xr(e,t,n,r){return br(e(r*R/4,t,n),r)}var Sr=e=>{let{K:t,PRF:n,XOF:r,HASH512:i,ETA1:a,ETA2:o,du:s,dv:c}=e,l=mr(1),u=mr(c),d=mr(s),f=or(`publicKey`,sr(mr(12),t),32),p=sr(mr(12),t),m=or(`ciphertext`,sr(d,t),u),h=or(`seed`,32,32),g=(e,r,i,s)=>{let c=[];for(let e=0;e<t;e++)c.push(B.NTT.encode(xr(n,s,e,a)));let u=new Uint16Array(R),d=[];for(let i=0;i<t;i++){let a=xr(n,s,t+i,o),l=new Uint16Array(R);for(let e=0;e<t;e++)hr(l,vr(r(i,e),c[e]));hr(a,B.NTT.decode(l)),d.push(a),hr(u,vr(e[i],c[i])),L(l)}let f=xr(n,s,2*t,o);hr(f,B.NTT.decode(u));let p=l.decode(i);return hr(p,f),L(e,c,u,f),m.encode([d,p])};return{secretCoder:p,lengths:{secretKey:p.bytesLen,publicKey:f.bytesLen,cipherText:m.bytesLen},keygen:e=>{er(e,32,`seed`);let o=new Uint8Array(33);o.set(e),o[32]=t;let s=i(o),[c,l]=h.decode(s),u=[],d=[];for(let e=0;e<t;e++)u.push(B.NTT.encode(xr(n,l,e,a)));let m=r(c);for(let e=0;e<t;e++){let r=B.NTT.encode(xr(n,l,t+e,a));for(let n=0;n<t;n++)hr(r,vr(yr(m.get(n,e)),u[n]));d.push(r)}m.clean();let g={publicKey:f.encode([d,c]),secretKey:p.encode(u)};return L(c,l,u,d,o,s),g},encrypt:(e,t,n)=>{let[i,a]=f.decode(e),o=r(a),s=g(i,(e,t)=>yr(o.get(e,t)),t,n);return o.clean(),s},prepare:e=>{let[n,i]=f.decode(e),a=r(i),o=[];for(let e=0;e<t;e++)for(let n=0;n<t;n++)o.push(yr(a.get(e,n)));return a.clean(),{encrypt:(e,r)=>g(n.map(e=>e.slice()),(e,n)=>o[e*t+n].slice(),e,r),clean:()=>L(n,o)}},decrypt:(e,n)=>{let[r,i]=m.decode(e),a=p.decode(n),o=new Uint16Array(R);for(let e=0;e<t;e++)hr(o,vr(a[e],B.NTT.encode(r[e])));gr(i,B.NTT.decode(o));let s=l.encode(i);return L(o,a,r,i),s}}};function Cr(e){let t=e,n=Sr(t),{HASH256:r,HASH512:i,KDF:a}=t,{secretCoder:o,lengths:s}=n,c=or(`secretKey`,s.secretKey,s.publicKey,32,32),l=(e,n)=>{let r=e.subarray(0,384*t.K),i=o.encode(o.decode(ar(r))),a=ir(i,r);if(L(i),!a)throw Error(`ML-KEM.${n}: wrong publicKey modulus`)},u=Object.freeze({...s,seed:64,msg:32,msgRand:32,secretKey:c.bytesLen});return Object.freeze({info:Object.freeze({type:`ml-kem`}),lengths:u,keygen:e=>{let t=e===void 0,i=t?tr(64):e,a,o;try{er(i,64,`seed`);let e=n.keygen(i.subarray(0,32)),t=e.publicKey;return a=e.secretKey,o=r(t),{publicKey:t,secretKey:c.encode([a,t,o,i.subarray(32)])}}finally{a!==void 0&&L(a),o!==void 0&&L(o),t&&L(i)}},getPublicKey:e=>{let[t,n,r,i]=c.decode(e);return Uint8Array.from(n)},encapsulate:(e,t)=>{let a=t===void 0,o=a?tr(32):t,c;try{return er(e,s.publicKey,`publicKey`),er(o,32,`message`),l(e,`encapsulate`),c=i.create().update(o).update(r(e)).digest(),{cipherText:n.encrypt(e,o,c.subarray(32,64)),sharedSecret:c.subarray(0,32)}}finally{c!==void 0&&L(c.subarray(32)),a&&L(o)}},decapsulate:(e,t)=>{er(t,c.bytesLen,`secretKey`),er(e,s.cipherText,`cipherText`);let o=c.bytesLen-96,l=o+32;if(!ir(r(t.subarray(o/2,l)),t.subarray(l,l+32)))throw Error(`invalid secretKey: hash check failed`);let[u,d,f,p]=c.decode(t),m=n.decrypt(e,u),h=i.create().update(m).update(f).digest(),g=h.subarray(0,32),_=n.encrypt(d,m,h.subarray(32,64)),v=ir(e,_),y=a.create({dkLen:32}).update(p).update(e).digest();return L(m,_,h.subarray(32),v?y:g),v?g:y},prepare:e=>{er(e,s.publicKey,`publicKey`),l(e,`prepare`);let t=ar(e),o=r(t),u=n.prepare(t);return Object.freeze({publicKey:t,encapsulate:e=>{let t=e===void 0,n=t?tr(32):e,r;try{return er(n,32,`message`),r=i.create().update(n).update(o).digest(),{cipherText:u.encrypt(n,r.subarray(32,64)),sharedSecret:r.subarray(0,32)}}finally{r!==void 0&&L(r.subarray(32)),t&&L(n)}},decapsulate:(e,r)=>{er(r,c.bytesLen,`secretKey`),er(e,s.cipherText,`cipherText`);let[l,d,f,p]=c.decode(r);if(!ir(d,t)||!ir(f,o))throw Error(`ML-KEM.decapsulate: secretKey does not match prepared publicKey`);let m=n.decrypt(e,l),h=i.create().update(m).update(o).digest(),g=h.subarray(0,32),_=u.encrypt(m,h.subarray(32,64)),v=ir(e,_),y=a.create({dkLen:32}).update(p).update(e).digest();return L(m,_,h.subarray(32),v?y:g),v?g:y},clean:u.clean})}})}function wr(e,t,n){return $n.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}var Tr=(()=>({HASH256:Yn,HASH512:Xn,KDF:$n,XOF:ur,PRF:wr}))(),Er=e=>Cr({...Tr,...e});const Dr=(()=>Er(dr[768]))();var Or=(e,t)=>{let n=rr(e,t);return rr(n.lengths,`${t}.lengths`),le(n.keygen,`${t}.keygen`),le(n.getPublicKey,`${t}.getPublicKey`),le(n.encapsulate,`${t}.encapsulate`),le(n.decapsulate,`${t}.decapsulate`),n};function kr(e,t){let n=f(e,t);if(n===0)throw RangeError(`"${t}" expected integer greater than 0, got 0`);return n}function Ar(e,t){let n=or(t,...e.map(e=>{if(typeof e.lengths[t]!=`number`)throw Error(`wrong length: `+t);return kr(e.lengths[t],t)}));return kr(n.bytesLen,t),n}function jr(e,t,...n){let r=t,i=n,a=Ar(i,`seed`),o=Ar(i,`publicKey`),s=kr(e===void 0?a.bytesLen:e,`realSeedLen`);function c(e){m(e,s);let t=r(e,a.bytesLen),n=t.buffer===e.buffer?ar(t):t,o=[],c=[],l=[],u=[],d=!1;try{for(let e of a.decode(n))o.push(ar(e));for(let e=0;e<i.length;e++){let t=i[e].keygen(o[e]);c.push(t.secretKey),l.push(ar(t.secretKey)),u.push(t.publicKey)}return d=!0,{secretKey:l,publicKey:u}}finally{L(n,o,c),d||L(l)}}let l=e=>{let t=e===void 0?tr(s):ar(e),n;try{let{publicKey:e,secretKey:r}=c(t);try{n={secretKey:t,publicKey:o.encode(e)}}finally{L(e,r)}return n}finally{n||L(t)}};return{info:{lengths:{seed:s,publicKey:o.bytesLen,secretKey:s}},getPublicKey:e=>{let t=l(e);return L(t.secretKey),t.publicKey},keygen:l,expandDecapsulationKey:c,realSeedLen:s}}function Mr(e,t,n,r,...i){if(e!==void 0&&kr(e,`realSeedLen`),t!==void 0&&kr(t,`realMsgLen`),typeof n!=`function`)throw TypeError(`"expandSeed" expected function, got type=`+typeof n);if(typeof r!=`function`)throw TypeError(`"combiner" expected function, got type=`+typeof r);let a=r,o=i;if(o.length===0)throw RangeError(`combineKEMS requires at least one KEM`);for(let e=0;e<o.length;e++)Or(o[e],`kems[${e}]`);let s=jr(e,n,...o),c=Ar(o,`cipherText`),l=Ar(o,`publicKey`),d=Ar(o,`msg`),f=kr(t===void 0?d.bytesLen:t,`realMsgLen`),p=Object.freeze({...s.info.lengths,msg:f,msgRand:d.bytesLen,cipherText:c.bytesLen}),h=(e,t,n)=>{let r=a(e,t,n);try{return ar(m(r,f,`sharedSecret`))}catch(n){if(u(r)){let n=e=>r.buffer===e.buffer&&r.byteOffset<e.byteOffset+e.byteLength&&e.byteOffset<r.byteOffset+r.byteLength;e.some(n)||t.some(n)||L(r)}throw n}};return Object.freeze({lengths:p,getPublicKey:s.getPublicKey,keygen:s.keygen,encapsulate(e,t=tr(d.bytesLen)){let n=l.decode(e),r=d.decode(t),i=[],a=[];try{for(let e=0;e<o.length;e++){let t=o[e].encapsulate(n[e],r[e]);i.push(t.sharedSecret),a.push(t.cipherText)}let e=c.encode(a);return{sharedSecret:h(n,a,i),cipherText:e}}finally{L(i,a)}},decapsulate(e,t){let n=c.decode(e),{publicKey:r,secretKey:i}=s.expandDecapsulationKey(t),a=[];try{for(let e=0;e<o.length;e++)a.push(o[e].decapsulate(n[e],i[e]));return h(r,n,a)}finally{L(i,a)}}})}function Nr(e,t,n,r){let i=e.Point.Fn;if(!i)throw Error(`no Point.Fn`);function a(n){let r;for(let e=0,a=t;;e=a,a+=t){if(a>n.length)throw Error(`rejection sampling failed`);if(r=i.fromBytes(n.subarray(e,a),!0),i.isValidNot0(r))break}let a=i.toBytes(i.create(r));return{secretKey:a,publicKey:e.getPublicKey(a,!1)}}let o=(t,n)=>e.getSharedSecret(n,t).subarray(1);return{lengths:{secretKey:t,publicKey:n,seed:r,msg:r,cipherText:n},keygen(e=tr(r)){return m(e,r,`seed`),a(e)},getPublicKey(t){return e.getPublicKey(t,!1)},encapsulate(t,n=tr(r)){m(n,r,`rand`);let i;try{return i=a(n).secretKey,{sharedSecret:o(t,i),cipherText:e.getPublicKey(i,!1)}}finally{i&&L(i)}},decapsulate:o}}function Pr(e,t,n,r){let{secretKey:i,publicKeyUncompressed:a}=n.lengths;if(!i||!a)throw Error(`wrong curve`);let o=Nr(n,i,a,r),s=64+r;return Mr(32,32,e=>(m(e,32),$n(e,{dkLen:s})),(t,n,r)=>Yn(de(r[0],r[1],n[1],t[1],Oe(e))),t,o)}const Fr=(()=>Pr(`MLKEM768-P256`,Dr,En,128))();function Ir(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ir(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Lr(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ir(e))&&(r&&(r+=` `),r+=t);return r}var Rr=Lr,zr=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Br=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),Vr=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),Hr=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ur=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Wr=t((e=>{var t=Br().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Gr=t((e=>{var t=Br().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Kr=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),qr=t((e=>{var t=Vr(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Jr=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Yr=t((e=>{var t=Jr();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Xr=t(((e,t)=>{var n=Yr();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Zr=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Qr=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
2
  ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),$r=t((e=>{var t=Zr(),n=Qr();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),ei=t((e=>{var t=Br(),n=qr(),r=Vr(),i=$r(),a=Zr(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),ti=t((e=>{var t=Br(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),ni=t(((e,t)=>{var n=$r();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),ri=t(((e,t)=>{var n=$r(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),ii=t(((e,t)=>{var n=$r();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),ai=t(((e,t)=>{var n=$r(),r=Br();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),oi=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),si=t((e=>{var t=$r(),n=ni(),r=ri(),i=ii(),a=ai(),o=Qr(),s=Br(),c=oi();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
4
  Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),ci=t((e=>{var t=Br(),n=Vr(),r=Hr(),i=Ur(),a=Wr(),o=Gr(),s=Kr(),c=qr(),l=Xr(),u=ei(),d=ti(),f=$r(),p=si();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`