@cedros/login-react 0.0.16 → 0.0.17

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 (28) hide show
  1. package/dist/{EmailRegisterForm-DcpT5LU6.cjs → EmailRegisterForm-CdTuvJmf.cjs} +1 -1
  2. package/dist/{EmailRegisterForm-DcpT5LU6.cjs.map → EmailRegisterForm-CdTuvJmf.cjs.map} +1 -1
  3. package/dist/{EmailRegisterForm-HMcnD3KA.js → EmailRegisterForm-CxOdldks.js} +1 -1
  4. package/dist/{EmailRegisterForm-HMcnD3KA.js.map → EmailRegisterForm-CxOdldks.js.map} +1 -1
  5. package/dist/email-only.cjs +1 -1
  6. package/dist/email-only.js +2 -2
  7. package/dist/google-only.cjs +1 -1
  8. package/dist/google-only.js +1 -1
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +5 -5
  11. package/dist/{shamir-DAa54dMh.cjs → shamir-CiBczzDN.cjs} +1 -1
  12. package/dist/{shamir-DAa54dMh.cjs.map → shamir-CiBczzDN.cjs.map} +1 -1
  13. package/dist/{shamir-CDbZS8I1.js → shamir-OAB2zD9Y.js} +1 -1
  14. package/dist/{shamir-CDbZS8I1.js.map → shamir-OAB2zD9Y.js.map} +1 -1
  15. package/dist/{silentWalletEnroll-CRHzr4Zy.js → silentWalletEnroll-FqXS7Rvh.js} +2 -2
  16. package/dist/{silentWalletEnroll-CRHzr4Zy.js.map → silentWalletEnroll-FqXS7Rvh.js.map} +1 -1
  17. package/dist/{silentWalletEnroll-Dl_oFapH.cjs → silentWalletEnroll-wnkcB9HP.cjs} +1 -1
  18. package/dist/{silentWalletEnroll-Dl_oFapH.cjs.map → silentWalletEnroll-wnkcB9HP.cjs.map} +1 -1
  19. package/dist/solana-only.cjs +1 -1
  20. package/dist/solana-only.js +1 -1
  21. package/dist/useAuth-X6Ds6WW4.cjs +1 -0
  22. package/dist/useAuth-X6Ds6WW4.cjs.map +1 -0
  23. package/dist/{useAuth-D1NSN6yY.js → useAuth-m5Hf89v8.js} +408 -397
  24. package/dist/useAuth-m5Hf89v8.js.map +1 -0
  25. package/package.json +1 -1
  26. package/dist/useAuth-D1NSN6yY.js.map +0 -1
  27. package/dist/useAuth-dS_6wAMp.cjs +0 -1
  28. package/dist/useAuth-dS_6wAMp.cjs.map +0 -1
@@ -1 +1 @@
1
- "use strict";const K=require("./useAuth-dS_6wAMp.cjs");var dt=typeof document<"u"?document.currentScript:null;let F=null,ve=0;const nt=new Map;function Re(){return typeof Worker>"u"?null:(F||(F=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/argon2Worker-Bi5TuQvD.js").href:new URL("assets/argon2Worker-Bi5TuQvD.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:dt&&dt.tagName.toUpperCase()==="SCRIPT"&&dt.src||new URL("shamir-DAa54dMh.cjs",document.baseURI).href),{type:"module"}),F.onmessage=e=>{const{id:t,key:n,error:o}=e.data,r=nt.get(t);if(r){if(nt.delete(t),o){r.reject(new Error(o));return}if(!n){r.reject(new Error("Argon2 worker returned no key"));return}r.resolve(n)}},F.onerror=e=>{const t=e instanceof ErrorEvent?e.error:new Error("Argon2 worker error");for(const n of nt.values())n.reject(t instanceof Error?t:new Error(String(t)));nt.clear(),F?.terminate(),F=null}),F)}async function Ae(e,t,n=K.DEFAULT_KDF_PARAMS){K.validateKdfParams(n);const o=Re();return o?new Promise((r,s)=>{const c=ve++;nt.set(c,{resolve:r,reject:s});const u={id:c,password:e,salt:t,params:n};o.postMessage(u)}):K.argon2Derive(e,t,n)}function ne(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ie(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}),n}var ct={exports:{}};const _e=globalThis.crypto,Ne=globalThis.crypto,Te=globalThis.crypto.subtle,Oe=globalThis.crypto.getRandomValues.bind(globalThis.crypto),Ce=globalThis.crypto.randomUUID.bind(globalThis.crypto),Le=Object.freeze(Object.defineProperty({__proto__:null,default:_e,getRandomValues:Oe,randomUUID:Ce,subtle:Te,webcrypto:Ne},Symbol.toStringTag,{value:"Module"})),Ue=Ie(Le);var He=ct.exports,Dt;function De(){return Dt||(Dt=1,(function(e,t){(function(n,o){e.exports=o(Ue)})(He,function(n){var o,r,s,c,u;function i(){o={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},r={},s=new Array(1024).join("0"),c=!0,u=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function x(){return!!(r&&r.rng&&typeof r.rng=="function")}function y(a,h){var f;if(h===0||h===1)return a;if(h&&h>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return h=h||r.bits,a&&(f=a.length%h),f?(s+a).slice(-(h-f+a.length)):a}function w(a){var h="",f,l;for(l=a.length-1;l>=0;l--){if(f=parseInt(a[l],16),isNaN(f))throw new Error("Invalid hex character.");h=y(f.toString(2),4)+h}return h}function S(a){var h="",f,l;for(a=y(a,4),l=a.length;l>=4;l-=4){if(f=parseInt(a.slice(l-4,l),2),isNaN(f))throw new Error("Invalid binary character.");h=f.toString(16)+h}return h}function I(){return!!(n&&typeof n=="object"&&(typeof n.getRandomValues=="function"||typeof n.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function v(){return typeof n=="object"&&typeof n.randomBytes=="function"}function T(a){function h(b,g,m,B){var A=0,C,L="",q;for(g&&(C=g.length-1);A<C||L.length<b;)q=Math.abs(parseInt(g[A],m)),L=L+y(q.toString(2),B),A++;return L=L.substr(-b),(L.match(/0/g)||[]).length===L.length?null:L}function f(b){var g,m,B,A,C=null;for(B=16,A=4,m=Math.ceil(b/8);C===null;)g=n.randomBytes(m),C=h(b,g.toString("hex"),B,A);return C}function l(b){var g,m,B,A=null;for(m=10,B=32,g=Math.ceil(b/32);A===null;)A=h(b,n.getRandomValues(new Uint32Array(g)),m,B);return A}function d(b){var g,m,B,A,C,L=null;A=10,C=32,m=Math.ceil(b/32),B=123456789,g=new Uint32Array(m);for(var q=0;q<g.length;q++)g[q]=B;for(;L===null;)L=h(b,g,A,C);return L}if(a&&a==="testRandom")return r.typeCSPRNG=a,d;if(a&&a==="nodeCryptoRandomBytes")return r.typeCSPRNG=a,f;if(a&&a==="browserCryptoGetRandomValues")return r.typeCSPRNG=a,l;if(v())return r.typeCSPRNG="nodeCryptoRandomBytes",f;if(I())return r.typeCSPRNG="browserCryptoGetRandomValues",l}function _(a,h){var f=[],l;for(h&&(a=y(a,h)),l=a.length;l>r.bits;l-=r.bits)f.push(parseInt(a.slice(l-r.bits,l),2));return f.push(parseInt(a.slice(0,l),2)),f}function E(a,h){var f=r.logs[a],l=0,d;for(d=h.length-1;d>=0;d--)l!==0?l=r.exps[(f+r.logs[l])%r.maxShares]^h[d]:l=h[d];return l}function R(a,h,f){var l=0,d,b,g,m;for(g=0,d=h.length;g<d;g++)if(f[g]){for(b=r.logs[f[g]],m=0;m<d;m++)if(g!==m){if(a===h[m]){b=-1;break}b=(b+r.logs[a^h[m]]-r.logs[h[g]^h[m]]+r.maxShares)%r.maxShares}l=b===-1?l:l^r.exps[b]}return l}function p(a,h,f){var l=[],d=[a],b,g;for(b=1;b<f;b++)d[b]=parseInt(r.rng(r.bits),2);for(b=1,g=h+1;b<g;b++)l[b-1]={x:b,y:E(b,d)};return l}function N(a,h,f){var l,d,b,g,m;if(h=parseInt(h,r.radix),a=parseInt(a,10)||r.bits,l=a.toString(36).toUpperCase(),b=Math.pow(2,a)-1,g=b.toString(r.radix).length,d=y(h.toString(r.radix),g),typeof h!="number"||h%1!==0||h<1||h>b)throw new Error("Share id must be an integer between 1 and "+b+", inclusive.");return m=l+d+f,m}var O={init:function(a,h){var f=[],l=[],d=1,b,g;if(i(),a&&(typeof a!="number"||a%1!==0||a<o.minBits||a>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(h&&u.indexOf(h)===-1)throw new Error("Invalid RNG type argument : '"+h+"'");for(r.radix=o.radix,r.bits=a||o.bits,r.size=Math.pow(2,r.bits),r.maxShares=r.size-1,b=o.primitivePolynomials[r.bits],g=0;g<r.size;g++)l[g]=d,f[d]=g,d=d<<1,d>=r.size&&(d=d^b,d=d&r.maxShares);if(r.logs=f,r.exps=l,h&&this.setRNG(h),x()||this.setRNG(),!x()||!r.bits||!r.size||!r.maxShares||!r.logs||!r.exps||r.logs.length!==r.size||r.exps.length!==r.size)throw new Error("Initialization failed.")},combine:function(a,h){var f,l,d,b,g="",m,B,A,C=[],L=[];for(h=h||0,f=0,d=a.length;f<d;f++){if(B=this.extractShareComponents(a[f]),m===void 0)m=B.bits;else if(B.bits!==m)throw new Error("Mismatched shares: Different bit settings.");if(r.bits!==m&&this.init(m),C.indexOf(B.id)===-1)for(C.push(B.id),A=_(w(B.data)),l=0,b=A.length;l<b;l++)L[l]=L[l]||[],L[l][C.length-1]=A[l]}for(f=0,d=L.length;f<d;f++)g=y(R(h,C,L[f]).toString(2))+g;return S(h>=1?g:g.slice(g.indexOf("1")+1))},getConfig:function(){var a={};return a.radix=r.radix,a.bits=r.bits,a.maxShares=r.maxShares,a.hasCSPRNG=x(),a.typeCSPRNG=r.typeCSPRNG,a},extractShareComponents:function(a){var h,f,l,d,b={},g,m;if(h=parseInt(a.substr(0,1),36),h&&(typeof h!="number"||h%1!==0||h<o.minBits||h>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(d=Math.pow(2,h)-1,l=(Math.pow(2,h)-1).toString(r.radix).length,g="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+l+"})([a-fA-F0-9]+)$",m=new RegExp(g).exec(a),m&&(f=parseInt(m[2],r.radix)),typeof f!="number"||f%1!==0||f<1||f>d)throw new Error("Invalid share : Share id must be an integer between 1 and "+r.maxShares+", inclusive.");if(m&&m[3])return b.bits=h,b.id=f,b.data=m[3],b;throw new Error("The share data provided is invalid : "+a)},setRNG:function(a){var h="Random number generator is invalid ",f=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(a&&typeof a=="string"&&u.indexOf(a)===-1)throw new Error("Invalid RNG type argument : '"+a+"'");if(a||(a=T()),a&&typeof a=="string"&&(a=T(a)),c){if(a&&typeof a!="function")throw new Error(h+"(Not a function)."+f);if(a&&typeof a(r.bits)!="string")throw new Error(h+"(Output is not a string)."+f);if(a&&!parseInt(a(r.bits),2))throw new Error(h+"(Binary string output not parseable to an Integer)."+f);if(a&&a(r.bits).length>r.bits)throw new Error(h+"(Output length is greater than config.bits)."+f);if(a&&a(r.bits).length<r.bits)throw new Error(h+"(Output length is less than config.bits)."+f)}return r.rng=a,!0},str2hex:function(a,h){var f,l,d="",b,g,m,B;if(typeof a!="string")throw new Error("Input must be a character string.");if(h||(h=o.bytesPerChar),typeof h!="number"||h<1||h>o.maxBytesPerChar||h%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(f=2*h,l=Math.pow(16,f)-1,m=0,B=a.length;m<B;m++){if(g=a[m].charCodeAt(),isNaN(g))throw new Error("Invalid character: "+a[m]);if(g>l)throw b=Math.ceil(Math.log(g+1)/Math.log(256)),new Error("Invalid character code ("+g+"). Maximum allowable is 256^bytes-1 ("+l+"). To convert this character, use at least "+b+" bytes.");d=y(g.toString(16),f)+d}return d},hex2str:function(a,h){var f,l="",d,b;if(typeof a!="string")throw new Error("Input must be a hexadecimal string.");if(h=h||o.bytesPerChar,typeof h!="number"||h%1!==0||h<1||h>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(f=2*h,a=y(a,f),d=0,b=a.length;d<b;d+=f)l=String.fromCharCode(parseInt(a.slice(d,d+f),16))+l;return l},random:function(a){if(typeof a!="number"||a%1!==0||a<2||a>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return S(r.rng(a))},share:function(a,h,f,l){var d,b,g=new Array(h),m=new Array(h),B,A,C;if(l=l||128,typeof a!="string")throw new Error("Secret must be a string.");if(typeof h!="number"||h%1!==0||h<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(h>r.maxShares)throw d=Math.ceil(Math.log(h+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To create "+h+" shares, use at least "+d+" bits.");if(typeof f!="number"||f%1!==0||f<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(f>r.maxShares)throw d=Math.ceil(Math.log(f+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To use a threshold of "+f+", use at least "+d+" bits.");if(f>h)throw new Error("Threshold number of shares was "+f+" but must be less than or equal to the "+h+" shares specified as the total to generate.");if(typeof l!="number"||l%1!==0||l<0||l>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(a="1"+w(a),a=_(a,l),B=0,C=a.length;B<C;B++)for(b=p(a[B],h,f),A=0;A<h;A++)g[A]=g[A]||b[A].x.toString(r.radix),m[A]=y(b[A].y.toString(2))+(m[A]||"");for(B=0;B<h;B++)g[B]=N(r.bits,g[B],S(m[B]));return g},newShare:function(a,h){var f,l;if(a&&typeof a=="string"&&(a=parseInt(a,r.radix)),l=a.toString(r.radix),a&&l&&h&&h[0])return f=this.extractShareComponents(h[0]),N(f.bits,l,this.combine(h,a));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:i,_padLeft:y,_hex2bin:w,_bin2hex:S,_hasCryptoGetRandomValues:I,_hasCryptoRandomBytes:v,_getRNG:T,_isSetRNG:x,_splitNumStringToIntArray:_,_horner:E,_lagrange:R,_getShares:p,_constructPublicShareString:N};return O.init(),O})})(ct)),ct.exports}var qe=De();const re=ne(qe);function oe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function _t(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function D(e,t,n=""){const o=oe(e),r=e?.length,s=t!==void 0;if(!o||s&&r!==t){const c=n&&`"${n}" `,u=s?` of length ${t}`:"",i=o?`length=${r}`:`type=${typeof e}`;throw new Error(c+"expected Uint8Array"+u+", got "+i)}return e}function qt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Me(e,t){D(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function Bt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function bt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const se=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ge=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Nt(e){if(D(e),se)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Ge[e[n]];return t}const V={_0:48,_9:57,A:65,F:70,a:97,f:102};function Mt(e){if(e>=V._0&&e<=V._9)return e-V._0;if(e>=V.A&&e<=V.F)return e-(V.A-10);if(e>=V.a&&e<=V.f)return e-(V.a-10)}function ie(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(se)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const o=new Uint8Array(n);for(let r=0,s=0;r<n;r++,s+=2){const c=Mt(e.charCodeAt(s)),u=Mt(e.charCodeAt(s+1));if(c===void 0||u===void 0){const i=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+i+'" at index '+s)}o[r]=c*16+u}return o}function Gt(...e){let t=0;for(let o=0;o<e.length;o++){const r=e[o];D(r),t+=r.length}const n=new Uint8Array(t);for(let o=0,r=0;o<e.length;o++){const s=e[o];n.set(s,r),r+=s.length}return n}function $e(e,t={}){const n=(r,s)=>e(s).update(r).digest(),o=e(void 0);return n.outputLen=o.outputLen,n.blockLen=o.blockLen,n.create=r=>e(r),Object.assign(n,t),Object.freeze(n)}function Ze(e=32){const t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}const je=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});let Ve=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,n,o,r){this.blockLen=t,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(t),this.view=bt(this.buffer)}update(t){qt(this),D(t);const{view:n,buffer:o,blockLen:r}=this,s=t.length;for(let c=0;c<s;){const u=Math.min(r-this.pos,s-c);if(u===r){const i=bt(t);for(;r<=s-c;c+=r)this.process(i,c);continue}o.set(t.subarray(c,c+u),this.pos),this.pos+=u,c+=u,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){qt(this),Me(t,this),this.finished=!0;const{buffer:n,view:o,blockLen:r,isLE:s}=this;let{pos:c}=this;n[c++]=128,Bt(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(o,0),c=0);for(let w=c;w<r;w++)n[w]=0;o.setBigUint64(r-8,BigInt(this.length*8),s),this.process(o,0);const u=bt(t),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const x=i/4,y=this.get();if(x>y.length)throw new Error("_sha2: outputLen bigger than state");for(let w=0;w<x;w++)u.setUint32(4*w,y[w],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const o=t.slice(0,n);return this.destroy(),o}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:n,buffer:o,length:r,finished:s,destroyed:c,pos:u}=this;return t.destroyed=c,t.finished=s,t.length=r,t.pos=u,r%n&&t.buffer.set(o),t}clone(){return this._cloneInto()}};const M=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ot=BigInt(2**32-1),$t=BigInt(32);function ke(e,t=!1){return t?{h:Number(e&ot),l:Number(e>>$t&ot)}:{h:Number(e>>$t&ot)|0,l:Number(e&ot)|0}}function Ke(e,t=!1){const n=e.length;let o=new Uint32Array(n),r=new Uint32Array(n);for(let s=0;s<n;s++){const{h:c,l:u}=ke(e[s],t);[o[s],r[s]]=[c,u]}return[o,r]}const Zt=(e,t,n)=>e>>>n,jt=(e,t,n)=>e<<32-n|t>>>n,tt=(e,t,n)=>e>>>n|t<<32-n,et=(e,t,n)=>e<<32-n|t>>>n,st=(e,t,n)=>e<<64-n|t>>>n-32,it=(e,t,n)=>e>>>n-32|t<<64-n;function k(e,t,n,o){const r=(t>>>0)+(o>>>0);return{h:e+n+(r/2**32|0)|0,l:r|0}}const Ye=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),ze=(e,t,n,o)=>t+n+o+(e/2**32|0)|0,We=(e,t,n,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Xe=(e,t,n,o,r)=>t+n+o+r+(e/2**32|0)|0,Pe=(e,t,n,o,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0)+(r>>>0),Fe=(e,t,n,o,r,s)=>t+n+o+r+s+(e/2**32|0)|0,ce=Ke(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Qe=ce[0],Je=ce[1],Y=new Uint32Array(80),z=new Uint32Array(80);class tn extends Ve{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:n,Bh:o,Bl:r,Ch:s,Cl:c,Dh:u,Dl:i,Eh:x,El:y,Fh:w,Fl:S,Gh:I,Gl:v,Hh:T,Hl:_}=this;return[t,n,o,r,s,c,u,i,x,y,w,S,I,v,T,_]}set(t,n,o,r,s,c,u,i,x,y,w,S,I,v,T,_){this.Ah=t|0,this.Al=n|0,this.Bh=o|0,this.Bl=r|0,this.Ch=s|0,this.Cl=c|0,this.Dh=u|0,this.Dl=i|0,this.Eh=x|0,this.El=y|0,this.Fh=w|0,this.Fl=S|0,this.Gh=I|0,this.Gl=v|0,this.Hh=T|0,this.Hl=_|0}process(t,n){for(let p=0;p<16;p++,n+=4)Y[p]=t.getUint32(n),z[p]=t.getUint32(n+=4);for(let p=16;p<80;p++){const N=Y[p-15]|0,O=z[p-15]|0,a=tt(N,O,1)^tt(N,O,8)^Zt(N,O,7),h=et(N,O,1)^et(N,O,8)^jt(N,O,7),f=Y[p-2]|0,l=z[p-2]|0,d=tt(f,l,19)^st(f,l,61)^Zt(f,l,6),b=et(f,l,19)^it(f,l,61)^jt(f,l,6),g=We(h,b,z[p-7],z[p-16]),m=Xe(g,a,d,Y[p-7],Y[p-16]);Y[p]=m|0,z[p]=g|0}let{Ah:o,Al:r,Bh:s,Bl:c,Ch:u,Cl:i,Dh:x,Dl:y,Eh:w,El:S,Fh:I,Fl:v,Gh:T,Gl:_,Hh:E,Hl:R}=this;for(let p=0;p<80;p++){const N=tt(w,S,14)^tt(w,S,18)^st(w,S,41),O=et(w,S,14)^et(w,S,18)^it(w,S,41),a=w&I^~w&T,h=S&v^~S&_,f=Pe(R,O,h,Je[p],z[p]),l=Fe(f,E,N,a,Qe[p],Y[p]),d=f|0,b=tt(o,r,28)^st(o,r,34)^st(o,r,39),g=et(o,r,28)^it(o,r,34)^it(o,r,39),m=o&s^o&u^s&u,B=r&c^r&i^c&i;E=T|0,R=_|0,T=I|0,_=v|0,I=w|0,v=S|0,{h:w,l:S}=k(x|0,y|0,l|0,d|0),x=u|0,y=i|0,u=s|0,i=c|0,s=o|0,c=r|0;const A=Ye(d,g,B);o=ze(A,l,b,m),r=A|0}({h:o,l:r}=k(this.Ah|0,this.Al|0,o|0,r|0)),{h:s,l:c}=k(this.Bh|0,this.Bl|0,s|0,c|0),{h:u,l:i}=k(this.Ch|0,this.Cl|0,u|0,i|0),{h:x,l:y}=k(this.Dh|0,this.Dl|0,x|0,y|0),{h:w,l:S}=k(this.Eh|0,this.El|0,w|0,S|0),{h:I,l:v}=k(this.Fh|0,this.Fl|0,I|0,v|0),{h:T,l:_}=k(this.Gh|0,this.Gl|0,T|0,_|0),{h:E,l:R}=k(this.Hh|0,this.Hl|0,E|0,R|0),this.set(o,r,s,c,u,i,x,y,w,S,I,v,T,_,E,R)}roundClean(){Bt(Y,z)}destroy(){Bt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class en extends tn{Ah=M[0]|0;Al=M[1]|0;Bh=M[2]|0;Bl=M[3]|0;Ch=M[4]|0;Cl=M[5]|0;Dh=M[6]|0;Dl=M[7]|0;Eh=M[8]|0;El=M[9]|0;Fh=M[10]|0;Fl=M[11]|0;Gh=M[12]|0;Gl=M[13]|0;Hh=M[14]|0;Hl=M[15]|0;constructor(){super(64)}}const nn=$e(()=>new en,je(3));const fe=BigInt(0),Vt=BigInt(1);function St(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}" `;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function rn(e){if(typeof e=="bigint"){if(!ft(e))throw new Error("positive bigint expected, got "+e)}else _t(e);return e}function ae(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?fe:BigInt("0x"+e)}function on(e){return ae(Nt(e))}function at(e){return ae(Nt(vt(D(e)).reverse()))}function ue(e,t){_t(t),e=rn(e);const n=ie(e.toString(16).padStart(t*2,"0"));if(n.length!==t)throw new Error("number too large");return n}function sn(e,t){return ue(e,t).reverse()}function vt(e){return Uint8Array.from(e)}const ft=e=>typeof e=="bigint"&&fe<=e;function cn(e,t,n){return ft(e)&&ft(t)&&ft(n)&&t<=e&&e<n}function kt(e,t,n,o){if(!cn(t,n,o))throw new Error("expected valid "+e+": "+n+" <= n < "+o+", got "+t)}const fn=e=>(Vt<<BigInt(e))-Vt;function Tt(e,t={},n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function o(s,c,u){const i=e[s];if(u&&i===void 0)return;const x=typeof i;if(x!==c||i===null)throw new Error(`param "${s}" is invalid: expected ${c}, got ${x}`)}const r=(s,c)=>Object.entries(s).forEach(([u,i])=>o(u,i,c));r(t,!1),r(n,!0)}function Kt(e){const t=new WeakMap;return(n,...o)=>{const r=t.get(n);if(r!==void 0)return r;const s=e(n,...o);return t.set(n,s),s}}const $=BigInt(0),G=BigInt(1),Q=BigInt(2),he=BigInt(3),le=BigInt(4),de=BigInt(5),an=BigInt(7),be=BigInt(8),un=BigInt(9),ge=BigInt(16);function U(e,t){const n=e%t;return n>=$?n:t+n}function Z(e,t,n){let o=e;for(;t-- >$;)o*=o,o%=n;return o}function Yt(e,t){if(e===$)throw new Error("invert: expected non-zero number");if(t<=$)throw new Error("invert: expected positive modulus, got "+t);let n=U(e,t),o=t,r=$,s=G;for(;n!==$;){const u=o/n,i=o%n,x=r-s*u;o=n,n=i,r=s,s=x}if(o!==G)throw new Error("invert: does not exist");return U(r,t)}function Ot(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function we(e,t){const n=(e.ORDER+G)/le,o=e.pow(t,n);return Ot(e,o,t),o}function hn(e,t){const n=(e.ORDER-de)/be,o=e.mul(t,Q),r=e.pow(o,n),s=e.mul(t,r),c=e.mul(e.mul(s,Q),r),u=e.mul(s,e.sub(c,e.ONE));return Ot(e,u,t),u}function ln(e){const t=Ct(e),n=xe(e),o=n(t,t.neg(t.ONE)),r=n(t,o),s=n(t,t.neg(o)),c=(e+an)/ge;return(u,i)=>{let x=u.pow(i,c),y=u.mul(x,o);const w=u.mul(x,r),S=u.mul(x,s),I=u.eql(u.sqr(y),i),v=u.eql(u.sqr(w),i);x=u.cmov(x,y,I),y=u.cmov(S,w,v);const T=u.eql(u.sqr(y),i),_=u.cmov(x,y,T);return Ot(u,_,i),_}}function xe(e){if(e<he)throw new Error("sqrt is not defined for small field");let t=e-G,n=0;for(;t%Q===$;)t/=Q,n++;let o=Q;const r=Ct(e);for(;zt(r,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return we;let s=r.pow(o,t);const c=(t+G)/Q;return function(i,x){if(i.is0(x))return x;if(zt(i,x)!==1)throw new Error("Cannot find square root");let y=n,w=i.mul(i.ONE,s),S=i.pow(x,t),I=i.pow(x,c);for(;!i.eql(S,i.ONE);){if(i.is0(S))return i.ZERO;let v=1,T=i.sqr(S);for(;!i.eql(T,i.ONE);)if(v++,T=i.sqr(T),v===y)throw new Error("Cannot find square root");const _=G<<BigInt(y-v-1),E=i.pow(w,_);y=v,w=i.sqr(E),S=i.mul(S,w),I=i.mul(I,E)}return I}}function dn(e){return e%le===he?we:e%be===de?hn:e%ge===un?ln(e):xe(e)}const bn=(e,t)=>(U(e,t)&G)===G,gn=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wn(e){const t={ORDER:"bigint",BYTES:"number",BITS:"number"},n=gn.reduce((o,r)=>(o[r]="function",o),t);return Tt(e,n),e}function xn(e,t,n){if(n<$)throw new Error("invalid exponent, negatives unsupported");if(n===$)return e.ONE;if(n===G)return t;let o=e.ONE,r=t;for(;n>$;)n&G&&(o=e.mul(o,r)),r=e.sqr(r),n>>=G;return o}function pe(e,t,n=!1){const o=new Array(t.length).fill(n?e.ZERO:void 0),r=t.reduce((c,u,i)=>e.is0(u)?c:(o[i]=c,e.mul(c,u)),e.ONE),s=e.inv(r);return t.reduceRight((c,u,i)=>e.is0(u)?c:(o[i]=e.mul(c,o[i]),e.mul(c,u)),s),o}function zt(e,t){const n=(e.ORDER-G)/Q,o=e.pow(t,n),r=e.eql(o,e.ONE),s=e.eql(o,e.ZERO),c=e.eql(o,e.neg(e.ONE));if(!r&&!s&&!c)throw new Error("invalid Legendre symbol result");return r?1:s?0:-1}function pn(e,t){t!==void 0&&_t(t);const n=t!==void 0?t:e.toString(2).length,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}class mn{ORDER;BITS;BYTES;isLE;ZERO=$;ONE=G;_lengths;_sqrt;_mod;constructor(t,n={}){if(t<=$)throw new Error("invalid field: expected ORDER > 0, got "+t);let o;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(o=n.BITS),typeof n.sqrt=="function"&&(this.sqrt=n.sqrt),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=n.allowedLengths?.slice()),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));const{nBitLength:r,nByteLength:s}=pn(t,o);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=r,this.BYTES=s,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return U(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return $<=t&&t<this.ORDER}is0(t){return t===$}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&G)===G}neg(t){return U(-t,this.ORDER)}eql(t,n){return t===n}sqr(t){return U(t*t,this.ORDER)}add(t,n){return U(t+n,this.ORDER)}sub(t,n){return U(t-n,this.ORDER)}mul(t,n){return U(t*n,this.ORDER)}pow(t,n){return xn(this,t,n)}div(t,n){return U(t*Yt(n,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,n){return t+n}subN(t,n){return t-n}mulN(t,n){return t*n}inv(t){return Yt(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=dn(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?sn(t,this.BYTES):ue(t,this.BYTES)}fromBytes(t,n=!1){D(t);const{_lengths:o,BYTES:r,isLE:s,ORDER:c,_mod:u}=this;if(o){if(!o.includes(t.length)||t.length>r)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);const x=new Uint8Array(r);x.set(t,s?0:x.length-t.length),t=x}if(t.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);let i=s?at(t):on(t);if(u&&(i=U(i,c)),!n&&!this.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i}invertBatch(t){return pe(this,t)}cmov(t,n,o){return o?n:t}}function Ct(e,t={}){return new mn(e,t)}const ut=BigInt(0),Rt=BigInt(1);function Wt(e,t){const n=t.negate();return e?n:t}function gt(e,t){const n=pe(e.Fp,t.map(o=>o.Z));return t.map((o,r)=>e.fromAffine(o.toAffine(n[r])))}function me(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function wt(e,t){me(e,t);const n=Math.ceil(t/e)+1,o=2**(e-1),r=2**e,s=fn(e),c=BigInt(e);return{windows:n,windowSize:o,mask:s,maxNumber:r,shiftBy:c}}function Xt(e,t,n){const{windowSize:o,mask:r,maxNumber:s,shiftBy:c}=n;let u=Number(e&r),i=e>>c;u>o&&(u-=s,i+=Rt);const x=t*o,y=x+Math.abs(u)-1,w=u===0,S=u<0,I=t%2!==0;return{nextN:i,offset:y,isZero:w,isNeg:S,isNegF:I,offsetF:x}}const xt=new WeakMap,ye=new WeakMap;function pt(e){return ye.get(e)||1}function Pt(e){if(e!==ut)throw new Error("invalid wNAF")}class yn{BASE;ZERO;Fn;bits;constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,o=this.ZERO){let r=t;for(;n>ut;)n&Rt&&(o=o.add(r)),r=r.double(),n>>=Rt;return o}precomputeWindow(t,n){const{windows:o,windowSize:r}=wt(n,this.bits),s=[];let c=t,u=c;for(let i=0;i<o;i++){u=c,s.push(u);for(let x=1;x<r;x++)u=u.add(c),s.push(u);c=u.double()}return s}wNAF(t,n,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let r=this.ZERO,s=this.BASE;const c=wt(t,this.bits);for(let u=0;u<c.windows;u++){const{nextN:i,offset:x,isZero:y,isNeg:w,isNegF:S,offsetF:I}=Xt(o,u,c);o=i,y?s=s.add(Wt(S,n[I])):r=r.add(Wt(w,n[x]))}return Pt(o),{p:r,f:s}}wNAFUnsafe(t,n,o,r=this.ZERO){const s=wt(t,this.bits);for(let c=0;c<s.windows&&o!==ut;c++){const{nextN:u,offset:i,isZero:x,isNeg:y}=Xt(o,c,s);if(o=u,!x){const w=n[i];r=r.add(y?w.negate():w)}}return Pt(o),r}getPrecomputes(t,n,o){let r=xt.get(n);return r||(r=this.precomputeWindow(n,t),t!==1&&(typeof o=="function"&&(r=o(r)),xt.set(n,r))),r}cached(t,n,o){const r=pt(t);return this.wNAF(r,this.getPrecomputes(r,t,o),n)}unsafe(t,n,o,r){const s=pt(t);return s===1?this._unsafeLadder(t,n,r):this.wNAFUnsafe(s,this.getPrecomputes(s,t,o),n,r)}createCache(t,n){me(n,this.bits),ye.set(t,n),xt.delete(t)}hasCache(t){return pt(t)!==1}}function Ft(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return wn(t),t}else return Ct(e,{isLE:n})}function En(e,t,n={},o){if(o===void 0&&(o=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const i of["p","n","h"]){const x=t[i];if(!(typeof x=="bigint"&&x>ut))throw new Error(`CURVE.${i} must be positive bigint`)}const r=Ft(t.p,n.Fp,o),s=Ft(t.n,n.Fn,o),u=["Gx","Gy","a","d"];for(const i of u)if(!r.isValid(t[i]))throw new Error(`CURVE.${i} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:r,Fn:s}}function Bn(e,t){return function(o){const r=e(o);return{secretKey:r,publicKey:t(r)}}}const W=BigInt(0),H=BigInt(1),mt=BigInt(2),Sn=BigInt(8);function vn(e,t,n,o){const r=e.sqr(n),s=e.sqr(o),c=e.add(e.mul(t.a,r),s),u=e.add(e.ONE,e.mul(t.d,e.mul(r,s)));return e.eql(c,u)}function Rn(e,t={}){const n=En("edwards",e,t,t.FpFnLE),{Fp:o,Fn:r}=n;let s=n.CURVE;const{h:c}=s;Tt(t,{},{uvRatio:"function"});const u=mt<<BigInt(r.BYTES*8)-H,i=_=>o.create(_),x=t.uvRatio||((_,E)=>{try{return{isValid:!0,value:o.sqrt(o.div(_,E))}}catch{return{isValid:!1,value:W}}});if(!vn(o,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function y(_,E,R=!1){const p=R?H:W;return kt("coordinate "+_,E,p,u),E}function w(_){if(!(_ instanceof v))throw new Error("EdwardsPoint expected")}const S=Kt((_,E)=>{const{X:R,Y:p,Z:N}=_,O=_.is0();E==null&&(E=O?Sn:o.inv(N));const a=i(R*E),h=i(p*E),f=o.mul(N,E);if(O)return{x:W,y:H};if(f!==H)throw new Error("invZ was invalid");return{x:a,y:h}}),I=Kt(_=>{const{a:E,d:R}=s;if(_.is0())throw new Error("bad point: ZERO");const{X:p,Y:N,Z:O,T:a}=_,h=i(p*p),f=i(N*N),l=i(O*O),d=i(l*l),b=i(h*E),g=i(l*i(b+f)),m=i(d+i(R*i(h*f)));if(g!==m)throw new Error("bad point: equation left != right (1)");const B=i(p*N),A=i(O*a);if(B!==A)throw new Error("bad point: equation left != right (2)");return!0});class v{static BASE=new v(s.Gx,s.Gy,H,i(s.Gx*s.Gy));static ZERO=new v(W,H,H,W);static Fp=o;static Fn=r;X;Y;Z;T;constructor(E,R,p,N){this.X=y("x",E),this.Y=y("y",R),this.Z=y("z",p,!0),this.T=y("t",N),Object.freeze(this)}static CURVE(){return s}static fromAffine(E){if(E instanceof v)throw new Error("extended point not allowed");const{x:R,y:p}=E||{};return y("x",R),y("y",p),new v(R,p,H,i(R*p))}static fromBytes(E,R=!1){const p=o.BYTES,{a:N,d:O}=s;E=vt(D(E,p,"point")),St(R,"zip215");const a=vt(E),h=E[p-1];a[p-1]=h&-129;const f=at(a),l=R?u:o.ORDER;kt("point.y",f,W,l);const d=i(f*f),b=i(d-H),g=i(O*d-N);let{isValid:m,value:B}=x(b,g);if(!m)throw new Error("bad point: invalid y coordinate");const A=(B&H)===H,C=(h&128)!==0;if(!R&&B===W&&C)throw new Error("bad point: x=0 and x_0=1");return C!==A&&(B=i(-B)),v.fromAffine({x:B,y:f})}static fromHex(E,R=!1){return v.fromBytes(ie(E),R)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(E=8,R=!0){return T.createCache(this,E),R||this.multiply(mt),this}assertValidity(){I(this)}equals(E){w(E);const{X:R,Y:p,Z:N}=this,{X:O,Y:a,Z:h}=E,f=i(R*h),l=i(O*N),d=i(p*h),b=i(a*N);return f===l&&d===b}is0(){return this.equals(v.ZERO)}negate(){return new v(i(-this.X),this.Y,this.Z,i(-this.T))}double(){const{a:E}=s,{X:R,Y:p,Z:N}=this,O=i(R*R),a=i(p*p),h=i(mt*i(N*N)),f=i(E*O),l=R+p,d=i(i(l*l)-O-a),b=f+a,g=b-h,m=f-a,B=i(d*g),A=i(b*m),C=i(d*m),L=i(g*b);return new v(B,A,L,C)}add(E){w(E);const{a:R,d:p}=s,{X:N,Y:O,Z:a,T:h}=this,{X:f,Y:l,Z:d,T:b}=E,g=i(N*f),m=i(O*l),B=i(h*p*b),A=i(a*d),C=i((N+O)*(f+l)-g-m),L=A-B,q=A+B,J=i(m-R*g),rt=i(C*L),lt=i(q*J),Ut=i(C*J),Ht=i(L*q);return new v(rt,lt,Ht,Ut)}subtract(E){return this.add(E.negate())}multiply(E){if(!r.isValidNot0(E))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:R,f:p}=T.cached(this,E,N=>gt(v,N));return gt(v,[R,p])[0]}multiplyUnsafe(E,R=v.ZERO){if(!r.isValid(E))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return E===W?v.ZERO:this.is0()||E===H?this:T.unsafe(this,E,p=>gt(v,p),R)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafe(this,s.n).is0()}toAffine(E){return S(this,E)}clearCofactor(){return c===H?this:this.multiplyUnsafe(c)}toBytes(){const{x:E,y:R}=this.toAffine(),p=o.toBytes(R);return p[p.length-1]|=E&H?128:0,p}toHex(){return Nt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const T=new yn(v,r.BITS);return v.BASE.precompute(8),v}function An(e,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');Tt(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=n,{BASE:r,Fp:s,Fn:c}=e,u=n.randomBytes||Ze,i=n.adjustScalarBytes||(f=>f),x=n.domain||((f,l,d)=>{if(St(d,"phflag"),l.length||d)throw new Error("Contexts/pre-hash are not supported");return f});function y(f){return c.create(at(f))}function w(f){const l=p.secretKey;D(f,p.secretKey,"secretKey");const d=D(t(f),2*l,"hashedSecretKey"),b=i(d.slice(0,l)),g=d.slice(l,2*l),m=y(b);return{head:b,prefix:g,scalar:m}}function S(f){const{head:l,prefix:d,scalar:b}=w(f),g=r.multiply(b),m=g.toBytes();return{head:l,prefix:d,scalar:b,point:g,pointBytes:m}}function I(f){return S(f).pointBytes}function v(f=Uint8Array.of(),...l){const d=Gt(...l);return y(t(x(d,D(f,void 0,"context"),!!o)))}function T(f,l,d={}){f=D(f,void 0,"message"),o&&(f=o(f));const{prefix:b,scalar:g,pointBytes:m}=S(l),B=v(d.context,b,f),A=r.multiply(B).toBytes(),C=v(d.context,A,m,f),L=c.create(B+C*g);if(!c.isValid(L))throw new Error("sign failed: invalid s");const q=Gt(A,c.toBytes(L));return D(q,p.signature,"result")}const _={zip215:!0};function E(f,l,d,b=_){const{context:g,zip215:m}=b,B=p.signature;f=D(f,B,"signature"),l=D(l,void 0,"message"),d=D(d,p.publicKey,"publicKey"),m!==void 0&&St(m,"zip215"),o&&(l=o(l));const A=B/2,C=f.subarray(0,A),L=at(f.subarray(A,B));let q,J,rt;try{q=e.fromBytes(d,m),J=e.fromBytes(C,m),rt=r.multiplyUnsafe(L)}catch{return!1}if(!m&&q.isSmallOrder())return!1;const lt=v(g,J.toBytes(),q.toBytes(),l);return J.add(q.multiplyUnsafe(lt)).subtract(rt).clearCofactor().is0()}const R=s.BYTES,p={secretKey:R,publicKey:R,signature:2*R,seed:R};function N(f=u(p.seed)){return D(f,p.seed,"seed")}function O(f){return oe(f)&&f.length===c.BYTES}function a(f,l){try{return!!e.fromBytes(f,l)}catch{return!1}}const h={getExtendedPublicKey:S,randomSecretKey:N,isValidSecretKey:O,isValidPublicKey:a,toMontgomery(f){const{y:l}=e.fromBytes(f),d=p.publicKey,b=d===32;if(!b&&d!==57)throw new Error("only defined for 25519 and 448");const g=b?s.div(H+l,H-l):s.div(l-H,l+H);return s.toBytes(g)},toMontgomerySecret(f){const l=p.secretKey;D(f,l);const d=t(f.subarray(0,l));return i(d).subarray(0,l)}};return Object.freeze({keygen:Bn(N,I),getPublicKey:I,sign:T,verify:E,utils:h,Point:e,lengths:p})}const In=BigInt(1),Qt=BigInt(2),_n=BigInt(5),Nn=BigInt(8),Lt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Tn={p:Lt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Nn,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function On(e){const t=BigInt(10),n=BigInt(20),o=BigInt(40),r=BigInt(80),s=Lt,u=e*e%s*e%s,i=Z(u,Qt,s)*u%s,x=Z(i,In,s)*e%s,y=Z(x,_n,s)*x%s,w=Z(y,t,s)*y%s,S=Z(w,n,s)*w%s,I=Z(S,o,s)*S%s,v=Z(I,r,s)*I%s,T=Z(v,r,s)*I%s,_=Z(T,t,s)*y%s;return{pow_p_5_8:Z(_,Qt,s)*e%s,b2:u}}function Cn(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const Jt=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ln(e,t){const n=Lt,o=U(t*t*t,n),r=U(o*o*t,n),s=On(e*r).pow_p_5_8;let c=U(e*o*s,n);const u=U(t*c*c,n),i=c,x=U(c*Jt,n),y=u===e,w=u===U(-e,n),S=u===U(-e*Jt,n);return y&&(c=i),(w||S)&&(c=x),bn(c,n)&&(c=U(-c,n)),{isValid:y||w,value:c}}const Un=Rn(Tn,{uvRatio:Ln});function Hn(e){return An(Un,nn,Object.assign({adjustScalarBytes:Cn},e))}const Dn=Hn({});function qn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ht(e,...t){if(!qn(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function te(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Mn(e,t){ht(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function At(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function yt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function j(e,t){return e<<32-t|e>>>t}function Gn(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ee(e){return typeof e=="string"&&(e=Gn(e)),ht(e),e}class $n{}function Zn(e){const t=o=>e().update(Ee(o)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function jn(e,t,n,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,o);const r=BigInt(32),s=BigInt(4294967295),c=Number(n>>r&s),u=Number(n&s),i=o?4:0,x=o?0:4;e.setUint32(t+i,c,o),e.setUint32(t+x,u,o)}function Vn(e,t,n){return e&t^~e&n}function kn(e,t,n){return e&t^e&n^t&n}class Kn extends $n{constructor(t,n,o,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(t),this.view=yt(this.buffer)}update(t){te(this),t=Ee(t),ht(t);const{view:n,buffer:o,blockLen:r}=this,s=t.length;for(let c=0;c<s;){const u=Math.min(r-this.pos,s-c);if(u===r){const i=yt(t);for(;r<=s-c;c+=r)this.process(i,c);continue}o.set(t.subarray(c,c+u),this.pos),this.pos+=u,c+=u,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){te(this),Mn(t,this),this.finished=!0;const{buffer:n,view:o,blockLen:r,isLE:s}=this;let{pos:c}=this;n[c++]=128,At(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(o,0),c=0);for(let w=c;w<r;w++)n[w]=0;jn(o,r-8,BigInt(this.length*8),s),this.process(o,0);const u=yt(t),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const x=i/4,y=this.get();if(x>y.length)throw new Error("_sha2: outputLen bigger than state");for(let w=0;w<x;w++)u.setUint32(4*w,y[w],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const o=t.slice(0,n);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:o,length:r,finished:s,destroyed:c,pos:u}=this;return t.destroyed=c,t.finished=s,t.length=r,t.pos=u,r%n&&t.buffer.set(o),t}clone(){return this._cloneInto()}}const X=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yn=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]),P=new Uint32Array(64);class zn extends Kn{constructor(t=32){super(64,t,8,!1),this.A=X[0]|0,this.B=X[1]|0,this.C=X[2]|0,this.D=X[3]|0,this.E=X[4]|0,this.F=X[5]|0,this.G=X[6]|0,this.H=X[7]|0}get(){const{A:t,B:n,C:o,D:r,E:s,F:c,G:u,H:i}=this;return[t,n,o,r,s,c,u,i]}set(t,n,o,r,s,c,u,i){this.A=t|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=s|0,this.F=c|0,this.G=u|0,this.H=i|0}process(t,n){for(let w=0;w<16;w++,n+=4)P[w]=t.getUint32(n,!1);for(let w=16;w<64;w++){const S=P[w-15],I=P[w-2],v=j(S,7)^j(S,18)^S>>>3,T=j(I,17)^j(I,19)^I>>>10;P[w]=T+P[w-7]+v+P[w-16]|0}let{A:o,B:r,C:s,D:c,E:u,F:i,G:x,H:y}=this;for(let w=0;w<64;w++){const S=j(u,6)^j(u,11)^j(u,25),I=y+S+Vn(u,i,x)+Yn[w]+P[w]|0,T=(j(o,2)^j(o,13)^j(o,22))+kn(o,r,s)|0;y=x,x=i,i=u,u=c+I|0,c=s,s=r,r=o,o=I+T|0}o=o+this.A|0,r=r+this.B|0,s=s+this.C|0,c=c+this.D|0,u=u+this.E|0,i=i+this.F|0,x=x+this.G|0,y=y+this.H|0,this.set(o,r,s,c,u,i,x,y)}roundClean(){At(P)}destroy(){this.set(0,0,0,0,0,0,0,0),At(this.buffer)}}const Be=Zn(()=>new zn),Wn=Be,Xn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Pn(e){if(e.length!==16)throw new Error(`Invalid seed length: expected 16, got ${e.length}`);const t=Wn(e),n=Dn.getPublicKey(t),o=new Uint8Array(64);return o.set(t,0),o.set(n,32),K.wipeBytes(t),{publicKey:n,secretKey:o}}function Fn(e){const t=Pn(e),n=t.publicKey;return K.wipeBytes(t.secretKey),n}function Qn(e){if(e.length!==32)throw new Error(`Invalid public key length: expected 32, got ${e.length}`);return Jn(e)}function Jn(e){let t=0;for(let r=0;r<e.length&&e[r]===0;r++)t++;let n=0n;for(let r=0;r<e.length;r++)n=n*256n+BigInt(e[r]);let o="";for(;n>0n;){const r=Number(n%58n);o=Xn[r]+o,n=n/58n}return"1".repeat(t)+o}const tr=2,er=3;function nr(e){if(e.length!==16)throw new Error(`Invalid seed length: expected 16, got ${e.length}`);const t=It(e),n=re.share(t,er,tr);if(n.length!==3)throw new Error(`Unexpected share count: ${n.length}`);const o=Et(n[0]),r=Et(n[1]),s=Et(n[2]);return{shareA:K.toShamirShare(o),shareB:K.toShamirShare(r),shareC:K.toShamirShare(s)}}function rr(e,t,n){const o=ee(e),r=ee(t);try{const s=re.combine([o,r]),c=Se(s);if(c.length!==16)throw new Error(`Reconstructed seed has wrong length: ${c.length}`);return K.toSeed(c)}catch(s){throw s instanceof Error&&s.message.startsWith("Reconstructed seed")||s instanceof Error&&s.message.startsWith("Invalid expectedPublicKey")||s instanceof Error&&s.message.startsWith("Reconstructed seed does not match")?s:new Error("Failed to reconstruct seed from shares")}}function It(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}function Se(e){if(!/^[0-9a-fA-F]*$/.test(e))throw new Error("Invalid hex string: contains non-hex characters");if(e.length%2!==0)throw new Error(`Invalid hex string: length ${e.length} is odd (must be even)`);const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=parseInt(e.substr(n*2,2),16);return t}function Et(e){const t=e.length%2!==0,n=t?"0"+e:e,o=Se(n),r=new Uint8Array(1+o.length);return r[0]=t?1:0,r.set(o,1),r}function ee(e){const t=e[0];if(t===0||t===1){const o=t===1,r=e.subarray(1),s=It(r),c=o?s.substring(1):s;if(/^[0-9a-f]/.test(c))return c}const n=It(e);return n.startsWith("0")&&!n.startsWith("00")?n.substring(1):n}exports.abytes=ht;exports.argon2DeriveInWorker=Ae;exports.combineShares=rr;exports.getDefaultExportFromCjs=ne;exports.getPublicKeyFromSeed=Fn;exports.publicKeyToBase58=Qn;exports.sha256=Be;exports.splitSecret=nr;
1
+ "use strict";const K=require("./useAuth-X6Ds6WW4.cjs");var dt=typeof document<"u"?document.currentScript:null;let F=null,ve=0;const nt=new Map;function Re(){return typeof Worker>"u"?null:(F||(F=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/argon2Worker-Bi5TuQvD.js").href:new URL("assets/argon2Worker-Bi5TuQvD.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:dt&&dt.tagName.toUpperCase()==="SCRIPT"&&dt.src||new URL("shamir-CiBczzDN.cjs",document.baseURI).href),{type:"module"}),F.onmessage=e=>{const{id:t,key:n,error:o}=e.data,r=nt.get(t);if(r){if(nt.delete(t),o){r.reject(new Error(o));return}if(!n){r.reject(new Error("Argon2 worker returned no key"));return}r.resolve(n)}},F.onerror=e=>{const t=e instanceof ErrorEvent?e.error:new Error("Argon2 worker error");for(const n of nt.values())n.reject(t instanceof Error?t:new Error(String(t)));nt.clear(),F?.terminate(),F=null}),F)}async function Ae(e,t,n=K.DEFAULT_KDF_PARAMS){K.validateKdfParams(n);const o=Re();return o?new Promise((r,s)=>{const c=ve++;nt.set(c,{resolve:r,reject:s});const u={id:c,password:e,salt:t,params:n};o.postMessage(u)}):K.argon2Derive(e,t,n)}function ne(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ie(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}),n}var ct={exports:{}};const _e=globalThis.crypto,Ne=globalThis.crypto,Te=globalThis.crypto.subtle,Oe=globalThis.crypto.getRandomValues.bind(globalThis.crypto),Ce=globalThis.crypto.randomUUID.bind(globalThis.crypto),Le=Object.freeze(Object.defineProperty({__proto__:null,default:_e,getRandomValues:Oe,randomUUID:Ce,subtle:Te,webcrypto:Ne},Symbol.toStringTag,{value:"Module"})),Ue=Ie(Le);var He=ct.exports,Dt;function De(){return Dt||(Dt=1,(function(e,t){(function(n,o){e.exports=o(Ue)})(He,function(n){var o,r,s,c,u;function i(){o={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},r={},s=new Array(1024).join("0"),c=!0,u=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function x(){return!!(r&&r.rng&&typeof r.rng=="function")}function y(a,h){var f;if(h===0||h===1)return a;if(h&&h>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return h=h||r.bits,a&&(f=a.length%h),f?(s+a).slice(-(h-f+a.length)):a}function w(a){var h="",f,l;for(l=a.length-1;l>=0;l--){if(f=parseInt(a[l],16),isNaN(f))throw new Error("Invalid hex character.");h=y(f.toString(2),4)+h}return h}function S(a){var h="",f,l;for(a=y(a,4),l=a.length;l>=4;l-=4){if(f=parseInt(a.slice(l-4,l),2),isNaN(f))throw new Error("Invalid binary character.");h=f.toString(16)+h}return h}function I(){return!!(n&&typeof n=="object"&&(typeof n.getRandomValues=="function"||typeof n.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function v(){return typeof n=="object"&&typeof n.randomBytes=="function"}function T(a){function h(b,g,m,B){var A=0,C,L="",q;for(g&&(C=g.length-1);A<C||L.length<b;)q=Math.abs(parseInt(g[A],m)),L=L+y(q.toString(2),B),A++;return L=L.substr(-b),(L.match(/0/g)||[]).length===L.length?null:L}function f(b){var g,m,B,A,C=null;for(B=16,A=4,m=Math.ceil(b/8);C===null;)g=n.randomBytes(m),C=h(b,g.toString("hex"),B,A);return C}function l(b){var g,m,B,A=null;for(m=10,B=32,g=Math.ceil(b/32);A===null;)A=h(b,n.getRandomValues(new Uint32Array(g)),m,B);return A}function d(b){var g,m,B,A,C,L=null;A=10,C=32,m=Math.ceil(b/32),B=123456789,g=new Uint32Array(m);for(var q=0;q<g.length;q++)g[q]=B;for(;L===null;)L=h(b,g,A,C);return L}if(a&&a==="testRandom")return r.typeCSPRNG=a,d;if(a&&a==="nodeCryptoRandomBytes")return r.typeCSPRNG=a,f;if(a&&a==="browserCryptoGetRandomValues")return r.typeCSPRNG=a,l;if(v())return r.typeCSPRNG="nodeCryptoRandomBytes",f;if(I())return r.typeCSPRNG="browserCryptoGetRandomValues",l}function _(a,h){var f=[],l;for(h&&(a=y(a,h)),l=a.length;l>r.bits;l-=r.bits)f.push(parseInt(a.slice(l-r.bits,l),2));return f.push(parseInt(a.slice(0,l),2)),f}function E(a,h){var f=r.logs[a],l=0,d;for(d=h.length-1;d>=0;d--)l!==0?l=r.exps[(f+r.logs[l])%r.maxShares]^h[d]:l=h[d];return l}function R(a,h,f){var l=0,d,b,g,m;for(g=0,d=h.length;g<d;g++)if(f[g]){for(b=r.logs[f[g]],m=0;m<d;m++)if(g!==m){if(a===h[m]){b=-1;break}b=(b+r.logs[a^h[m]]-r.logs[h[g]^h[m]]+r.maxShares)%r.maxShares}l=b===-1?l:l^r.exps[b]}return l}function p(a,h,f){var l=[],d=[a],b,g;for(b=1;b<f;b++)d[b]=parseInt(r.rng(r.bits),2);for(b=1,g=h+1;b<g;b++)l[b-1]={x:b,y:E(b,d)};return l}function N(a,h,f){var l,d,b,g,m;if(h=parseInt(h,r.radix),a=parseInt(a,10)||r.bits,l=a.toString(36).toUpperCase(),b=Math.pow(2,a)-1,g=b.toString(r.radix).length,d=y(h.toString(r.radix),g),typeof h!="number"||h%1!==0||h<1||h>b)throw new Error("Share id must be an integer between 1 and "+b+", inclusive.");return m=l+d+f,m}var O={init:function(a,h){var f=[],l=[],d=1,b,g;if(i(),a&&(typeof a!="number"||a%1!==0||a<o.minBits||a>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(h&&u.indexOf(h)===-1)throw new Error("Invalid RNG type argument : '"+h+"'");for(r.radix=o.radix,r.bits=a||o.bits,r.size=Math.pow(2,r.bits),r.maxShares=r.size-1,b=o.primitivePolynomials[r.bits],g=0;g<r.size;g++)l[g]=d,f[d]=g,d=d<<1,d>=r.size&&(d=d^b,d=d&r.maxShares);if(r.logs=f,r.exps=l,h&&this.setRNG(h),x()||this.setRNG(),!x()||!r.bits||!r.size||!r.maxShares||!r.logs||!r.exps||r.logs.length!==r.size||r.exps.length!==r.size)throw new Error("Initialization failed.")},combine:function(a,h){var f,l,d,b,g="",m,B,A,C=[],L=[];for(h=h||0,f=0,d=a.length;f<d;f++){if(B=this.extractShareComponents(a[f]),m===void 0)m=B.bits;else if(B.bits!==m)throw new Error("Mismatched shares: Different bit settings.");if(r.bits!==m&&this.init(m),C.indexOf(B.id)===-1)for(C.push(B.id),A=_(w(B.data)),l=0,b=A.length;l<b;l++)L[l]=L[l]||[],L[l][C.length-1]=A[l]}for(f=0,d=L.length;f<d;f++)g=y(R(h,C,L[f]).toString(2))+g;return S(h>=1?g:g.slice(g.indexOf("1")+1))},getConfig:function(){var a={};return a.radix=r.radix,a.bits=r.bits,a.maxShares=r.maxShares,a.hasCSPRNG=x(),a.typeCSPRNG=r.typeCSPRNG,a},extractShareComponents:function(a){var h,f,l,d,b={},g,m;if(h=parseInt(a.substr(0,1),36),h&&(typeof h!="number"||h%1!==0||h<o.minBits||h>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(d=Math.pow(2,h)-1,l=(Math.pow(2,h)-1).toString(r.radix).length,g="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+l+"})([a-fA-F0-9]+)$",m=new RegExp(g).exec(a),m&&(f=parseInt(m[2],r.radix)),typeof f!="number"||f%1!==0||f<1||f>d)throw new Error("Invalid share : Share id must be an integer between 1 and "+r.maxShares+", inclusive.");if(m&&m[3])return b.bits=h,b.id=f,b.data=m[3],b;throw new Error("The share data provided is invalid : "+a)},setRNG:function(a){var h="Random number generator is invalid ",f=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(a&&typeof a=="string"&&u.indexOf(a)===-1)throw new Error("Invalid RNG type argument : '"+a+"'");if(a||(a=T()),a&&typeof a=="string"&&(a=T(a)),c){if(a&&typeof a!="function")throw new Error(h+"(Not a function)."+f);if(a&&typeof a(r.bits)!="string")throw new Error(h+"(Output is not a string)."+f);if(a&&!parseInt(a(r.bits),2))throw new Error(h+"(Binary string output not parseable to an Integer)."+f);if(a&&a(r.bits).length>r.bits)throw new Error(h+"(Output length is greater than config.bits)."+f);if(a&&a(r.bits).length<r.bits)throw new Error(h+"(Output length is less than config.bits)."+f)}return r.rng=a,!0},str2hex:function(a,h){var f,l,d="",b,g,m,B;if(typeof a!="string")throw new Error("Input must be a character string.");if(h||(h=o.bytesPerChar),typeof h!="number"||h<1||h>o.maxBytesPerChar||h%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(f=2*h,l=Math.pow(16,f)-1,m=0,B=a.length;m<B;m++){if(g=a[m].charCodeAt(),isNaN(g))throw new Error("Invalid character: "+a[m]);if(g>l)throw b=Math.ceil(Math.log(g+1)/Math.log(256)),new Error("Invalid character code ("+g+"). Maximum allowable is 256^bytes-1 ("+l+"). To convert this character, use at least "+b+" bytes.");d=y(g.toString(16),f)+d}return d},hex2str:function(a,h){var f,l="",d,b;if(typeof a!="string")throw new Error("Input must be a hexadecimal string.");if(h=h||o.bytesPerChar,typeof h!="number"||h%1!==0||h<1||h>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(f=2*h,a=y(a,f),d=0,b=a.length;d<b;d+=f)l=String.fromCharCode(parseInt(a.slice(d,d+f),16))+l;return l},random:function(a){if(typeof a!="number"||a%1!==0||a<2||a>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return S(r.rng(a))},share:function(a,h,f,l){var d,b,g=new Array(h),m=new Array(h),B,A,C;if(l=l||128,typeof a!="string")throw new Error("Secret must be a string.");if(typeof h!="number"||h%1!==0||h<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(h>r.maxShares)throw d=Math.ceil(Math.log(h+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To create "+h+" shares, use at least "+d+" bits.");if(typeof f!="number"||f%1!==0||f<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(f>r.maxShares)throw d=Math.ceil(Math.log(f+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To use a threshold of "+f+", use at least "+d+" bits.");if(f>h)throw new Error("Threshold number of shares was "+f+" but must be less than or equal to the "+h+" shares specified as the total to generate.");if(typeof l!="number"||l%1!==0||l<0||l>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(a="1"+w(a),a=_(a,l),B=0,C=a.length;B<C;B++)for(b=p(a[B],h,f),A=0;A<h;A++)g[A]=g[A]||b[A].x.toString(r.radix),m[A]=y(b[A].y.toString(2))+(m[A]||"");for(B=0;B<h;B++)g[B]=N(r.bits,g[B],S(m[B]));return g},newShare:function(a,h){var f,l;if(a&&typeof a=="string"&&(a=parseInt(a,r.radix)),l=a.toString(r.radix),a&&l&&h&&h[0])return f=this.extractShareComponents(h[0]),N(f.bits,l,this.combine(h,a));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:i,_padLeft:y,_hex2bin:w,_bin2hex:S,_hasCryptoGetRandomValues:I,_hasCryptoRandomBytes:v,_getRNG:T,_isSetRNG:x,_splitNumStringToIntArray:_,_horner:E,_lagrange:R,_getShares:p,_constructPublicShareString:N};return O.init(),O})})(ct)),ct.exports}var qe=De();const re=ne(qe);function oe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function _t(e,t=""){if(!Number.isSafeInteger(e)||e<0){const n=t&&`"${t}" `;throw new Error(`${n}expected integer >= 0, got ${e}`)}}function D(e,t,n=""){const o=oe(e),r=e?.length,s=t!==void 0;if(!o||s&&r!==t){const c=n&&`"${n}" `,u=s?` of length ${t}`:"",i=o?`length=${r}`:`type=${typeof e}`;throw new Error(c+"expected Uint8Array"+u+", got "+i)}return e}function qt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Me(e,t){D(e,void 0,"digestInto() output");const n=t.outputLen;if(e.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function Bt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function bt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const se=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ge=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Nt(e){if(D(e),se)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Ge[e[n]];return t}const V={_0:48,_9:57,A:65,F:70,a:97,f:102};function Mt(e){if(e>=V._0&&e<=V._9)return e-V._0;if(e>=V.A&&e<=V.F)return e-(V.A-10);if(e>=V.a&&e<=V.f)return e-(V.a-10)}function ie(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(se)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const o=new Uint8Array(n);for(let r=0,s=0;r<n;r++,s+=2){const c=Mt(e.charCodeAt(s)),u=Mt(e.charCodeAt(s+1));if(c===void 0||u===void 0){const i=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+i+'" at index '+s)}o[r]=c*16+u}return o}function Gt(...e){let t=0;for(let o=0;o<e.length;o++){const r=e[o];D(r),t+=r.length}const n=new Uint8Array(t);for(let o=0,r=0;o<e.length;o++){const s=e[o];n.set(s,r),r+=s.length}return n}function $e(e,t={}){const n=(r,s)=>e(s).update(r).digest(),o=e(void 0);return n.outputLen=o.outputLen,n.blockLen=o.blockLen,n.create=r=>e(r),Object.assign(n,t),Object.freeze(n)}function Ze(e=32){const t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}const je=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});let Ve=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,n,o,r){this.blockLen=t,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(t),this.view=bt(this.buffer)}update(t){qt(this),D(t);const{view:n,buffer:o,blockLen:r}=this,s=t.length;for(let c=0;c<s;){const u=Math.min(r-this.pos,s-c);if(u===r){const i=bt(t);for(;r<=s-c;c+=r)this.process(i,c);continue}o.set(t.subarray(c,c+u),this.pos),this.pos+=u,c+=u,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){qt(this),Me(t,this),this.finished=!0;const{buffer:n,view:o,blockLen:r,isLE:s}=this;let{pos:c}=this;n[c++]=128,Bt(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(o,0),c=0);for(let w=c;w<r;w++)n[w]=0;o.setBigUint64(r-8,BigInt(this.length*8),s),this.process(o,0);const u=bt(t),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const x=i/4,y=this.get();if(x>y.length)throw new Error("_sha2: outputLen bigger than state");for(let w=0;w<x;w++)u.setUint32(4*w,y[w],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const o=t.slice(0,n);return this.destroy(),o}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:n,buffer:o,length:r,finished:s,destroyed:c,pos:u}=this;return t.destroyed=c,t.finished=s,t.length=r,t.pos=u,r%n&&t.buffer.set(o),t}clone(){return this._cloneInto()}};const M=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ot=BigInt(2**32-1),$t=BigInt(32);function ke(e,t=!1){return t?{h:Number(e&ot),l:Number(e>>$t&ot)}:{h:Number(e>>$t&ot)|0,l:Number(e&ot)|0}}function Ke(e,t=!1){const n=e.length;let o=new Uint32Array(n),r=new Uint32Array(n);for(let s=0;s<n;s++){const{h:c,l:u}=ke(e[s],t);[o[s],r[s]]=[c,u]}return[o,r]}const Zt=(e,t,n)=>e>>>n,jt=(e,t,n)=>e<<32-n|t>>>n,tt=(e,t,n)=>e>>>n|t<<32-n,et=(e,t,n)=>e<<32-n|t>>>n,st=(e,t,n)=>e<<64-n|t>>>n-32,it=(e,t,n)=>e>>>n-32|t<<64-n;function k(e,t,n,o){const r=(t>>>0)+(o>>>0);return{h:e+n+(r/2**32|0)|0,l:r|0}}const Ye=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),ze=(e,t,n,o)=>t+n+o+(e/2**32|0)|0,We=(e,t,n,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Xe=(e,t,n,o,r)=>t+n+o+r+(e/2**32|0)|0,Pe=(e,t,n,o,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0)+(r>>>0),Fe=(e,t,n,o,r,s)=>t+n+o+r+s+(e/2**32|0)|0,ce=Ke(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Qe=ce[0],Je=ce[1],Y=new Uint32Array(80),z=new Uint32Array(80);class tn extends Ve{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:n,Bh:o,Bl:r,Ch:s,Cl:c,Dh:u,Dl:i,Eh:x,El:y,Fh:w,Fl:S,Gh:I,Gl:v,Hh:T,Hl:_}=this;return[t,n,o,r,s,c,u,i,x,y,w,S,I,v,T,_]}set(t,n,o,r,s,c,u,i,x,y,w,S,I,v,T,_){this.Ah=t|0,this.Al=n|0,this.Bh=o|0,this.Bl=r|0,this.Ch=s|0,this.Cl=c|0,this.Dh=u|0,this.Dl=i|0,this.Eh=x|0,this.El=y|0,this.Fh=w|0,this.Fl=S|0,this.Gh=I|0,this.Gl=v|0,this.Hh=T|0,this.Hl=_|0}process(t,n){for(let p=0;p<16;p++,n+=4)Y[p]=t.getUint32(n),z[p]=t.getUint32(n+=4);for(let p=16;p<80;p++){const N=Y[p-15]|0,O=z[p-15]|0,a=tt(N,O,1)^tt(N,O,8)^Zt(N,O,7),h=et(N,O,1)^et(N,O,8)^jt(N,O,7),f=Y[p-2]|0,l=z[p-2]|0,d=tt(f,l,19)^st(f,l,61)^Zt(f,l,6),b=et(f,l,19)^it(f,l,61)^jt(f,l,6),g=We(h,b,z[p-7],z[p-16]),m=Xe(g,a,d,Y[p-7],Y[p-16]);Y[p]=m|0,z[p]=g|0}let{Ah:o,Al:r,Bh:s,Bl:c,Ch:u,Cl:i,Dh:x,Dl:y,Eh:w,El:S,Fh:I,Fl:v,Gh:T,Gl:_,Hh:E,Hl:R}=this;for(let p=0;p<80;p++){const N=tt(w,S,14)^tt(w,S,18)^st(w,S,41),O=et(w,S,14)^et(w,S,18)^it(w,S,41),a=w&I^~w&T,h=S&v^~S&_,f=Pe(R,O,h,Je[p],z[p]),l=Fe(f,E,N,a,Qe[p],Y[p]),d=f|0,b=tt(o,r,28)^st(o,r,34)^st(o,r,39),g=et(o,r,28)^it(o,r,34)^it(o,r,39),m=o&s^o&u^s&u,B=r&c^r&i^c&i;E=T|0,R=_|0,T=I|0,_=v|0,I=w|0,v=S|0,{h:w,l:S}=k(x|0,y|0,l|0,d|0),x=u|0,y=i|0,u=s|0,i=c|0,s=o|0,c=r|0;const A=Ye(d,g,B);o=ze(A,l,b,m),r=A|0}({h:o,l:r}=k(this.Ah|0,this.Al|0,o|0,r|0)),{h:s,l:c}=k(this.Bh|0,this.Bl|0,s|0,c|0),{h:u,l:i}=k(this.Ch|0,this.Cl|0,u|0,i|0),{h:x,l:y}=k(this.Dh|0,this.Dl|0,x|0,y|0),{h:w,l:S}=k(this.Eh|0,this.El|0,w|0,S|0),{h:I,l:v}=k(this.Fh|0,this.Fl|0,I|0,v|0),{h:T,l:_}=k(this.Gh|0,this.Gl|0,T|0,_|0),{h:E,l:R}=k(this.Hh|0,this.Hl|0,E|0,R|0),this.set(o,r,s,c,u,i,x,y,w,S,I,v,T,_,E,R)}roundClean(){Bt(Y,z)}destroy(){Bt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class en extends tn{Ah=M[0]|0;Al=M[1]|0;Bh=M[2]|0;Bl=M[3]|0;Ch=M[4]|0;Cl=M[5]|0;Dh=M[6]|0;Dl=M[7]|0;Eh=M[8]|0;El=M[9]|0;Fh=M[10]|0;Fl=M[11]|0;Gh=M[12]|0;Gl=M[13]|0;Hh=M[14]|0;Hl=M[15]|0;constructor(){super(64)}}const nn=$e(()=>new en,je(3));const fe=BigInt(0),Vt=BigInt(1);function St(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}" `;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function rn(e){if(typeof e=="bigint"){if(!ft(e))throw new Error("positive bigint expected, got "+e)}else _t(e);return e}function ae(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?fe:BigInt("0x"+e)}function on(e){return ae(Nt(e))}function at(e){return ae(Nt(vt(D(e)).reverse()))}function ue(e,t){_t(t),e=rn(e);const n=ie(e.toString(16).padStart(t*2,"0"));if(n.length!==t)throw new Error("number too large");return n}function sn(e,t){return ue(e,t).reverse()}function vt(e){return Uint8Array.from(e)}const ft=e=>typeof e=="bigint"&&fe<=e;function cn(e,t,n){return ft(e)&&ft(t)&&ft(n)&&t<=e&&e<n}function kt(e,t,n,o){if(!cn(t,n,o))throw new Error("expected valid "+e+": "+n+" <= n < "+o+", got "+t)}const fn=e=>(Vt<<BigInt(e))-Vt;function Tt(e,t={},n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function o(s,c,u){const i=e[s];if(u&&i===void 0)return;const x=typeof i;if(x!==c||i===null)throw new Error(`param "${s}" is invalid: expected ${c}, got ${x}`)}const r=(s,c)=>Object.entries(s).forEach(([u,i])=>o(u,i,c));r(t,!1),r(n,!0)}function Kt(e){const t=new WeakMap;return(n,...o)=>{const r=t.get(n);if(r!==void 0)return r;const s=e(n,...o);return t.set(n,s),s}}const $=BigInt(0),G=BigInt(1),Q=BigInt(2),he=BigInt(3),le=BigInt(4),de=BigInt(5),an=BigInt(7),be=BigInt(8),un=BigInt(9),ge=BigInt(16);function U(e,t){const n=e%t;return n>=$?n:t+n}function Z(e,t,n){let o=e;for(;t-- >$;)o*=o,o%=n;return o}function Yt(e,t){if(e===$)throw new Error("invert: expected non-zero number");if(t<=$)throw new Error("invert: expected positive modulus, got "+t);let n=U(e,t),o=t,r=$,s=G;for(;n!==$;){const u=o/n,i=o%n,x=r-s*u;o=n,n=i,r=s,s=x}if(o!==G)throw new Error("invert: does not exist");return U(r,t)}function Ot(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function we(e,t){const n=(e.ORDER+G)/le,o=e.pow(t,n);return Ot(e,o,t),o}function hn(e,t){const n=(e.ORDER-de)/be,o=e.mul(t,Q),r=e.pow(o,n),s=e.mul(t,r),c=e.mul(e.mul(s,Q),r),u=e.mul(s,e.sub(c,e.ONE));return Ot(e,u,t),u}function ln(e){const t=Ct(e),n=xe(e),o=n(t,t.neg(t.ONE)),r=n(t,o),s=n(t,t.neg(o)),c=(e+an)/ge;return(u,i)=>{let x=u.pow(i,c),y=u.mul(x,o);const w=u.mul(x,r),S=u.mul(x,s),I=u.eql(u.sqr(y),i),v=u.eql(u.sqr(w),i);x=u.cmov(x,y,I),y=u.cmov(S,w,v);const T=u.eql(u.sqr(y),i),_=u.cmov(x,y,T);return Ot(u,_,i),_}}function xe(e){if(e<he)throw new Error("sqrt is not defined for small field");let t=e-G,n=0;for(;t%Q===$;)t/=Q,n++;let o=Q;const r=Ct(e);for(;zt(r,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return we;let s=r.pow(o,t);const c=(t+G)/Q;return function(i,x){if(i.is0(x))return x;if(zt(i,x)!==1)throw new Error("Cannot find square root");let y=n,w=i.mul(i.ONE,s),S=i.pow(x,t),I=i.pow(x,c);for(;!i.eql(S,i.ONE);){if(i.is0(S))return i.ZERO;let v=1,T=i.sqr(S);for(;!i.eql(T,i.ONE);)if(v++,T=i.sqr(T),v===y)throw new Error("Cannot find square root");const _=G<<BigInt(y-v-1),E=i.pow(w,_);y=v,w=i.sqr(E),S=i.mul(S,w),I=i.mul(I,E)}return I}}function dn(e){return e%le===he?we:e%be===de?hn:e%ge===un?ln(e):xe(e)}const bn=(e,t)=>(U(e,t)&G)===G,gn=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wn(e){const t={ORDER:"bigint",BYTES:"number",BITS:"number"},n=gn.reduce((o,r)=>(o[r]="function",o),t);return Tt(e,n),e}function xn(e,t,n){if(n<$)throw new Error("invalid exponent, negatives unsupported");if(n===$)return e.ONE;if(n===G)return t;let o=e.ONE,r=t;for(;n>$;)n&G&&(o=e.mul(o,r)),r=e.sqr(r),n>>=G;return o}function pe(e,t,n=!1){const o=new Array(t.length).fill(n?e.ZERO:void 0),r=t.reduce((c,u,i)=>e.is0(u)?c:(o[i]=c,e.mul(c,u)),e.ONE),s=e.inv(r);return t.reduceRight((c,u,i)=>e.is0(u)?c:(o[i]=e.mul(c,o[i]),e.mul(c,u)),s),o}function zt(e,t){const n=(e.ORDER-G)/Q,o=e.pow(t,n),r=e.eql(o,e.ONE),s=e.eql(o,e.ZERO),c=e.eql(o,e.neg(e.ONE));if(!r&&!s&&!c)throw new Error("invalid Legendre symbol result");return r?1:s?0:-1}function pn(e,t){t!==void 0&&_t(t);const n=t!==void 0?t:e.toString(2).length,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}class mn{ORDER;BITS;BYTES;isLE;ZERO=$;ONE=G;_lengths;_sqrt;_mod;constructor(t,n={}){if(t<=$)throw new Error("invalid field: expected ORDER > 0, got "+t);let o;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(o=n.BITS),typeof n.sqrt=="function"&&(this.sqrt=n.sqrt),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=n.allowedLengths?.slice()),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));const{nBitLength:r,nByteLength:s}=pn(t,o);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=r,this.BYTES=s,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return U(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return $<=t&&t<this.ORDER}is0(t){return t===$}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&G)===G}neg(t){return U(-t,this.ORDER)}eql(t,n){return t===n}sqr(t){return U(t*t,this.ORDER)}add(t,n){return U(t+n,this.ORDER)}sub(t,n){return U(t-n,this.ORDER)}mul(t,n){return U(t*n,this.ORDER)}pow(t,n){return xn(this,t,n)}div(t,n){return U(t*Yt(n,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,n){return t+n}subN(t,n){return t-n}mulN(t,n){return t*n}inv(t){return Yt(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=dn(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?sn(t,this.BYTES):ue(t,this.BYTES)}fromBytes(t,n=!1){D(t);const{_lengths:o,BYTES:r,isLE:s,ORDER:c,_mod:u}=this;if(o){if(!o.includes(t.length)||t.length>r)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);const x=new Uint8Array(r);x.set(t,s?0:x.length-t.length),t=x}if(t.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);let i=s?at(t):on(t);if(u&&(i=U(i,c)),!n&&!this.isValid(i))throw new Error("invalid field element: outside of range 0..ORDER");return i}invertBatch(t){return pe(this,t)}cmov(t,n,o){return o?n:t}}function Ct(e,t={}){return new mn(e,t)}const ut=BigInt(0),Rt=BigInt(1);function Wt(e,t){const n=t.negate();return e?n:t}function gt(e,t){const n=pe(e.Fp,t.map(o=>o.Z));return t.map((o,r)=>e.fromAffine(o.toAffine(n[r])))}function me(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function wt(e,t){me(e,t);const n=Math.ceil(t/e)+1,o=2**(e-1),r=2**e,s=fn(e),c=BigInt(e);return{windows:n,windowSize:o,mask:s,maxNumber:r,shiftBy:c}}function Xt(e,t,n){const{windowSize:o,mask:r,maxNumber:s,shiftBy:c}=n;let u=Number(e&r),i=e>>c;u>o&&(u-=s,i+=Rt);const x=t*o,y=x+Math.abs(u)-1,w=u===0,S=u<0,I=t%2!==0;return{nextN:i,offset:y,isZero:w,isNeg:S,isNegF:I,offsetF:x}}const xt=new WeakMap,ye=new WeakMap;function pt(e){return ye.get(e)||1}function Pt(e){if(e!==ut)throw new Error("invalid wNAF")}class yn{BASE;ZERO;Fn;bits;constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,o=this.ZERO){let r=t;for(;n>ut;)n&Rt&&(o=o.add(r)),r=r.double(),n>>=Rt;return o}precomputeWindow(t,n){const{windows:o,windowSize:r}=wt(n,this.bits),s=[];let c=t,u=c;for(let i=0;i<o;i++){u=c,s.push(u);for(let x=1;x<r;x++)u=u.add(c),s.push(u);c=u.double()}return s}wNAF(t,n,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let r=this.ZERO,s=this.BASE;const c=wt(t,this.bits);for(let u=0;u<c.windows;u++){const{nextN:i,offset:x,isZero:y,isNeg:w,isNegF:S,offsetF:I}=Xt(o,u,c);o=i,y?s=s.add(Wt(S,n[I])):r=r.add(Wt(w,n[x]))}return Pt(o),{p:r,f:s}}wNAFUnsafe(t,n,o,r=this.ZERO){const s=wt(t,this.bits);for(let c=0;c<s.windows&&o!==ut;c++){const{nextN:u,offset:i,isZero:x,isNeg:y}=Xt(o,c,s);if(o=u,!x){const w=n[i];r=r.add(y?w.negate():w)}}return Pt(o),r}getPrecomputes(t,n,o){let r=xt.get(n);return r||(r=this.precomputeWindow(n,t),t!==1&&(typeof o=="function"&&(r=o(r)),xt.set(n,r))),r}cached(t,n,o){const r=pt(t);return this.wNAF(r,this.getPrecomputes(r,t,o),n)}unsafe(t,n,o,r){const s=pt(t);return s===1?this._unsafeLadder(t,n,r):this.wNAFUnsafe(s,this.getPrecomputes(s,t,o),n,r)}createCache(t,n){me(n,this.bits),ye.set(t,n),xt.delete(t)}hasCache(t){return pt(t)!==1}}function Ft(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return wn(t),t}else return Ct(e,{isLE:n})}function En(e,t,n={},o){if(o===void 0&&(o=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const i of["p","n","h"]){const x=t[i];if(!(typeof x=="bigint"&&x>ut))throw new Error(`CURVE.${i} must be positive bigint`)}const r=Ft(t.p,n.Fp,o),s=Ft(t.n,n.Fn,o),u=["Gx","Gy","a","d"];for(const i of u)if(!r.isValid(t[i]))throw new Error(`CURVE.${i} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:r,Fn:s}}function Bn(e,t){return function(o){const r=e(o);return{secretKey:r,publicKey:t(r)}}}const W=BigInt(0),H=BigInt(1),mt=BigInt(2),Sn=BigInt(8);function vn(e,t,n,o){const r=e.sqr(n),s=e.sqr(o),c=e.add(e.mul(t.a,r),s),u=e.add(e.ONE,e.mul(t.d,e.mul(r,s)));return e.eql(c,u)}function Rn(e,t={}){const n=En("edwards",e,t,t.FpFnLE),{Fp:o,Fn:r}=n;let s=n.CURVE;const{h:c}=s;Tt(t,{},{uvRatio:"function"});const u=mt<<BigInt(r.BYTES*8)-H,i=_=>o.create(_),x=t.uvRatio||((_,E)=>{try{return{isValid:!0,value:o.sqrt(o.div(_,E))}}catch{return{isValid:!1,value:W}}});if(!vn(o,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function y(_,E,R=!1){const p=R?H:W;return kt("coordinate "+_,E,p,u),E}function w(_){if(!(_ instanceof v))throw new Error("EdwardsPoint expected")}const S=Kt((_,E)=>{const{X:R,Y:p,Z:N}=_,O=_.is0();E==null&&(E=O?Sn:o.inv(N));const a=i(R*E),h=i(p*E),f=o.mul(N,E);if(O)return{x:W,y:H};if(f!==H)throw new Error("invZ was invalid");return{x:a,y:h}}),I=Kt(_=>{const{a:E,d:R}=s;if(_.is0())throw new Error("bad point: ZERO");const{X:p,Y:N,Z:O,T:a}=_,h=i(p*p),f=i(N*N),l=i(O*O),d=i(l*l),b=i(h*E),g=i(l*i(b+f)),m=i(d+i(R*i(h*f)));if(g!==m)throw new Error("bad point: equation left != right (1)");const B=i(p*N),A=i(O*a);if(B!==A)throw new Error("bad point: equation left != right (2)");return!0});class v{static BASE=new v(s.Gx,s.Gy,H,i(s.Gx*s.Gy));static ZERO=new v(W,H,H,W);static Fp=o;static Fn=r;X;Y;Z;T;constructor(E,R,p,N){this.X=y("x",E),this.Y=y("y",R),this.Z=y("z",p,!0),this.T=y("t",N),Object.freeze(this)}static CURVE(){return s}static fromAffine(E){if(E instanceof v)throw new Error("extended point not allowed");const{x:R,y:p}=E||{};return y("x",R),y("y",p),new v(R,p,H,i(R*p))}static fromBytes(E,R=!1){const p=o.BYTES,{a:N,d:O}=s;E=vt(D(E,p,"point")),St(R,"zip215");const a=vt(E),h=E[p-1];a[p-1]=h&-129;const f=at(a),l=R?u:o.ORDER;kt("point.y",f,W,l);const d=i(f*f),b=i(d-H),g=i(O*d-N);let{isValid:m,value:B}=x(b,g);if(!m)throw new Error("bad point: invalid y coordinate");const A=(B&H)===H,C=(h&128)!==0;if(!R&&B===W&&C)throw new Error("bad point: x=0 and x_0=1");return C!==A&&(B=i(-B)),v.fromAffine({x:B,y:f})}static fromHex(E,R=!1){return v.fromBytes(ie(E),R)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(E=8,R=!0){return T.createCache(this,E),R||this.multiply(mt),this}assertValidity(){I(this)}equals(E){w(E);const{X:R,Y:p,Z:N}=this,{X:O,Y:a,Z:h}=E,f=i(R*h),l=i(O*N),d=i(p*h),b=i(a*N);return f===l&&d===b}is0(){return this.equals(v.ZERO)}negate(){return new v(i(-this.X),this.Y,this.Z,i(-this.T))}double(){const{a:E}=s,{X:R,Y:p,Z:N}=this,O=i(R*R),a=i(p*p),h=i(mt*i(N*N)),f=i(E*O),l=R+p,d=i(i(l*l)-O-a),b=f+a,g=b-h,m=f-a,B=i(d*g),A=i(b*m),C=i(d*m),L=i(g*b);return new v(B,A,L,C)}add(E){w(E);const{a:R,d:p}=s,{X:N,Y:O,Z:a,T:h}=this,{X:f,Y:l,Z:d,T:b}=E,g=i(N*f),m=i(O*l),B=i(h*p*b),A=i(a*d),C=i((N+O)*(f+l)-g-m),L=A-B,q=A+B,J=i(m-R*g),rt=i(C*L),lt=i(q*J),Ut=i(C*J),Ht=i(L*q);return new v(rt,lt,Ht,Ut)}subtract(E){return this.add(E.negate())}multiply(E){if(!r.isValidNot0(E))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:R,f:p}=T.cached(this,E,N=>gt(v,N));return gt(v,[R,p])[0]}multiplyUnsafe(E,R=v.ZERO){if(!r.isValid(E))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return E===W?v.ZERO:this.is0()||E===H?this:T.unsafe(this,E,p=>gt(v,p),R)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafe(this,s.n).is0()}toAffine(E){return S(this,E)}clearCofactor(){return c===H?this:this.multiplyUnsafe(c)}toBytes(){const{x:E,y:R}=this.toAffine(),p=o.toBytes(R);return p[p.length-1]|=E&H?128:0,p}toHex(){return Nt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const T=new yn(v,r.BITS);return v.BASE.precompute(8),v}function An(e,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');Tt(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=n,{BASE:r,Fp:s,Fn:c}=e,u=n.randomBytes||Ze,i=n.adjustScalarBytes||(f=>f),x=n.domain||((f,l,d)=>{if(St(d,"phflag"),l.length||d)throw new Error("Contexts/pre-hash are not supported");return f});function y(f){return c.create(at(f))}function w(f){const l=p.secretKey;D(f,p.secretKey,"secretKey");const d=D(t(f),2*l,"hashedSecretKey"),b=i(d.slice(0,l)),g=d.slice(l,2*l),m=y(b);return{head:b,prefix:g,scalar:m}}function S(f){const{head:l,prefix:d,scalar:b}=w(f),g=r.multiply(b),m=g.toBytes();return{head:l,prefix:d,scalar:b,point:g,pointBytes:m}}function I(f){return S(f).pointBytes}function v(f=Uint8Array.of(),...l){const d=Gt(...l);return y(t(x(d,D(f,void 0,"context"),!!o)))}function T(f,l,d={}){f=D(f,void 0,"message"),o&&(f=o(f));const{prefix:b,scalar:g,pointBytes:m}=S(l),B=v(d.context,b,f),A=r.multiply(B).toBytes(),C=v(d.context,A,m,f),L=c.create(B+C*g);if(!c.isValid(L))throw new Error("sign failed: invalid s");const q=Gt(A,c.toBytes(L));return D(q,p.signature,"result")}const _={zip215:!0};function E(f,l,d,b=_){const{context:g,zip215:m}=b,B=p.signature;f=D(f,B,"signature"),l=D(l,void 0,"message"),d=D(d,p.publicKey,"publicKey"),m!==void 0&&St(m,"zip215"),o&&(l=o(l));const A=B/2,C=f.subarray(0,A),L=at(f.subarray(A,B));let q,J,rt;try{q=e.fromBytes(d,m),J=e.fromBytes(C,m),rt=r.multiplyUnsafe(L)}catch{return!1}if(!m&&q.isSmallOrder())return!1;const lt=v(g,J.toBytes(),q.toBytes(),l);return J.add(q.multiplyUnsafe(lt)).subtract(rt).clearCofactor().is0()}const R=s.BYTES,p={secretKey:R,publicKey:R,signature:2*R,seed:R};function N(f=u(p.seed)){return D(f,p.seed,"seed")}function O(f){return oe(f)&&f.length===c.BYTES}function a(f,l){try{return!!e.fromBytes(f,l)}catch{return!1}}const h={getExtendedPublicKey:S,randomSecretKey:N,isValidSecretKey:O,isValidPublicKey:a,toMontgomery(f){const{y:l}=e.fromBytes(f),d=p.publicKey,b=d===32;if(!b&&d!==57)throw new Error("only defined for 25519 and 448");const g=b?s.div(H+l,H-l):s.div(l-H,l+H);return s.toBytes(g)},toMontgomerySecret(f){const l=p.secretKey;D(f,l);const d=t(f.subarray(0,l));return i(d).subarray(0,l)}};return Object.freeze({keygen:Bn(N,I),getPublicKey:I,sign:T,verify:E,utils:h,Point:e,lengths:p})}const In=BigInt(1),Qt=BigInt(2),_n=BigInt(5),Nn=BigInt(8),Lt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Tn={p:Lt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Nn,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function On(e){const t=BigInt(10),n=BigInt(20),o=BigInt(40),r=BigInt(80),s=Lt,u=e*e%s*e%s,i=Z(u,Qt,s)*u%s,x=Z(i,In,s)*e%s,y=Z(x,_n,s)*x%s,w=Z(y,t,s)*y%s,S=Z(w,n,s)*w%s,I=Z(S,o,s)*S%s,v=Z(I,r,s)*I%s,T=Z(v,r,s)*I%s,_=Z(T,t,s)*y%s;return{pow_p_5_8:Z(_,Qt,s)*e%s,b2:u}}function Cn(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const Jt=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ln(e,t){const n=Lt,o=U(t*t*t,n),r=U(o*o*t,n),s=On(e*r).pow_p_5_8;let c=U(e*o*s,n);const u=U(t*c*c,n),i=c,x=U(c*Jt,n),y=u===e,w=u===U(-e,n),S=u===U(-e*Jt,n);return y&&(c=i),(w||S)&&(c=x),bn(c,n)&&(c=U(-c,n)),{isValid:y||w,value:c}}const Un=Rn(Tn,{uvRatio:Ln});function Hn(e){return An(Un,nn,Object.assign({adjustScalarBytes:Cn},e))}const Dn=Hn({});function qn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ht(e,...t){if(!qn(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function te(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Mn(e,t){ht(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function At(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function yt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function j(e,t){return e<<32-t|e>>>t}function Gn(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ee(e){return typeof e=="string"&&(e=Gn(e)),ht(e),e}class $n{}function Zn(e){const t=o=>e().update(Ee(o)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function jn(e,t,n,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,o);const r=BigInt(32),s=BigInt(4294967295),c=Number(n>>r&s),u=Number(n&s),i=o?4:0,x=o?0:4;e.setUint32(t+i,c,o),e.setUint32(t+x,u,o)}function Vn(e,t,n){return e&t^~e&n}function kn(e,t,n){return e&t^e&n^t&n}class Kn extends $n{constructor(t,n,o,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(t),this.view=yt(this.buffer)}update(t){te(this),t=Ee(t),ht(t);const{view:n,buffer:o,blockLen:r}=this,s=t.length;for(let c=0;c<s;){const u=Math.min(r-this.pos,s-c);if(u===r){const i=yt(t);for(;r<=s-c;c+=r)this.process(i,c);continue}o.set(t.subarray(c,c+u),this.pos),this.pos+=u,c+=u,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){te(this),Mn(t,this),this.finished=!0;const{buffer:n,view:o,blockLen:r,isLE:s}=this;let{pos:c}=this;n[c++]=128,At(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(o,0),c=0);for(let w=c;w<r;w++)n[w]=0;jn(o,r-8,BigInt(this.length*8),s),this.process(o,0);const u=yt(t),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const x=i/4,y=this.get();if(x>y.length)throw new Error("_sha2: outputLen bigger than state");for(let w=0;w<x;w++)u.setUint32(4*w,y[w],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const o=t.slice(0,n);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:o,length:r,finished:s,destroyed:c,pos:u}=this;return t.destroyed=c,t.finished=s,t.length=r,t.pos=u,r%n&&t.buffer.set(o),t}clone(){return this._cloneInto()}}const X=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yn=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]),P=new Uint32Array(64);class zn extends Kn{constructor(t=32){super(64,t,8,!1),this.A=X[0]|0,this.B=X[1]|0,this.C=X[2]|0,this.D=X[3]|0,this.E=X[4]|0,this.F=X[5]|0,this.G=X[6]|0,this.H=X[7]|0}get(){const{A:t,B:n,C:o,D:r,E:s,F:c,G:u,H:i}=this;return[t,n,o,r,s,c,u,i]}set(t,n,o,r,s,c,u,i){this.A=t|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=s|0,this.F=c|0,this.G=u|0,this.H=i|0}process(t,n){for(let w=0;w<16;w++,n+=4)P[w]=t.getUint32(n,!1);for(let w=16;w<64;w++){const S=P[w-15],I=P[w-2],v=j(S,7)^j(S,18)^S>>>3,T=j(I,17)^j(I,19)^I>>>10;P[w]=T+P[w-7]+v+P[w-16]|0}let{A:o,B:r,C:s,D:c,E:u,F:i,G:x,H:y}=this;for(let w=0;w<64;w++){const S=j(u,6)^j(u,11)^j(u,25),I=y+S+Vn(u,i,x)+Yn[w]+P[w]|0,T=(j(o,2)^j(o,13)^j(o,22))+kn(o,r,s)|0;y=x,x=i,i=u,u=c+I|0,c=s,s=r,r=o,o=I+T|0}o=o+this.A|0,r=r+this.B|0,s=s+this.C|0,c=c+this.D|0,u=u+this.E|0,i=i+this.F|0,x=x+this.G|0,y=y+this.H|0,this.set(o,r,s,c,u,i,x,y)}roundClean(){At(P)}destroy(){this.set(0,0,0,0,0,0,0,0),At(this.buffer)}}const Be=Zn(()=>new zn),Wn=Be,Xn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Pn(e){if(e.length!==16)throw new Error(`Invalid seed length: expected 16, got ${e.length}`);const t=Wn(e),n=Dn.getPublicKey(t),o=new Uint8Array(64);return o.set(t,0),o.set(n,32),K.wipeBytes(t),{publicKey:n,secretKey:o}}function Fn(e){const t=Pn(e),n=t.publicKey;return K.wipeBytes(t.secretKey),n}function Qn(e){if(e.length!==32)throw new Error(`Invalid public key length: expected 32, got ${e.length}`);return Jn(e)}function Jn(e){let t=0;for(let r=0;r<e.length&&e[r]===0;r++)t++;let n=0n;for(let r=0;r<e.length;r++)n=n*256n+BigInt(e[r]);let o="";for(;n>0n;){const r=Number(n%58n);o=Xn[r]+o,n=n/58n}return"1".repeat(t)+o}const tr=2,er=3;function nr(e){if(e.length!==16)throw new Error(`Invalid seed length: expected 16, got ${e.length}`);const t=It(e),n=re.share(t,er,tr);if(n.length!==3)throw new Error(`Unexpected share count: ${n.length}`);const o=Et(n[0]),r=Et(n[1]),s=Et(n[2]);return{shareA:K.toShamirShare(o),shareB:K.toShamirShare(r),shareC:K.toShamirShare(s)}}function rr(e,t,n){const o=ee(e),r=ee(t);try{const s=re.combine([o,r]),c=Se(s);if(c.length!==16)throw new Error(`Reconstructed seed has wrong length: ${c.length}`);return K.toSeed(c)}catch(s){throw s instanceof Error&&s.message.startsWith("Reconstructed seed")||s instanceof Error&&s.message.startsWith("Invalid expectedPublicKey")||s instanceof Error&&s.message.startsWith("Reconstructed seed does not match")?s:new Error("Failed to reconstruct seed from shares")}}function It(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}function Se(e){if(!/^[0-9a-fA-F]*$/.test(e))throw new Error("Invalid hex string: contains non-hex characters");if(e.length%2!==0)throw new Error(`Invalid hex string: length ${e.length} is odd (must be even)`);const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++)t[n]=parseInt(e.substr(n*2,2),16);return t}function Et(e){const t=e.length%2!==0,n=t?"0"+e:e,o=Se(n),r=new Uint8Array(1+o.length);return r[0]=t?1:0,r.set(o,1),r}function ee(e){const t=e[0];if(t===0||t===1){const o=t===1,r=e.subarray(1),s=It(r),c=o?s.substring(1):s;if(/^[0-9a-f]/.test(c))return c}const n=It(e);return n.startsWith("0")&&!n.startsWith("00")?n.substring(1):n}exports.abytes=ht;exports.argon2DeriveInWorker=Ae;exports.combineShares=rr;exports.getDefaultExportFromCjs=ne;exports.getPublicKeyFromSeed=Fn;exports.publicKeyToBase58=Qn;exports.sha256=Be;exports.splitSecret=nr;