/**
* Minified by jsDelivr using Terser v5.39.0.
* Original file: /npm/window.nostr.js@0.5.0/dist/window.nostr.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
var tl=Object.defineProperty,el=(t,e,n)=>e in t?tl(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,v=(t,e,n)=>(el(t,"symbol"!=typeof e?e+"":e,n),n);!function(){"use strict";var t,e,n,r,o;function i(){}function s(t){return t()}function a(){return Object.create(null)}function c(t){t.forEach(s)}function l(t){return"function"==typeof t}function u(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}let h;function d(t,e){return t===e||(h||(h=document.createElement("a")),h.href=e,t===h.href)}function f(t,e,n){t.$$.on_destroy.push(function(t,...e){if(null==t){for(const t of e)t(void 0);return i}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}(e,n))}const p=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function g(t,e){t.appendChild(e)}function w(t,e,n){t.insertBefore(e,n||null)}function b(t){t.parentNode&&t.parentNode.removeChild(t)}function y(t){return document.createElement(t)}function m(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function x(t){return document.createTextNode(t)}function E(){return x(" ")}function k(){return x("")}function A(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function S(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function $(t,e){e=""+e,t.data!==e&&(t.data=e)}function I(t,e){t.value=e??""}function O(t,e,n){t.classList.toggle(e,!!n)}let B;function T(t){B=t}function U(t){(function(){if(!B)throw new Error("Function called outside component initialization");return B})().$$.on_mount.push(t)}const _=[],L=[];let P=[];const R=[],N=Promise.resolve();let H=!1;function C(t){P.push(t)}const j=new Set;let q=0;function M(){if(0!==q)return;const t=B;do{try{for(;q<_.length;){const t=_[q];q++,T(t),z(t.$$)}}catch(t){throw _.length=0,q=0,t}for(T(null),_.length=0,q=0;L.length;)L.pop()();for(let t=0;t
{K.delete(t),r&&(n&&t.d(1),r())})),t.o(e)}else r&&r()}function J(t){t&&t.c()}function Y(t,e,n){const{fragment:r,after_update:o}=t.$$;r&&r.m(e,n),C((()=>{const e=t.$$.on_mount.map(s).filter(l);t.$$.on_destroy?t.$$.on_destroy.push(...e):c(e),t.$$.on_mount=[]})),o.forEach(C)}function G(t,e){const n=t.$$;null!==n.fragment&&(function(t){const e=[],n=[];P.forEach((r=>-1===t.indexOf(r)?e.push(r):n.push(r))),n.forEach((t=>t())),P=e}(n.after_update),c(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Q(t,e){-1===t.$$.dirty[0]&&(_.push(t),H||(H=!0,N.then(M)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const i=r.length?r[0]:n;return d.ctx&&o(d.ctx[e],d.ctx[e]=i)&&(!d.skip_bound&&d.bound[e]&&d.bound[e](i),f&&Q(t,e)),n})):[],d.update(),f=!0,c(d.before_update),d.fragment=!!r&&r(d.ctx),e.target){if(e.hydrate){const t=function(t){return Array.from(t.childNodes)}(e.target);d.fragment&&d.fragment.l(t),t.forEach(b)}else d.fragment&&d.fragment.c();e.intro&&V(t.$$.fragment),Y(t,e.target,e.anchor),M()}T(h)}class tt{constructor(){v(this,"$$"),v(this,"$$set")}$destroy(){G(this,1),this.$destroy=i}$on(t,e){if(!l(e))return i;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");var et={exports:{}};function nt(t,e=100,n={}){if("function"!=typeof t)throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(e<0)throw new RangeError("`wait` must not be negative.");const{immediate:r}="boolean"==typeof n?{immediate:n}:n;let o,i,s,a,c;function l(){const n=Date.now()-a;if(n=0)s=setTimeout(l,e-n);else if(s=void 0,!r){const e=o,n=i;o=void 0,i=void 0,c=t.apply(e,n)}}const u=function(...n){if(o&&this!==o)throw new Error("Debounced method called with different contexts.");o=this,i=n,a=Date.now();const u=r&&!s;if(s||(s=setTimeout(l,e)),u){const e=o,n=i;o=void 0,i=void 0,c=t.apply(e,n)}return c};return u.clear=()=>{s&&(clearTimeout(s),s=void 0)},u.flush=()=>{if(!s)return;const e=o,n=i;o=void 0,i=void 0,c=t.apply(e,n),clearTimeout(s),s=void 0},u}et.exports.debounce=nt,et.exports=nt;var rt=et.exports;const ot=(st=rt)&&st.__esModule&&Object.prototype.hasOwnProperty.call(st,"default")?st.default:st,it="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */var st;const at=t=>t instanceof Uint8Array,ct=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),lt=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");const ut=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function ht(t){if(!at(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nt+e.length),0));let n=0;return t.forEach((t=>{if(!at(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}let gt=class{clone(){return this._cloneInto()}};function wt(t){const e=e=>t().update(ft(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function bt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function yt(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 mt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}const vt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,xt=t=>t instanceof Uint8Array,Et=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),kt=(t,e)=>t<<32-e|t>>>e;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function At(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!xt(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class St{clone(){return this._cloneInto()}}function $t(t=32){if(vt&&"function"==typeof vt.getRandomValues)return vt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}let It=class extends St{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Et(this.buffer)}update(t){mt(this);const{view:e,buffer:n,blockLen:r}=this,o=(t=At(t)).length;for(let i=0;ir-i&&(this.process(n,0),i=0);for(let t=i;t>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+l,a,r)})(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=Et(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;tt&e^~t&n,Bt=(t,e,n)=>t&e^t&n^e&n,Tt=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]),Ut=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_t=new Uint32Array(64);let Lt=class extends It{constructor(){super(64,32,8,!1),this.A=0|Ut[0],this.B=0|Ut[1],this.C=0|Ut[2],this.D=0|Ut[3],this.E=0|Ut[4],this.F=0|Ut[5],this.G=0|Ut[6],this.H=0|Ut[7]}get(){const{A:t,B:e,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[t,e,n,r,o,i,s,a]}set(t,e,n,r,o,i,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)_t[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=_t[t-15],n=_t[t-2],r=kt(e,7)^kt(e,18)^e>>>3,o=kt(n,17)^kt(n,19)^n>>>10;_t[t]=o+_t[t-7]+r+_t[t-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:l}=this;for(let t=0;t<64;t++){const e=l+(kt(s,6)^kt(s,11)^kt(s,25))+Ot(s,a,c)+Tt[t]+_t[t]|0,u=(kt(n,2)^kt(n,13)^kt(n,22))+Bt(n,r,o)|0;l=c,c=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,i,s,a,c,l)}roundClean(){_t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Pt=function(t){const e=e=>t().update(At(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}((()=>new Lt)),Rt=BigInt(0),Nt=BigInt(1),Ht=BigInt(2),Ct=t=>t instanceof Uint8Array,jt=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qt(t){if(!Ct(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nt+e.length),0));let n=0;return t.forEach((t=>{if(!Ct(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}const Yt=t=>(Ht<new Uint8Array(t),Qt=t=>Uint8Array.from(t);function Xt(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=Gt(t),o=Gt(t),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...t)=>n(o,r,...t),c=(t=Gt())=>{o=a(Qt([0]),t),r=a(),0!==t.length&&(o=a(Qt([1]),t),r=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t{let n;for(s(),c(t);!(n=e(l()));)c();return s(),n}}const te={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function ee(t,e,n={}){const r=(e,n,r)=>{const o=te[n];if("function"!=typeof o)throw new Error(`Invalid validator "${n}", expected function`);const i=t[e];if(!(r&&void 0===i||o(i,t)))throw new Error(`Invalid param ${String(e)}=${i} (${typeof i}), expected ${n}`)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0);return t}const ne=Object.freeze(Object.defineProperty({__proto__:null,bitGet:function(t,e){return t>>BigInt(e)&Nt},bitLen:function(t){let e;for(e=0;t>Rt;t>>=Nt,e+=1);return e},bitMask:Yt,bitSet:(t,e,n)=>t|(n?Nt:Rt)<=re?n:e+n}function he(t,e,n){if(n<=re||e 0");if(n===oe)return re;let r=oe;for(;e>re;)e&oe&&(r=r*t%n),t=t*t%n,e>>=oe;return r}function de(t,e,n){let r=t;for(;e-- >re;)r*=r,r%=n;return r}function fe(t,e){if(t===re||e<=re)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ue(t,e),r=e,o=re,i=oe;for(;n!==re;){const t=r%n,e=o-i*(r/n);r=n,n=t,o=i,i=e}if(r!==oe)throw new Error("invert: does not exist");return ue(o,e)}function pe(t){if(t%ae===se){const e=(t+oe)/ae;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}if(t%le===ce){const e=(t-ce)/le;return function(t,n){const r=t.mul(n,ie),o=t.pow(r,e),i=t.mul(n,o),s=t.mul(t.mul(i,ie),o),a=t.mul(i,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-oe)/ie;let n,r,o;for(n=t-oe,r=0;n%ie===re;n/=ie,r++);for(o=ie;o(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}(t.Fp),ee(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...we(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:Ee,hexToBytes:ke}=ne,Ae={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=Ae;if(t.length<2||2!==t[0])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(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Ee(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=Ae,n="string"==typeof t?ke(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:o,l:i}=Ae._parseInt(n.subarray(2)),{d:s,l:a}=Ae._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s:s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},r=e(n(t.s)),o=e(n(t.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},Se=BigInt(0),$e=BigInt(1);BigInt(2);const Ie=BigInt(3);function Oe(t){const e=function(t){const e=xe(t);ee(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:o}=e;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:n}=e,r=e.toBytes||((t,e,r)=>{const o=e.toAffine();return Jt(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),o=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function i(t){const{a:r,b:o}=e,i=n.sqr(t),s=n.mul(i,t);return n.add(n.add(s,n.mul(t,r)),o)}if(!n.eql(n.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&Sen.eql(t,n.ZERO);return o(e)&&o(r)?h.ZERO:new h(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(o(Zt("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(c(t))}_setWindowSize(t){this._WINDOW_SIZE=t,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw new Error("bad point: x or y not FE");const o=n.sqr(r),s=i(t);if(!n.eql(o,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:o}=this,{px:i,py:s,pz:a}=t,c=n.eql(n.mul(e,a),n.mul(i,o)),l=n.eql(n.mul(r,a),n.mul(s,o));return c&&l}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,o=n.mul(r,Ie),{px:i,py:s,pz:a}=this;let c=n.ZERO,l=n.ZERO,u=n.ZERO,d=n.mul(i,i),f=n.mul(s,s),p=n.mul(a,a),g=n.mul(i,s);return g=n.add(g,g),u=n.mul(i,a),u=n.add(u,u),c=n.mul(t,u),l=n.mul(o,p),l=n.add(c,l),c=n.sub(f,l),l=n.add(f,l),l=n.mul(c,l),c=n.mul(g,c),u=n.mul(o,u),p=n.mul(t,p),g=n.sub(d,p),g=n.mul(t,g),g=n.add(g,u),u=n.add(d,d),d=n.add(u,d),d=n.add(d,p),d=n.mul(d,g),l=n.add(l,d),p=n.mul(s,a),p=n.add(p,p),d=n.mul(p,g),c=n.sub(c,d),u=n.mul(p,f),u=n.add(u,u),u=n.add(u,u),new h(c,l,u)}add(t){u(t);const{px:r,py:o,pz:i}=this,{px:s,py:a,pz:c}=t;let l=n.ZERO,d=n.ZERO,f=n.ZERO;const p=e.a,g=n.mul(e.b,Ie);let w=n.mul(r,s),b=n.mul(o,a),y=n.mul(i,c),m=n.add(r,o),v=n.add(s,a);m=n.mul(m,v),v=n.add(w,b),m=n.sub(m,v),v=n.add(r,i);let x=n.add(s,c);return v=n.mul(v,x),x=n.add(w,y),v=n.sub(v,x),x=n.add(o,i),l=n.add(a,c),x=n.mul(x,l),l=n.add(b,y),x=n.sub(x,l),f=n.mul(p,v),l=n.mul(g,y),f=n.add(l,f),l=n.sub(b,f),f=n.add(b,f),d=n.mul(l,f),b=n.add(w,w),b=n.add(b,w),y=n.mul(p,y),v=n.mul(g,v),b=n.add(b,y),y=n.sub(w,y),y=n.mul(p,y),v=n.add(v,y),w=n.mul(b,v),d=n.add(d,w),w=n.mul(x,v),l=n.mul(m,l),l=n.sub(l,w),w=n.mul(m,b),f=n.mul(x,f),f=n.add(f,w),new h(l,d,f)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return f.wNAFCached(this,l,t,(t=>{const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(h.fromAffine)}))}multiplyUnsafe(t){const r=h.ZERO;if(t===Se)return r;if(a(t),t===$e)return this;const{endo:o}=e;if(!o)return f.unsafeLadder(this,t);let{k1neg:i,k1:s,k2neg:c,k2:l}=o.splitScalar(t),u=r,d=r,p=this;for(;s>Se||l>Se;)s&$e&&(u=u.add(p)),l&$e&&(d=d.add(p)),p=p.double(),s>>=$e,l>>=$e;return i&&(u=u.negate()),c&&(d=d.negate()),d=new h(n.mul(d.px,o.beta),d.py,d.pz),u.add(d)}multiply(t){a(t);let r,o,i=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:c}=s.splitScalar(i);let{p:l,f:u}=this.wNAF(e),{p:d,f:p}=this.wNAF(c);l=f.constTimeNegate(t,l),d=f.constTimeNegate(a,d),d=new h(n.mul(d.px,s.beta),d.py,d.pz),r=l.add(d),o=u.add(p)}else{const{p:t,f:e}=this.wNAF(i);r=t,o=e}return h.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(t,e,n){const r=h.BASE,o=(t,e)=>e!==Se&&e!==$e&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),i=o(this,e).add(o(t,n));return i.is0()?void 0:i}toAffine(t){const{px:e,py:r,pz:o}=this,i=this.is0();null==t&&(t=i?n.ONE:n.inv(o));const s=n.mul(e,t),a=n.mul(r,t),c=n.mul(o,t);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===$e)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===$e?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(h,this,t)}toHex(t=!0){return qt(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,f=function(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,o=e;for(;n>me;)n&ve&&(r=r.add(o)),o=o.double(),n>>=ve;return r},precomputeWindow(t,e){const{windows:n,windowSize:o}=r(e),i=[];let s=t,a=s;for(let t=0;t>=d,r>a&&(r-=h,i+=ve);const s=e,f=e+Math.abs(r)-1,p=t%2!=0,g=r<0;0===r?l=l.add(n(p,o[s])):c=c.add(n(g,o[f]))}return{p:c,f:l}},wNAFCached(t,e,n,r){const o=t._WINDOW_SIZE||1;let i=e.get(t);return i||(i=this.precomputeWindow(t,o),1!==o&&e.set(t,r(i))),this.wNAF(o,i,n)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function Be(t){const e=function(t){const e=xe(t);return ee(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r}=e,o=n.BYTES+1,i=2*n.BYTES+1;function s(t){return ue(t,r)}function a(t){return fe(t,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:h}=Oe({...e,toBytes(t,e,r){const o=e.toAffine(),i=n.toBytes(o.x),s=Jt;return r?s(Uint8Array.from([e.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(t){const e=t.length,r=t[0],s=t.subarray(1);if(e!==o||2!==r&&3!==r){if(e===i&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${e} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}{const t=Wt(s);if(!function(t){return Seqt(Ft(t,e.nByteLength));function f(t){return t>r>>$e}const p=(t,e,n)=>Wt(t.slice(e,n));class g{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=Zt("compactSignature",t,2*n),new g(p(t,0,n),p(t,n,2*n))}static fromDER(t){const{r:e,s:n}=Ae.toSig(Zt("DER",t));return new g(e,n)}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(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:o,recovery:i}=this,l=m(Zt("msgHash",t));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?r+e.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&i?"03":"02",f=c.fromHex(h+d(u)),p=a(u),g=s(-l*p),w=s(o*p),b=c.BASE.multiplyAndAddUnsafe(f,g,w);if(!b)throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Kt(this.toDERHex())}toDERHex(){return Ae.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Kt(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const w={isValidPrivateKey(t){try{return l(t),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const t=ye(e.n);return function(t,e,n=!1){const r=t.length,o=be(e),i=ye(e);if(r<16||r1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=ue(n?Wt(t):Dt(t),e-oe)+oe;return n?Vt(s,o):Ft(s,o)}(e.randomBytes(t),e.n)},precompute:(t=8,e=c.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function b(t){const e=t instanceof Uint8Array,n="string"==typeof t,r=(e||n)&&t.length;return e?r===o||r===i:n?r===2*o||r===2*i:t instanceof c}const y=e.bits2int||function(t){const n=Wt(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},m=e.bits2int_modN||function(t){return s(y(t))},v=Yt(e.nBitLength);function x(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(Se<=t&&tt in o)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=e;let{lowS:d,prehash:p,extraEntropy:w}=o;null==d&&(d=!0),t=Zt("msgHash",t),p&&(t=Zt("prehashed msgHash",i(t)));const b=m(t),v=l(r),E=[x(v),x(b)];if(null!=w){const t=!0===w?u(n.BYTES):w;E.push(Zt("extraEntropy",t))}const A=Jt(...E),S=b;return{seed:A,k2sig:function(t){const e=y(t);if(!h(e))return;const n=a(e),r=c.BASE.multiply(e).toAffine(),o=s(r.x);if(o===Se)return;const i=s(n*s(S+o*v));if(i===Se)return;let l=(r.x===o?0:2)|Number(r.y&$e),u=i;return d&&f(i)&&(u=function(t){return f(t)?s(-t):t}(i),l^=1),new g(o,u,l)}}}const k={lowS:e.lowS,prehash:!1},A={lowS:e.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return c.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(b(t))throw new Error("first arg must be private key");if(!b(e))throw new Error("second arg must be public key");return c.fromHex(e).multiply(l(t)).toRawBytes(n)},sign:function(t,n,r=k){const{seed:o,k2sig:i}=E(t,n,r),s=e;return Xt(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(t,n,r,o=A){var i;const l=t;if(n=Zt("msgHash",n),r=Zt("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:h}=o;let d,f;try{if("string"==typeof l||l instanceof Uint8Array)try{d=g.fromDER(l)}catch(t){if(!(t instanceof Ae.Err))throw t;d=g.fromCompact(l)}else{if("object"!=typeof l||"bigint"!=typeof l.r||"bigint"!=typeof l.s)throw new Error("PARSE");{const{r:t,s:e}=l;d=new g(t,e)}}f=c.fromHex(r)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&d.hasHighS())return!1;h&&(n=e.hash(n));const{r:p,s:w}=d,b=m(n),y=a(w),v=s(b*y),x=s(p*y),E=null==(i=c.BASE.multiplyAndAddUnsafe(f,v,x))?void 0:i.toAffine();return!!E&&s(E.x)===p},ProjectivePoint:c,Signature:g,utils:w}}BigInt(4);let Te=class extends St{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");bt(t.outputLen),bt(t.blockLen)}(t);const n=At(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?t.create().update(n).digest():n);for(let t=0;tnew Te(t,e).update(n).digest();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function _e(t){return{hash:t,hmac:(e,...n)=>Ue(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let n=0;return t.forEach((t=>{if(!xt(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length})),e}(...n)),randomBytes:$t}}Ue.create=(t,e)=>new Te(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Le=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Pe=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Re=BigInt(1),Ne=BigInt(2),He=(t,e)=>(t+e/Ne)/e;function Ce(t){const e=Le,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=t*t*t%e,u=l*l*t%e,h=de(u,n,e)*u%e,d=de(h,n,e)*u%e,f=de(d,Ne,e)*l%e,p=de(f,o,e)*f%e,g=de(p,i,e)*p%e,w=de(g,a,e)*g%e,b=de(w,c,e)*w%e,y=de(b,a,e)*g%e,m=de(y,n,e)*u%e,v=de(m,s,e)*p%e,x=de(v,r,e)*l%e,E=de(x,Ne,e);if(!je.eql(je.sqr(E),t))throw new Error("Cannot find square root");return E}const je=function(t,e,n=!1,r={}){if(t<=re)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=we(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=pe(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:Yt(o),ZERO:re,ONE:oe,create:e=>ue(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return re<=e&&et===re,isOdd:t=>(t&oe)===oe,neg:e=>ue(-e,t),eql:(t,e)=>t===e,sqr:e=>ue(e*e,t),add:(e,n)=>ue(e+n,t),sub:(e,n)=>ue(e-n,t),mul:(e,n)=>ue(e*n,t),pow:(t,e)=>function(t,e,n){if(n 0");if(n===re)return t.ONE;if(n===oe)return e;let r=t.ONE,o=e;for(;n>re;)n&oe&&(r=t.mul(r,o)),o=t.sqr(o),n>>=oe;return r}(a,t,e),div:(e,n)=>ue(e*fe(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>fe(e,t),sqrt:r.sqrt||(t=>s(a,t)),invertBatch:t=>function(t,e){const n=new Array(e.length),r=e.reduce(((e,r,o)=>t.is0(r)?e:(n[o]=e,t.mul(e,r))),t.ONE),o=t.inv(r);return e.reduceRight(((e,r,o)=>t.is0(r)?e:(n[o]=t.mul(e,n[o]),t.mul(e,r))),o),n}(a,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?Vt(t,i):Ft(t,i),fromBytes:t=>{if(t.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${t.length}`);return n?Dt(t):Wt(t)}});return Object.freeze(a)}(Le,void 0,void 0,{sqrt:Ce}),qe=function(t,e){const n=e=>Be({...t,..._e(e)});return Object.freeze({...n(e),create:n})}({a:BigInt(0),b:BigInt(7),Fp:je,n:Pe,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Pe,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Re*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=He(i*t,e),c=He(-r*t,e);let l=ue(t-a*n-c*o,e),u=ue(-a*r-c*i,e);const h=l>s,d=u>s;if(h&&(l=e-l),d&&(u=e-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:l,k2neg:d,k2:u}}}},Pt),Me=BigInt(0),ze=t=>"bigint"==typeof t&&Met.charCodeAt(0))));n=Jt(e,e),Ke[t]=n}return Pt(Jt(n,...e))}const De=t=>t.toRawBytes(!0).slice(1),Fe=t=>Ft(t,32),Ve=t=>ue(t,Le),Ze=t=>ue(t,Pe),Je=qe.ProjectivePoint;function Ye(t){let e=qe.utils.normPrivateKeyToScalar(t),n=Je.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Ze(-e),bytes:De(n)}}function Ge(t){if(!ze(t))throw new Error("bad x: need 0 < x < p");const e=Ve(t*t);let n=Ce(Ve(e*t+BigInt(7)));n%Ne!==Me&&(n=Ve(-n));const r=new Je(t,n,Re);return r.assertValidity(),r}function Qe(...t){return Ze(Wt(We("BIP0340/challenge",...t)))}function Xe(t,e,n){const r=Zt("signature",t,64),o=Zt("message",e),i=Zt("publicKey",n,32);try{const t=Ge(Wt(i)),e=Wt(r.subarray(0,32));if(!ze(e))return!1;const n=Wt(r.subarray(32,64));if(!(t=>"bigint"==typeof t&&MeJe.BASE.multiplyAndAddUnsafe(t,e,n))(t,n,Ze(-s));return!(!a||!a.hasEvenY()||a.toAffine().x!==e)}catch{return!1}}const tn={getPublicKey:function(t){return Ye(t).bytes},sign:function(t,e,n=$t(32)){const r=Zt("message",t),{bytes:o,scalar:i}=Ye(e),s=Zt("auxRand",n,32),a=Fe(i^Wt(We("BIP0340/aux",s))),c=We("BIP0340/nonce",a,o,r),l=Ze(Wt(c));if(l===Me)throw new Error("sign failed: k is zero");const{bytes:u,scalar:h}=Ye(l),d=Qe(u,o,r),f=new Uint8Array(64);if(f.set(u,0),f.set(Fe(Ze(h+d*i)),32),!Xe(f,r,o))throw new Error("sign: Invalid signature produced");return f},verify:Xe,utils:{randomPrivateKey:qe.utils.randomPrivateKey,lift_x:Ge,pointToBytes:De,numberToBytesBE:Ft,bytesToNumberBE:Wt,taggedHash:We,mod:ue}};function en(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function nn(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}`)}const rn={number:en,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:nn,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");en(t.outputLen),en(t.blockLen)},exists:function(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")},output:function(t,e){nn(t);const n=e.outputLen;if(t.lengthr-i&&(this.process(n,0),i=0);for(let t=i;t>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+l,a,r)})(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=ct(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;tt&e^~t&n,an=(t,e,n)=>t&e^t&n^e&n,cn=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]),ln=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),un=new Uint32Array(64);class hn extends on{constructor(){super(64,32,8,!1),this.A=0|ln[0],this.B=0|ln[1],this.C=0|ln[2],this.D=0|ln[3],this.E=0|ln[4],this.F=0|ln[5],this.G=0|ln[6],this.H=0|ln[7]}get(){const{A:t,B:e,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[t,e,n,r,o,i,s,a]}set(t,e,n,r,o,i,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)un[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=un[t-15],n=un[t-2],r=lt(e,7)^lt(e,18)^e>>>3,o=lt(n,17)^lt(n,19)^n>>>10;un[t]=o+un[t-7]+r+un[t-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:l}=this;for(let t=0;t<64;t++){const e=l+(lt(s,6)^lt(s,11)^lt(s,25))+sn(s,a,c)+cn[t]+un[t]|0,u=(lt(n,2)^lt(n,13)^lt(n,22))+an(n,r,o)|0;l=c,c=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,i,s,a,c,l)}roundClean(){un.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class dn extends hn{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 fn=wt((()=>new hn));wt((()=>new dn));var pn=Symbol("verified");function gn(t){if(!(t=>t instanceof Object)(t)||"number"!=typeof t.kind||"string"!=typeof t.content||"number"!=typeof t.created_at||"string"!=typeof t.pubkey||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;et instanceof Object)(t)||"number"!=typeof t.kind||"string"!=typeof t.content||"number"!=typeof t.created_at||"string"!=typeof t.pubkey||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;et===n.slice(1)&&-1!==r.indexOf(e))))return!1}return!(t.since&&e.created_att.until)}async function Un(){return new Promise((t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()}))}var _n,Ln=t=>(t[xn]=!0,!0),Pn=class{constructor(t,e){v(this,"url"),v(this,"_connected",!1),v(this,"onclose",null),v(this,"onnotice",(t=>console.debug(`NOTICE from ${this.url}: ${t}`))),v(this,"_onauth",null),v(this,"baseEoseTimeout",4400),v(this,"connectionTimeout",4400),v(this,"publishTimeout",4400),v(this,"openSubs",new Map),v(this,"connectionTimeoutHandle"),v(this,"connectionPromise"),v(this,"openCountRequests",new Map),v(this,"openEventPublishes",new Map),v(this,"ws"),v(this,"incomingMessageQueue",new $n),v(this,"queueRunning",!1),v(this,"challenge"),v(this,"serial",0),v(this,"verifyEvent"),v(this,"_WebSocket"),this.url=An(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket}static async connect(t,e){const n=new Pn(t,e);return await n.connect(),n}closeAllSubscriptions(t){for(let[e,n]of this.openSubs)n.close(t);this.openSubs.clear();for(let[e,n]of this.openEventPublishes)n.reject(new Error(t));this.openEventPublishes.clear();for(let[e,n]of this.openCountRequests)n.reject(new Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise||(this.challenge=void 0,this.connectionPromise=new Promise(((t,e)=>{this.connectionTimeoutHandle=setTimeout((()=>{var t;e("connection timed out"),this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection timed out")}),this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(t){return void e(t)}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=t=>{var n;e(t.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,null==(n=this.onclose)||n.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var t;this._connected&&(this._connected=!1,this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}))),this.connectionPromise}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await Un();this.queueRunning=!1}handleNext(){var t,e,n;const r=this.incomingMessageQueue.dequeue();if(!r)return!1;const o=function(t){let e=t.slice(0,22).indexOf('"EVENT"');if(-1===e)return null;let n=t.slice(e+7+1).indexOf('"');if(-1===n)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return t.slice(r+1,i)}(r);if(o){const n=this.openSubs.get(o);if(!n)return;const i=function(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}(r,"id"),s=null==(t=n.alreadyHaveEvent)?void 0:t.call(n,i);if(null==(e=n.receivedEvent)||e.call(n,this,i),s)return}try{let t=JSON.parse(r);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return void(this.verifyEvent(n)&&function(t,e){for(let n=0;n{var e;null==(e=this.ws)||e.send(t)}))}async auth(t){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const e=await t(function(t,e){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}(this.url,this.challenge)),n=new Promise(((t,n)=>{const r=setTimeout((()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("auth timed out")),this.openEventPublishes.delete(e.id))}),this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:r})}));return this.send('["AUTH",'+JSON.stringify(e)+"]"),n}async publish(t){const e=new Promise(((e,n)=>{const r=setTimeout((()=>{const e=this.openEventPublishes.get(t.id);e&&(e.reject(new Error("publish timed out")),this.openEventPublishes.delete(t.id))}),this.publishTimeout);this.openEventPublishes.set(t.id,{resolve:e,reject:n,timeout:r})}));return this.send('["EVENT",'+JSON.stringify(t)+"]"),e}async count(t,e){this.serial++;const n=(null==e?void 0:e.id)||"count:"+this.serial,r=new Promise(((t,e)=>{this.openCountRequests.set(n,{resolve:t,reject:e})}));return this.send('["COUNT","'+n+'",'+JSON.stringify(t).substring(1)),r}subscribe(t,e){const n=this.prepareSubscription(t,e);return n.fire(),n}prepareSubscription(t,e){this.serial++;const n=e.id||(e.label?e.label+":":"sub:")+this.serial,r=new Rn(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,null==(t=this.ws)||t.close()}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},Rn=class{constructor(t,e,n,r){v(this,"relay"),v(this,"id"),v(this,"closed",!1),v(this,"eosed",!1),v(this,"filters"),v(this,"alreadyHaveEvent"),v(this,"receivedEvent"),v(this,"onevent"),v(this,"oneose"),v(this,"onclose"),v(this,"eoseTimeout"),v(this,"eoseTimeoutHandle"),this.relay=t,this.filters=n,this.id=e,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||t.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(t=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,t)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var t;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,null==(t=this.oneose)||t.call(this))}close(t="closed by caller"){var e;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),null==(e=this.onclose)||e.call(this,t)}},Nn=class{constructor(t){v(this,"relays",new Map),v(this,"seenOn",new Map),v(this,"trackRelays",!1),v(this,"verifyEvent"),v(this,"trustedRelayURLs",new Set),v(this,"_WebSocket"),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation}async ensureRelay(t,e){t=An(t);let n=this.relays.get(t);return n||(n=new Pn(t,{verifyEvent:this.trustedRelayURLs.has(t)?Ln:this.verifyEvent,websocketImplementation:this._WebSocket}),null!=e&&e.connectionTimeout&&(n.connectionTimeout=e.connectionTimeout),this.relays.set(t,n)),await n.connect(),n}close(t){t.map(An).forEach((t=>{var e;null==(e=this.relays.get(t))||e.close()}))}subscribeMany(t,e,n){return this.subscribeManyMap(Object.fromEntries(t.map((t=>[t,e]))),n)}subscribeManyMap(t,e){this.trackRelays&&(e.receivedEvent=(t,e)=>{let n=this.seenOn.get(e);n||(n=new Set,this.seenOn.set(e,n)),n.add(t)});const n=new Set,r=[],o=Object.keys(t).length,i=[];let s=t=>{var n;i[t]||(i[t]=!0,i.filter((t=>t)).length===o&&(null==(n=e.oneose)||n.call(e),s=()=>{}))};const a=[];let c=(t,n)=>{var r;a[t]||(s(t),a[t]=n,a.filter((t=>t)).length===o&&(null==(r=e.onclose)||r.call(e,a),c=()=>{}))};const l=t=>{var r;if(null!=(r=e.alreadyHaveEvent)&&r.call(e,t))return!0;const o=n.has(t);return n.add(t),o},u=Promise.all(Object.entries(t).map((async(t,n,o)=>{if(o.indexOf(t)!==n)return void c(n,"duplicate url");let i,[a,u]=t;a=An(a);try{i=await this.ensureRelay(a,{connectionTimeout:e.maxWait?Math.max(.8*e.maxWait,e.maxWait-1e3):void 0})}catch(t){return void c(n,(null==t?void 0:t.message)||String(t))}let h=i.subscribe(u,{...e,oneose:()=>s(n),onclose:t=>c(n,t),alreadyHaveEvent:l,eoseTimeout:e.maxWait});r.push(h)})));return{async close(){await u,r.forEach((t=>{t.close()}))}}}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close()}});return r}async querySync(t,e,n){return new Promise((async r=>{const o=[];this.subscribeManyEose(t,[e],{...n,onevent(t){o.push(t)},onclose(t){r(o)}})}))}async get(t,e,n){e.limit=1;const r=await this.querySync(t,e,n);return r.sort(((t,e)=>e.created_at-t.created_at)),r[0]||null}publish(t,e){return t.map(An).map((async(t,n,r)=>{if(r.indexOf(t)!==n)return Promise.reject("duplicate url");let o=await this.ensureRelay(t);return o.publish(e).then((t=>{if(this.trackRelays){let t=this.seenOn.get(e.id);t||(t=new Set,this.seenOn.set(e.id,t)),t.add(o)}return t}))}))}listConnectionStatus(){const t=new Map;return this.relays.forEach(((e,n)=>t.set(n,e.connected))),t}destroy(){this.relays.forEach((t=>t.close())),this.relays=new Map}};try{_n=WebSocket}catch{}var Hn=class extends Nn{constructor(){super({verifyEvent:Bn,websocketImplementation:_n})}};function Cn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function jn(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function qn(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function Mn(t,...e){if(!qn(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function zn(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 Kn(t,e){Mn(t);const n=e.outputLen;if(t.lengthnew Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Dn(t){if("string"!=typeof t)throw new Error("string expected, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function Fn(t){if("string"==typeof t)t=Dn(t);else{if(!qn(t))throw new Error("Uint8Array expected, got "+typeof t);t=t.slice()}return t}const Vn=16,Zn=new Uint8Array(16),Jn=Wn(Zn),Yn=(t,e,n,r)=>({s3:n<<31|r>>>1,s2:e<<31|n>>>1,s1:t<<31|e>>>1,s0:t>>>1^225<<24&-(1&(1&r))}),Gn=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255;class Qn{constructor(t,e){this.blockLen=Vn,this.outputLen=Vn,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,Mn(t=Fn(t),16);const n=(t=>new DataView(t.buffer,t.byteOffset,t.byteLength))(t);let r=n.getUint32(0,!1),o=n.getUint32(4,!1),i=n.getUint32(8,!1),s=n.getUint32(12,!1);const a=[];for(let t=0;t<128;t++)a.push({s0:Gn(r),s1:Gn(o),s2:Gn(i),s3:Gn(s)}),({s0:r,s1:o,s2:i,s3:s}=Yn(r,o,i,s));const c=(t=>t>65536?8:t>1024?4:2)(e||1024);if(![1,2,4,8].includes(c))throw new Error(`ghash: wrong window size=${c}, should be 2, 4 or 8`);this.W=c;const l=128/c,u=this.windowSize=2**c,h=[];for(let t=0;t>>c-s-1&1))continue;const{s0:l,s1:u,s2:h,s3:d}=a[c*t+s];n^=l,r^=u,o^=h,i^=d}h.push({s0:n,s1:r,s2:o,s3:i})}this.t=h}_updateBlock(t,e,n,r){t^=this.s0,e^=this.s1,n^=this.s2,r^=this.s3;const{W:o,t:i,windowSize:s}=this;let a=0,c=0,l=0,u=0;const h=(1<>>8*t&255;for(let t=8/o-1;t>=0;t--){const n=e>>>o*t&h,{s0:r,s1:f,s2:p,s3:g}=i[d*s+n];a^=r,c^=f,l^=p,u^=g,d+=1}}this.s0=a,this.s1=c,this.s2=l,this.s3=u}update(t){t=Fn(t),zn(this);const e=Wn(t),n=Math.floor(t.length/Vn),r=t.length%Vn;for(let t=0;t>>1|n,n=(1&r)<<7}return t[0]^=225&-e,t}((t=Fn(t)).slice());super(n,e),n.fill(0)}update(t){t=Fn(t),zn(this);const e=Wn(t),n=t.length%Vn,r=Math.floor(t.length/Vn);for(let t=0;tt(n,e.length).update(Fn(e)).digest(),n=t(new Uint8Array(16),0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=(e,n)=>t(e,n),e}tr(((t,e)=>new Qn(t,e))),tr(((t,e)=>new Xn(t,e)));const er=16;function nr(t){return t<<1^283&-(t>>7)}function rr(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(1&e),t=nr(t);return n}const or=(()=>{let t=new Uint8Array(256);for(let e=0,n=1;e<256;e++,n^=nr(n))t[e]=n;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return e})(),ir=or.map(((t,e)=>or.indexOf(e))),sr=t=>t<<24|t>>>8,ar=t=>t<<8|t>>>24;function cr(t,e){if(256!==t.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((n,r)=>e(t[r]))),r=n.map(ar),o=r.map(ar),i=o.map(ar),s=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let e=0;e<256;e++)for(let l=0;l<256;l++){const u=256*e+l;s[u]=n[e]^r[l],a[u]=o[e]^i[l],c[u]=t[e]<<8|t[l]}return{sbox:t,sbox2:c,T0:n,T1:r,T2:o,T3:i,T01:s,T23:a}}const lr=cr(or,(t=>rr(t,3)<<24|t<<16|t<<8|rr(t,2))),ur=cr(ir,(t=>rr(t,11)<<24|rr(t,13)<<16|rr(t,9)<<8|rr(t,14))),hr=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=nr(n))t[e]=n;return t})();function dr(t){Mn(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=lr,r=Wn(t),o=r.length,i=t=>pr(n,t,t,t,t),s=new Uint32Array(e+28);s.set(r);for(let t=o;t6&&t%o==4&&(e=i(e)),s[t]=s[t-o]^e}return s}function fr(t,e,n,r,o,i){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|i>>>24&255]}function pr(t,e,n,r,o){return t[255&e|65280&n]|t[r>>>16&255|o>>>16&65280]<<16}function gr(t,e,n,r,o){const{sbox2:i,T01:s,T23:a}=lr;let c=0;e^=t[c++],n^=t[c++],r^=t[c++],o^=t[c++];const l=t.length/4-2;for(let i=0;i(Object.assign(e,t),e))({blockSize:16,nonceLength:16},(function(t,e,n={}){Mn(t),Mn(e,16);const r=!n.disablePadding;return{encrypt:(n,o)=>{const i=dr(t),{b:s,o:a,out:c}=function(t,e,n){let r=t.length;const o=r%er;if(!e&&0!==o)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=Wn(t);if(e){let t=er-o;t||(t=er),r+=t}const s=br(r,n);return{b:i,o:Wn(s),out:s}}(n,r,o),l=Wn(e);let u=l[0],h=l[1],d=l[2],f=l[3],p=0;for(;p+4<=s.length;)u^=s[p+0],h^=s[p+1],d^=s[p+2],f^=s[p+3],({s0:u,s1:h,s2:d,s3:f}=gr(i,u,h,d,f)),a[p++]=u,a[p++]=h,a[p++]=d,a[p++]=f;if(r){const t=function(t){const e=new Uint8Array(16),n=Wn(e);e.set(t);const r=er-t.length;for(let t=er-r;t{!function(t){if(Mn(t),t.length%er!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const i=function(t){const e=dr(t),n=e.slice(),r=e.length,{sbox2:o}=lr,{T0:i,T1:s,T2:a,T3:c}=ur;for(let t=0;t>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}(t),s=Wn(e),a=br(n.length,o),c=Wn(n),l=Wn(a);let u=s[0],h=s[1],d=s[2],f=s[3];for(let t=0;t+4<=c.length;){const e=u,n=h,r=d,o=f;u=c[t+0],h=c[t+1],d=c[t+2],f=c[t+3];const{s0:s,s1:a,s2:p,s3:g}=wr(i,u,h,d,f);l[t++]=s^e,l[t++]=a^n,l[t++]=p^r,l[t++]=g^o}return i.fill(0),function(t,e){if(!e)return t;const n=t.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=t[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=t.subarray(0,-r);for(let e=0;en=>t(e(n));return{encode:Array.from(t).reverse().reduce(((t,n)=>t?e(t,n.encode):n.encode),void 0),decode:t.reduce(((t,n)=>t?e(t,n.decode):n.decode),void 0)}}function xr(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map((e=>{if(mr(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map((e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const n=t.indexOf(e);if(-1===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n}))}}}function Er(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function kr(t,e="="){if(mr(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);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 Ar(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function Sr(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 o=[],i=Array.from(t);for(i.forEach((t=>{if(mr(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,s=!0;for(let o=r;oe?$r(e,t%e):t,Ir=(t,e)=>t+(e-$r(t,e));function Or(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(Ir(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Ir(e,n)}`);let o=0,i=0;const s=2**n-1,a=[];for(const r of t){if(mr(r),r>=2**e)throw new Error(`convertRadix2: invalid data word=${r} from=${e}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=n;i-=n)a.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<=e)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&a.push(o>>>0),a}function Br(t,e=!1){if(mr(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Ir(8,t)>32||Ir(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 Or(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Or(n,t,8,e))}}}function Tr(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Ur=vr(Br(4),xr("0123456789ABCDEF"),Er("")),_r=vr(Br(5),xr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),kr(5),Er(""));vr(Br(5),xr("0123456789ABCDEFGHIJKLMNOPQRSTUV"),kr(5),Er("")),vr(Br(5),xr("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Er(""),Ar((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))));const Lr=vr(Br(6),xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),kr(6),Er("")),Pr=vr(Br(6),xr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),kr(6),Er("")),Rr=t=>vr(function(t){return mr(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Sr(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Sr(e,t,256))}}}(58),xr(t),Er("")),Nr=Rr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Rr("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Rr("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Hr=[0,2,3,5,6,7,9,10,11],Cr={encode(t){let e="";for(let n=0;n>25;let n=(33554431&t)<<5;for(let t=0;t>t&1)&&(n^=qr[t]);return n}function zr(t,e,n=1){const r=t.length;let o=1;for(let e=0;e126)throw new Error(`Invalid prefix (${t})`);o=Mr(o)^n>>5}o=Mr(o);for(let e=0;en)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${n})`);const r=t.toLowerCase();if(t!==r&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(t=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=t.slice(0,o),s=t.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=jr.decode(s).slice(0,-6),c=zr(i,a,e);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(t,n,r=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const o=t.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${t=t.toLowerCase()}1${jr.encode(n)}${zr(t,n,e)}`},decode:s,decodeToBytes:function(t){const{prefix:e,words:n}=s(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:Tr(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}const Wr=Kr("bech32");Kr("bech32m");const Dr={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},Fr=vr(Br(4),xr("0123456789abcdef"),Er(""),Ar((t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));Object.keys({utf8:Dr,hex:Fr,base16:Ur,base32:_r,base64:Lr,base64url:Pr,base58:Nr,base58xmr:Cr}).join(", ");const Vr=(t,e)=>255&t[e++]|(255&t[e++])<<8;class Zr{constructor(t){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,Mn(t=Fn(t),32);const e=Vr(t,0),n=Vr(t,2),r=Vr(t,4),o=Vr(t,6),i=Vr(t,8),s=Vr(t,10),a=Vr(t,12),c=Vr(t,14);this.r[0]=8191&e,this.r[1]=8191&(e>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|o<<9),this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let e=0;e<8;e++)this.pad[e]=Vr(t,16+2*e)}process(t,e,n=!1){const r=n?0:2048,{h:o,r:i}=this,s=i[0],a=i[1],c=i[2],l=i[3],u=i[4],h=i[5],d=i[6],f=i[7],p=i[8],g=i[9],w=Vr(t,e+0),b=Vr(t,e+2),y=Vr(t,e+4),m=Vr(t,e+6),v=Vr(t,e+8),x=Vr(t,e+10),E=Vr(t,e+12),k=Vr(t,e+14);let A=o[0]+(8191&w),S=o[1]+(8191&(w>>>13|b<<3)),$=o[2]+(8191&(b>>>10|y<<6)),I=o[3]+(8191&(y>>>7|m<<9)),O=o[4]+(8191&(m>>>4|v<<12)),B=o[5]+(v>>>1&8191),T=o[6]+(8191&(v>>>14|x<<2)),U=o[7]+(8191&(x>>>11|E<<5)),_=o[8]+(8191&(E>>>8|k<<8)),L=o[9]+(k>>>5|r),P=0,R=P+A*s+S*(5*g)+$*(5*p)+I*(5*f)+O*(5*d);P=R>>>13,R&=8191,R+=B*(5*h)+T*(5*u)+U*(5*l)+_*(5*c)+L*(5*a),P+=R>>>13,R&=8191;let N=P+A*a+S*s+$*(5*g)+I*(5*p)+O*(5*f);P=N>>>13,N&=8191,N+=B*(5*d)+T*(5*h)+U*(5*u)+_*(5*l)+L*(5*c),P+=N>>>13,N&=8191;let H=P+A*c+S*a+$*s+I*(5*g)+O*(5*p);P=H>>>13,H&=8191,H+=B*(5*f)+T*(5*d)+U*(5*h)+_*(5*u)+L*(5*l),P+=H>>>13,H&=8191;let C=P+A*l+S*c+$*a+I*s+O*(5*g);P=C>>>13,C&=8191,C+=B*(5*p)+T*(5*f)+U*(5*d)+_*(5*h)+L*(5*u),P+=C>>>13,C&=8191;let j=P+A*u+S*l+$*c+I*a+O*s;P=j>>>13,j&=8191,j+=B*(5*g)+T*(5*p)+U*(5*f)+_*(5*d)+L*(5*h),P+=j>>>13,j&=8191;let q=P+A*h+S*u+$*l+I*c+O*a;P=q>>>13,q&=8191,q+=B*s+T*(5*g)+U*(5*p)+_*(5*f)+L*(5*d),P+=q>>>13,q&=8191;let M=P+A*d+S*h+$*u+I*l+O*c;P=M>>>13,M&=8191,M+=B*a+T*s+U*(5*g)+_*(5*p)+L*(5*f),P+=M>>>13,M&=8191;let z=P+A*f+S*d+$*h+I*u+O*l;P=z>>>13,z&=8191,z+=B*c+T*a+U*s+_*(5*g)+L*(5*p),P+=z>>>13,z&=8191;let K=P+A*p+S*f+$*d+I*h+O*u;P=K>>>13,K&=8191,K+=B*l+T*c+U*a+_*s+L*(5*g),P+=K>>>13,K&=8191;let W=P+A*g+S*p+$*f+I*d+O*h;P=W>>>13,W&=8191,W+=B*u+T*l+U*c+_*a+L*s,P+=W>>>13,W&=8191,P=(P<<2)+P|0,P=P+R|0,R=8191&P,P>>>=13,N+=P,o[0]=R,o[1]=N,o[2]=H,o[3]=C,o[4]=j,o[5]=q,o[6]=M,o[7]=z,o[8]=K,o[9]=W}finalize(){const{h:t,pad:e}=this,n=new Uint16Array(10);let r=t[1]>>>13;t[1]&=8191;for(let e=2;e<10;e++)t[e]+=r,r=t[e]>>>13,t[e]&=8191;t[0]+=5*r,r=t[0]>>>13,t[0]&=8191,t[1]+=r,r=t[1]>>>13,t[1]&=8191,t[2]+=r,n[0]=t[0]+5,r=n[0]>>>13,n[0]&=8191;for(let e=1;e<10;e++)n[e]=t[e]+r,r=n[e]>>>13,n[e]&=8191;n[9]-=8192;let o=(1^r)-1;for(let t=0;t<10;t++)n[t]&=o;o=~o;for(let e=0;e<10;e++)t[e]=t[e]&o|n[e];t[0]=65535&(t[0]|t[1]<<13),t[1]=65535&(t[1]>>>3|t[2]<<10),t[2]=65535&(t[2]>>>6|t[3]<<7),t[3]=65535&(t[3]>>>9|t[4]<<4),t[4]=65535&(t[4]>>>12|t[5]<<1|t[6]<<14),t[5]=65535&(t[6]>>>2|t[7]<<11),t[6]=65535&(t[7]>>>5|t[8]<<8),t[7]=65535&(t[8]>>>8|t[9]<<5);let i=t[0]+e[0];t[0]=65535&i;for(let n=1;n<8;n++)i=(t[n]+e[n]|0)+(i>>>16)|0,t[n]=65535&i}update(t){zn(this);const{buffer:e,blockLen:n}=this,r=(t=Fn(t)).length;for(let o=0;o>>0,t[o++]=n[e]>>>8;return t}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}}!function(t){const e=(e,n)=>t(n).update(Fn(e)).digest(),n=t(new Uint8Array(32));e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e)}((t=>new Zr(t)));const Jr=Dn("expand 16-byte k"),Yr=Dn("expand 32-byte k"),Gr=Wn(Jr),Qr=Wn(Yr);function Xr(t,e){return t<>>32-e}function to(t){return t.byteOffset%4==0}const eo=2**32-1,no=new Uint32Array;const ro=function(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=function(t,e){if(null==e||"object"!=typeof e)throw new Error("options must be defined");return Object.assign(t,e)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if("function"!=typeof t)throw new Error("core must be a function");return Cn(o),Cn(s),jn(i),jn(n),(e,a,c,l,u=0)=>{Mn(e),Mn(a),Mn(c);const h=c.length;if(l||(l=new Uint8Array(h)),Mn(l),Cn(u),u<0||u>=eo)throw new Error("arx: counter overflow");if(l.length=eo)throw new Error("arx: counter overflow");const g=Math.min(64,c-p);if(h&&64===g){const t=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let e,n=0;n<16;n++)e=t+n,f[e]=d[e]^u[n];p+=64}else{for(let t,e=0;e0;)d.pop().fill(0);return l}}((function(t,e,n,r,o,i=20){let s=t[0],a=t[1],c=t[2],l=t[3],u=e[0],h=e[1],d=e[2],f=e[3],p=e[4],g=e[5],w=e[6],b=e[7],y=o,m=n[0],v=n[1],x=n[2],E=s,k=a,A=c,S=l,$=u,I=h,O=d,B=f,T=p,U=g,_=w,L=b,P=y,R=m,N=v,H=x;for(let t=0;tr?t.create().update(n).digest():n);for(let t=0;tnew oo(t,e).update(n).digest();io.create=(t,e)=>new oo(t,e);const so=new Uint8Array([0]),ao=new Uint8Array;var co=Symbol("verified");function lo(t){if(!(t=>t instanceof Object)(t)||"number"!=typeof t.kind||"string"!=typeof t.content||"number"!=typeof t.created_at||"string"!=typeof t.pubkey||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);void 0===n&&(n=ao);const i=new Uint8Array(o*t.outputLen),s=io.create(t,e),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let e=0;e65535)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}(n);return pt(r,e,new Uint8Array(ko(n)-n))}function So(t,e,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=pt(n,e);return io(fn,t,r)}function $o(t,e,n=function(t=32){if(it&&"function"==typeof it.getRandomValues)return it.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=Eo(e,n),s=Ao(t),a=ro(r,o,s),c=So(i,a,n);return Lr.encode(pt(new Uint8Array([2]),n,a,c))}function Io(t,e){const{nonce:n,ciphertext:r,mac:o}=function(t){if("string"!=typeof t)throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if("#"===t[0])throw new Error("unknown encryption version");let n;try{n=Lr.decode(t)}catch(t){throw new Error("invalid base64: "+t.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(2!==o)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(t),{chacha_key:i,chacha_nonce:s,hmac_key:a}=Eo(e,n);if(!function(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r65535||n.length!==e||t.length!==2+ko(e))throw new Error("invalid padding");return uo.decode(n)}(ro(i,s,r))}var Oo=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/;try{fetch}catch{}function Bo(t,e){if(t.ids&&-1===t.ids.indexOf(e.id)||t.kinds&&-1===t.kinds.indexOf(e.kind)||t.authors&&-1===t.authors.indexOf(e.pubkey))return!1;for(let n in t)if("#"===n[0]){let r=t[`#${n.slice(1)}`];if(r&&!e.tags.find((([t,e])=>t===n.slice(1)&&-1!==r.indexOf(e))))return!1}return!(t.since&&e.created_att.until)}async function To(){return new Promise((t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()}))}var Uo,_o=t=>(t[co]=!0,!0),Lo=class{constructor(t,e){v(this,"url"),v(this,"_connected",!1),v(this,"onclose",null),v(this,"onnotice",(t=>console.debug(`NOTICE from ${this.url}: ${t}`))),v(this,"_onauth",null),v(this,"baseEoseTimeout",4400),v(this,"connectionTimeout",4400),v(this,"publishTimeout",4400),v(this,"openSubs",new Map),v(this,"connectionTimeoutHandle"),v(this,"connectionPromise"),v(this,"openCountRequests",new Map),v(this,"openEventPublishes",new Map),v(this,"ws"),v(this,"incomingMessageQueue",new go),v(this,"queueRunning",!1),v(this,"challenge"),v(this,"serial",0),v(this,"verifyEvent"),v(this,"_WebSocket"),this.url=fo(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket}static async connect(t,e){const n=new Lo(t,e);return await n.connect(),n}closeAllSubscriptions(t){for(let[e,n]of this.openSubs)n.close(t);this.openSubs.clear();for(let[e,n]of this.openEventPublishes)n.reject(new Error(t));this.openEventPublishes.clear();for(let[e,n]of this.openCountRequests)n.reject(new Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise||(this.challenge=void 0,this.connectionPromise=new Promise(((t,e)=>{this.connectionTimeoutHandle=setTimeout((()=>{var t;e("connection timed out"),this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection timed out")}),this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(t){return void e(t)}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=t=>{var n;e(t.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,null==(n=this.onclose)||n.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var t;this._connected&&(this._connected=!1,this.connectionPromise=void 0,null==(t=this.onclose)||t.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}))),this.connectionPromise}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await To();this.queueRunning=!1}handleNext(){var t,e,n;const r=this.incomingMessageQueue.dequeue();if(!r)return!1;const o=function(t){let e=t.slice(0,22).indexOf('"EVENT"');if(-1===e)return null;let n=t.slice(e+7+1).indexOf('"');if(-1===n)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return t.slice(r+1,i)}(r);if(o){const n=this.openSubs.get(o);if(!n)return;const i=function(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,o=t.slice(r).indexOf('"')+r+1;return t.slice(o,o+64)}(r,"id"),s=null==(t=n.alreadyHaveEvent)?void 0:t.call(n,i);if(null==(e=n.receivedEvent)||e.call(n,this,i),s)return}try{let t=JSON.parse(r);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return void(this.verifyEvent(n)&&function(t,e){for(let n=0;n{var e;null==(e=this.ws)||e.send(t)}))}async auth(t){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const e=await t(function(t,e){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}(this.url,this.challenge)),n=new Promise(((t,n)=>{const r=setTimeout((()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("auth timed out")),this.openEventPublishes.delete(e.id))}),this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:r})}));return this.send('["AUTH",'+JSON.stringify(e)+"]"),n}async publish(t){const e=new Promise(((e,n)=>{const r=setTimeout((()=>{const e=this.openEventPublishes.get(t.id);e&&(e.reject(new Error("publish timed out")),this.openEventPublishes.delete(t.id))}),this.publishTimeout);this.openEventPublishes.set(t.id,{resolve:e,reject:n,timeout:r})}));return this.send('["EVENT",'+JSON.stringify(t)+"]"),e}async count(t,e){this.serial++;const n=(null==e?void 0:e.id)||"count:"+this.serial,r=new Promise(((t,e)=>{this.openCountRequests.set(n,{resolve:t,reject:e})}));return this.send('["COUNT","'+n+'",'+JSON.stringify(t).substring(1)),r}subscribe(t,e){const n=this.prepareSubscription(t,e);return n.fire(),n}prepareSubscription(t,e){this.serial++;const n=e.id||(e.label?e.label+":":"sub:")+this.serial,r=new Po(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,null==(t=this.ws)||t.close()}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},Po=class{constructor(t,e,n,r){v(this,"relay"),v(this,"id"),v(this,"closed",!1),v(this,"eosed",!1),v(this,"filters"),v(this,"alreadyHaveEvent"),v(this,"receivedEvent"),v(this,"onevent"),v(this,"oneose"),v(this,"onclose"),v(this,"eoseTimeout"),v(this,"eoseTimeoutHandle"),this.relay=t,this.filters=n,this.id=e,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||t.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(t=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,t)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var t;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,null==(t=this.oneose)||t.call(this))}close(t="closed by caller"){var e;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),null==(e=this.onclose)||e.call(this,t)}},Ro=class{constructor(t){v(this,"relays",new Map),v(this,"seenOn",new Map),v(this,"trackRelays",!1),v(this,"verifyEvent"),v(this,"trustedRelayURLs",new Set),v(this,"_WebSocket"),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation}async ensureRelay(t,e){t=fo(t);let n=this.relays.get(t);return n||(n=new Lo(t,{verifyEvent:this.trustedRelayURLs.has(t)?_o:this.verifyEvent,websocketImplementation:this._WebSocket}),null!=e&&e.connectionTimeout&&(n.connectionTimeout=e.connectionTimeout),this.relays.set(t,n)),await n.connect(),n}close(t){t.map(fo).forEach((t=>{var e;null==(e=this.relays.get(t))||e.close()}))}subscribeMany(t,e,n){return this.subscribeManyMap(Object.fromEntries(t.map((t=>[t,e]))),n)}subscribeManyMap(t,e){this.trackRelays&&(e.receivedEvent=(t,e)=>{let n=this.seenOn.get(e);n||(n=new Set,this.seenOn.set(e,n)),n.add(t)});const n=new Set,r=[],o=Object.keys(t).length,i=[];let s=t=>{var n;i[t]||(i[t]=!0,i.filter((t=>t)).length===o&&(null==(n=e.oneose)||n.call(e),s=()=>{}))};const a=[];let c=(t,n)=>{var r;a[t]||(s(t),a[t]=n,a.filter((t=>t)).length===o&&(null==(r=e.onclose)||r.call(e,a),c=()=>{}))};const l=t=>{var r;if(null!=(r=e.alreadyHaveEvent)&&r.call(e,t))return!0;const o=n.has(t);return n.add(t),o},u=Promise.all(Object.entries(t).map((async(t,n,o)=>{if(o.indexOf(t)!==n)return void c(n,"duplicate url");let i,[a,u]=t;a=fo(a);try{i=await this.ensureRelay(a,{connectionTimeout:e.maxWait?Math.max(.8*e.maxWait,e.maxWait-1e3):void 0})}catch(t){return void c(n,(null==t?void 0:t.message)||String(t))}let h=i.subscribe(u,{...e,oneose:()=>s(n),onclose:t=>c(n,t),alreadyHaveEvent:l,eoseTimeout:e.maxWait});r.push(h)})));return{async close(){await u,r.forEach((t=>{t.close()}))}}}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close()}});return r}async querySync(t,e,n){return new Promise((async r=>{const o=[];this.subscribeManyEose(t,[e],{...n,onevent(t){o.push(t)},onclose(t){r(o)}})}))}async get(t,e,n){e.limit=1;const r=await this.querySync(t,e,n);return r.sort(((t,e)=>e.created_at-t.created_at)),r[0]||null}publish(t,e){return t.map(fo).map((async(t,n,r)=>{if(r.indexOf(t)!==n)return Promise.reject("duplicate url");let o=await this.ensureRelay(t);return o.publish(e).then((t=>{if(this.trackRelays){let t=this.seenOn.get(e.id);t||(t=new Set,this.seenOn.set(e.id,t)),t.add(o)}return t}))}))}listConnectionStatus(){const t=new Map;return this.relays.forEach(((e,n)=>t.set(n,e.connected))),t}destroy(){this.relays.forEach((t=>t.close())),this.relays=new Map}};try{Uo=WebSocket}catch{}var No,Ho=class extends Ro{constructor(){super({verifyEvent:vo,websocketImplementation:Uo})}};try{No=fetch}catch{}var Co=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function jo(t){let e=t.match(Co);if(e)try{const t=e[1],n=new URLSearchParams(e[2]);return{pubkey:t,relays:n.getAll("relay"),secret:n.get("secret")}}catch{}return async function(t){const e=t.match(Oo);if(!e)return null;const[n,r="_",o]=e;try{const t=`https://${o}/.well-known/nostr.json?name=${r}`,e=await(await No(t,{redirect:"error"})).json();let n=e.names[r];return{pubkey:n,relays:e.nip46[n]||[],secret:null}}catch{return null}}(t)}var qo=class{constructor(t,e,n={}){if(v(this,"pool"),v(this,"subCloser"),v(this,"isOpen"),v(this,"serial"),v(this,"idPrefix"),v(this,"listeners"),v(this,"waitingForAuth"),v(this,"secretKey"),v(this,"conversationKey"),v(this,"bp"),v(this,"cachedPubKey"),0===e.relays.length)throw new Error("no relays are specified for this bunker");this.pool=n.pool||new Ho,this.secretKey=t,this.conversationKey=xo(t,e.pubkey),this.bp=e,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={};const r=this.listeners,o=this.waitingForAuth,i=this.conversationKey;this.subCloser=this.pool.subscribeMany(this.bp.relays,[{kinds:[24133],authors:[e.pubkey],"#p":[yo(this.secretKey)]}],{async onevent(s){let a;try{a=JSON.parse(Io(s.content,i))}catch{a=JSON.parse(await async function(t,e,n){const r=t instanceof Uint8Array?ht(t):t;let[o,i]=n.split("?iv="),s=function(t){return t.slice(1,33)}(qe.getSharedSecret(r,"02"+e)),a=Lr.decode(i),c=Lr.decode(o),l=yr(s,a).decrypt(c);return uo.decode(l)}(t,s.pubkey,s.content))}const{id:c,result:l,error:u}=a;if("auth_url"===l&&o[c])return delete o[c],void(n.onauth?n.onauth(u):console.warn(`nostr-tools/nip46: remote signer ${e.pubkey} tried to send an "auth_url"='${u}' but there was no onauth() callback configured.`));let h=r[c];h&&(u?h.reject(u):l&&h.resolve(l),delete r[c])}}),this.isOpen=!0}async close(){this.isOpen=!1,this.subCloser.close()}async sendRequest(t,e){return new Promise((async(n,r)=>{try{if(!this.isOpen)throw new Error("this signer is not open anymore, create a new one");this.serial++;const o=`${this.idPrefix}-${this.serial}`,i=$o(JSON.stringify({id:o,method:t,params:e}),this.conversationKey),s=mo({kind:24133,tags:[["p",this.bp.pubkey]],content:i,created_at:Math.floor(Date.now()/1e3)},this.secretKey);this.listeners[o]={resolve:n,reject:r},this.waitingForAuth[o]=!0,await Promise.any(this.pool.publish(this.bp.relays,s))}catch(t){r(t)}}))}async ping(){let t=await this.sendRequest("ping",[]);if("pong"!==t)throw new Error(`result is not pong: ${t}`)}async connect(){await this.sendRequest("connect",[this.bp.pubkey,this.bp.secret||""])}async getPublicKey(){return this.cachedPubKey||(this.cachedPubKey=await this.sendRequest("get_public_key",[])),this.cachedPubKey}async getRelays(){return JSON.parse(await this.sendRequest("get_relays",[]))}async signEvent(t){let e=await this.sendRequest("sign_event",[JSON.stringify(t)]),n=JSON.parse(e);if(vo(n))return n;throw new Error(`event returned from bunker is improperly signed: ${JSON.stringify(n)}`)}async nip04Encrypt(t,e){return await this.sendRequest("nip04_encrypt",[t,e])}async nip04Decrypt(t,e){return await this.sendRequest("nip04_decrypt",[t,e])}async nip44Encrypt(t,e){return await this.sendRequest("nip44_encrypt",[t,e])}async nip44Decrypt(t,e){return await this.sendRequest("nip44_decrypt",[t,e])}},Mo=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/;try{fetch}catch{}new TextDecoder("utf-8"),new TextEncoder;function zo(t){return function(t,e){return function(t,e){let n=Wr.toWords(e);return Wr.encode(t,n,5e3)}(t,e)}("npub",dt(t))}const Ko=[];const Wo=t=>{const{subscribe:e,set:n}=function(t,e=i){let n;const r=new Set;function o(e){if(u(t,e)&&(t=e,n)){const e=!Ko.length;for(const e of r)e[1](),Ko.push(e,t);if(e){for(let t=0;t{r.delete(l),0===r.size&&n&&(n(),n=null)}}}}(void 0,(()=>{const e=window.matchMedia(t);n(e.matches);const r=()=>n(e.matches);return e.addEventListener("change",r),()=>{e.removeEventListener("change",r)}}));return{subscribe:e}};function Do(t){let e,n,r;return{c(){e=m("svg"),n=m("circle"),r=m("path"),S(n,"class","opacity-25"),S(n,"cx","12"),S(n,"cy","12"),S(n,"r","10"),S(n,"stroke","currentColor"),S(n,"stroke-width","4"),S(r,"class","opacity-75"),S(r,"fill","currentColor"),S(r,"d","M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"),S(e,"class","ml-2 h-5 w-5 animate-spin text-white"),S(e,"xmlns","http://www.w3.org/2000/svg"),S(e,"fill","none"),S(e,"viewBox","0 0 24 24")},m(t,o){w(t,e,o),g(e,n),g(e,r)},p:i,i:i,o:i,d(t){t&&b(e)}}}class Fo extends tt{constructor(t){super(),X(this,t,null,Do,u,{})}}const{window:Vo}=p;function Zo(t){let e,n,r,o,i,s,a,c,u,h,d,f,p=!t[17]&&!t[10]&&!t[11]&&!t[12]&&Go(t);const m=[oi,ri,ni,ei,ti,Xo,Qo],v=[];function k(t,e){return t[10]?0:t[11]?1:t[12]?2:t[17]?3:t[15]?4:t[18]?6:5}return a=k(t),c=v[a]=m[a](t),{c(){e=y("div"),n=y("button"),r=x("⤫"),i=E(),p&&p.c(),s=E(),c.c(),S(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"),S(e,"class",u="animate-show rounded-md bg-gradient-to-b px-8 py-8 shadow-[0_0px_30px_0px_rgba(0,0,0,0.6)] transition-all sm:w-96 bg-"+t[0]+"-800 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[23])},m(o,c){w(o,e,c),g(e,n),g(n,r),g(e,i),p&&p.m(e,null),g(e,s),v[a].m(e,null),h=!0,d||(f=A(n,"click",(function(){l(t[17]?t[28]:t[26])&&(t[17]?t[28]:t[26]).apply(this,arguments)})),d=!0)},p(r,i){t=r,(!h||1&i[0]&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"))&&S(n,"class",o),t[17]||t[10]||t[11]||t[12]?p&&(p.d(1),p=null):p?p.p(t,i):(p=Go(t),p.c(),p.m(e,s));let l=a;a=k(t),a===l?v[a].p(t,i):(D(),Z(v[l],1,1,(()=>{v[l]=null})),F(),c=v[a],c?c.p(t,i):(c=v[a]=m[a](t),c.c()),V(c,1),c.m(e,null)),(!h||8388609&i[0]&&u!==(u="animate-show rounded-md bg-gradient-to-b px-8 py-8 shadow-[0_0px_30px_0px_rgba(0,0,0,0.6)] transition-all sm:w-96 bg-"+t[0]+"-800 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[23]))&&S(e,"class",u)},i(t){h||(V(c),h=!0)},o(t){Z(c),h=!1},d(t){t&&b(e),p&&p.d(),v[a].d(),d=!1,f()}}}function Jo(t){let e,n,r,o,i;const s=[yi,bi,wi,gi],a=[];function c(t,e){return t[9]?0:t[18]?t[2]?3:2:1}return n=c(t),r=a[n]=s[n](t),{c(){e=y("div"),r.c(),S(e,"class",o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+t[0]+"-700 hover:bg-"+t[0]+"-800 "+t[23])},m(t,r){w(t,e,r),a[n].m(e,null),i=!0},p(t,l){let u=n;n=c(t),n===u?a[n].p(t,l):(D(),Z(a[u],1,1,(()=>{a[u]=null})),F(),r=a[n],r?r.p(t,l):(r=a[n]=s[n](t),r.c()),V(r,1),r.m(e,null)),(!i||8388609&l[0]&&o!==(o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+t[0]+"-700 hover:bg-"+t[0]+"-800 "+t[23]))&&S(e,"class",o)},i(t){i||(V(r),i=!0)},o(t){Z(r),i=!1},d(t){t&&b(e),a[n].d()}}}function Yo(t){return{c:i,m:i,p:i,i:i,o:i,d:i}}function Go(t){let e,n,r,o,i;return{c(){e=y("button"),n=x("?"),S(e,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")},m(r,s){w(r,e,s),g(e,n),o||(i=A(e,"click",t[27]),o=!0)},p(t,n){1&n[0]&&r!==(r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")&&S(e,"class",r)},d(t){t&&b(e),o=!1,i()}}}function Qo(t){let e,n,r,o,s,a,c,l,u,h,d,f,p,m,v,k,I,O,B,T,U=t[18].npub+"",_=vn(t[8])+"",L=(t[18].picture||t[18].name)&&ii(t);return{c(){e=y("div"),n=y("div"),n.textContent="You are connected to Nostr as",r=E(),o=y("a"),L&&L.c(),s=E(),a=y("div"),c=x(U),u=E(),h=y("button"),d=x("Disconnect"),p=E(),m=y("div"),v=x("This webpage is using the public key:"),k=y("br"),I=E(),O=x(_),S(n,"class","mb-4 text-sm"),S(a,"class","block break-all"),S(o,"target","_blank"),S(o,"href",l="https://nosta.me/"+t[18].npub),S(o,"class","group text-white no-underline"),S(e,"class","text-center"),S(h,"class",f="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),S(m,"class","mt-6 block break-all text-center text-sm")},m(i,l){w(i,e,l),g(e,n),g(e,r),g(e,o),L&&L.m(o,null),g(o,s),g(o,a),g(a,c),w(i,u,l),w(i,h,l),g(h,d),w(i,p,l),w(i,m,l),g(m,v),g(m,k),g(m,I),g(m,O),B||(T=A(h,"click",t[30]),B=!0)},p(t,e){t[18].picture||t[18].name?L?L.p(t,e):(L=ii(t),L.c(),L.m(o,s)):L&&(L.d(1),L=null),262144&e[0]&&U!==(U=t[18].npub+"")&&$(c,U),262144&e[0]&&l!==(l="https://nosta.me/"+t[18].npub)&&S(o,"href",l),1&e[0]&&f!==(f="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&S(h,"class",f),256&e[0]&&_!==(_=vn(t[8])+"")&&$(O,_)},i:i,o:i,d(t){t&&(b(e),b(u),b(h),b(p),b(m)),L&&L.d(),B=!1,T()}}}function Xo(t){let e,n,r,o,i,s,a,l,u,h,d,f,p,m,v,x,$,O=t[16]&&ci(t);const B=[ui,li],T=[];function U(t,e){return t[9]?0:1}l=U(t),u=T[l]=B[l](t);let _=t[9]&&t[13]&&hi(t),L=!t[9]&&di(t);return{c(){e=y("div"),e.textContent="How do you want to connect to Nostr?",n=E(),r=y("form"),o=y("input"),i=E(),O&&O.c(),s=E(),a=y("button"),u.c(),f=E(),_&&_.c(),p=E(),L&&L.c(),m=k(),S(e,"class","text-center text-lg"),S(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 dark:text-gray-100 outline-none"),S(o,"placeholder","user@provider or bunker://..."),o.autofocus=!0,o.disabled=t[9],S(o,"autocapitalize","none"),S(a,"class",h="mt-4 flex w-full cursor-pointer items-center justify-center rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),a.disabled=d=!t[22]||t[9],S(r,"class","mb-1 mt-4 flex flex-col")},m(c,u){w(c,e,u),w(c,n,u),w(c,r,u),g(r,o),t[44](o),I(o,t[4]),g(r,i),O&&O.m(r,null),g(r,s),g(r,a),T[l].m(a,null),g(r,f),_&&_.m(r,null),w(c,p,u),L&&L.m(c,u),w(c,m,u),v=!0,o.focus(),x||($=[A(o,"input",t[45]),A(r,"submit",t[29])],x=!0)},p(t,e){(!v||512&e[0])&&(o.disabled=t[9]),16&e[0]&&o.value!==t[4]&&I(o,t[4]),t[16]?O?O.p(t,e):(O=ci(t),O.c(),O.m(r,s)):O&&(O.d(1),O=null);let n=l;l=U(t),l!==n&&(D(),Z(T[n],1,1,(()=>{T[n]=null})),F(),u=T[l],u||(u=T[l]=B[l](t),u.c()),V(u,1),u.m(a,null)),(!v||1&e[0]&&h!==(h="mt-4 flex w-full cursor-pointer items-center justify-center rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"))&&S(a,"class",h),(!v||4194816&e[0]&&d!==(d=!t[22]||t[9]))&&(a.disabled=d),t[9]&&t[13]?_?_.p(t,e):(_=hi(t),_.c(),_.m(r,null)):_&&(_.d(1),_=null),t[9]?L&&(L.d(1),L=null):L?L.p(t,e):(L=di(t),L.c(),L.m(m.parentNode,m))},i(t){v||(V(u),v=!0)},o(t){Z(u),v=!1},d(o){o&&(b(e),b(n),b(r),b(p),b(m)),t[44](null),O&&O.d(),T[l].d(),_&&_.d(),L&&L.d(o),x=!1,c($)}}}function ti(t){let e,n,r,o,s,a,l,u,h,d,f,p,m,v,k;return{c(){e=y("div"),e.textContent="Create a Nostr account",n=E(),r=y("div"),r.textContent="To use this Nostr app you need a profile. The following button opens a\n wizard that help you to create your keypair and safely manage it in a\n few steps. Are you ready?",o=E(),s=y("button"),a=x("Create an account »"),u=E(),h=y("div"),d=x("Do you already have a Nostr address?"),f=y("br"),p=E(),m=y("button"),m.textContent="Login now",S(e,"class","text-center text-lg"),S(r,"class","mt-4 text-base leading-5"),S(s,"class",l="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),s.disabled=Ai,S(m,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),S(h,"class","mt-6 text-center text-sm leading-3")},m(i,c){w(i,e,c),w(i,n,c),w(i,r,c),w(i,o,c),w(i,s,c),g(s,a),w(i,u,c),w(i,h,c),g(h,d),g(h,f),g(h,p),g(h,m),v||(k=[A(s,"click",t[37]),A(m,"click",t[32])],v=!0)},p(t,e){1&e[0]&&l!==(l="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&S(s,"class",l)},i:i,o:i,d(t){t&&(b(e),b(n),b(r),b(o),b(s),b(u),b(h)),v=!1,c(k)}}}function ei(t){let e,n,r;return{c(){e=y("div"),e.textContent="What is that?",n=E(),r=y("div"),r.innerHTML='This widget is created with window.nostr.js, a small script\n you can drop in any page that already uses NIP-07 and make it also\n work with NIP-46 automatically when the user doesn't have an\n extension installed.\n
\n It adds a small floating button on the side of the window that users\n can use to create Nostr accuonts or connect to their NIP-46 bunkers.
This tool is opensource, get the code from the project's page.
You don't know what Nostr is?\n Learn more.
',S(e,"class","text-center text-lg"),S(r,"class","text-base leading-5")},m(t,o){w(t,e,o),w(t,n,o),w(t,r,o)},p:i,i:i,o:i,d(t){t&&(b(e),b(n),b(r))}}}function ni(t){let e,n,r,o,s,a,c,l,u,h,d,f,p,m,v,k,I=new URL(t[12]).host+"";return{c(){e=y("div"),n=y("div"),n.textContent="An action requires your confirmation",r=E(),o=y("div"),s=x("A new window will now open, taking you to "),a=y("strong"),c=x(I),l=x("\n where you can approve the current action. If nothing happens, ensure\n your browser is not blocking popups."),u=y("br"),h=x("\n Afterward, you'll be redirected back to this page."),d=E(),f=y("button"),p=x("Confirm action »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(f,"class",m="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),S(e,"class","m-auto w-full")},m(i,b){w(i,e,b),g(e,n),g(e,r),g(e,o),g(o,s),g(o,a),g(a,c),g(o,l),g(o,u),g(o,h),g(e,d),g(e,f),g(f,p),v||(k=A(f,"click",t[43]),v=!0)},p(t,e){4096&e[0]&&I!==(I=new URL(t[12]).host+"")&&$(c,I),1&e[0]&&m!==(m="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&S(f,"class",m)},i:i,o:i,d(t){t&&b(e),v=!1,k()}}}function ri(t){let e,n,r,o,s,a,c,l,u,h,d,f,p,m,v,k,I=new URL(t[11]).host+"";return{c(){e=y("div"),n=y("div"),n.textContent="Login into a Nostr account",r=E(),o=y("div"),s=x("A new window will now open, taking you to "),a=y("strong"),c=x(I),l=x("\n where you can login and approve the permissions. If nothing happens,\n ensure your browser is not blocking popups. "),u=y("br"),h=x("\n Afterward, you'll be redirected back to this page."),d=E(),f=y("button"),p=x("Login now »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(f,"class",m="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),S(e,"class","m-auto w-full")},m(i,b){w(i,e,b),g(e,n),g(e,r),g(e,o),g(o,s),g(o,a),g(a,c),g(o,l),g(o,u),g(o,h),g(e,d),g(e,f),g(f,p),v||(k=A(f,"click",t[42]),v=!0)},p(t,e){2048&e[0]&&I!==(I=new URL(t[11]).host+"")&&$(c,I),1&e[0]&&m!==(m="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&S(f,"class",m)},i:i,o:i,d(t){t&&b(e),v=!1,k()}}}function oi(t){let e,n,r,o,s,a,c,l,u,h,d,f,p,m,v,k,I=new URL(t[10]).host+"";return{c(){e=y("div"),n=y("div"),n.textContent="Create a Nostr account",r=E(),o=y("div"),s=x("A new window will now open, taking you to\n "),a=y("strong"),c=x(I),l=x("\n where the account creation will occur. If nothing happens, ensure your\n browser is not blocking popups.\n "),u=y("br"),h=x(" Afterward, you'll be redirected back to this page."),d=E(),f=y("button"),p=x("Start account creation »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(f,"class",m="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950"),S(e,"class","m-auto w-full")},m(i,b){w(i,e,b),g(e,n),g(e,r),g(e,o),g(o,s),g(o,a),g(a,c),g(o,l),g(o,u),g(o,h),g(e,d),g(e,f),g(f,p),v||(k=A(f,"click",t[41]),v=!0)},p(t,e){1024&e[0]&&I!==(I=new URL(t[10]).host+"")&&$(c,I),1&e[0]&&m!==(m="mt-4 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white disabled:cursor-default disabled:bg-neutral-400 disabled:text-neutral-200 bg-"+t[0]+"-900 hover:bg-"+t[0]+"-950")&&S(f,"class",m)},i:i,o:i,d(t){t&&b(e),v=!1,k()}}}function ii(t){let e,n,r=t[18].picture&&si(t),o=t[18].name&&ai(t);return{c(){e=y("div"),r&&r.c(),n=E(),o&&o.c(),S(e,"class","mb-2 flex items-center justify-center gap-2")},m(t,i){w(t,e,i),r&&r.m(e,null),g(e,n),o&&o.m(e,null)},p(t,i){t[18].picture?r?r.p(t,i):(r=si(t),r.c(),r.m(e,n)):r&&(r.d(1),r=null),t[18].name?o?o.p(t,i):(o=ai(t),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(t){t&&b(e),r&&r.d(),o&&o.d()}}}function si(t){let e,n,r;return{c(){e=y("img"),d(e.src,n=t[18].picture)||S(e,"src",n),S(e,"alt",""),S(e,"class",r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+t[0]+"-100")},m(t,n){w(t,e,n)},p(t,o){262144&o[0]&&!d(e.src,n=t[18].picture)&&S(e,"src",n),1&o[0]&&r!==(r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+t[0]+"-100")&&S(e,"class",r)},d(t){t&&b(e)}}}function ai(t){let e,n,r=t[18].name+"";return{c(){e=y("div"),n=x(r),S(e,"class","text-3xl decoration-2 underline-offset-4 group-hover:underline")},m(t,r){w(t,e,r),g(e,n)},p(t,e){262144&e[0]&&r!==(r=t[18].name+"")&&$(n,r)},d(t){t&&b(e)}}}function ci(t){let e,n;return{c(){e=y("div"),n=x(t[16]),S(e,"class","my-2 rounded bg-yellow-100 p-2 text-center text-sm leading-4 text-red-400")},m(t,r){w(t,e,r),g(e,n)},p(t,e){65536&e[0]&&$(n,t[16])},d(t){t&&b(e)}}}function li(t){let e;return{c(){e=x("Connect »")},m(t,n){w(t,e,n)},i:i,o:i,d(t){t&&b(e)}}}function ui(t){let e,n,r;return n=new Fo({}),{c(){e=x("Connecting to bunker\n "),J(n.$$.fragment)},m(t,o){w(t,e,o),Y(n,t,o),r=!0},i(t){r||(V(n.$$.fragment,t),r=!0)},o(t){Z(n.$$.fragment,t),r=!1},d(t){t&&b(e),G(n,t)}}}function hi(t){let e,n,r,o,s;return{c(){e=y("div"),n=x("Waiting too much?\n "),r=y("button"),r.textContent="Cancel the connection",S(r,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),S(e,"class","mt-6 text-center text-sm leading-3")},m(i,a){w(i,e,a),g(e,n),g(e,r),o||(s=A(r,"click",t[33]),o=!0)},p:i,d(t){t&&b(e),o=!1,s()}}}function di(t){let e;function n(t,e){return t[14]?pi:fi}let r=n(t),o=r(t);return{c(){e=y("div"),o.c(),S(e,"class","mt-6 text-center text-sm leading-3")},m(t,n){w(t,e,n),o.m(e,null)},p(t,i){r===(r=n(t))&&o?o.p(t,i):(o.d(1),o=r(t),o&&(o.c(),o.m(e,null)))},d(t){t&&b(e),o.d()}}}function fi(t){let e,n,r,o,s,a;return{c(){e=x("Do you need a Nostr account?"),n=y("br"),r=E(),o=y("button"),o.textContent="Sign up now",S(o,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline")},m(i,c){w(i,e,c),w(i,n,c),w(i,r,c),w(i,o,c),s||(a=A(o,"click",t[37]),s=!0)},p:i,d(t){t&&(b(e),b(n),b(r),b(o)),s=!1,a()}}}function pi(t){let e,n,r,o,s,a;return{c(){e=x("Is this bunker provider broken?"),n=y("br"),r=E(),o=y("button"),o.textContent="Clear it",S(o,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline")},m(i,c){w(i,e,c),w(i,n,c),w(i,r,c),w(i,o,c),s||(a=A(o,"click",t[31]),s=!0)},p:i,d(t){t&&(b(e),b(n),b(r),b(o)),s=!1,a()}}}function gi(t){let e,n;return{c(){e=y("img"),d(e.src,n=t[18].picture)||S(e,"src",n),S(e,"alt",""),S(e,"class","h-6 w-6 rounded-full")},m(t,n){w(t,e,n)},p(t,r){262144&r[0]&&!d(e.src,n=t[18].picture)&&S(e,"src",n)},i:i,o:i,d(t){t&&b(e)}}}function wi(t){let e,n,r,o,s=(t[18].name||t[18].npub.slice(0,7)+"…"+t[18].npub.slice(-4))+"";function a(t,e){return t[18].picture?vi:mi}let c=a(t),l=c(t);return{c(){e=y("div"),l.c(),n=E(),r=y("div"),o=x(s),S(r,"class","inline-block max-w-56 overflow-hidden overflow-ellipsis whitespace-nowrap"),S(e,"class","flex items-center px-2")},m(t,i){w(t,e,i),l.m(e,null),g(e,n),g(e,r),g(r,o)},p(t,r){c===(c=a(t))&&l?l.p(t,r):(l.d(1),l=c(t),l&&(l.c(),l.m(e,n))),262144&r[0]&&s!==(s=(t[18].name||t[18].npub.slice(0,7)+"…"+t[18].npub.slice(-4))+"")&&$(o,s)},i:i,o:i,d(t){t&&b(e),l.d()}}}function bi(t){let e;function n(t,e){return t[2]?Ei:xi}let r=n(t),o=r(t);return{c(){o.c(),e=k()},m(t,n){o.m(t,n),w(t,e,n)},p(t,i){r!==(r=n(t))&&(o.d(1),o=r(t),o&&(o.c(),o.m(e.parentNode,e)))},i:i,o:i,d(t){t&&b(e),o.d(t)}}}function yi(t){let e,n,r,o;return r=new Fo({}),{c(){e=y("div"),n=x("Connecting to bunker\n "),J(r.$$.fragment),S(e,"class","flex items-center px-2")},m(t,i){w(t,e,i),g(e,n),Y(r,e,null),o=!0},p:i,i(t){o||(V(r.$$.fragment,t),o=!0)},o(t){Z(r.$$.fragment,t),o=!1},d(t){t&&b(e),G(r)}}}function mi(t){let e;return{c(){e=y("span"),e.textContent="☉",S(e,"class","mr-2")},m(t,n){w(t,e,n)},p:i,d(t){t&&b(e)}}}function vi(t){let e,n;return{c(){e=y("img"),d(e.src,n=t[18].picture)||S(e,"src",n),S(e,"alt",""),S(e,"class","mr-2 h-5 w-5 rounded-full")},m(t,n){w(t,e,n)},p(t,r){262144&r[0]&&!d(e.src,n=t[18].picture)&&S(e,"src",n)},d(t){t&&b(e)}}}function xi(t){let e;return{c(){e=y("div"),e.textContent="Connect with Nostr",S(e,"class","flex items-center px-2")},m(t,n){w(t,e,n)},d(t){t&&b(e)}}}function Ei(t){let e;return{c(){e=y("div"),e.textContent="N",S(e,"class","w-6 text-center")},m(t,n){w(t,e,n)},d(t){t&&b(e)}}}function ki(t){let e,n,r,o,i,s,a;const l=[Yo,Jo,Zo],u=[];function h(t,e){return t[21]||t[18]||!t[1]?t[21]?2:1:0}return n=h(t),r=u[n]=l[n](t),{c(){e=y("div"),r.c(),S(e,"class","draggable z-[9000] animate-fadein font-sans text-white"),S(e,"style",o="position: fixed; "+(t[21]&&t[5]?"width: 100vw;":"")+"; right: "+(t[21]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[21]&&t[5]?"bottom: 0px":t[20]+":"+t[19]+"px")),O(e,"cursor-pointer",!t[18]&&!t[21])},m(r,o){w(r,e,o),u[n].m(e,null),t[46](e),i=!0,s||(a=[A(Vo,"click",t[25]),A(Vo,"mouseup",t[36]),A(Vo,"mousemove",t[35]),A(e,"mousedown",t[34])],s=!0)},p(t,s){let a=n;n=h(t),n===a?u[n].p(t,s):(D(),Z(u[a],1,1,(()=>{u[a]=null})),F(),r=u[n],r?r.p(t,s):(r=u[n]=l[n](t),r.c()),V(r,1),r.m(e,null)),(!i||3670056&s[0]&&o!==(o="position: fixed; "+(t[21]&&t[5]?"width: 100vw;":"")+"; right: "+(t[21]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[21]&&t[5]?"bottom: 0px":t[20]+":"+t[19]+"px")))&&S(e,"style",o),(!i||2359296&s[0])&&O(e,"cursor-pointer",!t[18]&&!t[21])},i(t){i||(V(r),i=!0)},o(t){Z(r),i=!1},d(r){r&&b(e),u[n].d(),t[46](null),s=!1,c(a)}}}let Ai=!1;const Si="We could not connect to a NIP-46 bunker with that url, are you sure it is set up correctly?",$i="We were not able to connect using this address. For it to work it has to come from a NIP-46 provider.",Ii=20;function Oi(t){return window.open(t,"window.nostr","width=600,height=800,popup=yes")}function Bi(t,e,n){let r,o,i,s,a,c;const l=window.location.hostname,u=window.location.protocol,h=Wo("only screen and (max-width: 640px)");f(t,h,(t=>n(5,c=t)));const d="wnj:origin",p="wnj:clientSecret",g="wnj:ypos",w="wnj:bunkerPointer";let b,{accent:y}=e,{position:m="top"}=e,{startHidden:v}=e,{compactMode:x}=e;const E=window,k=new Hn;let A,S,$;const I=localStorage.getItem(p);I?$=dt(I):($=mn(),localStorage.setItem(p,ht($)));let O,B,T,_,P,R,N,H,C,j,q,M,z,K="closed",W=!1,D=null,F=null,V=null,Z=!1,J=!1,Y=!1,G=[],{right:Q=20}=e,X=!1,tt=!1;const et={pool:k,onauth(t){N?n(10,D=t):C?(n(12,V=t),n(39,K="opened")):n(11,F=t)}},nt=ot((()=>{switch(K){case"justopened":n(39,K="opened");break;case"justclosed":n(39,K="closed")}}),500);function rt(){n(39,K="justopened"),nt()}function it(){n(39,K="justclosed"),nt()}function st(){!O||R?rt():ut()}ct();let at={isWnj:!0,getPublicKey:async()=>new Promise((async(t,e)=>{G.push(e);try{!P&&!R&&st();t(await(await _).getPublicKey())}catch(t){e(t)}finally{const t=G.indexOf(e);-1!==t&&G.splice(t,1)}})),async signEvent(t){try{return!P&&!R&&st(),await(await _).signEvent(t)}finally{n(12,V=null),it()}},getRelays:async()=>({}),nip04:{encrypt:async(t,e)=>(!P&&!R&&st(),(await _).nip04Encrypt(t,e)),decrypt:async(t,e)=>(!P&&!R&&st(),(await _).nip04Decrypt(t,e))},nip44:{encrypt:async(t,e)=>(!P&&!R&&st(),(await _).nip44Encrypt(t,e)),decrypt:async(t,e)=>(!P&&!R&&st(),(await _).nip44Decrypt(t,e))}};function ct(){it(),O=null,_=new Promise(((t,e)=>{B=t,T=e})),n(18,C=null),n(9,P=!1),n(13,Z=!1),n(15,N=!1),R=!1,j=null,n(16,H="")}async function lt(t){t.preventDefault();try{if(O=await jo(S),!O)return void(S.match(Co)?n(16,H=Si):n(16,H=$i));A.setCustomValidity(""),n(16,H=""),await ut(),ft()}catch{S.match(Co)?n(16,H=Si):n(16,H=$i),n(9,P=!1)}}async function ut(t=void 0){t=t||new qo($,O,et),n(9,P=!0);let e=setTimeout((()=>{n(13,Z=!0),n(39,K="opened")}),5e3);try{await t.connect(),R=!0,localStorage.setItem(w,JSON.stringify(O)),it(),B(t)}catch(t){T((null==t?void 0:t.message)||String(t))}finally{clearTimeout(e),n(9,P=!1),n(13,Z=!1),n(10,D=null),n(11,F=null),n(12,V=null),W&&rt()}}async function ft(){let t;try{t=await(await _).getPublicKey()}catch{return void n(14,J=!0)}n(18,C={pubkey:t,npub:zo(t),event:null}),j=k.subscribeMany(["wss://purplepag.es","wss://relay.snort.social","wss://relay.nos.social"],[{kinds:[0],authors:[t]}],{onevent(t){var e;if(!(((null==(e=C.event)?void 0:e.created_at)||0)>=t.created_at))try{let{name:e,picture:r}=JSON.parse(t.content);n(18,C.event=t,C),n(18,C.name=e,C),n(18,C.picture=r,C)}catch{}}})}U((()=>{const t=window.location.hash;if(t.startsWith("#nostr-login=")){const e=t.substring(t.indexOf("=")+1),r=window.location.href.split("#")[0];if(history.replaceState(null,"",r),e.startsWith("bunker://")){n(4,S=e);const t=new SubmitEvent("submit",{bubbles:!0,cancelable:!0});W=!0,rt(),lt(t)}}if(!O){let t=localStorage.getItem(w);if(t){O=JSON.parse(t);let e=new URL(`bunker://${O.pubkey}`);O.relays.forEach((t=>{e.searchParams.append("relay",t)})),O.secret&&e.searchParams.set("secret",O.secret),n(4,S=e.toString()),ft(),ut()}}if(!E.nostr||E.nostr.isWnj)return Object.defineProperty(window,"nostr",{get:()=>at,set(t){at=t,t.isWnj||E.destroyWnj(),G.forEach((t=>{t(new Error("Nostr extension took over, please retry the operation"))})),G=[]},configurable:!0}),()=>{j&&j.close()};E.destroyWnj()}));return t.$$set=t=>{"accent"in t&&n(0,y=t.accent),"position"in t&&n(38,m=t.position),"startHidden"in t&&n(1,v=t.startHidden),"compactMode"in t&&n(2,x=t.compactMode),"right"in t&&n(3,Q=t.right)},t.$$.update=()=>{32&t.$$.dirty[0]|128&t.$$.dirty[1]&&n(20,r=c?"bottom":localStorage.getItem(d)||m),32&t.$$.dirty[0]&&n(19,o=c?Ii:parseInt(localStorage.getItem(g)||"0")||Ii),256&t.$$.dirty[1]&&n(21,i="justopened"===K||"opened"===K),1&t.$$.dirty[0]|512&t.$$.dirty[1]&&n(23,s=tt?"cursor-grabbing outline-dashed outline-"+y+"-500 outline-1 outline-offset-4":"outline-none"),16&t.$$.dirty[0]&&n(22,a=S&&(S.match(Co)||S.match(Mo)))},[y,v,x,Q,S,c,b,A,$,P,D,F,V,Z,J,N,H,Y,C,o,r,i,a,s,h,function(t){Math.abs(o-M)>6||Date.now()-z>600||"justopened"===K||"justclosed"===K||(t.composedPath().find((t=>"wnj"===t.id))?rt():it())},function(t){it(),n(15,N=!1),n(10,D=null),n(11,F=null),n(12,V=null),t.stopPropagation()},function(t){n(17,Y=!0),t.stopPropagation()},function(t){n(17,Y=!1),t.stopPropagation()},lt,async function(t){t.preventDefault(),localStorage.removeItem(w),ct()},async function(t){t.preventDefault(),n(4,S=""),localStorage.removeItem(w),n(14,J=!1)},function(t){n(15,N=!1)},function(){n(13,Z=!1),n(9,P=!1),T("connection aborted"),ct(),rt()},function(t){if(i)return;X=!0;const e=b.getBoundingClientRect();q=t.clientY-e.top,M=o,z=Date.now()},function(t){X&&(n(19,o="top"===r?t.clientY:window.innerHeight-t.clientY),n(19,o-=q),n(40,tt=!0),owindow.innerHeight-Ii&&n(19,o=window.innerHeight-Ii))},function(){if(X=!1,setTimeout((()=>{n(40,tt=!1)}),10),tt){const t=b.getBoundingClientRect(),e=window.innerHeight,i=e/2;t.topOi(D),()=>Oi(F),()=>{Oi(V)},function(t){L[t?"unshift":"push"]((()=>{A=t,n(7,A)}))},function(){S=this.value,n(4,S)},function(t){L[t?"unshift":"push"]((()=>{b=t,n(6,b)}))}]}const Ti=window;Ti.destroyWnj=()=>{setTimeout((()=>{Ri.$destroy()}),1)};const Ui=document.createElement("div");Ui.style.zIndex="90000",document.body.appendChild(Ui);const _i=document.createElement("div");_i.id="wnj";const Li=document.createElement("style");Li.innerHTML='*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{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,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}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-feature-settings:normal;font-variation-settings:normal;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}*,: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: }.fixed{position:fixed}.absolute{position:absolute}.bottom-1{bottom:.25rem}.right-2{right:.5rem}.right-3{right:.75rem}.top-0{top:0}.z-\\[9000\\]{z-index:9000}.m-auto{margin:auto}.my-2{margin-top:.5rem;margin-bottom:.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.ml-2{margin-left:.5rem}.mr-2{margin-right:.5rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.box-border{box-sizing:border-box}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.h-10{height:2.5rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.w-10{width:2.5rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-full{width:100%}.max-w-56{max-width:14rem}@keyframes moveIn{0%{transform:translateY(-10px)}to{transform:translateY(0)}}.animate-fadein{animation:fadeIn 1s ease-in-out,moveIn 1s ease-in-out}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.animate-show{animation:fadeIn .2s ease-in-out}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-grabbing{cursor:grabbing}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.overflow-hidden{overflow:hidden}.overflow-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-md{border-radius:.375rem}.border-0{border-width:0px}.border-2{border-width:2px}.border-solid{border-style:solid}.border-transparent{border-color:transparent}.bg-cyan-700{--tw-bg-opacity: 1;background-color:rgb(14 116 144 / var(--tw-bg-opacity))}.bg-cyan-800{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity))}.bg-cyan-900{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity))}.bg-cyan-950{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity))}.bg-green-700{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.bg-green-800{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.bg-green-900{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity))}.bg-green-950{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity))}.bg-neutral-700{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}.bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.bg-neutral-900{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity))}.bg-neutral-950{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity))}.bg-orange-700{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity))}.bg-orange-800{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity))}.bg-orange-900{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity))}.bg-orange-950{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity))}.bg-purple-700{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity))}.bg-purple-800{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity))}.bg-purple-900{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity))}.bg-purple-950{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity))}.bg-red-700{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity))}.bg-red-800{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity))}.bg-red-900{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity))}.bg-red-950{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity))}.bg-stone-700{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity))}.bg-stone-800{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity))}.bg-stone-900{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity))}.bg-stone-950{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity))}.bg-transparent{background-color:transparent}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity))}.bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--tw-gradient-stops))}.from-cyan-900{--tw-gradient-from: #164e63 var(--tw-gradient-from-position);--tw-gradient-to: rgb(22 78 99 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-green-900{--tw-gradient-from: #14532d var(--tw-gradient-from-position);--tw-gradient-to: rgb(20 83 45 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-neutral-900{--tw-gradient-from: #171717 var(--tw-gradient-from-position);--tw-gradient-to: rgb(23 23 23 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-orange-900{--tw-gradient-from: #7c2d12 var(--tw-gradient-from-position);--tw-gradient-to: rgb(124 45 18 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-purple-900{--tw-gradient-from: #581c87 var(--tw-gradient-from-position);--tw-gradient-to: rgb(88 28 135 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-red-900{--tw-gradient-from: #7f1d1d var(--tw-gradient-from-position);--tw-gradient-to: rgb(127 29 29 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-stone-900{--tw-gradient-from: #1c1917 var(--tw-gradient-from-position);--tw-gradient-to: rgb(28 25 23 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-cyan-700{--tw-gradient-to: #0e7490 var(--tw-gradient-to-position)}.to-green-700{--tw-gradient-to: #15803d var(--tw-gradient-to-position)}.to-neutral-700{--tw-gradient-to: #404040 var(--tw-gradient-to-position)}.to-orange-700{--tw-gradient-to: #c2410c var(--tw-gradient-to-position)}.to-purple-700{--tw-gradient-to: #7e22ce var(--tw-gradient-to-position)}.to-red-700{--tw-gradient-to: #b91c1c var(--tw-gradient-to-position)}.to-stone-700{--tw-gradient-to: #44403c var(--tw-gradient-to-position)}.p-2{padding:.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.text-center{text-align:center}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.leading-3{line-height:.75rem}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.text-cyan-600{--tw-text-opacity: 1;color:rgb(8 145 178 / var(--tw-text-opacity))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity))}.text-neutral-600{--tw-text-opacity: 1;color:rgb(82 82 82 / var(--tw-text-opacity))}.text-neutral-800{--tw-text-opacity: 1;color:white;}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity))}.text-stone-600{--tw-text-opacity: 1;color:rgb(87 83 78 / var(--tw-text-opacity))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.underline{text-decoration-line:underline}.no-underline{text-decoration-line:none}.decoration-2{text-decoration-thickness:2px}.underline-offset-4{text-underline-offset:4px}.opacity-25{opacity:.25}.opacity-75{opacity:.75}.shadow-\\[0_0px_10px_0px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\]{--tw-shadow: 0 0px 10px 0px rgba(0,0,0,.3);--tw-shadow-colored: 0 0px 10px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-\\[0_0px_30px_0px_rgba\\(0\\,0\\,0\\,0\\.6\\)\\]{--tw-shadow: 0 0px 30px 0px rgba(0,0,0,.6);--tw-shadow-colored: 0 0px 30px 0px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline-dashed{outline-style:dashed}.outline-1{outline-width:1px}.outline-offset-4{outline-offset:4px}.outline-cyan-500{outline-color:#06b6d4}.outline-green-500{outline-color:#22c55e}.outline-neutral-500{outline-color:#737373}.outline-orange-500{outline-color:#f97316}.outline-purple-500{outline-color:#a855f7}.outline-red-500{outline-color:#ef4444}.outline-stone-500{outline-color:#78716c}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.hover\\:bg-cyan-700:hover{--tw-bg-opacity: 1;background-color:rgb(14 116 144 / var(--tw-bg-opacity))}.hover\\:bg-cyan-800:hover{--tw-bg-opacity: 1;background-color:rgb(21 94 117 / var(--tw-bg-opacity))}.hover\\:bg-cyan-900:hover{--tw-bg-opacity: 1;background-color:rgb(22 78 99 / var(--tw-bg-opacity))}.hover\\:bg-cyan-950:hover{--tw-bg-opacity: 1;background-color:rgb(8 51 68 / var(--tw-bg-opacity))}.hover\\:bg-green-700:hover{--tw-bg-opacity: 1;background-color:rgb(21 128 61 / var(--tw-bg-opacity))}.hover\\:bg-green-800:hover{--tw-bg-opacity: 1;background-color:rgb(22 101 52 / var(--tw-bg-opacity))}.hover\\:bg-green-900:hover{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity))}.hover\\:bg-green-950:hover{--tw-bg-opacity: 1;background-color:rgb(5 46 22 / var(--tw-bg-opacity))}.hover\\:bg-neutral-700:hover{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity))}.hover\\:bg-neutral-800:hover{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity))}.hover\\:bg-neutral-900:hover{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity))}.hover\\:bg-neutral-950:hover{--tw-bg-opacity: 1;background-color:rgb(10 10 10 / var(--tw-bg-opacity))}.hover\\:bg-orange-700:hover{--tw-bg-opacity: 1;background-color:rgb(194 65 12 / var(--tw-bg-opacity))}.hover\\:bg-orange-800:hover{--tw-bg-opacity: 1;background-color:rgb(154 52 18 / var(--tw-bg-opacity))}.hover\\:bg-orange-900:hover{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity))}.hover\\:bg-orange-950:hover{--tw-bg-opacity: 1;background-color:rgb(67 20 7 / var(--tw-bg-opacity))}.hover\\:bg-purple-700:hover{--tw-bg-opacity: 1;background-color:rgb(126 34 206 / var(--tw-bg-opacity))}.hover\\:bg-purple-800:hover{--tw-bg-opacity: 1;background-color:rgb(107 33 168 / var(--tw-bg-opacity))}.hover\\:bg-purple-900:hover{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity))}.hover\\:bg-purple-950:hover{--tw-bg-opacity: 1;background-color:rgb(59 7 100 / var(--tw-bg-opacity))}.hover\\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity))}.hover\\:bg-red-800:hover{--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity))}.hover\\:bg-red-900:hover{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity))}.hover\\:bg-red-950:hover{--tw-bg-opacity: 1;background-color:rgb(69 10 10 / var(--tw-bg-opacity))}.hover\\:bg-stone-700:hover{--tw-bg-opacity: 1;background-color:rgb(68 64 60 / var(--tw-bg-opacity))}.hover\\:bg-stone-800:hover{--tw-bg-opacity: 1;background-color:rgb(41 37 36 / var(--tw-bg-opacity))}.hover\\:bg-stone-900:hover{--tw-bg-opacity: 1;background-color:rgb(28 25 23 / var(--tw-bg-opacity))}.hover\\:bg-stone-950:hover{--tw-bg-opacity: 1;background-color:rgb(12 10 9 / var(--tw-bg-opacity))}.disabled\\:cursor-default:disabled{cursor:default}.disabled\\:bg-neutral-400:disabled{--tw-bg-opacity: 1;background-color:rgb(163 163 163 / var(--tw-bg-opacity))}.disabled\\:text-neutral-200:disabled{--tw-text-opacity: 1;color:rgb(229 229 229 / var(--tw-text-opacity))}.group:hover .group-hover\\:underline{text-decoration-line:underline}@media (min-width: 640px){.sm\\:w-96{width:24rem}}';const Pi=Ui.attachShadow({mode:"open"});Pi.appendChild(_i),Pi.appendChild(Li);const Ri=new class extends tt{constructor(t){super(),X(this,t,Bi,ki,u,{accent:0,position:38,startHidden:1,compactMode:2,right:3},null,[-1,-1,-1])}}({target:_i,props:{accent:(null==(t=Ti.wnjParams)?void 0:t.accent)||"cyan",position:"bottom"===(null==(e=Ti.wnjParams)?void 0:e.position)?"bottom":"top",startHidden:null==(n=Ti.wnjParams)?void 0:n.startHidden,compactMode:null==(r=Ti.wnjParams)?void 0:r.compactMode}});if(null==(o=Ti.wnjParams)||!o.disableOverflowFix){const t=document.createElement("style"),e="\n html, body {\n overflow: auto;\n height: 100%;\n }\n ";t.innerHTML=e,document.head.appendChild(t)}}();
//# sourceMappingURL=/sm/c70b83e199fa1741533055a0248868439d650c779d78ea522db6d51a1121b0d9.map