diff --git a/ui/.gitignore b/ui/.gitignore index 3c3629e..76add87 100644 --- a/ui/.gitignore +++ b/ui/.gitignore @@ -1 +1,2 @@ node_modules +dist \ No newline at end of file diff --git a/ui/dist/assets/index-183b5ca2.js b/ui/dist/assets/index-183b5ca2.js deleted file mode 100644 index 0271f5f..0000000 --- a/ui/dist/assets/index-183b5ca2.js +++ /dev/null @@ -1,2051 +0,0 @@ -var as=Object.defineProperty;var cs=(t,e,n)=>e in t?as(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var H=(t,e,n)=>(cs(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 Z(){}function ls(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Fi(t){return t()}function Hr(){return Object.create(null)}function Ye(t){t.forEach(Fi)}function Pi(t){return typeof t=="function"}function ct(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let Gt;function Pt(t,e){return Gt||(Gt=document.createElement("a")),Gt.href=e,t===Gt.href}function us(t){return Object.keys(t).length===0}function fs(t,...e){if(t==null)return Z;const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function st(t,e,n){t.$$.on_destroy.push(fs(e,n))}function Fr(t,e,n){return t.set(n),e}function j(t,e){t.appendChild(e)}function M(t,e,n){t.insertBefore(e,n||null)}function q(t){t.parentNode&&t.parentNode.removeChild(t)}function zi(t,e){for(let n=0;nt.removeEventListener(e,n,r)}function K(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function hs(t){return Array.from(t.childNodes)}function $e(t,e){e=""+e,t.data!==e&&(t.data=e)}function Pr(t,e){t.value=e??""}let zt;function Te(t){zt=t}function Ki(){if(!zt)throw new Error("Function called outside component initialization");return zt}function cr(t){Ki().$$.on_mount.push(t)}const yt=[],zr=[];let bt=[];const Kr=[],ds=Promise.resolve();let jn=!1;function ps(){jn||(jn=!0,ds.then(lr))}function Dn(t){bt.push(t)}const Cn=new Set;let pt=0;function lr(){if(pt!==0)return;const t=zt;do{try{for(;ptt.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),bt=e}const rn=new Set;let tt;function lt(){tt={r:0,c:[],p:tt}}function ut(){tt.r||Ye(tt.c),tt=tt.p}function te(t,e){t&&t.i&&(rn.delete(t),t.i(e))}function he(t,e,n,r){if(t&&t.o){if(rn.has(t))return;rn.add(t),tt.c.push(()=>{rn.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function mt(t,e){const n=e.token={};function r(i,o,s,a){if(e.token!==n)return;e.resolved=a;let c=e.ctx;s!==void 0&&(c=c.slice(),c[s]=a);const f=i&&(e.current=i)(c);let l=!1;e.block&&(e.blocks?e.blocks.forEach((u,h)=>{h!==o&&u&&(lt(),he(u,1,1,()=>{e.blocks[h]===u&&(e.blocks[h]=null)}),ut())}):e.block.d(1),f.c(),te(f,1),f.m(e.mount(),e.anchor),l=!0),e.block=f,e.blocks&&(e.blocks[o]=f),l&&lr()}if(ls(t)){const i=Ki();if(t.then(o=>{Te(i),r(e.then,1,e.value,o),Te(null)},o=>{if(Te(i),r(e.catch,2,e.error,o),Te(null),!e.hasCatch)throw o}),e.current!==e.pending)return r(e.pending,0),!0}else{if(e.current!==e.then)return r(e.then,1,e.value,t),!0;e.resolved=t}}function ur(t,e,n){const r=e.slice(),{resolved:i}=t;t.current===t.then&&(r[t.value]=i),t.current===t.catch&&(r[t.error]=i),t.block.p(r,n)}function ji(t,e){he(t,1,1,()=>{e.delete(t.key)})}function Di(t,e,n,r,i,o,s,a,c,f,l,u){let h=t.length,b=o.length,g=h;const d={};for(;g--;)d[t[g].key]=g;const p=[],y=new Map,m=new Map,v=[];for(g=b;g--;){const $=u(i,o,g),N=n($);let R=s.get(N);R?r&&v.push(()=>R.p($,e)):(R=f(N,$),R.c()),y.set(N,p[g]=R),N in d&&m.set(N,Math.abs(g-d[N]))}const B=new Set,C=new Set;function A($){te($,1),$.m(a,l),s.set($.key,$),l=$.first,b--}for(;h&&b;){const $=p[b-1],N=t[h-1],R=$.key,L=N.key;$===N?(l=$.first,h--,b--):y.has(L)?!s.has(R)||B.has(R)?A($):C.has(L)?h--:m.get(R)>m.get(L)?(C.add(R),A($)):(B.add(L),h--):(c(N,s),h--)}for(;h--;){const $=t[h];y.has($.key)||c($,s)}for(;b;)A(p[b-1]);return Ye(v),p}function _t(t){t&&t.c()}function ft(t,e,n,r){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,n),r||Dn(()=>{const s=t.$$.on_mount.map(Fi).filter(Pi);t.$$.on_destroy?t.$$.on_destroy.push(...s):Ye(s),t.$$.on_mount=[]}),o.forEach(Dn)}function ht(t,e){const n=t.$$;n.fragment!==null&&(ys(n.after_update),Ye(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function bs(t,e){t.$$.dirty[0]===-1&&(yt.push(t),ps(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const g=b.length?b[0]:h;return f.ctx&&i(f.ctx[u],f.ctx[u]=g)&&(!f.skip_bound&&f.bound[u]&&f.bound[u](g),l&&bs(t,u)),h}):[],f.update(),l=!0,Ye(f.before_update),f.fragment=r?r(f.ctx):!1,e.target){if(e.hydrate){const u=hs(e.target);f.fragment&&f.fragment.l(u),u.forEach(q)}else f.fragment&&f.fragment.c();e.intro&&te(t.$$.fragment),ft(t,e.target,e.anchor,e.customElement),lr()}Te(c)}class $t{$destroy(){ht(this,1),this.$destroy=Z}$on(e,n){if(!Pi(n))return Z;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&&!us(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function qi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qn={exports:{}},Bn,jr;function ws(){if(jr)return Bn;jr=1;var t=1e3,e=t*60,n=e*60,r=n*24,i=r*7,o=r*365.25;Bn=function(l,u){u=u||{};var h=typeof l;if(h==="string"&&l.length>0)return s(l);if(h==="number"&&isFinite(l))return u.long?c(l):a(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function s(l){if(l=String(l),!(l.length>100)){var u=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(u){var h=parseFloat(u[1]),b=(u[2]||"ms").toLowerCase();switch(b){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(l){var u=Math.abs(l);return u>=r?Math.round(l/r)+"d":u>=n?Math.round(l/n)+"h":u>=e?Math.round(l/e)+"m":u>=t?Math.round(l/t)+"s":l+"ms"}function c(l){var u=Math.abs(l);return u>=r?f(l,u,r,"day"):u>=n?f(l,u,n,"hour"):u>=e?f(l,u,e,"minute"):u>=t?f(l,u,t,"second"):l+" ms"}function f(l,u,h,b){var g=u>=h*1.5;return Math.round(l/h)+" "+b+(g?"s":"")}return Bn}function ms(t){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=ws(),n.destroy=f,Object.keys(t).forEach(l=>{n[l]=t[l]}),n.names=[],n.skips=[],n.formatters={};function e(l){let u=0;for(let h=0;h{if(A==="%%")return"%";B++;const N=n.formatters[$];if(typeof N=="function"){const R=p[B];A=N.call(y,R),p.splice(B,1),B--}return A}),n.formatArgs.call(y,p),(y.log||n.log).apply(y,p)}return d.namespace=l,d.useColors=n.useColors(),d.color=n.selectColor(l),d.extend=r,d.destroy=n.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(b!==n.namespaces&&(b=n.namespaces,g=n.enabled(l)),g),set:p=>{h=p}}),typeof n.init=="function"&&n.init(d),d}function r(l,u){const h=n(this.namespace+(typeof u>"u"?":":u)+l);return h.log=this.log,h}function i(l){n.save(l),n.namespaces=l,n.names=[],n.skips=[];let u;const h=(typeof l=="string"?l:"").split(/[\s,]+/),b=h.length;for(u=0;u"-"+u)].join(",");return n.enable(""),l}function s(l){if(l[l.length-1]==="*")return!0;let u,h;for(u=0,h=n.skips.length;u{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 l=0,u=0;c[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(l++,h==="%c"&&(u=l))}),c.splice(u,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=xs(e);const{formatters:a}=t.exports;a.j=function(c){try{return JSON.stringify(c)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}})(qn,qn.exports);var vs=qn.exports;const fr=qi(vs);var Mi={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,l){this.fn=c,this.context=f,this.once=l||!1}function o(c,f,l,u,h){if(typeof l!="function")throw new TypeError("The listener must be a function");var b=new i(l,u||c,h),g=n?n+f:f;return c._events[g]?c._events[g].fn?c._events[g]=[c._events[g],b]:c._events[g].push(b):(c._events[g]=b,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=[],l,u;if(this._eventsCount===0)return f;for(u in l=this._events)e.call(l,u)&&f.push(n?u.slice(1):u);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(l)):f},a.prototype.listeners=function(f){var l=n?n+f:f,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,b=u.length,g=new Array(b);h0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function _s(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mn(t.outputLen),Mn(t.blockLen)}function As(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 $s(t,e){Vi(t);const n=e.outputLen;if(t.lengtht instanceof Uint8Array,Nn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Se=(t,e)=>t<<32-e|t>>>e,Ss=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ss)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Cs(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function hr(t){if(typeof t=="string"&&(t=Cs(t)),!Wi(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Bs(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!Wi(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let Gi=class{clone(){return this._cloneInto()}};function Zi(t){const e=r=>t().update(hr(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ji(t=32){if(In&&typeof In.getRandomValues=="function")return In.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Is(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 Ns=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=Nn(this.buffer)}update(e){nt.exists(this);const{view:n,buffer:r,blockLen:i}=this;e=hr(e);const o=e.length;for(let s=0;si-s&&(this.process(r,0),s=0);for(let u=s;ul.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;ut&e^~t&n,Rs=(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]),ze=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ke=new Uint32Array(64);let Yi=class extends Ns{constructor(){super(64,32,8,!1),this.A=ze[0]|0,this.B=ze[1]|0,this.C=ze[2]|0,this.D=ze[3]|0,this.E=ze[4]|0,this.F=ze[5]|0,this.G=ze[6]|0,this.H=ze[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 u=0;u<16;u++,n+=4)Ke[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const h=Ke[u-15],b=Ke[u-2],g=Se(h,7)^Se(h,18)^h>>>3,d=Se(b,17)^Se(b,19)^b>>>10;Ke[u]=d+Ke[u-7]+g+Ke[u-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:c,G:f,H:l}=this;for(let u=0;u<64;u++){const h=Se(a,6)^Se(a,11)^Se(a,25),b=l+h+Us(a,c,f)+Ts[u]+Ke[u]|0,d=(Se(r,2)^Se(r,13)^Se(r,22))+Rs(r,i,o)|0;l=f,f=c,c=a,a=s+b|0,s=o,o=i,i=r,r=b+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,l=l+this.H|0,this.set(r,i,o,s,a,c,f,l)}roundClean(){Ke.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Ls=class extends Yi{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 Vn=Zi(()=>new Yi);Zi(()=>new Ls);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qi=BigInt(0),hn=BigInt(1),Os=BigInt(2),dn=t=>t instanceof Uint8Array,Hs=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function xt(t){if(!dn(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nr+i.length,0));let n=0;return t.forEach(r=>{if(!dn(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function Ps(t,e){if(t.length!==e.length)return!1;for(let n=0;nQi;t>>=hn,e+=1);return e}function js(t,e){return t>>BigInt(e)&hn}const Ds=(t,e,n)=>t|(n?hn:Qi)<(Os<new Uint8Array(t),Dr=t=>Uint8Array.from(t);function to(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=Un(t),i=Un(t),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...u)=>n(i,r,...u),c=(u=Un())=>{i=a(Dr([0]),u),r=a(),u.length!==0&&(i=a(Dr([1]),u),r=a())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const h=[];for(;u{s(),c(u);let b;for(;!(b=h(f()));)c();return s(),b}}const qs={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 Mt(t,e,n={}){const r=(i,o,s)=>{const a=qs[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 Ms=Object.freeze(Object.defineProperty({__proto__:null,bitGet:js,bitLen:Ks,bitMask:gr,bitSet:Ds,bytesToHex:xt,bytesToNumberBE:we,bytesToNumberLE:pr,concatBytes:at,createHmacDrbg:to,ensureBytes:pe,equalBytes:Ps,hexToBytes:vt,hexToNumber:dr,numberToBytesBE:Ze,numberToBytesLE:eo,numberToHexUnpadded:Xi,numberToVarBytesBE:Fs,utf8ToBytes:zs,validateObject:Mt},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fe=BigInt(0),re=BigInt(1),Xe=BigInt(2),Vs=BigInt(3),Wn=BigInt(4),qr=BigInt(5),Mr=BigInt(8);BigInt(9);BigInt(16);function ue(t,e){const n=t%e;return n>=fe?n:e+n}function Ws(t,e,n){if(n<=fe||e 0");if(n===re)return fe;let r=re;for(;e>fe;)e&re&&(r=r*t%n),t=t*t%n,e>>=re;return r}function xe(t,e,n){let r=t;for(;e-- >fe;)r*=r,r%=n;return r}function Gn(t,e){if(t===fe||e<=fe)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ue(t,e),r=e,i=fe,o=re;for(;n!==fe;){const a=r/n,c=r%n,f=i-o*a;r=n,n=c,i=o,o=f}if(r!==re)throw new Error("invert: does not exist");return ue(i,e)}function Gs(t){const e=(t-re)/Xe;let n,r,i;for(n=t-re,r=0;n%Xe===fe;n/=Xe,r++);for(i=Xe;i(r[i]="function",r),e);return Mt(t,n)}function Qs(t,e,n){if(n 0");if(n===fe)return t.ONE;if(n===re)return e;let r=t.ONE,i=e;for(;n>fe;)n&re&&(r=t.mul(r,i)),i=t.sqr(i),n>>=re;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 yr(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ea(t,e,n=!1,r={}){if(t<=fe)throw new Error(`Expected Fp ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=yr(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Zs(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:gr(i),ZERO:fe,ONE:re,create:c=>ue(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return fe<=c&&cc===fe,isOdd:c=>(c&re)===re,neg:c=>ue(-c,t),eql:(c,f)=>c===f,sqr:c=>ue(c*c,t),add:(c,f)=>ue(c+f,t),sub:(c,f)=>ue(c-f,t),mul:(c,f)=>ue(c*f,t),pow:(c,f)=>Qs(a,c,f),div:(c,f)=>ue(c*Gn(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Gn(c,t),sqrt:r.sqrt||(c=>s(a,c)),invertBatch:c=>Xs(a,c),cmov:(c,f,l)=>l?f:c,toBytes:c=>n?eo(c,o):Ze(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return n?pr(c):we(c)}});return Object.freeze(a)}function ta(t,e,n=!1){t=pe("privateHash",t);const r=t.length,i=yr(e).nByteLength+8;if(i<24||r1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);const o=n?pr(t):we(t);return ue(o,e-re)+re}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const na=BigInt(0),Rn=BigInt(1);function ra(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>na;)o&Rn&&(s=s.add(a)),a=a.double(),o>>=Rn;return s},precomputeWindow(i,o){const{windows:s,windowSize:a}=r(o),c=[];let f=i,l=f;for(let u=0;u>=b,p>c&&(p-=h,s+=Rn);const y=d,m=d+Math.abs(p)-1,v=g%2!==0,B=p<0;p===0?l=l.add(n(v,o[y])):f=f.add(n(B,o[m]))}return{p:f,f:l}},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 no(t){return Ys(t.Fp),Mt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...yr(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ia(t){const e=no(t);Mt(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:oa,hexToBytes:sa}=Ms,rt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=rt;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:oa(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=rt,n=typeof t=="string"?sa(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}=rt._parseInt(n.subarray(2)),{d:s,l:a}=rt._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 l=f.toString(16);return l.length&1?`0${l}`:l},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}`}},Re=BigInt(0),ve=BigInt(1);BigInt(2);const Vr=BigInt(3);BigInt(4);function aa(t){const e=ia(t),{Fp:n}=e,r=e.toBytes||((g,d,p)=>{const y=d.toAffine();return at(Uint8Array.from([4]),n.toBytes(y.x),n.toBytes(y.y))}),i=e.fromBytes||(g=>{const d=g.subarray(1),p=n.fromBytes(d.subarray(0,n.BYTES)),y=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:p,y}});function o(g){const{a:d,b:p}=e,y=n.sqr(g),m=n.mul(y,g);return n.add(n.add(m,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"&&Ren.eql(v,n.ZERO);return m(p)&&m(y)?u.ZERO:new u(p,y,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const p=n.invertBatch(d.map(y=>y.pz));return d.map((y,m)=>y.toAffine(p[m])).map(u.fromAffine)}static fromHex(d){const p=u.fromAffine(i(pe("pointHex",d)));return p.assertValidity(),p}static fromPrivateKey(d){return u.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 y=n.sqr(p),m=o(d);if(!n.eql(y,m))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){l(d);const{px:p,py:y,pz:m}=this,{px:v,py:B,pz:C}=d,A=n.eql(n.mul(p,C),n.mul(v,m)),$=n.eql(n.mul(y,C),n.mul(B,m));return A&&$}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b:p}=e,y=n.mul(p,Vr),{px:m,py:v,pz:B}=this;let C=n.ZERO,A=n.ZERO,$=n.ZERO,N=n.mul(m,m),R=n.mul(v,v),L=n.mul(B,B),w=n.mul(m,v);return w=n.add(w,w),$=n.mul(m,B),$=n.add($,$),C=n.mul(d,$),A=n.mul(y,L),A=n.add(C,A),C=n.sub(R,A),A=n.add(R,A),A=n.mul(C,A),C=n.mul(w,C),$=n.mul(y,$),L=n.mul(d,L),w=n.sub(N,L),w=n.mul(d,w),w=n.add(w,$),$=n.add(N,N),N=n.add($,N),N=n.add(N,L),N=n.mul(N,w),A=n.add(A,N),L=n.mul(v,B),L=n.add(L,L),N=n.mul(L,w),C=n.sub(C,N),$=n.mul(L,R),$=n.add($,$),$=n.add($,$),new u(C,A,$)}add(d){l(d);const{px:p,py:y,pz:m}=this,{px:v,py:B,pz:C}=d;let A=n.ZERO,$=n.ZERO,N=n.ZERO;const R=e.a,L=n.mul(e.b,Vr);let w=n.mul(p,v),E=n.mul(y,B),_=n.mul(m,C),U=n.add(p,y),x=n.add(v,B);U=n.mul(U,x),x=n.add(w,E),U=n.sub(U,x),x=n.add(p,m);let k=n.add(v,C);return x=n.mul(x,k),k=n.add(w,_),x=n.sub(x,k),k=n.add(y,m),A=n.add(B,C),k=n.mul(k,A),A=n.add(E,_),k=n.sub(k,A),N=n.mul(R,x),A=n.mul(L,_),N=n.add(A,N),A=n.sub(E,N),N=n.add(E,N),$=n.mul(A,N),E=n.add(w,w),E=n.add(E,w),_=n.mul(R,_),x=n.mul(L,x),E=n.add(E,_),_=n.sub(w,_),_=n.mul(R,_),x=n.add(x,_),w=n.mul(E,x),$=n.add($,w),w=n.mul(k,x),A=n.mul(U,A),A=n.sub(A,w),w=n.mul(U,E),N=n.mul(k,N),N=n.add(N,w),new u(A,$,N)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return b.wNAFCached(this,f,d,p=>{const y=n.invertBatch(p.map(m=>m.pz));return p.map((m,v)=>m.toAffine(y[v])).map(u.fromAffine)})}multiplyUnsafe(d){const p=u.ZERO;if(d===Re)return p;if(a(d),d===ve)return this;const{endo:y}=e;if(!y)return b.unsafeLadder(this,d);let{k1neg:m,k1:v,k2neg:B,k2:C}=y.splitScalar(d),A=p,$=p,N=this;for(;v>Re||C>Re;)v&ve&&(A=A.add(N)),C&ve&&($=$.add(N)),N=N.double(),v>>=ve,C>>=ve;return m&&(A=A.negate()),B&&($=$.negate()),$=new u(n.mul($.px,y.beta),$.py,$.pz),A.add($)}multiply(d){a(d);let p=d,y,m;const{endo:v}=e;if(v){const{k1neg:B,k1:C,k2neg:A,k2:$}=v.splitScalar(p);let{p:N,f:R}=this.wNAF(C),{p:L,f:w}=this.wNAF($);N=b.constTimeNegate(B,N),L=b.constTimeNegate(A,L),L=new u(n.mul(L.px,v.beta),L.py,L.pz),y=N.add(L),m=R.add(w)}else{const{p:B,f:C}=this.wNAF(p);y=B,m=C}return u.normalizeZ([y,m])[0]}multiplyAndAddUnsafe(d,p,y){const m=u.BASE,v=(C,A)=>A===Re||A===ve||!C.equals(m)?C.multiplyUnsafe(A):C.multiply(A),B=v(this,p).add(v(d,y));return B.is0()?void 0:B}toAffine(d){const{px:p,py:y,pz:m}=this,v=this.is0();d==null&&(d=v?n.ONE:n.inv(m));const B=n.mul(p,d),C=n.mul(y,d),A=n.mul(m,d);if(v)return{x:n.ZERO,y:n.ZERO};if(!n.eql(A,n.ONE))throw new Error("invZ was invalid");return{x:B,y:C}}isTorsionFree(){const{h:d,isTorsionFree:p}=e;if(d===ve)return!0;if(p)return p(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:d,clearCofactor:p}=e;return d===ve?this:p?p(u,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),r(u,this,d)}toHex(d=!0){return xt(this.toRawBytes(d))}}u.BASE=new u(e.Gx,e.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const h=e.nBitLength,b=ra(u,e.endo?Math.ceil(h/2):h);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function ca(t){const e=no(t);return Mt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function la(t){const e=ca(t),{Fp:n,n:r}=e,i=n.BYTES+1,o=2*n.BYTES+1;function s(x){return Rext(Ze(x,e.nByteLength));function g(x){const k=r>>ve;return x>k}function d(x){return g(x)?a(-x):x}const p=(x,k,S)=>we(x.slice(k,S));class y{constructor(k,S,O){this.r=k,this.s=S,this.recovery=O,this.assertValidity()}static fromCompact(k){const S=e.nByteLength;return k=pe("compactSignature",k,S*2),new y(p(k,0,S),p(k,S,2*S))}static fromDER(k){const{r:S,s:O}=rt.toSig(pe("DER",k));return new y(S,O)}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(k){return new y(this.r,this.s,k)}recoverPublicKey(k){const{r:S,s:O,recovery:I}=this,z=$(pe("msgHash",k));if(I==null||![0,1,2,3].includes(I))throw new Error("recovery id invalid");const T=I===2||I===3?S+e.n:S;if(T>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const F=I&1?"03":"02",G=f.fromHex(F+b(T)),Y=c(T),oe=a(-z*Y),se=a(O*Y),ne=f.BASE.multiplyAndAddUnsafe(G,oe,se);if(!ne)throw new Error("point at infinify");return ne.assertValidity(),ne}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return vt(this.toDERHex())}toDERHex(){return rt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return vt(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}const m={isValidPrivateKey(x){try{return l(x),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const x=e.randomBytes(n.BYTES+8),k=ta(x,r);return Ze(k,e.nByteLength)},precompute(x=8,k=f.BASE){return k._setWindowSize(x),k.multiply(BigInt(3)),k}};function v(x,k=!0){return f.fromPrivateKey(x).toRawBytes(k)}function B(x){const k=x instanceof Uint8Array,S=typeof x=="string",O=(k||S)&&x.length;return k?O===i||O===o:S?O===2*i||O===2*o:x instanceof f}function C(x,k,S=!0){if(B(x))throw new Error("first arg must be private key");if(!B(k))throw new Error("second arg must be public key");return f.fromHex(k).multiply(l(x)).toRawBytes(S)}const A=e.bits2int||function(x){const k=we(x),S=x.length*8-e.nBitLength;return S>0?k>>BigInt(S):k},$=e.bits2int_modN||function(x){return a(A(x))},N=gr(e.nBitLength);function R(x){if(typeof x!="bigint")throw new Error("bigint expected");if(!(Re<=x&&xW in S))throw new Error("sign() legacy options not supported");const{hash:O,randomBytes:I}=e;let{lowS:z,prehash:T,extraEntropy:F}=S;z==null&&(z=!0),x=pe("msgHash",x),T&&(x=pe("prehashed msgHash",O(x)));const G=$(x),Y=l(k),oe=[R(Y),R(G)];if(F!=null){const W=F===!0?I(n.BYTES):F;oe.push(pe("extraEntropy",W,n.BYTES))}const se=at(...oe),ne=G;function ge(W){const J=A(W);if(!h(J))return;const be=c(J),ce=f.BASE.multiply(J).toAffine(),X=a(ce.x);if(X===Re)return;const le=a(be*a(ne+X*Y));if(le===Re)return;let ke=(ce.x===X?0:2)|Number(ce.y&ve),_e=le;return z&&g(le)&&(_e=d(le),ke^=1),new y(X,_e,ke)}return{seed:se,k2sig:ge}}const w={lowS:e.lowS,prehash:!1},E={lowS:e.lowS,prehash:!1};function _(x,k,S=w){const{seed:O,k2sig:I}=L(x,k,S),z=e;return to(z.hash.outputLen,z.nByteLength,z.hmac)(O,I)}f.BASE._setWindowSize(8);function U(x,k,S,O=E){var ce;const I=x;if(k=pe("msgHash",k),S=pe("publicKey",S),"strict"in O)throw new Error("options.strict was renamed to lowS");const{lowS:z,prehash:T}=O;let F,G;try{if(typeof I=="string"||I instanceof Uint8Array)try{F=y.fromDER(I)}catch(X){if(!(X instanceof rt.Err))throw X;F=y.fromCompact(I)}else if(typeof I=="object"&&typeof I.r=="bigint"&&typeof I.s=="bigint"){const{r:X,s:le}=I;F=new y(X,le)}else throw new Error("PARSE");G=f.fromHex(S)}catch(X){if(X.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(z&&F.hasHighS())return!1;T&&(k=e.hash(k));const{r:Y,s:oe}=F,se=$(k),ne=c(oe),ge=a(se*ne),W=a(Y*ne),J=(ce=f.BASE.multiplyAndAddUnsafe(G,ge,W))==null?void 0:ce.toAffine();return J?a(J.x)===Y:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:C,sign:_,verify:U,ProjectivePoint:f,Signature:y,utils:m}}let ro=class extends Gi{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,nt.hash(e);const r=hr(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;snew ro(t,e).update(n).digest();io.create=(t,e)=>new ro(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ua(t){return{hash:t,hmac:(e,...n)=>io(t,e,Bs(...n)),randomBytes:Ji}}function fa(t,e){const n=r=>la({...t,...ua(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pn=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),sn=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),oo=BigInt(1),an=BigInt(2),Wr=(t,e)=>(t+e/an)/e;function so(t){const e=pn,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,l=f*f*t%e,u=xe(l,n,e)*l%e,h=xe(u,n,e)*l%e,b=xe(h,an,e)*f%e,g=xe(b,i,e)*b%e,d=xe(g,o,e)*g%e,p=xe(d,a,e)*d%e,y=xe(p,c,e)*p%e,m=xe(y,a,e)*d%e,v=xe(m,n,e)*l%e,B=xe(v,s,e)*g%e,C=xe(B,r,e)*f%e,A=xe(C,an,e);if(!Zn.eql(Zn.sqr(A),t))throw new Error("Cannot find square root");return A}const Zn=ea(pn,void 0,void 0,{sqrt:so}),ye=fa({a:BigInt(0),b:BigInt(7),Fp:Zn,n:sn,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=sn,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-oo*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Wr(o*t,e),c=Wr(-r*t,e);let f=ue(t-a*n-c*i,e),l=ue(-a*r-c*o,e);const u=f>s,h=l>s;if(u&&(f=e-f),h&&(l=e-l),f>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:f,k2neg:h,k2:l}}}},Vn),gn=BigInt(0),ao=t=>typeof t=="bigint"&&gntypeof t=="bigint"&&gni.charCodeAt(0)));n=at(r,r),Gr[t]=n}return Vn(at(n,...e))}const br=t=>t.toRawBytes(!0).slice(1),Jn=t=>Ze(t,32),Tn=t=>ue(t,pn),Kt=t=>ue(t,sn),wr=ye.ProjectivePoint,da=(t,e,n)=>wr.BASE.multiplyAndAddUnsafe(t,e,n);function Yn(t){let e=ye.utils.normPrivateKeyToScalar(t),n=wr.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Kt(-e),bytes:br(n)}}function co(t){if(!ao(t))throw new Error("bad x: need 0 < x < p");const e=Tn(t*t),n=Tn(e*t+BigInt(7));let r=so(n);r%an!==gn&&(r=Tn(-r));const i=new wr(t,r,oo);return i.assertValidity(),i}function lo(...t){return Kt(we(cn("BIP0340/challenge",...t)))}function pa(t){return Yn(t).bytes}function ga(t,e,n=Ji(32)){const r=pe("message",t),{bytes:i,scalar:o}=Yn(e),s=pe("auxRand",n,32),a=Jn(o^we(cn("BIP0340/aux",s))),c=cn("BIP0340/nonce",a,i,r),f=Kt(we(c));if(f===gn)throw new Error("sign failed: k is zero");const{bytes:l,scalar:u}=Yn(f),h=lo(l,i,r),b=new Uint8Array(64);if(b.set(l,0),b.set(Jn(Kt(u+h*o)),32),!uo(b,r,i))throw new Error("sign: Invalid signature produced");return b}function uo(t,e,n){const r=pe("signature",t,64),i=pe("message",e),o=pe("publicKey",n,32);try{const s=co(we(o)),a=we(r.subarray(0,32));if(!ao(a))return!1;const c=we(r.subarray(32,64));if(!ha(c))return!1;const f=lo(Jn(a),br(s),i),l=da(s,c,Kt(-f));return!(!l||!l.hasEvenY()||l.toAffine().x!==a)}catch{return!1}}const Vt=(()=>({getPublicKey:pa,sign:ga,verify:uo,utils:{randomPrivateKey:ye.utils.randomPrivateKey,lift_x:co,pointToBytes:br,numberToBytesBE:Ze,bytesToNumberBE:we,taggedHash:cn,mod:ue}}))(),Ln=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mr=t=>t instanceof Uint8Array,On=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ce=(t,e)=>t<<32-e|t>>>e,ya=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ya)throw new Error("Non little-endian hardware is not supported");const ba=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ae(t){if(!mr(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nr+i.length,0));let n=0;return t.forEach(r=>{if(!mr(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let xa=class{clone(){return this._cloneInto()}};function ho(t){const e=r=>t().update(fo(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function po(t=32){if(Ln&&typeof Ln.getRandomValues=="function")return Ln.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Qn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function va(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function go(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 Ea(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Qn(t.outputLen),Qn(t.blockLen)}function ka(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 _a(t,e){go(t);const n=e.outputLen;if(t.length>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 $a=class extends xa{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=On(this.buffer)}update(e){Hn.exists(this);const{view:n,buffer:r,blockLen:i}=this;e=fo(e);const o=e.length;for(let s=0;si-s&&(this.process(r,0),s=0);for(let u=s;ul.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;ut&e^~t&n,Ca=(t,e,n)=>t&e^t&n^e&n,Ba=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]),je=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),De=new Uint32Array(64);let yo=class extends $a{constructor(){super(64,32,8,!1),this.A=je[0]|0,this.B=je[1]|0,this.C=je[2]|0,this.D=je[3]|0,this.E=je[4]|0,this.F=je[5]|0,this.G=je[6]|0,this.H=je[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 u=0;u<16;u++,n+=4)De[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const h=De[u-15],b=De[u-2],g=Ce(h,7)^Ce(h,18)^h>>>3,d=Ce(b,17)^Ce(b,19)^b>>>10;De[u]=d+De[u-7]+g+De[u-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:c,G:f,H:l}=this;for(let u=0;u<64;u++){const h=Ce(a,6)^Ce(a,11)^Ce(a,25),b=l+h+Sa(a,c,f)+Ba[u]+De[u]|0,d=(Ce(r,2)^Ce(r,13)^Ce(r,22))+Ca(r,i,o)|0;l=f,f=c,c=a,a=s+b|0,s=o,o=i,i=r,r=b+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,l=l+this.H|0,this.set(r,i,o,s,a,c,f,l)}roundClean(){De.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class Ia extends yo{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 yn=ho(()=>new yo);ho(()=>new Ia);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ct(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function He(...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 Fe(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(Ct(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 Pe(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 bn(t,e="="){if(Ct(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 bo(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}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(Ct(s),s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let c=r;ce?wo(e,t%e):t,ln=(t,e)=>t+(e-wo(t,e));function Xn(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(ln(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${ln(e,n)}`);let i=0,o=0;const s=2**n-1,a=[];for(const c of t){if(Ct(c),c>=2**e)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(i=i<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<=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 Na(t){return Ct(t),{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 Qe(t,e=!1){if(Ct(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(ln(8,t)>32||ln(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 Xn(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(Xn(n,t,8,e))}}}function Jr(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Ua=He(Qe(4),Fe("0123456789ABCDEF"),Pe("")),Ra=He(Qe(5),Fe("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),bn(5),Pe(""));He(Qe(5),Fe("0123456789ABCDEFGHIJKLMNOPQRSTUV"),bn(5),Pe(""));He(Qe(5),Fe("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Pe(""),bo(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const Le=He(Qe(6),Fe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),bn(6),Pe("")),Ta=He(Qe(6),Fe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),bn(6),Pe("")),xr=t=>He(Na(58),Fe(t),Pe("")),er=xr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");xr("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");xr("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Yr=[0,2,3,5,6,7,9,10,11],La={encode(t){let e="";for(let n=0;n>25;let n=(t&33554431)<<5;for(let r=0;r>r&1)===1&&(n^=Qr[r]);return n}function Xr(t,e,n=1){const r=t.length;let i=1;for(let o=0;o126)throw new Error(`Invalid prefix (${t})`);i=Ht(i)^s>>5}i=Ht(i);for(let o=0;oh)throw new TypeError(`Length ${b} exceeds limit ${h}`);return l=l.toLowerCase(),`${l}1${tr.encode(u)}${Xr(l,u,e)}`}function a(l,u=90){if(typeof l!="string")throw new Error(`bech32.decode input should be string, not ${typeof l}`);if(l.length<8||u!==!1&&l.length>u)throw new TypeError(`Wrong string length: ${l.length} (${l}). Expected (8..${u})`);const h=l.toLowerCase();if(l!==h&&l!==l.toUpperCase())throw new Error("String must be lowercase or uppercase");l=h;const b=l.lastIndexOf("1");if(b===0||b===-1)throw new Error('Letter "1" must be present between prefix and data only');const g=l.slice(0,b),d=l.slice(b+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const p=tr.decode(d).slice(0,-6),y=Xr(g,p,e);if(!d.endsWith(y))throw new Error(`Invalid checksum in ${l}: expected "${y}"`);return{prefix:g,words:p}}const c=Jr(a);function f(l){const{prefix:u,words:h}=a(l,!1);return{prefix:u,words:h,bytes:r(h)}}return{encode:s,decode:a,decodeToBytes:f,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:o,toWords:i}}const kt=mo("bech32");mo("bech32m");const Oa={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},Ha=He(Qe(4),Fe("0123456789abcdef"),Pe(""),bo(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()})),Fa={utf8:Oa,hex:Ha,base16:Ua,base32:Ra,base64:Le,base64url:Ta,base58:er,base58xmr:La};`${Object.keys(Fa).join(", ")}`;const xo=`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 wt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Pa(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Ge(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 vr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");wt(t.outputLen),wt(t.blockLen)}function jt(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){Ge(t);const n=e.outputLen;if(t.lengtht instanceof Uint8Array,it=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Be=(t,e)=>t<<32-e|t>>>e,Ka=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ka)throw new Error("Non little-endian hardware is not supported");const ja=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ko(t){if(!Er(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nr+i.length,0));let n=0;return t.forEach(r=>{if(!Er(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class Ao{clone(){return this._cloneInto()}}const qa={}.toString;function Ma(t,e){if(e!==void 0&&qa.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function kr(t){const e=r=>t().update(Dt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Va(t=32){if(Fn&&typeof Fn.getRandomValues=="function")return Fn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class $o extends Ao{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,vr(e);const r=Dt(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;snew $o(t,e).update(n).digest();un.create=(t,e)=>new $o(t,e);function Wa(t,e,n,r){vr(t);const i=Ma({dkLen:32,asyncTick:10},r),{c:o,dkLen:s,asyncTick:a}=i;if(wt(o),wt(s),wt(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=Dt(e),f=Dt(n),l=new Uint8Array(s),u=un.create(t,c),h=u._cloneInto().update(f);return{c:o,dkLen:s,asyncTick:a,DK:l,PRF:u,PRFSalt:h}}function Ga(t,e,n,r,i){return t.destroy(),e.destroy(),r&&r.destroy(),i.fill(0),n}function Za(t,e,n,r){const{c:i,dkLen:o,DK:s,PRF:a,PRFSalt:c}=Wa(t,e,n,r);let f;const l=new Uint8Array(4),u=it(l),h=new Uint8Array(a.outputLen);for(let b=1,g=0;g>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 _r extends Ao{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=it(this.buffer)}update(e){jt(this);const{view:n,buffer:r,blockLen:i}=this;e=Dt(e);const o=e.length;for(let s=0;si-s&&(this.process(r,0),s=0);for(let u=s;ul.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;ut&e^~t&n,Qa=(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]),qe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Me=new Uint32Array(64);class ec extends _r{constructor(){super(64,32,8,!1),this.A=qe[0]|0,this.B=qe[1]|0,this.C=qe[2]|0,this.D=qe[3]|0,this.E=qe[4]|0,this.F=qe[5]|0,this.G=qe[6]|0,this.H=qe[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 u=0;u<16;u++,n+=4)Me[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const h=Me[u-15],b=Me[u-2],g=Be(h,7)^Be(h,18)^h>>>3,d=Be(b,17)^Be(b,19)^b>>>10;Me[u]=d+Me[u-7]+g+Me[u-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:c,G:f,H:l}=this;for(let u=0;u<64;u++){const h=Be(a,6)^Be(a,11)^Be(a,25),b=l+h+Ya(a,c,f)+Xa[u]+Me[u]|0,d=(Be(r,2)^Be(r,13)^Be(r,22))+Qa(r,i,o)|0;l=f,f=c,c=a,a=s+b|0,s=o,o=i,i=r,r=b+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,l=l+this.H|0,this.set(r,i,o,s,a,c,f,l)}roundClean(){Me.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const wn=kr(()=>new ec),Jt=BigInt(2**32-1),nr=BigInt(32);function So(t,e=!1){return e?{h:Number(t&Jt),l:Number(t>>nr&Jt)}:{h:Number(t>>nr&Jt)|0,l:Number(t&Jt)|0}}function tc(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;iBigInt(t>>>0)<>>0),rc=(t,e,n)=>t>>>n,ic=(t,e,n)=>t<<32-n|e>>>n,oc=(t,e,n)=>t>>>n|e<<32-n,sc=(t,e,n)=>t<<32-n|e>>>n,ac=(t,e,n)=>t<<64-n|e>>>n-32,cc=(t,e,n)=>t>>>n-32|e<<64-n,lc=(t,e)=>e,uc=(t,e)=>t,fc=(t,e,n)=>t<>>32-n,hc=(t,e,n)=>e<>>32-n,dc=(t,e,n)=>e<>>64-n,pc=(t,e,n)=>t<>>64-n;function gc(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:i|0}}const yc=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),bc=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,wc=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),mc=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,xc=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),vc=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,Ec={fromBig:So,split:tc,toBig:nc,shrSH:rc,shrSL:ic,rotrSH:oc,rotrSL:sc,rotrBH:ac,rotrBL:cc,rotr32H:lc,rotr32L:uc,rotlSH:fc,rotlSL:hc,rotlBH:dc,rotlBL:pc,add:gc,add3L:yc,add3H:bc,add4L:wc,add4H:mc,add5H:vc,add5L:xc},V=Ec,[kc,_c]=(()=>V.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))))(),Ve=new Uint32Array(80),We=new Uint32Array(80);class Ac extends _r{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:l,Fh:u,Fl:h,Gh:b,Gl:g,Hh:d,Hl:p}=this;return[e,n,r,i,o,s,a,c,f,l,u,h,b,g,d,p]}set(e,n,r,i,o,s,a,c,f,l,u,h,b,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=l|0,this.Fh=u|0,this.Fl=h|0,this.Gh=b|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)Ve[v]=e.getUint32(n),We[v]=e.getUint32(n+=4);for(let v=16;v<80;v++){const B=Ve[v-15]|0,C=We[v-15]|0,A=V.rotrSH(B,C,1)^V.rotrSH(B,C,8)^V.shrSH(B,C,7),$=V.rotrSL(B,C,1)^V.rotrSL(B,C,8)^V.shrSL(B,C,7),N=Ve[v-2]|0,R=We[v-2]|0,L=V.rotrSH(N,R,19)^V.rotrBH(N,R,61)^V.shrSH(N,R,6),w=V.rotrSL(N,R,19)^V.rotrBL(N,R,61)^V.shrSL(N,R,6),E=V.add4L($,w,We[v-7],We[v-16]),_=V.add4H(E,A,L,Ve[v-7],Ve[v-16]);Ve[v]=_|0,We[v]=E|0}let{Ah:r,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:f,Dl:l,Eh:u,El:h,Fh:b,Fl:g,Gh:d,Gl:p,Hh:y,Hl:m}=this;for(let v=0;v<80;v++){const B=V.rotrSH(u,h,14)^V.rotrSH(u,h,18)^V.rotrBH(u,h,41),C=V.rotrSL(u,h,14)^V.rotrSL(u,h,18)^V.rotrBL(u,h,41),A=u&b^~u&d,$=h&g^~h&p,N=V.add5L(m,C,$,_c[v],We[v]),R=V.add5H(N,y,B,A,kc[v],Ve[v]),L=N|0,w=V.rotrSH(r,i,28)^V.rotrBH(r,i,34)^V.rotrBH(r,i,39),E=V.rotrSL(r,i,28)^V.rotrBL(r,i,34)^V.rotrBL(r,i,39),_=r&o^r&a^o&a,U=i&s^i&c^s&c;y=d|0,m=p|0,d=b|0,p=g|0,b=u|0,g=h|0,{h:u,l:h}=V.add(f|0,l|0,R|0,L|0),f=a|0,l=c|0,a=o|0,c=s|0,o=r|0,s=i|0;const x=V.add3L(L,E,U);r=V.add3H(x,R,w,_),i=x|0}({h:r,l:i}=V.add(this.Ah|0,this.Al|0,r|0,i|0)),{h:o,l:s}=V.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=V.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l}=V.add(this.Dh|0,this.Dl|0,f|0,l|0),{h:u,l:h}=V.add(this.Eh|0,this.El|0,u|0,h|0),{h:b,l:g}=V.add(this.Fh|0,this.Fl|0,b|0,g|0),{h:d,l:p}=V.add(this.Gh|0,this.Gl|0,d|0,p|0),{h:y,l:m}=V.add(this.Hh|0,this.Hl|0,y|0,m|0),this.set(r,i,o,s,a,c,f,l,u,h,b,g,d,p,y,m)}roundClean(){Ve.fill(0),We.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 rr=kr(()=>new Ac);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mn(...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 Ar(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 $r(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 $c(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 ei(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;ce?Co(e,t%e):t,fn=(t,e)=>t+(e-Co(t,e));function ir(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(fn(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${fn(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<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<=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 Bo(t){return{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return ei(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(ei(e,t,2**8))}}}function Io(t,e=!1){if(t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(fn(8,t)>32||fn(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 ir(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(ir(n,t,8,e))}}}function ti(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}function No(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;smn(Bo(58),Ar(t),$r("")),Cc=Sc("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Bc=t=>mn(No(4,e=>t(t(e))),Cc),or=mn(Ar("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),$r("")),ni=[996825010,642813549,513874426,1027748829,705979059];function Ft(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r>r&1)===1&&(n^=ni[r]);return n}function ri(t,e,n=1){const r=t.length;let i=1;for(let o=0;o126)throw new Error(`Invalid prefix (${t})`);i=Ft(i)^s>>5}i=Ft(i);for(let o=0;oh)throw new TypeError(`Length ${b} exceeds limit ${h}`);const g=l.toLowerCase(),d=ri(g,u,e);return`${g}1${or.encode(u)}${d}`}function a(l,u=90){if(typeof l!="string")throw new Error(`bech32.decode input should be string, not ${typeof l}`);if(l.length<8||u!==!1&&l.length>u)throw new TypeError(`Wrong string length: ${l.length} (${l}). Expected (8..${u})`);const h=l.toLowerCase();if(l!==h&&l!==l.toUpperCase())throw new Error("String must be lowercase or uppercase");l=h;const b=l.lastIndexOf("1");if(b===0||b===-1)throw new Error('Letter "1" must be present between prefix and data only');const g=l.slice(0,b),d=l.slice(b+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const p=or.decode(d).slice(0,-6),y=ri(g,p,e);if(!d.endsWith(y))throw new Error(`Invalid checksum in ${l}: expected "${y}"`);return{prefix:g,words:p}}const c=ti(a);function f(l){const{prefix:u,words:h}=a(l,!1);return{prefix:u,words:h,bytes:r(h)}}return{encode:s,decode:a,decodeToBytes:f,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:o,toWords:i}}const ii=Ic("bech32"),Nc=t=>t[0]==="あいこくしん";function Uo(t){if(typeof t!="string")throw new TypeError(`Invalid mnemonic type: ${typeof t}`);return t.normalize("NFKD")}function Ro(t){const e=Uo(t),n=e.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:n}}function To(t){Eo.bytes(t,16,20,24,28,32)}function Uc(t,e=128){if(Eo.number(e),e%32!==0||e>256)throw new TypeError("Invalid entropy");return Lc(Va(e/8),t)}const Rc=t=>{const e=8-t.length/4;return new Uint8Array([wn(t)[0]>>e<{if(typeof e!="string")throw new Error(`Wordlist: non-string element: ${e}`)}),Yt.chain(Yt.checksum(1,Rc),Yt.radix2(11,!0),Yt.alphabet(t))}function Tc(t,e){const{words:n}=Ro(t),r=Lo(e).decode(n);return To(r),r}function Lc(t,e){return To(t),Lo(e).encode(t).join(Nc(e)?" ":" ")}function Oc(t,e){try{Tc(t,e)}catch{return!1}return!0}const Hc=t=>Uo(`mnemonic${t}`);function Fc(t,e=""){return Za(rr,Ro(t).nfkd,Hc(e),{c:2048,dkLen:64})}const Pc=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Oo=Uint8Array.from({length:16},(t,e)=>e),zc=Oo.map(t=>(9*t+5)%16);let Sr=[Oo],Cr=[zc];for(let t=0;t<4;t++)for(let e of[Sr,Cr])e.push(e[t].map(n=>Pc[n]));const Ho=[[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)),Kc=Sr.map((t,e)=>t.map(n=>Ho[e][n])),jc=Cr.map((t,e)=>t.map(n=>Ho[e][n])),Dc=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),qc=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),Qt=(t,e)=>t<>>32-e;function oi(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 Xt=new Uint32Array(16);class Mc extends _r{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 b=0;b<16;b++,n+=4)Xt[b]=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,l=f,u=this.h4|0,h=u;for(let b=0;b<5;b++){const g=4-b,d=Dc[b],p=qc[b],y=Sr[b],m=Cr[b],v=Kc[b],B=jc[b];for(let C=0;C<16;C++){const A=Qt(r+oi(b,o,a,f)+Xt[y[C]]+d,v[C])+u|0;r=u,u=f,f=Qt(a,10)|0,a=o,o=A}for(let C=0;C<16;C++){const A=Qt(i+oi(g,s,c,l)+Xt[m[C]]+p,B[C])+h|0;i=h,h=l,l=Qt(c,10)|0,c=s,s=A}}this.set(this.h1+a+l|0,this.h2+f+h|0,this.h3+u+i|0,this.h4+r+s|0,this.h0+o+c|0)}roundClean(){Xt.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Vc=kr(()=>new Mc),en=ye.ProjectivePoint,Pn=Bc(wn);function si(t){return BigInt(`0x${ko(t)}`)}function Wc(t){return Da(t.toString(16).padStart(64,"0"))}const Gc=_o("Bitcoin seed"),zn={private:76066276,public:76067358},Kn=2147483648,Zc=t=>Vc(wn(t)),Jc=t=>it(t).getUint32(0,!1),tn=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 it(e).setUint32(0,t,!1),e};class et{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return Jc(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 Pn.encode(this.serialize(this.versions.private,Zt(new Uint8Array([0]),e)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return Pn.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(e,n=zn){if(Ge(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=un(rr,Gc,e);return new et({versions:n,chainCode:r.slice(32),privateKey:r.slice(0,32)})}static fromExtendedKey(e,n=zn){const r=Pn.decode(e),i=it(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 et({...s,privateKey:a.slice(1)}):new et({...s,publicKey:a})}static fromJSON(e){return et.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||zn,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(!ye.utils.isValidPrivateKey(e.privateKey))throw new Error("Invalid private key");this.privKey=typeof e.privateKey=="bigint"?e.privateKey:si(e.privateKey),this.privKeyBytes=Wc(this.privKey),this.pubKey=ye.getPublicKey(e.privateKey,!0)}else if(e.publicKey)this.pubKey=en.fromHex(e.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=Zc(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>=Kn)throw new Error("Invalid index");o[2]==="'"&&(s+=Kn),r=r.deriveChild(s)}return r}deriveChild(e){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=tn(e);if(e>=Kn){const a=this.privateKey;if(!a)throw new Error("Could not derive hardened child key");n=Zt(new Uint8Array([0]),a,n)}else n=Zt(this.pubKey,n);const r=un(rr,this.chainCode,n),i=si(r.slice(0,32)),o=r.slice(32);if(!ye.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=ue(this.privKey+i,ye.CURVE.n);if(!ye.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=en.fromHex(this.pubKey).add(en.fromPrivateKey(i));if(a.equals(en.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");s.publicKey=a.toRawBytes(!0)}return new et(s)}catch{return this.deriveChild(e+1)}}sign(e){if(!this.privateKey)throw new Error("No privateKey set!");return Ge(e,32),ye.sign(e,this.privKey).toCompactRawBytes()}verify(e,n){if(Ge(e,32),Ge(n,64),!this.publicKey)throw new Error("No publicKey set!");let r;try{r=ye.Signature.fromCompact(n)}catch{return!1}return ye.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 Ge(n,33),Zt(tn(e),new Uint8Array([this.depth]),tn(this.parentFingerprint),tn(this.index),this.chainCode,n)}}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const Yc=t=>t instanceof Uint8Array,Ie=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Qc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Qc)throw new Error("Non little-endian hardware is not supported");function Br(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function sr(t){if(typeof t=="string"&&(t=Br(t)),!Yc(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 el(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 tl(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 ar(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function nl(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Fo(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 rl(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("hash must be wrapped by utils.wrapConstructor");ar(t.outputLen),ar(t.blockLen)}function il(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 ol(t,e){Fo(t);const n=e.outputLen;if(t.lengtht[e++]&255|(t[e++]&255)<<8;class sl{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=sr(e),tl(e,32);const n=de(e,0),r=de(e,2),i=de(e,4),o=de(e,6),s=de(e,8),a=de(e,10),c=de(e,12),f=de(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 l=0;l<8;l++)this.pad[l]=de(e,16+2*l)}process(e,n,r=!1){const i=r?0:2048,{h:o,r:s}=this,a=s[0],c=s[1],f=s[2],l=s[3],u=s[4],h=s[5],b=s[6],g=s[7],d=s[8],p=s[9],y=de(e,n+0),m=de(e,n+2),v=de(e,n+4),B=de(e,n+6),C=de(e,n+8),A=de(e,n+10),$=de(e,n+12),N=de(e,n+14);let R=o[0]+(y&8191),L=o[1]+((y>>>13|m<<3)&8191),w=o[2]+((m>>>10|v<<6)&8191),E=o[3]+((v>>>7|B<<9)&8191),_=o[4]+((B>>>4|C<<12)&8191),U=o[5]+(C>>>1&8191),x=o[6]+((C>>>14|A<<2)&8191),k=o[7]+((A>>>11|$<<5)&8191),S=o[8]+(($>>>8|N<<8)&8191),O=o[9]+(N>>>5|i),I=0,z=I+R*a+L*(5*p)+w*(5*d)+E*(5*g)+_*(5*b);I=z>>>13,z&=8191,z+=U*(5*h)+x*(5*u)+k*(5*l)+S*(5*f)+O*(5*c),I+=z>>>13,z&=8191;let T=I+R*c+L*a+w*(5*p)+E*(5*d)+_*(5*g);I=T>>>13,T&=8191,T+=U*(5*b)+x*(5*h)+k*(5*u)+S*(5*l)+O*(5*f),I+=T>>>13,T&=8191;let F=I+R*f+L*c+w*a+E*(5*p)+_*(5*d);I=F>>>13,F&=8191,F+=U*(5*g)+x*(5*b)+k*(5*h)+S*(5*u)+O*(5*l),I+=F>>>13,F&=8191;let G=I+R*l+L*f+w*c+E*a+_*(5*p);I=G>>>13,G&=8191,G+=U*(5*d)+x*(5*g)+k*(5*b)+S*(5*h)+O*(5*u),I+=G>>>13,G&=8191;let Y=I+R*u+L*l+w*f+E*c+_*a;I=Y>>>13,Y&=8191,Y+=U*(5*p)+x*(5*d)+k*(5*g)+S*(5*b)+O*(5*h),I+=Y>>>13,Y&=8191;let oe=I+R*h+L*u+w*l+E*f+_*c;I=oe>>>13,oe&=8191,oe+=U*a+x*(5*p)+k*(5*d)+S*(5*g)+O*(5*b),I+=oe>>>13,oe&=8191;let se=I+R*b+L*h+w*u+E*l+_*f;I=se>>>13,se&=8191,se+=U*c+x*a+k*(5*p)+S*(5*d)+O*(5*g),I+=se>>>13,se&=8191;let ne=I+R*g+L*b+w*h+E*u+_*l;I=ne>>>13,ne&=8191,ne+=U*f+x*c+k*a+S*(5*p)+O*(5*d),I+=ne>>>13,ne&=8191;let ge=I+R*d+L*g+w*b+E*h+_*u;I=ge>>>13,ge&=8191,ge+=U*l+x*f+k*c+S*a+O*(5*p),I+=ge>>>13,ge&=8191;let W=I+R*p+L*d+w*g+E*b+_*h;I=W>>>13,W&=8191,W+=U*u+x*l+k*f+S*c+O*a,I+=W>>>13,W&=8191,I=(I<<2)+I|0,I=I+z|0,z=I&8191,I=I>>>13,T+=I,o[0]=z,o[1]=T,o[2]=F,o[3]=G,o[4]=Y,o[5]=oe,o[6]=se,o[7]=ne,o[8]=ge,o[9]=W}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){me.exists(this);const{buffer:n,blockLen:r}=this;e=sr(e);const i=e.length;for(let o=0;o>>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 al(t){const e=(r,i)=>t(i).update(sr(r)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}al(t=>new sl(t));const cl=Br("expand 16-byte k"),ll=Br("expand 32-byte k"),ul=Ie(cl),fl=Ie(ll),ai=t=>!(t.byteOffset%4),hl=t=>{const{core:e,rounds:n,counterRight:r,counterLen:i,allow128bitKeys:o,extendNonceFn:s,blockLen:a}=el({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},t);me.number(i),me.number(n),me.number(a),me.bool(r),me.bool(o);const c=a/4;if(a%4!==0)throw new Error("Salsa/ChaCha: blockLen must be aligned to 4 bytes");return(f,l,u,h,b=0)=>{if(me.bytes(f),me.bytes(l),me.bytes(u),h||(h=new Uint8Array(u.length)),me.bytes(h),me.number(b),b<0||b>=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");if(h.length=2**32-1)throw new Error("Salsa/ChaCha: counter overflow");const w=Math.min(a,N-R);if(w===a&&$&&A){const E=R/4;if(R%4!==0)throw new Error("Salsa/ChaCha: invalid block position");for(let _=0;_t<>>32-e;function dl(t,e,n,r,i,o=20){let s=t[0],a=t[1],c=t[2],f=t[3],l=e[0],u=e[1],h=e[2],b=e[3],g=e[4],d=e[5],p=e[6],y=e[7],m=i,v=n[0],B=n[1],C=n[2],A=s,$=a,N=c,R=f,L=l,w=u,E=h,_=b,U=g,x=d,k=p,S=y,O=m,I=v,z=B,T=C;for(let G=0;G{for(var n in e)gl(t,n,{get:e[n],enumerable:!0})};function zo(t){return Ae(Vt.getPublicKey(t))}var yl={};ae(yl,{MessageNode:()=>Ko,MessageQueue:()=>jo,insertEventIntoAscendingList:()=>ml,insertEventIntoDescendingList:()=>wl,normalizeURL:()=>bl,utf8Decoder:()=>Ne,utf8Encoder:()=>Ee});var Ne=new TextDecoder("utf-8"),Ee=new TextEncoder;function bl(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 wl(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[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_att[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_ate.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 Ko=class{constructor(t){H(this,"_value");H(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}},jo=class{constructor(){H(this,"_first");H(this,"_last");H(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 Ko(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 xl(t=255){return{kind:t,content:"",tags:[],created_at:0}}function dt(t,e){let n=t;return n.pubkey=zo(e),n.id=xn(n),n.sig=kl(n,e),n}function vl(t){if(!Ir(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 xn(t){let e=yn(Ee.encode(vl(t)));return Ae(e)}var El=t=>t instanceof Object;function Ir(t){if(!El(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;ee.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_att.until)}function _l(t,e){for(let n=0;nEn,getInt:()=>qo,getSubscriptionId:()=>Mo,matchEventId:()=>$l,matchEventKind:()=>Cl,matchEventPubkey:()=>Sl});function En(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 qo(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 Mo(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 $l(t,e){return e===En(t,"id")}function Sl(t,e){return e===En(t,"pubkey")}function Cl(t,e){return e===qo(t,"kind")}var ci=()=>({connect:[],disconnect:[],error:[],notice:[],auth:[]});function Bl(t,e={}){let{listTimeout:n=3e3,getTimeout:r=3e3,countTimeout:i=3e3}=e;var o,s={},a=ci(),c={},f={},l;async function u(){return l||(l=new Promise((y,m)=>{try{o=new WebSocket(t)}catch(A){m(A)}o.onopen=()=>{a.connect.forEach(A=>A()),y()},o.onerror=()=>{l=void 0,a.error.forEach(A=>A()),m()},o.onclose=async()=>{l=void 0,a.disconnect.forEach(A=>A())};let v=new jo,B;o.onmessage=A=>{v.enqueue(A.data),B||(B=setInterval(C,0))};function C(){var N,R,L;if(v.size===0){clearInterval(B),B=null;return}var A=v.dequeue();if(!A)return;let $=Mo(A);if($){let w=s[$];if(w&&w.alreadyHaveEvent&&w.alreadyHaveEvent(En(A,"id"),t))return}try{let w=JSON.parse(A);switch(w[0]){case"EVENT":{let x=w[1],k=w[2];Ir(k)&&s[x]&&(s[x].skipVerification||vn(k))&&_l(s[x].filters,k)&&(s[x],(((N=c[x])==null?void 0:N.event)||[]).forEach(S=>S(k)));return}case"COUNT":let E=w[1],_=w[2];s[E]&&(((R=c[E])==null?void 0:R.count)||[]).forEach(x=>x(_));return;case"EOSE":{let x=w[1];x in c&&(c[x].eose.forEach(k=>k()),c[x].eose=[]);return}case"OK":{let x=w[1],k=w[2],S=w[3]||"";if(x in f){let{resolve:O,reject:I}=f[x];k?O(null):I(new Error(S))}return}case"NOTICE":let U=w[1];a.notice.forEach(x=>x(U));return;case"AUTH":{let x=w[1];(L=a.auth)==null||L.forEach(k=>k(x));return}}}catch{return}}}),l)}function h(){return(o==null?void 0:o.readyState)===1}async function b(){h()||await u()}async function g(y){let m=JSON.stringify(y);if(!(!h()&&(await new Promise(v=>setTimeout(v,1e3)),!h())))try{o.send(m)}catch(v){console.log(v)}}const d=(y,{verb:m="REQ",skipVerification:v=!1,alreadyHaveEvent:B=null,id:C=Math.random().toString().slice(2)}={})=>{let A=C;return s[A]={id:A,filters:y,skipVerification:v,alreadyHaveEvent:B},g([m,A,...y]),{sub:($,N={})=>d($||y,{skipVerification:N.skipVerification||v,alreadyHaveEvent:N.alreadyHaveEvent||B,id:A}),unsub:()=>{delete s[A],delete c[A],g(["CLOSE",A])},on:($,N)=>{c[A]=c[A]||{event:[],count:[],eose:[]},c[A][$].push(N)},off:($,N)=>{let R=c[A],L=R[$].indexOf(N);L>=0&&R[$].splice(L,1)}}};function p(y,m){return new Promise((v,B)=>{if(!y.id){B(new Error(`event ${y} has no id`));return}let C=y.id;g([m,y]),f[C]={resolve:v,reject:B}})}return{url:t,sub:d,on:(y,m)=>{a[y].push(m),y==="connect"&&(o==null?void 0:o.readyState)===1&&m()},off:(y,m)=>{let v=a[y].indexOf(m);v!==-1&&a[y].splice(v,1)},list:(y,m)=>new Promise(v=>{let B=d(y,m),C=[],A=setTimeout(()=>{B.unsub(),v(C)},n);B.on("eose",()=>{B.unsub(),clearTimeout(A),v(C)}),B.on("event",$=>{C.push($)})}),get:(y,m)=>new Promise(v=>{let B=d([y],m),C=setTimeout(()=>{B.unsub(),v(null)},r);B.on("event",A=>{B.unsub(),clearTimeout(C),v(A)})}),count:y=>new Promise(m=>{let v=d(y,{...d,verb:"COUNT"}),B=setTimeout(()=>{v.unsub(),m(null)},i);v.on("count",C=>{v.unsub(),clearTimeout(B),m(C)})}),async publish(y){await p(y,"EVENT")},async auth(y){await p(y,"AUTH")},connect:b,close(){a=ci(),c={},f={},(o==null?void 0:o.readyState)===WebSocket.OPEN&&o.close()},get status(){return(o==null?void 0:o.readyState)??3}}}var ie={};ae(ie,{BECH32_REGEX:()=>Wo,decode:()=>kn,naddrEncode:()=>Ll,neventEncode:()=>Tl,noteEncode:()=>Ul,nprofileEncode:()=>Rl,npubEncode:()=>Nl,nrelayEncode:()=>Ol,nsecEncode:()=>Il});var Vo=5e3,Wo=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function kn(t){var i,o,s,a,c,f,l;let{prefix:e,words:n}=kt.decode(t,Vo),r=new Uint8Array(kt.fromWords(n));switch(e){case"nprofile":{let u=nn(r);if(!((i=u[0])!=null&&i[0]))throw new Error("missing TLV 0 for nprofile");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Ae(u[0][0]),relays:u[1]?u[1].map(h=>Ne.decode(h)):[]}}}case"nevent":{let u=nn(r);if(!((o=u[0])!=null&&o[0]))throw new Error("missing TLV 0 for nevent");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(u[2]&&u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");return{type:"nevent",data:{id:Ae(u[0][0]),relays:u[1]?u[1].map(h=>Ne.decode(h)):[],author:(s=u[2])!=null&&s[0]?Ae(u[2][0]):void 0}}}case"naddr":{let u=nn(r);if(!((a=u[0])!=null&&a[0]))throw new Error("missing TLV 0 for naddr");if(!((c=u[2])!=null&&c[0]))throw new Error("missing TLV 2 for naddr");if(u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!((f=u[3])!=null&&f[0]))throw new Error("missing TLV 3 for naddr");if(u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Ne.decode(u[0][0]),pubkey:Ae(u[2][0]),kind:parseInt(Ae(u[3][0]),16),relays:u[1]?u[1].map(h=>Ne.decode(h)):[]}}}case"nrelay":{let u=nn(r);if(!((l=u[0])!=null&&l[0]))throw new Error("missing TLV 0 for nrelay");return{type:"nrelay",data:Ne.decode(u[0][0])}}case"nsec":case"npub":case"note":return{type:e,data:Ae(r)};default:throw new Error(`unknown prefix ${e}`)}}function nn(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.lengthEe.encode(n))});return Wt("nprofile",e)}function Tl(t){let e=_n({0:[Et(t.id)],1:(t.relays||[]).map(n=>Ee.encode(n)),2:t.author?[Et(t.author)]:[]});return Wt("nevent",e)}function Ll(t){let e=new ArrayBuffer(4);new DataView(e).setUint32(0,t.kind,!1);let n=_n({0:[Ee.encode(t.identifier)],1:(t.relays||[]).map(r=>Ee.encode(r)),2:[Et(t.pubkey)],3:[new Uint8Array(e)]});return Wt("naddr",n)}function Ol(t){let e=_n({0:[Ee.encode(t)]});return Wt("nrelay",e)}function _n(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)})}),ma(...e)}var Hl={};ae(Hl,{decrypt:()=>Pl,encrypt:()=>Fl});typeof crypto<"u"&&!crypto.subtle&&crypto.webcrypto&&(crypto.subtle=crypto.webcrypto.subtle);async function Fl(t,e,n){const r=ye.getSharedSecret(t,"02"+e),i=Go(r);let o=Uint8Array.from(po(16)),s=Ee.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=Le.encode(new Uint8Array(c)),l=Le.encode(new Uint8Array(o.buffer));return`${f}?iv=${l}`}async function Pl(t,e,n){let[r,i]=n.split("?iv="),o=ye.getSharedSecret(t,"02"+e),s=Go(o),a=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["decrypt"]),c=Le.decode(r),f=Le.decode(i),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:f},a,c);return Ne.decode(l)}function Go(t){return t.slice(1,33)}var Zo={};ae(Zo,{NIP05_REGEX:()=>Jo,queryProfile:()=>jl,searchDomain:()=>Kl,useFetchImplementation:()=>zl});var Jo=/^(?:([\w.+-]+)@)?([\w.-]+)$/,An;try{An=fetch}catch{}function zl(t){An=t}async function Kl(t,e=""){try{return(await(await An(`https://${t}/.well-known/nostr.json?name=${e}`)).json()).names}catch{return{}}}async function jl(t){const e=t.match(Jo);if(!e)return null;const[n,r="_",i]=e;try{const o=await An(`https://${i}/.well-known/nostr.json?name=${r}`),{names:s,relays:a}=Dl(await o.json()),c=s[r];return c?{pubkey:c,relays:a==null?void 0:a[c]}:null}catch{return null}}function Dl(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 ql={};ae(ql,{generateSeedWords:()=>Vl,privateKeyFromSeedWords:()=>Ml,validateWords:()=>Wl});function Ml(t,e){let r=et.fromMasterSeed(Fc(t,e)).derive("m/44'/1237'/0'/0/0").privateKey;if(!r)throw new Error("could not derive private key");return Ae(r)}function Vl(){return Uc(xo)}function Wl(t){return Oc(t,xo)}var Gl={};ae(Gl,{parse:()=>Zl});function Zl(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;rYl});function Yl(t){return Ql(Et(t))}function Ql(t){let e,n,r;for(n=0,e=0;n>=1;)e++;return 7-e}var eu={};ae(eu,{finishRepostEvent:()=>tu,getRepostedEvent:()=>nu,getRepostedEventPointer:()=>Yo});function tu(t,e,n,r){return dt({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 Yo(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 nu(t,{skipVerification:e}={}){const n=Yo(t);if(n===void 0||t.content==="")return;let r;try{r=JSON.parse(t.content)}catch{return}if(r.id===n.id&&!(!e&&!vn(r)))return r}var ru={};ae(ru,{NOSTR_URI_REGEX:()=>$n,parse:()=>ou,test:()=>iu});var $n=new RegExp(`nostr:(${Wo.source})`);function iu(t){return typeof t=="string"&&new RegExp(`^${$n.source}$`).test(t)}function ou(t){const e=t.match(new RegExp(`^${$n.source}$`));if(!e)throw new Error(`Invalid Nostr URI: ${t}`);return{uri:e[0],value:e[1],decoded:kn(e[1])}}var su={};ae(su,{finishReactionEvent:()=>au,getReactedEventPointer:()=>cu});function au(t,e,n){const r=e.tags.filter(i=>i.length>=2&&(i[0]==="e"||i[0]==="p"));return dt({...t,kind:7,tags:[...t.tags??[],...r,["e",e.id],["p",e.pubkey]],content:t.content??"+"},n)}function cu(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 lu={};ae(lu,{createDelegation:()=>uu,getDelegator:()=>fu});function uu(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=yn(Ee.encode(`nostr:delegation:${e.pubkey}:${r}`)),o=Ae(Vt.sign(i,t));return{from:zo(t),to:e.pubkey,cond:r,sig:o}}function fu(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"&&t.created_at>parseInt(l))continue;return null}}let s=yn(Ee.encode(`nostr:delegation:${t.pubkey}:${r}`));return Vt.verify(i,s,n)?n:null}var hu={};ae(hu,{matchAll:()=>du,regex:()=>Ur,replaceAll:()=>pu});var Ur=()=>new RegExp(`\\b${$n.source}\\b`,"g");function*du(t){const e=t.matchAll(Ur());for(const n of e)try{const[r,i]=n;yield{uri:r,value:i,decoded:kn(i),start:n.index,end:n.index+r.length}}catch{}}function pu(t,e){return t.replaceAll(Ur(),(n,r)=>e({uri:n,value:r,decoded:kn(r)}))}var gu={};ae(gu,{channelCreateEvent:()=>yu,channelHideMessageEvent:()=>mu,channelMessageEvent:()=>wu,channelMetadataEvent:()=>bu,channelMuteUserEvent:()=>xu});var yu=(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 dt({kind:40,tags:[...t.tags??[]],content:n,created_at:t.created_at},e)},bu=(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 dt({kind:41,tags:[["e",t.channel_create_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},wu=(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"]),dt({kind:42,tags:[...n,...t.tags??[]],content:t.content,created_at:t.created_at},e)},mu=(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 dt({kind:43,tags:[["e",t.channel_message_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},xu=(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 dt({kind:44,tags:[["p",t.pubkey_to_mute],...t.tags??[]],content:n,created_at:t.created_at},e)},vu={};ae(vu,{useFetchImplementation:()=>Eu,validateGithub:()=>ku});var Rr;try{Rr=fetch}catch{}function Eu(t){Rr=t}async function ku(t,e,n){try{return await(await Rr(`https://gist.github.com/${e}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${t}`}catch{return!1}}var _u={};ae(_u,{authenticate:()=>Au});var Au=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))},$u={};ae($u,{decrypt:()=>Bu,encrypt:()=>Cu,getSharedSecret:()=>Su});var Su=(t,e)=>yn(ye.getSharedSecret(t,"02"+e).subarray(1,33));function Cu(t,e,n=1){if(n!==1)throw new Error("NIP44: unknown encryption version");const r=po(24),i=Ee.encode(e),o=Po(t,r,i),s=new Uint8Array(25+o.length);return s.set([n],0),s.set(r,1),s.set(o,25),Le.encode(s)}function Bu(t,e){let n=Le.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=Po(t,r,i);return Ne.decode(o)}var Qo={};ae(Qo,{getZapEndpoint:()=>Nu,makeZapReceipt:()=>Tu,makeZapRequest:()=>Uu,useFetchImplementation:()=>Iu,validateZapRequest:()=>Ru});var Tr;try{Tr=fetch}catch{}function Iu(t){Tr=t}async function Nu(t){try{let e="",{lud06:n,lud16:r}=JSON.parse(t.content);if(n){let{words:s}=kt.decode(n,1e3),a=kt.fromWords(s);e=Ne.decode(a)}else if(r){let[s,a]=r.split("@");e=`https://${a}/.well-known/lnurlp/${s}`}else return null;let o=await(await Tr(e)).json();if(o.allowsNostr&&o.nostrPubkey)return o.callback}catch{}return null}function Uu({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 Ru(t){let e;try{e=JSON.parse(t)}catch{return"Invalid zap request JSON."}if(!Ir(e))return"Zap request is not a valid Nostr event.";if(!vn(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 Lu={};ae(Lu,{getToken:()=>Ou,unpackEventFromToken:()=>es,validateEvent:()=>ts,validateToken:()=>Hu});var Xo="Nostr ";async function Ou(t,e,n,r=!1){if(!t||!e)throw new Error("Missing loginUrl or httpMethod");const i=xl(27235);i.tags=[["u",t],["method",e]],i.created_at=Math.round(new Date().getTime()/1e3);const o=await n(i);return(r?Xo:"")+Le.encode(Ee.encode(JSON.stringify(o)))}async function Hu(t,e,n){const r=await es(t).catch(o=>{throw o});return await ts(r,e,n).catch(o=>{throw o})}async function es(t){if(!t)throw new Error("Missing token");t=t.replace(Xo,"");const e=Ne.decode(Le.decode(t));if(!e||e.length===0||!e.startsWith("{"))throw new Error("Invalid token");return JSON.parse(e)}async function ts(t,e,n){if(!t)throw new Error("Invalid nostr event");if(!vn(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 Fu={};(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 E=(x,k)=>S=>x(k(S)),_=Array.from(w).reverse().reduce((x,k)=>x?E(x,k.encode):k.encode,void 0),U=w.reduce((x,k)=>x?E(x,k.decode):k.decode,void 0);return{encode:_,decode:U}}function r(w){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(_=>{if(e(_),_<0||_>=w.length)throw new Error(`Digit index outside alphabet: ${_} (alphabet: ${w.length})`);return w[_]})},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(_=>{if(typeof _!="string")throw new Error(`alphabet.decode: not string element=${_}`);const U=w.indexOf(_);if(U===-1)throw new Error(`Unknown letter: "${_}". Allowed: ${w}`);return U})}}}function i(w=""){if(typeof w!="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 _ of E)if(typeof _!="string")throw new Error(`join.encode: non-string input=${_}`);return E.join(w)},decode:E=>{if(typeof E!="string")throw new Error("join.decode input should be string");return E.split(w)}}}function o(w,E="="){if(e(w),typeof E!="string")throw new Error("padding chr should be string");return{encode(_){if(!Array.isArray(_)||_.length&&typeof _[0]!="string")throw new Error("padding.encode input should be array of strings");for(let U of _)if(typeof U!="string")throw new Error(`padding.encode: non-string input=${U}`);for(;_.length*w%8;)_.push(E);return _},decode(_){if(!Array.isArray(_)||_.length&&typeof _[0]!="string")throw new Error("padding.encode input should be array of strings");for(let x of _)if(typeof x!="string")throw new Error(`padding.decode: non-string input=${x}`);let U=_.length;if(U*w%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;U>0&&_[U-1]===E;U--)if(!((U-1)*w%8))throw new Error("Invalid padding: string has too much padding");return _.slice(0,U)}}}function s(w){if(typeof w!="function")throw new Error("normalize fn should be function");return{encode:E=>E,decode:E=>w(E)}}function a(w,E,_){if(E<2)throw new Error(`convertRadix: wrong from=${E}, base cannot be less than 2`);if(_<2)throw new Error(`convertRadix: wrong to=${_}, base cannot be less than 2`);if(!Array.isArray(w))throw new Error("convertRadix: data should be array");if(!w.length)return[];let U=0;const x=[],k=Array.from(w);for(k.forEach(S=>{if(e(S),S<0||S>=E)throw new Error(`Wrong integer: ${S}`)});;){let S=0,O=!0;for(let I=U;IE?c(E,w%E):w,f=(w,E)=>w+(E-c(w,E));function l(w,E,_,U){if(!Array.isArray(w))throw new Error("convertRadix2: data should be array");if(E<=0||E>32)throw new Error(`convertRadix2: wrong from=${E}`);if(_<=0||_>32)throw new Error(`convertRadix2: wrong to=${_}`);if(f(E,_)>32)throw new Error(`convertRadix2: carry overflow from=${E} to=${_} carryBits=${f(E,_)}`);let x=0,k=0;const S=2**_-1,O=[];for(const I of w){if(e(I),I>=2**E)throw new Error(`convertRadix2: invalid data word=${I} from=${E}`);if(x=x<32)throw new Error(`convertRadix2: carry overflow pos=${k} from=${E}`);for(k+=E;k>=_;k-=_)O.push((x>>k-_&S)>>>0);x&=2**k-1}if(x=x<<_-k&S,!U&&k>=E)throw new Error("Excess padding");if(!U&&x)throw new Error(`Non-zero padding: ${x}`);return U&&k>0&&O.push(x>>>0),O}function u(w){return e(w),{encode:E=>{if(!(E instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(Array.from(E),2**8,w)},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(a(E,w,2**8))}}}function h(w,E=!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:_=>{if(!(_ instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return l(Array.from(_),8,w,!E)},decode:_=>{if(!Array.isArray(_)||_.length&&typeof _[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(l(_,w,8,E))}}}function b(w){if(typeof w!="function")throw new Error("unsafeWrapper fn should be function");return function(...E){try{return w.apply(null,E)}catch{}}}function g(w,E){if(e(w),typeof E!="function")throw new Error("checksum fn should be function");return{encode(_){if(!(_ instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const U=E(_).slice(0,w),x=new Uint8Array(_.length+w);return x.set(_),x.set(U,_.length),x},decode(_){if(!(_ instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const U=_.slice(0,-w),x=E(U).slice(0,w),k=_.slice(-w);for(let S=0;Sw.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(u(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 E="";for(let _=0;_n(g(4,E=>w(w(E))),t.base58);t.base58check=y;const m=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),i("")),v=[996825010,642813549,513874426,1027748829,705979059];function B(w){const E=w>>25;let _=(w&33554431)<<5;for(let U=0;U>U&1)===1&&(_^=v[U]);return _}function C(w,E,_=1){const U=w.length;let x=1;for(let k=0;k126)throw new Error(`Invalid prefix (${w})`);x=B(x)^S>>5}x=B(x);for(let k=0;kG)throw new TypeError(`Length ${Y} exceeds limit ${G}`);return T=T.toLowerCase(),`${T}1${m.encode(F)}${C(T,F,E)}`}function O(T,F=90){if(typeof T!="string")throw new Error(`bech32.decode input should be string, not ${typeof T}`);if(T.length<8||F!==!1&&T.length>F)throw new TypeError(`Wrong string length: ${T.length} (${T}). Expected (8..${F})`);const G=T.toLowerCase();if(T!==G&&T!==T.toUpperCase())throw new Error("String must be lowercase or uppercase");T=G;const Y=T.lastIndexOf("1");if(Y===0||Y===-1)throw new Error('Letter "1" must be present between prefix and data only');const oe=T.slice(0,Y),se=T.slice(Y+1);if(se.length<6)throw new Error("Data must be at least 6 characters long");const ne=m.decode(se).slice(0,-6),ge=C(oe,ne,E);if(!se.endsWith(ge))throw new Error(`Invalid checksum in ${T}: expected "${ge}"`);return{prefix:oe,words:ne}}const I=b(O);function z(T){const{prefix:F,words:G}=O(T,!1);return{prefix:F,words:G,bytes:U(G)}}return{encode:S,decode:O,decodeToBytes:z,decodeUnsafe:I,fromWords:U,fromWordsUnsafe:k,toWords:x}}t.bech32=A("bech32"),t.bech32m=A("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 $={utf8:t.utf8,hex:t.hex,base16:t.base16,base32:t.base32,base64:t.base64,base64url:t.base64url,base58:t.base58,base58xmr:t.base58xmr},N=`Invalid encoding type. Available types: ${Object.keys($).join(", ")}`,R=(w,E)=>{if(typeof w!="string"||!$.hasOwnProperty(w))throw new TypeError(N);if(!(E instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return $[w].encode(E)};t.bytesToString=R,t.str=t.bytesToString;const L=(w,E)=>{if(!$.hasOwnProperty(w))throw new TypeError(N);if(typeof E!="string")throw new TypeError("stringToBytes() expects string");return $[w].decode(E)};t.stringToBytes=L,t.bytes=t.stringToBytes})(Fu);BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12);BigInt("2100000000000000000");BigInt(1e11);const li={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(li);te.created_at?t:e}var zu=["wss://nos.lol","wss://relay.nostr.band","wss://relay.f7z.io","wss://relay.damus.io","wss://nostr.mom","wss://no.str.cr"],Ku=class extends St{constructor(e){super();H(this,"ndk");H(this,"zappedEvent");H(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}=ii.decode(e,1e3),c=ii.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=Qo.makeZapRequest({profile:this.zappedUser.hexpubkey(),event:null,amount:e,comment:n||"",relays:i??this.relays()});if(this.zappedEvent){const u=this.zappedEvent.tagReference();u&&s.tags.push(u)}s.tags.push(["lnurl",o]);const a=new Ue(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=zu),e}};function ju(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}=ie.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 Du(){if(this.kind===void 0)throw new Error("Kind not set");return this.kind>=1e4&&this.kind<2e4}function qu(){if(this.kind===void 0)throw new Error("Kind not set");return this.kind>=3e4&&this.kind<4e4}var Bt=class extends St{constructor(e){super();H(this,"url");H(this,"scores");H(this,"relay");H(this,"_status");H(this,"connectedAt");H(this,"_connectionStats",{attempts:0,success:0,durations:[]});H(this,"complaining",!1);H(this,"debug");H(this,"activeSubscriptions",new Set);H(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=Bl(e),this.scores=new Map,this._status=3,this.debug=fr(`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 Ue(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(l=>{clearTimeout(o),this.debug("Publish failed",l,e.id),this.emit("publish:failed",e,l),f(l)})});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}},Oe=class{constructor(t,e){H(this,"relays");H(this,"debug");H(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 Oe(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 ko(wn(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 Yu(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 Mu(t,e){var r;const n=new Set;return(r=t.pool)==null||r.relays.forEach(i=>n.add(i)),new Oe(n,t)}function Vu(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 Oe(n,t)}function Wu(t){return!!(Gu(t.filter)&&Zu(t))}function Gu(t){return!!t.ids}function Zu(t){const e=t.filter.ids;return!!e&&e.length===t.eventFirstSeen.size}var Ju={closeOnEose:!0,cacheUsage:"CACHE_FIRST",groupable:!0,groupableDelay:100},ns=class extends St{constructor(e,n,r,i,o){super();H(this,"subId");H(this,"filters");H(this,"opts");H(this,"relaySet");H(this,"ndk");H(this,"relaySubscriptions");H(this,"debug");H(this,"eventFirstSeen",new Map);H(this,"eosesSeen",new Set);H(this,"eventsPerRelay",new Map);H(this,"eoseTimeout");if(this.ndk=e,this.opts={...Ju,...r||{}},this.filters=n instanceof Array?n:[n],this.subId=o||(r==null?void 0:r.subId)||tf(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,Wu(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=Vu(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))}},Yu=class extends ns{constructor(e,n){const r=e.debug.extend("subscription-group"),i=Qu(n.map(o=>o.filters[0]));super(e,i,n[0].opts,n[0].relaySet);H(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?Do(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 Qu(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=ie.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 ef(t){try{const e=ie.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 Bt(r))}}catch{}return[]}function tf(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 nf(){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=ie.npubEncode(r[1]);e.add(i)}catch{}})}),[...e].reduce((n,r)=>{const i=new It({npub:r});return i.ndk=this.ndk,n.add(i),n},new Set)}return new Set}function rf(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 It=class{constructor(t){H(this,"ndk");H(this,"profile");H(this,"npub","");H(this,"relayUrls",[]);H(this,"follows",nf.bind(this));t.npub&&(this.npub=t.npub),t.hexpubkey&&(this.npub=ie.npubEncode(t.hexpubkey)),t.relayUrls&&(this.relayUrls=t.relayUrls)}static async fromNip05(t){const e=await Zo.queryProfile(t);if(e)return new It({hexpubkey:e.pubkey,relayUrls:e.relays})}hexpubkey(){return ie.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=rf(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 Ue(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 Ue(this.ndk,{kind:3});for(const r of e)n.tag(r);return await n.publish(),!0}};async function of(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 It({hexpubkey:n[0][1]}),t.ndk=this.ndk}this.content=await e.encrypt(t,this.content)}async function sf(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 af(){return this.isParamReplaceable()?ie.naddrEncode({kind:this.kind,pubkey:this.pubkey,identifier:this.replaceableDTag(),relays:this.relay?[this.relay.url]:[]}):this.relay?ie.neventEncode({id:this.tagId(),relays:[this.relay.url],author:this.pubkey}):ie.noteEncode(this.tagId())}async function cf(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 Ue(this.ndk,{kind:lf(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 lf(t){return t.kind===1?6:16}var Ue=class extends St{constructor(e,n){super();H(this,"ndk");H(this,"created_at");H(this,"content","");H(this,"tags",[]);H(this,"kind");H(this,"id","");H(this,"sig");H(this,"pubkey","");H(this,"relay");H(this,"isReplaceable",Du.bind(this));H(this,"isParamReplaceable",qu.bind(this));H(this,"encode",af.bind(this));H(this,"encrypt",of.bind(this));H(this,"decrypt",sf.bind(this));H(this,"repost",cf.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 It({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 Ue){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=xn(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=ju(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 Ku({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 Ue(this.ndk,{kind:5,content:e||""});return n.tag(this),await n.publish(),n}},uf=class extends St{constructor(e=[],n){super();H(this,"relays",new Map);H(this,"debug");H(this,"temporaryRelayTimers",new Map);this.debug=n.debug.extend("pool");for(const r of e){const i=new Bt(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 ff(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 hf=class{constructor(){H(this,"_userPromise");H(this,"nip04Queue",[]);H(this,"nip04Processing",!1);H(this,"debug");if(!window.nostr)throw new Error("NIP-07 extension not available");this.debug=fr("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 It({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()}},df=class extends St{constructor(e={}){super();H(this,"pool");H(this,"signer");H(this,"cacheAdapter");H(this,"debug");H(this,"devWriteRelaySet");H(this,"delayedSubscriptions");this.debug=e.debug||fr("ndk"),this.pool=new uf(e.explicitRelayUrls||[],this),this.signer=e.signer,this.cacheAdapter=e.cacheAdapter,this.delayedSubscriptions=new Map,e.devWriteRelayUrls&&(this.devWriteRelaySet=Oe.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 It(e);return n.ndk=this,n}subscribe(e,n,r,i=!0){const o=new ns(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||Mu(this)),n.publish(e,r)}async fetchEvent(e,n,r){let i;if(!r&&typeof e=="string"){const o=ef(e);o.length>0&&(r=new Oe(new Set(o),this),r=ff(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(),l=o.get(f);l&&(c=Pu(l,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 gt=[];function rs(t,e=Z){let n;const r=new Set;function i(a){if(ct(t,a)&&(t=a,n)){const c=!gt.length;for(const f of r)f[1](),gt.push(f,t);if(c){for(let f=0;f{r.delete(f),r.size===0&&n&&(n(),n=null)}}return{set:i,update:o,subscribe:s}}const Sn="ws://localhost:3334",pf=["wss://nos.lol","wss://relay.snort.social"],gf=[...pf],is=new df({explicitRelayUrls:gf});is.connect().then(()=>console.log("ndk connected"));const ot=rs(is),on=rs(void 0);function ui(t,e,n){const r=t.slice();return r[6]=e[n],r}function yf(t){let e=ie.npubEncode(t[0].pk)+"",n;return{c(){n=ee(e)},m(r,i){M(r,n,i)},p(r,i){i&1&&e!==(e=ie.npubEncode(r[0].pk)+"")&&$e(n,e)},d(r){r&&q(n)}}}function bf(t){let e;return{c(){e=ee(t[2])},m(n,r){M(n,e,r)},p(n,r){r&4&&$e(e,n[2])},d(n){n&&q(e)}}}function fi(t){let e,n,r;return{c(){e=D("button"),e.textContent="[-]",K(e,"class","inline cusor-pointer font-semibold text-red-500")},m(i,o){M(i,e,o),n||(r=Je(e,"click",t[4]),n=!0)},p:Z,d(i){i&&q(e),n=!1,r()}}}function hi(t){let e;return{c(){e=D("span"),e.textContent="(you)"},m(n,r){M(n,e,r)},d(n){n&&q(e)}}}function di(t){let e,n=[],r=new Map,i,o=t[0].children;const s=a=>a[6].pk;for(let a=0;a0&&di(t);return{c(){e=D("li"),n=D("span"),r=D("a"),b.c(),o=Q(),g&&g.c(),a=qt(),d&&d.c(),f=Q(),p&&p.c(),K(r,"class","inline hover:underline"),K(r,"href",i=`nostr:${ie.npubEncode(t[0].pk)}`)},m(y,m){M(y,e,m),j(e,n),j(n,r),b.m(r,null),j(n,o),g&&g.m(n,null),j(n,a),d&&d.m(n,null),j(e,f),p&&p.m(e,null),l=!0},p(y,[m]){h===(h=u(y))&&b?b.p(y,m):(b.d(1),b=h(y),b&&(b.c(),b.m(r,null))),(!l||m&1&&i!==(i=`nostr:${ie.npubEncode(y[0].pk)}`))&&K(r,"href",i),m&9&&(s=y[3]==ie.npubEncode(y[0].invited_by)),s?g?g.p(y,m):(g=fi(y),g.c(),g.m(n,a)):g&&(g.d(1),g=null),m&9&&(c=y[3]==ie.npubEncode(y[0].pk)),c?d||(d=hi(),d.c(),d.m(n,null)):d&&(d.d(1),d=null),y[0].children&&y[0].children.length>0?p?(p.p(y,m),m&1&&te(p,1)):(p=di(y),p.c(),te(p,1),p.m(e,null)):p&&(lt(),he(p,1,1,()=>{p=null}),ut())},i(y){l||(te(p),l=!0)},o(y){he(p),l=!1},d(y){y&&q(e),b.d(),g&&g.d(),d&&d.d(),p&&p.d()}}}function mf(t,e,n){let r,i;st(t,ot,f=>n(5,r=f)),st(t,on,f=>n(3,i=f));let{person:o}=e,{reload:s}=e,a="...";cr(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. (you can only do this if you invited this user or are the relay admin)`))try{let l=[new Bt(Sn)];const u=new Oe(l,r);u.relays.forEach(async b=>{await b.connect().catch(g=>{console.log("error while connecting to relay",g)}),b.on("connect",()=>{console.log("connected")})});const h=new Ue(r);h.kind=20202,h.tags.push(["p",o.pk]),await h.publish(u).then(()=>s())}catch(l){console.log("error while publishing",l)}}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 os extends $t{constructor(e){super(),At(this,e,mf,wf,ct,{person:0,reload:1})}}function gi(t,e,n){const r=t.slice();return r[2]=e[n],r}function yi(t,e){let n,r,i;return r=new os({props:{reload:e[0],person:e[2]}}),{key:t,first:null,c(){n=qt(),_t(r.$$.fragment),this.first=n},m(o,s){M(o,n,s),ft(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||(te(r.$$.fragment,o),i=!0)},o(o){he(r.$$.fragment,o),i=!1},d(o){o&&q(n),ht(r,o)}}}function xf(t){let e,n,r=[],i=new Map,o,s=t[1];const a=c=>c[2].pk;for(let c=0;c{"reload"in o&&n(0,r=o.reload),"hierarchy"in o&&n(1,i=o.hierarchy)},[r,i]}class Ef extends $t{constructor(e){super(),At(this,e,vf,xf,ct,{reload:0,hierarchy:1})}}function kf(t){let e,n,r,i,o,s;return{c(){e=D("div"),n=D("input"),r=Q(),i=D("button"),i.textContent="Go",K(n,"class","focus:ring-indigo-500 focus:border-indigo-500 block w-full rounded-none rounded-l-md sm:text-sm border-gray-300"),K(n,"placeholder","hex or npub"),K(i,"type","submit"),K(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"),K(e,"class","relative flex items-stretch flex-grow focus-within:z-10")},m(a,c){M(a,e,c),j(e,n),Pr(n,t[0]),j(e,r),j(e,i),o||(s=[Je(n,"input",t[3]),Je(i,"click",t[1])],o=!0)},p(a,[c]){c&1&&n.value!==a[0]&&Pr(n,a[0])},i:Z,o:Z,d(a){a&&q(e),o=!1,Ye(s)}}}function _f(t,e,n){let r;st(t,ot,c=>n(4,r=c));let i="",{reload:o}=e;async function s(){if(i)try{let c=[new Bt(Sn)];const f=new Oe(c,r);f.relays.forEach(async h=>{await h.connect().catch(b=>{console.log("RELAY CONNECT ERROR"),console.error(b)}),h.on("connect",()=>{console.log(h.url,"connected")})});const l=i.startsWith("npub")?ie.decode(i).data:i,u=new Ue(r);u.kind=20201,u.tags.push(["p",l.toString()]),await u.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 Af extends $t{constructor(e){super(),At(this,e,_f,kf,ct,{reload:2})}}function ss(t,e=null){return t.filter(r=>r.invited_by===(e?e.pk:null)).map(r=>({...r,children:ss(t,r)}))}function bi(t,e,n){const r=t.slice();return r[7]=e[n],r}function wi(t){var G,Y,oe,se,ne,ge;let e,n,r,i,o,s,a,c,f,l,u,h,b,g,d=((Y=(G=t[0])==null?void 0:G.tags.find(Ei))==null?void 0:Y[0])&&((se=(oe=t[0])==null?void 0:oe.tags.find(ki))==null?void 0:se[1]),p,y,m,v,B,C,A,$,N,R,L,w,E,_,U={ctx:t,current:null,token:null,hasCatch:!1,pending:Cf,then:Sf,catch:$f,value:10};mt(o=(ne=t[0].author)==null?void 0:ne.fetchProfile(),U);function x(W,J){var be,ce,X,le;return J&1&&(c=null),c==null&&(c=!!((ce=(be=W[0])==null?void 0:be.tags.find(Vf))!=null&&ce[0]&&((le=(X=W[0])==null?void 0:X.tags.find(Wf))!=null&&le[1]))),c?If:Bf}let k=x(t,-1),S=k(t);function O(W,J){var be,ce,X,le,ke,_e,Nt,Ut,Rt,Tt,Lt,Ot;if(J&1&&(u=null),J&1&&(h=null),u==null&&(u=!!((ce=(be=W[0])==null?void 0:be.tags.find(zf))!=null&&ce[0]&&((le=(X=W[0])==null?void 0:X.tags.find(Kf))!=null&&le[1])&&((_e=(ke=W[0])==null?void 0:ke.tags.find(jf))!=null&&_e[2]))),u)return Lf;if(h==null&&(h=!!((Ut=(Nt=W[0])==null?void 0:Nt.tags.find(Df))!=null&&Ut[0]&&((Tt=(Rt=W[0])==null?void 0:Rt.tags.find(qf))!=null&&Tt[1])&&((Ot=(Lt=W[0])==null?void 0:Lt.tags.find(Mf))!=null&&Ot[2]))),h)return Tf}let I=O(t,-1),z=I&&I(t),T=((ge=t[0])==null?void 0:ge.content)&&mi(t),F=d&&xi(t);return{c(){var W,J,be,ce,X,le,ke,_e;e=D("div"),n=D("div"),r=D("div"),i=ee(`from - `),U.block.c(),s=Q(),a=D("div"),S.c(),f=Q(),l=D("div"),z&&z.c(),b=Q(),T&&T.c(),g=Q(),F&&F.c(),p=Q(),y=D("div"),m=D("div"),v=D("a"),B=ee("Open in client"),A=Q(),$=D("button"),$.textContent="View in invite tree",N=Q(),R=D("button"),R.textContent="Dismiss",L=Q(),w=D("button"),w.textContent="Exlude this user",K(r,"class","bg-white rounded-lg px-4 py-2"),K(a,"class","bg-white rounded-lg px-4 py-2"),K(n,"class","columns-2 p-0 m-0"),K(l,"class","bg-white max-h-64 scroll-auto rounded-lg m-0 p-4 mt-2"),K(v,"href",C=`nostr:${(J=(W=t[0])==null?void 0:W.tags.find(Ii))!=null&&J[0]&&((ce=(be=t[0])==null?void 0:be.tags.find(Ni))!=null&&ce[1])?(le=(X=t[0])==null?void 0:X.tags.find(Ui))==null?void 0:le[1]:(_e=(ke=t[0])==null?void 0:ke.tags.find(Ri))==null?void 0:_e[1]}`),K(v,"class","rounded-lg inline bg-slate-100 p-2 cursor-pointer hover:bg-white"),K($,"class","rounded-lg inline bg-slate-100 p-2 cursor-pointer hover:bg-white"),K(R,"class","rounded-lg inline bg-green-500 p-2 cursor-pointer hover:bg-green-400"),K(w,"class","rounded-lg inline bg-red-500 p-2 cursor-pointer hover:bg-red-400"),K(m,"class","columns-4 inline"),K(y,"class","p-0 mb-0 mx-0 mt-2"),K(e,"class","rounded-lg border border-slate-500 bg-slate-50 w-full p-4 mt-8")},m(W,J){M(W,e,J),j(e,n),j(n,r),j(r,i),U.block.m(r,U.anchor=null),U.mount=()=>r,U.anchor=null,j(n,s),j(n,a),S.m(a,null),j(e,f),j(e,l),z&&z.m(l,null),j(l,b),T&&T.m(l,null),j(e,g),F&&F.m(e,null),j(e,p),j(e,y),j(y,m),j(m,v),j(v,B),j(m,A),j(m,$),j(m,N),j(m,R),j(m,L),j(m,w),E||(_=[Je(R,"click",t[4]),Je(w,"click",t[5])],E=!0)},p(W,J){var be,ce,X,le,ke,_e,Nt,Ut,Rt,Tt,Lt,Ot,Lr,Or;t=W,U.ctx=t,J&1&&o!==(o=(be=t[0].author)==null?void 0:be.fetchProfile())&&mt(o,U)||ur(U,t,J),k===(k=x(t,J))&&S?S.p(t,J):(S.d(1),S=k(t),S&&(S.c(),S.m(a,null))),I===(I=O(t,J))&&z?z.p(t,J):(z&&z.d(1),z=I&&I(t),z&&(z.c(),z.m(l,b))),(ce=t[0])!=null&&ce.content?T?T.p(t,J):(T=mi(t),T.c(),T.m(l,null)):T&&(T.d(1),T=null),J&1&&(d=((le=(X=t[0])==null?void 0:X.tags.find(Ei))==null?void 0:le[0])&&((_e=(ke=t[0])==null?void 0:ke.tags.find(ki))==null?void 0:_e[1])),d?F?F.p(t,J):(F=xi(t),F.c(),F.m(e,p)):F&&(F.d(1),F=null),J&1&&C!==(C=`nostr:${(Ut=(Nt=t[0])==null?void 0:Nt.tags.find(Ii))!=null&&Ut[0]&&((Tt=(Rt=t[0])==null?void 0:Rt.tags.find(Ni))!=null&&Tt[1])?(Ot=(Lt=t[0])==null?void 0:Lt.tags.find(Ui))==null?void 0:Ot[1]:(Or=(Lr=t[0])==null?void 0:Lr.tags.find(Ri))==null?void 0:Or[1]}`)&&K(v,"href",C)},d(W){W&&q(e),U.block.d(),U.token=null,U=null,S.d(),z&&z.d(),T&&T.d(),F&&F.d(),E=!1,Ye(_)}}}function $f(t){return{c:Z,m:Z,p:Z,d:Z}}function Sf(t){var c,f;let e,n,r,i,o=(t[10]&&((f=JSON.parse((c=Array.from(t[10])[0])==null?void 0:c.content))==null?void 0:f.name))+"",s,a;return{c(){var l,u;e=D("img"),r=Q(),i=D("a"),s=ee(o),K(e,"class","h-7 w-7 m-0 p-0 rounded-full inline"),Pt(e.src,n=t[10]&&((u=JSON.parse((l=Array.from(t[10])[0])==null?void 0:l.content))==null?void 0:u.picture))||K(e,"src",n),K(e,"alt",""),K(i,"href",a=`nostr:${t[0].author.npub}`)},m(l,u){M(l,e,u),M(l,r,u),M(l,i,u),j(i,s)},p(l,u){var h,b,g,d;u&1&&!Pt(e.src,n=l[10]&&((b=JSON.parse((h=Array.from(l[10])[0])==null?void 0:h.content))==null?void 0:b.picture))&&K(e,"src",n),u&1&&o!==(o=(l[10]&&((d=JSON.parse((g=Array.from(l[10])[0])==null?void 0:g.content))==null?void 0:d.name))+"")&&$e(s,o),u&1&&a!==(a=`nostr:${l[0].author.npub}`)&&K(i,"href",a)},d(l){l&&q(e),l&&q(r),l&&q(i)}}}function Cf(t){let e,n,r;return{c(){e=D("a"),n=ee("..."),K(e,"href",r=`nostr:${t[0].author.npub}`)},m(i,o){M(i,e,o),j(e,n)},p(i,o){o&1&&r!==(r=`nostr:${i[0].author.npub}`)&&K(e,"href",r)},d(i){i&&q(e)}}}function Bf(t){let e;return{c(){e=ee("huh, nothing here")},m(n,r){M(n,e,r)},p:Z,d(n){n&&q(e)}}}function If(t){var o;let e,n,r,i={ctx:t,current:null,token:null,hasCatch:!1,pending:Rf,then:Uf,catch:Nf,value:10};return mt(r=t[2].getUser({hexpubkey:(o=t[0].tags.find(_i))==null?void 0:o[1]}).fetchProfile(),i),{c(){e=ee(`to - `),n=qt(),i.block.c()},m(s,a){M(s,e,a),M(s,n,a),i.block.m(s,i.anchor=a),i.mount=()=>n.parentNode,i.anchor=n},p(s,a){var c;t=s,i.ctx=t,a&5&&r!==(r=t[2].getUser({hexpubkey:(c=t[0].tags.find(_i))==null?void 0:c[1]}).fetchProfile())&&mt(r,i)||ur(i,t,a)},d(s){s&&q(e),s&&q(n),i.block.d(s),i.token=null,i=null}}}function Nf(t){return{c:Z,m:Z,p:Z,d:Z}}function Uf(t){var c,f,l,u,h,b;let e,n,r,i,o=(t[10]&&((f=JSON.parse((c=Array.from(t[10])[0])==null?void 0:c.content))==null?void 0:f.name.length)<=16?(u=JSON.parse((l=Array.from(t[10])[0])==null?void 0:l.content))==null?void 0:u.name:((b=JSON.parse((h=Array.from(t[10])[0])==null?void 0:h.content))==null?void 0:b.name.substring(0,13))+"...")+"",s,a;return{c(){var g,d,p;e=D("img"),r=Q(),i=D("a"),s=ee(o),K(e,"class","h-7 w-7 m-0 p-0 rounded-full inline"),Pt(e.src,n=t[10]&&((d=JSON.parse((g=Array.from(t[10])[0])==null?void 0:g.content))==null?void 0:d.picture))||K(e,"src",n),K(e,"alt",""),K(i,"href",a=`nostr:${(p=t[0].tags.find($i))==null?void 0:p[1]}`)},m(g,d){M(g,e,d),M(g,r,d),M(g,i,d),j(i,s)},p(g,d){var p,y,m,v,B,C,A,$,N;d&5&&!Pt(e.src,n=g[10]&&((y=JSON.parse((p=Array.from(g[10])[0])==null?void 0:p.content))==null?void 0:y.picture))&&K(e,"src",n),d&5&&o!==(o=(g[10]&&((v=JSON.parse((m=Array.from(g[10])[0])==null?void 0:m.content))==null?void 0:v.name.length)<=16?(C=JSON.parse((B=Array.from(g[10])[0])==null?void 0:B.content))==null?void 0:C.name:(($=JSON.parse((A=Array.from(g[10])[0])==null?void 0:A.content))==null?void 0:$.name.substring(0,13))+"...")+"")&&$e(s,o),d&1&&a!==(a=`nostr:${(N=g[0].tags.find($i))==null?void 0:N[1]}`)&&K(i,"href",a)},d(g){g&&q(e),g&&q(r),g&&q(i)}}}function Rf(t){let e,n,r,i,o,s;return{c(){var a;e=D("img"),r=Q(),i=D("a"),o=ee("..."),K(e,"class","h-7 w-7 m-0 p-0 rounded-full inline"),Pt(e.src,n="")||K(e,"src",n),K(e,"alt",""),K(i,"href",s=`nostr:${(a=t[0].tags.find(Ai))==null?void 0:a[1]}`)},m(a,c){M(a,e,c),M(a,r,c),M(a,i,c),j(i,o)},p(a,c){var f;c&1&&s!==(s=`nostr:${(f=a[0].tags.find(Ai))==null?void 0:f[1]}`)&&K(i,"href",s)},d(a){a&&q(e),a&&q(r),a&&q(i)}}}function Tf(t){var r,i;let e=((i=(r=t[0])==null?void 0:r.tags.find(Ci))==null?void 0:i[2])+"",n;return{c(){n=ee(e)},m(o,s){M(o,n,s)},p(o,s){var a,c;s&1&&e!==(e=((c=(a=o[0])==null?void 0:a.tags.find(Ci))==null?void 0:c[2])+"")&&$e(n,e)},d(o){o&&q(n)}}}function Lf(t){var r,i;let e=((i=(r=t[0])==null?void 0:r.tags.find(Si))==null?void 0:i[2])+"",n;return{c(){n=ee(e)},m(o,s){M(o,n,s)},p(o,s){var a,c;s&1&&e!==(e=((c=(a=o[0])==null?void 0:a.tags.find(Si))==null?void 0:c[2])+"")&&$e(n,e)},d(o){o&&q(n)}}}function mi(t){let e,n=t[0].content+"",r;return{c(){e=D("p"),r=ee(n),K(e,"class","text-gray-500 m-0 p-0")},m(i,o){M(i,e,o),j(e,r)},p(i,o){o&1&&n!==(n=i[0].content+"")&&$e(r,n)},d(i){i&&q(e)}}}function xi(t){var i,o;let e,n,r={ctx:t,current:null,token:null,hasCatch:!1,pending:Ff,then:Hf,catch:Of,value:6};return mt(n=t[2].fetchEvent({ids:[(o=(i=t[0])==null?void 0:i.tags.find(Bi))==null?void 0:o[1]]}),r),{c(){e=D("div"),r.block.c(),K(e,"class","bg-white max-h-64 max-w-full overflow-y-scroll rounded-lg m-0 p-4 mt-2")},m(s,a){M(s,e,a),r.block.m(e,r.anchor=null),r.mount=()=>e,r.anchor=null},p(s,a){var c,f;t=s,r.ctx=t,a&5&&n!==(n=t[2].fetchEvent({ids:[(f=(c=t[0])==null?void 0:c.tags.find(Bi))==null?void 0:f[1]]}))&&mt(n,r)||ur(r,t,a)},d(s){s&&q(e),r.block.d(),r.token=null,r=null}}}function Of(t){return{c:Z,m:Z,p:Z,d:Z}}function Hf(t){let e,n=t[6].content+"",r,i,o,s,a,c=t[6].kind+"",f,l,u,h,b=t[6].tags,g=[];for(let d=0;dt[0]=="e",ki=t=>t[0]=="e",zf=t=>t[0]=="e",Kf=t=>t[0]=="e",jf=t=>t[0]=="e",Df=t=>t[0]=="p",qf=t=>t[0]=="p",Mf=t=>t[0]=="p",Vf=t=>t[0]=="p",Wf=t=>t[0]=="p",_i=t=>t[0]=="p",Ai=t=>t[0]=="p",$i=t=>t[0]=="p",Si=t=>t[0]=="e",Ci=t=>t[0]=="p",Bi=t=>t[0]=="e",Ii=t=>t[0]=="e",Ni=t=>t[0]=="e",Ui=t=>t[0]=="e",Ri=t=>t[0]=="p";function Gf(t,e,n){let r;st(t,ot,f=>n(2,r=f));let{event:i}=e,o=!0;async function s(f,l){if(confirm(`Are you sure you want to remove ${f||l}? All people they invited will also be removed. (you can only do this if you invited this user or are the relay admin)`))try{let h=[new Bt(Sn)];const b=new Oe(h,r);b.relays.forEach(async d=>{await d.connect().catch(p=>{console.log("error while connecting to relay",p)}),d.on("connect",()=>{console.log("connected")})});const g=new Ue(r);g.kind=20202,g.tags.push(["p",l]),await g.publish(b).then(()=>reload())}catch(h){console.log("error while publishing",h)}}const a=()=>n(1,o=!1),c=()=>{var f;return s("user",(f=i.tags.find(l=>l[0]=="p"))==null?void 0:f[1])};return t.$$set=f=>{"event"in f&&n(0,i=f.event)},[i,o,r,s,a,c]}class Zf extends $t{constructor(e){super(),At(this,e,Gf,Pf,ct,{event:0})}}function Ti(t,e,n){const r=t.slice();return r[2]=e[n],r}function Li(t){let e,n,r;return e=new Zf({props:{event:t[2]}}),{c(){_t(e.$$.fragment),n=Q()},m(i,o){ft(e,i,o),M(i,n,o),r=!0},p(i,o){const s={};o&1&&(s.event=i[2]),e.$set(s)},i(i){r||(te(e.$$.fragment,i),r=!0)},o(i){he(e.$$.fragment,i),r=!1},d(i){ht(e,i),i&&q(n)}}}function Jf(t){let e,n,r=t[0],i=[];for(let s=0;she(i[s],1,1,()=>{i[s]=null});return{c(){e=D("div");for(let s=0;sn(1,r=o));let i=[];return cr(async()=>{try{let o=[new Bt(Sn)];new Oe(o,r).relays.forEach(async f=>{await f.connect().catch(l=>{console.log("RELAY CONNECT ERROR"),console.error(l)}),f.on("connect",()=>{console.log(f.url,"connected")})});let a={kinds:[1984],limit:250},c=await r.fetchEvents(a);n(0,i=Array.from(c))}catch{console.log("error while getting feed",error)}}),[i]}class Qf extends $t{constructor(e){super(),At(this,e,Yf,Jf,ct,{})}}function Xf(t){let e,n,r,i,o,s=t[1].find(t[6]),a,c,f,l,u,h,b,g,d,p=t[3]===void 0&&Oi(t),y=s&&Hi(t);return h=new Ef({props:{hierarchy:t[2],reload:t[5]}}),{c(){e=D("div"),p&&p.c(),n=Q(),r=D("div"),i=D("button"),i.textContent="Open Admin View",o=Q(),y&&y.c(),a=Q(),c=D("div"),f=D("h3"),f.textContent="Current hieracy",l=Q(),u=D("div"),_t(h.$$.fragment),K(i,"type","button"),K(i,"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(m,v){M(m,e,v),p&&p.m(e,null),M(m,n,v),M(m,r,v),j(r,i),M(m,o,v),y&&y.m(m,v),M(m,a,v),M(m,c,v),j(c,f),j(c,l),j(c,u),ft(h,u,null),b=!0,g||(d=Je(i,"click",t[8]),g=!0)},p(m,v){m[3]===void 0?p?p.p(m,v):(p=Oi(m),p.c(),p.m(e,null)):p&&(p.d(1),p=null),v&10&&(s=m[1].find(m[6])),s?y?(y.p(m,v),v&10&&te(y,1)):(y=Hi(m),y.c(),te(y,1),y.m(a.parentNode,a)):y&&(lt(),he(y,1,1,()=>{y=null}),ut());const B={};v&4&&(B.hierarchy=m[2]),h.$set(B)},i(m){b||(te(y),te(h.$$.fragment,m),b=!0)},o(m){he(y),he(h.$$.fragment,m),b=!1},d(m){m&&q(e),p&&p.d(),m&&q(n),m&&q(r),m&&q(o),y&&y.d(m),m&&q(a),m&&q(c),ht(h),g=!1,d()}}}function eh(t){let e,n,r,i,o,s;return r=new Qf({}),{c(){e=D("button"),e.textContent="Leave Admin View",n=Q(),_t(r.$$.fragment),K(e,"type","button"),K(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(a,c){M(a,e,c),M(a,n,c),ft(r,a,c),i=!0,o||(s=Je(e,"click",t[7]),o=!0)},p:Z,i(a){i||(te(r.$$.fragment,a),i=!0)},o(a){he(r.$$.fragment,a),i=!1},d(a){a&&q(e),a&&q(n),ht(r,a),o=!1,s()}}}function Oi(t){let e,n,r;return{c(){e=D("button"),e.textContent="Login with NIP07",K(e,"type","button"),K(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){M(i,e,o),n||(r=Je(e,"click",t[4]),n=!0)},p:Z,d(i){i&&q(e),n=!1,r()}}}function Hi(t){let e,n,r,i,o,s;return o=new Af({props:{reload:t[5]}}),{c(){e=D("div"),n=D("h3"),n.textContent="Invite Someone",r=Q(),i=D("div"),_t(o.$$.fragment)},m(a,c){M(a,e,c),j(e,n),j(e,r),j(e,i),ft(o,i,null),s=!0},p:Z,i(a){s||(te(o.$$.fragment,a),s=!0)},o(a){he(o.$$.fragment,a),s=!1},d(a){a&&q(e),ht(o)}}}function th(t){let e,n,r,i,o,s;const a=[eh,Xf],c=[];function f(l,u){return l[0]==!0?0:l[0]==!1?1:-1}return~(i=f(t))&&(o=c[i]=a[i](t)),{c(){e=D("article"),n=D("h1"),n.textContent="Invite Relay",r=Q(),o&&o.c(),K(e,"class","font-sans px-4 py-6 lg:max-w-7xl lg:pt-6 lg:pb-28")},m(l,u){M(l,e,u),j(e,n),j(e,r),~i&&c[i].m(e,null),s=!0},p(l,[u]){let h=i;i=f(l),i===h?~i&&c[i].p(l,u):(o&&(lt(),he(c[h],1,1,()=>{c[h]=null}),ut()),~i?(o=c[i],o?o.p(l,u):(o=c[i]=a[i](l),o.c()),te(o,1),o.m(e,null)):o=null)},i(l){s||(te(o),s=!0)},o(l){he(o),s=!1},d(l){l&&q(e),~i&&c[i].d()}}}function nh(t,e,n){let r,i;st(t,on,b=>n(3,r=b)),st(t,ot,b=>n(9,i=b));let o=!1;async function s(){const b=new hf;Fr(ot,i.signer=b,i),ot.set(i),Fr(on,r=(await i.signer.user()).npub,r),on.set(r)}async function a(){const b=await fetch("/invitedata");n(1,c=Object.values(await b.json())),n(2,f=ss(c,{pk:"",invited_by:""}))}let c=[],f=[];return cr(()=>{addEventListener("load",b=>{s()}),a()}),[o,c,f,r,s,a,b=>r==ie.npubEncode(b.pk),()=>n(0,o=!1),()=>n(0,o=!0)]}class rh extends $t{constructor(e){super(),At(this,e,nh,th,ct,{})}}new rh({target:document.getElementById("app")}); diff --git a/ui/dist/assets/index-8d16ea5e.css b/ui/dist/assets/index-8d16ea5e.css deleted file mode 100644 index c274b44..0000000 --- a/ui/dist/assets/index-8d16ea5e.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}[type=text],input:where(:not([type])),[type=email],[type=url],[type=password],[type=number],[type=date],[type=datetime-local],[type=month],[type=search],[type=tel],[type=time],[type=week],[multiple],textarea,select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#6b7280;border-width:1px;border-radius:0;padding:.5rem .75rem;font-size:1rem;line-height:1.5rem;--tw-shadow: 0 0 #0000}[type=text]:focus,input:where(:not([type])):focus,[type=email]:focus,[type=url]:focus,[type=password]:focus,[type=number]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=month]:focus,[type=search]:focus,[type=tel]:focus,[type=time]:focus,[type=week]:focus,[multiple]:focus,textarea:focus,select:focus{outline:2px solid transparent;outline-offset:2px;--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: #2563eb;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);border-color:#2563eb}input::-moz-placeholder,textarea::-moz-placeholder{color:#6b7280;opacity:1}input::placeholder,textarea::placeholder{color:#6b7280;opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit,::-webkit-datetime-edit-year-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-meridiem-field{padding-top:0;padding-bottom:0}select{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}[multiple],[size]:where(select:not([size="1"])){background-image:initial;background-position:initial;background-repeat:unset;background-size:initial;padding-right:.75rem;-webkit-print-color-adjust:unset;print-color-adjust:unset}[type=checkbox],[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact;display:inline-block;vertical-align:middle;background-origin:border-box;-webkit-user-select:none;-moz-user-select:none;user-select:none;flex-shrink:0;height:1rem;width:1rem;color:#2563eb;background-color:#fff;border-color:#6b7280;border-width:1px;--tw-shadow: 0 0 #0000}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{outline:2px solid transparent;outline-offset:2px;--tw-ring-inset: var(--tw-empty, );--tw-ring-offset-width: 2px;--tw-ring-offset-color: #fff;--tw-ring-color: #2563eb;--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}[type=checkbox]:checked,[type=radio]:checked{border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:center;background-repeat:no-repeat}[type=checkbox]:checked{background-image:url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e")}[type=radio]:checked{background-image:url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e")}[type=checkbox]:checked:hover,[type=checkbox]:checked:focus,[type=radio]:checked:hover,[type=radio]:checked:focus{border-color:transparent;background-color:currentColor}[type=checkbox]:indeterminate{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e");border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:center;background-repeat:no-repeat}[type=checkbox]:indeterminate:hover,[type=checkbox]:indeterminate:focus{border-color:transparent;background-color:currentColor}[type=file]{background:unset;border-color:inherit;border-width:0;border-radius:0;padding:0;font-size:unset;line-height:inherit}[type=file]:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.relative{position:relative}.m-0{margin:0}.mx-0{margin-left:0;margin-right:0}.-ml-px{margin-left:-1px}.mb-0{margin-bottom:0}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.mr-2{margin-right:.5rem}.mt-2{margin-top:.5rem}.mt-8{margin-top:2rem}.block{display:block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.h-7{height:1.75rem}.max-h-64{max-height:16rem}.w-7{width:1.75rem}.w-full{width:100%}.max-w-full{max-width:100%}.flex-grow{flex-grow:1}.cursor-pointer{cursor:pointer}.list-disc{list-style-type:disc}.columns-2{-moz-columns:2;columns:2}.columns-4{-moz-columns:4;columns:4}.items-center{align-items:center}.items-stretch{align-items:stretch}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.overflow-y-scroll{overflow-y:scroll}.scroll-auto{scroll-behavior:auto}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-none{border-radius:0}.rounded-l-md{border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.border{border-width:1px}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity))}.border-slate-500{--tw-border-opacity: 1;border-color:rgb(100 116 139 / var(--tw-border-opacity))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity))}.bg-indigo-600{--tw-bg-opacity: 1;background-color:rgb(79 70 229 / var(--tw-bg-opacity))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity))}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.p-0{padding:0}.p-2{padding:.5rem}.p-4{padding:1rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.font-sans{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-sm{font-size:.875rem;line-height:1.25rem}.font-medium{font-weight:500}.font-semibold{font-weight:600}.leading-4{line-height:1rem}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.focus-within\:z-10:focus-within{z-index:10}.hover\:bg-gray-50:hover{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity))}.hover\:bg-green-400:hover{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity))}.hover\:bg-indigo-700:hover{--tw-bg-opacity: 1;background-color:rgb(67 56 202 / var(--tw-bg-opacity))}.hover\:bg-red-400:hover{--tw-bg-opacity: 1;background-color:rgb(248 113 113 / var(--tw-bg-opacity))}.hover\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.hover\:underline:hover{text-decoration-line:underline}.focus\:border-indigo-500:focus{--tw-border-opacity: 1;border-color:rgb(99 102 241 / var(--tw-border-opacity))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-gray-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(107 114 128 / var(--tw-ring-opacity))}.focus\:ring-indigo-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(99 102 241 / var(--tw-ring-opacity))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}@media (min-width: 640px){.sm\:text-sm{font-size:.875rem;line-height:1.25rem}}@media (min-width: 1024px){.lg\:max-w-7xl{max-width:80rem}.lg\:pb-28{padding-bottom:7rem}.lg\:pt-6{padding-top:1.5rem}} diff --git a/ui/dist/index.html b/ui/dist/index.html deleted file mode 100644 index 26516d9..0000000 --- a/ui/dist/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Invite Relay - - - - - - - - -
- - - diff --git a/ui/src/components/AdminView.svelte b/ui/src/components/AdminView.svelte index 410c1cf..2d3d559 100644 --- a/ui/src/components/AdminView.svelte +++ b/ui/src/components/AdminView.svelte @@ -26,7 +26,7 @@ }); let filter = { kinds: [1984], limit: 250 }; - let es = await $ndk.fetchEvents(filter/*, relaySet*/); + let es = await $ndk.fetchEvents(filter, relaySet); events = Array.from(es); } catch { console.log("error while getting feed", error);