var Co=Object.defineProperty;var Bo=(t,e,n)=>e in t?Co(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var O=(t,e,n)=>(Bo(t,typeof e!="symbol"?e+"":e,n),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function de(){}function ii(t){return t()}function vr(){return Object.create(null)}function Ze(t){t.forEach(ii)}function oi(t){return typeof t=="function"}function Et(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Io(t){return Object.keys(t).length===0}function Uo(t,...e){if(t==null)return de;const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function yt(t,e,n){t.$$.on_destroy.push(Uo(e,n))}function kr(t,e,n){return t.set(n),e}function q(t,e){t.appendChild(e)}function ue(t,e,n){t.insertBefore(e,n||null)}function ae(t){t.parentNode&&t.parentNode.removeChild(t)}function M(t){return document.createElement(t)}function qt(t){return document.createTextNode(t)}function Fe(){return qt(" ")}function Vn(){return qt("")}function Ht(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function re(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Ro(t){return Array.from(t.childNodes)}function si(t,e){e=""+e,t.data!==e&&(t.data=e)}function _r(t,e){t.value=e??""}let bt;function pt(t){bt=t}function No(){if(!bt)throw new Error("Function called outside component initialization");return bt}function ai(t){No().$$.on_mount.push(t)}const nt=[],Ar=[];let rt=[];const Sr=[],To=Promise.resolve();let $n=!1;function Lo(){$n||($n=!0,To.then(ci))}function Cn(t){rt.push(t)}const dn=new Set;let et=0;function ci(){if(et!==0)return;const t=bt;do{try{for(;et<nt.length;){const e=nt[et];et++,pt(e),Oo(e.$$)}}catch(e){throw nt.length=0,et=0,e}for(pt(null),nt.length=0,et=0;Ar.length;)Ar.pop()();for(let e=0;e<rt.length;e+=1){const n=rt[e];dn.has(n)||(dn.add(n),n())}rt.length=0}while(nt.length);for(;Sr.length;)Sr.pop()();$n=!1,dn.clear(),pt(t)}function Oo(t){if(t.fragment!==null){t.update(),Ze(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(Cn)}}function Ho(t){const e=[],n=[];rt.forEach(r=>t.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),rt=e}const Lt=new Set;let De;function Mt(){De={r:0,c:[],p:De}}function Wt(){De.r||Ze(De.c),De=De.p}function oe(t,e){t&&t.i&&(Lt.delete(t),t.i(e))}function be(t,e,n,r){if(t&&t.o){if(Lt.has(t))return;Lt.add(t),De.c.push(()=>{Lt.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function li(t,e){be(t,1,1,()=>{e.delete(t.key)})}function ui(t,e,n,r,i,o,s,a,c,f,u,l){let h=t.length,y=o.length,g=h;const d={};for(;g--;)d[t[g].key]=g;const p=[],b=new Map,A=new Map,v=[];for(g=y;g--;){const S=l(i,o,g),U=n(S);let R=s.get(U);R?r&&v.push(()=>R.p(S,e)):(R=f(U,S),R.c()),b.set(U,p[g]=R),U in d&&A.set(U,Math.abs(g-d[U]))}const B=new Set,$=new Set;function _(S){oe(S,1),S.m(a,u),s.set(S.key,S),u=S.first,y--}for(;h&&y;){const S=p[y-1],U=t[h-1],R=S.key,T=U.key;S===U?(u=S.first,h--,y--):b.has(T)?!s.has(R)||B.has(R)?_(S):$.has(T)?h--:A.get(R)>A.get(T)?($.add(R),_(S)):(B.add(T),h--):(c(U,s),h--)}for(;h--;){const S=t[h];b.has(S.key)||c(S,s)}for(;y;)_(p[y-1]);return Ze(v),p}function Vt(t){t&&t.c()}function vt(t,e,n,r){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,n),r||Cn(()=>{const s=t.$$.on_mount.map(ii).filter(oi);t.$$.on_destroy?t.$$.on_destroy.push(...s):Ze(s),t.$$.on_mount=[]}),o.forEach(Cn)}function kt(t,e){const n=t.$$;n.fragment!==null&&(Ho(n.after_update),Ze(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Fo(t,e){t.$$.dirty[0]===-1&&(nt.push(t),Lo(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Gt(t,e,n,r,i,o,s,a=[-1]){const c=bt;pt(t);const f=t.$$={fragment:null,ctx:[],props:o,update:de,not_equal:i,bound:vr(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:vr(),dirty:a,skip_bound:!1,root:e.target||c.$$.root};s&&s(f.root);let u=!1;if(f.ctx=n?n(t,e.props||{},(l,h,...y)=>{const g=y.length?y[0]:h;return f.ctx&&i(f.ctx[l],f.ctx[l]=g)&&(!f.skip_bound&&f.bound[l]&&f.bound[l](g),u&&Fo(t,l)),h}):[],f.update(),u=!0,Ze(f.before_update),f.fragment=r?r(f.ctx):!1,e.target){if(e.hydrate){const l=Ro(e.target);f.fragment&&f.fragment.l(l),l.forEach(ae)}else f.fragment&&f.fragment.c();e.intro&&oe(t.$$.fragment),vt(t,e.target,e.anchor,e.customElement),ci()}pt(c)}class Zt{$destroy(){kt(this,1),this.$destroy=de}$on(e,n){if(!oi(n))return de;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const i=r.indexOf(n);i!==-1&&r.splice(i,1)}}$set(e){this.$$set&&!Io(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function fi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Bn={exports:{}},pn,$r;function zo(){if($r)return pn;$r=1;var t=1e3,e=t*60,n=e*60,r=n*24,i=r*7,o=r*365.25;pn=function(u,l){l=l||{};var h=typeof u;if(h==="string"&&u.length>0)return s(u);if(h==="number"&&isFinite(u))return l.long?c(u):a(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function s(u){if(u=String(u),!(u.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(l){var h=parseFloat(l[1]),y=(l[2]||"ms").toLowerCase();switch(y){case"years":case"year":case"yrs":case"yr":case"y":return h*o;case"weeks":case"week":case"w":return h*i;case"days":case"day":case"d":return h*r;case"hours":case"hour":case"hrs":case"hr":case"h":return h*n;case"minutes":case"minute":case"mins":case"min":case"m":return h*e;case"seconds":case"second":case"secs":case"sec":case"s":return h*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return h;default:return}}}}function a(u){var l=Math.abs(u);return l>=r?Math.round(u/r)+"d":l>=n?Math.round(u/n)+"h":l>=e?Math.round(u/e)+"m":l>=t?Math.round(u/t)+"s":u+"ms"}function c(u){var l=Math.abs(u);return l>=r?f(u,l,r,"day"):l>=n?f(u,l,n,"hour"):l>=e?f(u,l,e,"minute"):l>=t?f(u,l,t,"second"):u+" ms"}function f(u,l,h,y){var g=l>=h*1.5;return Math.round(u/h)+" "+y+(g?"s":"")}return pn}function Po(t){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=zo(),n.destroy=f,Object.keys(t).forEach(u=>{n[u]=t[u]}),n.names=[],n.skips=[],n.formatters={};function e(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return n.colors[Math.abs(l)%n.colors.length]}n.selectColor=e;function n(u){let l,h=null,y,g;function d(...p){if(!d.enabled)return;const b=d,A=Number(new Date),v=A-(l||A);b.diff=v,b.prev=l,b.curr=A,l=A,p[0]=n.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let B=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(_,S)=>{if(_==="%%")return"%";B++;const U=n.formatters[S];if(typeof U=="function"){const R=p[B];_=U.call(b,R),p.splice(B,1),B--}return _}),n.formatArgs.call(b,p),(b.log||n.log).apply(b,p)}return d.namespace=u,d.useColors=n.useColors(),d.color=n.selectColor(u),d.extend=r,d.destroy=n.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(y!==n.namespaces&&(y=n.namespaces,g=n.enabled(u)),g),set:p=>{h=p}}),typeof n.init=="function"&&n.init(d),d}function r(u,l){const h=n(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function i(u){n.save(u),n.namespaces=u,n.names=[],n.skips=[];let l;const h=(typeof u=="string"?u:"").split(/[\s,]+/),y=h.length;for(l=0;l<y;l++)h[l]&&(u=h[l].replace(/\*/g,".*?"),u[0]==="-"?n.skips.push(new RegExp("^"+u.slice(1)+"$")):n.names.push(new RegExp("^"+u+"$")))}function o(){const u=[...n.names.map(a),...n.skips.map(a).map(l=>"-"+l)].join(",");return n.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=n.skips.length;l<h;l++)if(n.skips[l].test(u))return!1;for(l=0,h=n.names.length;l<h;l++)if(n.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack||u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var Ko=Po;(function(t,e){e.formatArgs=r,e.save=i,e.load=o,e.useColors=n,e.storage=s(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;c.splice(1,0,f,"color: inherit");let u=0,l=0;c[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(u++,h==="%c"&&(l=u))}),c.splice(l,0,f)}e.log=console.debug||console.log||(()=>{});function i(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function o(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c={}.DEBUG),c}function s(){try{return localStorage}catch{}}t.exports=Ko(e);const{formatters:a}=t.exports;a.j=function(c){try{return JSON.stringify(c)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}})(Bn,Bn.exports);var jo=Bn.exports;const Gn=fi(jo);var hi={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,f,u){this.fn=c,this.context=f,this.once=u||!1}function o(c,f,u,l,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var y=new i(u,l||c,h),g=n?n+f:f;return c._events[g]?c._events[g].fn?c._events[g]=[c._events[g],y]:c._events[g].push(y):(c._events[g]=y,c._eventsCount++),c}function s(c,f){--c._eventsCount===0?c._events=new r:delete c._events[f]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var f=[],u,l;if(this._eventsCount===0)return f;for(l in u=this._events)e.call(u,l)&&f.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(u)):f},a.prototype.listeners=function(f){var u=n?n+f:f,l=this._events[u];if(!l)return[];if(l.fn)return[l.fn];for(var h=0,y=l.length,g=new Array(y);h<y;h++)g[h]=l[h].fn;return g},a.prototype.listenerCount=function(f){var u=n?n+f:f,l=this._events[u];return l?l.fn?1:l.length:0},a.prototype.emit=function(f,u,l,h,y,g){var d=n?n+f:f;if(!this._events[d])return!1;var p=this._events[d],b=arguments.length,A,v;if(p.fn){switch(p.once&&this.removeListener(f,p.fn,void 0,!0),b){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,u),!0;case 3:return p.fn.call(p.context,u,l),!0;case 4:return p.fn.call(p.context,u,l,h),!0;case 5:return p.fn.call(p.context,u,l,h,y),!0;case 6:return p.fn.call(p.context,u,l,h,y,g),!0}for(v=1,A=new Array(b-1);v<b;v++)A[v-1]=arguments[v];p.fn.apply(p.context,A)}else{var B=p.length,$;for(v=0;v<B;v++)switch(p[v].once&&this.removeListener(f,p[v].fn,void 0,!0),b){case 1:p[v].fn.call(p[v].context);break;case 2:p[v].fn.call(p[v].context,u);break;case 3:p[v].fn.call(p[v].context,u,l);break;case 4:p[v].fn.call(p[v].context,u,l,h);break;default:if(!A)for($=1,A=new Array(b-1);$<b;$++)A[$-1]=arguments[$];p[v].fn.apply(p[v].context,A)}}return!0},a.prototype.on=function(f,u,l){return o(this,f,u,l,!1)},a.prototype.once=function(f,u,l){return o(this,f,u,l,!0)},a.prototype.removeListener=function(f,u,l,h){var y=n?n+f:f;if(!this._events[y])return this;if(!u)return s(this,y),this;var g=this._events[y];if(g.fn)g.fn===u&&(!h||g.once)&&(!l||g.context===l)&&s(this,y);else{for(var d=0,p=[],b=g.length;d<b;d++)(g[d].fn!==u||h&&!g[d].once||l&&g[d].context!==l)&&p.push(g[d]);p.length?this._events[y]=p.length===1?p[0]:p:s(this,y)}return this},a.prototype.removeAllListeners=function(f){var u;return f?(u=n?n+f:f,this._events[u]&&s(this,u)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(hi);var Do=hi.exports;const lt=fi(Do);function In(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function qo(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function di(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Mo(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");In(t.outputLen),In(t.blockLen)}function Wo(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Vo(t,e){di(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const qe={number:In,bool:qo,bytes:di,hash:Mo,exists:Wo,output:Vo},gn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pi=t=>t instanceof Uint8Array,yn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),we=(t,e)=>t<<32-e|t>>>e,Go=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Go)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Zo(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Zn(t){if(typeof t=="string"&&(t=Zo(t)),!pi(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Yo(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!pi(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let gi=class{clone(){return this._cloneInto()}};function yi(t){const e=r=>t().update(Zn(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function bi(t=32){if(gn&&typeof gn.getRandomValues=="function")return gn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Jo(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,f=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+f,a,r)}let Qo=class extends gi{constructor(e,n,r,i){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=yn(this.buffer)}update(e){qe.exists(this);const{view:n,buffer:r,blockLen:i}=this;e=Zn(e);const o=e.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const c=yn(e);for(;i<=o-s;s+=i)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){qe.exists(this),qe.output(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:o}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let l=s;l<i;l++)n[l]=0;Jo(r,i-8,BigInt(this.length*8),o),this.process(r,0);const a=yn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%n&&e.buffer.set(r),e}};const Xo=(t,e,n)=>t&e^~t&n,es=(t,e,n)=>t&e^t&n^e&n,ts=new Uint32Array([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]),Be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ie=new Uint32Array(64);let wi=class extends Qo{constructor(){super(64,32,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[7]|0}get(){const{A:e,B:n,C:r,D:i,E:o,F:s,G:a,H:c}=this;return[e,n,r,i,o,s,a,c]}set(e,n,r,i,o,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)Ie[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){const h=Ie[l-15],y=Ie[l-2],g=we(h,7)^we(h,18)^h>>>3,d=we(y,17)^we(y,19)^y>>>10;Ie[l]=d+Ie[l-7]+g+Ie[l-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){const h=we(a,6)^we(a,11)^we(a,25),y=u+h+Xo(a,c,f)+ts[l]+Ie[l]|0,d=(we(r,2)^we(r,13)^we(r,22))+es(r,i,o)|0;u=f,f=c,c=a,a=s+y|0,s=o,o=i,i=r,r=y+d|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,i,o,s,a,c,f,u)}roundClean(){Ie.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},ns=class extends wi{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};const Un=yi(()=>new wi);yi(()=>new ns);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mi=BigInt(0),Yt=BigInt(1),rs=BigInt(2),Jt=t=>t instanceof Uint8Array,is=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ot(t){if(!Jt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=is[t[n]];return e}function xi(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function Yn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function st(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const i=r*2,o=t.slice(i,i+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function se(t){return Yn(ot(t))}function Jn(t){if(!Jt(t))throw new Error("Uint8Array expected");return Yn(ot(Uint8Array.from(t).reverse()))}function ze(t,e){return st(t.toString(16).padStart(e*2,"0"))}function Ei(t,e){return ze(t,e).reverse()}function os(t){return st(xi(t))}function X(t,e,n){let r;if(typeof e=="string")try{r=st(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(Jt(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(`${t} expected ${n} bytes, got ${i}`);return r}function Ve(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!Jt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function ss(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function as(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function cs(t){let e;for(e=0;t>mi;t>>=Yt,e+=1);return e}function ls(t,e){return t>>BigInt(e)&Yt}const us=(t,e,n)=>t|(n?Yt:mi)<<BigInt(e),Qn=t=>(rs<<BigInt(t-1))-Yt,bn=t=>new Uint8Array(t),Cr=t=>Uint8Array.from(t);function vi(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=bn(t),i=bn(t),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...l)=>n(i,r,...l),c=(l=bn())=>{i=a(Cr([0]),l),r=a(),l.length!==0&&(i=a(Cr([1]),l),r=a())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0;const h=[];for(;l<e;){r=a();const y=r.slice();h.push(y),l+=r.length}return Ve(...h)};return(l,h)=>{s(),c(l);let y;for(;!(y=h(f()));)c();return s(),y}}const fs={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function _t(t,e,n={}){const r=(i,o,s)=>{const a=fs[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);const c=t[i];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`)};for(const[i,o]of Object.entries(e))r(i,o,!1);for(const[i,o]of Object.entries(n))r(i,o,!0);return t}const hs=Object.freeze(Object.defineProperty({__proto__:null,bitGet:ls,bitLen:cs,bitMask:Qn,bitSet:us,bytesToHex:ot,bytesToNumberBE:se,bytesToNumberLE:Jn,concatBytes:Ve,createHmacDrbg:vi,ensureBytes:X,equalBytes:ss,hexToBytes:st,hexToNumber:Yn,numberToBytesBE:ze,numberToBytesLE:Ei,numberToHexUnpadded:xi,numberToVarBytesBE:os,utf8ToBytes:as,validateObject:_t},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const J=BigInt(0),W=BigInt(1),Ke=BigInt(2),ds=BigInt(3),Rn=BigInt(4),Br=BigInt(5),Ir=BigInt(8);BigInt(9);BigInt(16);function Y(t,e){const n=t%e;return n>=J?n:e+n}function ps(t,e,n){if(n<=J||e<J)throw new Error("Expected power/modulo > 0");if(n===W)return J;let r=W;for(;e>J;)e&W&&(r=r*t%n),t=t*t%n,e>>=W;return r}function fe(t,e,n){let r=t;for(;e-- >J;)r*=r,r%=n;return r}function Nn(t,e){if(t===J||e<=J)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=Y(t,e),r=e,i=J,o=W;for(;n!==J;){const a=r/n,c=r%n,f=i-o*a;r=n,n=c,i=o,o=f}if(r!==W)throw new Error("invert: does not exist");return Y(i,e)}function gs(t){const e=(t-W)/Ke;let n,r,i;for(n=t-W,r=0;n%Ke===J;n/=Ke,r++);for(i=Ke;i<t&&ps(i,e,t)!==t-W;i++);if(r===1){const s=(t+W)/Rn;return function(c,f){const u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}const o=(n+W)/Ke;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=r,u=a.pow(a.mul(a.ONE,i),n),l=a.pow(c,o),h=a.pow(c,n);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let y=1;for(let d=a.sqr(h);y<f&&!a.eql(d,a.ONE);y++)d=a.sqr(d);const g=a.pow(u,W<<BigInt(f-y-1));u=a.sqr(g),l=a.mul(l,g),h=a.mul(h,u),f=y}return l}}function ys(t){if(t%Rn===ds){const e=(t+W)/Rn;return function(r,i){const o=r.pow(i,e);if(!r.eql(r.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%Ir===Br){const e=(t-Br)/Ir;return function(r,i){const o=r.mul(i,Ke),s=r.pow(o,e),a=r.mul(i,s),c=r.mul(r.mul(a,Ke),s),f=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(f),i))throw new Error("Cannot find square root");return f}}return gs(t)}const bs=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ws(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=bs.reduce((r,i)=>(r[i]="function",r),e);return _t(t,n)}function ms(t,e,n){if(n<J)throw new Error("Expected power > 0");if(n===J)return t.ONE;if(n===W)return e;let r=t.ONE,i=e;for(;n>J;)n&W&&(r=t.mul(r,i)),i=t.sqr(i),n>>=W;return r}function xs(t,e){const n=new Array(e.length),r=e.reduce((o,s,a)=>t.is0(s)?o:(n[a]=o,t.mul(o,s)),t.ONE),i=t.inv(r);return e.reduceRight((o,s,a)=>t.is0(s)?o:(n[a]=t.mul(o,n[a]),t.mul(o,s)),i),n}function Xn(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Es(t,e,n=!1,r={}){if(t<=J)throw new Error(`Expected Fp ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=Xn(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=ys(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:Qn(i),ZERO:J,ONE:W,create:c=>Y(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return J<=c&&c<t},is0:c=>c===J,isOdd:c=>(c&W)===W,neg:c=>Y(-c,t),eql:(c,f)=>c===f,sqr:c=>Y(c*c,t),add:(c,f)=>Y(c+f,t),sub:(c,f)=>Y(c-f,t),mul:(c,f)=>Y(c*f,t),pow:(c,f)=>ms(a,c,f),div:(c,f)=>Y(c*Nn(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Nn(c,t),sqrt:r.sqrt||(c=>s(a,c)),invertBatch:c=>xs(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>n?Ei(c,o):ze(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return n?Jn(c):se(c)}});return Object.freeze(a)}function vs(t,e,n=!1){t=X("privateHash",t);const r=t.length,i=Xn(e).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);const o=n?Jn(t):se(t);return Y(o,e-W)+W}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ks=BigInt(0),wn=BigInt(1);function _s(t,e){const n=(i,o)=>{const s=o.negate();return i?s:o},r=i=>{const o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:n,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>ks;)o&wn&&(s=s.add(a)),a=a.double(),o>>=wn;return s},precomputeWindow(i,o){const{windows:s,windowSize:a}=r(o),c=[];let f=i,u=f;for(let l=0;l<s;l++){u=f,c.push(u);for(let h=1;h<a;h++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(i,o,s){const{windows:a,windowSize:c}=r(i);let f=t.ZERO,u=t.BASE;const l=BigInt(2**i-1),h=2**i,y=BigInt(i);for(let g=0;g<a;g++){const d=g*c;let p=Number(s&l);s>>=y,p>c&&(p-=h,s+=wn);const b=d,A=d+Math.abs(p)-1,v=g%2!==0,B=p<0;p===0?u=u.add(n(v,o[b])):f=f.add(n(B,o[A]))}return{p:f,f:u}},wNAFCached(i,o,s,a){const c=i._WINDOW_SIZE||1;let f=o.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&o.set(i,a(f))),this.wNAF(c,f,s)}}}function ki(t){return ws(t.Fp),_t(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Xn(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function As(t){const e=ki(t);_t(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Ss,hexToBytes:$s}=hs,Me={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=Me;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Ss(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=Me,n=typeof t=="string"?$s(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=Me._parseInt(n.subarray(2)),{d:s,l:a}=Me._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){const e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,n=f=>{const u=f.toString(16);return u.length&1?`0${u}`:u},r=e(n(t.s)),i=e(n(t.r)),o=r.length/2,s=i.length/2,a=n(o),c=n(s);return`30${n(s+o+4)}02${c}${i}02${a}${r}`}},ke=BigInt(0),he=BigInt(1);BigInt(2);const Ur=BigInt(3);BigInt(4);function Cs(t){const e=As(t),{Fp:n}=e,r=e.toBytes||((g,d,p)=>{const b=d.toAffine();return Ve(Uint8Array.from([4]),n.toBytes(b.x),n.toBytes(b.y))}),i=e.fromBytes||(g=>{const d=g.subarray(1),p=n.fromBytes(d.subarray(0,n.BYTES)),b=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:p,y:b}});function o(g){const{a:d,b:p}=e,b=n.sqr(g),A=n.mul(b,g);return n.add(n.add(A,n.mul(g,d)),p)}if(!n.eql(n.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&ke<g&&g<e.n}function a(g){if(!s(g))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(g){const{allowedPrivateKeyLengths:d,nByteLength:p,wrapPrivateKey:b,n:A}=e;if(d&&typeof g!="bigint"){if(g instanceof Uint8Array&&(g=ot(g)),typeof g!="string"||!d.includes(g.length))throw new Error("Invalid key");g=g.padStart(p*2,"0")}let v;try{v=typeof g=="bigint"?g:se(X("private key",g,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof g}`)}return b&&(v=Y(v,A)),a(v),v}const f=new Map;function u(g){if(!(g instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(d,p,b){if(this.px=d,this.py=p,this.pz=b,d==null||!n.isValid(d))throw new Error("x required");if(p==null||!n.isValid(p))throw new Error("y required");if(b==null||!n.isValid(b))throw new Error("z required")}static fromAffine(d){const{x:p,y:b}=d||{};if(!d||!n.isValid(p)||!n.isValid(b))throw new Error("invalid affine point");if(d instanceof l)throw new Error("projective point not allowed");const A=v=>n.eql(v,n.ZERO);return A(p)&&A(b)?l.ZERO:new l(p,b,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const p=n.invertBatch(d.map(b=>b.pz));return d.map((b,A)=>b.toAffine(p[A])).map(l.fromAffine)}static fromHex(d){const p=l.fromAffine(i(X("pointHex",d)));return p.assertValidity(),p}static fromPrivateKey(d){return l.BASE.multiply(c(d))}_setWindowSize(d){this._WINDOW_SIZE=d,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:d,y:p}=this.toAffine();if(!n.isValid(d)||!n.isValid(p))throw new Error("bad point: x or y not FE");const b=n.sqr(p),A=o(d);if(!n.eql(b,A))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:d}=this.toAffine();if(n.isOdd)return!n.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){u(d);const{px:p,py:b,pz:A}=this,{px:v,py:B,pz:$}=d,_=n.eql(n.mul(p,$),n.mul(v,A)),S=n.eql(n.mul(b,$),n.mul(B,A));return _&&S}negate(){return new l(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b:p}=e,b=n.mul(p,Ur),{px:A,py:v,pz:B}=this;let $=n.ZERO,_=n.ZERO,S=n.ZERO,U=n.mul(A,A),R=n.mul(v,v),T=n.mul(B,B),w=n.mul(A,v);return w=n.add(w,w),S=n.mul(A,B),S=n.add(S,S),$=n.mul(d,S),_=n.mul(b,T),_=n.add($,_),$=n.sub(R,_),_=n.add(R,_),_=n.mul($,_),$=n.mul(w,$),S=n.mul(b,S),T=n.mul(d,T),w=n.sub(U,T),w=n.mul(d,w),w=n.add(w,S),S=n.add(U,U),U=n.add(S,U),U=n.add(U,T),U=n.mul(U,w),_=n.add(_,U),T=n.mul(v,B),T=n.add(T,T),U=n.mul(T,w),$=n.sub($,U),S=n.mul(T,R),S=n.add(S,S),S=n.add(S,S),new l($,_,S)}add(d){u(d);const{px:p,py:b,pz:A}=this,{px:v,py:B,pz:$}=d;let _=n.ZERO,S=n.ZERO,U=n.ZERO;const R=e.a,T=n.mul(e.b,Ur);let w=n.mul(p,v),x=n.mul(b,B),k=n.mul(A,$),N=n.add(p,b),m=n.add(v,B);N=n.mul(N,m),m=n.add(w,x),N=n.sub(N,m),m=n.add(p,A);let E=n.add(v,$);return m=n.mul(m,E),E=n.add(w,k),m=n.sub(m,E),E=n.add(b,A),_=n.add(B,$),E=n.mul(E,_),_=n.add(x,k),E=n.sub(E,_),U=n.mul(R,m),_=n.mul(T,k),U=n.add(_,U),_=n.sub(x,U),U=n.add(x,U),S=n.mul(_,U),x=n.add(w,w),x=n.add(x,w),k=n.mul(R,k),m=n.mul(T,m),x=n.add(x,k),k=n.sub(w,k),k=n.mul(R,k),m=n.add(m,k),w=n.mul(x,m),S=n.add(S,w),w=n.mul(E,m),_=n.mul(N,_),_=n.sub(_,w),w=n.mul(N,x),U=n.mul(E,U),U=n.add(U,w),new l(_,S,U)}subtract(d){return this.add(d.negate())}is0(){return this.equals(l.ZERO)}wNAF(d){return y.wNAFCached(this,f,d,p=>{const b=n.invertBatch(p.map(A=>A.pz));return p.map((A,v)=>A.toAffine(b[v])).map(l.fromAffine)})}multiplyUnsafe(d){const p=l.ZERO;if(d===ke)return p;if(a(d),d===he)return this;const{endo:b}=e;if(!b)return y.unsafeLadder(this,d);let{k1neg:A,k1:v,k2neg:B,k2:$}=b.splitScalar(d),_=p,S=p,U=this;for(;v>ke||$>ke;)v&he&&(_=_.add(U)),$&he&&(S=S.add(U)),U=U.double(),v>>=he,$>>=he;return A&&(_=_.negate()),B&&(S=S.negate()),S=new l(n.mul(S.px,b.beta),S.py,S.pz),_.add(S)}multiply(d){a(d);let p=d,b,A;const{endo:v}=e;if(v){const{k1neg:B,k1:$,k2neg:_,k2:S}=v.splitScalar(p);let{p:U,f:R}=this.wNAF($),{p:T,f:w}=this.wNAF(S);U=y.constTimeNegate(B,U),T=y.constTimeNegate(_,T),T=new l(n.mul(T.px,v.beta),T.py,T.pz),b=U.add(T),A=R.add(w)}else{const{p:B,f:$}=this.wNAF(p);b=B,A=$}return l.normalizeZ([b,A])[0]}multiplyAndAddUnsafe(d,p,b){const A=l.BASE,v=($,_)=>_===ke||_===he||!$.equals(A)?$.multiplyUnsafe(_):$.multiply(_),B=v(this,p).add(v(d,b));return B.is0()?void 0:B}toAffine(d){const{px:p,py:b,pz:A}=this,v=this.is0();d==null&&(d=v?n.ONE:n.inv(A));const B=n.mul(p,d),$=n.mul(b,d),_=n.mul(A,d);if(v)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:B,y:$}}isTorsionFree(){const{h:d,isTorsionFree:p}=e;if(d===he)return!0;if(p)return p(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:d,clearCofactor:p}=e;return d===he?this:p?p(l,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),r(l,this,d)}toHex(d=!0){return ot(this.toRawBytes(d))}}l.BASE=new l(e.Gx,e.Gy,n.ONE),l.ZERO=new l(n.ZERO,n.ONE,n.ZERO);const h=e.nBitLength,y=_s(l,e.endo?Math.ceil(h/2):h);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function Bs(t){const e=ki(t);return _t(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Is(t){const e=Bs(t),{Fp:n,n:r}=e,i=n.BYTES+1,o=2*n.BYTES+1;function s(m){return ke<m&&m<n.ORDER}function a(m){return Y(m,r)}function c(m){return Nn(m,r)}const{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:h}=Cs({...e,toBytes(m,E,C){const H=E.toAffine(),I=n.toBytes(H.x),P=Ve;return C?P(Uint8Array.from([E.hasEvenY()?2:3]),I):P(Uint8Array.from([4]),I,n.toBytes(H.y))},fromBytes(m){const E=m.length,C=m[0],H=m.subarray(1);if(E===i&&(C===2||C===3)){const I=se(H);if(!s(I))throw new Error("Point is not on curve");const P=l(I);let L=n.sqrt(P);const z=(L&he)===he;return(C&1)===1!==z&&(L=n.neg(L)),{x:I,y:L}}else if(E===o&&C===4){const I=n.fromBytes(H.subarray(0,n.BYTES)),P=n.fromBytes(H.subarray(n.BYTES,2*n.BYTES));return{x:I,y:P}}else throw new Error(`Point of length ${E} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),y=m=>ot(ze(m,e.nByteLength));function g(m){const E=r>>he;return m>E}function d(m){return g(m)?a(-m):m}const p=(m,E,C)=>se(m.slice(E,C));class b{constructor(E,C,H){this.r=E,this.s=C,this.recovery=H,this.assertValidity()}static fromCompact(E){const C=e.nByteLength;return E=X("compactSignature",E,C*2),new b(p(E,0,C),p(E,C,2*C))}static fromDER(E){const{r:C,s:H}=Me.toSig(X("DER",E));return new b(C,H)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(E){return new b(this.r,this.s,E)}recoverPublicKey(E){const{r:C,s:H,recovery:I}=this,P=S(X("msgHash",E));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const L=I===2||I===3?C+e.n:C;if(L>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const z=I&1?"03":"02",j=f.fromHex(z+y(L)),D=c(L),ee=a(-P*D),te=a(H*D),Z=f.BASE.multiplyAndAddUnsafe(j,ee,te);if(!Z)throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return st(this.toDERHex())}toDERHex(){return Me.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return st(this.toCompactHex())}toCompactHex(){return y(this.r)+y(this.s)}}const A={isValidPrivateKey(m){try{return u(m),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const m=e.randomBytes(n.BYTES+8),E=vs(m,r);return ze(E,e.nByteLength)},precompute(m=8,E=f.BASE){return E._setWindowSize(m),E.multiply(BigInt(3)),E}};function v(m,E=!0){return f.fromPrivateKey(m).toRawBytes(E)}function B(m){const E=m instanceof Uint8Array,C=typeof m=="string",H=(E||C)&&m.length;return E?H===i||H===o:C?H===2*i||H===2*o:m instanceof f}function $(m,E,C=!0){if(B(m))throw new Error("first arg must be private key");if(!B(E))throw new Error("second arg must be public key");return f.fromHex(E).multiply(u(m)).toRawBytes(C)}const _=e.bits2int||function(m){const E=se(m),C=m.length*8-e.nBitLength;return C>0?E>>BigInt(C):E},S=e.bits2int_modN||function(m){return a(_(m))},U=Qn(e.nBitLength);function R(m){if(typeof m!="bigint")throw new Error("bigint expected");if(!(ke<=m&&m<U))throw new Error(`bigint expected < 2^${e.nBitLength}`);return ze(m,e.nByteLength)}function T(m,E,C=w){if(["recovered","canonical"].some(ie=>ie in C))throw new Error("sign() legacy options not supported");const{hash:H,randomBytes:I}=e;let{lowS:P,prehash:L,extraEntropy:z}=C;P==null&&(P=!0),m=X("msgHash",m),L&&(m=X("prehashed msgHash",H(m)));const j=S(m),D=u(E),ee=[R(D),R(j)];if(z!=null){const ie=z===!0?I(n.BYTES):z;ee.push(X("extraEntropy",ie,n.BYTES))}const te=Ve(...ee),Z=j;function ce(ie){const Je=_(ie);if(!h(Je))return;const mr=c(Je),Qe=f.BASE.multiply(Je).toAffine(),ge=a(Qe.x);if(ge===ke)return;const Xe=a(mr*a(Z+ge*D));if(Xe===ke)return;let xr=(Qe.x===ge?0:2)|Number(Qe.y&he),Er=Xe;return P&&g(Xe)&&(Er=d(Xe),xr^=1),new b(ge,Er,xr)}return{seed:te,k2sig:ce}}const w={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};function k(m,E,C=w){const{seed:H,k2sig:I}=T(m,E,C),P=e;return vi(P.hash.outputLen,P.nByteLength,P.hmac)(H,I)}f.BASE._setWindowSize(8);function N(m,E,C,H=x){var Qe;const I=m;if(E=X("msgHash",E),C=X("publicKey",C),"strict"in H)throw new Error("options.strict was renamed to lowS");const{lowS:P,prehash:L}=H;let z,j;try{if(typeof I=="string"||I instanceof Uint8Array)try{z=b.fromDER(I)}catch(ge){if(!(ge instanceof Me.Err))throw ge;z=b.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:ge,s:Xe}=I;z=new b(ge,Xe)}else throw new Error("PARSE");j=f.fromHex(C)}catch(ge){if(ge.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&z.hasHighS())return!1;L&&(E=e.hash(E));const{r:D,s:ee}=z,te=S(E),Z=c(ee),ce=a(te*Z),ie=a(D*Z),Je=(Qe=f.BASE.multiplyAndAddUnsafe(j,ce,ie))==null?void 0:Qe.toAffine();return Je?a(Je.x)===D:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:$,sign:k,verify:N,ProjectivePoint:f,Signature:b,utils:A}}let _i=class extends gi{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,qe.hash(e);const r=Zn(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(r.length>i?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return qe.exists(this),this.iHash.update(e),this}digestInto(e){qe.exists(this),qe.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Ai=(t,e,n)=>new _i(t,e).update(n).digest();Ai.create=(t,e)=>new _i(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Us(t){return{hash:t,hmac:(e,...n)=>Ai(t,e,Yo(...n)),randomBytes:bi}}function Rs(t,e){const n=r=>Is({...t,...Us(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ft=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Si=BigInt(1),zt=BigInt(2),Rr=(t,e)=>(t+e/zt)/e;function $i(t){const e=Qt,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=fe(u,n,e)*u%e,h=fe(l,n,e)*u%e,y=fe(h,zt,e)*f%e,g=fe(y,i,e)*y%e,d=fe(g,o,e)*g%e,p=fe(d,a,e)*d%e,b=fe(p,c,e)*p%e,A=fe(b,a,e)*d%e,v=fe(A,n,e)*u%e,B=fe(v,s,e)*g%e,$=fe(B,r,e)*f%e,_=fe($,zt,e);if(!Tn.eql(Tn.sqr(_),t))throw new Error("Cannot find square root");return _}const Tn=Es(Qt,void 0,void 0,{sqrt:$i}),ne=Rs({a:BigInt(0),b:BigInt(7),Fp:Tn,n:Ft,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Ft,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Si*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Rr(o*t,e),c=Rr(-r*t,e);let f=Y(t-a*n-c*i,e),u=Y(-a*r-c*o,e);const l=f>s,h=u>s;if(l&&(f=e-f),h&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},Un),Xt=BigInt(0),Ci=t=>typeof t=="bigint"&&Xt<t&&t<Qt,Ns=t=>typeof t=="bigint"&&Xt<t&&t<Ft,Nr={};function Pt(t,...e){let n=Nr[t];if(n===void 0){const r=Un(Uint8Array.from(t,i=>i.charCodeAt(0)));n=Ve(r,r),Nr[t]=n}return Un(Ve(n,...e))}const er=t=>t.toRawBytes(!0).slice(1),Ln=t=>ze(t,32),mn=t=>Y(t,Qt),wt=t=>Y(t,Ft),tr=ne.ProjectivePoint,Ts=(t,e,n)=>tr.BASE.multiplyAndAddUnsafe(t,e,n);function On(t){let e=ne.utils.normPrivateKeyToScalar(t),n=tr.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:wt(-e),bytes:er(n)}}function Bi(t){if(!Ci(t))throw new Error("bad x: need 0 < x < p");const e=mn(t*t),n=mn(e*t+BigInt(7));let r=$i(n);r%zt!==Xt&&(r=mn(-r));const i=new tr(t,r,Si);return i.assertValidity(),i}function Ii(...t){return wt(se(Pt("BIP0340/challenge",...t)))}function Ls(t){return On(t).bytes}function Os(t,e,n=bi(32)){const r=X("message",t),{bytes:i,scalar:o}=On(e),s=X("auxRand",n,32),a=Ln(o^se(Pt("BIP0340/aux",s))),c=Pt("BIP0340/nonce",a,i,r),f=wt(se(c));if(f===Xt)throw new Error("sign failed: k is zero");const{bytes:u,scalar:l}=On(f),h=Ii(u,i,r),y=new Uint8Array(64);if(y.set(u,0),y.set(Ln(wt(l+h*o)),32),!Ui(y,r,i))throw new Error("sign: Invalid signature produced");return y}function Ui(t,e,n){const r=X("signature",t,64),i=X("message",e),o=X("publicKey",n,32);try{const s=Bi(se(o)),a=se(r.subarray(0,32));if(!Ci(a))return!1;const c=se(r.subarray(32,64));if(!Ns(c))return!1;const f=Ii(Ln(a),er(s),i),u=Ts(s,c,wt(-f));return!(!u||!u.hasEvenY()||u.toAffine().x!==a)}catch{return!1}}const At=(()=>({getPublicKey:Ls,sign:Os,verify:Ui,utils:{randomPrivateKey:ne.utils.randomPrivateKey,lift_x:Bi,pointToBytes:er,numberToBytesBE:ze,bytesToNumberBE:se,taggedHash:Pt,mod:Y}}))(),xn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nr=t=>t instanceof Uint8Array,En=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),me=(t,e)=>t<<32-e|t>>>e,Hs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Hs)throw new Error("Non little-endian hardware is not supported");const Fs=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ye(t){if(!nr(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Fs[t[n]];return e}function at(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const i=r*2,o=t.slice(i,i+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function zs(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ri(t){if(typeof t=="string"&&(t=zs(t)),!nr(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Ps(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!nr(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let Ks=class{clone(){return this._cloneInto()}};function Ni(t){const e=r=>t().update(Ri(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ti(t=32){if(xn&&typeof xn.getRandomValues=="function")return xn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Hn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function js(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Li(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Ds(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Hn(t.outputLen),Hn(t.blockLen)}function qs(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ms(t,e){Li(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const vn={number:Hn,bool:js,bytes:Li,hash:Ds,exists:qs,output:Ms};function Ws(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,f=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+f,a,r)}let Vs=class extends Ks{constructor(e,n,r,i){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=En(this.buffer)}update(e){vn.exists(this);const{view:n,buffer:r,blockLen:i}=this;e=Ri(e);const o=e.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const c=En(e);for(;i<=o-s;s+=i)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){vn.exists(this),vn.output(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:o}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let l=s;l<i;l++)n[l]=0;Ws(r,i-8,BigInt(this.length*8),o),this.process(r,0);const a=En(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%n&&e.buffer.set(r),e}};const Gs=(t,e,n)=>t&e^~t&n,Zs=(t,e,n)=>t&e^t&n^e&n,Ys=new Uint32Array([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]),Ue=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Re=new Uint32Array(64);let Oi=class extends Vs{constructor(){super(64,32,8,!1),this.A=Ue[0]|0,this.B=Ue[1]|0,this.C=Ue[2]|0,this.D=Ue[3]|0,this.E=Ue[4]|0,this.F=Ue[5]|0,this.G=Ue[6]|0,this.H=Ue[7]|0}get(){const{A:e,B:n,C:r,D:i,E:o,F:s,G:a,H:c}=this;return[e,n,r,i,o,s,a,c]}set(e,n,r,i,o,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)Re[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){const h=Re[l-15],y=Re[l-2],g=me(h,7)^me(h,18)^h>>>3,d=me(y,17)^me(y,19)^y>>>10;Re[l]=d+Re[l-7]+g+Re[l-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){const h=me(a,6)^me(a,11)^me(a,25),y=u+h+Gs(a,c,f)+Ys[l]+Re[l]|0,d=(me(r,2)^me(r,13)^me(r,22))+Zs(r,i,o)|0;u=f,f=c,c=a,a=s+y|0,s=o,o=i,i=r,r=y+d|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,i,o,s,a,c,f,u)}roundClean(){Re.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class Js extends Oi{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const en=Ni(()=>new Oi);Ni(()=>new Js);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ut(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function Se(...t){const e=(i,o)=>s=>i(o(s)),n=Array.from(t).reverse().reduce((i,o)=>i?e(i,o.encode):o.encode,void 0),r=t.reduce((i,o)=>i?e(i,o.decode):o.decode,void 0);return{encode:n,decode:r}}function $e(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(n=>{if(ut(n),n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r})}}}function Ce(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of e)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function tn(t,e="="){if(ut(t),typeof e!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let i of n)if(typeof i!="string")throw new Error(`padding.decode: non-string input=${i}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function Hi(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function Tr(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const i=[],o=Array.from(t);for(o.forEach(s=>{if(ut(s),s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let c=r;c<o.length;c++){const f=o[c],u=e*s+f;if(!Number.isSafeInteger(u)||e*s/e!==s||u-f!==e*s)throw new Error("convertRadix: carry overflow");if(s=u%n,o[c]=Math.floor(u/n),!Number.isSafeInteger(o[c])||o[c]*n+s!==u)throw new Error("convertRadix: carry overflow");if(a)o[c]?a=!1:r=c;else continue}if(i.push(s),a)break}for(let s=0;s<t.length-1&&t[s]===0;s++)i.push(0);return i.reverse()}const Fi=(t,e)=>e?Fi(e,t%e):t,Kt=(t,e)=>t+(e-Fi(t,e));function Fn(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Kt(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Kt(e,n)}`);let i=0,o=0;const s=2**n-1,a=[];for(const c of t){if(ut(c),c>=2**e)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(i=i<<e|c,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)a.push((i>>o-n&s)>>>0);i&=2**o-1}if(i=i<<n-o&s,!r&&o>=e)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&a.push(i>>>0),a}function Qs(t){return ut(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Tr(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Tr(e,t,2**8))}}}function Pe(t,e=!1){if(ut(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Kt(8,t)>32||Kt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Fn(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Fn(n,t,8,e))}}}function Lr(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Xs=Se(Pe(4),$e("0123456789ABCDEF"),Ce("")),ea=Se(Pe(5),$e("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),tn(5),Ce(""));Se(Pe(5),$e("0123456789ABCDEFGHIJKLMNOPQRSTUV"),tn(5),Ce(""));Se(Pe(5),$e("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Ce(""),Hi(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const _e=Se(Pe(6),$e("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),tn(6),Ce("")),ta=Se(Pe(6),$e("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),tn(6),Ce("")),rr=t=>Se(Qs(58),$e(t),Ce("")),zn=rr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");rr("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");rr("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Or=[0,2,3,5,6,7,9,10,11],na={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=zn.encode(r).padStart(Or[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),i=Or.indexOf(r.length),o=zn.decode(r);for(let s=0;s<o.length-i;s++)if(o[s]!==0)throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(o.slice(o.length-i)))}return Uint8Array.from(e)}},Pn=Se($e("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Ce("")),Hr=[996825010,642813549,513874426,1027748829,705979059];function ht(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<Hr.length;r++)(e>>r&1)===1&&(n^=Hr[r]);return n}function Fr(t,e,n=1){const r=t.length;let i=1;for(let o=0;o<r;o++){const s=t.charCodeAt(o);if(s<33||s>126)throw new Error(`Invalid prefix (${t})`);i=ht(i)^s>>5}i=ht(i);for(let o=0;o<r;o++)i=ht(i)^t.charCodeAt(o)&31;for(let o of e)i=ht(i)^o;for(let o=0;o<6;o++)i=ht(i);return i^=n,Pn.encode(Fn([i%2**30],30,5,!1))}function zi(t){const e=t==="bech32"?1:734539939,n=Pe(5),r=n.decode,i=n.encode,o=Lr(r);function s(u,l,h=90){if(typeof u!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof u}`);if(!Array.isArray(l)||l.length&&typeof l[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof l}`);const y=u.length+7+l.length;if(h!==!1&&y>h)throw new TypeError(`Length ${y} exceeds limit ${h}`);return u=u.toLowerCase(),`${u}1${Pn.encode(l)}${Fr(u,l,e)}`}function a(u,l=90){if(typeof u!="string")throw new Error(`bech32.decode input should be string, not ${typeof u}`);if(u.length<8||l!==!1&&u.length>l)throw new TypeError(`Wrong string length: ${u.length} (${u}). Expected (8..${l})`);const h=u.toLowerCase();if(u!==h&&u!==u.toUpperCase())throw new Error("String must be lowercase or uppercase");u=h;const y=u.lastIndexOf("1");if(y===0||y===-1)throw new Error('Letter "1" must be present between prefix and data only');const g=u.slice(0,y),d=u.slice(y+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const p=Pn.decode(d).slice(0,-6),b=Fr(g,p,e);if(!d.endsWith(b))throw new Error(`Invalid checksum in ${u}: expected "${b}"`);return{prefix:g,words:p}}const c=Lr(a);function f(u){const{prefix:l,words:h}=a(u,!1);return{prefix:l,words:h,bytes:r(h)}}return{encode:s,decode:a,decodeToBytes:f,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:o,toWords:i}}const ct=zi("bech32");zi("bech32m");const ra={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},ia=Se(Pe(4),$e("0123456789abcdef"),Ce(""),Hi(t=>{if(typeof t!="string"||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),oa={utf8:ra,hex:ia,base16:Xs,base32:ea,base64:_e,base64url:ta,base58:zn,base58xmr:na};`${Object.keys(oa).join(", ")}`;const Pi=`abandon
ability
able
about
above
absent
absorb
abstract
absurd
abuse
access
accident
account
accuse
achieve
acid
acoustic
acquire
across
act
action
actor
actress
actual
adapt
add
addict
address
adjust
admit
adult
advance
advice
aerobic
affair
afford
afraid
again
age
agent
agree
ahead
aim
air
airport
aisle
alarm
album
alcohol
alert
alien
all
alley
allow
almost
alone
alpha
already
also
alter
always
amateur
amazing
among
amount
amused
analyst
anchor
ancient
anger
angle
angry
animal
ankle
announce
annual
another
answer
antenna
antique
anxiety
any
apart
apology
appear
apple
approve
april
arch
arctic
area
arena
argue
arm
armed
armor
army
around
arrange
arrest
arrive
arrow
art
artefact
artist
artwork
ask
aspect
assault
asset
assist
assume
asthma
athlete
atom
attack
attend
attitude
attract
auction
audit
august
aunt
author
auto
autumn
average
avocado
avoid
awake
aware
away
awesome
awful
awkward
axis
baby
bachelor
bacon
badge
bag
balance
balcony
ball
bamboo
banana
banner
bar
barely
bargain
barrel
base
basic
basket
battle
beach
bean
beauty
because
become
beef
before
begin
behave
behind
believe
below
belt
bench
benefit
best
betray
better
between
beyond
bicycle
bid
bike
bind
biology
bird
birth
bitter
black
blade
blame
blanket
blast
bleak
bless
blind
blood
blossom
blouse
blue
blur
blush
board
boat
body
boil
bomb
bone
bonus
book
boost
border
boring
borrow
boss
bottom
bounce
box
boy
bracket
brain
brand
brass
brave
bread
breeze
brick
bridge
brief
bright
bring
brisk
broccoli
broken
bronze
broom
brother
brown
brush
bubble
buddy
budget
buffalo
build
bulb
bulk
bullet
bundle
bunker
burden
burger
burst
bus
business
busy
butter
buyer
buzz
cabbage
cabin
cable
cactus
cage
cake
call
calm
camera
camp
can
canal
cancel
candy
cannon
canoe
canvas
canyon
capable
capital
captain
car
carbon
card
cargo
carpet
carry
cart
case
cash
casino
castle
casual
cat
catalog
catch
category
cattle
caught
cause
caution
cave
ceiling
celery
cement
census
century
cereal
certain
chair
chalk
champion
change
chaos
chapter
charge
chase
chat
cheap
check
cheese
chef
cherry
chest
chicken
chief
child
chimney
choice
choose
chronic
chuckle
chunk
churn
cigar
cinnamon
circle
citizen
city
civil
claim
clap
clarify
claw
clay
clean
clerk
clever
click
client
cliff
climb
clinic
clip
clock
clog
close
cloth
cloud
clown
club
clump
cluster
clutch
coach
coast
coconut
code
coffee
coil
coin
collect
color
column
combine
come
comfort
comic
common
company
concert
conduct
confirm
congress
connect
consider
control
convince
cook
cool
copper
copy
coral
core
corn
correct
cost
cotton
couch
country
couple
course
cousin
cover
coyote
crack
cradle
craft
cram
crane
crash
crater
crawl
crazy
cream
credit
creek
crew
cricket
crime
crisp
critic
crop
cross
crouch
crowd
crucial
cruel
cruise
crumble
crunch
crush
cry
crystal
cube
culture
cup
cupboard
curious
current
curtain
curve
cushion
custom
cute
cycle
dad
damage
damp
dance
danger
daring
dash
daughter
dawn
day
deal
debate
debris
decade
december
decide
decline
decorate
decrease
deer
defense
define
defy
degree
delay
deliver
demand
demise
denial
dentist
deny
depart
depend
deposit
depth
deputy
derive
describe
desert
design
desk
despair
destroy
detail
detect
develop
device
devote
diagram
dial
diamond
diary
dice
diesel
diet
differ
digital
dignity
dilemma
dinner
dinosaur
direct
dirt
disagree
discover
disease
dish
dismiss
disorder
display
distance
divert
divide
divorce
dizzy
doctor
document
dog
doll
dolphin
domain
donate
donkey
donor
door
dose
double
dove
draft
dragon
drama
drastic
draw
dream
dress
drift
drill
drink
drip
drive
drop
drum
dry
duck
dumb
dune
during
dust
dutch
duty
dwarf
dynamic
eager
eagle
early
earn
earth
easily
east
easy
echo
ecology
economy
edge
edit
educate
effort
egg
eight
either
elbow
elder
electric
elegant
element
elephant
elevator
elite
else
embark
embody
embrace
emerge
emotion
employ
empower
empty
enable
enact
end
endless
endorse
enemy
energy
enforce
engage
engine
enhance
enjoy
enlist
enough
enrich
enroll
ensure
enter
entire
entry
envelope
episode
equal
equip
era
erase
erode
erosion
error
erupt
escape
essay
essence
estate
eternal
ethics
evidence
evil
evoke
evolve
exact
example
excess
exchange
excite
exclude
excuse
execute
exercise
exhaust
exhibit
exile
exist
exit
exotic
expand
expect
expire
explain
expose
express
extend
extra
eye
eyebrow
fabric
face
faculty
fade
faint
faith
fall
false
fame
family
famous
fan
fancy
fantasy
farm
fashion
fat
fatal
father
fatigue
fault
favorite
feature
february
federal
fee
feed
feel
female
fence
festival
fetch
fever
few
fiber
fiction
field
figure
file
film
filter
final
find
fine
finger
finish
fire
firm
first
fiscal
fish
fit
fitness
fix
flag
flame
flash
flat
flavor
flee
flight
flip
float
flock
floor
flower
fluid
flush
fly
foam
focus
fog
foil
fold
follow
food
foot
force
forest
forget
fork
fortune
forum
forward
fossil
foster
found
fox
fragile
frame
frequent
fresh
friend
fringe
frog
front
frost
frown
frozen
fruit
fuel
fun
funny
furnace
fury
future
gadget
gain
galaxy
gallery
game
gap
garage
garbage
garden
garlic
garment
gas
gasp
gate
gather
gauge
gaze
general
genius
genre
gentle
genuine
gesture
ghost
giant
gift
giggle
ginger
giraffe
girl
give
glad
glance
glare
glass
glide
glimpse
globe
gloom
glory
glove
glow
glue
goat
goddess
gold
good
goose
gorilla
gospel
gossip
govern
gown
grab
grace
grain
grant
grape
grass
gravity
great
green
grid
grief
grit
grocery
group
grow
grunt
guard
guess
guide
guilt
guitar
gun
gym
habit
hair
half
hammer
hamster
hand
happy
harbor
hard
harsh
harvest
hat
have
hawk
hazard
head
health
heart
heavy
hedgehog
height
hello
helmet
help
hen
hero
hidden
high
hill
hint
hip
hire
history
hobby
hockey
hold
hole
holiday
hollow
home
honey
hood
hope
horn
horror
horse
hospital
host
hotel
hour
hover
hub
huge
human
humble
humor
hundred
hungry
hunt
hurdle
hurry
hurt
husband
hybrid
ice
icon
idea
identify
idle
ignore
ill
illegal
illness
image
imitate
immense
immune
impact
impose
improve
impulse
inch
include
income
increase
index
indicate
indoor
industry
infant
inflict
inform
inhale
inherit
initial
inject
injury
inmate
inner
innocent
input
inquiry
insane
insect
inside
inspire
install
intact
interest
into
invest
invite
involve
iron
island
isolate
issue
item
ivory
jacket
jaguar
jar
jazz
jealous
jeans
jelly
jewel
job
join
joke
journey
joy
judge
juice
jump
jungle
junior
junk
just
kangaroo
keen
keep
ketchup
key
kick
kid
kidney
kind
kingdom
kiss
kit
kitchen
kite
kitten
kiwi
knee
knife
knock
know
lab
label
labor
ladder
lady
lake
lamp
language
laptop
large
later
latin
laugh
laundry
lava
law
lawn
lawsuit
layer
lazy
leader
leaf
learn
leave
lecture
left
leg
legal
legend
leisure
lemon
lend
length
lens
leopard
lesson
letter
level
liar
liberty
library
license
life
lift
light
like
limb
limit
link
lion
liquid
list
little
live
lizard
load
loan
lobster
local
lock
logic
lonely
long
loop
lottery
loud
lounge
love
loyal
lucky
luggage
lumber
lunar
lunch
luxury
lyrics
machine
mad
magic
magnet
maid
mail
main
major
make
mammal
man
manage
mandate
mango
mansion
manual
maple
marble
march
margin
marine
market
marriage
mask
mass
master
match
material
math
matrix
matter
maximum
maze
meadow
mean
measure
meat
mechanic
medal
media
melody
melt
member
memory
mention
menu
mercy
merge
merit
merry
mesh
message
metal
method
middle
midnight
milk
million
mimic
mind
minimum
minor
minute
miracle
mirror
misery
miss
mistake
mix
mixed
mixture
mobile
model
modify
mom
moment
monitor
monkey
monster
month
moon
moral
more
morning
mosquito
mother
motion
motor
mountain
mouse
move
movie
much
muffin
mule
multiply
muscle
museum
mushroom
music
must
mutual
myself
mystery
myth
naive
name
napkin
narrow
nasty
nation
nature
near
neck
need
negative
neglect
neither
nephew
nerve
nest
net
network
neutral
never
news
next
nice
night
noble
noise
nominee
noodle
normal
north
nose
notable
note
nothing
notice
novel
now
nuclear
number
nurse
nut
oak
obey
object
oblige
obscure
observe
obtain
obvious
occur
ocean
october
odor
off
offer
office
often
oil
okay
old
olive
olympic
omit
once
one
onion
online
only
open
opera
opinion
oppose
option
orange
orbit
orchard
order
ordinary
organ
orient
original
orphan
ostrich
other
outdoor
outer
output
outside
oval
oven
over
own
owner
oxygen
oyster
ozone
pact
paddle
page
pair
palace
palm
panda
panel
panic
panther
paper
parade
parent
park
parrot
party
pass
patch
path
patient
patrol
pattern
pause
pave
payment
peace
peanut
pear
peasant
pelican
pen
penalty
pencil
people
pepper
perfect
permit
person
pet
phone
photo
phrase
physical
piano
picnic
picture
piece
pig
pigeon
pill
pilot
pink
pioneer
pipe
pistol
pitch
pizza
place
planet
plastic
plate
play
please
pledge
pluck
plug
plunge
poem
poet
point
polar
pole
police
pond
pony
pool
popular
portion
position
possible
post
potato
pottery
poverty
powder
power
practice
praise
predict
prefer
prepare
present
pretty
prevent
price
pride
primary
print
priority
prison
private
prize
problem
process
produce
profit
program
project
promote
proof
property
prosper
protect
proud
provide
public
pudding
pull
pulp
pulse
pumpkin
punch
pupil
puppy
purchase
purity
purpose
purse
push
put
puzzle
pyramid
quality
quantum
quarter
question
quick
quit
quiz
quote
rabbit
raccoon
race
rack
radar
radio
rail
rain
raise
rally
ramp
ranch
random
range
rapid
rare
rate
rather
raven
raw
razor
ready
real
reason
rebel
rebuild
recall
receive
recipe
record
recycle
reduce
reflect
reform
refuse
region
regret
regular
reject
relax
release
relief
rely
remain
remember
remind
remove
render
renew
rent
reopen
repair
repeat
replace
report
require
rescue
resemble
resist
resource
response
result
retire
retreat
return
reunion
reveal
review
reward
rhythm
rib
ribbon
rice
rich
ride
ridge
rifle
right
rigid
ring
riot
ripple
risk
ritual
rival
river
road
roast
robot
robust
rocket
romance
roof
rookie
room
rose
rotate
rough
round
route
royal
rubber
rude
rug
rule
run
runway
rural
sad
saddle
sadness
safe
sail
salad
salmon
salon
salt
salute
same
sample
sand
satisfy
satoshi
sauce
sausage
save
say
scale
scan
scare
scatter
scene
scheme
school
science
scissors
scorpion
scout
scrap
screen
script
scrub
sea
search
season
seat
second
secret
section
security
seed
seek
segment
select
sell
seminar
senior
sense
sentence
series
service
session
settle
setup
seven
shadow
shaft
shallow
share
shed
shell
sheriff
shield
shift
shine
ship
shiver
shock
shoe
shoot
shop
short
shoulder
shove
shrimp
shrug
shuffle
shy
sibling
sick
side
siege
sight
sign
silent
silk
silly
silver
similar
simple
since
sing
siren
sister
situate
six
size
skate
sketch
ski
skill
skin
skirt
skull
slab
slam
sleep
slender
slice
slide
slight
slim
slogan
slot
slow
slush
small
smart
smile
smoke
smooth
snack
snake
snap
sniff
snow
soap
soccer
social
sock
soda
soft
solar
soldier
solid
solution
solve
someone
song
soon
sorry
sort
soul
sound
soup
source
south
space
spare
spatial
spawn
speak
special
speed
spell
spend
sphere
spice
spider
spike
spin
spirit
split
spoil
sponsor
spoon
sport
spot
spray
spread
spring
spy
square
squeeze
squirrel
stable
stadium
staff
stage
stairs
stamp
stand
start
state
stay
steak
steel
stem
step
stereo
stick
still
sting
stock
stomach
stone
stool
story
stove
strategy
street
strike
strong
struggle
student
stuff
stumble
style
subject
submit
subway
success
such
sudden
suffer
sugar
suggest
suit
summer
sun
sunny
sunset
super
supply
supreme
sure
surface
surge
surprise
surround
survey
suspect
sustain
swallow
swamp
swap
swarm
swear
sweet
swift
swim
swing
switch
sword
symbol
symptom
syrup
system
table
tackle
tag
tail
talent
talk
tank
tape
target
task
taste
tattoo
taxi
teach
team
tell
ten
tenant
tennis
tent
term
test
text
thank
that
theme
then
theory
there
they
thing
this
thought
three
thrive
throw
thumb
thunder
ticket
tide
tiger
tilt
timber
time
tiny
tip
tired
tissue
title
toast
tobacco
today
toddler
toe
together
toilet
token
tomato
tomorrow
tone
tongue
tonight
tool
tooth
top
topic
topple
torch
tornado
tortoise
toss
total
tourist
toward
tower
town
toy
track
trade
traffic
tragic
train
transfer
trap
trash
travel
tray
treat
tree
trend
trial
tribe
trick
trigger
trim
trip
trophy
trouble
truck
true
truly
trumpet
trust
truth
try
tube
tuition
tumble
tuna
tunnel
turkey
turn
turtle
twelve
twenty
twice
twin
twist
two
type
typical
ugly
umbrella
unable
unaware
uncle
uncover
under
undo
unfair
unfold
unhappy
uniform
unique
unit
universe
unknown
unlock
until
unusual
unveil
update
upgrade
uphold
upon
upper
upset
urban
urge
usage
use
used
useful
useless
usual
utility
vacant
vacuum
vague
valid
valley
valve
van
vanish
vapor
various
vast
vault
vehicle
velvet
vendor
venture
venue
verb
verify
version
very
vessel
veteran
viable
vibrant
vicious
victory
video
view
village
vintage
violin
virtual
virus
visa
visit
visual
vital
vivid
vocal
voice
void
volcano
volume
vote
voyage
wage
wagon
wait
walk
wall
walnut
want
warfare
warm
warrior
wash
wasp
waste
water
wave
way
wealth
weapon
wear
weasel
weather
web
wedding
weekend
weird
welcome
west
wet
whale
what
wheat
wheel
when
where
whip
whisper
wide
width
wife
wild
will
win
window
wine
wing
wink
winner
winter
wire
wisdom
wise
wish
witness
wolf
woman
wonder
wood
wool
word
work
world
worry
worth
wrap
wreck
wrestle
wrist
write
wrong
yard
year
yellow
you
young
youth
zebra
zero
zone
zoo`.split(`
`);function it(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function sa(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function He(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function ir(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");it(t.outputLen),it(t.blockLen)}function mt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ki(t,e){He(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const aa={number:it,bool:sa,bytes:He,hash:ir,exists:mt,output:Ki},ji=aa,kn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const or=t=>t instanceof Uint8Array,We=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),xe=(t,e)=>t<<32-e|t>>>e,ca=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ca)throw new Error("Non little-endian hardware is not supported");const la=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Di(t){if(!or(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=la[t[n]];return e}function ua(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const i=r*2,o=t.slice(i,i+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function qi(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function xt(t){if(typeof t=="string"&&(t=qi(t)),!or(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function $t(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!or(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class Mi{clone(){return this._cloneInto()}}const fa={}.toString;function ha(t,e){if(e!==void 0&&fa.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function sr(t){const e=r=>t().update(xt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function da(t=32){if(kn&&typeof kn.getRandomValues=="function")return kn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class Wi extends Mi{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,ir(e);const r=xt(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(r.length>i?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return mt(this),this.iHash.update(e),this}digestInto(e){mt(this),He(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const jt=(t,e,n)=>new Wi(t,e).update(n).digest();jt.create=(t,e)=>new Wi(t,e);function pa(t,e,n,r){ir(t);const i=ha({dkLen:32,asyncTick:10},r),{c:o,dkLen:s,asyncTick:a}=i;if(it(o),it(s),it(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=xt(e),f=xt(n),u=new Uint8Array(s),l=jt.create(t,c),h=l._cloneInto().update(f);return{c:o,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:h}}function ga(t,e,n,r,i){return t.destroy(),e.destroy(),r&&r.destroy(),i.fill(0),n}function ya(t,e,n,r){const{c:i,dkLen:o,DK:s,PRF:a,PRFSalt:c}=pa(t,e,n,r);let f;const u=new Uint8Array(4),l=We(u),h=new Uint8Array(a.outputLen);for(let y=1,g=0;g<o;y++,g+=a.outputLen){const d=s.subarray(g,g+a.outputLen);l.setInt32(0,y,!1),(f=c._cloneInto(f)).update(u).digestInto(h),d.set(h.subarray(0,d.length));for(let p=1;p<i;p++){a._cloneInto(f).update(h).digestInto(h);for(let b=0;b<d.length;b++)d[b]^=h[b]}}return ga(a,c,s,f,h)}function ba(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,f=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+f,a,r)}class ar extends Mi{constructor(e,n,r,i){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=We(this.buffer)}update(e){mt(this);const{view:n,buffer:r,blockLen:i}=this;e=xt(e);const o=e.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const c=We(e);for(;i<=o-s;s+=i)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mt(this),Ki(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:o}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let l=s;l<i;l++)n[l]=0;ba(r,i-8,BigInt(this.length*8),o),this.process(r,0);const a=We(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%n&&e.buffer.set(r),e}}const wa=(t,e,n)=>t&e^~t&n,ma=(t,e,n)=>t&e^t&n^e&n,xa=new Uint32Array([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]),Ne=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Te=new Uint32Array(64);class Ea extends ar{constructor(){super(64,32,8,!1),this.A=Ne[0]|0,this.B=Ne[1]|0,this.C=Ne[2]|0,this.D=Ne[3]|0,this.E=Ne[4]|0,this.F=Ne[5]|0,this.G=Ne[6]|0,this.H=Ne[7]|0}get(){const{A:e,B:n,C:r,D:i,E:o,F:s,G:a,H:c}=this;return[e,n,r,i,o,s,a,c]}set(e,n,r,i,o,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let l=0;l<16;l++,n+=4)Te[l]=e.getUint32(n,!1);for(let l=16;l<64;l++){const h=Te[l-15],y=Te[l-2],g=xe(h,7)^xe(h,18)^h>>>3,d=xe(y,17)^xe(y,19)^y>>>10;Te[l]=d+Te[l-7]+g+Te[l-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){const h=xe(a,6)^xe(a,11)^xe(a,25),y=u+h+wa(a,c,f)+xa[l]+Te[l]|0,d=(xe(r,2)^xe(r,13)^xe(r,22))+ma(r,i,o)|0;u=f,f=c,c=a,a=s+y|0,s=o,o=i,i=r,r=y+d|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,i,o,s,a,c,f,u)}roundClean(){Te.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const nn=sr(()=>new Ea),Ct=BigInt(2**32-1),Kn=BigInt(32);function Vi(t,e=!1){return e?{h:Number(t&Ct),l:Number(t>>Kn&Ct)}:{h:Number(t>>Kn&Ct)|0,l:Number(t&Ct)|0}}function va(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=Vi(t[i],e);[n[i],r[i]]=[o,s]}return[n,r]}const ka=(t,e)=>BigInt(t>>>0)<<Kn|BigInt(e>>>0),_a=(t,e,n)=>t>>>n,Aa=(t,e,n)=>t<<32-n|e>>>n,Sa=(t,e,n)=>t>>>n|e<<32-n,$a=(t,e,n)=>t<<32-n|e>>>n,Ca=(t,e,n)=>t<<64-n|e>>>n-32,Ba=(t,e,n)=>t>>>n-32|e<<64-n,Ia=(t,e)=>e,Ua=(t,e)=>t,Ra=(t,e,n)=>t<<n|e>>>32-n,Na=(t,e,n)=>e<<n|t>>>32-n,Ta=(t,e,n)=>e<<n-32|t>>>64-n,La=(t,e,n)=>t<<n-32|e>>>64-n;function Oa(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:i|0}}const Ha=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Fa=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,za=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Pa=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,Ka=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),ja=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,Da={fromBig:Vi,split:va,toBig:ka,shrSH:_a,shrSL:Aa,rotrSH:Sa,rotrSL:$a,rotrBH:Ca,rotrBL:Ba,rotr32H:Ia,rotr32L:Ua,rotlSH:Ra,rotlSL:Na,rotlBH:Ta,rotlBL:La,add:Oa,add3L:Ha,add3H:Fa,add4L:za,add4H:Pa,add5H:ja,add5L:Ka},K=Da,[qa,Ma]=(()=>K.split(["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(t=>BigInt(t))))(),Le=new Uint32Array(80),Oe=new Uint32Array(80);class Wa extends ar{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:n,Bh:r,Bl:i,Ch:o,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:y,Gl:g,Hh:d,Hl:p}=this;return[e,n,r,i,o,s,a,c,f,u,l,h,y,g,d,p]}set(e,n,r,i,o,s,a,c,f,u,l,h,y,g,d,p){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=y|0,this.Gl=g|0,this.Hh=d|0,this.Hl=p|0}process(e,n){for(let v=0;v<16;v++,n+=4)Le[v]=e.getUint32(n),Oe[v]=e.getUint32(n+=4);for(let v=16;v<80;v++){const B=Le[v-15]|0,$=Oe[v-15]|0,_=K.rotrSH(B,$,1)^K.rotrSH(B,$,8)^K.shrSH(B,$,7),S=K.rotrSL(B,$,1)^K.rotrSL(B,$,8)^K.shrSL(B,$,7),U=Le[v-2]|0,R=Oe[v-2]|0,T=K.rotrSH(U,R,19)^K.rotrBH(U,R,61)^K.shrSH(U,R,6),w=K.rotrSL(U,R,19)^K.rotrBL(U,R,61)^K.shrSL(U,R,6),x=K.add4L(S,w,Oe[v-7],Oe[v-16]),k=K.add4H(x,_,T,Le[v-7],Le[v-16]);Le[v]=k|0,Oe[v]=x|0}let{Ah:r,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:y,Fl:g,Gh:d,Gl:p,Hh:b,Hl:A}=this;for(let v=0;v<80;v++){const B=K.rotrSH(l,h,14)^K.rotrSH(l,h,18)^K.rotrBH(l,h,41),$=K.rotrSL(l,h,14)^K.rotrSL(l,h,18)^K.rotrBL(l,h,41),_=l&y^~l&d,S=h&g^~h&p,U=K.add5L(A,$,S,Ma[v],Oe[v]),R=K.add5H(U,b,B,_,qa[v],Le[v]),T=U|0,w=K.rotrSH(r,i,28)^K.rotrBH(r,i,34)^K.rotrBH(r,i,39),x=K.rotrSL(r,i,28)^K.rotrBL(r,i,34)^K.rotrBL(r,i,39),k=r&o^r&a^o&a,N=i&s^i&c^s&c;b=d|0,A=p|0,d=y|0,p=g|0,y=l|0,g=h|0,{h:l,l:h}=K.add(f|0,u|0,R|0,T|0),f=a|0,u=c|0,a=o|0,c=s|0,o=r|0,s=i|0;const m=K.add3L(T,x,N);r=K.add3H(m,R,w,k),i=m|0}({h:r,l:i}=K.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:o,l:s}=K.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=K.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=K.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=K.add(this.Eh|0,this.El|0,l|0,h|0),{h:y,l:g}=K.add(this.Fh|0,this.Fl|0,y|0,g|0),{h:d,l:p}=K.add(this.Gh|0,this.Gl|0,d|0,p|0),{h:b,l:A}=K.add(this.Hh|0,this.Hl|0,b|0,A|0),this.set(r,i,o,s,a,c,f,u,l,h,y,g,d,p,b,A)}roundClean(){Le.fill(0),Oe.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const jn=sr(()=>new Wa);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function rn(...t){const e=(i,o)=>s=>i(o(s)),n=Array.from(t).reverse().reduce((i,o)=>i?e(i,o.encode):o.encode,void 0),r=t.reduce((i,o)=>i?e(i,o.decode):o.decode,void 0);return{encode:n,decode:r}}function cr(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(n=>{if(n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r})}}}function lr(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of e)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function Va(t,e="="){if(typeof e!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let i of n)if(typeof i!="string")throw new Error(`padding.decode: non-string input=${i}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function zr(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const i=[],o=Array.from(t);for(o.forEach(s=>{if(s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let c=r;c<o.length;c++){const f=o[c],u=e*s+f;if(!Number.isSafeInteger(u)||e*s/e!==s||u-f!==e*s)throw new Error("convertRadix: carry overflow");s=u%n;const l=Math.floor(u/n);if(o[c]=l,!Number.isSafeInteger(l)||l*n+s!==u)throw new Error("convertRadix: carry overflow");if(a)l?a=!1:r=c;else continue}if(i.push(s),a)break}for(let s=0;s<t.length-1&&t[s]===0;s++)i.push(0);return i.reverse()}const Gi=(t,e)=>e?Gi(e,t%e):t,Dt=(t,e)=>t+(e-Gi(t,e));function Dn(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Dt(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Dt(e,n)}`);let i=0,o=0;const s=2**n-1,a=[];for(const c of t){if(c>=2**e)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(i=i<<e|c,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)a.push((i>>o-n&s)>>>0);i&=2**o-1}if(i=i<<n-o&s,!r&&o>=e)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&a.push(i>>>0),a}function Zi(t){return{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return zr(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(zr(e,t,2**8))}}}function Yi(t,e=!1){if(t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Dt(8,t)>32||Dt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Dn(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Dn(n,t,8,e))}}}function Pr(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}function Ji(t,e){if(typeof e!="function")throw new Error("checksum fn should be function");return{encode(n){if(!(n instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=e(n).slice(0,t),i=new Uint8Array(n.length+t);return i.set(n),i.set(r,n.length),i},decode(n){if(!(n instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-t),i=e(r).slice(0,t),o=n.slice(-t);for(let s=0;s<t;s++)if(i[s]!==o[s])throw new Error("Invalid checksum");return r}}}const Bt={alphabet:cr,chain:rn,checksum:Ji,radix:Zi,radix2:Yi,join:lr,padding:Va},Ga=t=>rn(Zi(58),cr(t),lr("")),Za=Ga("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Ya=t=>rn(Ji(4,e=>t(t(e))),Za),qn=rn(cr("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),lr("")),Kr=[996825010,642813549,513874426,1027748829,705979059];function dt(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<Kr.length;r++)(e>>r&1)===1&&(n^=Kr[r]);return n}function jr(t,e,n=1){const r=t.length;let i=1;for(let o=0;o<r;o++){const s=t.charCodeAt(o);if(s<33||s>126)throw new Error(`Invalid prefix (${t})`);i=dt(i)^s>>5}i=dt(i);for(let o=0;o<r;o++)i=dt(i)^t.charCodeAt(o)&31;for(let o of e)i=dt(i)^o;for(let o=0;o<6;o++)i=dt(i);return i^=n,qn.encode(Dn([i%2**30],30,5,!1))}function Ja(t){const e=t==="bech32"?1:734539939,n=Yi(5),r=n.decode,i=n.encode,o=Pr(r);function s(u,l,h=90){if(typeof u!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof u}`);if(!Array.isArray(l)||l.length&&typeof l[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof l}`);const y=u.length+7+l.length;if(h!==!1&&y>h)throw new TypeError(`Length ${y} exceeds limit ${h}`);const g=u.toLowerCase(),d=jr(g,l,e);return`${g}1${qn.encode(l)}${d}`}function a(u,l=90){if(typeof u!="string")throw new Error(`bech32.decode input should be string, not ${typeof u}`);if(u.length<8||l!==!1&&u.length>l)throw new TypeError(`Wrong string length: ${u.length} (${u}). Expected (8..${l})`);const h=u.toLowerCase();if(u!==h&&u!==u.toUpperCase())throw new Error("String must be lowercase or uppercase");u=h;const y=u.lastIndexOf("1");if(y===0||y===-1)throw new Error('Letter "1" must be present between prefix and data only');const g=u.slice(0,y),d=u.slice(y+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const p=qn.decode(d).slice(0,-6),b=jr(g,p,e);if(!d.endsWith(b))throw new Error(`Invalid checksum in ${u}: expected "${b}"`);return{prefix:g,words:p}}const c=Pr(a);function f(u){const{prefix:l,words:h}=a(u,!1);return{prefix:l,words:h,bytes:r(h)}}return{encode:s,decode:a,decodeToBytes:f,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:o,toWords:i}}const Dr=Ja("bech32"),Qa=t=>t[0]==="あいこくしん";function Qi(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function Xi(t){const e=Qi(t),n=e.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:n}}function eo(t){ji.bytes(t,16,20,24,28,32)}function Xa(t,e=128){if(ji.number(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return nc(da(e/8),t)}const ec=t=>{const e=8-t.length/4;return new Uint8Array([nn(t)[0]>>e<<e])};function to(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Worlist: expected array of 2048 strings");return t.forEach(e=>{if(typeof e!="string")throw new Error(`Wordlist: non-string element: ${e}`)}),Bt.chain(Bt.checksum(1,ec),Bt.radix2(11,!0),Bt.alphabet(t))}function tc(t,e){const{words:n}=Xi(t),r=to(e).decode(n);return eo(r),r}function nc(t,e){return eo(t),to(e).encode(t).join(Qa(e)?" ":" ")}function rc(t,e){try{tc(t,e)}catch{return!1}return!0}const ic=t=>Qi(`mnemonic${t}`);function oc(t,e=""){return ya(jn,Xi(t).nfkd,ic(e),{c:2048,dkLen:64})}const sc=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),no=Uint8Array.from({length:16},(t,e)=>e),ac=no.map(t=>(9*t+5)%16);let ur=[no],fr=[ac];for(let t=0;t<4;t++)for(let e of[ur,fr])e.push(e[t].map(n=>sc[n]));const ro=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>new Uint8Array(t)),cc=ur.map((t,e)=>t.map(n=>ro[e][n])),lc=fr.map((t,e)=>t.map(n=>ro[e][n])),uc=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),fc=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),It=(t,e)=>t<<e|t>>>32-e;function qr(t,e,n,r){return t===0?e^n^r:t===1?e&n|~e&r:t===2?(e|~n)^r:t===3?e&r|n&~r:e^(n|~r)}const Ut=new Uint32Array(16);class hc extends ar{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:n,h2:r,h3:i,h4:o}=this;return[e,n,r,i,o]}set(e,n,r,i,o){this.h0=e|0,this.h1=n|0,this.h2=r|0,this.h3=i|0,this.h4=o|0}process(e,n){for(let y=0;y<16;y++,n+=4)Ut[y]=e.getUint32(n,!0);let r=this.h0|0,i=r,o=this.h1|0,s=o,a=this.h2|0,c=a,f=this.h3|0,u=f,l=this.h4|0,h=l;for(let y=0;y<5;y++){const g=4-y,d=uc[y],p=fc[y],b=ur[y],A=fr[y],v=cc[y],B=lc[y];for(let $=0;$<16;$++){const _=It(r+qr(y,o,a,f)+Ut[b[$]]+d,v[$])+l|0;r=l,l=f,f=It(a,10)|0,a=o,o=_}for(let $=0;$<16;$++){const _=It(i+qr(g,s,c,u)+Ut[A[$]]+p,B[$])+h|0;i=h,h=u,u=It(c,10)|0,c=s,s=_}}this.set(this.h1+a+u|0,this.h2+f+h|0,this.h3+l+i|0,this.h4+r+s|0,this.h0+o+c|0)}roundClean(){Ut.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const dc=sr(()=>new hc),Rt=ne.ProjectivePoint,_n=Ya(nn);function Mr(t){return BigInt(`0x${Di(t)}`)}function pc(t){return ua(t.toString(16).padStart(64,"0"))}const gc=qi("Bitcoin seed"),An={private:76066276,public:76067358},Sn=2147483648,yc=t=>dc(nn(t)),bc=t=>We(t).getUint32(0,!1),Nt=t=>{if(!Number.isSafeInteger(t)||t<0||t>2**32-1)throw new Error(`Invalid number=${t}. Should be from 0 to 2 ** 32 - 1`);const e=new Uint8Array(4);return We(e).setUint32(0,t,!1),e};class je{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return bc(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const e=this.privateKey;if(!e)throw new Error("No private key");return _n.encode(this.serialize(this.versions.private,$t(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return _n.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,n=An){if(He(e),8*e.length<128||8*e.length>512)throw new Error(`HDKey: wrong seed length=${e.length}. Should be between 128 and 512 bits; 256 bits is advised)`);const r=jt(jn,gc,e);return new je({versions:n,chainCode:r.slice(32),privateKey:r.slice(0,32)})}static fromExtendedKey(e,n=An){const r=_n.decode(e),i=We(r),o=i.getUint32(0,!1),s={versions:n,depth:r[4],parentFingerprint:i.getUint32(5,!1),index:i.getUint32(9,!1),chainCode:r.slice(13,45)},a=r.slice(45),c=a[0]===0;if(o!==n[c?"private":"public"])throw new Error("Version mismatch");return c?new je({...s,privateKey:a.slice(1)}):new je({...s,publicKey:a})}static fromJSON(e){return je.fromExtendedKey(e.xpriv)}constructor(e){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!e||typeof e!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=e.versions||An,this.depth=e.depth||0,this.chainCode=e.chainCode,this.index=e.index||0,this.parentFingerprint=e.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(e.publicKey&&e.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(e.privateKey){if(!ne.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey=typeof e.privateKey=="bigint"?e.privateKey:Mr(e.privateKey),this.privKeyBytes=pc(this.privKey),this.pubKey=ne.getPublicKey(e.privateKey,!0)}else if(e.publicKey)this.pubKey=Rt.fromHex(e.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=yc(this.pubKey)}derive(e){if(!/^[mM]'?/.test(e))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(e))return this;const n=e.replace(/^[mM]'?\//,"").split("/");let r=this;for(const i of n){const o=/^(\d+)('?)$/.exec(i);if(!o||o.length!==3)throw new Error(`Invalid child index: ${i}`);let s=+o[1];if(!Number.isSafeInteger(s)||s>=Sn)throw new Error("Invalid index");o[2]==="'"&&(s+=Sn),r=r.deriveChild(s)}return r}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=Nt(e);if(e>=Sn){const a=this.privateKey;if(!a)throw new Error("Could not derive hardened child key");n=$t(new Uint8Array([0]),a,n)}else n=$t(this.pubKey,n);const r=jt(jn,this.chainCode,n),i=Mr(r.slice(0,32)),o=r.slice(32);if(!ne.utils.isValidPrivateKey(i))throw new Error("Tweak bigger than curve order");const s={versions:this.versions,chainCode:o,depth:this.depth+1,parentFingerprint:this.fingerprint,index:e};try{if(this.privateKey){const a=Y(this.privKey+i,ne.CURVE.n);if(!ne.utils.isValidPrivateKey(a))throw new Error("The tweak was out of range or the resulted private key is invalid");s.privateKey=a}else{const a=Rt.fromHex(this.pubKey).add(Rt.fromPrivateKey(i));if(a.equals(Rt.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");s.publicKey=a.toRawBytes(!0)}return new je(s)}catch{return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return He(e,32),ne.sign(e,this.privKey).toCompactRawBytes()}verify(e,n){if(He(e,32),He(n,64),!this.publicKey)throw new Error("No publicKey set!");let r;try{r=ne.Signature.fromCompact(n)}catch{return!1}return ne.verify(r,e,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(e,n){if(!this.chainCode)throw new Error("No chainCode set");return He(n,33),$t(Nt(e),new Uint8Array([this.depth]),Nt(this.parentFingerprint),Nt(this.index),this.chainCode,n)}}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const wc=t=>t instanceof Uint8Array,Ee=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),mc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!mc)throw new Error("Non little-endian hardware is not supported");function hr(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Mn(t){if(typeof t=="string"&&(t=hr(t)),!wc(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}const xc=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function Ec(t,e){if(e!==void 0&&(typeof e!="object"||!xc(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}function vc(t,e){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");if(typeof e=="number"&&t.length!==e)throw new Error(`Uint8Array length ${e} expected`)}function Wn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function kc(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function io(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function _c(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");Wn(t.outputLen),Wn(t.blockLen)}function Ac(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Sc(t,e){io(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const le={number:Wn,bool:kc,bytes:io,hash:_c,exists:Ac,output:Sc},Q=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class $c{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Mn(e),vc(e,32);const n=Q(e,0),r=Q(e,2),i=Q(e,4),o=Q(e,6),s=Q(e,8),a=Q(e,10),c=Q(e,12),f=Q(e,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let u=0;u<8;u++)this.pad[u]=Q(e,16+2*u)}process(e,n,r=!1){const i=r?0:2048,{h:o,r:s}=this,a=s[0],c=s[1],f=s[2],u=s[3],l=s[4],h=s[5],y=s[6],g=s[7],d=s[8],p=s[9],b=Q(e,n+0),A=Q(e,n+2),v=Q(e,n+4),B=Q(e,n+6),$=Q(e,n+8),_=Q(e,n+10),S=Q(e,n+12),U=Q(e,n+14);let R=o[0]+(b&8191),T=o[1]+((b>>>13|A<<3)&8191),w=o[2]+((A>>>10|v<<6)&8191),x=o[3]+((v>>>7|B<<9)&8191),k=o[4]+((B>>>4|$<<12)&8191),N=o[5]+($>>>1&8191),m=o[6]+(($>>>14|_<<2)&8191),E=o[7]+((_>>>11|S<<5)&8191),C=o[8]+((S>>>8|U<<8)&8191),H=o[9]+(U>>>5|i),I=0,P=I+R*a+T*(5*p)+w*(5*d)+x*(5*g)+k*(5*y);I=P>>>13,P&=8191,P+=N*(5*h)+m*(5*l)+E*(5*u)+C*(5*f)+H*(5*c),I+=P>>>13,P&=8191;let L=I+R*c+T*a+w*(5*p)+x*(5*d)+k*(5*g);I=L>>>13,L&=8191,L+=N*(5*y)+m*(5*h)+E*(5*l)+C*(5*u)+H*(5*f),I+=L>>>13,L&=8191;let z=I+R*f+T*c+w*a+x*(5*p)+k*(5*d);I=z>>>13,z&=8191,z+=N*(5*g)+m*(5*y)+E*(5*h)+C*(5*l)+H*(5*u),I+=z>>>13,z&=8191;let j=I+R*u+T*f+w*c+x*a+k*(5*p);I=j>>>13,j&=8191,j+=N*(5*d)+m*(5*g)+E*(5*y)+C*(5*h)+H*(5*l),I+=j>>>13,j&=8191;let D=I+R*l+T*u+w*f+x*c+k*a;I=D>>>13,D&=8191,D+=N*(5*p)+m*(5*d)+E*(5*g)+C*(5*y)+H*(5*h),I+=D>>>13,D&=8191;let ee=I+R*h+T*l+w*u+x*f+k*c;I=ee>>>13,ee&=8191,ee+=N*a+m*(5*p)+E*(5*d)+C*(5*g)+H*(5*y),I+=ee>>>13,ee&=8191;let te=I+R*y+T*h+w*l+x*u+k*f;I=te>>>13,te&=8191,te+=N*c+m*a+E*(5*p)+C*(5*d)+H*(5*g),I+=te>>>13,te&=8191;let Z=I+R*g+T*y+w*h+x*l+k*u;I=Z>>>13,Z&=8191,Z+=N*f+m*c+E*a+C*(5*p)+H*(5*d),I+=Z>>>13,Z&=8191;let ce=I+R*d+T*g+w*y+x*h+k*l;I=ce>>>13,ce&=8191,ce+=N*u+m*f+E*c+C*a+H*(5*p),I+=ce>>>13,ce&=8191;let ie=I+R*p+T*d+w*g+x*y+k*h;I=ie>>>13,ie&=8191,ie+=N*l+m*u+E*f+C*c+H*a,I+=ie>>>13,ie&=8191,I=(I<<2)+I|0,I=I+P|0,P=I&8191,I=I>>>13,L+=I,o[0]=P,o[1]=L,o[2]=z,o[3]=j,o[4]=D,o[5]=ee,o[6]=te,o[7]=Z,o[8]=ce,o[9]=ie}finalize(){const{h:e,pad:n}=this,r=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=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 a=1;a<10;a++)r[a]=e[a]+i,i=r[a]>>>13,r[a]&=8191;r[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)r[a]&=o;o=~o;for(let a=0;a<10;a++)e[a]=e[a]&o|r[a];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 s=e[0]+n[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+n[a]|0)+(s>>>16)|0,e[a]=s&65535}update(e){le.exists(this);const{buffer:n,blockLen:r}=this;e=Mn(e);const i=e.length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){for(;r<=i-o;o+=r)this.process(e,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){le.exists(this),le.output(e,this),this.finished=!0;const{buffer:n,h:r}=this;let{pos:i}=this;if(i){for(n[i++]=1;i<16;i++)n[i]=0;this.process(n,0,!0)}this.finalize();let o=0;for(let s=0;s<8;s++)e[o++]=r[s]>>>0,e[o++]=r[s]>>>8;return e}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}}function Cc(t){const e=(r,i)=>t(i).update(Mn(r)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}Cc(t=>new $c(t));const Bc=hr("expand 16-byte k"),Ic=hr("expand 32-byte k"),Uc=Ee(Bc),Rc=Ee(Ic),Wr=t=>!(t.byteOffset%4),Nc=t=>{const{core:e,rounds:n,counterRight:r,counterLen:i,allow128bitKeys:o,extendNonceFn:s,blockLen:a}=Ec({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},t);le.number(i),le.number(n),le.number(a),le.bool(r),le.bool(o);const c=a/4;if(a%4!==0)throw new Error("Salsa/ChaCha: blockLen must be aligned to 4 bytes");return(f,u,l,h,y=0)=>{if(le.bytes(f),le.bytes(u),le.bytes(l),h||(h=new Uint8Array(l.length)),le.bytes(h),le.number(y),y<0||y>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(h.length<l.length)throw new Error(`Salsa/ChaCha: output (${h.length}) is shorter than data (${l.length})`);const g=[];let d,p;if(f.length===32)d=f,p=Rc;else if(f.length===16&&o)d=new Uint8Array(32),d.set(f),d.set(f,16),p=Uc,g.push(d);else throw new Error(`Salsa/ChaCha: invalid 32-byte key, got length=${f.length}`);if(s){if(u.length<=16)throw new Error("Salsa/ChaCha: extended nonce must be bigger than 16 bytes");d=s(p,d,u.subarray(0,16),new Uint8Array(32)),g.push(d),u=u.subarray(16)}const b=16-i;if(u.length!==b)throw new Error(`Salsa/ChaCha: nonce must be ${b} or 16 bytes`);if(b!==12){const R=new Uint8Array(12);R.set(u,r?0:12-u.length),g.push(u=R)}const A=new Uint8Array(a),v=Ee(A),B=Ee(d),$=Ee(u),_=Wr(l)&&Ee(l),S=Wr(h)&&Ee(h);g.push(v);const U=l.length;for(let R=0,T=y;R<U;T++){if(e(p,B,$,v,T,n),T>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");const w=Math.min(a,U-R);if(w===a&&S&&_){const x=R/4;if(R%4!==0)throw new Error("Salsa/ChaCha: invalid block position");for(let k=0;k<c;k++)S[x+k]=_[x+k]^v[k];R+=a;continue}for(let x=0;x<w;x++)h[R+x]=l[R+x]^A[x];R+=w}for(let R=0;R<g.length;R++)g[R].fill(0);return h}},F=(t,e)=>t<<e|t>>>32-e;function Tc(t,e,n,r,i,o=20){let s=t[0],a=t[1],c=t[2],f=t[3],u=e[0],l=e[1],h=e[2],y=e[3],g=e[4],d=e[5],p=e[6],b=e[7],A=i,v=n[0],B=n[1],$=n[2],_=s,S=a,U=c,R=f,T=u,w=l,x=h,k=y,N=g,m=d,E=p,C=b,H=A,I=v,P=B,L=$;for(let j=0;j<o;j+=2)_=_+T|0,H=F(H^_,16),N=N+H|0,T=F(T^N,12),_=_+T|0,H=F(H^_,8),N=N+H|0,T=F(T^N,7),S=S+w|0,I=F(I^S,16),m=m+I|0,w=F(w^m,12),S=S+w|0,I=F(I^S,8),m=m+I|0,w=F(w^m,7),U=U+x|0,P=F(P^U,16),E=E+P|0,x=F(x^E,12),U=U+x|0,P=F(P^U,8),E=E+P|0,x=F(x^E,7),R=R+k|0,L=F(L^R,16),C=C+L|0,k=F(k^C,12),R=R+k|0,L=F(L^R,8),C=C+L|0,k=F(k^C,7),_=_+w|0,L=F(L^_,16),E=E+L|0,w=F(w^E,12),_=_+w|0,L=F(L^_,8),E=E+L|0,w=F(w^E,7),S=S+x|0,H=F(H^S,16),C=C+H|0,x=F(x^C,12),S=S+x|0,H=F(H^S,8),C=C+H|0,x=F(x^C,7),U=U+k|0,I=F(I^U,16),N=N+I|0,k=F(k^N,12),U=U+k|0,I=F(I^U,8),N=N+I|0,k=F(k^N,7),R=R+T|0,P=F(P^R,16),m=m+P|0,T=F(T^m,12),R=R+T|0,P=F(P^R,8),m=m+P|0,T=F(T^m,7);let z=0;r[z++]=s+_|0,r[z++]=a+S|0,r[z++]=c+U|0,r[z++]=f+R|0,r[z++]=u+T|0,r[z++]=l+w|0,r[z++]=h+x|0,r[z++]=y+k|0,r[z++]=g+N|0,r[z++]=d+m|0,r[z++]=p+E|0,r[z++]=b+C|0,r[z++]=A+H|0,r[z++]=v+I|0,r[z++]=B+P|0,r[z++]=$+L|0}function Lc(t,e,n,r){const i=Ee(e),o=Ee(n),s=Ee(r);let a=t[0],c=t[1],f=t[2],u=t[3],l=i[0],h=i[1],y=i[2],g=i[3],d=i[4],p=i[5],b=i[6],A=i[7],v=o[0],B=o[1],$=o[2],_=o[3];for(let S=0;S<20;S+=2)a=a+l|0,v=F(v^a,16),d=d+v|0,l=F(l^d,12),a=a+l|0,v=F(v^a,8),d=d+v|0,l=F(l^d,7),c=c+h|0,B=F(B^c,16),p=p+B|0,h=F(h^p,12),c=c+h|0,B=F(B^c,8),p=p+B|0,h=F(h^p,7),f=f+y|0,$=F($^f,16),b=b+$|0,y=F(y^b,12),f=f+y|0,$=F($^f,8),b=b+$|0,y=F(y^b,7),u=u+g|0,_=F(_^u,16),A=A+_|0,g=F(g^A,12),u=u+g|0,_=F(_^u,8),A=A+_|0,g=F(g^A,7),a=a+h|0,_=F(_^a,16),b=b+_|0,h=F(h^b,12),a=a+h|0,_=F(_^a,8),b=b+_|0,h=F(h^b,7),c=c+y|0,v=F(v^c,16),A=A+v|0,y=F(y^A,12),c=c+y|0,v=F(v^c,8),A=A+v|0,y=F(y^A,7),f=f+g|0,B=F(B^f,16),d=d+B|0,g=F(g^d,12),f=f+g|0,B=F(B^f,8),d=d+B|0,g=F(g^d,7),u=u+l|0,$=F($^u,16),p=p+$|0,l=F(l^p,12),u=u+l|0,$=F($^u,8),p=p+$|0,l=F(l^p,7);return s[0]=a,s[1]=c,s[2]=f,s[3]=u,s[4]=v,s[5]=B,s[6]=$,s[7]=_,r}const oo=Nc({core:Tc,counterRight:!1,counterLen:8,extendNonceFn:Lc,allow128bitKeys:!1});var Oc=Object.defineProperty,G=(t,e)=>{for(var n in e)Oc(t,n,{get:e[n],enumerable:!0})};function so(t){return ye(At.getPublicKey(t))}var Hc={};G(Hc,{MessageNode:()=>ao,MessageQueue:()=>co,insertEventIntoAscendingList:()=>Pc,insertEventIntoDescendingList:()=>zc,normalizeURL:()=>Fc,utf8Decoder:()=>ve,utf8Encoder:()=>pe});var ve=new TextDecoder("utf-8"),pe=new TextEncoder;function Fc(t){let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}function zc(t,e){var s;let n=0,r=t.length-1,i,o=n;if(r<0)o=0;else if(e.created_at<t[r].created_at)o=r+1;else if(e.created_at>=t[n].created_at)o=n;else for(;;){if(r<=n+1){o=r;break}if(i=Math.floor(n+(r-n)/2),t[i].created_at>e.created_at)n=i;else if(t[i].created_at<e.created_at)r=i;else{o=i;break}}return((s=t[o])==null?void 0:s.id)!==e.id?[...t.slice(0,o),e,...t.slice(o)]:t}function Pc(t,e){var s;let n=0,r=t.length-1,i,o=n;if(r<0)o=0;else if(e.created_at>t[r].created_at)o=r+1;else if(e.created_at<=t[n].created_at)o=n;else for(;;){if(r<=n+1){o=r;break}if(i=Math.floor(n+(r-n)/2),t[i].created_at<e.created_at)n=i;else if(t[i].created_at>e.created_at)r=i;else{o=i;break}}return((s=t[o])==null?void 0:s.id)!==e.id?[...t.slice(0,o),e,...t.slice(o)]:t}var ao=class{constructor(t){O(this,"_value");O(this,"_next");this._value=t,this._next=null}get value(){return this._value}set value(t){this._value=t}get next(){return this._next}set next(t){this._next=t}},co=class{constructor(){O(this,"_first");O(this,"_last");O(this,"_size");this._first=null,this._last=null,this._size=0}get first(){return this._first}set first(t){this._first=t}get last(){return this._last}set last(t){this._last=t}get size(){return this._size}set size(t){this._size=t}enqueue(t){const e=new ao(t);return this._size===0||!this._last?(this._first=e,this._last=e):(this._last.next=e,this._last=e),this._size++,!0}dequeue(){if(this._size===0||!this._first)return null;let t=this._first;return this._first=t.next,t.next=null,this._size--,t.value}};function Kc(t=255){return{kind:t,content:"",tags:[],created_at:0}}function Ye(t,e){let n=t;return n.pubkey=so(e),n.id=on(n),n.sig=qc(n,e),n}function jc(t){if(!dr(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function on(t){let e=en(pe.encode(jc(t)));return ye(e)}var Dc=t=>t instanceof Object;function dr(t){if(!Dc(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}function sn(t){try{return At.verify(t.sig,on(t),t.pubkey)}catch{return!1}}function qc(t,e){return ye(At.sign(on(t),e))}function lo(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1&&!t.ids.some(n=>e.id.startsWith(n))||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1&&!t.authors.some(n=>e.pubkey.startsWith(n)))return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),i=t[`#${r}`];if(i&&!e.tags.find(([o,s])=>o===n.slice(1)&&i.indexOf(s)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function Mc(t,e){for(let n=0;n<t.length;n++)if(lo(t[n],e))return!0;return!1}var Wc={};G(Wc,{getHex64:()=>an,getInt:()=>uo,getSubscriptionId:()=>fo,matchEventId:()=>Vc,matchEventKind:()=>Zc,matchEventPubkey:()=>Gc});function an(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,i=t.slice(r).indexOf('"')+r+1;return t.slice(i,i+64)}function uo(t,e){let n=e.length,r=t.indexOf(`"${e}":`)+n+3,i=t.slice(r),o=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,o),10)}function fo(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,i=t.slice(r+1,80).indexOf('"');if(i===-1)return null;let o=r+1+i;return t.slice(r+1,o)}function Vc(t,e){return e===an(t,"id")}function Gc(t,e){return e===an(t,"pubkey")}function Zc(t,e){return e===uo(t,"kind")}var Vr=()=>({connect:[],disconnect:[],error:[],notice:[],auth:[]});function Yc(t,e={}){let{listTimeout:n=3e3,getTimeout:r=3e3,countTimeout:i=3e3}=e;var o,s={},a=Vr(),c={},f={},u;async function l(){return u||(u=new Promise((b,A)=>{try{o=new WebSocket(t)}catch(_){A(_)}o.onopen=()=>{a.connect.forEach(_=>_()),b()},o.onerror=()=>{u=void 0,a.error.forEach(_=>_()),A()},o.onclose=async()=>{u=void 0,a.disconnect.forEach(_=>_())};let v=new co,B;o.onmessage=_=>{v.enqueue(_.data),B||(B=setInterval($,0))};function $(){var U,R,T;if(v.size===0){clearInterval(B),B=null;return}var _=v.dequeue();if(!_)return;let S=fo(_);if(S){let w=s[S];if(w&&w.alreadyHaveEvent&&w.alreadyHaveEvent(an(_,"id"),t))return}try{let w=JSON.parse(_);switch(w[0]){case"EVENT":{let m=w[1],E=w[2];dr(E)&&s[m]&&(s[m].skipVerification||sn(E))&&Mc(s[m].filters,E)&&(s[m],(((U=c[m])==null?void 0:U.event)||[]).forEach(C=>C(E)));return}case"COUNT":let x=w[1],k=w[2];s[x]&&(((R=c[x])==null?void 0:R.count)||[]).forEach(m=>m(k));return;case"EOSE":{let m=w[1];m in c&&(c[m].eose.forEach(E=>E()),c[m].eose=[]);return}case"OK":{let m=w[1],E=w[2],C=w[3]||"";if(m in f){let{resolve:H,reject:I}=f[m];E?H(null):I(new Error(C))}return}case"NOTICE":let N=w[1];a.notice.forEach(m=>m(N));return;case"AUTH":{let m=w[1];(T=a.auth)==null||T.forEach(E=>E(m));return}}}catch{return}}}),u)}function h(){return(o==null?void 0:o.readyState)===1}async function y(){h()||await l()}async function g(b){let A=JSON.stringify(b);if(!(!h()&&(await new Promise(v=>setTimeout(v,1e3)),!h())))try{o.send(A)}catch(v){console.log(v)}}const d=(b,{verb:A="REQ",skipVerification:v=!1,alreadyHaveEvent:B=null,id:$=Math.random().toString().slice(2)}={})=>{let _=$;return s[_]={id:_,filters:b,skipVerification:v,alreadyHaveEvent:B},g([A,_,...b]),{sub:(S,U={})=>d(S||b,{skipVerification:U.skipVerification||v,alreadyHaveEvent:U.alreadyHaveEvent||B,id:_}),unsub:()=>{delete s[_],delete c[_],g(["CLOSE",_])},on:(S,U)=>{c[_]=c[_]||{event:[],count:[],eose:[]},c[_][S].push(U)},off:(S,U)=>{let R=c[_],T=R[S].indexOf(U);T>=0&&R[S].splice(T,1)}}};function p(b,A){return new Promise((v,B)=>{if(!b.id){B(new Error(`event ${b} has no id`));return}let $=b.id;g([A,b]),f[$]={resolve:v,reject:B}})}return{url:t,sub:d,on:(b,A)=>{a[b].push(A),b==="connect"&&(o==null?void 0:o.readyState)===1&&A()},off:(b,A)=>{let v=a[b].indexOf(A);v!==-1&&a[b].splice(v,1)},list:(b,A)=>new Promise(v=>{let B=d(b,A),$=[],_=setTimeout(()=>{B.unsub(),v($)},n);B.on("eose",()=>{B.unsub(),clearTimeout(_),v($)}),B.on("event",S=>{$.push(S)})}),get:(b,A)=>new Promise(v=>{let B=d([b],A),$=setTimeout(()=>{B.unsub(),v(null)},r);B.on("event",_=>{B.unsub(),clearTimeout($),v(_)})}),count:b=>new Promise(A=>{let v=d(b,{...d,verb:"COUNT"}),B=setTimeout(()=>{v.unsub(),A(null)},i);v.on("count",$=>{v.unsub(),clearTimeout(B),A($)})}),async publish(b){await p(b,"EVENT")},async auth(b){await p(b,"AUTH")},connect:y,close(){a=Vr(),c={},f={},(o==null?void 0:o.readyState)===WebSocket.OPEN&&o.close()},get status(){return(o==null?void 0:o.readyState)??3}}}var V={};G(V,{BECH32_REGEX:()=>po,decode:()=>cn,naddrEncode:()=>nl,neventEncode:()=>tl,noteEncode:()=>Xc,nprofileEncode:()=>el,npubEncode:()=>Qc,nrelayEncode:()=>rl,nsecEncode:()=>Jc});var ho=5e3,po=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function cn(t){var i,o,s,a,c,f,u;let{prefix:e,words:n}=ct.decode(t,ho),r=new Uint8Array(ct.fromWords(n));switch(e){case"nprofile":{let l=Tt(r);if(!((i=l[0])!=null&&i[0]))throw new Error("missing TLV 0 for nprofile");if(l[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:ye(l[0][0]),relays:l[1]?l[1].map(h=>ve.decode(h)):[]}}}case"nevent":{let l=Tt(r);if(!((o=l[0])!=null&&o[0]))throw new Error("missing TLV 0 for nevent");if(l[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(l[2]&&l[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");return{type:"nevent",data:{id:ye(l[0][0]),relays:l[1]?l[1].map(h=>ve.decode(h)):[],author:(s=l[2])!=null&&s[0]?ye(l[2][0]):void 0}}}case"naddr":{let l=Tt(r);if(!((a=l[0])!=null&&a[0]))throw new Error("missing TLV 0 for naddr");if(!((c=l[2])!=null&&c[0]))throw new Error("missing TLV 2 for naddr");if(l[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!((f=l[3])!=null&&f[0]))throw new Error("missing TLV 3 for naddr");if(l[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:ve.decode(l[0][0]),pubkey:ye(l[2][0]),kind:parseInt(ye(l[3][0]),16),relays:l[1]?l[1].map(h=>ve.decode(h)):[]}}}case"nrelay":{let l=Tt(r);if(!((u=l[0])!=null&&u[0]))throw new Error("missing TLV 0 for nrelay");return{type:"nrelay",data:ve.decode(l[0][0])}}case"nsec":case"npub":case"note":return{type:e,data:ye(r)};default:throw new Error(`unknown prefix ${e}`)}}function Tt(t){let e={},n=t;for(;n.length>0;){let r=n[0],i=n[1];if(!i)throw new Error(`malformed TLV ${r}`);let o=n.slice(2,2+i);if(n=n.slice(2+i),o.length<i)throw new Error(`not enough data to read on TLV ${r}`);e[r]=e[r]||[],e[r].push(o)}return e}function Jc(t){return pr("nsec",t)}function Qc(t){return pr("npub",t)}function Xc(t){return pr("note",t)}function St(t,e){let n=ct.toWords(e);return ct.encode(t,n,ho)}function pr(t,e){let n=at(e);return St(t,n)}function el(t){let e=ln({0:[at(t.pubkey)],1:(t.relays||[]).map(n=>pe.encode(n))});return St("nprofile",e)}function tl(t){let e=ln({0:[at(t.id)],1:(t.relays||[]).map(n=>pe.encode(n)),2:t.author?[at(t.author)]:[]});return St("nevent",e)}function nl(t){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,t.kind,!1);let n=ln({0:[pe.encode(t.identifier)],1:(t.relays||[]).map(r=>pe.encode(r)),2:[at(t.pubkey)],3:[new Uint8Array(e)]});return St("naddr",n)}function rl(t){let e=ln({0:[pe.encode(t)]});return St("nrelay",e)}function ln(t){let e=[];return Object.entries(t).forEach(([n,r])=>{r.forEach(i=>{let o=new Uint8Array(i.length+2);o.set([parseInt(n)],0),o.set([i.length],1),o.set(i,2),e.push(o)})}),Ps(...e)}var il={};G(il,{decrypt:()=>sl,encrypt:()=>ol});typeof crypto<"u"&&!crypto.subtle&&crypto.webcrypto&&(crypto.subtle=crypto.webcrypto.subtle);async function ol(t,e,n){const r=ne.getSharedSecret(t,"02"+e),i=go(r);let o=Uint8Array.from(Ti(16)),s=pe.encode(n),a=await crypto.subtle.importKey("raw",i,{name:"AES-CBC"},!1,["encrypt"]),c=await crypto.subtle.encrypt({name:"AES-CBC",iv:o},a,s),f=_e.encode(new Uint8Array(c)),u=_e.encode(new Uint8Array(o.buffer));return`${f}?iv=${u}`}async function sl(t,e,n){let[r,i]=n.split("?iv="),o=ne.getSharedSecret(t,"02"+e),s=go(o),a=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["decrypt"]),c=_e.decode(r),f=_e.decode(i),u=await crypto.subtle.decrypt({name:"AES-CBC",iv:f},a,c);return ve.decode(u)}function go(t){return t.slice(1,33)}var yo={};G(yo,{NIP05_REGEX:()=>bo,queryProfile:()=>ll,searchDomain:()=>cl,useFetchImplementation:()=>al});var bo=/^(?:([\w.+-]+)@)?([\w.-]+)$/,un;try{un=fetch}catch{}function al(t){un=t}async function cl(t,e=""){try{return(await(await un(`https://${t}/.well-known/nostr.json?name=${e}`)).json()).names}catch{return{}}}async function ll(t){const e=t.match(bo);if(!e)return null;const[n,r="_",i]=e;try{const o=await un(`https://${i}/.well-known/nostr.json?name=${r}`),{names:s,relays:a}=ul(await o.json()),c=s[r];return c?{pubkey:c,relays:a==null?void 0:a[c]}:null}catch{return null}}function ul(t){const e={names:{}};for(const[n,r]of Object.entries(t.names))typeof n=="string"&&typeof r=="string"&&(e.names[n]=r);if(t.relays){e.relays={};for(const[n,r]of Object.entries(t.relays))typeof n=="string"&&Array.isArray(r)&&(e.relays[n]=r.filter(i=>typeof i=="string"))}return e}var fl={};G(fl,{generateSeedWords:()=>dl,privateKeyFromSeedWords:()=>hl,validateWords:()=>pl});function hl(t,e){let r=je.fromMasterSeed(oc(t,e)).derive("m/44'/1237'/0'/0/0").privateKey;if(!r)throw new Error("could not derive private key");return ye(r)}function dl(){return Xa(Pi)}function pl(t){return rc(t,Pi)}var gl={};G(gl,{parse:()=>yl});function yl(t){const e={reply:void 0,root:void 0,mentions:[],profiles:[]},n=[];for(const r of t.tags)r[0]==="e"&&r[1]&&n.push(r),r[0]==="p"&&r[1]&&e.profiles.push({pubkey:r[1],relays:r[2]?[r[2]]:[]});for(let r=0;r<n.length;r++){const i=n[r],[o,s,a,c]=i,f={id:s,relays:a?[a]:[]},u=r===0,l=r===n.length-1;if(c==="root"){e.root=f;continue}if(c==="reply"){e.reply=f;continue}if(c==="mention"){e.mentions.push(f);continue}if(u){e.root=f;continue}if(l){e.reply=f;continue}e.mentions.push(f)}return e}var bl={};G(bl,{getPow:()=>wl});function wl(t){return ml(at(t))}function ml(t){let e,n,r;for(n=0,e=0;n<t.length&&(r=xl(t[n]),e+=r,r===8);n++);return e}function xl(t){let e=0;if(t===0)return 8;for(;t>>=1;)e++;return 7-e}var El={};G(El,{finishRepostEvent:()=>vl,getRepostedEvent:()=>kl,getRepostedEventPointer:()=>wo});function vl(t,e,n,r){return Ye({kind:6,tags:[...t.tags??[],["e",e.id,n],["p",e.pubkey]],content:t.content===""?"":JSON.stringify(e),created_at:t.created_at},r)}function wo(t){if(t.kind!==6)return;let e,n;for(let r=t.tags.length-1;r>=0&&(e===void 0||n===void 0);r--){const i=t.tags[r];i.length>=2&&(i[0]==="e"&&e===void 0?e=i:i[0]==="p"&&n===void 0&&(n=i))}if(e!==void 0)return{id:e[1],relays:[e[2],n==null?void 0:n[2]].filter(r=>typeof r=="string"),author:n==null?void 0:n[1]}}function kl(t,{skipVerification:e}={}){const n=wo(t);if(n===void 0||t.content==="")return;let r;try{r=JSON.parse(t.content)}catch{return}if(r.id===n.id&&!(!e&&!sn(r)))return r}var _l={};G(_l,{NOSTR_URI_REGEX:()=>fn,parse:()=>Sl,test:()=>Al});var fn=new RegExp(`nostr:(${po.source})`);function Al(t){return typeof t=="string"&&new RegExp(`^${fn.source}$`).test(t)}function Sl(t){const e=t.match(new RegExp(`^${fn.source}$`));if(!e)throw new Error(`Invalid Nostr URI: ${t}`);return{uri:e[0],value:e[1],decoded:cn(e[1])}}var $l={};G($l,{finishReactionEvent:()=>Cl,getReactedEventPointer:()=>Bl});function Cl(t,e,n){const r=e.tags.filter(i=>i.length>=2&&(i[0]==="e"||i[0]==="p"));return Ye({...t,kind:7,tags:[...t.tags??[],...r,["e",e.id],["p",e.pubkey]],content:t.content??"+"},n)}function Bl(t){if(t.kind!==7)return;let e,n;for(let r=t.tags.length-1;r>=0&&(e===void 0||n===void 0);r--){const i=t.tags[r];i.length>=2&&(i[0]==="e"&&e===void 0?e=i:i[0]==="p"&&n===void 0&&(n=i))}if(!(e===void 0||n===void 0))return{id:e[1],relays:[e[2],n[2]].filter(r=>r!==void 0),author:n[1]}}var Il={};G(Il,{createDelegation:()=>Ul,getDelegator:()=>Rl});function Ul(t,e){let n=[];(e.kind||-1)>=0&&n.push(`kind=${e.kind}`),e.until&&n.push(`created_at<${e.until}`),e.since&&n.push(`created_at>${e.since}`);let r=n.join("&");if(r==="")throw new Error("refusing to create a delegation without any conditions");let i=en(pe.encode(`nostr:delegation:${e.pubkey}:${r}`)),o=ye(At.sign(i,t));return{from:so(t),to:e.pubkey,cond:r,sig:o}}function Rl(t){let e=t.tags.find(a=>a[0]==="delegation"&&a.length>=4);if(!e)return null;let n=e[1],r=e[2],i=e[3],o=r.split("&");for(let a=0;a<o.length;a++){let[c,f,u]=o[a].split(/\b/);if(!(c==="kind"&&f==="="&&t.kind===parseInt(u))){if(c==="created_at"&&f==="<"&&t.created_at<parseInt(u))continue;if(c==="created_at"&&f===">"&&t.created_at>parseInt(u))continue;return null}}let s=en(pe.encode(`nostr:delegation:${t.pubkey}:${r}`));return At.verify(i,s,n)?n:null}var Nl={};G(Nl,{matchAll:()=>Tl,regex:()=>gr,replaceAll:()=>Ll});var gr=()=>new RegExp(`\\b${fn.source}\\b`,"g");function*Tl(t){const e=t.matchAll(gr());for(const n of e)try{const[r,i]=n;yield{uri:r,value:i,decoded:cn(i),start:n.index,end:n.index+r.length}}catch{}}function Ll(t,e){return t.replaceAll(gr(),(n,r)=>e({uri:n,value:r,decoded:cn(r)}))}var Ol={};G(Ol,{channelCreateEvent:()=>Hl,channelHideMessageEvent:()=>Pl,channelMessageEvent:()=>zl,channelMetadataEvent:()=>Fl,channelMuteUserEvent:()=>Kl});var Hl=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return Ye({kind:40,tags:[...t.tags??[]],content:n,created_at:t.created_at},e)},Fl=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return Ye({kind:41,tags:[["e",t.channel_create_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},zl=(t,e)=>{const n=[["e",t.channel_create_event_id,t.relay_url,"root"]];return t.reply_to_channel_message_event_id&&n.push(["e",t.reply_to_channel_message_event_id,t.relay_url,"reply"]),Ye({kind:42,tags:[...n,...t.tags??[]],content:t.content,created_at:t.created_at},e)},Pl=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return Ye({kind:43,tags:[["e",t.channel_message_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},Kl=(t,e)=>{let n;if(typeof t.content=="object")n=JSON.stringify(t.content);else if(typeof t.content=="string")n=t.content;else return;return Ye({kind:44,tags:[["p",t.pubkey_to_mute],...t.tags??[]],content:n,created_at:t.created_at},e)},jl={};G(jl,{useFetchImplementation:()=>Dl,validateGithub:()=>ql});var yr;try{yr=fetch}catch{}function Dl(t){yr=t}async function ql(t,e,n){try{return await(await yr(`https://gist.github.com/${e}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${t}`}catch{return!1}}var Ml={};G(Ml,{authenticate:()=>Wl});var Wl=async({challenge:t,relay:e,sign:n})=>{const r={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e.url],["challenge",t]],content:""};return e.auth(await n(r))},Vl={};G(Vl,{decrypt:()=>Yl,encrypt:()=>Zl,getSharedSecret:()=>Gl});var Gl=(t,e)=>en(ne.getSharedSecret(t,"02"+e).subarray(1,33));function Zl(t,e,n=1){if(n!==1)throw new Error("NIP44: unknown encryption version");const r=Ti(24),i=pe.encode(e),o=oo(t,r,i),s=new Uint8Array(25+o.length);return s.set([n],0),s.set(r,1),s.set(o,25),_e.encode(s)}function Yl(t,e){let n=_e.decode(e);if(n[0]!==1)throw new Error(`NIP44: unknown encryption version: ${n[0]}`);const r=n.slice(1,25),i=n.slice(25),o=oo(t,r,i);return ve.decode(o)}var mo={};G(mo,{getZapEndpoint:()=>Ql,makeZapReceipt:()=>tu,makeZapRequest:()=>Xl,useFetchImplementation:()=>Jl,validateZapRequest:()=>eu});var br;try{br=fetch}catch{}function Jl(t){br=t}async function Ql(t){try{let e="",{lud06:n,lud16:r}=JSON.parse(t.content);if(n){let{words:s}=ct.decode(n,1e3),a=ct.fromWords(s);e=ve.decode(a)}else if(r){let[s,a]=r.split("@");e=`https://${a}/.well-known/lnurlp/${s}`}else return null;let o=await(await br(e)).json();if(o.allowsNostr&&o.nostrPubkey)return o.callback}catch{}return null}function Xl({profile:t,event:e,amount:n,relays:r,comment:i=""}){if(!n)throw new Error("amount not given");if(!t)throw new Error("profile not given");let o={kind:9734,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",t],["amount",n.toString()],["relays",...r]]};return e&&o.tags.push(["e",e]),o}function eu(t){let e;try{e=JSON.parse(t)}catch{return"Invalid zap request JSON."}if(!dr(e))return"Zap request is not a valid Nostr event.";if(!sn(e))return"Invalid signature on zap request.";let n=e.tags.find(([o,s])=>o==="p"&&s);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=e.tags.find(([o,s])=>o==="e"&&s);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":e.tags.find(([o,s])=>o==="relays"&&s)?null:"Zap request doesn't have a 'relays' tag."}function tu({zapRequest:t,preimage:e,bolt11:n,paidAt:r}){let o=JSON.parse(t).tags.filter(([a])=>a==="e"||a==="p"||a==="a"),s={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...o,["bolt11",n],["description",t]]};return e&&s.tags.push(["preimage",e]),s}var nu={};G(nu,{getToken:()=>ru,unpackEventFromToken:()=>Eo,validateEvent:()=>vo,validateToken:()=>iu});var xo="Nostr ";async function ru(t,e,n,r=!1){if(!t||!e)throw new Error("Missing loginUrl or httpMethod");const i=Kc(27235);i.tags=[["u",t],["method",e]],i.created_at=Math.round(new Date().getTime()/1e3);const o=await n(i);return(r?xo:"")+_e.encode(pe.encode(JSON.stringify(o)))}async function iu(t,e,n){const r=await Eo(t).catch(o=>{throw o});return await vo(r,e,n).catch(o=>{throw o})}async function Eo(t){if(!t)throw new Error("Missing token");t=t.replace(xo,"");const e=ve.decode(_e.decode(t));if(!e||e.length===0||!e.startsWith("{"))throw new Error("Invalid token");return JSON.parse(e)}async function vo(t,e,n){if(!t)throw new Error("Invalid nostr event");if(!sn(t))throw new Error("Invalid nostr event, signature invalid");if(t.kind!==27235)throw new Error("Invalid nostr event, kind invalid");if(!t.created_at)throw new Error("Invalid nostr event, created_at invalid");if(Math.round(new Date().getTime()/1e3)-t.created_at>60)throw new Error("Invalid nostr event, expired");const r=t.tags.find(o=>o[0]==="u");if((r==null?void 0:r.length)!==1&&(r==null?void 0:r[1])!==e)throw new Error("Invalid nostr event, url tag invalid");const i=t.tags.find(o=>o[0]==="method");if((i==null?void 0:i.length)!==1&&(i==null?void 0:i[1].toLowerCase())!==n.toLowerCase())throw new Error("Invalid nostr event, method tag invalid");return!0}var ou={};(function(t){/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(t,"__esModule",{value:!0}),t.bytes=t.stringToBytes=t.str=t.bytesToString=t.hex=t.utf8=t.bech32m=t.bech32=t.base58check=t.base58xmr=t.base58xrp=t.base58flickr=t.base58=t.base64url=t.base64=t.base32crockford=t.base32hex=t.base32=t.base16=t.utils=t.assertNumber=void 0;function e(w){if(!Number.isSafeInteger(w))throw new Error(`Wrong integer: ${w}`)}t.assertNumber=e;function n(...w){const x=(m,E)=>C=>m(E(C)),k=Array.from(w).reverse().reduce((m,E)=>m?x(m,E.encode):E.encode,void 0),N=w.reduce((m,E)=>m?x(m,E.decode):E.decode,void 0);return{encode:k,decode:N}}function r(w){return{encode:x=>{if(!Array.isArray(x)||x.length&&typeof x[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return x.map(k=>{if(e(k),k<0||k>=w.length)throw new Error(`Digit index outside alphabet: ${k} (alphabet: ${w.length})`);return w[k]})},decode:x=>{if(!Array.isArray(x)||x.length&&typeof x[0]!="string")throw new Error("alphabet.decode input should be array of strings");return x.map(k=>{if(typeof k!="string")throw new Error(`alphabet.decode: not string element=${k}`);const N=w.indexOf(k);if(N===-1)throw new Error(`Unknown letter: "${k}". Allowed: ${w}`);return N})}}}function i(w=""){if(typeof w!="string")throw new Error("join separator should be string");return{encode:x=>{if(!Array.isArray(x)||x.length&&typeof x[0]!="string")throw new Error("join.encode input should be array of strings");for(let k of x)if(typeof k!="string")throw new Error(`join.encode: non-string input=${k}`);return x.join(w)},decode:x=>{if(typeof x!="string")throw new Error("join.decode input should be string");return x.split(w)}}}function o(w,x="="){if(e(w),typeof x!="string")throw new Error("padding chr should be string");return{encode(k){if(!Array.isArray(k)||k.length&&typeof k[0]!="string")throw new Error("padding.encode input should be array of strings");for(let N of k)if(typeof N!="string")throw new Error(`padding.encode: non-string input=${N}`);for(;k.length*w%8;)k.push(x);return k},decode(k){if(!Array.isArray(k)||k.length&&typeof k[0]!="string")throw new Error("padding.encode input should be array of strings");for(let m of k)if(typeof m!="string")throw new Error(`padding.decode: non-string input=${m}`);let N=k.length;if(N*w%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;N>0&&k[N-1]===x;N--)if(!((N-1)*w%8))throw new Error("Invalid padding: string has too much padding");return k.slice(0,N)}}}function s(w){if(typeof w!="function")throw new Error("normalize fn should be function");return{encode:x=>x,decode:x=>w(x)}}function a(w,x,k){if(x<2)throw new Error(`convertRadix: wrong from=${x}, base cannot be less than 2`);if(k<2)throw new Error(`convertRadix: wrong to=${k}, base cannot be less than 2`);if(!Array.isArray(w))throw new Error("convertRadix: data should be array");if(!w.length)return[];let N=0;const m=[],E=Array.from(w);for(E.forEach(C=>{if(e(C),C<0||C>=x)throw new Error(`Wrong integer: ${C}`)});;){let C=0,H=!0;for(let I=N;I<E.length;I++){const P=E[I],L=x*C+P;if(!Number.isSafeInteger(L)||x*C/x!==C||L-P!==x*C)throw new Error("convertRadix: carry overflow");if(C=L%k,E[I]=Math.floor(L/k),!Number.isSafeInteger(E[I])||E[I]*k+C!==L)throw new Error("convertRadix: carry overflow");if(H)E[I]?H=!1:N=I;else continue}if(m.push(C),H)break}for(let C=0;C<w.length-1&&w[C]===0;C++)m.push(0);return m.reverse()}const c=(w,x)=>x?c(x,w%x):w,f=(w,x)=>w+(x-c(w,x));function u(w,x,k,N){if(!Array.isArray(w))throw new Error("convertRadix2: data should be array");if(x<=0||x>32)throw new Error(`convertRadix2: wrong from=${x}`);if(k<=0||k>32)throw new Error(`convertRadix2: wrong to=${k}`);if(f(x,k)>32)throw new Error(`convertRadix2: carry overflow from=${x} to=${k} carryBits=${f(x,k)}`);let m=0,E=0;const C=2**k-1,H=[];for(const I of w){if(e(I),I>=2**x)throw new Error(`convertRadix2: invalid data word=${I} from=${x}`);if(m=m<<x|I,E+x>32)throw new Error(`convertRadix2: carry overflow pos=${E} from=${x}`);for(E+=x;E>=k;E-=k)H.push((m>>E-k&C)>>>0);m&=2**E-1}if(m=m<<k-E&C,!N&&E>=x)throw new Error("Excess padding");if(!N&&m)throw new Error(`Non-zero padding: ${m}`);return N&&E>0&&H.push(m>>>0),H}function l(w){return e(w),{encode:x=>{if(!(x instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(Array.from(x),2**8,w)},decode:x=>{if(!Array.isArray(x)||x.length&&typeof x[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(a(x,w,2**8))}}}function h(w,x=!1){if(e(w),w<=0||w>32)throw new Error("radix2: bits should be in (0..32]");if(f(8,w)>32||f(w,8)>32)throw new Error("radix2: carry overflow");return{encode:k=>{if(!(k instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(k),8,w,!x)},decode:k=>{if(!Array.isArray(k)||k.length&&typeof k[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(k,w,8,x))}}}function y(w){if(typeof w!="function")throw new Error("unsafeWrapper fn should be function");return function(...x){try{return w.apply(null,x)}catch{}}}function g(w,x){if(e(w),typeof x!="function")throw new Error("checksum fn should be function");return{encode(k){if(!(k instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const N=x(k).slice(0,w),m=new Uint8Array(k.length+w);return m.set(k),m.set(N,k.length),m},decode(k){if(!(k instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const N=k.slice(0,-w),m=x(N).slice(0,w),E=k.slice(-w);for(let C=0;C<w;C++)if(m[C]!==E[C])throw new Error("Invalid checksum");return N}}}t.utils={alphabet:r,chain:n,checksum:g,radix:l,radix2:h,join:i,padding:o},t.base16=n(h(4),r("0123456789ABCDEF"),i("")),t.base32=n(h(5),r("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),o(5),i("")),t.base32hex=n(h(5),r("0123456789ABCDEFGHIJKLMNOPQRSTUV"),o(5),i("")),t.base32crockford=n(h(5),r("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),i(""),s(w=>w.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),t.base64=n(h(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),o(6),i("")),t.base64url=n(h(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),o(6),i(""));const d=w=>n(l(58),r(w),i(""));t.base58=d("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.base58flickr=d("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),t.base58xrp=d("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const p=[0,2,3,5,6,7,9,10,11];t.base58xmr={encode(w){let x="";for(let k=0;k<w.length;k+=8){const N=w.subarray(k,k+8);x+=t.base58.encode(N).padStart(p[N.length],"1")}return x},decode(w){let x=[];for(let k=0;k<w.length;k+=11){const N=w.slice(k,k+11),m=p.indexOf(N.length),E=t.base58.decode(N);for(let C=0;C<E.length-m;C++)if(E[C]!==0)throw new Error("base58xmr: wrong padding");x=x.concat(Array.from(E.slice(E.length-m)))}return Uint8Array.from(x)}};const b=w=>n(g(4,x=>w(w(x))),t.base58);t.base58check=b;const A=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),i("")),v=[996825010,642813549,513874426,1027748829,705979059];function B(w){const x=w>>25;let k=(w&33554431)<<5;for(let N=0;N<v.length;N++)(x>>N&1)===1&&(k^=v[N]);return k}function $(w,x,k=1){const N=w.length;let m=1;for(let E=0;E<N;E++){const C=w.charCodeAt(E);if(C<33||C>126)throw new Error(`Invalid prefix (${w})`);m=B(m)^C>>5}m=B(m);for(let E=0;E<N;E++)m=B(m)^w.charCodeAt(E)&31;for(let E of x)m=B(m)^E;for(let E=0;E<6;E++)m=B(m);return m^=k,A.encode(u([m%2**30],30,5,!1))}function _(w){const x=w==="bech32"?1:734539939,k=h(5),N=k.decode,m=k.encode,E=y(N);function C(L,z,j=90){if(typeof L!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof L}`);if(!Array.isArray(z)||z.length&&typeof z[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof z}`);const D=L.length+7+z.length;if(j!==!1&&D>j)throw new TypeError(`Length ${D} exceeds limit ${j}`);return L=L.toLowerCase(),`${L}1${A.encode(z)}${$(L,z,x)}`}function H(L,z=90){if(typeof L!="string")throw new Error(`bech32.decode input should be string, not ${typeof L}`);if(L.length<8||z!==!1&&L.length>z)throw new TypeError(`Wrong string length: ${L.length} (${L}). Expected (8..${z})`);const j=L.toLowerCase();if(L!==j&&L!==L.toUpperCase())throw new Error("String must be lowercase or uppercase");L=j;const D=L.lastIndexOf("1");if(D===0||D===-1)throw new Error('Letter "1" must be present between prefix and data only');const ee=L.slice(0,D),te=L.slice(D+1);if(te.length<6)throw new Error("Data must be at least 6 characters long");const Z=A.decode(te).slice(0,-6),ce=$(ee,Z,x);if(!te.endsWith(ce))throw new Error(`Invalid checksum in ${L}: expected "${ce}"`);return{prefix:ee,words:Z}}const I=y(H);function P(L){const{prefix:z,words:j}=H(L,!1);return{prefix:z,words:j,bytes:N(j)}}return{encode:C,decode:H,decodeToBytes:P,decodeUnsafe:I,fromWords:N,fromWordsUnsafe:E,toWords:m}}t.bech32=_("bech32"),t.bech32m=_("bech32m"),t.utf8={encode:w=>new TextDecoder().decode(w),decode:w=>new TextEncoder().encode(w)},t.hex=n(h(4),r("0123456789abcdef"),i(""),s(w=>{if(typeof w!="string"||w.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof w} with length ${w.length}`);return w.toLowerCase()}));const S={utf8:t.utf8,hex:t.hex,base16:t.base16,base32:t.base32,base64:t.base64,base64url:t.base64url,base58:t.base58,base58xmr:t.base58xmr},U=`Invalid encoding type. Available types: ${Object.keys(S).join(", ")}`,R=(w,x)=>{if(typeof w!="string"||!S.hasOwnProperty(w))throw new TypeError(U);if(!(x instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return S[w].encode(x)};t.bytesToString=R,t.str=t.bytesToString;const T=(w,x)=>{if(!S.hasOwnProperty(w))throw new TypeError(U);if(typeof x!="string")throw new TypeError("stringToBytes() expects string");return S[w].decode(x)};t.stringToBytes=T,t.bytes=t.stringToBytes})(ou);BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12);BigInt("2100000000000000000");BigInt(1e11);const Gr={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let t=0,e=Object.keys(Gr);t<e.length;t++)e[t],Gr[e[t]].toString();function su(t,e){return t.created_at>e.created_at?t:e}var au=["wss://nos.lol","wss://relay.nostr.band","wss://relay.f7z.io","wss://relay.damus.io","wss://nostr.mom","wss://no.str.cr"],cu=class extends lt{constructor(e){super();O(this,"ndk");O(this,"zappedEvent");O(this,"zappedUser");this.ndk=e.ndk,this.zappedEvent=e.zappedEvent,this.zappedUser=e.zappedUser||this.ndk.getUser({hexpubkey:this.zappedEvent.pubkey})}async getZapEndpoint(){let e,n,r,i;if(this.zappedEvent){const a=(await this.zappedEvent.getMatchingTags("zap"))[0];if(a)switch(a[2]){case"lud06":e=a[1];break;case"lud16":n=a[1];break;default:throw new Error(`Unknown zap tag ${a}`)}}if(this.zappedUser&&!e&&!n&&(this.zappedUser.profile||await this.zappedUser.fetchProfile(),e=(this.zappedUser.profile||{}).lud06,n=(this.zappedUser.profile||{}).lud16),n){const[a,c]=n.split("@");r=`https://${c}/.well-known/lnurlp/${a}`}else if(e){const{words:a}=Dr.decode(e,1e3),c=Dr.fromWords(a);r=new TextDecoder("utf-8").decode(c)}if(!r)throw new Error("No zap endpoint found");const s=await(await fetch(r)).json();return s!=null&&s.allowsNostr&&(s!=null&&s.nostrPubkey||s!=null&&s.nostrPubKey)&&(i=s.callback),i}async createZapRequest(e,n,r,i){const o=await this.getZapEndpoint();if(!o)throw new Error("No zap endpoint found");if(!this.zappedEvent)throw new Error("No zapped event found");const s=mo.makeZapRequest({profile:this.zappedUser.hexpubkey(),event:null,amount:e,comment:n||"",relays:i??this.relays()});if(this.zappedEvent){const l=this.zappedEvent.tagReference();l&&s.tags.push(l)}s.tags.push(["lnurl",o]);const a=new Ae(this.ndk,s);r&&(a.tags=a.tags.concat(r)),await a.sign();const c=await a.toNostrEvent();return(await(await fetch(`${o}?`+new URLSearchParams({amount:e.toString(),nostr:JSON.stringify(c)}))).json()).pr}relays(){var n,r;let e=[];return(r=(n=this.ndk)==null?void 0:n.pool)!=null&&r.relays&&(e=this.ndk.pool.urls()),e.length||(e=au),e}};function lu(t,e=[]){const n=/(@|nostr:)(npub|nprofile|note|nevent)[a-zA-Z0-9]+/g;return t=t.replace(n,r=>{try{const i=r.split(/(@|nostr:)/)[2],{type:o,data:s}=V.decode(i);let a;switch(o){case"npub":a=["p",s];break;case"nprofile":a=["p",s.pubkey];break;case"nevent":a=["e",s.id];break;case"note":a=["e",s];break;default:return r}return e.find(c=>c[0]===a[0]&&c[1]===a[1])||e.push(a),`nostr:${i}`}catch{return r}}),{content:t,tags:e}}function uu(){if(this.kind===void 0)throw new Error("Kind not set");return this.kind>=1e4&&this.kind<2e4}function fu(){if(this.kind===void 0)throw new Error("Kind not set");return this.kind>=3e4&&this.kind<4e4}var hn=class extends lt{constructor(e){super();O(this,"url");O(this,"scores");O(this,"relay");O(this,"_status");O(this,"connectedAt");O(this,"_connectionStats",{attempts:0,success:0,durations:[]});O(this,"complaining",!1);O(this,"debug");O(this,"activeSubscriptions",new Set);O(this,"updateConnectionStats",{connected:()=>{this._connectionStats.success++,this._connectionStats.connectedAt=Date.now()},disconnected:()=>{this._connectionStats.connectedAt&&(this._connectionStats.durations.push(Date.now()-this._connectionStats.connectedAt),this._connectionStats.durations.length>100&&this._connectionStats.durations.shift()),this._connectionStats.connectedAt=void 0},attempt:()=>{this._connectionStats.attempts++}});this.url=e,this.relay=Yc(e),this.scores=new Map,this._status=3,this.debug=Gn(`ndk:relay:${e}`),this.relay.on("connect",()=>{this.updateConnectionStats.connected(),this._status=1,this.emit("connect")}),this.relay.on("disconnect",()=>{this.updateConnectionStats.disconnected(),this._status===1&&(this._status=3,this.handleReconnection()),this.emit("disconnect")}),this.relay.on("notice",n=>this.handleNotice(n))}isFlapping(){const e=this._connectionStats.durations;if(e.length<10)return!1;const r=e.reduce((a,c)=>a+c,0)/e.length,i=e.map(a=>Math.pow(a-r,2)).reduce((a,c)=>a+c,0)/e.length;return Math.sqrt(i)<1e3}handleReconnection(e=0){this.isFlapping()&&(this.emit("flapping",this,this._connectionStats),this._status=5);const n=this.connectedAt?Math.max(0,6e4-(Date.now()-this.connectedAt)):0;setTimeout(()=>{this._status=4,this.connect().then(()=>{this.debug("Reconnected")}).catch(r=>{this.debug("Reconnect failed",r),e<5?setTimeout(()=>{this.handleReconnection(e+1)},6e4):this.debug("Reconnect failed after 5 attempts")})},n)}get status(){return this._status}async connect(){try{this.updateConnectionStats.attempt(),this._status=0,await this.relay.connect()}catch(e){throw this.debug("Failed to connect",e),this._status=3,e}}disconnect(){this._status=2,this.relay.close()}async handleNotice(e){(e.includes("oo many")||e.includes("aximum"))&&(this.disconnect(),setTimeout(()=>this.connect(),2e3),this.debug(this.relay.url,"Relay complaining?",e)),this.emit("notice",this,e)}subscribe(e){const{filters:n}=e,r=this.relay.sub(n,{id:e.subId});this.debug(`Subscribed to ${JSON.stringify(n)}`),r.on("event",o=>{const s=new Ae(void 0,o);s.relay=this,e.eventReceived(s,this)}),r.on("eose",()=>{e.eoseReceived(this)});const i=r.unsub;return r.unsub=()=>{this.debug(`Unsubscribing from ${JSON.stringify(n)}`),this.activeSubscriptions.delete(e),i()},this.activeSubscriptions.add(e),e.on("close",()=>{this.activeSubscriptions.delete(e)}),r}async publish(e,n=2500){return this.status===1?this.publishEvent(e,n):(this.once("connect",()=>{this.publishEvent(e,n)}),!0)}async publishEvent(e,n){const r=await e.toNostrEvent(),i=this.relay.publish(r);let o;const s=new Promise((c,f)=>{i.then(()=>{clearTimeout(o),this.emit("published",e),c(!0)}).catch(u=>{clearTimeout(o),this.debug("Publish failed",u,e.id),this.emit("publish:failed",e,u),f(u)})});if(!n)return s;const a=new Promise((c,f)=>{o=setTimeout(()=>{this.debug("Publish timed out",e.rawEvent()),this.emit("publish:failed",e,"Timeout"),f(new Error("Publish operation timed out"))},n)});return Promise.race([s,a])}scoreSlowerEvent(e){}get connectionStats(){return this._connectionStats}tagReference(e){const n=["r",this.relay.url];return e&&n.push(e),n}},Ge=class{constructor(t,e){O(this,"relays");O(this,"debug");O(this,"ndk");this.relays=t,this.ndk=e,this.debug=e.debug.extend("relayset")}addRelay(t){this.relays.add(t)}static fromRelayUrls(t,e){const n=new Set;for(const r of t){const i=e.pool.relays.get(r);i&&n.add(i)}return new Ge(new Set(n),e)}subscribeOnRelay(t,e){const n=t.subscribe(e);e.relaySubscriptions.set(t,n)}getId(){const e=Array.from(this.relays).map(n=>n.url).sort().join(",");return Di(nn(e))}subscribe(t){const e=t.groupableId(),n=`${this.getId()}:${e}`;if(!e)return this.executeSubscription(t),t;const r=this.ndk.delayedSubscriptions.get(n);return r?r.push(t):(setTimeout(()=>{this.executeDelayedSubscription(n)},t.opts.groupableDelay),this.ndk.delayedSubscriptions.set(n,[t])),t}executeDelayedSubscription(t){const e=this.ndk.delayedSubscriptions.get(t);this.ndk.delayedSubscriptions.delete(t),e&&(e.length>1?this.executeSubscriptions(e):this.executeSubscription(e[0]))}executeSubscriptions(t){const e=t[0].ndk,n=new wu(e,t);this.executeSubscription(n)}executeSubscription(t){this.debug("subscribing",{filters:t.filters});for(const e of this.relays)if(e.status===1)this.subscribeOnRelay(e,t);else{const n=()=>{this.debug("new relay coming online for active subscription",{relay:e.url,filters:t.filters}),this.subscribeOnRelay(e,t)};e.once("connect",n),t.once("close",()=>{e.removeListener("connect",n)})}return t}async publish(t,e){const n=new Set,r=Array.from(this.relays).map(i=>new Promise(o=>{i.publish(t,e).then(()=>{n.add(i),o()}).catch(s=>{this.debug("error publishing to relay",{relay:i.url,err:s}),o()})}));if(await Promise.all(r),n.size===0)throw new Error("No relay was able to receive the event");return n}size(){return this.relays.size}};function hu(t,e){var r;const n=new Set;return(r=t.pool)==null||r.relays.forEach(i=>n.add(i)),new Ge(n,t)}function du(t,e){var r;const n=new Set;return(r=t.pool)==null||r.relays.forEach(i=>{i.complaining?t.debug(`Relay ${i.url} is complaining, not adding to set`):n.add(i)}),new Ge(n,t)}function pu(t){return!!(gu(t.filter)&&yu(t))}function gu(t){return!!t.ids}function yu(t){const e=t.filter.ids;return!!e&&e.length===t.eventFirstSeen.size}var bu={closeOnEose:!0,cacheUsage:"CACHE_FIRST",groupable:!0,groupableDelay:100},ko=class extends lt{constructor(e,n,r,i,o){super();O(this,"subId");O(this,"filters");O(this,"opts");O(this,"relaySet");O(this,"ndk");O(this,"relaySubscriptions");O(this,"debug");O(this,"eventFirstSeen",new Map);O(this,"eosesSeen",new Set);O(this,"eventsPerRelay",new Map);O(this,"eoseTimeout");if(this.ndk=e,this.opts={...bu,...r||{}},this.filters=n instanceof Array?n:[n],this.subId=o||(r==null?void 0:r.subId)||vu(this.filters[0]),this.relaySet=i,this.relaySubscriptions=new Map,this.debug=e.debug.extend(`subscription:${this.subId}`),this.opts.cacheUsage==="ONLY_CACHE"&&!this.opts.closeOnEose)throw new Error("Cannot use cache-only options with a persistent subscription")}get filter(){return this.filters[0]}groupableId(){var i;if(!((i=this.opts)!=null&&i.groupable)||this.filters.length>1)return null;const e=this.filters[0],n=!e.since&&!e.until,r=!e.limit;if(n&&r){let o=e.kinds?e.kinds.join(","):"";const s=Object.keys(e||{}).sort().join("-");return o+=`-${s}`,o}return null}shouldQueryCache(){var e;return((e=this.opts)==null?void 0:e.cacheUsage)!=="ONLY_RELAY"}shouldQueryRelays(){var e;return((e=this.opts)==null?void 0:e.cacheUsage)!=="ONLY_CACHE"}shouldWaitForCache(){var e;return this.opts.closeOnEose&&!!((e=this.ndk.cacheAdapter)!=null&&e.locking)&&this.opts.cacheUsage!=="PARALLEL"}async start(){let e;if(this.shouldQueryCache()&&(e=this.startWithCache(),this.shouldWaitForCache()&&(await e,pu(this)))){this.emit("eose",this);return}this.shouldQueryRelays()?this.startWithRelaySet():this.emit("eose",this)}stop(){this.relaySubscriptions.forEach(e=>e.unsub()),this.relaySubscriptions.clear(),this.emit("close",this)}async startWithCache(){var e;if((e=this.ndk.cacheAdapter)!=null&&e.query){const n=this.ndk.cacheAdapter.query(this);this.ndk.cacheAdapter.locking&&await n}}startWithRelaySet(){this.relaySet||(this.relaySet=du(this.ndk,this.filters[0])),this.relaySet&&this.relaySet.subscribe(this)}eventReceived(e,n,r=!1){if(n&&(e.relay=n),n||(n=e.relay),!r&&n){let i=this.eventsPerRelay.get(n);if(i||(i=new Set,this.eventsPerRelay.set(n,i)),i.add(e.id),this.eventFirstSeen.has(e.id)){const s=Date.now()-(this.eventFirstSeen.get(e.id)||0);n.scoreSlowerEvent(s),this.emit("event:dup",e,n,s,this);return}this.ndk.cacheAdapter&&this.ndk.cacheAdapter.setEvent(e,this.filters[0],n),this.eventFirstSeen.set(`${e.id}`,Date.now())}else this.eventFirstSeen.set(`${e.id}`,0);this.emit("event",e,n,this)}eoseReceived(e){var r,i,o;(r=this.opts)!=null&&r.closeOnEose&&((i=this.relaySubscriptions.get(e))==null||i.unsub(),this.relaySubscriptions.delete(e),this.relaySubscriptions.size===0&&this.emit("close",this)),this.eosesSeen.add(e),this.eosesSeen.size===((o=this.relaySet)==null?void 0:o.size())?this.emit("eose"):(this.eoseTimeout&&clearTimeout(this.eoseTimeout),this.eoseTimeout=setTimeout(()=>{this.emit("eose")},500))}},wu=class extends ko{constructor(e,n){const r=e.debug.extend("subscription-group"),i=mu(n.map(o=>o.filters[0]));super(e,i,n[0].opts,n[0].relaySet);O(this,"subscriptions");this.subscriptions=n,r("merged filters",{count:n.length,mergedFilters:this.filters[0]}),this.on("event",this.forwardEvent),this.on("event:dup",this.forwardEventDup),this.on("eose",this.forwardEose),this.on("close",this.forwardClose)}isEventForSubscription(e,n){const{filters:r}=n;return r?lo(r[0],e.rawEvent()):!1}forwardEvent(e,n){for(const r of this.subscriptions)this.isEventForSubscription(e,r)&&r.emit("event",e,n,r)}forwardEventDup(e,n,r){for(const i of this.subscriptions)this.isEventForSubscription(e,i)&&i.emit("event:dup",e,n,r,i)}forwardEose(){for(const e of this.subscriptions)e.emit("eose",e)}forwardClose(){for(const e of this.subscriptions)e.emit("close",e)}};function mu(t){const e={};return t.forEach(n=>{Object.entries(n).forEach(([r,i])=>{Array.isArray(i)?e[r]===void 0?e[r]=[...i]:e[r]=Array.from(new Set([...e[r],...i])):e[r]=i})}),e}function xu(t){let e;try{switch(e=V.decode(t),e.type){case"nevent":return{ids:[e.data.id]};case"note":return{ids:[e.data]};case"naddr":return{authors:[e.data.pubkey],"#d":[e.data.identifier],kinds:[e.data.kind]}}}catch{}return{ids:[t]}}function Eu(t){try{const e=V.decode(t);if(["naddr","nevent"].includes(e==null?void 0:e.type)){const n=e.data;if(n!=null&&n.relays)return n.relays.map(r=>new hn(r))}}catch{}return[]}function vu(t){const e=Object.keys(t)||[],n=[];for(const r of e)if(r==="kinds"){const i=[r,t.kinds.join(",")];n.push(i.join(":"))}else n.push(r);return n.push(Math.floor(Math.random()*999999999).toString()),n.join("-")}async function ku(){if(!this.ndk)throw new Error("NDK not set");const t=await this.ndk.fetchEvents({kinds:[3],authors:[this.hexpubkey()]});if(t){const e=new Set;return t.forEach(n=>{n.tags.forEach(r=>{if(r[0]==="p")try{const i=V.npubEncode(r[1]);e.add(i)}catch{}})}),[...e].reduce((n,r)=>{const i=new ft({npub:r});return i.ndk=this.ndk,n.add(i),n},new Set)}return new Set}function _u(t,e){const n=JSON.parse(t.content);return Object.keys(n).forEach(r=>{switch(r){case"name":e.name=n.name;break;case"display_name":case"displayName":e.displayName=n.displayName||n.display_name;break;case"image":case"picture":e.image=n.image||n.picture;break;case"banner":e.banner=n.banner;break;case"bio":e.bio=n.bio;break;case"nip05":e.nip05=n.nip05;break;case"lud06":e.lud06=n.lud06;break;case"lud16":e.lud16=n.lud16;break;case"about":e.about=n.about;break;case"zapService":e.zapService=n.zapService;break;case"website":e.website=n.website;break;default:e[r]=n[r];break}}),e}var ft=class{constructor(t){O(this,"ndk");O(this,"profile");O(this,"npub","");O(this,"relayUrls",[]);O(this,"follows",ku.bind(this));t.npub&&(this.npub=t.npub),t.hexpubkey&&(this.npub=V.npubEncode(t.hexpubkey)),t.relayUrls&&(this.relayUrls=t.relayUrls)}static async fromNip05(t){const e=await yo.queryProfile(t);if(e)return new ft({hexpubkey:e.pubkey,relayUrls:e.relays})}hexpubkey(){return V.decode(this.npub).data}async fetchProfile(t){if(!this.ndk)throw new Error("NDK not set");this.profile||(this.profile={});let e=null;return!t&&this.ndk.cacheAdapter&&this.ndk.cacheAdapter.locking&&(e=await this.ndk.fetchEvents({kinds:[0],authors:[this.hexpubkey()]},{cacheUsage:"ONLY_CACHE",closeOnEose:!0,groupable:!1}),t={cacheUsage:"ONLY_RELAY",closeOnEose:!0}),(!e||e.size===0)&&(e=await this.ndk.fetchEvents({kinds:[0],authors:[this.hexpubkey()]},t)),e&&Array.from(e).sort((r,i)=>r.created_at-i.created_at).forEach(r=>{try{this.profile=_u(r,this.profile)}catch{}}),e}async relayList(){if(!this.ndk)throw new Error("NDK not set");const t=await this.ndk.fetchEvents({kinds:[10002],authors:[this.hexpubkey()]});return t||new Set}tagReference(){return["p",this.hexpubkey()]}async publish(){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),await new Ae(this.ndk,{kind:0,content:JSON.stringify(this.profile)}).publish()}async follow(t,e){if(!this.ndk)throw new Error("No NDK instance found");if(this.ndk.assertSigner(),e||(e=await this.follows()),e.has(t))return!1;e.add(t);const n=new Ae(this.ndk,{kind:3});for(const r of e)n.tag(r);return await n.publish(),!0}};async function Au(t,e){if(!e){if(!this.ndk)throw new Error("No signer available");await this.ndk.assertSigner(),e=this.ndk.signer}if(!t){const n=this.getMatchingTags("p");if(n.length!==1)throw new Error("No recipient could be determined and no explicit recipient was provided");t=new ft({hexpubkey:n[0][1]}),t.ndk=this.ndk}this.content=await e.encrypt(t,this.content)}async function Su(t,e){if(!e){if(!this.ndk)throw new Error("No signer available");await this.ndk.assertSigner(),e=this.ndk.signer}t||(t=this.author),this.content=await e.decrypt(t,this.content)}function $u(){return this.isParamReplaceable()?V.naddrEncode({kind:this.kind,pubkey:this.pubkey,identifier:this.replaceableDTag(),relays:this.relay?[this.relay.url]:[]}):this.relay?V.neventEncode({id:this.tagId(),relays:[this.relay.url],author:this.pubkey}):V.noteEncode(this.tagId())}async function Cu(t=!0,e){if(!e){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner(),e=this.ndk.signer}if(!e)throw new Error("No signer available");const n=await e.user(),r=new Ae(this.ndk,{kind:Bu(this),content:"",pubkey:n.hexpubkey()});return r.tag(this),r.kind===16&&r.tags.push(["k",`${this.kind}`]),await r.sign(e),t&&await r.publish(),r}function Bu(t){return t.kind===1?6:16}var Ae=class extends lt{constructor(e,n){super();O(this,"ndk");O(this,"created_at");O(this,"content","");O(this,"tags",[]);O(this,"kind");O(this,"id","");O(this,"sig");O(this,"pubkey","");O(this,"relay");O(this,"isReplaceable",uu.bind(this));O(this,"isParamReplaceable",fu.bind(this));O(this,"encode",$u.bind(this));O(this,"encrypt",Au.bind(this));O(this,"decrypt",Su.bind(this));O(this,"repost",Cu.bind(this));this.ndk=e,this.created_at=n==null?void 0:n.created_at,this.content=(n==null?void 0:n.content)||"",this.tags=(n==null?void 0:n.tags)||[],this.id=(n==null?void 0:n.id)||"",this.sig=n==null?void 0:n.sig,this.pubkey=(n==null?void 0:n.pubkey)||"",this.kind=n==null?void 0:n.kind}rawEvent(){return{created_at:this.created_at,content:this.content,tags:this.tags,kind:this.kind,pubkey:this.pubkey,id:this.id,sig:this.sig}}set author(e){this.pubkey=e.hexpubkey()}get author(){const e=new ft({hexpubkey:this.pubkey});return e.ndk=this.ndk,e}tag(e,n){const r=e.tagReference();if(n&&r.push(n),this.tags.push(r),e instanceof Ae){const i=e.author;i&&this.pubkey!==i.hexpubkey()&&this.tag(i);for(const o of e.getMatchingTags("p"))o[1]!==this.pubkey&&(this.tags.find(s=>s[0]==="p"&&s[1]===o[1])||this.tags.push(["p",o[1]]))}}async toNostrEvent(e){var o,s;if(!e&&this.pubkey===""){const a=await((s=(o=this.ndk)==null?void 0:o.signer)==null?void 0:s.user());this.pubkey=(a==null?void 0:a.hexpubkey())||""}this.created_at||(this.created_at=Math.floor(Date.now()/1e3));const n=this.rawEvent(),{content:r,tags:i}=this.generateTags();n.content=r||"",n.tags=i;try{this.id=on(n)}catch{}return this.id&&(n.id=this.id),this.sig&&(n.sig=this.sig),n}getMatchingTags(e){return this.tags.filter(n=>n[0]===e)}tagValue(e){const n=this.getMatchingTags(e);if(n.length!==0)return n[0][1]}removeTag(e){this.tags=this.tags.filter(n=>n[0]!==e)}async sign(e){var r;e||((r=this.ndk)==null||r.assertSigner(),e=this.ndk.signer),await this.generateTags(),this.isReplaceable()&&(this.created_at=Math.floor(Date.now()/1e3));const n=await this.toNostrEvent();return this.sig=await e.sign(n),this.sig}async publish(e,n){if(this.sig||await this.sign(),!this.ndk)throw new Error("NDKEvent must be associated with an NDK instance to publish");return this.ndk.publish(this,e,n)}generateTags(){let e=[];const n=lu(this.content,this.tags),r=n.content;if(e=n.tags,this.kind&&this.kind>=3e4&&this.kind<=4e4&&!this.getMatchingTags("d")[0]){const o=[...Array(16)].map(()=>Math.random().toString(36)[2]).join("");e.push(["d",o])}return{content:r||"",tags:e}}replaceableDTag(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.getMatchingTags("d")[0];return e?e[1]:""}throw new Error("Event is not a parameterized replaceable event")}deduplicationKey(){return this.kind===0||this.kind===3?`${this.kind}:${this.pubkey}`:this.tagId()}tagId(){if(this.kind&&this.kind>=3e4&&this.kind<=4e4){const e=this.replaceableDTag();return`${this.kind}:${this.pubkey}:${e}`}return this.id}tagReference(){return this.isParamReplaceable()?["a",this.tagId()]:["e",this.tagId()]}filter(){return this.isParamReplaceable()?{"#a":[this.tagId()]}:{"#e":[this.tagId()]}}async zap(e,n,r){if(!this.ndk)throw new Error("No NDK instance found");return this.ndk.assertSigner(),await new cu({ndk:this.ndk,zappedEvent:this}).createZapRequest(e,n,r)}async delete(e){if(!this.ndk)throw new Error("No NDK instance found");this.ndk.assertSigner();const n=new Ae(this.ndk,{kind:5,content:e||""});return n.tag(this),await n.publish(),n}},Iu=class extends lt{constructor(e=[],n){super();O(this,"relays",new Map);O(this,"debug");O(this,"temporaryRelayTimers",new Map);this.debug=n.debug.extend("pool");for(const r of e){const i=new hn(r);this.addRelay(i,!1)}}useTemporaryRelay(e,n=6e5){const r=this.relays.has(e.url);r||this.addRelay(e);const i=this.temporaryRelayTimers.get(e.url);if(i&&clearTimeout(i),!r||i){const o=setTimeout(()=>{this.removeRelay(e.url)},n);this.temporaryRelayTimers.set(e.url,o)}}addRelay(e,n=!0){const r=e.url;e.on("notice",(i,o)=>this.emit("notice",i,o)),e.on("connect",()=>this.handleRelayConnect(r)),e.on("disconnect",()=>this.emit("relay:disconnect",e)),e.on("flapping",()=>this.handleFlapping(e)),this.relays.set(r,e),n&&e.connect()}removeRelay(e){const n=this.relays.get(e);if(n)return n.disconnect(),this.relays.delete(e),this.emit("relay:disconnect",n),!0;const r=this.temporaryRelayTimers.get(e);return r&&(clearTimeout(r),this.temporaryRelayTimers.delete(e)),!1}handleRelayConnect(e){this.debug(`Relay ${e} connected`),this.emit("relay:connect",this.relays.get(e)),this.stats().connected===this.relays.size&&this.emit("connect")}async connect(e){const n=[];this.debug(`Connecting to ${this.relays.size} relays${e?`, timeout ${e}...`:""}`);for(const r of this.relays.values())if(e){const i=new Promise((o,s)=>{setTimeout(()=>s(`Timed out after ${e}ms`),e)});n.push(Promise.race([r.connect(),i]).catch(o=>{this.debug(`Failed to connect to relay ${r.url}: ${o}`)}))}else n.push(r.connect());e&&setTimeout(()=>{const r=this.stats().connected===this.relays.size,i=this.stats().connected>0;!r&&i&&this.emit("connect")},e),await Promise.all(n)}handleFlapping(e){this.debug(`Relay ${e.url} is flapping`),this.relays.delete(e.url),this.emit("flapping",e)}size(){return this.relays.size}stats(){const e={total:0,connected:0,disconnected:0,connecting:0};for(const n of this.relays.values())e.total++,n.status===1?e.connected++:n.status===3?e.disconnected++:n.status===0&&e.connecting++;return e}connectedRelays(){return Array.from(this.relays.values()).filter(e=>e.status===1)}urls(){return Array.from(this.relays.keys())}};function Uu(t,e){const n=e.connectedRelays();if(!Array.from(t.relays).some(i=>n.map(o=>o.url).includes(i.url)))for(const i of n)t.addRelay(i);if(n.length===0)for(const i of e.relays.values())t.addRelay(i);return t}var Ru=class{constructor(){O(this,"_userPromise");O(this,"nip04Queue",[]);O(this,"nip04Processing",!1);O(this,"debug");if(!window.nostr)throw new Error("NIP-07 extension not available");this.debug=Gn("ndk:nip07")}async blockUntilReady(){var e;const t=await((e=window.nostr)==null?void 0:e.getPublicKey());if(!t)throw new Error("User rejected access");return new ft({hexpubkey:t})}async user(){return this._userPromise||(this._userPromise=this.blockUntilReady()),this._userPromise}async sign(t){if(!window.nostr)throw new Error("NIP-07 extension not available");return(await window.nostr.signEvent(t)).sig}async encrypt(t,e){if(!window.nostr)throw new Error("NIP-07 extension not available");const n=t.hexpubkey();return this.queueNip04("encrypt",n,e)}async decrypt(t,e){if(!window.nostr)throw new Error("NIP-07 extension not available");const n=t.hexpubkey();return this.queueNip04("decrypt",n,e)}async queueNip04(t,e,n){return new Promise((r,i)=>{this.nip04Queue.push({type:t,counterpartyHexpubkey:e,value:n,resolve:r,reject:i}),this.nip04Processing||this.processNip04Queue()})}async processNip04Queue(t,e=0){if(!t&&this.nip04Queue.length===0){this.nip04Processing=!1;return}this.nip04Processing=!0;const{type:n,counterpartyHexpubkey:r,value:i,resolve:o,reject:s}=t||this.nip04Queue.shift();this.debug("Processing encryption queue item",{type:n,counterpartyHexpubkey:r,value:i});try{let a;n==="encrypt"?a=await window.nostr.nip04.encrypt(r,i):a=await window.nostr.nip04.decrypt(r,i),o(a)}catch(a){if(a.message&&a.message.includes("call already executing")&&e<5){this.debug("Retrying encryption queue item",{type:n,counterpartyHexpubkey:r,value:i,retries:e}),setTimeout(()=>{this.processNip04Queue(t,e+1)},50*e);return}s(a)}this.processNip04Queue()}},Nu=class extends lt{constructor(e={}){super();O(this,"pool");O(this,"signer");O(this,"cacheAdapter");O(this,"debug");O(this,"devWriteRelaySet");O(this,"delayedSubscriptions");this.debug=e.debug||Gn("ndk"),this.pool=new Iu(e.explicitRelayUrls||[],this),this.signer=e.signer,this.cacheAdapter=e.cacheAdapter,this.delayedSubscriptions=new Map,e.devWriteRelayUrls&&(this.devWriteRelaySet=Ge.fromRelayUrls(e.devWriteRelayUrls,this))}toJSON(){return{relayCount:this.pool.relays.size}.toString()}async connect(e){return this.debug("Connecting to relays",{timeoutMs:e}),this.pool.connect(e)}getUser(e){const n=new ft(e);return n.ndk=this,n}subscribe(e,n,r,i=!0){const o=new ko(this,e,n,r);if(r)for(const s of r.relays)this.pool.useTemporaryRelay(s);return i&&o.start(),o}async publish(e,n,r){return this.debug("Deprecated: Use `event.publish()` instead"),n||(n=this.devWriteRelaySet||hu(this)),n.publish(e,r)}async fetchEvent(e,n,r){let i;if(!r&&typeof e=="string"){const o=Eu(e);o.length>0&&(r=new Ge(new Set(o),this),r=Uu(r,this.pool))}if(typeof e=="string"?i=xu(e):i=e,!i)throw new Error(`Invalid filter: ${JSON.stringify(e)}`);return new Promise(o=>{const s=this.subscribe(i,{...n||{},closeOnEose:!0},r,!1);s.on("event",a=>{a.ndk=this,o(a)}),s.on("eose",()=>{o(null)}),s.start()})}async fetchEvents(e,n,r){return new Promise(i=>{const o=new Map,s=this.subscribe(e,{...n||{},closeOnEose:!0},r,!1),a=c=>{const f=c.deduplicationKey(),u=o.get(f);u&&(c=su(u,c)),c.ndk=this,o.set(f,c)};s.on("event",a),s.on("event:dup",a),s.on("eose",()=>{i(new Set(o.values()))}),s.start()})}async assertSigner(){if(!this.signer)throw this.emit("signerRequired"),new Error("Signer required")}};const tt=[];function _o(t,e=de){let n;const r=new Set;function i(a){if(Et(t,a)&&(t=a,n)){const c=!tt.length;for(const f of r)f[1](),tt.push(f,t);if(c){for(let f=0;f<tt.length;f+=2)tt[f][0](tt[f+1]);tt.length=0}}}function o(a){i(a(t))}function s(a,c=de){const f=[a,c];return r.add(f),r.size===1&&(n=e(i)||de),a(t),()=>{r.delete(f),r.size===0&&n&&(n(),n=null)}}return{set:i,update:o,subscribe:s}}const wr="ws://localhost:3334",Tu=["wss://nos.lol","wss://relay.snort.social"],Lu=[wr,...Tu],Ao=new Nu({explicitRelayUrls:Lu});Ao.connect().then(()=>console.log("ndk connected"));const gt=_o(Ao),Ot=_o(void 0);function Zr(t,e,n){const r=t.slice();return r[6]=e[n],r}function Ou(t){let e=V.npubEncode(t[0].pk)+"",n;return{c(){n=qt(e)},m(r,i){ue(r,n,i)},p(r,i){i&1&&e!==(e=V.npubEncode(r[0].pk)+"")&&si(n,e)},d(r){r&&ae(n)}}}function Hu(t){let e;return{c(){e=qt(t[2])},m(n,r){ue(n,e,r)},p(n,r){r&4&&si(e,n[2])},d(n){n&&ae(e)}}}function Yr(t){let e,n,r;return{c(){e=M("button"),e.textContent="[-]",re(e,"class","inline cusor-pointer font-semibold text-red-500")},m(i,o){ue(i,e,o),n||(r=Ht(e,"click",t[4]),n=!0)},p:de,d(i){i&&ae(e),n=!1,r()}}}function Jr(t){let e;return{c(){e=M("span"),e.textContent="(you)"},m(n,r){ue(n,e,r)},d(n){n&&ae(e)}}}function Qr(t){let e,n=[],r=new Map,i,o=t[0].children;const s=a=>a[6].pk;for(let a=0;a<o.length;a+=1){let c=Zr(t,o,a),f=s(c);r.set(f,n[a]=Xr(f,c))}return{c(){e=M("ul");for(let a=0;a<n.length;a+=1)n[a].c();re(e,"class","list-disc ml-2")},m(a,c){ue(a,e,c);for(let f=0;f<n.length;f+=1)n[f]&&n[f].m(e,null);i=!0},p(a,c){c&3&&(o=a[0].children,Mt(),n=ui(n,c,s,1,a,o,r,e,li,Xr,null,Zr),Wt())},i(a){if(!i){for(let c=0;c<o.length;c+=1)oe(n[c]);i=!0}},o(a){for(let c=0;c<n.length;c+=1)be(n[c]);i=!1},d(a){a&&ae(e);for(let c=0;c<n.length;c+=1)n[c].d()}}}function Xr(t,e){let n,r,i;return r=new So({props:{reload:e[1],person:e[6]}}),{key:t,first:null,c(){n=Vn(),Vt(r.$$.fragment),this.first=n},m(o,s){ue(o,n,s),vt(r,o,s),i=!0},p(o,s){e=o;const a={};s&2&&(a.reload=e[1]),s&1&&(a.person=e[6]),r.$set(a)},i(o){i||(oe(r.$$.fragment,o),i=!0)},o(o){be(r.$$.fragment,o),i=!1},d(o){o&&ae(n),kt(r,o)}}}function Fu(t){let e,n,r,i,o,s=t[3]==V.npubEncode(t[0].invited_by),a,c=t[3]==V.npubEncode(t[0].pk),f,u;function l(b,A){return b[2]?Hu:Ou}let h=l(t),y=h(t),g=s&&Yr(t),d=c&&Jr(),p=t[0].children&&t[0].children.length>0&&Qr(t);return{c(){e=M("li"),n=M("span"),r=M("a"),y.c(),o=Fe(),g&&g.c(),a=Vn(),d&&d.c(),f=Fe(),p&&p.c(),re(r,"class","inline hover:underline"),re(r,"href",i=`nostr:${V.npubEncode(t[0].pk)}`)},m(b,A){ue(b,e,A),q(e,n),q(n,r),y.m(r,null),q(n,o),g&&g.m(n,null),q(n,a),d&&d.m(n,null),q(e,f),p&&p.m(e,null),u=!0},p(b,[A]){h===(h=l(b))&&y?y.p(b,A):(y.d(1),y=h(b),y&&(y.c(),y.m(r,null))),(!u||A&1&&i!==(i=`nostr:${V.npubEncode(b[0].pk)}`))&&re(r,"href",i),A&9&&(s=b[3]==V.npubEncode(b[0].invited_by)),s?g?g.p(b,A):(g=Yr(b),g.c(),g.m(n,a)):g&&(g.d(1),g=null),A&9&&(c=b[3]==V.npubEncode(b[0].pk)),c?d||(d=Jr(),d.c(),d.m(n,null)):d&&(d.d(1),d=null),b[0].children&&b[0].children.length>0?p?(p.p(b,A),A&1&&oe(p,1)):(p=Qr(b),p.c(),oe(p,1),p.m(e,null)):p&&(Mt(),be(p,1,1,()=>{p=null}),Wt())},i(b){u||(oe(p),u=!0)},o(b){be(p),u=!1},d(b){b&&ae(e),y.d(),g&&g.d(),d&&d.d(),p&&p.d()}}}function zu(t,e,n){let r,i;yt(t,gt,f=>n(5,r=f)),yt(t,Ot,f=>n(3,i=f));let{person:o}=e,{reload:s}=e,a="...";ai(async()=>{try{let f=r.getUser({hexpubkey:o.pk});await f.fetchProfile(),n(2,a=f.profile.name)}catch(f){console.log(f)}});async function c(){if(confirm(`Are you sure you want to remove ${a||o.pk}? All people they invited will also be removed.`))try{let u=[new hn(wr)];const l=new Ge(u,r);l.relays.forEach(async y=>{await y.connect().catch(g=>{console.log("RELAY CONNECT ERROR"),console.error(g)}),y.on("connect",()=>{console.log("connected")})});const h=new Ae(r);h.kind=20202,h.tags.push(["p",o.pk]),await h.publish(l).then(()=>s())}catch(u){console.log("error while publishing",u)}}return t.$$set=f=>{"person"in f&&n(0,o=f.person),"reload"in f&&n(1,s=f.reload)},[o,s,a,i,c]}class So extends Zt{constructor(e){super(),Gt(this,e,zu,Fu,Et,{person:0,reload:1})}}function ei(t,e,n){const r=t.slice();return r[2]=e[n],r}function ti(t,e){let n,r,i;return r=new So({props:{reload:e[0],person:e[2]}}),{key:t,first:null,c(){n=Vn(),Vt(r.$$.fragment),this.first=n},m(o,s){ue(o,n,s),vt(r,o,s),i=!0},p(o,s){e=o;const a={};s&1&&(a.reload=e[0]),s&2&&(a.person=e[2]),r.$set(a)},i(o){i||(oe(r.$$.fragment,o),i=!0)},o(o){be(r.$$.fragment,o),i=!1},d(o){o&&ae(n),kt(r,o)}}}function Pu(t){let e,n,r=[],i=new Map,o,s=t[1];const a=c=>c[2].pk;for(let c=0;c<s.length;c+=1){let f=ei(t,s,c),u=a(f);i.set(u,r[c]=ti(u,f))}return{c(){e=M("div"),n=M("ul");for(let c=0;c<r.length;c+=1)r[c].c();re(n,"class","list-disc ml-4"),re(e,"class","px-4")},m(c,f){ue(c,e,f),q(e,n);for(let u=0;u<r.length;u+=1)r[u]&&r[u].m(n,null);o=!0},p(c,[f]){f&3&&(s=c[1],Mt(),r=ui(r,f,a,1,c,s,i,n,li,ti,null,ei),Wt())},i(c){if(!o){for(let f=0;f<s.length;f+=1)oe(r[f]);o=!0}},o(c){for(let f=0;f<r.length;f+=1)be(r[f]);o=!1},d(c){c&&ae(e);for(let f=0;f<r.length;f+=1)r[f].d()}}}function Ku(t,e,n){let{reload:r}=e,{hierarchy:i}=e;return t.$$set=o=>{"reload"in o&&n(0,r=o.reload),"hierarchy"in o&&n(1,i=o.hierarchy)},[r,i]}class ju extends Zt{constructor(e){super(),Gt(this,e,Ku,Pu,Et,{reload:0,hierarchy:1})}}function Du(t){let e,n,r,i,o,s;return{c(){e=M("div"),n=M("input"),r=Fe(),i=M("button"),i.textContent="Go",re(n,"class","focus:ring-indigo-500 focus:border-indigo-500 block w-full rounded-none rounded-l-md sm:text-sm border-gray-300"),re(n,"placeholder","hex or npub"),re(i,"type","submit"),re(i,"class","-ml-px relative inline-flex items-center space-x-2 px-3 py-2 border border-gray-300 text-sm font-medium rounded-r-md text-gray-700 bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 text-white"),re(e,"class","relative flex items-stretch flex-grow focus-within:z-10")},m(a,c){ue(a,e,c),q(e,n),_r(n,t[0]),q(e,r),q(e,i),o||(s=[Ht(n,"input",t[3]),Ht(i,"click",t[1])],o=!0)},p(a,[c]){c&1&&n.value!==a[0]&&_r(n,a[0])},i:de,o:de,d(a){a&&ae(e),o=!1,Ze(s)}}}function qu(t,e,n){let r;yt(t,gt,c=>n(4,r=c));let i="",{reload:o}=e;async function s(){if(i)try{let c=[new hn(wr)];const f=new Ge(c,r);f.relays.forEach(async h=>{await h.connect().catch(y=>{console.log("RELAY CONNECT ERROR"),console.error(y)}),h.on("connect",()=>{console.log(h.url,"connected")})});const u=i.startsWith("npub")?V.decode(i).data:i,l=new Ae(r);l.kind=20201,l.tags.push(["p",u.toString()]),await l.publish(f).then(()=>o()),n(0,i="")}catch(c){console.log("error while publishing",c)}}function a(){i=this.value,n(0,i)}return t.$$set=c=>{"reload"in c&&n(2,o=c.reload)},[i,s,o,a]}class Mu extends Zt{constructor(e){super(),Gt(this,e,qu,Du,Et,{reload:2})}}function $o(t,e=null){return t.filter(r=>r.invited_by===(e?e.pk:null)).map(r=>({...r,children:$o(t,r)}))}function ni(t){let e,n,r;return{c(){e=M("button"),e.textContent="Login with NIP07",re(e,"type","button"),re(e,"class","inline-flex mr-2 items-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500")},m(i,o){ue(i,e,o),n||(r=Ht(e,"click",t[3]),n=!0)},p:de,d(i){i&&ae(e),n=!1,r()}}}function ri(t){let e,n,r,i,o,s;return o=new Mu({props:{reload:t[4]}}),{c(){e=M("div"),n=M("h3"),n.textContent="Invite Someone",r=Fe(),i=M("div"),Vt(o.$$.fragment)},m(a,c){ue(a,e,c),q(e,n),q(e,r),q(e,i),vt(o,i,null),s=!0},p:de,i(a){s||(oe(o.$$.fragment,a),s=!0)},o(a){be(o.$$.fragment,a),s=!1},d(a){a&&ae(e),kt(o)}}}function Wu(t){let e,n,r,i,o,s=t[0].find(t[5]),a,c,f,u,l,h,y,g=t[2]===void 0&&ni(t),d=s&&ri(t);return h=new ju({props:{hierarchy:t[1],reload:t[4]}}),{c(){e=M("article"),n=M("h1"),n.textContent="Invite Relay",r=Fe(),i=M("div"),g&&g.c(),o=Fe(),d&&d.c(),a=Fe(),c=M("div"),f=M("h3"),f.textContent="Current hieracy",u=Fe(),l=M("div"),Vt(h.$$.fragment),re(e,"class","prose font-sans px-4 py-6 lg:max-w-7xl lg:pt-6 lg:pb-28")},m(p,b){ue(p,e,b),q(e,n),q(e,r),q(e,i),g&&g.m(i,null),q(e,o),d&&d.m(e,null),q(e,a),q(e,c),q(c,f),q(c,u),q(c,l),vt(h,l,null),y=!0},p(p,[b]){p[2]===void 0?g?g.p(p,b):(g=ni(p),g.c(),g.m(i,null)):g&&(g.d(1),g=null),b&5&&(s=p[0].find(p[5])),s?d?(d.p(p,b),b&5&&oe(d,1)):(d=ri(p),d.c(),oe(d,1),d.m(e,a)):d&&(Mt(),be(d,1,1,()=>{d=null}),Wt());const A={};b&2&&(A.hierarchy=p[1]),h.$set(A)},i(p){y||(oe(d),oe(h.$$.fragment,p),y=!0)},o(p){be(d),be(h.$$.fragment,p),y=!1},d(p){p&&ae(e),g&&g.d(),d&&d.d(),kt(h)}}}function Vu(t,e,n){let r,i;yt(t,Ot,u=>n(2,r=u)),yt(t,gt,u=>n(6,i=u));async function o(){const u=new Ru;kr(gt,i.signer=u,i),gt.set(i),kr(Ot,r=(await i.signer.user()).npub,r),Ot.set(r)}async function s(){const u=await fetch("/invitedata");n(0,a=Object.values(await u.json())),n(1,c=$o(a,{pk:"",invited_by:""}))}let a=[],c=[];return ai(()=>{addEventListener("load",u=>{o()}),s()}),[a,c,r,o,s,u=>r==V.npubEncode(u.pk)]}class Gu extends Zt{constructor(e){super(),Gt(this,e,Vu,Wu,Et,{})}}new Gu({target:document.getElementById("app")});