@rizom/ops 0.2.0-alpha.396 → 0.2.0-alpha.397

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.
@@ -765,7 +765,7 @@ printf 'REMOTE_ARTIFACT_DIR=%s\\n' "$remote_dir"
765
765
  `).replace(/\\n/g,`
766
766
  `).trimEnd()}
767
767
  `}var JK,kSe;var kO=v(async()=>{Je();MK();qo();Np();await UK();JK=h.object({HCLOUD_TOKEN:h.string().min(1),KAMAL_SSH_PRIVATE_KEY:h.string().min(1)}),kSe=h.object({servers:h.array(h.object({status:h.string(),public_net:h.object({ipv4:h.object({ip:h.string().min(1)})})}))})});import{parseArgs as OV}from"util";function xt(e){return e}class qp extends Error{constructor(e){super(e);this.name="CliUsageError"}}function RV(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 PV(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 NV(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 $O(e,t){let r=RV(t.commands,t.globalFlags??{}),i,n;try{({values:i,positionals:n}=OV({args:e,options:PV(r),allowPositionals:!0,strict:t.strict??!0}))}catch(s){if(NV(s))throw new qp(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 CO(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 zV(e){return CO(e.map((t)=>({label:t.usage?`${t.name} ${t.usage}`:t.name,description:t.description})))}function LV(e,t){let r=t.type==="string"?` ${t.placeholder??"<value>"}`:"",i=t.short!==void 0?`, -${t.short}`:"";return`--${e}${r}${i}`}function TO(e){return CO(Object.entries(e).map(([t,r])=>({label:LV(t,r),description:r.description})))}function OO(e,t){return`Usage: ${e} ${t.name}${t.usage?` ${t.usage}`:""}`}function DV(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 BV(e){let t=[],r=new Map;for(let n of e){let o=n.flags??{};if(Object.keys(o).length===0)continue;let s=DV(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(...TO(n.flags));return i}function RO(e){let t=[e.intro,"",`Usage: ${e.cliName} ${e.usage??"<command> [args]"}`,"","Commands:",...zV(e.commands)];if(e.globalFlags&&Object.keys(e.globalFlags).length>0)t.push("","Options:",...TO(e.globalFlags));return t.push(...BV(e.commands)),t.join(`
768
- `)}function PO(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 wt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function Iu(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var jp={name:"@rizom/ops",version:"0.2.0-alpha.396",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/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 run build && 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 pG,mkdirSync as mG,readFileSync as dw,writeFileSync as fw}from"fs";import{dirname as hG,join as U2}from"path";function Ex(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Tt(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 er(e,t,r=""){let i=Ex(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 Ei(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(Tt(e.outputLen),Tt(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function tc(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 Up(e,t){er(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Mp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function rc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Pn(e,t){return e<<32-t|e>>>t}function Xe(e,t){return e<<t|e>>>32-t>>>0}var jV=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function UV(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function MV(e){for(let t=0;t<e.length;t++)e[t]=UV(e[t]);return e}var Ix=jV?(e)=>e:MV,zO=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),FV=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Fp(e){if(er(e),zO)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=FV[e[r]];return t}var ki={_0:48,_9:57,A:65,F:70,a:97,f:102};function NO(e){if(e>=ki._0&&e<=ki._9)return e-ki._0;if(e>=ki.A&&e<=ki.F)return e-(ki.A-10);if(e>=ki.a&&e<=ki.f)return e-(ki.a-10);return}function Au(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(zO)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=NO(e.charCodeAt(o)),a=NO(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 ZV(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ax(e,t=""){if(typeof e==="string")return ZV(e);return er(e,void 0,t)}function $x(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];er(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 Zp(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 Cx(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 Ii(e=32){Tt(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 Tx=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class Ox{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(Ei(e),er(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),Ar(i)}update(e){return tc(this),this.iHash.update(e),this}digestInto(e){tc(this),Up(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 Yn=(()=>{let e=(t,r,i)=>new Ox(t,r).update(i).digest();return e.create=(t,r)=>new Ox(t,r),e})();function $u(e,t,r){if(Ei(e),r===void 0)r=new Uint8Array(e.outputLen);return Yn(e,r,t)}var Rx=Uint8Array.of(0),LO=Uint8Array.of();function Px(e,t,r,i=32){Ei(e),Tt(i,"length"),er(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=LO;else er(r,void 0,"info");let s=new Uint8Array(o*n),a=Yn.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)Rx[0]=u+1,c.update(u===0?LO:l).update(r).update(Rx).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Ar(l,Rx),s.slice(0,i)}var lo=(e,t,r,i,n)=>Px(e,$u(e,t,r),i,n);function DO(e,t,r){return e&t^~e&r}function BO(e,t,r){return e&t^e&r^t&r}class Hp{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=rc(this.buffer)}update(e){tc(this),er(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=rc(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){tc(this),Up(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Ar(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=rc(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 Ai=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var tr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Jp=BigInt(4294967295),qO=BigInt(32);function HV(e,t=!1){if(t)return{h:Number(e&Jp),l:Number(e>>qO&Jp)};return{h:Number(e>>qO&Jp)|0,l:Number(e&Jp)|0}}function jO(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}=HV(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var Nx=(e,t,r)=>e>>>r,zx=(e,t,r)=>e<<32-r|t>>>r,Es=(e,t,r)=>e>>>r|t<<32-r,Is=(e,t,r)=>e<<32-r|t>>>r,Cu=(e,t,r)=>e<<64-r|t>>>r-32,Tu=(e,t,r)=>e>>>r-32|t<<64-r;function Xn(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var UO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),MO=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,FO=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),ZO=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,HO=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),JO=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var KV=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]),uo=new Uint32Array(64);class KO extends Hp{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)uo[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=uo[u-15],f=uo[u-2],p=Pn(d,7)^Pn(d,18)^d>>>3,y=Pn(f,17)^Pn(f,19)^f>>>10;uo[u]=y+uo[u-7]+p+uo[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 d=Pn(s,6)^Pn(s,11)^Pn(s,25),f=l+d+DO(s,a,c)+KV[u]+uo[u]|0,y=(Pn(r,2)^Pn(r,13)^Pn(r,22))+BO(r,i,n)|0;l=c,c=a,a=s,s=o+f|0,o=n,n=i,i=r,r=f+y|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(){Ar(uo)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ar(this.buffer)}}class VO extends KO{A=Ai[0]|0;B=Ai[1]|0;C=Ai[2]|0;D=Ai[3]|0;E=Ai[4]|0;F=Ai[5]|0;G=Ai[6]|0;H=Ai[7]|0;constructor(){super(32)}}var WO=(()=>jO(["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))))(),VV=(()=>WO[0])(),WV=(()=>WO[1])(),fo=new Uint32Array(80),po=new Uint32Array(80);class GO extends Hp{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:d,Gh:f,Gl:p,Hh:y,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,d,f,p,y,g]}set(e,t,r,i,n,o,s,a,c,l,u,d,f,p,y,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=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=y|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)fo[A]=e.getUint32(t),po[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let C=fo[A-15]|0,N=po[A-15]|0,q=Es(C,N,1)^Es(C,N,8)^Nx(C,N,7),E=Is(C,N,1)^Is(C,N,8)^zx(C,N,7),Z=fo[A-2]|0,L=po[A-2]|0,H=Es(Z,L,19)^Cu(Z,L,61)^Nx(Z,L,6),ee=Is(Z,L,19)^Tu(Z,L,61)^zx(Z,L,6),M=FO(E,ee,po[A-7],po[A-16]),P=ZO(M,q,H,fo[A-7],fo[A-16]);fo[A]=P|0,po[A]=M|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:y,Gl:g,Hh:b,Hl:S}=this;for(let A=0;A<80;A++){let C=Es(u,d,14)^Es(u,d,18)^Cu(u,d,41),N=Is(u,d,14)^Is(u,d,18)^Tu(u,d,41),q=u&f^~u&y,E=d&p^~d&g,Z=HO(S,N,E,WV[A],po[A]),L=JO(Z,b,C,q,VV[A],fo[A]),H=Z|0,ee=Es(r,i,28)^Cu(r,i,34)^Cu(r,i,39),M=Is(r,i,28)^Tu(r,i,34)^Tu(r,i,39),P=r&n^r&s^n&s,z=i&o^i&a^o&a;b=y|0,S=g|0,y=f|0,g=p|0,f=u|0,p=d|0,{h:u,l:d}=Xn(c|0,l|0,L|0,H|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=UO(H,M,z);r=MO(I,L,ee,P),i=I|0}({h:r,l:i}=Xn(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=Xn(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=Xn(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=Xn(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Xn(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Xn(this.Fh|0,this.Fl|0,f|0,p|0),{h:y,l:g}=Xn(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:S}=Xn(this.Hh|0,this.Hl|0,b|0,S|0),this.set(r,i,n,o,s,a,c,l,u,d,f,p,y,g,b,S)}roundClean(){Ar(fo,po)}destroy(){this.destroyed=!0,Ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class QO extends GO{Ah=tr[0]|0;Al=tr[1]|0;Bh=tr[2]|0;Bl=tr[3]|0;Ch=tr[4]|0;Cl=tr[5]|0;Dh=tr[6]|0;Dl=tr[7]|0;Eh=tr[8]|0;El=tr[9]|0;Fh=tr[10]|0;Fl=tr[11]|0;Gh=tr[12]|0;Gl=tr[13]|0;Hh=tr[14]|0;Hl=tr[15]|0;constructor(){super(64)}}var Ot=Cx(()=>new VO,Tx(1));var Kp=Cx(()=>new QO,Tx(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Yp(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Bx(e){if(!Yp(e))throw TypeError("Uint8Array expected")}function rR(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 nR(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function mo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function Ru(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Wp(e){if(!Array.isArray(e))throw TypeError("array expected")}function Gp(e,t){if(!rR(!0,t))throw TypeError(`${e}: array of strings expected`)}function qx(e,t){if(!rR(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Yr(...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 Xr(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Gp("alphabet",t);let i=new Map(t.map((n,o)=>[n,o]));return{encode:(n)=>(Wp(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)=>(Wp(n),n.map((o)=>{mo("alphabet.decode",o);let s=i.get(o);if(s===void 0)throw Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function en(e=""){return mo("join",e),{encode:(t)=>(Gp("join.decode",t),t.join(e)),decode:(t)=>(mo("join.decode",t),t.split(e))}}function Xp(e,t="="){return Ru(e),mo("padding",t),{encode(r){Gp("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Gp("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 iR(e){return nR(e),{encode:(t)=>t,decode:(t)=>e(t)}}function YO(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(Wp(e),!e.length)return[];let i=0,n=[],o=Array.from(e,(a)=>{if(Ru(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],d=t*a,f=d+u;if(!Number.isSafeInteger(f)||d/t!==a||f-u!==d)throw Error("convertRadix: carry overflow");let p=f/r;a=f%r;let y=Math.floor(p);if(o[l]=y,!Number.isSafeInteger(y)||y*r+a!==f)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!y)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 oR=(e,t)=>t===0?e:oR(t,e%t),Qp=(e,t)=>e+(t-oR(e,t)),Vp=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Lx(e,t,r,i){if(Wp(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Qp(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Qp(t,r)}`);let n=0,o=0,s=Vp[t],a=Vp[r]-1,c=[];for(let l of e){if(Ru(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=Vp[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 GV(e){Ru(e);let t=256;return{encode:(r)=>{if(!Yp(r))throw TypeError("radix.encode input should be Uint8Array");return YO(Array.from(r),t,e)},decode:(r)=>(qx("radix.decode",r),Uint8Array.from(YO(r,e,t)))}}function gn(e,t=!1){if(Ru(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Qp(8,e)>32||Qp(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Yp(r))throw TypeError("radix2.encode input should be Uint8Array");return Lx(Array.from(r),8,e,!t)},decode:(r)=>(qx("radix2.decode",r),Uint8Array.from(Lx(r,e,8,t)))}}function XO(e){return nR(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var QSe=Object.freeze(Yr(gn(4),Xr("0123456789ABCDEF"),en(""))),YSe=Object.freeze(Yr(gn(5),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Xp(5),en(""))),XSe=Object.freeze(Yr(gn(5),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),en(""))),e_e=Object.freeze(Yr(gn(5),Xr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Xp(5),en(""))),t_e=Object.freeze(Yr(gn(5),Xr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),en(""))),r_e=Object.freeze(Yr(gn(5),Xr("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),en(""),iR((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),sR=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),QV=/[\t\n\f\r ]/,aR=(e,t)=>{mo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&QV.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},jx=Object.freeze(sR?{encode(e){return Bx(e),e.toBase64()},decode(e){return aR(e,!1)}}:Yr(gn(6),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Xp(6),en(""))),hr=Object.freeze(Yr(gn(6),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),en(""))),n_e=Object.freeze(sR?{encode(e){return Bx(e),e.toBase64({alphabet:"base64url"})},decode(e){return aR(e,!0)}}:Yr(gn(6),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Xp(6),en(""))),i_e=Object.freeze(Yr(gn(6),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),en(""))),Ux=(e)=>Yr(GV(58),Xr(e),en("")),o_e=Object.freeze(Ux("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),s_e=Object.freeze(Ux("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),a_e=Object.freeze(Ux("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var Dx=Yr(Xr("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),en("")),eR=[996825010,642813549,513874426,1027748829,705979059];function Ou(e){let t=e>>25,r=(e&33554431)<<5;for(let i=0;i<eR.length;i++)if((t>>i&1)===1)r^=eR[i];return r}function tR(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=Ou(n)^s>>5}n=Ou(n);for(let o=0;o<i;o++)n=Ou(n)^e.charCodeAt(o)&31;for(let o of t)n=Ou(n)^o;for(let o=0;o<6;o++)n=Ou(n);return n^=r,Dx.encode(Lx([n%Vp[30]],30,5,!1))}function cR(e){let t=e==="bech32"?1:734539939,r=gn(5),i=r.decode,n=r.encode,o=XO(i);function s(d,f,p=90){if(mo("bech32.encode prefix",d),Yp(f))f=Array.from(f);qx("bech32.encode",f);let y=d.length;if(y===0)throw TypeError(`Invalid prefix length ${y}`);let g=y+7+f.length;if(p!==!1&&g>p)throw TypeError(`Length ${g} exceeds limit ${p}`);let b=d.toLowerCase(),S=tR(b,f,t);return`${b}1${Dx.encode(f)}${S}`}function a(d,f=90){mo("bech32.decode input",d);let p=d.length;if(p<8||f!==!1&&p>f)throw TypeError(`invalid string length: ${p} (${d}). Expected (8..${f})`);let y=d.toLowerCase();if(d!==y&&d!==d.toUpperCase())throw Error("String must be lowercase or uppercase");let g=y.lastIndexOf("1");if(g===0||g===-1)throw Error('Letter "1" must be present between prefix and data only');let b=y.slice(0,g),S=y.slice(g+1);if(S.length<6)throw Error("Data must be at least 6 characters long");let A=Dx.decode(S).slice(0,-6),C=tR(b,A,t);if(!S.endsWith(C))throw Error(`Invalid checksum in ${d}: expected "${C}"`);return{prefix:b,words:A}}let c=XO(a);function l(d){let{prefix:f,words:p}=a(d,!1);return{prefix:f,words:p,bytes:i(p)}}function u(d,f){return s(d,n(f))}return{encode:s,decode:a,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:i,fromWordsUnsafe:o,toWords:n}}var tn=Object.freeze(cR("bech32")),c_e=Object.freeze(cR("bech32m"));var YV=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),XV={encode(e){return Bx(e),e.toHex()},decode(e){return mo("hex",e),Uint8Array.fromHex(e)}},l_e=Object.freeze(YV?XV:Yr(gn(4),Xr("0123456789abcdef"),en(""),iR((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 t7(e,t,r,i){Ei(e);let n=Zp({dkLen:32,asyncTick:10},i),{c:o,dkLen:s,asyncTick:a}=n;if(Tt(o,"c"),Tt(s,"dkLen"),Tt(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=Ax(t,"password"),l=Ax(r,"salt"),u=new Uint8Array(s),d=Yn.create(e,c),f=d._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:d,PRFSalt:f}}function r7(e,t,r,i,n){if(e.destroy(),t.destroy(),i)i.destroy();return Ar(n),r}function Mx(e,t,r,i){let{c:n,dkLen:o,DK:s,PRF:a,PRFSalt:c}=t7(e,t,r,i),l,u=new Uint8Array(4),d=rc(u),f=new Uint8Array(a.outputLen);for(let p=1,y=0;y<o;p++,y+=a.outputLen){let g=s.subarray(y,y+a.outputLen);d.setInt32(0,p,!1),(l=c._cloneInto(l)).update(u).digestInto(f),g.set(f.subarray(0,g.length));for(let b=1;b<n;b++){a._cloneInto(l).update(f).digestInto(f);for(let S=0;S<g.length;S++)g[S]^=f[S]}}return r7(a,c,s,l,f)}function lR(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++],d=e[t++]^r[i++],f=e[t++]^r[i++],p=e[t++]^r[i++],y=e[t++]^r[i++],g=e[t++]^r[i++],b=e[t++]^r[i++],S=e[t++]^r[i++],A=e[t++]^r[i++],C=e[t++]^r[i++],N=e[t++]^r[i++],q=e[t++]^r[i++],E=s,Z=a,L=c,H=l,ee=u,M=d,P=f,z=p,I=y,R=g,O=b,F=S,D=A,V=C,_=N,re=q;for(let ue=0;ue<8;ue+=2)ee^=Xe(E+D|0,7),I^=Xe(ee+E|0,9),D^=Xe(I+ee|0,13),E^=Xe(D+I|0,18),R^=Xe(M+Z|0,7),V^=Xe(R+M|0,9),Z^=Xe(V+R|0,13),M^=Xe(Z+V|0,18),_^=Xe(O+P|0,7),L^=Xe(_+O|0,9),P^=Xe(L+_|0,13),O^=Xe(P+L|0,18),H^=Xe(re+F|0,7),z^=Xe(H+re|0,9),F^=Xe(z+H|0,13),re^=Xe(F+z|0,18),Z^=Xe(E+H|0,7),L^=Xe(Z+E|0,9),H^=Xe(L+Z|0,13),E^=Xe(H+L|0,18),P^=Xe(M+ee|0,7),z^=Xe(P+M|0,9),ee^=Xe(z+P|0,13),M^=Xe(ee+z|0,18),F^=Xe(O+R|0,7),I^=Xe(F+O|0,9),R^=Xe(I+F|0,13),O^=Xe(R+I|0,18),D^=Xe(re+_|0,7),V^=Xe(D+re|0,9),_^=Xe(V+D|0,13),re^=Xe(_+V|0,18);n[o++]=s+E|0,n[o++]=a+Z|0,n[o++]=c+L|0,n[o++]=l+H|0,n[o++]=u+ee|0,n[o++]=d+M|0,n[o++]=f+P|0,n[o++]=p+z|0,n[o++]=y+I|0,n[o++]=g+R|0,n[o++]=b+O|0,n[o++]=S+F|0,n[o++]=A+D|0,n[o++]=C+V|0,n[o++]=N+_|0,n[o++]=q+re|0}function Fx(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(lR(r,s,e,t,r,o),a>0)s+=16;lR(r,o,e,t+=16,r,s)}}function n7(e,t,r){let i=Zp({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:o,p:s,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=i;if(Tt(n,"N"),Tt(o,"r"),Tt(s,"p"),Tt(a,"dkLen"),Tt(c,"asyncTick"),Tt(l,"maxmem"),u!==void 0&&typeof u!=="function")throw Error("progressCb must be a function");let d=128*o,f=d/4,p=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>p)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(p-1)*32/d)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(p-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let y=d*(n+s+1);if(y>l)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+y+", maxmem="+l);let g=Mx(Ot,e,t,{c:1,dkLen:d*s}),b=Mp(g),S=Mp(new Uint8Array(d*n)),A=Mp(new Uint8Array(d)),C=()=>{};if(u){let N=2*n*s,q=Math.max(Math.floor(N/1e4),1),E=0;C=()=>{if(E++,u&&(!(E%q)||E===N))u(E/N)}}return{N:n,r:o,p:s,dkLen:a,blockSize32:f,V:S,B32:b,B:g,tmp:A,blockMixCb:C,asyncTick:c}}function i7(e,t,r,i,n){let o=Mx(Ot,e,r,{c:1,dkLen:t});return Ar(r,i,n),o}function Zx(e,t,r){let{N:i,r:n,p:o,dkLen:s,blockSize32:a,V:c,B32:l,B:u,tmp:d,blockMixCb:f}=n7(e,t,r);Ix(l);for(let p=0;p<o;p++){let y=a*p;for(let g=0;g<a;g++)c[g]=l[y+g];for(let g=0,b=0;g<i-1;g++)Fx(c,b,c,b+=a,n),f();Fx(c,(i-1)*a,l,y,n),f();for(let g=0;g<i;g++){let b=(l[y+a-16]&i-1)>>>0;for(let S=0;S<a;S++)d[S]=l[y+S]^c[b*a+S];Fx(d,0,l,y,n),f()}}return Ix(l),i7(e,s,u,c,d)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function o7(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function em(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function nc(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 Mt(e,t,r=""){let i=o7(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 Hx(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 uR(e,t,r=!1){Mt(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&&!ic(e))throw Error("invalid output, must be aligned")}function ei(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Nn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function s7(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var As=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),a7=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var c7=(e)=>{for(let t=0;t<e.length;t++)e[t]=a7(e[t]);return e},$i=As?(e)=>e:c7;function dR(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function fR(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 pR(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 mR=(e,t)=>{function r(i,...n){if(Mt(i,void 0,"key"),e.nonceLength!==void 0){let u=n[0];Mt(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;if(o&&n[1]!==void 0)Mt(n[1],void 0,"AAD");let s=t(i,...n),a=(u,d)=>{if(d!==void 0){if(u!==2)throw Error("cipher output not supported");Mt(d,void 0,"output")}},c=!1;return{encrypt(u,d){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Mt(u),a(s.encrypt.length,d),s.encrypt(u,d)},decrypt(u,d){if(Mt(u),o&&u.length<o)throw Error('"ciphertext" expected length bigger than tagLength='+o);return a(s.decrypt.length,d),s.decrypt(u,d)}}}return Object.assign(r,e),r};function Pu(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Mt(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!ic(t))throw Error("invalid output, must be aligned");return t}function hR(e,t,r){nc(e),nc(t),em(r);let i=new Uint8Array(16),n=s7(i);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),i}function ic(e){return e.byteOffset%4===0}function oc(e){return Uint8Array.from(Mt(e))}var yR=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),l7=(()=>$i(ei(yR("expand 16-byte k"))))(),u7=(()=>$i(ei(yR("expand 32-byte k"))))();function et(e,t){return e<<t|e>>>32-t}var Nu=64,d7=16,Jx=(()=>4294967295)(),gR=Uint32Array.of();function f7(e,t,r,i,n,o,s,a){let c=n.length,l=new Uint8Array(Nu),u=ei(l),d=As&&ic(n)&&ic(o),f=d?ei(n):gR,p=d?ei(o):gR;if(!As){for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),$i(u),s>=Jx)throw Error("arx: counter overflow");let g=Math.min(Nu,c-y);for(let b=0,S;b<g;b++)S=y+b,o[S]=n[S]^l[b];y+=g}return}for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),s>=Jx)throw Error("arx: counter overflow");let g=Math.min(Nu,c-y);if(d&&g===Nu){let b=y/4;if(y%4!==0)throw Error("arx: invalid block position");for(let S=0,A;S<d7;S++)A=b+S,p[A]=f[A]^u[S];y+=Nu;continue}for(let b=0,S;b<g;b++)S=y+b,o[S]=n[S]^l[b];y+=g}}function bR(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:o,rounds:s}=dR({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return nc(n),nc(s),em(o),em(r),(a,c,l,u,d=0)=>{Mt(a,void 0,"key"),Mt(c,void 0,"nonce"),Mt(l,void 0,"data");let f=l.length;if(u=Pu(f,u,!1),nc(d),d<0||d>=Jx)throw Error("arx: counter overflow");let p=[],y=a.length,g,b;if(y===32)p.push(g=oc(a)),b=u7;else if(y===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),b=l7,p.push(g);else throw Mt(a,32,"arx key"),Error("invalid key size");if(!As||!ic(c))p.push(c=oc(c));let S=ei(g);if(i){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let N=c.subarray(0,16);if(As)i(b,S,ei(N),S);else{let q=$i(Uint32Array.from(b));i(q,S,ei(N),S),Nn(q),$i(S)}c=c.subarray(16)}else if(!As)$i(S);let A=16-n;if(A!==c.length)throw Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){let N=new Uint8Array(12);N.set(c,o?0:12-c.length),c=N,p.push(c)}let C=$i(ei(c));try{return f7(e,b,S,C,l,u,d,s),u}finally{Nn(...p)}}}function rr(e,t){return e[t++]&255|(e[t++]&255)<<8}class xR{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=oc(Mt(e,32,"key"));let t=rr(e,0),r=rr(e,2),i=rr(e,4),n=rr(e,6),o=rr(e,8),s=rr(e,10),a=rr(e,12),c=rr(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]=rr(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],d=o[5],f=o[6],p=o[7],y=o[8],g=o[9],b=rr(e,t+0),S=rr(e,t+2),A=rr(e,t+4),C=rr(e,t+6),N=rr(e,t+8),q=rr(e,t+10),E=rr(e,t+12),Z=rr(e,t+14),L=n[0]+(b&8191),H=n[1]+((b>>>13|S<<3)&8191),ee=n[2]+((S>>>10|A<<6)&8191),M=n[3]+((A>>>7|C<<9)&8191),P=n[4]+((C>>>4|N<<12)&8191),z=n[5]+(N>>>1&8191),I=n[6]+((N>>>14|q<<2)&8191),R=n[7]+((q>>>11|E<<5)&8191),O=n[8]+((E>>>8|Z<<8)&8191),F=n[9]+(Z>>>5|i),D=0,V=D+L*s+H*(5*g)+ee*(5*y)+M*(5*p)+P*(5*f);D=V>>>13,V&=8191,V+=z*(5*d)+I*(5*u)+R*(5*l)+O*(5*c)+F*(5*a),D+=V>>>13,V&=8191;let _=D+L*a+H*s+ee*(5*g)+M*(5*y)+P*(5*p);D=_>>>13,_&=8191,_+=z*(5*f)+I*(5*d)+R*(5*u)+O*(5*l)+F*(5*c),D+=_>>>13,_&=8191;let re=D+L*c+H*a+ee*s+M*(5*g)+P*(5*y);D=re>>>13,re&=8191,re+=z*(5*p)+I*(5*f)+R*(5*d)+O*(5*u)+F*(5*l),D+=re>>>13,re&=8191;let ue=D+L*l+H*c+ee*a+M*s+P*(5*g);D=ue>>>13,ue&=8191,ue+=z*(5*y)+I*(5*p)+R*(5*f)+O*(5*d)+F*(5*u),D+=ue>>>13,ue&=8191;let T=D+L*u+H*l+ee*c+M*a+P*s;D=T>>>13,T&=8191,T+=z*(5*g)+I*(5*y)+R*(5*p)+O*(5*f)+F*(5*d),D+=T>>>13,T&=8191;let we=D+L*d+H*u+ee*l+M*c+P*a;D=we>>>13,we&=8191,we+=z*s+I*(5*g)+R*(5*y)+O*(5*p)+F*(5*f),D+=we>>>13,we&=8191;let Ee=D+L*f+H*d+ee*u+M*l+P*c;D=Ee>>>13,Ee&=8191,Ee+=z*a+I*s+R*(5*g)+O*(5*y)+F*(5*p),D+=Ee>>>13,Ee&=8191;let Te=D+L*p+H*f+ee*d+M*u+P*l;D=Te>>>13,Te&=8191,Te+=z*c+I*a+R*s+O*(5*g)+F*(5*y),D+=Te>>>13,Te&=8191;let Ce=D+L*y+H*p+ee*f+M*d+P*u;D=Ce>>>13,Ce&=8191,Ce+=z*l+I*c+R*a+O*s+F*(5*g),D+=Ce>>>13,Ce&=8191;let _e=D+L*g+H*y+ee*p+M*f+P*d;D=_e>>>13,_e&=8191,_e+=z*u+I*l+R*c+O*a+F*s,D+=_e>>>13,_e&=8191,D=(D<<2)+D|0,D=D+V|0,V=D&8191,D=D>>>13,_+=D,n[0]=V,n[1]=_,n[2]=re,n[3]=ue,n[4]=T,n[5]=we,n[6]=Ee,n[7]=Te,n[8]=Ce,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;Nn(r)}update(e){Hx(this),Mt(e),e=oc(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,Nn(this.h,this.r,this.buffer,this.pad)}digestInto(e){Hx(this),uR(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 wR=pR(32,(e)=>new xR(e));function p7(e,t,r,i,n,o=20){let s=e[0],a=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],y=t[4],g=t[5],b=t[6],S=t[7],A=n,C=r[0],N=r[1],q=r[2],E=s,Z=a,L=c,H=l,ee=u,M=d,P=f,z=p,I=y,R=g,O=b,F=S,D=A,V=C,_=N,re=q;for(let T=0;T<o;T+=2)E=E+ee|0,D=et(D^E,16),I=I+D|0,ee=et(ee^I,12),E=E+ee|0,D=et(D^E,8),I=I+D|0,ee=et(ee^I,7),Z=Z+M|0,V=et(V^Z,16),R=R+V|0,M=et(M^R,12),Z=Z+M|0,V=et(V^Z,8),R=R+V|0,M=et(M^R,7),L=L+P|0,_=et(_^L,16),O=O+_|0,P=et(P^O,12),L=L+P|0,_=et(_^L,8),O=O+_|0,P=et(P^O,7),H=H+z|0,re=et(re^H,16),F=F+re|0,z=et(z^F,12),H=H+z|0,re=et(re^H,8),F=F+re|0,z=et(z^F,7),E=E+M|0,re=et(re^E,16),O=O+re|0,M=et(M^O,12),E=E+M|0,re=et(re^E,8),O=O+re|0,M=et(M^O,7),Z=Z+P|0,D=et(D^Z,16),F=F+D|0,P=et(P^F,12),Z=Z+P|0,D=et(D^Z,8),F=F+D|0,P=et(P^F,7),L=L+z|0,V=et(V^L,16),I=I+V|0,z=et(z^I,12),L=L+z|0,V=et(V^L,8),I=I+V|0,z=et(z^I,7),H=H+ee|0,_=et(_^H,16),R=R+_|0,ee=et(ee^R,12),H=H+ee|0,_=et(_^H,8),R=R+_|0,ee=et(ee^R,7);let ue=0;i[ue++]=s+E|0,i[ue++]=a+Z|0,i[ue++]=c+L|0,i[ue++]=l+H|0,i[ue++]=u+ee|0,i[ue++]=d+M|0,i[ue++]=f+P|0,i[ue++]=p+z|0,i[ue++]=y+I|0,i[ue++]=g+R|0,i[ue++]=b+O|0,i[ue++]=S+F|0,i[ue++]=A+D|0,i[ue++]=C+V|0,i[ue++]=N+_|0,i[ue++]=q+re|0}var m7=bR(p7,{counterRight:!1,counterLength:4,allowShortKeys:!1});var h7=new Uint8Array(16),vR=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(h7.subarray(r))},g7=new Uint8Array(32);function SR(e,t,r,i,n){if(n!==void 0)Mt(n,void 0,"AAD");let o=e(t,r,g7),s=hR(i.length,n?n.length:0,!0),a=wR.create(o);if(n)vR(a,n);vR(a,i),a.update(s);let c=a.digest();return Nn(o,s),c}var y7=(e)=>(t,r,i)=>({encrypt(o,s){let a=o.length;s=Pu(a+16,s,!1),s.set(o);let c=s.subarray(0,-16);e(t,r,c,c,1);let l=SR(e,t,r,c,i);return s.set(l,a),Nn(l),s},decrypt(o,s){s=Pu(o.length-16,s,!1);let a=o.subarray(0,-16),c=o.subarray(-16),l=SR(e,t,r,a,i);if(!fR(c,l))throw Nn(l),Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),Nn(l),s}}),yn=mR({blockSize:64,nonceLength:12,tagLength:16},y7(m7));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function sc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Vt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Ne(e,t,r=""){let i=sc(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 bn(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Vt(e.outputLen),Vt(e.blockLen)}function Ti(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 tm(e,t){Ne(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function rm(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ur(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function nm(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function zn(e,t){return e<<32-t|e>>>t}var b7=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function x7(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function w7(e){for(let t=0;t<e.length;t++)e[t]=x7(e[t]);return e}var Kx=b7?(e)=>e:w7,kR=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),v7=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function $s(e){if(Ne(e),kR)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=v7[e[r]];return t}var Ci={_0:48,_9:57,A:65,F:70,a:97,f:102};function _R(e){if(e>=Ci._0&&e<=Ci._9)return e-Ci._0;if(e>=Ci.A&&e<=Ci.F)return e-(Ci.A-10);if(e>=Ci.a&&e<=Ci.f)return e-(Ci.a-10);return}function Cs(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(kR)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=_R(e.charCodeAt(o)),a=_R(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 Lt(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];Ne(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 ac(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 ho(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 go=(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 Wx=BigInt(0),Vx=BigInt(1);function zu(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function ER(e){if(typeof e==="bigint"){if(!im(e))throw Error("positive bigint expected, got "+e)}else Vt(e);return e}function Lu(e){let t=ER(e).toString(16);return t.length&1?"0"+t:t}function IR(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?Wx:BigInt("0x"+e)}function yo(e){return IR($s(e))}function bo(e){return IR($s(om(Ne(e)).reverse()))}function cc(e,t){Vt(t),e=ER(e);let r=Cs(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Du(e,t){return cc(e,t).reverse()}function om(e){return Uint8Array.from(e)}function xo(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 im=(e)=>typeof e==="bigint"&&Wx<=e;function S7(e,t,r){return im(e)&&im(t)&&im(r)&&t<=e&&e<r}function Bu(e,t,r,i){if(!S7(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function Gx(e){let t;for(t=0;e>Wx;e>>=Vx,t+=1);return t}var qu=(e)=>(Vx<<BigInt(e))-Vx;function AR(e,t,r){if(Vt(e,"hashLen"),Vt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let i=(b)=>new Uint8Array(b),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},f=(...b)=>r(l,Lt(c,...b)),p=(b=n)=>{if(l=f(o,b),c=f(),b.length===0)return;l=f(s,b),c=f()},y=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let b=0,S=[];while(b<t){c=f();let A=c.slice();S.push(A),b+=c.length}return Lt(...S)};return(b,S)=>{d(),p(b);let A=void 0;while(!(A=S(y())))p();return d(),A}}function Ts(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 Qx(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),gr=BigInt(1),Os=BigInt(2),TR=BigInt(3),OR=BigInt(4),RR=BigInt(5),_7=BigInt(7),PR=BigInt(8),k7=BigInt(9),NR=BigInt(16);function $r(e,t){let r=e%t;return r>=Cr?r:t+r}function xn(e,t,r){let i=e;while(t-- >Cr)i*=i,i%=r;return i}function $R(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=$r(e,t),i=t,n=Cr,o=gr,s=gr,a=Cr;while(r!==Cr){let l=i/r,u=i%r,d=n-s*l,f=o-a*l;i=r,r=u,n=s,o=a,s=d,a=f}if(i!==gr)throw Error("invert: does not exist");return $r(n,t)}function Yx(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function zR(e,t){let r=(e.ORDER+gr)/OR,i=e.pow(t,r);return Yx(e,i,t),i}function E7(e,t){let r=(e.ORDER-RR)/PR,i=e.mul(t,Os),n=e.pow(i,r),o=e.mul(t,n),s=e.mul(e.mul(o,Os),n),a=e.mul(o,e.sub(s,e.ONE));return Yx(e,a,t),a}function I7(e){let t=sm(e),r=LR(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+_7)/NR;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,i),d=a.mul(l,n),f=a.mul(l,o),p=a.eql(a.sqr(u),c),y=a.eql(a.sqr(d),c);l=a.cmov(l,u,p),u=a.cmov(f,d,y);let g=a.eql(a.sqr(u),c),b=a.cmov(l,u,g);return Yx(a,b,c),b}}function LR(e){if(e<TR)throw Error("sqrt is not defined for small field");let t=e-gr,r=0;while(t%Os===Cr)t/=Os,r++;let i=Os,n=sm(e);while(CR(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return zR;let o=n.pow(i,t),s=(t+gr)/Os;return function(c,l){if(c.is0(l))return l;if(CR(c,l)!==1)throw Error("Cannot find square root");let u=r,d=c.mul(c.ONE,o),f=c.pow(l,t),p=c.pow(l,s);while(!c.eql(f,c.ONE)){if(c.is0(f))return c.ZERO;let y=1,g=c.sqr(f);while(!c.eql(g,c.ONE))if(y++,g=c.sqr(g),y===u)throw Error("Cannot find square root");let b=gr<<BigInt(u-y-1),S=c.pow(d,b);u=y,d=c.sqr(S),f=c.mul(f,d),p=c.mul(p,S)}return p}}function A7(e){if(e%OR===TR)return zR;if(e%PR===RR)return E7;if(e%NR===k7)return I7(e);return LR(e)}var $7=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Xx(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=$7.reduce((i,n)=>(i[n]="function",i),t);return Ts(e,r),e}function C7(e,t,r){if(r<Cr)throw Error("invalid exponent, negatives unsupported");if(r===Cr)return e.ONE;if(r===gr)return t;let i=e.ONE,n=t;while(r>Cr){if(r&gr)i=e.mul(i,n);n=e.sqr(n),r>>=gr}return i}function ju(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 CR(e,t){let r=(e.ORDER-gr)/Os,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 T7(e,t){if(t!==void 0)Vt(t);let r=t!==void 0?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}class DR{ORDER;BITS;BYTES;isLE;ZERO=Cr;ONE=gr;_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}=T7(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 $r(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&gr)===gr}neg(e){return $r(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return $r(e*e,this.ORDER)}add(e,t){return $r(e+t,this.ORDER)}sub(e,t){return $r(e-t,this.ORDER)}mul(e,t){return $r(e*t,this.ORDER)}pow(e,t){return C7(this,e,t)}div(e,t){return $r(e*$R(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 $R(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=A7(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Du(e,this.BYTES):cc(e,this.BYTES)}fromBytes(e,t=!1){Ne(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?bo(e):yo(e);if(s)a=$r(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ju(this,e)}cmov(e,t,r){return r?t:e}}function sm(e,t={}){return new DR(e,t)}function BR(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function e0(e){let t=BR(e);return t+Math.ceil(t/2)}function qR(e,t,r=!1){Ne(e);let i=e.length,n=BR(t),o=e0(t);if(i<16||i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?bo(e):yo(e),a=$r(s,t-gr)+gr;return r?Du(a,n):cc(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lc=BigInt(0),Rs=BigInt(1);function Uu(e,t){let r=t.negate();return e?r:t}function i0(e,t){let r=ju(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function FR(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function t0(e,t){FR(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=qu(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function jR(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+=Rs;let l=t*i,u=l+Math.abs(a)-1,d=a===0,f=a<0,p=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}var r0=new WeakMap,ZR=new WeakMap;function n0(e){return ZR.get(e)||1}function UR(e){if(e!==lc)throw Error("invalid wNAF")}class o0{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>lc){if(t&Rs)r=r.add(i);i=i.double(),t>>=Rs}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=t0(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=t0(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:f}=jR(r,s,o);if(r=a,l)n=n.add(Uu(d,t[f]));else i=i.add(Uu(u,t[c]))}return UR(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=t0(e,this.bits);for(let o=0;o<n.windows;o++){if(r===lc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=jR(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return UR(r),i}getPrecomputes(e,t,r){let i=r0.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);r0.set(t,i)}}return i}cached(e,t,r){let i=n0(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=n0(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){FR(t,this.bits),ZR.set(e,t),r0.delete(e)}hasCache(e){return n0(e)!==1}}function HR(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>lc||i>lc){if(r&Rs)o=o.add(n);if(i&Rs)s=s.add(n);n=n.double(),r>>=Rs,i>>=Rs}return{p1:o,p2:s}}function MR(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Xx(t),t}else return sm(e,{isLE:r})}function JR(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>lc))throw Error(`CURVE.${c} must be positive bigint`)}let n=MR(t.p,r.Fp,i),o=MR(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 am(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 Mu=BigInt(0),uc=BigInt(1),cm=BigInt(2);function O7(e){return Ts(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function KR(e){let t=O7(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||ho,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),f=a?BigInt(121665):BigInt(39081),p=a?cm**BigInt(254):cm**BigInt(447),y=a?BigInt(8)*cm**BigInt(251)-uc:BigInt(4)*cm**BigInt(445)-uc,g=p+y+uc,b=(I)=>$r(I,r),S=A(d);function A(I){return Du(b(I),u)}function C(I){let R=om(Ne(I,u,"uCoordinate"));if(a)R[31]&=127;return b(bo(R))}function N(I){return bo(n(om(Ne(I,u,"scalar"))))}function q(I,R){let O=ee(C(R),N(I));if(O===Mu)throw Error("invalid private or public key received");return A(O)}function E(I){return q(I,S)}let Z=E,L=q;function H(I,R,O){let F=b(I*(R-O));return R=b(R-F),O=b(O+F),{x_2:R,x_3:O}}function ee(I,R){Bu("u",I,Mu,r),Bu("scalar",R,p,g);let O=R,F=I,D=uc,V=Mu,_=I,re=uc,ue=Mu;for(let we=BigInt(l-1);we>=Mu;we--){let Ee=O>>we&uc;ue^=Ee,{x_2:D,x_3:_}=H(ue,D,_),{x_2:V,x_3:re}=H(ue,V,re),ue=Ee;let Te=D+V,Ce=b(Te*Te),_e=D-V,Pe=b(_e*_e),Ve=Ce-Pe,tt=_+re,bt=_-re,zt=b(bt*Te),pr=b(tt*_e),Gr=zt+pr,Qr=zt-pr;_=b(Gr*Gr),re=b(F*b(Qr*Qr)),D=b(Ce*Pe),V=b(Ve*(Ce+b(f*Ve)))}({x_2:D,x_3:_}=H(ue,D,_)),{x_2:V,x_3:re}=H(ue,V,re);let T=o(V);return b(D*T)}let M={secretKey:u,publicKey:u,seed:u},P=(I=c(u))=>(Ne(I,M.seed,"seed"),I),z={randomSecretKey:P};return Object.freeze({keygen:am(P,Z),getSharedSecret:L,getPublicKey:Z,scalarMult:q,scalarMultBase:E,utils:z,GuBytes:S.slice(),lengths:M})}class s0{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(bn(e),Ne(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),Ur(i)}update(e){return Ti(this),this.iHash.update(e),this}digestInto(e){Ti(this),Ne(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 dc=(e,t,r)=>new s0(e,t).update(r).digest();dc.create=(e,t)=>new s0(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var VR=(e,t)=>(e+(e>=0?t:-t)/GR)/t;function R7(e,t,r){let[[i,n],[o,s]]=t,a=VR(s*e,r),c=VR(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<Oi,f=u<Oi;if(d)l=-l;if(f)u=-u;let p=qu(Math.ceil(Gx(r)/2))+fc;if(l<Oi||l>=p||u<Oi||u>=p)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}function c0(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function a0(e,t){let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(zu(r.lowS,"lowS"),zu(r.prehash,"prehash"),r.format!==void 0)c0(r.format);return r}class WR extends Error{constructor(e=""){super(e)}}var wo={Err:WR,_tlv:{encode:(e,t)=>{let{Err:r}=wo;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=Lu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Lu(n.length/2|128):"";return Lu(e)+o+n+t},decode(e,t){let{Err:r}=wo,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}=wo;if(e<Oi)throw new t("integer: negative integers are not allowed");let r=Lu(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}=wo;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return yo(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=wo,n=Ne(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}=wo,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},Oi=BigInt(0),fc=BigInt(1),GR=BigInt(2),lm=BigInt(3),P7=BigInt(4);function l0(e,t={}){let r=JR("weierstrass",e,t),{Fp:i,Fn:n}=r,o=r.CURVE,{h:s,n:a}=o;Ts(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=YR(i,n);function u(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function d(P,z,I){let{x:R,y:O}=z.toAffine(),F=i.toBytes(R);if(zu(I,"isCompressed"),I){u();let D=!i.isOdd(O);return Lt(QR(D),F)}else return Lt(Uint8Array.of(4),F,i.toBytes(O))}function f(P){Ne(P,void 0,"Point");let{publicKey:z,publicKeyUncompressed:I}=l,R=P.length,O=P[0],F=P.subarray(1);if(R===z&&(O===2||O===3)){let D=i.fromBytes(F);if(!i.isValid(D))throw Error("bad point: is not on curve, wrong x");let V=g(D),_;try{_=i.sqrt(V)}catch(T){let we=T instanceof Error?": "+T.message:"";throw Error("bad point: is not on curve, sqrt error"+we)}u();let re=i.isOdd(_);if((O&1)===1!==re)_=i.neg(_);return{x:D,y:_}}else if(R===I&&O===4){let D=i.BYTES,V=i.fromBytes(F.subarray(0,D)),_=i.fromBytes(F.subarray(D,D*2));if(!b(V,_))throw Error("bad point: is not on curve");return{x:V,y:_}}else throw Error(`bad point: got length ${R}, expected compressed=${z} or uncompressed=${I}`)}let p=t.toBytes||d,y=t.fromBytes||f;function g(P){let z=i.sqr(P),I=i.mul(z,P);return i.add(i.add(I,i.mul(P,o.a)),o.b)}function b(P,z){let I=i.sqr(z),R=g(P);return i.eql(I,R)}if(!b(o.Gx,o.Gy))throw Error("bad curve params: generator point");let S=i.mul(i.pow(o.a,lm),P7),A=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(S,A)))throw Error("bad curve params: a or b");function C(P,z,I=!1){if(!i.isValid(z)||I&&i.is0(z))throw Error(`bad point coordinate ${P}`);return z}function N(P){if(!(P instanceof H))throw Error("Weierstrass Point expected")}function q(P){if(!c||!c.basises)throw Error("no endo");return R7(P,c.basises,n.ORDER)}let E=Qx((P,z)=>{let{X:I,Y:R,Z:O}=P;if(i.eql(O,i.ONE))return{x:I,y:R};let F=P.is0();if(z==null)z=F?i.ONE:i.inv(O);let D=i.mul(I,z),V=i.mul(R,z),_=i.mul(O,z);if(F)return{x:i.ZERO,y:i.ZERO};if(!i.eql(_,i.ONE))throw Error("invZ was invalid");return{x:D,y:V}}),Z=Qx((P)=>{if(P.is0()){if(t.allowInfinityPoint&&!i.is0(P.Y))return;throw Error("bad point: ZERO")}let{x:z,y:I}=P.toAffine();if(!i.isValid(z)||!i.isValid(I))throw Error("bad point: x or y not field elements");if(!b(z,I))throw Error("bad point: equation left != right");if(!P.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function L(P,z,I,R,O){return I=new H(i.mul(I.X,P),I.Y,I.Z),z=Uu(R,z),I=Uu(O,I),z.add(I)}class H{static BASE=new H(o.Gx,o.Gy,i.ONE);static ZERO=new H(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(P,z,I){this.X=C("x",P),this.Y=C("y",z,!0),this.Z=C("z",I),Object.freeze(this)}static CURVE(){return o}static fromAffine(P){let{x:z,y:I}=P||{};if(!P||!i.isValid(z)||!i.isValid(I))throw Error("invalid affine point");if(P instanceof H)throw Error("projective point not allowed");if(i.is0(z)&&i.is0(I))return H.ZERO;return new H(z,I,i.ONE)}static fromBytes(P){let z=H.fromAffine(y(Ne(P,void 0,"point")));return z.assertValidity(),z}static fromHex(P){return H.fromBytes(Cs(P))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(P=8,z=!0){if(M.createCache(this,P),!z)this.multiply(lm);return this}assertValidity(){Z(this)}hasEvenY(){let{y:P}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(P)}equals(P){N(P);let{X:z,Y:I,Z:R}=this,{X:O,Y:F,Z:D}=P,V=i.eql(i.mul(z,D),i.mul(O,R)),_=i.eql(i.mul(I,D),i.mul(F,R));return V&&_}negate(){return new H(this.X,i.neg(this.Y),this.Z)}double(){let{a:P,b:z}=o,I=i.mul(z,lm),{X:R,Y:O,Z:F}=this,D=i.ZERO,V=i.ZERO,_=i.ZERO,re=i.mul(R,R),ue=i.mul(O,O),T=i.mul(F,F),we=i.mul(R,O);return we=i.add(we,we),_=i.mul(R,F),_=i.add(_,_),D=i.mul(P,_),V=i.mul(I,T),V=i.add(D,V),D=i.sub(ue,V),V=i.add(ue,V),V=i.mul(D,V),D=i.mul(we,D),_=i.mul(I,_),T=i.mul(P,T),we=i.sub(re,T),we=i.mul(P,we),we=i.add(we,_),_=i.add(re,re),re=i.add(_,re),re=i.add(re,T),re=i.mul(re,we),V=i.add(V,re),T=i.mul(O,F),T=i.add(T,T),re=i.mul(T,we),D=i.sub(D,re),_=i.mul(T,ue),_=i.add(_,_),_=i.add(_,_),new H(D,V,_)}add(P){N(P);let{X:z,Y:I,Z:R}=this,{X:O,Y:F,Z:D}=P,V=i.ZERO,_=i.ZERO,re=i.ZERO,ue=o.a,T=i.mul(o.b,lm),we=i.mul(z,O),Ee=i.mul(I,F),Te=i.mul(R,D),Ce=i.add(z,I),_e=i.add(O,F);Ce=i.mul(Ce,_e),_e=i.add(we,Ee),Ce=i.sub(Ce,_e),_e=i.add(z,R);let Pe=i.add(O,D);return _e=i.mul(_e,Pe),Pe=i.add(we,Te),_e=i.sub(_e,Pe),Pe=i.add(I,R),V=i.add(F,D),Pe=i.mul(Pe,V),V=i.add(Ee,Te),Pe=i.sub(Pe,V),re=i.mul(ue,_e),V=i.mul(T,Te),re=i.add(V,re),V=i.sub(Ee,re),re=i.add(Ee,re),_=i.mul(V,re),Ee=i.add(we,we),Ee=i.add(Ee,we),Te=i.mul(ue,Te),_e=i.mul(T,_e),Ee=i.add(Ee,Te),Te=i.sub(we,Te),Te=i.mul(ue,Te),_e=i.add(_e,Te),we=i.mul(Ee,_e),_=i.add(_,we),we=i.mul(Pe,_e),V=i.mul(Ce,V),V=i.sub(V,we),we=i.mul(Ce,Ee),re=i.mul(Pe,re),re=i.add(re,we),new H(V,_,re)}subtract(P){return this.add(P.negate())}is0(){return this.equals(H.ZERO)}multiply(P){let{endo:z}=t;if(!n.isValidNot0(P))throw Error("invalid scalar: out of range");let I,R,O=(F)=>M.cached(this,F,(D)=>i0(H,D));if(z){let{k1neg:F,k1:D,k2neg:V,k2:_}=q(P),{p:re,f:ue}=O(D),{p:T,f:we}=O(_);R=ue.add(we),I=L(z.beta,re,T,F,V)}else{let{p:F,f:D}=O(P);I=F,R=D}return i0(H,[I,R])[0]}multiplyUnsafe(P){let{endo:z}=t,I=this;if(!n.isValid(P))throw Error("invalid scalar: out of range");if(P===Oi||I.is0())return H.ZERO;if(P===fc)return I;if(M.hasCache(this))return this.multiply(P);if(z){let{k1neg:R,k1:O,k2neg:F,k2:D}=q(P),{p1:V,p2:_}=HR(H,I,O,D);return L(z.beta,V,_,R,F)}else return M.unsafe(I,P)}toAffine(P){return E(this,P)}isTorsionFree(){let{isTorsionFree:P}=t;if(s===fc)return!0;if(P)return P(H,this);return M.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:P}=t;if(s===fc)return this;if(P)return P(H,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(P=!0){return zu(P,"isCompressed"),this.assertValidity(),p(H,this,P)}toHex(P=!0){return $s(this.toBytes(P))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,M=new o0(H,t.endo?Math.ceil(ee/2):ee);return H.BASE.precompute(8),H}function QR(e){return Uint8Array.of(e?2:3)}function YR(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function N7(e,t={}){let{Fn:r}=e,i=t.randomBytes||ho,n=Object.assign(YR(e.Fp,r),{seed:e0(r.ORDER)});function o(p){try{let y=r.fromBytes(p);return r.isValidNot0(y)}catch(y){return!1}}function s(p,y){let{publicKey:g,publicKeyUncompressed:b}=n;try{let S=p.length;if(y===!0&&S!==g)return!1;if(y===!1&&S!==b)return!1;return!!e.fromBytes(p)}catch(S){return!1}}function a(p=i(n.seed)){return qR(Ne(p,n.seed,"seed"),r.ORDER)}function c(p,y=!0){return e.BASE.multiply(r.fromBytes(p)).toBytes(y)}function l(p){let{secretKey:y,publicKey:g,publicKeyUncompressed:b}=n;if(!sc(p))return;if("_lengths"in r&&r._lengths||y===g)return;let S=Ne(p,void 0,"key").length;return S===g||S===b}function u(p,y,g=!0){if(l(p)===!0)throw Error("first arg must be private key");if(l(y)===!1)throw Error("second arg must be public key");let b=r.fromBytes(p);return e.fromBytes(y).multiply(b).toBytes(g)}let d={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},f=am(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:n})}function u0(e,t,r={}){bn(t),Ts(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes||ho,n=r.hmac||((I,R)=>dc(t,I,R)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p}=N7(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*GR<o.ORDER;function b(I){let R=a>>fc;return I>R}function S(I,R){if(!s.isValidNot0(R))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return R}function A(){if(g)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function C(I,R){c0(R);let O=p.signature,F=R==="compact"?O:R==="recovered"?O+1:void 0;return Ne(I,F)}class N{r;s;recovery;constructor(I,R,O){if(this.r=S("r",I),this.s=S("s",R),O!=null){if(A(),![0,1,2,3].includes(O))throw Error("invalid recovery id");this.recovery=O}Object.freeze(this)}static fromBytes(I,R=y.format){C(I,R);let O;if(R==="der"){let{r:_,s:re}=wo.toSig(Ne(I));return new N(_,re)}if(R==="recovered")O=I[0],R="compact",I=I.subarray(1);let F=p.signature/2,D=I.subarray(0,F),V=I.subarray(F,F*2);return new N(s.fromBytes(D),s.fromBytes(V),O)}static fromHex(I,R){return this.fromBytes(Cs(I),R)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new N(this.r,this.s,I)}recoverPublicKey(I){let{r:R,s:O}=this,F=this.assertRecovery(),D=F===2||F===3?R+a:R;if(!o.isValid(D))throw Error("invalid recovery id: sig.r+curve.n != R.x");let V=o.toBytes(D),_=e.fromBytes(Lt(QR((F&1)===0),V)),re=s.inv(D),ue=E(Ne(I,void 0,"msgHash")),T=s.create(-ue*re),we=s.create(O*re),Ee=e.BASE.multiplyUnsafe(T).add(_.multiplyUnsafe(we));if(Ee.is0())throw Error("invalid recovery: point at infinify");return Ee.assertValidity(),Ee}hasHighS(){return b(this.s)}toBytes(I=y.format){if(c0(I),I==="der")return Cs(wo.hexFromSig(this));let{r:R,s:O}=this,F=s.toBytes(R),D=s.toBytes(O);if(I==="recovered")return A(),Lt(Uint8Array.of(this.assertRecovery()),F,D);return Lt(F,D)}toHex(I){return $s(this.toBytes(I))}}let q=r.bits2int||function(R){if(R.length>8192)throw Error("input is too large");let O=yo(R),F=R.length*8-c;return F>0?O>>BigInt(F):O},E=r.bits2int_modN||function(R){return s.create(q(R))},Z=qu(c);function L(I){return Bu("num < 2^"+c,I,Oi,Z),s.toBytes(I)}function H(I,R){return Ne(I,void 0,"message"),R?Ne(t(I),void 0,"prehashed message"):I}function ee(I,R,O){let{lowS:F,prehash:D,extraEntropy:V}=a0(O,y);I=H(I,D);let _=E(I),re=s.fromBytes(R);if(!s.isValidNot0(re))throw Error("invalid private key");let ue=[L(re),L(_)];if(V!=null&&V!==!1){let Te=V===!0?i(p.secretKey):V;ue.push(Ne(Te,void 0,"extraEntropy"))}let T=Lt(...ue),we=_;function Ee(Te){let Ce=q(Te);if(!s.isValidNot0(Ce))return;let _e=s.inv(Ce),Pe=e.BASE.multiply(Ce).toAffine(),Ve=s.create(Pe.x);if(Ve===Oi)return;let tt=s.create(_e*s.create(we+Ve*re));if(tt===Oi)return;let bt=(Pe.x===Ve?0:2)|Number(Pe.y&fc),zt=tt;if(F&&b(tt))zt=s.neg(tt),bt^=1;return new N(Ve,zt,g?void 0:bt)}return{seed:T,k2sig:Ee}}function M(I,R,O={}){let{seed:F,k2sig:D}=ee(I,R,O);return AR(t.outputLen,s.BYTES,n)(F,D).toBytes(O.format)}function P(I,R,O,F={}){let{lowS:D,prehash:V,format:_}=a0(F,y);if(O=Ne(O,void 0,"publicKey"),R=H(R,V),!sc(I)){let re=I instanceof N?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}C(I,_);try{let re=N.fromBytes(I,_),ue=e.fromBytes(O);if(D&&re.hasHighS())return!1;let{r:T,s:we}=re,Ee=E(R),Te=s.inv(we),Ce=s.create(Ee*Te),_e=s.create(T*Te),Pe=e.BASE.multiplyUnsafe(Ce).add(ue.multiplyUnsafe(_e));if(Pe.is0())return!1;return s.create(Pe.x)===T}catch(re){return!1}}function z(I,R,O={}){let{prehash:F}=a0(O,y);return R=H(R,F),N.fromBytes(I,"recovered").recoverPublicKey(R).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p,Point:e,sign:M,verify:P,recoverPublicKey:z,Signature:N,hash:t})}function XR(e,t,r){return e&t^~e&r}function eP(e,t,r){return e&t^e&r^t&r}class um{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=nm(this.buffer)}update(e){Ti(this),Ne(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=nm(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){Ti(this),tm(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Ur(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=nm(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 Ri=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var nr=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var dm=BigInt(4294967295),tP=BigInt(32);function z7(e,t=!1){if(t)return{h:Number(e&dm),l:Number(e>>tP&dm)};return{h:Number(e>>tP&dm)|0,l:Number(e&dm)|0}}function fm(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}=z7(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var d0=(e,t,r)=>e>>>r,f0=(e,t,r)=>e<<32-r|t>>>r,Ps=(e,t,r)=>e>>>r|t<<32-r,Ns=(e,t,r)=>e<<32-r|t>>>r,Fu=(e,t,r)=>e<<64-r|t>>>r-32,Zu=(e,t,r)=>e>>>r-32|t<<64-r;var rP=(e,t,r)=>e<<r|t>>>32-r,nP=(e,t,r)=>t<<r|e>>>32-r,iP=(e,t,r)=>t<<r-32|e>>>64-r,oP=(e,t,r)=>e<<r-32|t>>>64-r;function ti(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var sP=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),aP=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,cP=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),lP=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,uP=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),dP=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var D7=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]),vo=new Uint32Array(64);class fP extends um{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)vo[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=vo[u-15],f=vo[u-2],p=zn(d,7)^zn(d,18)^d>>>3,y=zn(f,17)^zn(f,19)^f>>>10;vo[u]=y+vo[u-7]+p+vo[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 d=zn(s,6)^zn(s,11)^zn(s,25),f=l+d+XR(s,a,c)+D7[u]+vo[u]|0,y=(zn(r,2)^zn(r,13)^zn(r,22))+eP(r,i,n)|0;l=c,c=a,a=s,s=o+f|0,o=n,n=i,i=r,r=f+y|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(){Ur(vo)}destroy(){this.set(0,0,0,0,0,0,0,0),Ur(this.buffer)}}class pP extends fP{A=Ri[0]|0;B=Ri[1]|0;C=Ri[2]|0;D=Ri[3]|0;E=Ri[4]|0;F=Ri[5]|0;G=Ri[6]|0;H=Ri[7]|0;constructor(){super(32)}}var mP=(()=>fm(["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))))(),B7=(()=>mP[0])(),q7=(()=>mP[1])(),So=new Uint32Array(80),_o=new Uint32Array(80);class hP extends um{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:d,Gh:f,Gl:p,Hh:y,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,d,f,p,y,g]}set(e,t,r,i,n,o,s,a,c,l,u,d,f,p,y,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=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=y|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)So[A]=e.getUint32(t),_o[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let C=So[A-15]|0,N=_o[A-15]|0,q=Ps(C,N,1)^Ps(C,N,8)^d0(C,N,7),E=Ns(C,N,1)^Ns(C,N,8)^f0(C,N,7),Z=So[A-2]|0,L=_o[A-2]|0,H=Ps(Z,L,19)^Fu(Z,L,61)^d0(Z,L,6),ee=Ns(Z,L,19)^Zu(Z,L,61)^f0(Z,L,6),M=cP(E,ee,_o[A-7],_o[A-16]),P=lP(M,q,H,So[A-7],So[A-16]);So[A]=P|0,_o[A]=M|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:y,Gl:g,Hh:b,Hl:S}=this;for(let A=0;A<80;A++){let C=Ps(u,d,14)^Ps(u,d,18)^Fu(u,d,41),N=Ns(u,d,14)^Ns(u,d,18)^Zu(u,d,41),q=u&f^~u&y,E=d&p^~d&g,Z=uP(S,N,E,q7[A],_o[A]),L=dP(Z,b,C,q,B7[A],So[A]),H=Z|0,ee=Ps(r,i,28)^Fu(r,i,34)^Fu(r,i,39),M=Ns(r,i,28)^Zu(r,i,34)^Zu(r,i,39),P=r&n^r&s^n&s,z=i&o^i&a^o&a;b=y|0,S=g|0,y=f|0,g=p|0,f=u|0,p=d|0,{h:u,l:d}=ti(c|0,l|0,L|0,H|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=sP(H,M,z);r=aP(I,L,ee,P),i=I|0}({h:r,l:i}=ti(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ti(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ti(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ti(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=ti(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=ti(this.Fh|0,this.Fl|0,f|0,p|0),{h:y,l:g}=ti(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:S}=ti(this.Hh|0,this.Hl|0,b|0,S|0),this.set(r,i,n,o,s,a,c,l,u,d,f,p,y,g,b,S)}roundClean(){Ur(So,_o)}destroy(){Ur(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class gP extends hP{Ah=nr[0]|0;Al=nr[1]|0;Bh=nr[2]|0;Bl=nr[3]|0;Ch=nr[4]|0;Cl=nr[5]|0;Dh=nr[6]|0;Dl=nr[7]|0;Eh=nr[8]|0;El=nr[9]|0;Fh=nr[10]|0;Fl=nr[11]|0;Gh=nr[12]|0;Gl=nr[13]|0;Hh=nr[14]|0;Hl=nr[15]|0;constructor(){super(48)}}var pm=ac(()=>new pP,go(1));var yP=ac(()=>new gP,go(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var j7=BigInt(1),bP=BigInt(2),U7=BigInt(3),M7=BigInt(5),fke=BigInt(8),xP=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function F7(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=xP,a=e*e%o*e%o,c=xn(a,bP,o)*a%o,l=xn(c,j7,o)*e%o,u=xn(l,M7,o)*l%o,d=xn(u,t,o)*u%o,f=xn(d,r,o)*d%o,p=xn(f,i,o)*f%o,y=xn(p,n,o)*p%o,g=xn(y,n,o)*p%o,b=xn(g,t,o)*u%o;return{pow_p_5_8:xn(b,bP,o)*e%o,b2:a}}function Z7(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var wP=(()=>{let e=xP;return KR({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=F7(t);return $r(xn(r,U7,e)*i,e)},adjustScalarBytes:Z7})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var H7=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),J7=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var K7=l0(H7),p0=u0(K7,pm);var V7=l0(J7),vP=u0(V7,yP);function _P(e,t,r){if(bn(e),r===void 0)r=new Uint8Array(e.outputLen);return dc(e,r,t)}var m0=Uint8Array.of(0),SP=Uint8Array.of();function kP(e,t,r,i=32){bn(e),Vt(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=SP;else Ne(r,void 0,"info");let s=new Uint8Array(o*n),a=dc.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)m0[0]=u+1,c.update(u===0?SP:l).update(r).update(m0).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Ur(l,m0),s.slice(0,i)}var W7=BigInt(0),Hu=BigInt(1),G7=BigInt(2),Q7=BigInt(7),Y7=BigInt(256),X7=BigInt(113),AP=[],$P=[],CP=[];for(let e=0,t=Hu,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],AP.push(2*(5*i+r)),$P.push((e+1)*(e+2)/2%64);let n=W7;for(let o=0;o<7;o++)if(t=(t<<Hu^(t>>Q7)*X7)%Y7,t&G7)n^=Hu<<(Hu<<BigInt(o))-Hu;CP.push(n)}var TP=fm(CP,!0),eW=TP[0],tW=TP[1],EP=(e,t,r)=>r>32?iP(e,t,r):rP(e,t,r),IP=(e,t,r)=>r>32?oP(e,t,r):nP(e,t,r);function rW(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],d=EP(l,u,1)^r[a],f=IP(l,u,1)^r[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=f}let n=e[2],o=e[3];for(let s=0;s<24;s++){let a=$P[s],c=EP(n,o,a),l=IP(n,o,a),u=AP[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]^=eW[i],e[1]^=tW[i]}Ur(r)}class mm{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,Vt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=rm(this.state)}clone(){return this._cloneInto()}keccak(){Kx(this.state32),rW(this.state32,this.rounds),Kx(this.state32),this.posOut=0,this.pos=0}update(e){Ti(this),Ne(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){Ti(this,!1),Ne(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 Vt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(tm(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,Ur(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||=new mm(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 OP=(e,t,r,i={})=>ac(()=>new mm(t,e,r),i);var zs=OP(6,136,32,go(8));var RP=OP(6,72,64,go(10));var PP=(e,t,r,i={})=>ac((n={})=>new mm(t,e,n.dkLen===void 0?r:n.dkLen,!0),i),NP=PP(31,168,16,go(11)),ri=PP(31,136,32,go(12));function h0(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function LP(e){return h0(e),(e&e-1)===0&&e!==0}function g0(e,t){h0(e);let r=0;for(let i=0;i<t;i++,e>>>=1)r=r<<1|e&1;return r}function DP(e){return h0(e),31-Math.clz32(e)}function zP(e){let t=e.length;if(t<2||!LP(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=DP(t);for(let i=0;i<t;i++){let n=g0(i,r);if(i<n){let o=e[i];e[i]=e[n],e[n]=o}}return e}var y0=(e,t)=>{let{N:r,roots:i,dit:n,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,c=DP(r);if(!LP(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)zP(u);for(let d=0,f=1;d<c-s;d++){let p=n?d+1+s:c-d,y=1<<p,g=y>>1,b=r>>p;for(let S=0;S<r;S+=y)for(let A=0,C=f++;A<g;A++){let N=o?n?r-C:C:A*b,q=S+A,E=S+A+g,Z=i[N],L=u[E],H=u[q];if(l){let ee=e.mul(L,Z);u[q]=e.add(H,ee),u[E]=e.sub(H,ee)}else if(o)u[q]=e.add(L,H),u[E]=e.mul(e.sub(L,H),Z);else u[q]=e.add(H,L),u[E]=e.mul(e.sub(H,L),Z)}}if(!n&&a)zP(u);return u}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var ni=ho;function hm(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 BP(e){return Uint8Array.from(e)}function Ls(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(Ne(u,l,e),o.set(u,a),typeof c!=="number")u.fill(0);a+=l}return o},decode:(n)=>{Ne(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 gm(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)=>{Ne(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 Ft(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function b0(e){return(1<<e)-1}var Ake=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,C=i)=>{let N=A%C|0;return(N>=0?N|0:C+N|0)|0},l=(A,C=i)=>{let N=c(A,C)|0;return(N>C>>1?N-C|0:N)|0};function u(){let A=t(r);for(let C=0;C<r;C++){let N=g0(C,s),q=BigInt(o)**BigInt(N)%BigInt(i);A[C]=Number(q)|0}return A}let d=u(),f={add:(A,C)=>c((A|0)+(C|0))|0,sub:(A,C)=>c((A|0)-(C|0))|0,mul:(A,C)=>c((A|0)*(C|0))|0,inv:(A)=>{throw Error("not implemented")}},p={N:r,roots:d,invertButterflies:!0,skipStages:a?1:0,brp:!1},y=y0(f,{dit:!1,...p}),g=y0(f,{dit:!0,...p});return{mod:c,smod:l,nttZetas:d,NTT:{encode:(A)=>y(A),decode:(A)=>{g(A);for(let C=0;C<A.length;C++)A[C]=c(n*A[C]);return A}},bitsCoder:(A,C)=>{let N=b0(A),q=A*(r/8);return{bytesLen:q,encode:(E)=>{let Z=new Uint8Array(q);for(let L=0,H=0,ee=0,M=0;L<E.length;L++){H|=(C.encode(E[L])&N)<<ee,ee+=A;for(;ee>=8;ee-=8,H>>=8)Z[M++]=H&b0(ee)}return Z},decode:(E)=>{let Z=t(r);for(let L=0,H=0,ee=0,M=0;L<E.length;L++){H|=E[L]<<ee,ee+=8;for(;ee>=A;ee-=A,H>>=A)Z[M++]=C.decode(H&N)}return Z}}}}},nW=(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(),Ft(o,i)}}},jP=nW(NP);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var yr=256,Pi=3329,iW=3303,oW=17,{mod:Vu,nttZetas:sW,NTT:Ds,bitsCoder:aW}=qP({N:yr,Q:Pi,F:iW,ROOT_OF_UNITY:oW,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),x0={512:{N:yr,Q:Pi,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:yr,Q:Pi,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:yr,Q:Pi,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},cW=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Pi/2)/Pi,decode:(r)=>r*Pi+t>>>e}},Ju=(e)=>aW(e,cW(e));function Bs(e,t){for(let r=0;r<yr;r++)e[r]=Vu(e[r]+t[r])}function lW(e,t){for(let r=0;r<yr;r++)e[r]=Vu(e[r]-t[r])}function uW(e,t,r,i,n){let o=Vu(t*i*n+e*r),s=Vu(e*i+t*r);return{c0:o,c1:s}}function ym(e,t){for(let r=0;r<yr/2;r++){let i=sW[64+(r>>1)];if(r&1)i=-i;let{c0:n,c1:o}=uW(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 UP(e){let t=new Uint16Array(yr);for(let r=0;r<yr;){let i=e();if(i.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<yr&&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<Pi)t[r++]=o;if(r<yr&&s<Pi)t[r++]=s}}return t}function Ku(e,t,r,i){let n=e(i*yr/4,t,r),o=new Uint16Array(yr),s=rm(n),a=0;for(let c=0,l=0,u=0,d=0;c<s.length;c++){let f=s[c];for(let p=0;p<32;p++)if(u+=f&1,f>>=1,a+=1,a===i)d=u,u=0;else if(a===2*i)o[l++]=Vu(d-u),u=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return o}var dW=(e)=>{let{K:t,PRF:r,XOF:i,HASH512:n,ETA1:o,ETA2:s,du:a,dv:c}=e,l=Ju(1),u=Ju(c),d=Ju(a),f=Ls("publicKey",gm(Ju(12),t),32),p=gm(Ju(12),t),y=Ls("ciphertext",gm(d,t),u),g=Ls("seed",32,32);return{secretCoder:p,lengths:{secretKey:p.bytesLen,publicKey:f.bytesLen,cipherText:y.bytesLen},keygen:(b)=>{Ne(b,32,"seed");let S=new Uint8Array(33);S.set(b),S[32]=t;let A=n(S),[C,N]=g.decode(A),q=[],E=[];for(let H=0;H<t;H++)q.push(Ds.encode(Ku(r,N,H,o)));let Z=i(C);for(let H=0;H<t;H++){let ee=Ds.encode(Ku(r,N,t+H,o));for(let M=0;M<t;M++){let P=UP(Z.get(M,H));Bs(ee,ym(P,q[M]))}E.push(ee)}Z.clean();let L={publicKey:f.encode([E,C]),secretKey:p.encode(q)};return Ft(C,N,q,E,S,A),L},encrypt:(b,S,A)=>{let[C,N]=f.decode(b),q=[];for(let M=0;M<t;M++)q.push(Ds.encode(Ku(r,A,M,o)));let E=i(N),Z=new Uint16Array(yr),L=[];for(let M=0;M<t;M++){let P=Ku(r,A,t+M,s),z=new Uint16Array(yr);for(let I=0;I<t;I++){let R=UP(E.get(M,I));Bs(z,ym(R,q[I]))}Bs(P,Ds.decode(z)),L.push(P),Bs(Z,ym(C[M],q[M])),Ft(z)}E.clean();let H=Ku(r,A,2*t,s);Bs(H,Ds.decode(Z));let ee=l.decode(S);return Bs(ee,H),Ft(C,q,Z,H),y.encode([L,ee])},decrypt:(b,S)=>{let[A,C]=y.decode(b),N=p.decode(S),q=new Uint16Array(yr);for(let E=0;E<t;E++)Bs(q,ym(N[E],Ds.encode(A[E])));return lW(C,Ds.decode(q)),Ft(q,N,A),l.encode(C)}}};function w0(e){let t=dW(e),{HASH256:r,HASH512:i,KDF:n}=e,{secretCoder:o,lengths:s}=t,a=Ls("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=ni(64))=>{Ne(u,64,"seed");let{publicKey:d,secretKey:f}=t.keygen(u.subarray(0,32)),p=r(d),y=a.encode([f,d,p,u.subarray(32)]);return Ft(f,p),{publicKey:d,secretKey:y}},getPublicKey:(u)=>{let[d,f,p,y]=a.decode(u);return Uint8Array.from(f)},encapsulate:(u,d=ni(32))=>{Ne(u,s.publicKey,"publicKey"),Ne(d,32,"message");let f=u.subarray(0,384*e.K),p=o.encode(o.decode(BP(f)));if(!hm(p,f))throw Ft(p),Error("ML-KEM.encapsulate: wrong publicKey modulus");Ft(p);let y=i.create().update(d).update(r(u)).digest(),g=t.encrypt(u,d,y.subarray(32,64));return Ft(y.subarray(32)),{cipherText:g,sharedSecret:y.subarray(0,32)}},decapsulate:(u,d)=>{Ne(d,a.bytesLen,"secretKey"),Ne(u,s.cipherText,"cipherText");let f=a.bytesLen-96,p=f+32,y=r(d.subarray(f/2,p));if(!hm(y,d.subarray(p,p+32)))throw Error("invalid secretKey: hash check failed");let[g,b,S,A]=a.decode(d),C=t.decrypt(u,g),N=i.create().update(C).update(S).digest(),q=N.subarray(0,32),E=t.encrypt(b,C,N.subarray(32,64)),Z=hm(u,E),L=n.create({dkLen:32}).update(A).update(u).digest();return Ft(C,E,!Z?q:L),Z?q:L}}}function fW(e,t,r){return ri.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var v0={HASH256:zs,HASH512:RP,KDF:ri,XOF:jP,PRF:fW},Bke=w0({...v0,...x0[512]}),Wu=w0({...v0,...x0[768]}),MP=w0({...v0,...x0[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function pW(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=ni(r.seed))=>{Ne(s,r.seed,"seed");let a=o.isLE?bo(s):yo(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 S0(e,t=!1){let r=pW(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=ni(e.lengths.seed)){let o=this.keygen(n).secretKey,s=this.decapsulate(i,o),a=e.getPublicKey(o);return Ft(o),{sharedSecret:s,cipherText:a}},decapsulate(i,n){let o=e.getSharedSecret(n,i);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function Gu(e,t){return Ls(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function _0(e){return(t,r)=>e(t,{dkLen:r})}function mW(e,t,...r){let i=Gu(r,"seed"),n=Gu(r,"publicKey");if(e===void 0)e=i.bytesLen;Vt(e);function o(s){Ne(s,e);let a=i.decode(t(s,i.bytesLen)),c=r.map((d,f)=>d.keygen(a[f])),l=c.map((d)=>d.secretKey),u=c.map((d)=>d.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=ni(e)){let{publicKey:a,secretKey:c}=o(s),l=n.encode(a);return Ft(a),Ft(c),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function bm(e,t,r,i,...n){let o=mW(e,r,...n),s=Gu(n,"cipherText"),a=Gu(n,"publicKey"),c=Gu(n,"msg");if(t===void 0)t=c.bytesLen;return Vt(t),{lengths:{...o.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,u=ni(c.bytesLen)){let d=a.decode(l),f=c.decode(u),p=n.map((S,A)=>S.encapsulate(d[A],f[A])),y=p.map((S)=>S.sharedSecret),g=p.map((S)=>S.cipherText),b={sharedSecret:i(d,g,y),cipherText:s.encode(g)};return Ft(y,g),b},decapsulate(l,u){let d=s.decode(l),{publicKey:f,secretKey:p}=o.expandDecapsulationKey(u),y=n.map((g,b)=>g.decapsulate(d[b],p[b]));return i(f,d,y)}}}function FP(e,t,r,i,n){return bn(i),bn(n),bm(32,32,_0(i),(o,s,a)=>n(Lt(a[0],a[1],s[1],o[1],xo(e))),t,r)}var Wke=FP("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Wu,S0(p0,!0),ri,zs),Gke=FP("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",MP,S0(vP,!0),ri,zs);function hW(e,t,r,i,n){return bn(i),bn(n),bm(32,32,_0(i),(o,s,a)=>{let c=Lt(a[0],a[1],s[0],o[0],s[1],o[1],xo(e)),l=32,u=Lt(xo("hybrid_prk"),c),d=_P(n,u),f=Lt(cc(32,2),xo("shared_secret"),xo("")),p=kP(n,d,f,32);return Ft(d,f,u,c),p},t,r)}var ZP=S0(wP),Qke=hW("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Wu,ZP,ri,pm),gW=(()=>bm(32,32,_0(ri),(e,t,r)=>zs(Lt(r[0],r[1],t[1],e[1],xo("\\.//^\\"))),Wu,ZP))();function yW(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,d=t;;u=d,d+=t){if(d>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(u,d),!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=ni(i)){return Ne(s,i,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=ni(i)){Ne(a,i,"rand");let{secretKey:c}=o(a),l=this.decapsulate(s,c),u=e.getPublicKey(c,!1);return Ft(c),{sharedSecret:l,cipherText:u}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function bW(e,t,r,i){let{secretKey:n,publicKeyUncompressed:o}=r.lengths;if(!n||!o)throw Error("wrong curve");let s=yW(r,n,o,i),a=64,c=a+i;return bm(32,32,(l)=>{Ne(l,32);let u=ri(l,{dkLen:c}),d=u.subarray(0,a),f=u.subarray(a,c);return Lt(d,f)},(l,u,d)=>zs(Lt(d[0],d[1],u[1],l[1],xo(e))),t,s)}var xW=(()=>bW("MLKEM768-P256",Wu,p0,128))();var xm=gW,HP=xW;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lt=(e,t,r)=>er(e,t,r),E0=Tt,pc=Fp,ir=(...e)=>$x(...e),mc=(e)=>Au(e),hc=Ex,gc=(e)=>Ii(e),vm=BigInt(0),k0=BigInt(1);function Ni(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(!wm(e))throw RangeError("positive bigint expected, got "+e)}else E0(e);return e}function ii(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 Qu(e){let t=Sm(e).toString(16);return t.length&1?"0"+t:t}function JP(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?vm:BigInt("0x"+e)}function qs(e){return JP(Fp(e))}function Ln(e){return JP(Fp(ko(er(e)).reverse()))}function _m(e,t){if(Tt(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 Au(r.padStart(t*2,"0"))}function Yu(e,t){return _m(e,t).reverse()}function KP(e,t){if(e=lt(e),t=lt(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 ko(e){return Uint8Array.from(lt(e))}function km(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 wm=(e)=>typeof e==="bigint"&&vm<=e;function wW(e,t,r){return wm(e)&&wm(t)&&wm(r)&&t<=e&&e<r}function zi(e,t,r,i){if(!wW(t,r,i))throw RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function yc(e){if(e<vm)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>vm;e>>=k0,t+=1);return t}var Xu=(e)=>(k0<<BigInt(e))-k0;function VP(e,t,r){if(Tt(e,"hashLen"),Tt(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let i=(b)=>new Uint8Array(b),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},f=(...b)=>r(l,ir(c,...b)),p=(b=n)=>{if(l=f(o,b),c=f(),b.length===0)return;l=f(s,b),c=f()},y=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let b=0,S=[];while(b<t){c=f();let A=c.slice();S.push(A),b+=c.length}return ir(...S)};return(b,S)=>{d(),p(b);let A=void 0;while((A=S(y()))===void 0)p();return d(),A}}function wn(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 I0=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var or=BigInt(0),Et=BigInt(1),js=BigInt(2),YP=BigInt(3),XP=BigInt(4),e2=BigInt(5),vW=BigInt(7),t2=BigInt(8),SW=BigInt(9),r2=BigInt(16);function mt(e,t){if(t<=or)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=or?r:t+r}function vn(e,t,r){if(t<or)throw Error("pow2: expected non-negative exponent, got "+t);let i=e;while(t-- >or)i*=i,i%=r;return i}function WP(e,t){if(e===or)throw Error("invert: expected non-zero number");if(t<=or)throw Error("invert: expected positive modulus, got "+t);let r=mt(e,t),i=t,n=or,o=Et,s=Et,a=or;while(r!==or){let l=i/r,u=i-r*l,d=n-s*l,f=o-a*l;i=r,r=u,n=s,o=a,s=d,a=f}if(i!==Et)throw Error("invert: does not exist");return mt(n,t)}function A0(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw Error("Cannot find square root")}function n2(e,t){let r=e,i=(r.ORDER+Et)/XP,n=r.pow(t,i);return A0(r,n,t),n}function _W(e,t){let r=e,i=(r.ORDER-e2)/t2,n=r.mul(t,js),o=r.pow(n,i),s=r.mul(t,o),a=r.mul(r.mul(s,js),o),c=r.mul(s,r.sub(a,r.ONE));return A0(r,c,t),c}function kW(e){let t=Em(e),r=i2(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+vW)/r2;return(a,c)=>{let l=a,u=l.pow(c,s),d=l.mul(u,i),f=l.mul(u,n),p=l.mul(u,o),y=l.eql(l.sqr(d),c),g=l.eql(l.sqr(f),c);u=l.cmov(u,d,y),d=l.cmov(p,f,g);let b=l.eql(l.sqr(d),c),S=l.cmov(u,d,b);return A0(l,S,c),S}}function i2(e){if(e<YP)throw Error("sqrt is not defined for small field");let t=e-Et,r=0;while(t%js===or)t/=js,r++;let i=js,n=Em(e);while(GP(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return n2;let o=n.pow(i,t),s=(t+Et)/js;return function(c,l){let u=c;if(u.is0(l))return l;if(GP(u,l)!==1)throw Error("Cannot find square root");let d=r,f=u.mul(u.ONE,o),p=u.pow(l,t),y=u.pow(l,s);while(!u.eql(p,u.ONE)){if(u.is0(p))return u.ZERO;let g=1,b=u.sqr(p);while(!u.eql(b,u.ONE))if(g++,b=u.sqr(b),g===d)throw Error("Cannot find square root");let S=Et<<BigInt(d-g-1),A=u.pow(f,S);d=g,f=u.sqr(A),p=u.mul(p,f),y=u.mul(y,A)}return y}}function EW(e){if(e%XP===YP)return n2;if(e%t2===e2)return _W;if(e%r2===SW)return kW(e);return i2(e)}var Li=(e,t)=>(mt(e,t)&Et)===Et,IW=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function $0(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=IW.reduce((i,n)=>(i[n]="function",i),t);if(wn(e,r),ii(e.BYTES,"BYTES"),ii(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Et)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function AW(e,t,r){let i=e;if(r<or)throw Error("invalid exponent, negatives unsupported");if(r===or)return i.ONE;if(r===Et)return t;let n=i.ONE,o=t;while(r>or){if(r&Et)n=i.mul(n,o);o=i.sqr(o),r>>=Et}return n}function ed(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 GP(e,t){let r=e,i=(r.ORDER-Et)/js,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 $W(e,t){if(t!==void 0)E0(t);if(e<=or)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=yc(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 QP=new WeakMap;class C0{ORDER;BITS;BYTES;isLE;ZERO=or;ONE=Et;_lengths;_mod;constructor(e,t={}){if(e<=Et)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}=$W(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 mt(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return or<=e&&e<this.ORDER}is0(e){return e===or}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Et)===Et}neg(e){return mt(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return mt(e*e,this.ORDER)}add(e,t){return mt(e+t,this.ORDER)}sub(e,t){return mt(e-t,this.ORDER)}mul(e,t){return mt(e*t,this.ORDER)}pow(e,t){return AW(this,e,t)}div(e,t){return mt(e*WP(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 WP(e,this.ORDER)}sqrt(e){let t=QP.get(this);if(!t)QP.set(this,t=EW(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?Yu(e,this.BYTES):_m(e,this.BYTES)}fromBytes(e,t=!1){lt(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?Ln(e):qs(e);if(s)a=mt(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ed(this,e)}cmov(e,t,r){return Ni(r,"condition"),r?t:e}}Object.freeze(C0.prototype);function Em(e,t={}){return new C0(e,t)}function o2(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=Et)throw Error("field order must be greater than 1");let t=yc(e-Et);return Math.ceil(t/8)}function T0(e){let t=o2(e);return t+Math.ceil(t/2)}function s2(e,t,r=!1){lt(e);let i=e.length,n=o2(t),o=Math.max(T0(t),16);if(i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?Ln(e):qs(e),a=mt(s,t-Et)+Et;return r?Yu(a,n):_m(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var bc=BigInt(0),Us=BigInt(1);function td(e,t){let r=t.negate();return e?r:t}function Ms(e,t){let r=ed(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function u2(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function O0(e,t){u2(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Xu(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function a2(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+=Us;let l=t*i,u=l+Math.abs(a)-1,d=a===0,f=a<0,p=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}var R0=new WeakMap,d2=new WeakMap;function P0(e){return d2.get(e)||1}function c2(e){if(e!==bc)throw Error("invalid wNAF")}class rd{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>bc){if(t&Us)r=r.add(i);i=i.double(),t>>=Us}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=O0(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=O0(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:f}=a2(r,s,o);if(r=a,l)n=n.add(td(d,t[f]));else i=i.add(td(u,t[c]))}return c2(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=O0(e,this.bits);for(let o=0;o<n.windows;o++){if(r===bc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=a2(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return c2(r),i}getPrecomputes(e,t,r){let i=R0.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);R0.set(t,i)}}return i}cached(e,t,r){let i=P0(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=P0(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){u2(t,this.bits),d2.set(e,t),R0.delete(e)}hasCache(e){return P0(e)!==1}}function f2(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>bc||i>bc){if(r&Us)o=o.add(n);if(i&Us)s=s.add(n);n=n.double(),r>>=Us,i>>=Us}return{p1:o,p2:s}}function l2(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return $0(t),t}else return Em(e,{isLE:r})}function Im(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>bc))throw Error(`CURVE.${c} must be positive bigint`)}let n=l2(t.p,r.Fp,i),o=l2(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 nd(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}function id(e,t){if(ii(e),ii(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 CW(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 TW(e){if(!hc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?km(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function N0(e,t,r,i){if(lt(e),ii(r),t=TW(t),t.length>255)t=i(ir(km("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=ir(t,id(t.length,1)),c=new Uint8Array(o),l=id(r,2),u=Array(s),d=i(ir(c,e,l,id(0,1),a));u[0]=i(ir(d,id(1,1),a));for(let p=1;p<s;p++){let y=[CW(d,u[p-1]),id(p+1,1),a];u[p]=i(ir(...y))}return ir(...u).slice(0,r)}var p2="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var m2=(e,t)=>(e+(e>=0?t:-t)/g2)/t;function OW(e,t,r){zi("scalar",e,oi,r);let[[i,n],[o,s]]=t,a=m2(s*e,r),c=m2(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<oi,f=u<oi;if(d)l=-l;if(f)u=-u;let p=Xu(Math.ceil(yc(r)/2))+Eo;if(l<oi||l>=p||u<oi||u>=p)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:l,k2neg:f,k2:u}}function L0(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function z0(e,t){wn(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Ni(r.lowS,"lowS"),Ni(r.prehash,"prehash"),r.format!==void 0)L0(r.format);return r}class h2 extends Error{constructor(e=""){super(e)}}var Dn={Err:h2,_tlv:{encode:(e,t)=>{let{Err:r}=Dn;if(ii(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=Qu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Qu(n.length/2|128):"";return Qu(e)+o+n+t},decode(e,t){let{Err:r}=Dn;t=lt(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}=Dn;if(Sm(e),e<oi)throw new t("integer: negative integers are not allowed");let r=Qu(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}=Dn;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 qs(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Dn,n=lt(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}=Dn,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(Dn._tlv);Object.freeze(Dn._int);Object.freeze(Dn);var oi=BigInt(0),Eo=BigInt(1),g2=BigInt(2),Am=BigInt(3),RW=BigInt(4);function y2(e,t={}){let r=Im("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:s,n:a}=o;wn(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=x2(i,n);function d(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(M,P,z){if(l&&P.is0())return Uint8Array.of(0);let{x:I,y:R}=P.toAffine(),O=i.toBytes(I);if(Ni(z,"isCompressed"),z){d();let F=!i.isOdd(R);return ir(b2(F),O)}else return ir(Uint8Array.of(4),O,i.toBytes(R))}function p(M){lt(M,void 0,"Point");let{publicKey:P,publicKeyUncompressed:z}=u,I=M.length,R=M[0],O=M.subarray(1);if(l&&I===1&&R===0)return{x:i.ZERO,y:i.ZERO};if(I===P&&(R===2||R===3)){let F=i.fromBytes(O);if(!i.isValid(F))throw Error("bad point: is not on curve, wrong x");let D=b(F),V;try{V=i.sqrt(D)}catch(ue){let T=ue instanceof Error?": "+ue.message:"";throw Error("bad point: is not on curve, sqrt error"+T)}d();let _=i.isOdd(V);if((R&1)===1!==_)V=i.neg(V);return{x:F,y:V}}else if(I===z&&R===4){let F=i.BYTES,D=i.fromBytes(O.subarray(0,F)),V=i.fromBytes(O.subarray(F,F*2));if(!S(D,V))throw Error("bad point: is not on curve");return{x:D,y:V}}else throw Error(`bad point: got length ${I}, expected compressed=${P} or uncompressed=${z}`)}let y=t.toBytes===void 0?f:t.toBytes,g=t.fromBytes===void 0?p:t.fromBytes;function b(M){let P=i.sqr(M),z=i.mul(P,M);return i.add(i.add(z,i.mul(M,o.a)),o.b)}function S(M,P){let z=i.sqr(P),I=b(M);return i.eql(z,I)}if(!S(o.Gx,o.Gy))throw Error("bad curve params: generator point");let A=i.mul(i.pow(o.a,Am),RW),C=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(A,C)))throw Error("bad curve params: a or b");function N(M,P,z=!1){if(!i.isValid(P)||z&&i.is0(P))throw Error(`bad point coordinate ${M}`);return P}function q(M){if(!(M instanceof L))throw Error("Weierstrass Point expected")}function E(M){if(!c||!c.basises)throw Error("no endo");return OW(M,c.basises,n.ORDER)}function Z(M,P,z,I,R){return z=new L(i.mul(z.X,M),z.Y,z.Z),P=td(I,P),z=td(R,z),P.add(z)}class L{static BASE=new L(o.Gx,o.Gy,i.ONE);static ZERO=new L(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(M,P,z){this.X=N("x",M),this.Y=N("y",P,!0),this.Z=N("z",z),Object.freeze(this)}static CURVE(){return o}static fromAffine(M){let{x:P,y:z}=M||{};if(!M||!i.isValid(P)||!i.isValid(z))throw Error("invalid affine point");if(M instanceof L)throw Error("projective point not allowed");if(i.is0(P)&&i.is0(z))return L.ZERO;return new L(P,z,i.ONE)}static fromBytes(M){let P=L.fromAffine(g(lt(M,void 0,"point")));return P.assertValidity(),P}static fromHex(M){return L.fromBytes(mc(M))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(M=8,P=!0){if(ee.createCache(this,M),!P)this.multiply(Am);return this}assertValidity(){let M=this;if(M.is0()){if(t.allowInfinityPoint&&i.is0(M.X)&&i.eql(M.Y,i.ONE)&&i.is0(M.Z))return;throw Error("bad point: ZERO")}let{x:P,y:z}=M.toAffine();if(!i.isValid(P)||!i.isValid(z))throw Error("bad point: x or y not field elements");if(!S(P,z))throw Error("bad point: equation left != right");if(!M.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:M}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(M)}equals(M){q(M);let{X:P,Y:z,Z:I}=this,{X:R,Y:O,Z:F}=M,D=i.eql(i.mul(P,F),i.mul(R,I)),V=i.eql(i.mul(z,F),i.mul(O,I));return D&&V}negate(){return new L(this.X,i.neg(this.Y),this.Z)}double(){let{a:M,b:P}=o,z=i.mul(P,Am),{X:I,Y:R,Z:O}=this,F=i.ZERO,D=i.ZERO,V=i.ZERO,_=i.mul(I,I),re=i.mul(R,R),ue=i.mul(O,O),T=i.mul(I,R);return T=i.add(T,T),V=i.mul(I,O),V=i.add(V,V),F=i.mul(M,V),D=i.mul(z,ue),D=i.add(F,D),F=i.sub(re,D),D=i.add(re,D),D=i.mul(F,D),F=i.mul(T,F),V=i.mul(z,V),ue=i.mul(M,ue),T=i.sub(_,ue),T=i.mul(M,T),T=i.add(T,V),V=i.add(_,_),_=i.add(V,_),_=i.add(_,ue),_=i.mul(_,T),D=i.add(D,_),ue=i.mul(R,O),ue=i.add(ue,ue),_=i.mul(ue,T),F=i.sub(F,_),V=i.mul(ue,re),V=i.add(V,V),V=i.add(V,V),new L(F,D,V)}add(M){q(M);let{X:P,Y:z,Z:I}=this,{X:R,Y:O,Z:F}=M,D=i.ZERO,V=i.ZERO,_=i.ZERO,re=o.a,ue=i.mul(o.b,Am),T=i.mul(P,R),we=i.mul(z,O),Ee=i.mul(I,F),Te=i.add(P,z),Ce=i.add(R,O);Te=i.mul(Te,Ce),Ce=i.add(T,we),Te=i.sub(Te,Ce),Ce=i.add(P,I);let _e=i.add(R,F);return Ce=i.mul(Ce,_e),_e=i.add(T,Ee),Ce=i.sub(Ce,_e),_e=i.add(z,I),D=i.add(O,F),_e=i.mul(_e,D),D=i.add(we,Ee),_e=i.sub(_e,D),_=i.mul(re,Ce),D=i.mul(ue,Ee),_=i.add(D,_),D=i.sub(we,_),_=i.add(we,_),V=i.mul(D,_),we=i.add(T,T),we=i.add(we,T),Ee=i.mul(re,Ee),Ce=i.mul(ue,Ce),we=i.add(we,Ee),Ee=i.sub(T,Ee),Ee=i.mul(re,Ee),Ce=i.add(Ce,Ee),T=i.mul(we,Ce),V=i.add(V,T),T=i.mul(_e,Ce),D=i.mul(Te,D),D=i.sub(D,T),T=i.mul(Te,we),_=i.mul(_e,_),_=i.add(_,T),new L(D,V,_)}subtract(M){return q(M),this.add(M.negate())}is0(){return this.equals(L.ZERO)}multiply(M){let{endo:P}=t;if(!n.isValidNot0(M))throw RangeError("invalid scalar: out of range");let z,I,R=(O)=>ee.cached(this,O,(F)=>Ms(L,F));if(P){let{k1neg:O,k1:F,k2neg:D,k2:V}=E(M),{p:_,f:re}=R(F),{p:ue,f:T}=R(V);I=re.add(T),z=Z(P.beta,_,ue,O,D)}else{let{p:O,f:F}=R(M);z=O,I=F}return Ms(L,[z,I])[0]}multiplyUnsafe(M){let{endo:P}=t,z=this,I=M;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===oi||z.is0())return L.ZERO;if(I===Eo)return z;if(ee.hasCache(this))return this.multiply(I);if(P){let{k1neg:R,k1:O,k2neg:F,k2:D}=E(I),{p1:V,p2:_}=f2(L,z,O,D);return Z(P.beta,V,_,R,F)}else return ee.unsafe(z,I)}toAffine(M){let P=this,z=M,{X:I,Y:R,Z:O}=P;if(i.eql(O,i.ONE))return{x:I,y:R};let F=P.is0();if(z==null)z=F?i.ONE:i.inv(O);let D=i.mul(I,z),V=i.mul(R,z),_=i.mul(O,z);if(F)return{x:i.ZERO,y:i.ZERO};if(!i.eql(_,i.ONE))throw Error("invZ was invalid");return{x:D,y:V}}isTorsionFree(){let{isTorsionFree:M}=t;if(s===Eo)return!0;if(M)return M(L,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:M}=t;if(s===Eo)return this;if(M)return M(L,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Eo)return this.is0();return this.clearCofactor().is0()}toBytes(M=!0){return Ni(M,"isCompressed"),this.assertValidity(),y(L,this,M)}toHex(M=!0){return pc(this.toBytes(M))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let H=n.BITS,ee=new rd(L,t.endo?Math.ceil(H/2):H);if(H>=8)L.BASE.precompute(8);return Object.freeze(L.prototype),Object.freeze(L),L}function b2(e){return Uint8Array.of(e?2:3)}function x2(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function PW(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?gc:t.randomBytes,n=Object.assign(x2(e.Fp,r),{seed:Math.max(T0(r.ORDER),16)});function o(p){try{let y=r.fromBytes(p);return r.isValidNot0(y)}catch(y){return!1}}function s(p,y){let{publicKey:g,publicKeyUncompressed:b}=n;try{let S=p.length;if(y===!0&&S!==g)return!1;if(y===!1&&S!==b)return!1;return!!e.fromBytes(p)}catch(S){return!1}}function a(p){return p=p===void 0?i(n.seed):p,s2(lt(p,n.seed,"seed"),r.ORDER)}function c(p,y=!0){return e.BASE.multiply(r.fromBytes(p)).toBytes(y)}function l(p){let{secretKey:y,publicKey:g,publicKeyUncompressed:b}=n,S=r._lengths;if(!hc(p))return;let A=lt(p,void 0,"key").length,C=A===g||A===b,N=A===y||!!S?.includes(A);if(C&&N)return;return C}function u(p,y,g=!0){if(l(p)===!0)throw Error("first arg must be private key");if(l(y)===!1)throw Error("second arg must be public key");let b=r.fromBytes(p);return e.fromBytes(y).multiply(b).toBytes(g)}let d={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},f=nd(a,c);return Object.freeze(d),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:n})}function w2(e,t,r={}){let i=t;Ei(i),wn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?gc:r.randomBytes,o=r.hmac===void 0?(R,O)=>Yn(i,R,O):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:l}=a,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:y}=PW(e,r),g={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},b=c*g2+Eo<s.ORDER;function S(R){let O=c>>Eo;return R>O}function A(R,O){if(!a.isValidNot0(O))throw Error(`invalid signature ${R}: out of range 1..Point.Fn.ORDER`);return O}function C(){if(b)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function N(R,O){L0(O);let F=y.signature,D=O==="compact"?F:O==="recovered"?F+1:void 0;return lt(R,D)}class q{r;s;recovery;constructor(R,O,F){if(this.r=A("r",R),this.s=A("s",O),F!=null){if(C(),![0,1,2,3].includes(F))throw Error("invalid recovery id");this.recovery=F}Object.freeze(this)}static fromBytes(R,O=g.format){N(R,O);let F;if(O==="der"){let{r:re,s:ue}=Dn.toSig(lt(R));return new q(re,ue)}if(O==="recovered")F=R[0],O="compact",R=R.subarray(1);let D=y.signature/2,V=R.subarray(0,D),_=R.subarray(D,D*2);return new q(a.fromBytes(V),a.fromBytes(_),F)}static fromHex(R,O){return this.fromBytes(mc(R),O)}assertRecovery(){let{recovery:R}=this;if(R==null)throw Error("invalid recovery id: must be present");return R}addRecoveryBit(R){return new q(this.r,this.s,R)}recoverPublicKey(R){let{r:O,s:F}=this,D=this.assertRecovery(),V=D===2||D===3?O+c:O;if(!s.isValid(V))throw Error("invalid recovery id: sig.r+curve.n != R.x");let _=s.toBytes(V),re=e.fromBytes(ir(b2((D&1)===0),_)),ue=a.inv(V),T=Z(lt(R,void 0,"msgHash")),we=a.create(-T*ue),Ee=a.create(F*ue),Te=e.BASE.multiplyUnsafe(we).add(re.multiplyUnsafe(Ee));if(Te.is0())throw Error("invalid recovery: point at infinify");return Te.assertValidity(),Te}hasHighS(){return S(this.s)}toBytes(R=g.format){if(L0(R),R==="der")return mc(Dn.hexFromSig(this));let{r:O,s:F}=this,D=a.toBytes(O),V=a.toBytes(F);if(R==="recovered")return C(),ir(Uint8Array.of(this.assertRecovery()),D,V);return ir(D,V)}toHex(R){return pc(this.toBytes(R))}}Object.freeze(q.prototype),Object.freeze(q);let E=r.bits2int===void 0?function(O){if(O.length>8192)throw Error("input is too large");let F=qs(O),D=O.length*8-l;return D>0?F>>BigInt(D):F}:r.bits2int,Z=r.bits2int_modN===void 0?function(O){return a.create(E(O))}:r.bits2int_modN,L=Xu(l);function H(R){return zi("num < 2^"+l,R,oi,L),a.toBytes(R)}function ee(R,O){return lt(R,void 0,"message"),O?lt(i(R),void 0,"prehashed message"):R}function M(R,O,F){let{lowS:D,prehash:V,extraEntropy:_}=z0(F,g);R=ee(R,V);let re=Z(R),ue=a.fromBytes(O);if(!a.isValidNot0(ue))throw Error("invalid private key");let T=[H(ue),H(re)];if(_!=null&&_!==!1){let Ce=_===!0?n(y.secretKey):_;T.push(lt(Ce,void 0,"extraEntropy"))}let we=ir(...T),Ee=re;function Te(Ce){let _e=E(Ce);if(!a.isValidNot0(_e))return;let Pe=a.inv(_e),Ve=e.BASE.multiply(_e).toAffine(),tt=a.create(Ve.x);if(tt===oi)return;let bt=a.create(Pe*a.create(Ee+tt*ue));if(bt===oi)return;let zt=(Ve.x===tt?0:2)|Number(Ve.y&Eo),pr=bt;if(D&&S(bt))pr=a.neg(bt),zt^=1;return new q(tt,pr,b?void 0:zt)}return{seed:we,k2sig:Te}}function P(R,O,F={}){let{seed:D,k2sig:V}=M(R,O,F);return VP(i.outputLen,a.BYTES,o)(D,V).toBytes(F.format)}function z(R,O,F,D={}){let{lowS:V,prehash:_,format:re}=z0(D,g);if(F=lt(F,void 0,"publicKey"),O=ee(O,_),!hc(R)){let ue=R instanceof q?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ue)}N(R,re);try{let ue=q.fromBytes(R,re),T=e.fromBytes(F);if(V&&ue.hasHighS())return!1;let{r:we,s:Ee}=ue,Te=Z(O),Ce=a.inv(Ee),_e=a.create(Te*Ce),Pe=a.create(we*Ce),Ve=e.BASE.multiplyUnsafe(_e).add(T.multiplyUnsafe(Pe));if(Ve.is0())return!1;return a.create(Ve.x)===we}catch(ue){return!1}}function I(R,O,F={}){let{prehash:D}=z0(F,g);return O=ee(O,D),q.fromBytes(R,"recovered").recoverPublicKey(O).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:y,Point:e,sign:P,verify:z,recoverPublicKey:I,Signature:q,hash:i})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var NW=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var zW=y2(NW),xc=w2(zW,Ot);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Io=BigInt(0),Mr=BigInt(1),D0=BigInt(2),LW=BigInt(8);function DW(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 v2(e,t={}){let r=t,i=Im("edwards",e,r,r.FpFnLE),{Fp:n,Fn:o}=i,s=i.CURVE,{h:a}=s;wn(r,{},{uvRatio:"function"});let c=D0<<BigInt(o.BYTES*8)-Mr,l=(g)=>n.create(g),u=r.uvRatio===void 0?(g,b)=>{try{return{isValid:!0,value:n.sqrt(n.div(g,b))}}catch(S){return{isValid:!1,value:Io}}}:r.uvRatio;if(!DW(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function d(g,b,S=!1){let A=S?Mr:Io;return zi("coordinate "+g,b,A,c),b}function f(g){if(!(g instanceof p))throw Error("EdwardsPoint expected")}class p{static BASE=new p(s.Gx,s.Gy,Mr,l(s.Gx*s.Gy));static ZERO=new p(Io,Mr,Mr,Io);static Fp=n;static Fn=o;X;Y;Z;T;constructor(g,b,S,A){this.X=d("x",g),this.Y=d("y",b),this.Z=d("z",S,!0),this.T=d("t",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){if(g instanceof p)throw Error("extended point not allowed");let{x:b,y:S}=g||{};return d("x",b),d("y",S),new p(b,S,Mr,l(b*S))}static fromBytes(g,b=!1){let S=n.BYTES,{a:A,d:C}=s;g=ko(lt(g,S,"point")),Ni(b,"zip215");let N=ko(g),q=g[S-1];N[S-1]=q&-129;let E=Ln(N),Z=b?c:n.ORDER;zi("point.y",E,Io,Z);let L=l(E*E),H=l(L-Mr),ee=l(C*L-A),{isValid:M,value:P}=u(H,ee);if(!M)throw Error("bad point: invalid y coordinate");let z=(P&Mr)===Mr,I=(q&128)!==0;if(!b&&P===Io&&I)throw Error("bad point: x=0 and x_0=1");if(I!==z)P=l(-P);return p.fromAffine({x:P,y:E})}static fromHex(g,b=!1){return p.fromBytes(mc(g),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,b=!0){if(y.createCache(this,g),!b)this.multiply(D0);return this}assertValidity(){let g=this,{a:b,d:S}=s;if(g.is0())throw Error("bad point: ZERO");let{X:A,Y:C,Z:N,T:q}=g,E=l(A*A),Z=l(C*C),L=l(N*N),H=l(L*L),ee=l(E*b),M=l(L*l(ee+Z)),P=l(H+l(S*l(E*Z)));if(M!==P)throw Error("bad point: equation left != right (1)");let z=l(A*C),I=l(N*q);if(z!==I)throw Error("bad point: equation left != right (2)")}equals(g){f(g);let{X:b,Y:S,Z:A}=this,{X:C,Y:N,Z:q}=g,E=l(b*q),Z=l(C*A),L=l(S*q),H=l(N*A);return E===Z&&L===H}is0(){return this.equals(p.ZERO)}negate(){return new p(l(-this.X),this.Y,this.Z,l(-this.T))}double(){let{a:g}=s,{X:b,Y:S,Z:A}=this,C=l(b*b),N=l(S*S),q=l(D0*l(A*A)),E=l(g*C),Z=b+S,L=l(l(Z*Z)-C-N),H=E+N,ee=H-q,M=E-N,P=l(L*ee),z=l(H*M),I=l(L*M),R=l(ee*H);return new p(P,z,R,I)}add(g){f(g);let{a:b,d:S}=s,{X:A,Y:C,Z:N,T:q}=this,{X:E,Y:Z,Z:L,T:H}=g,ee=l(A*E),M=l(C*Z),P=l(q*S*H),z=l(N*L),I=l((A+C)*(E+Z)-ee-M),R=z-P,O=z+P,F=l(M-b*ee),D=l(I*R),V=l(O*F),_=l(I*F),re=l(R*O);return new p(D,V,re,_)}subtract(g){return f(g),this.add(g.negate())}multiply(g){if(!o.isValidNot0(g))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:S}=y.cached(this,g,(A)=>Ms(p,A));return Ms(p,[b,S])[0]}multiplyUnsafe(g){if(!o.isValid(g))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(g===Io)return p.ZERO;if(this.is0()||g===Mr)return this;return y.unsafe(this,g,(b)=>Ms(p,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return y.unsafe(this,s.n).is0()}toAffine(g){let b=this,S=g,{X:A,Y:C,Z:N}=b,q=b.is0();if(S==null)S=q?LW:n.inv(N);let E=l(A*S),Z=l(C*S),L=n.mul(N,S);if(q)return{x:Io,y:Mr};if(L!==Mr)throw Error("invZ was invalid");return{x:E,y:Z}}clearCofactor(){if(a===Mr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:g,y:b}=this.toAffine(),S=n.toBytes(b);return S[S.length-1]|=g&Mr?128:0,S}toHex(){return pc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let y=new rd(p,o.BITS);if(o.BITS>=8)p.BASE.precompute(8);return Object.freeze(p.prototype),Object.freeze(p),p}class B0{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){I0()}static fromHex(e){I0()}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 pc(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 od=BigInt(0),wc=BigInt(1),$m=BigInt(2);function BW(e){return wn(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function S2(e){let t=BW(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?gc:s,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),f=a?BigInt(121665):BigInt(39081),p=a?$m**BigInt(254):$m**BigInt(447),y=a?BigInt(8)*$m**BigInt(251)-wc:BigInt(4)*$m**BigInt(445)-wc,g=p+y+wc,b=(I)=>mt(I,r),S=A(d);function A(I){return Yu(b(I),u)}function C(I){let R=ko(lt(I,u,"uCoordinate"));if(a)R[31]&=127;return b(Ln(R))}function N(I){return Ln(n(ko(lt(I,u,"scalar"))))}function q(I,R){let O=ee(C(R),N(I));if(O===od)throw Error("invalid private or public key received");return A(O)}function E(I){return q(I,S)}let Z=E,L=q;function H(I,R,O){let F=b(I*(R-O));return R=b(R-F),O=b(O+F),{x_2:R,x_3:O}}function ee(I,R){zi("u",I,od,r),zi("scalar",R,p,g);let O=R,F=I,D=wc,V=od,_=I,re=wc,ue=od;for(let we=BigInt(l-1);we>=od;we--){let Ee=O>>we&wc;ue^=Ee,{x_2:D,x_3:_}=H(ue,D,_),{x_2:V,x_3:re}=H(ue,V,re),ue=Ee;let Te=D+V,Ce=b(Te*Te),_e=D-V,Pe=b(_e*_e),Ve=Ce-Pe,tt=_+re,bt=_-re,zt=b(bt*Te),pr=b(tt*_e),Gr=zt+pr,Qr=zt-pr;_=b(Gr*Gr),re=b(F*b(Qr*Qr)),D=b(Ce*Pe),V=b(Ve*(Ce+b(f*Ve)))}({x_2:D,x_3:_}=H(ue,D,_)),{x_2:V,x_3:re}=H(ue,V,re);let T=o(V);return b(D*T)}let M={secretKey:u,publicKey:u,seed:u},P=(I)=>(I=I===void 0?c(u):I,lt(I,M.seed,"seed"),I),z={randomSecretKey:P};return Object.freeze(M),Object.freeze(z),Object.freeze({keygen:nd(P,Z),getSharedSecret:L,getPublicKey:Z,scalarMult:q,scalarMultBase:E,utils:z,GuBytes:S.slice(),lengths:M})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var qW=BigInt(0),Di=BigInt(1),_2=BigInt(2),jW=BigInt(3),UW=BigInt(5),MW=BigInt(8),Zs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),M0=(()=>({p:Zs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:MW,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function I2(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=Zs,a=e*e%o*e%o,c=vn(a,_2,o)*a%o,l=vn(c,Di,o)*e%o,u=vn(l,UW,o)*l%o,d=vn(u,t,o)*u%o,f=vn(d,r,o)*d%o,p=vn(f,i,o)*f%o,y=vn(p,n,o)*p%o,g=vn(y,n,o)*p%o,b=vn(g,t,o)*u%o;return{pow_p_5_8:vn(b,_2,o)*e%o,b2:a}}function FW(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var q0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function F0(e,t){let r=Zs,i=mt(t*t*t,r),n=mt(i*i*t,r),o=I2(e*n).pow_p_5_8,s=mt(e*i*o,r),a=mt(t*s*s,r),c=s,l=mt(s*q0,r),u=a===e,d=a===mt(-e,r),f=a===mt(-e*q0,r);if(u)s=c;if(d||f)s=l;if(Li(s,r))s=mt(-s,r);return{isValid:u||d,value:s}}var Fs=v2(M0,{uvRatio:F0}),Ao=(()=>Fs.Fp)(),A2=(()=>Fs.Fn)();var Cm=(()=>{let e=Zs;return S2({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=I2(t);return mt(vn(r,jW,e)*i,e)},adjustScalarBytes:FW})})();var j0=q0,ZW=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),HW=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),JW=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),KW=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),k2=(e)=>F0(Di,e),VW=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),U0=(e)=>Ao.create(Ln(e)&VW);function E2(e){let{d:t}=M0,r=Zs,i=(S)=>Ao.create(S),n=i(j0*e*e),o=i((n+Di)*JW),s=BigInt(-1),a=i((s-t*n)*i(n+t)),{isValid:c,value:l}=F0(o,a),u=i(l*e);if(!Li(u,r))u=i(-u);if(!c)l=u;if(!c)s=n;let d=i(s*(n-Di)*KW-a),f=l*l,p=i((l+l)*a),y=i(d*ZW),g=i(Di-f),b=i(Di+f);return new Fs(i(p*b),i(g*y),i(y*b),i(p*g))}class Tr extends B0{static BASE=(()=>new Tr(Fs.BASE))();static ZERO=(()=>new Tr(Fs.ZERO))();static Fp=(()=>Ao)();static Fn=(()=>A2)();constructor(e){super(e)}static fromAffine(e){return new Tr(Fs.fromAffine(e))}assertSame(e){if(!(e instanceof Tr))throw Error("RistrettoPoint expected")}init(e){return new Tr(e)}static fromBytes(e){er(e,32);let{a:t,d:r}=M0,i=Zs,n=(C)=>Ao.create(C),o=U0(e);if(!KP(Ao.toBytes(o),e)||Li(o,i))throw Error("invalid ristretto255 encoding 1");let s=n(o*o),a=n(Di+t*s),c=n(Di-t*s),l=n(a*a),u=n(c*c),d=n(t*r*l-u),{isValid:f,value:p}=k2(n(d*u)),y=n(p*c),g=n(p*y*d),b=n((o+o)*y);if(Li(b,i))b=n(-b);let S=n(a*g),A=n(b*S);if(!f||Li(A,i)||S===qW)throw Error("invalid ristretto255 encoding 2");return new Tr(new Fs(b,S,Di,A))}static fromHex(e){return Tr.fromBytes(Au(e))}toBytes(){let{X:e,Y:t,Z:r,T:i}=this.ep,n=Zs,o=(g)=>Ao.create(g),s=o(o(r+t)*o(r-t)),a=o(e*t),c=o(a*a),{value:l}=k2(o(s*c)),u=o(l*s),d=o(l*a),f=o(u*d*i),p;if(Li(i*f,n)){let g=o(t*j0),b=o(e*j0);e=g,t=b,p=o(u*HW)}else p=d;if(Li(e*f,n))t=o(-t);let y=o((r-t)*p);if(Li(y,n))y=o(-y);return Ao.toBytes(y)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:n}=e.ep,o=(c)=>Ao.create(c),s=o(t*n)===o(r*i),a=o(r*n)===o(t*i);return s||a}is0(){return this.equals(Tr.ZERO)}}Object.freeze(Tr.BASE);Object.freeze(Tr.ZERO);Object.freeze(Tr.prototype);Object.freeze(Tr);var WW=Object.freeze({Point:Tr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,i=N0(e,r,64,Kp);return WW.deriveToCurve(i)},hashToScalar(e,t={DST:p2}){let r=N0(e,t.DST,64,Kp);return A2.create(Ln(r))},deriveToCurve(e){er(e,64);let t=U0(e.subarray(0,32)),r=E2(t),i=U0(e.subarray(32,64)),n=E2(i);return new Tr(r.add(n))}});var $2=!1,GW=!1;async function C2(e,t){if(GW)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 Tm(e,t){return await C2(async()=>{let r=Z0(e)?e:await YW(e),i=await crypto.subtle.importKey("raw",XW(t),{name:"X25519"},$2,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},r,256))},()=>{if(Z0(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Cm.scalarMult(e,t)})}async function sd(e){return await C2(async()=>Tm(e,Cm.GuBytes),()=>{if(Z0(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Cm.scalarMultBase(e)})}var QW=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function YW(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...QW,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},$2,["deriveBits"])}function Z0(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function XW(e){return e}class H0{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),tG(Hs(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=Hs(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:Hs(this.transcript)}}}function tG(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function Hs(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 vc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let i of t)r.enqueue(i)}}))}function Om(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function J0(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function T2(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function O2(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=Hs(i),s=o.subarray(0,t),a=vc(e,o.subarray(t));return{data:s,rest:a}}class si{args;body;constructor(e,t){this.args=e,this.body=t}}async function rG(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=hr.decode(o);if(s.length>48)throw Error("invalid stanza");if(i.push(s),s.length<48)break}let n=Hs(i);return{s:new si(r,n)}}async function R2(e){let t=new H0(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 rG(t);if(n!==void 0){i.push(n);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=hr.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:vc(e,a)}}}function K0(e){let t=[];t.push(`age-encryption.org/v1
768
+ `)}function PO(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 wt(e,t){let r=e[t];return typeof r==="string"?r:void 0}function Iu(e,t){let r=e[t];return typeof r==="boolean"?r:void 0}var jp={name:"@rizom/ops",version:"0.2.0-alpha.397",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/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 run build && 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 pG,mkdirSync as mG,readFileSync as dw,writeFileSync as fw}from"fs";import{dirname as hG,join as U2}from"path";function Ex(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Tt(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 er(e,t,r=""){let i=Ex(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 Ei(e){if(typeof e!=="function"||typeof e.create!=="function")throw TypeError("Hash must wrapped by utils.createHasher");if(Tt(e.outputLen),Tt(e.blockLen),e.outputLen<1)throw Error('"outputLen" must be >= 1');if(e.blockLen<1)throw Error('"blockLen" must be >= 1')}function tc(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 Up(e,t){er(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw RangeError('"digestInto() output" expected to be of length >='+r)}function Mp(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ar(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function rc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Pn(e,t){return e<<32-t|e>>>t}function Xe(e,t){return e<<t|e>>>32-t>>>0}var jV=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function UV(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function MV(e){for(let t=0;t<e.length;t++)e[t]=UV(e[t]);return e}var Ix=jV?(e)=>e:MV,zO=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),FV=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Fp(e){if(er(e),zO)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=FV[e[r]];return t}var ki={_0:48,_9:57,A:65,F:70,a:97,f:102};function NO(e){if(e>=ki._0&&e<=ki._9)return e-ki._0;if(e>=ki.A&&e<=ki.F)return e-(ki.A-10);if(e>=ki.a&&e<=ki.f)return e-(ki.a-10);return}function Au(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);if(zO)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=NO(e.charCodeAt(o)),a=NO(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 ZV(e){if(typeof e!=="string")throw TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ax(e,t=""){if(typeof e==="string")return ZV(e);return er(e,void 0,t)}function $x(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];er(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 Zp(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 Cx(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 Ii(e=32){Tt(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 Tx=(e)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});class Ox{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if(Ei(e),er(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),Ar(i)}update(e){return tc(this),this.iHash.update(e),this}digestInto(e){tc(this),Up(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 Yn=(()=>{let e=(t,r,i)=>new Ox(t,r).update(i).digest();return e.create=(t,r)=>new Ox(t,r),e})();function $u(e,t,r){if(Ei(e),r===void 0)r=new Uint8Array(e.outputLen);return Yn(e,r,t)}var Rx=Uint8Array.of(0),LO=Uint8Array.of();function Px(e,t,r,i=32){Ei(e),Tt(i,"length"),er(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=LO;else er(r,void 0,"info");let s=new Uint8Array(o*n),a=Yn.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)Rx[0]=u+1,c.update(u===0?LO:l).update(r).update(Rx).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Ar(l,Rx),s.slice(0,i)}var lo=(e,t,r,i,n)=>Px(e,$u(e,t,r),i,n);function DO(e,t,r){return e&t^~e&r}function BO(e,t,r){return e&t^e&r^t&r}class Hp{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=rc(this.buffer)}update(e){tc(this),er(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=rc(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){tc(this),Up(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Ar(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=rc(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 Ai=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var tr=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Jp=BigInt(4294967295),qO=BigInt(32);function HV(e,t=!1){if(t)return{h:Number(e&Jp),l:Number(e>>qO&Jp)};return{h:Number(e>>qO&Jp)|0,l:Number(e&Jp)|0}}function jO(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}=HV(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var Nx=(e,t,r)=>e>>>r,zx=(e,t,r)=>e<<32-r|t>>>r,Es=(e,t,r)=>e>>>r|t<<32-r,Is=(e,t,r)=>e<<32-r|t>>>r,Cu=(e,t,r)=>e<<64-r|t>>>r-32,Tu=(e,t,r)=>e>>>r-32|t<<64-r;function Xn(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var UO=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),MO=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,FO=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),ZO=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,HO=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),JO=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var KV=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]),uo=new Uint32Array(64);class KO extends Hp{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)uo[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=uo[u-15],f=uo[u-2],p=Pn(d,7)^Pn(d,18)^d>>>3,y=Pn(f,17)^Pn(f,19)^f>>>10;uo[u]=y+uo[u-7]+p+uo[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 d=Pn(s,6)^Pn(s,11)^Pn(s,25),f=l+d+DO(s,a,c)+KV[u]+uo[u]|0,y=(Pn(r,2)^Pn(r,13)^Pn(r,22))+BO(r,i,n)|0;l=c,c=a,a=s,s=o+f|0,o=n,n=i,i=r,r=f+y|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(){Ar(uo)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Ar(this.buffer)}}class VO extends KO{A=Ai[0]|0;B=Ai[1]|0;C=Ai[2]|0;D=Ai[3]|0;E=Ai[4]|0;F=Ai[5]|0;G=Ai[6]|0;H=Ai[7]|0;constructor(){super(32)}}var WO=(()=>jO(["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))))(),VV=(()=>WO[0])(),WV=(()=>WO[1])(),fo=new Uint32Array(80),po=new Uint32Array(80);class GO extends Hp{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:d,Gh:f,Gl:p,Hh:y,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,d,f,p,y,g]}set(e,t,r,i,n,o,s,a,c,l,u,d,f,p,y,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=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=y|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)fo[A]=e.getUint32(t),po[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let C=fo[A-15]|0,N=po[A-15]|0,q=Es(C,N,1)^Es(C,N,8)^Nx(C,N,7),E=Is(C,N,1)^Is(C,N,8)^zx(C,N,7),Z=fo[A-2]|0,L=po[A-2]|0,H=Es(Z,L,19)^Cu(Z,L,61)^Nx(Z,L,6),ee=Is(Z,L,19)^Tu(Z,L,61)^zx(Z,L,6),M=FO(E,ee,po[A-7],po[A-16]),P=ZO(M,q,H,fo[A-7],fo[A-16]);fo[A]=P|0,po[A]=M|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:y,Gl:g,Hh:b,Hl:S}=this;for(let A=0;A<80;A++){let C=Es(u,d,14)^Es(u,d,18)^Cu(u,d,41),N=Is(u,d,14)^Is(u,d,18)^Tu(u,d,41),q=u&f^~u&y,E=d&p^~d&g,Z=HO(S,N,E,WV[A],po[A]),L=JO(Z,b,C,q,VV[A],fo[A]),H=Z|0,ee=Es(r,i,28)^Cu(r,i,34)^Cu(r,i,39),M=Is(r,i,28)^Tu(r,i,34)^Tu(r,i,39),P=r&n^r&s^n&s,z=i&o^i&a^o&a;b=y|0,S=g|0,y=f|0,g=p|0,f=u|0,p=d|0,{h:u,l:d}=Xn(c|0,l|0,L|0,H|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=UO(H,M,z);r=MO(I,L,ee,P),i=I|0}({h:r,l:i}=Xn(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=Xn(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=Xn(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=Xn(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Xn(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Xn(this.Fh|0,this.Fl|0,f|0,p|0),{h:y,l:g}=Xn(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:S}=Xn(this.Hh|0,this.Hl|0,b|0,S|0),this.set(r,i,n,o,s,a,c,l,u,d,f,p,y,g,b,S)}roundClean(){Ar(fo,po)}destroy(){this.destroyed=!0,Ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class QO extends GO{Ah=tr[0]|0;Al=tr[1]|0;Bh=tr[2]|0;Bl=tr[3]|0;Ch=tr[4]|0;Cl=tr[5]|0;Dh=tr[6]|0;Dl=tr[7]|0;Eh=tr[8]|0;El=tr[9]|0;Fh=tr[10]|0;Fl=tr[11]|0;Gh=tr[12]|0;Gl=tr[13]|0;Hh=tr[14]|0;Hl=tr[15]|0;constructor(){super(64)}}var Ot=Cx(()=>new VO,Tx(1));var Kp=Cx(()=>new QO,Tx(3));/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Yp(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Bx(e){if(!Yp(e))throw TypeError("Uint8Array expected")}function rR(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 nR(e){if(typeof e!=="function")throw TypeError("function expected");return!0}function mo(e,t){if(typeof t!=="string")throw TypeError(`${e}: string expected`);return!0}function Ru(e){if(typeof e!=="number")throw TypeError(`number expected, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`invalid integer: ${e}`)}function Wp(e){if(!Array.isArray(e))throw TypeError("array expected")}function Gp(e,t){if(!rR(!0,t))throw TypeError(`${e}: array of strings expected`)}function qx(e,t){if(!rR(!1,t))throw TypeError(`${e}: array of numbers expected`)}function Yr(...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 Xr(e){let t=typeof e==="string"?e.split(""):e,r=t.length;Gp("alphabet",t);let i=new Map(t.map((n,o)=>[n,o]));return{encode:(n)=>(Wp(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)=>(Wp(n),n.map((o)=>{mo("alphabet.decode",o);let s=i.get(o);if(s===void 0)throw Error(`Unknown letter: "${o}". Allowed: ${e}`);return s}))}}function en(e=""){return mo("join",e),{encode:(t)=>(Gp("join.decode",t),t.join(e)),decode:(t)=>(mo("join.decode",t),t.split(e))}}function Xp(e,t="="){return Ru(e),mo("padding",t),{encode(r){Gp("padding.encode",r);while(r.length*e%8)r.push(t);return r},decode(r){Gp("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 iR(e){return nR(e),{encode:(t)=>t,decode:(t)=>e(t)}}function YO(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(Wp(e),!e.length)return[];let i=0,n=[],o=Array.from(e,(a)=>{if(Ru(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],d=t*a,f=d+u;if(!Number.isSafeInteger(f)||d/t!==a||f-u!==d)throw Error("convertRadix: carry overflow");let p=f/r;a=f%r;let y=Math.floor(p);if(o[l]=y,!Number.isSafeInteger(y)||y*r+a!==f)throw Error("convertRadix: carry overflow");if(!c)continue;else if(!y)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 oR=(e,t)=>t===0?e:oR(t,e%t),Qp=(e,t)=>e+(t-oR(e,t)),Vp=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Lx(e,t,r,i){if(Wp(e),t<=0||t>32)throw RangeError(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw RangeError(`convertRadix2: wrong to=${r}`);if(Qp(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Qp(t,r)}`);let n=0,o=0,s=Vp[t],a=Vp[r]-1,c=[];for(let l of e){if(Ru(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=Vp[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 GV(e){Ru(e);let t=256;return{encode:(r)=>{if(!Yp(r))throw TypeError("radix.encode input should be Uint8Array");return YO(Array.from(r),t,e)},decode:(r)=>(qx("radix.decode",r),Uint8Array.from(YO(r,e,t)))}}function gn(e,t=!1){if(Ru(e),e<=0||e>32)throw RangeError("radix2: bits should be in (0..32]");if(Qp(8,e)>32||Qp(e,8)>32)throw RangeError("radix2: carry overflow");return{encode:(r)=>{if(!Yp(r))throw TypeError("radix2.encode input should be Uint8Array");return Lx(Array.from(r),8,e,!t)},decode:(r)=>(qx("radix2.decode",r),Uint8Array.from(Lx(r,e,8,t)))}}function XO(e){return nR(e),function(...t){try{return e.apply(null,t)}catch(r){}}}var QSe=Object.freeze(Yr(gn(4),Xr("0123456789ABCDEF"),en(""))),YSe=Object.freeze(Yr(gn(5),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Xp(5),en(""))),XSe=Object.freeze(Yr(gn(5),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),en(""))),e_e=Object.freeze(Yr(gn(5),Xr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Xp(5),en(""))),t_e=Object.freeze(Yr(gn(5),Xr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),en(""))),r_e=Object.freeze(Yr(gn(5),Xr("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),en(""),iR((e)=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),sR=(()=>typeof Uint8Array.from([]).toBase64==="function"&&typeof Uint8Array.fromBase64==="function")(),QV=/[\t\n\f\r ]/,aR=(e,t)=>{mo("base64",e);let r=t?"base64url":"base64";if(e.length>0&&QV.test(e))throw Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},jx=Object.freeze(sR?{encode(e){return Bx(e),e.toBase64()},decode(e){return aR(e,!1)}}:Yr(gn(6),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Xp(6),en(""))),hr=Object.freeze(Yr(gn(6),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),en(""))),n_e=Object.freeze(sR?{encode(e){return Bx(e),e.toBase64({alphabet:"base64url"})},decode(e){return aR(e,!0)}}:Yr(gn(6),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Xp(6),en(""))),i_e=Object.freeze(Yr(gn(6),Xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),en(""))),Ux=(e)=>Yr(GV(58),Xr(e),en("")),o_e=Object.freeze(Ux("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),s_e=Object.freeze(Ux("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ")),a_e=Object.freeze(Ux("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"));var Dx=Yr(Xr("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),en("")),eR=[996825010,642813549,513874426,1027748829,705979059];function Ou(e){let t=e>>25,r=(e&33554431)<<5;for(let i=0;i<eR.length;i++)if((t>>i&1)===1)r^=eR[i];return r}function tR(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=Ou(n)^s>>5}n=Ou(n);for(let o=0;o<i;o++)n=Ou(n)^e.charCodeAt(o)&31;for(let o of t)n=Ou(n)^o;for(let o=0;o<6;o++)n=Ou(n);return n^=r,Dx.encode(Lx([n%Vp[30]],30,5,!1))}function cR(e){let t=e==="bech32"?1:734539939,r=gn(5),i=r.decode,n=r.encode,o=XO(i);function s(d,f,p=90){if(mo("bech32.encode prefix",d),Yp(f))f=Array.from(f);qx("bech32.encode",f);let y=d.length;if(y===0)throw TypeError(`Invalid prefix length ${y}`);let g=y+7+f.length;if(p!==!1&&g>p)throw TypeError(`Length ${g} exceeds limit ${p}`);let b=d.toLowerCase(),S=tR(b,f,t);return`${b}1${Dx.encode(f)}${S}`}function a(d,f=90){mo("bech32.decode input",d);let p=d.length;if(p<8||f!==!1&&p>f)throw TypeError(`invalid string length: ${p} (${d}). Expected (8..${f})`);let y=d.toLowerCase();if(d!==y&&d!==d.toUpperCase())throw Error("String must be lowercase or uppercase");let g=y.lastIndexOf("1");if(g===0||g===-1)throw Error('Letter "1" must be present between prefix and data only');let b=y.slice(0,g),S=y.slice(g+1);if(S.length<6)throw Error("Data must be at least 6 characters long");let A=Dx.decode(S).slice(0,-6),C=tR(b,A,t);if(!S.endsWith(C))throw Error(`Invalid checksum in ${d}: expected "${C}"`);return{prefix:b,words:A}}let c=XO(a);function l(d){let{prefix:f,words:p}=a(d,!1);return{prefix:f,words:p,bytes:i(p)}}function u(d,f){return s(d,n(f))}return{encode:s,decode:a,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:i,fromWordsUnsafe:o,toWords:n}}var tn=Object.freeze(cR("bech32")),c_e=Object.freeze(cR("bech32m"));var YV=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),XV={encode(e){return Bx(e),e.toHex()},decode(e){return mo("hex",e),Uint8Array.fromHex(e)}},l_e=Object.freeze(YV?XV:Yr(gn(4),Xr("0123456789abcdef"),en(""),iR((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 t7(e,t,r,i){Ei(e);let n=Zp({dkLen:32,asyncTick:10},i),{c:o,dkLen:s,asyncTick:a}=n;if(Tt(o,"c"),Tt(s,"dkLen"),Tt(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=Ax(t,"password"),l=Ax(r,"salt"),u=new Uint8Array(s),d=Yn.create(e,c),f=d._cloneInto().update(l);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:d,PRFSalt:f}}function r7(e,t,r,i,n){if(e.destroy(),t.destroy(),i)i.destroy();return Ar(n),r}function Mx(e,t,r,i){let{c:n,dkLen:o,DK:s,PRF:a,PRFSalt:c}=t7(e,t,r,i),l,u=new Uint8Array(4),d=rc(u),f=new Uint8Array(a.outputLen);for(let p=1,y=0;y<o;p++,y+=a.outputLen){let g=s.subarray(y,y+a.outputLen);d.setInt32(0,p,!1),(l=c._cloneInto(l)).update(u).digestInto(f),g.set(f.subarray(0,g.length));for(let b=1;b<n;b++){a._cloneInto(l).update(f).digestInto(f);for(let S=0;S<g.length;S++)g[S]^=f[S]}}return r7(a,c,s,l,f)}function lR(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++],d=e[t++]^r[i++],f=e[t++]^r[i++],p=e[t++]^r[i++],y=e[t++]^r[i++],g=e[t++]^r[i++],b=e[t++]^r[i++],S=e[t++]^r[i++],A=e[t++]^r[i++],C=e[t++]^r[i++],N=e[t++]^r[i++],q=e[t++]^r[i++],E=s,Z=a,L=c,H=l,ee=u,M=d,P=f,z=p,I=y,R=g,O=b,F=S,D=A,V=C,_=N,re=q;for(let ue=0;ue<8;ue+=2)ee^=Xe(E+D|0,7),I^=Xe(ee+E|0,9),D^=Xe(I+ee|0,13),E^=Xe(D+I|0,18),R^=Xe(M+Z|0,7),V^=Xe(R+M|0,9),Z^=Xe(V+R|0,13),M^=Xe(Z+V|0,18),_^=Xe(O+P|0,7),L^=Xe(_+O|0,9),P^=Xe(L+_|0,13),O^=Xe(P+L|0,18),H^=Xe(re+F|0,7),z^=Xe(H+re|0,9),F^=Xe(z+H|0,13),re^=Xe(F+z|0,18),Z^=Xe(E+H|0,7),L^=Xe(Z+E|0,9),H^=Xe(L+Z|0,13),E^=Xe(H+L|0,18),P^=Xe(M+ee|0,7),z^=Xe(P+M|0,9),ee^=Xe(z+P|0,13),M^=Xe(ee+z|0,18),F^=Xe(O+R|0,7),I^=Xe(F+O|0,9),R^=Xe(I+F|0,13),O^=Xe(R+I|0,18),D^=Xe(re+_|0,7),V^=Xe(D+re|0,9),_^=Xe(V+D|0,13),re^=Xe(_+V|0,18);n[o++]=s+E|0,n[o++]=a+Z|0,n[o++]=c+L|0,n[o++]=l+H|0,n[o++]=u+ee|0,n[o++]=d+M|0,n[o++]=f+P|0,n[o++]=p+z|0,n[o++]=y+I|0,n[o++]=g+R|0,n[o++]=b+O|0,n[o++]=S+F|0,n[o++]=A+D|0,n[o++]=C+V|0,n[o++]=N+_|0,n[o++]=q+re|0}function Fx(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(lR(r,s,e,t,r,o),a>0)s+=16;lR(r,o,e,t+=16,r,s)}}function n7(e,t,r){let i=Zp({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:n,r:o,p:s,dkLen:a,asyncTick:c,maxmem:l,onProgress:u}=i;if(Tt(n,"N"),Tt(o,"r"),Tt(s,"p"),Tt(a,"dkLen"),Tt(c,"asyncTick"),Tt(l,"maxmem"),u!==void 0&&typeof u!=="function")throw Error("progressCb must be a function");let d=128*o,f=d/4,p=Math.pow(2,32);if(n<=1||(n&n-1)!==0||n>p)throw Error('"N" expected a power of 2, and 2^1 <= N <= 2^32');if(s<1||s>(p-1)*32/d)throw Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');if(a<1||a>(p-1)*32)throw Error('"dkLen" expected integer 1..(2^32 - 1) * 32');let y=d*(n+s+1);if(y>l)throw Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))='+y+", maxmem="+l);let g=Mx(Ot,e,t,{c:1,dkLen:d*s}),b=Mp(g),S=Mp(new Uint8Array(d*n)),A=Mp(new Uint8Array(d)),C=()=>{};if(u){let N=2*n*s,q=Math.max(Math.floor(N/1e4),1),E=0;C=()=>{if(E++,u&&(!(E%q)||E===N))u(E/N)}}return{N:n,r:o,p:s,dkLen:a,blockSize32:f,V:S,B32:b,B:g,tmp:A,blockMixCb:C,asyncTick:c}}function i7(e,t,r,i,n){let o=Mx(Ot,e,r,{c:1,dkLen:t});return Ar(r,i,n),o}function Zx(e,t,r){let{N:i,r:n,p:o,dkLen:s,blockSize32:a,V:c,B32:l,B:u,tmp:d,blockMixCb:f}=n7(e,t,r);Ix(l);for(let p=0;p<o;p++){let y=a*p;for(let g=0;g<a;g++)c[g]=l[y+g];for(let g=0,b=0;g<i-1;g++)Fx(c,b,c,b+=a,n),f();Fx(c,(i-1)*a,l,y,n),f();for(let g=0;g<i;g++){let b=(l[y+a-16]&i-1)>>>0;for(let S=0;S<a;S++)d[S]=l[y+S]^c[b*a+S];Fx(d,0,l,y,n),f()}}return Ix(l),i7(e,s,u,c,d)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function o7(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function em(e){if(typeof e!=="boolean")throw TypeError(`boolean expected, not ${e}`)}function nc(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 Mt(e,t,r=""){let i=o7(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 Hx(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 uR(e,t,r=!1){Mt(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&&!ic(e))throw Error("invalid output, must be aligned")}function ei(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Nn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function s7(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var As=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)(),a7=(e)=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;var c7=(e)=>{for(let t=0;t<e.length;t++)e[t]=a7(e[t]);return e},$i=As?(e)=>e:c7;function dR(e,t){if(t==null||typeof t!=="object")throw Error("options must be defined");return Object.assign(e,t)}function fR(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 pR(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 mR=(e,t)=>{function r(i,...n){if(Mt(i,void 0,"key"),e.nonceLength!==void 0){let u=n[0];Mt(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let o=e.tagLength;if(o&&n[1]!==void 0)Mt(n[1],void 0,"AAD");let s=t(i,...n),a=(u,d)=>{if(d!==void 0){if(u!==2)throw Error("cipher output not supported");Mt(d,void 0,"output")}},c=!1;return{encrypt(u,d){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,Mt(u),a(s.encrypt.length,d),s.encrypt(u,d)},decrypt(u,d){if(Mt(u),o&&u.length<o)throw Error('"ciphertext" expected length bigger than tagLength='+o);return a(s.decrypt.length,d),s.decrypt(u,d)}}}return Object.assign(r,e),r};function Pu(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(Mt(t,void 0,"output"),t.length!==e)throw Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(r&&!ic(t))throw Error("invalid output, must be aligned");return t}function hR(e,t,r){nc(e),nc(t),em(r);let i=new Uint8Array(16),n=s7(i);return n.setBigUint64(0,BigInt(t),r),n.setBigUint64(8,BigInt(e),r),i}function ic(e){return e.byteOffset%4===0}function oc(e){return Uint8Array.from(Mt(e))}var yR=(e)=>Uint8Array.from(e.split(""),(t)=>t.charCodeAt(0)),l7=(()=>$i(ei(yR("expand 16-byte k"))))(),u7=(()=>$i(ei(yR("expand 32-byte k"))))();function et(e,t){return e<<t|e>>>32-t}var Nu=64,d7=16,Jx=(()=>4294967295)(),gR=Uint32Array.of();function f7(e,t,r,i,n,o,s,a){let c=n.length,l=new Uint8Array(Nu),u=ei(l),d=As&&ic(n)&&ic(o),f=d?ei(n):gR,p=d?ei(o):gR;if(!As){for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),$i(u),s>=Jx)throw Error("arx: counter overflow");let g=Math.min(Nu,c-y);for(let b=0,S;b<g;b++)S=y+b,o[S]=n[S]^l[b];y+=g}return}for(let y=0;y<c;s++){if(e(t,r,i,u,s,a),s>=Jx)throw Error("arx: counter overflow");let g=Math.min(Nu,c-y);if(d&&g===Nu){let b=y/4;if(y%4!==0)throw Error("arx: invalid block position");for(let S=0,A;S<d7;S++)A=b+S,p[A]=f[A]^u[S];y+=Nu;continue}for(let b=0,S;b<g;b++)S=y+b,o[S]=n[S]^l[b];y+=g}}function bR(e,t){let{allowShortKeys:r,extendNonceFn:i,counterLength:n,counterRight:o,rounds:s}=dR({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=="function")throw Error("core must be a function");return nc(n),nc(s),em(o),em(r),(a,c,l,u,d=0)=>{Mt(a,void 0,"key"),Mt(c,void 0,"nonce"),Mt(l,void 0,"data");let f=l.length;if(u=Pu(f,u,!1),nc(d),d<0||d>=Jx)throw Error("arx: counter overflow");let p=[],y=a.length,g,b;if(y===32)p.push(g=oc(a)),b=u7;else if(y===16&&r)g=new Uint8Array(32),g.set(a),g.set(a,16),b=l7,p.push(g);else throw Mt(a,32,"arx key"),Error("invalid key size");if(!As||!ic(c))p.push(c=oc(c));let S=ei(g);if(i){if(c.length!==24)throw Error("arx: extended nonce must be 24 bytes");let N=c.subarray(0,16);if(As)i(b,S,ei(N),S);else{let q=$i(Uint32Array.from(b));i(q,S,ei(N),S),Nn(q),$i(S)}c=c.subarray(16)}else if(!As)$i(S);let A=16-n;if(A!==c.length)throw Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){let N=new Uint8Array(12);N.set(c,o?0:12-c.length),c=N,p.push(c)}let C=$i(ei(c));try{return f7(e,b,S,C,l,u,d,s),u}finally{Nn(...p)}}}function rr(e,t){return e[t++]&255|(e[t++]&255)<<8}class xR{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=oc(Mt(e,32,"key"));let t=rr(e,0),r=rr(e,2),i=rr(e,4),n=rr(e,6),o=rr(e,8),s=rr(e,10),a=rr(e,12),c=rr(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]=rr(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],d=o[5],f=o[6],p=o[7],y=o[8],g=o[9],b=rr(e,t+0),S=rr(e,t+2),A=rr(e,t+4),C=rr(e,t+6),N=rr(e,t+8),q=rr(e,t+10),E=rr(e,t+12),Z=rr(e,t+14),L=n[0]+(b&8191),H=n[1]+((b>>>13|S<<3)&8191),ee=n[2]+((S>>>10|A<<6)&8191),M=n[3]+((A>>>7|C<<9)&8191),P=n[4]+((C>>>4|N<<12)&8191),z=n[5]+(N>>>1&8191),I=n[6]+((N>>>14|q<<2)&8191),R=n[7]+((q>>>11|E<<5)&8191),O=n[8]+((E>>>8|Z<<8)&8191),F=n[9]+(Z>>>5|i),D=0,V=D+L*s+H*(5*g)+ee*(5*y)+M*(5*p)+P*(5*f);D=V>>>13,V&=8191,V+=z*(5*d)+I*(5*u)+R*(5*l)+O*(5*c)+F*(5*a),D+=V>>>13,V&=8191;let _=D+L*a+H*s+ee*(5*g)+M*(5*y)+P*(5*p);D=_>>>13,_&=8191,_+=z*(5*f)+I*(5*d)+R*(5*u)+O*(5*l)+F*(5*c),D+=_>>>13,_&=8191;let re=D+L*c+H*a+ee*s+M*(5*g)+P*(5*y);D=re>>>13,re&=8191,re+=z*(5*p)+I*(5*f)+R*(5*d)+O*(5*u)+F*(5*l),D+=re>>>13,re&=8191;let ue=D+L*l+H*c+ee*a+M*s+P*(5*g);D=ue>>>13,ue&=8191,ue+=z*(5*y)+I*(5*p)+R*(5*f)+O*(5*d)+F*(5*u),D+=ue>>>13,ue&=8191;let T=D+L*u+H*l+ee*c+M*a+P*s;D=T>>>13,T&=8191,T+=z*(5*g)+I*(5*y)+R*(5*p)+O*(5*f)+F*(5*d),D+=T>>>13,T&=8191;let we=D+L*d+H*u+ee*l+M*c+P*a;D=we>>>13,we&=8191,we+=z*s+I*(5*g)+R*(5*y)+O*(5*p)+F*(5*f),D+=we>>>13,we&=8191;let Ee=D+L*f+H*d+ee*u+M*l+P*c;D=Ee>>>13,Ee&=8191,Ee+=z*a+I*s+R*(5*g)+O*(5*y)+F*(5*p),D+=Ee>>>13,Ee&=8191;let Te=D+L*p+H*f+ee*d+M*u+P*l;D=Te>>>13,Te&=8191,Te+=z*c+I*a+R*s+O*(5*g)+F*(5*y),D+=Te>>>13,Te&=8191;let Ce=D+L*y+H*p+ee*f+M*d+P*u;D=Ce>>>13,Ce&=8191,Ce+=z*l+I*c+R*a+O*s+F*(5*g),D+=Ce>>>13,Ce&=8191;let _e=D+L*g+H*y+ee*p+M*f+P*d;D=_e>>>13,_e&=8191,_e+=z*u+I*l+R*c+O*a+F*s,D+=_e>>>13,_e&=8191,D=(D<<2)+D|0,D=D+V|0,V=D&8191,D=D>>>13,_+=D,n[0]=V,n[1]=_,n[2]=re,n[3]=ue,n[4]=T,n[5]=we,n[6]=Ee,n[7]=Te,n[8]=Ce,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;Nn(r)}update(e){Hx(this),Mt(e),e=oc(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,Nn(this.h,this.r,this.buffer,this.pad)}digestInto(e){Hx(this),uR(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 wR=pR(32,(e)=>new xR(e));function p7(e,t,r,i,n,o=20){let s=e[0],a=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],y=t[4],g=t[5],b=t[6],S=t[7],A=n,C=r[0],N=r[1],q=r[2],E=s,Z=a,L=c,H=l,ee=u,M=d,P=f,z=p,I=y,R=g,O=b,F=S,D=A,V=C,_=N,re=q;for(let T=0;T<o;T+=2)E=E+ee|0,D=et(D^E,16),I=I+D|0,ee=et(ee^I,12),E=E+ee|0,D=et(D^E,8),I=I+D|0,ee=et(ee^I,7),Z=Z+M|0,V=et(V^Z,16),R=R+V|0,M=et(M^R,12),Z=Z+M|0,V=et(V^Z,8),R=R+V|0,M=et(M^R,7),L=L+P|0,_=et(_^L,16),O=O+_|0,P=et(P^O,12),L=L+P|0,_=et(_^L,8),O=O+_|0,P=et(P^O,7),H=H+z|0,re=et(re^H,16),F=F+re|0,z=et(z^F,12),H=H+z|0,re=et(re^H,8),F=F+re|0,z=et(z^F,7),E=E+M|0,re=et(re^E,16),O=O+re|0,M=et(M^O,12),E=E+M|0,re=et(re^E,8),O=O+re|0,M=et(M^O,7),Z=Z+P|0,D=et(D^Z,16),F=F+D|0,P=et(P^F,12),Z=Z+P|0,D=et(D^Z,8),F=F+D|0,P=et(P^F,7),L=L+z|0,V=et(V^L,16),I=I+V|0,z=et(z^I,12),L=L+z|0,V=et(V^L,8),I=I+V|0,z=et(z^I,7),H=H+ee|0,_=et(_^H,16),R=R+_|0,ee=et(ee^R,12),H=H+ee|0,_=et(_^H,8),R=R+_|0,ee=et(ee^R,7);let ue=0;i[ue++]=s+E|0,i[ue++]=a+Z|0,i[ue++]=c+L|0,i[ue++]=l+H|0,i[ue++]=u+ee|0,i[ue++]=d+M|0,i[ue++]=f+P|0,i[ue++]=p+z|0,i[ue++]=y+I|0,i[ue++]=g+R|0,i[ue++]=b+O|0,i[ue++]=S+F|0,i[ue++]=A+D|0,i[ue++]=C+V|0,i[ue++]=N+_|0,i[ue++]=q+re|0}var m7=bR(p7,{counterRight:!1,counterLength:4,allowShortKeys:!1});var h7=new Uint8Array(16),vR=(e,t)=>{e.update(t);let r=t.length%16;if(r)e.update(h7.subarray(r))},g7=new Uint8Array(32);function SR(e,t,r,i,n){if(n!==void 0)Mt(n,void 0,"AAD");let o=e(t,r,g7),s=hR(i.length,n?n.length:0,!0),a=wR.create(o);if(n)vR(a,n);vR(a,i),a.update(s);let c=a.digest();return Nn(o,s),c}var y7=(e)=>(t,r,i)=>({encrypt(o,s){let a=o.length;s=Pu(a+16,s,!1),s.set(o);let c=s.subarray(0,-16);e(t,r,c,c,1);let l=SR(e,t,r,c,i);return s.set(l,a),Nn(l),s},decrypt(o,s){s=Pu(o.length-16,s,!1);let a=o.subarray(0,-16),c=o.subarray(-16),l=SR(e,t,r,a,i);if(!fR(c,l))throw Nn(l),Error("invalid tag");return s.set(o.subarray(0,-16)),e(t,r,s,s,1),Nn(l),s}}),yn=mR({blockSize:64,nonceLength:12,tagLength:16},y7(m7));/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function sc(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Vt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw Error(`${r}expected integer >= 0, got ${e}`)}}function Ne(e,t,r=""){let i=sc(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 bn(e){if(typeof e!=="function"||typeof e.create!=="function")throw Error("Hash must wrapped by utils.createHasher");Vt(e.outputLen),Vt(e.blockLen)}function Ti(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 tm(e,t){Ne(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw Error('"digestInto() output" expected to be of length >='+r)}function rm(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ur(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function nm(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function zn(e,t){return e<<32-t|e>>>t}var b7=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function x7(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function w7(e){for(let t=0;t<e.length;t++)e[t]=x7(e[t]);return e}var Kx=b7?(e)=>e:w7,kR=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),v7=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function $s(e){if(Ne(e),kR)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=v7[e[r]];return t}var Ci={_0:48,_9:57,A:65,F:70,a:97,f:102};function _R(e){if(e>=Ci._0&&e<=Ci._9)return e-Ci._0;if(e>=Ci.A&&e<=Ci.F)return e-(Ci.A-10);if(e>=Ci.a&&e<=Ci.f)return e-(Ci.a-10);return}function Cs(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);if(kR)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=_R(e.charCodeAt(o)),a=_R(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 Lt(...e){let t=0;for(let i=0;i<e.length;i++){let n=e[i];Ne(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 ac(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 ho(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 go=(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 Wx=BigInt(0),Vx=BigInt(1);function zu(e,t=""){if(typeof e!=="boolean"){let r=t&&`"${t}" `;throw Error(r+"expected boolean, got type="+typeof e)}return e}function ER(e){if(typeof e==="bigint"){if(!im(e))throw Error("positive bigint expected, got "+e)}else Vt(e);return e}function Lu(e){let t=ER(e).toString(16);return t.length&1?"0"+t:t}function IR(e){if(typeof e!=="string")throw Error("hex string expected, got "+typeof e);return e===""?Wx:BigInt("0x"+e)}function yo(e){return IR($s(e))}function bo(e){return IR($s(om(Ne(e)).reverse()))}function cc(e,t){Vt(t),e=ER(e);let r=Cs(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw Error("number too large");return r}function Du(e,t){return cc(e,t).reverse()}function om(e){return Uint8Array.from(e)}function xo(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 im=(e)=>typeof e==="bigint"&&Wx<=e;function S7(e,t,r){return im(e)&&im(t)&&im(r)&&t<=e&&e<r}function Bu(e,t,r,i){if(!S7(t,r,i))throw Error("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function Gx(e){let t;for(t=0;e>Wx;e>>=Vx,t+=1);return t}var qu=(e)=>(Vx<<BigInt(e))-Vx;function AR(e,t,r){if(Vt(e,"hashLen"),Vt(t,"qByteLen"),typeof r!=="function")throw Error("hmacFn must be a function");let i=(b)=>new Uint8Array(b),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},f=(...b)=>r(l,Lt(c,...b)),p=(b=n)=>{if(l=f(o,b),c=f(),b.length===0)return;l=f(s,b),c=f()},y=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let b=0,S=[];while(b<t){c=f();let A=c.slice();S.push(A),b+=c.length}return Lt(...S)};return(b,S)=>{d(),p(b);let A=void 0;while(!(A=S(y())))p();return d(),A}}function Ts(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 Qx(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),gr=BigInt(1),Os=BigInt(2),TR=BigInt(3),OR=BigInt(4),RR=BigInt(5),_7=BigInt(7),PR=BigInt(8),k7=BigInt(9),NR=BigInt(16);function $r(e,t){let r=e%t;return r>=Cr?r:t+r}function xn(e,t,r){let i=e;while(t-- >Cr)i*=i,i%=r;return i}function $R(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=$r(e,t),i=t,n=Cr,o=gr,s=gr,a=Cr;while(r!==Cr){let l=i/r,u=i%r,d=n-s*l,f=o-a*l;i=r,r=u,n=s,o=a,s=d,a=f}if(i!==gr)throw Error("invert: does not exist");return $r(n,t)}function Yx(e,t,r){if(!e.eql(e.sqr(t),r))throw Error("Cannot find square root")}function zR(e,t){let r=(e.ORDER+gr)/OR,i=e.pow(t,r);return Yx(e,i,t),i}function E7(e,t){let r=(e.ORDER-RR)/PR,i=e.mul(t,Os),n=e.pow(i,r),o=e.mul(t,n),s=e.mul(e.mul(o,Os),n),a=e.mul(o,e.sub(s,e.ONE));return Yx(e,a,t),a}function I7(e){let t=sm(e),r=LR(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+_7)/NR;return(a,c)=>{let l=a.pow(c,s),u=a.mul(l,i),d=a.mul(l,n),f=a.mul(l,o),p=a.eql(a.sqr(u),c),y=a.eql(a.sqr(d),c);l=a.cmov(l,u,p),u=a.cmov(f,d,y);let g=a.eql(a.sqr(u),c),b=a.cmov(l,u,g);return Yx(a,b,c),b}}function LR(e){if(e<TR)throw Error("sqrt is not defined for small field");let t=e-gr,r=0;while(t%Os===Cr)t/=Os,r++;let i=Os,n=sm(e);while(CR(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return zR;let o=n.pow(i,t),s=(t+gr)/Os;return function(c,l){if(c.is0(l))return l;if(CR(c,l)!==1)throw Error("Cannot find square root");let u=r,d=c.mul(c.ONE,o),f=c.pow(l,t),p=c.pow(l,s);while(!c.eql(f,c.ONE)){if(c.is0(f))return c.ZERO;let y=1,g=c.sqr(f);while(!c.eql(g,c.ONE))if(y++,g=c.sqr(g),y===u)throw Error("Cannot find square root");let b=gr<<BigInt(u-y-1),S=c.pow(d,b);u=y,d=c.sqr(S),f=c.mul(f,d),p=c.mul(p,S)}return p}}function A7(e){if(e%OR===TR)return zR;if(e%PR===RR)return E7;if(e%NR===k7)return I7(e);return LR(e)}var $7=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Xx(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=$7.reduce((i,n)=>(i[n]="function",i),t);return Ts(e,r),e}function C7(e,t,r){if(r<Cr)throw Error("invalid exponent, negatives unsupported");if(r===Cr)return e.ONE;if(r===gr)return t;let i=e.ONE,n=t;while(r>Cr){if(r&gr)i=e.mul(i,n);n=e.sqr(n),r>>=gr}return i}function ju(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 CR(e,t){let r=(e.ORDER-gr)/Os,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 T7(e,t){if(t!==void 0)Vt(t);let r=t!==void 0?t:e.toString(2).length,i=Math.ceil(r/8);return{nBitLength:r,nByteLength:i}}class DR{ORDER;BITS;BYTES;isLE;ZERO=Cr;ONE=gr;_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}=T7(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 $r(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&gr)===gr}neg(e){return $r(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return $r(e*e,this.ORDER)}add(e,t){return $r(e+t,this.ORDER)}sub(e,t){return $r(e-t,this.ORDER)}mul(e,t){return $r(e*t,this.ORDER)}pow(e,t){return C7(this,e,t)}div(e,t){return $r(e*$R(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 $R(e,this.ORDER)}sqrt(e){if(!this._sqrt)this._sqrt=A7(this.ORDER);return this._sqrt(this,e)}toBytes(e){return this.isLE?Du(e,this.BYTES):cc(e,this.BYTES)}fromBytes(e,t=!1){Ne(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?bo(e):yo(e);if(s)a=$r(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ju(this,e)}cmov(e,t,r){return r?t:e}}function sm(e,t={}){return new DR(e,t)}function BR(e){if(typeof e!=="bigint")throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function e0(e){let t=BR(e);return t+Math.ceil(t/2)}function qR(e,t,r=!1){Ne(e);let i=e.length,n=BR(t),o=e0(t);if(i<16||i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?bo(e):yo(e),a=$r(s,t-gr)+gr;return r?Du(a,n):cc(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lc=BigInt(0),Rs=BigInt(1);function Uu(e,t){let r=t.negate();return e?r:t}function i0(e,t){let r=ju(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function FR(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function t0(e,t){FR(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=qu(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function jR(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+=Rs;let l=t*i,u=l+Math.abs(a)-1,d=a===0,f=a<0,p=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}var r0=new WeakMap,ZR=new WeakMap;function n0(e){return ZR.get(e)||1}function UR(e){if(e!==lc)throw Error("invalid wNAF")}class o0{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>lc){if(t&Rs)r=r.add(i);i=i.double(),t>>=Rs}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=t0(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=t0(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:f}=jR(r,s,o);if(r=a,l)n=n.add(Uu(d,t[f]));else i=i.add(Uu(u,t[c]))}return UR(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=t0(e,this.bits);for(let o=0;o<n.windows;o++){if(r===lc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=jR(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return UR(r),i}getPrecomputes(e,t,r){let i=r0.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);r0.set(t,i)}}return i}cached(e,t,r){let i=n0(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=n0(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){FR(t,this.bits),ZR.set(e,t),r0.delete(e)}hasCache(e){return n0(e)!==1}}function HR(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>lc||i>lc){if(r&Rs)o=o.add(n);if(i&Rs)s=s.add(n);n=n.double(),r>>=Rs,i>>=Rs}return{p1:o,p2:s}}function MR(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return Xx(t),t}else return sm(e,{isLE:r})}function JR(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>lc))throw Error(`CURVE.${c} must be positive bigint`)}let n=MR(t.p,r.Fp,i),o=MR(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 am(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 Mu=BigInt(0),uc=BigInt(1),cm=BigInt(2);function O7(e){return Ts(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...e})}function KR(e){let t=O7(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||ho,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),f=a?BigInt(121665):BigInt(39081),p=a?cm**BigInt(254):cm**BigInt(447),y=a?BigInt(8)*cm**BigInt(251)-uc:BigInt(4)*cm**BigInt(445)-uc,g=p+y+uc,b=(I)=>$r(I,r),S=A(d);function A(I){return Du(b(I),u)}function C(I){let R=om(Ne(I,u,"uCoordinate"));if(a)R[31]&=127;return b(bo(R))}function N(I){return bo(n(om(Ne(I,u,"scalar"))))}function q(I,R){let O=ee(C(R),N(I));if(O===Mu)throw Error("invalid private or public key received");return A(O)}function E(I){return q(I,S)}let Z=E,L=q;function H(I,R,O){let F=b(I*(R-O));return R=b(R-F),O=b(O+F),{x_2:R,x_3:O}}function ee(I,R){Bu("u",I,Mu,r),Bu("scalar",R,p,g);let O=R,F=I,D=uc,V=Mu,_=I,re=uc,ue=Mu;for(let we=BigInt(l-1);we>=Mu;we--){let Ee=O>>we&uc;ue^=Ee,{x_2:D,x_3:_}=H(ue,D,_),{x_2:V,x_3:re}=H(ue,V,re),ue=Ee;let Te=D+V,Ce=b(Te*Te),_e=D-V,Pe=b(_e*_e),Ve=Ce-Pe,tt=_+re,bt=_-re,zt=b(bt*Te),pr=b(tt*_e),Gr=zt+pr,Qr=zt-pr;_=b(Gr*Gr),re=b(F*b(Qr*Qr)),D=b(Ce*Pe),V=b(Ve*(Ce+b(f*Ve)))}({x_2:D,x_3:_}=H(ue,D,_)),{x_2:V,x_3:re}=H(ue,V,re);let T=o(V);return b(D*T)}let M={secretKey:u,publicKey:u,seed:u},P=(I=c(u))=>(Ne(I,M.seed,"seed"),I),z={randomSecretKey:P};return Object.freeze({keygen:am(P,Z),getSharedSecret:L,getPublicKey:Z,scalarMult:q,scalarMultBase:E,utils:z,GuBytes:S.slice(),lengths:M})}class s0{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(bn(e),Ne(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),Ur(i)}update(e){return Ti(this),this.iHash.update(e),this}digestInto(e){Ti(this),Ne(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 dc=(e,t,r)=>new s0(e,t).update(r).digest();dc.create=(e,t)=>new s0(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var VR=(e,t)=>(e+(e>=0?t:-t)/GR)/t;function R7(e,t,r){let[[i,n],[o,s]]=t,a=VR(s*e,r),c=VR(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<Oi,f=u<Oi;if(d)l=-l;if(f)u=-u;let p=qu(Math.ceil(Gx(r)/2))+fc;if(l<Oi||l>=p||u<Oi||u>=p)throw Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}function c0(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function a0(e,t){let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(zu(r.lowS,"lowS"),zu(r.prehash,"prehash"),r.format!==void 0)c0(r.format);return r}class WR extends Error{constructor(e=""){super(e)}}var wo={Err:WR,_tlv:{encode:(e,t)=>{let{Err:r}=wo;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=Lu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Lu(n.length/2|128):"";return Lu(e)+o+n+t},decode(e,t){let{Err:r}=wo,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}=wo;if(e<Oi)throw new t("integer: negative integers are not allowed");let r=Lu(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}=wo;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return yo(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=wo,n=Ne(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}=wo,i=t.encode(2,r.encode(e.r)),n=t.encode(2,r.encode(e.s)),o=i+n;return t.encode(48,o)}},Oi=BigInt(0),fc=BigInt(1),GR=BigInt(2),lm=BigInt(3),P7=BigInt(4);function l0(e,t={}){let r=JR("weierstrass",e,t),{Fp:i,Fn:n}=r,o=r.CURVE,{h:s,n:a}=o;Ts(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=YR(i,n);function u(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function d(P,z,I){let{x:R,y:O}=z.toAffine(),F=i.toBytes(R);if(zu(I,"isCompressed"),I){u();let D=!i.isOdd(O);return Lt(QR(D),F)}else return Lt(Uint8Array.of(4),F,i.toBytes(O))}function f(P){Ne(P,void 0,"Point");let{publicKey:z,publicKeyUncompressed:I}=l,R=P.length,O=P[0],F=P.subarray(1);if(R===z&&(O===2||O===3)){let D=i.fromBytes(F);if(!i.isValid(D))throw Error("bad point: is not on curve, wrong x");let V=g(D),_;try{_=i.sqrt(V)}catch(T){let we=T instanceof Error?": "+T.message:"";throw Error("bad point: is not on curve, sqrt error"+we)}u();let re=i.isOdd(_);if((O&1)===1!==re)_=i.neg(_);return{x:D,y:_}}else if(R===I&&O===4){let D=i.BYTES,V=i.fromBytes(F.subarray(0,D)),_=i.fromBytes(F.subarray(D,D*2));if(!b(V,_))throw Error("bad point: is not on curve");return{x:V,y:_}}else throw Error(`bad point: got length ${R}, expected compressed=${z} or uncompressed=${I}`)}let p=t.toBytes||d,y=t.fromBytes||f;function g(P){let z=i.sqr(P),I=i.mul(z,P);return i.add(i.add(I,i.mul(P,o.a)),o.b)}function b(P,z){let I=i.sqr(z),R=g(P);return i.eql(I,R)}if(!b(o.Gx,o.Gy))throw Error("bad curve params: generator point");let S=i.mul(i.pow(o.a,lm),P7),A=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(S,A)))throw Error("bad curve params: a or b");function C(P,z,I=!1){if(!i.isValid(z)||I&&i.is0(z))throw Error(`bad point coordinate ${P}`);return z}function N(P){if(!(P instanceof H))throw Error("Weierstrass Point expected")}function q(P){if(!c||!c.basises)throw Error("no endo");return R7(P,c.basises,n.ORDER)}let E=Qx((P,z)=>{let{X:I,Y:R,Z:O}=P;if(i.eql(O,i.ONE))return{x:I,y:R};let F=P.is0();if(z==null)z=F?i.ONE:i.inv(O);let D=i.mul(I,z),V=i.mul(R,z),_=i.mul(O,z);if(F)return{x:i.ZERO,y:i.ZERO};if(!i.eql(_,i.ONE))throw Error("invZ was invalid");return{x:D,y:V}}),Z=Qx((P)=>{if(P.is0()){if(t.allowInfinityPoint&&!i.is0(P.Y))return;throw Error("bad point: ZERO")}let{x:z,y:I}=P.toAffine();if(!i.isValid(z)||!i.isValid(I))throw Error("bad point: x or y not field elements");if(!b(z,I))throw Error("bad point: equation left != right");if(!P.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function L(P,z,I,R,O){return I=new H(i.mul(I.X,P),I.Y,I.Z),z=Uu(R,z),I=Uu(O,I),z.add(I)}class H{static BASE=new H(o.Gx,o.Gy,i.ONE);static ZERO=new H(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(P,z,I){this.X=C("x",P),this.Y=C("y",z,!0),this.Z=C("z",I),Object.freeze(this)}static CURVE(){return o}static fromAffine(P){let{x:z,y:I}=P||{};if(!P||!i.isValid(z)||!i.isValid(I))throw Error("invalid affine point");if(P instanceof H)throw Error("projective point not allowed");if(i.is0(z)&&i.is0(I))return H.ZERO;return new H(z,I,i.ONE)}static fromBytes(P){let z=H.fromAffine(y(Ne(P,void 0,"point")));return z.assertValidity(),z}static fromHex(P){return H.fromBytes(Cs(P))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(P=8,z=!0){if(M.createCache(this,P),!z)this.multiply(lm);return this}assertValidity(){Z(this)}hasEvenY(){let{y:P}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(P)}equals(P){N(P);let{X:z,Y:I,Z:R}=this,{X:O,Y:F,Z:D}=P,V=i.eql(i.mul(z,D),i.mul(O,R)),_=i.eql(i.mul(I,D),i.mul(F,R));return V&&_}negate(){return new H(this.X,i.neg(this.Y),this.Z)}double(){let{a:P,b:z}=o,I=i.mul(z,lm),{X:R,Y:O,Z:F}=this,D=i.ZERO,V=i.ZERO,_=i.ZERO,re=i.mul(R,R),ue=i.mul(O,O),T=i.mul(F,F),we=i.mul(R,O);return we=i.add(we,we),_=i.mul(R,F),_=i.add(_,_),D=i.mul(P,_),V=i.mul(I,T),V=i.add(D,V),D=i.sub(ue,V),V=i.add(ue,V),V=i.mul(D,V),D=i.mul(we,D),_=i.mul(I,_),T=i.mul(P,T),we=i.sub(re,T),we=i.mul(P,we),we=i.add(we,_),_=i.add(re,re),re=i.add(_,re),re=i.add(re,T),re=i.mul(re,we),V=i.add(V,re),T=i.mul(O,F),T=i.add(T,T),re=i.mul(T,we),D=i.sub(D,re),_=i.mul(T,ue),_=i.add(_,_),_=i.add(_,_),new H(D,V,_)}add(P){N(P);let{X:z,Y:I,Z:R}=this,{X:O,Y:F,Z:D}=P,V=i.ZERO,_=i.ZERO,re=i.ZERO,ue=o.a,T=i.mul(o.b,lm),we=i.mul(z,O),Ee=i.mul(I,F),Te=i.mul(R,D),Ce=i.add(z,I),_e=i.add(O,F);Ce=i.mul(Ce,_e),_e=i.add(we,Ee),Ce=i.sub(Ce,_e),_e=i.add(z,R);let Pe=i.add(O,D);return _e=i.mul(_e,Pe),Pe=i.add(we,Te),_e=i.sub(_e,Pe),Pe=i.add(I,R),V=i.add(F,D),Pe=i.mul(Pe,V),V=i.add(Ee,Te),Pe=i.sub(Pe,V),re=i.mul(ue,_e),V=i.mul(T,Te),re=i.add(V,re),V=i.sub(Ee,re),re=i.add(Ee,re),_=i.mul(V,re),Ee=i.add(we,we),Ee=i.add(Ee,we),Te=i.mul(ue,Te),_e=i.mul(T,_e),Ee=i.add(Ee,Te),Te=i.sub(we,Te),Te=i.mul(ue,Te),_e=i.add(_e,Te),we=i.mul(Ee,_e),_=i.add(_,we),we=i.mul(Pe,_e),V=i.mul(Ce,V),V=i.sub(V,we),we=i.mul(Ce,Ee),re=i.mul(Pe,re),re=i.add(re,we),new H(V,_,re)}subtract(P){return this.add(P.negate())}is0(){return this.equals(H.ZERO)}multiply(P){let{endo:z}=t;if(!n.isValidNot0(P))throw Error("invalid scalar: out of range");let I,R,O=(F)=>M.cached(this,F,(D)=>i0(H,D));if(z){let{k1neg:F,k1:D,k2neg:V,k2:_}=q(P),{p:re,f:ue}=O(D),{p:T,f:we}=O(_);R=ue.add(we),I=L(z.beta,re,T,F,V)}else{let{p:F,f:D}=O(P);I=F,R=D}return i0(H,[I,R])[0]}multiplyUnsafe(P){let{endo:z}=t,I=this;if(!n.isValid(P))throw Error("invalid scalar: out of range");if(P===Oi||I.is0())return H.ZERO;if(P===fc)return I;if(M.hasCache(this))return this.multiply(P);if(z){let{k1neg:R,k1:O,k2neg:F,k2:D}=q(P),{p1:V,p2:_}=HR(H,I,O,D);return L(z.beta,V,_,R,F)}else return M.unsafe(I,P)}toAffine(P){return E(this,P)}isTorsionFree(){let{isTorsionFree:P}=t;if(s===fc)return!0;if(P)return P(H,this);return M.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:P}=t;if(s===fc)return this;if(P)return P(H,this);return this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(P=!0){return zu(P,"isCompressed"),this.assertValidity(),p(H,this,P)}toHex(P=!0){return $s(this.toBytes(P))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ee=n.BITS,M=new o0(H,t.endo?Math.ceil(ee/2):ee);return H.BASE.precompute(8),H}function QR(e){return Uint8Array.of(e?2:3)}function YR(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function N7(e,t={}){let{Fn:r}=e,i=t.randomBytes||ho,n=Object.assign(YR(e.Fp,r),{seed:e0(r.ORDER)});function o(p){try{let y=r.fromBytes(p);return r.isValidNot0(y)}catch(y){return!1}}function s(p,y){let{publicKey:g,publicKeyUncompressed:b}=n;try{let S=p.length;if(y===!0&&S!==g)return!1;if(y===!1&&S!==b)return!1;return!!e.fromBytes(p)}catch(S){return!1}}function a(p=i(n.seed)){return qR(Ne(p,n.seed,"seed"),r.ORDER)}function c(p,y=!0){return e.BASE.multiply(r.fromBytes(p)).toBytes(y)}function l(p){let{secretKey:y,publicKey:g,publicKeyUncompressed:b}=n;if(!sc(p))return;if("_lengths"in r&&r._lengths||y===g)return;let S=Ne(p,void 0,"key").length;return S===g||S===b}function u(p,y,g=!0){if(l(p)===!0)throw Error("first arg must be private key");if(l(y)===!1)throw Error("second arg must be public key");let b=r.fromBytes(p);return e.fromBytes(y).multiply(b).toBytes(g)}let d={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},f=am(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:n})}function u0(e,t,r={}){bn(t),Ts(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let i=r.randomBytes||ho,n=r.hmac||((I,R)=>dc(t,I,R)),{Fp:o,Fn:s}=e,{ORDER:a,BITS:c}=s,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p}=N7(e,r),y={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},g=a*GR<o.ORDER;function b(I){let R=a>>fc;return I>R}function S(I,R){if(!s.isValidNot0(R))throw Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return R}function A(){if(g)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function C(I,R){c0(R);let O=p.signature,F=R==="compact"?O:R==="recovered"?O+1:void 0;return Ne(I,F)}class N{r;s;recovery;constructor(I,R,O){if(this.r=S("r",I),this.s=S("s",R),O!=null){if(A(),![0,1,2,3].includes(O))throw Error("invalid recovery id");this.recovery=O}Object.freeze(this)}static fromBytes(I,R=y.format){C(I,R);let O;if(R==="der"){let{r:_,s:re}=wo.toSig(Ne(I));return new N(_,re)}if(R==="recovered")O=I[0],R="compact",I=I.subarray(1);let F=p.signature/2,D=I.subarray(0,F),V=I.subarray(F,F*2);return new N(s.fromBytes(D),s.fromBytes(V),O)}static fromHex(I,R){return this.fromBytes(Cs(I),R)}assertRecovery(){let{recovery:I}=this;if(I==null)throw Error("invalid recovery id: must be present");return I}addRecoveryBit(I){return new N(this.r,this.s,I)}recoverPublicKey(I){let{r:R,s:O}=this,F=this.assertRecovery(),D=F===2||F===3?R+a:R;if(!o.isValid(D))throw Error("invalid recovery id: sig.r+curve.n != R.x");let V=o.toBytes(D),_=e.fromBytes(Lt(QR((F&1)===0),V)),re=s.inv(D),ue=E(Ne(I,void 0,"msgHash")),T=s.create(-ue*re),we=s.create(O*re),Ee=e.BASE.multiplyUnsafe(T).add(_.multiplyUnsafe(we));if(Ee.is0())throw Error("invalid recovery: point at infinify");return Ee.assertValidity(),Ee}hasHighS(){return b(this.s)}toBytes(I=y.format){if(c0(I),I==="der")return Cs(wo.hexFromSig(this));let{r:R,s:O}=this,F=s.toBytes(R),D=s.toBytes(O);if(I==="recovered")return A(),Lt(Uint8Array.of(this.assertRecovery()),F,D);return Lt(F,D)}toHex(I){return $s(this.toBytes(I))}}let q=r.bits2int||function(R){if(R.length>8192)throw Error("input is too large");let O=yo(R),F=R.length*8-c;return F>0?O>>BigInt(F):O},E=r.bits2int_modN||function(R){return s.create(q(R))},Z=qu(c);function L(I){return Bu("num < 2^"+c,I,Oi,Z),s.toBytes(I)}function H(I,R){return Ne(I,void 0,"message"),R?Ne(t(I),void 0,"prehashed message"):I}function ee(I,R,O){let{lowS:F,prehash:D,extraEntropy:V}=a0(O,y);I=H(I,D);let _=E(I),re=s.fromBytes(R);if(!s.isValidNot0(re))throw Error("invalid private key");let ue=[L(re),L(_)];if(V!=null&&V!==!1){let Te=V===!0?i(p.secretKey):V;ue.push(Ne(Te,void 0,"extraEntropy"))}let T=Lt(...ue),we=_;function Ee(Te){let Ce=q(Te);if(!s.isValidNot0(Ce))return;let _e=s.inv(Ce),Pe=e.BASE.multiply(Ce).toAffine(),Ve=s.create(Pe.x);if(Ve===Oi)return;let tt=s.create(_e*s.create(we+Ve*re));if(tt===Oi)return;let bt=(Pe.x===Ve?0:2)|Number(Pe.y&fc),zt=tt;if(F&&b(tt))zt=s.neg(tt),bt^=1;return new N(Ve,zt,g?void 0:bt)}return{seed:T,k2sig:Ee}}function M(I,R,O={}){let{seed:F,k2sig:D}=ee(I,R,O);return AR(t.outputLen,s.BYTES,n)(F,D).toBytes(O.format)}function P(I,R,O,F={}){let{lowS:D,prehash:V,format:_}=a0(F,y);if(O=Ne(O,void 0,"publicKey"),R=H(R,V),!sc(I)){let re=I instanceof N?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+re)}C(I,_);try{let re=N.fromBytes(I,_),ue=e.fromBytes(O);if(D&&re.hasHighS())return!1;let{r:T,s:we}=re,Ee=E(R),Te=s.inv(we),Ce=s.create(Ee*Te),_e=s.create(T*Te),Pe=e.BASE.multiplyUnsafe(Ce).add(ue.multiplyUnsafe(_e));if(Pe.is0())return!1;return s.create(Pe.x)===T}catch(re){return!1}}function z(I,R,O={}){let{prehash:F}=a0(O,y);return R=H(R,F),N.fromBytes(I,"recovered").recoverPublicKey(R).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:f,lengths:p,Point:e,sign:M,verify:P,recoverPublicKey:z,Signature:N,hash:t})}function XR(e,t,r){return e&t^~e&r}function eP(e,t,r){return e&t^e&r^t&r}class um{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=nm(this.buffer)}update(e){Ti(this),Ne(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=nm(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){Ti(this),tm(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:n}=this,{pos:o}=this;if(t[o++]=128,Ur(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=nm(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 Ri=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var nr=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]);var dm=BigInt(4294967295),tP=BigInt(32);function z7(e,t=!1){if(t)return{h:Number(e&dm),l:Number(e>>tP&dm)};return{h:Number(e>>tP&dm)|0,l:Number(e&dm)|0}}function fm(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}=z7(e[o],t);[i[o],n[o]]=[s,a]}return[i,n]}var d0=(e,t,r)=>e>>>r,f0=(e,t,r)=>e<<32-r|t>>>r,Ps=(e,t,r)=>e>>>r|t<<32-r,Ns=(e,t,r)=>e<<32-r|t>>>r,Fu=(e,t,r)=>e<<64-r|t>>>r-32,Zu=(e,t,r)=>e>>>r-32|t<<64-r;var rP=(e,t,r)=>e<<r|t>>>32-r,nP=(e,t,r)=>t<<r|e>>>32-r,iP=(e,t,r)=>t<<r-32|e>>>64-r,oP=(e,t,r)=>e<<r-32|t>>>64-r;function ti(e,t,r,i){let n=(t>>>0)+(i>>>0);return{h:e+r+(n/4294967296|0)|0,l:n|0}}var sP=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),aP=(e,t,r,i)=>t+r+i+(e/4294967296|0)|0,cP=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),lP=(e,t,r,i,n)=>t+r+i+n+(e/4294967296|0)|0,uP=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),dP=(e,t,r,i,n,o)=>t+r+i+n+o+(e/4294967296|0)|0;var D7=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]),vo=new Uint32Array(64);class fP extends um{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)vo[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let d=vo[u-15],f=vo[u-2],p=zn(d,7)^zn(d,18)^d>>>3,y=zn(f,17)^zn(f,19)^f>>>10;vo[u]=y+vo[u-7]+p+vo[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 d=zn(s,6)^zn(s,11)^zn(s,25),f=l+d+XR(s,a,c)+D7[u]+vo[u]|0,y=(zn(r,2)^zn(r,13)^zn(r,22))+eP(r,i,n)|0;l=c,c=a,a=s,s=o+f|0,o=n,n=i,i=r,r=f+y|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(){Ur(vo)}destroy(){this.set(0,0,0,0,0,0,0,0),Ur(this.buffer)}}class pP extends fP{A=Ri[0]|0;B=Ri[1]|0;C=Ri[2]|0;D=Ri[3]|0;E=Ri[4]|0;F=Ri[5]|0;G=Ri[6]|0;H=Ri[7]|0;constructor(){super(32)}}var mP=(()=>fm(["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))))(),B7=(()=>mP[0])(),q7=(()=>mP[1])(),So=new Uint32Array(80),_o=new Uint32Array(80);class hP extends um{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:d,Gh:f,Gl:p,Hh:y,Hl:g}=this;return[e,t,r,i,n,o,s,a,c,l,u,d,f,p,y,g]}set(e,t,r,i,n,o,s,a,c,l,u,d,f,p,y,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=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=y|0,this.Hl=g|0}process(e,t){for(let A=0;A<16;A++,t+=4)So[A]=e.getUint32(t),_o[A]=e.getUint32(t+=4);for(let A=16;A<80;A++){let C=So[A-15]|0,N=_o[A-15]|0,q=Ps(C,N,1)^Ps(C,N,8)^d0(C,N,7),E=Ns(C,N,1)^Ns(C,N,8)^f0(C,N,7),Z=So[A-2]|0,L=_o[A-2]|0,H=Ps(Z,L,19)^Fu(Z,L,61)^d0(Z,L,6),ee=Ns(Z,L,19)^Zu(Z,L,61)^f0(Z,L,6),M=cP(E,ee,_o[A-7],_o[A-16]),P=lP(M,q,H,So[A-7],So[A-16]);So[A]=P|0,_o[A]=M|0}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:y,Gl:g,Hh:b,Hl:S}=this;for(let A=0;A<80;A++){let C=Ps(u,d,14)^Ps(u,d,18)^Fu(u,d,41),N=Ns(u,d,14)^Ns(u,d,18)^Zu(u,d,41),q=u&f^~u&y,E=d&p^~d&g,Z=uP(S,N,E,q7[A],_o[A]),L=dP(Z,b,C,q,B7[A],So[A]),H=Z|0,ee=Ps(r,i,28)^Fu(r,i,34)^Fu(r,i,39),M=Ns(r,i,28)^Zu(r,i,34)^Zu(r,i,39),P=r&n^r&s^n&s,z=i&o^i&a^o&a;b=y|0,S=g|0,y=f|0,g=p|0,f=u|0,p=d|0,{h:u,l:d}=ti(c|0,l|0,L|0,H|0),c=s|0,l=a|0,s=n|0,a=o|0,n=r|0,o=i|0;let I=sP(H,M,z);r=aP(I,L,ee,P),i=I|0}({h:r,l:i}=ti(this.Ah|0,this.Al|0,r|0,i|0)),{h:n,l:o}=ti(this.Bh|0,this.Bl|0,n|0,o|0),{h:s,l:a}=ti(this.Ch|0,this.Cl|0,s|0,a|0),{h:c,l}=ti(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=ti(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=ti(this.Fh|0,this.Fl|0,f|0,p|0),{h:y,l:g}=ti(this.Gh|0,this.Gl|0,y|0,g|0),{h:b,l:S}=ti(this.Hh|0,this.Hl|0,b|0,S|0),this.set(r,i,n,o,s,a,c,l,u,d,f,p,y,g,b,S)}roundClean(){Ur(So,_o)}destroy(){Ur(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class gP extends hP{Ah=nr[0]|0;Al=nr[1]|0;Bh=nr[2]|0;Bl=nr[3]|0;Ch=nr[4]|0;Cl=nr[5]|0;Dh=nr[6]|0;Dl=nr[7]|0;Eh=nr[8]|0;El=nr[9]|0;Fh=nr[10]|0;Fl=nr[11]|0;Gh=nr[12]|0;Gl=nr[13]|0;Hh=nr[14]|0;Hl=nr[15]|0;constructor(){super(48)}}var pm=ac(()=>new pP,go(1));var yP=ac(()=>new gP,go(2));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var j7=BigInt(1),bP=BigInt(2),U7=BigInt(3),M7=BigInt(5),fke=BigInt(8),xP=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function F7(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=xP,a=e*e%o*e%o,c=xn(a,bP,o)*a%o,l=xn(c,j7,o)*e%o,u=xn(l,M7,o)*l%o,d=xn(u,t,o)*u%o,f=xn(d,r,o)*d%o,p=xn(f,i,o)*f%o,y=xn(p,n,o)*p%o,g=xn(y,n,o)*p%o,b=xn(g,t,o)*u%o;return{pow_p_5_8:xn(b,bP,o)*e%o,b2:a}}function Z7(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var wP=(()=>{let e=xP;return KR({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=F7(t);return $r(xn(r,U7,e)*i,e)},adjustScalarBytes:Z7})})();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var H7=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))(),J7=(()=>({p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")}))();var K7=l0(H7),p0=u0(K7,pm);var V7=l0(J7),vP=u0(V7,yP);function _P(e,t,r){if(bn(e),r===void 0)r=new Uint8Array(e.outputLen);return dc(e,r,t)}var m0=Uint8Array.of(0),SP=Uint8Array.of();function kP(e,t,r,i=32){bn(e),Vt(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=SP;else Ne(r,void 0,"info");let s=new Uint8Array(o*n),a=dc.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<o;u++)m0[0]=u+1,c.update(u===0?SP:l).update(r).update(m0).digestInto(l),s.set(l,n*u),a._cloneInto(c);return a.destroy(),c.destroy(),Ur(l,m0),s.slice(0,i)}var W7=BigInt(0),Hu=BigInt(1),G7=BigInt(2),Q7=BigInt(7),Y7=BigInt(256),X7=BigInt(113),AP=[],$P=[],CP=[];for(let e=0,t=Hu,r=1,i=0;e<24;e++){[r,i]=[i,(2*r+3*i)%5],AP.push(2*(5*i+r)),$P.push((e+1)*(e+2)/2%64);let n=W7;for(let o=0;o<7;o++)if(t=(t<<Hu^(t>>Q7)*X7)%Y7,t&G7)n^=Hu<<(Hu<<BigInt(o))-Hu;CP.push(n)}var TP=fm(CP,!0),eW=TP[0],tW=TP[1],EP=(e,t,r)=>r>32?iP(e,t,r):rP(e,t,r),IP=(e,t,r)=>r>32?oP(e,t,r):nP(e,t,r);function rW(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],d=EP(l,u,1)^r[a],f=IP(l,u,1)^r[a+1];for(let p=0;p<50;p+=10)e[s+p]^=d,e[s+p+1]^=f}let n=e[2],o=e[3];for(let s=0;s<24;s++){let a=$P[s],c=EP(n,o,a),l=IP(n,o,a),u=AP[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]^=eW[i],e[1]^=tW[i]}Ur(r)}class mm{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,Vt(r,"outputLen"),!(0<e&&e<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=rm(this.state)}clone(){return this._cloneInto()}keccak(){Kx(this.state32),rW(this.state32,this.rounds),Kx(this.state32),this.posOut=0,this.pos=0}update(e){Ti(this),Ne(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){Ti(this,!1),Ne(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 Vt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(tm(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,Ur(this.state)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:i,rounds:n,enableXOF:o}=this;return e||=new mm(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 OP=(e,t,r,i={})=>ac(()=>new mm(t,e,r),i);var zs=OP(6,136,32,go(8));var RP=OP(6,72,64,go(10));var PP=(e,t,r,i={})=>ac((n={})=>new mm(t,e,n.dkLen===void 0?r:n.dkLen,!0),i),NP=PP(31,168,16,go(11)),ri=PP(31,136,32,go(12));function h0(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw Error("wrong u32 integer:"+e);return e}function LP(e){return h0(e),(e&e-1)===0&&e!==0}function g0(e,t){h0(e);let r=0;for(let i=0;i<t;i++,e>>>=1)r=r<<1|e&1;return r}function DP(e){return h0(e),31-Math.clz32(e)}function zP(e){let t=e.length;if(t<2||!LP(t))throw Error("n must be a power of 2 and greater than 1. Got "+t);let r=DP(t);for(let i=0;i<t;i++){let n=g0(i,r);if(i<n){let o=e[i];e[i]=e[n],e[n]=o}}return e}var y0=(e,t)=>{let{N:r,roots:i,dit:n,invertButterflies:o=!1,skipStages:s=0,brp:a=!0}=t,c=DP(r);if(!LP(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)zP(u);for(let d=0,f=1;d<c-s;d++){let p=n?d+1+s:c-d,y=1<<p,g=y>>1,b=r>>p;for(let S=0;S<r;S+=y)for(let A=0,C=f++;A<g;A++){let N=o?n?r-C:C:A*b,q=S+A,E=S+A+g,Z=i[N],L=u[E],H=u[q];if(l){let ee=e.mul(L,Z);u[q]=e.add(H,ee),u[E]=e.sub(H,ee)}else if(o)u[q]=e.add(L,H),u[E]=e.mul(e.sub(L,H),Z);else u[q]=e.add(H,L),u[E]=e.mul(e.sub(H,L),Z)}}if(!n&&a)zP(u);return u}};/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var ni=ho;function hm(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 BP(e){return Uint8Array.from(e)}function Ls(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(Ne(u,l,e),o.set(u,a),typeof c!=="number")u.fill(0);a+=l}return o},decode:(n)=>{Ne(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 gm(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)=>{Ne(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 Ft(...e){for(let t of e)if(Array.isArray(t))for(let r of t)r.fill(0);else t.fill(0)}function b0(e){return(1<<e)-1}var Ake=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,C=i)=>{let N=A%C|0;return(N>=0?N|0:C+N|0)|0},l=(A,C=i)=>{let N=c(A,C)|0;return(N>C>>1?N-C|0:N)|0};function u(){let A=t(r);for(let C=0;C<r;C++){let N=g0(C,s),q=BigInt(o)**BigInt(N)%BigInt(i);A[C]=Number(q)|0}return A}let d=u(),f={add:(A,C)=>c((A|0)+(C|0))|0,sub:(A,C)=>c((A|0)-(C|0))|0,mul:(A,C)=>c((A|0)*(C|0))|0,inv:(A)=>{throw Error("not implemented")}},p={N:r,roots:d,invertButterflies:!0,skipStages:a?1:0,brp:!1},y=y0(f,{dit:!1,...p}),g=y0(f,{dit:!0,...p});return{mod:c,smod:l,nttZetas:d,NTT:{encode:(A)=>y(A),decode:(A)=>{g(A);for(let C=0;C<A.length;C++)A[C]=c(n*A[C]);return A}},bitsCoder:(A,C)=>{let N=b0(A),q=A*(r/8);return{bytesLen:q,encode:(E)=>{let Z=new Uint8Array(q);for(let L=0,H=0,ee=0,M=0;L<E.length;L++){H|=(C.encode(E[L])&N)<<ee,ee+=A;for(;ee>=8;ee-=8,H>>=8)Z[M++]=H&b0(ee)}return Z},decode:(E)=>{let Z=t(r);for(let L=0,H=0,ee=0,M=0;L<E.length;L++){H|=E[L]<<ee,ee+=8;for(;ee>=A;ee-=A,H>>=A)Z[M++]=C.decode(H&N)}return Z}}}}},nW=(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(),Ft(o,i)}}},jP=nW(NP);/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */var yr=256,Pi=3329,iW=3303,oW=17,{mod:Vu,nttZetas:sW,NTT:Ds,bitsCoder:aW}=qP({N:yr,Q:Pi,F:iW,ROOT_OF_UNITY:oW,newPoly:(e)=>new Uint16Array(e),brvBits:7,isKyber:!0}),x0={512:{N:yr,Q:Pi,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:yr,Q:Pi,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:yr,Q:Pi,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},cW=(e)=>{if(e>=12)return{encode:(r)=>r,decode:(r)=>r};let t=2**(e-1);return{encode:(r)=>((r<<e)+Pi/2)/Pi,decode:(r)=>r*Pi+t>>>e}},Ju=(e)=>aW(e,cW(e));function Bs(e,t){for(let r=0;r<yr;r++)e[r]=Vu(e[r]+t[r])}function lW(e,t){for(let r=0;r<yr;r++)e[r]=Vu(e[r]-t[r])}function uW(e,t,r,i,n){let o=Vu(t*i*n+e*r),s=Vu(e*i+t*r);return{c0:o,c1:s}}function ym(e,t){for(let r=0;r<yr/2;r++){let i=sW[64+(r>>1)];if(r&1)i=-i;let{c0:n,c1:o}=uW(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 UP(e){let t=new Uint16Array(yr);for(let r=0;r<yr;){let i=e();if(i.length%3)throw Error("SampleNTT: unaligned block");for(let n=0;r<yr&&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<Pi)t[r++]=o;if(r<yr&&s<Pi)t[r++]=s}}return t}function Ku(e,t,r,i){let n=e(i*yr/4,t,r),o=new Uint16Array(yr),s=rm(n),a=0;for(let c=0,l=0,u=0,d=0;c<s.length;c++){let f=s[c];for(let p=0;p<32;p++)if(u+=f&1,f>>=1,a+=1,a===i)d=u,u=0;else if(a===2*i)o[l++]=Vu(d-u),u=0,a=0}if(a)throw Error(`sampleCBD: leftover bits: ${a}`);return o}var dW=(e)=>{let{K:t,PRF:r,XOF:i,HASH512:n,ETA1:o,ETA2:s,du:a,dv:c}=e,l=Ju(1),u=Ju(c),d=Ju(a),f=Ls("publicKey",gm(Ju(12),t),32),p=gm(Ju(12),t),y=Ls("ciphertext",gm(d,t),u),g=Ls("seed",32,32);return{secretCoder:p,lengths:{secretKey:p.bytesLen,publicKey:f.bytesLen,cipherText:y.bytesLen},keygen:(b)=>{Ne(b,32,"seed");let S=new Uint8Array(33);S.set(b),S[32]=t;let A=n(S),[C,N]=g.decode(A),q=[],E=[];for(let H=0;H<t;H++)q.push(Ds.encode(Ku(r,N,H,o)));let Z=i(C);for(let H=0;H<t;H++){let ee=Ds.encode(Ku(r,N,t+H,o));for(let M=0;M<t;M++){let P=UP(Z.get(M,H));Bs(ee,ym(P,q[M]))}E.push(ee)}Z.clean();let L={publicKey:f.encode([E,C]),secretKey:p.encode(q)};return Ft(C,N,q,E,S,A),L},encrypt:(b,S,A)=>{let[C,N]=f.decode(b),q=[];for(let M=0;M<t;M++)q.push(Ds.encode(Ku(r,A,M,o)));let E=i(N),Z=new Uint16Array(yr),L=[];for(let M=0;M<t;M++){let P=Ku(r,A,t+M,s),z=new Uint16Array(yr);for(let I=0;I<t;I++){let R=UP(E.get(M,I));Bs(z,ym(R,q[I]))}Bs(P,Ds.decode(z)),L.push(P),Bs(Z,ym(C[M],q[M])),Ft(z)}E.clean();let H=Ku(r,A,2*t,s);Bs(H,Ds.decode(Z));let ee=l.decode(S);return Bs(ee,H),Ft(C,q,Z,H),y.encode([L,ee])},decrypt:(b,S)=>{let[A,C]=y.decode(b),N=p.decode(S),q=new Uint16Array(yr);for(let E=0;E<t;E++)Bs(q,ym(N[E],Ds.encode(A[E])));return lW(C,Ds.decode(q)),Ft(q,N,A),l.encode(C)}}};function w0(e){let t=dW(e),{HASH256:r,HASH512:i,KDF:n}=e,{secretCoder:o,lengths:s}=t,a=Ls("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=ni(64))=>{Ne(u,64,"seed");let{publicKey:d,secretKey:f}=t.keygen(u.subarray(0,32)),p=r(d),y=a.encode([f,d,p,u.subarray(32)]);return Ft(f,p),{publicKey:d,secretKey:y}},getPublicKey:(u)=>{let[d,f,p,y]=a.decode(u);return Uint8Array.from(f)},encapsulate:(u,d=ni(32))=>{Ne(u,s.publicKey,"publicKey"),Ne(d,32,"message");let f=u.subarray(0,384*e.K),p=o.encode(o.decode(BP(f)));if(!hm(p,f))throw Ft(p),Error("ML-KEM.encapsulate: wrong publicKey modulus");Ft(p);let y=i.create().update(d).update(r(u)).digest(),g=t.encrypt(u,d,y.subarray(32,64));return Ft(y.subarray(32)),{cipherText:g,sharedSecret:y.subarray(0,32)}},decapsulate:(u,d)=>{Ne(d,a.bytesLen,"secretKey"),Ne(u,s.cipherText,"cipherText");let f=a.bytesLen-96,p=f+32,y=r(d.subarray(f/2,p));if(!hm(y,d.subarray(p,p+32)))throw Error("invalid secretKey: hash check failed");let[g,b,S,A]=a.decode(d),C=t.decrypt(u,g),N=i.create().update(C).update(S).digest(),q=N.subarray(0,32),E=t.encrypt(b,C,N.subarray(32,64)),Z=hm(u,E),L=n.create({dkLen:32}).update(A).update(u).digest();return Ft(C,E,!Z?q:L),Z?q:L}}}function fW(e,t,r){return ri.create({dkLen:e}).update(t).update(new Uint8Array([r])).digest()}var v0={HASH256:zs,HASH512:RP,KDF:ri,XOF:jP,PRF:fW},Bke=w0({...v0,...x0[512]}),Wu=w0({...v0,...x0[768]}),MP=w0({...v0,...x0[1024]});/*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) */function pW(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=ni(r.seed))=>{Ne(s,r.seed,"seed");let a=o.isLE?bo(s):yo(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 S0(e,t=!1){let r=pW(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=ni(e.lengths.seed)){let o=this.keygen(n).secretKey,s=this.decapsulate(i,o),a=e.getPublicKey(o);return Ft(o),{sharedSecret:s,cipherText:a}},decapsulate(i,n){let o=e.getSharedSecret(n,i);return e.lengths.publicKeyHasPrefix?o.subarray(1):o}}}function Gu(e,t){return Ls(t,...e.map((r)=>{if(typeof r.lengths[t]!=="number")throw Error("wrong length: "+t);return r.lengths[t]}))}function _0(e){return(t,r)=>e(t,{dkLen:r})}function mW(e,t,...r){let i=Gu(r,"seed"),n=Gu(r,"publicKey");if(e===void 0)e=i.bytesLen;Vt(e);function o(s){Ne(s,e);let a=i.decode(t(s,i.bytesLen)),c=r.map((d,f)=>d.keygen(a[f])),l=c.map((d)=>d.secretKey),u=c.map((d)=>d.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=ni(e)){let{publicKey:a,secretKey:c}=o(s),l=n.encode(a);return Ft(a),Ft(c),{secretKey:s,publicKey:l}},expandDecapsulationKey:o,realSeedLen:e}}function bm(e,t,r,i,...n){let o=mW(e,r,...n),s=Gu(n,"cipherText"),a=Gu(n,"publicKey"),c=Gu(n,"msg");if(t===void 0)t=c.bytesLen;return Vt(t),{lengths:{...o.info.lengths,msg:t,msgRand:c.bytesLen,cipherText:s.bytesLen},getPublicKey:o.getPublicKey,keygen:o.keygen,encapsulate(l,u=ni(c.bytesLen)){let d=a.decode(l),f=c.decode(u),p=n.map((S,A)=>S.encapsulate(d[A],f[A])),y=p.map((S)=>S.sharedSecret),g=p.map((S)=>S.cipherText),b={sharedSecret:i(d,g,y),cipherText:s.encode(g)};return Ft(y,g),b},decapsulate(l,u){let d=s.decode(l),{publicKey:f,secretKey:p}=o.expandDecapsulationKey(u),y=n.map((g,b)=>g.decapsulate(d[b],p[b]));return i(f,d,y)}}}function FP(e,t,r,i,n){return bn(i),bn(n),bm(32,32,_0(i),(o,s,a)=>n(Lt(a[0],a[1],s[1],o[1],xo(e))),t,r)}var Wke=FP("QSF-KEM(ML-KEM-768,P-256)-XOF(SHAKE256)-KDF(SHA3-256)",Wu,S0(p0,!0),ri,zs),Gke=FP("QSF-KEM(ML-KEM-1024,P-384)-XOF(SHAKE256)-KDF(SHA3-256)",MP,S0(vP,!0),ri,zs);function hW(e,t,r,i,n){return bn(i),bn(n),bm(32,32,_0(i),(o,s,a)=>{let c=Lt(a[0],a[1],s[0],o[0],s[1],o[1],xo(e)),l=32,u=Lt(xo("hybrid_prk"),c),d=_P(n,u),f=Lt(cc(32,2),xo("shared_secret"),xo("")),p=kP(n,d,f,32);return Ft(d,f,u,c),p},t,r)}var ZP=S0(wP),Qke=hW("KitchenSink-KEM(ML-KEM-768,X25519)-XOF(SHAKE256)-KDF(HKDF-SHA-256)",Wu,ZP,ri,pm),gW=(()=>bm(32,32,_0(ri),(e,t,r)=>zs(Lt(r[0],r[1],t[1],e[1],xo("\\.//^\\"))),Wu,ZP))();function yW(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,d=t;;u=d,d+=t){if(d>s.length)throw Error("rejection sampling failed");if(a=n.fromBytes(s.subarray(u,d),!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=ni(i)){return Ne(s,i,"seed"),o(s)},getPublicKey(s){return e.getPublicKey(s,!1)},encapsulate(s,a=ni(i)){Ne(a,i,"rand");let{secretKey:c}=o(a),l=this.decapsulate(s,c),u=e.getPublicKey(c,!1);return Ft(c),{sharedSecret:l,cipherText:u}},decapsulate(s,a){return e.getSharedSecret(a,s).subarray(1)}}}function bW(e,t,r,i){let{secretKey:n,publicKeyUncompressed:o}=r.lengths;if(!n||!o)throw Error("wrong curve");let s=yW(r,n,o,i),a=64,c=a+i;return bm(32,32,(l)=>{Ne(l,32);let u=ri(l,{dkLen:c}),d=u.subarray(0,a),f=u.subarray(a,c);return Lt(d,f)},(l,u,d)=>zs(Lt(d[0],d[1],u[1],l[1],xo(e))),t,s)}var xW=(()=>bW("MLKEM768-P256",Wu,p0,128))();var xm=gW,HP=xW;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lt=(e,t,r)=>er(e,t,r),E0=Tt,pc=Fp,ir=(...e)=>$x(...e),mc=(e)=>Au(e),hc=Ex,gc=(e)=>Ii(e),vm=BigInt(0),k0=BigInt(1);function Ni(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(!wm(e))throw RangeError("positive bigint expected, got "+e)}else E0(e);return e}function ii(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 Qu(e){let t=Sm(e).toString(16);return t.length&1?"0"+t:t}function JP(e){if(typeof e!=="string")throw TypeError("hex string expected, got "+typeof e);return e===""?vm:BigInt("0x"+e)}function qs(e){return JP(Fp(e))}function Ln(e){return JP(Fp(ko(er(e)).reverse()))}function _m(e,t){if(Tt(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 Au(r.padStart(t*2,"0"))}function Yu(e,t){return _m(e,t).reverse()}function KP(e,t){if(e=lt(e),t=lt(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 ko(e){return Uint8Array.from(lt(e))}function km(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 wm=(e)=>typeof e==="bigint"&&vm<=e;function wW(e,t,r){return wm(e)&&wm(t)&&wm(r)&&t<=e&&e<r}function zi(e,t,r,i){if(!wW(t,r,i))throw RangeError("expected valid "+e+": "+r+" <= n < "+i+", got "+t)}function yc(e){if(e<vm)throw Error("expected non-negative bigint, got "+e);let t;for(t=0;e>vm;e>>=k0,t+=1);return t}var Xu=(e)=>(k0<<BigInt(e))-k0;function VP(e,t,r){if(Tt(e,"hashLen"),Tt(t,"qByteLen"),typeof r!=="function")throw TypeError("hmacFn must be a function");let i=(b)=>new Uint8Array(b),n=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),a=1000,c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},f=(...b)=>r(l,ir(c,...b)),p=(b=n)=>{if(l=f(o,b),c=f(),b.length===0)return;l=f(s,b),c=f()},y=()=>{if(u++>=a)throw Error("drbg: tried max amount of iterations");let b=0,S=[];while(b<t){c=f();let A=c.slice();S.push(A),b+=c.length}return ir(...S)};return(b,S)=>{d(),p(b);let A=void 0;while((A=S(y()))===void 0)p();return d(),A}}function wn(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 I0=()=>{throw Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var or=BigInt(0),Et=BigInt(1),js=BigInt(2),YP=BigInt(3),XP=BigInt(4),e2=BigInt(5),vW=BigInt(7),t2=BigInt(8),SW=BigInt(9),r2=BigInt(16);function mt(e,t){if(t<=or)throw Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=or?r:t+r}function vn(e,t,r){if(t<or)throw Error("pow2: expected non-negative exponent, got "+t);let i=e;while(t-- >or)i*=i,i%=r;return i}function WP(e,t){if(e===or)throw Error("invert: expected non-zero number");if(t<=or)throw Error("invert: expected positive modulus, got "+t);let r=mt(e,t),i=t,n=or,o=Et,s=Et,a=or;while(r!==or){let l=i/r,u=i-r*l,d=n-s*l,f=o-a*l;i=r,r=u,n=s,o=a,s=d,a=f}if(i!==Et)throw Error("invert: does not exist");return mt(n,t)}function A0(e,t,r){let i=e;if(!i.eql(i.sqr(t),r))throw Error("Cannot find square root")}function n2(e,t){let r=e,i=(r.ORDER+Et)/XP,n=r.pow(t,i);return A0(r,n,t),n}function _W(e,t){let r=e,i=(r.ORDER-e2)/t2,n=r.mul(t,js),o=r.pow(n,i),s=r.mul(t,o),a=r.mul(r.mul(s,js),o),c=r.mul(s,r.sub(a,r.ONE));return A0(r,c,t),c}function kW(e){let t=Em(e),r=i2(e),i=r(t,t.neg(t.ONE)),n=r(t,i),o=r(t,t.neg(i)),s=(e+vW)/r2;return(a,c)=>{let l=a,u=l.pow(c,s),d=l.mul(u,i),f=l.mul(u,n),p=l.mul(u,o),y=l.eql(l.sqr(d),c),g=l.eql(l.sqr(f),c);u=l.cmov(u,d,y),d=l.cmov(p,f,g);let b=l.eql(l.sqr(d),c),S=l.cmov(u,d,b);return A0(l,S,c),S}}function i2(e){if(e<YP)throw Error("sqrt is not defined for small field");let t=e-Et,r=0;while(t%js===or)t/=js,r++;let i=js,n=Em(e);while(GP(n,i)===1)if(i++>1000)throw Error("Cannot find square root: probably non-prime P");if(r===1)return n2;let o=n.pow(i,t),s=(t+Et)/js;return function(c,l){let u=c;if(u.is0(l))return l;if(GP(u,l)!==1)throw Error("Cannot find square root");let d=r,f=u.mul(u.ONE,o),p=u.pow(l,t),y=u.pow(l,s);while(!u.eql(p,u.ONE)){if(u.is0(p))return u.ZERO;let g=1,b=u.sqr(p);while(!u.eql(b,u.ONE))if(g++,b=u.sqr(b),g===d)throw Error("Cannot find square root");let S=Et<<BigInt(d-g-1),A=u.pow(f,S);d=g,f=u.sqr(A),p=u.mul(p,f),y=u.mul(y,A)}return y}}function EW(e){if(e%XP===YP)return n2;if(e%t2===e2)return _W;if(e%r2===SW)return kW(e);return i2(e)}var Li=(e,t)=>(mt(e,t)&Et)===Et,IW=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function $0(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=IW.reduce((i,n)=>(i[n]="function",i),t);if(wn(e,r),ii(e.BYTES,"BYTES"),ii(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Et)throw Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function AW(e,t,r){let i=e;if(r<or)throw Error("invalid exponent, negatives unsupported");if(r===or)return i.ONE;if(r===Et)return t;let n=i.ONE,o=t;while(r>or){if(r&Et)n=i.mul(n,o);o=i.sqr(o),r>>=Et}return n}function ed(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 GP(e,t){let r=e,i=(r.ORDER-Et)/js,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 $W(e,t){if(t!==void 0)E0(t);if(e<=or)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=yc(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 QP=new WeakMap;class C0{ORDER;BITS;BYTES;isLE;ZERO=or;ONE=Et;_lengths;_mod;constructor(e,t={}){if(e<=Et)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}=$W(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 mt(e,this.ORDER)}isValid(e){if(typeof e!=="bigint")throw TypeError("invalid field element: expected bigint, got "+typeof e);return or<=e&&e<this.ORDER}is0(e){return e===or}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Et)===Et}neg(e){return mt(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return mt(e*e,this.ORDER)}add(e,t){return mt(e+t,this.ORDER)}sub(e,t){return mt(e-t,this.ORDER)}mul(e,t){return mt(e*t,this.ORDER)}pow(e,t){return AW(this,e,t)}div(e,t){return mt(e*WP(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 WP(e,this.ORDER)}sqrt(e){let t=QP.get(this);if(!t)QP.set(this,t=EW(this.ORDER));return t(this,e)}toBytes(e){return this.isLE?Yu(e,this.BYTES):_m(e,this.BYTES)}fromBytes(e,t=!1){lt(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?Ln(e):qs(e);if(s)a=mt(a,o);if(!t){if(!this.isValid(a))throw Error("invalid field element: outside of range 0..ORDER")}return a}invertBatch(e){return ed(this,e)}cmov(e,t,r){return Ni(r,"condition"),r?t:e}}Object.freeze(C0.prototype);function Em(e,t={}){return new C0(e,t)}function o2(e){if(typeof e!=="bigint")throw Error("field order must be bigint");if(e<=Et)throw Error("field order must be greater than 1");let t=yc(e-Et);return Math.ceil(t/8)}function T0(e){let t=o2(e);return t+Math.ceil(t/2)}function s2(e,t,r=!1){lt(e);let i=e.length,n=o2(t),o=Math.max(T0(t),16);if(i<o||i>1024)throw Error("expected "+o+"-1024 bytes of input, got "+i);let s=r?Ln(e):qs(e),a=mt(s,t-Et)+Et;return r?Yu(a,n):_m(a,n)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var bc=BigInt(0),Us=BigInt(1);function td(e,t){let r=t.negate();return e?r:t}function Ms(e,t){let r=ed(e.Fp,t.map((i)=>i.Z));return t.map((i,n)=>e.fromAffine(i.toAffine(r[n])))}function u2(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function O0(e,t){u2(e,t);let r=Math.ceil(t/e)+1,i=2**(e-1),n=2**e,o=Xu(e),s=BigInt(e);return{windows:r,windowSize:i,mask:o,maxNumber:n,shiftBy:s}}function a2(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+=Us;let l=t*i,u=l+Math.abs(a)-1,d=a===0,f=a<0,p=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:f,isNegF:p,offsetF:l}}var R0=new WeakMap,d2=new WeakMap;function P0(e){return d2.get(e)||1}function c2(e){if(e!==bc)throw Error("invalid wNAF")}class rd{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>bc){if(t&Us)r=r.add(i);i=i.double(),t>>=Us}return r}precomputeWindow(e,t){let{windows:r,windowSize:i}=O0(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=O0(e,this.bits);for(let s=0;s<o.windows;s++){let{nextN:a,offset:c,isZero:l,isNeg:u,isNegF:d,offsetF:f}=a2(r,s,o);if(r=a,l)n=n.add(td(d,t[f]));else i=i.add(td(u,t[c]))}return c2(r),{p:i,f:n}}wNAFUnsafe(e,t,r,i=this.ZERO){let n=O0(e,this.bits);for(let o=0;o<n.windows;o++){if(r===bc)break;let{nextN:s,offset:a,isZero:c,isNeg:l}=a2(r,o,n);if(r=s,c)continue;else{let u=t[a];i=i.add(l?u.negate():u)}}return c2(r),i}getPrecomputes(e,t,r){let i=R0.get(t);if(!i){if(i=this.precomputeWindow(t,e),e!==1){if(typeof r==="function")i=r(i);R0.set(t,i)}}return i}cached(e,t,r){let i=P0(e);return this.wNAF(i,this.getPrecomputes(i,e,r),t)}unsafe(e,t,r,i){let n=P0(e);if(n===1)return this._unsafeLadder(e,t,i);return this.wNAFUnsafe(n,this.getPrecomputes(n,e,r),t,i)}createCache(e,t){u2(t,this.bits),d2.set(e,t),R0.delete(e)}hasCache(e){return P0(e)!==1}}function f2(e,t,r,i){let n=t,o=e.ZERO,s=e.ZERO;while(r>bc||i>bc){if(r&Us)o=o.add(n);if(i&Us)s=s.add(n);n=n.double(),r>>=Us,i>>=Us}return{p1:o,p2:s}}function l2(e,t,r){if(t){if(t.ORDER!==e)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return $0(t),t}else return Em(e,{isLE:r})}function Im(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>bc))throw Error(`CURVE.${c} must be positive bigint`)}let n=l2(t.p,r.Fp,i),o=l2(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 nd(e,t){return function(i){let n=e(i);return{secretKey:n,publicKey:t(n)}}}function id(e,t){if(ii(e),ii(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 CW(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 TW(e){if(!hc(e)&&typeof e!=="string")throw Error("DST must be Uint8Array or ascii string");let t=typeof e==="string"?km(e):e;if(t.length===0)throw Error("DST must be non-empty");return t}function N0(e,t,r,i){if(lt(e),ii(r),t=TW(t),t.length>255)t=i(ir(km("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=ir(t,id(t.length,1)),c=new Uint8Array(o),l=id(r,2),u=Array(s),d=i(ir(c,e,l,id(0,1),a));u[0]=i(ir(d,id(1,1),a));for(let p=1;p<s;p++){let y=[CW(d,u[p-1]),id(p+1,1),a];u[p]=i(ir(...y))}return ir(...u).slice(0,r)}var p2="HashToScalar-";/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var m2=(e,t)=>(e+(e>=0?t:-t)/g2)/t;function OW(e,t,r){zi("scalar",e,oi,r);let[[i,n],[o,s]]=t,a=m2(s*e,r),c=m2(-n*e,r),l=e-a*i-c*o,u=-a*n-c*s,d=l<oi,f=u<oi;if(d)l=-l;if(f)u=-u;let p=Xu(Math.ceil(yc(r)/2))+Eo;if(l<oi||l>=p||u<oi||u>=p)throw Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:l,k2neg:f,k2:u}}function L0(e){if(!["compact","recovered","der"].includes(e))throw Error('Signature format must be "compact", "recovered", or "der"');return e}function z0(e,t){wn(e);let r={};for(let i of Object.keys(t))r[i]=e[i]===void 0?t[i]:e[i];if(Ni(r.lowS,"lowS"),Ni(r.prehash,"prehash"),r.format!==void 0)L0(r.format);return r}class h2 extends Error{constructor(e=""){super(e)}}var Dn={Err:h2,_tlv:{encode:(e,t)=>{let{Err:r}=Dn;if(ii(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=Qu(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");let o=i>127?Qu(n.length/2|128):"";return Qu(e)+o+n+t},decode(e,t){let{Err:r}=Dn;t=lt(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}=Dn;if(Sm(e),e<oi)throw new t("integer: negative integers are not allowed");let r=Qu(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}=Dn;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 qs(e)}},toSig(e){let{Err:t,_int:r,_tlv:i}=Dn,n=lt(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}=Dn,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(Dn._tlv);Object.freeze(Dn._int);Object.freeze(Dn);var oi=BigInt(0),Eo=BigInt(1),g2=BigInt(2),Am=BigInt(3),RW=BigInt(4);function y2(e,t={}){let r=Im("weierstrass",e,t),i=r.Fp,n=r.Fn,o=r.CURVE,{h:s,n:a}=o;wn(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=x2(i,n);function d(){if(!i.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function f(M,P,z){if(l&&P.is0())return Uint8Array.of(0);let{x:I,y:R}=P.toAffine(),O=i.toBytes(I);if(Ni(z,"isCompressed"),z){d();let F=!i.isOdd(R);return ir(b2(F),O)}else return ir(Uint8Array.of(4),O,i.toBytes(R))}function p(M){lt(M,void 0,"Point");let{publicKey:P,publicKeyUncompressed:z}=u,I=M.length,R=M[0],O=M.subarray(1);if(l&&I===1&&R===0)return{x:i.ZERO,y:i.ZERO};if(I===P&&(R===2||R===3)){let F=i.fromBytes(O);if(!i.isValid(F))throw Error("bad point: is not on curve, wrong x");let D=b(F),V;try{V=i.sqrt(D)}catch(ue){let T=ue instanceof Error?": "+ue.message:"";throw Error("bad point: is not on curve, sqrt error"+T)}d();let _=i.isOdd(V);if((R&1)===1!==_)V=i.neg(V);return{x:F,y:V}}else if(I===z&&R===4){let F=i.BYTES,D=i.fromBytes(O.subarray(0,F)),V=i.fromBytes(O.subarray(F,F*2));if(!S(D,V))throw Error("bad point: is not on curve");return{x:D,y:V}}else throw Error(`bad point: got length ${I}, expected compressed=${P} or uncompressed=${z}`)}let y=t.toBytes===void 0?f:t.toBytes,g=t.fromBytes===void 0?p:t.fromBytes;function b(M){let P=i.sqr(M),z=i.mul(P,M);return i.add(i.add(z,i.mul(M,o.a)),o.b)}function S(M,P){let z=i.sqr(P),I=b(M);return i.eql(z,I)}if(!S(o.Gx,o.Gy))throw Error("bad curve params: generator point");let A=i.mul(i.pow(o.a,Am),RW),C=i.mul(i.sqr(o.b),BigInt(27));if(i.is0(i.add(A,C)))throw Error("bad curve params: a or b");function N(M,P,z=!1){if(!i.isValid(P)||z&&i.is0(P))throw Error(`bad point coordinate ${M}`);return P}function q(M){if(!(M instanceof L))throw Error("Weierstrass Point expected")}function E(M){if(!c||!c.basises)throw Error("no endo");return OW(M,c.basises,n.ORDER)}function Z(M,P,z,I,R){return z=new L(i.mul(z.X,M),z.Y,z.Z),P=td(I,P),z=td(R,z),P.add(z)}class L{static BASE=new L(o.Gx,o.Gy,i.ONE);static ZERO=new L(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(M,P,z){this.X=N("x",M),this.Y=N("y",P,!0),this.Z=N("z",z),Object.freeze(this)}static CURVE(){return o}static fromAffine(M){let{x:P,y:z}=M||{};if(!M||!i.isValid(P)||!i.isValid(z))throw Error("invalid affine point");if(M instanceof L)throw Error("projective point not allowed");if(i.is0(P)&&i.is0(z))return L.ZERO;return new L(P,z,i.ONE)}static fromBytes(M){let P=L.fromAffine(g(lt(M,void 0,"point")));return P.assertValidity(),P}static fromHex(M){return L.fromBytes(mc(M))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(M=8,P=!0){if(ee.createCache(this,M),!P)this.multiply(Am);return this}assertValidity(){let M=this;if(M.is0()){if(t.allowInfinityPoint&&i.is0(M.X)&&i.eql(M.Y,i.ONE)&&i.is0(M.Z))return;throw Error("bad point: ZERO")}let{x:P,y:z}=M.toAffine();if(!i.isValid(P)||!i.isValid(z))throw Error("bad point: x or y not field elements");if(!S(P,z))throw Error("bad point: equation left != right");if(!M.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:M}=this.toAffine();if(!i.isOdd)throw Error("Field doesn't support isOdd");return!i.isOdd(M)}equals(M){q(M);let{X:P,Y:z,Z:I}=this,{X:R,Y:O,Z:F}=M,D=i.eql(i.mul(P,F),i.mul(R,I)),V=i.eql(i.mul(z,F),i.mul(O,I));return D&&V}negate(){return new L(this.X,i.neg(this.Y),this.Z)}double(){let{a:M,b:P}=o,z=i.mul(P,Am),{X:I,Y:R,Z:O}=this,F=i.ZERO,D=i.ZERO,V=i.ZERO,_=i.mul(I,I),re=i.mul(R,R),ue=i.mul(O,O),T=i.mul(I,R);return T=i.add(T,T),V=i.mul(I,O),V=i.add(V,V),F=i.mul(M,V),D=i.mul(z,ue),D=i.add(F,D),F=i.sub(re,D),D=i.add(re,D),D=i.mul(F,D),F=i.mul(T,F),V=i.mul(z,V),ue=i.mul(M,ue),T=i.sub(_,ue),T=i.mul(M,T),T=i.add(T,V),V=i.add(_,_),_=i.add(V,_),_=i.add(_,ue),_=i.mul(_,T),D=i.add(D,_),ue=i.mul(R,O),ue=i.add(ue,ue),_=i.mul(ue,T),F=i.sub(F,_),V=i.mul(ue,re),V=i.add(V,V),V=i.add(V,V),new L(F,D,V)}add(M){q(M);let{X:P,Y:z,Z:I}=this,{X:R,Y:O,Z:F}=M,D=i.ZERO,V=i.ZERO,_=i.ZERO,re=o.a,ue=i.mul(o.b,Am),T=i.mul(P,R),we=i.mul(z,O),Ee=i.mul(I,F),Te=i.add(P,z),Ce=i.add(R,O);Te=i.mul(Te,Ce),Ce=i.add(T,we),Te=i.sub(Te,Ce),Ce=i.add(P,I);let _e=i.add(R,F);return Ce=i.mul(Ce,_e),_e=i.add(T,Ee),Ce=i.sub(Ce,_e),_e=i.add(z,I),D=i.add(O,F),_e=i.mul(_e,D),D=i.add(we,Ee),_e=i.sub(_e,D),_=i.mul(re,Ce),D=i.mul(ue,Ee),_=i.add(D,_),D=i.sub(we,_),_=i.add(we,_),V=i.mul(D,_),we=i.add(T,T),we=i.add(we,T),Ee=i.mul(re,Ee),Ce=i.mul(ue,Ce),we=i.add(we,Ee),Ee=i.sub(T,Ee),Ee=i.mul(re,Ee),Ce=i.add(Ce,Ee),T=i.mul(we,Ce),V=i.add(V,T),T=i.mul(_e,Ce),D=i.mul(Te,D),D=i.sub(D,T),T=i.mul(Te,we),_=i.mul(_e,_),_=i.add(_,T),new L(D,V,_)}subtract(M){return q(M),this.add(M.negate())}is0(){return this.equals(L.ZERO)}multiply(M){let{endo:P}=t;if(!n.isValidNot0(M))throw RangeError("invalid scalar: out of range");let z,I,R=(O)=>ee.cached(this,O,(F)=>Ms(L,F));if(P){let{k1neg:O,k1:F,k2neg:D,k2:V}=E(M),{p:_,f:re}=R(F),{p:ue,f:T}=R(V);I=re.add(T),z=Z(P.beta,_,ue,O,D)}else{let{p:O,f:F}=R(M);z=O,I=F}return Ms(L,[z,I])[0]}multiplyUnsafe(M){let{endo:P}=t,z=this,I=M;if(!n.isValid(I))throw RangeError("invalid scalar: out of range");if(I===oi||z.is0())return L.ZERO;if(I===Eo)return z;if(ee.hasCache(this))return this.multiply(I);if(P){let{k1neg:R,k1:O,k2neg:F,k2:D}=E(I),{p1:V,p2:_}=f2(L,z,O,D);return Z(P.beta,V,_,R,F)}else return ee.unsafe(z,I)}toAffine(M){let P=this,z=M,{X:I,Y:R,Z:O}=P;if(i.eql(O,i.ONE))return{x:I,y:R};let F=P.is0();if(z==null)z=F?i.ONE:i.inv(O);let D=i.mul(I,z),V=i.mul(R,z),_=i.mul(O,z);if(F)return{x:i.ZERO,y:i.ZERO};if(!i.eql(_,i.ONE))throw Error("invZ was invalid");return{x:D,y:V}}isTorsionFree(){let{isTorsionFree:M}=t;if(s===Eo)return!0;if(M)return M(L,this);return ee.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:M}=t;if(s===Eo)return this;if(M)return M(L,this);return this.multiplyUnsafe(s)}isSmallOrder(){if(s===Eo)return this.is0();return this.clearCofactor().is0()}toBytes(M=!0){return Ni(M,"isCompressed"),this.assertValidity(),y(L,this,M)}toHex(M=!0){return pc(this.toBytes(M))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let H=n.BITS,ee=new rd(L,t.endo?Math.ceil(H/2):H);if(H>=8)L.BASE.precompute(8);return Object.freeze(L.prototype),Object.freeze(L),L}function b2(e){return Uint8Array.of(e?2:3)}function x2(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function PW(e,t={}){let{Fn:r}=e,i=t.randomBytes===void 0?gc:t.randomBytes,n=Object.assign(x2(e.Fp,r),{seed:Math.max(T0(r.ORDER),16)});function o(p){try{let y=r.fromBytes(p);return r.isValidNot0(y)}catch(y){return!1}}function s(p,y){let{publicKey:g,publicKeyUncompressed:b}=n;try{let S=p.length;if(y===!0&&S!==g)return!1;if(y===!1&&S!==b)return!1;return!!e.fromBytes(p)}catch(S){return!1}}function a(p){return p=p===void 0?i(n.seed):p,s2(lt(p,n.seed,"seed"),r.ORDER)}function c(p,y=!0){return e.BASE.multiply(r.fromBytes(p)).toBytes(y)}function l(p){let{secretKey:y,publicKey:g,publicKeyUncompressed:b}=n,S=r._lengths;if(!hc(p))return;let A=lt(p,void 0,"key").length,C=A===g||A===b,N=A===y||!!S?.includes(A);if(C&&N)return;return C}function u(p,y,g=!0){if(l(p)===!0)throw Error("first arg must be private key");if(l(y)===!1)throw Error("second arg must be public key");let b=r.fromBytes(p);return e.fromBytes(y).multiply(b).toBytes(g)}let d={isValidSecretKey:o,isValidPublicKey:s,randomSecretKey:a},f=nd(a,c);return Object.freeze(d),Object.freeze(n),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:n})}function w2(e,t,r={}){let i=t;Ei(i),wn(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes===void 0?gc:r.randomBytes,o=r.hmac===void 0?(R,O)=>Yn(i,R,O):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:l}=a,{keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:y}=PW(e,r),g={prehash:!0,lowS:typeof r.lowS==="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},b=c*g2+Eo<s.ORDER;function S(R){let O=c>>Eo;return R>O}function A(R,O){if(!a.isValidNot0(O))throw Error(`invalid signature ${R}: out of range 1..Point.Fn.ORDER`);return O}function C(){if(b)throw Error('"recovered" sig type is not supported for cofactor >2 curves')}function N(R,O){L0(O);let F=y.signature,D=O==="compact"?F:O==="recovered"?F+1:void 0;return lt(R,D)}class q{r;s;recovery;constructor(R,O,F){if(this.r=A("r",R),this.s=A("s",O),F!=null){if(C(),![0,1,2,3].includes(F))throw Error("invalid recovery id");this.recovery=F}Object.freeze(this)}static fromBytes(R,O=g.format){N(R,O);let F;if(O==="der"){let{r:re,s:ue}=Dn.toSig(lt(R));return new q(re,ue)}if(O==="recovered")F=R[0],O="compact",R=R.subarray(1);let D=y.signature/2,V=R.subarray(0,D),_=R.subarray(D,D*2);return new q(a.fromBytes(V),a.fromBytes(_),F)}static fromHex(R,O){return this.fromBytes(mc(R),O)}assertRecovery(){let{recovery:R}=this;if(R==null)throw Error("invalid recovery id: must be present");return R}addRecoveryBit(R){return new q(this.r,this.s,R)}recoverPublicKey(R){let{r:O,s:F}=this,D=this.assertRecovery(),V=D===2||D===3?O+c:O;if(!s.isValid(V))throw Error("invalid recovery id: sig.r+curve.n != R.x");let _=s.toBytes(V),re=e.fromBytes(ir(b2((D&1)===0),_)),ue=a.inv(V),T=Z(lt(R,void 0,"msgHash")),we=a.create(-T*ue),Ee=a.create(F*ue),Te=e.BASE.multiplyUnsafe(we).add(re.multiplyUnsafe(Ee));if(Te.is0())throw Error("invalid recovery: point at infinify");return Te.assertValidity(),Te}hasHighS(){return S(this.s)}toBytes(R=g.format){if(L0(R),R==="der")return mc(Dn.hexFromSig(this));let{r:O,s:F}=this,D=a.toBytes(O),V=a.toBytes(F);if(R==="recovered")return C(),ir(Uint8Array.of(this.assertRecovery()),D,V);return ir(D,V)}toHex(R){return pc(this.toBytes(R))}}Object.freeze(q.prototype),Object.freeze(q);let E=r.bits2int===void 0?function(O){if(O.length>8192)throw Error("input is too large");let F=qs(O),D=O.length*8-l;return D>0?F>>BigInt(D):F}:r.bits2int,Z=r.bits2int_modN===void 0?function(O){return a.create(E(O))}:r.bits2int_modN,L=Xu(l);function H(R){return zi("num < 2^"+l,R,oi,L),a.toBytes(R)}function ee(R,O){return lt(R,void 0,"message"),O?lt(i(R),void 0,"prehashed message"):R}function M(R,O,F){let{lowS:D,prehash:V,extraEntropy:_}=z0(F,g);R=ee(R,V);let re=Z(R),ue=a.fromBytes(O);if(!a.isValidNot0(ue))throw Error("invalid private key");let T=[H(ue),H(re)];if(_!=null&&_!==!1){let Ce=_===!0?n(y.secretKey):_;T.push(lt(Ce,void 0,"extraEntropy"))}let we=ir(...T),Ee=re;function Te(Ce){let _e=E(Ce);if(!a.isValidNot0(_e))return;let Pe=a.inv(_e),Ve=e.BASE.multiply(_e).toAffine(),tt=a.create(Ve.x);if(tt===oi)return;let bt=a.create(Pe*a.create(Ee+tt*ue));if(bt===oi)return;let zt=(Ve.x===tt?0:2)|Number(Ve.y&Eo),pr=bt;if(D&&S(bt))pr=a.neg(bt),zt^=1;return new q(tt,pr,b?void 0:zt)}return{seed:we,k2sig:Te}}function P(R,O,F={}){let{seed:D,k2sig:V}=M(R,O,F);return VP(i.outputLen,a.BYTES,o)(D,V).toBytes(F.format)}function z(R,O,F,D={}){let{lowS:V,prehash:_,format:re}=z0(D,g);if(F=lt(F,void 0,"publicKey"),O=ee(O,_),!hc(R)){let ue=R instanceof q?", use sig.toBytes()":"";throw Error("verify expects Uint8Array signature"+ue)}N(R,re);try{let ue=q.fromBytes(R,re),T=e.fromBytes(F);if(V&&ue.hasHighS())return!1;let{r:we,s:Ee}=ue,Te=Z(O),Ce=a.inv(Ee),_e=a.create(Te*Ce),Pe=a.create(we*Ce),Ve=e.BASE.multiplyUnsafe(_e).add(T.multiplyUnsafe(Pe));if(Ve.is0())return!1;return a.create(Ve.x)===we}catch(ue){return!1}}function I(R,O,F={}){let{prehash:D}=z0(F,g);return O=ee(O,D),q.fromBytes(R,"recovered").recoverPublicKey(O).toBytes()}return Object.freeze({keygen:u,getPublicKey:d,getSharedSecret:f,utils:p,lengths:y,Point:e,sign:P,verify:z,recoverPublicKey:I,Signature:q,hash:i})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var NW=(()=>({p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")}))();var zW=y2(NW),xc=w2(zW,Ot);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var Io=BigInt(0),Mr=BigInt(1),D0=BigInt(2),LW=BigInt(8);function DW(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 v2(e,t={}){let r=t,i=Im("edwards",e,r,r.FpFnLE),{Fp:n,Fn:o}=i,s=i.CURVE,{h:a}=s;wn(r,{},{uvRatio:"function"});let c=D0<<BigInt(o.BYTES*8)-Mr,l=(g)=>n.create(g),u=r.uvRatio===void 0?(g,b)=>{try{return{isValid:!0,value:n.sqrt(n.div(g,b))}}catch(S){return{isValid:!1,value:Io}}}:r.uvRatio;if(!DW(n,s,s.Gx,s.Gy))throw Error("bad curve params: generator point");function d(g,b,S=!1){let A=S?Mr:Io;return zi("coordinate "+g,b,A,c),b}function f(g){if(!(g instanceof p))throw Error("EdwardsPoint expected")}class p{static BASE=new p(s.Gx,s.Gy,Mr,l(s.Gx*s.Gy));static ZERO=new p(Io,Mr,Mr,Io);static Fp=n;static Fn=o;X;Y;Z;T;constructor(g,b,S,A){this.X=d("x",g),this.Y=d("y",b),this.Z=d("z",S,!0),this.T=d("t",A),Object.freeze(this)}static CURVE(){return s}static fromAffine(g){if(g instanceof p)throw Error("extended point not allowed");let{x:b,y:S}=g||{};return d("x",b),d("y",S),new p(b,S,Mr,l(b*S))}static fromBytes(g,b=!1){let S=n.BYTES,{a:A,d:C}=s;g=ko(lt(g,S,"point")),Ni(b,"zip215");let N=ko(g),q=g[S-1];N[S-1]=q&-129;let E=Ln(N),Z=b?c:n.ORDER;zi("point.y",E,Io,Z);let L=l(E*E),H=l(L-Mr),ee=l(C*L-A),{isValid:M,value:P}=u(H,ee);if(!M)throw Error("bad point: invalid y coordinate");let z=(P&Mr)===Mr,I=(q&128)!==0;if(!b&&P===Io&&I)throw Error("bad point: x=0 and x_0=1");if(I!==z)P=l(-P);return p.fromAffine({x:P,y:E})}static fromHex(g,b=!1){return p.fromBytes(mc(g),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,b=!0){if(y.createCache(this,g),!b)this.multiply(D0);return this}assertValidity(){let g=this,{a:b,d:S}=s;if(g.is0())throw Error("bad point: ZERO");let{X:A,Y:C,Z:N,T:q}=g,E=l(A*A),Z=l(C*C),L=l(N*N),H=l(L*L),ee=l(E*b),M=l(L*l(ee+Z)),P=l(H+l(S*l(E*Z)));if(M!==P)throw Error("bad point: equation left != right (1)");let z=l(A*C),I=l(N*q);if(z!==I)throw Error("bad point: equation left != right (2)")}equals(g){f(g);let{X:b,Y:S,Z:A}=this,{X:C,Y:N,Z:q}=g,E=l(b*q),Z=l(C*A),L=l(S*q),H=l(N*A);return E===Z&&L===H}is0(){return this.equals(p.ZERO)}negate(){return new p(l(-this.X),this.Y,this.Z,l(-this.T))}double(){let{a:g}=s,{X:b,Y:S,Z:A}=this,C=l(b*b),N=l(S*S),q=l(D0*l(A*A)),E=l(g*C),Z=b+S,L=l(l(Z*Z)-C-N),H=E+N,ee=H-q,M=E-N,P=l(L*ee),z=l(H*M),I=l(L*M),R=l(ee*H);return new p(P,z,R,I)}add(g){f(g);let{a:b,d:S}=s,{X:A,Y:C,Z:N,T:q}=this,{X:E,Y:Z,Z:L,T:H}=g,ee=l(A*E),M=l(C*Z),P=l(q*S*H),z=l(N*L),I=l((A+C)*(E+Z)-ee-M),R=z-P,O=z+P,F=l(M-b*ee),D=l(I*R),V=l(O*F),_=l(I*F),re=l(R*O);return new p(D,V,re,_)}subtract(g){return f(g),this.add(g.negate())}multiply(g){if(!o.isValidNot0(g))throw RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:b,f:S}=y.cached(this,g,(A)=>Ms(p,A));return Ms(p,[b,S])[0]}multiplyUnsafe(g){if(!o.isValid(g))throw RangeError("invalid scalar: expected 0 <= sc < curve.n");if(g===Io)return p.ZERO;if(this.is0()||g===Mr)return this;return y.unsafe(this,g,(b)=>Ms(p,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return y.unsafe(this,s.n).is0()}toAffine(g){let b=this,S=g,{X:A,Y:C,Z:N}=b,q=b.is0();if(S==null)S=q?LW:n.inv(N);let E=l(A*S),Z=l(C*S),L=n.mul(N,S);if(q)return{x:Io,y:Mr};if(L!==Mr)throw Error("invZ was invalid");return{x:E,y:Z}}clearCofactor(){if(a===Mr)return this;return this.multiplyUnsafe(a)}toBytes(){let{x:g,y:b}=this.toAffine(),S=n.toBytes(b);return S[S.length-1]|=g&Mr?128:0,S}toHex(){return pc(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let y=new rd(p,o.BITS);if(o.BITS>=8)p.BASE.precompute(8);return Object.freeze(p.prototype),Object.freeze(p),p}class B0{static BASE;static ZERO;static Fp;static Fn;ep;constructor(e){this.ep=e}static fromBytes(e){I0()}static fromHex(e){I0()}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 pc(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 od=BigInt(0),wc=BigInt(1),$m=BigInt(2);function BW(e){return wn(e,{P:"bigint",type:"string",adjustScalarBytes:"function",powPminus2:"function"},{randomBytes:"function"}),Object.freeze({...e})}function S2(e){let t=BW(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?gc:s,l=a?255:448,u=a?32:56,d=a?BigInt(9):BigInt(5),f=a?BigInt(121665):BigInt(39081),p=a?$m**BigInt(254):$m**BigInt(447),y=a?BigInt(8)*$m**BigInt(251)-wc:BigInt(4)*$m**BigInt(445)-wc,g=p+y+wc,b=(I)=>mt(I,r),S=A(d);function A(I){return Yu(b(I),u)}function C(I){let R=ko(lt(I,u,"uCoordinate"));if(a)R[31]&=127;return b(Ln(R))}function N(I){return Ln(n(ko(lt(I,u,"scalar"))))}function q(I,R){let O=ee(C(R),N(I));if(O===od)throw Error("invalid private or public key received");return A(O)}function E(I){return q(I,S)}let Z=E,L=q;function H(I,R,O){let F=b(I*(R-O));return R=b(R-F),O=b(O+F),{x_2:R,x_3:O}}function ee(I,R){zi("u",I,od,r),zi("scalar",R,p,g);let O=R,F=I,D=wc,V=od,_=I,re=wc,ue=od;for(let we=BigInt(l-1);we>=od;we--){let Ee=O>>we&wc;ue^=Ee,{x_2:D,x_3:_}=H(ue,D,_),{x_2:V,x_3:re}=H(ue,V,re),ue=Ee;let Te=D+V,Ce=b(Te*Te),_e=D-V,Pe=b(_e*_e),Ve=Ce-Pe,tt=_+re,bt=_-re,zt=b(bt*Te),pr=b(tt*_e),Gr=zt+pr,Qr=zt-pr;_=b(Gr*Gr),re=b(F*b(Qr*Qr)),D=b(Ce*Pe),V=b(Ve*(Ce+b(f*Ve)))}({x_2:D,x_3:_}=H(ue,D,_)),{x_2:V,x_3:re}=H(ue,V,re);let T=o(V);return b(D*T)}let M={secretKey:u,publicKey:u,seed:u},P=(I)=>(I=I===void 0?c(u):I,lt(I,M.seed,"seed"),I),z={randomSecretKey:P};return Object.freeze(M),Object.freeze(z),Object.freeze({keygen:nd(P,Z),getSharedSecret:L,getPublicKey:Z,scalarMult:q,scalarMultBase:E,utils:z,GuBytes:S.slice(),lengths:M})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var qW=BigInt(0),Di=BigInt(1),_2=BigInt(2),jW=BigInt(3),UW=BigInt(5),MW=BigInt(8),Zs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),M0=(()=>({p:Zs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:MW,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function I2(e){let t=BigInt(10),r=BigInt(20),i=BigInt(40),n=BigInt(80),o=Zs,a=e*e%o*e%o,c=vn(a,_2,o)*a%o,l=vn(c,Di,o)*e%o,u=vn(l,UW,o)*l%o,d=vn(u,t,o)*u%o,f=vn(d,r,o)*d%o,p=vn(f,i,o)*f%o,y=vn(p,n,o)*p%o,g=vn(y,n,o)*p%o,b=vn(g,t,o)*u%o;return{pow_p_5_8:vn(b,_2,o)*e%o,b2:a}}function FW(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var q0=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function F0(e,t){let r=Zs,i=mt(t*t*t,r),n=mt(i*i*t,r),o=I2(e*n).pow_p_5_8,s=mt(e*i*o,r),a=mt(t*s*s,r),c=s,l=mt(s*q0,r),u=a===e,d=a===mt(-e,r),f=a===mt(-e*q0,r);if(u)s=c;if(d||f)s=l;if(Li(s,r))s=mt(-s,r);return{isValid:u||d,value:s}}var Fs=v2(M0,{uvRatio:F0}),Ao=(()=>Fs.Fp)(),A2=(()=>Fs.Fn)();var Cm=(()=>{let e=Zs;return S2({P:e,type:"x25519",powPminus2:(t)=>{let{pow_p_5_8:r,b2:i}=I2(t);return mt(vn(r,jW,e)*i,e)},adjustScalarBytes:FW})})();var j0=q0,ZW=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),HW=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),JW=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),KW=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),k2=(e)=>F0(Di,e),VW=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),U0=(e)=>Ao.create(Ln(e)&VW);function E2(e){let{d:t}=M0,r=Zs,i=(S)=>Ao.create(S),n=i(j0*e*e),o=i((n+Di)*JW),s=BigInt(-1),a=i((s-t*n)*i(n+t)),{isValid:c,value:l}=F0(o,a),u=i(l*e);if(!Li(u,r))u=i(-u);if(!c)l=u;if(!c)s=n;let d=i(s*(n-Di)*KW-a),f=l*l,p=i((l+l)*a),y=i(d*ZW),g=i(Di-f),b=i(Di+f);return new Fs(i(p*b),i(g*y),i(y*b),i(p*g))}class Tr extends B0{static BASE=(()=>new Tr(Fs.BASE))();static ZERO=(()=>new Tr(Fs.ZERO))();static Fp=(()=>Ao)();static Fn=(()=>A2)();constructor(e){super(e)}static fromAffine(e){return new Tr(Fs.fromAffine(e))}assertSame(e){if(!(e instanceof Tr))throw Error("RistrettoPoint expected")}init(e){return new Tr(e)}static fromBytes(e){er(e,32);let{a:t,d:r}=M0,i=Zs,n=(C)=>Ao.create(C),o=U0(e);if(!KP(Ao.toBytes(o),e)||Li(o,i))throw Error("invalid ristretto255 encoding 1");let s=n(o*o),a=n(Di+t*s),c=n(Di-t*s),l=n(a*a),u=n(c*c),d=n(t*r*l-u),{isValid:f,value:p}=k2(n(d*u)),y=n(p*c),g=n(p*y*d),b=n((o+o)*y);if(Li(b,i))b=n(-b);let S=n(a*g),A=n(b*S);if(!f||Li(A,i)||S===qW)throw Error("invalid ristretto255 encoding 2");return new Tr(new Fs(b,S,Di,A))}static fromHex(e){return Tr.fromBytes(Au(e))}toBytes(){let{X:e,Y:t,Z:r,T:i}=this.ep,n=Zs,o=(g)=>Ao.create(g),s=o(o(r+t)*o(r-t)),a=o(e*t),c=o(a*a),{value:l}=k2(o(s*c)),u=o(l*s),d=o(l*a),f=o(u*d*i),p;if(Li(i*f,n)){let g=o(t*j0),b=o(e*j0);e=g,t=b,p=o(u*HW)}else p=d;if(Li(e*f,n))t=o(-t);let y=o((r-t)*p);if(Li(y,n))y=o(-y);return Ao.toBytes(y)}equals(e){this.assertSame(e);let{X:t,Y:r}=this.ep,{X:i,Y:n}=e.ep,o=(c)=>Ao.create(c),s=o(t*n)===o(r*i),a=o(r*n)===o(t*i);return s||a}is0(){return this.equals(Tr.ZERO)}}Object.freeze(Tr.BASE);Object.freeze(Tr.ZERO);Object.freeze(Tr.prototype);Object.freeze(Tr);var WW=Object.freeze({Point:Tr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,i=N0(e,r,64,Kp);return WW.deriveToCurve(i)},hashToScalar(e,t={DST:p2}){let r=N0(e,t.DST,64,Kp);return A2.create(Ln(r))},deriveToCurve(e){er(e,64);let t=U0(e.subarray(0,32)),r=E2(t),i=U0(e.subarray(32,64)),n=E2(i);return new Tr(r.add(n))}});var $2=!1,GW=!1;async function C2(e,t){if(GW)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 Tm(e,t){return await C2(async()=>{let r=Z0(e)?e:await YW(e),i=await crypto.subtle.importKey("raw",XW(t),{name:"X25519"},$2,[]);return new Uint8Array(await crypto.subtle.deriveBits({name:"X25519",public:i},r,256))},()=>{if(Z0(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Cm.scalarMult(e,t)})}async function sd(e){return await C2(async()=>Tm(e,Cm.GuBytes),()=>{if(Z0(e))throw Error("CryptoKey provided but X25519 WebCrypto is not supported");return Cm.scalarMultBase(e)})}var QW=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);async function YW(e){if(e.length!==32)throw Error("X25519 private key must be 32 bytes");let t=new Uint8Array([...QW,...e]);return crypto.subtle.importKey("pkcs8",t,{name:"X25519"},$2,["deriveBits"])}function Z0(e){return typeof CryptoKey<"u"&&e instanceof CryptoKey}function XW(e){return e}class H0{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),tG(Hs(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=Hs(e),null;this.buf=r.value}}close(){return this.s.releaseLock(),{rest:this.buf,transcript:Hs(this.transcript)}}}function tG(e){return e.forEach((t)=>{if(t<32||t>126)throw Error("invalid non-ASCII byte in header")}),new TextDecoder().decode(e)}function Hs(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 vc(e,...t){return e.pipeThrough(new TransformStream({start(r){for(let i of t)r.enqueue(i)}}))}function Om(e){return new ReadableStream({start(t){t.enqueue(e),t.close()}})}async function J0(e){if(!(e instanceof ReadableStream))throw Error("readAll expects a ReadableStream<Uint8Array>");return new Uint8Array(await new Response(e).arrayBuffer())}async function T2(e){if(!(e instanceof ReadableStream))throw Error("readAllString expects a ReadableStream<Uint8Array>");return await new Response(e).text()}async function O2(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=Hs(i),s=o.subarray(0,t),a=vc(e,o.subarray(t));return{data:s,rest:a}}class si{args;body;constructor(e,t){this.args=e,this.body=t}}async function rG(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=hr.decode(o);if(s.length>48)throw Error("invalid stanza");if(i.push(s),s.length<48)break}let n=Hs(i);return{s:new si(r,n)}}async function R2(e){let t=new H0(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 rG(t);if(n!==void 0){i.push(n);continue}if(!o.startsWith("--- "))throw Error("invalid header");let s=hr.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:vc(e,a)}}}function K0(e){let t=[];t.push(`age-encryption.org/v1
769
769
  `);for(let r of e){t.push("-> "+r.args.join(" ")+`
770
770
  `);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(hr.encode(r.body.subarray(i,n))+`
771
771
  `)}if(r.body.length%48===0)t.push(`