@rizom/ops 0.2.0-alpha.637 → 0.2.0-alpha.638

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.
@@ -733,7 +733,7 @@ printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
733
733
  `).replace(/\\n/g,`
734
734
  `).trimEnd()}
735
735
  `}var C9,Rve;var LO=x(async()=>{Ae();I9();Un();Op();await E9();C9=d.object({HCLOUD_TOKEN:d.string().min(1),KAMAL_SSH_PRIVATE_KEY:d.string().min(1)}),Rve=d.object({servers:d.array(d.object({status:d.string(),public_net:d.object({ipv4:d.object({ip:d.string().min(1)})})}))})});import{parseArgs as y7}from"util";function St(e){return e}class Dp extends Error{constructor(e){super(e);this.name="CliUsageError"}}function b7(e,t){let r={...t};for(let i of e)for(let[n,o]of Object.entries(i.flags??{})){let s=r[n];if(s===void 0){r[n]=o;continue}if(s.type!==o.type||s.short!==o.short||s.default!==o.default)throw Error(`Conflicting definitions for flag --${n}: commands must agree on type, short, and default`)}return r}function S7(e){let t={};for(let[r,i]of Object.entries(e))t[r]={type:i.type,...i.short!==void 0?{short:i.short}:{},...i.default!==void 0?{default:i.default}:{}};return t}function x7(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 UO(e,t){let r=b7(t.commands,t.globalFlags??{}),i,n;try{({values:i,positionals:n}=y7({args:e,options:S7(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(x7(s))throw new Dp(s.message.split(". ")[0]??s.message);throw s}if("help"in r&&i.help===!0)return{command:"help",args:[],flags:{help:!0}};if("version"in r&&i.version===!0)return{command:"version",args:[],flags:{version:!0}};let o={};for(let[s,a]of Object.entries(r)){let c=i[s];if(typeof c==="string"&&a.type==="string")o[s]=c;else if(typeof c==="boolean"&&a.type==="boolean")o[s]=c}return{command:n[0]??"help",args:n.slice(1),flags:o}}function qO(e){let t=e.reduce((r,i)=>Math.max(r,i.label.length),0);return e.map((r)=>` ${r.label.padEnd(t)} ${r.description}`)}function w7(e){return qO(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function v7(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",i=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${i}`}function ZO(e){return qO(Object.entries(e).map(([t,r])=>({label:v7(t,r),description:r.description})))}function MO(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function _7(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 k7(e){let t=[],r=new Map;for(let n of e){let o=n.flags??{};if(Object.keys(o).length===0)continue;let s=_7(o),a=r.get(s);if(a){a.names.push(n.name);continue}let c={names:[n.name],flags:o};r.set(s,c),t.push(c)}let i=[];for(let n of t)i.push("",`${n.names.join(" / ")} options:`),i.push(...ZO(n.flags));return i}function FO(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...w7(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...ZO(e.globalFlags));return t.push(...k7(e.commands)),t.join(`
736
- `)}function HO(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 bt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function Ns(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var Lp={name:"@rizom/ops",version:"0.2.0-alpha.637",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 XG,mkdirSync as eQ,readFileSync as pw,writeFileSync as mw}from"fs";import{dirname as tQ,join as eN}from"path";function AS(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Pt(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 nr(e,t,r=""){let i=AS(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;if(!i)throw TypeError(l);throw RangeError(l)}return e}function $i(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(Pt(e.outputLen),Pt(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function Xa(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 Bp(e,t){nr(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function jp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Tr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ec(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function On(e,t){return e<<32-t|e>>>t}function rt(e,t){return e<<t|e>>>32-t>>>0}var I7=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function A7(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function T7(e){for(let t=0;t<e.length;t++)e[t]=A7(e[t]);return e}var TS=I7?(e)=>e:T7,JO=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),R7=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Up(e){if(nr(e),JO)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=R7[e[r]];return t}var Oi={_0:48,_9:57,A:65,F:70,a:97,f:102};function KO(e){if(e>=Oi._0&&e<=Oi._9)return e-Oi._0;if(e>=Oi.A&&e<=Oi.F)return e-(Oi.A-10);if(e>=Oi.a&&e<=Oi.f)return e-(Oi.a-10);return}function wu(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(JO)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 i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let s=KO(e.charCodeAt(o)),a=KO(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}i[n]=s*16+a}return i}function C7(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function RS(e,t=""){if(typeof e==="string")return C7(e);return nr(e,void 0,t)}function CS(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];nr(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function qp(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 OS(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Pi(e=32){Pt(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 $S=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class PS{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if($i(e),nr(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,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<i.length;n++)i[n]^=54;this.iHash.update(i),this.oHash=e.create();for(let n=0;n<i.length;n++)i[n]^=106;this.oHash.update(i),Tr(i)}update(e){return Xa(this),this.iHash.update(e),this}digestInto(e){Xa(this),Bp(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:i,destroyed:n,blockLen:o,outputLen:s}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,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 ri=(()=>{let e=(t,r,i)=>new PS(t,r).update(i).digest();return e.create=(t,r)=>new PS(t,r),e})();function vu(e,t,r){if($i(e),r===void 0)r=new Uint8Array(e.outputLen);return ri(e,r,t)}var zS=Uint8Array.of(0),VO=Uint8Array.of();function NS(e,t,r,i=32){$i(e),Pt(i,"length"),nr(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(i>255*n)throw Error("Length must be <= 255*HashLen");let o=Math.ceil(i/n);if(r===void 0)r=VO;else nr(r,void 0,"info");let s=new Uint8Array(o*n),a=ri.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)zS[0]=u+1,c.update(u===0?VO:l).update(r).update(zS).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Tr(l,zS),s.slice(0,i)}var bo=(e,t,r,i,n)=>NS(e,vu(e,t,r),i,n);function WO(e,t,r){return e&t^~e&r}function GO(e,t,r){return e&t^e&r^t&r}class Zp{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,i){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=ec(this.buffer)}update(e){Xa(this),nr(e);let{view:t,buffer:r,blockLen:i}=this,n=e.length;for(let o=0;o<n;){let s=Math.min(i-this.pos,n-o);if(s===i){let a=ec(e);for(;i<=n-o;o+=i)this.process(a,o);continue}if(r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){Xa(this),Bp(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Tr(this.buffer.subarray(o)),this.padOffset>i-o)this.process(r,0),o=0;for(let u=o;u<i;u++)t[u]=0;r.setBigUint64(i-8,BigInt(this.length*8),n),this.process(r,0);let s=ec(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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:i,finished:n,destroyed:o,pos:s}=this;if(e.destroyed=o,e.finished=n,e.length=i,e.pos=s,i%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var zi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ir=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Mp=BigInt(4294967295),QO=BigInt(32);function O7(e,t=!1){if(t)return{h:Number(e&Mp),l:Number(e>>QO&Mp)};return{h:Number(e>>QO&Mp)|0,l:Number(e&Mp)|0}}function YO(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=O7(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var DS=(e,t,r)=>e>>>r,LS=(e,t,r)=>e<<32-r|t>>>r,Ds=(e,t,r)=>e>>>r|t<<32-r,Ls=(e,t,r)=>e<<32-r|t>>>r,_u=(e,t,r)=>e<<64-r|t>>>r-32,ku=(e,t,r)=>e>>>r-32|t<<64-r;function ni(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var XO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),e$=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,t$=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),r$=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,n$=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),i$=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var P7=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]),So=new Uint32Array(64);class o$ extends Zp{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:i,E:n,F:o,G:s,H:a}=this;return[e,t,r,i,n,o,s,a]}set(e,t,r,i,n,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)So[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let f=So[u-15],p=So[u-2],m=On(f,7)^On(f,18)^f>>>3,b=On(p,17)^On(p,19)^p>>>10;So[u]=b+So[u-7]+m+So[u-16]|0}let{A:r,B:i,C:n,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){let f=On(s,6)^On(s,11)^On(s,25),p=l+f+WO(s,a,c)+P7[u]+So[u]|0,b=(On(r,2)^On(r,13)^On(r,22))+GO(r,i,n)|0;l=c,c=a,a=s,s=o+p|0,o=n,n=i,i=r,r=p+b|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,n,o,s,a,c,l)}roundClean(){Tr(So)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Tr(this.buffer)}}class s$ extends o${A=zi[0]|0;B=zi[1]|0;C=zi[2]|0;D=zi[3]|0;E=zi[4]|0;F=zi[5]|0;G=zi[6]|0;H=zi[7]|0;constructor(){super(32)}}var a$=(()=>YO(["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))))(),z7=(()=>a$[0])(),N7=(()=>a$[1])(),xo=new Uint32Array(80),wo=new Uint32Array(80);class c$ extends Zp{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:u,Fl:f,Gh:p,Gl:m,Hh:b,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,f,p,m,b,g]}set(e,t,r,i,n,o,s,a,c,l,u,f,p,m,b,g){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=n|0,this.Cl=o|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=f|0,this.Gh=p|0,this.Gl=m|0,this.Hh=b|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)xo[A]=e.getUint32(t),wo[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let R=xo[A-15]|0,D=wo[A-15]|0,U=Ds(R,D,1)^Ds(R,D,8)^DS(R,D,7),T=Ls(R,D,1)^Ls(R,D,8)^LS(R,D,7),H=xo[A-2]|0,B=wo[A-2]|0,V=Ds(H,B,19)^_u(H,B,61)^DS(H,B,6),te=Ls(H,B,19)^ku(H,B,61)^LS(H,B,6),K=t$(T,te,wo[A-7],wo[A-16]),N=r$(K,U,V,xo[A-7],xo[A-16]);xo[A]=N|0,wo[A]=K|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:f,Fh:p,Fl:m,Gh:b,Gl:g,Hh:S,Hl:k}=this;for(let A=0;A<80;A++){let R=Ds(u,f,14)^Ds(u,f,18)^_u(u,f,41),D=Ls(u,f,14)^Ls(u,f,18)^ku(u,f,41),U=u&p^~u&b,T=f&m^~f&g,H=n$(k,D,T,N7[A],wo[A]),B=i$(H,S,R,U,z7[A],xo[A]),V=H|0,te=Ds(r,i,28)^_u(r,i,34)^_u(r,i,39),K=Ls(r,i,28)^ku(r,i,34)^ku(r,i,39),N=r&n^r&s^n&s,L=i&o^i&a^o&a;S=b|0,k=g|0,b=p|0,g=m|0,p=u|0,m=f|0,{h:u,l:f}=ni(c|0,l|0,B|0,V|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=XO(V,K,L);r=e$(I,B,te,N),i=I|0}({h:r,l:i}=ni(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ni(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ni(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ni(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:f}=ni(this.Eh|0,this.El|0,u|0,f|0),{h:p,l:m}=ni(this.Fh|0,this.Fl|0,p|0,m|0),{h:b,l:g}=ni(this.Gh|0,this.Gl|0,b|0,g|0),{h:S,l:k}=ni(this.Hh|0,this.Hl|0,S|0,k|0),this.set(r,i,n,o,s,a,c,l,u,f,p,m,b,g,S,k)}roundClean(){Tr(xo,wo)}destroy(){this.destroyed=!0,Tr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class l$ extends c${Ah=ir[0]|0;Al=ir[1]|0;Bh=ir[2]|0;Bl=ir[3]|0;Ch=ir[4]|0;Cl=ir[5]|0;Dh=ir[6]|0;Dl=ir[7]|0;Eh=ir[8]|0;El=ir[9]|0;Fh=ir[10]|0;Fl=ir[11]|0;Gh=ir[12]|0;Gl=ir[13]|0;Hh=ir[14]|0;Hl=ir[15]|0;constructor(){super(64)}}var zt=OS(()=>new s$,$S(1));var Fp=OS(()=>new l$,$S(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Wp(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function US(e){if(!Wp(e))throw TypeError("Uint8Array expected")}function m$(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 h$(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function vo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function Iu(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Kp(e){if(!Array.isArray(e))throw TypeError("array expected")}function Jp(e,t){if(!m$(!0,t))throw TypeError(`${e}: array of strings expected`)}function qS(e,t){if(!m$(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Xr(...e){let t=(o)=>o,r=(o,s)=>(a)=>o(s(a)),i=e.map((o)=>o.encode).reduceRight(r,t),n=e.map((o)=>o.decode).reduce(r,t);return{encode:i,decode:n}}function en(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Jp("alphabet",t);let i=new Map(t.map((n,o)=>[n,o]));return{encode:(n)=>(Kp(n),n.map((o)=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:(n)=>(Kp(n),n.map((o)=>{vo("alphabet.decode",o);let s=i.get(o);if(s===void 0)throw Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function tn(e=""){return vo("join",e),{encode:(t)=>(Jp("join.decode",t),t.join(e)),decode:(t)=>(vo("join.decode",t),t.split(e))}}function Gp(e,t="="){return Iu(e),vo("padding",t),{encode(r){Jp("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Jp("padding.decode",r);let i=r.length;if(i*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;i>0&&r[i-1]===t;i--)if((i-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,i)}}}function g$(e){return h$(e),{encode:(t)=>t,decode:(t)=>e(t)}}function u$(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(Kp(e),!e.length)return[];let i=0,n=[],o=Array.from(e,(a)=>{if(Iu(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=o.length;while(!0){let a=0,c=!0;for(let l=i;l<s;l++){let u=o[l],f=t*a,p=f+u;if(!Number.isSafeInteger(p)||f/t!==a||p-u!==f)throw Error("convertRadix: carry overflow");let m=p/r;a=p%r;let b=Math.floor(m);if(o[l]=b,!Number.isSafeInteger(b)||b*r+a!==p)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!b)i=l;else c=!1}if(n.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}var y$=(e,t)=>t===0?e:y$(t,e%t),Vp=(e,t)=>e+(t-y$(e,t)),Hp=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function BS(e,t,r,i){if(Kp(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Vp(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Vp(t,r)}`);let n=0,o=0,s=Hp[t],a=Hp[r]-1,c=[];for(let l of e){if(Iu(l),l>=s)throw Error(`convertRadix2: invalid data word=${l} from=${t}`);if(n=n<<t|l,o+t>32)throw Error(`convertRadix2: carry overflow pos=${o} from=${t}`);o+=t;for(;o>=r;o-=r)c.push((n>>o-r&a)>>>0);let u=Hp[o];if(u===void 0)throw Error("invalid carry");n&=u-1}if(n=n<<r-o&a,!i&&o>=t)throw Error("Excess padding");if(!i&&n>0)throw Error(`Non-zero padding: ${n}`);if(i&&o>0)c.push(n>>>0);return c}function D7(e){Iu(e);let t=256;return{encode:(r)=>{if(!Wp(r))throw TypeError("radix.encode input should be Uint8Array");return u$(Array.from(r),t,e)},decode:(r)=>(qS("radix.decode",r),Uint8Array.from(u$(r,e,t)))}}function hn(e,t=!1){if(Iu(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Vp(8,e)>32||Vp(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Wp(r))throw TypeError("radix2.encode input should be Uint8Array");return BS(Array.from(r),8,e,!t)},decode:(r)=>(qS("radix2.decode",r),Uint8Array.from(BS(r,e,8,t)))}}function d$(e){return h$(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var r0e=Object.freeze(Xr(hn(4),en("0123456789ABCDEF"),tn(""))),n0e=Object.freeze(Xr(hn(5),en("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Gp(5),tn(""))),i0e=Object.freeze(Xr(hn(5),en("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),tn(""))),o0e=Object.freeze(Xr(hn(5),en("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Gp(5),tn(""))),s0e=Object.freeze(Xr(hn(5),en("0123456789ABCDEFGHIJKLMNOPQRSTUV"),tn(""))),a0e=Object.freeze(Xr(hn(5),en("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),tn(""),g$((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),b$=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),L7=/[\t\n\f\r ]/,S$=(e,t)=>{vo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&L7.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},ZS=Object.freeze(b$?{encode(e){return US(e),e.toBase64()},decode(e){return S$(e,!1)}}:Xr(hn(6),en("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Gp(6),tn(""))),yr=Object.freeze(Xr(hn(6),en("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),tn(""))),c0e=Object.freeze(b$?{encode(e){return US(e),e.toBase64({alphabet:"base64url"})},decode(e){return S$(e,!0)}}:Xr(hn(6),en("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Gp(6),tn(""))),l0e=Object.freeze(Xr(hn(6),en("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),tn(""))),MS=(e)=>Xr(D7(58),en(e),tn("")),u0e=Object.freeze(MS("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),d0e=Object.freeze(MS("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),f0e=Object.freeze(MS("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var jS=Xr(en("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),tn("")),f$=[996825010,642813549,513874426,1027748829,705979059];function Eu(e){let t=e>>25,r=(e&33554431)<<5;for(let i=0;i<f$.length;i++)if((t>>i&1)===1)r^=f$[i];return r}function p$(e,t,r=1){let i=e.length,n=1;for(let o=0;o<i;o++){let s=e.charCodeAt(o);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=Eu(n)^s>>5}n=Eu(n);for(let o=0;o<i;o++)n=Eu(n)^e.charCodeAt(o)&31;for(let o of t)n=Eu(n)^o;for(let o=0;o<6;o++)n=Eu(n);return n^=r,jS.encode(BS([n%Hp[30]],30,5,!1))}function x$(e){let t=e==="bech32"?1:734539939,r=hn(5),i=r.decode,n=r.encode,o=d$(i);function s(f,p,m=90){if(vo("bech32.encode prefix",f),Wp(p))p=Array.from(p);qS("bech32.encode",p);let b=f.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let g=b+7+p.length;if(m!==!1&&g>m)throw TypeError(`Length ${g} exceeds limit ${m}`);let S=f.toLowerCase(),k=p$(S,p,t);return`${S}1${jS.encode(p)}${k}`}function a(f,p=90){vo("bech32.decode input",f);let m=f.length;if(m<8||p!==!1&&m>p)throw TypeError(`invalid string length: ${m} (${f}). Expected (8..${p})`);let b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw Error("String must be lowercase or uppercase");let g=b.lastIndexOf("1");if(g===0||g===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,g),k=b.slice(g+1);if(k.length<6)throw Error("Data must be at least 6 characters long");let A=jS.decode(k).slice(0,-6),R=p$(S,A,t);if(!k.endsWith(R))throw Error(`Invalid checksum in ${f}: expected "${R}"`);return{prefix:S,words:A}}let c=d$(a);function l(f){let{prefix:p,words:m}=a(f,!1);return{prefix:p,words:m,bytes:i(m)}}function u(f,p){return s(f,n(p))}return{encode:s,decode:a,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:i,fromWordsUnsafe:o,toWords:n}}var rn=Object.freeze(x$("bech32")),p0e=Object.freeze(x$("bech32m"));var B7=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),j7={encode(e){return US(e),e.toHex()},decode(e){return vo("hex",e),Uint8Array.fromHex(e)}},m0e=Object.freeze(B7?j7:Xr(hn(4),en("0123456789abcdef"),tn(""),g$((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 q7(e,t,r,i){$i(e);let n=qp({dkLen:32,asyncTick:10},i),{c:o,dkLen:s,asyncTick:a}=n;if(Pt(o,"c"),Pt(s,"dkLen"),Pt(a,"asyncTick"),o<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 c=RS(t,"password"),l=RS(r,"salt"),u=new Uint8Array(s),f=ri.create(e,c),p=f._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:f,PRFSalt:p}}function Z7(e,t,r,i,n){if(e.destroy(),t.destroy(),i)i.destroy();return Tr(n),r}function FS(e,t,r,i){let{c:n,dkLen:o,DK:s,PRF:a,PRFSalt:c}=q7(e,t,r,i),l,u=new Uint8Array(4),f=ec(u),p=new Uint8Array(a.outputLen);for(let m=1,b=0;b<o;m++,b+=a.outputLen){let g=s.subarray(b,b+a.outputLen);f.setInt32(0,m,!1),(l=c._cloneInto(l)).update(u).digestInto(p),g.set(p.subarray(0,g.length));for(let S=1;S<n;S++){a._cloneInto(l).update(p).digestInto(p);for(let k=0;k<g.length;k++)g[k]^=p[k]}}return Z7(a,c,s,l,p)}function w$(e,t,r,i,n,o){let s=e[t++]^r[i++],a=e[t++]^r[i++],c=e[t++]^r[i++],l=e[t++]^r[i++],u=e[t++]^r[i++],f=e[t++]^r[i++],p=e[t++]^r[i++],m=e[t++]^r[i++],b=e[t++]^r[i++],g=e[t++]^r[i++],S=e[t++]^r[i++],k=e[t++]^r[i++],A=e[t++]^r[i++],R=e[t++]^r[i++],D=e[t++]^r[i++],U=e[t++]^r[i++],T=s,H=a,B=c,V=l,te=u,K=f,N=p,L=m,I=b,z=g,P=S,J=k,j=A,Q=R,E=D,ae=U;for(let fe=0;fe<8;fe+=2)te^=rt(T+j|0,7),I^=rt(te+T|0,9),j^=rt(I+te|0,13),T^=rt(j+I|0,18),z^=rt(K+H|0,7),Q^=rt(z+K|0,9),H^=rt(Q+z|0,13),K^=rt(H+Q|0,18),E^=rt(P+N|0,7),B^=rt(E+P|0,9),N^=rt(B+E|0,13),P^=rt(N+B|0,18),V^=rt(ae+J|0,7),L^=rt(V+ae|0,9),J^=rt(L+V|0,13),ae^=rt(J+L|0,18),H^=rt(T+V|0,7),B^=rt(H+T|0,9),V^=rt(B+H|0,13),T^=rt(V+B|0,18),N^=rt(K+te|0,7),L^=rt(N+K|0,9),te^=rt(L+N|0,13),K^=rt(te+L|0,18),J^=rt(P+z|0,7),I^=rt(J+P|0,9),z^=rt(I+J|0,13),P^=rt(z+I|0,18),j^=rt(ae+E|0,7),Q^=rt(j+ae|0,9),E^=rt(Q+j|0,13),ae^=rt(E+Q|0,18);n[o++]=s+T|0,n[o++]=a+H|0,n[o++]=c+B|0,n[o++]=l+V|0,n[o++]=u+te|0,n[o++]=f+K|0,n[o++]=p+N|0,n[o++]=m+L|0,n[o++]=b+I|0,n[o++]=g+z|0,n[o++]=S+P|0,n[o++]=k+J|0,n[o++]=A+j|0,n[o++]=R+Q|0,n[o++]=D+E|0,n[o++]=U+ae|0}function HS(e,t,r,i,n){let o=i+0,s=i+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++,o+=16,t+=16){if(w$(r,s,e,t,r,o),a>0)s+=16;w$(r,o,e,t+=16,r,s)}}function M7(e,t,r){let i=qp({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:o,p:s,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=i;if(Pt(n,"N"),Pt(o,"r"),Pt(s,"p"),Pt(a,"dkLen"),Pt(c,"asyncTick"),Pt(l,"maxmem"),u!==void 0&&typeof u!=="function")throw Error("progressCb must be a function");let f=128*o,p=f/4,m=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>m)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(m-1)*32/f)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(m-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=f*(n+s+1);if(b>l)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+l);let g=FS(zt,e,t,{c:1,dkLen:f*s}),S=jp(g),k=jp(new Uint8Array(f*n)),A=jp(new Uint8Array(f)),R=()=>{};if(u){let D=2*n*s,U=Math.max(Math.floor(D/1e4),1),T=0;R=()=>{if(T++,u&&(!(T%U)||T===D))u(T/D)}}return{N:n,r:o,p:s,dkLen:a,blockSize32:p,V:k,B32:S,B:g,tmp:A,blockMixCb:R,asyncTick:c}}function F7(e,t,r,i,n){let o=FS(zt,e,r,{c:1,dkLen:t});return Tr(r,i,n),o}function KS(e,t,r){let{N:i,r:n,p:o,dkLen:s,blockSize32:a,V:c,B32:l,B:u,tmp:f,blockMixCb:p}=M7(e,t,r);TS(l);for(let m=0;m<o;m++){let b=a*m;for(let g=0;g<a;g++)c[g]=l[b+g];for(let g=0,S=0;g<i-1;g++)HS(c,S,c,S+=a,n),p();HS(c,(i-1)*a,l,b,n),p();for(let g=0;g<i;g++){let S=(l[b+a-16]&i-1)>>>0;for(let k=0;k<a;k++)f[k]=l[b+k]^c[S*a+k];HS(f,0,l,b,n),p()}}return TS(l),F7(e,s,u,c,f)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function H7(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Qp(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function tc(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 Ft(e,t,r=""){let i=H7(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;if(!i)throw TypeError(l);throw RangeError(l)}return e}function JS(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 v$(e,t,r=!1){Ft(e,void 0,"output");let i=t.outputLen;if(e.length<i)throw RangeError("digestInto() expects output buffer of length at least "+i);if(r&&!rc(e))throw Error("invalid output, must be aligned")}function ii(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function $n(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function K7(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Bs=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),J7=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var V7=(e)=>{for(let t=0;t<e.length;t++)e[t]=J7(e[t]);return e},Ni=Bs?(e)=>e:V7;function _$(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function k$(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function E$(e,t,r){let i=t,n=r||(()=>[]),o=(a,c)=>i(c,...n(a)).update(a).digest(),s=i(new Uint8Array(e),...n(new Uint8Array(0)));return o.outputLen=s.outputLen,o.blockLen=s.blockLen,o.create=(a,...c)=>i(a,...c),o}var I$=(e,t)=>{function r(i,...n){if(Ft(i,void 0,"key"),e.nonceLength!==void 0){let u=n[0];Ft(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;if(o&&n[1]!==void 0)Ft(n[1],void 0,"AAD");let s=t(i,...n),a=(u,f)=>{if(f!==void 0){if(u!==2)throw Error("cipher output not supported");Ft(f,void 0,"output")}},c=!1;return{encrypt(u,f){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Ft(u),a(s.encrypt.length,f),s.encrypt(u,f)},decrypt(u,f){if(Ft(u),o&&u.length<o)throw Error('"ciphertext" expected length bigger than tagLength='+o);return a(s.decrypt.length,f),s.decrypt(u,f)}}}return Object.assign(r,e),r};function Au(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Ft(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!rc(t))throw Error("invalid output, must be aligned");return t}function A$(e,t,r){tc(e),tc(t),Qp(r);let i=new Uint8Array(16),n=K7(i);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),i}function rc(e){return e.byteOffset%4===0}function nc(e){return Uint8Array.from(Ft(e))}var R$=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),W7=(()=>Ni(ii(R$("expand 16-byte k"))))(),G7=(()=>Ni(ii(R$("expand 32-byte k"))))();function nt(e,t){return e<<t|e>>>32-t}var Tu=64,Q7=16,VS=(()=>4294967295)(),T$=Uint32Array.of();function Y7(e,t,r,i,n,o,s,a){let c=n.length,l=new Uint8Array(Tu),u=ii(l),f=Bs&&rc(n)&&rc(o),p=f?ii(n):T$,m=f?ii(o):T$;if(!Bs){for(let b=0;b<c;s++){if(e(t,r,i,u,s,a),Ni(u),s>=VS)throw Error("arx: counter overflow");let g=Math.min(Tu,c-b);for(let S=0,k;S<g;S++)k=b+S,o[k]=n[k]^l[S];b+=g}return}for(let b=0;b<c;s++){if(e(t,r,i,u,s,a),s>=VS)throw Error("arx: counter overflow");let g=Math.min(Tu,c-b);if(f&&g===Tu){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let k=0,A;k<Q7;k++)A=S+k,m[A]=p[A]^u[k];b+=Tu;continue}for(let S=0,k;S<g;S++)k=b+S,o[k]=n[k]^l[S];b+=g}}function C$(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:o,rounds:s}=_$({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return tc(n),tc(s),Qp(o),Qp(r),(a,c,l,u,f=0)=>{Ft(a,void 0,"key"),Ft(c,void 0,"nonce"),Ft(l,void 0,"data");let p=l.length;if(u=Au(p,u,!1),tc(f),f<0||f>=VS)throw Error("arx: counter overflow");let m=[],b=a.length,g,S;if(b===32)m.push(g=nc(a)),S=G7;else if(b===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),S=W7,m.push(g);else throw Ft(a,32,"arx key"),Error("invalid key size");if(!Bs||!rc(c))m.push(c=nc(c));let k=ii(g);if(i){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let D=c.subarray(0,16);if(Bs)i(S,k,ii(D),k);else{let U=Ni(Uint32Array.from(S));i(U,k,ii(D),k),$n(U),Ni(k)}c=c.subarray(16)}else if(!Bs)Ni(k);let A=16-n;if(A!==c.length)throw Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){let D=new Uint8Array(12);D.set(c,o?0:12-c.length),c=D,m.push(c)}let R=Ni(ii(c));try{return Y7(e,S,k,R,l,u,f,s),u}finally{$n(...m)}}}function or(e,t){return e[t++]&255|(e[t++]&255)<<8}class O${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=nc(Ft(e,32,"key"));let t=or(e,0),r=or(e,2),i=or(e,4),n=or(e,6),o=or(e,8),s=or(e,10),a=or(e,12),c=or(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let l=0;l<8;l++)this.pad[l]=or(e,16+2*l)}process(e,t,r=!1){let i=r?0:2048,{h:n,r:o}=this,s=o[0],a=o[1],c=o[2],l=o[3],u=o[4],f=o[5],p=o[6],m=o[7],b=o[8],g=o[9],S=or(e,t+0),k=or(e,t+2),A=or(e,t+4),R=or(e,t+6),D=or(e,t+8),U=or(e,t+10),T=or(e,t+12),H=or(e,t+14),B=n[0]+(S&8191),V=n[1]+((S>>>13|k<<3)&8191),te=n[2]+((k>>>10|A<<6)&8191),K=n[3]+((A>>>7|R<<9)&8191),N=n[4]+((R>>>4|D<<12)&8191),L=n[5]+(D>>>1&8191),I=n[6]+((D>>>14|U<<2)&8191),z=n[7]+((U>>>11|T<<5)&8191),P=n[8]+((T>>>8|H<<8)&8191),J=n[9]+(H>>>5|i),j=0,Q=j+B*s+V*(5*g)+te*(5*b)+K*(5*m)+N*(5*p);j=Q>>>13,Q&=8191,Q+=L*(5*f)+I*(5*u)+z*(5*l)+P*(5*c)+J*(5*a),j+=Q>>>13,Q&=8191;let E=j+B*a+V*s+te*(5*g)+K*(5*b)+N*(5*m);j=E>>>13,E&=8191,E+=L*(5*p)+I*(5*f)+z*(5*u)+P*(5*l)+J*(5*c),j+=E>>>13,E&=8191;let ae=j+B*c+V*a+te*s+K*(5*g)+N*(5*b);j=ae>>>13,ae&=8191,ae+=L*(5*m)+I*(5*p)+z*(5*f)+P*(5*u)+J*(5*l),j+=ae>>>13,ae&=8191;let fe=j+B*l+V*c+te*a+K*s+N*(5*g);j=fe>>>13,fe&=8191,fe+=L*(5*b)+I*(5*m)+z*(5*p)+P*(5*f)+J*(5*u),j+=fe>>>13,fe&=8191;let C=j+B*u+V*l+te*c+K*a+N*s;j=C>>>13,C&=8191,C+=L*(5*g)+I*(5*b)+z*(5*m)+P*(5*p)+J*(5*f),j+=C>>>13,C&=8191;let xe=j+B*f+V*u+te*l+K*c+N*a;j=xe>>>13,xe&=8191,xe+=L*s+I*(5*g)+z*(5*b)+P*(5*m)+J*(5*p),j+=xe>>>13,xe&=8191;let Te=j+B*p+V*f+te*u+K*l+N*c;j=Te>>>13,Te&=8191,Te+=L*a+I*s+z*(5*g)+P*(5*b)+J*(5*m),j+=Te>>>13,Te&=8191;let Pe=j+B*m+V*p+te*f+K*u+N*l;j=Pe>>>13,Pe&=8191,Pe+=L*c+I*a+z*s+P*(5*g)+J*(5*b),j+=Pe>>>13,Pe&=8191;let $e=j+B*b+V*m+te*p+K*f+N*u;j=$e>>>13,$e&=8191,$e+=L*l+I*c+z*a+P*s+J*(5*g),j+=$e>>>13,$e&=8191;let _e=j+B*g+V*b+te*m+K*p+N*f;j=_e>>>13,_e&=8191,_e+=L*u+I*l+z*c+P*a+J*s,j+=_e>>>13,_e&=8191,j=(j<<2)+j|0,j=j+Q|0,Q=j&8191,j=j>>>13,E+=j,n[0]=Q,n[1]=E,n[2]=ae,n[3]=fe,n[4]=C,n[5]=xe,n[6]=Te,n[7]=Pe,n[8]=$e,n[9]=_e}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=i,i=e[s]>>>13,e[s]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+i,i=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(i^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 o=e[0]+t[0];e[0]=o&65535;for(let s=1;s<8;s++)o=(e[s]+t[s]|0)+(o>>>16)|0,e[s]=o&65535;$n(r)}update(e){JS(this),Ft(e),e=nc(e);let{buffer:t,blockLen:r}=this,i=e.length;for(let n=0;n<i;){let o=Math.min(r-this.pos,i-n);if(o===r){for(;r<=i-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,$n(this.h,this.r,this.buffer,this.pad)}digestInto(e){JS(this),v$(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:i}=this;if(i){t[i++]=1;for(;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var $$=E$(32,(e)=>new O$(e));function X7(e,t,r,i,n,o=20){let s=e[0],a=e[1],c=e[2],l=e[3],u=t[0],f=t[1],p=t[2],m=t[3],b=t[4],g=t[5],S=t[6],k=t[7],A=n,R=r[0],D=r[1],U=r[2],T=s,H=a,B=c,V=l,te=u,K=f,N=p,L=m,I=b,z=g,P=S,J=k,j=A,Q=R,E=D,ae=U;for(let C=0;C<o;C+=2)T=T+te|0,j=nt(j^T,16),I=I+j|0,te=nt(te^I,12),T=T+te|0,j=nt(j^T,8),I=I+j|0,te=nt(te^I,7),H=H+K|0,Q=nt(Q^H,16),z=z+Q|0,K=nt(K^z,12),H=H+K|0,Q=nt(Q^H,8),z=z+Q|0,K=nt(K^z,7),B=B+N|0,E=nt(E^B,16),P=P+E|0,N=nt(N^P,12),B=B+N|0,E=nt(E^B,8),P=P+E|0,N=nt(N^P,7),V=V+L|0,ae=nt(ae^V,16),J=J+ae|0,L=nt(L^J,12),V=V+L|0,ae=nt(ae^V,8),J=J+ae|0,L=nt(L^J,7),T=T+K|0,ae=nt(ae^T,16),P=P+ae|0,K=nt(K^P,12),T=T+K|0,ae=nt(ae^T,8),P=P+ae|0,K=nt(K^P,7),H=H+N|0,j=nt(j^H,16),J=J+j|0,N=nt(N^J,12),H=H+N|0,j=nt(j^H,8),J=J+j|0,N=nt(N^J,7),B=B+L|0,Q=nt(Q^B,16),I=I+Q|0,L=nt(L^I,12),B=B+L|0,Q=nt(Q^B,8),I=I+Q|0,L=nt(L^I,7),V=V+te|0,E=nt(E^V,16),z=z+E|0,te=nt(te^z,12),V=V+te|0,E=nt(E^V,8),z=z+E|0,te=nt(te^z,7);let fe=0;i[fe++]=s+T|0,i[fe++]=a+H|0,i[fe++]=c+B|0,i[fe++]=l+V|0,i[fe++]=u+te|0,i[fe++]=f+K|0,i[fe++]=p+N|0,i[fe++]=m+L|0,i[fe++]=b+I|0,i[fe++]=g+z|0,i[fe++]=S+P|0,i[fe++]=k+J|0,i[fe++]=A+j|0,i[fe++]=R+Q|0,i[fe++]=D+E|0,i[fe++]=U+ae|0}var eW=C$(X7,{counterRight:!1,counterLength:4,allowShortKeys:!1});var tW=new Uint8Array(16),P$=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(tW.subarray(r))},rW=new Uint8Array(32);function z$(e,t,r,i,n){if(n!==void 0)Ft(n,void 0,"AAD");let o=e(t,r,rW),s=A$(i.length,n?n.length:0,!0),a=$$.create(o);if(n)P$(a,n);P$(a,i),a.update(s);let c=a.digest();return $n(o,s),c}var nW=(e)=>(t,r,i)=>({encrypt(o,s){let a=o.length;s=Au(a+16,s,!1),s.set(o);let c=s.subarray(0,-16);e(t,r,c,c,1);let l=z$(e,t,r,c,i);return s.set(l,a),$n(l),s},decrypt(o,s){s=Au(o.length-16,s,!1);let a=o.subarray(0,-16),c=o.subarray(-16),l=z$(e,t,r,a,i);if(!k$(c,l))throw $n(l),Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),$n(l),s}}),gn=I$({blockSize:64,nonceLength:12,tagLength:16},nW(eW));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ic(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Qt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function De(e,t,r=""){let i=ic(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function yn(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Qt(e.outputLen),Qt(e.blockLen)}function Li(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 Yp(e,t){De(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function Xp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Mr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function em(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Pn(e,t){return e<<32-t|e>>>t}var iW=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function oW(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function sW(e){for(let t=0;t<e.length;t++)e[t]=oW(e[t]);return e}var WS=iW?(e)=>e:sW,D$=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),aW=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function js(e){if(De(e),D$)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=aW[e[r]];return t}var Di={_0:48,_9:57,A:65,F:70,a:97,f:102};function N$(e){if(e>=Di._0&&e<=Di._9)return e-Di._0;if(e>=Di.A&&e<=Di.F)return e-(Di.A-10);if(e>=Di.a&&e<=Di.f)return e-(Di.a-10);return}function Us(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(D$)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 i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let s=N$(e.charCodeAt(o)),a=N$(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+o)}i[n]=s*16+a}return i}function Ut(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];De(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function oc(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function _o(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 ko=(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 QS=BigInt(0),GS=BigInt(1);function Ru(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function L$(e){if(typeof e==="bigint"){if(!tm(e))throw Error("positive bigint expected, got "+e)}else Qt(e);return e}function Cu(e){let t=L$(e).toString(16);return t.length&1?"0"+t:t}function B$(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?QS:BigInt("0x"+e)}function Eo(e){return B$(js(e))}function Io(e){return B$(js(rm(De(e)).reverse()))}function sc(e,t){Qt(t),e=L$(e);let r=Us(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Ou(e,t){return sc(e,t).reverse()}function rm(e){return Uint8Array.from(e)}function Ao(e){return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}var tm=(e)=>typeof e==="bigint"&&QS<=e;function cW(e,t,r){return tm(e)&&tm(t)&&tm(r)&&t<=e&&e<r}function $u(e,t,r,i){if(!cW(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function YS(e){let t;for(t=0;e>QS;e>>=GS,t+=1);return t}var Pu=(e)=>(GS<<BigInt(e))-GS;function j$(e,t,r){if(Qt(e,"hashLen"),Qt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let i=(S)=>new Uint8Array(S),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,f=()=>{c.fill(1),l.fill(0),u=0},p=(...S)=>r(l,Ut(c,...S)),m=(S=n)=>{if(l=p(o,S),c=p(),S.length===0)return;l=p(s,S),c=p()},b=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let S=0,k=[];while(S<t){c=p();let A=c.slice();k.push(A),S+=c.length}return Ut(...k)};return(S,k)=>{f(),m(S);let A=void 0;while(!(A=k(b())))m();return f(),A}}function qs(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function i(o,s,a){let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw Error(`param "${o}" is invalid: expected ${s}, got ${l}`)}let n=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));n(t,!1),n(r,!0)}function XS(e){let t=new WeakMap;return(r,...i)=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r,...i);return t.set(r,o),o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Cr=BigInt(0),br=BigInt(1),Zs=BigInt(2),Z$=BigInt(3),M$=BigInt(4),F$=BigInt(5),lW=BigInt(7),H$=BigInt(8),uW=BigInt(9),K$=BigInt(16);function Rr(e,t){let r=e%t;return r>=Cr?r:t+r}function bn(e,t,r){let i=e;while(t-- >Cr)i*=i,i%=r;return i}function U$(e,t){if(e===Cr)throw Error("invert: expected non-zero number");if(t<=Cr)throw Error("invert: expected positive modulus, got "+t);let r=Rr(e,t),i=t,n=Cr,o=br,s=br,a=Cr;while(r!==Cr){let l=i/r,u=i%r,f=n-s*l,p=o-a*l;i=r,r=u,n=s,o=a,s=f,a=p}if(i!==br)throw Error("invert: does not exist");return Rr(n,t)}function ex(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function J$(e,t){let r=(e.ORDER+br)/M$,i=e.pow(t,r);return ex(e,i,t),i}function dW(e,t){let r=(e.ORDER-F$)/H$,i=e.mul(t,Zs),n=e.pow(i,r),o=e.mul(t,n),s=e.mul(e.mul(o,Zs),n),a=e.mul(o,e.sub(s,e.ONE));return ex(e,a,t),a}function fW(e){let t=nm(e),r=V$(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+lW)/K$;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,i),f=a.mul(l,n),p=a.mul(l,o),m=a.eql(a.sqr(u),c),b=a.eql(a.sqr(f),c);l=a.cmov(l,u,m),u=a.cmov(p,f,b);let g=a.eql(a.sqr(u),c),S=a.cmov(l,u,g);return ex(a,S,c),S}}function V$(e){if(e<Z$)throw Error("sqrt is not defined for small field");let t=e-br,r=0;while(t%Zs===Cr)t/=Zs,r++;let i=Zs,n=nm(e);while(q$(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return J$;let o=n.pow(i,t),s=(t+br)/Zs;return function(c,l){if(c.is0(l))return l;if(q$(c,l)!==1)throw Error("Cannot find square root");let u=r,f=c.mul(c.ONE,o),p=c.pow(l,t),m=c.pow(l,s);while(!c.eql(p,c.ONE)){if(c.is0(p))return c.ZERO;let b=1,g=c.sqr(p);while(!c.eql(g,c.ONE))if(b++,g=c.sqr(g),b===u)throw Error("Cannot find square root");let S=br<<BigInt(u-b-1),k=c.pow(f,S);u=b,f=c.sqr(k),p=c.mul(p,f),m=c.mul(m,k)}return m}}function pW(e){if(e%M$===Z$)return J$;if(e%H$===F$)return dW;if(e%K$===uW)return fW(e);return V$(e)}var mW=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function tx(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=mW.reduce((i,n)=>(i[n]="function",i),t);return qs(e,r),e}function hW(e,t,r){if(r<Cr)throw Error("invalid exponent, negatives unsupported");if(r===Cr)return e.ONE;if(r===br)return t;let i=e.ONE,n=t;while(r>Cr){if(r&br)i=e.mul(i,n);n=e.sqr(n),r>>=br}return i}function zu(e,t,r=!1){let i=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return i[c]=s,e.mul(s,a)},e.ONE),o=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return i[c]=e.mul(s,i[c]),e.mul(s,a)},o),i}function q$(e,t){let r=(e.ORDER-br)/Zs,i=e.pow(t,r),n=e.eql(i,e.ONE),o=e.eql(i,e.ZERO),s=e.eql(i,e.neg(e.ONE));if(!n&&!o&&!s)throw Error("invalid Legendre symbol result");return n?1:o?0:-1}function gW(e,t){if(t!==void 0)Qt(t);let r=t!==void 0?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}class W${ORDER;BITS;BYTES;isLE;ZERO=Cr;ONE=br;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=Cr)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:i,nByteLength:n}=gW(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Rr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return Cr<=e&&e<this.ORDER}is0(e){return e===Cr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&br)===br}neg(e){return Rr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Rr(e*e,this.ORDER)}add(e,t){return Rr(e+t,this.ORDER)}sub(e,t){return Rr(e-t,this.ORDER)}mul(e,t){return Rr(e*t,this.ORDER)}pow(e,t){return hW(this,e,t)}div(e,t){return Rr(e*U$(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 U$(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=pW(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Ou(e,this.BYTES):sc(e,this.BYTES)}fromBytes(e,t=!1){De(e);let{_lengths:r,BYTES:i,isLE:n,ORDER:o,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>i)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(i);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==i)throw Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let a=n?Io(e):Eo(e);if(s)a=Rr(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return zu(this,e)}cmov(e,t,r){return r?t:e}}function nm(e,t={}){return new W$(e,t)}function G$(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function rx(e){let t=G$(e);return t+Math.ceil(t/2)}function Q$(e,t,r=!1){De(e);let i=e.length,n=G$(t),o=rx(t);if(i<16||i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?Io(e):Eo(e),a=Rr(s,t-br)+br;return r?Ou(a,n):sc(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ac=BigInt(0),Ms=BigInt(1);function Nu(e,t){let r=t.negate();return e?r:t}function sx(e,t){let r=zu(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function tP(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function nx(e,t){tP(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Pu(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function Y$(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>i)a-=o,c+=Ms;let l=t*i,u=l+Math.abs(a)-1,f=a===0,p=a<0,m=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:p,isNegF:m,offsetF:l}}var ix=new WeakMap,rP=new WeakMap;function ox(e){return rP.get(e)||1}function X$(e){if(e!==ac)throw Error("invalid wNAF")}class ax{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 i=e;while(t>ac){if(t&Ms)r=r.add(i);i=i.double(),t>>=Ms}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=nx(t,this.bits),n=[],o=e,s=o;for(let a=0;a<r;a++){s=o,n.push(s);for(let c=1;c<i;c++)s=s.add(o),n.push(s);o=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let i=this.ZERO,n=this.BASE,o=nx(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:f,offsetF:p}=Y$(r,s,o);if(r=a,l)n=n.add(Nu(f,t[p]));else i=i.add(Nu(u,t[c]))}return X$(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=nx(e,this.bits);for(let o=0;o<n.windows;o++){if(r===ac)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=Y$(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return X$(r),i}getPrecomputes(e,t,r){let i=ix.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);ix.set(t,i)}}return i}cached(e,t,r){let i=ox(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=ox(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){tP(t,this.bits),rP.set(e,t),ix.delete(e)}hasCache(e){return ox(e)!==1}}function nP(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>ac||i>ac){if(r&Ms)o=o.add(n);if(i&Ms)s=s.add(n);n=n.double(),r>>=Ms,i>>=Ms}return{p1:o,p2:s}}function eP(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return tx(t),t}else return nm(e,{isLE:r})}function iP(e,t,r={},i){if(i===void 0)i=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l==="bigint"&&l>ac))throw Error(`CURVE.${c} must be positive bigint`)}let n=eP(t.p,r.Fp,i),o=eP(t.n,r.Fn,i),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:o}}function im(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Du=BigInt(0),cc=BigInt(1),om=BigInt(2);function yW(e){return qs(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function oP(e){let t=yW(e),{P:r,type:i,adjustScalarBytes:n,powPminus2:o,randomBytes:s}=t,a=i==="x25519";if(!a&&i!=="x448")throw Error("invalid type");let c=s||_o,l=a?255:448,u=a?32:56,f=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?om**BigInt(254):om**BigInt(447),b=a?BigInt(8)*om**BigInt(251)-cc:BigInt(4)*om**BigInt(445)-cc,g=m+b+cc,S=(I)=>Rr(I,r),k=A(f);function A(I){return Ou(S(I),u)}function R(I){let z=rm(De(I,u,"uCoordinate"));if(a)z[31]&=127;return S(Io(z))}function D(I){return Io(n(rm(De(I,u,"scalar"))))}function U(I,z){let P=te(R(z),D(I));if(P===Du)throw Error("invalid private or public key received");return A(P)}function T(I){return U(I,k)}let H=T,B=U;function V(I,z,P){let J=S(I*(z-P));return z=S(z-J),P=S(P+J),{x_2:z,x_3:P}}function te(I,z){$u("u",I,Du,r),$u("scalar",z,m,g);let P=z,J=I,j=cc,Q=Du,E=I,ae=cc,fe=Du;for(let xe=BigInt(l-1);xe>=Du;xe--){let Te=P>>xe&cc;fe^=Te,{x_2:j,x_3:E}=V(fe,j,E),{x_2:Q,x_3:ae}=V(fe,Q,ae),fe=Te;let Pe=j+Q,$e=S(Pe*Pe),_e=j-Q,We=S(_e*_e),Le=$e-We,Xe=E+ae,dt=E-ae,kt=S(dt*Pe),jt=S(Xe*_e),yt=kt+jt,hr=kt-jt;E=S(yt*yt),ae=S(J*S(hr*hr)),j=S($e*We),Q=S(Le*($e+S(p*Le)))}({x_2:j,x_3:E}=V(fe,j,E)),{x_2:Q,x_3:ae}=V(fe,Q,ae);let C=o(Q);return S(j*C)}let K={secretKey:u,publicKey:u,seed:u},N=(I=c(u))=>(De(I,K.seed,"seed"),I),L={randomSecretKey:N};return Object.freeze({keygen:im(N,H),getSharedSecret:B,getPublicKey:H,scalarMult:U,scalarMultBase:T,utils:L,GuBytes:k.slice(),lengths:K})}class cx{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(yn(e),De(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,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<i.length;n++)i[n]^=54;this.iHash.update(i),this.oHash=e.create();for(let n=0;n<i.length;n++)i[n]^=106;this.oHash.update(i),Mr(i)}update(e){return Li(this),this.iHash.update(e),this}digestInto(e){Li(this),De(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:i,destroyed:n,blockLen:o,outputLen:s}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,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 lc=(e,t,r)=>new cx(e,t).update(r).digest();lc.create=(e,t)=>new cx(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var sP=(e,t)=>(e+(e>=0?t:-t)/cP)/t;function bW(e,t,r){let[[i,n],[o,s]]=t,a=sP(s*e,r),c=sP(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,f=l<Bi,p=u<Bi;if(f)l=-l;if(p)u=-u;let m=Pu(Math.ceil(YS(r)/2))+uc;if(l<Bi||l>=m||u<Bi||u>=m)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:l,k2neg:p,k2:u}}function ux(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function lx(e,t){let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Ru(r.lowS,"lowS"),Ru(r.prehash,"prehash"),r.format!==void 0)ux(r.format);return r}class aP extends Error{constructor(e=""){super(e)}}var To={Err:aP,_tlv:{encode:(e,t)=>{let{Err:r}=To;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let i=t.length/2,n=Cu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Cu(n.length/2|128):"";return Cu(e)+o+n+t},decode(e,t){let{Err:r}=To,i=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),s=0;if(!o)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(i+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){let{Err:t}=To;if(e<Bi)throw new t("integer: negative integers are not allowed");let r=Cu(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}=To;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 Eo(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=To,n=De(e,void 0,"signature"),{v:o,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,o),{v:l,l:u}=i.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=To,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},Bi=BigInt(0),uc=BigInt(1),cP=BigInt(2),sm=BigInt(3),SW=BigInt(4);function dx(e,t={}){let r=iP("weierstrass",e,t),{Fp:i,Fn:n}=r,o=r.CURVE,{h:s,n:a}=o;qs(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!i.is0(o.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let l=uP(i,n);function u(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(N,L,I){let{x:z,y:P}=L.toAffine(),J=i.toBytes(z);if(Ru(I,"isCompressed"),I){u();let j=!i.isOdd(P);return Ut(lP(j),J)}else return Ut(Uint8Array.of(4),J,i.toBytes(P))}function p(N){De(N,void 0,"Point");let{publicKey:L,publicKeyUncompressed:I}=l,z=N.length,P=N[0],J=N.subarray(1);if(z===L&&(P===2||P===3)){let j=i.fromBytes(J);if(!i.isValid(j))throw Error("bad point: is not on curve, wrong x");let Q=g(j),E;try{E=i.sqrt(Q)}catch(C){let xe=C instanceof Error?": "+C.message:"";throw Error("bad point: is not on curve, sqrt error"+xe)}u();let ae=i.isOdd(E);if((P&1)===1!==ae)E=i.neg(E);return{x:j,y:E}}else if(z===I&&P===4){let j=i.BYTES,Q=i.fromBytes(J.subarray(0,j)),E=i.fromBytes(J.subarray(j,j*2));if(!S(Q,E))throw Error("bad point: is not on curve");return{x:Q,y:E}}else throw Error(`bad point: got length ${z}, expected compressed=${L} or uncompressed=${I}`)}let m=t.toBytes||f,b=t.fromBytes||p;function g(N){let L=i.sqr(N),I=i.mul(L,N);return i.add(i.add(I,i.mul(N,o.a)),o.b)}function S(N,L){let I=i.sqr(L),z=g(N);return i.eql(I,z)}if(!S(o.Gx,o.Gy))throw Error("bad curve params: generator point");let k=i.mul(i.pow(o.a,sm),SW),A=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(k,A)))throw Error("bad curve params: a or b");function R(N,L,I=!1){if(!i.isValid(L)||I&&i.is0(L))throw Error(`bad point coordinate ${N}`);return L}function D(N){if(!(N instanceof V))throw Error("Weierstrass Point expected")}function U(N){if(!c||!c.basises)throw Error("no endo");return bW(N,c.basises,n.ORDER)}let T=XS((N,L)=>{let{X:I,Y:z,Z:P}=N;if(i.eql(P,i.ONE))return{x:I,y:z};let J=N.is0();if(L==null)L=J?i.ONE:i.inv(P);let j=i.mul(I,L),Q=i.mul(z,L),E=i.mul(P,L);if(J)return{x:i.ZERO,y:i.ZERO};if(!i.eql(E,i.ONE))throw Error("invZ was invalid");return{x:j,y:Q}}),H=XS((N)=>{if(N.is0()){if(t.allowInfinityPoint&&!i.is0(N.Y))return;throw Error("bad point: ZERO")}let{x:L,y:I}=N.toAffine();if(!i.isValid(L)||!i.isValid(I))throw Error("bad point: x or y not field elements");if(!S(L,I))throw Error("bad point: equation left != right");if(!N.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function B(N,L,I,z,P){return I=new V(i.mul(I.X,N),I.Y,I.Z),L=Nu(z,L),I=Nu(P,I),L.add(I)}class V{static BASE=new V(o.Gx,o.Gy,i.ONE);static ZERO=new V(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(N,L,I){this.X=R("x",N),this.Y=R("y",L,!0),this.Z=R("z",I),Object.freeze(this)}static CURVE(){return o}static fromAffine(N){let{x:L,y:I}=N||{};if(!N||!i.isValid(L)||!i.isValid(I))throw Error("invalid affine point");if(N instanceof V)throw Error("projective point not allowed");if(i.is0(L)&&i.is0(I))return V.ZERO;return new V(L,I,i.ONE)}static fromBytes(N){let L=V.fromAffine(b(De(N,void 0,"point")));return L.assertValidity(),L}static fromHex(N){return V.fromBytes(Us(N))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(N=8,L=!0){if(K.createCache(this,N),!L)this.multiply(sm);return this}assertValidity(){H(this)}hasEvenY(){let{y:N}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(N)}equals(N){D(N);let{X:L,Y:I,Z:z}=this,{X:P,Y:J,Z:j}=N,Q=i.eql(i.mul(L,j),i.mul(P,z)),E=i.eql(i.mul(I,j),i.mul(J,z));return Q&&E}negate(){return new V(this.X,i.neg(this.Y),this.Z)}double(){let{a:N,b:L}=o,I=i.mul(L,sm),{X:z,Y:P,Z:J}=this,j=i.ZERO,Q=i.ZERO,E=i.ZERO,ae=i.mul(z,z),fe=i.mul(P,P),C=i.mul(J,J),xe=i.mul(z,P);return xe=i.add(xe,xe),E=i.mul(z,J),E=i.add(E,E),j=i.mul(N,E),Q=i.mul(I,C),Q=i.add(j,Q),j=i.sub(fe,Q),Q=i.add(fe,Q),Q=i.mul(j,Q),j=i.mul(xe,j),E=i.mul(I,E),C=i.mul(N,C),xe=i.sub(ae,C),xe=i.mul(N,xe),xe=i.add(xe,E),E=i.add(ae,ae),ae=i.add(E,ae),ae=i.add(ae,C),ae=i.mul(ae,xe),Q=i.add(Q,ae),C=i.mul(P,J),C=i.add(C,C),ae=i.mul(C,xe),j=i.sub(j,ae),E=i.mul(C,fe),E=i.add(E,E),E=i.add(E,E),new V(j,Q,E)}add(N){D(N);let{X:L,Y:I,Z:z}=this,{X:P,Y:J,Z:j}=N,Q=i.ZERO,E=i.ZERO,ae=i.ZERO,fe=o.a,C=i.mul(o.b,sm),xe=i.mul(L,P),Te=i.mul(I,J),Pe=i.mul(z,j),$e=i.add(L,I),_e=i.add(P,J);$e=i.mul($e,_e),_e=i.add(xe,Te),$e=i.sub($e,_e),_e=i.add(L,z);let We=i.add(P,j);return _e=i.mul(_e,We),We=i.add(xe,Pe),_e=i.sub(_e,We),We=i.add(I,z),Q=i.add(J,j),We=i.mul(We,Q),Q=i.add(Te,Pe),We=i.sub(We,Q),ae=i.mul(fe,_e),Q=i.mul(C,Pe),ae=i.add(Q,ae),Q=i.sub(Te,ae),ae=i.add(Te,ae),E=i.mul(Q,ae),Te=i.add(xe,xe),Te=i.add(Te,xe),Pe=i.mul(fe,Pe),_e=i.mul(C,_e),Te=i.add(Te,Pe),Pe=i.sub(xe,Pe),Pe=i.mul(fe,Pe),_e=i.add(_e,Pe),xe=i.mul(Te,_e),E=i.add(E,xe),xe=i.mul(We,_e),Q=i.mul($e,Q),Q=i.sub(Q,xe),xe=i.mul($e,Te),ae=i.mul(We,ae),ae=i.add(ae,xe),new V(Q,E,ae)}subtract(N){return this.add(N.negate())}is0(){return this.equals(V.ZERO)}multiply(N){let{endo:L}=t;if(!n.isValidNot0(N))throw Error("invalid scalar: out of range");let I,z,P=(J)=>K.cached(this,J,(j)=>sx(V,j));if(L){let{k1neg:J,k1:j,k2neg:Q,k2:E}=U(N),{p:ae,f:fe}=P(j),{p:C,f:xe}=P(E);z=fe.add(xe),I=B(L.beta,ae,C,J,Q)}else{let{p:J,f:j}=P(N);I=J,z=j}return sx(V,[I,z])[0]}multiplyUnsafe(N){let{endo:L}=t,I=this;if(!n.isValid(N))throw Error("invalid scalar: out of range");if(N===Bi||I.is0())return V.ZERO;if(N===uc)return I;if(K.hasCache(this))return this.multiply(N);if(L){let{k1neg:z,k1:P,k2neg:J,k2:j}=U(N),{p1:Q,p2:E}=nP(V,I,P,j);return B(L.beta,Q,E,z,J)}else return K.unsafe(I,N)}toAffine(N){return T(this,N)}isTorsionFree(){let{isTorsionFree:N}=t;if(s===uc)return!0;if(N)return N(V,this);return K.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:N}=t;if(s===uc)return this;if(N)return N(V,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(N=!0){return Ru(N,"isCompressed"),this.assertValidity(),m(V,this,N)}toHex(N=!0){return js(this.toBytes(N))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let te=n.BITS,K=new ax(V,t.endo?Math.ceil(te/2):te);return V.BASE.precompute(8),V}function lP(e){return Uint8Array.of(e?2:3)}function uP(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function xW(e,t={}){let{Fn:r}=e,i=t.randomBytes||_o,n=Object.assign(uP(e.Fp,r),{seed:rx(r.ORDER)});function o(m){try{let b=r.fromBytes(m);return r.isValidNot0(b)}catch(b){return!1}}function s(m,b){let{publicKey:g,publicKeyUncompressed:S}=n;try{let k=m.length;if(b===!0&&k!==g)return!1;if(b===!1&&k!==S)return!1;return!!e.fromBytes(m)}catch(k){return!1}}function a(m=i(n.seed)){return Q$(De(m,n.seed,"seed"),r.ORDER)}function c(m,b=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(b)}function l(m){let{secretKey:b,publicKey:g,publicKeyUncompressed:S}=n;if(!ic(m))return;if("_lengths"in r&&r._lengths||b===g)return;let k=De(m,void 0,"key").length;return k===g||k===S}function u(m,b,g=!0){if(l(m)===!0)throw Error("first arg must be private key");if(l(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(m);return e.fromBytes(b).multiply(S).toBytes(g)}let f={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=im(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:f,lengths:n})}function fx(e,t,r={}){yn(t),qs(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes||_o,n=r.hmac||((I,z)=>lc(t,I,z)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:f,utils:p,lengths:m}=xW(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*cP<o.ORDER;function S(I){let z=a>>uc;return I>z}function k(I,z){if(!s.isValidNot0(z))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return z}function A(){if(g)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function R(I,z){ux(z);let P=m.signature,J=z==="compact"?P:z==="recovered"?P+1:void 0;return De(I,J)}class D{r;s;recovery;constructor(I,z,P){if(this.r=k("r",I),this.s=k("s",z),P!=null){if(A(),![0,1,2,3].includes(P))throw Error("invalid recovery id");this.recovery=P}Object.freeze(this)}static fromBytes(I,z=b.format){R(I,z);let P;if(z==="der"){let{r:E,s:ae}=To.toSig(De(I));return new D(E,ae)}if(z==="recovered")P=I[0],z="compact",I=I.subarray(1);let J=m.signature/2,j=I.subarray(0,J),Q=I.subarray(J,J*2);return new D(s.fromBytes(j),s.fromBytes(Q),P)}static fromHex(I,z){return this.fromBytes(Us(I),z)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new D(this.r,this.s,I)}recoverPublicKey(I){let{r:z,s:P}=this,J=this.assertRecovery(),j=J===2||J===3?z+a:z;if(!o.isValid(j))throw Error("invalid recovery id: sig.r+curve.n != R.x");let Q=o.toBytes(j),E=e.fromBytes(Ut(lP((J&1)===0),Q)),ae=s.inv(j),fe=T(De(I,void 0,"msgHash")),C=s.create(-fe*ae),xe=s.create(P*ae),Te=e.BASE.multiplyUnsafe(C).add(E.multiplyUnsafe(xe));if(Te.is0())throw Error("invalid recovery: point at infinify");return Te.assertValidity(),Te}hasHighS(){return S(this.s)}toBytes(I=b.format){if(ux(I),I==="der")return Us(To.hexFromSig(this));let{r:z,s:P}=this,J=s.toBytes(z),j=s.toBytes(P);if(I==="recovered")return A(),Ut(Uint8Array.of(this.assertRecovery()),J,j);return Ut(J,j)}toHex(I){return js(this.toBytes(I))}}let U=r.bits2int||function(z){if(z.length>8192)throw Error("input is too large");let P=Eo(z),J=z.length*8-c;return J>0?P>>BigInt(J):P},T=r.bits2int_modN||function(z){return s.create(U(z))},H=Pu(c);function B(I){return $u("num < 2^"+c,I,Bi,H),s.toBytes(I)}function V(I,z){return De(I,void 0,"message"),z?De(t(I),void 0,"prehashed message"):I}function te(I,z,P){let{lowS:J,prehash:j,extraEntropy:Q}=lx(P,b);I=V(I,j);let E=T(I),ae=s.fromBytes(z);if(!s.isValidNot0(ae))throw Error("invalid private key");let fe=[B(ae),B(E)];if(Q!=null&&Q!==!1){let Pe=Q===!0?i(m.secretKey):Q;fe.push(De(Pe,void 0,"extraEntropy"))}let C=Ut(...fe),xe=E;function Te(Pe){let $e=U(Pe);if(!s.isValidNot0($e))return;let _e=s.inv($e),We=e.BASE.multiply($e).toAffine(),Le=s.create(We.x);if(Le===Bi)return;let Xe=s.create(_e*s.create(xe+Le*ae));if(Xe===Bi)return;let dt=(We.x===Le?0:2)|Number(We.y&uc),kt=Xe;if(J&&S(Xe))kt=s.neg(Xe),dt^=1;return new D(Le,kt,g?void 0:dt)}return{seed:C,k2sig:Te}}function K(I,z,P={}){let{seed:J,k2sig:j}=te(I,z,P);return j$(t.outputLen,s.BYTES,n)(J,j).toBytes(P.format)}function N(I,z,P,J={}){let{lowS:j,prehash:Q,format:E}=lx(J,b);if(P=De(P,void 0,"publicKey"),z=V(z,Q),!ic(I)){let ae=I instanceof D?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}R(I,E);try{let ae=D.fromBytes(I,E),fe=e.fromBytes(P);if(j&&ae.hasHighS())return!1;let{r:C,s:xe}=ae,Te=T(z),Pe=s.inv(xe),$e=s.create(Te*Pe),_e=s.create(C*Pe),We=e.BASE.multiplyUnsafe($e).add(fe.multiplyUnsafe(_e));if(We.is0())return!1;return s.create(We.x)===C}catch(ae){return!1}}function L(I,z,P={}){let{prehash:J}=lx(P,b);return z=V(z,J),D.fromBytes(I,"recovered").recoverPublicKey(z).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:f,utils:p,lengths:m,Point:e,sign:K,verify:N,recoverPublicKey:L,Signature:D,hash:t})}function dP(e,t,r){return e&t^~e&r}function fP(e,t,r){return e&t^e&r^t&r}class am{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,i){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=em(this.buffer)}update(e){Li(this),De(e);let{view:t,buffer:r,blockLen:i}=this,n=e.length;for(let o=0;o<n;){let s=Math.min(i-this.pos,n-o);if(s===i){let a=em(e);for(;i<=n-o;o+=i)this.process(a,o);continue}if(r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){Li(this),Yp(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Mr(this.buffer.subarray(o)),this.padOffset>i-o)this.process(r,0),o=0;for(let u=o;u<i;u++)t[u]=0;r.setBigUint64(i-8,BigInt(this.length*8),n),this.process(r,0);let s=em(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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:i,finished:n,destroyed:o,pos:s}=this;if(e.destroyed=o,e.finished=n,e.length=i,e.pos=s,i%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var ji=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var sr=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var cm=BigInt(4294967295),pP=BigInt(32);function wW(e,t=!1){if(t)return{h:Number(e&cm),l:Number(e>>pP&cm)};return{h:Number(e>>pP&cm)|0,l:Number(e&cm)|0}}function lm(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=wW(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var px=(e,t,r)=>e>>>r,mx=(e,t,r)=>e<<32-r|t>>>r,Fs=(e,t,r)=>e>>>r|t<<32-r,Hs=(e,t,r)=>e<<32-r|t>>>r,Lu=(e,t,r)=>e<<64-r|t>>>r-32,Bu=(e,t,r)=>e>>>r-32|t<<64-r;var mP=(e,t,r)=>e<<r|t>>>32-r,hP=(e,t,r)=>t<<r|e>>>32-r,gP=(e,t,r)=>t<<r-32|e>>>64-r,yP=(e,t,r)=>e<<r-32|t>>>64-r;function oi(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var bP=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),SP=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,xP=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),wP=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,vP=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),_P=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var _W=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]),Ro=new Uint32Array(64);class kP extends am{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:i,E:n,F:o,G:s,H:a}=this;return[e,t,r,i,n,o,s,a]}set(e,t,r,i,n,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)Ro[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let f=Ro[u-15],p=Ro[u-2],m=Pn(f,7)^Pn(f,18)^f>>>3,b=Pn(p,17)^Pn(p,19)^p>>>10;Ro[u]=b+Ro[u-7]+m+Ro[u-16]|0}let{A:r,B:i,C:n,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){let f=Pn(s,6)^Pn(s,11)^Pn(s,25),p=l+f+dP(s,a,c)+_W[u]+Ro[u]|0,b=(Pn(r,2)^Pn(r,13)^Pn(r,22))+fP(r,i,n)|0;l=c,c=a,a=s,s=o+p|0,o=n,n=i,i=r,r=p+b|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,n,o,s,a,c,l)}roundClean(){Mr(Ro)}destroy(){this.set(0,0,0,0,0,0,0,0),Mr(this.buffer)}}class EP extends kP{A=ji[0]|0;B=ji[1]|0;C=ji[2]|0;D=ji[3]|0;E=ji[4]|0;F=ji[5]|0;G=ji[6]|0;H=ji[7]|0;constructor(){super(32)}}var IP=(()=>lm(["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))))(),kW=(()=>IP[0])(),EW=(()=>IP[1])(),Co=new Uint32Array(80),Oo=new Uint32Array(80);class AP extends am{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:u,Fl:f,Gh:p,Gl:m,Hh:b,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,f,p,m,b,g]}set(e,t,r,i,n,o,s,a,c,l,u,f,p,m,b,g){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=n|0,this.Cl=o|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=f|0,this.Gh=p|0,this.Gl=m|0,this.Hh=b|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)Co[A]=e.getUint32(t),Oo[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let R=Co[A-15]|0,D=Oo[A-15]|0,U=Fs(R,D,1)^Fs(R,D,8)^px(R,D,7),T=Hs(R,D,1)^Hs(R,D,8)^mx(R,D,7),H=Co[A-2]|0,B=Oo[A-2]|0,V=Fs(H,B,19)^Lu(H,B,61)^px(H,B,6),te=Hs(H,B,19)^Bu(H,B,61)^mx(H,B,6),K=xP(T,te,Oo[A-7],Oo[A-16]),N=wP(K,U,V,Co[A-7],Co[A-16]);Co[A]=N|0,Oo[A]=K|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:f,Fh:p,Fl:m,Gh:b,Gl:g,Hh:S,Hl:k}=this;for(let A=0;A<80;A++){let R=Fs(u,f,14)^Fs(u,f,18)^Lu(u,f,41),D=Hs(u,f,14)^Hs(u,f,18)^Bu(u,f,41),U=u&p^~u&b,T=f&m^~f&g,H=vP(k,D,T,EW[A],Oo[A]),B=_P(H,S,R,U,kW[A],Co[A]),V=H|0,te=Fs(r,i,28)^Lu(r,i,34)^Lu(r,i,39),K=Hs(r,i,28)^Bu(r,i,34)^Bu(r,i,39),N=r&n^r&s^n&s,L=i&o^i&a^o&a;S=b|0,k=g|0,b=p|0,g=m|0,p=u|0,m=f|0,{h:u,l:f}=oi(c|0,l|0,B|0,V|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=bP(V,K,L);r=SP(I,B,te,N),i=I|0}({h:r,l:i}=oi(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=oi(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=oi(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=oi(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:f}=oi(this.Eh|0,this.El|0,u|0,f|0),{h:p,l:m}=oi(this.Fh|0,this.Fl|0,p|0,m|0),{h:b,l:g}=oi(this.Gh|0,this.Gl|0,b|0,g|0),{h:S,l:k}=oi(this.Hh|0,this.Hl|0,S|0,k|0),this.set(r,i,n,o,s,a,c,l,u,f,p,m,b,g,S,k)}roundClean(){Mr(Co,Oo)}destroy(){Mr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class TP extends AP{Ah=sr[0]|0;Al=sr[1]|0;Bh=sr[2]|0;Bl=sr[3]|0;Ch=sr[4]|0;Cl=sr[5]|0;Dh=sr[6]|0;Dl=sr[7]|0;Eh=sr[8]|0;El=sr[9]|0;Fh=sr[10]|0;Fl=sr[11]|0;Gh=sr[12]|0;Gl=sr[13]|0;Hh=sr[14]|0;Hl=sr[15]|0;constructor(){super(48)}}var um=oc(()=>new EP,ko(1));var RP=oc(()=>new TP,ko(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var IW=BigInt(1),CP=BigInt(2),AW=BigInt(3),TW=BigInt(5),y_e=BigInt(8),OP=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function RW(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=OP,a=e*e%o*e%o,c=bn(a,CP,o)*a%o,l=bn(c,IW,o)*e%o,u=bn(l,TW,o)*l%o,f=bn(u,t,o)*u%o,p=bn(f,r,o)*f%o,m=bn(p,i,o)*p%o,b=bn(m,n,o)*m%o,g=bn(b,n,o)*m%o,S=bn(g,t,o)*u%o;return{pow_p_5_8:bn(S,CP,o)*e%o,b2:a}}function CW(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var $P=(()=>{let e=OP;return oP({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=RW(t);return Rr(bn(r,AW,e)*i,e)},adjustScalarBytes:CW})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var OW=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),$W=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var PW=dx(OW),hx=fx(PW,um);var zW=dx($W),PP=fx(zW,RP);function NP(e,t,r){if(yn(e),r===void 0)r=new Uint8Array(e.outputLen);return lc(e,r,t)}var gx=Uint8Array.of(0),zP=Uint8Array.of();function DP(e,t,r,i=32){yn(e),Qt(i,"length");let n=e.outputLen;if(i>255*n)throw Error("Length must be <= 255*HashLen");let o=Math.ceil(i/n);if(r===void 0)r=zP;else De(r,void 0,"info");let s=new Uint8Array(o*n),a=lc.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)gx[0]=u+1,c.update(u===0?zP:l).update(r).update(gx).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Mr(l,gx),s.slice(0,i)}var NW=BigInt(0),ju=BigInt(1),DW=BigInt(2),LW=BigInt(7),BW=BigInt(256),jW=BigInt(113),jP=[],UP=[],qP=[];for(let e=0,t=ju,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],jP.push(2*(5*i+r)),UP.push((e+1)*(e+2)/2%64);let n=NW;for(let o=0;o<7;o++)if(t=(t<<ju^(t>>LW)*jW)%BW,t&DW)n^=ju<<(ju<<BigInt(o))-ju;qP.push(n)}var ZP=lm(qP,!0),UW=ZP[0],qW=ZP[1],LP=(e,t,r)=>r>32?gP(e,t,r):mP(e,t,r),BP=(e,t,r)=>r>32?yP(e,t,r):hP(e,t,r);function ZW(e,t=24){let r=new Uint32Array(10);for(let i=24-t;i<24;i++){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,c=(s+2)%10,l=r[c],u=r[c+1],f=LP(l,u,1)^r[a],p=BP(l,u,1)^r[a+1];for(let m=0;m<50;m+=10)e[s+m]^=f,e[s+m+1]^=p}let n=e[2],o=e[3];for(let s=0;s<24;s++){let a=UP[s],c=LP(n,o,a),l=BP(n,o,a),u=jP[s];n=e[u],o=e[u+1],e[u]=c,e[u+1]=l}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]^=UW[i],e[1]^=qW[i]}Mr(r)}class dm{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,i=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=n,Qt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Xp(this.state)}clone(){return this._cloneInto()}keccak(){WS(this.state32),ZW(this.state32,this.rounds),WS(this.state32),this.posOut=0,this.pos=0}update(e){Li(this),De(e);let{blockLen:t,state:r}=this,i=e.length;for(let n=0;n<i;){let o=Math.min(t-this.pos,i-n);for(let s=0;s<o;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:i}=this;if(e[r]^=t,(t&128)!==0&&r===i-1)this.keccak();e[i-1]^=128,this.keccak()}writeInto(e){Li(this,!1),De(e),this.finish();let t=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){if(this.posOut>=r)this.keccak();let o=Math.min(r-this.posOut,n-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Qt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Yp(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,Mr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||=new dm(t,r,i,o,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=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}var MP=(e,t,r,i={})=>oc(()=>new dm(t,e,r),i);var Ks=MP(6,136,32,ko(8));var FP=MP(6,72,64,ko(10));var HP=(e,t,r,i={})=>oc((n={})=>new dm(t,e,n.dkLen===void 0?r:n.dkLen,!0),i),KP=HP(31,168,16,ko(11)),si=HP(31,136,32,ko(12));function yx(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function VP(e){return yx(e),(e&e-1)===0&&e!==0}function bx(e,t){yx(e);let r=0;for(let i=0;i<t;i++,e>>>=1)r=r<<1|e&1;return r}function WP(e){return yx(e),31-Math.clz32(e)}function JP(e){let t=e.length;if(t<2||!VP(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=WP(t);for(let i=0;i<t;i++){let n=bx(i,r);if(i<n){let o=e[i];e[i]=e[n],e[n]=o}}return e}var Sx=(e,t)=>{let{N:r,roots:i,dit:n,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,c=WP(r);if(!VP(r))throw Error("FFT: Polynomial size should be power of two");let l=n!==o;return(u)=>{if(u.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)JP(u);for(let f=0,p=1;f<c-s;f++){let m=n?f+1+s:c-f,b=1<<m,g=b>>1,S=r>>m;for(let k=0;k<r;k+=b)for(let A=0,R=p++;A<g;A++){let D=o?n?r-R:R:A*S,U=k+A,T=k+A+g,H=i[D],B=u[T],V=u[U];if(l){let te=e.mul(B,H);u[U]=e.add(V,te),u[T]=e.sub(V,te)}else if(o)u[U]=e.add(B,V),u[T]=e.mul(e.sub(B,V),H);else u[U]=e.add(V,B),u[T]=e.mul(e.sub(V,B),H)}}if(!n&&a)JP(u);return u}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var ai=_o;function fm(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function GP(e){return Uint8Array.from(e)}function Js(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,i=t.reduce((n,o)=>n+r(o),0);return{bytesLen:i,encode:(n)=>{let o=new Uint8Array(i);for(let s=0,a=0;s<t.length;s++){let c=t[s],l=r(c),u=typeof c==="number"?n[s]:c.encode(n[s]);if(De(u,l,e),o.set(u,a),typeof c!=="number")u.fill(0);a+=l}return o},decode:(n)=>{De(n,i,e);let o=[];for(let s of t){let a=r(s),c=n.subarray(0,a);o.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return o}}}function pm(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(i)=>{if(i.length!==t)throw Error(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let o=0,s=0;o<i.length;o++){let a=e.encode(i[o]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(i)=>{De(i,r);let n=[];for(let o=0;o<i.length;o+=e.bytesLen)n.push(e.decode(i.subarray(o,o+e.bytesLen)));return n}}}function Ht(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function xx(e){return(1<<e)-1}var $_e=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var QP=(e)=>{let{newPoly:t,N:r,Q:i,F:n,ROOT_OF_UNITY:o,brvBits:s,isKyber:a}=e,c=(A,R=i)=>{let D=A%R|0;return(D>=0?D|0:R+D|0)|0},l=(A,R=i)=>{let D=c(A,R)|0;return(D>R>>1?D-R|0:D)|0};function u(){let A=t(r);for(let R=0;R<r;R++){let D=bx(R,s),U=BigInt(o)**BigInt(D)%BigInt(i);A[R]=Number(U)|0}return A}let f=u(),p={add:(A,R)=>c((A|0)+(R|0))|0,sub:(A,R)=>c((A|0)-(R|0))|0,mul:(A,R)=>c((A|0)*(R|0))|0,inv:(A)=>{throw Error("not implemented")}},m={N:r,roots:f,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=Sx(p,{dit:!1,...m}),g=Sx(p,{dit:!0,...m});return{mod:c,smod:l,nttZetas:f,NTT:{encode:(A)=>b(A),decode:(A)=>{g(A);for(let R=0;R<A.length;R++)A[R]=c(n*A[R]);return A}},bitsCoder:(A,R)=>{let D=xx(A),U=A*(r/8);return{bytesLen:U,encode:(T)=>{let H=new Uint8Array(U);for(let B=0,V=0,te=0,K=0;B<T.length;B++){V|=(R.encode(T[B])&D)<<te,te+=A;for(;te>=8;te-=8,V>>=8)H[K++]=V&xx(te)}return H},decode:(T)=>{let H=t(r);for(let B=0,V=0,te=0,K=0;B<T.length;B++){V|=T[B]<<te,te+=8;for(;te>=A;te-=A,V>>=A)H[K++]=R.decode(V&D)}return H}}}}},MW=(e)=>(t,r)=>{if(!r)r=e.blockLen;let i=new Uint8Array(t.length+2);i.set(t);let n=t.length,o=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(i[n+0]=l,i[n+1]=u,s.destroy(),s=e.create({}).update(i),a++,()=>(c++,s.xofInto(o))),clean:()=>{s.destroy(),Ht(o,i)}}},YP=MW(KP);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Sr=256,Ui=3329,FW=3303,HW=17,{mod:Zu,nttZetas:KW,NTT:Vs,bitsCoder:JW}=QP({N:Sr,Q:Ui,F:FW,ROOT_OF_UNITY:HW,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),wx={512:{N:Sr,Q:Ui,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:Sr,Q:Ui,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:Sr,Q:Ui,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},VW=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Ui/2)/Ui,decode:(r)=>r*Ui+t>>>e}},Uu=(e)=>JW(e,VW(e));function Ws(e,t){for(let r=0;r<Sr;r++)e[r]=Zu(e[r]+t[r])}function WW(e,t){for(let r=0;r<Sr;r++)e[r]=Zu(e[r]-t[r])}function GW(e,t,r,i,n){let o=Zu(t*i*n+e*r),s=Zu(e*i+t*r);return{c0:o,c1:s}}function mm(e,t){for(let r=0;r<Sr/2;r++){let i=KW[64+(r>>1)];if(r&1)i=-i;let{c0:n,c1:o}=GW(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],i);e[2*r+0]=n,e[2*r+1]=o}return e}function XP(e){let t=new Uint16Array(Sr);for(let r=0;r<Sr;){let i=e();if(i.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<Sr&&n+3<=i.length;n+=3){let o=(i[n+0]>>0|i[n+1]<<8)&4095,s=(i[n+1]>>4|i[n+2]<<4)&4095;if(o<Ui)t[r++]=o;if(r<Sr&&s<Ui)t[r++]=s}}return t}function qu(e,t,r,i){let n=e(i*Sr/4,t,r),o=new Uint16Array(Sr),s=Xp(n),a=0;for(let c=0,l=0,u=0,f=0;c<s.length;c++){let p=s[c];for(let m=0;m<32;m++)if(u+=p&1,p>>=1,a+=1,a===i)f=u,u=0;else if(a===2*i)o[l++]=Zu(f-u),u=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return o}var QW=(e)=>{let{K:t,PRF:r,XOF:i,HASH512:n,ETA1:o,ETA2:s,du:a,dv:c}=e,l=Uu(1),u=Uu(c),f=Uu(a),p=Js("publicKey",pm(Uu(12),t),32),m=pm(Uu(12),t),b=Js("ciphertext",pm(f,t),u),g=Js("seed",32,32);return{secretCoder:m,lengths:{secretKey:m.bytesLen,publicKey:p.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{De(S,32,"seed");let k=new Uint8Array(33);k.set(S),k[32]=t;let A=n(k),[R,D]=g.decode(A),U=[],T=[];for(let V=0;V<t;V++)U.push(Vs.encode(qu(r,D,V,o)));let H=i(R);for(let V=0;V<t;V++){let te=Vs.encode(qu(r,D,t+V,o));for(let K=0;K<t;K++){let N=XP(H.get(K,V));Ws(te,mm(N,U[K]))}T.push(te)}H.clean();let B={publicKey:p.encode([T,R]),secretKey:m.encode(U)};return Ht(R,D,U,T,k,A),B},encrypt:(S,k,A)=>{let[R,D]=p.decode(S),U=[];for(let K=0;K<t;K++)U.push(Vs.encode(qu(r,A,K,o)));let T=i(D),H=new Uint16Array(Sr),B=[];for(let K=0;K<t;K++){let N=qu(r,A,t+K,s),L=new Uint16Array(Sr);for(let I=0;I<t;I++){let z=XP(T.get(K,I));Ws(L,mm(z,U[I]))}Ws(N,Vs.decode(L)),B.push(N),Ws(H,mm(R[K],U[K])),Ht(L)}T.clean();let V=qu(r,A,2*t,s);Ws(V,Vs.decode(H));let te=l.decode(k);return Ws(te,V),Ht(R,U,H,V),b.encode([B,te])},decrypt:(S,k)=>{let[A,R]=b.decode(S),D=m.decode(k),U=new Uint16Array(Sr);for(let T=0;T<t;T++)Ws(U,mm(D[T],Vs.encode(A[T])));return WW(R,Vs.decode(U)),Ht(U,D,A),l.encode(R)}}};function vx(e){let t=QW(e),{HASH256:r,HASH512:i,KDF:n}=e,{secretCoder:o,lengths:s}=t,a=Js("secretKey",s.secretKey,s.publicKey,32,32),c=32,l=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(u=ai(64))=>{De(u,64,"seed");let{publicKey:f,secretKey:p}=t.keygen(u.subarray(0,32)),m=r(f),b=a.encode([p,f,m,u.subarray(32)]);return Ht(p,m),{publicKey:f,secretKey:b}},getPublicKey:(u)=>{let[f,p,m,b]=a.decode(u);return Uint8Array.from(p)},encapsulate:(u,f=ai(32))=>{De(u,s.publicKey,"publicKey"),De(f,32,"message");let p=u.subarray(0,384*e.K),m=o.encode(o.decode(GP(p)));if(!fm(m,p))throw Ht(m),Error("ML-KEM.encapsulate: wrong publicKey modulus");Ht(m);let b=i.create().update(f).update(r(u)).digest(),g=t.encrypt(u,f,b.subarray(32,64));return Ht(b.subarray(32)),{cipherText:g,sharedSecret:b.subarray(0,32)}},decapsulate:(u,f)=>{De(f,a.bytesLen,"secretKey"),De(u,s.cipherText,"cipherText");let p=a.bytesLen-96,m=p+32,b=r(f.subarray(p/2,m));if(!fm(b,f.subarray(m,m+32)))throw Error("invalid secretKey: hash check failed");let[g,S,k,A]=a.decode(f),R=t.decrypt(u,g),D=i.create().update(R).update(k).digest(),U=D.subarray(0,32),T=t.encrypt(S,R,D.subarray(32,64)),H=fm(u,T),B=n.create({dkLen:32}).update(A).update(u).digest();return Ht(R,T,!H?U:B),H?U:B}}}function YW(e,t,r){return si.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var _x={HASH256:Ks,HASH512:FP,KDF:si,XOF:YP,PRF:YW},M_e=vx({..._x,...wx[512]}),Mu=vx({..._x,...wx[768]}),ez=vx({..._x,...wx[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function XW(e,t=!1){let{lengths:r,keygen:i}=e;if(t){let o=e.Point.Fn;if(!o)throw Error("No Point.Fn");i=(s=ai(r.seed))=>{De(s,r.seed,"seed");let a=o.isLE?Io(s):Eo(s),c=o.toBytes(o.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:i,getPublicKey:(n)=>e.getPublicKey(n)}}function kx(e,t=!1){let r=XW(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(i,n=ai(e.lengths.seed)){let o=this.keygen(n).secretKey,s=this.decapsulate(i,o),a=e.getPublicKey(o);return Ht(o),{sharedSecret:s,cipherText:a}},decapsulate(i,n){let o=e.getSharedSecret(n,i);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function Fu(e,t){return Js(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function Ex(e){return(t,r)=>e(t,{dkLen:r})}function eG(e,t,...r){let i=Fu(r,"seed"),n=Fu(r,"publicKey");if(e===void 0)e=i.bytesLen;Qt(e);function o(s){De(s,e);let a=i.decode(t(s,i.bytesLen)),c=r.map((f,p)=>f.keygen(a[p])),l=c.map((f)=>f.secretKey),u=c.map((f)=>f.publicKey);return{secretKey:l,publicKey:u}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=ai(e)){let{publicKey:a,secretKey:c}=o(s),l=n.encode(a);return Ht(a),Ht(c),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function hm(e,t,r,i,...n){let o=eG(e,r,...n),s=Fu(n,"cipherText"),a=Fu(n,"publicKey"),c=Fu(n,"msg");if(t===void 0)t=c.bytesLen;return Qt(t),{lengths:{...o.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,u=ai(c.bytesLen)){let f=a.decode(l),p=c.decode(u),m=n.map((k,A)=>k.encapsulate(f[A],p[A])),b=m.map((k)=>k.sharedSecret),g=m.map((k)=>k.cipherText),S={sharedSecret:i(f,g,b),cipherText:s.encode(g)};return Ht(b,g),S},decapsulate(l,u){let f=s.decode(l),{publicKey:p,secretKey:m}=o.expandDecapsulationKey(u),b=n.map((g,S)=>g.decapsulate(f[S],m[S]));return i(p,f,b)}}}function tz(e,t,r,i,n){return yn(i),yn(n),hm(32,32,Ex(i),(o,s,a)=>n(Ut(a[0],a[1],s[1],o[1],Ao(e))),t,r)}var eke=tz("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Mu,kx(hx,!0),si,Ks),tke=tz("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",ez,kx(PP,!0),si,Ks);function tG(e,t,r,i,n){return yn(i),yn(n),hm(32,32,Ex(i),(o,s,a)=>{let c=Ut(a[0],a[1],s[0],o[0],s[1],o[1],Ao(e)),l=32,u=Ut(Ao("hybrid_prk"),c),f=NP(n,u),p=Ut(sc(32,2),Ao("shared_secret"),Ao("")),m=DP(n,f,p,32);return Ht(f,p,u,c),m},t,r)}var rz=kx($P),rke=tG("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Mu,rz,si,um),rG=(()=>hm(32,32,Ex(si),(e,t,r)=>Ks(Ut(r[0],r[1],t[1],e[1],Ao("\\.//^\\"))),Mu,rz))();function nG(e,t,r,i){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function o(s){let a;for(let u=0,f=t;;u=f,f+=t){if(f>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(u,f),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),l=e.getPublicKey(c,!1);return{secretKey:c,publicKey:l}}return{lengths:{secretKey:t,publicKey:r,seed:i,msg:i,cipherText:r},keygen(s=ai(i)){return De(s,i,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=ai(i)){De(a,i,"rand");let{secretKey:c}=o(a),l=this.decapsulate(s,c),u=e.getPublicKey(c,!1);return Ht(c),{sharedSecret:l,cipherText:u}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function iG(e,t,r,i){let{secretKey:n,publicKeyUncompressed:o}=r.lengths;if(!n||!o)throw Error("wrong curve");let s=nG(r,n,o,i),a=64,c=a+i;return hm(32,32,(l)=>{De(l,32);let u=si(l,{dkLen:c}),f=u.subarray(0,a),p=u.subarray(a,c);return Ut(f,p)},(l,u,f)=>Ks(Ut(f[0],f[1],u[1],l[1],Ao(e))),t,s)}var oG=(()=>iG("MLKEM768-P256",Mu,hx,128))();var gm=rG,nz=oG;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ft=(e,t,r)=>nr(e,t,r),Ax=Pt,dc=Up,ar=(...e)=>CS(...e),fc=(e)=>wu(e),pc=AS,mc=(e)=>Pi(e),bm=BigInt(0),Ix=BigInt(1);function qi(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function Sm(e){if(typeof e==="bigint"){if(!ym(e))throw RangeError("positive bigint expected, got "+e)}else Ax(e);return e}function ci(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 Hu(e){let t=Sm(e).toString(16);return t.length&1?"0"+t:t}function iz(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?bm:BigInt("0x"+e)}function Gs(e){return iz(Up(e))}function zn(e){return iz(Up($o(nr(e)).reverse()))}function xm(e,t){if(Pt(t),t===0)throw RangeError("zero length");e=Sm(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return wu(r.padStart(t*2,"0"))}function Ku(e,t){return xm(e,t).reverse()}function oz(e,t){if(e=ft(e),t=ft(t),e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function $o(e){return Uint8Array.from(ft(e))}function wm(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}var ym=(e)=>typeof e==="bigint"&&bm<=e;function sG(e,t,r){return ym(e)&&ym(t)&&ym(r)&&t<=e&&e<r}function Zi(e,t,r,i){if(!sG(t,r,i))throw RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function hc(e){if(e<bm)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>bm;e>>=Ix,t+=1);return t}var Ju=(e)=>(Ix<<BigInt(e))-Ix;function sz(e,t,r){if(Pt(e,"hashLen"),Pt(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let i=(S)=>new Uint8Array(S),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,f=()=>{c.fill(1),l.fill(0),u=0},p=(...S)=>r(l,ar(c,...S)),m=(S=n)=>{if(l=p(o,S),c=p(),S.length===0)return;l=p(s,S),c=p()},b=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let S=0,k=[];while(S<t){c=p();let A=c.slice();k.push(A),S+=c.length}return ar(...k)};return(S,k)=>{f(),m(S);let A=void 0;while((A=k(b()))===void 0)m();return f(),A}}function Sn(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function i(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw TypeError(`param "${o}" is invalid: expected own property`);let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}let n=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));n(t,!1),n(r,!0)}var Tx=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var cr=BigInt(0),Tt=BigInt(1),Qs=BigInt(2),uz=BigInt(3),dz=BigInt(4),fz=BigInt(5),aG=BigInt(7),pz=BigInt(8),cG=BigInt(9),mz=BigInt(16);function xt(e,t){if(t<=cr)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=cr?r:t+r}function xn(e,t,r){if(t<cr)throw Error("pow2: expected non-negative exponent, got "+t);let i=e;while(t-- >cr)i*=i,i%=r;return i}function az(e,t){if(e===cr)throw Error("invert: expected non-zero number");if(t<=cr)throw Error("invert: expected positive modulus, got "+t);let r=xt(e,t),i=t,n=cr,o=Tt,s=Tt,a=cr;while(r!==cr){let l=i/r,u=i-r*l,f=n-s*l,p=o-a*l;i=r,r=u,n=s,o=a,s=f,a=p}if(i!==Tt)throw Error("invert: does not exist");return xt(n,t)}function Rx(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw Error("Cannot find square root")}function hz(e,t){let r=e,i=(r.ORDER+Tt)/dz,n=r.pow(t,i);return Rx(r,n,t),n}function lG(e,t){let r=e,i=(r.ORDER-fz)/pz,n=r.mul(t,Qs),o=r.pow(n,i),s=r.mul(t,o),a=r.mul(r.mul(s,Qs),o),c=r.mul(s,r.sub(a,r.ONE));return Rx(r,c,t),c}function uG(e){let t=vm(e),r=gz(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+aG)/mz;return(a,c)=>{let l=a,u=l.pow(c,s),f=l.mul(u,i),p=l.mul(u,n),m=l.mul(u,o),b=l.eql(l.sqr(f),c),g=l.eql(l.sqr(p),c);u=l.cmov(u,f,b),f=l.cmov(m,p,g);let S=l.eql(l.sqr(f),c),k=l.cmov(u,f,S);return Rx(l,k,c),k}}function gz(e){if(e<uz)throw Error("sqrt is not defined for small field");let t=e-Tt,r=0;while(t%Qs===cr)t/=Qs,r++;let i=Qs,n=vm(e);while(cz(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return hz;let o=n.pow(i,t),s=(t+Tt)/Qs;return function(c,l){let u=c;if(u.is0(l))return l;if(cz(u,l)!==1)throw Error("Cannot find square root");let f=r,p=u.mul(u.ONE,o),m=u.pow(l,t),b=u.pow(l,s);while(!u.eql(m,u.ONE)){if(u.is0(m))return u.ZERO;let g=1,S=u.sqr(m);while(!u.eql(S,u.ONE))if(g++,S=u.sqr(S),g===f)throw Error("Cannot find square root");let k=Tt<<BigInt(f-g-1),A=u.pow(p,k);f=g,p=u.sqr(A),m=u.mul(m,p),b=u.mul(b,A)}return b}}function dG(e){if(e%dz===uz)return hz;if(e%pz===fz)return lG;if(e%mz===cG)return uG(e);return gz(e)}var Mi=(e,t)=>(xt(e,t)&Tt)===Tt,fG=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Cx(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=fG.reduce((i,n)=>(i[n]="function",i),t);if(Sn(e,r),ci(e.BYTES,"BYTES"),ci(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Tt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function pG(e,t,r){let i=e;if(r<cr)throw Error("invalid exponent, negatives unsupported");if(r===cr)return i.ONE;if(r===Tt)return t;let n=i.ONE,o=t;while(r>cr){if(r&Tt)n=i.mul(n,o);o=i.sqr(o),r>>=Tt}return n}function Vu(e,t,r=!1){let i=e,n=Array(t.length).fill(r?i.ZERO:void 0),o=t.reduce((a,c,l)=>{if(i.is0(c))return a;return n[l]=a,i.mul(a,c)},i.ONE),s=i.inv(o);return t.reduceRight((a,c,l)=>{if(i.is0(c))return a;return n[l]=i.mul(a,n[l]),i.mul(a,c)},s),n}function cz(e,t){let r=e,i=(r.ORDER-Tt)/Qs,n=r.pow(t,i),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!a)throw Error("invalid Legendre symbol result");return o?1:s?0:-1}function mG(e,t){if(t!==void 0)Ax(t);if(e<=cr)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=hc(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let i=t!==void 0?t:r,n=Math.ceil(i/8);return{nBitLength:i,nByteLength:n}}var lz=new WeakMap;class Ox{ORDER;BITS;BYTES;isLE;ZERO=cr;ONE=Tt;_lengths;_mod;constructor(e,t={}){if(e<=Tt)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:i,nByteLength:n}=mG(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=n,Object.freeze(this)}create(e){return xt(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return cr<=e&&e<this.ORDER}is0(e){return e===cr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Tt)===Tt}neg(e){return xt(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return xt(e*e,this.ORDER)}add(e,t){return xt(e+t,this.ORDER)}sub(e,t){return xt(e-t,this.ORDER)}mul(e,t){return xt(e*t,this.ORDER)}pow(e,t){return pG(this,e,t)}div(e,t){return xt(e*az(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 az(e,this.ORDER)}sqrt(e){let t=lz.get(this);if(!t)lz.set(this,t=dG(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?Ku(e,this.BYTES):xm(e,this.BYTES)}fromBytes(e,t=!1){ft(e);let{_lengths:r,BYTES:i,isLE:n,ORDER:o,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>i)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(i);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==i)throw Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let a=n?zn(e):Gs(e);if(s)a=xt(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Vu(this,e)}cmov(e,t,r){return qi(r,"condition"),r?t:e}}Object.freeze(Ox.prototype);function vm(e,t={}){return new Ox(e,t)}function yz(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=Tt)throw Error("field order must be greater than 1");let t=hc(e-Tt);return Math.ceil(t/8)}function $x(e){let t=yz(e);return t+Math.ceil(t/2)}function bz(e,t,r=!1){ft(e);let i=e.length,n=yz(t),o=Math.max($x(t),16);if(i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?zn(e):Gs(e),a=xt(s,t-Tt)+Tt;return r?Ku(a,n):xm(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gc=BigInt(0),Ys=BigInt(1);function Wu(e,t){let r=t.negate();return e?r:t}function Xs(e,t){let r=Vu(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function vz(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function Px(e,t){vz(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Ju(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function Sz(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>i)a-=o,c+=Ys;let l=t*i,u=l+Math.abs(a)-1,f=a===0,p=a<0,m=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:p,isNegF:m,offsetF:l}}var zx=new WeakMap,_z=new WeakMap;function Nx(e){return _z.get(e)||1}function xz(e){if(e!==gc)throw Error("invalid wNAF")}class Gu{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 i=e;while(t>gc){if(t&Ys)r=r.add(i);i=i.double(),t>>=Ys}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=Px(t,this.bits),n=[],o=e,s=o;for(let a=0;a<r;a++){s=o,n.push(s);for(let c=1;c<i;c++)s=s.add(o),n.push(s);o=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let i=this.ZERO,n=this.BASE,o=Px(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:f,offsetF:p}=Sz(r,s,o);if(r=a,l)n=n.add(Wu(f,t[p]));else i=i.add(Wu(u,t[c]))}return xz(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=Px(e,this.bits);for(let o=0;o<n.windows;o++){if(r===gc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=Sz(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return xz(r),i}getPrecomputes(e,t,r){let i=zx.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);zx.set(t,i)}}return i}cached(e,t,r){let i=Nx(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=Nx(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){vz(t,this.bits),_z.set(e,t),zx.delete(e)}hasCache(e){return Nx(e)!==1}}function kz(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>gc||i>gc){if(r&Ys)o=o.add(n);if(i&Ys)s=s.add(n);n=n.double(),r>>=Ys,i>>=Ys}return{p1:o,p2:s}}function wz(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Cx(t),t}else return vm(e,{isLE:r})}function _m(e,t,r={},i){if(i===void 0)i=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l==="bigint"&&l>gc))throw Error(`CURVE.${c} must be positive bigint`)}let n=wz(t.p,r.Fp,i),o=wz(t.n,r.Fn,i),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:o}}function Qu(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}function Yu(e,t){if(ci(e),ci(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 i=t-1;i>=0;i--)r[i]=e&255,e>>>=8;return new Uint8Array(r)}function hG(e,t){let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]^t[i];return r}function gG(e){if(!pc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?wm(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function Dx(e,t,r,i){if(ft(e),ci(r),t=gG(t),t.length>255)t=i(ar(wm("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:o}=i,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=ar(t,Yu(t.length,1)),c=new Uint8Array(o),l=Yu(r,2),u=Array(s),f=i(ar(c,e,l,Yu(0,1),a));u[0]=i(ar(f,Yu(1,1),a));for(let m=1;m<s;m++){let b=[hG(f,u[m-1]),Yu(m+1,1),a];u[m]=i(ar(...b))}return ar(...u).slice(0,r)}var Ez="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Iz=(e,t)=>(e+(e>=0?t:-t)/Tz)/t;function yG(e,t,r){Zi("scalar",e,li,r);let[[i,n],[o,s]]=t,a=Iz(s*e,r),c=Iz(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,f=l<li,p=u<li;if(f)l=-l;if(p)u=-u;let m=Ju(Math.ceil(hc(r)/2))+Po;if(l<li||l>=m||u<li||u>=m)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:l,k2neg:p,k2:u}}function Bx(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function Lx(e,t){Sn(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(qi(r.lowS,"lowS"),qi(r.prehash,"prehash"),r.format!==void 0)Bx(r.format);return r}class Az extends Error{constructor(e=""){super(e)}}var Nn={Err:Az,_tlv:{encode:(e,t)=>{let{Err:r}=Nn;if(ci(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 i=t.length/2,n=Hu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Hu(n.length/2|128):"";return Hu(e)+o+n+t},decode(e,t){let{Err:r}=Nn;t=ft(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),s=0;if(!o)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(i+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){let{Err:t}=Nn;if(Sm(e),e<li)throw new t("integer: negative integers are not allowed");let r=Hu(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}=Nn;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 Gs(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Nn,n=ft(e,void 0,"signature"),{v:o,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,o),{v:l,l:u}=i.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=Nn,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}};Object.freeze(Nn._tlv);Object.freeze(Nn._int);Object.freeze(Nn);var li=BigInt(0),Po=BigInt(1),Tz=BigInt(2),km=BigInt(3),bG=BigInt(4);function Rz(e,t={}){let r=_m("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:s,n:a}=o;Sn(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:l}=t;if(c){if(!i.is0(o.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=Oz(i,n);function f(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function p(K,N,L){if(l&&N.is0())return Uint8Array.of(0);let{x:I,y:z}=N.toAffine(),P=i.toBytes(I);if(qi(L,"isCompressed"),L){f();let J=!i.isOdd(z);return ar(Cz(J),P)}else return ar(Uint8Array.of(4),P,i.toBytes(z))}function m(K){ft(K,void 0,"Point");let{publicKey:N,publicKeyUncompressed:L}=u,I=K.length,z=K[0],P=K.subarray(1);if(l&&I===1&&z===0)return{x:i.ZERO,y:i.ZERO};if(I===N&&(z===2||z===3)){let J=i.fromBytes(P);if(!i.isValid(J))throw Error("bad point: is not on curve, wrong x");let j=S(J),Q;try{Q=i.sqrt(j)}catch(fe){let C=fe instanceof Error?": "+fe.message:"";throw Error("bad point: is not on curve, sqrt error"+C)}f();let E=i.isOdd(Q);if((z&1)===1!==E)Q=i.neg(Q);return{x:J,y:Q}}else if(I===L&&z===4){let J=i.BYTES,j=i.fromBytes(P.subarray(0,J)),Q=i.fromBytes(P.subarray(J,J*2));if(!k(j,Q))throw Error("bad point: is not on curve");return{x:j,y:Q}}else throw Error(`bad point: got length ${I}, expected compressed=${N} or uncompressed=${L}`)}let b=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?m:t.fromBytes;function S(K){let N=i.sqr(K),L=i.mul(N,K);return i.add(i.add(L,i.mul(K,o.a)),o.b)}function k(K,N){let L=i.sqr(N),I=S(K);return i.eql(L,I)}if(!k(o.Gx,o.Gy))throw Error("bad curve params: generator point");let A=i.mul(i.pow(o.a,km),bG),R=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(A,R)))throw Error("bad curve params: a or b");function D(K,N,L=!1){if(!i.isValid(N)||L&&i.is0(N))throw Error(`bad point coordinate ${K}`);return N}function U(K){if(!(K instanceof B))throw Error("Weierstrass Point expected")}function T(K){if(!c||!c.basises)throw Error("no endo");return yG(K,c.basises,n.ORDER)}function H(K,N,L,I,z){return L=new B(i.mul(L.X,K),L.Y,L.Z),N=Wu(I,N),L=Wu(z,L),N.add(L)}class B{static BASE=new B(o.Gx,o.Gy,i.ONE);static ZERO=new B(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(K,N,L){this.X=D("x",K),this.Y=D("y",N,!0),this.Z=D("z",L),Object.freeze(this)}static CURVE(){return o}static fromAffine(K){let{x:N,y:L}=K||{};if(!K||!i.isValid(N)||!i.isValid(L))throw Error("invalid affine point");if(K instanceof B)throw Error("projective point not allowed");if(i.is0(N)&&i.is0(L))return B.ZERO;return new B(N,L,i.ONE)}static fromBytes(K){let N=B.fromAffine(g(ft(K,void 0,"point")));return N.assertValidity(),N}static fromHex(K){return B.fromBytes(fc(K))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(K=8,N=!0){if(te.createCache(this,K),!N)this.multiply(km);return this}assertValidity(){let K=this;if(K.is0()){if(t.allowInfinityPoint&&i.is0(K.X)&&i.eql(K.Y,i.ONE)&&i.is0(K.Z))return;throw Error("bad point: ZERO")}let{x:N,y:L}=K.toAffine();if(!i.isValid(N)||!i.isValid(L))throw Error("bad point: x or y not field elements");if(!k(N,L))throw Error("bad point: equation left != right");if(!K.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:K}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(K)}equals(K){U(K);let{X:N,Y:L,Z:I}=this,{X:z,Y:P,Z:J}=K,j=i.eql(i.mul(N,J),i.mul(z,I)),Q=i.eql(i.mul(L,J),i.mul(P,I));return j&&Q}negate(){return new B(this.X,i.neg(this.Y),this.Z)}double(){let{a:K,b:N}=o,L=i.mul(N,km),{X:I,Y:z,Z:P}=this,J=i.ZERO,j=i.ZERO,Q=i.ZERO,E=i.mul(I,I),ae=i.mul(z,z),fe=i.mul(P,P),C=i.mul(I,z);return C=i.add(C,C),Q=i.mul(I,P),Q=i.add(Q,Q),J=i.mul(K,Q),j=i.mul(L,fe),j=i.add(J,j),J=i.sub(ae,j),j=i.add(ae,j),j=i.mul(J,j),J=i.mul(C,J),Q=i.mul(L,Q),fe=i.mul(K,fe),C=i.sub(E,fe),C=i.mul(K,C),C=i.add(C,Q),Q=i.add(E,E),E=i.add(Q,E),E=i.add(E,fe),E=i.mul(E,C),j=i.add(j,E),fe=i.mul(z,P),fe=i.add(fe,fe),E=i.mul(fe,C),J=i.sub(J,E),Q=i.mul(fe,ae),Q=i.add(Q,Q),Q=i.add(Q,Q),new B(J,j,Q)}add(K){U(K);let{X:N,Y:L,Z:I}=this,{X:z,Y:P,Z:J}=K,j=i.ZERO,Q=i.ZERO,E=i.ZERO,ae=o.a,fe=i.mul(o.b,km),C=i.mul(N,z),xe=i.mul(L,P),Te=i.mul(I,J),Pe=i.add(N,L),$e=i.add(z,P);Pe=i.mul(Pe,$e),$e=i.add(C,xe),Pe=i.sub(Pe,$e),$e=i.add(N,I);let _e=i.add(z,J);return $e=i.mul($e,_e),_e=i.add(C,Te),$e=i.sub($e,_e),_e=i.add(L,I),j=i.add(P,J),_e=i.mul(_e,j),j=i.add(xe,Te),_e=i.sub(_e,j),E=i.mul(ae,$e),j=i.mul(fe,Te),E=i.add(j,E),j=i.sub(xe,E),E=i.add(xe,E),Q=i.mul(j,E),xe=i.add(C,C),xe=i.add(xe,C),Te=i.mul(ae,Te),$e=i.mul(fe,$e),xe=i.add(xe,Te),Te=i.sub(C,Te),Te=i.mul(ae,Te),$e=i.add($e,Te),C=i.mul(xe,$e),Q=i.add(Q,C),C=i.mul(_e,$e),j=i.mul(Pe,j),j=i.sub(j,C),C=i.mul(Pe,xe),E=i.mul(_e,E),E=i.add(E,C),new B(j,Q,E)}subtract(K){return U(K),this.add(K.negate())}is0(){return this.equals(B.ZERO)}multiply(K){let{endo:N}=t;if(!n.isValidNot0(K))throw RangeError("invalid scalar: out of range");let L,I,z=(P)=>te.cached(this,P,(J)=>Xs(B,J));if(N){let{k1neg:P,k1:J,k2neg:j,k2:Q}=T(K),{p:E,f:ae}=z(J),{p:fe,f:C}=z(Q);I=ae.add(C),L=H(N.beta,E,fe,P,j)}else{let{p:P,f:J}=z(K);L=P,I=J}return Xs(B,[L,I])[0]}multiplyUnsafe(K){let{endo:N}=t,L=this,I=K;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===li||L.is0())return B.ZERO;if(I===Po)return L;if(te.hasCache(this))return this.multiply(I);if(N){let{k1neg:z,k1:P,k2neg:J,k2:j}=T(I),{p1:Q,p2:E}=kz(B,L,P,j);return H(N.beta,Q,E,z,J)}else return te.unsafe(L,I)}toAffine(K){let N=this,L=K,{X:I,Y:z,Z:P}=N;if(i.eql(P,i.ONE))return{x:I,y:z};let J=N.is0();if(L==null)L=J?i.ONE:i.inv(P);let j=i.mul(I,L),Q=i.mul(z,L),E=i.mul(P,L);if(J)return{x:i.ZERO,y:i.ZERO};if(!i.eql(E,i.ONE))throw Error("invZ was invalid");return{x:j,y:Q}}isTorsionFree(){let{isTorsionFree:K}=t;if(s===Po)return!0;if(K)return K(B,this);return te.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:K}=t;if(s===Po)return this;if(K)return K(B,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Po)return this.is0();return this.clearCofactor().is0()}toBytes(K=!0){return qi(K,"isCompressed"),this.assertValidity(),b(B,this,K)}toHex(K=!0){return dc(this.toBytes(K))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let V=n.BITS,te=new Gu(B,t.endo?Math.ceil(V/2):V);if(V>=8)B.BASE.precompute(8);return Object.freeze(B.prototype),Object.freeze(B),B}function Cz(e){return Uint8Array.of(e?2:3)}function Oz(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function SG(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?mc:t.randomBytes,n=Object.assign(Oz(e.Fp,r),{seed:Math.max($x(r.ORDER),16)});function o(m){try{let b=r.fromBytes(m);return r.isValidNot0(b)}catch(b){return!1}}function s(m,b){let{publicKey:g,publicKeyUncompressed:S}=n;try{let k=m.length;if(b===!0&&k!==g)return!1;if(b===!1&&k!==S)return!1;return!!e.fromBytes(m)}catch(k){return!1}}function a(m){return m=m===void 0?i(n.seed):m,bz(ft(m,n.seed,"seed"),r.ORDER)}function c(m,b=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(b)}function l(m){let{secretKey:b,publicKey:g,publicKeyUncompressed:S}=n,k=r._lengths;if(!pc(m))return;let A=ft(m,void 0,"key").length,R=A===g||A===S,D=A===b||!!k?.includes(A);if(R&&D)return;return R}function u(m,b,g=!0){if(l(m)===!0)throw Error("first arg must be private key");if(l(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(m);return e.fromBytes(b).multiply(S).toBytes(g)}let f={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=Qu(a,c);return Object.freeze(f),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:f,lengths:n})}function $z(e,t,r={}){let i=t;$i(i),Sn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?mc:r.randomBytes,o=r.hmac===void 0?(z,P)=>ri(i,z,P):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:l}=a,{keygen:u,getPublicKey:f,getSharedSecret:p,utils:m,lengths:b}=SG(e,r),g={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=c*Tz+Po<s.ORDER;function k(z){let P=c>>Po;return z>P}function A(z,P){if(!a.isValidNot0(P))throw Error(`invalid signature ${z}: out of range 1..Point.Fn.ORDER`);return P}function R(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function D(z,P){Bx(P);let J=b.signature,j=P==="compact"?J:P==="recovered"?J+1:void 0;return ft(z,j)}class U{r;s;recovery;constructor(z,P,J){if(this.r=A("r",z),this.s=A("s",P),J!=null){if(R(),![0,1,2,3].includes(J))throw Error("invalid recovery id");this.recovery=J}Object.freeze(this)}static fromBytes(z,P=g.format){D(z,P);let J;if(P==="der"){let{r:ae,s:fe}=Nn.toSig(ft(z));return new U(ae,fe)}if(P==="recovered")J=z[0],P="compact",z=z.subarray(1);let j=b.signature/2,Q=z.subarray(0,j),E=z.subarray(j,j*2);return new U(a.fromBytes(Q),a.fromBytes(E),J)}static fromHex(z,P){return this.fromBytes(fc(z),P)}assertRecovery(){let{recovery:z}=this;if(z==null)throw Error("invalid recovery id: must be present");return z}addRecoveryBit(z){return new U(this.r,this.s,z)}recoverPublicKey(z){let{r:P,s:J}=this,j=this.assertRecovery(),Q=j===2||j===3?P+c:P;if(!s.isValid(Q))throw Error("invalid recovery id: sig.r+curve.n != R.x");let E=s.toBytes(Q),ae=e.fromBytes(ar(Cz((j&1)===0),E)),fe=a.inv(Q),C=H(ft(z,void 0,"msgHash")),xe=a.create(-C*fe),Te=a.create(J*fe),Pe=e.BASE.multiplyUnsafe(xe).add(ae.multiplyUnsafe(Te));if(Pe.is0())throw Error("invalid recovery: point at infinify");return Pe.assertValidity(),Pe}hasHighS(){return k(this.s)}toBytes(z=g.format){if(Bx(z),z==="der")return fc(Nn.hexFromSig(this));let{r:P,s:J}=this,j=a.toBytes(P),Q=a.toBytes(J);if(z==="recovered")return R(),ar(Uint8Array.of(this.assertRecovery()),j,Q);return ar(j,Q)}toHex(z){return dc(this.toBytes(z))}}Object.freeze(U.prototype),Object.freeze(U);let T=r.bits2int===void 0?function(P){if(P.length>8192)throw Error("input is too large");let J=Gs(P),j=P.length*8-l;return j>0?J>>BigInt(j):J}:r.bits2int,H=r.bits2int_modN===void 0?function(P){return a.create(T(P))}:r.bits2int_modN,B=Ju(l);function V(z){return Zi("num < 2^"+l,z,li,B),a.toBytes(z)}function te(z,P){return ft(z,void 0,"message"),P?ft(i(z),void 0,"prehashed message"):z}function K(z,P,J){let{lowS:j,prehash:Q,extraEntropy:E}=Lx(J,g);z=te(z,Q);let ae=H(z),fe=a.fromBytes(P);if(!a.isValidNot0(fe))throw Error("invalid private key");let C=[V(fe),V(ae)];if(E!=null&&E!==!1){let $e=E===!0?n(b.secretKey):E;C.push(ft($e,void 0,"extraEntropy"))}let xe=ar(...C),Te=ae;function Pe($e){let _e=T($e);if(!a.isValidNot0(_e))return;let We=a.inv(_e),Le=e.BASE.multiply(_e).toAffine(),Xe=a.create(Le.x);if(Xe===li)return;let dt=a.create(We*a.create(Te+Xe*fe));if(dt===li)return;let kt=(Le.x===Xe?0:2)|Number(Le.y&Po),jt=dt;if(j&&k(dt))jt=a.neg(dt),kt^=1;return new U(Xe,jt,S?void 0:kt)}return{seed:xe,k2sig:Pe}}function N(z,P,J={}){let{seed:j,k2sig:Q}=K(z,P,J);return sz(i.outputLen,a.BYTES,o)(j,Q).toBytes(J.format)}function L(z,P,J,j={}){let{lowS:Q,prehash:E,format:ae}=Lx(j,g);if(J=ft(J,void 0,"publicKey"),P=te(P,E),!pc(z)){let fe=z instanceof U?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+fe)}D(z,ae);try{let fe=U.fromBytes(z,ae),C=e.fromBytes(J);if(Q&&fe.hasHighS())return!1;let{r:xe,s:Te}=fe,Pe=H(P),$e=a.inv(Te),_e=a.create(Pe*$e),We=a.create(xe*$e),Le=e.BASE.multiplyUnsafe(_e).add(C.multiplyUnsafe(We));if(Le.is0())return!1;return a.create(Le.x)===xe}catch(fe){return!1}}function I(z,P,J={}){let{prehash:j}=Lx(J,g);return P=te(P,j),U.fromBytes(z,"recovered").recoverPublicKey(P).toBytes()}return Object.freeze({keygen:u,getPublicKey:f,getSharedSecret:p,utils:m,lengths:b,Point:e,sign:N,verify:L,recoverPublicKey:I,Signature:U,hash:i})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var xG=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var wG=Rz(xG),yc=$z(wG,zt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var zo=BigInt(0),Fr=BigInt(1),jx=BigInt(2),vG=BigInt(8);function _G(e,t,r,i){let n=e.sqr(r),o=e.sqr(i),s=e.add(e.mul(t.a,n),o),a=e.add(e.ONE,e.mul(t.d,e.mul(n,o)));return e.eql(s,a)}function Pz(e,t={}){let r=t,i=_m("edwards",e,r,r.FpFnLE),{Fp:n,Fn:o}=i,s=i.CURVE,{h:a}=s;Sn(r,{},{uvRatio:"function"});let c=jx<<BigInt(o.BYTES*8)-Fr,l=(g)=>n.create(g),u=r.uvRatio===void 0?(g,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(g,S))}}catch(k){return{isValid:!1,value:zo}}}:r.uvRatio;if(!_G(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function f(g,S,k=!1){let A=k?Fr:zo;return Zi("coordinate "+g,S,A,c),S}function p(g){if(!(g instanceof m))throw Error("EdwardsPoint expected")}class m{static BASE=new m(s.Gx,s.Gy,Fr,l(s.Gx*s.Gy));static ZERO=new m(zo,Fr,Fr,zo);static Fp=n;static Fn=o;X;Y;Z;T;constructor(g,S,k,A){this.X=f("x",g),this.Y=f("y",S),this.Z=f("z",k,!0),this.T=f("t",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){if(g instanceof m)throw Error("extended point not allowed");let{x:S,y:k}=g||{};return f("x",S),f("y",k),new m(S,k,Fr,l(S*k))}static fromBytes(g,S=!1){let k=n.BYTES,{a:A,d:R}=s;g=$o(ft(g,k,"point")),qi(S,"zip215");let D=$o(g),U=g[k-1];D[k-1]=U&-129;let T=zn(D),H=S?c:n.ORDER;Zi("point.y",T,zo,H);let B=l(T*T),V=l(B-Fr),te=l(R*B-A),{isValid:K,value:N}=u(V,te);if(!K)throw Error("bad point: invalid y coordinate");let L=(N&Fr)===Fr,I=(U&128)!==0;if(!S&&N===zo&&I)throw Error("bad point: x=0 and x_0=1");if(I!==L)N=l(-N);return m.fromAffine({x:N,y:T})}static fromHex(g,S=!1){return m.fromBytes(fc(g),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,S=!0){if(b.createCache(this,g),!S)this.multiply(jx);return this}assertValidity(){let g=this,{a:S,d:k}=s;if(g.is0())throw Error("bad point: ZERO");let{X:A,Y:R,Z:D,T:U}=g,T=l(A*A),H=l(R*R),B=l(D*D),V=l(B*B),te=l(T*S),K=l(B*l(te+H)),N=l(V+l(k*l(T*H)));if(K!==N)throw Error("bad point: equation left != right (1)");let L=l(A*R),I=l(D*U);if(L!==I)throw Error("bad point: equation left != right (2)")}equals(g){p(g);let{X:S,Y:k,Z:A}=this,{X:R,Y:D,Z:U}=g,T=l(S*U),H=l(R*A),B=l(k*U),V=l(D*A);return T===H&&B===V}is0(){return this.equals(m.ZERO)}negate(){return new m(l(-this.X),this.Y,this.Z,l(-this.T))}double(){let{a:g}=s,{X:S,Y:k,Z:A}=this,R=l(S*S),D=l(k*k),U=l(jx*l(A*A)),T=l(g*R),H=S+k,B=l(l(H*H)-R-D),V=T+D,te=V-U,K=T-D,N=l(B*te),L=l(V*K),I=l(B*K),z=l(te*V);return new m(N,L,z,I)}add(g){p(g);let{a:S,d:k}=s,{X:A,Y:R,Z:D,T:U}=this,{X:T,Y:H,Z:B,T:V}=g,te=l(A*T),K=l(R*H),N=l(U*k*V),L=l(D*B),I=l((A+R)*(T+H)-te-K),z=L-N,P=L+N,J=l(K-S*te),j=l(I*z),Q=l(P*J),E=l(I*J),ae=l(z*P);return new m(j,Q,ae,E)}subtract(g){return p(g),this.add(g.negate())}multiply(g){if(!o.isValidNot0(g))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:k}=b.cached(this,g,(A)=>Xs(m,A));return Xs(m,[S,k])[0]}multiplyUnsafe(g){if(!o.isValid(g))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(g===zo)return m.ZERO;if(this.is0()||g===Fr)return this;return b.unsafe(this,g,(S)=>Xs(m,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(g){let S=this,k=g,{X:A,Y:R,Z:D}=S,U=S.is0();if(k==null)k=U?vG:n.inv(D);let T=l(A*k),H=l(R*k),B=n.mul(D,k);if(U)return{x:zo,y:Fr};if(B!==Fr)throw Error("invZ was invalid");return{x:T,y:H}}clearCofactor(){if(a===Fr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:g,y:S}=this.toAffine(),k=n.toBytes(S);return k[k.length-1]|=g&Fr?128:0,k}toHex(){return dc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new Gu(m,o.BITS);if(o.BITS>=8)m.BASE.precompute(8);return Object.freeze(m.prototype),Object.freeze(m),m}class Ux{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){Tx()}static fromHex(e){Tx()}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 dc(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 Xu=BigInt(0),bc=BigInt(1),Em=BigInt(2);function kG(e){return Sn(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function zz(e){let t=kG(e),{P:r,type:i,adjustScalarBytes:n,powPminus2:o,randomBytes:s}=t,a=i==="x25519";if(!a&&i!=="x448")throw Error("invalid type");let c=s===void 0?mc:s,l=a?255:448,u=a?32:56,f=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?Em**BigInt(254):Em**BigInt(447),b=a?BigInt(8)*Em**BigInt(251)-bc:BigInt(4)*Em**BigInt(445)-bc,g=m+b+bc,S=(I)=>xt(I,r),k=A(f);function A(I){return Ku(S(I),u)}function R(I){let z=$o(ft(I,u,"uCoordinate"));if(a)z[31]&=127;return S(zn(z))}function D(I){return zn(n($o(ft(I,u,"scalar"))))}function U(I,z){let P=te(R(z),D(I));if(P===Xu)throw Error("invalid private or public key received");return A(P)}function T(I){return U(I,k)}let H=T,B=U;function V(I,z,P){let J=S(I*(z-P));return z=S(z-J),P=S(P+J),{x_2:z,x_3:P}}function te(I,z){Zi("u",I,Xu,r),Zi("scalar",z,m,g);let P=z,J=I,j=bc,Q=Xu,E=I,ae=bc,fe=Xu;for(let xe=BigInt(l-1);xe>=Xu;xe--){let Te=P>>xe&bc;fe^=Te,{x_2:j,x_3:E}=V(fe,j,E),{x_2:Q,x_3:ae}=V(fe,Q,ae),fe=Te;let Pe=j+Q,$e=S(Pe*Pe),_e=j-Q,We=S(_e*_e),Le=$e-We,Xe=E+ae,dt=E-ae,kt=S(dt*Pe),jt=S(Xe*_e),yt=kt+jt,hr=kt-jt;E=S(yt*yt),ae=S(J*S(hr*hr)),j=S($e*We),Q=S(Le*($e+S(p*Le)))}({x_2:j,x_3:E}=V(fe,j,E)),{x_2:Q,x_3:ae}=V(fe,Q,ae);let C=o(Q);return S(j*C)}let K={secretKey:u,publicKey:u,seed:u},N=(I)=>(I=I===void 0?c(u):I,ft(I,K.seed,"seed"),I),L={randomSecretKey:N};return Object.freeze(K),Object.freeze(L),Object.freeze({keygen:Qu(N,H),getSharedSecret:B,getPublicKey:H,scalarMult:U,scalarMultBase:T,utils:L,GuBytes:k.slice(),lengths:K})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var EG=BigInt(0),Fi=BigInt(1),Nz=BigInt(2),IG=BigInt(3),AG=BigInt(5),TG=BigInt(8),ta=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Fx=(()=>({p:ta,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:TG,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function Bz(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=ta,a=e*e%o*e%o,c=xn(a,Nz,o)*a%o,l=xn(c,Fi,o)*e%o,u=xn(l,AG,o)*l%o,f=xn(u,t,o)*u%o,p=xn(f,r,o)*f%o,m=xn(p,i,o)*p%o,b=xn(m,n,o)*m%o,g=xn(b,n,o)*m%o,S=xn(g,t,o)*u%o;return{pow_p_5_8:xn(S,Nz,o)*e%o,b2:a}}function RG(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var qx=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Hx(e,t){let r=ta,i=xt(t*t*t,r),n=xt(i*i*t,r),o=Bz(e*n).pow_p_5_8,s=xt(e*i*o,r),a=xt(t*s*s,r),c=s,l=xt(s*qx,r),u=a===e,f=a===xt(-e,r),p=a===xt(-e*qx,r);if(u)s=c;if(f||p)s=l;if(Mi(s,r))s=xt(-s,r);return{isValid:u||f,value:s}}var ea=Pz(Fx,{uvRatio:Hx}),No=(()=>ea.Fp)(),jz=(()=>ea.Fn)();var Im=(()=>{let e=ta;return zz({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=Bz(t);return xt(xn(r,IG,e)*i,e)},adjustScalarBytes:RG})})();var Zx=qx,CG=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),OG=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),$G=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),PG=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Dz=(e)=>Hx(Fi,e),zG=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Mx=(e)=>No.create(zn(e)&zG);function Lz(e){let{d:t}=Fx,r=ta,i=(k)=>No.create(k),n=i(Zx*e*e),o=i((n+Fi)*$G),s=BigInt(-1),a=i((s-t*n)*i(n+t)),{isValid:c,value:l}=Hx(o,a),u=i(l*e);if(!Mi(u,r))u=i(-u);if(!c)l=u;if(!c)s=n;let f=i(s*(n-Fi)*PG-a),p=l*l,m=i((l+l)*a),b=i(f*CG),g=i(Fi-p),S=i(Fi+p);return new ea(i(m*S),i(g*b),i(b*S),i(m*g))}class Or extends Ux{static BASE=(()=>new Or(ea.BASE))();static ZERO=(()=>new Or(ea.ZERO))();static Fp=(()=>No)();static Fn=(()=>jz)();constructor(e){super(e)}static fromAffine(e){return new Or(ea.fromAffine(e))}assertSame(e){if(!(e instanceof Or))throw Error("RistrettoPoint expected")}init(e){return new Or(e)}static fromBytes(e){nr(e,32);let{a:t,d:r}=Fx,i=ta,n=(R)=>No.create(R),o=Mx(e);if(!oz(No.toBytes(o),e)||Mi(o,i))throw Error("invalid ristretto255 encoding 1");let s=n(o*o),a=n(Fi+t*s),c=n(Fi-t*s),l=n(a*a),u=n(c*c),f=n(t*r*l-u),{isValid:p,value:m}=Dz(n(f*u)),b=n(m*c),g=n(m*b*f),S=n((o+o)*b);if(Mi(S,i))S=n(-S);let k=n(a*g),A=n(S*k);if(!p||Mi(A,i)||k===EG)throw Error("invalid ristretto255 encoding 2");return new Or(new ea(S,k,Fi,A))}static fromHex(e){return Or.fromBytes(wu(e))}toBytes(){let{X:e,Y:t,Z:r,T:i}=this.ep,n=ta,o=(g)=>No.create(g),s=o(o(r+t)*o(r-t)),a=o(e*t),c=o(a*a),{value:l}=Dz(o(s*c)),u=o(l*s),f=o(l*a),p=o(u*f*i),m;if(Mi(i*p,n)){let g=o(t*Zx),S=o(e*Zx);e=g,t=S,m=o(u*OG)}else m=f;if(Mi(e*p,n))t=o(-t);let b=o((r-t)*m);if(Mi(b,n))b=o(-b);return No.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:n}=e.ep,o=(c)=>No.create(c),s=o(t*n)===o(r*i),a=o(r*n)===o(t*i);return s||a}is0(){return this.equals(Or.ZERO)}}Object.freeze(Or.BASE);Object.freeze(Or.ZERO);Object.freeze(Or.prototype);Object.freeze(Or);var NG=Object.freeze({Point:Or,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,i=Dx(e,r,64,Fp);return NG.deriveToCurve(i)},hashToScalar(e,t={DST:Ez}){let r=Dx(e,t.DST,64,Fp);return jz.create(zn(r))},deriveToCurve(e){nr(e,64);let t=Mx(e.subarray(0,32)),r=Lz(t),i=Mx(e.subarray(32,64)),n=Lz(i);return new Or(r.add(n))}});var Uz=!1,DG=!1;async function qz(e,t){if(DG)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 Am(e,t){return await qz(async()=>{let r=Kx(e)?e:await BG(e),i=await crypto.subtle.importKey("raw",jG(t),{name:"X25519"},Uz,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},r,256))},()=>{if(Kx(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Im.scalarMult(e,t)})}async function ed(e){return await qz(async()=>Am(e,Im.GuBytes),()=>{if(Kx(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Im.scalarMultBase(e)})}var LG=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function BG(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...LG,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},Uz,["deriveBits"])}function Kx(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function jG(e){return e}class Jx{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),qG(ra(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=ra(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:ra(this.transcript)}}}function qG(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function ra(e){let t=e.reduce((n,o)=>n+o.length,0),r=new Uint8Array(t),i=0;for(let n of e)r.set(n,i),i+=n.length;return r}function Sc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let i of t)r.enqueue(i)}}))}function Tm(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function Vx(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function Zz(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function Mz(e,t){let r=e.getReader(),i=[],n=0;while(n<t){let{done:c,value:l}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");i.push(l),n+=l.length}r.releaseLock();let o=ra(i),s=o.subarray(0,t),a=Sc(e,o.subarray(t));return{data:s,rest:a}}class ui{args;body;constructor(e,t){this.args=e,this.body=t}}async function ZG(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 o of r)if(o.length===0)throw Error("invalid stanza");let i=[];for(;;){let o=await e.readLine();if(o===null)throw Error("invalid stanza");let s=yr.decode(o);if(s.length>48)throw Error("invalid stanza");if(i.push(s),s.length<48)break}let n=ra(i);return{s:new ui(r,n)}}async function Fz(e){let t=new Jx(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let i=[];for(;;){let{s:n,next:o}=await ZG(t);if(n!==void 0){i.push(n);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=yr.decode(o.slice(4)),{rest:a,transcript:c}=t.close(),l=c.slice(0,c.length-1-o.length+3);return{stanzas:i,headerNoMAC:l,MAC:s,headerSize:c.length,rest:Sc(e,a)}}}function Wx(e){let t=[];t.push(`age-encryption.org/v1
736
+ `)}function HO(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 bt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function Ns(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var Lp={name:"@rizom/ops",version:"0.2.0-alpha.638",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 XG,mkdirSync as eQ,readFileSync as pw,writeFileSync as mw}from"fs";import{dirname as tQ,join as eN}from"path";function AS(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Pt(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 nr(e,t,r=""){let i=AS(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;if(!i)throw TypeError(l);throw RangeError(l)}return e}function $i(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(Pt(e.outputLen),Pt(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function Xa(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 Bp(e,t){nr(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function jp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Tr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ec(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function On(e,t){return e<<32-t|e>>>t}function rt(e,t){return e<<t|e>>>32-t>>>0}var I7=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function A7(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function T7(e){for(let t=0;t<e.length;t++)e[t]=A7(e[t]);return e}var TS=I7?(e)=>e:T7,JO=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),R7=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Up(e){if(nr(e),JO)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=R7[e[r]];return t}var Oi={_0:48,_9:57,A:65,F:70,a:97,f:102};function KO(e){if(e>=Oi._0&&e<=Oi._9)return e-Oi._0;if(e>=Oi.A&&e<=Oi.F)return e-(Oi.A-10);if(e>=Oi.a&&e<=Oi.f)return e-(Oi.a-10);return}function wu(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(JO)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 i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let s=KO(e.charCodeAt(o)),a=KO(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}i[n]=s*16+a}return i}function C7(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function RS(e,t=""){if(typeof e==="string")return C7(e);return nr(e,void 0,t)}function CS(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];nr(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function qp(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 OS(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function Pi(e=32){Pt(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 $S=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class PS{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if($i(e),nr(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,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<i.length;n++)i[n]^=54;this.iHash.update(i),this.oHash=e.create();for(let n=0;n<i.length;n++)i[n]^=106;this.oHash.update(i),Tr(i)}update(e){return Xa(this),this.iHash.update(e),this}digestInto(e){Xa(this),Bp(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:i,destroyed:n,blockLen:o,outputLen:s}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,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 ri=(()=>{let e=(t,r,i)=>new PS(t,r).update(i).digest();return e.create=(t,r)=>new PS(t,r),e})();function vu(e,t,r){if($i(e),r===void 0)r=new Uint8Array(e.outputLen);return ri(e,r,t)}var zS=Uint8Array.of(0),VO=Uint8Array.of();function NS(e,t,r,i=32){$i(e),Pt(i,"length"),nr(t,void 0,"prk");let n=e.outputLen;if(t.length<n)throw Error('"prk" must be at least HashLen octets');if(i>255*n)throw Error("Length must be <= 255*HashLen");let o=Math.ceil(i/n);if(r===void 0)r=VO;else nr(r,void 0,"info");let s=new Uint8Array(o*n),a=ri.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)zS[0]=u+1,c.update(u===0?VO:l).update(r).update(zS).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Tr(l,zS),s.slice(0,i)}var bo=(e,t,r,i,n)=>NS(e,vu(e,t,r),i,n);function WO(e,t,r){return e&t^~e&r}function GO(e,t,r){return e&t^e&r^t&r}class Zp{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,i){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=ec(this.buffer)}update(e){Xa(this),nr(e);let{view:t,buffer:r,blockLen:i}=this,n=e.length;for(let o=0;o<n;){let s=Math.min(i-this.pos,n-o);if(s===i){let a=ec(e);for(;i<=n-o;o+=i)this.process(a,o);continue}if(r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){Xa(this),Bp(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Tr(this.buffer.subarray(o)),this.padOffset>i-o)this.process(r,0),o=0;for(let u=o;u<i;u++)t[u]=0;r.setBigUint64(i-8,BigInt(this.length*8),n),this.process(r,0);let s=ec(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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:i,finished:n,destroyed:o,pos:s}=this;if(e.destroyed=o,e.finished=n,e.length=i,e.pos=s,i%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var zi=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ir=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Mp=BigInt(4294967295),QO=BigInt(32);function O7(e,t=!1){if(t)return{h:Number(e&Mp),l:Number(e>>QO&Mp)};return{h:Number(e>>QO&Mp)|0,l:Number(e&Mp)|0}}function YO(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=O7(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var DS=(e,t,r)=>e>>>r,LS=(e,t,r)=>e<<32-r|t>>>r,Ds=(e,t,r)=>e>>>r|t<<32-r,Ls=(e,t,r)=>e<<32-r|t>>>r,_u=(e,t,r)=>e<<64-r|t>>>r-32,ku=(e,t,r)=>e>>>r-32|t<<64-r;function ni(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var XO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),e$=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,t$=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),r$=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,n$=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),i$=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var P7=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]),So=new Uint32Array(64);class o$ extends Zp{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:i,E:n,F:o,G:s,H:a}=this;return[e,t,r,i,n,o,s,a]}set(e,t,r,i,n,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)So[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let f=So[u-15],p=So[u-2],m=On(f,7)^On(f,18)^f>>>3,b=On(p,17)^On(p,19)^p>>>10;So[u]=b+So[u-7]+m+So[u-16]|0}let{A:r,B:i,C:n,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){let f=On(s,6)^On(s,11)^On(s,25),p=l+f+WO(s,a,c)+P7[u]+So[u]|0,b=(On(r,2)^On(r,13)^On(r,22))+GO(r,i,n)|0;l=c,c=a,a=s,s=o+p|0,o=n,n=i,i=r,r=p+b|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,n,o,s,a,c,l)}roundClean(){Tr(So)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Tr(this.buffer)}}class s$ extends o${A=zi[0]|0;B=zi[1]|0;C=zi[2]|0;D=zi[3]|0;E=zi[4]|0;F=zi[5]|0;G=zi[6]|0;H=zi[7]|0;constructor(){super(32)}}var a$=(()=>YO(["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))))(),z7=(()=>a$[0])(),N7=(()=>a$[1])(),xo=new Uint32Array(80),wo=new Uint32Array(80);class c$ extends Zp{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:u,Fl:f,Gh:p,Gl:m,Hh:b,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,f,p,m,b,g]}set(e,t,r,i,n,o,s,a,c,l,u,f,p,m,b,g){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=n|0,this.Cl=o|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=f|0,this.Gh=p|0,this.Gl=m|0,this.Hh=b|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)xo[A]=e.getUint32(t),wo[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let R=xo[A-15]|0,D=wo[A-15]|0,U=Ds(R,D,1)^Ds(R,D,8)^DS(R,D,7),T=Ls(R,D,1)^Ls(R,D,8)^LS(R,D,7),H=xo[A-2]|0,B=wo[A-2]|0,V=Ds(H,B,19)^_u(H,B,61)^DS(H,B,6),te=Ls(H,B,19)^ku(H,B,61)^LS(H,B,6),K=t$(T,te,wo[A-7],wo[A-16]),N=r$(K,U,V,xo[A-7],xo[A-16]);xo[A]=N|0,wo[A]=K|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:f,Fh:p,Fl:m,Gh:b,Gl:g,Hh:S,Hl:k}=this;for(let A=0;A<80;A++){let R=Ds(u,f,14)^Ds(u,f,18)^_u(u,f,41),D=Ls(u,f,14)^Ls(u,f,18)^ku(u,f,41),U=u&p^~u&b,T=f&m^~f&g,H=n$(k,D,T,N7[A],wo[A]),B=i$(H,S,R,U,z7[A],xo[A]),V=H|0,te=Ds(r,i,28)^_u(r,i,34)^_u(r,i,39),K=Ls(r,i,28)^ku(r,i,34)^ku(r,i,39),N=r&n^r&s^n&s,L=i&o^i&a^o&a;S=b|0,k=g|0,b=p|0,g=m|0,p=u|0,m=f|0,{h:u,l:f}=ni(c|0,l|0,B|0,V|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=XO(V,K,L);r=e$(I,B,te,N),i=I|0}({h:r,l:i}=ni(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ni(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ni(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ni(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:f}=ni(this.Eh|0,this.El|0,u|0,f|0),{h:p,l:m}=ni(this.Fh|0,this.Fl|0,p|0,m|0),{h:b,l:g}=ni(this.Gh|0,this.Gl|0,b|0,g|0),{h:S,l:k}=ni(this.Hh|0,this.Hl|0,S|0,k|0),this.set(r,i,n,o,s,a,c,l,u,f,p,m,b,g,S,k)}roundClean(){Tr(xo,wo)}destroy(){this.destroyed=!0,Tr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class l$ extends c${Ah=ir[0]|0;Al=ir[1]|0;Bh=ir[2]|0;Bl=ir[3]|0;Ch=ir[4]|0;Cl=ir[5]|0;Dh=ir[6]|0;Dl=ir[7]|0;Eh=ir[8]|0;El=ir[9]|0;Fh=ir[10]|0;Fl=ir[11]|0;Gh=ir[12]|0;Gl=ir[13]|0;Hh=ir[14]|0;Hl=ir[15]|0;constructor(){super(64)}}var zt=OS(()=>new s$,$S(1));var Fp=OS(()=>new l$,$S(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Wp(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function US(e){if(!Wp(e))throw TypeError("Uint8Array expected")}function m$(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 h$(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function vo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function Iu(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Kp(e){if(!Array.isArray(e))throw TypeError("array expected")}function Jp(e,t){if(!m$(!0,t))throw TypeError(`${e}: array of strings expected`)}function qS(e,t){if(!m$(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Xr(...e){let t=(o)=>o,r=(o,s)=>(a)=>o(s(a)),i=e.map((o)=>o.encode).reduceRight(r,t),n=e.map((o)=>o.decode).reduce(r,t);return{encode:i,decode:n}}function en(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Jp("alphabet",t);let i=new Map(t.map((n,o)=>[n,o]));return{encode:(n)=>(Kp(n),n.map((o)=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);return t[o]})),decode:(n)=>(Kp(n),n.map((o)=>{vo("alphabet.decode",o);let s=i.get(o);if(s===void 0)throw Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function tn(e=""){return vo("join",e),{encode:(t)=>(Jp("join.decode",t),t.join(e)),decode:(t)=>(vo("join.decode",t),t.split(e))}}function Gp(e,t="="){return Iu(e),vo("padding",t),{encode(r){Jp("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Jp("padding.decode",r);let i=r.length;if(i*e%8)throw Error("padding: invalid, string should have whole number of bytes");for(;i>0&&r[i-1]===t;i--)if((i-1)*e%8===0)throw Error("padding: invalid, string has too much padding");return r.slice(0,i)}}}function g$(e){return h$(e),{encode:(t)=>t,decode:(t)=>e(t)}}function u$(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(Kp(e),!e.length)return[];let i=0,n=[],o=Array.from(e,(a)=>{if(Iu(a),a<0||a>=t)throw Error(`invalid integer: ${a}`);return a}),s=o.length;while(!0){let a=0,c=!0;for(let l=i;l<s;l++){let u=o[l],f=t*a,p=f+u;if(!Number.isSafeInteger(p)||f/t!==a||p-u!==f)throw Error("convertRadix: carry overflow");let m=p/r;a=p%r;let b=Math.floor(m);if(o[l]=b,!Number.isSafeInteger(b)||b*r+a!==p)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!b)i=l;else c=!1}if(n.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)n.push(0);return n.reverse()}var y$=(e,t)=>t===0?e:y$(t,e%t),Vp=(e,t)=>e+(t-y$(e,t)),Hp=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function BS(e,t,r,i){if(Kp(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Vp(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Vp(t,r)}`);let n=0,o=0,s=Hp[t],a=Hp[r]-1,c=[];for(let l of e){if(Iu(l),l>=s)throw Error(`convertRadix2: invalid data word=${l} from=${t}`);if(n=n<<t|l,o+t>32)throw Error(`convertRadix2: carry overflow pos=${o} from=${t}`);o+=t;for(;o>=r;o-=r)c.push((n>>o-r&a)>>>0);let u=Hp[o];if(u===void 0)throw Error("invalid carry");n&=u-1}if(n=n<<r-o&a,!i&&o>=t)throw Error("Excess padding");if(!i&&n>0)throw Error(`Non-zero padding: ${n}`);if(i&&o>0)c.push(n>>>0);return c}function D7(e){Iu(e);let t=256;return{encode:(r)=>{if(!Wp(r))throw TypeError("radix.encode input should be Uint8Array");return u$(Array.from(r),t,e)},decode:(r)=>(qS("radix.decode",r),Uint8Array.from(u$(r,e,t)))}}function hn(e,t=!1){if(Iu(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Vp(8,e)>32||Vp(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Wp(r))throw TypeError("radix2.encode input should be Uint8Array");return BS(Array.from(r),8,e,!t)},decode:(r)=>(qS("radix2.decode",r),Uint8Array.from(BS(r,e,8,t)))}}function d$(e){return h$(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var r0e=Object.freeze(Xr(hn(4),en("0123456789ABCDEF"),tn(""))),n0e=Object.freeze(Xr(hn(5),en("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Gp(5),tn(""))),i0e=Object.freeze(Xr(hn(5),en("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),tn(""))),o0e=Object.freeze(Xr(hn(5),en("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Gp(5),tn(""))),s0e=Object.freeze(Xr(hn(5),en("0123456789ABCDEFGHIJKLMNOPQRSTUV"),tn(""))),a0e=Object.freeze(Xr(hn(5),en("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),tn(""),g$((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),b$=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),L7=/[\t\n\f\r ]/,S$=(e,t)=>{vo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&L7.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},ZS=Object.freeze(b$?{encode(e){return US(e),e.toBase64()},decode(e){return S$(e,!1)}}:Xr(hn(6),en("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Gp(6),tn(""))),yr=Object.freeze(Xr(hn(6),en("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),tn(""))),c0e=Object.freeze(b$?{encode(e){return US(e),e.toBase64({alphabet:"base64url"})},decode(e){return S$(e,!0)}}:Xr(hn(6),en("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Gp(6),tn(""))),l0e=Object.freeze(Xr(hn(6),en("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),tn(""))),MS=(e)=>Xr(D7(58),en(e),tn("")),u0e=Object.freeze(MS("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),d0e=Object.freeze(MS("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),f0e=Object.freeze(MS("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var jS=Xr(en("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),tn("")),f$=[996825010,642813549,513874426,1027748829,705979059];function Eu(e){let t=e>>25,r=(e&33554431)<<5;for(let i=0;i<f$.length;i++)if((t>>i&1)===1)r^=f$[i];return r}function p$(e,t,r=1){let i=e.length,n=1;for(let o=0;o<i;o++){let s=e.charCodeAt(o);if(s<33||s>126)throw Error(`Invalid prefix (${e})`);n=Eu(n)^s>>5}n=Eu(n);for(let o=0;o<i;o++)n=Eu(n)^e.charCodeAt(o)&31;for(let o of t)n=Eu(n)^o;for(let o=0;o<6;o++)n=Eu(n);return n^=r,jS.encode(BS([n%Hp[30]],30,5,!1))}function x$(e){let t=e==="bech32"?1:734539939,r=hn(5),i=r.decode,n=r.encode,o=d$(i);function s(f,p,m=90){if(vo("bech32.encode prefix",f),Wp(p))p=Array.from(p);qS("bech32.encode",p);let b=f.length;if(b===0)throw TypeError(`Invalid prefix length ${b}`);let g=b+7+p.length;if(m!==!1&&g>m)throw TypeError(`Length ${g} exceeds limit ${m}`);let S=f.toLowerCase(),k=p$(S,p,t);return`${S}1${jS.encode(p)}${k}`}function a(f,p=90){vo("bech32.decode input",f);let m=f.length;if(m<8||p!==!1&&m>p)throw TypeError(`invalid string length: ${m} (${f}). Expected (8..${p})`);let b=f.toLowerCase();if(f!==b&&f!==f.toUpperCase())throw Error("String must be lowercase or uppercase");let g=b.lastIndexOf("1");if(g===0||g===-1)throw Error('Letter "1" must be present between prefix and data only');let S=b.slice(0,g),k=b.slice(g+1);if(k.length<6)throw Error("Data must be at least 6 characters long");let A=jS.decode(k).slice(0,-6),R=p$(S,A,t);if(!k.endsWith(R))throw Error(`Invalid checksum in ${f}: expected "${R}"`);return{prefix:S,words:A}}let c=d$(a);function l(f){let{prefix:p,words:m}=a(f,!1);return{prefix:p,words:m,bytes:i(m)}}function u(f,p){return s(f,n(p))}return{encode:s,decode:a,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:i,fromWordsUnsafe:o,toWords:n}}var rn=Object.freeze(x$("bech32")),p0e=Object.freeze(x$("bech32m"));var B7=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),j7={encode(e){return US(e),e.toHex()},decode(e){return vo("hex",e),Uint8Array.fromHex(e)}},m0e=Object.freeze(B7?j7:Xr(hn(4),en("0123456789abcdef"),tn(""),g$((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 q7(e,t,r,i){$i(e);let n=qp({dkLen:32,asyncTick:10},i),{c:o,dkLen:s,asyncTick:a}=n;if(Pt(o,"c"),Pt(s,"dkLen"),Pt(a,"asyncTick"),o<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 c=RS(t,"password"),l=RS(r,"salt"),u=new Uint8Array(s),f=ri.create(e,c),p=f._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:f,PRFSalt:p}}function Z7(e,t,r,i,n){if(e.destroy(),t.destroy(),i)i.destroy();return Tr(n),r}function FS(e,t,r,i){let{c:n,dkLen:o,DK:s,PRF:a,PRFSalt:c}=q7(e,t,r,i),l,u=new Uint8Array(4),f=ec(u),p=new Uint8Array(a.outputLen);for(let m=1,b=0;b<o;m++,b+=a.outputLen){let g=s.subarray(b,b+a.outputLen);f.setInt32(0,m,!1),(l=c._cloneInto(l)).update(u).digestInto(p),g.set(p.subarray(0,g.length));for(let S=1;S<n;S++){a._cloneInto(l).update(p).digestInto(p);for(let k=0;k<g.length;k++)g[k]^=p[k]}}return Z7(a,c,s,l,p)}function w$(e,t,r,i,n,o){let s=e[t++]^r[i++],a=e[t++]^r[i++],c=e[t++]^r[i++],l=e[t++]^r[i++],u=e[t++]^r[i++],f=e[t++]^r[i++],p=e[t++]^r[i++],m=e[t++]^r[i++],b=e[t++]^r[i++],g=e[t++]^r[i++],S=e[t++]^r[i++],k=e[t++]^r[i++],A=e[t++]^r[i++],R=e[t++]^r[i++],D=e[t++]^r[i++],U=e[t++]^r[i++],T=s,H=a,B=c,V=l,te=u,K=f,N=p,L=m,I=b,z=g,P=S,J=k,j=A,Q=R,E=D,ae=U;for(let fe=0;fe<8;fe+=2)te^=rt(T+j|0,7),I^=rt(te+T|0,9),j^=rt(I+te|0,13),T^=rt(j+I|0,18),z^=rt(K+H|0,7),Q^=rt(z+K|0,9),H^=rt(Q+z|0,13),K^=rt(H+Q|0,18),E^=rt(P+N|0,7),B^=rt(E+P|0,9),N^=rt(B+E|0,13),P^=rt(N+B|0,18),V^=rt(ae+J|0,7),L^=rt(V+ae|0,9),J^=rt(L+V|0,13),ae^=rt(J+L|0,18),H^=rt(T+V|0,7),B^=rt(H+T|0,9),V^=rt(B+H|0,13),T^=rt(V+B|0,18),N^=rt(K+te|0,7),L^=rt(N+K|0,9),te^=rt(L+N|0,13),K^=rt(te+L|0,18),J^=rt(P+z|0,7),I^=rt(J+P|0,9),z^=rt(I+J|0,13),P^=rt(z+I|0,18),j^=rt(ae+E|0,7),Q^=rt(j+ae|0,9),E^=rt(Q+j|0,13),ae^=rt(E+Q|0,18);n[o++]=s+T|0,n[o++]=a+H|0,n[o++]=c+B|0,n[o++]=l+V|0,n[o++]=u+te|0,n[o++]=f+K|0,n[o++]=p+N|0,n[o++]=m+L|0,n[o++]=b+I|0,n[o++]=g+z|0,n[o++]=S+P|0,n[o++]=k+J|0,n[o++]=A+j|0,n[o++]=R+Q|0,n[o++]=D+E|0,n[o++]=U+ae|0}function HS(e,t,r,i,n){let o=i+0,s=i+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++,o+=16,t+=16){if(w$(r,s,e,t,r,o),a>0)s+=16;w$(r,o,e,t+=16,r,s)}}function M7(e,t,r){let i=qp({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:o,p:s,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=i;if(Pt(n,"N"),Pt(o,"r"),Pt(s,"p"),Pt(a,"dkLen"),Pt(c,"asyncTick"),Pt(l,"maxmem"),u!==void 0&&typeof u!=="function")throw Error("progressCb must be a function");let f=128*o,p=f/4,m=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>m)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(m-1)*32/f)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(m-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let b=f*(n+s+1);if(b>l)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+b+", maxmem="+l);let g=FS(zt,e,t,{c:1,dkLen:f*s}),S=jp(g),k=jp(new Uint8Array(f*n)),A=jp(new Uint8Array(f)),R=()=>{};if(u){let D=2*n*s,U=Math.max(Math.floor(D/1e4),1),T=0;R=()=>{if(T++,u&&(!(T%U)||T===D))u(T/D)}}return{N:n,r:o,p:s,dkLen:a,blockSize32:p,V:k,B32:S,B:g,tmp:A,blockMixCb:R,asyncTick:c}}function F7(e,t,r,i,n){let o=FS(zt,e,r,{c:1,dkLen:t});return Tr(r,i,n),o}function KS(e,t,r){let{N:i,r:n,p:o,dkLen:s,blockSize32:a,V:c,B32:l,B:u,tmp:f,blockMixCb:p}=M7(e,t,r);TS(l);for(let m=0;m<o;m++){let b=a*m;for(let g=0;g<a;g++)c[g]=l[b+g];for(let g=0,S=0;g<i-1;g++)HS(c,S,c,S+=a,n),p();HS(c,(i-1)*a,l,b,n),p();for(let g=0;g<i;g++){let S=(l[b+a-16]&i-1)>>>0;for(let k=0;k<a;k++)f[k]=l[b+k]^c[S*a+k];HS(f,0,l,b,n),p()}}return TS(l),F7(e,s,u,c,f)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function H7(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Qp(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function tc(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 Ft(e,t,r=""){let i=H7(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`,l=s+"expected Uint8Array"+a+", got "+c;if(!i)throw TypeError(l);throw RangeError(l)}return e}function JS(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 v$(e,t,r=!1){Ft(e,void 0,"output");let i=t.outputLen;if(e.length<i)throw RangeError("digestInto() expects output buffer of length at least "+i);if(r&&!rc(e))throw Error("invalid output, must be aligned")}function ii(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function $n(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function K7(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Bs=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),J7=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var V7=(e)=>{for(let t=0;t<e.length;t++)e[t]=J7(e[t]);return e},Ni=Bs?(e)=>e:V7;function _$(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function k$(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function E$(e,t,r){let i=t,n=r||(()=>[]),o=(a,c)=>i(c,...n(a)).update(a).digest(),s=i(new Uint8Array(e),...n(new Uint8Array(0)));return o.outputLen=s.outputLen,o.blockLen=s.blockLen,o.create=(a,...c)=>i(a,...c),o}var I$=(e,t)=>{function r(i,...n){if(Ft(i,void 0,"key"),e.nonceLength!==void 0){let u=n[0];Ft(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;if(o&&n[1]!==void 0)Ft(n[1],void 0,"AAD");let s=t(i,...n),a=(u,f)=>{if(f!==void 0){if(u!==2)throw Error("cipher output not supported");Ft(f,void 0,"output")}},c=!1;return{encrypt(u,f){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Ft(u),a(s.encrypt.length,f),s.encrypt(u,f)},decrypt(u,f){if(Ft(u),o&&u.length<o)throw Error('"ciphertext" expected length bigger than tagLength='+o);return a(s.decrypt.length,f),s.decrypt(u,f)}}}return Object.assign(r,e),r};function Au(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Ft(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!rc(t))throw Error("invalid output, must be aligned");return t}function A$(e,t,r){tc(e),tc(t),Qp(r);let i=new Uint8Array(16),n=K7(i);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),i}function rc(e){return e.byteOffset%4===0}function nc(e){return Uint8Array.from(Ft(e))}var R$=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),W7=(()=>Ni(ii(R$("expand 16-byte k"))))(),G7=(()=>Ni(ii(R$("expand 32-byte k"))))();function nt(e,t){return e<<t|e>>>32-t}var Tu=64,Q7=16,VS=(()=>4294967295)(),T$=Uint32Array.of();function Y7(e,t,r,i,n,o,s,a){let c=n.length,l=new Uint8Array(Tu),u=ii(l),f=Bs&&rc(n)&&rc(o),p=f?ii(n):T$,m=f?ii(o):T$;if(!Bs){for(let b=0;b<c;s++){if(e(t,r,i,u,s,a),Ni(u),s>=VS)throw Error("arx: counter overflow");let g=Math.min(Tu,c-b);for(let S=0,k;S<g;S++)k=b+S,o[k]=n[k]^l[S];b+=g}return}for(let b=0;b<c;s++){if(e(t,r,i,u,s,a),s>=VS)throw Error("arx: counter overflow");let g=Math.min(Tu,c-b);if(f&&g===Tu){let S=b/4;if(b%4!==0)throw Error("arx: invalid block position");for(let k=0,A;k<Q7;k++)A=S+k,m[A]=p[A]^u[k];b+=Tu;continue}for(let S=0,k;S<g;S++)k=b+S,o[k]=n[k]^l[S];b+=g}}function C$(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:o,rounds:s}=_$({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return tc(n),tc(s),Qp(o),Qp(r),(a,c,l,u,f=0)=>{Ft(a,void 0,"key"),Ft(c,void 0,"nonce"),Ft(l,void 0,"data");let p=l.length;if(u=Au(p,u,!1),tc(f),f<0||f>=VS)throw Error("arx: counter overflow");let m=[],b=a.length,g,S;if(b===32)m.push(g=nc(a)),S=G7;else if(b===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),S=W7,m.push(g);else throw Ft(a,32,"arx key"),Error("invalid key size");if(!Bs||!rc(c))m.push(c=nc(c));let k=ii(g);if(i){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let D=c.subarray(0,16);if(Bs)i(S,k,ii(D),k);else{let U=Ni(Uint32Array.from(S));i(U,k,ii(D),k),$n(U),Ni(k)}c=c.subarray(16)}else if(!Bs)Ni(k);let A=16-n;if(A!==c.length)throw Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){let D=new Uint8Array(12);D.set(c,o?0:12-c.length),c=D,m.push(c)}let R=Ni(ii(c));try{return Y7(e,S,k,R,l,u,f,s),u}finally{$n(...m)}}}function or(e,t){return e[t++]&255|(e[t++]&255)<<8}class O${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=nc(Ft(e,32,"key"));let t=or(e,0),r=or(e,2),i=or(e,4),n=or(e,6),o=or(e,8),s=or(e,10),a=or(e,12),c=or(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let l=0;l<8;l++)this.pad[l]=or(e,16+2*l)}process(e,t,r=!1){let i=r?0:2048,{h:n,r:o}=this,s=o[0],a=o[1],c=o[2],l=o[3],u=o[4],f=o[5],p=o[6],m=o[7],b=o[8],g=o[9],S=or(e,t+0),k=or(e,t+2),A=or(e,t+4),R=or(e,t+6),D=or(e,t+8),U=or(e,t+10),T=or(e,t+12),H=or(e,t+14),B=n[0]+(S&8191),V=n[1]+((S>>>13|k<<3)&8191),te=n[2]+((k>>>10|A<<6)&8191),K=n[3]+((A>>>7|R<<9)&8191),N=n[4]+((R>>>4|D<<12)&8191),L=n[5]+(D>>>1&8191),I=n[6]+((D>>>14|U<<2)&8191),z=n[7]+((U>>>11|T<<5)&8191),P=n[8]+((T>>>8|H<<8)&8191),J=n[9]+(H>>>5|i),j=0,Q=j+B*s+V*(5*g)+te*(5*b)+K*(5*m)+N*(5*p);j=Q>>>13,Q&=8191,Q+=L*(5*f)+I*(5*u)+z*(5*l)+P*(5*c)+J*(5*a),j+=Q>>>13,Q&=8191;let E=j+B*a+V*s+te*(5*g)+K*(5*b)+N*(5*m);j=E>>>13,E&=8191,E+=L*(5*p)+I*(5*f)+z*(5*u)+P*(5*l)+J*(5*c),j+=E>>>13,E&=8191;let ae=j+B*c+V*a+te*s+K*(5*g)+N*(5*b);j=ae>>>13,ae&=8191,ae+=L*(5*m)+I*(5*p)+z*(5*f)+P*(5*u)+J*(5*l),j+=ae>>>13,ae&=8191;let fe=j+B*l+V*c+te*a+K*s+N*(5*g);j=fe>>>13,fe&=8191,fe+=L*(5*b)+I*(5*m)+z*(5*p)+P*(5*f)+J*(5*u),j+=fe>>>13,fe&=8191;let C=j+B*u+V*l+te*c+K*a+N*s;j=C>>>13,C&=8191,C+=L*(5*g)+I*(5*b)+z*(5*m)+P*(5*p)+J*(5*f),j+=C>>>13,C&=8191;let xe=j+B*f+V*u+te*l+K*c+N*a;j=xe>>>13,xe&=8191,xe+=L*s+I*(5*g)+z*(5*b)+P*(5*m)+J*(5*p),j+=xe>>>13,xe&=8191;let Te=j+B*p+V*f+te*u+K*l+N*c;j=Te>>>13,Te&=8191,Te+=L*a+I*s+z*(5*g)+P*(5*b)+J*(5*m),j+=Te>>>13,Te&=8191;let Pe=j+B*m+V*p+te*f+K*u+N*l;j=Pe>>>13,Pe&=8191,Pe+=L*c+I*a+z*s+P*(5*g)+J*(5*b),j+=Pe>>>13,Pe&=8191;let $e=j+B*b+V*m+te*p+K*f+N*u;j=$e>>>13,$e&=8191,$e+=L*l+I*c+z*a+P*s+J*(5*g),j+=$e>>>13,$e&=8191;let _e=j+B*g+V*b+te*m+K*p+N*f;j=_e>>>13,_e&=8191,_e+=L*u+I*l+z*c+P*a+J*s,j+=_e>>>13,_e&=8191,j=(j<<2)+j|0,j=j+Q|0,Q=j&8191,j=j>>>13,E+=j,n[0]=Q,n[1]=E,n[2]=ae,n[3]=fe,n[4]=C,n[5]=xe,n[6]=Te,n[7]=Pe,n[8]=$e,n[9]=_e}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=i,i=e[s]>>>13,e[s]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,r[0]=e[0]+5,i=r[0]>>>13,r[0]&=8191;for(let s=1;s<10;s++)r[s]=e[s]+i,i=r[s]>>>13,r[s]&=8191;r[9]-=8192;let n=(i^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 o=e[0]+t[0];e[0]=o&65535;for(let s=1;s<8;s++)o=(e[s]+t[s]|0)+(o>>>16)|0,e[s]=o&65535;$n(r)}update(e){JS(this),Ft(e),e=nc(e);let{buffer:t,blockLen:r}=this,i=e.length;for(let n=0;n<i;){let o=Math.min(r-this.pos,i-n);if(o===r){for(;r<=i-n;n+=r)this.process(e,n);continue}if(t.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r)this.process(t,0,!1),this.pos=0}return this}destroy(){this.destroyed=!0,$n(this.h,this.r,this.buffer,this.pad)}digestInto(e){JS(this),v$(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:i}=this;if(i){t[i++]=1;for(;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=r[o]>>>0,e[n++]=r[o]>>>8}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}}var $$=E$(32,(e)=>new O$(e));function X7(e,t,r,i,n,o=20){let s=e[0],a=e[1],c=e[2],l=e[3],u=t[0],f=t[1],p=t[2],m=t[3],b=t[4],g=t[5],S=t[6],k=t[7],A=n,R=r[0],D=r[1],U=r[2],T=s,H=a,B=c,V=l,te=u,K=f,N=p,L=m,I=b,z=g,P=S,J=k,j=A,Q=R,E=D,ae=U;for(let C=0;C<o;C+=2)T=T+te|0,j=nt(j^T,16),I=I+j|0,te=nt(te^I,12),T=T+te|0,j=nt(j^T,8),I=I+j|0,te=nt(te^I,7),H=H+K|0,Q=nt(Q^H,16),z=z+Q|0,K=nt(K^z,12),H=H+K|0,Q=nt(Q^H,8),z=z+Q|0,K=nt(K^z,7),B=B+N|0,E=nt(E^B,16),P=P+E|0,N=nt(N^P,12),B=B+N|0,E=nt(E^B,8),P=P+E|0,N=nt(N^P,7),V=V+L|0,ae=nt(ae^V,16),J=J+ae|0,L=nt(L^J,12),V=V+L|0,ae=nt(ae^V,8),J=J+ae|0,L=nt(L^J,7),T=T+K|0,ae=nt(ae^T,16),P=P+ae|0,K=nt(K^P,12),T=T+K|0,ae=nt(ae^T,8),P=P+ae|0,K=nt(K^P,7),H=H+N|0,j=nt(j^H,16),J=J+j|0,N=nt(N^J,12),H=H+N|0,j=nt(j^H,8),J=J+j|0,N=nt(N^J,7),B=B+L|0,Q=nt(Q^B,16),I=I+Q|0,L=nt(L^I,12),B=B+L|0,Q=nt(Q^B,8),I=I+Q|0,L=nt(L^I,7),V=V+te|0,E=nt(E^V,16),z=z+E|0,te=nt(te^z,12),V=V+te|0,E=nt(E^V,8),z=z+E|0,te=nt(te^z,7);let fe=0;i[fe++]=s+T|0,i[fe++]=a+H|0,i[fe++]=c+B|0,i[fe++]=l+V|0,i[fe++]=u+te|0,i[fe++]=f+K|0,i[fe++]=p+N|0,i[fe++]=m+L|0,i[fe++]=b+I|0,i[fe++]=g+z|0,i[fe++]=S+P|0,i[fe++]=k+J|0,i[fe++]=A+j|0,i[fe++]=R+Q|0,i[fe++]=D+E|0,i[fe++]=U+ae|0}var eW=C$(X7,{counterRight:!1,counterLength:4,allowShortKeys:!1});var tW=new Uint8Array(16),P$=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(tW.subarray(r))},rW=new Uint8Array(32);function z$(e,t,r,i,n){if(n!==void 0)Ft(n,void 0,"AAD");let o=e(t,r,rW),s=A$(i.length,n?n.length:0,!0),a=$$.create(o);if(n)P$(a,n);P$(a,i),a.update(s);let c=a.digest();return $n(o,s),c}var nW=(e)=>(t,r,i)=>({encrypt(o,s){let a=o.length;s=Au(a+16,s,!1),s.set(o);let c=s.subarray(0,-16);e(t,r,c,c,1);let l=z$(e,t,r,c,i);return s.set(l,a),$n(l),s},decrypt(o,s){s=Au(o.length-16,s,!1);let a=o.subarray(0,-16),c=o.subarray(-16),l=z$(e,t,r,a,i);if(!k$(c,l))throw $n(l),Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),$n(l),s}}),gn=I$({blockSize:64,nonceLength:12,tagLength:16},nW(eW));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ic(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Qt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function De(e,t,r=""){let i=ic(e),n=e?.length,o=t!==void 0;if(!i||o&&n!==t){let s=r&&`"${r}" `,a=o?` of length ${t}`:"",c=i?`length=${n}`:`type=${typeof e}`;throw Error(s+"expected Uint8Array"+a+", got "+c)}return e}function yn(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Qt(e.outputLen),Qt(e.blockLen)}function Li(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 Yp(e,t){De(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function Xp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Mr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function em(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Pn(e,t){return e<<32-t|e>>>t}var iW=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function oW(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function sW(e){for(let t=0;t<e.length;t++)e[t]=oW(e[t]);return e}var WS=iW?(e)=>e:sW,D$=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),aW=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function js(e){if(De(e),D$)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=aW[e[r]];return t}var Di={_0:48,_9:57,A:65,F:70,a:97,f:102};function N$(e){if(e>=Di._0&&e<=Di._9)return e-Di._0;if(e>=Di.A&&e<=Di.F)return e-(Di.A-10);if(e>=Di.a&&e<=Di.f)return e-(Di.a-10);return}function Us(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(D$)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 i=new Uint8Array(r);for(let n=0,o=0;n<r;n++,o+=2){let s=N$(e.charCodeAt(o)),a=N$(e.charCodeAt(o+1));if(s===void 0||a===void 0){let c=e[o]+e[o+1];throw Error('hex string expected, got non-hex character "'+c+'" at index '+o)}i[n]=s*16+a}return i}function Ut(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];De(n),t+=n.length}let r=new Uint8Array(t);for(let i=0,n=0;i<e.length;i++){let o=e[i];r.set(o,n),n+=o.length}return r}function oc(e,t={}){let r=(n,o)=>e(o).update(n).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.create=(n)=>e(n),Object.assign(r,t),Object.freeze(r)}function _o(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 ko=(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 QS=BigInt(0),GS=BigInt(1);function Ru(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function L$(e){if(typeof e==="bigint"){if(!tm(e))throw Error("positive bigint expected, got "+e)}else Qt(e);return e}function Cu(e){let t=L$(e).toString(16);return t.length&1?"0"+t:t}function B$(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?QS:BigInt("0x"+e)}function Eo(e){return B$(js(e))}function Io(e){return B$(js(rm(De(e)).reverse()))}function sc(e,t){Qt(t),e=L$(e);let r=Us(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Ou(e,t){return sc(e,t).reverse()}function rm(e){return Uint8Array.from(e)}function Ao(e){return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw Error(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}var tm=(e)=>typeof e==="bigint"&&QS<=e;function cW(e,t,r){return tm(e)&&tm(t)&&tm(r)&&t<=e&&e<r}function $u(e,t,r,i){if(!cW(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function YS(e){let t;for(t=0;e>QS;e>>=GS,t+=1);return t}var Pu=(e)=>(GS<<BigInt(e))-GS;function j$(e,t,r){if(Qt(e,"hashLen"),Qt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let i=(S)=>new Uint8Array(S),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,f=()=>{c.fill(1),l.fill(0),u=0},p=(...S)=>r(l,Ut(c,...S)),m=(S=n)=>{if(l=p(o,S),c=p(),S.length===0)return;l=p(s,S),c=p()},b=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let S=0,k=[];while(S<t){c=p();let A=c.slice();k.push(A),S+=c.length}return Ut(...k)};return(S,k)=>{f(),m(S);let A=void 0;while(!(A=k(b())))m();return f(),A}}function qs(e,t={},r={}){if(!e||typeof e!=="object")throw Error("expected valid options object");function i(o,s,a){let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw Error(`param "${o}" is invalid: expected ${s}, got ${l}`)}let n=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));n(t,!1),n(r,!0)}function XS(e){let t=new WeakMap;return(r,...i)=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r,...i);return t.set(r,o),o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Cr=BigInt(0),br=BigInt(1),Zs=BigInt(2),Z$=BigInt(3),M$=BigInt(4),F$=BigInt(5),lW=BigInt(7),H$=BigInt(8),uW=BigInt(9),K$=BigInt(16);function Rr(e,t){let r=e%t;return r>=Cr?r:t+r}function bn(e,t,r){let i=e;while(t-- >Cr)i*=i,i%=r;return i}function U$(e,t){if(e===Cr)throw Error("invert: expected non-zero number");if(t<=Cr)throw Error("invert: expected positive modulus, got "+t);let r=Rr(e,t),i=t,n=Cr,o=br,s=br,a=Cr;while(r!==Cr){let l=i/r,u=i%r,f=n-s*l,p=o-a*l;i=r,r=u,n=s,o=a,s=f,a=p}if(i!==br)throw Error("invert: does not exist");return Rr(n,t)}function ex(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function J$(e,t){let r=(e.ORDER+br)/M$,i=e.pow(t,r);return ex(e,i,t),i}function dW(e,t){let r=(e.ORDER-F$)/H$,i=e.mul(t,Zs),n=e.pow(i,r),o=e.mul(t,n),s=e.mul(e.mul(o,Zs),n),a=e.mul(o,e.sub(s,e.ONE));return ex(e,a,t),a}function fW(e){let t=nm(e),r=V$(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+lW)/K$;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,i),f=a.mul(l,n),p=a.mul(l,o),m=a.eql(a.sqr(u),c),b=a.eql(a.sqr(f),c);l=a.cmov(l,u,m),u=a.cmov(p,f,b);let g=a.eql(a.sqr(u),c),S=a.cmov(l,u,g);return ex(a,S,c),S}}function V$(e){if(e<Z$)throw Error("sqrt is not defined for small field");let t=e-br,r=0;while(t%Zs===Cr)t/=Zs,r++;let i=Zs,n=nm(e);while(q$(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return J$;let o=n.pow(i,t),s=(t+br)/Zs;return function(c,l){if(c.is0(l))return l;if(q$(c,l)!==1)throw Error("Cannot find square root");let u=r,f=c.mul(c.ONE,o),p=c.pow(l,t),m=c.pow(l,s);while(!c.eql(p,c.ONE)){if(c.is0(p))return c.ZERO;let b=1,g=c.sqr(p);while(!c.eql(g,c.ONE))if(b++,g=c.sqr(g),b===u)throw Error("Cannot find square root");let S=br<<BigInt(u-b-1),k=c.pow(f,S);u=b,f=c.sqr(k),p=c.mul(p,f),m=c.mul(m,k)}return m}}function pW(e){if(e%M$===Z$)return J$;if(e%H$===F$)return dW;if(e%K$===uW)return fW(e);return V$(e)}var mW=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function tx(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=mW.reduce((i,n)=>(i[n]="function",i),t);return qs(e,r),e}function hW(e,t,r){if(r<Cr)throw Error("invalid exponent, negatives unsupported");if(r===Cr)return e.ONE;if(r===br)return t;let i=e.ONE,n=t;while(r>Cr){if(r&br)i=e.mul(i,n);n=e.sqr(n),r>>=br}return i}function zu(e,t,r=!1){let i=Array(t.length).fill(r?e.ZERO:void 0),n=t.reduce((s,a,c)=>{if(e.is0(a))return s;return i[c]=s,e.mul(s,a)},e.ONE),o=e.inv(n);return t.reduceRight((s,a,c)=>{if(e.is0(a))return s;return i[c]=e.mul(s,i[c]),e.mul(s,a)},o),i}function q$(e,t){let r=(e.ORDER-br)/Zs,i=e.pow(t,r),n=e.eql(i,e.ONE),o=e.eql(i,e.ZERO),s=e.eql(i,e.neg(e.ONE));if(!n&&!o&&!s)throw Error("invalid Legendre symbol result");return n?1:o?0:-1}function gW(e,t){if(t!==void 0)Qt(t);let r=t!==void 0?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}class W${ORDER;BITS;BYTES;isLE;ZERO=Cr;ONE=br;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=Cr)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:i,nByteLength:n}=gW(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=n,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Rr(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof e);return Cr<=e&&e<this.ORDER}is0(e){return e===Cr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&br)===br}neg(e){return Rr(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Rr(e*e,this.ORDER)}add(e,t){return Rr(e+t,this.ORDER)}sub(e,t){return Rr(e-t,this.ORDER)}mul(e,t){return Rr(e*t,this.ORDER)}pow(e,t){return hW(this,e,t)}div(e,t){return Rr(e*U$(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 U$(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=pW(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Ou(e,this.BYTES):sc(e,this.BYTES)}fromBytes(e,t=!1){De(e);let{_lengths:r,BYTES:i,isLE:n,ORDER:o,_mod:s}=this;if(r){if(!r.includes(e.length)||e.length>i)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(i);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==i)throw Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let a=n?Io(e):Eo(e);if(s)a=Rr(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return zu(this,e)}cmov(e,t,r){return r?t:e}}function nm(e,t={}){return new W$(e,t)}function G$(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function rx(e){let t=G$(e);return t+Math.ceil(t/2)}function Q$(e,t,r=!1){De(e);let i=e.length,n=G$(t),o=rx(t);if(i<16||i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?Io(e):Eo(e),a=Rr(s,t-br)+br;return r?Ou(a,n):sc(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ac=BigInt(0),Ms=BigInt(1);function Nu(e,t){let r=t.negate();return e?r:t}function sx(e,t){let r=zu(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function tP(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function nx(e,t){tP(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Pu(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function Y$(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>i)a-=o,c+=Ms;let l=t*i,u=l+Math.abs(a)-1,f=a===0,p=a<0,m=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:p,isNegF:m,offsetF:l}}var ix=new WeakMap,rP=new WeakMap;function ox(e){return rP.get(e)||1}function X$(e){if(e!==ac)throw Error("invalid wNAF")}class ax{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 i=e;while(t>ac){if(t&Ms)r=r.add(i);i=i.double(),t>>=Ms}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=nx(t,this.bits),n=[],o=e,s=o;for(let a=0;a<r;a++){s=o,n.push(s);for(let c=1;c<i;c++)s=s.add(o),n.push(s);o=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let i=this.ZERO,n=this.BASE,o=nx(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:f,offsetF:p}=Y$(r,s,o);if(r=a,l)n=n.add(Nu(f,t[p]));else i=i.add(Nu(u,t[c]))}return X$(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=nx(e,this.bits);for(let o=0;o<n.windows;o++){if(r===ac)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=Y$(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return X$(r),i}getPrecomputes(e,t,r){let i=ix.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);ix.set(t,i)}}return i}cached(e,t,r){let i=ox(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=ox(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){tP(t,this.bits),rP.set(e,t),ix.delete(e)}hasCache(e){return ox(e)!==1}}function nP(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>ac||i>ac){if(r&Ms)o=o.add(n);if(i&Ms)s=s.add(n);n=n.double(),r>>=Ms,i>>=Ms}return{p1:o,p2:s}}function eP(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return tx(t),t}else return nm(e,{isLE:r})}function iP(e,t,r={},i){if(i===void 0)i=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l==="bigint"&&l>ac))throw Error(`CURVE.${c} must be positive bigint`)}let n=eP(t.p,r.Fp,i),o=eP(t.n,r.Fn,i),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:o}}function im(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Du=BigInt(0),cc=BigInt(1),om=BigInt(2);function yW(e){return qs(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function oP(e){let t=yW(e),{P:r,type:i,adjustScalarBytes:n,powPminus2:o,randomBytes:s}=t,a=i==="x25519";if(!a&&i!=="x448")throw Error("invalid type");let c=s||_o,l=a?255:448,u=a?32:56,f=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?om**BigInt(254):om**BigInt(447),b=a?BigInt(8)*om**BigInt(251)-cc:BigInt(4)*om**BigInt(445)-cc,g=m+b+cc,S=(I)=>Rr(I,r),k=A(f);function A(I){return Ou(S(I),u)}function R(I){let z=rm(De(I,u,"uCoordinate"));if(a)z[31]&=127;return S(Io(z))}function D(I){return Io(n(rm(De(I,u,"scalar"))))}function U(I,z){let P=te(R(z),D(I));if(P===Du)throw Error("invalid private or public key received");return A(P)}function T(I){return U(I,k)}let H=T,B=U;function V(I,z,P){let J=S(I*(z-P));return z=S(z-J),P=S(P+J),{x_2:z,x_3:P}}function te(I,z){$u("u",I,Du,r),$u("scalar",z,m,g);let P=z,J=I,j=cc,Q=Du,E=I,ae=cc,fe=Du;for(let xe=BigInt(l-1);xe>=Du;xe--){let Te=P>>xe&cc;fe^=Te,{x_2:j,x_3:E}=V(fe,j,E),{x_2:Q,x_3:ae}=V(fe,Q,ae),fe=Te;let Pe=j+Q,$e=S(Pe*Pe),_e=j-Q,We=S(_e*_e),Le=$e-We,Xe=E+ae,dt=E-ae,kt=S(dt*Pe),jt=S(Xe*_e),yt=kt+jt,hr=kt-jt;E=S(yt*yt),ae=S(J*S(hr*hr)),j=S($e*We),Q=S(Le*($e+S(p*Le)))}({x_2:j,x_3:E}=V(fe,j,E)),{x_2:Q,x_3:ae}=V(fe,Q,ae);let C=o(Q);return S(j*C)}let K={secretKey:u,publicKey:u,seed:u},N=(I=c(u))=>(De(I,K.seed,"seed"),I),L={randomSecretKey:N};return Object.freeze({keygen:im(N,H),getSharedSecret:B,getPublicKey:H,scalarMult:U,scalarMultBase:T,utils:L,GuBytes:k.slice(),lengths:K})}class cx{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(yn(e),De(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,i=new Uint8Array(r);i.set(t.length>r?e.create().update(t).digest():t);for(let n=0;n<i.length;n++)i[n]^=54;this.iHash.update(i),this.oHash=e.create();for(let n=0;n<i.length;n++)i[n]^=106;this.oHash.update(i),Mr(i)}update(e){return Li(this),this.iHash.update(e),this}digestInto(e){Li(this),De(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:i,destroyed:n,blockLen:o,outputLen:s}=this;return e=e,e.finished=i,e.destroyed=n,e.blockLen=o,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 lc=(e,t,r)=>new cx(e,t).update(r).digest();lc.create=(e,t)=>new cx(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var sP=(e,t)=>(e+(e>=0?t:-t)/cP)/t;function bW(e,t,r){let[[i,n],[o,s]]=t,a=sP(s*e,r),c=sP(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,f=l<Bi,p=u<Bi;if(f)l=-l;if(p)u=-u;let m=Pu(Math.ceil(YS(r)/2))+uc;if(l<Bi||l>=m||u<Bi||u>=m)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:l,k2neg:p,k2:u}}function ux(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function lx(e,t){let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Ru(r.lowS,"lowS"),Ru(r.prehash,"prehash"),r.format!==void 0)ux(r.format);return r}class aP extends Error{constructor(e=""){super(e)}}var To={Err:aP,_tlv:{encode:(e,t)=>{let{Err:r}=To;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let i=t.length/2,n=Cu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Cu(n.length/2|128):"";return Cu(e)+o+n+t},decode(e,t){let{Err:r}=To,i=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),s=0;if(!o)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(i+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){let{Err:t}=To;if(e<Bi)throw new t("integer: negative integers are not allowed");let r=Cu(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}=To;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 Eo(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=To,n=De(e,void 0,"signature"),{v:o,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,o),{v:l,l:u}=i.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=To,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},Bi=BigInt(0),uc=BigInt(1),cP=BigInt(2),sm=BigInt(3),SW=BigInt(4);function dx(e,t={}){let r=iP("weierstrass",e,t),{Fp:i,Fn:n}=r,o=r.CURVE,{h:s,n:a}=o;qs(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c){if(!i.is0(o.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let l=uP(i,n);function u(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(N,L,I){let{x:z,y:P}=L.toAffine(),J=i.toBytes(z);if(Ru(I,"isCompressed"),I){u();let j=!i.isOdd(P);return Ut(lP(j),J)}else return Ut(Uint8Array.of(4),J,i.toBytes(P))}function p(N){De(N,void 0,"Point");let{publicKey:L,publicKeyUncompressed:I}=l,z=N.length,P=N[0],J=N.subarray(1);if(z===L&&(P===2||P===3)){let j=i.fromBytes(J);if(!i.isValid(j))throw Error("bad point: is not on curve, wrong x");let Q=g(j),E;try{E=i.sqrt(Q)}catch(C){let xe=C instanceof Error?": "+C.message:"";throw Error("bad point: is not on curve, sqrt error"+xe)}u();let ae=i.isOdd(E);if((P&1)===1!==ae)E=i.neg(E);return{x:j,y:E}}else if(z===I&&P===4){let j=i.BYTES,Q=i.fromBytes(J.subarray(0,j)),E=i.fromBytes(J.subarray(j,j*2));if(!S(Q,E))throw Error("bad point: is not on curve");return{x:Q,y:E}}else throw Error(`bad point: got length ${z}, expected compressed=${L} or uncompressed=${I}`)}let m=t.toBytes||f,b=t.fromBytes||p;function g(N){let L=i.sqr(N),I=i.mul(L,N);return i.add(i.add(I,i.mul(N,o.a)),o.b)}function S(N,L){let I=i.sqr(L),z=g(N);return i.eql(I,z)}if(!S(o.Gx,o.Gy))throw Error("bad curve params: generator point");let k=i.mul(i.pow(o.a,sm),SW),A=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(k,A)))throw Error("bad curve params: a or b");function R(N,L,I=!1){if(!i.isValid(L)||I&&i.is0(L))throw Error(`bad point coordinate ${N}`);return L}function D(N){if(!(N instanceof V))throw Error("Weierstrass Point expected")}function U(N){if(!c||!c.basises)throw Error("no endo");return bW(N,c.basises,n.ORDER)}let T=XS((N,L)=>{let{X:I,Y:z,Z:P}=N;if(i.eql(P,i.ONE))return{x:I,y:z};let J=N.is0();if(L==null)L=J?i.ONE:i.inv(P);let j=i.mul(I,L),Q=i.mul(z,L),E=i.mul(P,L);if(J)return{x:i.ZERO,y:i.ZERO};if(!i.eql(E,i.ONE))throw Error("invZ was invalid");return{x:j,y:Q}}),H=XS((N)=>{if(N.is0()){if(t.allowInfinityPoint&&!i.is0(N.Y))return;throw Error("bad point: ZERO")}let{x:L,y:I}=N.toAffine();if(!i.isValid(L)||!i.isValid(I))throw Error("bad point: x or y not field elements");if(!S(L,I))throw Error("bad point: equation left != right");if(!N.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function B(N,L,I,z,P){return I=new V(i.mul(I.X,N),I.Y,I.Z),L=Nu(z,L),I=Nu(P,I),L.add(I)}class V{static BASE=new V(o.Gx,o.Gy,i.ONE);static ZERO=new V(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(N,L,I){this.X=R("x",N),this.Y=R("y",L,!0),this.Z=R("z",I),Object.freeze(this)}static CURVE(){return o}static fromAffine(N){let{x:L,y:I}=N||{};if(!N||!i.isValid(L)||!i.isValid(I))throw Error("invalid affine point");if(N instanceof V)throw Error("projective point not allowed");if(i.is0(L)&&i.is0(I))return V.ZERO;return new V(L,I,i.ONE)}static fromBytes(N){let L=V.fromAffine(b(De(N,void 0,"point")));return L.assertValidity(),L}static fromHex(N){return V.fromBytes(Us(N))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(N=8,L=!0){if(K.createCache(this,N),!L)this.multiply(sm);return this}assertValidity(){H(this)}hasEvenY(){let{y:N}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(N)}equals(N){D(N);let{X:L,Y:I,Z:z}=this,{X:P,Y:J,Z:j}=N,Q=i.eql(i.mul(L,j),i.mul(P,z)),E=i.eql(i.mul(I,j),i.mul(J,z));return Q&&E}negate(){return new V(this.X,i.neg(this.Y),this.Z)}double(){let{a:N,b:L}=o,I=i.mul(L,sm),{X:z,Y:P,Z:J}=this,j=i.ZERO,Q=i.ZERO,E=i.ZERO,ae=i.mul(z,z),fe=i.mul(P,P),C=i.mul(J,J),xe=i.mul(z,P);return xe=i.add(xe,xe),E=i.mul(z,J),E=i.add(E,E),j=i.mul(N,E),Q=i.mul(I,C),Q=i.add(j,Q),j=i.sub(fe,Q),Q=i.add(fe,Q),Q=i.mul(j,Q),j=i.mul(xe,j),E=i.mul(I,E),C=i.mul(N,C),xe=i.sub(ae,C),xe=i.mul(N,xe),xe=i.add(xe,E),E=i.add(ae,ae),ae=i.add(E,ae),ae=i.add(ae,C),ae=i.mul(ae,xe),Q=i.add(Q,ae),C=i.mul(P,J),C=i.add(C,C),ae=i.mul(C,xe),j=i.sub(j,ae),E=i.mul(C,fe),E=i.add(E,E),E=i.add(E,E),new V(j,Q,E)}add(N){D(N);let{X:L,Y:I,Z:z}=this,{X:P,Y:J,Z:j}=N,Q=i.ZERO,E=i.ZERO,ae=i.ZERO,fe=o.a,C=i.mul(o.b,sm),xe=i.mul(L,P),Te=i.mul(I,J),Pe=i.mul(z,j),$e=i.add(L,I),_e=i.add(P,J);$e=i.mul($e,_e),_e=i.add(xe,Te),$e=i.sub($e,_e),_e=i.add(L,z);let We=i.add(P,j);return _e=i.mul(_e,We),We=i.add(xe,Pe),_e=i.sub(_e,We),We=i.add(I,z),Q=i.add(J,j),We=i.mul(We,Q),Q=i.add(Te,Pe),We=i.sub(We,Q),ae=i.mul(fe,_e),Q=i.mul(C,Pe),ae=i.add(Q,ae),Q=i.sub(Te,ae),ae=i.add(Te,ae),E=i.mul(Q,ae),Te=i.add(xe,xe),Te=i.add(Te,xe),Pe=i.mul(fe,Pe),_e=i.mul(C,_e),Te=i.add(Te,Pe),Pe=i.sub(xe,Pe),Pe=i.mul(fe,Pe),_e=i.add(_e,Pe),xe=i.mul(Te,_e),E=i.add(E,xe),xe=i.mul(We,_e),Q=i.mul($e,Q),Q=i.sub(Q,xe),xe=i.mul($e,Te),ae=i.mul(We,ae),ae=i.add(ae,xe),new V(Q,E,ae)}subtract(N){return this.add(N.negate())}is0(){return this.equals(V.ZERO)}multiply(N){let{endo:L}=t;if(!n.isValidNot0(N))throw Error("invalid scalar: out of range");let I,z,P=(J)=>K.cached(this,J,(j)=>sx(V,j));if(L){let{k1neg:J,k1:j,k2neg:Q,k2:E}=U(N),{p:ae,f:fe}=P(j),{p:C,f:xe}=P(E);z=fe.add(xe),I=B(L.beta,ae,C,J,Q)}else{let{p:J,f:j}=P(N);I=J,z=j}return sx(V,[I,z])[0]}multiplyUnsafe(N){let{endo:L}=t,I=this;if(!n.isValid(N))throw Error("invalid scalar: out of range");if(N===Bi||I.is0())return V.ZERO;if(N===uc)return I;if(K.hasCache(this))return this.multiply(N);if(L){let{k1neg:z,k1:P,k2neg:J,k2:j}=U(N),{p1:Q,p2:E}=nP(V,I,P,j);return B(L.beta,Q,E,z,J)}else return K.unsafe(I,N)}toAffine(N){return T(this,N)}isTorsionFree(){let{isTorsionFree:N}=t;if(s===uc)return!0;if(N)return N(V,this);return K.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:N}=t;if(s===uc)return this;if(N)return N(V,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(N=!0){return Ru(N,"isCompressed"),this.assertValidity(),m(V,this,N)}toHex(N=!0){return js(this.toBytes(N))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let te=n.BITS,K=new ax(V,t.endo?Math.ceil(te/2):te);return V.BASE.precompute(8),V}function lP(e){return Uint8Array.of(e?2:3)}function uP(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function xW(e,t={}){let{Fn:r}=e,i=t.randomBytes||_o,n=Object.assign(uP(e.Fp,r),{seed:rx(r.ORDER)});function o(m){try{let b=r.fromBytes(m);return r.isValidNot0(b)}catch(b){return!1}}function s(m,b){let{publicKey:g,publicKeyUncompressed:S}=n;try{let k=m.length;if(b===!0&&k!==g)return!1;if(b===!1&&k!==S)return!1;return!!e.fromBytes(m)}catch(k){return!1}}function a(m=i(n.seed)){return Q$(De(m,n.seed,"seed"),r.ORDER)}function c(m,b=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(b)}function l(m){let{secretKey:b,publicKey:g,publicKeyUncompressed:S}=n;if(!ic(m))return;if("_lengths"in r&&r._lengths||b===g)return;let k=De(m,void 0,"key").length;return k===g||k===S}function u(m,b,g=!0){if(l(m)===!0)throw Error("first arg must be private key");if(l(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(m);return e.fromBytes(b).multiply(S).toBytes(g)}let f={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=im(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:f,lengths:n})}function fx(e,t,r={}){yn(t),qs(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes||_o,n=r.hmac||((I,z)=>lc(t,I,z)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:f,utils:p,lengths:m}=xW(e,r),b={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*cP<o.ORDER;function S(I){let z=a>>uc;return I>z}function k(I,z){if(!s.isValidNot0(z))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return z}function A(){if(g)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function R(I,z){ux(z);let P=m.signature,J=z==="compact"?P:z==="recovered"?P+1:void 0;return De(I,J)}class D{r;s;recovery;constructor(I,z,P){if(this.r=k("r",I),this.s=k("s",z),P!=null){if(A(),![0,1,2,3].includes(P))throw Error("invalid recovery id");this.recovery=P}Object.freeze(this)}static fromBytes(I,z=b.format){R(I,z);let P;if(z==="der"){let{r:E,s:ae}=To.toSig(De(I));return new D(E,ae)}if(z==="recovered")P=I[0],z="compact",I=I.subarray(1);let J=m.signature/2,j=I.subarray(0,J),Q=I.subarray(J,J*2);return new D(s.fromBytes(j),s.fromBytes(Q),P)}static fromHex(I,z){return this.fromBytes(Us(I),z)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new D(this.r,this.s,I)}recoverPublicKey(I){let{r:z,s:P}=this,J=this.assertRecovery(),j=J===2||J===3?z+a:z;if(!o.isValid(j))throw Error("invalid recovery id: sig.r+curve.n != R.x");let Q=o.toBytes(j),E=e.fromBytes(Ut(lP((J&1)===0),Q)),ae=s.inv(j),fe=T(De(I,void 0,"msgHash")),C=s.create(-fe*ae),xe=s.create(P*ae),Te=e.BASE.multiplyUnsafe(C).add(E.multiplyUnsafe(xe));if(Te.is0())throw Error("invalid recovery: point at infinify");return Te.assertValidity(),Te}hasHighS(){return S(this.s)}toBytes(I=b.format){if(ux(I),I==="der")return Us(To.hexFromSig(this));let{r:z,s:P}=this,J=s.toBytes(z),j=s.toBytes(P);if(I==="recovered")return A(),Ut(Uint8Array.of(this.assertRecovery()),J,j);return Ut(J,j)}toHex(I){return js(this.toBytes(I))}}let U=r.bits2int||function(z){if(z.length>8192)throw Error("input is too large");let P=Eo(z),J=z.length*8-c;return J>0?P>>BigInt(J):P},T=r.bits2int_modN||function(z){return s.create(U(z))},H=Pu(c);function B(I){return $u("num < 2^"+c,I,Bi,H),s.toBytes(I)}function V(I,z){return De(I,void 0,"message"),z?De(t(I),void 0,"prehashed message"):I}function te(I,z,P){let{lowS:J,prehash:j,extraEntropy:Q}=lx(P,b);I=V(I,j);let E=T(I),ae=s.fromBytes(z);if(!s.isValidNot0(ae))throw Error("invalid private key");let fe=[B(ae),B(E)];if(Q!=null&&Q!==!1){let Pe=Q===!0?i(m.secretKey):Q;fe.push(De(Pe,void 0,"extraEntropy"))}let C=Ut(...fe),xe=E;function Te(Pe){let $e=U(Pe);if(!s.isValidNot0($e))return;let _e=s.inv($e),We=e.BASE.multiply($e).toAffine(),Le=s.create(We.x);if(Le===Bi)return;let Xe=s.create(_e*s.create(xe+Le*ae));if(Xe===Bi)return;let dt=(We.x===Le?0:2)|Number(We.y&uc),kt=Xe;if(J&&S(Xe))kt=s.neg(Xe),dt^=1;return new D(Le,kt,g?void 0:dt)}return{seed:C,k2sig:Te}}function K(I,z,P={}){let{seed:J,k2sig:j}=te(I,z,P);return j$(t.outputLen,s.BYTES,n)(J,j).toBytes(P.format)}function N(I,z,P,J={}){let{lowS:j,prehash:Q,format:E}=lx(J,b);if(P=De(P,void 0,"publicKey"),z=V(z,Q),!ic(I)){let ae=I instanceof D?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ae)}R(I,E);try{let ae=D.fromBytes(I,E),fe=e.fromBytes(P);if(j&&ae.hasHighS())return!1;let{r:C,s:xe}=ae,Te=T(z),Pe=s.inv(xe),$e=s.create(Te*Pe),_e=s.create(C*Pe),We=e.BASE.multiplyUnsafe($e).add(fe.multiplyUnsafe(_e));if(We.is0())return!1;return s.create(We.x)===C}catch(ae){return!1}}function L(I,z,P={}){let{prehash:J}=lx(P,b);return z=V(z,J),D.fromBytes(I,"recovered").recoverPublicKey(z).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:f,utils:p,lengths:m,Point:e,sign:K,verify:N,recoverPublicKey:L,Signature:D,hash:t})}function dP(e,t,r){return e&t^~e&r}function fP(e,t,r){return e&t^e&r^t&r}class am{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,i){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=em(this.buffer)}update(e){Li(this),De(e);let{view:t,buffer:r,blockLen:i}=this,n=e.length;for(let o=0;o<n;){let s=Math.min(i-this.pos,n-o);if(s===i){let a=em(e);for(;i<=n-o;o+=i)this.process(a,o);continue}if(r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===i)this.process(t,0),this.pos=0}return this.length+=e.length,this.roundClean(),this}digestInto(e){Li(this),Yp(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Mr(this.buffer.subarray(o)),this.padOffset>i-o)this.process(r,0),o=0;for(let u=o;u<i;u++)t[u]=0;r.setBigUint64(i-8,BigInt(this.length*8),n),this.process(r,0);let s=em(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen must be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],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:i,finished:n,destroyed:o,pos:s}=this;if(e.destroyed=o,e.finished=n,e.length=i,e.pos=s,i%t)e.buffer.set(r);return e}clone(){return this._cloneInto()}}var ji=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var sr=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var cm=BigInt(4294967295),pP=BigInt(32);function wW(e,t=!1){if(t)return{h:Number(e&cm),l:Number(e>>pP&cm)};return{h:Number(e>>pP&cm)|0,l:Number(e&cm)|0}}function lm(e,t=!1){let r=e.length,i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){let{h:s,l:a}=wW(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var px=(e,t,r)=>e>>>r,mx=(e,t,r)=>e<<32-r|t>>>r,Fs=(e,t,r)=>e>>>r|t<<32-r,Hs=(e,t,r)=>e<<32-r|t>>>r,Lu=(e,t,r)=>e<<64-r|t>>>r-32,Bu=(e,t,r)=>e>>>r-32|t<<64-r;var mP=(e,t,r)=>e<<r|t>>>32-r,hP=(e,t,r)=>t<<r|e>>>32-r,gP=(e,t,r)=>t<<r-32|e>>>64-r,yP=(e,t,r)=>e<<r-32|t>>>64-r;function oi(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var bP=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),SP=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,xP=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),wP=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,vP=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),_P=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var _W=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]),Ro=new Uint32Array(64);class kP extends am{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:r,D:i,E:n,F:o,G:s,H:a}=this;return[e,t,r,i,n,o,s,a]}set(e,t,r,i,n,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=n|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)Ro[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let f=Ro[u-15],p=Ro[u-2],m=Pn(f,7)^Pn(f,18)^f>>>3,b=Pn(p,17)^Pn(p,19)^p>>>10;Ro[u]=b+Ro[u-7]+m+Ro[u-16]|0}let{A:r,B:i,C:n,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){let f=Pn(s,6)^Pn(s,11)^Pn(s,25),p=l+f+dP(s,a,c)+_W[u]+Ro[u]|0,b=(Pn(r,2)^Pn(r,13)^Pn(r,22))+fP(r,i,n)|0;l=c,c=a,a=s,s=o+p|0,o=n,n=i,i=r,r=p+b|0}r=r+this.A|0,i=i+this.B|0,n=n+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,i,n,o,s,a,c,l)}roundClean(){Mr(Ro)}destroy(){this.set(0,0,0,0,0,0,0,0),Mr(this.buffer)}}class EP extends kP{A=ji[0]|0;B=ji[1]|0;C=ji[2]|0;D=ji[3]|0;E=ji[4]|0;F=ji[5]|0;G=ji[6]|0;H=ji[7]|0;constructor(){super(32)}}var IP=(()=>lm(["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))))(),kW=(()=>IP[0])(),EW=(()=>IP[1])(),Co=new Uint32Array(80),Oo=new Uint32Array(80);class AP extends am{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:u,Fl:f,Gh:p,Gl:m,Hh:b,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,f,p,m,b,g]}set(e,t,r,i,n,o,s,a,c,l,u,f,p,m,b,g){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=i|0,this.Ch=n|0,this.Cl=o|0,this.Dh=s|0,this.Dl=a|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=f|0,this.Gh=p|0,this.Gl=m|0,this.Hh=b|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)Co[A]=e.getUint32(t),Oo[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let R=Co[A-15]|0,D=Oo[A-15]|0,U=Fs(R,D,1)^Fs(R,D,8)^px(R,D,7),T=Hs(R,D,1)^Hs(R,D,8)^mx(R,D,7),H=Co[A-2]|0,B=Oo[A-2]|0,V=Fs(H,B,19)^Lu(H,B,61)^px(H,B,6),te=Hs(H,B,19)^Bu(H,B,61)^mx(H,B,6),K=xP(T,te,Oo[A-7],Oo[A-16]),N=wP(K,U,V,Co[A-7],Co[A-16]);Co[A]=N|0,Oo[A]=K|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:f,Fh:p,Fl:m,Gh:b,Gl:g,Hh:S,Hl:k}=this;for(let A=0;A<80;A++){let R=Fs(u,f,14)^Fs(u,f,18)^Lu(u,f,41),D=Hs(u,f,14)^Hs(u,f,18)^Bu(u,f,41),U=u&p^~u&b,T=f&m^~f&g,H=vP(k,D,T,EW[A],Oo[A]),B=_P(H,S,R,U,kW[A],Co[A]),V=H|0,te=Fs(r,i,28)^Lu(r,i,34)^Lu(r,i,39),K=Hs(r,i,28)^Bu(r,i,34)^Bu(r,i,39),N=r&n^r&s^n&s,L=i&o^i&a^o&a;S=b|0,k=g|0,b=p|0,g=m|0,p=u|0,m=f|0,{h:u,l:f}=oi(c|0,l|0,B|0,V|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=bP(V,K,L);r=SP(I,B,te,N),i=I|0}({h:r,l:i}=oi(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=oi(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=oi(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=oi(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:f}=oi(this.Eh|0,this.El|0,u|0,f|0),{h:p,l:m}=oi(this.Fh|0,this.Fl|0,p|0,m|0),{h:b,l:g}=oi(this.Gh|0,this.Gl|0,b|0,g|0),{h:S,l:k}=oi(this.Hh|0,this.Hl|0,S|0,k|0),this.set(r,i,n,o,s,a,c,l,u,f,p,m,b,g,S,k)}roundClean(){Mr(Co,Oo)}destroy(){Mr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class TP extends AP{Ah=sr[0]|0;Al=sr[1]|0;Bh=sr[2]|0;Bl=sr[3]|0;Ch=sr[4]|0;Cl=sr[5]|0;Dh=sr[6]|0;Dl=sr[7]|0;Eh=sr[8]|0;El=sr[9]|0;Fh=sr[10]|0;Fl=sr[11]|0;Gh=sr[12]|0;Gl=sr[13]|0;Hh=sr[14]|0;Hl=sr[15]|0;constructor(){super(48)}}var um=oc(()=>new EP,ko(1));var RP=oc(()=>new TP,ko(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var IW=BigInt(1),CP=BigInt(2),AW=BigInt(3),TW=BigInt(5),y_e=BigInt(8),OP=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function RW(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=OP,a=e*e%o*e%o,c=bn(a,CP,o)*a%o,l=bn(c,IW,o)*e%o,u=bn(l,TW,o)*l%o,f=bn(u,t,o)*u%o,p=bn(f,r,o)*f%o,m=bn(p,i,o)*p%o,b=bn(m,n,o)*m%o,g=bn(b,n,o)*m%o,S=bn(g,t,o)*u%o;return{pow_p_5_8:bn(S,CP,o)*e%o,b2:a}}function CW(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var $P=(()=>{let e=OP;return oP({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=RW(t);return Rr(bn(r,AW,e)*i,e)},adjustScalarBytes:CW})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var OW=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),$W=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var PW=dx(OW),hx=fx(PW,um);var zW=dx($W),PP=fx(zW,RP);function NP(e,t,r){if(yn(e),r===void 0)r=new Uint8Array(e.outputLen);return lc(e,r,t)}var gx=Uint8Array.of(0),zP=Uint8Array.of();function DP(e,t,r,i=32){yn(e),Qt(i,"length");let n=e.outputLen;if(i>255*n)throw Error("Length must be <= 255*HashLen");let o=Math.ceil(i/n);if(r===void 0)r=zP;else De(r,void 0,"info");let s=new Uint8Array(o*n),a=lc.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)gx[0]=u+1,c.update(u===0?zP:l).update(r).update(gx).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Mr(l,gx),s.slice(0,i)}var NW=BigInt(0),ju=BigInt(1),DW=BigInt(2),LW=BigInt(7),BW=BigInt(256),jW=BigInt(113),jP=[],UP=[],qP=[];for(let e=0,t=ju,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],jP.push(2*(5*i+r)),UP.push((e+1)*(e+2)/2%64);let n=NW;for(let o=0;o<7;o++)if(t=(t<<ju^(t>>LW)*jW)%BW,t&DW)n^=ju<<(ju<<BigInt(o))-ju;qP.push(n)}var ZP=lm(qP,!0),UW=ZP[0],qW=ZP[1],LP=(e,t,r)=>r>32?gP(e,t,r):mP(e,t,r),BP=(e,t,r)=>r>32?yP(e,t,r):hP(e,t,r);function ZW(e,t=24){let r=new Uint32Array(10);for(let i=24-t;i<24;i++){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,c=(s+2)%10,l=r[c],u=r[c+1],f=LP(l,u,1)^r[a],p=BP(l,u,1)^r[a+1];for(let m=0;m<50;m+=10)e[s+m]^=f,e[s+m+1]^=p}let n=e[2],o=e[3];for(let s=0;s<24;s++){let a=UP[s],c=LP(n,o,a),l=BP(n,o,a),u=jP[s];n=e[u],o=e[u+1],e[u]=c,e[u+1]=l}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]^=UW[i],e[1]^=qW[i]}Mr(r)}class dm{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;enableXOF=!1;rounds;constructor(e,t,r,i=!1,n=24){if(this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=n,Qt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Xp(this.state)}clone(){return this._cloneInto()}keccak(){WS(this.state32),ZW(this.state32,this.rounds),WS(this.state32),this.posOut=0,this.pos=0}update(e){Li(this),De(e);let{blockLen:t,state:r}=this,i=e.length;for(let n=0;n<i;){let o=Math.min(t-this.pos,i-n);for(let s=0;s<o;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:i}=this;if(e[r]^=t,(t&128)!==0&&r===i-1)this.keccak();e[i-1]^=128,this.keccak()}writeInto(e){Li(this,!1),De(e),this.finish();let t=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){if(this.posOut>=r)this.keccak();let o=Math.min(r-this.posOut,n-i);e.set(t.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Qt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Yp(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,Mr(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||=new dm(t,r,i,o,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=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}var MP=(e,t,r,i={})=>oc(()=>new dm(t,e,r),i);var Ks=MP(6,136,32,ko(8));var FP=MP(6,72,64,ko(10));var HP=(e,t,r,i={})=>oc((n={})=>new dm(t,e,n.dkLen===void 0?r:n.dkLen,!0),i),KP=HP(31,168,16,ko(11)),si=HP(31,136,32,ko(12));function yx(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function VP(e){return yx(e),(e&e-1)===0&&e!==0}function bx(e,t){yx(e);let r=0;for(let i=0;i<t;i++,e>>>=1)r=r<<1|e&1;return r}function WP(e){return yx(e),31-Math.clz32(e)}function JP(e){let t=e.length;if(t<2||!VP(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=WP(t);for(let i=0;i<t;i++){let n=bx(i,r);if(i<n){let o=e[i];e[i]=e[n],e[n]=o}}return e}var Sx=(e,t)=>{let{N:r,roots:i,dit:n,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,c=WP(r);if(!VP(r))throw Error("FFT: Polynomial size should be power of two");let l=n!==o;return(u)=>{if(u.length!==r)throw Error("FFT: wrong Polynomial length");if(n&&a)JP(u);for(let f=0,p=1;f<c-s;f++){let m=n?f+1+s:c-f,b=1<<m,g=b>>1,S=r>>m;for(let k=0;k<r;k+=b)for(let A=0,R=p++;A<g;A++){let D=o?n?r-R:R:A*S,U=k+A,T=k+A+g,H=i[D],B=u[T],V=u[U];if(l){let te=e.mul(B,H);u[U]=e.add(V,te),u[T]=e.sub(V,te)}else if(o)u[U]=e.add(B,V),u[T]=e.mul(e.sub(B,V),H);else u[U]=e.add(V,B),u[T]=e.mul(e.sub(V,B),H)}}if(!n&&a)JP(u);return u}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var ai=_o;function fm(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function GP(e){return Uint8Array.from(e)}function Js(e,...t){let r=(n)=>typeof n==="number"?n:n.bytesLen,i=t.reduce((n,o)=>n+r(o),0);return{bytesLen:i,encode:(n)=>{let o=new Uint8Array(i);for(let s=0,a=0;s<t.length;s++){let c=t[s],l=r(c),u=typeof c==="number"?n[s]:c.encode(n[s]);if(De(u,l,e),o.set(u,a),typeof c!=="number")u.fill(0);a+=l}return o},decode:(n)=>{De(n,i,e);let o=[];for(let s of t){let a=r(s),c=n.subarray(0,a);o.push(typeof s==="number"?c:s.decode(c)),n=n.subarray(a)}return o}}}function pm(e,t){let r=t*e.bytesLen;return{bytesLen:r,encode:(i)=>{if(i.length!==t)throw Error(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);let n=new Uint8Array(r);for(let o=0,s=0;o<i.length;o++){let a=e.encode(i[o]);n.set(a,s),a.fill(0),s+=a.length}return n},decode:(i)=>{De(i,r);let n=[];for(let o=0;o<i.length;o+=e.bytesLen)n.push(e.decode(i.subarray(o,o+e.bytesLen)));return n}}}function Ht(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function xx(e){return(1<<e)-1}var $_e=Uint8Array.of();/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var QP=(e)=>{let{newPoly:t,N:r,Q:i,F:n,ROOT_OF_UNITY:o,brvBits:s,isKyber:a}=e,c=(A,R=i)=>{let D=A%R|0;return(D>=0?D|0:R+D|0)|0},l=(A,R=i)=>{let D=c(A,R)|0;return(D>R>>1?D-R|0:D)|0};function u(){let A=t(r);for(let R=0;R<r;R++){let D=bx(R,s),U=BigInt(o)**BigInt(D)%BigInt(i);A[R]=Number(U)|0}return A}let f=u(),p={add:(A,R)=>c((A|0)+(R|0))|0,sub:(A,R)=>c((A|0)-(R|0))|0,mul:(A,R)=>c((A|0)*(R|0))|0,inv:(A)=>{throw Error("not implemented")}},m={N:r,roots:f,invertButterflies:!0,skipStages:a?1:0,brp:!1},b=Sx(p,{dit:!1,...m}),g=Sx(p,{dit:!0,...m});return{mod:c,smod:l,nttZetas:f,NTT:{encode:(A)=>b(A),decode:(A)=>{g(A);for(let R=0;R<A.length;R++)A[R]=c(n*A[R]);return A}},bitsCoder:(A,R)=>{let D=xx(A),U=A*(r/8);return{bytesLen:U,encode:(T)=>{let H=new Uint8Array(U);for(let B=0,V=0,te=0,K=0;B<T.length;B++){V|=(R.encode(T[B])&D)<<te,te+=A;for(;te>=8;te-=8,V>>=8)H[K++]=V&xx(te)}return H},decode:(T)=>{let H=t(r);for(let B=0,V=0,te=0,K=0;B<T.length;B++){V|=T[B]<<te,te+=8;for(;te>=A;te-=A,V>>=A)H[K++]=R.decode(V&D)}return H}}}}},MW=(e)=>(t,r)=>{if(!r)r=e.blockLen;let i=new Uint8Array(t.length+2);i.set(t);let n=t.length,o=new Uint8Array(r),s=e.create({}),a=0,c=0;return{stats:()=>({calls:a,xofs:c}),get:(l,u)=>(i[n+0]=l,i[n+1]=u,s.destroy(),s=e.create({}).update(i),a++,()=>(c++,s.xofInto(o))),clean:()=>{s.destroy(),Ht(o,i)}}},YP=MW(KP);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var Sr=256,Ui=3329,FW=3303,HW=17,{mod:Zu,nttZetas:KW,NTT:Vs,bitsCoder:JW}=QP({N:Sr,Q:Ui,F:FW,ROOT_OF_UNITY:HW,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),wx={512:{N:Sr,Q:Ui,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:Sr,Q:Ui,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:Sr,Q:Ui,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},VW=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Ui/2)/Ui,decode:(r)=>r*Ui+t>>>e}},Uu=(e)=>JW(e,VW(e));function Ws(e,t){for(let r=0;r<Sr;r++)e[r]=Zu(e[r]+t[r])}function WW(e,t){for(let r=0;r<Sr;r++)e[r]=Zu(e[r]-t[r])}function GW(e,t,r,i,n){let o=Zu(t*i*n+e*r),s=Zu(e*i+t*r);return{c0:o,c1:s}}function mm(e,t){for(let r=0;r<Sr/2;r++){let i=KW[64+(r>>1)];if(r&1)i=-i;let{c0:n,c1:o}=GW(e[2*r+0],e[2*r+1],t[2*r+0],t[2*r+1],i);e[2*r+0]=n,e[2*r+1]=o}return e}function XP(e){let t=new Uint16Array(Sr);for(let r=0;r<Sr;){let i=e();if(i.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<Sr&&n+3<=i.length;n+=3){let o=(i[n+0]>>0|i[n+1]<<8)&4095,s=(i[n+1]>>4|i[n+2]<<4)&4095;if(o<Ui)t[r++]=o;if(r<Sr&&s<Ui)t[r++]=s}}return t}function qu(e,t,r,i){let n=e(i*Sr/4,t,r),o=new Uint16Array(Sr),s=Xp(n),a=0;for(let c=0,l=0,u=0,f=0;c<s.length;c++){let p=s[c];for(let m=0;m<32;m++)if(u+=p&1,p>>=1,a+=1,a===i)f=u,u=0;else if(a===2*i)o[l++]=Zu(f-u),u=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return o}var QW=(e)=>{let{K:t,PRF:r,XOF:i,HASH512:n,ETA1:o,ETA2:s,du:a,dv:c}=e,l=Uu(1),u=Uu(c),f=Uu(a),p=Js("publicKey",pm(Uu(12),t),32),m=pm(Uu(12),t),b=Js("ciphertext",pm(f,t),u),g=Js("seed",32,32);return{secretCoder:m,lengths:{secretKey:m.bytesLen,publicKey:p.bytesLen,cipherText:b.bytesLen},keygen:(S)=>{De(S,32,"seed");let k=new Uint8Array(33);k.set(S),k[32]=t;let A=n(k),[R,D]=g.decode(A),U=[],T=[];for(let V=0;V<t;V++)U.push(Vs.encode(qu(r,D,V,o)));let H=i(R);for(let V=0;V<t;V++){let te=Vs.encode(qu(r,D,t+V,o));for(let K=0;K<t;K++){let N=XP(H.get(K,V));Ws(te,mm(N,U[K]))}T.push(te)}H.clean();let B={publicKey:p.encode([T,R]),secretKey:m.encode(U)};return Ht(R,D,U,T,k,A),B},encrypt:(S,k,A)=>{let[R,D]=p.decode(S),U=[];for(let K=0;K<t;K++)U.push(Vs.encode(qu(r,A,K,o)));let T=i(D),H=new Uint16Array(Sr),B=[];for(let K=0;K<t;K++){let N=qu(r,A,t+K,s),L=new Uint16Array(Sr);for(let I=0;I<t;I++){let z=XP(T.get(K,I));Ws(L,mm(z,U[I]))}Ws(N,Vs.decode(L)),B.push(N),Ws(H,mm(R[K],U[K])),Ht(L)}T.clean();let V=qu(r,A,2*t,s);Ws(V,Vs.decode(H));let te=l.decode(k);return Ws(te,V),Ht(R,U,H,V),b.encode([B,te])},decrypt:(S,k)=>{let[A,R]=b.decode(S),D=m.decode(k),U=new Uint16Array(Sr);for(let T=0;T<t;T++)Ws(U,mm(D[T],Vs.encode(A[T])));return WW(R,Vs.decode(U)),Ht(U,D,A),l.encode(R)}}};function vx(e){let t=QW(e),{HASH256:r,HASH512:i,KDF:n}=e,{secretCoder:o,lengths:s}=t,a=Js("secretKey",s.secretKey,s.publicKey,32,32),c=32,l=64;return{info:{type:"ml-kem"},lengths:{...s,seed:64,msg:32,msgRand:32,secretKey:a.bytesLen},keygen:(u=ai(64))=>{De(u,64,"seed");let{publicKey:f,secretKey:p}=t.keygen(u.subarray(0,32)),m=r(f),b=a.encode([p,f,m,u.subarray(32)]);return Ht(p,m),{publicKey:f,secretKey:b}},getPublicKey:(u)=>{let[f,p,m,b]=a.decode(u);return Uint8Array.from(p)},encapsulate:(u,f=ai(32))=>{De(u,s.publicKey,"publicKey"),De(f,32,"message");let p=u.subarray(0,384*e.K),m=o.encode(o.decode(GP(p)));if(!fm(m,p))throw Ht(m),Error("ML-KEM.encapsulate: wrong publicKey modulus");Ht(m);let b=i.create().update(f).update(r(u)).digest(),g=t.encrypt(u,f,b.subarray(32,64));return Ht(b.subarray(32)),{cipherText:g,sharedSecret:b.subarray(0,32)}},decapsulate:(u,f)=>{De(f,a.bytesLen,"secretKey"),De(u,s.cipherText,"cipherText");let p=a.bytesLen-96,m=p+32,b=r(f.subarray(p/2,m));if(!fm(b,f.subarray(m,m+32)))throw Error("invalid secretKey: hash check failed");let[g,S,k,A]=a.decode(f),R=t.decrypt(u,g),D=i.create().update(R).update(k).digest(),U=D.subarray(0,32),T=t.encrypt(S,R,D.subarray(32,64)),H=fm(u,T),B=n.create({dkLen:32}).update(A).update(u).digest();return Ht(R,T,!H?U:B),H?U:B}}}function YW(e,t,r){return si.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var _x={HASH256:Ks,HASH512:FP,KDF:si,XOF:YP,PRF:YW},M_e=vx({..._x,...wx[512]}),Mu=vx({..._x,...wx[768]}),ez=vx({..._x,...wx[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function XW(e,t=!1){let{lengths:r,keygen:i}=e;if(t){let o=e.Point.Fn;if(!o)throw Error("No Point.Fn");i=(s=ai(r.seed))=>{De(s,r.seed,"seed");let a=o.isLE?Io(s):Eo(s),c=o.toBytes(o.create(a));return{secretKey:c,publicKey:e.getPublicKey(c)}}}return{lengths:{secretKey:r.secretKey,publicKey:r.publicKey,seed:r.seed},keygen:i,getPublicKey:(n)=>e.getPublicKey(n)}}function kx(e,t=!1){let r=XW(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(i,n=ai(e.lengths.seed)){let o=this.keygen(n).secretKey,s=this.decapsulate(i,o),a=e.getPublicKey(o);return Ht(o),{sharedSecret:s,cipherText:a}},decapsulate(i,n){let o=e.getSharedSecret(n,i);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function Fu(e,t){return Js(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function Ex(e){return(t,r)=>e(t,{dkLen:r})}function eG(e,t,...r){let i=Fu(r,"seed"),n=Fu(r,"publicKey");if(e===void 0)e=i.bytesLen;Qt(e);function o(s){De(s,e);let a=i.decode(t(s,i.bytesLen)),c=r.map((f,p)=>f.keygen(a[p])),l=c.map((f)=>f.secretKey),u=c.map((f)=>f.publicKey);return{secretKey:l,publicKey:u}}return{info:{lengths:{seed:e,publicKey:n.bytesLen,secretKey:e}},getPublicKey(s){return this.keygen(s).publicKey},keygen(s=ai(e)){let{publicKey:a,secretKey:c}=o(s),l=n.encode(a);return Ht(a),Ht(c),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function hm(e,t,r,i,...n){let o=eG(e,r,...n),s=Fu(n,"cipherText"),a=Fu(n,"publicKey"),c=Fu(n,"msg");if(t===void 0)t=c.bytesLen;return Qt(t),{lengths:{...o.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,u=ai(c.bytesLen)){let f=a.decode(l),p=c.decode(u),m=n.map((k,A)=>k.encapsulate(f[A],p[A])),b=m.map((k)=>k.sharedSecret),g=m.map((k)=>k.cipherText),S={sharedSecret:i(f,g,b),cipherText:s.encode(g)};return Ht(b,g),S},decapsulate(l,u){let f=s.decode(l),{publicKey:p,secretKey:m}=o.expandDecapsulationKey(u),b=n.map((g,S)=>g.decapsulate(f[S],m[S]));return i(p,f,b)}}}function tz(e,t,r,i,n){return yn(i),yn(n),hm(32,32,Ex(i),(o,s,a)=>n(Ut(a[0],a[1],s[1],o[1],Ao(e))),t,r)}var eke=tz("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Mu,kx(hx,!0),si,Ks),tke=tz("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",ez,kx(PP,!0),si,Ks);function tG(e,t,r,i,n){return yn(i),yn(n),hm(32,32,Ex(i),(o,s,a)=>{let c=Ut(a[0],a[1],s[0],o[0],s[1],o[1],Ao(e)),l=32,u=Ut(Ao("hybrid_prk"),c),f=NP(n,u),p=Ut(sc(32,2),Ao("shared_secret"),Ao("")),m=DP(n,f,p,32);return Ht(f,p,u,c),m},t,r)}var rz=kx($P),rke=tG("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Mu,rz,si,um),rG=(()=>hm(32,32,Ex(si),(e,t,r)=>Ks(Ut(r[0],r[1],t[1],e[1],Ao("\\.//^\\"))),Mu,rz))();function nG(e,t,r,i){let n=e.Point.Fn;if(!n)throw Error("no Point.Fn");function o(s){let a;for(let u=0,f=t;;u=f,f+=t){if(f>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(u,f),!0),n.isValidNot0(a))break}let c=n.toBytes(n.create(a)),l=e.getPublicKey(c,!1);return{secretKey:c,publicKey:l}}return{lengths:{secretKey:t,publicKey:r,seed:i,msg:i,cipherText:r},keygen(s=ai(i)){return De(s,i,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=ai(i)){De(a,i,"rand");let{secretKey:c}=o(a),l=this.decapsulate(s,c),u=e.getPublicKey(c,!1);return Ht(c),{sharedSecret:l,cipherText:u}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function iG(e,t,r,i){let{secretKey:n,publicKeyUncompressed:o}=r.lengths;if(!n||!o)throw Error("wrong curve");let s=nG(r,n,o,i),a=64,c=a+i;return hm(32,32,(l)=>{De(l,32);let u=si(l,{dkLen:c}),f=u.subarray(0,a),p=u.subarray(a,c);return Ut(f,p)},(l,u,f)=>Ks(Ut(f[0],f[1],u[1],l[1],Ao(e))),t,s)}var oG=(()=>iG("MLKEM768-P256",Mu,hx,128))();var gm=rG,nz=oG;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var ft=(e,t,r)=>nr(e,t,r),Ax=Pt,dc=Up,ar=(...e)=>CS(...e),fc=(e)=>wu(e),pc=AS,mc=(e)=>Pi(e),bm=BigInt(0),Ix=BigInt(1);function qi(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw TypeError(r+"expected boolean, got type="+typeof e)}return e}function Sm(e){if(typeof e==="bigint"){if(!ym(e))throw RangeError("positive bigint expected, got "+e)}else Ax(e);return e}function ci(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 Hu(e){let t=Sm(e).toString(16);return t.length&1?"0"+t:t}function iz(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?bm:BigInt("0x"+e)}function Gs(e){return iz(Up(e))}function zn(e){return iz(Up($o(nr(e)).reverse()))}function xm(e,t){if(Pt(t),t===0)throw RangeError("zero length");e=Sm(e);let r=e.toString(16);if(r.length>t*2)throw RangeError("number too large");return wu(r.padStart(t*2,"0"))}function Ku(e,t){return xm(e,t).reverse()}function oz(e,t){if(e=ft(e),t=ft(t),e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return r===0}function $o(e){return Uint8Array.from(ft(e))}function wm(e){if(typeof e!=="string")throw TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let i=t.charCodeAt(0);if(t.length!==1||i>127)throw RangeError(`string contains non-ASCII character "${e[r]}" with code ${i} at position ${r}`);return i})}var ym=(e)=>typeof e==="bigint"&&bm<=e;function sG(e,t,r){return ym(e)&&ym(t)&&ym(r)&&t<=e&&e<r}function Zi(e,t,r,i){if(!sG(t,r,i))throw RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function hc(e){if(e<bm)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>bm;e>>=Ix,t+=1);return t}var Ju=(e)=>(Ix<<BigInt(e))-Ix;function sz(e,t,r){if(Pt(e,"hashLen"),Pt(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let i=(S)=>new Uint8Array(S),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,f=()=>{c.fill(1),l.fill(0),u=0},p=(...S)=>r(l,ar(c,...S)),m=(S=n)=>{if(l=p(o,S),c=p(),S.length===0)return;l=p(s,S),c=p()},b=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let S=0,k=[];while(S<t){c=p();let A=c.slice();k.push(A),S+=c.length}return ar(...k)};return(S,k)=>{f(),m(S);let A=void 0;while((A=k(b()))===void 0)m();return f(),A}}function Sn(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw TypeError("expected valid options object");function i(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,o))throw TypeError(`param "${o}" is invalid: expected own property`);let c=e[o];if(a&&c===void 0)return;let l=typeof c;if(l!==s||c===null)throw TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}let n=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));n(t,!1),n(r,!0)}var Tx=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var cr=BigInt(0),Tt=BigInt(1),Qs=BigInt(2),uz=BigInt(3),dz=BigInt(4),fz=BigInt(5),aG=BigInt(7),pz=BigInt(8),cG=BigInt(9),mz=BigInt(16);function xt(e,t){if(t<=cr)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=cr?r:t+r}function xn(e,t,r){if(t<cr)throw Error("pow2: expected non-negative exponent, got "+t);let i=e;while(t-- >cr)i*=i,i%=r;return i}function az(e,t){if(e===cr)throw Error("invert: expected non-zero number");if(t<=cr)throw Error("invert: expected positive modulus, got "+t);let r=xt(e,t),i=t,n=cr,o=Tt,s=Tt,a=cr;while(r!==cr){let l=i/r,u=i-r*l,f=n-s*l,p=o-a*l;i=r,r=u,n=s,o=a,s=f,a=p}if(i!==Tt)throw Error("invert: does not exist");return xt(n,t)}function Rx(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw Error("Cannot find square root")}function hz(e,t){let r=e,i=(r.ORDER+Tt)/dz,n=r.pow(t,i);return Rx(r,n,t),n}function lG(e,t){let r=e,i=(r.ORDER-fz)/pz,n=r.mul(t,Qs),o=r.pow(n,i),s=r.mul(t,o),a=r.mul(r.mul(s,Qs),o),c=r.mul(s,r.sub(a,r.ONE));return Rx(r,c,t),c}function uG(e){let t=vm(e),r=gz(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+aG)/mz;return(a,c)=>{let l=a,u=l.pow(c,s),f=l.mul(u,i),p=l.mul(u,n),m=l.mul(u,o),b=l.eql(l.sqr(f),c),g=l.eql(l.sqr(p),c);u=l.cmov(u,f,b),f=l.cmov(m,p,g);let S=l.eql(l.sqr(f),c),k=l.cmov(u,f,S);return Rx(l,k,c),k}}function gz(e){if(e<uz)throw Error("sqrt is not defined for small field");let t=e-Tt,r=0;while(t%Qs===cr)t/=Qs,r++;let i=Qs,n=vm(e);while(cz(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return hz;let o=n.pow(i,t),s=(t+Tt)/Qs;return function(c,l){let u=c;if(u.is0(l))return l;if(cz(u,l)!==1)throw Error("Cannot find square root");let f=r,p=u.mul(u.ONE,o),m=u.pow(l,t),b=u.pow(l,s);while(!u.eql(m,u.ONE)){if(u.is0(m))return u.ZERO;let g=1,S=u.sqr(m);while(!u.eql(S,u.ONE))if(g++,S=u.sqr(S),g===f)throw Error("Cannot find square root");let k=Tt<<BigInt(f-g-1),A=u.pow(p,k);f=g,p=u.sqr(A),m=u.mul(m,p),b=u.mul(b,A)}return b}}function dG(e){if(e%dz===uz)return hz;if(e%pz===fz)return lG;if(e%mz===cG)return uG(e);return gz(e)}var Mi=(e,t)=>(xt(e,t)&Tt)===Tt,fG=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Cx(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=fG.reduce((i,n)=>(i[n]="function",i),t);if(Sn(e,r),ci(e.BYTES,"BYTES"),ci(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Tt)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function pG(e,t,r){let i=e;if(r<cr)throw Error("invalid exponent, negatives unsupported");if(r===cr)return i.ONE;if(r===Tt)return t;let n=i.ONE,o=t;while(r>cr){if(r&Tt)n=i.mul(n,o);o=i.sqr(o),r>>=Tt}return n}function Vu(e,t,r=!1){let i=e,n=Array(t.length).fill(r?i.ZERO:void 0),o=t.reduce((a,c,l)=>{if(i.is0(c))return a;return n[l]=a,i.mul(a,c)},i.ONE),s=i.inv(o);return t.reduceRight((a,c,l)=>{if(i.is0(c))return a;return n[l]=i.mul(a,n[l]),i.mul(a,c)},s),n}function cz(e,t){let r=e,i=(r.ORDER-Tt)/Qs,n=r.pow(t,i),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),a=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!a)throw Error("invalid Legendre symbol result");return o?1:s?0:-1}function mG(e,t){if(t!==void 0)Ax(t);if(e<=cr)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=hc(e);if(t!==void 0&&t<r)throw Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let i=t!==void 0?t:r,n=Math.ceil(i/8);return{nBitLength:i,nByteLength:n}}var lz=new WeakMap;class Ox{ORDER;BITS;BYTES;isLE;ZERO=cr;ONE=Tt;_lengths;_mod;constructor(e,t={}){if(e<=Tt)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:i,nByteLength:n}=mG(e,r);if(n>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=i,this.BYTES=n,Object.freeze(this)}create(e){return xt(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return cr<=e&&e<this.ORDER}is0(e){return e===cr}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Tt)===Tt}neg(e){return xt(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return xt(e*e,this.ORDER)}add(e,t){return xt(e+t,this.ORDER)}sub(e,t){return xt(e-t,this.ORDER)}mul(e,t){return xt(e*t,this.ORDER)}pow(e,t){return pG(this,e,t)}div(e,t){return xt(e*az(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 az(e,this.ORDER)}sqrt(e){let t=lz.get(this);if(!t)lz.set(this,t=dG(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?Ku(e,this.BYTES):xm(e,this.BYTES)}fromBytes(e,t=!1){ft(e);let{_lengths:r,BYTES:i,isLE:n,ORDER:o,_mod:s}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>i)throw Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=new Uint8Array(i);c.set(e,n?0:c.length-e.length),e=c}if(e.length!==i)throw Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);let a=n?zn(e):Gs(e);if(s)a=xt(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return Vu(this,e)}cmov(e,t,r){return qi(r,"condition"),r?t:e}}Object.freeze(Ox.prototype);function vm(e,t={}){return new Ox(e,t)}function yz(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=Tt)throw Error("field order must be greater than 1");let t=hc(e-Tt);return Math.ceil(t/8)}function $x(e){let t=yz(e);return t+Math.ceil(t/2)}function bz(e,t,r=!1){ft(e);let i=e.length,n=yz(t),o=Math.max($x(t),16);if(i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?zn(e):Gs(e),a=xt(s,t-Tt)+Tt;return r?Ku(a,n):xm(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gc=BigInt(0),Ys=BigInt(1);function Wu(e,t){let r=t.negate();return e?r:t}function Xs(e,t){let r=Vu(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function vz(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function Px(e,t){vz(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Ju(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function Sz(e,t,r){let{windowSize:i,mask:n,maxNumber:o,shiftBy:s}=r,a=Number(e&n),c=e>>s;if(a>i)a-=o,c+=Ys;let l=t*i,u=l+Math.abs(a)-1,f=a===0,p=a<0,m=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:p,isNegF:m,offsetF:l}}var zx=new WeakMap,_z=new WeakMap;function Nx(e){return _z.get(e)||1}function xz(e){if(e!==gc)throw Error("invalid wNAF")}class Gu{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 i=e;while(t>gc){if(t&Ys)r=r.add(i);i=i.double(),t>>=Ys}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=Px(t,this.bits),n=[],o=e,s=o;for(let a=0;a<r;a++){s=o,n.push(s);for(let c=1;c<i;c++)s=s.add(o),n.push(s);o=s.double()}return n}wNAF(e,t,r){if(!this.Fn.isValid(r))throw Error("invalid scalar");let i=this.ZERO,n=this.BASE,o=Px(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:f,offsetF:p}=Sz(r,s,o);if(r=a,l)n=n.add(Wu(f,t[p]));else i=i.add(Wu(u,t[c]))}return xz(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=Px(e,this.bits);for(let o=0;o<n.windows;o++){if(r===gc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=Sz(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return xz(r),i}getPrecomputes(e,t,r){let i=zx.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);zx.set(t,i)}}return i}cached(e,t,r){let i=Nx(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=Nx(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){vz(t,this.bits),_z.set(e,t),zx.delete(e)}hasCache(e){return Nx(e)!==1}}function kz(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>gc||i>gc){if(r&Ys)o=o.add(n);if(i&Ys)s=s.add(n);n=n.double(),r>>=Ys,i>>=Ys}return{p1:o,p2:s}}function wz(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Cx(t),t}else return vm(e,{isLE:r})}function _m(e,t,r={},i){if(i===void 0)i=e==="edwards";if(!t||typeof t!=="object")throw Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let l=t[c];if(!(typeof l==="bigint"&&l>gc))throw Error(`CURVE.${c} must be positive bigint`)}let n=wz(t.p,r.Fp,i),o=wz(t.n,r.Fn,i),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!n.isValid(t[c]))throw Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:o}}function Qu(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}function Yu(e,t){if(ci(e),ci(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 i=t-1;i>=0;i--)r[i]=e&255,e>>>=8;return new Uint8Array(r)}function hG(e,t){let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e[i]^t[i];return r}function gG(e){if(!pc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?wm(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function Dx(e,t,r,i){if(ft(e),ci(r),t=gG(t),t.length>255)t=i(ar(wm("H2C-OVERSIZE-DST-"),t));let{outputLen:n,blockLen:o}=i,s=Math.ceil(r/n);if(r>65535||s>255)throw Error("expand_message_xmd: invalid lenInBytes");let a=ar(t,Yu(t.length,1)),c=new Uint8Array(o),l=Yu(r,2),u=Array(s),f=i(ar(c,e,l,Yu(0,1),a));u[0]=i(ar(f,Yu(1,1),a));for(let m=1;m<s;m++){let b=[hG(f,u[m-1]),Yu(m+1,1),a];u[m]=i(ar(...b))}return ar(...u).slice(0,r)}var Ez="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Iz=(e,t)=>(e+(e>=0?t:-t)/Tz)/t;function yG(e,t,r){Zi("scalar",e,li,r);let[[i,n],[o,s]]=t,a=Iz(s*e,r),c=Iz(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,f=l<li,p=u<li;if(f)l=-l;if(p)u=-u;let m=Ju(Math.ceil(hc(r)/2))+Po;if(l<li||l>=m||u<li||u>=m)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:f,k1:l,k2neg:p,k2:u}}function Bx(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function Lx(e,t){Sn(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(qi(r.lowS,"lowS"),qi(r.prehash,"prehash"),r.format!==void 0)Bx(r.format);return r}class Az extends Error{constructor(e=""){super(e)}}var Nn={Err:Az,_tlv:{encode:(e,t)=>{let{Err:r}=Nn;if(ci(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 i=t.length/2,n=Hu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Hu(n.length/2|128):"";return Hu(e)+o+n+t},decode(e,t){let{Err:r}=Nn;t=ft(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");let n=t[i++],o=!!(n&128),s=0;if(!o)s=n;else{let c=n&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(i,i+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(i+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(i+s)}}},_int:{encode(e){let{Err:t}=Nn;if(Sm(e),e<li)throw new t("integer: negative integers are not allowed");let r=Hu(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}=Nn;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 Gs(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Nn,n=ft(e,void 0,"signature"),{v:o,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=i.decode(2,o),{v:l,l:u}=i.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=Nn,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}};Object.freeze(Nn._tlv);Object.freeze(Nn._int);Object.freeze(Nn);var li=BigInt(0),Po=BigInt(1),Tz=BigInt(2),km=BigInt(3),bG=BigInt(4);function Rz(e,t={}){let r=_m("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:s,n:a}=o;Sn(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:l}=t;if(c){if(!i.is0(o.a)||typeof c.beta!=="bigint"||!Array.isArray(c.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let u=Oz(i,n);function f(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function p(K,N,L){if(l&&N.is0())return Uint8Array.of(0);let{x:I,y:z}=N.toAffine(),P=i.toBytes(I);if(qi(L,"isCompressed"),L){f();let J=!i.isOdd(z);return ar(Cz(J),P)}else return ar(Uint8Array.of(4),P,i.toBytes(z))}function m(K){ft(K,void 0,"Point");let{publicKey:N,publicKeyUncompressed:L}=u,I=K.length,z=K[0],P=K.subarray(1);if(l&&I===1&&z===0)return{x:i.ZERO,y:i.ZERO};if(I===N&&(z===2||z===3)){let J=i.fromBytes(P);if(!i.isValid(J))throw Error("bad point: is not on curve, wrong x");let j=S(J),Q;try{Q=i.sqrt(j)}catch(fe){let C=fe instanceof Error?": "+fe.message:"";throw Error("bad point: is not on curve, sqrt error"+C)}f();let E=i.isOdd(Q);if((z&1)===1!==E)Q=i.neg(Q);return{x:J,y:Q}}else if(I===L&&z===4){let J=i.BYTES,j=i.fromBytes(P.subarray(0,J)),Q=i.fromBytes(P.subarray(J,J*2));if(!k(j,Q))throw Error("bad point: is not on curve");return{x:j,y:Q}}else throw Error(`bad point: got length ${I}, expected compressed=${N} or uncompressed=${L}`)}let b=t.toBytes===void 0?p:t.toBytes,g=t.fromBytes===void 0?m:t.fromBytes;function S(K){let N=i.sqr(K),L=i.mul(N,K);return i.add(i.add(L,i.mul(K,o.a)),o.b)}function k(K,N){let L=i.sqr(N),I=S(K);return i.eql(L,I)}if(!k(o.Gx,o.Gy))throw Error("bad curve params: generator point");let A=i.mul(i.pow(o.a,km),bG),R=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(A,R)))throw Error("bad curve params: a or b");function D(K,N,L=!1){if(!i.isValid(N)||L&&i.is0(N))throw Error(`bad point coordinate ${K}`);return N}function U(K){if(!(K instanceof B))throw Error("Weierstrass Point expected")}function T(K){if(!c||!c.basises)throw Error("no endo");return yG(K,c.basises,n.ORDER)}function H(K,N,L,I,z){return L=new B(i.mul(L.X,K),L.Y,L.Z),N=Wu(I,N),L=Wu(z,L),N.add(L)}class B{static BASE=new B(o.Gx,o.Gy,i.ONE);static ZERO=new B(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(K,N,L){this.X=D("x",K),this.Y=D("y",N,!0),this.Z=D("z",L),Object.freeze(this)}static CURVE(){return o}static fromAffine(K){let{x:N,y:L}=K||{};if(!K||!i.isValid(N)||!i.isValid(L))throw Error("invalid affine point");if(K instanceof B)throw Error("projective point not allowed");if(i.is0(N)&&i.is0(L))return B.ZERO;return new B(N,L,i.ONE)}static fromBytes(K){let N=B.fromAffine(g(ft(K,void 0,"point")));return N.assertValidity(),N}static fromHex(K){return B.fromBytes(fc(K))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(K=8,N=!0){if(te.createCache(this,K),!N)this.multiply(km);return this}assertValidity(){let K=this;if(K.is0()){if(t.allowInfinityPoint&&i.is0(K.X)&&i.eql(K.Y,i.ONE)&&i.is0(K.Z))return;throw Error("bad point: ZERO")}let{x:N,y:L}=K.toAffine();if(!i.isValid(N)||!i.isValid(L))throw Error("bad point: x or y not field elements");if(!k(N,L))throw Error("bad point: equation left != right");if(!K.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:K}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(K)}equals(K){U(K);let{X:N,Y:L,Z:I}=this,{X:z,Y:P,Z:J}=K,j=i.eql(i.mul(N,J),i.mul(z,I)),Q=i.eql(i.mul(L,J),i.mul(P,I));return j&&Q}negate(){return new B(this.X,i.neg(this.Y),this.Z)}double(){let{a:K,b:N}=o,L=i.mul(N,km),{X:I,Y:z,Z:P}=this,J=i.ZERO,j=i.ZERO,Q=i.ZERO,E=i.mul(I,I),ae=i.mul(z,z),fe=i.mul(P,P),C=i.mul(I,z);return C=i.add(C,C),Q=i.mul(I,P),Q=i.add(Q,Q),J=i.mul(K,Q),j=i.mul(L,fe),j=i.add(J,j),J=i.sub(ae,j),j=i.add(ae,j),j=i.mul(J,j),J=i.mul(C,J),Q=i.mul(L,Q),fe=i.mul(K,fe),C=i.sub(E,fe),C=i.mul(K,C),C=i.add(C,Q),Q=i.add(E,E),E=i.add(Q,E),E=i.add(E,fe),E=i.mul(E,C),j=i.add(j,E),fe=i.mul(z,P),fe=i.add(fe,fe),E=i.mul(fe,C),J=i.sub(J,E),Q=i.mul(fe,ae),Q=i.add(Q,Q),Q=i.add(Q,Q),new B(J,j,Q)}add(K){U(K);let{X:N,Y:L,Z:I}=this,{X:z,Y:P,Z:J}=K,j=i.ZERO,Q=i.ZERO,E=i.ZERO,ae=o.a,fe=i.mul(o.b,km),C=i.mul(N,z),xe=i.mul(L,P),Te=i.mul(I,J),Pe=i.add(N,L),$e=i.add(z,P);Pe=i.mul(Pe,$e),$e=i.add(C,xe),Pe=i.sub(Pe,$e),$e=i.add(N,I);let _e=i.add(z,J);return $e=i.mul($e,_e),_e=i.add(C,Te),$e=i.sub($e,_e),_e=i.add(L,I),j=i.add(P,J),_e=i.mul(_e,j),j=i.add(xe,Te),_e=i.sub(_e,j),E=i.mul(ae,$e),j=i.mul(fe,Te),E=i.add(j,E),j=i.sub(xe,E),E=i.add(xe,E),Q=i.mul(j,E),xe=i.add(C,C),xe=i.add(xe,C),Te=i.mul(ae,Te),$e=i.mul(fe,$e),xe=i.add(xe,Te),Te=i.sub(C,Te),Te=i.mul(ae,Te),$e=i.add($e,Te),C=i.mul(xe,$e),Q=i.add(Q,C),C=i.mul(_e,$e),j=i.mul(Pe,j),j=i.sub(j,C),C=i.mul(Pe,xe),E=i.mul(_e,E),E=i.add(E,C),new B(j,Q,E)}subtract(K){return U(K),this.add(K.negate())}is0(){return this.equals(B.ZERO)}multiply(K){let{endo:N}=t;if(!n.isValidNot0(K))throw RangeError("invalid scalar: out of range");let L,I,z=(P)=>te.cached(this,P,(J)=>Xs(B,J));if(N){let{k1neg:P,k1:J,k2neg:j,k2:Q}=T(K),{p:E,f:ae}=z(J),{p:fe,f:C}=z(Q);I=ae.add(C),L=H(N.beta,E,fe,P,j)}else{let{p:P,f:J}=z(K);L=P,I=J}return Xs(B,[L,I])[0]}multiplyUnsafe(K){let{endo:N}=t,L=this,I=K;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===li||L.is0())return B.ZERO;if(I===Po)return L;if(te.hasCache(this))return this.multiply(I);if(N){let{k1neg:z,k1:P,k2neg:J,k2:j}=T(I),{p1:Q,p2:E}=kz(B,L,P,j);return H(N.beta,Q,E,z,J)}else return te.unsafe(L,I)}toAffine(K){let N=this,L=K,{X:I,Y:z,Z:P}=N;if(i.eql(P,i.ONE))return{x:I,y:z};let J=N.is0();if(L==null)L=J?i.ONE:i.inv(P);let j=i.mul(I,L),Q=i.mul(z,L),E=i.mul(P,L);if(J)return{x:i.ZERO,y:i.ZERO};if(!i.eql(E,i.ONE))throw Error("invZ was invalid");return{x:j,y:Q}}isTorsionFree(){let{isTorsionFree:K}=t;if(s===Po)return!0;if(K)return K(B,this);return te.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:K}=t;if(s===Po)return this;if(K)return K(B,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Po)return this.is0();return this.clearCofactor().is0()}toBytes(K=!0){return qi(K,"isCompressed"),this.assertValidity(),b(B,this,K)}toHex(K=!0){return dc(this.toBytes(K))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let V=n.BITS,te=new Gu(B,t.endo?Math.ceil(V/2):V);if(V>=8)B.BASE.precompute(8);return Object.freeze(B.prototype),Object.freeze(B),B}function Cz(e){return Uint8Array.of(e?2:3)}function Oz(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function SG(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?mc:t.randomBytes,n=Object.assign(Oz(e.Fp,r),{seed:Math.max($x(r.ORDER),16)});function o(m){try{let b=r.fromBytes(m);return r.isValidNot0(b)}catch(b){return!1}}function s(m,b){let{publicKey:g,publicKeyUncompressed:S}=n;try{let k=m.length;if(b===!0&&k!==g)return!1;if(b===!1&&k!==S)return!1;return!!e.fromBytes(m)}catch(k){return!1}}function a(m){return m=m===void 0?i(n.seed):m,bz(ft(m,n.seed,"seed"),r.ORDER)}function c(m,b=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(b)}function l(m){let{secretKey:b,publicKey:g,publicKeyUncompressed:S}=n,k=r._lengths;if(!pc(m))return;let A=ft(m,void 0,"key").length,R=A===g||A===S,D=A===b||!!k?.includes(A);if(R&&D)return;return R}function u(m,b,g=!0){if(l(m)===!0)throw Error("first arg must be private key");if(l(b)===!1)throw Error("second arg must be public key");let S=r.fromBytes(m);return e.fromBytes(b).multiply(S).toBytes(g)}let f={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},p=Qu(a,c);return Object.freeze(f),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:p,Point:e,utils:f,lengths:n})}function $z(e,t,r={}){let i=t;$i(i),Sn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?mc:r.randomBytes,o=r.hmac===void 0?(z,P)=>ri(i,z,P):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:l}=a,{keygen:u,getPublicKey:f,getSharedSecret:p,utils:m,lengths:b}=SG(e,r),g={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=c*Tz+Po<s.ORDER;function k(z){let P=c>>Po;return z>P}function A(z,P){if(!a.isValidNot0(P))throw Error(`invalid signature ${z}: out of range 1..Point.Fn.ORDER`);return P}function R(){if(S)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function D(z,P){Bx(P);let J=b.signature,j=P==="compact"?J:P==="recovered"?J+1:void 0;return ft(z,j)}class U{r;s;recovery;constructor(z,P,J){if(this.r=A("r",z),this.s=A("s",P),J!=null){if(R(),![0,1,2,3].includes(J))throw Error("invalid recovery id");this.recovery=J}Object.freeze(this)}static fromBytes(z,P=g.format){D(z,P);let J;if(P==="der"){let{r:ae,s:fe}=Nn.toSig(ft(z));return new U(ae,fe)}if(P==="recovered")J=z[0],P="compact",z=z.subarray(1);let j=b.signature/2,Q=z.subarray(0,j),E=z.subarray(j,j*2);return new U(a.fromBytes(Q),a.fromBytes(E),J)}static fromHex(z,P){return this.fromBytes(fc(z),P)}assertRecovery(){let{recovery:z}=this;if(z==null)throw Error("invalid recovery id: must be present");return z}addRecoveryBit(z){return new U(this.r,this.s,z)}recoverPublicKey(z){let{r:P,s:J}=this,j=this.assertRecovery(),Q=j===2||j===3?P+c:P;if(!s.isValid(Q))throw Error("invalid recovery id: sig.r+curve.n != R.x");let E=s.toBytes(Q),ae=e.fromBytes(ar(Cz((j&1)===0),E)),fe=a.inv(Q),C=H(ft(z,void 0,"msgHash")),xe=a.create(-C*fe),Te=a.create(J*fe),Pe=e.BASE.multiplyUnsafe(xe).add(ae.multiplyUnsafe(Te));if(Pe.is0())throw Error("invalid recovery: point at infinify");return Pe.assertValidity(),Pe}hasHighS(){return k(this.s)}toBytes(z=g.format){if(Bx(z),z==="der")return fc(Nn.hexFromSig(this));let{r:P,s:J}=this,j=a.toBytes(P),Q=a.toBytes(J);if(z==="recovered")return R(),ar(Uint8Array.of(this.assertRecovery()),j,Q);return ar(j,Q)}toHex(z){return dc(this.toBytes(z))}}Object.freeze(U.prototype),Object.freeze(U);let T=r.bits2int===void 0?function(P){if(P.length>8192)throw Error("input is too large");let J=Gs(P),j=P.length*8-l;return j>0?J>>BigInt(j):J}:r.bits2int,H=r.bits2int_modN===void 0?function(P){return a.create(T(P))}:r.bits2int_modN,B=Ju(l);function V(z){return Zi("num < 2^"+l,z,li,B),a.toBytes(z)}function te(z,P){return ft(z,void 0,"message"),P?ft(i(z),void 0,"prehashed message"):z}function K(z,P,J){let{lowS:j,prehash:Q,extraEntropy:E}=Lx(J,g);z=te(z,Q);let ae=H(z),fe=a.fromBytes(P);if(!a.isValidNot0(fe))throw Error("invalid private key");let C=[V(fe),V(ae)];if(E!=null&&E!==!1){let $e=E===!0?n(b.secretKey):E;C.push(ft($e,void 0,"extraEntropy"))}let xe=ar(...C),Te=ae;function Pe($e){let _e=T($e);if(!a.isValidNot0(_e))return;let We=a.inv(_e),Le=e.BASE.multiply(_e).toAffine(),Xe=a.create(Le.x);if(Xe===li)return;let dt=a.create(We*a.create(Te+Xe*fe));if(dt===li)return;let kt=(Le.x===Xe?0:2)|Number(Le.y&Po),jt=dt;if(j&&k(dt))jt=a.neg(dt),kt^=1;return new U(Xe,jt,S?void 0:kt)}return{seed:xe,k2sig:Pe}}function N(z,P,J={}){let{seed:j,k2sig:Q}=K(z,P,J);return sz(i.outputLen,a.BYTES,o)(j,Q).toBytes(J.format)}function L(z,P,J,j={}){let{lowS:Q,prehash:E,format:ae}=Lx(j,g);if(J=ft(J,void 0,"publicKey"),P=te(P,E),!pc(z)){let fe=z instanceof U?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+fe)}D(z,ae);try{let fe=U.fromBytes(z,ae),C=e.fromBytes(J);if(Q&&fe.hasHighS())return!1;let{r:xe,s:Te}=fe,Pe=H(P),$e=a.inv(Te),_e=a.create(Pe*$e),We=a.create(xe*$e),Le=e.BASE.multiplyUnsafe(_e).add(C.multiplyUnsafe(We));if(Le.is0())return!1;return a.create(Le.x)===xe}catch(fe){return!1}}function I(z,P,J={}){let{prehash:j}=Lx(J,g);return P=te(P,j),U.fromBytes(z,"recovered").recoverPublicKey(P).toBytes()}return Object.freeze({keygen:u,getPublicKey:f,getSharedSecret:p,utils:m,lengths:b,Point:e,sign:N,verify:L,recoverPublicKey:I,Signature:U,hash:i})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var xG=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var wG=Rz(xG),yc=$z(wG,zt);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var zo=BigInt(0),Fr=BigInt(1),jx=BigInt(2),vG=BigInt(8);function _G(e,t,r,i){let n=e.sqr(r),o=e.sqr(i),s=e.add(e.mul(t.a,n),o),a=e.add(e.ONE,e.mul(t.d,e.mul(n,o)));return e.eql(s,a)}function Pz(e,t={}){let r=t,i=_m("edwards",e,r,r.FpFnLE),{Fp:n,Fn:o}=i,s=i.CURVE,{h:a}=s;Sn(r,{},{uvRatio:"function"});let c=jx<<BigInt(o.BYTES*8)-Fr,l=(g)=>n.create(g),u=r.uvRatio===void 0?(g,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(g,S))}}catch(k){return{isValid:!1,value:zo}}}:r.uvRatio;if(!_G(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function f(g,S,k=!1){let A=k?Fr:zo;return Zi("coordinate "+g,S,A,c),S}function p(g){if(!(g instanceof m))throw Error("EdwardsPoint expected")}class m{static BASE=new m(s.Gx,s.Gy,Fr,l(s.Gx*s.Gy));static ZERO=new m(zo,Fr,Fr,zo);static Fp=n;static Fn=o;X;Y;Z;T;constructor(g,S,k,A){this.X=f("x",g),this.Y=f("y",S),this.Z=f("z",k,!0),this.T=f("t",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){if(g instanceof m)throw Error("extended point not allowed");let{x:S,y:k}=g||{};return f("x",S),f("y",k),new m(S,k,Fr,l(S*k))}static fromBytes(g,S=!1){let k=n.BYTES,{a:A,d:R}=s;g=$o(ft(g,k,"point")),qi(S,"zip215");let D=$o(g),U=g[k-1];D[k-1]=U&-129;let T=zn(D),H=S?c:n.ORDER;Zi("point.y",T,zo,H);let B=l(T*T),V=l(B-Fr),te=l(R*B-A),{isValid:K,value:N}=u(V,te);if(!K)throw Error("bad point: invalid y coordinate");let L=(N&Fr)===Fr,I=(U&128)!==0;if(!S&&N===zo&&I)throw Error("bad point: x=0 and x_0=1");if(I!==L)N=l(-N);return m.fromAffine({x:N,y:T})}static fromHex(g,S=!1){return m.fromBytes(fc(g),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,S=!0){if(b.createCache(this,g),!S)this.multiply(jx);return this}assertValidity(){let g=this,{a:S,d:k}=s;if(g.is0())throw Error("bad point: ZERO");let{X:A,Y:R,Z:D,T:U}=g,T=l(A*A),H=l(R*R),B=l(D*D),V=l(B*B),te=l(T*S),K=l(B*l(te+H)),N=l(V+l(k*l(T*H)));if(K!==N)throw Error("bad point: equation left != right (1)");let L=l(A*R),I=l(D*U);if(L!==I)throw Error("bad point: equation left != right (2)")}equals(g){p(g);let{X:S,Y:k,Z:A}=this,{X:R,Y:D,Z:U}=g,T=l(S*U),H=l(R*A),B=l(k*U),V=l(D*A);return T===H&&B===V}is0(){return this.equals(m.ZERO)}negate(){return new m(l(-this.X),this.Y,this.Z,l(-this.T))}double(){let{a:g}=s,{X:S,Y:k,Z:A}=this,R=l(S*S),D=l(k*k),U=l(jx*l(A*A)),T=l(g*R),H=S+k,B=l(l(H*H)-R-D),V=T+D,te=V-U,K=T-D,N=l(B*te),L=l(V*K),I=l(B*K),z=l(te*V);return new m(N,L,z,I)}add(g){p(g);let{a:S,d:k}=s,{X:A,Y:R,Z:D,T:U}=this,{X:T,Y:H,Z:B,T:V}=g,te=l(A*T),K=l(R*H),N=l(U*k*V),L=l(D*B),I=l((A+R)*(T+H)-te-K),z=L-N,P=L+N,J=l(K-S*te),j=l(I*z),Q=l(P*J),E=l(I*J),ae=l(z*P);return new m(j,Q,ae,E)}subtract(g){return p(g),this.add(g.negate())}multiply(g){if(!o.isValidNot0(g))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:k}=b.cached(this,g,(A)=>Xs(m,A));return Xs(m,[S,k])[0]}multiplyUnsafe(g){if(!o.isValid(g))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(g===zo)return m.ZERO;if(this.is0()||g===Fr)return this;return b.unsafe(this,g,(S)=>Xs(m,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return b.unsafe(this,s.n).is0()}toAffine(g){let S=this,k=g,{X:A,Y:R,Z:D}=S,U=S.is0();if(k==null)k=U?vG:n.inv(D);let T=l(A*k),H=l(R*k),B=n.mul(D,k);if(U)return{x:zo,y:Fr};if(B!==Fr)throw Error("invZ was invalid");return{x:T,y:H}}clearCofactor(){if(a===Fr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:g,y:S}=this.toAffine(),k=n.toBytes(S);return k[k.length-1]|=g&Fr?128:0,k}toHex(){return dc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let b=new Gu(m,o.BITS);if(o.BITS>=8)m.BASE.precompute(8);return Object.freeze(m.prototype),Object.freeze(m),m}class Ux{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){Tx()}static fromHex(e){Tx()}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 dc(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 Xu=BigInt(0),bc=BigInt(1),Em=BigInt(2);function kG(e){return Sn(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function zz(e){let t=kG(e),{P:r,type:i,adjustScalarBytes:n,powPminus2:o,randomBytes:s}=t,a=i==="x25519";if(!a&&i!=="x448")throw Error("invalid type");let c=s===void 0?mc:s,l=a?255:448,u=a?32:56,f=a?BigInt(9):BigInt(5),p=a?BigInt(121665):BigInt(39081),m=a?Em**BigInt(254):Em**BigInt(447),b=a?BigInt(8)*Em**BigInt(251)-bc:BigInt(4)*Em**BigInt(445)-bc,g=m+b+bc,S=(I)=>xt(I,r),k=A(f);function A(I){return Ku(S(I),u)}function R(I){let z=$o(ft(I,u,"uCoordinate"));if(a)z[31]&=127;return S(zn(z))}function D(I){return zn(n($o(ft(I,u,"scalar"))))}function U(I,z){let P=te(R(z),D(I));if(P===Xu)throw Error("invalid private or public key received");return A(P)}function T(I){return U(I,k)}let H=T,B=U;function V(I,z,P){let J=S(I*(z-P));return z=S(z-J),P=S(P+J),{x_2:z,x_3:P}}function te(I,z){Zi("u",I,Xu,r),Zi("scalar",z,m,g);let P=z,J=I,j=bc,Q=Xu,E=I,ae=bc,fe=Xu;for(let xe=BigInt(l-1);xe>=Xu;xe--){let Te=P>>xe&bc;fe^=Te,{x_2:j,x_3:E}=V(fe,j,E),{x_2:Q,x_3:ae}=V(fe,Q,ae),fe=Te;let Pe=j+Q,$e=S(Pe*Pe),_e=j-Q,We=S(_e*_e),Le=$e-We,Xe=E+ae,dt=E-ae,kt=S(dt*Pe),jt=S(Xe*_e),yt=kt+jt,hr=kt-jt;E=S(yt*yt),ae=S(J*S(hr*hr)),j=S($e*We),Q=S(Le*($e+S(p*Le)))}({x_2:j,x_3:E}=V(fe,j,E)),{x_2:Q,x_3:ae}=V(fe,Q,ae);let C=o(Q);return S(j*C)}let K={secretKey:u,publicKey:u,seed:u},N=(I)=>(I=I===void 0?c(u):I,ft(I,K.seed,"seed"),I),L={randomSecretKey:N};return Object.freeze(K),Object.freeze(L),Object.freeze({keygen:Qu(N,H),getSharedSecret:B,getPublicKey:H,scalarMult:U,scalarMultBase:T,utils:L,GuBytes:k.slice(),lengths:K})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var EG=BigInt(0),Fi=BigInt(1),Nz=BigInt(2),IG=BigInt(3),AG=BigInt(5),TG=BigInt(8),ta=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Fx=(()=>({p:ta,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:TG,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function Bz(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=ta,a=e*e%o*e%o,c=xn(a,Nz,o)*a%o,l=xn(c,Fi,o)*e%o,u=xn(l,AG,o)*l%o,f=xn(u,t,o)*u%o,p=xn(f,r,o)*f%o,m=xn(p,i,o)*p%o,b=xn(m,n,o)*m%o,g=xn(b,n,o)*m%o,S=xn(g,t,o)*u%o;return{pow_p_5_8:xn(S,Nz,o)*e%o,b2:a}}function RG(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var qx=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Hx(e,t){let r=ta,i=xt(t*t*t,r),n=xt(i*i*t,r),o=Bz(e*n).pow_p_5_8,s=xt(e*i*o,r),a=xt(t*s*s,r),c=s,l=xt(s*qx,r),u=a===e,f=a===xt(-e,r),p=a===xt(-e*qx,r);if(u)s=c;if(f||p)s=l;if(Mi(s,r))s=xt(-s,r);return{isValid:u||f,value:s}}var ea=Pz(Fx,{uvRatio:Hx}),No=(()=>ea.Fp)(),jz=(()=>ea.Fn)();var Im=(()=>{let e=ta;return zz({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=Bz(t);return xt(xn(r,IG,e)*i,e)},adjustScalarBytes:RG})})();var Zx=qx,CG=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),OG=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),$G=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),PG=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Dz=(e)=>Hx(Fi,e),zG=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Mx=(e)=>No.create(zn(e)&zG);function Lz(e){let{d:t}=Fx,r=ta,i=(k)=>No.create(k),n=i(Zx*e*e),o=i((n+Fi)*$G),s=BigInt(-1),a=i((s-t*n)*i(n+t)),{isValid:c,value:l}=Hx(o,a),u=i(l*e);if(!Mi(u,r))u=i(-u);if(!c)l=u;if(!c)s=n;let f=i(s*(n-Fi)*PG-a),p=l*l,m=i((l+l)*a),b=i(f*CG),g=i(Fi-p),S=i(Fi+p);return new ea(i(m*S),i(g*b),i(b*S),i(m*g))}class Or extends Ux{static BASE=(()=>new Or(ea.BASE))();static ZERO=(()=>new Or(ea.ZERO))();static Fp=(()=>No)();static Fn=(()=>jz)();constructor(e){super(e)}static fromAffine(e){return new Or(ea.fromAffine(e))}assertSame(e){if(!(e instanceof Or))throw Error("RistrettoPoint expected")}init(e){return new Or(e)}static fromBytes(e){nr(e,32);let{a:t,d:r}=Fx,i=ta,n=(R)=>No.create(R),o=Mx(e);if(!oz(No.toBytes(o),e)||Mi(o,i))throw Error("invalid ristretto255 encoding 1");let s=n(o*o),a=n(Fi+t*s),c=n(Fi-t*s),l=n(a*a),u=n(c*c),f=n(t*r*l-u),{isValid:p,value:m}=Dz(n(f*u)),b=n(m*c),g=n(m*b*f),S=n((o+o)*b);if(Mi(S,i))S=n(-S);let k=n(a*g),A=n(S*k);if(!p||Mi(A,i)||k===EG)throw Error("invalid ristretto255 encoding 2");return new Or(new ea(S,k,Fi,A))}static fromHex(e){return Or.fromBytes(wu(e))}toBytes(){let{X:e,Y:t,Z:r,T:i}=this.ep,n=ta,o=(g)=>No.create(g),s=o(o(r+t)*o(r-t)),a=o(e*t),c=o(a*a),{value:l}=Dz(o(s*c)),u=o(l*s),f=o(l*a),p=o(u*f*i),m;if(Mi(i*p,n)){let g=o(t*Zx),S=o(e*Zx);e=g,t=S,m=o(u*OG)}else m=f;if(Mi(e*p,n))t=o(-t);let b=o((r-t)*m);if(Mi(b,n))b=o(-b);return No.toBytes(b)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:n}=e.ep,o=(c)=>No.create(c),s=o(t*n)===o(r*i),a=o(r*n)===o(t*i);return s||a}is0(){return this.equals(Or.ZERO)}}Object.freeze(Or.BASE);Object.freeze(Or.ZERO);Object.freeze(Or.prototype);Object.freeze(Or);var NG=Object.freeze({Point:Or,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,i=Dx(e,r,64,Fp);return NG.deriveToCurve(i)},hashToScalar(e,t={DST:Ez}){let r=Dx(e,t.DST,64,Fp);return jz.create(zn(r))},deriveToCurve(e){nr(e,64);let t=Mx(e.subarray(0,32)),r=Lz(t),i=Mx(e.subarray(32,64)),n=Lz(i);return new Or(r.add(n))}});var Uz=!1,DG=!1;async function qz(e,t){if(DG)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 Am(e,t){return await qz(async()=>{let r=Kx(e)?e:await BG(e),i=await crypto.subtle.importKey("raw",jG(t),{name:"X25519"},Uz,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},r,256))},()=>{if(Kx(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Im.scalarMult(e,t)})}async function ed(e){return await qz(async()=>Am(e,Im.GuBytes),()=>{if(Kx(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Im.scalarMultBase(e)})}var LG=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function BG(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...LG,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},Uz,["deriveBits"])}function Kx(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function jG(e){return e}class Jx{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),qG(ra(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=ra(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:ra(this.transcript)}}}function qG(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function ra(e){let t=e.reduce((n,o)=>n+o.length,0),r=new Uint8Array(t),i=0;for(let n of e)r.set(n,i),i+=n.length;return r}function Sc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let i of t)r.enqueue(i)}}))}function Tm(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function Vx(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function Zz(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function Mz(e,t){let r=e.getReader(),i=[],n=0;while(n<t){let{done:c,value:l}=await r.read();if(c)throw Error("stream ended before reading "+t.toString()+" bytes");i.push(l),n+=l.length}r.releaseLock();let o=ra(i),s=o.subarray(0,t),a=Sc(e,o.subarray(t));return{data:s,rest:a}}class ui{args;body;constructor(e,t){this.args=e,this.body=t}}async function ZG(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 o of r)if(o.length===0)throw Error("invalid stanza");let i=[];for(;;){let o=await e.readLine();if(o===null)throw Error("invalid stanza");let s=yr.decode(o);if(s.length>48)throw Error("invalid stanza");if(i.push(s),s.length<48)break}let n=ra(i);return{s:new ui(r,n)}}async function Fz(e){let t=new Jx(e),r=await t.readLine();if(r!=="age-encryption.org/v1")throw Error("invalid version "+(r??"line"));let i=[];for(;;){let{s:n,next:o}=await ZG(t);if(n!==void 0){i.push(n);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=yr.decode(o.slice(4)),{rest:a,transcript:c}=t.close(),l=c.slice(0,c.length-1-o.length+3);return{stanzas:i,headerNoMAC:l,MAC:s,headerSize:c.length,rest:Sc(e,a)}}}function Wx(e){let t=[];t.push(`age-encryption.org/v1
737
737
  `);for(let r of e){t.push("-> "+r.args.join(" ")+`
738
738
  `);for(let i=0;i<r.body.length;i+=48){let n=i+48;if(n>r.body.length)n=r.body.length;t.push(yr.encode(r.body.subarray(i,n))+`
739
739
  `)}if(r.body.length%48===0)t.push(`
package/dist/index.js CHANGED
@@ -743,7 +743,7 @@ printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
743
743
  `),o}async function M9(e,t){let r=await Et(e),i=r.users.find((n)=>n.handle===t);if(!i)throw Error(`Unknown pilot user: ${t}`);return{pilot:r.pilot,user:i}}async function F9(e){let t=await Cve(Ri(Ove(),"brains-ops-watchdog-smoke-")),r=Ri(t,"id_ed25519"),i=Ri(t,"known_hosts");try{let n=encodeURIComponent(`brain=${e.target.pilot.contentRepoPrefix}${e.target.user.handle}`),o=await e.fetchImpl(`https://api.hetzner.cloud/v1/servers?label_selector=${n}`,{headers:{Authorization:`Bearer ${e.environment.HCLOUD_TOKEN}`}});if(!o.ok)throw Error(`Hetzner server lookup failed with ${o.status}`);let s=$ve.parse(await o.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 wu(r,Nve(e.environment.KAMAL_SSH_PRIVATE_KEY),{mode:384}),await Rve(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 wu(i,c.stdout,{mode:384}),{temporaryRoot:t,sshKeyPath:r,knownHostsPath:i,serverIp:a.public_net.ipv4.ip,commandRunner:e.commandRunner}}catch(n){throw await XO(t,{recursive:!0,force:!0}),n}}async function YO(e,t,r){return e.commandRunner("ssh",[...H9(e),`root@${e.serverIp}`,"bash","-s","--",t,r],{stdin:e$()})}async function Pve(e,t,r){return e.commandRunner("scp",[...H9(e),"-r",`root@${e.serverIp}:${t}/.`,r])}function H9(e){return["-i",e.sshKeyPath,"-o","BatchMode=yes","-o","IdentitiesOnly=yes","-o","ConnectTimeout=10","-o","StrictHostKeyChecking=yes","-o",`UserKnownHostsFile=${e.knownHostsPath}`]}async function zve(e){try{return await Tve(e),!0}catch{return!1}}async function TS(e,t,r){await Promise.all([wu(Ri(e,`${t}.stdout.log`),r.stdout),wu(Ri(e,`${t}.stderr.log`),r.stderr)])}function Nve(e){return`${e.replace(/\r\n/g,`
744
744
  `).replace(/\\n/g,`
745
745
  `).trimEnd()}
746
- `}var U9,$ve;var CS=x(async()=>{Ae();D9();yn();Dp();await N9();U9=d.object({HCLOUD_TOKEN:d.string().min(1),KAMAL_SSH_PRIVATE_KEY:d.string().min(1)}),$ve=d.object({servers:d.array(d.object({status:d.string(),public_net:d.object({ipv4:d.object({ip:d.string().min(1)})})}))})});import{access as UL,chmod as jE,mkdir as Bh,readFile as ZL,writeFile as qL}from"fs/promises";import{dirname as ZX,join as Uc}from"path";import{fileURLToPath as MX}from"url";var qp={name:"@rizom/ops",version:"0.2.0-alpha.637",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"};Ls();jc();var FX=["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/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"],UE=new Set([".kamal/hooks/pre-deploy"]),HX=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),KX=MX(new URL("../templates/rover-pilot/",import.meta.url)),JX=[`service: rover
746
+ `}var U9,$ve;var CS=x(async()=>{Ae();D9();yn();Dp();await N9();U9=d.object({HCLOUD_TOKEN:d.string().min(1),KAMAL_SSH_PRIVATE_KEY:d.string().min(1)}),$ve=d.object({servers:d.array(d.object({status:d.string(),public_net:d.object({ipv4:d.object({ip:d.string().min(1)})})}))})});import{access as UL,chmod as jE,mkdir as Bh,readFile as ZL,writeFile as qL}from"fs/promises";import{dirname as ZX,join as Uc}from"path";import{fileURLToPath as MX}from"url";var qp={name:"@rizom/ops",version:"0.2.0-alpha.638",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"};Ls();jc();var FX=["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/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"],UE=new Set([".kamal/hooks/pre-deploy"]),HX=new Set(["cohorts/cohort-1.yaml","users/alice.yaml","docs/canonical-crossover-record.md"]),KX=MX(new URL("../templates/rover-pilot/",import.meta.url)),JX=[`service: rover
747
747
  image: <%= ENV['IMAGE_REPOSITORY'] %>
748
748
 
749
749
  servers:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rizom/ops",
3
- "version": "0.2.0-alpha.637",
3
+ "version": "0.2.0-alpha.638",
4
4
  "description": "Operator CLI for managing private brain fleet registry repos",
5
5
  "keywords": [
6
6
  "brains",