@rizom/ops 0.2.0-alpha.680 → 0.2.0-alpha.682
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.
- package/dist/brains-ops.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/brains-ops.js
CHANGED
|
@@ -717,7 +717,7 @@ printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
|
|
|
717
717
|
`).replace(/\\n/g,`
|
|
718
718
|
`).trimEnd()}
|
|
719
719
|
`}var p5,wme;var a$=w(async()=>{me();l5();fn();zf();await c5();p5=c.object({HCLOUD_TOKEN:c.string().min(1),KAMAL_SSH_PRIVATE_KEY:c.string().min(1)}),wme=c.object({servers:c.array(c.object({status:c.string(),public_net:c.object({ipv4:c.object({ip:c.string().min(1)})})}))})});import{parseArgs as e8}from"util";function ot(e){return e}class jf extends Error{constructor(e){super(e);this.name="CliUsageError"}}function t8(e,t){let r={...t};for(let o of e)for(let[n,i]of Object.entries(o.flags??{})){let s=r[n];if(s===void 0){r[n]=i;continue}if(s.type!==i.type||s.short!==i.short||s.default!==i.default)throw Error(`Conflicting definitions for flag --${n}: commands must agree on type, short, and default`)}return r}function r8(e){let t={};for(let[r,o]of Object.entries(e))t[r]={type:o.type,...o.short!==void 0?{short:o.short}:{},...o.default!==void 0?{default:o.default}:{}};return t}function n8(e){if(!(e instanceof Error)||!("code"in e))return!1;return e.code==="ERR_PARSE_ARGS_UNKNOWN_OPTION"||e.code==="ERR_PARSE_ARGS_INVALID_OPTION_VALUE"}function u$(e,t){let r=t8(t.commands,t.globalFlags??{}),o,n;try{({values:o,positionals:n}=e8({args:e,options:r8(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(n8(s))throw new jf(s.message.split(". ")[0]??s.message);throw s}if("help"in r&&o.help===!0)return{command:"help",args:[],flags:{help:!0}};if("version"in r&&o.version===!0)return{command:"version",args:[],flags:{version:!0}};let i={};for(let[s,a]of Object.entries(r)){let l=o[s];if(typeof l==="string"&&a.type==="string")i[s]=l;else if(typeof l==="boolean"&&a.type==="boolean")i[s]=l}return{command:n[0]??"help",args:n.slice(1),flags:i}}function d$(e){let t=e.reduce((r,o)=>Math.max(r,o.label.length),0);return e.map((r)=>` ${r.label.padEnd(t)} ${r.description}`)}function o8(e){return d$(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function i8(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",o=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${o}`}function f$(e){return d$(Object.entries(e).map(([t,r])=>({label:i8(t,r),description:r.description})))}function p$(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function s8(e){return JSON.stringify(Object.entries(e).map(([t,r])=>[t,r.type,r.short??"",r.description,r.placeholder??"",r.default??""]).sort((t,r)=>String(t[0]).localeCompare(String(r[0]))))}function a8(e){let t=[],r=new Map;for(let n of e){let i=n.flags??{};if(Object.keys(i).length===0)continue;let s=s8(i),a=r.get(s);if(a){a.names.push(n.name);continue}let l={names:[n.name],flags:i};r.set(s,l),t.push(l)}let o=[];for(let n of t)o.push("",`${n.names.join(" / ")} options:`),o.push(...f$(n.flags));return o}function m$(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...o8(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...f$(e.globalFlags));return t.push(...a8(e.commands)),t.join(`
|
|
720
|
-
`)}function h$(e){let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate command name: ${r.name}`);t.set(r.name,r)}return t}function nt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function rs(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var Zf={name:"@rizom/ops",version:"0.2.0-alpha.680",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};import{existsSync as DH,mkdirSync as LH,readFileSync as JS,writeFileSync as HS}from"fs";import{dirname as BH,join as E1}from"path";function ib(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function St(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function Mt(e,t,r=""){let o=ib(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+l;if(!o)throw TypeError(u);throw RangeError(u)}return e}function no(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(St(e.outputLen),St(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function ha(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function Uf(e,t){Mt(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Mf(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function cr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ga(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rn(e,t){return e<<32-t|e>>>t}function Fe(e,t){return e<<t|e>>>32-t>>>0}var l8=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function u8(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function d8(e){for(let t=0;t<e.length;t++)e[t]=u8(e[t]);return e}var sb=l8?(e)=>e:d8,y$=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),f8=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function qf(e){if(Mt(e),y$)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=f8[e[r]];return t}var ro={_0:48,_9:57,A:65,F:70,a:97,f:102};function g$(e){if(e>=ro._0&&e<=ro._9)return e-ro._0;if(e>=ro.A&&e<=ro.F)return e-(ro.A-10);if(e>=ro.a&&e<=ro.f)return e-(ro.a-10);return}function Ol(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(y$)try{return Uint8Array.fromHex(e)}catch(n){if(n instanceof SyntaxError)throw RangeError(n.message);throw n}let t=e.length,r=t/2;if(t%2)throw RangeError("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=g$(e.charCodeAt(i)),a=g$(e.charCodeAt(i+1));if(s===void 0||a===void 0){let l=e[i]+e[i+1];throw RangeError('hex string expected, got non-hex character "'+l+'" at index '+i)}o[n]=s*16+a}return o}function p8(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ab(e,t=""){if(typeof e==="string")return p8(e);return Mt(e,void 0,t)}function cb(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Mt(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Ff(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw TypeError("options must be object or undefined");return Object.assign(e,t)}function lb(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.canXOF=o.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function oo(e=32){St(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))}var ub=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class db{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(no(e),Mt(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),cr(o)}update(e){return ha(this),this.iHash.update(e),this}digestInto(e){ha(this),Uf(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:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Tn=(()=>{let e=(t,r,o)=>new db(t,r).update(o).digest();return e.create=(t,r)=>new db(t,r),e})();function Cl(e,t,r){if(no(e),r===void 0)r=new Uint8Array(e.outputLen);return Tn(e,r,t)}var fb=Uint8Array.of(0),b$=Uint8Array.of();function pb(e,t,r,o=32){no(e),St(o,"length"),Mt(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=b$;else Mt(r,void 0,"info");let s=new Uint8Array(i*n),a=Tn.create(e,t),l=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)fb[0]=d+1,l.update(d===0?b$:u).update(r).update(fb).digestInto(u),s.set(u,n*d),a._cloneInto(l);return a.destroy(),l.destroy(),cr(u,fb),s.slice(0,o)}var Jo=(e,t,r,o,n)=>pb(e,Cl(e,t,r),o,n);function S$(e,t,r){return e&t^~e&r}function v$(e,t,r){return e&t^e&r^t&r}class Jf{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ga(this.buffer)}update(e){ha(this),Mt(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=ga(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){ha(this),Uf(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,cr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=ga(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var io=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var qt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Hf=BigInt(4294967295),w$=BigInt(32);function m8(e,t=!1){if(t)return{h:Number(e&Hf),l:Number(e>>w$&Hf)};return{h:Number(e>>w$&Hf)|0,l:Number(e&Hf)|0}}function x$(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=m8(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var mb=(e,t,r)=>e>>>r,hb=(e,t,r)=>e<<32-r|t>>>r,ns=(e,t,r)=>e>>>r|t<<32-r,os=(e,t,r)=>e<<32-r|t>>>r,Pl=(e,t,r)=>e<<64-r|t>>>r-32,zl=(e,t,r)=>e>>>r-32|t<<64-r;function Rn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var _$=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),E$=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,k$=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),I$=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,A$=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),T$=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var g8=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]),Ho=new Uint32Array(64);class R$ extends Jf{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)Ho[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=Ho[d-15],m=Ho[d-2],h=rn(f,7)^rn(f,18)^f>>>3,b=rn(m,17)^rn(m,19)^m>>>10;Ho[d]=b+Ho[d-7]+h+Ho[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:l,H:u}=this;for(let d=0;d<64;d++){let f=rn(s,6)^rn(s,11)^rn(s,25),m=u+f+S$(s,a,l)+g8[d]+Ho[d]|0,b=(rn(r,2)^rn(r,13)^rn(r,22))+v$(r,o,n)|0;u=l,l=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,l,u)}roundClean(){cr(Ho)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),cr(this.buffer)}}class $$ extends R${A=io[0]|0;B=io[1]|0;C=io[2]|0;D=io[3]|0;E=io[4]|0;F=io[5]|0;G=io[6]|0;H=io[7]|0;constructor(){super(32)}}var O$=(()=>x$(["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))))(),y8=(()=>O$[0])(),b8=(()=>O$[1])(),Ko=new Uint32Array(80),Vo=new Uint32Array(80);class C$ extends Jf{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:l,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,l,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,l,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)Ko[_]=e.getUint32(t),Vo[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=Ko[_-15]|0,O=Vo[_-15]|0,L=ns(A,O,1)^ns(A,O,8)^mb(A,O,7),z=os(A,O,1)^os(A,O,8)^hb(A,O,7),H=Ko[_-2]|0,P=Vo[_-2]|0,W=ns(H,P,19)^Pl(H,P,61)^mb(H,P,6),ee=os(H,P,19)^zl(H,P,61)^hb(H,P,6),j=k$(z,ee,Vo[_-7],Vo[_-16]),R=I$(j,L,W,Ko[_-7],Ko[_-16]);Ko[_]=R|0,Vo[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:l,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=ns(d,f,14)^ns(d,f,18)^Pl(d,f,41),O=os(d,f,14)^os(d,f,18)^zl(d,f,41),L=d&m^~d&b,z=f&h^~f&y,H=A$(x,O,z,b8[_],Vo[_]),P=T$(H,S,A,L,y8[_],Ko[_]),W=H|0,ee=ns(r,o,28)^Pl(r,o,34)^Pl(r,o,39),j=os(r,o,28)^zl(r,o,34)^zl(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=Rn(l|0,u|0,P|0,W|0),l=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let k=_$(W,j,B);r=E$(k,P,ee,R),o=k|0}({h:r,l:o}=Rn(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=Rn(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=Rn(this.Ch|0,this.Cl|0,s|0,a|0),{h:l,l:u}=Rn(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:f}=Rn(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=Rn(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=Rn(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=Rn(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,l,u,d,f,m,h,b,y,S,x)}roundClean(){cr(Ko,Vo)}destroy(){this.destroyed=!0,cr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class P$ extends C${Ah=qt[0]|0;Al=qt[1]|0;Bh=qt[2]|0;Bl=qt[3]|0;Ch=qt[4]|0;Cl=qt[5]|0;Dh=qt[6]|0;Dl=qt[7]|0;Eh=qt[8]|0;El=qt[9]|0;Fh=qt[10]|0;Fl=qt[11]|0;Gh=qt[12]|0;Gl=qt[13]|0;Hh=qt[14]|0;Hl=qt[15]|0;constructor(){super(64)}}var vt=lb(()=>new $$,ub(1));var Kf=lb(()=>new P$,ub(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Yf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function bb(e){if(!Yf(e))throw TypeError("Uint8Array expected")}function B$(e,t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;if(e)return t.every((r)=>typeof r==="string");else return t.every((r)=>Number.isSafeInteger(r))}function j$(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function Wo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function Dl(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Wf(e){if(!Array.isArray(e))throw TypeError("array expected")}function Gf(e,t){if(!B$(!0,t))throw TypeError(`${e}: array of strings expected`)}function Sb(e,t){if(!B$(!1,t))throw TypeError(`${e}: array of numbers expected`)}function $r(...e){let t=(i)=>i,r=(i,s)=>(a)=>i(s(a)),o=e.map((i)=>i.encode).reduceRight(r,t),n=e.map((i)=>i.decode).reduce(r,t);return{encode:o,decode:n}}function Or(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Gf("alphabet",t);let o=new Map(t.map((n,i)=>[n,i]));return{encode:(n)=>(Wf(n),n.map((i)=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:(n)=>(Wf(n),n.map((i)=>{Wo("alphabet.decode",i);let s=o.get(i);if(s===void 0)throw Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function Cr(e=""){return Wo("join",e),{encode:(t)=>(Gf("join.decode",t),t.join(e)),decode:(t)=>(Wo("join.decode",t),t.split(e))}}function Xf(e,t="="){return Dl(e),Wo("padding",t),{encode(r){Gf("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Gf("padding.decode",r);let o=r.length;if(o*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function Z$(e){return j$(e),{encode:(t)=>t,decode:(t)=>e(t)}}function z$(e,t,r){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Wf(e),!e.length)return[];let o=0,n=[],i=Array.from(e,(a)=>{if(Dl(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=i.length;while(!0){let a=0,l=!0;for(let u=o;u<s;u++){let d=i[u],f=t*a,m=f+d;if(!Number.isSafeInteger(m)||f/t!==a||m-d!==f)throw Error("convertRadix: carry overflow");let h=m/r;a=m%r;let b=Math.floor(h);if(i[u]=b,!Number.isSafeInteger(b)||b*r+a!==m)throw Error("convertRadix: carry overflow");if(!l)continue;else if(!b)o=u;else l=!1}if(n.push(a),l)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}var U$=(e,t)=>t===0?e:U$(t,e%t),Qf=(e,t)=>e+(t-U$(e,t)),Vf=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function gb(e,t,r,o){if(Wf(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Qf(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Qf(t,r)}`);let n=0,i=0,s=Vf[t],a=Vf[r]-1,l=[];for(let u of e){if(Dl(u),u>=s)throw Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,i+t>32)throw Error(`convertRadix2: carry overflow pos=${i} from=${t}`);i+=t;for(;i>=r;i-=r)l.push((n>>i-r&a)>>>0);let d=Vf[i];if(d===void 0)throw Error("invalid carry");n&=d-1}if(n=n<<r-i&a,!o&&i>=t)throw Error("Excess padding");if(!o&&n>0)throw Error(`Non-zero padding: ${n}`);if(o&&i>0)l.push(n>>>0);return l}function S8(e){Dl(e);let t=256;return{encode:(r)=>{if(!Yf(r))throw TypeError("radix.encode input should be Uint8Array");return z$(Array.from(r),t,e)},decode:(r)=>(Sb("radix.decode",r),Uint8Array.from(z$(r,e,t)))}}function Ur(e,t=!1){if(Dl(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Qf(8,e)>32||Qf(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Yf(r))throw TypeError("radix2.encode input should be Uint8Array");return gb(Array.from(r),8,e,!t)},decode:(r)=>(Sb("radix2.decode",r),Uint8Array.from(gb(r,e,8,t)))}}function N$(e){return j$(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var Vme=Object.freeze($r(Ur(4),Or("0123456789ABCDEF"),Cr(""))),Wme=Object.freeze($r(Ur(5),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Xf(5),Cr(""))),Gme=Object.freeze($r(Ur(5),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Cr(""))),Qme=Object.freeze($r(Ur(5),Or("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Xf(5),Cr(""))),Yme=Object.freeze($r(Ur(5),Or("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Cr(""))),Xme=Object.freeze($r(Ur(5),Or("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Cr(""),Z$((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),M$=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),v8=/[\t\n\f\r ]/,q$=(e,t)=>{Wo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&v8.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},vb=Object.freeze(M$?{encode(e){return bb(e),e.toBase64()},decode(e){return q$(e,!1)}}:$r(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Xf(6),Cr(""))),Yt=Object.freeze($r(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Cr(""))),ehe=Object.freeze(M$?{encode(e){return bb(e),e.toBase64({alphabet:"base64url"})},decode(e){return q$(e,!0)}}:$r(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Xf(6),Cr(""))),the=Object.freeze($r(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Cr(""))),wb=(e)=>$r(S8(58),Or(e),Cr("")),rhe=Object.freeze(wb("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),nhe=Object.freeze(wb("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),ohe=Object.freeze(wb("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var yb=$r(Or("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Cr("")),D$=[996825010,642813549,513874426,1027748829,705979059];function Nl(e){let t=e>>25,r=(e&33554431)<<5;for(let o=0;o<D$.length;o++)if((t>>o&1)===1)r^=D$[o];return r}function L$(e,t,r=1){let o=e.length,n=1;for(let i=0;i<o;i++){let s=e.charCodeAt(i);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=Nl(n)^s>>5}n=Nl(n);for(let i=0;i<o;i++)n=Nl(n)^e.charCodeAt(i)&31;for(let i of t)n=Nl(n)^i;for(let i=0;i<6;i++)n=Nl(n);return n^=r,yb.encode(gb([n%Vf[30]],30,5,!1))}function F$(e){let t=e==="bech32"?1:734539939,r=Ur(5),o=r.decode,n=r.encode,i=N$(o);function s(f,m,h=90){if(Wo("bech32.encode prefix",f),Yf(m))m=Array.from(m);Sb("bech32.encode",m);let b=f.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let y=b+7+m.length;if(h!==!1&&y>h)throw TypeError(`Length ${y} exceeds limit ${h}`);let S=f.toLowerCase(),x=L$(S,m,t);return`${S}1${yb.encode(m)}${x}`}function a(f,m=90){Wo("bech32.decode input",f);let h=f.length;if(h<8||m!==!1&&h>m)throw TypeError(`invalid string length: ${h} (${f}). Expected (8..${m})`);let b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw Error("String must be lowercase or uppercase");let y=b.lastIndexOf("1");if(y===0||y===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,y),x=b.slice(y+1);if(x.length<6)throw Error("Data must be at least 6 characters long");let _=yb.decode(x).slice(0,-6),A=L$(S,_,t);if(!x.endsWith(A))throw Error(`Invalid checksum in ${f}: expected "${A}"`);return{prefix:S,words:_}}let l=N$(a);function u(f){let{prefix:m,words:h}=a(f,!1);return{prefix:m,words:h,bytes:o(h)}}function d(f,m){return s(f,n(m))}return{encode:s,decode:a,encodeFromBytes:d,decodeToBytes:u,decodeUnsafe:l,fromWords:o,fromWordsUnsafe:i,toWords:n}}var Pr=Object.freeze(F$("bech32")),ihe=Object.freeze(F$("bech32m"));var w8=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),x8={encode(e){return bb(e),e.toHex()},decode(e){return Wo("hex",e),Uint8Array.fromHex(e)}},she=Object.freeze(w8?x8:$r(Ur(4),Or("0123456789abcdef"),Cr(""),Z$((e)=>{if(typeof e!=="string"||e.length%2!==0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));function E8(e,t,r,o){no(e);let n=Ff({dkLen:32,asyncTick:10},o),{c:i,dkLen:s,asyncTick:a}=n;if(St(i,"c"),St(s,"dkLen"),St(a,"asyncTick"),i<1)throw Error("iterations (c) must be >= 1");if(s<1)throw Error('"dkLen" must be >= 1');if(s>4294967295*e.outputLen)throw Error("derived key too long");let l=ab(t,"password"),u=ab(r,"salt"),d=new Uint8Array(s),f=Tn.create(e,l),m=f._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:f,PRFSalt:m}}function k8(e,t,r,o,n){if(e.destroy(),t.destroy(),o)o.destroy();return cr(n),r}function xb(e,t,r,o){let{c:n,dkLen:i,DK:s,PRF:a,PRFSalt:l}=E8(e,t,r,o),u,d=new Uint8Array(4),f=ga(d),m=new Uint8Array(a.outputLen);for(let h=1,b=0;b<i;h++,b+=a.outputLen){let y=s.subarray(b,b+a.outputLen);f.setInt32(0,h,!1),(u=l._cloneInto(u)).update(d).digestInto(m),y.set(m.subarray(0,y.length));for(let S=1;S<n;S++){a._cloneInto(u).update(m).digestInto(m);for(let x=0;x<y.length;x++)y[x]^=m[x]}}return k8(a,l,s,u,m)}function J$(e,t,r,o,n,i){let s=e[t++]^r[o++],a=e[t++]^r[o++],l=e[t++]^r[o++],u=e[t++]^r[o++],d=e[t++]^r[o++],f=e[t++]^r[o++],m=e[t++]^r[o++],h=e[t++]^r[o++],b=e[t++]^r[o++],y=e[t++]^r[o++],S=e[t++]^r[o++],x=e[t++]^r[o++],_=e[t++]^r[o++],A=e[t++]^r[o++],O=e[t++]^r[o++],L=e[t++]^r[o++],z=s,H=a,P=l,W=u,ee=d,j=f,R=m,B=h,k=b,T=y,I=S,q=x,N=_,K=A,G=O,re=L;for(let ae=0;ae<8;ae+=2)ee^=Fe(z+N|0,7),k^=Fe(ee+z|0,9),N^=Fe(k+ee|0,13),z^=Fe(N+k|0,18),T^=Fe(j+H|0,7),K^=Fe(T+j|0,9),H^=Fe(K+T|0,13),j^=Fe(H+K|0,18),G^=Fe(I+R|0,7),P^=Fe(G+I|0,9),R^=Fe(P+G|0,13),I^=Fe(R+P|0,18),W^=Fe(re+q|0,7),B^=Fe(W+re|0,9),q^=Fe(B+W|0,13),re^=Fe(q+B|0,18),H^=Fe(z+W|0,7),P^=Fe(H+z|0,9),W^=Fe(P+H|0,13),z^=Fe(W+P|0,18),R^=Fe(j+ee|0,7),B^=Fe(R+j|0,9),ee^=Fe(B+R|0,13),j^=Fe(ee+B|0,18),q^=Fe(I+T|0,7),k^=Fe(q+I|0,9),T^=Fe(k+q|0,13),I^=Fe(T+k|0,18),N^=Fe(re+G|0,7),K^=Fe(N+re|0,9),G^=Fe(K+N|0,13),re^=Fe(G+K|0,18);n[i++]=s+z|0,n[i++]=a+H|0,n[i++]=l+P|0,n[i++]=u+W|0,n[i++]=d+ee|0,n[i++]=f+j|0,n[i++]=m+R|0,n[i++]=h+B|0,n[i++]=b+k|0,n[i++]=y+T|0,n[i++]=S+I|0,n[i++]=x+q|0,n[i++]=_+N|0,n[i++]=A+K|0,n[i++]=O+G|0,n[i++]=L+re|0}function _b(e,t,r,o,n){let i=o+0,s=o+16*n;for(let a=0;a<16;a++)r[s+a]=e[t+(2*n-1)*16+a];for(let a=0;a<n;a++,i+=16,t+=16){if(J$(r,s,e,t,r,i),a>0)s+=16;J$(r,i,e,t+=16,r,s)}}function I8(e,t,r){let o=Ff({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:i,p:s,dkLen:a,asyncTick:l,maxmem:u,onProgress:d}=o;if(St(n,"N"),St(i,"r"),St(s,"p"),St(a,"dkLen"),St(l,"asyncTick"),St(u,"maxmem"),d!==void 0&&typeof d!=="function")throw Error("progressCb must be a function");let f=128*i,m=f/4,h=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>h)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(h-1)*32/f)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(h-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=f*(n+s+1);if(b>u)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+u);let y=xb(vt,e,t,{c:1,dkLen:f*s}),S=Mf(y),x=Mf(new Uint8Array(f*n)),_=Mf(new Uint8Array(f)),A=()=>{};if(d){let O=2*n*s,L=Math.max(Math.floor(O/1e4),1),z=0;A=()=>{if(z++,d&&(!(z%L)||z===O))d(z/O)}}return{N:n,r:i,p:s,dkLen:a,blockSize32:m,V:x,B32:S,B:y,tmp:_,blockMixCb:A,asyncTick:l}}function A8(e,t,r,o,n){let i=xb(vt,e,r,{c:1,dkLen:t});return cr(r,o,n),i}function Eb(e,t,r){let{N:o,r:n,p:i,dkLen:s,blockSize32:a,V:l,B32:u,B:d,tmp:f,blockMixCb:m}=I8(e,t,r);sb(u);for(let h=0;h<i;h++){let b=a*h;for(let y=0;y<a;y++)l[y]=u[b+y];for(let y=0,S=0;y<o-1;y++)_b(l,S,l,S+=a,n),m();_b(l,(o-1)*a,u,b,n),m();for(let y=0;y<o;y++){let S=(u[b+a-16]&o-1)>>>0;for(let x=0;x<a;x++)f[x]=u[b+x]^l[S*a+x];_b(f,0,u,b,n),m()}}return sb(u),A8(e,s,d,l,f)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function T8(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function ep(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function ya(e){if(typeof e!=="number")throw TypeError("number expected, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError("positive integer expected, got "+e)}function Rt(e,t,r=""){let o=T8(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+l;if(!o)throw TypeError(u);throw RangeError(u)}return e}function kb(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function H$(e,t,r=!1){Rt(e,void 0,"output");let o=t.outputLen;if(e.length<o)throw RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!ba(e))throw Error("invalid output, must be aligned")}function $n(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function nn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function R8(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var is=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),$8=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var O8=(e)=>{for(let t=0;t<e.length;t++)e[t]=$8(e[t]);return e},so=is?(e)=>e:O8;function K$(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function V$(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function W$(e,t,r){let o=t,n=r||(()=>[]),i=(a,l)=>o(l,...n(a)).update(a).digest(),s=o(new Uint8Array(e),...n(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...l)=>o(a,...l),i}var G$=(e,t)=>{function r(o,...n){if(Rt(o,void 0,"key"),e.nonceLength!==void 0){let d=n[0];Rt(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let i=e.tagLength;if(i&&n[1]!==void 0)Rt(n[1],void 0,"AAD");let s=t(o,...n),a=(d,f)=>{if(f!==void 0){if(d!==2)throw Error("cipher output not supported");Rt(f,void 0,"output")}},l=!1;return{encrypt(d,f){if(l)throw Error("cannot encrypt() twice with same key + nonce");return l=!0,Rt(d),a(s.encrypt.length,f),s.encrypt(d,f)},decrypt(d,f){if(Rt(d),i&&d.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,f),s.decrypt(d,f)}}}return Object.assign(r,e),r};function Ll(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Rt(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!ba(t))throw Error("invalid output, must be aligned");return t}function Q$(e,t,r){ya(e),ya(t),ep(r);let o=new Uint8Array(16),n=R8(o);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),o}function ba(e){return e.byteOffset%4===0}function Sa(e){return Uint8Array.from(Rt(e))}var X$=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),C8=(()=>so($n(X$("expand 16-byte k"))))(),P8=(()=>so($n(X$("expand 32-byte k"))))();function Je(e,t){return e<<t|e>>>32-t}var Bl=64,z8=16,Ib=(()=>4294967295)(),Y$=Uint32Array.of();function N8(e,t,r,o,n,i,s,a){let l=n.length,u=new Uint8Array(Bl),d=$n(u),f=is&&ba(n)&&ba(i),m=f?$n(n):Y$,h=f?$n(i):Y$;if(!is){for(let b=0;b<l;s++){if(e(t,r,o,d,s,a),so(d),s>=Ib)throw Error("arx: counter overflow");let y=Math.min(Bl,l-b);for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}return}for(let b=0;b<l;s++){if(e(t,r,o,d,s,a),s>=Ib)throw Error("arx: counter overflow");let y=Math.min(Bl,l-b);if(f&&y===Bl){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let x=0,_;x<z8;x++)_=S+x,h[_]=m[_]^d[x];b+=Bl;continue}for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}}function eO(e,t){let{allowShortKeys:r,extendNonceFn:o,counterLength:n,counterRight:i,rounds:s}=K$({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return ya(n),ya(s),ep(i),ep(r),(a,l,u,d,f=0)=>{Rt(a,void 0,"key"),Rt(l,void 0,"nonce"),Rt(u,void 0,"data");let m=u.length;if(d=Ll(m,d,!1),ya(f),f<0||f>=Ib)throw Error("arx: counter overflow");let h=[],b=a.length,y,S;if(b===32)h.push(y=Sa(a)),S=P8;else if(b===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),S=C8,h.push(y);else throw Rt(a,32,"arx key"),Error("invalid key size");if(!is||!ba(l))h.push(l=Sa(l));let x=$n(y);if(o){if(l.length!==24)throw Error("arx: extended nonce must be 24 bytes");let O=l.subarray(0,16);if(is)o(S,x,$n(O),x);else{let L=so(Uint32Array.from(S));o(L,x,$n(O),x),nn(L),so(x)}l=l.subarray(16)}else if(!is)so(x);let _=16-n;if(_!==l.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let O=new Uint8Array(12);O.set(l,i?0:12-l.length),l=O,h.push(l)}let A=so($n(l));try{return N8(e,S,x,A,u,d,f,s),d}finally{nn(...h)}}}function Ft(e,t){return e[t++]&255|(e[t++]&255)<<8}class tO{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=Sa(Rt(e,32,"key"));let t=Ft(e,0),r=Ft(e,2),o=Ft(e,4),n=Ft(e,6),i=Ft(e,8),s=Ft(e,10),a=Ft(e,12),l=Ft(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|n<<9)&8191,this.r[4]=(n>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Ft(e,16+2*u)}process(e,t,r=!1){let o=r?0:2048,{h:n,r:i}=this,s=i[0],a=i[1],l=i[2],u=i[3],d=i[4],f=i[5],m=i[6],h=i[7],b=i[8],y=i[9],S=Ft(e,t+0),x=Ft(e,t+2),_=Ft(e,t+4),A=Ft(e,t+6),O=Ft(e,t+8),L=Ft(e,t+10),z=Ft(e,t+12),H=Ft(e,t+14),P=n[0]+(S&8191),W=n[1]+((S>>>13|x<<3)&8191),ee=n[2]+((x>>>10|_<<6)&8191),j=n[3]+((_>>>7|A<<9)&8191),R=n[4]+((A>>>4|O<<12)&8191),B=n[5]+(O>>>1&8191),k=n[6]+((O>>>14|L<<2)&8191),T=n[7]+((L>>>11|z<<5)&8191),I=n[8]+((z>>>8|H<<8)&8191),q=n[9]+(H>>>5|o),N=0,K=N+P*s+W*(5*y)+ee*(5*b)+j*(5*h)+R*(5*m);N=K>>>13,K&=8191,K+=B*(5*f)+k*(5*d)+T*(5*u)+I*(5*l)+q*(5*a),N+=K>>>13,K&=8191;let G=N+P*a+W*s+ee*(5*y)+j*(5*b)+R*(5*h);N=G>>>13,G&=8191,G+=B*(5*m)+k*(5*f)+T*(5*d)+I*(5*u)+q*(5*l),N+=G>>>13,G&=8191;let re=N+P*l+W*a+ee*s+j*(5*y)+R*(5*b);N=re>>>13,re&=8191,re+=B*(5*h)+k*(5*m)+T*(5*f)+I*(5*d)+q*(5*u),N+=re>>>13,re&=8191;let ae=N+P*u+W*l+ee*a+j*s+R*(5*y);N=ae>>>13,ae&=8191,ae+=B*(5*b)+k*(5*h)+T*(5*m)+I*(5*f)+q*(5*d),N+=ae>>>13,ae&=8191;let pe=N+P*d+W*u+ee*l+j*a+R*s;N=pe>>>13,pe&=8191,pe+=B*(5*y)+k*(5*b)+T*(5*h)+I*(5*m)+q*(5*f),N+=pe>>>13,pe&=8191;let be=N+P*f+W*d+ee*u+j*l+R*a;N=be>>>13,be&=8191,be+=B*s+k*(5*y)+T*(5*b)+I*(5*h)+q*(5*m),N+=be>>>13,be&=8191;let ve=N+P*m+W*f+ee*d+j*u+R*l;N=ve>>>13,ve&=8191,ve+=B*a+k*s+T*(5*y)+I*(5*b)+q*(5*h),N+=ve>>>13,ve&=8191;let Ae=N+P*h+W*m+ee*f+j*d+R*u;N=Ae>>>13,Ae&=8191,Ae+=B*l+k*a+T*s+I*(5*y)+q*(5*b),N+=Ae>>>13,Ae&=8191;let Ie=N+P*b+W*h+ee*m+j*f+R*d;N=Ie>>>13,Ie&=8191,Ie+=B*u+k*l+T*a+I*s+q*(5*y),N+=Ie>>>13,Ie&=8191;let we=N+P*y+W*b+ee*h+j*m+R*f;N=we>>>13,we&=8191,we+=B*d+k*u+T*l+I*a+q*s,N+=we>>>13,we&=8191,N=(N<<2)+N|0,N=N+K|0,K=N&8191,N=N>>>13,G+=N,n[0]=K,n[1]=G,n[2]=re,n[3]=ae,n[4]=pe,n[5]=be,n[6]=ve,n[7]=Ae,n[8]=Ie,n[9]=we}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=o,o=e[s]>>>13,e[s]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+o,o=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(o^1)-1;for(let s=0;s<10;s++)r[s]&=n;n=~n;for(let s=0;s<10;s++)e[s]=e[s]&n|r[s];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+t[0];e[0]=i&65535;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=i&65535;nn(r)}update(e){kb(this),Rt(e),e=Sa(e);let{buffer:t,blockLen:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(r-this.pos,o-n);if(i===r){for(;r<=o-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,nn(this.h,this.r,this.buffer,this.pad)}digestInto(e){kb(this),H$(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:o}=this;if(o){t[o++]=1;for(;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let i=0;i<8;i++)e[n++]=r[i]>>>0,e[n++]=r[i]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var rO=W$(32,(e)=>new tO(e));function D8(e,t,r,o,n,i=20){let s=e[0],a=e[1],l=e[2],u=e[3],d=t[0],f=t[1],m=t[2],h=t[3],b=t[4],y=t[5],S=t[6],x=t[7],_=n,A=r[0],O=r[1],L=r[2],z=s,H=a,P=l,W=u,ee=d,j=f,R=m,B=h,k=b,T=y,I=S,q=x,N=_,K=A,G=O,re=L;for(let pe=0;pe<i;pe+=2)z=z+ee|0,N=Je(N^z,16),k=k+N|0,ee=Je(ee^k,12),z=z+ee|0,N=Je(N^z,8),k=k+N|0,ee=Je(ee^k,7),H=H+j|0,K=Je(K^H,16),T=T+K|0,j=Je(j^T,12),H=H+j|0,K=Je(K^H,8),T=T+K|0,j=Je(j^T,7),P=P+R|0,G=Je(G^P,16),I=I+G|0,R=Je(R^I,12),P=P+R|0,G=Je(G^P,8),I=I+G|0,R=Je(R^I,7),W=W+B|0,re=Je(re^W,16),q=q+re|0,B=Je(B^q,12),W=W+B|0,re=Je(re^W,8),q=q+re|0,B=Je(B^q,7),z=z+j|0,re=Je(re^z,16),I=I+re|0,j=Je(j^I,12),z=z+j|0,re=Je(re^z,8),I=I+re|0,j=Je(j^I,7),H=H+R|0,N=Je(N^H,16),q=q+N|0,R=Je(R^q,12),H=H+R|0,N=Je(N^H,8),q=q+N|0,R=Je(R^q,7),P=P+B|0,K=Je(K^P,16),k=k+K|0,B=Je(B^k,12),P=P+B|0,K=Je(K^P,8),k=k+K|0,B=Je(B^k,7),W=W+ee|0,G=Je(G^W,16),T=T+G|0,ee=Je(ee^T,12),W=W+ee|0,G=Je(G^W,8),T=T+G|0,ee=Je(ee^T,7);let ae=0;o[ae++]=s+z|0,o[ae++]=a+H|0,o[ae++]=l+P|0,o[ae++]=u+W|0,o[ae++]=d+ee|0,o[ae++]=f+j|0,o[ae++]=m+R|0,o[ae++]=h+B|0,o[ae++]=b+k|0,o[ae++]=y+T|0,o[ae++]=S+I|0,o[ae++]=x+q|0,o[ae++]=_+N|0,o[ae++]=A+K|0,o[ae++]=O+G|0,o[ae++]=L+re|0}var L8=eO(D8,{counterRight:!1,counterLength:4,allowShortKeys:!1});var B8=new Uint8Array(16),nO=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(B8.subarray(r))},j8=new Uint8Array(32);function oO(e,t,r,o,n){if(n!==void 0)Rt(n,void 0,"AAD");let i=e(t,r,j8),s=Q$(o.length,n?n.length:0,!0),a=rO.create(i);if(n)nO(a,n);nO(a,o),a.update(s);let l=a.digest();return nn(i,s),l}var Z8=(e)=>(t,r,o)=>({encrypt(i,s){let a=i.length;s=Ll(a+16,s,!1),s.set(i);let l=s.subarray(0,-16);e(t,r,l,l,1);let u=oO(e,t,r,l,o);return s.set(u,a),nn(u),s},decrypt(i,s){s=Ll(i.length-16,s,!1);let a=i.subarray(0,-16),l=i.subarray(-16),u=oO(e,t,r,a,o);if(!V$(l,u))throw nn(u),Error("invalid tag");return s.set(i.subarray(0,-16)),e(t,r,s,s,1),nn(u),s}}),Mr=G$({blockSize:64,nonceLength:12,tagLength:16},Z8(L8));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function va(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Te(e,t,r=""){let o=va(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+l)}return e}function qr(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Lt(e.outputLen),Lt(e.blockLen)}function co(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function tp(e,t){Te(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function rp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function vr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function np(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function on(e,t){return e<<32-t|e>>>t}var U8=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function M8(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function q8(e){for(let t=0;t<e.length;t++)e[t]=M8(e[t]);return e}var Ab=U8?(e)=>e:q8,sO=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),F8=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ss(e){if(Te(e),sO)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=F8[e[r]];return t}var ao={_0:48,_9:57,A:65,F:70,a:97,f:102};function iO(e){if(e>=ao._0&&e<=ao._9)return e-ao._0;if(e>=ao.A&&e<=ao.F)return e-(ao.A-10);if(e>=ao.a&&e<=ao.f)return e-(ao.a-10);return}function as(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(sO)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=iO(e.charCodeAt(i)),a=iO(e.charCodeAt(i+1));if(s===void 0||a===void 0){let l=e[i]+e[i+1];throw Error('hex string expected, got non-hex character "'+l+'" at index '+i)}o[n]=s*16+a}return o}function Et(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Te(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function wa(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Go(e=32){let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Qo=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Rb=BigInt(0),Tb=BigInt(1);function jl(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function aO(e){if(typeof e==="bigint"){if(!op(e))throw Error("positive bigint expected, got "+e)}else Lt(e);return e}function Zl(e){let t=aO(e).toString(16);return t.length&1?"0"+t:t}function cO(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?Rb:BigInt("0x"+e)}function Yo(e){return cO(ss(e))}function Xo(e){return cO(ss(ip(Te(e)).reverse()))}function xa(e,t){Lt(t),e=aO(e);let r=as(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Ul(e,t){return xa(e,t).reverse()}function ip(e){return Uint8Array.from(e)}function ei(e){return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var op=(e)=>typeof e==="bigint"&&Rb<=e;function J8(e,t,r){return op(e)&&op(t)&&op(r)&&t<=e&&e<r}function Ml(e,t,r,o){if(!J8(t,r,o))throw Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function $b(e){let t;for(t=0;e>Rb;e>>=Tb,t+=1);return t}var ql=(e)=>(Tb<<BigInt(e))-Tb;function lO(e,t,r){if(Lt(e,"hashLen"),Lt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,l=o(e),u=o(e),d=0,f=()=>{l.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Et(l,...S)),h=(S=n)=>{if(u=m(i,S),l=m(),S.length===0)return;u=m(s,S),l=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){l=m();let _=l.slice();x.push(_),S+=l.length}return Et(...x)};return(S,x)=>{f(),h(S);let _=void 0;while(!(_=x(b())))h();return f(),_}}function cs(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function o(i,s,a){let l=e[i];if(a&&l===void 0)return;let u=typeof l;if(u!==s||l===null)throw Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,l])=>o(a,l,s));n(t,!1),n(r,!0)}function Ob(e){let t=new WeakMap;return(r,...o)=>{let n=t.get(r);if(n!==void 0)return n;let i=e(r,...o);return t.set(r,i),i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ur=BigInt(0),Xt=BigInt(1),ls=BigInt(2),fO=BigInt(3),pO=BigInt(4),mO=BigInt(5),H8=BigInt(7),hO=BigInt(8),K8=BigInt(9),gO=BigInt(16);function lr(e,t){let r=e%t;return r>=ur?r:t+r}function Fr(e,t,r){let o=e;while(t-- >ur)o*=o,o%=r;return o}function uO(e,t){if(e===ur)throw Error("invert: expected non-zero number");if(t<=ur)throw Error("invert: expected positive modulus, got "+t);let r=lr(e,t),o=t,n=ur,i=Xt,s=Xt,a=ur;while(r!==ur){let u=o/r,d=o%r,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==Xt)throw Error("invert: does not exist");return lr(n,t)}function Cb(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function yO(e,t){let r=(e.ORDER+Xt)/pO,o=e.pow(t,r);return Cb(e,o,t),o}function V8(e,t){let r=(e.ORDER-mO)/hO,o=e.mul(t,ls),n=e.pow(o,r),i=e.mul(t,n),s=e.mul(e.mul(i,ls),n),a=e.mul(i,e.sub(s,e.ONE));return Cb(e,a,t),a}function W8(e){let t=sp(e),r=bO(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+H8)/gO;return(a,l)=>{let u=a.pow(l,s),d=a.mul(u,o),f=a.mul(u,n),m=a.mul(u,i),h=a.eql(a.sqr(d),l),b=a.eql(a.sqr(f),l);u=a.cmov(u,d,h),d=a.cmov(m,f,b);let y=a.eql(a.sqr(d),l),S=a.cmov(u,d,y);return Cb(a,S,l),S}}function bO(e){if(e<fO)throw Error("sqrt is not defined for small field");let t=e-Xt,r=0;while(t%ls===ur)t/=ls,r++;let o=ls,n=sp(e);while(dO(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return yO;let i=n.pow(o,t),s=(t+Xt)/ls;return function(l,u){if(l.is0(u))return u;if(dO(l,u)!==1)throw Error("Cannot find square root");let d=r,f=l.mul(l.ONE,i),m=l.pow(u,t),h=l.pow(u,s);while(!l.eql(m,l.ONE)){if(l.is0(m))return l.ZERO;let b=1,y=l.sqr(m);while(!l.eql(y,l.ONE))if(b++,y=l.sqr(y),b===d)throw Error("Cannot find square root");let S=Xt<<BigInt(d-b-1),x=l.pow(f,S);d=b,f=l.sqr(x),m=l.mul(m,f),h=l.mul(h,x)}return h}}function G8(e){if(e%pO===fO)return yO;if(e%hO===mO)return V8;if(e%gO===K8)return W8(e);return bO(e)}var Q8=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Q8.reduce((o,n)=>(o[n]="function",o),t);return cs(e,r),e}function Y8(e,t,r){if(r<ur)throw Error("invalid exponent, negatives unsupported");if(r===ur)return e.ONE;if(r===Xt)return t;let o=e.ONE,n=t;while(r>ur){if(r&Xt)o=e.mul(o,n);n=e.sqr(n),r>>=Xt}return o}function Fl(e,t,r=!1){let o=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,l)=>{if(e.is0(a))return s;return o[l]=s,e.mul(s,a)},e.ONE),i=e.inv(n);return t.reduceRight((s,a,l)=>{if(e.is0(a))return s;return o[l]=e.mul(s,o[l]),e.mul(s,a)},i),o}function dO(e,t){let r=(e.ORDER-Xt)/ls,o=e.pow(t,r),n=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),s=e.eql(o,e.neg(e.ONE));if(!n&&!i&&!s)throw Error("invalid Legendre symbol result");return n?1:i?0:-1}function X8(e,t){if(t!==void 0)Lt(t);let r=t!==void 0?t:e.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class SO{ORDER;BITS;BYTES;isLE;ZERO=ur;ONE=Xt;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=ur)throw Error("invalid field: expected ORDER > 0, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")this.sqrt=t.sqrt;if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=t.allowedLengths?.slice();if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=X8(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return lr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return ur<=e&&e<this.ORDER}is0(e){return e===ur}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Xt)===Xt}neg(e){return lr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return lr(e*e,this.ORDER)}add(e,t){return lr(e+t,this.ORDER)}sub(e,t){return lr(e-t,this.ORDER)}mul(e,t){return lr(e*t,this.ORDER)}pow(e,t){return Y8(this,e,t)}div(e,t){return lr(e*uO(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 uO(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=G8(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Ul(e,this.BYTES):xa(e,this.BYTES)}fromBytes(e,t=!1){Te(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let l=new Uint8Array(o);l.set(e,n?0:l.length-e.length),e=l}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?Xo(e):Yo(e);if(s)a=lr(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Fl(this,e)}cmov(e,t,r){return r?t:e}}function sp(e,t={}){return new SO(e,t)}function vO(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function zb(e){let t=vO(e);return t+Math.ceil(t/2)}function wO(e,t,r=!1){Te(e);let o=e.length,n=vO(t),i=zb(t);if(o<16||o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?Xo(e):Yo(e),a=lr(s,t-Xt)+Xt;return r?Ul(a,n):xa(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var _a=BigInt(0),us=BigInt(1);function Jl(e,t){let r=t.negate();return e?r:t}function Bb(e,t){let r=Fl(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function kO(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function Nb(e,t){kO(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=ql(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function xO(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),l=e>>s;if(a>o)a-=i,l+=us;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:l,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var Db=new WeakMap,IO=new WeakMap;function Lb(e){return IO.get(e)||1}function _O(e){if(e!==_a)throw Error("invalid wNAF")}class jb{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>_a){if(t&us)r=r.add(o);o=o.double(),t>>=us}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=Nb(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let l=1;l<o;l++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=Nb(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:l,isZero:u,isNeg:d,isNegF:f,offsetF:m}=xO(r,s,i);if(r=a,u)n=n.add(Jl(f,t[m]));else o=o.add(Jl(d,t[l]))}return _O(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=Nb(e,this.bits);for(let i=0;i<n.windows;i++){if(r===_a)break;let{nextN:s,offset:a,isZero:l,isNeg:u}=xO(r,i,n);if(r=s,l)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return _O(r),o}getPrecomputes(e,t,r){let o=Db.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);Db.set(t,o)}}return o}cached(e,t,r){let o=Lb(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=Lb(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){kO(t,this.bits),IO.set(e,t),Db.delete(e)}hasCache(e){return Lb(e)!==1}}function AO(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>_a||o>_a){if(r&us)i=i.add(n);if(o&us)s=s.add(n);n=n.double(),r>>=us,o>>=us}return{p1:i,p2:s}}function EO(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Pb(t),t}else return sp(e,{isLE:r})}function TO(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let l of["p","n","h"]){let u=t[l];if(!(typeof u==="bigint"&&u>_a))throw Error(`CURVE.${l} must be positive bigint`)}let n=EO(t.p,r.Fp,o),i=EO(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let l of a)if(!n.isValid(t[l]))throw Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function ap(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Hl=BigInt(0),Ea=BigInt(1),cp=BigInt(2);function eJ(e){return cs(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function RO(e){let t=eJ(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let l=s||Go,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?cp**BigInt(254):cp**BigInt(447),b=a?BigInt(8)*cp**BigInt(251)-Ea:BigInt(4)*cp**BigInt(445)-Ea,y=h+b+Ea,S=(k)=>lr(k,r),x=_(f);function _(k){return Ul(S(k),d)}function A(k){let T=ip(Te(k,d,"uCoordinate"));if(a)T[31]&=127;return S(Xo(T))}function O(k){return Xo(n(ip(Te(k,d,"scalar"))))}function L(k,T){let I=ee(A(T),O(k));if(I===Hl)throw Error("invalid private or public key received");return _(I)}function z(k){return L(k,x)}let H=z,P=L;function W(k,T,I){let q=S(k*(T-I));return T=S(T-q),I=S(I+q),{x_2:T,x_3:I}}function ee(k,T){Ml("u",k,Hl,r),Ml("scalar",T,h,y);let I=T,q=k,N=Ea,K=Hl,G=k,re=Ea,ae=Hl;for(let be=BigInt(u-1);be>=Hl;be--){let ve=I>>be&Ea;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:K,x_3:re}=W(ae,K,re),ae=ve;let Ae=N+K,Ie=S(Ae*Ae),we=N-K,Ue=S(we*we),De=Ie-Ue,Qe=G+re,bt=G-re,Tt=S(bt*Ae),Dt=S(Qe*we),lt=Tt+Dt,Rr=Tt-Dt;G=S(lt*lt),re=S(q*S(Rr*Rr)),N=S(Ie*Ue),K=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:K,x_3:re}=W(ae,K,re);let pe=i(K);return S(N*pe)}let j={secretKey:d,publicKey:d,seed:d},R=(k=l(d))=>(Te(k,j.seed,"seed"),k),B={randomSecretKey:R};return Object.freeze({keygen:ap(R,H),getSharedSecret:P,getPublicKey:H,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}class Zb{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(qr(e),Te(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),vr(o)}update(e){return co(this),this.iHash.update(e),this}digestInto(e){co(this),Te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),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:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var ka=(e,t,r)=>new Zb(e,t).update(r).digest();ka.create=(e,t)=>new Zb(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var $O=(e,t)=>(e+(e>=0?t:-t)/CO)/t;function tJ(e,t,r){let[[o,n],[i,s]]=t,a=$O(s*e,r),l=$O(-n*e,r),u=e-a*o-l*i,d=-a*n-l*s,f=u<lo,m=d<lo;if(f)u=-u;if(m)d=-d;let h=ql(Math.ceil($b(r)/2))+Ia;if(u<lo||u>=h||d<lo||d>=h)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:m,k2:d}}function Mb(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function Ub(e,t){let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(jl(r.lowS,"lowS"),jl(r.prehash,"prehash"),r.format!==void 0)Mb(r.format);return r}class OO extends Error{constructor(e=""){super(e)}}var ti={Err:OO,_tlv:{encode:(e,t)=>{let{Err:r}=ti;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Zl(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Zl(n.length/2|128):"";return Zl(e)+i+n+t},decode(e,t){let{Err:r}=ti,o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let l=n&127;if(!l)throw new r("tlv.decode(long): indefinite length not supported");if(l>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+l);if(u.length!==l)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=l,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=ti;if(e<lo)throw new t("integer: negative integers are not allowed");let r=Zl(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=ti;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Yo(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=ti,n=Te(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l}=o.decode(2,i),{v:u,l:d}=o.decode(2,l);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=ti,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}},lo=BigInt(0),Ia=BigInt(1),CO=BigInt(2),lp=BigInt(3),rJ=BigInt(4);function qb(e,t={}){let r=TO("weierstrass",e,t),{Fp:o,Fn:n}=r,i=r.CURVE,{h:s,n:a}=i;cs(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:l}=t;if(l){if(!o.is0(i.a)||typeof l.beta!=="bigint"||!Array.isArray(l.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=zO(o,n);function d(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(R,B,k){let{x:T,y:I}=B.toAffine(),q=o.toBytes(T);if(jl(k,"isCompressed"),k){d();let N=!o.isOdd(I);return Et(PO(N),q)}else return Et(Uint8Array.of(4),q,o.toBytes(I))}function m(R){Te(R,void 0,"Point");let{publicKey:B,publicKeyUncompressed:k}=u,T=R.length,I=R[0],q=R.subarray(1);if(T===B&&(I===2||I===3)){let N=o.fromBytes(q);if(!o.isValid(N))throw Error("bad point: is not on curve, wrong x");let K=y(N),G;try{G=o.sqrt(K)}catch(pe){let be=pe instanceof Error?": "+pe.message:"";throw Error("bad point: is not on curve, sqrt error"+be)}d();let re=o.isOdd(G);if((I&1)===1!==re)G=o.neg(G);return{x:N,y:G}}else if(T===k&&I===4){let N=o.BYTES,K=o.fromBytes(q.subarray(0,N)),G=o.fromBytes(q.subarray(N,N*2));if(!S(K,G))throw Error("bad point: is not on curve");return{x:K,y:G}}else throw Error(`bad point: got length ${T}, expected compressed=${B} or uncompressed=${k}`)}let h=t.toBytes||f,b=t.fromBytes||m;function y(R){let B=o.sqr(R),k=o.mul(B,R);return o.add(o.add(k,o.mul(R,i.a)),i.b)}function S(R,B){let k=o.sqr(B),T=y(R);return o.eql(k,T)}if(!S(i.Gx,i.Gy))throw Error("bad curve params: generator point");let x=o.mul(o.pow(i.a,lp),rJ),_=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(x,_)))throw Error("bad curve params: a or b");function A(R,B,k=!1){if(!o.isValid(B)||k&&o.is0(B))throw Error(`bad point coordinate ${R}`);return B}function O(R){if(!(R instanceof W))throw Error("Weierstrass Point expected")}function L(R){if(!l||!l.basises)throw Error("no endo");return tJ(R,l.basises,n.ORDER)}let z=Ob((R,B)=>{let{X:k,Y:T,Z:I}=R;if(o.eql(I,o.ONE))return{x:k,y:T};let q=R.is0();if(B==null)B=q?o.ONE:o.inv(I);let N=o.mul(k,B),K=o.mul(T,B),G=o.mul(I,B);if(q)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:K}}),H=Ob((R)=>{if(R.is0()){if(t.allowInfinityPoint&&!o.is0(R.Y))return;throw Error("bad point: ZERO")}let{x:B,y:k}=R.toAffine();if(!o.isValid(B)||!o.isValid(k))throw Error("bad point: x or y not field elements");if(!S(B,k))throw Error("bad point: equation left != right");if(!R.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function P(R,B,k,T,I){return k=new W(o.mul(k.X,R),k.Y,k.Z),B=Jl(T,B),k=Jl(I,k),B.add(k)}class W{static BASE=new W(i.Gx,i.Gy,o.ONE);static ZERO=new W(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(R,B,k){this.X=A("x",R),this.Y=A("y",B,!0),this.Z=A("z",k),Object.freeze(this)}static CURVE(){return i}static fromAffine(R){let{x:B,y:k}=R||{};if(!R||!o.isValid(B)||!o.isValid(k))throw Error("invalid affine point");if(R instanceof W)throw Error("projective point not allowed");if(o.is0(B)&&o.is0(k))return W.ZERO;return new W(B,k,o.ONE)}static fromBytes(R){let B=W.fromAffine(b(Te(R,void 0,"point")));return B.assertValidity(),B}static fromHex(R){return W.fromBytes(as(R))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(R=8,B=!0){if(j.createCache(this,R),!B)this.multiply(lp);return this}assertValidity(){H(this)}hasEvenY(){let{y:R}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(R)}equals(R){O(R);let{X:B,Y:k,Z:T}=this,{X:I,Y:q,Z:N}=R,K=o.eql(o.mul(B,N),o.mul(I,T)),G=o.eql(o.mul(k,N),o.mul(q,T));return K&&G}negate(){return new W(this.X,o.neg(this.Y),this.Z)}double(){let{a:R,b:B}=i,k=o.mul(B,lp),{X:T,Y:I,Z:q}=this,N=o.ZERO,K=o.ZERO,G=o.ZERO,re=o.mul(T,T),ae=o.mul(I,I),pe=o.mul(q,q),be=o.mul(T,I);return be=o.add(be,be),G=o.mul(T,q),G=o.add(G,G),N=o.mul(R,G),K=o.mul(k,pe),K=o.add(N,K),N=o.sub(ae,K),K=o.add(ae,K),K=o.mul(N,K),N=o.mul(be,N),G=o.mul(k,G),pe=o.mul(R,pe),be=o.sub(re,pe),be=o.mul(R,be),be=o.add(be,G),G=o.add(re,re),re=o.add(G,re),re=o.add(re,pe),re=o.mul(re,be),K=o.add(K,re),pe=o.mul(I,q),pe=o.add(pe,pe),re=o.mul(pe,be),N=o.sub(N,re),G=o.mul(pe,ae),G=o.add(G,G),G=o.add(G,G),new W(N,K,G)}add(R){O(R);let{X:B,Y:k,Z:T}=this,{X:I,Y:q,Z:N}=R,K=o.ZERO,G=o.ZERO,re=o.ZERO,ae=i.a,pe=o.mul(i.b,lp),be=o.mul(B,I),ve=o.mul(k,q),Ae=o.mul(T,N),Ie=o.add(B,k),we=o.add(I,q);Ie=o.mul(Ie,we),we=o.add(be,ve),Ie=o.sub(Ie,we),we=o.add(B,T);let Ue=o.add(I,N);return we=o.mul(we,Ue),Ue=o.add(be,Ae),we=o.sub(we,Ue),Ue=o.add(k,T),K=o.add(q,N),Ue=o.mul(Ue,K),K=o.add(ve,Ae),Ue=o.sub(Ue,K),re=o.mul(ae,we),K=o.mul(pe,Ae),re=o.add(K,re),K=o.sub(ve,re),re=o.add(ve,re),G=o.mul(K,re),ve=o.add(be,be),ve=o.add(ve,be),Ae=o.mul(ae,Ae),we=o.mul(pe,we),ve=o.add(ve,Ae),Ae=o.sub(be,Ae),Ae=o.mul(ae,Ae),we=o.add(we,Ae),be=o.mul(ve,we),G=o.add(G,be),be=o.mul(Ue,we),K=o.mul(Ie,K),K=o.sub(K,be),be=o.mul(Ie,ve),re=o.mul(Ue,re),re=o.add(re,be),new W(K,G,re)}subtract(R){return this.add(R.negate())}is0(){return this.equals(W.ZERO)}multiply(R){let{endo:B}=t;if(!n.isValidNot0(R))throw Error("invalid scalar: out of range");let k,T,I=(q)=>j.cached(this,q,(N)=>Bb(W,N));if(B){let{k1neg:q,k1:N,k2neg:K,k2:G}=L(R),{p:re,f:ae}=I(N),{p:pe,f:be}=I(G);T=ae.add(be),k=P(B.beta,re,pe,q,K)}else{let{p:q,f:N}=I(R);k=q,T=N}return Bb(W,[k,T])[0]}multiplyUnsafe(R){let{endo:B}=t,k=this;if(!n.isValid(R))throw Error("invalid scalar: out of range");if(R===lo||k.is0())return W.ZERO;if(R===Ia)return k;if(j.hasCache(this))return this.multiply(R);if(B){let{k1neg:T,k1:I,k2neg:q,k2:N}=L(R),{p1:K,p2:G}=AO(W,k,I,N);return P(B.beta,K,G,T,q)}else return j.unsafe(k,R)}toAffine(R){return z(this,R)}isTorsionFree(){let{isTorsionFree:R}=t;if(s===Ia)return!0;if(R)return R(W,this);return j.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:R}=t;if(s===Ia)return this;if(R)return R(W,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(R=!0){return jl(R,"isCompressed"),this.assertValidity(),h(W,this,R)}toHex(R=!0){return ss(this.toBytes(R))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,j=new jb(W,t.endo?Math.ceil(ee/2):ee);return W.BASE.precompute(8),W}function PO(e){return Uint8Array.of(e?2:3)}function zO(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function nJ(e,t={}){let{Fn:r}=e,o=t.randomBytes||Go,n=Object.assign(zO(e.Fp,r),{seed:zb(r.ORDER)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h=o(n.seed)){return wO(Te(h,n.seed,"seed"),r.ORDER)}function l(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n;if(!va(h))return;if("_lengths"in r&&r._lengths||b===y)return;let x=Te(h,void 0,"key").length;return x===y||x===S}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=ap(a,l);return Object.freeze({getPublicKey:l,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function Fb(e,t,r={}){qr(t),cs(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes||Go,n=r.hmac||((k,T)=>ka(t,k,T)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:l}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h}=nJ(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=a*CO<i.ORDER;function S(k){let T=a>>Ia;return k>T}function x(k,T){if(!s.isValidNot0(T))throw Error(`invalid signature ${k}: out of range 1..Point.Fn.ORDER`);return T}function _(){if(y)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function A(k,T){Mb(T);let I=h.signature,q=T==="compact"?I:T==="recovered"?I+1:void 0;return Te(k,q)}class O{r;s;recovery;constructor(k,T,I){if(this.r=x("r",k),this.s=x("s",T),I!=null){if(_(),![0,1,2,3].includes(I))throw Error("invalid recovery id");this.recovery=I}Object.freeze(this)}static fromBytes(k,T=b.format){A(k,T);let I;if(T==="der"){let{r:G,s:re}=ti.toSig(Te(k));return new O(G,re)}if(T==="recovered")I=k[0],T="compact",k=k.subarray(1);let q=h.signature/2,N=k.subarray(0,q),K=k.subarray(q,q*2);return new O(s.fromBytes(N),s.fromBytes(K),I)}static fromHex(k,T){return this.fromBytes(as(k),T)}assertRecovery(){let{recovery:k}=this;if(k==null)throw Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new O(this.r,this.s,k)}recoverPublicKey(k){let{r:T,s:I}=this,q=this.assertRecovery(),N=q===2||q===3?T+a:T;if(!i.isValid(N))throw Error("invalid recovery id: sig.r+curve.n != R.x");let K=i.toBytes(N),G=e.fromBytes(Et(PO((q&1)===0),K)),re=s.inv(N),ae=z(Te(k,void 0,"msgHash")),pe=s.create(-ae*re),be=s.create(I*re),ve=e.BASE.multiplyUnsafe(pe).add(G.multiplyUnsafe(be));if(ve.is0())throw Error("invalid recovery: point at infinify");return ve.assertValidity(),ve}hasHighS(){return S(this.s)}toBytes(k=b.format){if(Mb(k),k==="der")return as(ti.hexFromSig(this));let{r:T,s:I}=this,q=s.toBytes(T),N=s.toBytes(I);if(k==="recovered")return _(),Et(Uint8Array.of(this.assertRecovery()),q,N);return Et(q,N)}toHex(k){return ss(this.toBytes(k))}}let L=r.bits2int||function(T){if(T.length>8192)throw Error("input is too large");let I=Yo(T),q=T.length*8-l;return q>0?I>>BigInt(q):I},z=r.bits2int_modN||function(T){return s.create(L(T))},H=ql(l);function P(k){return Ml("num < 2^"+l,k,lo,H),s.toBytes(k)}function W(k,T){return Te(k,void 0,"message"),T?Te(t(k),void 0,"prehashed message"):k}function ee(k,T,I){let{lowS:q,prehash:N,extraEntropy:K}=Ub(I,b);k=W(k,N);let G=z(k),re=s.fromBytes(T);if(!s.isValidNot0(re))throw Error("invalid private key");let ae=[P(re),P(G)];if(K!=null&&K!==!1){let Ae=K===!0?o(h.secretKey):K;ae.push(Te(Ae,void 0,"extraEntropy"))}let pe=Et(...ae),be=G;function ve(Ae){let Ie=L(Ae);if(!s.isValidNot0(Ie))return;let we=s.inv(Ie),Ue=e.BASE.multiply(Ie).toAffine(),De=s.create(Ue.x);if(De===lo)return;let Qe=s.create(we*s.create(be+De*re));if(Qe===lo)return;let bt=(Ue.x===De?0:2)|Number(Ue.y&Ia),Tt=Qe;if(q&&S(Qe))Tt=s.neg(Qe),bt^=1;return new O(De,Tt,y?void 0:bt)}return{seed:pe,k2sig:ve}}function j(k,T,I={}){let{seed:q,k2sig:N}=ee(k,T,I);return lO(t.outputLen,s.BYTES,n)(q,N).toBytes(I.format)}function R(k,T,I,q={}){let{lowS:N,prehash:K,format:G}=Ub(q,b);if(I=Te(I,void 0,"publicKey"),T=W(T,K),!va(k)){let re=k instanceof O?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}A(k,G);try{let re=O.fromBytes(k,G),ae=e.fromBytes(I);if(N&&re.hasHighS())return!1;let{r:pe,s:be}=re,ve=z(T),Ae=s.inv(be),Ie=s.create(ve*Ae),we=s.create(pe*Ae),Ue=e.BASE.multiplyUnsafe(Ie).add(ae.multiplyUnsafe(we));if(Ue.is0())return!1;return s.create(Ue.x)===pe}catch(re){return!1}}function B(k,T,I={}){let{prehash:q}=Ub(I,b);return T=W(T,q),O.fromBytes(k,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h,Point:e,sign:j,verify:R,recoverPublicKey:B,Signature:O,hash:t})}function NO(e,t,r){return e&t^~e&r}function DO(e,t,r){return e&t^e&r^t&r}class up{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=np(this.buffer)}update(e){co(this),Te(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=np(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){co(this),tp(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,vr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=np(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var uo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Jt=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var dp=BigInt(4294967295),LO=BigInt(32);function oJ(e,t=!1){if(t)return{h:Number(e&dp),l:Number(e>>LO&dp)};return{h:Number(e>>LO&dp)|0,l:Number(e&dp)|0}}function fp(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=oJ(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var Jb=(e,t,r)=>e>>>r,Hb=(e,t,r)=>e<<32-r|t>>>r,ds=(e,t,r)=>e>>>r|t<<32-r,fs=(e,t,r)=>e<<32-r|t>>>r,Kl=(e,t,r)=>e<<64-r|t>>>r-32,Vl=(e,t,r)=>e>>>r-32|t<<64-r;var BO=(e,t,r)=>e<<r|t>>>32-r,jO=(e,t,r)=>t<<r|e>>>32-r,ZO=(e,t,r)=>t<<r-32|e>>>64-r,UO=(e,t,r)=>e<<r-32|t>>>64-r;function On(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var MO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),qO=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,FO=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),JO=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,HO=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),KO=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var sJ=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]),ri=new Uint32Array(64);class VO extends up{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)ri[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=ri[d-15],m=ri[d-2],h=on(f,7)^on(f,18)^f>>>3,b=on(m,17)^on(m,19)^m>>>10;ri[d]=b+ri[d-7]+h+ri[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:l,H:u}=this;for(let d=0;d<64;d++){let f=on(s,6)^on(s,11)^on(s,25),m=u+f+NO(s,a,l)+sJ[d]+ri[d]|0,b=(on(r,2)^on(r,13)^on(r,22))+DO(r,o,n)|0;u=l,l=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,l,u)}roundClean(){vr(ri)}destroy(){this.set(0,0,0,0,0,0,0,0),vr(this.buffer)}}class WO extends VO{A=uo[0]|0;B=uo[1]|0;C=uo[2]|0;D=uo[3]|0;E=uo[4]|0;F=uo[5]|0;G=uo[6]|0;H=uo[7]|0;constructor(){super(32)}}var GO=(()=>fp(["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))))(),aJ=(()=>GO[0])(),cJ=(()=>GO[1])(),ni=new Uint32Array(80),oi=new Uint32Array(80);class QO extends up{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:l,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,l,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,l,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)ni[_]=e.getUint32(t),oi[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=ni[_-15]|0,O=oi[_-15]|0,L=ds(A,O,1)^ds(A,O,8)^Jb(A,O,7),z=fs(A,O,1)^fs(A,O,8)^Hb(A,O,7),H=ni[_-2]|0,P=oi[_-2]|0,W=ds(H,P,19)^Kl(H,P,61)^Jb(H,P,6),ee=fs(H,P,19)^Vl(H,P,61)^Hb(H,P,6),j=FO(z,ee,oi[_-7],oi[_-16]),R=JO(j,L,W,ni[_-7],ni[_-16]);ni[_]=R|0,oi[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:l,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=ds(d,f,14)^ds(d,f,18)^Kl(d,f,41),O=fs(d,f,14)^fs(d,f,18)^Vl(d,f,41),L=d&m^~d&b,z=f&h^~f&y,H=HO(x,O,z,cJ[_],oi[_]),P=KO(H,S,A,L,aJ[_],ni[_]),W=H|0,ee=ds(r,o,28)^Kl(r,o,34)^Kl(r,o,39),j=fs(r,o,28)^Vl(r,o,34)^Vl(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=On(l|0,u|0,P|0,W|0),l=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let k=MO(W,j,B);r=qO(k,P,ee,R),o=k|0}({h:r,l:o}=On(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=On(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=On(this.Ch|0,this.Cl|0,s|0,a|0),{h:l,l:u}=On(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:f}=On(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=On(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=On(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=On(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,l,u,d,f,m,h,b,y,S,x)}roundClean(){vr(ni,oi)}destroy(){vr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class YO extends QO{Ah=Jt[0]|0;Al=Jt[1]|0;Bh=Jt[2]|0;Bl=Jt[3]|0;Ch=Jt[4]|0;Cl=Jt[5]|0;Dh=Jt[6]|0;Dl=Jt[7]|0;Eh=Jt[8]|0;El=Jt[9]|0;Fh=Jt[10]|0;Fl=Jt[11]|0;Gh=Jt[12]|0;Gl=Jt[13]|0;Hh=Jt[14]|0;Hl=Jt[15]|0;constructor(){super(48)}}var pp=wa(()=>new WO,Qo(1));var XO=wa(()=>new YO,Qo(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lJ=BigInt(1),eC=BigInt(2),uJ=BigInt(3),dJ=BigInt(5),lge=BigInt(8),tC=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function fJ(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=tC,a=e*e%i*e%i,l=Fr(a,eC,i)*a%i,u=Fr(l,lJ,i)*e%i,d=Fr(u,dJ,i)*u%i,f=Fr(d,t,i)*d%i,m=Fr(f,r,i)*f%i,h=Fr(m,o,i)*m%i,b=Fr(h,n,i)*h%i,y=Fr(b,n,i)*h%i,S=Fr(y,t,i)*d%i;return{pow_p_5_8:Fr(S,eC,i)*e%i,b2:a}}function pJ(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var rC=(()=>{let e=tC;return RO({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=fJ(t);return lr(Fr(r,uJ,e)*o,e)},adjustScalarBytes:pJ})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var mJ=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),hJ=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var gJ=qb(mJ),Kb=Fb(gJ,pp);var yJ=qb(hJ),nC=Fb(yJ,XO);function iC(e,t,r){if(qr(e),r===void 0)r=new Uint8Array(e.outputLen);return ka(e,r,t)}var Vb=Uint8Array.of(0),oC=Uint8Array.of();function sC(e,t,r,o=32){qr(e),Lt(o,"length");let n=e.outputLen;if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=oC;else Te(r,void 0,"info");let s=new Uint8Array(i*n),a=ka.create(e,t),l=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)Vb[0]=d+1,l.update(d===0?oC:u).update(r).update(Vb).digestInto(u),s.set(u,n*d),a._cloneInto(l);return a.destroy(),l.destroy(),vr(u,Vb),s.slice(0,o)}var bJ=BigInt(0),Wl=BigInt(1),SJ=BigInt(2),vJ=BigInt(7),wJ=BigInt(256),xJ=BigInt(113),lC=[],uC=[],dC=[];for(let e=0,t=Wl,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],lC.push(2*(5*o+r)),uC.push((e+1)*(e+2)/2%64);let n=bJ;for(let i=0;i<7;i++)if(t=(t<<Wl^(t>>vJ)*xJ)%wJ,t&SJ)n^=Wl<<(Wl<<BigInt(i))-Wl;dC.push(n)}var fC=fp(dC,!0),_J=fC[0],EJ=fC[1],aC=(e,t,r)=>r>32?ZO(e,t,r):BO(e,t,r),cC=(e,t,r)=>r>32?UO(e,t,r):jO(e,t,r);function kJ(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,l=(s+2)%10,u=r[l],d=r[l+1],f=aC(u,d,1)^r[a],m=cC(u,d,1)^r[a+1];for(let h=0;h<50;h+=10)e[s+h]^=f,e[s+h+1]^=m}let n=e[2],i=e[3];for(let s=0;s<24;s++){let a=uC[s],l=aC(n,i,a),u=cC(n,i,a),d=lC[s];n=e[d],i=e[d+1],e[d]=l,e[d+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=_J[o],e[1]^=EJ[o]}vr(r)}class mp{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,o=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=o,this.rounds=n,Lt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=rp(this.state)}clone(){return this._cloneInto()}keccak(){Ab(this.state32),kJ(this.state32,this.rounds),Ab(this.state32),this.posOut=0,this.pos=0}update(e){co(this),Te(e);let{blockLen:t,state:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(t-this.pos,o-n);for(let s=0;s<i;s++)r[this.pos++]^=e[n++];if(this.pos===t)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:o}=this;if(e[r]^=t,(t&128)!==0&&r===o-1)this.keccak();e[o-1]^=128,this.keccak()}writeInto(e){co(this,!1),Te(e),this.finish();let t=this.state,{blockLen:r}=this;for(let o=0,n=e.length;o<n;){if(this.posOut>=r)this.keccak();let i=Math.min(r-this.posOut,n-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Lt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(tp(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,vr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:o,rounds:n,enableXOF:i}=this;return e||=new mp(t,r,o,i,n),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}var pC=(e,t,r,o={})=>wa(()=>new mp(t,e,r),o);var ps=pC(6,136,32,Qo(8));var mC=pC(6,72,64,Qo(10));var hC=(e,t,r,o={})=>wa((n={})=>new mp(t,e,n.dkLen===void 0?r:n.dkLen,!0),o),gC=hC(31,168,16,Qo(11)),Cn=hC(31,136,32,Qo(12));function Wb(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function bC(e){return Wb(e),(e&e-1)===0&&e!==0}function Gb(e,t){Wb(e);let r=0;for(let o=0;o<t;o++,e>>>=1)r=r<<1|e&1;return r}function SC(e){return Wb(e),31-Math.clz32(e)}function yC(e){let t=e.length;if(t<2||!bC(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=SC(t);for(let o=0;o<t;o++){let n=Gb(o,r);if(o<n){let i=e[o];e[o]=e[n],e[n]=i}}return e}var Qb=(e,t)=>{let{N:r,roots:o,dit:n,invertButterflies:i=!1,skipStages:s=0,brp:a=!0}=t,l=SC(r);if(!bC(r))throw Error("FFT: Polynomial size should be power of two");let u=n!==i;return(d)=>{if(d.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)yC(d);for(let f=0,m=1;f<l-s;f++){let h=n?f+1+s:l-f,b=1<<h,y=b>>1,S=r>>h;for(let x=0;x<r;x+=b)for(let _=0,A=m++;_<y;_++){let O=i?n?r-A:A:_*S,L=x+_,z=x+_+y,H=o[O],P=d[z],W=d[L];if(u){let ee=e.mul(P,H);d[L]=e.add(W,ee),d[z]=e.sub(W,ee)}else if(i)d[L]=e.add(P,W),d[z]=e.mul(e.sub(P,W),H);else d[L]=e.add(W,P),d[z]=e.mul(e.sub(W,P),H)}}if(!n&&a)yC(d);return d}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Pn=Go;function hp(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function vC(e){return Uint8Array.from(e)}function ms(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,o=t.reduce((n,i)=>n+r(i),0);return{bytesLen:o,encode:(n)=>{let i=new Uint8Array(o);for(let s=0,a=0;s<t.length;s++){let l=t[s],u=r(l),d=typeof l==="number"?n[s]:l.encode(n[s]);if(Te(d,u,e),i.set(d,a),typeof l!=="number")d.fill(0);a+=u}return i},decode:(n)=>{Te(n,o,e);let i=[];for(let s of t){let a=r(s),l=n.subarray(0,a);i.push(typeof s==="number"?l:s.decode(l)),n=n.subarray(a)}return i}}}function gp(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(o)=>{if(o.length!==t)throw Error(`vecCoder.encode: wrong length=${o.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let i=0,s=0;i<o.length;i++){let a=e.encode(o[i]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(o)=>{Te(o,r);let n=[];for(let i=0;i<o.length;i+=e.bytesLen)n.push(e.decode(o.subarray(i,i+e.bytesLen)));return n}}}function $t(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function Yb(e){return(1<<e)-1}var Ege=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var wC=(e)=>{let{newPoly:t,N:r,Q:o,F:n,ROOT_OF_UNITY:i,brvBits:s,isKyber:a}=e,l=(_,A=o)=>{let O=_%A|0;return(O>=0?O|0:A+O|0)|0},u=(_,A=o)=>{let O=l(_,A)|0;return(O>A>>1?O-A|0:O)|0};function d(){let _=t(r);for(let A=0;A<r;A++){let O=Gb(A,s),L=BigInt(i)**BigInt(O)%BigInt(o);_[A]=Number(L)|0}return _}let f=d(),m={add:(_,A)=>l((_|0)+(A|0))|0,sub:(_,A)=>l((_|0)-(A|0))|0,mul:(_,A)=>l((_|0)*(A|0))|0,inv:(_)=>{throw Error("not implemented")}},h={N:r,roots:f,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=Qb(m,{dit:!1,...h}),y=Qb(m,{dit:!0,...h});return{mod:l,smod:u,nttZetas:f,NTT:{encode:(_)=>b(_),decode:(_)=>{y(_);for(let A=0;A<_.length;A++)_[A]=l(n*_[A]);return _}},bitsCoder:(_,A)=>{let O=Yb(_),L=_*(r/8);return{bytesLen:L,encode:(z)=>{let H=new Uint8Array(L);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=(A.encode(z[P])&O)<<ee,ee+=_;for(;ee>=8;ee-=8,W>>=8)H[j++]=W&Yb(ee)}return H},decode:(z)=>{let H=t(r);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=z[P]<<ee,ee+=8;for(;ee>=_;ee-=_,W>>=_)H[j++]=A.decode(W&O)}return H}}}}},IJ=(e)=>(t,r)=>{if(!r)r=e.blockLen;let o=new Uint8Array(t.length+2);o.set(t);let n=t.length,i=new Uint8Array(r),s=e.create({}),a=0,l=0;return{stats:()=>({calls:a,xofs:l}),get:(u,d)=>(o[n+0]=u,o[n+1]=d,s.destroy(),s=e.create({}).update(o),a++,()=>(l++,s.xofInto(i))),clean:()=>{s.destroy(),$t(i,o)}}},xC=IJ(gC);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var er=256,fo=3329,AJ=3303,TJ=17,{mod:Yl,nttZetas:RJ,NTT:hs,bitsCoder:$J}=wC({N:er,Q:fo,F:AJ,ROOT_OF_UNITY:TJ,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),Xb={512:{N:er,Q:fo,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:er,Q:fo,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:er,Q:fo,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},OJ=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+fo/2)/fo,decode:(r)=>r*fo+t>>>e}},Gl=(e)=>$J(e,OJ(e));function gs(e,t){for(let r=0;r<er;r++)e[r]=Yl(e[r]+t[r])}function CJ(e,t){for(let r=0;r<er;r++)e[r]=Yl(e[r]-t[r])}function PJ(e,t,r,o,n){let i=Yl(t*o*n+e*r),s=Yl(e*o+t*r);return{c0:i,c1:s}}function yp(e,t){for(let r=0;r<er/2;r++){let o=RJ[64+(r>>1)];if(r&1)o=-o;let{c0:n,c1:i}=PJ(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],o);e[2*r+0]=n,e[2*r+1]=i}return e}function _C(e){let t=new Uint16Array(er);for(let r=0;r<er;){let o=e();if(o.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<er&&n+3<=o.length;n+=3){let i=(o[n+0]>>0|o[n+1]<<8)&4095,s=(o[n+1]>>4|o[n+2]<<4)&4095;if(i<fo)t[r++]=i;if(r<er&&s<fo)t[r++]=s}}return t}function Ql(e,t,r,o){let n=e(o*er/4,t,r),i=new Uint16Array(er),s=rp(n),a=0;for(let l=0,u=0,d=0,f=0;l<s.length;l++){let m=s[l];for(let h=0;h<32;h++)if(d+=m&1,m>>=1,a+=1,a===o)f=d,d=0;else if(a===2*o)i[u++]=Yl(f-d),d=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return i}var zJ=(e)=>{let{K:t,PRF:r,XOF:o,HASH512:n,ETA1:i,ETA2:s,du:a,dv:l}=e,u=Gl(1),d=Gl(l),f=Gl(a),m=ms("publicKey",gp(Gl(12),t),32),h=gp(Gl(12),t),b=ms("ciphertext",gp(f,t),d),y=ms("seed",32,32);return{secretCoder:h,lengths:{secretKey:h.bytesLen,publicKey:m.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{Te(S,32,"seed");let x=new Uint8Array(33);x.set(S),x[32]=t;let _=n(x),[A,O]=y.decode(_),L=[],z=[];for(let W=0;W<t;W++)L.push(hs.encode(Ql(r,O,W,i)));let H=o(A);for(let W=0;W<t;W++){let ee=hs.encode(Ql(r,O,t+W,i));for(let j=0;j<t;j++){let R=_C(H.get(j,W));gs(ee,yp(R,L[j]))}z.push(ee)}H.clean();let P={publicKey:m.encode([z,A]),secretKey:h.encode(L)};return $t(A,O,L,z,x,_),P},encrypt:(S,x,_)=>{let[A,O]=m.decode(S),L=[];for(let j=0;j<t;j++)L.push(hs.encode(Ql(r,_,j,i)));let z=o(O),H=new Uint16Array(er),P=[];for(let j=0;j<t;j++){let R=Ql(r,_,t+j,s),B=new Uint16Array(er);for(let k=0;k<t;k++){let T=_C(z.get(j,k));gs(B,yp(T,L[k]))}gs(R,hs.decode(B)),P.push(R),gs(H,yp(A[j],L[j])),$t(B)}z.clean();let W=Ql(r,_,2*t,s);gs(W,hs.decode(H));let ee=u.decode(x);return gs(ee,W),$t(A,L,H,W),b.encode([P,ee])},decrypt:(S,x)=>{let[_,A]=b.decode(S),O=h.decode(x),L=new Uint16Array(er);for(let z=0;z<t;z++)gs(L,yp(O[z],hs.encode(_[z])));return CJ(A,hs.decode(L)),$t(L,O,_),u.encode(A)}}};function eS(e){let t=zJ(e),{HASH256:r,HASH512:o,KDF:n}=e,{secretCoder:i,lengths:s}=t,a=ms("secretKey",s.secretKey,s.publicKey,32,32),l=32,u=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(d=Pn(64))=>{Te(d,64,"seed");let{publicKey:f,secretKey:m}=t.keygen(d.subarray(0,32)),h=r(f),b=a.encode([m,f,h,d.subarray(32)]);return $t(m,h),{publicKey:f,secretKey:b}},getPublicKey:(d)=>{let[f,m,h,b]=a.decode(d);return Uint8Array.from(m)},encapsulate:(d,f=Pn(32))=>{Te(d,s.publicKey,"publicKey"),Te(f,32,"message");let m=d.subarray(0,384*e.K),h=i.encode(i.decode(vC(m)));if(!hp(h,m))throw $t(h),Error("ML-KEM.encapsulate: wrong publicKey modulus");$t(h);let b=o.create().update(f).update(r(d)).digest(),y=t.encrypt(d,f,b.subarray(32,64));return $t(b.subarray(32)),{cipherText:y,sharedSecret:b.subarray(0,32)}},decapsulate:(d,f)=>{Te(f,a.bytesLen,"secretKey"),Te(d,s.cipherText,"cipherText");let m=a.bytesLen-96,h=m+32,b=r(f.subarray(m/2,h));if(!hp(b,f.subarray(h,h+32)))throw Error("invalid secretKey: hash check failed");let[y,S,x,_]=a.decode(f),A=t.decrypt(d,y),O=o.create().update(A).update(x).digest(),L=O.subarray(0,32),z=t.encrypt(S,A,O.subarray(32,64)),H=hp(d,z),P=n.create({dkLen:32}).update(_).update(d).digest();return $t(A,z,!H?L:P),H?L:P}}}function NJ(e,t,r){return Cn.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var tS={HASH256:ps,HASH512:mC,KDF:Cn,XOF:xC,PRF:NJ},Nge=eS({...tS,...Xb[512]}),Xl=eS({...tS,...Xb[768]}),EC=eS({...tS,...Xb[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function DJ(e,t=!1){let{lengths:r,keygen:o}=e;if(t){let i=e.Point.Fn;if(!i)throw Error("No Point.Fn");o=(s=Pn(r.seed))=>{Te(s,r.seed,"seed");let a=i.isLE?Xo(s):Yo(s),l=i.toBytes(i.create(a));return{secretKey:l,publicKey:e.getPublicKey(l)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:o,getPublicKey:(n)=>e.getPublicKey(n)}}function rS(e,t=!1){let r=DJ(e,t);if(!e.getSharedSecret)throw Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(o,n=Pn(e.lengths.seed)){let i=this.keygen(n).secretKey,s=this.decapsulate(o,i),a=e.getPublicKey(i);return $t(i),{sharedSecret:s,cipherText:a}},decapsulate(o,n){let i=e.getSharedSecret(n,o);return e.lengths.publicKeyHasPrefix?i.subarray(1):i}}}function eu(e,t){return ms(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function nS(e){return(t,r)=>e(t,{dkLen:r})}function LJ(e,t,...r){let o=eu(r,"seed"),n=eu(r,"publicKey");if(e===void 0)e=o.bytesLen;Lt(e);function i(s){Te(s,e);let a=o.decode(t(s,o.bytesLen)),l=r.map((f,m)=>f.keygen(a[m])),u=l.map((f)=>f.secretKey),d=l.map((f)=>f.publicKey);return{secretKey:u,publicKey:d}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Pn(e)){let{publicKey:a,secretKey:l}=i(s),u=n.encode(a);return $t(a),$t(l),{secretKey:s,publicKey:u}},expandDecapsulationKey:i,realSeedLen:e}}function bp(e,t,r,o,...n){let i=LJ(e,r,...n),s=eu(n,"cipherText"),a=eu(n,"publicKey"),l=eu(n,"msg");if(t===void 0)t=l.bytesLen;return Lt(t),{lengths:{...i.info.lengths,msg:t,msgRand:l.bytesLen,cipherText:s.bytesLen},getPublicKey:i.getPublicKey,keygen:i.keygen,encapsulate(u,d=Pn(l.bytesLen)){let f=a.decode(u),m=l.decode(d),h=n.map((x,_)=>x.encapsulate(f[_],m[_])),b=h.map((x)=>x.sharedSecret),y=h.map((x)=>x.cipherText),S={sharedSecret:o(f,y,b),cipherText:s.encode(y)};return $t(b,y),S},decapsulate(u,d){let f=s.decode(u),{publicKey:m,secretKey:h}=i.expandDecapsulationKey(d),b=n.map((y,S)=>y.decapsulate(f[S],h[S]));return o(m,f,b)}}}function kC(e,t,r,o,n){return qr(o),qr(n),bp(32,32,nS(o),(i,s,a)=>n(Et(a[0],a[1],s[1],i[1],ei(e))),t,r)}var Hge=kC("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Xl,rS(Kb,!0),Cn,ps),Kge=kC("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",EC,rS(nC,!0),Cn,ps);function BJ(e,t,r,o,n){return qr(o),qr(n),bp(32,32,nS(o),(i,s,a)=>{let l=Et(a[0],a[1],s[0],i[0],s[1],i[1],ei(e)),u=32,d=Et(ei("hybrid_prk"),l),f=iC(n,d),m=Et(xa(32,2),ei("shared_secret"),ei("")),h=sC(n,f,m,32);return $t(f,m,d,l),h},t,r)}var IC=rS(rC),Vge=BJ("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Xl,IC,Cn,pp),jJ=(()=>bp(32,32,nS(Cn),(e,t,r)=>ps(Et(r[0],r[1],t[1],e[1],ei("\\.//^\\"))),Xl,IC))();function ZJ(e,t,r,o){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function i(s){let a;for(let d=0,f=t;;d=f,f+=t){if(f>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(d,f),!0),n.isValidNot0(a))break}let l=n.toBytes(n.create(a)),u=e.getPublicKey(l,!1);return{secretKey:l,publicKey:u}}return{lengths:{secretKey:t,publicKey:r,seed:o,msg:o,cipherText:r},keygen(s=Pn(o)){return Te(s,o,"seed"),i(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Pn(o)){Te(a,o,"rand");let{secretKey:l}=i(a),u=this.decapsulate(s,l),d=e.getPublicKey(l,!1);return $t(l),{sharedSecret:u,cipherText:d}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function UJ(e,t,r,o){let{secretKey:n,publicKeyUncompressed:i}=r.lengths;if(!n||!i)throw Error("wrong curve");let s=ZJ(r,n,i,o),a=64,l=a+o;return bp(32,32,(u)=>{Te(u,32);let d=Cn(u,{dkLen:l}),f=d.subarray(0,a),m=d.subarray(a,l);return Et(f,m)},(u,d,f)=>ps(Et(f[0],f[1],d[1],u[1],ei(e))),t,s)}var MJ=(()=>UJ("MLKEM768-P256",Xl,Kb,128))();var Sp=jJ,AC=MJ;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ye=(e,t,r)=>Mt(e,t,r),iS=St,Aa=qf,Ht=(...e)=>cb(...e),Ta=(e)=>Ol(e),Ra=ib,$a=(e)=>oo(e),wp=BigInt(0),oS=BigInt(1);function po(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function xp(e){if(typeof e==="bigint"){if(!vp(e))throw RangeError("positive bigint expected, got "+e)}else iS(e);return e}function zn(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw RangeError(r+"expected safe integer, got "+e)}}function tu(e){let t=xp(e).toString(16);return t.length&1?"0"+t:t}function TC(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?wp:BigInt("0x"+e)}function ys(e){return TC(qf(e))}function sn(e){return TC(qf(ii(Mt(e)).reverse()))}function _p(e,t){if(St(t),t===0)throw RangeError("zero length");e=xp(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return Ol(r.padStart(t*2,"0"))}function ru(e,t){return _p(e,t).reverse()}function RC(e,t){if(e=Ye(e),t=Ye(t),e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function ii(e){return Uint8Array.from(Ye(e))}function Ep(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var vp=(e)=>typeof e==="bigint"&&wp<=e;function qJ(e,t,r){return vp(e)&&vp(t)&&vp(r)&&t<=e&&e<r}function mo(e,t,r,o){if(!qJ(t,r,o))throw RangeError("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Oa(e){if(e<wp)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>wp;e>>=oS,t+=1);return t}var nu=(e)=>(oS<<BigInt(e))-oS;function $C(e,t,r){if(St(e,"hashLen"),St(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,l=o(e),u=o(e),d=0,f=()=>{l.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Ht(l,...S)),h=(S=n)=>{if(u=m(i,S),l=m(),S.length===0)return;u=m(s,S),l=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){l=m();let _=l.slice();x.push(_),S+=l.length}return Ht(...x)};return(S,x)=>{f(),h(S);let _=void 0;while((_=x(b()))===void 0)h();return f(),_}}function Jr(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function o(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw TypeError(`param "${i}" is invalid: expected own property`);let l=e[i];if(a&&l===void 0)return;let u=typeof l;if(u!==s||l===null)throw TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,l])=>o(a,l,s));n(t,!1),n(r,!0)}var sS=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Kt=BigInt(0),mt=BigInt(1),bs=BigInt(2),zC=BigInt(3),NC=BigInt(4),DC=BigInt(5),FJ=BigInt(7),LC=BigInt(8),JJ=BigInt(9),BC=BigInt(16);function it(e,t){if(t<=Kt)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Kt?r:t+r}function Hr(e,t,r){if(t<Kt)throw Error("pow2: expected non-negative exponent, got "+t);let o=e;while(t-- >Kt)o*=o,o%=r;return o}function OC(e,t){if(e===Kt)throw Error("invert: expected non-zero number");if(t<=Kt)throw Error("invert: expected positive modulus, got "+t);let r=it(e,t),o=t,n=Kt,i=mt,s=mt,a=Kt;while(r!==Kt){let u=o/r,d=o-r*u,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==mt)throw Error("invert: does not exist");return it(n,t)}function aS(e,t,r){let o=e;if(!o.eql(o.sqr(t),r))throw Error("Cannot find square root")}function jC(e,t){let r=e,o=(r.ORDER+mt)/NC,n=r.pow(t,o);return aS(r,n,t),n}function HJ(e,t){let r=e,o=(r.ORDER-DC)/LC,n=r.mul(t,bs),i=r.pow(n,o),s=r.mul(t,i),a=r.mul(r.mul(s,bs),i),l=r.mul(s,r.sub(a,r.ONE));return aS(r,l,t),l}function KJ(e){let t=kp(e),r=ZC(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+FJ)/BC;return(a,l)=>{let u=a,d=u.pow(l,s),f=u.mul(d,o),m=u.mul(d,n),h=u.mul(d,i),b=u.eql(u.sqr(f),l),y=u.eql(u.sqr(m),l);d=u.cmov(d,f,b),f=u.cmov(h,m,y);let S=u.eql(u.sqr(f),l),x=u.cmov(d,f,S);return aS(u,x,l),x}}function ZC(e){if(e<zC)throw Error("sqrt is not defined for small field");let t=e-mt,r=0;while(t%bs===Kt)t/=bs,r++;let o=bs,n=kp(e);while(CC(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return jC;let i=n.pow(o,t),s=(t+mt)/bs;return function(l,u){let d=l;if(d.is0(u))return u;if(CC(d,u)!==1)throw Error("Cannot find square root");let f=r,m=d.mul(d.ONE,i),h=d.pow(u,t),b=d.pow(u,s);while(!d.eql(h,d.ONE)){if(d.is0(h))return d.ZERO;let y=1,S=d.sqr(h);while(!d.eql(S,d.ONE))if(y++,S=d.sqr(S),y===f)throw Error("Cannot find square root");let x=mt<<BigInt(f-y-1),_=d.pow(m,x);f=y,m=d.sqr(_),h=d.mul(h,m),b=d.mul(b,_)}return b}}function VJ(e){if(e%NC===zC)return jC;if(e%LC===DC)return HJ;if(e%BC===JJ)return KJ(e);return ZC(e)}var ho=(e,t)=>(it(e,t)&mt)===mt,WJ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function cS(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=WJ.reduce((o,n)=>(o[n]="function",o),t);if(Jr(e,r),zn(e.BYTES,"BYTES"),zn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=mt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function GJ(e,t,r){let o=e;if(r<Kt)throw Error("invalid exponent, negatives unsupported");if(r===Kt)return o.ONE;if(r===mt)return t;let n=o.ONE,i=t;while(r>Kt){if(r&mt)n=o.mul(n,i);i=o.sqr(i),r>>=mt}return n}function ou(e,t,r=!1){let o=e,n=Array(t.length).fill(r?o.ZERO:void 0),i=t.reduce((a,l,u)=>{if(o.is0(l))return a;return n[u]=a,o.mul(a,l)},o.ONE),s=o.inv(i);return t.reduceRight((a,l,u)=>{if(o.is0(l))return a;return n[u]=o.mul(a,n[u]),o.mul(a,l)},s),n}function CC(e,t){let r=e,o=(r.ORDER-mt)/bs,n=r.pow(t,o),i=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!i&&!s&&!a)throw Error("invalid Legendre symbol result");return i?1:s?0:-1}function QJ(e,t){if(t!==void 0)iS(t);if(e<=Kt)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 r=Oa(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let o=t!==void 0?t:r,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}var PC=new WeakMap;class lS{ORDER;BITS;BYTES;isLE;ZERO=Kt;ONE=mt;_lengths;_mod;constructor(e,t={}){if(e<=mt)throw Error("invalid field: expected ORDER > 1, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0});if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=Object.freeze(t.allowedLengths.slice());if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=QJ(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,Object.freeze(this)}create(e){return it(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return Kt<=e&&e<this.ORDER}is0(e){return e===Kt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&mt)===mt}neg(e){return it(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return it(e*e,this.ORDER)}add(e,t){return it(e+t,this.ORDER)}sub(e,t){return it(e-t,this.ORDER)}mul(e,t){return it(e*t,this.ORDER)}pow(e,t){return GJ(this,e,t)}div(e,t){return it(e*OC(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 OC(e,this.ORDER)}sqrt(e){let t=PC.get(this);if(!t)PC.set(this,t=VJ(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?ru(e,this.BYTES):_p(e,this.BYTES)}fromBytes(e,t=!1){Ye(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let l=new Uint8Array(o);l.set(e,n?0:l.length-e.length),e=l}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?sn(e):ys(e);if(s)a=it(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ou(this,e)}cmov(e,t,r){return po(r,"condition"),r?t:e}}Object.freeze(lS.prototype);function kp(e,t={}){return new lS(e,t)}function UC(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=mt)throw Error("field order must be greater than 1");let t=Oa(e-mt);return Math.ceil(t/8)}function uS(e){let t=UC(e);return t+Math.ceil(t/2)}function MC(e,t,r=!1){Ye(e);let o=e.length,n=UC(t),i=Math.max(uS(t),16);if(o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?sn(e):ys(e),a=it(s,t-mt)+mt;return r?ru(a,n):_p(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ca=BigInt(0),Ss=BigInt(1);function iu(e,t){let r=t.negate();return e?r:t}function vs(e,t){let r=ou(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function HC(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function dS(e,t){HC(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=nu(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function qC(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),l=e>>s;if(a>o)a-=i,l+=Ss;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:l,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var fS=new WeakMap,KC=new WeakMap;function pS(e){return KC.get(e)||1}function FC(e){if(e!==Ca)throw Error("invalid wNAF")}class su{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Ca){if(t&Ss)r=r.add(o);o=o.double(),t>>=Ss}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=dS(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let l=1;l<o;l++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=dS(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:l,isZero:u,isNeg:d,isNegF:f,offsetF:m}=qC(r,s,i);if(r=a,u)n=n.add(iu(f,t[m]));else o=o.add(iu(d,t[l]))}return FC(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=dS(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Ca)break;let{nextN:s,offset:a,isZero:l,isNeg:u}=qC(r,i,n);if(r=s,l)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return FC(r),o}getPrecomputes(e,t,r){let o=fS.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);fS.set(t,o)}}return o}cached(e,t,r){let o=pS(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=pS(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){HC(t,this.bits),KC.set(e,t),fS.delete(e)}hasCache(e){return pS(e)!==1}}function VC(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Ca||o>Ca){if(r&Ss)i=i.add(n);if(o&Ss)s=s.add(n);n=n.double(),r>>=Ss,o>>=Ss}return{p1:i,p2:s}}function JC(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return cS(t),t}else return kp(e,{isLE:r})}function Ip(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let l of["p","n","h"]){let u=t[l];if(!(typeof u==="bigint"&&u>Ca))throw Error(`CURVE.${l} must be positive bigint`)}let n=JC(t.p,r.Fp,o),i=JC(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let l of a)if(!n.isValid(t[l]))throw Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function au(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}function cu(e,t){if(zn(e),zn(t),t<0||t>4)throw Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--)r[o]=e&255,e>>>=8;return new Uint8Array(r)}function YJ(e,t){let r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e[o]^t[o];return r}function XJ(e){if(!Ra(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?Ep(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function mS(e,t,r,o){if(Ye(e),zn(r),t=XJ(t),t.length>255)t=o(Ht(Ep("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:i}=o,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=Ht(t,cu(t.length,1)),l=new Uint8Array(i),u=cu(r,2),d=Array(s),f=o(Ht(l,e,u,cu(0,1),a));d[0]=o(Ht(f,cu(1,1),a));for(let h=1;h<s;h++){let b=[YJ(f,d[h-1]),cu(h+1,1),a];d[h]=o(Ht(...b))}return Ht(...d).slice(0,r)}var WC="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var GC=(e,t)=>(e+(e>=0?t:-t)/YC)/t;function eH(e,t,r){mo("scalar",e,Nn,r);let[[o,n],[i,s]]=t,a=GC(s*e,r),l=GC(-n*e,r),u=e-a*o-l*i,d=-a*n-l*s,f=u<Nn,m=d<Nn;if(f)u=-u;if(m)d=-d;let h=nu(Math.ceil(Oa(r)/2))+si;if(u<Nn||u>=h||d<Nn||d>=h)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:u,k2neg:m,k2:d}}function gS(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function hS(e,t){Jr(e);let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(po(r.lowS,"lowS"),po(r.prehash,"prehash"),r.format!==void 0)gS(r.format);return r}class QC extends Error{constructor(e=""){super(e)}}var an={Err:QC,_tlv:{encode:(e,t)=>{let{Err:r}=an;if(zn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!=="string")throw TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=tu(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?tu(n.length/2|128):"";return tu(e)+i+n+t},decode(e,t){let{Err:r}=an;t=Ye(t,void 0,"DER data");let o=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let l=n&127;if(!l)throw new r("tlv.decode(long): indefinite length not supported");if(l>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+l);if(u.length!==l)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=l,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=an;if(xp(e),e<Nn)throw new t("integer: negative integers are not allowed");let r=tu(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=an;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 ys(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=an,n=Ye(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l}=o.decode(2,i),{v:u,l:d}=o.decode(2,l);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=an,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}};Object.freeze(an._tlv);Object.freeze(an._int);Object.freeze(an);var Nn=BigInt(0),si=BigInt(1),YC=BigInt(2),Ap=BigInt(3),tH=BigInt(4);function XC(e,t={}){let r=Ip("weierstrass",e,t),o=r.Fp,n=r.Fn,i=r.CURVE,{h:s,n:a}=i;Jr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:l,allowInfinityPoint:u}=t;if(l){if(!o.is0(i.a)||typeof l.beta!=="bigint"||!Array.isArray(l.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let d=t1(o,n);function f(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function m(j,R,B){if(u&&R.is0())return Uint8Array.of(0);let{x:k,y:T}=R.toAffine(),I=o.toBytes(k);if(po(B,"isCompressed"),B){f();let q=!o.isOdd(T);return Ht(e1(q),I)}else return Ht(Uint8Array.of(4),I,o.toBytes(T))}function h(j){Ye(j,void 0,"Point");let{publicKey:R,publicKeyUncompressed:B}=d,k=j.length,T=j[0],I=j.subarray(1);if(u&&k===1&&T===0)return{x:o.ZERO,y:o.ZERO};if(k===R&&(T===2||T===3)){let q=o.fromBytes(I);if(!o.isValid(q))throw Error("bad point: is not on curve, wrong x");let N=S(q),K;try{K=o.sqrt(N)}catch(ae){let pe=ae instanceof Error?": "+ae.message:"";throw Error("bad point: is not on curve, sqrt error"+pe)}f();let G=o.isOdd(K);if((T&1)===1!==G)K=o.neg(K);return{x:q,y:K}}else if(k===B&&T===4){let q=o.BYTES,N=o.fromBytes(I.subarray(0,q)),K=o.fromBytes(I.subarray(q,q*2));if(!x(N,K))throw Error("bad point: is not on curve");return{x:N,y:K}}else throw Error(`bad point: got length ${k}, expected compressed=${R} or uncompressed=${B}`)}let b=t.toBytes===void 0?m:t.toBytes,y=t.fromBytes===void 0?h:t.fromBytes;function S(j){let R=o.sqr(j),B=o.mul(R,j);return o.add(o.add(B,o.mul(j,i.a)),i.b)}function x(j,R){let B=o.sqr(R),k=S(j);return o.eql(B,k)}if(!x(i.Gx,i.Gy))throw Error("bad curve params: generator point");let _=o.mul(o.pow(i.a,Ap),tH),A=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(_,A)))throw Error("bad curve params: a or b");function O(j,R,B=!1){if(!o.isValid(R)||B&&o.is0(R))throw Error(`bad point coordinate ${j}`);return R}function L(j){if(!(j instanceof P))throw Error("Weierstrass Point expected")}function z(j){if(!l||!l.basises)throw Error("no endo");return eH(j,l.basises,n.ORDER)}function H(j,R,B,k,T){return B=new P(o.mul(B.X,j),B.Y,B.Z),R=iu(k,R),B=iu(T,B),R.add(B)}class P{static BASE=new P(i.Gx,i.Gy,o.ONE);static ZERO=new P(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(j,R,B){this.X=O("x",j),this.Y=O("y",R,!0),this.Z=O("z",B),Object.freeze(this)}static CURVE(){return i}static fromAffine(j){let{x:R,y:B}=j||{};if(!j||!o.isValid(R)||!o.isValid(B))throw Error("invalid affine point");if(j instanceof P)throw Error("projective point not allowed");if(o.is0(R)&&o.is0(B))return P.ZERO;return new P(R,B,o.ONE)}static fromBytes(j){let R=P.fromAffine(y(Ye(j,void 0,"point")));return R.assertValidity(),R}static fromHex(j){return P.fromBytes(Ta(j))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(j=8,R=!0){if(ee.createCache(this,j),!R)this.multiply(Ap);return this}assertValidity(){let j=this;if(j.is0()){if(t.allowInfinityPoint&&o.is0(j.X)&&o.eql(j.Y,o.ONE)&&o.is0(j.Z))return;throw Error("bad point: ZERO")}let{x:R,y:B}=j.toAffine();if(!o.isValid(R)||!o.isValid(B))throw Error("bad point: x or y not field elements");if(!x(R,B))throw Error("bad point: equation left != right");if(!j.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:j}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(j)}equals(j){L(j);let{X:R,Y:B,Z:k}=this,{X:T,Y:I,Z:q}=j,N=o.eql(o.mul(R,q),o.mul(T,k)),K=o.eql(o.mul(B,q),o.mul(I,k));return N&&K}negate(){return new P(this.X,o.neg(this.Y),this.Z)}double(){let{a:j,b:R}=i,B=o.mul(R,Ap),{X:k,Y:T,Z:I}=this,q=o.ZERO,N=o.ZERO,K=o.ZERO,G=o.mul(k,k),re=o.mul(T,T),ae=o.mul(I,I),pe=o.mul(k,T);return pe=o.add(pe,pe),K=o.mul(k,I),K=o.add(K,K),q=o.mul(j,K),N=o.mul(B,ae),N=o.add(q,N),q=o.sub(re,N),N=o.add(re,N),N=o.mul(q,N),q=o.mul(pe,q),K=o.mul(B,K),ae=o.mul(j,ae),pe=o.sub(G,ae),pe=o.mul(j,pe),pe=o.add(pe,K),K=o.add(G,G),G=o.add(K,G),G=o.add(G,ae),G=o.mul(G,pe),N=o.add(N,G),ae=o.mul(T,I),ae=o.add(ae,ae),G=o.mul(ae,pe),q=o.sub(q,G),K=o.mul(ae,re),K=o.add(K,K),K=o.add(K,K),new P(q,N,K)}add(j){L(j);let{X:R,Y:B,Z:k}=this,{X:T,Y:I,Z:q}=j,N=o.ZERO,K=o.ZERO,G=o.ZERO,re=i.a,ae=o.mul(i.b,Ap),pe=o.mul(R,T),be=o.mul(B,I),ve=o.mul(k,q),Ae=o.add(R,B),Ie=o.add(T,I);Ae=o.mul(Ae,Ie),Ie=o.add(pe,be),Ae=o.sub(Ae,Ie),Ie=o.add(R,k);let we=o.add(T,q);return Ie=o.mul(Ie,we),we=o.add(pe,ve),Ie=o.sub(Ie,we),we=o.add(B,k),N=o.add(I,q),we=o.mul(we,N),N=o.add(be,ve),we=o.sub(we,N),G=o.mul(re,Ie),N=o.mul(ae,ve),G=o.add(N,G),N=o.sub(be,G),G=o.add(be,G),K=o.mul(N,G),be=o.add(pe,pe),be=o.add(be,pe),ve=o.mul(re,ve),Ie=o.mul(ae,Ie),be=o.add(be,ve),ve=o.sub(pe,ve),ve=o.mul(re,ve),Ie=o.add(Ie,ve),pe=o.mul(be,Ie),K=o.add(K,pe),pe=o.mul(we,Ie),N=o.mul(Ae,N),N=o.sub(N,pe),pe=o.mul(Ae,be),G=o.mul(we,G),G=o.add(G,pe),new P(N,K,G)}subtract(j){return L(j),this.add(j.negate())}is0(){return this.equals(P.ZERO)}multiply(j){let{endo:R}=t;if(!n.isValidNot0(j))throw RangeError("invalid scalar: out of range");let B,k,T=(I)=>ee.cached(this,I,(q)=>vs(P,q));if(R){let{k1neg:I,k1:q,k2neg:N,k2:K}=z(j),{p:G,f:re}=T(q),{p:ae,f:pe}=T(K);k=re.add(pe),B=H(R.beta,G,ae,I,N)}else{let{p:I,f:q}=T(j);B=I,k=q}return vs(P,[B,k])[0]}multiplyUnsafe(j){let{endo:R}=t,B=this,k=j;if(!n.isValid(k))throw RangeError("invalid scalar: out of range");if(k===Nn||B.is0())return P.ZERO;if(k===si)return B;if(ee.hasCache(this))return this.multiply(k);if(R){let{k1neg:T,k1:I,k2neg:q,k2:N}=z(k),{p1:K,p2:G}=VC(P,B,I,N);return H(R.beta,K,G,T,q)}else return ee.unsafe(B,k)}toAffine(j){let R=this,B=j,{X:k,Y:T,Z:I}=R;if(o.eql(I,o.ONE))return{x:k,y:T};let q=R.is0();if(B==null)B=q?o.ONE:o.inv(I);let N=o.mul(k,B),K=o.mul(T,B),G=o.mul(I,B);if(q)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:K}}isTorsionFree(){let{isTorsionFree:j}=t;if(s===si)return!0;if(j)return j(P,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:j}=t;if(s===si)return this;if(j)return j(P,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===si)return this.is0();return this.clearCofactor().is0()}toBytes(j=!0){return po(j,"isCompressed"),this.assertValidity(),b(P,this,j)}toHex(j=!0){return Aa(this.toBytes(j))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=n.BITS,ee=new su(P,t.endo?Math.ceil(W/2):W);if(W>=8)P.BASE.precompute(8);return Object.freeze(P.prototype),Object.freeze(P),P}function e1(e){return Uint8Array.of(e?2:3)}function t1(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function rH(e,t={}){let{Fn:r}=e,o=t.randomBytes===void 0?$a:t.randomBytes,n=Object.assign(t1(e.Fp,r),{seed:Math.max(uS(r.ORDER),16)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h){return h=h===void 0?o(n.seed):h,MC(Ye(h,n.seed,"seed"),r.ORDER)}function l(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n,x=r._lengths;if(!Ra(h))return;let _=Ye(h,void 0,"key").length,A=_===y||_===S,O=_===b||!!x?.includes(_);if(A&&O)return;return A}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=au(a,l);return Object.freeze(f),Object.freeze(n),Object.freeze({getPublicKey:l,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function r1(e,t,r={}){let o=t;no(o),Jr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?$a:r.randomBytes,i=r.hmac===void 0?(T,I)=>Tn(o,T,I):r.hmac,{Fp:s,Fn:a}=e,{ORDER:l,BITS:u}=a,{keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b}=rH(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=l*YC+si<s.ORDER;function x(T){let I=l>>si;return T>I}function _(T,I){if(!a.isValidNot0(I))throw Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return I}function A(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(T,I){gS(I);let q=b.signature,N=I==="compact"?q:I==="recovered"?q+1:void 0;return Ye(T,N)}class L{r;s;recovery;constructor(T,I,q){if(this.r=_("r",T),this.s=_("s",I),q!=null){if(A(),![0,1,2,3].includes(q))throw Error("invalid recovery id");this.recovery=q}Object.freeze(this)}static fromBytes(T,I=y.format){O(T,I);let q;if(I==="der"){let{r:re,s:ae}=an.toSig(Ye(T));return new L(re,ae)}if(I==="recovered")q=T[0],I="compact",T=T.subarray(1);let N=b.signature/2,K=T.subarray(0,N),G=T.subarray(N,N*2);return new L(a.fromBytes(K),a.fromBytes(G),q)}static fromHex(T,I){return this.fromBytes(Ta(T),I)}assertRecovery(){let{recovery:T}=this;if(T==null)throw Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new L(this.r,this.s,T)}recoverPublicKey(T){let{r:I,s:q}=this,N=this.assertRecovery(),K=N===2||N===3?I+l:I;if(!s.isValid(K))throw Error("invalid recovery id: sig.r+curve.n != R.x");let G=s.toBytes(K),re=e.fromBytes(Ht(e1((N&1)===0),G)),ae=a.inv(K),pe=H(Ye(T,void 0,"msgHash")),be=a.create(-pe*ae),ve=a.create(q*ae),Ae=e.BASE.multiplyUnsafe(be).add(re.multiplyUnsafe(ve));if(Ae.is0())throw Error("invalid recovery: point at infinify");return Ae.assertValidity(),Ae}hasHighS(){return x(this.s)}toBytes(T=y.format){if(gS(T),T==="der")return Ta(an.hexFromSig(this));let{r:I,s:q}=this,N=a.toBytes(I),K=a.toBytes(q);if(T==="recovered")return A(),Ht(Uint8Array.of(this.assertRecovery()),N,K);return Ht(N,K)}toHex(T){return Aa(this.toBytes(T))}}Object.freeze(L.prototype),Object.freeze(L);let z=r.bits2int===void 0?function(I){if(I.length>8192)throw Error("input is too large");let q=ys(I),N=I.length*8-u;return N>0?q>>BigInt(N):q}:r.bits2int,H=r.bits2int_modN===void 0?function(I){return a.create(z(I))}:r.bits2int_modN,P=nu(u);function W(T){return mo("num < 2^"+u,T,Nn,P),a.toBytes(T)}function ee(T,I){return Ye(T,void 0,"message"),I?Ye(o(T),void 0,"prehashed message"):T}function j(T,I,q){let{lowS:N,prehash:K,extraEntropy:G}=hS(q,y);T=ee(T,K);let re=H(T),ae=a.fromBytes(I);if(!a.isValidNot0(ae))throw Error("invalid private key");let pe=[W(ae),W(re)];if(G!=null&&G!==!1){let Ie=G===!0?n(b.secretKey):G;pe.push(Ye(Ie,void 0,"extraEntropy"))}let be=Ht(...pe),ve=re;function Ae(Ie){let we=z(Ie);if(!a.isValidNot0(we))return;let Ue=a.inv(we),De=e.BASE.multiply(we).toAffine(),Qe=a.create(De.x);if(Qe===Nn)return;let bt=a.create(Ue*a.create(ve+Qe*ae));if(bt===Nn)return;let Tt=(De.x===Qe?0:2)|Number(De.y&si),Dt=bt;if(N&&x(bt))Dt=a.neg(bt),Tt^=1;return new L(Qe,Dt,S?void 0:Tt)}return{seed:be,k2sig:Ae}}function R(T,I,q={}){let{seed:N,k2sig:K}=j(T,I,q);return $C(o.outputLen,a.BYTES,i)(N,K).toBytes(q.format)}function B(T,I,q,N={}){let{lowS:K,prehash:G,format:re}=hS(N,y);if(q=Ye(q,void 0,"publicKey"),I=ee(I,G),!Ra(T)){let ae=T instanceof L?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}O(T,re);try{let ae=L.fromBytes(T,re),pe=e.fromBytes(q);if(K&&ae.hasHighS())return!1;let{r:be,s:ve}=ae,Ae=H(I),Ie=a.inv(ve),we=a.create(Ae*Ie),Ue=a.create(be*Ie),De=e.BASE.multiplyUnsafe(we).add(pe.multiplyUnsafe(Ue));if(De.is0())return!1;return a.create(De.x)===be}catch(ae){return!1}}function k(T,I,q={}){let{prehash:N}=hS(q,y);return I=ee(I,N),L.fromBytes(T,"recovered").recoverPublicKey(I).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b,Point:e,sign:R,verify:B,recoverPublicKey:k,Signature:L,hash:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var nH=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var oH=XC(nH),Pa=r1(oH,vt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ai=BigInt(0),wr=BigInt(1),yS=BigInt(2),iH=BigInt(8);function sH(e,t,r,o){let n=e.sqr(r),i=e.sqr(o),s=e.add(e.mul(t.a,n),i),a=e.add(e.ONE,e.mul(t.d,e.mul(n,i)));return e.eql(s,a)}function n1(e,t={}){let r=t,o=Ip("edwards",e,r,r.FpFnLE),{Fp:n,Fn:i}=o,s=o.CURVE,{h:a}=s;Jr(r,{},{uvRatio:"function"});let l=yS<<BigInt(i.BYTES*8)-wr,u=(y)=>n.create(y),d=r.uvRatio===void 0?(y,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(y,S))}}catch(x){return{isValid:!1,value:ai}}}:r.uvRatio;if(!sH(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function f(y,S,x=!1){let _=x?wr:ai;return mo("coordinate "+y,S,_,l),S}function m(y){if(!(y instanceof h))throw Error("EdwardsPoint expected")}class h{static BASE=new h(s.Gx,s.Gy,wr,u(s.Gx*s.Gy));static ZERO=new h(ai,wr,wr,ai);static Fp=n;static Fn=i;X;Y;Z;T;constructor(y,S,x,_){this.X=f("x",y),this.Y=f("y",S),this.Z=f("z",x,!0),this.T=f("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof h)throw Error("extended point not allowed");let{x:S,y:x}=y||{};return f("x",S),f("y",x),new h(S,x,wr,u(S*x))}static fromBytes(y,S=!1){let x=n.BYTES,{a:_,d:A}=s;y=ii(Ye(y,x,"point")),po(S,"zip215");let O=ii(y),L=y[x-1];O[x-1]=L&-129;let z=sn(O),H=S?l:n.ORDER;mo("point.y",z,ai,H);let P=u(z*z),W=u(P-wr),ee=u(A*P-_),{isValid:j,value:R}=d(W,ee);if(!j)throw Error("bad point: invalid y coordinate");let B=(R&wr)===wr,k=(L&128)!==0;if(!S&&R===ai&&k)throw Error("bad point: x=0 and x_0=1");if(k!==B)R=u(-R);return h.fromAffine({x:R,y:z})}static fromHex(y,S=!1){return h.fromBytes(Ta(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){if(b.createCache(this,y),!S)this.multiply(yS);return this}assertValidity(){let y=this,{a:S,d:x}=s;if(y.is0())throw Error("bad point: ZERO");let{X:_,Y:A,Z:O,T:L}=y,z=u(_*_),H=u(A*A),P=u(O*O),W=u(P*P),ee=u(z*S),j=u(P*u(ee+H)),R=u(W+u(x*u(z*H)));if(j!==R)throw Error("bad point: equation left != right (1)");let B=u(_*A),k=u(O*L);if(B!==k)throw Error("bad point: equation left != right (2)")}equals(y){m(y);let{X:S,Y:x,Z:_}=this,{X:A,Y:O,Z:L}=y,z=u(S*L),H=u(A*_),P=u(x*L),W=u(O*_);return z===H&&P===W}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:x,Z:_}=this,A=u(S*S),O=u(x*x),L=u(yS*u(_*_)),z=u(y*A),H=S+x,P=u(u(H*H)-A-O),W=z+O,ee=W-L,j=z-O,R=u(P*ee),B=u(W*j),k=u(P*j),T=u(ee*W);return new h(R,B,T,k)}add(y){m(y);let{a:S,d:x}=s,{X:_,Y:A,Z:O,T:L}=this,{X:z,Y:H,Z:P,T:W}=y,ee=u(_*z),j=u(A*H),R=u(L*x*W),B=u(O*P),k=u((_+A)*(z+H)-ee-j),T=B-R,I=B+R,q=u(j-S*ee),N=u(k*T),K=u(I*q),G=u(k*q),re=u(T*I);return new h(N,K,re,G)}subtract(y){return m(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:x}=b.cached(this,y,(_)=>vs(h,_));return vs(h,[S,x])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(y===ai)return h.ZERO;if(this.is0()||y===wr)return this;return b.unsafe(this,y,(S)=>vs(h,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(y){let S=this,x=y,{X:_,Y:A,Z:O}=S,L=S.is0();if(x==null)x=L?iH:n.inv(O);let z=u(_*x),H=u(A*x),P=n.mul(O,x);if(L)return{x:ai,y:wr};if(P!==wr)throw Error("invZ was invalid");return{x:z,y:H}}clearCofactor(){if(a===wr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),x=n.toBytes(S);return x[x.length-1]|=y&wr?128:0,x}toHex(){return Aa(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new su(h,i.BITS);if(i.BITS>=8)h.BASE.precompute(8);return Object.freeze(h.prototype),Object.freeze(h),h}class bS{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){sS()}static fromHex(e){sS()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Aa(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.ep.precompute(e,t),this}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lu=BigInt(0),za=BigInt(1),Tp=BigInt(2);function aH(e){return Jr(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function o1(e){let t=aH(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let l=s===void 0?$a:s,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?Tp**BigInt(254):Tp**BigInt(447),b=a?BigInt(8)*Tp**BigInt(251)-za:BigInt(4)*Tp**BigInt(445)-za,y=h+b+za,S=(k)=>it(k,r),x=_(f);function _(k){return ru(S(k),d)}function A(k){let T=ii(Ye(k,d,"uCoordinate"));if(a)T[31]&=127;return S(sn(T))}function O(k){return sn(n(ii(Ye(k,d,"scalar"))))}function L(k,T){let I=ee(A(T),O(k));if(I===lu)throw Error("invalid private or public key received");return _(I)}function z(k){return L(k,x)}let H=z,P=L;function W(k,T,I){let q=S(k*(T-I));return T=S(T-q),I=S(I+q),{x_2:T,x_3:I}}function ee(k,T){mo("u",k,lu,r),mo("scalar",T,h,y);let I=T,q=k,N=za,K=lu,G=k,re=za,ae=lu;for(let be=BigInt(u-1);be>=lu;be--){let ve=I>>be&za;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:K,x_3:re}=W(ae,K,re),ae=ve;let Ae=N+K,Ie=S(Ae*Ae),we=N-K,Ue=S(we*we),De=Ie-Ue,Qe=G+re,bt=G-re,Tt=S(bt*Ae),Dt=S(Qe*we),lt=Tt+Dt,Rr=Tt-Dt;G=S(lt*lt),re=S(q*S(Rr*Rr)),N=S(Ie*Ue),K=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:K,x_3:re}=W(ae,K,re);let pe=i(K);return S(N*pe)}let j={secretKey:d,publicKey:d,seed:d},R=(k)=>(k=k===void 0?l(d):k,Ye(k,j.seed,"seed"),k),B={randomSecretKey:R};return Object.freeze(j),Object.freeze(B),Object.freeze({keygen:au(R,H),getSharedSecret:P,getPublicKey:H,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var cH=BigInt(0),go=BigInt(1),i1=BigInt(2),lH=BigInt(3),uH=BigInt(5),dH=BigInt(8),xs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),xS=(()=>({p:xs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:dH,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function c1(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=xs,a=e*e%i*e%i,l=Hr(a,i1,i)*a%i,u=Hr(l,go,i)*e%i,d=Hr(u,uH,i)*u%i,f=Hr(d,t,i)*d%i,m=Hr(f,r,i)*f%i,h=Hr(m,o,i)*m%i,b=Hr(h,n,i)*h%i,y=Hr(b,n,i)*h%i,S=Hr(y,t,i)*d%i;return{pow_p_5_8:Hr(S,i1,i)*e%i,b2:a}}function fH(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var SS=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function _S(e,t){let r=xs,o=it(t*t*t,r),n=it(o*o*t,r),i=c1(e*n).pow_p_5_8,s=it(e*o*i,r),a=it(t*s*s,r),l=s,u=it(s*SS,r),d=a===e,f=a===it(-e,r),m=a===it(-e*SS,r);if(d)s=l;if(f||m)s=u;if(ho(s,r))s=it(-s,r);return{isValid:d||f,value:s}}var ws=n1(xS,{uvRatio:_S}),ci=(()=>ws.Fp)(),l1=(()=>ws.Fn)();var Rp=(()=>{let e=xs;return o1({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=c1(t);return it(Hr(r,lH,e)*o,e)},adjustScalarBytes:fH})})();var vS=SS,pH=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),mH=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),hH=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),gH=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),s1=(e)=>_S(go,e),yH=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),wS=(e)=>ci.create(sn(e)&yH);function a1(e){let{d:t}=xS,r=xs,o=(x)=>ci.create(x),n=o(vS*e*e),i=o((n+go)*hH),s=BigInt(-1),a=o((s-t*n)*o(n+t)),{isValid:l,value:u}=_S(i,a),d=o(u*e);if(!ho(d,r))d=o(-d);if(!l)u=d;if(!l)s=n;let f=o(s*(n-go)*gH-a),m=u*u,h=o((u+u)*a),b=o(f*pH),y=o(go-m),S=o(go+m);return new ws(o(h*S),o(y*b),o(b*S),o(h*y))}class dr extends bS{static BASE=(()=>new dr(ws.BASE))();static ZERO=(()=>new dr(ws.ZERO))();static Fp=(()=>ci)();static Fn=(()=>l1)();constructor(e){super(e)}static fromAffine(e){return new dr(ws.fromAffine(e))}assertSame(e){if(!(e instanceof dr))throw Error("RistrettoPoint expected")}init(e){return new dr(e)}static fromBytes(e){Mt(e,32);let{a:t,d:r}=xS,o=xs,n=(A)=>ci.create(A),i=wS(e);if(!RC(ci.toBytes(i),e)||ho(i,o))throw Error("invalid ristretto255 encoding 1");let s=n(i*i),a=n(go+t*s),l=n(go-t*s),u=n(a*a),d=n(l*l),f=n(t*r*u-d),{isValid:m,value:h}=s1(n(f*d)),b=n(h*l),y=n(h*b*f),S=n((i+i)*b);if(ho(S,o))S=n(-S);let x=n(a*y),_=n(S*x);if(!m||ho(_,o)||x===cH)throw Error("invalid ristretto255 encoding 2");return new dr(new ws(S,x,go,_))}static fromHex(e){return dr.fromBytes(Ol(e))}toBytes(){let{X:e,Y:t,Z:r,T:o}=this.ep,n=xs,i=(y)=>ci.create(y),s=i(i(r+t)*i(r-t)),a=i(e*t),l=i(a*a),{value:u}=s1(i(s*l)),d=i(u*s),f=i(u*a),m=i(d*f*o),h;if(ho(o*m,n)){let y=i(t*vS),S=i(e*vS);e=y,t=S,h=i(d*mH)}else h=f;if(ho(e*m,n))t=i(-t);let b=i((r-t)*h);if(ho(b,n))b=i(-b);return ci.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:o,Y:n}=e.ep,i=(l)=>ci.create(l),s=i(t*n)===i(r*o),a=i(r*n)===i(t*o);return s||a}is0(){return this.equals(dr.ZERO)}}Object.freeze(dr.BASE);Object.freeze(dr.ZERO);Object.freeze(dr.prototype);Object.freeze(dr);var bH=Object.freeze({Point:dr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,o=mS(e,r,64,Kf);return bH.deriveToCurve(o)},hashToScalar(e,t={DST:WC}){let r=mS(e,t.DST,64,Kf);return l1.create(sn(r))},deriveToCurve(e){Mt(e,64);let t=wS(e.subarray(0,32)),r=a1(t),o=wS(e.subarray(32,64)),n=a1(o);return new dr(r.add(n))}});var u1=!1,SH=!1;async function d1(e,t){if(SH)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();else throw r}}async function $p(e,t){return await d1(async()=>{let r=ES(e)?e:await wH(e),o=await crypto.subtle.importKey("raw",xH(t),{name:"X25519"},u1,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:o},r,256))},()=>{if(ES(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Rp.scalarMult(e,t)})}async function uu(e){return await d1(async()=>$p(e,Rp.GuBytes),()=>{if(ES(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Rp.scalarMultBase(e)})}var vH=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function wH(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...vH,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},u1,["deriveBits"])}function ES(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function xH(e){return e}class kS{s;transcript=[];buf=new Uint8Array(0);constructor(e){this.s=e.getReader()}async readLine(){let e=[];while(!0){let t=this.buf.indexOf(10);if(t>=0)return e.push(this.buf.subarray(0,t)),this.transcript.push(this.buf.subarray(0,t+1)),this.buf=this.buf.subarray(t+1),EH(_s(e));if(this.buf.length>0)e.push(this.buf),this.transcript.push(this.buf);let r=await this.s.read();if(r.done)return this.buf=_s(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:_s(this.transcript)}}}function EH(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function _s(e){let t=e.reduce((n,i)=>n+i.length,0),r=new Uint8Array(t),o=0;for(let n of e)r.set(n,o),o+=n.length;return r}function Na(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let o of t)r.enqueue(o)}}))}function Op(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function IS(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function f1(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function p1(e,t){let r=e.getReader(),o=[],n=0;while(n<t){let{done:l,value:u}=await r.read();if(l)throw Error("stream ended before reading "+t.toString()+" bytes");o.push(u),n+=u.length}r.releaseLock();let i=_s(o),s=i.subarray(0,t),a=Na(e,i.subarray(t));return{data:s,rest:a}}class Dn{args;body;constructor(e,t){this.args=e,this.body=t}}async function kH(e){let t=await e.readLine();if(t===null)throw Error("invalid stanza");let r=t.split(" ");if(r.length<2||r.shift()!=="->")return{next:t};for(let i of r)if(i.length===0)throw Error("invalid stanza");let o=[];for(;;){let i=await e.readLine();if(i===null)throw Error("invalid stanza");let s=Yt.decode(i);if(s.length>48)throw Error("invalid stanza");if(o.push(s),s.length<48)break}let n=_s(o);return{s:new Dn(r,n)}}async function m1(e){let t=new kS(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let o=[];for(;;){let{s:n,next:i}=await kH(t);if(n!==void 0){o.push(n);continue}if(!i.startsWith("--- "))throw Error("invalid header");let s=Yt.decode(i.slice(4)),{rest:a,transcript:l}=t.close(),u=l.slice(0,l.length-1-i.length+3);return{stanzas:o,headerNoMAC:u,MAC:s,headerSize:l.length,rest:Na(e,a)}}}function AS(e){let t=[];t.push(`age-encryption.org/v1
|
|
720
|
+
`)}function h$(e){let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate command name: ${r.name}`);t.set(r.name,r)}return t}function nt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function rs(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var Zf={name:"@rizom/ops",version:"0.2.0-alpha.682",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};import{existsSync as DH,mkdirSync as LH,readFileSync as JS,writeFileSync as HS}from"fs";import{dirname as BH,join as E1}from"path";function ib(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function St(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw RangeError(`${r}expected integer >= 0, got ${e}`)}}function Mt(e,t,r=""){let o=ib(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+l;if(!o)throw TypeError(u);throw RangeError(u)}return e}function no(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(St(e.outputLen),St(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function ha(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function Uf(e,t){Mt(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Mf(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function cr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ga(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rn(e,t){return e<<32-t|e>>>t}function Fe(e,t){return e<<t|e>>>32-t>>>0}var l8=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function u8(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function d8(e){for(let t=0;t<e.length;t++)e[t]=u8(e[t]);return e}var sb=l8?(e)=>e:d8,y$=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),f8=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function qf(e){if(Mt(e),y$)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=f8[e[r]];return t}var ro={_0:48,_9:57,A:65,F:70,a:97,f:102};function g$(e){if(e>=ro._0&&e<=ro._9)return e-ro._0;if(e>=ro.A&&e<=ro.F)return e-(ro.A-10);if(e>=ro.a&&e<=ro.f)return e-(ro.a-10);return}function Ol(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(y$)try{return Uint8Array.fromHex(e)}catch(n){if(n instanceof SyntaxError)throw RangeError(n.message);throw n}let t=e.length,r=t/2;if(t%2)throw RangeError("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=g$(e.charCodeAt(i)),a=g$(e.charCodeAt(i+1));if(s===void 0||a===void 0){let l=e[i]+e[i+1];throw RangeError('hex string expected, got non-hex character "'+l+'" at index '+i)}o[n]=s*16+a}return o}function p8(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ab(e,t=""){if(typeof e==="string")return p8(e);return Mt(e,void 0,t)}function cb(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Mt(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function Ff(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw TypeError("options must be object or undefined");return Object.assign(e,t)}function lb(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.canXOF=o.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function oo(e=32){St(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))}var ub=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class db{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(no(e),Mt(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),cr(o)}update(e){return ha(this),this.iHash.update(e),this}digestInto(e){ha(this),Uf(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:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var Tn=(()=>{let e=(t,r,o)=>new db(t,r).update(o).digest();return e.create=(t,r)=>new db(t,r),e})();function Cl(e,t,r){if(no(e),r===void 0)r=new Uint8Array(e.outputLen);return Tn(e,r,t)}var fb=Uint8Array.of(0),b$=Uint8Array.of();function pb(e,t,r,o=32){no(e),St(o,"length"),Mt(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=b$;else Mt(r,void 0,"info");let s=new Uint8Array(i*n),a=Tn.create(e,t),l=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)fb[0]=d+1,l.update(d===0?b$:u).update(r).update(fb).digestInto(u),s.set(u,n*d),a._cloneInto(l);return a.destroy(),l.destroy(),cr(u,fb),s.slice(0,o)}var Jo=(e,t,r,o,n)=>pb(e,Cl(e,t,r),o,n);function S$(e,t,r){return e&t^~e&r}function v$(e,t,r){return e&t^e&r^t&r}class Jf{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ga(this.buffer)}update(e){ha(this),Mt(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=ga(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){ha(this),Uf(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,cr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=ga(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var io=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var qt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Hf=BigInt(4294967295),w$=BigInt(32);function m8(e,t=!1){if(t)return{h:Number(e&Hf),l:Number(e>>w$&Hf)};return{h:Number(e>>w$&Hf)|0,l:Number(e&Hf)|0}}function x$(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=m8(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var mb=(e,t,r)=>e>>>r,hb=(e,t,r)=>e<<32-r|t>>>r,ns=(e,t,r)=>e>>>r|t<<32-r,os=(e,t,r)=>e<<32-r|t>>>r,Pl=(e,t,r)=>e<<64-r|t>>>r-32,zl=(e,t,r)=>e>>>r-32|t<<64-r;function Rn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var _$=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),E$=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,k$=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),I$=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,A$=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),T$=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var g8=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]),Ho=new Uint32Array(64);class R$ extends Jf{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)Ho[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=Ho[d-15],m=Ho[d-2],h=rn(f,7)^rn(f,18)^f>>>3,b=rn(m,17)^rn(m,19)^m>>>10;Ho[d]=b+Ho[d-7]+h+Ho[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:l,H:u}=this;for(let d=0;d<64;d++){let f=rn(s,6)^rn(s,11)^rn(s,25),m=u+f+S$(s,a,l)+g8[d]+Ho[d]|0,b=(rn(r,2)^rn(r,13)^rn(r,22))+v$(r,o,n)|0;u=l,l=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,l,u)}roundClean(){cr(Ho)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),cr(this.buffer)}}class $$ extends R${A=io[0]|0;B=io[1]|0;C=io[2]|0;D=io[3]|0;E=io[4]|0;F=io[5]|0;G=io[6]|0;H=io[7]|0;constructor(){super(32)}}var O$=(()=>x$(["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))))(),y8=(()=>O$[0])(),b8=(()=>O$[1])(),Ko=new Uint32Array(80),Vo=new Uint32Array(80);class C$ extends Jf{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:l,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,l,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,l,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)Ko[_]=e.getUint32(t),Vo[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=Ko[_-15]|0,O=Vo[_-15]|0,L=ns(A,O,1)^ns(A,O,8)^mb(A,O,7),z=os(A,O,1)^os(A,O,8)^hb(A,O,7),H=Ko[_-2]|0,P=Vo[_-2]|0,W=ns(H,P,19)^Pl(H,P,61)^mb(H,P,6),ee=os(H,P,19)^zl(H,P,61)^hb(H,P,6),j=k$(z,ee,Vo[_-7],Vo[_-16]),R=I$(j,L,W,Ko[_-7],Ko[_-16]);Ko[_]=R|0,Vo[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:l,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=ns(d,f,14)^ns(d,f,18)^Pl(d,f,41),O=os(d,f,14)^os(d,f,18)^zl(d,f,41),L=d&m^~d&b,z=f&h^~f&y,H=A$(x,O,z,b8[_],Vo[_]),P=T$(H,S,A,L,y8[_],Ko[_]),W=H|0,ee=ns(r,o,28)^Pl(r,o,34)^Pl(r,o,39),j=os(r,o,28)^zl(r,o,34)^zl(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=Rn(l|0,u|0,P|0,W|0),l=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let k=_$(W,j,B);r=E$(k,P,ee,R),o=k|0}({h:r,l:o}=Rn(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=Rn(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=Rn(this.Ch|0,this.Cl|0,s|0,a|0),{h:l,l:u}=Rn(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:f}=Rn(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=Rn(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=Rn(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=Rn(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,l,u,d,f,m,h,b,y,S,x)}roundClean(){cr(Ko,Vo)}destroy(){this.destroyed=!0,cr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class P$ extends C${Ah=qt[0]|0;Al=qt[1]|0;Bh=qt[2]|0;Bl=qt[3]|0;Ch=qt[4]|0;Cl=qt[5]|0;Dh=qt[6]|0;Dl=qt[7]|0;Eh=qt[8]|0;El=qt[9]|0;Fh=qt[10]|0;Fl=qt[11]|0;Gh=qt[12]|0;Gl=qt[13]|0;Hh=qt[14]|0;Hl=qt[15]|0;constructor(){super(64)}}var vt=lb(()=>new $$,ub(1));var Kf=lb(()=>new P$,ub(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Yf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function bb(e){if(!Yf(e))throw TypeError("Uint8Array expected")}function B$(e,t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;if(e)return t.every((r)=>typeof r==="string");else return t.every((r)=>Number.isSafeInteger(r))}function j$(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function Wo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function Dl(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Wf(e){if(!Array.isArray(e))throw TypeError("array expected")}function Gf(e,t){if(!B$(!0,t))throw TypeError(`${e}: array of strings expected`)}function Sb(e,t){if(!B$(!1,t))throw TypeError(`${e}: array of numbers expected`)}function $r(...e){let t=(i)=>i,r=(i,s)=>(a)=>i(s(a)),o=e.map((i)=>i.encode).reduceRight(r,t),n=e.map((i)=>i.decode).reduce(r,t);return{encode:o,decode:n}}function Or(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Gf("alphabet",t);let o=new Map(t.map((n,i)=>[n,i]));return{encode:(n)=>(Wf(n),n.map((i)=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:(n)=>(Wf(n),n.map((i)=>{Wo("alphabet.decode",i);let s=o.get(i);if(s===void 0)throw Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function Cr(e=""){return Wo("join",e),{encode:(t)=>(Gf("join.decode",t),t.join(e)),decode:(t)=>(Wo("join.decode",t),t.split(e))}}function Xf(e,t="="){return Dl(e),Wo("padding",t),{encode(r){Gf("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Gf("padding.decode",r);let o=r.length;if(o*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function Z$(e){return j$(e),{encode:(t)=>t,decode:(t)=>e(t)}}function z$(e,t,r){if(t<2)throw RangeError(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw RangeError(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Wf(e),!e.length)return[];let o=0,n=[],i=Array.from(e,(a)=>{if(Dl(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=i.length;while(!0){let a=0,l=!0;for(let u=o;u<s;u++){let d=i[u],f=t*a,m=f+d;if(!Number.isSafeInteger(m)||f/t!==a||m-d!==f)throw Error("convertRadix: carry overflow");let h=m/r;a=m%r;let b=Math.floor(h);if(i[u]=b,!Number.isSafeInteger(b)||b*r+a!==m)throw Error("convertRadix: carry overflow");if(!l)continue;else if(!b)o=u;else l=!1}if(n.push(a),l)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}var U$=(e,t)=>t===0?e:U$(t,e%t),Qf=(e,t)=>e+(t-U$(e,t)),Vf=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function gb(e,t,r,o){if(Wf(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Qf(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Qf(t,r)}`);let n=0,i=0,s=Vf[t],a=Vf[r]-1,l=[];for(let u of e){if(Dl(u),u>=s)throw Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,i+t>32)throw Error(`convertRadix2: carry overflow pos=${i} from=${t}`);i+=t;for(;i>=r;i-=r)l.push((n>>i-r&a)>>>0);let d=Vf[i];if(d===void 0)throw Error("invalid carry");n&=d-1}if(n=n<<r-i&a,!o&&i>=t)throw Error("Excess padding");if(!o&&n>0)throw Error(`Non-zero padding: ${n}`);if(o&&i>0)l.push(n>>>0);return l}function S8(e){Dl(e);let t=256;return{encode:(r)=>{if(!Yf(r))throw TypeError("radix.encode input should be Uint8Array");return z$(Array.from(r),t,e)},decode:(r)=>(Sb("radix.decode",r),Uint8Array.from(z$(r,e,t)))}}function Ur(e,t=!1){if(Dl(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Qf(8,e)>32||Qf(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Yf(r))throw TypeError("radix2.encode input should be Uint8Array");return gb(Array.from(r),8,e,!t)},decode:(r)=>(Sb("radix2.decode",r),Uint8Array.from(gb(r,e,8,t)))}}function N$(e){return j$(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var Vme=Object.freeze($r(Ur(4),Or("0123456789ABCDEF"),Cr(""))),Wme=Object.freeze($r(Ur(5),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Xf(5),Cr(""))),Gme=Object.freeze($r(Ur(5),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Cr(""))),Qme=Object.freeze($r(Ur(5),Or("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Xf(5),Cr(""))),Yme=Object.freeze($r(Ur(5),Or("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Cr(""))),Xme=Object.freeze($r(Ur(5),Or("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Cr(""),Z$((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),M$=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),v8=/[\t\n\f\r ]/,q$=(e,t)=>{Wo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&v8.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},vb=Object.freeze(M$?{encode(e){return bb(e),e.toBase64()},decode(e){return q$(e,!1)}}:$r(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Xf(6),Cr(""))),Yt=Object.freeze($r(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Cr(""))),ehe=Object.freeze(M$?{encode(e){return bb(e),e.toBase64({alphabet:"base64url"})},decode(e){return q$(e,!0)}}:$r(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Xf(6),Cr(""))),the=Object.freeze($r(Ur(6),Or("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Cr(""))),wb=(e)=>$r(S8(58),Or(e),Cr("")),rhe=Object.freeze(wb("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),nhe=Object.freeze(wb("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),ohe=Object.freeze(wb("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var yb=$r(Or("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Cr("")),D$=[996825010,642813549,513874426,1027748829,705979059];function Nl(e){let t=e>>25,r=(e&33554431)<<5;for(let o=0;o<D$.length;o++)if((t>>o&1)===1)r^=D$[o];return r}function L$(e,t,r=1){let o=e.length,n=1;for(let i=0;i<o;i++){let s=e.charCodeAt(i);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=Nl(n)^s>>5}n=Nl(n);for(let i=0;i<o;i++)n=Nl(n)^e.charCodeAt(i)&31;for(let i of t)n=Nl(n)^i;for(let i=0;i<6;i++)n=Nl(n);return n^=r,yb.encode(gb([n%Vf[30]],30,5,!1))}function F$(e){let t=e==="bech32"?1:734539939,r=Ur(5),o=r.decode,n=r.encode,i=N$(o);function s(f,m,h=90){if(Wo("bech32.encode prefix",f),Yf(m))m=Array.from(m);Sb("bech32.encode",m);let b=f.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let y=b+7+m.length;if(h!==!1&&y>h)throw TypeError(`Length ${y} exceeds limit ${h}`);let S=f.toLowerCase(),x=L$(S,m,t);return`${S}1${yb.encode(m)}${x}`}function a(f,m=90){Wo("bech32.decode input",f);let h=f.length;if(h<8||m!==!1&&h>m)throw TypeError(`invalid string length: ${h} (${f}). Expected (8..${m})`);let b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw Error("String must be lowercase or uppercase");let y=b.lastIndexOf("1");if(y===0||y===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,y),x=b.slice(y+1);if(x.length<6)throw Error("Data must be at least 6 characters long");let _=yb.decode(x).slice(0,-6),A=L$(S,_,t);if(!x.endsWith(A))throw Error(`Invalid checksum in ${f}: expected "${A}"`);return{prefix:S,words:_}}let l=N$(a);function u(f){let{prefix:m,words:h}=a(f,!1);return{prefix:m,words:h,bytes:o(h)}}function d(f,m){return s(f,n(m))}return{encode:s,decode:a,encodeFromBytes:d,decodeToBytes:u,decodeUnsafe:l,fromWords:o,fromWordsUnsafe:i,toWords:n}}var Pr=Object.freeze(F$("bech32")),ihe=Object.freeze(F$("bech32m"));var w8=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),x8={encode(e){return bb(e),e.toHex()},decode(e){return Wo("hex",e),Uint8Array.fromHex(e)}},she=Object.freeze(w8?x8:$r(Ur(4),Or("0123456789abcdef"),Cr(""),Z$((e)=>{if(typeof e!=="string"||e.length%2!==0)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));function E8(e,t,r,o){no(e);let n=Ff({dkLen:32,asyncTick:10},o),{c:i,dkLen:s,asyncTick:a}=n;if(St(i,"c"),St(s,"dkLen"),St(a,"asyncTick"),i<1)throw Error("iterations (c) must be >= 1");if(s<1)throw Error('"dkLen" must be >= 1');if(s>4294967295*e.outputLen)throw Error("derived key too long");let l=ab(t,"password"),u=ab(r,"salt"),d=new Uint8Array(s),f=Tn.create(e,l),m=f._cloneInto().update(u);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:f,PRFSalt:m}}function k8(e,t,r,o,n){if(e.destroy(),t.destroy(),o)o.destroy();return cr(n),r}function xb(e,t,r,o){let{c:n,dkLen:i,DK:s,PRF:a,PRFSalt:l}=E8(e,t,r,o),u,d=new Uint8Array(4),f=ga(d),m=new Uint8Array(a.outputLen);for(let h=1,b=0;b<i;h++,b+=a.outputLen){let y=s.subarray(b,b+a.outputLen);f.setInt32(0,h,!1),(u=l._cloneInto(u)).update(d).digestInto(m),y.set(m.subarray(0,y.length));for(let S=1;S<n;S++){a._cloneInto(u).update(m).digestInto(m);for(let x=0;x<y.length;x++)y[x]^=m[x]}}return k8(a,l,s,u,m)}function J$(e,t,r,o,n,i){let s=e[t++]^r[o++],a=e[t++]^r[o++],l=e[t++]^r[o++],u=e[t++]^r[o++],d=e[t++]^r[o++],f=e[t++]^r[o++],m=e[t++]^r[o++],h=e[t++]^r[o++],b=e[t++]^r[o++],y=e[t++]^r[o++],S=e[t++]^r[o++],x=e[t++]^r[o++],_=e[t++]^r[o++],A=e[t++]^r[o++],O=e[t++]^r[o++],L=e[t++]^r[o++],z=s,H=a,P=l,W=u,ee=d,j=f,R=m,B=h,k=b,T=y,I=S,q=x,N=_,K=A,G=O,re=L;for(let ae=0;ae<8;ae+=2)ee^=Fe(z+N|0,7),k^=Fe(ee+z|0,9),N^=Fe(k+ee|0,13),z^=Fe(N+k|0,18),T^=Fe(j+H|0,7),K^=Fe(T+j|0,9),H^=Fe(K+T|0,13),j^=Fe(H+K|0,18),G^=Fe(I+R|0,7),P^=Fe(G+I|0,9),R^=Fe(P+G|0,13),I^=Fe(R+P|0,18),W^=Fe(re+q|0,7),B^=Fe(W+re|0,9),q^=Fe(B+W|0,13),re^=Fe(q+B|0,18),H^=Fe(z+W|0,7),P^=Fe(H+z|0,9),W^=Fe(P+H|0,13),z^=Fe(W+P|0,18),R^=Fe(j+ee|0,7),B^=Fe(R+j|0,9),ee^=Fe(B+R|0,13),j^=Fe(ee+B|0,18),q^=Fe(I+T|0,7),k^=Fe(q+I|0,9),T^=Fe(k+q|0,13),I^=Fe(T+k|0,18),N^=Fe(re+G|0,7),K^=Fe(N+re|0,9),G^=Fe(K+N|0,13),re^=Fe(G+K|0,18);n[i++]=s+z|0,n[i++]=a+H|0,n[i++]=l+P|0,n[i++]=u+W|0,n[i++]=d+ee|0,n[i++]=f+j|0,n[i++]=m+R|0,n[i++]=h+B|0,n[i++]=b+k|0,n[i++]=y+T|0,n[i++]=S+I|0,n[i++]=x+q|0,n[i++]=_+N|0,n[i++]=A+K|0,n[i++]=O+G|0,n[i++]=L+re|0}function _b(e,t,r,o,n){let i=o+0,s=o+16*n;for(let a=0;a<16;a++)r[s+a]=e[t+(2*n-1)*16+a];for(let a=0;a<n;a++,i+=16,t+=16){if(J$(r,s,e,t,r,i),a>0)s+=16;J$(r,i,e,t+=16,r,s)}}function I8(e,t,r){let o=Ff({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:i,p:s,dkLen:a,asyncTick:l,maxmem:u,onProgress:d}=o;if(St(n,"N"),St(i,"r"),St(s,"p"),St(a,"dkLen"),St(l,"asyncTick"),St(u,"maxmem"),d!==void 0&&typeof d!=="function")throw Error("progressCb must be a function");let f=128*i,m=f/4,h=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>h)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(h-1)*32/f)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(h-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=f*(n+s+1);if(b>u)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+u);let y=xb(vt,e,t,{c:1,dkLen:f*s}),S=Mf(y),x=Mf(new Uint8Array(f*n)),_=Mf(new Uint8Array(f)),A=()=>{};if(d){let O=2*n*s,L=Math.max(Math.floor(O/1e4),1),z=0;A=()=>{if(z++,d&&(!(z%L)||z===O))d(z/O)}}return{N:n,r:i,p:s,dkLen:a,blockSize32:m,V:x,B32:S,B:y,tmp:_,blockMixCb:A,asyncTick:l}}function A8(e,t,r,o,n){let i=xb(vt,e,r,{c:1,dkLen:t});return cr(r,o,n),i}function Eb(e,t,r){let{N:o,r:n,p:i,dkLen:s,blockSize32:a,V:l,B32:u,B:d,tmp:f,blockMixCb:m}=I8(e,t,r);sb(u);for(let h=0;h<i;h++){let b=a*h;for(let y=0;y<a;y++)l[y]=u[b+y];for(let y=0,S=0;y<o-1;y++)_b(l,S,l,S+=a,n),m();_b(l,(o-1)*a,u,b,n),m();for(let y=0;y<o;y++){let S=(u[b+a-16]&o-1)>>>0;for(let x=0;x<a;x++)f[x]=u[b+x]^l[S*a+x];_b(f,0,u,b,n),m()}}return sb(u),A8(e,s,d,l,f)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function T8(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function ep(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function ya(e){if(typeof e!=="number")throw TypeError("number expected, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError("positive integer expected, got "+e)}function Rt(e,t,r=""){let o=T8(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+l;if(!o)throw TypeError(u);throw RangeError(u)}return e}function kb(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function H$(e,t,r=!1){Rt(e,void 0,"output");let o=t.outputLen;if(e.length<o)throw RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!ba(e))throw Error("invalid output, must be aligned")}function $n(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function nn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function R8(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var is=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),$8=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var O8=(e)=>{for(let t=0;t<e.length;t++)e[t]=$8(e[t]);return e},so=is?(e)=>e:O8;function K$(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function V$(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function W$(e,t,r){let o=t,n=r||(()=>[]),i=(a,l)=>o(l,...n(a)).update(a).digest(),s=o(new Uint8Array(e),...n(new Uint8Array(0)));return i.outputLen=s.outputLen,i.blockLen=s.blockLen,i.create=(a,...l)=>o(a,...l),i}var G$=(e,t)=>{function r(o,...n){if(Rt(o,void 0,"key"),e.nonceLength!==void 0){let d=n[0];Rt(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let i=e.tagLength;if(i&&n[1]!==void 0)Rt(n[1],void 0,"AAD");let s=t(o,...n),a=(d,f)=>{if(f!==void 0){if(d!==2)throw Error("cipher output not supported");Rt(f,void 0,"output")}},l=!1;return{encrypt(d,f){if(l)throw Error("cannot encrypt() twice with same key + nonce");return l=!0,Rt(d),a(s.encrypt.length,f),s.encrypt(d,f)},decrypt(d,f){if(Rt(d),i&&d.length<i)throw Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,f),s.decrypt(d,f)}}}return Object.assign(r,e),r};function Ll(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Rt(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!ba(t))throw Error("invalid output, must be aligned");return t}function Q$(e,t,r){ya(e),ya(t),ep(r);let o=new Uint8Array(16),n=R8(o);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),o}function ba(e){return e.byteOffset%4===0}function Sa(e){return Uint8Array.from(Rt(e))}var X$=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),C8=(()=>so($n(X$("expand 16-byte k"))))(),P8=(()=>so($n(X$("expand 32-byte k"))))();function Je(e,t){return e<<t|e>>>32-t}var Bl=64,z8=16,Ib=(()=>4294967295)(),Y$=Uint32Array.of();function N8(e,t,r,o,n,i,s,a){let l=n.length,u=new Uint8Array(Bl),d=$n(u),f=is&&ba(n)&&ba(i),m=f?$n(n):Y$,h=f?$n(i):Y$;if(!is){for(let b=0;b<l;s++){if(e(t,r,o,d,s,a),so(d),s>=Ib)throw Error("arx: counter overflow");let y=Math.min(Bl,l-b);for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}return}for(let b=0;b<l;s++){if(e(t,r,o,d,s,a),s>=Ib)throw Error("arx: counter overflow");let y=Math.min(Bl,l-b);if(f&&y===Bl){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let x=0,_;x<z8;x++)_=S+x,h[_]=m[_]^d[x];b+=Bl;continue}for(let S=0,x;S<y;S++)x=b+S,i[x]=n[x]^u[S];b+=y}}function eO(e,t){let{allowShortKeys:r,extendNonceFn:o,counterLength:n,counterRight:i,rounds:s}=K$({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return ya(n),ya(s),ep(i),ep(r),(a,l,u,d,f=0)=>{Rt(a,void 0,"key"),Rt(l,void 0,"nonce"),Rt(u,void 0,"data");let m=u.length;if(d=Ll(m,d,!1),ya(f),f<0||f>=Ib)throw Error("arx: counter overflow");let h=[],b=a.length,y,S;if(b===32)h.push(y=Sa(a)),S=P8;else if(b===16&&r)y=new Uint8Array(32),y.set(a),y.set(a,16),S=C8,h.push(y);else throw Rt(a,32,"arx key"),Error("invalid key size");if(!is||!ba(l))h.push(l=Sa(l));let x=$n(y);if(o){if(l.length!==24)throw Error("arx: extended nonce must be 24 bytes");let O=l.subarray(0,16);if(is)o(S,x,$n(O),x);else{let L=so(Uint32Array.from(S));o(L,x,$n(O),x),nn(L),so(x)}l=l.subarray(16)}else if(!is)so(x);let _=16-n;if(_!==l.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let O=new Uint8Array(12);O.set(l,i?0:12-l.length),l=O,h.push(l)}let A=so($n(l));try{return N8(e,S,x,A,u,d,f,s),d}finally{nn(...h)}}}function Ft(e,t){return e[t++]&255|(e[t++]&255)<<8}class tO{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;destroyed=!1;constructor(e){e=Sa(Rt(e,32,"key"));let t=Ft(e,0),r=Ft(e,2),o=Ft(e,4),n=Ft(e,6),i=Ft(e,8),s=Ft(e,10),a=Ft(e,12),l=Ft(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|n<<9)&8191,this.r[4]=(n>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Ft(e,16+2*u)}process(e,t,r=!1){let o=r?0:2048,{h:n,r:i}=this,s=i[0],a=i[1],l=i[2],u=i[3],d=i[4],f=i[5],m=i[6],h=i[7],b=i[8],y=i[9],S=Ft(e,t+0),x=Ft(e,t+2),_=Ft(e,t+4),A=Ft(e,t+6),O=Ft(e,t+8),L=Ft(e,t+10),z=Ft(e,t+12),H=Ft(e,t+14),P=n[0]+(S&8191),W=n[1]+((S>>>13|x<<3)&8191),ee=n[2]+((x>>>10|_<<6)&8191),j=n[3]+((_>>>7|A<<9)&8191),R=n[4]+((A>>>4|O<<12)&8191),B=n[5]+(O>>>1&8191),k=n[6]+((O>>>14|L<<2)&8191),T=n[7]+((L>>>11|z<<5)&8191),I=n[8]+((z>>>8|H<<8)&8191),q=n[9]+(H>>>5|o),N=0,K=N+P*s+W*(5*y)+ee*(5*b)+j*(5*h)+R*(5*m);N=K>>>13,K&=8191,K+=B*(5*f)+k*(5*d)+T*(5*u)+I*(5*l)+q*(5*a),N+=K>>>13,K&=8191;let G=N+P*a+W*s+ee*(5*y)+j*(5*b)+R*(5*h);N=G>>>13,G&=8191,G+=B*(5*m)+k*(5*f)+T*(5*d)+I*(5*u)+q*(5*l),N+=G>>>13,G&=8191;let re=N+P*l+W*a+ee*s+j*(5*y)+R*(5*b);N=re>>>13,re&=8191,re+=B*(5*h)+k*(5*m)+T*(5*f)+I*(5*d)+q*(5*u),N+=re>>>13,re&=8191;let ae=N+P*u+W*l+ee*a+j*s+R*(5*y);N=ae>>>13,ae&=8191,ae+=B*(5*b)+k*(5*h)+T*(5*m)+I*(5*f)+q*(5*d),N+=ae>>>13,ae&=8191;let pe=N+P*d+W*u+ee*l+j*a+R*s;N=pe>>>13,pe&=8191,pe+=B*(5*y)+k*(5*b)+T*(5*h)+I*(5*m)+q*(5*f),N+=pe>>>13,pe&=8191;let be=N+P*f+W*d+ee*u+j*l+R*a;N=be>>>13,be&=8191,be+=B*s+k*(5*y)+T*(5*b)+I*(5*h)+q*(5*m),N+=be>>>13,be&=8191;let ve=N+P*m+W*f+ee*d+j*u+R*l;N=ve>>>13,ve&=8191,ve+=B*a+k*s+T*(5*y)+I*(5*b)+q*(5*h),N+=ve>>>13,ve&=8191;let Ae=N+P*h+W*m+ee*f+j*d+R*u;N=Ae>>>13,Ae&=8191,Ae+=B*l+k*a+T*s+I*(5*y)+q*(5*b),N+=Ae>>>13,Ae&=8191;let Ie=N+P*b+W*h+ee*m+j*f+R*d;N=Ie>>>13,Ie&=8191,Ie+=B*u+k*l+T*a+I*s+q*(5*y),N+=Ie>>>13,Ie&=8191;let we=N+P*y+W*b+ee*h+j*m+R*f;N=we>>>13,we&=8191,we+=B*d+k*u+T*l+I*a+q*s,N+=we>>>13,we&=8191,N=(N<<2)+N|0,N=N+K|0,K=N&8191,N=N>>>13,G+=N,n[0]=K,n[1]=G,n[2]=re,n[3]=ae,n[4]=pe,n[5]=be,n[6]=ve,n[7]=Ae,n[8]=Ie,n[9]=we}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=o,o=e[s]>>>13,e[s]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+o,o=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(o^1)-1;for(let s=0;s<10;s++)r[s]&=n;n=~n;for(let s=0;s<10;s++)e[s]=e[s]&n|r[s];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let i=e[0]+t[0];e[0]=i&65535;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=i&65535;nn(r)}update(e){kb(this),Rt(e),e=Sa(e);let{buffer:t,blockLen:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(r-this.pos,o-n);if(i===r){for(;r<=o-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,nn(this.h,this.r,this.buffer,this.pad)}digestInto(e){kb(this),H$(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:o}=this;if(o){t[o++]=1;for(;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let i=0;i<8;i++)e[n++]=r[i]>>>0,e[n++]=r[i]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var rO=W$(32,(e)=>new tO(e));function D8(e,t,r,o,n,i=20){let s=e[0],a=e[1],l=e[2],u=e[3],d=t[0],f=t[1],m=t[2],h=t[3],b=t[4],y=t[5],S=t[6],x=t[7],_=n,A=r[0],O=r[1],L=r[2],z=s,H=a,P=l,W=u,ee=d,j=f,R=m,B=h,k=b,T=y,I=S,q=x,N=_,K=A,G=O,re=L;for(let pe=0;pe<i;pe+=2)z=z+ee|0,N=Je(N^z,16),k=k+N|0,ee=Je(ee^k,12),z=z+ee|0,N=Je(N^z,8),k=k+N|0,ee=Je(ee^k,7),H=H+j|0,K=Je(K^H,16),T=T+K|0,j=Je(j^T,12),H=H+j|0,K=Je(K^H,8),T=T+K|0,j=Je(j^T,7),P=P+R|0,G=Je(G^P,16),I=I+G|0,R=Je(R^I,12),P=P+R|0,G=Je(G^P,8),I=I+G|0,R=Je(R^I,7),W=W+B|0,re=Je(re^W,16),q=q+re|0,B=Je(B^q,12),W=W+B|0,re=Je(re^W,8),q=q+re|0,B=Je(B^q,7),z=z+j|0,re=Je(re^z,16),I=I+re|0,j=Je(j^I,12),z=z+j|0,re=Je(re^z,8),I=I+re|0,j=Je(j^I,7),H=H+R|0,N=Je(N^H,16),q=q+N|0,R=Je(R^q,12),H=H+R|0,N=Je(N^H,8),q=q+N|0,R=Je(R^q,7),P=P+B|0,K=Je(K^P,16),k=k+K|0,B=Je(B^k,12),P=P+B|0,K=Je(K^P,8),k=k+K|0,B=Je(B^k,7),W=W+ee|0,G=Je(G^W,16),T=T+G|0,ee=Je(ee^T,12),W=W+ee|0,G=Je(G^W,8),T=T+G|0,ee=Je(ee^T,7);let ae=0;o[ae++]=s+z|0,o[ae++]=a+H|0,o[ae++]=l+P|0,o[ae++]=u+W|0,o[ae++]=d+ee|0,o[ae++]=f+j|0,o[ae++]=m+R|0,o[ae++]=h+B|0,o[ae++]=b+k|0,o[ae++]=y+T|0,o[ae++]=S+I|0,o[ae++]=x+q|0,o[ae++]=_+N|0,o[ae++]=A+K|0,o[ae++]=O+G|0,o[ae++]=L+re|0}var L8=eO(D8,{counterRight:!1,counterLength:4,allowShortKeys:!1});var B8=new Uint8Array(16),nO=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(B8.subarray(r))},j8=new Uint8Array(32);function oO(e,t,r,o,n){if(n!==void 0)Rt(n,void 0,"AAD");let i=e(t,r,j8),s=Q$(o.length,n?n.length:0,!0),a=rO.create(i);if(n)nO(a,n);nO(a,o),a.update(s);let l=a.digest();return nn(i,s),l}var Z8=(e)=>(t,r,o)=>({encrypt(i,s){let a=i.length;s=Ll(a+16,s,!1),s.set(i);let l=s.subarray(0,-16);e(t,r,l,l,1);let u=oO(e,t,r,l,o);return s.set(u,a),nn(u),s},decrypt(i,s){s=Ll(i.length-16,s,!1);let a=i.subarray(0,-16),l=i.subarray(-16),u=oO(e,t,r,a,o);if(!V$(l,u))throw nn(u),Error("invalid tag");return s.set(i.subarray(0,-16)),e(t,r,s,s,1),nn(u),s}}),Mr=G$({blockSize:64,nonceLength:12,tagLength:16},Z8(L8));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function va(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Te(e,t,r=""){let o=va(e),n=e?.length,i=t!==void 0;if(!o||i&&n!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+l)}return e}function qr(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Lt(e.outputLen),Lt(e.blockLen)}function co(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function tp(e,t){Te(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function rp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function vr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function np(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function on(e,t){return e<<32-t|e>>>t}var U8=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function M8(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function q8(e){for(let t=0;t<e.length;t++)e[t]=M8(e[t]);return e}var Ab=U8?(e)=>e:q8,sO=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),F8=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ss(e){if(Te(e),sO)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=F8[e[r]];return t}var ao={_0:48,_9:57,A:65,F:70,a:97,f:102};function iO(e){if(e>=ao._0&&e<=ao._9)return e-ao._0;if(e>=ao.A&&e<=ao.F)return e-(ao.A-10);if(e>=ao.a&&e<=ao.f)return e-(ao.a-10);return}function as(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(sO)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,i=0;n<r;n++,i+=2){let s=iO(e.charCodeAt(i)),a=iO(e.charCodeAt(i+1));if(s===void 0||a===void 0){let l=e[i]+e[i+1];throw Error('hex string expected, got non-hex character "'+l+'" at index '+i)}o[n]=s*16+a}return o}function Et(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];Te(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}return r}function wa(e,t={}){let r=(n,i)=>e(i).update(n).digest(),o=e(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Go(e=32){let t=typeof globalThis==="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!=="function")throw Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Qo=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Rb=BigInt(0),Tb=BigInt(1);function jl(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function aO(e){if(typeof e==="bigint"){if(!op(e))throw Error("positive bigint expected, got "+e)}else Lt(e);return e}function Zl(e){let t=aO(e).toString(16);return t.length&1?"0"+t:t}function cO(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?Rb:BigInt("0x"+e)}function Yo(e){return cO(ss(e))}function Xo(e){return cO(ss(ip(Te(e)).reverse()))}function xa(e,t){Lt(t),e=aO(e);let r=as(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Ul(e,t){return xa(e,t).reverse()}function ip(e){return Uint8Array.from(e)}function ei(e){return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var op=(e)=>typeof e==="bigint"&&Rb<=e;function J8(e,t,r){return op(e)&&op(t)&&op(r)&&t<=e&&e<r}function Ml(e,t,r,o){if(!J8(t,r,o))throw Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function $b(e){let t;for(t=0;e>Rb;e>>=Tb,t+=1);return t}var ql=(e)=>(Tb<<BigInt(e))-Tb;function lO(e,t,r){if(Lt(e,"hashLen"),Lt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,l=o(e),u=o(e),d=0,f=()=>{l.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Et(l,...S)),h=(S=n)=>{if(u=m(i,S),l=m(),S.length===0)return;u=m(s,S),l=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){l=m();let _=l.slice();x.push(_),S+=l.length}return Et(...x)};return(S,x)=>{f(),h(S);let _=void 0;while(!(_=x(b())))h();return f(),_}}function cs(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function o(i,s,a){let l=e[i];if(a&&l===void 0)return;let u=typeof l;if(u!==s||l===null)throw Error(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,l])=>o(a,l,s));n(t,!1),n(r,!0)}function Ob(e){let t=new WeakMap;return(r,...o)=>{let n=t.get(r);if(n!==void 0)return n;let i=e(r,...o);return t.set(r,i),i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ur=BigInt(0),Xt=BigInt(1),ls=BigInt(2),fO=BigInt(3),pO=BigInt(4),mO=BigInt(5),H8=BigInt(7),hO=BigInt(8),K8=BigInt(9),gO=BigInt(16);function lr(e,t){let r=e%t;return r>=ur?r:t+r}function Fr(e,t,r){let o=e;while(t-- >ur)o*=o,o%=r;return o}function uO(e,t){if(e===ur)throw Error("invert: expected non-zero number");if(t<=ur)throw Error("invert: expected positive modulus, got "+t);let r=lr(e,t),o=t,n=ur,i=Xt,s=Xt,a=ur;while(r!==ur){let u=o/r,d=o%r,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==Xt)throw Error("invert: does not exist");return lr(n,t)}function Cb(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function yO(e,t){let r=(e.ORDER+Xt)/pO,o=e.pow(t,r);return Cb(e,o,t),o}function V8(e,t){let r=(e.ORDER-mO)/hO,o=e.mul(t,ls),n=e.pow(o,r),i=e.mul(t,n),s=e.mul(e.mul(i,ls),n),a=e.mul(i,e.sub(s,e.ONE));return Cb(e,a,t),a}function W8(e){let t=sp(e),r=bO(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+H8)/gO;return(a,l)=>{let u=a.pow(l,s),d=a.mul(u,o),f=a.mul(u,n),m=a.mul(u,i),h=a.eql(a.sqr(d),l),b=a.eql(a.sqr(f),l);u=a.cmov(u,d,h),d=a.cmov(m,f,b);let y=a.eql(a.sqr(d),l),S=a.cmov(u,d,y);return Cb(a,S,l),S}}function bO(e){if(e<fO)throw Error("sqrt is not defined for small field");let t=e-Xt,r=0;while(t%ls===ur)t/=ls,r++;let o=ls,n=sp(e);while(dO(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return yO;let i=n.pow(o,t),s=(t+Xt)/ls;return function(l,u){if(l.is0(u))return u;if(dO(l,u)!==1)throw Error("Cannot find square root");let d=r,f=l.mul(l.ONE,i),m=l.pow(u,t),h=l.pow(u,s);while(!l.eql(m,l.ONE)){if(l.is0(m))return l.ZERO;let b=1,y=l.sqr(m);while(!l.eql(y,l.ONE))if(b++,y=l.sqr(y),b===d)throw Error("Cannot find square root");let S=Xt<<BigInt(d-b-1),x=l.pow(f,S);d=b,f=l.sqr(x),m=l.mul(m,f),h=l.mul(h,x)}return h}}function G8(e){if(e%pO===fO)return yO;if(e%hO===mO)return V8;if(e%gO===K8)return W8(e);return bO(e)}var Q8=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pb(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Q8.reduce((o,n)=>(o[n]="function",o),t);return cs(e,r),e}function Y8(e,t,r){if(r<ur)throw Error("invalid exponent, negatives unsupported");if(r===ur)return e.ONE;if(r===Xt)return t;let o=e.ONE,n=t;while(r>ur){if(r&Xt)o=e.mul(o,n);n=e.sqr(n),r>>=Xt}return o}function Fl(e,t,r=!1){let o=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,l)=>{if(e.is0(a))return s;return o[l]=s,e.mul(s,a)},e.ONE),i=e.inv(n);return t.reduceRight((s,a,l)=>{if(e.is0(a))return s;return o[l]=e.mul(s,o[l]),e.mul(s,a)},i),o}function dO(e,t){let r=(e.ORDER-Xt)/ls,o=e.pow(t,r),n=e.eql(o,e.ONE),i=e.eql(o,e.ZERO),s=e.eql(o,e.neg(e.ONE));if(!n&&!i&&!s)throw Error("invalid Legendre symbol result");return n?1:i?0:-1}function X8(e,t){if(t!==void 0)Lt(t);let r=t!==void 0?t:e.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class SO{ORDER;BITS;BYTES;isLE;ZERO=ur;ONE=Xt;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=ur)throw Error("invalid field: expected ORDER > 0, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")this.sqrt=t.sqrt;if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=t.allowedLengths?.slice();if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=X8(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return lr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return ur<=e&&e<this.ORDER}is0(e){return e===ur}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Xt)===Xt}neg(e){return lr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return lr(e*e,this.ORDER)}add(e,t){return lr(e+t,this.ORDER)}sub(e,t){return lr(e-t,this.ORDER)}mul(e,t){return lr(e*t,this.ORDER)}pow(e,t){return Y8(this,e,t)}div(e,t){return lr(e*uO(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 uO(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=G8(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Ul(e,this.BYTES):xa(e,this.BYTES)}fromBytes(e,t=!1){Te(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let l=new Uint8Array(o);l.set(e,n?0:l.length-e.length),e=l}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?Xo(e):Yo(e);if(s)a=lr(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Fl(this,e)}cmov(e,t,r){return r?t:e}}function sp(e,t={}){return new SO(e,t)}function vO(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function zb(e){let t=vO(e);return t+Math.ceil(t/2)}function wO(e,t,r=!1){Te(e);let o=e.length,n=vO(t),i=zb(t);if(o<16||o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?Xo(e):Yo(e),a=lr(s,t-Xt)+Xt;return r?Ul(a,n):xa(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var _a=BigInt(0),us=BigInt(1);function Jl(e,t){let r=t.negate();return e?r:t}function Bb(e,t){let r=Fl(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function kO(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function Nb(e,t){kO(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=ql(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function xO(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),l=e>>s;if(a>o)a-=i,l+=us;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:l,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var Db=new WeakMap,IO=new WeakMap;function Lb(e){return IO.get(e)||1}function _O(e){if(e!==_a)throw Error("invalid wNAF")}class jb{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>_a){if(t&us)r=r.add(o);o=o.double(),t>>=us}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=Nb(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let l=1;l<o;l++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=Nb(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:l,isZero:u,isNeg:d,isNegF:f,offsetF:m}=xO(r,s,i);if(r=a,u)n=n.add(Jl(f,t[m]));else o=o.add(Jl(d,t[l]))}return _O(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=Nb(e,this.bits);for(let i=0;i<n.windows;i++){if(r===_a)break;let{nextN:s,offset:a,isZero:l,isNeg:u}=xO(r,i,n);if(r=s,l)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return _O(r),o}getPrecomputes(e,t,r){let o=Db.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);Db.set(t,o)}}return o}cached(e,t,r){let o=Lb(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=Lb(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){kO(t,this.bits),IO.set(e,t),Db.delete(e)}hasCache(e){return Lb(e)!==1}}function AO(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>_a||o>_a){if(r&us)i=i.add(n);if(o&us)s=s.add(n);n=n.double(),r>>=us,o>>=us}return{p1:i,p2:s}}function EO(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Pb(t),t}else return sp(e,{isLE:r})}function TO(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let l of["p","n","h"]){let u=t[l];if(!(typeof u==="bigint"&&u>_a))throw Error(`CURVE.${l} must be positive bigint`)}let n=EO(t.p,r.Fp,o),i=EO(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let l of a)if(!n.isValid(t[l]))throw Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function ap(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Hl=BigInt(0),Ea=BigInt(1),cp=BigInt(2);function eJ(e){return cs(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function RO(e){let t=eJ(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let l=s||Go,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?cp**BigInt(254):cp**BigInt(447),b=a?BigInt(8)*cp**BigInt(251)-Ea:BigInt(4)*cp**BigInt(445)-Ea,y=h+b+Ea,S=(k)=>lr(k,r),x=_(f);function _(k){return Ul(S(k),d)}function A(k){let T=ip(Te(k,d,"uCoordinate"));if(a)T[31]&=127;return S(Xo(T))}function O(k){return Xo(n(ip(Te(k,d,"scalar"))))}function L(k,T){let I=ee(A(T),O(k));if(I===Hl)throw Error("invalid private or public key received");return _(I)}function z(k){return L(k,x)}let H=z,P=L;function W(k,T,I){let q=S(k*(T-I));return T=S(T-q),I=S(I+q),{x_2:T,x_3:I}}function ee(k,T){Ml("u",k,Hl,r),Ml("scalar",T,h,y);let I=T,q=k,N=Ea,K=Hl,G=k,re=Ea,ae=Hl;for(let be=BigInt(u-1);be>=Hl;be--){let ve=I>>be&Ea;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:K,x_3:re}=W(ae,K,re),ae=ve;let Ae=N+K,Ie=S(Ae*Ae),we=N-K,Ue=S(we*we),De=Ie-Ue,Qe=G+re,bt=G-re,Tt=S(bt*Ae),Dt=S(Qe*we),lt=Tt+Dt,Rr=Tt-Dt;G=S(lt*lt),re=S(q*S(Rr*Rr)),N=S(Ie*Ue),K=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:K,x_3:re}=W(ae,K,re);let pe=i(K);return S(N*pe)}let j={secretKey:d,publicKey:d,seed:d},R=(k=l(d))=>(Te(k,j.seed,"seed"),k),B={randomSecretKey:R};return Object.freeze({keygen:ap(R,H),getSharedSecret:P,getPublicKey:H,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}class Zb{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(qr(e),Te(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<o.length;n++)o[n]^=54;this.iHash.update(o),this.oHash=e.create();for(let n=0;n<o.length;n++)o[n]^=106;this.oHash.update(o),vr(o)}update(e){return co(this),this.iHash.update(e),this}digestInto(e){co(this),Te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),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:r,finished:o,destroyed:n,blockLen:i,outputLen:s}=this;return e=e,e.finished=o,e.destroyed=n,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var ka=(e,t,r)=>new Zb(e,t).update(r).digest();ka.create=(e,t)=>new Zb(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var $O=(e,t)=>(e+(e>=0?t:-t)/CO)/t;function tJ(e,t,r){let[[o,n],[i,s]]=t,a=$O(s*e,r),l=$O(-n*e,r),u=e-a*o-l*i,d=-a*n-l*s,f=u<lo,m=d<lo;if(f)u=-u;if(m)d=-d;let h=ql(Math.ceil($b(r)/2))+Ia;if(u<lo||u>=h||d<lo||d>=h)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:m,k2:d}}function Mb(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function Ub(e,t){let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(jl(r.lowS,"lowS"),jl(r.prehash,"prehash"),r.format!==void 0)Mb(r.format);return r}class OO extends Error{constructor(e=""){super(e)}}var ti={Err:OO,_tlv:{encode:(e,t)=>{let{Err:r}=ti;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=Zl(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?Zl(n.length/2|128):"";return Zl(e)+i+n+t},decode(e,t){let{Err:r}=ti,o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let l=n&127;if(!l)throw new r("tlv.decode(long): indefinite length not supported");if(l>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+l);if(u.length!==l)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=l,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=ti;if(e<lo)throw new t("integer: negative integers are not allowed");let r=Zl(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=ti;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Yo(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=ti,n=Te(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l}=o.decode(2,i),{v:u,l:d}=o.decode(2,l);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=ti,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}},lo=BigInt(0),Ia=BigInt(1),CO=BigInt(2),lp=BigInt(3),rJ=BigInt(4);function qb(e,t={}){let r=TO("weierstrass",e,t),{Fp:o,Fn:n}=r,i=r.CURVE,{h:s,n:a}=i;cs(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:l}=t;if(l){if(!o.is0(i.a)||typeof l.beta!=="bigint"||!Array.isArray(l.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=zO(o,n);function d(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(R,B,k){let{x:T,y:I}=B.toAffine(),q=o.toBytes(T);if(jl(k,"isCompressed"),k){d();let N=!o.isOdd(I);return Et(PO(N),q)}else return Et(Uint8Array.of(4),q,o.toBytes(I))}function m(R){Te(R,void 0,"Point");let{publicKey:B,publicKeyUncompressed:k}=u,T=R.length,I=R[0],q=R.subarray(1);if(T===B&&(I===2||I===3)){let N=o.fromBytes(q);if(!o.isValid(N))throw Error("bad point: is not on curve, wrong x");let K=y(N),G;try{G=o.sqrt(K)}catch(pe){let be=pe instanceof Error?": "+pe.message:"";throw Error("bad point: is not on curve, sqrt error"+be)}d();let re=o.isOdd(G);if((I&1)===1!==re)G=o.neg(G);return{x:N,y:G}}else if(T===k&&I===4){let N=o.BYTES,K=o.fromBytes(q.subarray(0,N)),G=o.fromBytes(q.subarray(N,N*2));if(!S(K,G))throw Error("bad point: is not on curve");return{x:K,y:G}}else throw Error(`bad point: got length ${T}, expected compressed=${B} or uncompressed=${k}`)}let h=t.toBytes||f,b=t.fromBytes||m;function y(R){let B=o.sqr(R),k=o.mul(B,R);return o.add(o.add(k,o.mul(R,i.a)),i.b)}function S(R,B){let k=o.sqr(B),T=y(R);return o.eql(k,T)}if(!S(i.Gx,i.Gy))throw Error("bad curve params: generator point");let x=o.mul(o.pow(i.a,lp),rJ),_=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(x,_)))throw Error("bad curve params: a or b");function A(R,B,k=!1){if(!o.isValid(B)||k&&o.is0(B))throw Error(`bad point coordinate ${R}`);return B}function O(R){if(!(R instanceof W))throw Error("Weierstrass Point expected")}function L(R){if(!l||!l.basises)throw Error("no endo");return tJ(R,l.basises,n.ORDER)}let z=Ob((R,B)=>{let{X:k,Y:T,Z:I}=R;if(o.eql(I,o.ONE))return{x:k,y:T};let q=R.is0();if(B==null)B=q?o.ONE:o.inv(I);let N=o.mul(k,B),K=o.mul(T,B),G=o.mul(I,B);if(q)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:K}}),H=Ob((R)=>{if(R.is0()){if(t.allowInfinityPoint&&!o.is0(R.Y))return;throw Error("bad point: ZERO")}let{x:B,y:k}=R.toAffine();if(!o.isValid(B)||!o.isValid(k))throw Error("bad point: x or y not field elements");if(!S(B,k))throw Error("bad point: equation left != right");if(!R.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function P(R,B,k,T,I){return k=new W(o.mul(k.X,R),k.Y,k.Z),B=Jl(T,B),k=Jl(I,k),B.add(k)}class W{static BASE=new W(i.Gx,i.Gy,o.ONE);static ZERO=new W(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(R,B,k){this.X=A("x",R),this.Y=A("y",B,!0),this.Z=A("z",k),Object.freeze(this)}static CURVE(){return i}static fromAffine(R){let{x:B,y:k}=R||{};if(!R||!o.isValid(B)||!o.isValid(k))throw Error("invalid affine point");if(R instanceof W)throw Error("projective point not allowed");if(o.is0(B)&&o.is0(k))return W.ZERO;return new W(B,k,o.ONE)}static fromBytes(R){let B=W.fromAffine(b(Te(R,void 0,"point")));return B.assertValidity(),B}static fromHex(R){return W.fromBytes(as(R))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(R=8,B=!0){if(j.createCache(this,R),!B)this.multiply(lp);return this}assertValidity(){H(this)}hasEvenY(){let{y:R}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(R)}equals(R){O(R);let{X:B,Y:k,Z:T}=this,{X:I,Y:q,Z:N}=R,K=o.eql(o.mul(B,N),o.mul(I,T)),G=o.eql(o.mul(k,N),o.mul(q,T));return K&&G}negate(){return new W(this.X,o.neg(this.Y),this.Z)}double(){let{a:R,b:B}=i,k=o.mul(B,lp),{X:T,Y:I,Z:q}=this,N=o.ZERO,K=o.ZERO,G=o.ZERO,re=o.mul(T,T),ae=o.mul(I,I),pe=o.mul(q,q),be=o.mul(T,I);return be=o.add(be,be),G=o.mul(T,q),G=o.add(G,G),N=o.mul(R,G),K=o.mul(k,pe),K=o.add(N,K),N=o.sub(ae,K),K=o.add(ae,K),K=o.mul(N,K),N=o.mul(be,N),G=o.mul(k,G),pe=o.mul(R,pe),be=o.sub(re,pe),be=o.mul(R,be),be=o.add(be,G),G=o.add(re,re),re=o.add(G,re),re=o.add(re,pe),re=o.mul(re,be),K=o.add(K,re),pe=o.mul(I,q),pe=o.add(pe,pe),re=o.mul(pe,be),N=o.sub(N,re),G=o.mul(pe,ae),G=o.add(G,G),G=o.add(G,G),new W(N,K,G)}add(R){O(R);let{X:B,Y:k,Z:T}=this,{X:I,Y:q,Z:N}=R,K=o.ZERO,G=o.ZERO,re=o.ZERO,ae=i.a,pe=o.mul(i.b,lp),be=o.mul(B,I),ve=o.mul(k,q),Ae=o.mul(T,N),Ie=o.add(B,k),we=o.add(I,q);Ie=o.mul(Ie,we),we=o.add(be,ve),Ie=o.sub(Ie,we),we=o.add(B,T);let Ue=o.add(I,N);return we=o.mul(we,Ue),Ue=o.add(be,Ae),we=o.sub(we,Ue),Ue=o.add(k,T),K=o.add(q,N),Ue=o.mul(Ue,K),K=o.add(ve,Ae),Ue=o.sub(Ue,K),re=o.mul(ae,we),K=o.mul(pe,Ae),re=o.add(K,re),K=o.sub(ve,re),re=o.add(ve,re),G=o.mul(K,re),ve=o.add(be,be),ve=o.add(ve,be),Ae=o.mul(ae,Ae),we=o.mul(pe,we),ve=o.add(ve,Ae),Ae=o.sub(be,Ae),Ae=o.mul(ae,Ae),we=o.add(we,Ae),be=o.mul(ve,we),G=o.add(G,be),be=o.mul(Ue,we),K=o.mul(Ie,K),K=o.sub(K,be),be=o.mul(Ie,ve),re=o.mul(Ue,re),re=o.add(re,be),new W(K,G,re)}subtract(R){return this.add(R.negate())}is0(){return this.equals(W.ZERO)}multiply(R){let{endo:B}=t;if(!n.isValidNot0(R))throw Error("invalid scalar: out of range");let k,T,I=(q)=>j.cached(this,q,(N)=>Bb(W,N));if(B){let{k1neg:q,k1:N,k2neg:K,k2:G}=L(R),{p:re,f:ae}=I(N),{p:pe,f:be}=I(G);T=ae.add(be),k=P(B.beta,re,pe,q,K)}else{let{p:q,f:N}=I(R);k=q,T=N}return Bb(W,[k,T])[0]}multiplyUnsafe(R){let{endo:B}=t,k=this;if(!n.isValid(R))throw Error("invalid scalar: out of range");if(R===lo||k.is0())return W.ZERO;if(R===Ia)return k;if(j.hasCache(this))return this.multiply(R);if(B){let{k1neg:T,k1:I,k2neg:q,k2:N}=L(R),{p1:K,p2:G}=AO(W,k,I,N);return P(B.beta,K,G,T,q)}else return j.unsafe(k,R)}toAffine(R){return z(this,R)}isTorsionFree(){let{isTorsionFree:R}=t;if(s===Ia)return!0;if(R)return R(W,this);return j.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:R}=t;if(s===Ia)return this;if(R)return R(W,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(R=!0){return jl(R,"isCompressed"),this.assertValidity(),h(W,this,R)}toHex(R=!0){return ss(this.toBytes(R))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,j=new jb(W,t.endo?Math.ceil(ee/2):ee);return W.BASE.precompute(8),W}function PO(e){return Uint8Array.of(e?2:3)}function zO(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function nJ(e,t={}){let{Fn:r}=e,o=t.randomBytes||Go,n=Object.assign(zO(e.Fp,r),{seed:zb(r.ORDER)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h=o(n.seed)){return wO(Te(h,n.seed,"seed"),r.ORDER)}function l(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n;if(!va(h))return;if("_lengths"in r&&r._lengths||b===y)return;let x=Te(h,void 0,"key").length;return x===y||x===S}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=ap(a,l);return Object.freeze({getPublicKey:l,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function Fb(e,t,r={}){qr(t),cs(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes||Go,n=r.hmac||((k,T)=>ka(t,k,T)),{Fp:i,Fn:s}=e,{ORDER:a,BITS:l}=s,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h}=nJ(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=a*CO<i.ORDER;function S(k){let T=a>>Ia;return k>T}function x(k,T){if(!s.isValidNot0(T))throw Error(`invalid signature ${k}: out of range 1..Point.Fn.ORDER`);return T}function _(){if(y)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function A(k,T){Mb(T);let I=h.signature,q=T==="compact"?I:T==="recovered"?I+1:void 0;return Te(k,q)}class O{r;s;recovery;constructor(k,T,I){if(this.r=x("r",k),this.s=x("s",T),I!=null){if(_(),![0,1,2,3].includes(I))throw Error("invalid recovery id");this.recovery=I}Object.freeze(this)}static fromBytes(k,T=b.format){A(k,T);let I;if(T==="der"){let{r:G,s:re}=ti.toSig(Te(k));return new O(G,re)}if(T==="recovered")I=k[0],T="compact",k=k.subarray(1);let q=h.signature/2,N=k.subarray(0,q),K=k.subarray(q,q*2);return new O(s.fromBytes(N),s.fromBytes(K),I)}static fromHex(k,T){return this.fromBytes(as(k),T)}assertRecovery(){let{recovery:k}=this;if(k==null)throw Error("invalid recovery id: must be present");return k}addRecoveryBit(k){return new O(this.r,this.s,k)}recoverPublicKey(k){let{r:T,s:I}=this,q=this.assertRecovery(),N=q===2||q===3?T+a:T;if(!i.isValid(N))throw Error("invalid recovery id: sig.r+curve.n != R.x");let K=i.toBytes(N),G=e.fromBytes(Et(PO((q&1)===0),K)),re=s.inv(N),ae=z(Te(k,void 0,"msgHash")),pe=s.create(-ae*re),be=s.create(I*re),ve=e.BASE.multiplyUnsafe(pe).add(G.multiplyUnsafe(be));if(ve.is0())throw Error("invalid recovery: point at infinify");return ve.assertValidity(),ve}hasHighS(){return S(this.s)}toBytes(k=b.format){if(Mb(k),k==="der")return as(ti.hexFromSig(this));let{r:T,s:I}=this,q=s.toBytes(T),N=s.toBytes(I);if(k==="recovered")return _(),Et(Uint8Array.of(this.assertRecovery()),q,N);return Et(q,N)}toHex(k){return ss(this.toBytes(k))}}let L=r.bits2int||function(T){if(T.length>8192)throw Error("input is too large");let I=Yo(T),q=T.length*8-l;return q>0?I>>BigInt(q):I},z=r.bits2int_modN||function(T){return s.create(L(T))},H=ql(l);function P(k){return Ml("num < 2^"+l,k,lo,H),s.toBytes(k)}function W(k,T){return Te(k,void 0,"message"),T?Te(t(k),void 0,"prehashed message"):k}function ee(k,T,I){let{lowS:q,prehash:N,extraEntropy:K}=Ub(I,b);k=W(k,N);let G=z(k),re=s.fromBytes(T);if(!s.isValidNot0(re))throw Error("invalid private key");let ae=[P(re),P(G)];if(K!=null&&K!==!1){let Ae=K===!0?o(h.secretKey):K;ae.push(Te(Ae,void 0,"extraEntropy"))}let pe=Et(...ae),be=G;function ve(Ae){let Ie=L(Ae);if(!s.isValidNot0(Ie))return;let we=s.inv(Ie),Ue=e.BASE.multiply(Ie).toAffine(),De=s.create(Ue.x);if(De===lo)return;let Qe=s.create(we*s.create(be+De*re));if(Qe===lo)return;let bt=(Ue.x===De?0:2)|Number(Ue.y&Ia),Tt=Qe;if(q&&S(Qe))Tt=s.neg(Qe),bt^=1;return new O(De,Tt,y?void 0:bt)}return{seed:pe,k2sig:ve}}function j(k,T,I={}){let{seed:q,k2sig:N}=ee(k,T,I);return lO(t.outputLen,s.BYTES,n)(q,N).toBytes(I.format)}function R(k,T,I,q={}){let{lowS:N,prehash:K,format:G}=Ub(q,b);if(I=Te(I,void 0,"publicKey"),T=W(T,K),!va(k)){let re=k instanceof O?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}A(k,G);try{let re=O.fromBytes(k,G),ae=e.fromBytes(I);if(N&&re.hasHighS())return!1;let{r:pe,s:be}=re,ve=z(T),Ae=s.inv(be),Ie=s.create(ve*Ae),we=s.create(pe*Ae),Ue=e.BASE.multiplyUnsafe(Ie).add(ae.multiplyUnsafe(we));if(Ue.is0())return!1;return s.create(Ue.x)===pe}catch(re){return!1}}function B(k,T,I={}){let{prehash:q}=Ub(I,b);return T=W(T,q),O.fromBytes(k,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:m,lengths:h,Point:e,sign:j,verify:R,recoverPublicKey:B,Signature:O,hash:t})}function NO(e,t,r){return e&t^~e&r}function DO(e,t,r){return e&t^e&r^t&r}class up{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,o){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=np(this.buffer)}update(e){co(this),Te(e);let{view:t,buffer:r,blockLen:o}=this,n=e.length;for(let i=0;i<n;){let s=Math.min(o-this.pos,n-i);if(s===o){let a=np(e);for(;o<=n-i;i+=o)this.process(a,i);continue}if(r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){co(this),tp(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:n}=this,{pos:i}=this;if(t[i++]=128,vr(this.buffer.subarray(i)),this.padOffset>o-i)this.process(r,0),i=0;for(let d=i;d<o;d++)t[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),n),this.process(r,0);let s=np(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)s.setUint32(4*d,u[d],n)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:r,length:o,finished:n,destroyed:i,pos:s}=this;if(e.destroyed=i,e.finished=n,e.length=o,e.pos=s,o%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var uo=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Jt=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var dp=BigInt(4294967295),LO=BigInt(32);function oJ(e,t=!1){if(t)return{h:Number(e&dp),l:Number(e>>LO&dp)};return{h:Number(e>>LO&dp)|0,l:Number(e&dp)|0}}function fp(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=oJ(e[i],t);[o[i],n[i]]=[s,a]}return[o,n]}var Jb=(e,t,r)=>e>>>r,Hb=(e,t,r)=>e<<32-r|t>>>r,ds=(e,t,r)=>e>>>r|t<<32-r,fs=(e,t,r)=>e<<32-r|t>>>r,Kl=(e,t,r)=>e<<64-r|t>>>r-32,Vl=(e,t,r)=>e>>>r-32|t<<64-r;var BO=(e,t,r)=>e<<r|t>>>32-r,jO=(e,t,r)=>t<<r|e>>>32-r,ZO=(e,t,r)=>t<<r-32|e>>>64-r,UO=(e,t,r)=>e<<r-32|t>>>64-r;function On(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var MO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),qO=(e,t,r,o)=>t+r+o+(e/4294967296|0)|0,FO=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0),JO=(e,t,r,o,n)=>t+r+o+n+(e/4294967296|0)|0,HO=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),KO=(e,t,r,o,n,i)=>t+r+o+n+i+(e/4294967296|0)|0;var sJ=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]),ri=new Uint32Array(64);class VO extends up{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:o,E:n,F:i,G:s,H:a}=this;return[e,t,r,o,n,i,s,a]}set(e,t,r,o,n,i,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=o|0,this.E=n|0,this.F=i|0,this.G=s|0,this.H=a|0}process(e,t){for(let d=0;d<16;d++,t+=4)ri[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let f=ri[d-15],m=ri[d-2],h=on(f,7)^on(f,18)^f>>>3,b=on(m,17)^on(m,19)^m>>>10;ri[d]=b+ri[d-7]+h+ri[d-16]|0}let{A:r,B:o,C:n,D:i,E:s,F:a,G:l,H:u}=this;for(let d=0;d<64;d++){let f=on(s,6)^on(s,11)^on(s,25),m=u+f+NO(s,a,l)+sJ[d]+ri[d]|0,b=(on(r,2)^on(r,13)^on(r,22))+DO(r,o,n)|0;u=l,l=a,a=s,s=i+m|0,i=n,n=o,o=r,r=m+b|0}r=r+this.A|0,o=o+this.B|0,n=n+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,o,n,i,s,a,l,u)}roundClean(){vr(ri)}destroy(){this.set(0,0,0,0,0,0,0,0),vr(this.buffer)}}class WO extends VO{A=uo[0]|0;B=uo[1]|0;C=uo[2]|0;D=uo[3]|0;E=uo[4]|0;F=uo[5]|0;G=uo[6]|0;H=uo[7]|0;constructor(){super(32)}}var GO=(()=>fp(["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))))(),aJ=(()=>GO[0])(),cJ=(()=>GO[1])(),ni=new Uint32Array(80),oi=new Uint32Array(80);class QO extends up{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:o,Ch:n,Cl:i,Dh:s,Dl:a,Eh:l,El:u,Fh:d,Fl:f,Gh:m,Gl:h,Hh:b,Hl:y}=this;return[e,t,r,o,n,i,s,a,l,u,d,f,m,h,b,y]}set(e,t,r,o,n,i,s,a,l,u,d,f,m,h,b,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=o|0,this.Ch=n|0,this.Cl=i|0,this.Dh=s|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=f|0,this.Gh=m|0,this.Gl=h|0,this.Hh=b|0,this.Hl=y|0}process(e,t){for(let _=0;_<16;_++,t+=4)ni[_]=e.getUint32(t),oi[_]=e.getUint32(t+=4);for(let _=16;_<80;_++){let A=ni[_-15]|0,O=oi[_-15]|0,L=ds(A,O,1)^ds(A,O,8)^Jb(A,O,7),z=fs(A,O,1)^fs(A,O,8)^Hb(A,O,7),H=ni[_-2]|0,P=oi[_-2]|0,W=ds(H,P,19)^Kl(H,P,61)^Jb(H,P,6),ee=fs(H,P,19)^Vl(H,P,61)^Hb(H,P,6),j=FO(z,ee,oi[_-7],oi[_-16]),R=JO(j,L,W,ni[_-7],ni[_-16]);ni[_]=R|0,oi[_]=j|0}let{Ah:r,Al:o,Bh:n,Bl:i,Ch:s,Cl:a,Dh:l,Dl:u,Eh:d,El:f,Fh:m,Fl:h,Gh:b,Gl:y,Hh:S,Hl:x}=this;for(let _=0;_<80;_++){let A=ds(d,f,14)^ds(d,f,18)^Kl(d,f,41),O=fs(d,f,14)^fs(d,f,18)^Vl(d,f,41),L=d&m^~d&b,z=f&h^~f&y,H=HO(x,O,z,cJ[_],oi[_]),P=KO(H,S,A,L,aJ[_],ni[_]),W=H|0,ee=ds(r,o,28)^Kl(r,o,34)^Kl(r,o,39),j=fs(r,o,28)^Vl(r,o,34)^Vl(r,o,39),R=r&n^r&s^n&s,B=o&i^o&a^i&a;S=b|0,x=y|0,b=m|0,y=h|0,m=d|0,h=f|0,{h:d,l:f}=On(l|0,u|0,P|0,W|0),l=s|0,u=a|0,s=n|0,a=i|0,n=r|0,i=o|0;let k=MO(W,j,B);r=qO(k,P,ee,R),o=k|0}({h:r,l:o}=On(this.Ah|0,this.Al|0,r|0,o|0)),{h:n,l:i}=On(this.Bh|0,this.Bl|0,n|0,i|0),{h:s,l:a}=On(this.Ch|0,this.Cl|0,s|0,a|0),{h:l,l:u}=On(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:f}=On(this.Eh|0,this.El|0,d|0,f|0),{h:m,l:h}=On(this.Fh|0,this.Fl|0,m|0,h|0),{h:b,l:y}=On(this.Gh|0,this.Gl|0,b|0,y|0),{h:S,l:x}=On(this.Hh|0,this.Hl|0,S|0,x|0),this.set(r,o,n,i,s,a,l,u,d,f,m,h,b,y,S,x)}roundClean(){vr(ni,oi)}destroy(){vr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class YO extends QO{Ah=Jt[0]|0;Al=Jt[1]|0;Bh=Jt[2]|0;Bl=Jt[3]|0;Ch=Jt[4]|0;Cl=Jt[5]|0;Dh=Jt[6]|0;Dl=Jt[7]|0;Eh=Jt[8]|0;El=Jt[9]|0;Fh=Jt[10]|0;Fl=Jt[11]|0;Gh=Jt[12]|0;Gl=Jt[13]|0;Hh=Jt[14]|0;Hl=Jt[15]|0;constructor(){super(48)}}var pp=wa(()=>new WO,Qo(1));var XO=wa(()=>new YO,Qo(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lJ=BigInt(1),eC=BigInt(2),uJ=BigInt(3),dJ=BigInt(5),lge=BigInt(8),tC=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function fJ(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=tC,a=e*e%i*e%i,l=Fr(a,eC,i)*a%i,u=Fr(l,lJ,i)*e%i,d=Fr(u,dJ,i)*u%i,f=Fr(d,t,i)*d%i,m=Fr(f,r,i)*f%i,h=Fr(m,o,i)*m%i,b=Fr(h,n,i)*h%i,y=Fr(b,n,i)*h%i,S=Fr(y,t,i)*d%i;return{pow_p_5_8:Fr(S,eC,i)*e%i,b2:a}}function pJ(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var rC=(()=>{let e=tC;return RO({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=fJ(t);return lr(Fr(r,uJ,e)*o,e)},adjustScalarBytes:pJ})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var mJ=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),hJ=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var gJ=qb(mJ),Kb=Fb(gJ,pp);var yJ=qb(hJ),nC=Fb(yJ,XO);function iC(e,t,r){if(qr(e),r===void 0)r=new Uint8Array(e.outputLen);return ka(e,r,t)}var Vb=Uint8Array.of(0),oC=Uint8Array.of();function sC(e,t,r,o=32){qr(e),Lt(o,"length");let n=e.outputLen;if(o>255*n)throw Error("Length must be <= 255*HashLen");let i=Math.ceil(o/n);if(r===void 0)r=oC;else Te(r,void 0,"info");let s=new Uint8Array(i*n),a=ka.create(e,t),l=a._cloneInto(),u=new Uint8Array(a.outputLen);for(let d=0;d<i;d++)Vb[0]=d+1,l.update(d===0?oC:u).update(r).update(Vb).digestInto(u),s.set(u,n*d),a._cloneInto(l);return a.destroy(),l.destroy(),vr(u,Vb),s.slice(0,o)}var bJ=BigInt(0),Wl=BigInt(1),SJ=BigInt(2),vJ=BigInt(7),wJ=BigInt(256),xJ=BigInt(113),lC=[],uC=[],dC=[];for(let e=0,t=Wl,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],lC.push(2*(5*o+r)),uC.push((e+1)*(e+2)/2%64);let n=bJ;for(let i=0;i<7;i++)if(t=(t<<Wl^(t>>vJ)*xJ)%wJ,t&SJ)n^=Wl<<(Wl<<BigInt(i))-Wl;dC.push(n)}var fC=fp(dC,!0),_J=fC[0],EJ=fC[1],aC=(e,t,r)=>r>32?ZO(e,t,r):BO(e,t,r),cC=(e,t,r)=>r>32?UO(e,t,r):jO(e,t,r);function kJ(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let s=0;s<10;s++)r[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,l=(s+2)%10,u=r[l],d=r[l+1],f=aC(u,d,1)^r[a],m=cC(u,d,1)^r[a+1];for(let h=0;h<50;h+=10)e[s+h]^=f,e[s+h+1]^=m}let n=e[2],i=e[3];for(let s=0;s<24;s++){let a=uC[s],l=aC(n,i,a),u=cC(n,i,a),d=lC[s];n=e[d],i=e[d+1],e[d]=l,e[d+1]=u}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)r[a]=e[s+a];for(let a=0;a<10;a++)e[s+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=_J[o],e[1]^=EJ[o]}vr(r)}class mp{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,o=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=o,this.rounds=n,Lt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=rp(this.state)}clone(){return this._cloneInto()}keccak(){Ab(this.state32),kJ(this.state32,this.rounds),Ab(this.state32),this.posOut=0,this.pos=0}update(e){co(this),Te(e);let{blockLen:t,state:r}=this,o=e.length;for(let n=0;n<o;){let i=Math.min(t-this.pos,o-n);for(let s=0;s<i;s++)r[this.pos++]^=e[n++];if(this.pos===t)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:r,blockLen:o}=this;if(e[r]^=t,(t&128)!==0&&r===o-1)this.keccak();e[o-1]^=128,this.keccak()}writeInto(e){co(this,!1),Te(e),this.finish();let t=this.state,{blockLen:r}=this;for(let o=0,n=e.length;o<n;){if(this.posOut>=r)this.keccak();let i=Math.min(r-this.posOut,n-o);e.set(t.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Lt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(tp(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,vr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:o,rounds:n,enableXOF:i}=this;return e||=new mp(t,r,o,i,n),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=o,e.enableXOF=i,e.destroyed=this.destroyed,e}}var pC=(e,t,r,o={})=>wa(()=>new mp(t,e,r),o);var ps=pC(6,136,32,Qo(8));var mC=pC(6,72,64,Qo(10));var hC=(e,t,r,o={})=>wa((n={})=>new mp(t,e,n.dkLen===void 0?r:n.dkLen,!0),o),gC=hC(31,168,16,Qo(11)),Cn=hC(31,136,32,Qo(12));function Wb(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function bC(e){return Wb(e),(e&e-1)===0&&e!==0}function Gb(e,t){Wb(e);let r=0;for(let o=0;o<t;o++,e>>>=1)r=r<<1|e&1;return r}function SC(e){return Wb(e),31-Math.clz32(e)}function yC(e){let t=e.length;if(t<2||!bC(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=SC(t);for(let o=0;o<t;o++){let n=Gb(o,r);if(o<n){let i=e[o];e[o]=e[n],e[n]=i}}return e}var Qb=(e,t)=>{let{N:r,roots:o,dit:n,invertButterflies:i=!1,skipStages:s=0,brp:a=!0}=t,l=SC(r);if(!bC(r))throw Error("FFT: Polynomial size should be power of two");let u=n!==i;return(d)=>{if(d.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)yC(d);for(let f=0,m=1;f<l-s;f++){let h=n?f+1+s:l-f,b=1<<h,y=b>>1,S=r>>h;for(let x=0;x<r;x+=b)for(let _=0,A=m++;_<y;_++){let O=i?n?r-A:A:_*S,L=x+_,z=x+_+y,H=o[O],P=d[z],W=d[L];if(u){let ee=e.mul(P,H);d[L]=e.add(W,ee),d[z]=e.sub(W,ee)}else if(i)d[L]=e.add(P,W),d[z]=e.mul(e.sub(P,W),H);else d[L]=e.add(W,P),d[z]=e.mul(e.sub(W,P),H)}}if(!n&&a)yC(d);return d}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Pn=Go;function hp(e,t){if(e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function vC(e){return Uint8Array.from(e)}function ms(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,o=t.reduce((n,i)=>n+r(i),0);return{bytesLen:o,encode:(n)=>{let i=new Uint8Array(o);for(let s=0,a=0;s<t.length;s++){let l=t[s],u=r(l),d=typeof l==="number"?n[s]:l.encode(n[s]);if(Te(d,u,e),i.set(d,a),typeof l!=="number")d.fill(0);a+=u}return i},decode:(n)=>{Te(n,o,e);let i=[];for(let s of t){let a=r(s),l=n.subarray(0,a);i.push(typeof s==="number"?l:s.decode(l)),n=n.subarray(a)}return i}}}function gp(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(o)=>{if(o.length!==t)throw Error(`vecCoder.encode: wrong length=${o.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let i=0,s=0;i<o.length;i++){let a=e.encode(o[i]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(o)=>{Te(o,r);let n=[];for(let i=0;i<o.length;i+=e.bytesLen)n.push(e.decode(o.subarray(i,i+e.bytesLen)));return n}}}function $t(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function Yb(e){return(1<<e)-1}var Ege=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var wC=(e)=>{let{newPoly:t,N:r,Q:o,F:n,ROOT_OF_UNITY:i,brvBits:s,isKyber:a}=e,l=(_,A=o)=>{let O=_%A|0;return(O>=0?O|0:A+O|0)|0},u=(_,A=o)=>{let O=l(_,A)|0;return(O>A>>1?O-A|0:O)|0};function d(){let _=t(r);for(let A=0;A<r;A++){let O=Gb(A,s),L=BigInt(i)**BigInt(O)%BigInt(o);_[A]=Number(L)|0}return _}let f=d(),m={add:(_,A)=>l((_|0)+(A|0))|0,sub:(_,A)=>l((_|0)-(A|0))|0,mul:(_,A)=>l((_|0)*(A|0))|0,inv:(_)=>{throw Error("not implemented")}},h={N:r,roots:f,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=Qb(m,{dit:!1,...h}),y=Qb(m,{dit:!0,...h});return{mod:l,smod:u,nttZetas:f,NTT:{encode:(_)=>b(_),decode:(_)=>{y(_);for(let A=0;A<_.length;A++)_[A]=l(n*_[A]);return _}},bitsCoder:(_,A)=>{let O=Yb(_),L=_*(r/8);return{bytesLen:L,encode:(z)=>{let H=new Uint8Array(L);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=(A.encode(z[P])&O)<<ee,ee+=_;for(;ee>=8;ee-=8,W>>=8)H[j++]=W&Yb(ee)}return H},decode:(z)=>{let H=t(r);for(let P=0,W=0,ee=0,j=0;P<z.length;P++){W|=z[P]<<ee,ee+=8;for(;ee>=_;ee-=_,W>>=_)H[j++]=A.decode(W&O)}return H}}}}},IJ=(e)=>(t,r)=>{if(!r)r=e.blockLen;let o=new Uint8Array(t.length+2);o.set(t);let n=t.length,i=new Uint8Array(r),s=e.create({}),a=0,l=0;return{stats:()=>({calls:a,xofs:l}),get:(u,d)=>(o[n+0]=u,o[n+1]=d,s.destroy(),s=e.create({}).update(o),a++,()=>(l++,s.xofInto(i))),clean:()=>{s.destroy(),$t(i,o)}}},xC=IJ(gC);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var er=256,fo=3329,AJ=3303,TJ=17,{mod:Yl,nttZetas:RJ,NTT:hs,bitsCoder:$J}=wC({N:er,Q:fo,F:AJ,ROOT_OF_UNITY:TJ,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),Xb={512:{N:er,Q:fo,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:er,Q:fo,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:er,Q:fo,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},OJ=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+fo/2)/fo,decode:(r)=>r*fo+t>>>e}},Gl=(e)=>$J(e,OJ(e));function gs(e,t){for(let r=0;r<er;r++)e[r]=Yl(e[r]+t[r])}function CJ(e,t){for(let r=0;r<er;r++)e[r]=Yl(e[r]-t[r])}function PJ(e,t,r,o,n){let i=Yl(t*o*n+e*r),s=Yl(e*o+t*r);return{c0:i,c1:s}}function yp(e,t){for(let r=0;r<er/2;r++){let o=RJ[64+(r>>1)];if(r&1)o=-o;let{c0:n,c1:i}=PJ(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],o);e[2*r+0]=n,e[2*r+1]=i}return e}function _C(e){let t=new Uint16Array(er);for(let r=0;r<er;){let o=e();if(o.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<er&&n+3<=o.length;n+=3){let i=(o[n+0]>>0|o[n+1]<<8)&4095,s=(o[n+1]>>4|o[n+2]<<4)&4095;if(i<fo)t[r++]=i;if(r<er&&s<fo)t[r++]=s}}return t}function Ql(e,t,r,o){let n=e(o*er/4,t,r),i=new Uint16Array(er),s=rp(n),a=0;for(let l=0,u=0,d=0,f=0;l<s.length;l++){let m=s[l];for(let h=0;h<32;h++)if(d+=m&1,m>>=1,a+=1,a===o)f=d,d=0;else if(a===2*o)i[u++]=Yl(f-d),d=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return i}var zJ=(e)=>{let{K:t,PRF:r,XOF:o,HASH512:n,ETA1:i,ETA2:s,du:a,dv:l}=e,u=Gl(1),d=Gl(l),f=Gl(a),m=ms("publicKey",gp(Gl(12),t),32),h=gp(Gl(12),t),b=ms("ciphertext",gp(f,t),d),y=ms("seed",32,32);return{secretCoder:h,lengths:{secretKey:h.bytesLen,publicKey:m.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{Te(S,32,"seed");let x=new Uint8Array(33);x.set(S),x[32]=t;let _=n(x),[A,O]=y.decode(_),L=[],z=[];for(let W=0;W<t;W++)L.push(hs.encode(Ql(r,O,W,i)));let H=o(A);for(let W=0;W<t;W++){let ee=hs.encode(Ql(r,O,t+W,i));for(let j=0;j<t;j++){let R=_C(H.get(j,W));gs(ee,yp(R,L[j]))}z.push(ee)}H.clean();let P={publicKey:m.encode([z,A]),secretKey:h.encode(L)};return $t(A,O,L,z,x,_),P},encrypt:(S,x,_)=>{let[A,O]=m.decode(S),L=[];for(let j=0;j<t;j++)L.push(hs.encode(Ql(r,_,j,i)));let z=o(O),H=new Uint16Array(er),P=[];for(let j=0;j<t;j++){let R=Ql(r,_,t+j,s),B=new Uint16Array(er);for(let k=0;k<t;k++){let T=_C(z.get(j,k));gs(B,yp(T,L[k]))}gs(R,hs.decode(B)),P.push(R),gs(H,yp(A[j],L[j])),$t(B)}z.clean();let W=Ql(r,_,2*t,s);gs(W,hs.decode(H));let ee=u.decode(x);return gs(ee,W),$t(A,L,H,W),b.encode([P,ee])},decrypt:(S,x)=>{let[_,A]=b.decode(S),O=h.decode(x),L=new Uint16Array(er);for(let z=0;z<t;z++)gs(L,yp(O[z],hs.encode(_[z])));return CJ(A,hs.decode(L)),$t(L,O,_),u.encode(A)}}};function eS(e){let t=zJ(e),{HASH256:r,HASH512:o,KDF:n}=e,{secretCoder:i,lengths:s}=t,a=ms("secretKey",s.secretKey,s.publicKey,32,32),l=32,u=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(d=Pn(64))=>{Te(d,64,"seed");let{publicKey:f,secretKey:m}=t.keygen(d.subarray(0,32)),h=r(f),b=a.encode([m,f,h,d.subarray(32)]);return $t(m,h),{publicKey:f,secretKey:b}},getPublicKey:(d)=>{let[f,m,h,b]=a.decode(d);return Uint8Array.from(m)},encapsulate:(d,f=Pn(32))=>{Te(d,s.publicKey,"publicKey"),Te(f,32,"message");let m=d.subarray(0,384*e.K),h=i.encode(i.decode(vC(m)));if(!hp(h,m))throw $t(h),Error("ML-KEM.encapsulate: wrong publicKey modulus");$t(h);let b=o.create().update(f).update(r(d)).digest(),y=t.encrypt(d,f,b.subarray(32,64));return $t(b.subarray(32)),{cipherText:y,sharedSecret:b.subarray(0,32)}},decapsulate:(d,f)=>{Te(f,a.bytesLen,"secretKey"),Te(d,s.cipherText,"cipherText");let m=a.bytesLen-96,h=m+32,b=r(f.subarray(m/2,h));if(!hp(b,f.subarray(h,h+32)))throw Error("invalid secretKey: hash check failed");let[y,S,x,_]=a.decode(f),A=t.decrypt(d,y),O=o.create().update(A).update(x).digest(),L=O.subarray(0,32),z=t.encrypt(S,A,O.subarray(32,64)),H=hp(d,z),P=n.create({dkLen:32}).update(_).update(d).digest();return $t(A,z,!H?L:P),H?L:P}}}function NJ(e,t,r){return Cn.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var tS={HASH256:ps,HASH512:mC,KDF:Cn,XOF:xC,PRF:NJ},Nge=eS({...tS,...Xb[512]}),Xl=eS({...tS,...Xb[768]}),EC=eS({...tS,...Xb[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function DJ(e,t=!1){let{lengths:r,keygen:o}=e;if(t){let i=e.Point.Fn;if(!i)throw Error("No Point.Fn");o=(s=Pn(r.seed))=>{Te(s,r.seed,"seed");let a=i.isLE?Xo(s):Yo(s),l=i.toBytes(i.create(a));return{secretKey:l,publicKey:e.getPublicKey(l)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:o,getPublicKey:(n)=>e.getPublicKey(n)}}function rS(e,t=!1){let r=DJ(e,t);if(!e.getSharedSecret)throw Error("wrong curve");return{lengths:{...r.lengths,msg:r.lengths.seed,cipherText:r.lengths.publicKey},keygen:r.keygen,getPublicKey:r.getPublicKey,encapsulate(o,n=Pn(e.lengths.seed)){let i=this.keygen(n).secretKey,s=this.decapsulate(o,i),a=e.getPublicKey(i);return $t(i),{sharedSecret:s,cipherText:a}},decapsulate(o,n){let i=e.getSharedSecret(n,o);return e.lengths.publicKeyHasPrefix?i.subarray(1):i}}}function eu(e,t){return ms(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function nS(e){return(t,r)=>e(t,{dkLen:r})}function LJ(e,t,...r){let o=eu(r,"seed"),n=eu(r,"publicKey");if(e===void 0)e=o.bytesLen;Lt(e);function i(s){Te(s,e);let a=o.decode(t(s,o.bytesLen)),l=r.map((f,m)=>f.keygen(a[m])),u=l.map((f)=>f.secretKey),d=l.map((f)=>f.publicKey);return{secretKey:u,publicKey:d}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=Pn(e)){let{publicKey:a,secretKey:l}=i(s),u=n.encode(a);return $t(a),$t(l),{secretKey:s,publicKey:u}},expandDecapsulationKey:i,realSeedLen:e}}function bp(e,t,r,o,...n){let i=LJ(e,r,...n),s=eu(n,"cipherText"),a=eu(n,"publicKey"),l=eu(n,"msg");if(t===void 0)t=l.bytesLen;return Lt(t),{lengths:{...i.info.lengths,msg:t,msgRand:l.bytesLen,cipherText:s.bytesLen},getPublicKey:i.getPublicKey,keygen:i.keygen,encapsulate(u,d=Pn(l.bytesLen)){let f=a.decode(u),m=l.decode(d),h=n.map((x,_)=>x.encapsulate(f[_],m[_])),b=h.map((x)=>x.sharedSecret),y=h.map((x)=>x.cipherText),S={sharedSecret:o(f,y,b),cipherText:s.encode(y)};return $t(b,y),S},decapsulate(u,d){let f=s.decode(u),{publicKey:m,secretKey:h}=i.expandDecapsulationKey(d),b=n.map((y,S)=>y.decapsulate(f[S],h[S]));return o(m,f,b)}}}function kC(e,t,r,o,n){return qr(o),qr(n),bp(32,32,nS(o),(i,s,a)=>n(Et(a[0],a[1],s[1],i[1],ei(e))),t,r)}var Hge=kC("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Xl,rS(Kb,!0),Cn,ps),Kge=kC("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",EC,rS(nC,!0),Cn,ps);function BJ(e,t,r,o,n){return qr(o),qr(n),bp(32,32,nS(o),(i,s,a)=>{let l=Et(a[0],a[1],s[0],i[0],s[1],i[1],ei(e)),u=32,d=Et(ei("hybrid_prk"),l),f=iC(n,d),m=Et(xa(32,2),ei("shared_secret"),ei("")),h=sC(n,f,m,32);return $t(f,m,d,l),h},t,r)}var IC=rS(rC),Vge=BJ("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Xl,IC,Cn,pp),jJ=(()=>bp(32,32,nS(Cn),(e,t,r)=>ps(Et(r[0],r[1],t[1],e[1],ei("\\.//^\\"))),Xl,IC))();function ZJ(e,t,r,o){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function i(s){let a;for(let d=0,f=t;;d=f,f+=t){if(f>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(d,f),!0),n.isValidNot0(a))break}let l=n.toBytes(n.create(a)),u=e.getPublicKey(l,!1);return{secretKey:l,publicKey:u}}return{lengths:{secretKey:t,publicKey:r,seed:o,msg:o,cipherText:r},keygen(s=Pn(o)){return Te(s,o,"seed"),i(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=Pn(o)){Te(a,o,"rand");let{secretKey:l}=i(a),u=this.decapsulate(s,l),d=e.getPublicKey(l,!1);return $t(l),{sharedSecret:u,cipherText:d}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function UJ(e,t,r,o){let{secretKey:n,publicKeyUncompressed:i}=r.lengths;if(!n||!i)throw Error("wrong curve");let s=ZJ(r,n,i,o),a=64,l=a+o;return bp(32,32,(u)=>{Te(u,32);let d=Cn(u,{dkLen:l}),f=d.subarray(0,a),m=d.subarray(a,l);return Et(f,m)},(u,d,f)=>ps(Et(f[0],f[1],d[1],u[1],ei(e))),t,s)}var MJ=(()=>UJ("MLKEM768-P256",Xl,Kb,128))();var Sp=jJ,AC=MJ;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ye=(e,t,r)=>Mt(e,t,r),iS=St,Aa=qf,Ht=(...e)=>cb(...e),Ta=(e)=>Ol(e),Ra=ib,$a=(e)=>oo(e),wp=BigInt(0),oS=BigInt(1);function po(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function xp(e){if(typeof e==="bigint"){if(!vp(e))throw RangeError("positive bigint expected, got "+e)}else iS(e);return e}function zn(e,t=""){if(typeof e!=="number"){let r=t&&`"${t}" `;throw TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw RangeError(r+"expected safe integer, got "+e)}}function tu(e){let t=xp(e).toString(16);return t.length&1?"0"+t:t}function TC(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?wp:BigInt("0x"+e)}function ys(e){return TC(qf(e))}function sn(e){return TC(qf(ii(Mt(e)).reverse()))}function _p(e,t){if(St(t),t===0)throw RangeError("zero length");e=xp(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return Ol(r.padStart(t*2,"0"))}function ru(e,t){return _p(e,t).reverse()}function RC(e,t){if(e=Ye(e),t=Ye(t),e.length!==t.length)return!1;let r=0;for(let o=0;o<e.length;o++)r|=e[o]^t[o];return r===0}function ii(e){return Uint8Array.from(Ye(e))}function Ep(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let o=t.charCodeAt(0);if(t.length!==1||o>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${o} at position ${r}`);return o})}var vp=(e)=>typeof e==="bigint"&&wp<=e;function qJ(e,t,r){return vp(e)&&vp(t)&&vp(r)&&t<=e&&e<r}function mo(e,t,r,o){if(!qJ(t,r,o))throw RangeError("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function Oa(e){if(e<wp)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>wp;e>>=oS,t+=1);return t}var nu=(e)=>(oS<<BigInt(e))-oS;function $C(e,t,r){if(St(e,"hashLen"),St(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let o=(S)=>new Uint8Array(S),n=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,l=o(e),u=o(e),d=0,f=()=>{l.fill(1),u.fill(0),d=0},m=(...S)=>r(u,Ht(l,...S)),h=(S=n)=>{if(u=m(i,S),l=m(),S.length===0)return;u=m(s,S),l=m()},b=()=>{if(d++>=a)throw Error("drbg: tried max amount of iterations");let S=0,x=[];while(S<t){l=m();let _=l.slice();x.push(_),S+=l.length}return Ht(...x)};return(S,x)=>{f(),h(S);let _=void 0;while((_=x(b()))===void 0)h();return f(),_}}function Jr(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function o(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw TypeError(`param "${i}" is invalid: expected own property`);let l=e[i];if(a&&l===void 0)return;let u=typeof l;if(u!==s||l===null)throw TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let n=(i,s)=>Object.entries(i).forEach(([a,l])=>o(a,l,s));n(t,!1),n(r,!0)}var sS=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Kt=BigInt(0),mt=BigInt(1),bs=BigInt(2),zC=BigInt(3),NC=BigInt(4),DC=BigInt(5),FJ=BigInt(7),LC=BigInt(8),JJ=BigInt(9),BC=BigInt(16);function it(e,t){if(t<=Kt)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=Kt?r:t+r}function Hr(e,t,r){if(t<Kt)throw Error("pow2: expected non-negative exponent, got "+t);let o=e;while(t-- >Kt)o*=o,o%=r;return o}function OC(e,t){if(e===Kt)throw Error("invert: expected non-zero number");if(t<=Kt)throw Error("invert: expected positive modulus, got "+t);let r=it(e,t),o=t,n=Kt,i=mt,s=mt,a=Kt;while(r!==Kt){let u=o/r,d=o-r*u,f=n-s*u,m=i-a*u;o=r,r=d,n=s,i=a,s=f,a=m}if(o!==mt)throw Error("invert: does not exist");return it(n,t)}function aS(e,t,r){let o=e;if(!o.eql(o.sqr(t),r))throw Error("Cannot find square root")}function jC(e,t){let r=e,o=(r.ORDER+mt)/NC,n=r.pow(t,o);return aS(r,n,t),n}function HJ(e,t){let r=e,o=(r.ORDER-DC)/LC,n=r.mul(t,bs),i=r.pow(n,o),s=r.mul(t,i),a=r.mul(r.mul(s,bs),i),l=r.mul(s,r.sub(a,r.ONE));return aS(r,l,t),l}function KJ(e){let t=kp(e),r=ZC(e),o=r(t,t.neg(t.ONE)),n=r(t,o),i=r(t,t.neg(o)),s=(e+FJ)/BC;return(a,l)=>{let u=a,d=u.pow(l,s),f=u.mul(d,o),m=u.mul(d,n),h=u.mul(d,i),b=u.eql(u.sqr(f),l),y=u.eql(u.sqr(m),l);d=u.cmov(d,f,b),f=u.cmov(h,m,y);let S=u.eql(u.sqr(f),l),x=u.cmov(d,f,S);return aS(u,x,l),x}}function ZC(e){if(e<zC)throw Error("sqrt is not defined for small field");let t=e-mt,r=0;while(t%bs===Kt)t/=bs,r++;let o=bs,n=kp(e);while(CC(n,o)===1)if(o++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return jC;let i=n.pow(o,t),s=(t+mt)/bs;return function(l,u){let d=l;if(d.is0(u))return u;if(CC(d,u)!==1)throw Error("Cannot find square root");let f=r,m=d.mul(d.ONE,i),h=d.pow(u,t),b=d.pow(u,s);while(!d.eql(h,d.ONE)){if(d.is0(h))return d.ZERO;let y=1,S=d.sqr(h);while(!d.eql(S,d.ONE))if(y++,S=d.sqr(S),y===f)throw Error("Cannot find square root");let x=mt<<BigInt(f-y-1),_=d.pow(m,x);f=y,m=d.sqr(_),h=d.mul(h,m),b=d.mul(b,_)}return b}}function VJ(e){if(e%NC===zC)return jC;if(e%LC===DC)return HJ;if(e%BC===JJ)return KJ(e);return ZC(e)}var ho=(e,t)=>(it(e,t)&mt)===mt,WJ=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function cS(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=WJ.reduce((o,n)=>(o[n]="function",o),t);if(Jr(e,r),zn(e.BYTES,"BYTES"),zn(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=mt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function GJ(e,t,r){let o=e;if(r<Kt)throw Error("invalid exponent, negatives unsupported");if(r===Kt)return o.ONE;if(r===mt)return t;let n=o.ONE,i=t;while(r>Kt){if(r&mt)n=o.mul(n,i);i=o.sqr(i),r>>=mt}return n}function ou(e,t,r=!1){let o=e,n=Array(t.length).fill(r?o.ZERO:void 0),i=t.reduce((a,l,u)=>{if(o.is0(l))return a;return n[u]=a,o.mul(a,l)},o.ONE),s=o.inv(i);return t.reduceRight((a,l,u)=>{if(o.is0(l))return a;return n[u]=o.mul(a,n[u]),o.mul(a,l)},s),n}function CC(e,t){let r=e,o=(r.ORDER-mt)/bs,n=r.pow(t,o),i=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!i&&!s&&!a)throw Error("invalid Legendre symbol result");return i?1:s?0:-1}function QJ(e,t){if(t!==void 0)iS(t);if(e<=Kt)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 r=Oa(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let o=t!==void 0?t:r,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}var PC=new WeakMap;class lS{ORDER;BITS;BYTES;isLE;ZERO=Kt;ONE=mt;_lengths;_mod;constructor(e,t={}){if(e<=mt)throw Error("invalid field: expected ORDER > 1, got "+e);let r=void 0;if(this.isLE=!1,t!=null&&typeof t==="object"){if(typeof t.BITS==="number")r=t.BITS;if(typeof t.sqrt==="function")Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0});if(typeof t.isLE==="boolean")this.isLE=t.isLE;if(t.allowedLengths)this._lengths=Object.freeze(t.allowedLengths.slice());if(typeof t.modFromBytes==="boolean")this._mod=t.modFromBytes}let{nBitLength:o,nByteLength:n}=QJ(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=n,Object.freeze(this)}create(e){return it(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return Kt<=e&&e<this.ORDER}is0(e){return e===Kt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&mt)===mt}neg(e){return it(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return it(e*e,this.ORDER)}add(e,t){return it(e+t,this.ORDER)}sub(e,t){return it(e-t,this.ORDER)}mul(e,t){return it(e*t,this.ORDER)}pow(e,t){return GJ(this,e,t)}div(e,t){return it(e*OC(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 OC(e,this.ORDER)}sqrt(e){let t=PC.get(this);if(!t)PC.set(this,t=VJ(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?ru(e,this.BYTES):_p(e,this.BYTES)}fromBytes(e,t=!1){Ye(e);let{_lengths:r,BYTES:o,isLE:n,ORDER:i,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let l=new Uint8Array(o);l.set(e,n?0:l.length-e.length),e=l}if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=n?sn(e):ys(e);if(s)a=it(a,i);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ou(this,e)}cmov(e,t,r){return po(r,"condition"),r?t:e}}Object.freeze(lS.prototype);function kp(e,t={}){return new lS(e,t)}function UC(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=mt)throw Error("field order must be greater than 1");let t=Oa(e-mt);return Math.ceil(t/8)}function uS(e){let t=UC(e);return t+Math.ceil(t/2)}function MC(e,t,r=!1){Ye(e);let o=e.length,n=UC(t),i=Math.max(uS(t),16);if(o<i||o>1024)throw Error("expected "+i+"-1024 bytes of input, got "+o);let s=r?sn(e):ys(e),a=it(s,t-mt)+mt;return r?ru(a,n):_p(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Ca=BigInt(0),Ss=BigInt(1);function iu(e,t){let r=t.negate();return e?r:t}function vs(e,t){let r=ou(e.Fp,t.map((o)=>o.Z));return t.map((o,n)=>e.fromAffine(o.toAffine(r[n])))}function HC(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function dS(e,t){HC(e,t);let r=Math.ceil(t/e)+1,o=2**(e-1),n=2**e,i=nu(e),s=BigInt(e);return{windows:r,windowSize:o,mask:i,maxNumber:n,shiftBy:s}}function qC(e,t,r){let{windowSize:o,mask:n,maxNumber:i,shiftBy:s}=r,a=Number(e&n),l=e>>s;if(a>o)a-=i,l+=Ss;let u=t*o,d=u+Math.abs(a)-1,f=a===0,m=a<0,h=t%2!==0;return{nextN:l,offset:d,isZero:f,isNeg:m,isNegF:h,offsetF:u}}var fS=new WeakMap,KC=new WeakMap;function pS(e){return KC.get(e)||1}function FC(e){if(e!==Ca)throw Error("invalid wNAF")}class su{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,r=this.ZERO){let o=e;while(t>Ca){if(t&Ss)r=r.add(o);o=o.double(),t>>=Ss}return r}precomputeWindow(e,t){let{windows:r,windowSize:o}=dS(t,this.bits),n=[],i=e,s=i;for(let a=0;a<r;a++){s=i,n.push(s);for(let l=1;l<o;l++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let o=this.ZERO,n=this.BASE,i=dS(e,this.bits);for(let s=0;s<i.windows;s++){let{nextN:a,offset:l,isZero:u,isNeg:d,isNegF:f,offsetF:m}=qC(r,s,i);if(r=a,u)n=n.add(iu(f,t[m]));else o=o.add(iu(d,t[l]))}return FC(r),{p:o,f:n}}wNAFUnsafe(e,t,r,o=this.ZERO){let n=dS(e,this.bits);for(let i=0;i<n.windows;i++){if(r===Ca)break;let{nextN:s,offset:a,isZero:l,isNeg:u}=qC(r,i,n);if(r=s,l)continue;else{let d=t[a];o=o.add(u?d.negate():d)}}return FC(r),o}getPrecomputes(e,t,r){let o=fS.get(t);if(!o){if(o=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")o=r(o);fS.set(t,o)}}return o}cached(e,t,r){let o=pS(e);return this.wNAF(o,this.getPrecomputes(o,e,r),t)}unsafe(e,t,r,o){let n=pS(e);if(n===1)return this._unsafeLadder(e,t,o);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,o)}createCache(e,t){HC(t,this.bits),KC.set(e,t),fS.delete(e)}hasCache(e){return pS(e)!==1}}function VC(e,t,r,o){let n=t,i=e.ZERO,s=e.ZERO;while(r>Ca||o>Ca){if(r&Ss)i=i.add(n);if(o&Ss)s=s.add(n);n=n.double(),r>>=Ss,o>>=Ss}return{p1:i,p2:s}}function JC(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return cS(t),t}else return kp(e,{isLE:r})}function Ip(e,t,r={},o){if(o===void 0)o=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let l of["p","n","h"]){let u=t[l];if(!(typeof u==="bigint"&&u>Ca))throw Error(`CURVE.${l} must be positive bigint`)}let n=JC(t.p,r.Fp,o),i=JC(t.n,r.Fn,o),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let l of a)if(!n.isValid(t[l]))throw Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:i}}function au(e,t){return function(o){let n=e(o);return{secretKey:n,publicKey:t(n)}}}function cu(e,t){if(zn(e),zn(t),t<0||t>4)throw Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--)r[o]=e&255,e>>>=8;return new Uint8Array(r)}function YJ(e,t){let r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e[o]^t[o];return r}function XJ(e){if(!Ra(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?Ep(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function mS(e,t,r,o){if(Ye(e),zn(r),t=XJ(t),t.length>255)t=o(Ht(Ep("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:i}=o,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=Ht(t,cu(t.length,1)),l=new Uint8Array(i),u=cu(r,2),d=Array(s),f=o(Ht(l,e,u,cu(0,1),a));d[0]=o(Ht(f,cu(1,1),a));for(let h=1;h<s;h++){let b=[YJ(f,d[h-1]),cu(h+1,1),a];d[h]=o(Ht(...b))}return Ht(...d).slice(0,r)}var WC="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var GC=(e,t)=>(e+(e>=0?t:-t)/YC)/t;function eH(e,t,r){mo("scalar",e,Nn,r);let[[o,n],[i,s]]=t,a=GC(s*e,r),l=GC(-n*e,r),u=e-a*o-l*i,d=-a*n-l*s,f=u<Nn,m=d<Nn;if(f)u=-u;if(m)d=-d;let h=nu(Math.ceil(Oa(r)/2))+si;if(u<Nn||u>=h||d<Nn||d>=h)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:u,k2neg:m,k2:d}}function gS(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function hS(e,t){Jr(e);let r={};for(let o of Object.keys(t))r[o]=e[o]===void 0?t[o]:e[o];if(po(r.lowS,"lowS"),po(r.prehash,"prehash"),r.format!==void 0)gS(r.format);return r}class QC extends Error{constructor(e=""){super(e)}}var an={Err:QC,_tlv:{encode:(e,t)=>{let{Err:r}=an;if(zn(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!=="string")throw TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let o=t.length/2,n=tu(o);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let i=o>127?tu(n.length/2|128):"";return tu(e)+i+n+t},decode(e,t){let{Err:r}=an;t=Ye(t,void 0,"DER data");let o=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[o++],i=!!(n&128),s=0;if(!i)s=n;else{let l=n&127;if(!l)throw new r("tlv.decode(long): indefinite length not supported");if(l>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(o,o+l);if(u.length!==l)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let d of u)s=s<<8|d;if(o+=l,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(o,o+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+s)}}},_int:{encode(e){let{Err:t}=an;if(xp(e),e<Nn)throw new t("integer: negative integers are not allowed");let r=tu(e);if(Number.parseInt(r[0],16)&8)r="00"+r;if(r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=an;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 ys(e)}},toSig(e){let{Err:t,_int:r,_tlv:o}=an,n=Ye(e,void 0,"signature"),{v:i,l:s}=o.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l}=o.decode(2,i),{v:u,l:d}=o.decode(2,l);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=an,o=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),i=o+n;return t.encode(48,i)}};Object.freeze(an._tlv);Object.freeze(an._int);Object.freeze(an);var Nn=BigInt(0),si=BigInt(1),YC=BigInt(2),Ap=BigInt(3),tH=BigInt(4);function XC(e,t={}){let r=Ip("weierstrass",e,t),o=r.Fp,n=r.Fn,i=r.CURVE,{h:s,n:a}=i;Jr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:l,allowInfinityPoint:u}=t;if(l){if(!o.is0(i.a)||typeof l.beta!=="bigint"||!Array.isArray(l.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let d=t1(o,n);function f(){if(!o.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function m(j,R,B){if(u&&R.is0())return Uint8Array.of(0);let{x:k,y:T}=R.toAffine(),I=o.toBytes(k);if(po(B,"isCompressed"),B){f();let q=!o.isOdd(T);return Ht(e1(q),I)}else return Ht(Uint8Array.of(4),I,o.toBytes(T))}function h(j){Ye(j,void 0,"Point");let{publicKey:R,publicKeyUncompressed:B}=d,k=j.length,T=j[0],I=j.subarray(1);if(u&&k===1&&T===0)return{x:o.ZERO,y:o.ZERO};if(k===R&&(T===2||T===3)){let q=o.fromBytes(I);if(!o.isValid(q))throw Error("bad point: is not on curve, wrong x");let N=S(q),K;try{K=o.sqrt(N)}catch(ae){let pe=ae instanceof Error?": "+ae.message:"";throw Error("bad point: is not on curve, sqrt error"+pe)}f();let G=o.isOdd(K);if((T&1)===1!==G)K=o.neg(K);return{x:q,y:K}}else if(k===B&&T===4){let q=o.BYTES,N=o.fromBytes(I.subarray(0,q)),K=o.fromBytes(I.subarray(q,q*2));if(!x(N,K))throw Error("bad point: is not on curve");return{x:N,y:K}}else throw Error(`bad point: got length ${k}, expected compressed=${R} or uncompressed=${B}`)}let b=t.toBytes===void 0?m:t.toBytes,y=t.fromBytes===void 0?h:t.fromBytes;function S(j){let R=o.sqr(j),B=o.mul(R,j);return o.add(o.add(B,o.mul(j,i.a)),i.b)}function x(j,R){let B=o.sqr(R),k=S(j);return o.eql(B,k)}if(!x(i.Gx,i.Gy))throw Error("bad curve params: generator point");let _=o.mul(o.pow(i.a,Ap),tH),A=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(_,A)))throw Error("bad curve params: a or b");function O(j,R,B=!1){if(!o.isValid(R)||B&&o.is0(R))throw Error(`bad point coordinate ${j}`);return R}function L(j){if(!(j instanceof P))throw Error("Weierstrass Point expected")}function z(j){if(!l||!l.basises)throw Error("no endo");return eH(j,l.basises,n.ORDER)}function H(j,R,B,k,T){return B=new P(o.mul(B.X,j),B.Y,B.Z),R=iu(k,R),B=iu(T,B),R.add(B)}class P{static BASE=new P(i.Gx,i.Gy,o.ONE);static ZERO=new P(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=n;X;Y;Z;constructor(j,R,B){this.X=O("x",j),this.Y=O("y",R,!0),this.Z=O("z",B),Object.freeze(this)}static CURVE(){return i}static fromAffine(j){let{x:R,y:B}=j||{};if(!j||!o.isValid(R)||!o.isValid(B))throw Error("invalid affine point");if(j instanceof P)throw Error("projective point not allowed");if(o.is0(R)&&o.is0(B))return P.ZERO;return new P(R,B,o.ONE)}static fromBytes(j){let R=P.fromAffine(y(Ye(j,void 0,"point")));return R.assertValidity(),R}static fromHex(j){return P.fromBytes(Ta(j))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(j=8,R=!0){if(ee.createCache(this,j),!R)this.multiply(Ap);return this}assertValidity(){let j=this;if(j.is0()){if(t.allowInfinityPoint&&o.is0(j.X)&&o.eql(j.Y,o.ONE)&&o.is0(j.Z))return;throw Error("bad point: ZERO")}let{x:R,y:B}=j.toAffine();if(!o.isValid(R)||!o.isValid(B))throw Error("bad point: x or y not field elements");if(!x(R,B))throw Error("bad point: equation left != right");if(!j.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:j}=this.toAffine();if(!o.isOdd)throw Error("Field doesn't support isOdd");return!o.isOdd(j)}equals(j){L(j);let{X:R,Y:B,Z:k}=this,{X:T,Y:I,Z:q}=j,N=o.eql(o.mul(R,q),o.mul(T,k)),K=o.eql(o.mul(B,q),o.mul(I,k));return N&&K}negate(){return new P(this.X,o.neg(this.Y),this.Z)}double(){let{a:j,b:R}=i,B=o.mul(R,Ap),{X:k,Y:T,Z:I}=this,q=o.ZERO,N=o.ZERO,K=o.ZERO,G=o.mul(k,k),re=o.mul(T,T),ae=o.mul(I,I),pe=o.mul(k,T);return pe=o.add(pe,pe),K=o.mul(k,I),K=o.add(K,K),q=o.mul(j,K),N=o.mul(B,ae),N=o.add(q,N),q=o.sub(re,N),N=o.add(re,N),N=o.mul(q,N),q=o.mul(pe,q),K=o.mul(B,K),ae=o.mul(j,ae),pe=o.sub(G,ae),pe=o.mul(j,pe),pe=o.add(pe,K),K=o.add(G,G),G=o.add(K,G),G=o.add(G,ae),G=o.mul(G,pe),N=o.add(N,G),ae=o.mul(T,I),ae=o.add(ae,ae),G=o.mul(ae,pe),q=o.sub(q,G),K=o.mul(ae,re),K=o.add(K,K),K=o.add(K,K),new P(q,N,K)}add(j){L(j);let{X:R,Y:B,Z:k}=this,{X:T,Y:I,Z:q}=j,N=o.ZERO,K=o.ZERO,G=o.ZERO,re=i.a,ae=o.mul(i.b,Ap),pe=o.mul(R,T),be=o.mul(B,I),ve=o.mul(k,q),Ae=o.add(R,B),Ie=o.add(T,I);Ae=o.mul(Ae,Ie),Ie=o.add(pe,be),Ae=o.sub(Ae,Ie),Ie=o.add(R,k);let we=o.add(T,q);return Ie=o.mul(Ie,we),we=o.add(pe,ve),Ie=o.sub(Ie,we),we=o.add(B,k),N=o.add(I,q),we=o.mul(we,N),N=o.add(be,ve),we=o.sub(we,N),G=o.mul(re,Ie),N=o.mul(ae,ve),G=o.add(N,G),N=o.sub(be,G),G=o.add(be,G),K=o.mul(N,G),be=o.add(pe,pe),be=o.add(be,pe),ve=o.mul(re,ve),Ie=o.mul(ae,Ie),be=o.add(be,ve),ve=o.sub(pe,ve),ve=o.mul(re,ve),Ie=o.add(Ie,ve),pe=o.mul(be,Ie),K=o.add(K,pe),pe=o.mul(we,Ie),N=o.mul(Ae,N),N=o.sub(N,pe),pe=o.mul(Ae,be),G=o.mul(we,G),G=o.add(G,pe),new P(N,K,G)}subtract(j){return L(j),this.add(j.negate())}is0(){return this.equals(P.ZERO)}multiply(j){let{endo:R}=t;if(!n.isValidNot0(j))throw RangeError("invalid scalar: out of range");let B,k,T=(I)=>ee.cached(this,I,(q)=>vs(P,q));if(R){let{k1neg:I,k1:q,k2neg:N,k2:K}=z(j),{p:G,f:re}=T(q),{p:ae,f:pe}=T(K);k=re.add(pe),B=H(R.beta,G,ae,I,N)}else{let{p:I,f:q}=T(j);B=I,k=q}return vs(P,[B,k])[0]}multiplyUnsafe(j){let{endo:R}=t,B=this,k=j;if(!n.isValid(k))throw RangeError("invalid scalar: out of range");if(k===Nn||B.is0())return P.ZERO;if(k===si)return B;if(ee.hasCache(this))return this.multiply(k);if(R){let{k1neg:T,k1:I,k2neg:q,k2:N}=z(k),{p1:K,p2:G}=VC(P,B,I,N);return H(R.beta,K,G,T,q)}else return ee.unsafe(B,k)}toAffine(j){let R=this,B=j,{X:k,Y:T,Z:I}=R;if(o.eql(I,o.ONE))return{x:k,y:T};let q=R.is0();if(B==null)B=q?o.ONE:o.inv(I);let N=o.mul(k,B),K=o.mul(T,B),G=o.mul(I,B);if(q)return{x:o.ZERO,y:o.ZERO};if(!o.eql(G,o.ONE))throw Error("invZ was invalid");return{x:N,y:K}}isTorsionFree(){let{isTorsionFree:j}=t;if(s===si)return!0;if(j)return j(P,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:j}=t;if(s===si)return this;if(j)return j(P,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===si)return this.is0();return this.clearCofactor().is0()}toBytes(j=!0){return po(j,"isCompressed"),this.assertValidity(),b(P,this,j)}toHex(j=!0){return Aa(this.toBytes(j))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=n.BITS,ee=new su(P,t.endo?Math.ceil(W/2):W);if(W>=8)P.BASE.precompute(8);return Object.freeze(P.prototype),Object.freeze(P),P}function e1(e){return Uint8Array.of(e?2:3)}function t1(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function rH(e,t={}){let{Fn:r}=e,o=t.randomBytes===void 0?$a:t.randomBytes,n=Object.assign(t1(e.Fp,r),{seed:Math.max(uS(r.ORDER),16)});function i(h){try{let b=r.fromBytes(h);return r.isValidNot0(b)}catch(b){return!1}}function s(h,b){let{publicKey:y,publicKeyUncompressed:S}=n;try{let x=h.length;if(b===!0&&x!==y)return!1;if(b===!1&&x!==S)return!1;return!!e.fromBytes(h)}catch(x){return!1}}function a(h){return h=h===void 0?o(n.seed):h,MC(Ye(h,n.seed,"seed"),r.ORDER)}function l(h,b=!0){return e.BASE.multiply(r.fromBytes(h)).toBytes(b)}function u(h){let{secretKey:b,publicKey:y,publicKeyUncompressed:S}=n,x=r._lengths;if(!Ra(h))return;let _=Ye(h,void 0,"key").length,A=_===y||_===S,O=_===b||!!x?.includes(_);if(A&&O)return;return A}function d(h,b,y=!0){if(u(h)===!0)throw Error("first arg must be private key");if(u(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(h);return e.fromBytes(b).multiply(S).toBytes(y)}let f={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},m=au(a,l);return Object.freeze(f),Object.freeze(n),Object.freeze({getPublicKey:l,getSharedSecret:d,keygen:m,Point:e,utils:f,lengths:n})}function r1(e,t,r={}){let o=t;no(o),Jr(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?$a:r.randomBytes,i=r.hmac===void 0?(T,I)=>Tn(o,T,I):r.hmac,{Fp:s,Fn:a}=e,{ORDER:l,BITS:u}=a,{keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b}=rH(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=l*YC+si<s.ORDER;function x(T){let I=l>>si;return T>I}function _(T,I){if(!a.isValidNot0(I))throw Error(`invalid signature ${T}: out of range 1..Point.Fn.ORDER`);return I}function A(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(T,I){gS(I);let q=b.signature,N=I==="compact"?q:I==="recovered"?q+1:void 0;return Ye(T,N)}class L{r;s;recovery;constructor(T,I,q){if(this.r=_("r",T),this.s=_("s",I),q!=null){if(A(),![0,1,2,3].includes(q))throw Error("invalid recovery id");this.recovery=q}Object.freeze(this)}static fromBytes(T,I=y.format){O(T,I);let q;if(I==="der"){let{r:re,s:ae}=an.toSig(Ye(T));return new L(re,ae)}if(I==="recovered")q=T[0],I="compact",T=T.subarray(1);let N=b.signature/2,K=T.subarray(0,N),G=T.subarray(N,N*2);return new L(a.fromBytes(K),a.fromBytes(G),q)}static fromHex(T,I){return this.fromBytes(Ta(T),I)}assertRecovery(){let{recovery:T}=this;if(T==null)throw Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new L(this.r,this.s,T)}recoverPublicKey(T){let{r:I,s:q}=this,N=this.assertRecovery(),K=N===2||N===3?I+l:I;if(!s.isValid(K))throw Error("invalid recovery id: sig.r+curve.n != R.x");let G=s.toBytes(K),re=e.fromBytes(Ht(e1((N&1)===0),G)),ae=a.inv(K),pe=H(Ye(T,void 0,"msgHash")),be=a.create(-pe*ae),ve=a.create(q*ae),Ae=e.BASE.multiplyUnsafe(be).add(re.multiplyUnsafe(ve));if(Ae.is0())throw Error("invalid recovery: point at infinify");return Ae.assertValidity(),Ae}hasHighS(){return x(this.s)}toBytes(T=y.format){if(gS(T),T==="der")return Ta(an.hexFromSig(this));let{r:I,s:q}=this,N=a.toBytes(I),K=a.toBytes(q);if(T==="recovered")return A(),Ht(Uint8Array.of(this.assertRecovery()),N,K);return Ht(N,K)}toHex(T){return Aa(this.toBytes(T))}}Object.freeze(L.prototype),Object.freeze(L);let z=r.bits2int===void 0?function(I){if(I.length>8192)throw Error("input is too large");let q=ys(I),N=I.length*8-u;return N>0?q>>BigInt(N):q}:r.bits2int,H=r.bits2int_modN===void 0?function(I){return a.create(z(I))}:r.bits2int_modN,P=nu(u);function W(T){return mo("num < 2^"+u,T,Nn,P),a.toBytes(T)}function ee(T,I){return Ye(T,void 0,"message"),I?Ye(o(T),void 0,"prehashed message"):T}function j(T,I,q){let{lowS:N,prehash:K,extraEntropy:G}=hS(q,y);T=ee(T,K);let re=H(T),ae=a.fromBytes(I);if(!a.isValidNot0(ae))throw Error("invalid private key");let pe=[W(ae),W(re)];if(G!=null&&G!==!1){let Ie=G===!0?n(b.secretKey):G;pe.push(Ye(Ie,void 0,"extraEntropy"))}let be=Ht(...pe),ve=re;function Ae(Ie){let we=z(Ie);if(!a.isValidNot0(we))return;let Ue=a.inv(we),De=e.BASE.multiply(we).toAffine(),Qe=a.create(De.x);if(Qe===Nn)return;let bt=a.create(Ue*a.create(ve+Qe*ae));if(bt===Nn)return;let Tt=(De.x===Qe?0:2)|Number(De.y&si),Dt=bt;if(N&&x(bt))Dt=a.neg(bt),Tt^=1;return new L(Qe,Dt,S?void 0:Tt)}return{seed:be,k2sig:Ae}}function R(T,I,q={}){let{seed:N,k2sig:K}=j(T,I,q);return $C(o.outputLen,a.BYTES,i)(N,K).toBytes(q.format)}function B(T,I,q,N={}){let{lowS:K,prehash:G,format:re}=hS(N,y);if(q=Ye(q,void 0,"publicKey"),I=ee(I,G),!Ra(T)){let ae=T instanceof L?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}O(T,re);try{let ae=L.fromBytes(T,re),pe=e.fromBytes(q);if(K&&ae.hasHighS())return!1;let{r:be,s:ve}=ae,Ae=H(I),Ie=a.inv(ve),we=a.create(Ae*Ie),Ue=a.create(be*Ie),De=e.BASE.multiplyUnsafe(we).add(pe.multiplyUnsafe(Ue));if(De.is0())return!1;return a.create(De.x)===be}catch(ae){return!1}}function k(T,I,q={}){let{prehash:N}=hS(q,y);return I=ee(I,N),L.fromBytes(T,"recovered").recoverPublicKey(I).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:m,utils:h,lengths:b,Point:e,sign:R,verify:B,recoverPublicKey:k,Signature:L,hash:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var nH=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var oH=XC(nH),Pa=r1(oH,vt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ai=BigInt(0),wr=BigInt(1),yS=BigInt(2),iH=BigInt(8);function sH(e,t,r,o){let n=e.sqr(r),i=e.sqr(o),s=e.add(e.mul(t.a,n),i),a=e.add(e.ONE,e.mul(t.d,e.mul(n,i)));return e.eql(s,a)}function n1(e,t={}){let r=t,o=Ip("edwards",e,r,r.FpFnLE),{Fp:n,Fn:i}=o,s=o.CURVE,{h:a}=s;Jr(r,{},{uvRatio:"function"});let l=yS<<BigInt(i.BYTES*8)-wr,u=(y)=>n.create(y),d=r.uvRatio===void 0?(y,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(y,S))}}catch(x){return{isValid:!1,value:ai}}}:r.uvRatio;if(!sH(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function f(y,S,x=!1){let _=x?wr:ai;return mo("coordinate "+y,S,_,l),S}function m(y){if(!(y instanceof h))throw Error("EdwardsPoint expected")}class h{static BASE=new h(s.Gx,s.Gy,wr,u(s.Gx*s.Gy));static ZERO=new h(ai,wr,wr,ai);static Fp=n;static Fn=i;X;Y;Z;T;constructor(y,S,x,_){this.X=f("x",y),this.Y=f("y",S),this.Z=f("z",x,!0),this.T=f("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof h)throw Error("extended point not allowed");let{x:S,y:x}=y||{};return f("x",S),f("y",x),new h(S,x,wr,u(S*x))}static fromBytes(y,S=!1){let x=n.BYTES,{a:_,d:A}=s;y=ii(Ye(y,x,"point")),po(S,"zip215");let O=ii(y),L=y[x-1];O[x-1]=L&-129;let z=sn(O),H=S?l:n.ORDER;mo("point.y",z,ai,H);let P=u(z*z),W=u(P-wr),ee=u(A*P-_),{isValid:j,value:R}=d(W,ee);if(!j)throw Error("bad point: invalid y coordinate");let B=(R&wr)===wr,k=(L&128)!==0;if(!S&&R===ai&&k)throw Error("bad point: x=0 and x_0=1");if(k!==B)R=u(-R);return h.fromAffine({x:R,y:z})}static fromHex(y,S=!1){return h.fromBytes(Ta(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){if(b.createCache(this,y),!S)this.multiply(yS);return this}assertValidity(){let y=this,{a:S,d:x}=s;if(y.is0())throw Error("bad point: ZERO");let{X:_,Y:A,Z:O,T:L}=y,z=u(_*_),H=u(A*A),P=u(O*O),W=u(P*P),ee=u(z*S),j=u(P*u(ee+H)),R=u(W+u(x*u(z*H)));if(j!==R)throw Error("bad point: equation left != right (1)");let B=u(_*A),k=u(O*L);if(B!==k)throw Error("bad point: equation left != right (2)")}equals(y){m(y);let{X:S,Y:x,Z:_}=this,{X:A,Y:O,Z:L}=y,z=u(S*L),H=u(A*_),P=u(x*L),W=u(O*_);return z===H&&P===W}is0(){return this.equals(h.ZERO)}negate(){return new h(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:x,Z:_}=this,A=u(S*S),O=u(x*x),L=u(yS*u(_*_)),z=u(y*A),H=S+x,P=u(u(H*H)-A-O),W=z+O,ee=W-L,j=z-O,R=u(P*ee),B=u(W*j),k=u(P*j),T=u(ee*W);return new h(R,B,T,k)}add(y){m(y);let{a:S,d:x}=s,{X:_,Y:A,Z:O,T:L}=this,{X:z,Y:H,Z:P,T:W}=y,ee=u(_*z),j=u(A*H),R=u(L*x*W),B=u(O*P),k=u((_+A)*(z+H)-ee-j),T=B-R,I=B+R,q=u(j-S*ee),N=u(k*T),K=u(I*q),G=u(k*q),re=u(T*I);return new h(N,K,re,G)}subtract(y){return m(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:x}=b.cached(this,y,(_)=>vs(h,_));return vs(h,[S,x])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(y===ai)return h.ZERO;if(this.is0()||y===wr)return this;return b.unsafe(this,y,(S)=>vs(h,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(y){let S=this,x=y,{X:_,Y:A,Z:O}=S,L=S.is0();if(x==null)x=L?iH:n.inv(O);let z=u(_*x),H=u(A*x),P=n.mul(O,x);if(L)return{x:ai,y:wr};if(P!==wr)throw Error("invZ was invalid");return{x:z,y:H}}clearCofactor(){if(a===wr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),x=n.toBytes(S);return x[x.length-1]|=y&wr?128:0,x}toHex(){return Aa(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new su(h,i.BITS);if(i.BITS>=8)h.BASE.precompute(8);return Object.freeze(h.prototype),Object.freeze(h),h}class bS{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){sS()}static fromHex(e){sS()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return Aa(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.ep.precompute(e,t),this}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lu=BigInt(0),za=BigInt(1),Tp=BigInt(2);function aH(e){return Jr(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function o1(e){let t=aH(e),{P:r,type:o,adjustScalarBytes:n,powPminus2:i,randomBytes:s}=t,a=o==="x25519";if(!a&&o!=="x448")throw Error("invalid type");let l=s===void 0?$a:s,u=a?255:448,d=a?32:56,f=a?BigInt(9):BigInt(5),m=a?BigInt(121665):BigInt(39081),h=a?Tp**BigInt(254):Tp**BigInt(447),b=a?BigInt(8)*Tp**BigInt(251)-za:BigInt(4)*Tp**BigInt(445)-za,y=h+b+za,S=(k)=>it(k,r),x=_(f);function _(k){return ru(S(k),d)}function A(k){let T=ii(Ye(k,d,"uCoordinate"));if(a)T[31]&=127;return S(sn(T))}function O(k){return sn(n(ii(Ye(k,d,"scalar"))))}function L(k,T){let I=ee(A(T),O(k));if(I===lu)throw Error("invalid private or public key received");return _(I)}function z(k){return L(k,x)}let H=z,P=L;function W(k,T,I){let q=S(k*(T-I));return T=S(T-q),I=S(I+q),{x_2:T,x_3:I}}function ee(k,T){mo("u",k,lu,r),mo("scalar",T,h,y);let I=T,q=k,N=za,K=lu,G=k,re=za,ae=lu;for(let be=BigInt(u-1);be>=lu;be--){let ve=I>>be&za;ae^=ve,{x_2:N,x_3:G}=W(ae,N,G),{x_2:K,x_3:re}=W(ae,K,re),ae=ve;let Ae=N+K,Ie=S(Ae*Ae),we=N-K,Ue=S(we*we),De=Ie-Ue,Qe=G+re,bt=G-re,Tt=S(bt*Ae),Dt=S(Qe*we),lt=Tt+Dt,Rr=Tt-Dt;G=S(lt*lt),re=S(q*S(Rr*Rr)),N=S(Ie*Ue),K=S(De*(Ie+S(m*De)))}({x_2:N,x_3:G}=W(ae,N,G)),{x_2:K,x_3:re}=W(ae,K,re);let pe=i(K);return S(N*pe)}let j={secretKey:d,publicKey:d,seed:d},R=(k)=>(k=k===void 0?l(d):k,Ye(k,j.seed,"seed"),k),B={randomSecretKey:R};return Object.freeze(j),Object.freeze(B),Object.freeze({keygen:au(R,H),getSharedSecret:P,getPublicKey:H,scalarMult:L,scalarMultBase:z,utils:B,GuBytes:x.slice(),lengths:j})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var cH=BigInt(0),go=BigInt(1),i1=BigInt(2),lH=BigInt(3),uH=BigInt(5),dH=BigInt(8),xs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),xS=(()=>({p:xs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:dH,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function c1(e){let t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),i=xs,a=e*e%i*e%i,l=Hr(a,i1,i)*a%i,u=Hr(l,go,i)*e%i,d=Hr(u,uH,i)*u%i,f=Hr(d,t,i)*d%i,m=Hr(f,r,i)*f%i,h=Hr(m,o,i)*m%i,b=Hr(h,n,i)*h%i,y=Hr(b,n,i)*h%i,S=Hr(y,t,i)*d%i;return{pow_p_5_8:Hr(S,i1,i)*e%i,b2:a}}function fH(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var SS=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function _S(e,t){let r=xs,o=it(t*t*t,r),n=it(o*o*t,r),i=c1(e*n).pow_p_5_8,s=it(e*o*i,r),a=it(t*s*s,r),l=s,u=it(s*SS,r),d=a===e,f=a===it(-e,r),m=a===it(-e*SS,r);if(d)s=l;if(f||m)s=u;if(ho(s,r))s=it(-s,r);return{isValid:d||f,value:s}}var ws=n1(xS,{uvRatio:_S}),ci=(()=>ws.Fp)(),l1=(()=>ws.Fn)();var Rp=(()=>{let e=xs;return o1({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:o}=c1(t);return it(Hr(r,lH,e)*o,e)},adjustScalarBytes:fH})})();var vS=SS,pH=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),mH=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),hH=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),gH=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),s1=(e)=>_S(go,e),yH=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),wS=(e)=>ci.create(sn(e)&yH);function a1(e){let{d:t}=xS,r=xs,o=(x)=>ci.create(x),n=o(vS*e*e),i=o((n+go)*hH),s=BigInt(-1),a=o((s-t*n)*o(n+t)),{isValid:l,value:u}=_S(i,a),d=o(u*e);if(!ho(d,r))d=o(-d);if(!l)u=d;if(!l)s=n;let f=o(s*(n-go)*gH-a),m=u*u,h=o((u+u)*a),b=o(f*pH),y=o(go-m),S=o(go+m);return new ws(o(h*S),o(y*b),o(b*S),o(h*y))}class dr extends bS{static BASE=(()=>new dr(ws.BASE))();static ZERO=(()=>new dr(ws.ZERO))();static Fp=(()=>ci)();static Fn=(()=>l1)();constructor(e){super(e)}static fromAffine(e){return new dr(ws.fromAffine(e))}assertSame(e){if(!(e instanceof dr))throw Error("RistrettoPoint expected")}init(e){return new dr(e)}static fromBytes(e){Mt(e,32);let{a:t,d:r}=xS,o=xs,n=(A)=>ci.create(A),i=wS(e);if(!RC(ci.toBytes(i),e)||ho(i,o))throw Error("invalid ristretto255 encoding 1");let s=n(i*i),a=n(go+t*s),l=n(go-t*s),u=n(a*a),d=n(l*l),f=n(t*r*u-d),{isValid:m,value:h}=s1(n(f*d)),b=n(h*l),y=n(h*b*f),S=n((i+i)*b);if(ho(S,o))S=n(-S);let x=n(a*y),_=n(S*x);if(!m||ho(_,o)||x===cH)throw Error("invalid ristretto255 encoding 2");return new dr(new ws(S,x,go,_))}static fromHex(e){return dr.fromBytes(Ol(e))}toBytes(){let{X:e,Y:t,Z:r,T:o}=this.ep,n=xs,i=(y)=>ci.create(y),s=i(i(r+t)*i(r-t)),a=i(e*t),l=i(a*a),{value:u}=s1(i(s*l)),d=i(u*s),f=i(u*a),m=i(d*f*o),h;if(ho(o*m,n)){let y=i(t*vS),S=i(e*vS);e=y,t=S,h=i(d*mH)}else h=f;if(ho(e*m,n))t=i(-t);let b=i((r-t)*h);if(ho(b,n))b=i(-b);return ci.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:o,Y:n}=e.ep,i=(l)=>ci.create(l),s=i(t*n)===i(r*o),a=i(r*n)===i(t*o);return s||a}is0(){return this.equals(dr.ZERO)}}Object.freeze(dr.BASE);Object.freeze(dr.ZERO);Object.freeze(dr.prototype);Object.freeze(dr);var bH=Object.freeze({Point:dr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,o=mS(e,r,64,Kf);return bH.deriveToCurve(o)},hashToScalar(e,t={DST:WC}){let r=mS(e,t.DST,64,Kf);return l1.create(sn(r))},deriveToCurve(e){Mt(e,64);let t=wS(e.subarray(0,32)),r=a1(t),o=wS(e.subarray(32,64)),n=a1(o);return new dr(r.add(n))}});var u1=!1,SH=!1;async function d1(e,t){if(SH)return await t();try{return await e()}catch(r){if(r instanceof ReferenceError||r instanceof DOMException&&r.name==="NotSupportedError")return await t();else throw r}}async function $p(e,t){return await d1(async()=>{let r=ES(e)?e:await wH(e),o=await crypto.subtle.importKey("raw",xH(t),{name:"X25519"},u1,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:o},r,256))},()=>{if(ES(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Rp.scalarMult(e,t)})}async function uu(e){return await d1(async()=>$p(e,Rp.GuBytes),()=>{if(ES(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Rp.scalarMultBase(e)})}var vH=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function wH(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...vH,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},u1,["deriveBits"])}function ES(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function xH(e){return e}class kS{s;transcript=[];buf=new Uint8Array(0);constructor(e){this.s=e.getReader()}async readLine(){let e=[];while(!0){let t=this.buf.indexOf(10);if(t>=0)return e.push(this.buf.subarray(0,t)),this.transcript.push(this.buf.subarray(0,t+1)),this.buf=this.buf.subarray(t+1),EH(_s(e));if(this.buf.length>0)e.push(this.buf),this.transcript.push(this.buf);let r=await this.s.read();if(r.done)return this.buf=_s(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:_s(this.transcript)}}}function EH(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function _s(e){let t=e.reduce((n,i)=>n+i.length,0),r=new Uint8Array(t),o=0;for(let n of e)r.set(n,o),o+=n.length;return r}function Na(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let o of t)r.enqueue(o)}}))}function Op(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function IS(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function f1(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function p1(e,t){let r=e.getReader(),o=[],n=0;while(n<t){let{done:l,value:u}=await r.read();if(l)throw Error("stream ended before reading "+t.toString()+" bytes");o.push(u),n+=u.length}r.releaseLock();let i=_s(o),s=i.subarray(0,t),a=Na(e,i.subarray(t));return{data:s,rest:a}}class Dn{args;body;constructor(e,t){this.args=e,this.body=t}}async function kH(e){let t=await e.readLine();if(t===null)throw Error("invalid stanza");let r=t.split(" ");if(r.length<2||r.shift()!=="->")return{next:t};for(let i of r)if(i.length===0)throw Error("invalid stanza");let o=[];for(;;){let i=await e.readLine();if(i===null)throw Error("invalid stanza");let s=Yt.decode(i);if(s.length>48)throw Error("invalid stanza");if(o.push(s),s.length<48)break}let n=_s(o);return{s:new Dn(r,n)}}async function m1(e){let t=new kS(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let o=[];for(;;){let{s:n,next:i}=await kH(t);if(n!==void 0){o.push(n);continue}if(!i.startsWith("--- "))throw Error("invalid header");let s=Yt.decode(i.slice(4)),{rest:a,transcript:l}=t.close(),u=l.slice(0,l.length-1-i.length+3);return{stanzas:o,headerNoMAC:u,MAC:s,headerSize:l.length,rest:Na(e,a)}}}function AS(e){let t=[];t.push(`age-encryption.org/v1
|
|
721
721
|
`);for(let r of e){t.push("-> "+r.args.join(" ")+`
|
|
722
722
|
`);for(let o=0;o<r.body.length;o+=48){let n=o+48;if(n>r.body.length)n=r.body.length;t.push(Yt.encode(r.body.subarray(o,n))+`
|
|
723
723
|
`)}if(r.body.length%48===0)t.push(`
|
package/dist/index.js
CHANGED
|
@@ -727,7 +727,7 @@ printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
|
|
|
727
727
|
`),i}async function I5(e,t){let r=await ut(e),o=r.users.find((n)=>n.handle===t);if(!o)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:o}}async function A5(e){let t=await xme(to(_me(),"brains-ops-watchdog-smoke-")),r=to(t,"id_ed25519"),o=to(t,"known_hosts");try{let n=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),i=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${n}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!i.ok)throw Error(`Hetzner server lookup failed with ${i.status}`);let s=Eme.parse(await i.json());if(s.servers.length!==1)throw Error(`Expected one smoke server, found ${s.servers.length}`);let a=s.servers[0];if(a?.status!=="running")throw Error("Smoke server is not running");await Rl(r,Ame(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await wme(r,384);let c=await e.commandRunner("ssh-keyscan",["-T","10","-t","ed25519",a.public_net.ipv4.ip]);if(c.exitCode!==0||!c.stdout.trim())throw Error("Unable to resolve watchdog smoke SSH host key");return await Rl(o,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:o,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await _$(t,{recursive:!0,force:!0}),n}}async function x$(e,t,r){return e.commandRunner("ssh",[...T5(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:E$()})}async function kme(e,t,r){return e.commandRunner("scp",[...T5(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function T5(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function Ime(e){try{return await vme(e),!0}catch{return!1}}async function sb(e,t,r){await Promise.all([Rl(to(e,`${t}.stdout.log`),r.stdout),Rl(to(e,`${t}.stderr.log`),r.stderr)])}function Ame(e){return`${e.replace(/\r\n/g,`
|
|
728
728
|
`).replace(/\\n/g,`
|
|
729
729
|
`).trimEnd()}
|
|
730
|
-
`}var _5,Eme;var cb=w(async()=>{me();S5();qr();jf();await b5();_5=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1)}),Eme=l.object({servers:l.array(l.object({status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))})});import{access as LN,chmod as SE,mkdir as qm,readFile as jN,writeFile as BN}from"fs/promises";import{dirname as g7,join as rc}from"path";import{fileURLToPath as y7}from"url";var Ff={name:"@rizom/ops",version:"0.2.0-alpha.
|
|
730
|
+
`}var _5,Eme;var cb=w(async()=>{me();S5();qr();jf();await b5();_5=l.object({HCLOUD_TOKEN:l.string().min(1),KAMAL_SSH_PRIVATE_KEY:l.string().min(1)}),Eme=l.object({servers:l.array(l.object({status:l.string(),public_net:l.object({ipv4:l.object({ip:l.string().min(1)})})}))})});import{access as LN,chmod as SE,mkdir as qm,readFile as jN,writeFile as BN}from"fs/promises";import{dirname as g7,join as rc}from"path";import{fileURLToPath as y7}from"url";var Ff={name:"@rizom/ops",version:"0.2.0-alpha.682",description:"Operator CLI for managing private brain fleet registry repos",keywords:["brains","ops","cli","deploy","fleet","operator"],license:"AGPL-3.0-only",author:"Yeehaa <yeehaa@rizom.ai> (https://rizom.ai)",bin:{"brains-ops":"./dist/brains-ops.js"},bugs:"https://github.com/rizom-ai/brains/issues",dependencies:{"@libsql/client":"^0.17.4","age-encryption":"^0.3.0",yaml:"^2.9.0"},devDependencies:{"@brains/contracts":"workspace:*","@brains/deploy-support":"workspace:*","@brains/eslint-config":"workspace:*","@brains/job-queue":"workspace:*","@brains/profile":"workspace:*","@brains/site-composition":"workspace:*","@brains/test-utils":"workspace:*","@brains/typescript-config":"workspace:*","@brains/utils":"workspace:*","@types/bun":"^1.4.0",typescript:"^7.0.2"},engines:{bun:">=1.3.3"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./deploy":{types:"./dist/deploy.d.ts",import:"./dist/deploy.js",bun:"./dist/deploy.js"}},files:["dist","templates"],homepage:"https://github.com/rizom-ai/brains/tree/main/packages/brains-ops#readme",main:"./dist/index.js",publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/rizom-ai/brains.git",directory:"packages/brains-ops"},scripts:{build:"bun scripts/build.ts",lint:"eslint . --max-warnings 0","lint:fix":"eslint . --max-warnings 0 --fix",prepublishOnly:"bun scripts/build.ts",test:"bun test --timeout 20000","test:smoke":"bun run build && RUN_SMOKE_TESTS=1 bun test --timeout 60000",typecheck:"tsc --noEmit"},type:"module",types:"./dist/index.d.ts"};os();tc();var b7=["pilot.yaml","package.json",".env.schema",".gitignore","cohorts/cohort-1.yaml","users/alice.yaml",".github/actions/varlock-env/action.yml",".github/workflows/build.yml",".github/workflows/deploy.yml",".github/workflows/directory-sync-stress.yml",".github/workflows/health-watchdog-smoke.yml",".github/workflows/offboard.yml",".github/workflows/reconcile.yml",".github/workflows/upgrade.yml","deploy/Dockerfile","deploy/kamal/deploy.yml","deploy/scripts/helpers.ts","deploy/scripts/create-predeploy-backup.ts","deploy/scripts/install-health-watchdog.ts","deploy/scripts/provision-server.ts","deploy/scripts/pull-local-models.ts","deploy/scripts/update-dns.ts","deploy/scripts/write-ssh-key.ts","deploy/scripts/decrypt-user-secrets.ts","deploy/scripts/validate-secrets.ts","deploy/scripts/write-kamal-secrets.ts","deploy/scripts/resolve-user-config.ts","deploy/scripts/resolve-missing-images.ts","deploy/scripts/verify-runtime-image.ts","deploy/scripts/resolve-deploy-handles.ts","deploy/scripts/sync-content-repo.ts",".kamal/hooks/pre-deploy","docs/onboarding-checklist.md","docs/canonical-crossover-record.md","docs/operator-playbook.md","docs/user-onboarding.md","README.md"],vE=new Set([".kamal/hooks/pre-deploy"]),S7=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),v7=y7(new URL("../templates/rover-pilot/",import.meta.url));function lo(e){return(t)=>t.includes(e)}function w7(e){return P$.find((t)=>e===`deploy/scripts/${t}`)}function wE(e){return e.replace(/\n {2}secret:\n(?: {4}- .*\n)+\nvolumes:\n/,`
|
|
731
731
|
secret:
|
|
732
732
|
- __DYNAMIC_SECRETS__
|
|
733
733
|
|