window.nostr.js 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.html +1 -1
- package/dist/window.nostr.js +13 -13
- package/package.json +2 -2
- package/src/App.svelte +113 -41
- package/src/signer.ts +10 -0
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>dev</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-Ct8-MMGf.js"></script>
|
|
8
8
|
</head>
|
|
9
9
|
<body
|
|
10
10
|
style="
|
package/dist/window.nostr.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var tl=Object.defineProperty;var el=(Zt,$,Ct)=>$ in Zt?tl(Zt,$,{enumerable:!0,configurable:!0,writable:!0,value:Ct}):Zt[$]=Ct;var v=(Zt,$,Ct)=>(el(Zt,typeof $!="symbol"?$+"":$,Ct),Ct);(function(){"use strict";var Ro,Ho,Mo,jo,$o;const Zt='*,: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:rgb(38 38 38 / var(--tw-text-opacity))}.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}}';function $(){}function Ct(e){return e()}function Qn(){return Object.create(null)}function Rt(e){e.forEach(Ct)}function Ze(e){return typeof e=="function"}function Je(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}let Te;function re(e,t){return e===t?!0:(Te||(Te=document.createElement("a")),Te.href=t,e===Te.href)}function Wo(e){return Object.keys(e).length===0}function Do(e,...t){if(e==null){for(const r of t)r(void 0);return $}const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function Vo(e,t,n){e.$$.on_destroy.push(Do(t,n))}const Fo=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function T(e,t){e.appendChild(t)}function j(e,t,n){e.insertBefore(t,n||null)}function M(e){e.parentNode&&e.parentNode.removeChild(e)}function C(e){return document.createElement(e)}function Qe(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function G(e){return document.createTextNode(e)}function Z(){return G(" ")}function Xn(){return G("")}function ct(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function S(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Go(e){return Array.from(e.childNodes)}function Ht(e,t){t=""+t,e.data!==t&&(e.data=t)}function tr(e,t){e.value=t??""}function er(e,t,n){e.classList.toggle(t,!!n)}let ye;function me(e){ye=e}function Yo(){if(!ye)throw new Error("Function called outside component initialization");return ye}function Zo(e){Yo().$$.on_mount.push(e)}const oe=[],Oe=[];let ie=[];const nr=[],Jo=Promise.resolve();let Xe=!1;function Qo(){Xe||(Xe=!0,Jo.then(rr))}function tn(e){ie.push(e)}const en=new Set;let se=0;function rr(){if(se!==0)return;const e=ye;do{try{for(;se<oe.length;){const t=oe[se];se++,me(t),Xo(t.$$)}}catch(t){throw oe.length=0,se=0,t}for(me(null),oe.length=0,se=0;Oe.length;)Oe.pop()();for(let t=0;t<ie.length;t+=1){const n=ie[t];en.has(n)||(en.add(n),n())}ie.length=0}while(oe.length);for(;nr.length;)nr.pop()();Xe=!1,en.clear(),me(e)}function Xo(e){if(e.fragment!==null){e.update(),Rt(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(tn)}}function ti(e){const t=[],n=[];ie.forEach(r=>e.indexOf(r)===-1?t.push(r):n.push(r)),n.forEach(r=>r()),ie=t}const Le=new Set;let Jt;function Ne(){Jt={r:0,c:[],p:Jt}}function Pe(){Jt.r||Rt(Jt.c),Jt=Jt.p}function xt(e,t){e&&e.i&&(Le.delete(e),e.i(t))}function vt(e,t,n,r){if(e&&e.o){if(Le.has(e))return;Le.add(e),Jt.c.push(()=>{Le.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function or(e){e&&e.c()}function nn(e,t,n){const{fragment:r,after_update:o}=e.$$;r&&r.m(t,n),tn(()=>{const i=e.$$.on_mount.map(Ct).filter(Ze);e.$$.on_destroy?e.$$.on_destroy.push(...i):Rt(i),e.$$.on_mount=[]}),o.forEach(tn)}function rn(e,t){const n=e.$$;n.fragment!==null&&(ti(n.after_update),Rt(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function ei(e,t){e.$$.dirty[0]===-1&&(oe.push(e),Qo(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function ir(e,t,n,r,o,i,s=null,c=[-1]){const a=ye;me(e);const l=e.$$={fragment:null,ctx:[],props:i,update:$,not_equal:o,bound:Qn(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(a?a.$$.context:[])),callbacks:Qn(),dirty:c,skip_bound:!1,root:t.target||a.$$.root};s&&s(l.root);let f=!1;if(l.ctx=n?n(e,t.props||{},(u,g,...h)=>{const b=h.length?h[0]:g;return l.ctx&&o(l.ctx[u],l.ctx[u]=b)&&(!l.skip_bound&&l.bound[u]&&l.bound[u](b),f&&ei(e,u)),g}):[],l.update(),f=!0,Rt(l.before_update),l.fragment=r?r(l.ctx):!1,t.target){if(t.hydrate){const u=Go(t.target);l.fragment&&l.fragment.l(u),u.forEach(M)}else l.fragment&&l.fragment.c();t.intro&&xt(e.$$.fragment),nn(e,t.target,t.anchor),rr()}me(a)}class sr{constructor(){v(this,"$$");v(this,"$$set")}$destroy(){rn(this,1),this.$destroy=$}$on(t,n){if(!Ze(n))return $;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(t){this.$$set&&!Wo(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const ni="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(ni);function ri(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var on={exports:{}};function cr(e,t=100,n={}){if(typeof e!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw new RangeError("`wait` must not be negative.");const{immediate:r}=typeof n=="boolean"?{immediate:n}:n;let o,i,s,c,a;function l(){const u=Date.now()-c;if(u<t&&u>=0)s=setTimeout(l,t-u);else if(s=void 0,!r){const g=o,h=i;o=void 0,i=void 0,a=e.apply(g,h)}}const f=function(...u){if(o&&this!==o)throw new Error("Debounced method called with different contexts.");o=this,i=u,c=Date.now();const g=r&&!s;if(s||(s=setTimeout(l,t)),g){const h=o,b=i;o=void 0,i=void 0,a=e.apply(h,b)}return a};return f.clear=()=>{s&&(clearTimeout(s),s=void 0)},f.flush=()=>{if(!s)return;const u=o,g=i;o=void 0,i=void 0,a=e.apply(u,g),clearTimeout(s),s=void 0},f}on.exports.debounce=cr,on.exports=cr;var oi=on.exports;const ii=ri(oi),sn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cn=e=>e instanceof Uint8Array,an=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Et=(e,t)=>e<<32-t|e>>>t;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const si=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function dt(e){if(!cn(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=si[e[n]];return t}function ar(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let r=0;r<n.length;r++){const o=r*2,i=e.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function ci(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function xe(e){if(typeof e=="string"&&(e=ci(e)),!cn(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}function ln(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!cn(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}let lr=class{clone(){return this._cloneInto()}};function ur(e){const t=r=>e().update(xe(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ai(e=32){if(sn&&typeof sn.getRandomValues=="function")return sn.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function fr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function dr(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function li(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");fr(e.outputLen),fr(e.blockLen)}function Ue(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ui(e,t){dr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const un=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hr=e=>e instanceof Uint8Array,fn=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),_t=(e,t)=>e<<32-t|e>>>t;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function fi(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function dn(e){if(typeof e=="string"&&(e=fi(e)),!hr(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}function di(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!hr(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}class gr{clone(){return this._cloneInto()}}function hi(e){const t=r=>e().update(dn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function pr(e=32){if(un&&typeof un.getRandomValues=="function")return un.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function gi(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),a=r?4:0,l=r?0:4;e.setUint32(t+a,s,r),e.setUint32(t+l,c,r)}let pi=class extends gr{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=fn(this.buffer)}update(t){Ue(this);const{view:n,buffer:r,blockLen:o}=this;t=dn(t);const i=t.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const a=fn(t);for(;o<=i-s;s+=o)this.process(a,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ue(this),ui(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let u=s;u<o;u++)n[u]=0;gi(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=fn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)c.setUint32(4*u,f[u],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return t.length=o,t.pos=c,t.finished=i,t.destroyed=s,o%n&&t.buffer.set(r),t}};const bi=(e,t,n)=>e&t^~e&n,wi=(e,t,n)=>e&t^e&n^t&n,yi=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]),Mt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),jt=new Uint32Array(64);let mi=class extends pi{constructor(){super(64,32,8,!1),this.A=Mt[0]|0,this.B=Mt[1]|0,this.C=Mt[2]|0,this.D=Mt[3]|0,this.E=Mt[4]|0,this.F=Mt[5]|0,this.G=Mt[6]|0,this.H=Mt[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:c,H:a}=this;return[t,n,r,o,i,s,c,a]}set(t,n,r,o,i,s,c,a){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,n){for(let u=0;u<16;u++,n+=4)jt[u]=t.getUint32(n,!1);for(let u=16;u<64;u++){const g=jt[u-15],h=jt[u-2],b=_t(g,7)^_t(g,18)^g>>>3,d=_t(h,17)^_t(h,19)^h>>>10;jt[u]=d+jt[u-7]+b+jt[u-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:a,G:l,H:f}=this;for(let u=0;u<64;u++){const g=_t(c,6)^_t(c,11)^_t(c,25),h=f+g+bi(c,a,l)+yi[u]+jt[u]|0,d=(_t(r,2)^_t(r,13)^_t(r,22))+wi(r,o,i)|0;f=l,l=a,a=c,c=s+h|0,s=i,i=o,o=r,r=h+d|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,o,i,s,c,a,l,f)}roundClean(){jt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const hn=hi(()=>new mi);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const br=BigInt(0),Ce=BigInt(1),xi=BigInt(2),Re=e=>e instanceof Uint8Array,vi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ce(e){if(!Re(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=vi[e[n]];return t}function wr(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function gn(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function ae(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let r=0;r<n.length;r++){const o=r*2,i=e.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function ht(e){return gn(ce(e))}function pn(e){if(!Re(e))throw new Error("Uint8Array expected");return gn(ce(Uint8Array.from(e).reverse()))}function $t(e,t){return ae(e.toString(16).padStart(t*2,"0"))}function bn(e,t){return $t(e,t).reverse()}function Ei(e){return ae(wr(e))}function ut(e,t,n){let r;if(typeof t=="string")try{r=ae(t)}catch(i){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Re(t))r=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${e} expected ${n} bytes, got ${o}`);return r}function Qt(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!Re(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function _i(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ki(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Si(e){let t;for(t=0;e>br;e>>=Ce,t+=1);return t}function Ai(e,t){return e>>BigInt(t)&Ce}const Bi=(e,t,n)=>e|(n?Ce:br)<<BigInt(t),wn=e=>(xi<<BigInt(e-1))-Ce,yn=e=>new Uint8Array(e),yr=e=>Uint8Array.from(e);function mr(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=yn(e),o=yn(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},c=(...u)=>n(o,r,...u),a=(u=yn())=>{o=c(yr([0]),u),r=c(),u.length!==0&&(o=c(yr([1]),u),r=c())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const g=[];for(;u<t;){r=c();const h=r.slice();g.push(h),u+=r.length}return Qt(...g)};return(u,g)=>{s(),a(u);let h;for(;!(h=g(l()));)a();return s(),h}}const Ii={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function ve(e,t,n={}){const r=(o,i,s)=>{const c=Ii[i];if(typeof c!="function")throw new Error(`Invalid validator "${i}", expected function`);const a=e[o];if(!(s&&a===void 0)&&!c(a,e))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${i}`)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}const Ti=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Ai,bitLen:Si,bitMask:wn,bitSet:Bi,bytesToHex:ce,bytesToNumberBE:ht,bytesToNumberLE:pn,concatBytes:Qt,createHmacDrbg:mr,ensureBytes:ut,equalBytes:_i,hexToBytes:ae,hexToNumber:gn,numberToBytesBE:$t,numberToBytesLE:bn,numberToHexUnpadded:wr,numberToVarBytesBE:Ei,utf8ToBytes:ki,validateObject:ve},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rt=BigInt(0),tt=BigInt(1),Xt=BigInt(2),Oi=BigInt(3),mn=BigInt(4),xr=BigInt(5),vr=BigInt(8);BigInt(9),BigInt(16);function at(e,t){const n=e%t;return n>=rt?n:t+n}function Li(e,t,n){if(n<=rt||t<rt)throw new Error("Expected power/modulo > 0");if(n===tt)return rt;let r=tt;for(;t>rt;)t&tt&&(r=r*e%n),e=e*e%n,t>>=tt;return r}function bt(e,t,n){let r=e;for(;t-- >rt;)r*=r,r%=n;return r}function xn(e,t){if(e===rt||t<=rt)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=at(e,t),r=t,o=rt,i=tt;for(;n!==rt;){const c=r/n,a=r%n,l=o-i*c;r=n,n=a,o=i,i=l}if(r!==tt)throw new Error("invert: does not exist");return at(o,t)}function Ni(e){const t=(e-tt)/Xt;let n,r,o;for(n=e-tt,r=0;n%Xt===rt;n/=Xt,r++);for(o=Xt;o<e&&Li(o,t,e)!==e-tt;o++);if(r===1){const s=(e+tt)/mn;return function(a,l){const f=a.pow(l,s);if(!a.eql(a.sqr(f),l))throw new Error("Cannot find square root");return f}}const i=(n+tt)/Xt;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=r,f=c.pow(c.mul(c.ONE,o),n),u=c.pow(a,i),g=c.pow(a,n);for(;!c.eql(g,c.ONE);){if(c.eql(g,c.ZERO))return c.ZERO;let h=1;for(let d=c.sqr(g);h<l&&!c.eql(d,c.ONE);h++)d=c.sqr(d);const b=c.pow(f,tt<<BigInt(l-h-1));f=c.sqr(b),u=c.mul(u,b),g=c.mul(g,f),l=h}return u}}function Pi(e){if(e%mn===Oi){const t=(e+tt)/mn;return function(r,o){const i=r.pow(o,t);if(!r.eql(r.sqr(i),o))throw new Error("Cannot find square root");return i}}if(e%vr===xr){const t=(e-xr)/vr;return function(r,o){const i=r.mul(o,Xt),s=r.pow(i,t),c=r.mul(o,s),a=r.mul(r.mul(c,Xt),s),l=r.mul(c,r.sub(a,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return Ni(e)}const Ui=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ci(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Ui.reduce((r,o)=>(r[o]="function",r),t);return ve(e,n)}function Ri(e,t,n){if(n<rt)throw new Error("Expected power > 0");if(n===rt)return e.ONE;if(n===tt)return t;let r=e.ONE,o=t;for(;n>rt;)n&tt&&(r=e.mul(r,o)),o=e.sqr(o),n>>=tt;return r}function Hi(e,t){const n=new Array(t.length),r=t.reduce((i,s,c)=>e.is0(s)?i:(n[c]=i,e.mul(i,s)),e.ONE),o=e.inv(r);return t.reduceRight((i,s,c)=>e.is0(s)?i:(n[c]=e.mul(i,n[c]),e.mul(i,s)),o),n}function Er(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Mi(e,t,n=!1,r={}){if(e<=rt)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Er(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Pi(e),c=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:wn(o),ZERO:rt,ONE:tt,create:a=>at(a,e),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return rt<=a&&a<e},is0:a=>a===rt,isOdd:a=>(a&tt)===tt,neg:a=>at(-a,e),eql:(a,l)=>a===l,sqr:a=>at(a*a,e),add:(a,l)=>at(a+l,e),sub:(a,l)=>at(a-l,e),mul:(a,l)=>at(a*l,e),pow:(a,l)=>Ri(c,a,l),div:(a,l)=>at(a*xn(l,e),e),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>xn(a,e),sqrt:r.sqrt||(a=>s(c,a)),invertBatch:a=>Hi(c,a),cmov:(a,l,f)=>f?l:a,toBytes:a=>n?bn(a,i):$t(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return n?pn(a):ht(a)}});return Object.freeze(c)}function _r(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function kr(e){const t=_r(e);return t+Math.ceil(t/2)}function ji(e,t,n=!1){const r=e.length,o=_r(t),i=kr(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=n?ht(e):pn(e),c=at(s,t-tt)+tt;return n?bn(c,o):$t(c,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $i=BigInt(0),vn=BigInt(1);function qi(e,t){const n=(o,i)=>{const s=i.negate();return o?s:i},r=o=>{const i=Math.ceil(t/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:n,unsafeLadder(o,i){let s=e.ZERO,c=o;for(;i>$i;)i&vn&&(s=s.add(c)),c=c.double(),i>>=vn;return s},precomputeWindow(o,i){const{windows:s,windowSize:c}=r(i),a=[];let l=o,f=l;for(let u=0;u<s;u++){f=l,a.push(f);for(let g=1;g<c;g++)f=f.add(l),a.push(f);l=f.double()}return a},wNAF(o,i,s){const{windows:c,windowSize:a}=r(o);let l=e.ZERO,f=e.BASE;const u=BigInt(2**o-1),g=2**o,h=BigInt(o);for(let b=0;b<c;b++){const d=b*a;let p=Number(s&u);s>>=h,p>a&&(p-=g,s+=vn);const w=d,y=d+Math.abs(p)-1,k=b%2!==0,U=p<0;p===0?f=f.add(n(k,i[w])):l=l.add(n(U,i[y]))}return{p:l,f}},wNAFCached(o,i,s,c){const a=o._WINDOW_SIZE||1;let l=i.get(o);return l||(l=this.precomputeWindow(o,a),a!==1&&i.set(o,c(l))),this.wNAF(a,l,s)}}}function Sr(e){return Ci(e.Fp),ve(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Er(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function zi(e){const t=Sr(e);ve(t,{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}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:Ki,hexToBytes:Wi}=Ti,te={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=te;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Ki(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=te,n=typeof e=="string"?Wi(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=te._parseInt(n.subarray(2)),{d:s,l:c}=te._parseInt(i);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(e){const t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const f=l.toString(16);return f.length&1?`0${f}`:f},r=t(n(e.s)),o=t(n(e.r)),i=r.length/2,s=o.length/2,c=n(i),a=n(s);return`30${n(s+i+4)}02${a}${o}02${c}${r}`}},Bt=BigInt(0),wt=BigInt(1);BigInt(2);const Ar=BigInt(3);BigInt(4);function Di(e){const t=zi(e),{Fp:n}=t,r=t.toBytes||((b,d,p)=>{const w=d.toAffine();return Qt(Uint8Array.from([4]),n.toBytes(w.x),n.toBytes(w.y))}),o=t.fromBytes||(b=>{const d=b.subarray(1),p=n.fromBytes(d.subarray(0,n.BYTES)),w=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:p,y:w}});function i(b){const{a:d,b:p}=t,w=n.sqr(b),y=n.mul(w,b);return n.add(n.add(y,n.mul(b,d)),p)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(b){return typeof b=="bigint"&&Bt<b&&b<t.n}function c(b){if(!s(b))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function a(b){const{allowedPrivateKeyLengths:d,nByteLength:p,wrapPrivateKey:w,n:y}=t;if(d&&typeof b!="bigint"){if(b instanceof Uint8Array&&(b=ce(b)),typeof b!="string"||!d.includes(b.length))throw new Error("Invalid key");b=b.padStart(p*2,"0")}let k;try{k=typeof b=="bigint"?b:ht(ut("private key",b,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof b}`)}return w&&(k=at(k,y)),c(k),k}const l=new Map;function f(b){if(!(b instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,p,w){if(this.px=d,this.py=p,this.pz=w,d==null||!n.isValid(d))throw new Error("x required");if(p==null||!n.isValid(p))throw new Error("y required");if(w==null||!n.isValid(w))throw new Error("z required")}static fromAffine(d){const{x:p,y:w}=d||{};if(!d||!n.isValid(p)||!n.isValid(w))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");const y=k=>n.eql(k,n.ZERO);return y(p)&&y(w)?u.ZERO:new u(p,w,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const p=n.invertBatch(d.map(w=>w.pz));return d.map((w,y)=>w.toAffine(p[y])).map(u.fromAffine)}static fromHex(d){const p=u.fromAffine(o(ut("pointHex",d)));return p.assertValidity(),p}static fromPrivateKey(d){return u.BASE.multiply(a(d))}_setWindowSize(d){this._WINDOW_SIZE=d,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:d,y:p}=this.toAffine();if(!n.isValid(d)||!n.isValid(p))throw new Error("bad point: x or y not FE");const w=n.sqr(p),y=i(d);if(!n.eql(w,y))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:d}=this.toAffine();if(n.isOdd)return!n.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);const{px:p,py:w,pz:y}=this,{px:k,py:U,pz:N}=d,E=n.eql(n.mul(p,N),n.mul(k,y)),_=n.eql(n.mul(w,N),n.mul(U,y));return E&&_}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b:p}=t,w=n.mul(p,Ar),{px:y,py:k,pz:U}=this;let N=n.ZERO,E=n.ZERO,_=n.ZERO,m=n.mul(y,y),O=n.mul(k,k),P=n.mul(U,U),R=n.mul(y,k);return R=n.add(R,R),_=n.mul(y,U),_=n.add(_,_),N=n.mul(d,_),E=n.mul(w,P),E=n.add(N,E),N=n.sub(O,E),E=n.add(O,E),E=n.mul(N,E),N=n.mul(R,N),_=n.mul(w,_),P=n.mul(d,P),R=n.sub(m,P),R=n.mul(d,R),R=n.add(R,_),_=n.add(m,m),m=n.add(_,m),m=n.add(m,P),m=n.mul(m,R),E=n.add(E,m),P=n.mul(k,U),P=n.add(P,P),m=n.mul(P,R),N=n.sub(N,m),_=n.mul(P,O),_=n.add(_,_),_=n.add(_,_),new u(N,E,_)}add(d){f(d);const{px:p,py:w,pz:y}=this,{px:k,py:U,pz:N}=d;let E=n.ZERO,_=n.ZERO,m=n.ZERO;const O=t.a,P=n.mul(t.b,Ar);let R=n.mul(p,k),D=n.mul(w,U),q=n.mul(y,N),z=n.add(p,w),x=n.add(k,U);z=n.mul(z,x),x=n.add(R,D),z=n.sub(z,x),x=n.add(p,y);let A=n.add(k,N);return x=n.mul(x,A),A=n.add(R,q),x=n.sub(x,A),A=n.add(w,y),E=n.add(U,N),A=n.mul(A,E),E=n.add(D,q),A=n.sub(A,E),m=n.mul(O,x),E=n.mul(P,q),m=n.add(E,m),E=n.sub(D,m),m=n.add(D,m),_=n.mul(E,m),D=n.add(R,R),D=n.add(D,R),q=n.mul(O,q),x=n.mul(P,x),D=n.add(D,q),q=n.sub(R,q),q=n.mul(O,q),x=n.add(x,q),R=n.mul(D,x),_=n.add(_,R),R=n.mul(A,x),E=n.mul(z,E),E=n.sub(E,R),R=n.mul(z,D),m=n.mul(A,m),m=n.add(m,R),new u(E,_,m)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return h.wNAFCached(this,l,d,p=>{const w=n.invertBatch(p.map(y=>y.pz));return p.map((y,k)=>y.toAffine(w[k])).map(u.fromAffine)})}multiplyUnsafe(d){const p=u.ZERO;if(d===Bt)return p;if(c(d),d===wt)return this;const{endo:w}=t;if(!w)return h.unsafeLadder(this,d);let{k1neg:y,k1:k,k2neg:U,k2:N}=w.splitScalar(d),E=p,_=p,m=this;for(;k>Bt||N>Bt;)k&wt&&(E=E.add(m)),N&wt&&(_=_.add(m)),m=m.double(),k>>=wt,N>>=wt;return y&&(E=E.negate()),U&&(_=_.negate()),_=new u(n.mul(_.px,w.beta),_.py,_.pz),E.add(_)}multiply(d){c(d);let p=d,w,y;const{endo:k}=t;if(k){const{k1neg:U,k1:N,k2neg:E,k2:_}=k.splitScalar(p);let{p:m,f:O}=this.wNAF(N),{p:P,f:R}=this.wNAF(_);m=h.constTimeNegate(U,m),P=h.constTimeNegate(E,P),P=new u(n.mul(P.px,k.beta),P.py,P.pz),w=m.add(P),y=O.add(R)}else{const{p:U,f:N}=this.wNAF(p);w=U,y=N}return u.normalizeZ([w,y])[0]}multiplyAndAddUnsafe(d,p,w){const y=u.BASE,k=(N,E)=>E===Bt||E===wt||!N.equals(y)?N.multiplyUnsafe(E):N.multiply(E),U=k(this,p).add(k(d,w));return U.is0()?void 0:U}toAffine(d){const{px:p,py:w,pz:y}=this,k=this.is0();d==null&&(d=k?n.ONE:n.inv(y));const U=n.mul(p,d),N=n.mul(w,d),E=n.mul(y,d);if(k)return{x:n.ZERO,y:n.ZERO};if(!n.eql(E,n.ONE))throw new Error("invZ was invalid");return{x:U,y:N}}isTorsionFree(){const{h:d,isTorsionFree:p}=t;if(d===wt)return!0;if(p)return p(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:d,clearCofactor:p}=t;return d===wt?this:p?p(u,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return this.assertValidity(),r(u,this,d)}toHex(d=!0){return ce(this.toRawBytes(d))}}u.BASE=new u(t.Gx,t.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const g=t.nBitLength,h=qi(u,t.endo?Math.ceil(g/2):g);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:s}}function Vi(e){const t=Sr(e);return ve(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Fi(e){const t=Vi(e),{Fp:n,n:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(x){return Bt<x&&x<n.ORDER}function c(x){return at(x,r)}function a(x){return xn(x,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:g}=Di({...t,toBytes(x,A,L){const H=A.toAffine(),B=n.toBytes(H.x),K=Qt;return L?K(Uint8Array.from([A.hasEvenY()?2:3]),B):K(Uint8Array.from([4]),B,n.toBytes(H.y))},fromBytes(x){const A=x.length,L=x[0],H=x.subarray(1);if(A===o&&(L===2||L===3)){const B=ht(H);if(!s(B))throw new Error("Point is not on curve");const K=u(B);let V=n.sqrt(K);const W=(V&wt)===wt;return(L&1)===1!==W&&(V=n.neg(V)),{x:B,y:V}}else if(A===i&&L===4){const B=n.fromBytes(H.subarray(0,n.BYTES)),K=n.fromBytes(H.subarray(n.BYTES,2*n.BYTES));return{x:B,y:K}}else throw new Error(`Point of length ${A} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=x=>ce($t(x,t.nByteLength));function b(x){const A=r>>wt;return x>A}function d(x){return b(x)?c(-x):x}const p=(x,A,L)=>ht(x.slice(A,L));class w{constructor(A,L,H){this.r=A,this.s=L,this.recovery=H,this.assertValidity()}static fromCompact(A){const L=t.nByteLength;return A=ut("compactSignature",A,L*2),new w(p(A,0,L),p(A,L,2*L))}static fromDER(A){const{r:L,s:H}=te.toSig(ut("DER",A));return new w(L,H)}assertValidity(){if(!g(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!g(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(A){return new w(this.r,this.s,A)}recoverPublicKey(A){const{r:L,s:H,recovery:B}=this,K=_(ut("msgHash",A));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");const V=B===2||B===3?L+t.n:L;if(V>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const W=B&1?"03":"02",X=l.fromHex(W+h(V)),J=a(V),ot=c(-K*J),it=c(H*J),st=l.BASE.multiplyAndAddUnsafe(X,ot,it);if(!st)throw new Error("point at infinify");return st.assertValidity(),st}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return ae(this.toDERHex())}toDERHex(){return te.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ae(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const y={isValidPrivateKey(x){try{return f(x),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const x=kr(t.n);return ji(t.randomBytes(x),t.n)},precompute(x=8,A=l.BASE){return A._setWindowSize(x),A.multiply(BigInt(3)),A}};function k(x,A=!0){return l.fromPrivateKey(x).toRawBytes(A)}function U(x){const A=x instanceof Uint8Array,L=typeof x=="string",H=(A||L)&&x.length;return A?H===o||H===i:L?H===2*o||H===2*i:x instanceof l}function N(x,A,L=!0){if(U(x))throw new Error("first arg must be private key");if(!U(A))throw new Error("second arg must be public key");return l.fromHex(A).multiply(f(x)).toRawBytes(L)}const E=t.bits2int||function(x){const A=ht(x),L=x.length*8-t.nBitLength;return L>0?A>>BigInt(L):A},_=t.bits2int_modN||function(x){return c(E(x))},m=wn(t.nBitLength);function O(x){if(typeof x!="bigint")throw new Error("bigint expected");if(!(Bt<=x&&x<m))throw new Error(`bigint expected < 2^${t.nBitLength}`);return $t(x,t.nByteLength)}function P(x,A,L=R){if(["recovered","canonical"].some(nt=>nt in L))throw new Error("sign() legacy options not supported");const{hash:H,randomBytes:B}=t;let{lowS:K,prehash:V,extraEntropy:W}=L;K==null&&(K=!0),x=ut("msgHash",x),V&&(x=ut("prehashed msgHash",H(x)));const X=_(x),J=f(A),ot=[O(J),O(X)];if(W!=null){const nt=W===!0?B(n.BYTES):W;ot.push(ut("extraEntropy",nt))}const it=Qt(...ot),st=X;function gt(nt){const Nt=E(nt);if(!g(Nt))return;const Ie=a(Nt),Pt=l.BASE.multiply(Nt).toAffine(),pt=c(Pt.x);if(pt===Bt)return;const Ut=c(Ie*c(st+pt*J));if(Ut===Bt)return;let Gt=(Pt.x===pt?0:2)|Number(Pt.y&wt),Yt=Ut;return K&&b(Ut)&&(Yt=d(Ut),Gt^=1),new w(pt,Yt,Gt)}return{seed:it,k2sig:gt}}const R={lowS:t.lowS,prehash:!1},D={lowS:t.lowS,prehash:!1};function q(x,A,L=R){const{seed:H,k2sig:B}=P(x,A,L),K=t;return mr(K.hash.outputLen,K.nByteLength,K.hmac)(H,B)}l.BASE._setWindowSize(8);function z(x,A,L,H=D){var Pt;const B=x;if(A=ut("msgHash",A),L=ut("publicKey",L),"strict"in H)throw new Error("options.strict was renamed to lowS");const{lowS:K,prehash:V}=H;let W,X;try{if(typeof B=="string"||B instanceof Uint8Array)try{W=w.fromDER(B)}catch(pt){if(!(pt instanceof te.Err))throw pt;W=w.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){const{r:pt,s:Ut}=B;W=new w(pt,Ut)}else throw new Error("PARSE");X=l.fromHex(L)}catch(pt){if(pt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(K&&W.hasHighS())return!1;V&&(A=t.hash(A));const{r:J,s:ot}=W,it=_(A),st=a(ot),gt=c(it*st),nt=c(J*st),Nt=(Pt=l.BASE.multiplyAndAddUnsafe(X,gt,nt))==null?void 0:Pt.toAffine();return Nt?c(Nt.x)===J:!1}return{CURVE:t,getPublicKey:k,getSharedSecret:N,sign:q,verify:z,ProjectivePoint:l,Signature:w,utils:y}}let Br=class extends gr{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,li(t);const r=dn(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return Ue(this),this.iHash.update(t),this}digestInto(t){Ue(this),dr(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Ir=(e,t,n)=>new Br(e,t).update(n).digest();Ir.create=(e,t)=>new Br(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Gi(e){return{hash:e,hmac:(t,...n)=>Ir(e,t,di(...n)),randomBytes:pr}}function Yi(e,t){const n=r=>Fi({...e,...Gi(r)});return Object.freeze({...n(t),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const He=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Me=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Tr=BigInt(1),je=BigInt(2),Or=(e,t)=>(e+t/je)/t;function Lr(e){const t=He,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=e*e*e%t,f=l*l*e%t,u=bt(f,n,t)*f%t,g=bt(u,n,t)*f%t,h=bt(g,je,t)*l%t,b=bt(h,o,t)*h%t,d=bt(b,i,t)*b%t,p=bt(d,c,t)*d%t,w=bt(p,a,t)*p%t,y=bt(w,c,t)*d%t,k=bt(y,n,t)*f%t,U=bt(k,s,t)*b%t,N=bt(U,r,t)*l%t,E=bt(N,je,t);if(!En.eql(En.sqr(E),e))throw new Error("Cannot find square root");return E}const En=Mi(He,void 0,void 0,{sqrt:Lr}),Ee=Yi({a:BigInt(0),b:BigInt(7),Fp:En,n:Me,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Me,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Tr*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),c=Or(i*e,t),a=Or(-r*e,t);let l=at(e-c*n-a*o,t),f=at(-c*r-a*i,t);const u=l>s,g=f>s;if(u&&(l=t-l),g&&(f=t-f),l>s||f>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:u,k1:l,k2neg:g,k2:f}}}},hn),$e=BigInt(0),Nr=e=>typeof e=="bigint"&&$e<e&&e<He,Zi=e=>typeof e=="bigint"&&$e<e&&e<Me,Pr={};function qe(e,...t){let n=Pr[e];if(n===void 0){const r=hn(Uint8Array.from(e,o=>o.charCodeAt(0)));n=Qt(r,r),Pr[e]=n}return hn(Qt(n,...t))}const _n=e=>e.toRawBytes(!0).slice(1),kn=e=>$t(e,32),Sn=e=>at(e,He),_e=e=>at(e,Me),An=Ee.ProjectivePoint,Ji=(e,t,n)=>An.BASE.multiplyAndAddUnsafe(e,t,n);function Bn(e){let t=Ee.utils.normPrivateKeyToScalar(e),n=An.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:_e(-t),bytes:_n(n)}}function Ur(e){if(!Nr(e))throw new Error("bad x: need 0 < x < p");const t=Sn(e*e),n=Sn(t*e+BigInt(7));let r=Lr(n);r%je!==$e&&(r=Sn(-r));const o=new An(e,r,Tr);return o.assertValidity(),o}function Cr(...e){return _e(ht(qe("BIP0340/challenge",...e)))}function Qi(e){return Bn(e).bytes}function Xi(e,t,n=pr(32)){const r=ut("message",e),{bytes:o,scalar:i}=Bn(t),s=ut("auxRand",n,32),c=kn(i^ht(qe("BIP0340/aux",s))),a=qe("BIP0340/nonce",c,o,r),l=_e(ht(a));if(l===$e)throw new Error("sign failed: k is zero");const{bytes:f,scalar:u}=Bn(l),g=Cr(f,o,r),h=new Uint8Array(64);if(h.set(f,0),h.set(kn(_e(u+g*i)),32),!Rr(h,r,o))throw new Error("sign: Invalid signature produced");return h}function Rr(e,t,n){const r=ut("signature",e,64),o=ut("message",t),i=ut("publicKey",n,32);try{const s=Ur(ht(i)),c=ht(r.subarray(0,32));if(!Nr(c))return!1;const a=ht(r.subarray(32,64));if(!Zi(a))return!1;const l=Cr(kn(c),_n(s),o),f=Ji(s,a,_e(-l));return!(!f||!f.hasEvenY()||f.toAffine().x!==c)}catch{return!1}}const ft={getPublicKey:Qi,sign:Xi,verify:Rr,utils:{randomPrivateKey:Ee.utils.randomPrivateKey,lift_x:Ur,pointToBytes:_n,numberToBytesBE:$t,bytesToNumberBE:ht,taggedHash:qe,mod:at}};function In(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ts(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Hr(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function es(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");In(e.outputLen),In(e.blockLen)}function ns(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function rs(e,t){Hr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const kt={number:In,bool:ts,bytes:Hr,hash:es,exists:ns,output:rs};function os(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),a=r?4:0,l=r?0:4;e.setUint32(t+a,s,r),e.setUint32(t+l,c,r)}class is extends lr{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=an(this.buffer)}update(t){kt.exists(this);const{view:n,buffer:r,blockLen:o}=this;t=xe(t);const i=t.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const a=an(t);for(;o<=i-s;s+=o)this.process(a,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){kt.exists(this),kt.output(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let u=s;u<o;u++)n[u]=0;os(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=an(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)c.setUint32(4*u,f[u],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return t.length=o,t.pos=c,t.finished=i,t.destroyed=s,o%n&&t.buffer.set(r),t}}const ss=(e,t,n)=>e&t^~e&n,cs=(e,t,n)=>e&t^e&n^t&n,as=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]),qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),zt=new Uint32Array(64);class Mr extends is{constructor(){super(64,32,8,!1),this.A=qt[0]|0,this.B=qt[1]|0,this.C=qt[2]|0,this.D=qt[3]|0,this.E=qt[4]|0,this.F=qt[5]|0,this.G=qt[6]|0,this.H=qt[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:c,H:a}=this;return[t,n,r,o,i,s,c,a]}set(t,n,r,o,i,s,c,a){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,n){for(let u=0;u<16;u++,n+=4)zt[u]=t.getUint32(n,!1);for(let u=16;u<64;u++){const g=zt[u-15],h=zt[u-2],b=Et(g,7)^Et(g,18)^g>>>3,d=Et(h,17)^Et(h,19)^h>>>10;zt[u]=d+zt[u-7]+b+zt[u-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:a,G:l,H:f}=this;for(let u=0;u<64;u++){const g=Et(c,6)^Et(c,11)^Et(c,25),h=f+g+ss(c,a,l)+as[u]+zt[u]|0,d=(Et(r,2)^Et(r,13)^Et(r,22))+cs(r,o,i)|0;f=l,l=a,a=c,c=s+h|0,s=i,i=o,o=r,r=h+d|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,o,i,s,c,a,l,f)}roundClean(){zt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class ls extends Mr{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 le=ur(()=>new Mr);ur(()=>new ls);var ue=Symbol("verified"),us=e=>e instanceof Object;function fs(e){if(!us(e)||typeof e.kind!="number"||typeof e.content!="string"||typeof e.created_at!="number"||typeof e.pubkey!="string"||!e.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}new TextDecoder("utf-8");var ds=new TextEncoder,hs=class{generateSecretKey(){return ft.utils.randomPrivateKey()}getPublicKey(t){return dt(ft.getPublicKey(t))}finalizeEvent(t,n){const r=t;return r.pubkey=dt(ft.getPublicKey(n)),r.id=Tn(r),r.sig=dt(ft.sign(Tn(r),n)),r[ue]=!0,r}verifyEvent(t){if(typeof t[ue]=="boolean")return t[ue];const n=Tn(t);if(n!==t.id)return t[ue]=!1,!1;try{const r=ft.verify(t.sig,n,t.pubkey);return t[ue]=r,r}catch{return t[ue]=!1,!1}}};function gs(e){if(!fs(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function Tn(e){let t=le(ds.encode(gs(e)));return dt(t)}var ze=new hs,ps=ze.generateSecretKey,jr=ze.getPublicKey;ze.finalizeEvent,ze.verifyEvent;var ee=Symbol("verified"),bs=e=>e instanceof Object;function ws(e){if(!bs(e)||typeof e.kind!="number"||typeof e.content!="string"||typeof e.created_at!="number"||typeof e.pubkey!="string"||!e.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}new TextDecoder("utf-8");var ys=new TextEncoder;function ke(e){e.indexOf("://")===-1&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),(t.port==="80"&&t.protocol==="ws:"||t.port==="443"&&t.protocol==="wss:")&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}var ms=class{constructor(t){v(this,"value");v(this,"next",null);v(this,"prev",null);this.value=t}},xs=class{constructor(){v(this,"first");v(this,"last");this.first=null,this.last=null}enqueue(t){const n=new ms(t);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const t=this.first;return this.first=t.next,t.value}},vs=class{generateSecretKey(){return ft.utils.randomPrivateKey()}getPublicKey(t){return dt(ft.getPublicKey(t))}finalizeEvent(t,n){const r=t;return r.pubkey=dt(ft.getPublicKey(n)),r.id=On(r),r.sig=dt(ft.sign(On(r),n)),r[ee]=!0,r}verifyEvent(t){if(typeof t[ee]=="boolean")return t[ee];const n=On(t);if(n!==t.id)return t[ee]=!1,!1;try{const r=ft.verify(t.sig,n,t.pubkey);return t[ee]=r,r}catch{return t[ee]=!1,!1}}};function Es(e){if(!ws(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function On(e){let t=le(ys.encode(Es(e)));return dt(t)}var Ke=new vs;Ke.generateSecretKey,Ke.getPublicKey,Ke.finalizeEvent;var _s=Ke.verifyEvent,ks=22242;function Ss(e,t){if(e.ids&&e.ids.indexOf(t.id)===-1||e.kinds&&e.kinds.indexOf(t.kind)===-1||e.authors&&e.authors.indexOf(t.pubkey)===-1)return!1;for(let n in e)if(n[0]==="#"){let r=n.slice(1),o=e[`#${r}`];if(o&&!t.tags.find(([i,s])=>i===n.slice(1)&&o.indexOf(s)!==-1))return!1}return!(e.since&&t.created_at<e.since||e.until&&t.created_at>e.until)}function As(e,t){for(let n=0;n<e.length;n++)if(Ss(e[n],t))return!0;return!1}function Bs(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}function Is(e){let t=e.slice(0,22).indexOf('"EVENT"');if(t===-1)return null;let n=e.slice(t+7+1).indexOf('"');if(n===-1)return null;let r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(o===-1)return null;let i=r+1+o;return e.slice(r+1,i)}function Ts(e,t){return{kind:ks,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}async function Os(){return new Promise(e=>{const t=new MessageChannel,n=()=>{t.port1.removeEventListener("message",n),e()};t.port1.addEventListener("message",n),t.port2.postMessage(0),t.port1.start()})}var Ls=e=>(e[ee]=!0,!0),$r=class{constructor(t,n){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 xs);v(this,"queueRunning",!1);v(this,"challenge");v(this,"serial",0);v(this,"verifyEvent");v(this,"_WebSocket");this.url=ke(t),this.verifyEvent=n.verifyEvent,this._WebSocket=n.websocketImplementation||WebSocket}static async connect(t,n){const r=new $r(t,n);return await r.connect(),r}closeAllSubscriptions(t){for(let[n,r]of this.openSubs)r.close(t);this.openSubs.clear();for(let[n,r]of this.openEventPublishes)r.reject(new Error(t));this.openEventPublishes.clear();for(let[n,r]of this.openCountRequests)r.reject(new Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.connectionPromise=new Promise((t,n)=>{this.connectionTimeoutHandle=setTimeout(()=>{var r;n("connection timed out"),this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(r){n(r);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=r=>{var o;n(r.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,(o=this.onclose)==null||o.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var r;this._connected&&(this._connected=!1,this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await Os();this.queueRunning=!1}handleNext(){var r,o,i;const t=this.incomingMessageQueue.dequeue();if(!t)return!1;const n=Is(t);if(n){const s=this.openSubs.get(n);if(!s)return;const c=Bs(t,"id"),a=(r=s.alreadyHaveEvent)==null?void 0:r.call(s,c);if((o=s.receivedEvent)==null||o.call(s,this,c),a)return}try{let s=JSON.parse(t);switch(s[0]){case"EVENT":{const c=this.openSubs.get(s[1]),a=s[2];this.verifyEvent(a)&&As(c.filters,a)&&c.onevent(a);return}case"COUNT":{const c=s[1],a=s[2],l=this.openCountRequests.get(c);l&&(l.resolve(a.count),this.openCountRequests.delete(c));return}case"EOSE":{const c=this.openSubs.get(s[1]);if(!c)return;c.receivedEose();return}case"OK":{const c=s[1],a=s[2],l=s[3],f=this.openEventPublishes.get(c);f&&(clearTimeout(f.timeout),a?f.resolve(l):f.reject(new Error(l)),this.openEventPublishes.delete(c));return}case"CLOSED":{const c=s[1],a=this.openSubs.get(c);if(!a)return;a.closed=!0,a.close(s[2]);return}case"NOTICE":this.onnotice(s[1]);return;case"AUTH":{this.challenge=s[1],(i=this._onauth)==null||i.call(this,s[1]);return}}}catch{return}}async send(t){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(t)})}async auth(t){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const n=await t(Ts(this.url,this.challenge)),r=new Promise((o,i)=>{const s=setTimeout(()=>{const c=this.openEventPublishes.get(n.id);c&&(c.reject(new Error("auth timed out")),this.openEventPublishes.delete(n.id))},this.publishTimeout);this.openEventPublishes.set(n.id,{resolve:o,reject:i,timeout:s})});return this.send('["AUTH",'+JSON.stringify(n)+"]"),r}async publish(t){const n=new Promise((r,o)=>{const i=setTimeout(()=>{const s=this.openEventPublishes.get(t.id);s&&(s.reject(new Error("publish timed out")),this.openEventPublishes.delete(t.id))},this.publishTimeout);this.openEventPublishes.set(t.id,{resolve:r,reject:o,timeout:i})});return this.send('["EVENT",'+JSON.stringify(t)+"]"),n}async count(t,n){this.serial++;const r=(n==null?void 0:n.id)||"count:"+this.serial,o=new Promise((i,s)=>{this.openCountRequests.set(r,{resolve:i,reject:s})});return this.send('["COUNT","'+r+'",'+JSON.stringify(t).substring(1)),o}subscribe(t,n){const r=this.prepareSubscription(t,n);return r.fire(),r}prepareSubscription(t,n){this.serial++;const r=n.id||(n.label?n.label+":":"sub:")+this.serial,o=new Ns(this,r,t,n);return this.openSubs.set(r,o),o}close(){var t;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(t=this.ws)==null||t.close()}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},Ns=class{constructor(t,n,r,o){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=r,this.id=n,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||t.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.onevent=o.onevent||(i=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,i)})}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,(t=this.oneose)==null||t.call(this))}close(t="closed by caller"){var n;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,t)}},Ps=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,n){t=ke(t);let r=this.relays.get(t);return r||(r=new $r(t,{verifyEvent:this.trustedRelayURLs.has(t)?Ls:this.verifyEvent,websocketImplementation:this._WebSocket}),n!=null&&n.connectionTimeout&&(r.connectionTimeout=n.connectionTimeout),this.relays.set(t,r)),await r.connect(),r}close(t){t.map(ke).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close()})}subscribeMany(t,n,r){return this.subscribeManyMap(Object.fromEntries(t.map(o=>[o,n])),r)}subscribeManyMap(t,n){this.trackRelays&&(n.receivedEvent=(g,h)=>{let b=this.seenOn.get(h);b||(b=new Set,this.seenOn.set(h,b)),b.add(g)});const r=new Set,o=[],i=Object.keys(t).length,s=[];let c=g=>{var h;s[g]||(s[g]=!0,s.filter(b=>b).length===i&&((h=n.oneose)==null||h.call(n),c=()=>{}))};const a=[];let l=(g,h)=>{var b;a[g]||(c(g),a[g]=h,a.filter(d=>d).length===i&&((b=n.onclose)==null||b.call(n,a),l=()=>{}))};const f=g=>{var b;if((b=n.alreadyHaveEvent)!=null&&b.call(n,g))return!0;const h=r.has(g);return r.add(g),h},u=Promise.all(Object.entries(t).map(async(g,h,b)=>{if(b.indexOf(g)!==h){l(h,"duplicate url");return}let[d,p]=g;d=ke(d);let w;try{w=await this.ensureRelay(d,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0})}catch(k){l(h,(k==null?void 0:k.message)||String(k));return}let y=w.subscribe(p,{...n,oneose:()=>c(h),onclose:k=>l(h,k),alreadyHaveEvent:f,eoseTimeout:n.maxWait});o.push(y)}));return{async close(){await u,o.forEach(g=>{g.close()})}}}subscribeManyEose(t,n,r){const o=this.subscribeMany(t,n,{...r,oneose(){o.close()}});return o}async querySync(t,n,r){return new Promise(async o=>{const i=[];this.subscribeManyEose(t,[n],{...r,onevent(s){i.push(s)},onclose(s){o(i)}})})}async get(t,n,r){n.limit=1;const o=await this.querySync(t,n,r);return o.sort((i,s)=>s.created_at-i.created_at),o[0]||null}publish(t,n){return t.map(ke).map(async(r,o,i)=>{if(i.indexOf(r)!==o)return Promise.reject("duplicate url");let s=await this.ensureRelay(r);return s.publish(n).then(c=>{if(this.trackRelays){let a=this.seenOn.get(n.id);a||(a=new Set,this.seenOn.set(n.id,a)),a.add(s)}return c})})}listConnectionStatus(){const t=new Map;return this.relays.forEach((n,r)=>t.set(r,n.connected)),t}destroy(){this.relays.forEach(t=>t.close()),this.relays=new Map}},qr;try{qr=WebSocket}catch{}var Us=class extends Ps{constructor(){super({verifyEvent:_s,websocketImplementation:qr})}};function Ln(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function zr(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function Kr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function yt(e,...t){if(!Kr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function fe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Nn(e,t){yt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const et=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Cs=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function Pn(e){if(typeof e!="string")throw new Error(`string expected, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Kt(e){if(typeof e=="string")e=Pn(e);else if(Kr(e))e=e.slice();else throw new Error(`Uint8Array expected, got ${typeof e}`);return e}function Rs(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function Hs(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}const Ms=(e,t)=>(Object.assign(t,e),t),It=16,Un=new Uint8Array(16),St=et(Un),js=225,$s=(e,t,n,r)=>{const o=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^js<<24&-(o&1)}},mt=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function qs(e){e.reverse();const t=e[15]&1;let n=0;for(let r=0;r<e.length;r++){const o=e[r];e[r]=o>>>1|n,n=(o&1)<<7}return e[0]^=-t&225,e}const zs=e=>e>64*1024?8:e>1024?4:2;class Wr{constructor(t,n){this.blockLen=It,this.outputLen=It,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,t=Kt(t),yt(t,16);const r=Cs(t);let o=r.getUint32(0,!1),i=r.getUint32(4,!1),s=r.getUint32(8,!1),c=r.getUint32(12,!1);const a=[];for(let b=0;b<128;b++)a.push({s0:mt(o),s1:mt(i),s2:mt(s),s3:mt(c)}),{s0:o,s1:i,s2:s,s3:c}=$s(o,i,s,c);const l=zs(n||1024);if(![1,2,4,8].includes(l))throw new Error(`ghash: wrong window size=${l}, should be 2, 4 or 8`);this.W=l;const u=128/l,g=this.windowSize=2**l,h=[];for(let b=0;b<u;b++)for(let d=0;d<g;d++){let p=0,w=0,y=0,k=0;for(let U=0;U<l;U++){if(!(d>>>l-U-1&1))continue;const{s0:E,s1:_,s2:m,s3:O}=a[l*b+U];p^=E,w^=_,y^=m,k^=O}h.push({s0:p,s1:w,s2:y,s3:k})}this.t=h}_updateBlock(t,n,r,o){t^=this.s0,n^=this.s1,r^=this.s2,o^=this.s3;const{W:i,t:s,windowSize:c}=this;let a=0,l=0,f=0,u=0;const g=(1<<i)-1;let h=0;for(const b of[t,n,r,o])for(let d=0;d<4;d++){const p=b>>>8*d&255;for(let w=8/i-1;w>=0;w--){const y=p>>>i*w&g,{s0:k,s1:U,s2:N,s3:E}=s[h*c+y];a^=k,l^=U,f^=N,u^=E,h+=1}}this.s0=a,this.s1=l,this.s2=f,this.s3=u}update(t){t=Kt(t),fe(this);const n=et(t),r=Math.floor(t.length/It),o=t.length%It;for(let i=0;i<r;i++)this._updateBlock(n[i*4+0],n[i*4+1],n[i*4+2],n[i*4+3]);return o&&(Un.set(t.subarray(r*It)),this._updateBlock(St[0],St[1],St[2],St[3]),St.fill(0)),this}destroy(){const{t}=this;for(const n of t)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(t){fe(this),Nn(t,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=et(t);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,t}digest(){const t=new Uint8Array(It);return this.digestInto(t),this.destroy(),t}}class Ks extends Wr{constructor(t,n){t=Kt(t);const r=qs(t.slice());super(r,n),r.fill(0)}update(t){t=Kt(t),fe(this);const n=et(t),r=t.length%It,o=Math.floor(t.length/It);for(let i=0;i<o;i++)this._updateBlock(mt(n[i*4+3]),mt(n[i*4+2]),mt(n[i*4+1]),mt(n[i*4+0]));return r&&(Un.set(t.subarray(o*It)),this._updateBlock(mt(St[3]),mt(St[2]),mt(St[1]),mt(St[0])),St.fill(0)),this}digestInto(t){fe(this),Nn(t,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=et(t);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,t.reverse()}}function Dr(e){const t=(r,o)=>e(o,r.length).update(Kt(r)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(r,o)=>e(r,o),t}Dr((e,t)=>new Wr(e,t)),Dr((e,t)=>new Ks(e,t));const Wt=16,Ws=283;function Cn(e){return e<<1^Ws&-(e>>7)}function de(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Cn(e);return n}const Rn=(()=>{let e=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Cn(r))e[n]=r;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return t})(),Ds=Rn.map((e,t)=>Rn.indexOf(t)),Vs=e=>e<<24|e>>>8,Hn=e=>e<<8|e>>>24;function Vr(e,t){if(e.length!==256)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((l,f)=>t(e[f])),r=n.map(Hn),o=r.map(Hn),i=o.map(Hn),s=new Uint32Array(256*256),c=new Uint32Array(256*256),a=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let f=0;f<256;f++){const u=l*256+f;s[u]=n[l]^r[f],c[u]=o[l]^i[f],a[u]=e[l]<<8|e[f]}return{sbox:e,sbox2:a,T0:n,T1:r,T2:o,T3:i,T01:s,T23:c}}const Mn=Vr(Rn,e=>de(e,3)<<24|e<<16|e<<8|de(e,2)),Fr=Vr(Ds,e=>de(e,11)<<24|de(e,13)<<16|de(e,9)<<8|de(e,14)),Fs=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Cn(n))e[t]=n;return e})();function Gr(e){yt(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=Mn,r=et(e),o=r.length,i=c=>At(n,c,c,c,c),s=new Uint32Array(t+28);s.set(r);for(let c=o;c<s.length;c++){let a=s[c-1];c%o===0?a=i(Vs(a))^Fs[c/o-1]:o>6&&c%o===4&&(a=i(a)),s[c]=s[c-o]^a}return s}function Gs(e){const t=Gr(e),n=t.slice(),r=t.length,{sbox2:o}=Mn,{T0:i,T1:s,T2:c,T3:a}=Fr;for(let l=0;l<r;l+=4)for(let f=0;f<4;f++)n[l+f]=t[r-l-4+f];t.fill(0);for(let l=4;l<r-4;l++){const f=n[l],u=At(o,f,f,f,f);n[l]=i[u&255]^s[u>>>8&255]^c[u>>>16&255]^a[u>>>24]}return n}function Dt(e,t,n,r,o,i){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|i>>>24&255]}function At(e,t,n,r,o){return e[t&255|n&65280]|e[r>>>16&255|o>>>16&65280]<<16}function Yr(e,t,n,r,o){const{sbox2:i,T01:s,T23:c}=Mn;let a=0;t^=e[a++],n^=e[a++],r^=e[a++],o^=e[a++];const l=e.length/4-2;for(let b=0;b<l;b++){const d=e[a++]^Dt(s,c,t,n,r,o),p=e[a++]^Dt(s,c,n,r,o,t),w=e[a++]^Dt(s,c,r,o,t,n),y=e[a++]^Dt(s,c,o,t,n,r);t=d,n=p,r=w,o=y}const f=e[a++]^At(i,t,n,r,o),u=e[a++]^At(i,n,r,o,t),g=e[a++]^At(i,r,o,t,n),h=e[a++]^At(i,o,t,n,r);return{s0:f,s1:u,s2:g,s3:h}}function Ys(e,t,n,r,o){const{sbox2:i,T01:s,T23:c}=Fr;let a=0;t^=e[a++],n^=e[a++],r^=e[a++],o^=e[a++];const l=e.length/4-2;for(let b=0;b<l;b++){const d=e[a++]^Dt(s,c,t,o,r,n),p=e[a++]^Dt(s,c,n,t,o,r),w=e[a++]^Dt(s,c,r,n,t,o),y=e[a++]^Dt(s,c,o,r,n,t);t=d,n=p,r=w,o=y}const f=e[a++]^At(i,t,o,r,n),u=e[a++]^At(i,n,t,o,r),g=e[a++]^At(i,r,n,t,o),h=e[a++]^At(i,o,r,n,t);return{s0:f,s1:u,s2:g,s3:h}}function Zr(e,t){if(!t)return new Uint8Array(e);if(yt(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);return t}function Zs(e){if(yt(e),e.length%Wt!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Wt}`)}function Js(e,t,n){let r=e.length;const o=r%Wt;if(!t&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=et(e);if(t){let a=Wt-o;a||(a=Wt),r=r+a}const s=Zr(r,n),c=et(s);return{b:i,o:c,out:s}}function Qs(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=e.subarray(0,-r);for(let i=0;i<r;i++)if(e[n-i-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function Xs(e){const t=new Uint8Array(16),n=et(t);t.set(e);const r=Wt-e.length;for(let o=Wt-r;o<Wt;o++)t[o]=r;return n}const tc=Ms({blockSize:16,nonceLength:16},function(t,n,r={}){yt(t),yt(n,16);const o=!r.disablePadding;return{encrypt:(i,s)=>{const c=Gr(t),{b:a,o:l,out:f}=Js(i,o,s),u=et(n);let g=u[0],h=u[1],b=u[2],d=u[3],p=0;for(;p+4<=a.length;)g^=a[p+0],h^=a[p+1],b^=a[p+2],d^=a[p+3],{s0:g,s1:h,s2:b,s3:d}=Yr(c,g,h,b,d),l[p++]=g,l[p++]=h,l[p++]=b,l[p++]=d;if(o){const w=Xs(i.subarray(p*4));g^=w[0],h^=w[1],b^=w[2],d^=w[3],{s0:g,s1:h,s2:b,s3:d}=Yr(c,g,h,b,d),l[p++]=g,l[p++]=h,l[p++]=b,l[p++]=d}return c.fill(0),f},decrypt:(i,s)=>{Zs(i);const c=Gs(t),a=et(n),l=Zr(i.length,s),f=et(i),u=et(l);let g=a[0],h=a[1],b=a[2],d=a[3];for(let p=0;p+4<=f.length;){const w=g,y=h,k=b,U=d;g=f[p+0],h=f[p+1],b=f[p+2],d=f[p+3];const{s0:N,s1:E,s2:_,s3:m}=Ys(c,g,h,b,d);u[p++]=N^w,u[p++]=E^y,u[p++]=_^k,u[p++]=m^U}return c.fill(0),Qs(l,o)}}});/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function he(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function Tt(...e){const t=(o,i)=>s=>o(i(s)),n=Array.from(e).reverse().reduce((o,i)=>o?t(o,i.encode):i.encode,void 0),r=e.reduce((o,i)=>o?t(o,i.decode):i.decode,void 0);return{encode:n,decode:r}}function Ot(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(he(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function Lt(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function We(e,t="="){if(he(e),typeof t!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of n)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function Jr(e){if(typeof e!="function")throw new Error("normalize fn should be function");return{encode:t=>t,decode:t=>e(t)}}function Qr(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, 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(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],i=Array.from(e);for(i.forEach(s=>{if(he(s),s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,c=!0;for(let a=r;a<i.length;a++){const l=i[a],f=t*s+l;if(!Number.isSafeInteger(f)||t*s/t!==s||f-l!==t*s)throw new Error("convertRadix: carry overflow");if(s=f%n,i[a]=Math.floor(f/n),!Number.isSafeInteger(i[a])||i[a]*n+s!==f)throw new Error("convertRadix: carry overflow");if(c)i[a]?c=!1:r=a;else continue}if(o.push(s),c)break}for(let s=0;s<e.length-1&&e[s]===0;s++)o.push(0);return o.reverse()}const Xr=(e,t)=>t?Xr(t,e%t):e,De=(e,t)=>e+(t-Xr(e,t));function jn(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(De(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${De(t,n)}`);let o=0,i=0;const s=2**n-1,c=[];for(const a of e){if(he(a),a>=2**t)throw new Error(`convertRadix2: invalid data word=${a} from=${t}`);if(o=o<<t|a,i+t>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)c.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<<n-i&s,!r&&i>=t)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&c.push(o>>>0),c}function ec(e){return he(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Qr(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Qr(t,e,2**8))}}}function Vt(e,t=!1){if(he(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(De(8,e)>32||De(e,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 jn(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(jn(n,e,8,t))}}}function to(e){if(typeof e!="function")throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch{}}}const nc=Tt(Vt(4),Ot("0123456789ABCDEF"),Lt("")),rc=Tt(Vt(5),Ot("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),We(5),Lt(""));Tt(Vt(5),Ot("0123456789ABCDEFGHIJKLMNOPQRSTUV"),We(5),Lt("")),Tt(Vt(5),Ot("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Lt(""),Jr(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const Se=Tt(Vt(6),Ot("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),We(6),Lt("")),oc=Tt(Vt(6),Ot("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),We(6),Lt("")),$n=e=>Tt(ec(58),Ot(e),Lt("")),qn=$n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");$n("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),$n("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const eo=[0,2,3,5,6,7,9,10,11],ic={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=qn.encode(r).padStart(eo[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),o=eo.indexOf(r.length),i=qn.decode(r);for(let s=0;s<i.length-o;s++)if(i[s]!==0)throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(i.slice(i.length-o)))}return Uint8Array.from(t)}},zn=Tt(Ot("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Lt("")),no=[996825010,642813549,513874426,1027748829,705979059];function Ae(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<no.length;r++)(t>>r&1)===1&&(n^=no[r]);return n}function ro(e,t,n=1){const r=e.length;let o=1;for(let i=0;i<r;i++){const s=e.charCodeAt(i);if(s<33||s>126)throw new Error(`Invalid prefix (${e})`);o=Ae(o)^s>>5}o=Ae(o);for(let i=0;i<r;i++)o=Ae(o)^e.charCodeAt(i)&31;for(let i of t)o=Ae(o)^i;for(let i=0;i<6;i++)o=Ae(o);return o^=n,zn.encode(jn([o%2**30],30,5,!1))}function oo(e){const t=e==="bech32"?1:734539939,n=Vt(5),r=n.decode,o=n.encode,i=to(r);function s(f,u,g=90){if(typeof f!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);if(!Array.isArray(u)||u.length&&typeof u[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);const h=f.length+7+u.length;if(g!==!1&&h>g)throw new TypeError(`Length ${h} exceeds limit ${g}`);return f=f.toLowerCase(),`${f}1${zn.encode(u)}${ro(f,u,t)}`}function c(f,u=90){if(typeof f!="string")throw new Error(`bech32.decode input should be string, not ${typeof f}`);if(f.length<8||u!==!1&&f.length>u)throw new TypeError(`Wrong string length: ${f.length} (${f}). Expected (8..${u})`);const g=f.toLowerCase();if(f!==g&&f!==f.toUpperCase())throw new Error("String must be lowercase or uppercase");f=g;const h=f.lastIndexOf("1");if(h===0||h===-1)throw new Error('Letter "1" must be present between prefix and data only');const b=f.slice(0,h),d=f.slice(h+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const p=zn.decode(d).slice(0,-6),w=ro(b,p,t);if(!d.endsWith(w))throw new Error(`Invalid checksum in ${f}: expected "${w}"`);return{prefix:b,words:p}}const a=to(c);function l(f){const{prefix:u,words:g}=c(f,!1);return{prefix:u,words:g,bytes:r(g)}}return{encode:s,decode:c,decodeToBytes:l,decodeUnsafe:a,fromWords:r,fromWordsUnsafe:i,toWords:o}}const io=oo("bech32");oo("bech32m");const sc={encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)},cc=Tt(Vt(4),Ot("0123456789abcdef"),Lt(""),Jr(e=>{if(typeof e!="string"||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));`${Object.keys({utf8:sc,hex:cc,base16:nc,base32:rc,base64:Se,base64url:oc,base58:qn,base58xmr:ic}).join(", ")}`;const lt=(e,t)=>e[t++]&255|(e[t++]&255)<<8;class ac{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,t=Kt(t),yt(t,32);const n=lt(t,0),r=lt(t,2),o=lt(t,4),i=lt(t,6),s=lt(t,8),c=lt(t,10),a=lt(t,12),l=lt(t,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|i<<9)&8191,this.r[4]=(i>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|c<<2)&8191,this.r[7]=(c>>>11|a<<5)&8065,this.r[8]=(a>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let f=0;f<8;f++)this.pad[f]=lt(t,16+2*f)}process(t,n,r=!1){const o=r?0:2048,{h:i,r:s}=this,c=s[0],a=s[1],l=s[2],f=s[3],u=s[4],g=s[5],h=s[6],b=s[7],d=s[8],p=s[9],w=lt(t,n+0),y=lt(t,n+2),k=lt(t,n+4),U=lt(t,n+6),N=lt(t,n+8),E=lt(t,n+10),_=lt(t,n+12),m=lt(t,n+14);let O=i[0]+(w&8191),P=i[1]+((w>>>13|y<<3)&8191),R=i[2]+((y>>>10|k<<6)&8191),D=i[3]+((k>>>7|U<<9)&8191),q=i[4]+((U>>>4|N<<12)&8191),z=i[5]+(N>>>1&8191),x=i[6]+((N>>>14|E<<2)&8191),A=i[7]+((E>>>11|_<<5)&8191),L=i[8]+((_>>>8|m<<8)&8191),H=i[9]+(m>>>5|o),B=0,K=B+O*c+P*(5*p)+R*(5*d)+D*(5*b)+q*(5*h);B=K>>>13,K&=8191,K+=z*(5*g)+x*(5*u)+A*(5*f)+L*(5*l)+H*(5*a),B+=K>>>13,K&=8191;let V=B+O*a+P*c+R*(5*p)+D*(5*d)+q*(5*b);B=V>>>13,V&=8191,V+=z*(5*h)+x*(5*g)+A*(5*u)+L*(5*f)+H*(5*l),B+=V>>>13,V&=8191;let W=B+O*l+P*a+R*c+D*(5*p)+q*(5*d);B=W>>>13,W&=8191,W+=z*(5*b)+x*(5*h)+A*(5*g)+L*(5*u)+H*(5*f),B+=W>>>13,W&=8191;let X=B+O*f+P*l+R*a+D*c+q*(5*p);B=X>>>13,X&=8191,X+=z*(5*d)+x*(5*b)+A*(5*h)+L*(5*g)+H*(5*u),B+=X>>>13,X&=8191;let J=B+O*u+P*f+R*l+D*a+q*c;B=J>>>13,J&=8191,J+=z*(5*p)+x*(5*d)+A*(5*b)+L*(5*h)+H*(5*g),B+=J>>>13,J&=8191;let ot=B+O*g+P*u+R*f+D*l+q*a;B=ot>>>13,ot&=8191,ot+=z*c+x*(5*p)+A*(5*d)+L*(5*b)+H*(5*h),B+=ot>>>13,ot&=8191;let it=B+O*h+P*g+R*u+D*f+q*l;B=it>>>13,it&=8191,it+=z*a+x*c+A*(5*p)+L*(5*d)+H*(5*b),B+=it>>>13,it&=8191;let st=B+O*b+P*h+R*g+D*u+q*f;B=st>>>13,st&=8191,st+=z*l+x*a+A*c+L*(5*p)+H*(5*d),B+=st>>>13,st&=8191;let gt=B+O*d+P*b+R*h+D*g+q*u;B=gt>>>13,gt&=8191,gt+=z*f+x*l+A*a+L*c+H*(5*p),B+=gt>>>13,gt&=8191;let nt=B+O*p+P*d+R*b+D*h+q*g;B=nt>>>13,nt&=8191,nt+=z*u+x*f+A*l+L*a+H*c,B+=nt>>>13,nt&=8191,B=(B<<2)+B|0,B=B+K|0,K=B&8191,B=B>>>13,V+=B,i[0]=K,i[1]=V,i[2]=W,i[3]=X,i[4]=J,i[5]=ot,i[6]=it,i[7]=st,i[8]=gt,i[9]=nt}finalize(){const{h:t,pad:n}=this,r=new Uint16Array(10);let o=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=o,o=t[c]>>>13,t[c]&=8191;t[0]+=o*5,o=t[0]>>>13,t[0]&=8191,t[1]+=o,o=t[1]>>>13,t[1]&=8191,t[2]+=o,r[0]=t[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=t[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let i=(o^1)-1;for(let c=0;c<10;c++)r[c]&=i;i=~i;for(let c=0;c<10;c++)t[c]=t[c]&i|r[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let s=t[0]+n[0];t[0]=s&65535;for(let c=1;c<8;c++)s=(t[c]+n[c]|0)+(s>>>16)|0,t[c]=s&65535}update(t){fe(this);const{buffer:n,blockLen:r}=this;t=Kt(t);const o=t.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){for(;r<=o-i;i+=r)this.process(t,i);continue}n.set(t.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(t){fe(this),Nn(t,this),this.finished=!0;const{buffer:n,h:r}=this;let{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,!0)}this.finalize();let i=0;for(let s=0;s<8;s++)t[i++]=r[s]>>>0,t[i++]=r[s]>>>8;return t}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}}function lc(e){const t=(r,o)=>e(o).update(Kt(r)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}lc(e=>new ac(e));const uc=Pn("expand 16-byte k"),fc=Pn("expand 32-byte k"),dc=et(uc),hc=et(fc);function Y(e,t){return e<<t|e>>>32-t}function Kn(e){return e.byteOffset%4===0}const Ve=64,gc=16,so=2**32-1,co=new Uint32Array;function pc(e,t,n,r,o,i,s,c){const a=o.length,l=new Uint8Array(Ve),f=et(l),u=Kn(o)&&Kn(i),g=u?et(o):co,h=u?et(i):co;for(let b=0;b<a;s++){if(e(t,n,r,f,s,c),s>=so)throw new Error("arx: counter overflow");const d=Math.min(Ve,a-b);if(u&&d===Ve){const p=b/4;if(b%4!==0)throw new Error("arx: invalid block position");for(let w=0,y;w<gc;w++)y=p+w,h[y]=g[y]^f[w];b+=Ve;continue}for(let p=0,w;p<d;p++)w=b+p,i[w]=o[w]^l[p];b+=d}}function bc(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=Rs({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!="function")throw new Error("core must be a function");return Ln(o),Ln(s),zr(i),zr(n),(c,a,l,f,u=0)=>{yt(c),yt(a),yt(l);const g=l.length;if(f||(f=new Uint8Array(g)),yt(f),Ln(u),u<0||u>=so)throw new Error("arx: counter overflow");if(f.length<g)throw new Error(`arx: output (${f.length}) is shorter than data (${g})`);const h=[];let b=c.length,d,p;if(b===32)d=c.slice(),h.push(d),p=hc;else if(b===16&&n)d=new Uint8Array(32),d.set(c),d.set(c,16),p=dc,h.push(d);else throw new Error(`arx: invalid 32-byte key, got length=${b}`);Kn(a)||(a=a.slice(),h.push(a));const w=et(d);if(r){if(a.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(p,w,et(a.subarray(0,16)),w),a=a.subarray(16)}const y=16-o;if(y!==a.length)throw new Error(`arx: nonce must be ${y} or 16 bytes`);if(y!==12){const U=new Uint8Array(12);U.set(a,i?0:12-a.length),a=U,h.push(a)}const k=et(a);for(pc(e,p,w,k,l,f,u,s);h.length>0;)h.pop().fill(0);return f}}function wc(e,t,n,r,o,i=20){let s=e[0],c=e[1],a=e[2],l=e[3],f=t[0],u=t[1],g=t[2],h=t[3],b=t[4],d=t[5],p=t[6],w=t[7],y=o,k=n[0],U=n[1],N=n[2],E=s,_=c,m=a,O=l,P=f,R=u,D=g,q=h,z=b,x=d,A=p,L=w,H=y,B=k,K=U,V=N;for(let X=0;X<i;X+=2)E=E+P|0,H=Y(H^E,16),z=z+H|0,P=Y(P^z,12),E=E+P|0,H=Y(H^E,8),z=z+H|0,P=Y(P^z,7),_=_+R|0,B=Y(B^_,16),x=x+B|0,R=Y(R^x,12),_=_+R|0,B=Y(B^_,8),x=x+B|0,R=Y(R^x,7),m=m+D|0,K=Y(K^m,16),A=A+K|0,D=Y(D^A,12),m=m+D|0,K=Y(K^m,8),A=A+K|0,D=Y(D^A,7),O=O+q|0,V=Y(V^O,16),L=L+V|0,q=Y(q^L,12),O=O+q|0,V=Y(V^O,8),L=L+V|0,q=Y(q^L,7),E=E+R|0,V=Y(V^E,16),A=A+V|0,R=Y(R^A,12),E=E+R|0,V=Y(V^E,8),A=A+V|0,R=Y(R^A,7),_=_+D|0,H=Y(H^_,16),L=L+H|0,D=Y(D^L,12),_=_+D|0,H=Y(H^_,8),L=L+H|0,D=Y(D^L,7),m=m+q|0,B=Y(B^m,16),z=z+B|0,q=Y(q^z,12),m=m+q|0,B=Y(B^m,8),z=z+B|0,q=Y(q^z,7),O=O+P|0,K=Y(K^O,16),x=x+K|0,P=Y(P^x,12),O=O+P|0,K=Y(K^O,8),x=x+K|0,P=Y(P^x,7);let W=0;r[W++]=s+E|0,r[W++]=c+_|0,r[W++]=a+m|0,r[W++]=l+O|0,r[W++]=f+P|0,r[W++]=u+R|0,r[W++]=g+D|0,r[W++]=h+q|0,r[W++]=b+z|0,r[W++]=d+x|0,r[W++]=p+A|0,r[W++]=w+L|0,r[W++]=y+H|0,r[W++]=k+B|0,r[W++]=U+K|0,r[W++]=N+V|0}const ao=bc(wc,{counterRight:!1,counterLength:4,allowShortKeys:!1});class lo extends lr{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,kt.hash(t);const r=xe(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return kt.exists(this),this.iHash.update(t),this}digestInto(t){kt.exists(this),kt.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Fe=(e,t,n)=>new lo(e,t).update(n).digest();Fe.create=(e,t)=>new lo(e,t);function yc(e,t,n){return kt.hash(e),n===void 0&&(n=new Uint8Array(e.outputLen)),Fe(e,xe(n),xe(t))}const Wn=new Uint8Array([0]),uo=new Uint8Array;function mc(e,t,n,r=32){if(kt.hash(e),kt.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/e.outputLen);n===void 0&&(n=uo);const i=new Uint8Array(o*e.outputLen),s=Fe.create(e,t),c=s._cloneInto(),a=new Uint8Array(s.outputLen);for(let l=0;l<o;l++)Wn[0]=l+1,c.update(l===0?uo:a).update(n).update(Wn).digestInto(a),i.set(a,e.outputLen*l),s._cloneInto(c);return s.destroy(),c.destroy(),a.fill(0),Wn.fill(0),i.slice(0,r)}var ne=Symbol("verified"),xc=e=>e instanceof Object;function vc(e){if(!xc(e)||typeof e.kind!="number"||typeof e.content!="string"||typeof e.created_at!="number"||typeof e.pubkey!="string"||!e.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}var fo=new TextDecoder("utf-8"),ho=new TextEncoder;function Be(e){e.indexOf("://")===-1&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),(t.port==="80"&&t.protocol==="ws:"||t.port==="443"&&t.protocol==="wss:")&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}var Ec=class{constructor(e){v(this,"value");v(this,"next",null);v(this,"prev",null);this.value=e}},_c=class{constructor(){v(this,"first");v(this,"last");this.first=null,this.last=null}enqueue(e){const t=new Ec(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const t=this.first;return this.first=null,this.last=null,t.value}const e=this.first;return this.first=e.next,e.value}},kc=class{generateSecretKey(){return ft.utils.randomPrivateKey()}getPublicKey(e){return dt(ft.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=dt(ft.getPublicKey(t)),n.id=Dn(n),n.sig=dt(ft.sign(Dn(n),t)),n[ne]=!0,n}verifyEvent(e){if(typeof e[ne]=="boolean")return e[ne];const t=Dn(e);if(t!==e.id)return e[ne]=!1,!1;try{const n=ft.verify(e.sig,t,e.pubkey);return e[ne]=n,n}catch{return e[ne]=!1,!1}}};function Sc(e){if(!vc(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function Dn(e){let t=le(ho.encode(Sc(e)));return dt(t)}var Ge=new kc;Ge.generateSecretKey;var Ac=Ge.getPublicKey,Bc=Ge.finalizeEvent,go=Ge.verifyEvent;async function Ic(e,t,n){const r=e instanceof Uint8Array?dt(e):e;let[o,i]=n.split("?iv="),s=Ee.getSharedSecret(r,"02"+t),c=Tc(s),a=Se.decode(i),l=Se.decode(o),f=tc(c,a).decrypt(l);return fo.decode(f)}function Tc(e){return e.slice(1,33)}var po=1,bo=65535;function Oc(e,t){const n=Ee.getSharedSecret(e,"02"+t).subarray(1,33);return yc(le,n,"nip44-v2")}function wo(e,t){const n=mc(le,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function yo(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)}function Lc(e){if(!Number.isSafeInteger(e)||e<po||e>bo)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t}function Nc(e){const t=ho.encode(e),n=t.length,r=Lc(n),o=new Uint8Array(yo(n)-n);return ln(r,t,o)}function Pc(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(t<po||t>bo||n.length!==t||e.length!==2+yo(t))throw new Error("invalid padding");return fo.decode(n)}function mo(e,t,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=ln(n,t);return Fe(le,e,r)}function Uc(e){if(typeof e!="string")throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if(e[0]==="#")throw new Error("unknown encryption version");let n;try{n=Se.decode(e)}catch(i){throw new Error("invalid base64: "+i.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function Cc(e,t,n=ai(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=wo(t,n),s=Nc(e),c=ao(r,o,s),a=mo(i,c,n);return Se.encode(ln(new Uint8Array([2]),n,c,a))}function Rc(e,t){const{nonce:n,ciphertext:r,mac:o}=Uc(e),{chacha_key:i,chacha_nonce:s,hmac_key:c}=wo(t,n),a=mo(c,r,n);if(!Hs(a,o))throw new Error("invalid MAC");const l=ao(i,s,r);return Pc(l)}var Hc=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,Mc;try{Mc=fetch}catch{}var jc=22242,xo=24133;function $c(e,t){if(e.ids&&e.ids.indexOf(t.id)===-1||e.kinds&&e.kinds.indexOf(t.kind)===-1||e.authors&&e.authors.indexOf(t.pubkey)===-1)return!1;for(let n in e)if(n[0]==="#"){let r=n.slice(1),o=e[`#${r}`];if(o&&!t.tags.find(([i,s])=>i===n.slice(1)&&o.indexOf(s)!==-1))return!1}return!(e.since&&t.created_at<e.since||e.until&&t.created_at>e.until)}function qc(e,t){for(let n=0;n<e.length;n++)if($c(e[n],t))return!0;return!1}function zc(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}function Kc(e){let t=e.slice(0,22).indexOf('"EVENT"');if(t===-1)return null;let n=e.slice(t+7+1).indexOf('"');if(n===-1)return null;let r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(o===-1)return null;let i=r+1+o;return e.slice(r+1,i)}function Wc(e,t){return{kind:jc,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}async function Dc(){return new Promise(e=>{const t=new MessageChannel,n=()=>{t.port1.removeEventListener("message",n),e()};t.port1.addEventListener("message",n),t.port2.postMessage(0),t.port1.start()})}var Vc=e=>(e[ne]=!0,!0),vo=class{constructor(e,t){v(this,"url");v(this,"_connected",!1);v(this,"onclose",null);v(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));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 _c);v(this,"queueRunning",!1);v(this,"challenge");v(this,"serial",0);v(this,"verifyEvent");v(this,"_WebSocket");this.url=Be(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket}static async connect(e,t){const n=new vo(e,t);return await n.connect(),n}closeAllSubscriptions(e){for(let[t,n]of this.openSubs)n.close(e);this.openSubs.clear();for(let[t,n]of this.openEventPublishes)n.reject(new Error(e));this.openEventPublishes.clear();for(let[t,n]of this.openCountRequests)n.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.connectionPromise=new Promise((e,t)=>{this.connectionTimeoutHandle=setTimeout(()=>{var n;t("connection timed out"),this.connectionPromise=void 0,(n=this.onclose)==null||n.call(this),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(n){t(n);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,e()},this.ws.onerror=n=>{var r;t(n.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{var n;this._connected&&(this._connected=!1,this.connectionPromise=void 0,(n=this.onclose)==null||n.call(this),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await Dc();this.queueRunning=!1}handleNext(){var n,r,o;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=Kc(e);if(t){const i=this.openSubs.get(t);if(!i)return;const s=zc(e,"id"),c=(n=i.alreadyHaveEvent)==null?void 0:n.call(i,s);if((r=i.receivedEvent)==null||r.call(i,this,s),c)return}try{let i=JSON.parse(e);switch(i[0]){case"EVENT":{const s=this.openSubs.get(i[1]),c=i[2];this.verifyEvent(c)&&qc(s.filters,c)&&s.onevent(c);return}case"COUNT":{const s=i[1],c=i[2],a=this.openCountRequests.get(s);a&&(a.resolve(c.count),this.openCountRequests.delete(s));return}case"EOSE":{const s=this.openSubs.get(i[1]);if(!s)return;s.receivedEose();return}case"OK":{const s=i[1],c=i[2],a=i[3],l=this.openEventPublishes.get(s);l&&(clearTimeout(l.timeout),c?l.resolve(a):l.reject(new Error(a)),this.openEventPublishes.delete(s));return}case"CLOSED":{const s=i[1],c=this.openSubs.get(s);if(!c)return;c.closed=!0,c.close(i[2]);return}case"NOTICE":this.onnotice(i[1]);return;case"AUTH":{this.challenge=i[1],(o=this._onauth)==null||o.call(this,i[1]);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{var t;(t=this.ws)==null||t.send(e)})}async auth(e){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const t=await e(Wc(this.url,this.challenge)),n=new Promise((r,o)=>{const i=setTimeout(()=>{const s=this.openEventPublishes.get(t.id);s&&(s.reject(new Error("auth timed out")),this.openEventPublishes.delete(t.id))},this.publishTimeout);this.openEventPublishes.set(t.id,{resolve:r,reject:o,timeout:i})});return this.send('["AUTH",'+JSON.stringify(t)+"]"),n}async publish(e){const t=new Promise((n,r)=>{const o=setTimeout(()=>{const i=this.openEventPublishes.get(e.id);i&&(i.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:n,reject:r,timeout:o})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;const n=(t==null?void 0:t.id)||"count:"+this.serial,r=new Promise((o,i)=>{this.openCountRequests.set(n,{resolve:o,reject:i})});return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),r}subscribe(e,t){const n=this.prepareSubscription(e,t);return n.fire(),n}prepareSubscription(e,t){this.serial++;const n=t.id||(t.label?t.label+":":"sub:")+this.serial,r=new Fc(this,n,e,t);return this.openSubs.set(n,r),r}close(){var e;this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(e=this.ws)==null||e.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Fc=class{constructor(e,t,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=e,this.filters=n,this.id=t,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||e.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(o=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,o)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var e;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(e=this.oneose)==null||e.call(this))}close(e="closed by caller"){var t;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),(t=this.onclose)==null||t.call(this,e)}},Gc=class{constructor(e){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=e.verifyEvent,this._WebSocket=e.websocketImplementation}async ensureRelay(e,t){e=Be(e);let n=this.relays.get(e);return n||(n=new vo(e,{verifyEvent:this.trustedRelayURLs.has(e)?Vc:this.verifyEvent,websocketImplementation:this._WebSocket}),t!=null&&t.connectionTimeout&&(n.connectionTimeout=t.connectionTimeout),this.relays.set(e,n)),await n.connect(),n}close(e){e.map(Be).forEach(t=>{var n;(n=this.relays.get(t))==null||n.close()})}subscribeMany(e,t,n){return this.subscribeManyMap(Object.fromEntries(e.map(r=>[r,t])),n)}subscribeManyMap(e,t){this.trackRelays&&(t.receivedEvent=(u,g)=>{let h=this.seenOn.get(g);h||(h=new Set,this.seenOn.set(g,h)),h.add(u)});const n=new Set,r=[],o=Object.keys(e).length,i=[];let s=u=>{var g;i[u]||(i[u]=!0,i.filter(h=>h).length===o&&((g=t.oneose)==null||g.call(t),s=()=>{}))};const c=[];let a=(u,g)=>{var h;c[u]||(s(u),c[u]=g,c.filter(b=>b).length===o&&((h=t.onclose)==null||h.call(t,c),a=()=>{}))};const l=u=>{var h;if((h=t.alreadyHaveEvent)!=null&&h.call(t,u))return!0;const g=n.has(u);return n.add(u),g},f=Promise.all(Object.entries(e).map(async(u,g,h)=>{if(h.indexOf(u)!==g){a(g,"duplicate url");return}let[b,d]=u;b=Be(b);let p;try{p=await this.ensureRelay(b,{connectionTimeout:t.maxWait?Math.max(t.maxWait*.8,t.maxWait-1e3):void 0})}catch(y){a(g,(y==null?void 0:y.message)||String(y));return}let w=p.subscribe(d,{...t,oneose:()=>s(g),onclose:y=>a(g,y),alreadyHaveEvent:l,eoseTimeout:t.maxWait});r.push(w)}));return{async close(){await f,r.forEach(u=>{u.close()})}}}subscribeManyEose(e,t,n){const r=this.subscribeMany(e,t,{...n,oneose(){r.close()}});return r}async querySync(e,t,n){return new Promise(async r=>{const o=[];this.subscribeManyEose(e,[t],{...n,onevent(i){o.push(i)},onclose(i){r(o)}})})}async get(e,t,n){t.limit=1;const r=await this.querySync(e,t,n);return r.sort((o,i)=>i.created_at-o.created_at),r[0]||null}publish(e,t){return e.map(Be).map(async(n,r,o)=>{if(o.indexOf(n)!==r)return Promise.reject("duplicate url");let i=await this.ensureRelay(n);return i.publish(t).then(s=>{if(this.trackRelays){let c=this.seenOn.get(t.id);c||(c=new Set,this.seenOn.set(t.id,c)),c.add(i)}return s})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((t,n)=>e.set(n,t.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}},Eo;try{Eo=WebSocket}catch{}var Yc=class extends Gc{constructor(){super({verifyEvent:go,websocketImplementation:Eo})}},_o;try{_o=fetch}catch{}var Ye=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function Zc(e){let t=e.match(Ye);if(t)try{const n=t[1],r=new URLSearchParams(t[2]);return{pubkey:n,relays:r.getAll("relay"),secret:r.get("secret")}}catch{}return Jc(e)}async function Jc(e){const t=e.match(Hc);if(!t)return null;const[n,r="_",o]=t;try{const i=`https://${o}/.well-known/nostr.json?name=${r}`,s=await(await _o(i,{redirect:"error"})).json();let c=s.names[r],a=s.nip46[c]||[];return{pubkey:c,relays:a,secret:null}}catch{return null}}var Qc=class{constructor(e,t,n={}){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");if(t.relays.length===0)throw new Error("no relays are specified for this bunker");this.pool=n.pool||new Yc,this.secretKey=e,this.conversationKey=Oc(e,t.pubkey),this.bp=t,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:[xo],authors:[t.pubkey],"#p":[Ac(this.secretKey)]}],{async onevent(s){let c;try{c=JSON.parse(Rc(s.content,i))}catch{c=JSON.parse(await Ic(e,s.pubkey,s.content))}const{id:a,result:l,error:f}=c;if(l==="auth_url"&&o[a]){delete o[a],n.onauth?n.onauth(f):console.warn(`nostr-tools/nip46: remote signer ${t.pubkey} tried to send an "auth_url"='${f}' but there was no onauth() callback configured.`);return}let u=r[a];u&&(f?u.reject(f):l&&u.resolve(l),delete r[a])}}),this.isOpen=!0}async close(){this.isOpen=!1,this.subCloser.close()}async sendRequest(e,t){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=Cc(JSON.stringify({id:o,method:e,params:t}),this.conversationKey),s=Bc({kind:xo,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(o){r(o)}})}async ping(){let e=await this.sendRequest("ping",[]);if(e!=="pong")throw new Error(`result is not pong: ${e}`)}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(e){let t=await this.sendRequest("sign_event",[JSON.stringify(e)]),n=JSON.parse(t);if(go(n))return n;throw new Error(`event returned from bunker is improperly signed: ${JSON.stringify(n)}`)}async nip04Encrypt(e,t){return await this.sendRequest("nip04_encrypt",[e,t])}async nip04Decrypt(e,t){return await this.sendRequest("nip04_decrypt",[e,t])}async nip44Encrypt(e,t){return await this.sendRequest("nip44_encrypt",[e,t])}async nip44Decrypt(e,t){return await this.sendRequest("nip44_decrypt",[e,t])}},Xc=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,ta;try{ta=fetch}catch{}new TextDecoder("utf-8"),new TextEncoder;var ea=5e3;function na(e){return oa("npub",ar(e))}function ra(e,t){let n=io.toWords(t);return io.encode(e,n,ea)}function oa(e,t){return ra(e,t)}const ge=[];function ia(e,t=$){let n;const r=new Set;function o(c){if(Je(e,c)&&(e=c,n)){const a=!ge.length;for(const l of r)l[1](),ge.push(l,e);if(a){for(let l=0;l<ge.length;l+=2)ge[l][0](ge[l+1]);ge.length=0}}}function i(c){o(c(e))}function s(c,a=$){const l=[c,a];return r.add(l),r.size===1&&(n=t(o,i)||$),c(e),()=>{r.delete(l),r.size===0&&n&&(n(),n=null)}}return{set:o,update:i,subscribe:s}}const sa=e=>{const{subscribe:t,set:n}=ia(void 0,()=>{const r=window.matchMedia(e);n(r.matches);const o=()=>n(r.matches);return r.addEventListener("change",o),()=>{r.removeEventListener("change",o)}});return{subscribe:t}};function ca(e){let t,n,r;return{c(){t=Qe("svg"),n=Qe("circle"),r=Qe("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(t,"class","ml-2 h-5 w-5 animate-spin text-white"),S(t,"xmlns","http://www.w3.org/2000/svg"),S(t,"fill","none"),S(t,"viewBox","0 0 24 24")},m(o,i){j(o,t,i),T(t,n),T(t,r)},p:$,i:$,o:$,d(o){o&&M(t)}}}class ko extends sr{constructor(t){super(),ir(this,t,null,ca,Je,{})}}const{window:Vn}=Fo;function aa(e){let t,n,r,o,i,s,c,a,l,f,u,g,h=!e[17]&&!e[10]&&!e[11]&&!e[12]&&So(e);const b=[wa,ba,pa,ga,ha,da,fa],d=[];function p(w,y){return w[10]?0:w[11]?1:w[12]?2:w[17]?3:w[15]?4:w[18]?6:5}return c=p(e),a=d[c]=b[c](e),{c(){t=C("div"),n=C("button"),r=G("⤫"),i=Z(),h&&h.c(),s=Z(),a.c(),S(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+e[0]+"-600"),S(t,"class",l="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-"+e[0]+"-800 from-"+e[0]+"-900 to-"+e[0]+"-700 "+e[23])},m(w,y){j(w,t,y),T(t,n),T(n,r),T(t,i),h&&h.m(t,null),T(t,s),d[c].m(t,null),f=!0,u||(g=ct(n,"click",function(){Ze(e[17]?e[28]:e[26])&&(e[17]?e[28]:e[26]).apply(this,arguments)}),u=!0)},p(w,y){e=w,(!f||y[0]&1&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+e[0]+"-600"))&&S(n,"class",o),!e[17]&&!e[10]&&!e[11]&&!e[12]?h?h.p(e,y):(h=So(e),h.c(),h.m(t,s)):h&&(h.d(1),h=null);let k=c;c=p(e),c===k?d[c].p(e,y):(Ne(),vt(d[k],1,1,()=>{d[k]=null}),Pe(),a=d[c],a?a.p(e,y):(a=d[c]=b[c](e),a.c()),xt(a,1),a.m(t,null)),(!f||y[0]&8388609&&l!==(l="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-"+e[0]+"-800 from-"+e[0]+"-900 to-"+e[0]+"-700 "+e[23]))&&S(t,"class",l)},i(w){f||(xt(a),f=!0)},o(w){vt(a),f=!1},d(w){w&&M(t),h&&h.d(),d[c].d(),u=!1,g()}}}function la(e){let t,n,r,o,i;const s=[Sa,ka,_a,Ea],c=[];function a(l,f){return l[9]?0:l[18]?l[2]?3:2:1}return n=a(e),r=c[n]=s[n](e),{c(){t=C("div"),r.c(),S(t,"class",o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+e[0]+"-700 hover:bg-"+e[0]+"-800 "+e[23])},m(l,f){j(l,t,f),c[n].m(t,null),i=!0},p(l,f){let u=n;n=a(l),n===u?c[n].p(l,f):(Ne(),vt(c[u],1,1,()=>{c[u]=null}),Pe(),r=c[n],r?r.p(l,f):(r=c[n]=s[n](l),r.c()),xt(r,1),r.m(t,null)),(!i||f[0]&8388609&&o!==(o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+l[0]+"-700 hover:bg-"+l[0]+"-800 "+l[23]))&&S(t,"class",o)},i(l){i||(xt(r),i=!0)},o(l){vt(r),i=!1},d(l){l&&M(t),c[n].d()}}}function ua(e){return{c:$,m:$,p:$,i:$,o:$,d:$}}function So(e){let t,n,r,o,i;return{c(){t=C("button"),n=G("?"),S(t,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+e[0]+"-600")},m(s,c){j(s,t,c),T(t,n),o||(i=ct(t,"click",e[27]),o=!0)},p(s,c){c[0]&1&&r!==(r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+s[0]+"-600")&&S(t,"class",r)},d(s){s&&M(t),o=!1,i()}}}function fa(e){let t,n,r,o,i,s,c=e[18].npub+"",a,l,f,u,g,h,b,d,p,w,y,k=jr(e[8])+"",U,N,E,_=(e[18].picture||e[18].name)&&Ao(e);return{c(){t=C("div"),n=C("div"),n.textContent="You are connected to Nostr as",r=Z(),o=C("a"),_&&_.c(),i=Z(),s=C("div"),a=G(c),f=Z(),u=C("button"),g=G("Disconnect"),b=Z(),d=C("div"),p=G("This webpage is using the public key:"),w=C("br"),y=Z(),U=G(k),S(n,"class","mb-4 text-sm"),S(s,"class","block break-all"),S(o,"target","_blank"),S(o,"href",l="https://nosta.me/"+e[18].npub),S(o,"class","group text-white no-underline"),S(t,"class","text-center"),S(u,"class",h="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+e[0]+"-900 hover:bg-"+e[0]+"-950"),S(d,"class","mt-6 block break-all text-center text-sm")},m(m,O){j(m,t,O),T(t,n),T(t,r),T(t,o),_&&_.m(o,null),T(o,i),T(o,s),T(s,a),j(m,f,O),j(m,u,O),T(u,g),j(m,b,O),j(m,d,O),T(d,p),T(d,w),T(d,y),T(d,U),N||(E=ct(u,"click",e[30]),N=!0)},p(m,O){m[18].picture||m[18].name?_?_.p(m,O):(_=Ao(m),_.c(),_.m(o,i)):_&&(_.d(1),_=null),O[0]&262144&&c!==(c=m[18].npub+"")&&Ht(a,c),O[0]&262144&&l!==(l="https://nosta.me/"+m[18].npub)&&S(o,"href",l),O[0]&1&&h!==(h="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+m[0]+"-900 hover:bg-"+m[0]+"-950")&&S(u,"class",h),O[0]&256&&k!==(k=jr(m[8])+"")&&Ht(U,k)},i:$,o:$,d(m){m&&(M(t),M(f),M(u),M(b),M(d)),_&&_.d(),N=!1,E()}}}function da(e){let t,n,r,o,i,s,c,a,l,f,u,g,h,b,d,p,w,y=e[16]&&To(e);const k=[ma,ya],U=[];function N(m,O){return m[9]?0:1}a=N(e),l=U[a]=k[a](e);let E=e[9]&&e[13]&&Oo(e),_=!e[9]&&Lo(e);return{c(){t=C("div"),t.textContent="How do you want to connect to Nostr?",n=Z(),r=C("form"),o=C("input"),i=Z(),y&&y.c(),s=Z(),c=C("button"),l.c(),g=Z(),E&&E.c(),h=Z(),_&&_.c(),b=Xn(),S(t,"class","text-center text-lg"),S(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),S(o,"placeholder","user@provider or bunker://..."),o.autofocus=!0,o.disabled=e[9],S(o,"autocapitalize","none"),S(c,"class",f="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-"+e[0]+"-900 hover:bg-"+e[0]+"-950"),c.disabled=u=!e[22]||e[9],S(r,"class","mb-1 mt-4 flex flex-col")},m(m,O){j(m,t,O),j(m,n,O),j(m,r,O),T(r,o),e[44](o),tr(o,e[4]),T(r,i),y&&y.m(r,null),T(r,s),T(r,c),U[a].m(c,null),T(r,g),E&&E.m(r,null),j(m,h,O),_&&_.m(m,O),j(m,b,O),d=!0,o.focus(),p||(w=[ct(o,"input",e[45]),ct(r,"submit",e[29])],p=!0)},p(m,O){(!d||O[0]&512)&&(o.disabled=m[9]),O[0]&16&&o.value!==m[4]&&tr(o,m[4]),m[16]?y?y.p(m,O):(y=To(m),y.c(),y.m(r,s)):y&&(y.d(1),y=null);let P=a;a=N(m),a!==P&&(Ne(),vt(U[P],1,1,()=>{U[P]=null}),Pe(),l=U[a],l||(l=U[a]=k[a](m),l.c()),xt(l,1),l.m(c,null)),(!d||O[0]&1&&f!==(f="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-"+m[0]+"-900 hover:bg-"+m[0]+"-950"))&&S(c,"class",f),(!d||O[0]&4194816&&u!==(u=!m[22]||m[9]))&&(c.disabled=u),m[9]&&m[13]?E?E.p(m,O):(E=Oo(m),E.c(),E.m(r,null)):E&&(E.d(1),E=null),m[9]?_&&(_.d(1),_=null):_?_.p(m,O):(_=Lo(m),_.c(),_.m(b.parentNode,b))},i(m){d||(xt(l),d=!0)},o(m){vt(l),d=!1},d(m){m&&(M(t),M(n),M(r),M(h),M(b)),e[44](null),y&&y.d(),U[a].d(),E&&E.d(),_&&_.d(m),p=!1,Rt(w)}}}function ha(e){let t,n,r,o,i,s,c,a,l,f,u,g,h,b,d;return{c(){t=C("div"),t.textContent="Create a Nostr account",n=Z(),r=C("div"),r.textContent=`To use this Nostr app you need a profile. The following button opens a
|
|
1
|
+
var Ll=Object.defineProperty;var Ul=(Xe,M,qe)=>M in Xe?Ll(Xe,M,{enumerable:!0,configurable:!0,writable:!0,value:qe}):Xe[M]=qe;var m=(Xe,M,qe)=>(Ul(Xe,typeof M!="symbol"?M+"":M,qe),qe);(function(){"use strict";var fi,di,hi,pi,gi;const Xe='*,: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}.text-xs{font-size:.75rem;line-height:1rem}.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:rgb(38 38 38 / var(--tw-text-opacity))}.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}}';function M(){}function qe(t){return t()}function br(){return Object.create(null)}function $e(t){t.forEach(qe)}function cn(t){return typeof t=="function"}function an(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let Ct;function lt(t,e){return t===e?!0:(Ct||(Ct=document.createElement("a")),Ct.href=e,t===Ct.href)}function wi(t){return Object.keys(t).length===0}function yi(t,...e){if(t==null){for(const r of e)r(void 0);return M}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function mi(t,e,n){t.$$.on_destroy.push(yi(e,n))}const vi=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function O(t,e){t.appendChild(e)}function $(t,e,n){t.insertBefore(e,n||null)}function q(t){t.parentNode&&t.parentNode.removeChild(t)}function H(t){return document.createElement(t)}function ln(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function G(t){return document.createTextNode(t)}function J(){return G(" ")}function un(){return G("")}function ce(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function S(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function xi(t){return Array.from(t.childNodes)}function Me(t,e){e=""+e,t.data!==e&&(t.data=e)}function wr(t,e){t.value=e??""}function yr(t,e,n){t.classList.toggle(e,!!n)}let St;function At(t){St=t}function Ei(){if(!St)throw new Error("Function called outside component initialization");return St}function _i(t){Ei().$$.on_mount.push(t)}const ut=[],Nt=[];let ft=[];const mr=[],ki=Promise.resolve();let fn=!1;function Si(){fn||(fn=!0,ki.then(vr))}function dn(t){ft.push(t)}const hn=new Set;let dt=0;function vr(){if(dt!==0)return;const t=St;do{try{for(;dt<ut.length;){const e=ut[dt];dt++,At(e),Ai(e.$$)}}catch(e){throw ut.length=0,dt=0,e}for(At(null),ut.length=0,dt=0;Nt.length;)Nt.pop()();for(let e=0;e<ft.length;e+=1){const n=ft[e];hn.has(n)||(hn.add(n),n())}ft.length=0}while(ut.length);for(;mr.length;)mr.pop()();fn=!1,hn.clear(),At(t)}function Ai(t){if(t.fragment!==null){t.update(),$e(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(dn)}}function Ti(t){const e=[],n=[];ft.forEach(r=>t.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),ft=e}const Rt=new Set;let et;function qt(){et={r:0,c:[],p:et}}function $t(){et.r||$e(et.c),et=et.p}function xe(t,e){t&&t.i&&(Rt.delete(t),t.i(e))}function Ee(t,e,n,r){if(t&&t.o){if(Rt.has(t))return;Rt.add(t),et.c.push(()=>{Rt.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function xr(t){t&&t.c()}function pn(t,e,n){const{fragment:r,after_update:o}=t.$$;r&&r.m(e,n),dn(()=>{const i=t.$$.on_mount.map(qe).filter(cn);t.$$.on_destroy?t.$$.on_destroy.push(...i):$e(i),t.$$.on_mount=[]}),o.forEach(dn)}function gn(t,e){const n=t.$$;n.fragment!==null&&(Ti(n.after_update),$e(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Ii(t,e){t.$$.dirty[0]===-1&&(ut.push(t),Si(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Er(t,e,n,r,o,i,s=null,c=[-1]){const a=St;At(t);const l=t.$$={fragment:null,ctx:[],props:i,update:M,not_equal:o,bound:br(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:br(),dirty:c,skip_bound:!1,root:e.target||a.$$.root};s&&s(l.root);let f=!1;if(l.ctx=n?n(t,e.props||{},(u,g,...h)=>{const p=h.length?h[0]:g;return l.ctx&&o(l.ctx[u],l.ctx[u]=p)&&(!l.skip_bound&&l.bound[u]&&l.bound[u](p),f&&Ii(t,u)),g}):[],l.update(),f=!0,$e(l.before_update),l.fragment=r?r(l.ctx):!1,e.target){if(e.hydrate){const u=xi(e.target);l.fragment&&l.fragment.l(u),u.forEach(q)}else l.fragment&&l.fragment.c();e.intro&&xe(t.$$.fragment),pn(t,e.target,e.anchor),vr()}At(a)}class _r{constructor(){m(this,"$$");m(this,"$$set")}$destroy(){gn(this,1),this.$destroy=M}$on(e,n){if(!cn(n))return M;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!wi(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Pi="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Pi);function Bi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var bn={exports:{}};function kr(t,e=100,n={}){if(typeof t!="function")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}=typeof n=="boolean"?{immediate:n}:n;let o,i,s,c,a;function l(){const u=Date.now()-c;if(u<e&&u>=0)s=setTimeout(l,e-u);else if(s=void 0,!r){const g=o,h=i;o=void 0,i=void 0,a=t.apply(g,h)}}const f=function(...u){if(o&&this!==o)throw new Error("Debounced method called with different contexts.");o=this,i=u,c=Date.now();const g=r&&!s;if(s||(s=setTimeout(l,e)),g){const h=o,p=i;o=void 0,i=void 0,a=t.apply(h,p)}return a};return f.clear=()=>{s&&(clearTimeout(s),s=void 0)},f.flush=()=>{if(!s)return;const u=o,g=i;o=void 0,i=void 0,a=t.apply(u,g),clearTimeout(s),s=void 0},f}bn.exports.debounce=kr,bn.exports=kr;var Oi=bn.exports;const Li=Bi(Oi),wn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const yn=t=>t instanceof Uint8Array,mn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),_e=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const Ui=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ee(t){if(!yn(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Ui[t[n]];return e}function Sr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,i=t.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function Hi(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Tt(t){if(typeof t=="string"&&(t=Hi(t)),!yn(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function ht(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!yn(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}let Ar=class{clone(){return this._cloneInto()}};function Tr(t){const e=r=>t().update(Tt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function vn(t=32){if(wn&&typeof wn.getRandomValues=="function")return wn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Ir(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Pr(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 Ci(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ir(t.outputLen),Ir(t.blockLen)}function Mt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ni(t,e){Pr(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const xn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Br=t=>t instanceof Uint8Array,En=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ke=(t,e)=>t<<32-e|t>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function Ri(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function _n(t){if(typeof t=="string"&&(t=Ri(t)),!Br(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function qi(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!Br(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class Or{clone(){return this._cloneInto()}}function $i(t){const e=r=>t().update(_n(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Lr(t=32){if(xn&&typeof xn.getRandomValues=="function")return xn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Mi(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),a=r?4:0,l=r?0:4;t.setUint32(e+a,s,r),t.setUint32(e+l,c,r)}let zi=class extends Or{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=En(this.buffer)}update(e){Mt(this);const{view:n,buffer:r,blockLen:o}=this;e=_n(e);const i=e.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const a=En(e);for(;o<=i-s;s+=o)this.process(a,s);continue}r.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Mt(this),Ni(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let u=s;u<o;u++)n[u]=0;Mi(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=En(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)c.setUint32(4*u,f[u],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return e.length=o,e.pos=c,e.finished=i,e.destroyed=s,o%n&&e.buffer.set(r),e}};const ji=(t,e,n)=>t&e^~t&n,Ki=(t,e,n)=>t&e^t&n^e&n,Wi=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ze=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),je=new Uint32Array(64);let Di=class extends zi{constructor(){super(64,32,8,!1),this.A=ze[0]|0,this.B=ze[1]|0,this.C=ze[2]|0,this.D=ze[3]|0,this.E=ze[4]|0,this.F=ze[5]|0,this.G=ze[6]|0,this.H=ze[7]|0}get(){const{A:e,B:n,C:r,D:o,E:i,F:s,G:c,H:a}=this;return[e,n,r,o,i,s,c,a]}set(e,n,r,o,i,s,c,a){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,n){for(let u=0;u<16;u++,n+=4)je[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const g=je[u-15],h=je[u-2],p=ke(g,7)^ke(g,18)^g>>>3,d=ke(h,17)^ke(h,19)^h>>>10;je[u]=d+je[u-7]+p+je[u-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:a,G:l,H:f}=this;for(let u=0;u<64;u++){const g=ke(c,6)^ke(c,11)^ke(c,25),h=f+g+ji(c,a,l)+Wi[u]+je[u]|0,d=(ke(r,2)^ke(r,13)^ke(r,22))+Ki(r,o,i)|0;f=l,l=a,a=c,c=s+h|0,s=i,i=o,o=r,r=h+d|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,o,i,s,c,a,l,f)}roundClean(){je.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const kn=$i(()=>new Di);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ur=BigInt(0),zt=BigInt(1),Vi=BigInt(2),jt=t=>t instanceof Uint8Array,Fi=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function pt(t){if(!jt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Fi[t[n]];return e}function Hr(t){const e=t.toString(16);return e.length&1?`0${e}`:e}function Sn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function gt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const o=r*2,i=t.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function he(t){return Sn(pt(t))}function An(t){if(!jt(t))throw new Error("Uint8Array expected");return Sn(pt(Uint8Array.from(t).reverse()))}function Ke(t,e){return gt(t.toString(16).padStart(e*2,"0"))}function Tn(t,e){return Ke(t,e).reverse()}function Gi(t){return gt(Hr(t))}function fe(t,e,n){let r;if(typeof e=="string")try{r=gt(e)}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(jt(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${t} expected ${n} bytes, got ${o}`);return r}function tt(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!jt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function Yi(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function Zi(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ji(t){let e;for(e=0;t>Ur;t>>=zt,e+=1);return e}function Qi(t,e){return t>>BigInt(e)&zt}const Xi=(t,e,n)=>t|(n?zt:Ur)<<BigInt(e),In=t=>(Vi<<BigInt(t-1))-zt,Pn=t=>new Uint8Array(t),Cr=t=>Uint8Array.from(t);function Nr(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Pn(t),o=Pn(t),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},c=(...u)=>n(o,r,...u),a=(u=Pn())=>{o=c(Cr([0]),u),r=c(),u.length!==0&&(o=c(Cr([1]),u),r=c())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const g=[];for(;u<e;){r=c();const h=r.slice();g.push(h),u+=r.length}return tt(...g)};return(u,g)=>{s(),a(u);let h;for(;!(h=g(l()));)a();return s(),h}}const es={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function It(t,e,n={}){const r=(o,i,s)=>{const c=es[i];if(typeof c!="function")throw new Error(`Invalid validator "${i}", expected function`);const a=t[o];if(!(s&&a===void 0)&&!c(a,t))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${i}`)};for(const[o,i]of Object.entries(e))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return t}const ts=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Qi,bitLen:Ji,bitMask:In,bitSet:Xi,bytesToHex:pt,bytesToNumberBE:he,bytesToNumberLE:An,concatBytes:tt,createHmacDrbg:Nr,ensureBytes:fe,equalBytes:Yi,hexToBytes:gt,hexToNumber:Sn,numberToBytesBE:Ke,numberToBytesLE:Tn,numberToHexUnpadded:Hr,numberToVarBytesBE:Gi,utf8ToBytes:Zi,validateObject:It},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ie=BigInt(0),te=BigInt(1),nt=BigInt(2),ns=BigInt(3),Bn=BigInt(4),Rr=BigInt(5),qr=BigInt(8);BigInt(9),BigInt(16);function ae(t,e){const n=t%e;return n>=ie?n:e+n}function rs(t,e,n){if(n<=ie||e<ie)throw new Error("Expected power/modulo > 0");if(n===te)return ie;let r=te;for(;e>ie;)e&te&&(r=r*t%n),t=t*t%n,e>>=te;return r}function be(t,e,n){let r=t;for(;e-- >ie;)r*=r,r%=n;return r}function On(t,e){if(t===ie||e<=ie)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=ae(t,e),r=e,o=ie,i=te;for(;n!==ie;){const c=r/n,a=r%n,l=o-i*c;r=n,n=a,o=i,i=l}if(r!==te)throw new Error("invert: does not exist");return ae(o,e)}function os(t){const e=(t-te)/nt;let n,r,o;for(n=t-te,r=0;n%nt===ie;n/=nt,r++);for(o=nt;o<t&&rs(o,e,t)!==t-te;o++);if(r===1){const s=(t+te)/Bn;return function(a,l){const f=a.pow(l,s);if(!a.eql(a.sqr(f),l))throw new Error("Cannot find square root");return f}}const i=(n+te)/nt;return function(c,a){if(c.pow(a,e)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=r,f=c.pow(c.mul(c.ONE,o),n),u=c.pow(a,i),g=c.pow(a,n);for(;!c.eql(g,c.ONE);){if(c.eql(g,c.ZERO))return c.ZERO;let h=1;for(let d=c.sqr(g);h<l&&!c.eql(d,c.ONE);h++)d=c.sqr(d);const p=c.pow(f,te<<BigInt(l-h-1));f=c.sqr(p),u=c.mul(u,p),g=c.mul(g,f),l=h}return u}}function is(t){if(t%Bn===ns){const e=(t+te)/Bn;return function(r,o){const i=r.pow(o,e);if(!r.eql(r.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%qr===Rr){const e=(t-Rr)/qr;return function(r,o){const i=r.mul(o,nt),s=r.pow(i,e),c=r.mul(o,s),a=r.mul(r.mul(c,nt),s),l=r.mul(c,r.sub(a,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return os(t)}const ss=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function cs(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=ss.reduce((r,o)=>(r[o]="function",r),e);return It(t,n)}function as(t,e,n){if(n<ie)throw new Error("Expected power > 0");if(n===ie)return t.ONE;if(n===te)return e;let r=t.ONE,o=e;for(;n>ie;)n&te&&(r=t.mul(r,o)),o=t.sqr(o),n>>=te;return r}function ls(t,e){const n=new Array(e.length),r=e.reduce((i,s,c)=>t.is0(s)?i:(n[c]=i,t.mul(i,s)),t.ONE),o=t.inv(r);return e.reduceRight((i,s,c)=>t.is0(s)?i:(n[c]=t.mul(i,n[c]),t.mul(i,s)),o),n}function $r(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function us(t,e,n=!1,r={}){if(t<=ie)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=$r(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=is(t),c=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:In(o),ZERO:ie,ONE:te,create:a=>ae(a,t),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return ie<=a&&a<t},is0:a=>a===ie,isOdd:a=>(a&te)===te,neg:a=>ae(-a,t),eql:(a,l)=>a===l,sqr:a=>ae(a*a,t),add:(a,l)=>ae(a+l,t),sub:(a,l)=>ae(a-l,t),mul:(a,l)=>ae(a*l,t),pow:(a,l)=>as(c,a,l),div:(a,l)=>ae(a*On(l,t),t),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>On(a,t),sqrt:r.sqrt||(a=>s(c,a)),invertBatch:a=>ls(c,a),cmov:(a,l,f)=>f?l:a,toBytes:a=>n?Tn(a,i):Ke(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return n?An(a):he(a)}});return Object.freeze(c)}function Mr(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function zr(t){const e=Mr(t);return e+Math.ceil(e/2)}function fs(t,e,n=!1){const r=t.length,o=Mr(e),i=zr(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=n?he(t):An(t),c=ae(s,e-te)+te;return n?Tn(c,o):Ke(c,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ds=BigInt(0),Ln=BigInt(1);function hs(t,e){const n=(o,i)=>{const s=i.negate();return o?s:i},r=o=>{const i=Math.ceil(e/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:n,unsafeLadder(o,i){let s=t.ZERO,c=o;for(;i>ds;)i&Ln&&(s=s.add(c)),c=c.double(),i>>=Ln;return s},precomputeWindow(o,i){const{windows:s,windowSize:c}=r(i),a=[];let l=o,f=l;for(let u=0;u<s;u++){f=l,a.push(f);for(let g=1;g<c;g++)f=f.add(l),a.push(f);l=f.double()}return a},wNAF(o,i,s){const{windows:c,windowSize:a}=r(o);let l=t.ZERO,f=t.BASE;const u=BigInt(2**o-1),g=2**o,h=BigInt(o);for(let p=0;p<c;p++){const d=p*a;let b=Number(s&u);s>>=h,b>a&&(b-=g,s+=Ln);const w=d,y=d+Math.abs(b)-1,E=p%2!==0,I=b<0;b===0?f=f.add(n(E,i[w])):l=l.add(n(I,i[y]))}return{p:l,f}},wNAFCached(o,i,s,c){const a=o._WINDOW_SIZE||1;let l=i.get(o);return l||(l=this.precomputeWindow(o,a),a!==1&&i.set(o,c(l))),this.wNAF(a,l,s)}}}function jr(t){return cs(t.Fp),It(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...$r(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ps(t){const e=jr(t);It(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(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:gs,hexToBytes:bs}=ts,rt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=rt;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:gs(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=rt,n=typeof t=="string"?bs(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:o,l:i}=rt._parseInt(n.subarray(2)),{d:s,l:c}=rt._parseInt(i);if(c.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(t){const e=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const f=l.toString(16);return f.length&1?`0${f}`:f},r=e(n(t.s)),o=e(n(t.r)),i=r.length/2,s=o.length/2,c=n(i),a=n(s);return`30${n(s+i+4)}02${a}${o}02${c}${r}`}},Pe=BigInt(0),we=BigInt(1);BigInt(2);const Kr=BigInt(3);BigInt(4);function ws(t){const e=ps(t),{Fp:n}=e,r=e.toBytes||((p,d,b)=>{const w=d.toAffine();return tt(Uint8Array.from([4]),n.toBytes(w.x),n.toBytes(w.y))}),o=e.fromBytes||(p=>{const d=p.subarray(1),b=n.fromBytes(d.subarray(0,n.BYTES)),w=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:b,y:w}});function i(p){const{a:d,b}=e,w=n.sqr(p),y=n.mul(w,p);return n.add(n.add(y,n.mul(p,d)),b)}if(!n.eql(n.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(p){return typeof p=="bigint"&&Pe<p&&p<e.n}function c(p){if(!s(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function a(p){const{allowedPrivateKeyLengths:d,nByteLength:b,wrapPrivateKey:w,n:y}=e;if(d&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=pt(p)),typeof p!="string"||!d.includes(p.length))throw new Error("Invalid key");p=p.padStart(b*2,"0")}let E;try{E=typeof p=="bigint"?p:he(fe("private key",p,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof p}`)}return w&&(E=ae(E,y)),c(E),E}const l=new Map;function f(p){if(!(p instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,b,w){if(this.px=d,this.py=b,this.pz=w,d==null||!n.isValid(d))throw new Error("x required");if(b==null||!n.isValid(b))throw new Error("y required");if(w==null||!n.isValid(w))throw new Error("z required")}static fromAffine(d){const{x:b,y:w}=d||{};if(!d||!n.isValid(b)||!n.isValid(w))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");const y=E=>n.eql(E,n.ZERO);return y(b)&&y(w)?u.ZERO:new u(b,w,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const b=n.invertBatch(d.map(w=>w.pz));return d.map((w,y)=>w.toAffine(b[y])).map(u.fromAffine)}static fromHex(d){const b=u.fromAffine(o(fe("pointHex",d)));return b.assertValidity(),b}static fromPrivateKey(d){return u.BASE.multiply(a(d))}_setWindowSize(d){this._WINDOW_SIZE=d,l.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:d,y:b}=this.toAffine();if(!n.isValid(d)||!n.isValid(b))throw new Error("bad point: x or y not FE");const w=n.sqr(b),y=i(d);if(!n.eql(w,y))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:d}=this.toAffine();if(n.isOdd)return!n.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);const{px:b,py:w,pz:y}=this,{px:E,py:I,pz:P}=d,k=n.eql(n.mul(b,P),n.mul(E,y)),B=n.eql(n.mul(w,P),n.mul(I,y));return k&&B}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b}=e,w=n.mul(b,Kr),{px:y,py:E,pz:I}=this;let P=n.ZERO,k=n.ZERO,B=n.ZERO,x=n.mul(y,y),C=n.mul(E,E),U=n.mul(I,I),N=n.mul(y,E);return N=n.add(N,N),B=n.mul(y,I),B=n.add(B,B),P=n.mul(d,B),k=n.mul(w,U),k=n.add(P,k),P=n.sub(C,k),k=n.add(C,k),k=n.mul(P,k),P=n.mul(N,P),B=n.mul(w,B),U=n.mul(d,U),N=n.sub(x,U),N=n.mul(d,N),N=n.add(N,B),B=n.add(x,x),x=n.add(B,x),x=n.add(x,U),x=n.mul(x,N),k=n.add(k,x),U=n.mul(E,I),U=n.add(U,U),x=n.mul(U,N),P=n.sub(P,x),B=n.mul(U,C),B=n.add(B,B),B=n.add(B,B),new u(P,k,B)}add(d){f(d);const{px:b,py:w,pz:y}=this,{px:E,py:I,pz:P}=d;let k=n.ZERO,B=n.ZERO,x=n.ZERO;const C=e.a,U=n.mul(e.b,Kr);let N=n.mul(b,E),D=n.mul(w,I),V=n.mul(y,P),K=n.add(b,w),v=n.add(E,I);K=n.mul(K,v),v=n.add(N,D),K=n.sub(K,v),v=n.add(b,y);let _=n.add(E,P);return v=n.mul(v,_),_=n.add(N,V),v=n.sub(v,_),_=n.add(w,y),k=n.add(I,P),_=n.mul(_,k),k=n.add(D,V),_=n.sub(_,k),x=n.mul(C,v),k=n.mul(U,V),x=n.add(k,x),k=n.sub(D,x),x=n.add(D,x),B=n.mul(k,x),D=n.add(N,N),D=n.add(D,N),V=n.mul(C,V),v=n.mul(U,v),D=n.add(D,V),V=n.sub(N,V),V=n.mul(C,V),v=n.add(v,V),N=n.mul(D,v),B=n.add(B,N),N=n.mul(_,v),k=n.mul(K,k),k=n.sub(k,N),N=n.mul(K,D),x=n.mul(_,x),x=n.add(x,N),new u(k,B,x)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return h.wNAFCached(this,l,d,b=>{const w=n.invertBatch(b.map(y=>y.pz));return b.map((y,E)=>y.toAffine(w[E])).map(u.fromAffine)})}multiplyUnsafe(d){const b=u.ZERO;if(d===Pe)return b;if(c(d),d===we)return this;const{endo:w}=e;if(!w)return h.unsafeLadder(this,d);let{k1neg:y,k1:E,k2neg:I,k2:P}=w.splitScalar(d),k=b,B=b,x=this;for(;E>Pe||P>Pe;)E&we&&(k=k.add(x)),P&we&&(B=B.add(x)),x=x.double(),E>>=we,P>>=we;return y&&(k=k.negate()),I&&(B=B.negate()),B=new u(n.mul(B.px,w.beta),B.py,B.pz),k.add(B)}multiply(d){c(d);let b=d,w,y;const{endo:E}=e;if(E){const{k1neg:I,k1:P,k2neg:k,k2:B}=E.splitScalar(b);let{p:x,f:C}=this.wNAF(P),{p:U,f:N}=this.wNAF(B);x=h.constTimeNegate(I,x),U=h.constTimeNegate(k,U),U=new u(n.mul(U.px,E.beta),U.py,U.pz),w=x.add(U),y=C.add(N)}else{const{p:I,f:P}=this.wNAF(b);w=I,y=P}return u.normalizeZ([w,y])[0]}multiplyAndAddUnsafe(d,b,w){const y=u.BASE,E=(P,k)=>k===Pe||k===we||!P.equals(y)?P.multiplyUnsafe(k):P.multiply(k),I=E(this,b).add(E(d,w));return I.is0()?void 0:I}toAffine(d){const{px:b,py:w,pz:y}=this,E=this.is0();d==null&&(d=E?n.ONE:n.inv(y));const I=n.mul(b,d),P=n.mul(w,d),k=n.mul(y,d);if(E)return{x:n.ZERO,y:n.ZERO};if(!n.eql(k,n.ONE))throw new Error("invZ was invalid");return{x:I,y:P}}isTorsionFree(){const{h:d,isTorsionFree:b}=e;if(d===we)return!0;if(b)return b(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:d,clearCofactor:b}=e;return d===we?this:b?b(u,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),r(u,this,d)}toHex(d=!0){return pt(this.toRawBytes(d))}}u.BASE=new u(e.Gx,e.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const g=e.nBitLength,h=hs(u,e.endo?Math.ceil(g/2):g);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:s}}function ys(t){const e=jr(t);return It(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ms(t){const e=ys(t),{Fp:n,n:r}=e,o=n.BYTES+1,i=2*n.BYTES+1;function s(v){return Pe<v&&v<n.ORDER}function c(v){return ae(v,r)}function a(v){return On(v,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:g}=ws({...e,toBytes(v,_,L){const R=_.toAffine(),A=n.toBytes(R.x),z=tt;return L?z(Uint8Array.from([_.hasEvenY()?2:3]),A):z(Uint8Array.from([4]),A,n.toBytes(R.y))},fromBytes(v){const _=v.length,L=v[0],R=v.subarray(1);if(_===o&&(L===2||L===3)){const A=he(R);if(!s(A))throw new Error("Point is not on curve");const z=u(A);let F=n.sqrt(z);const W=(F&we)===we;return(L&1)===1!==W&&(F=n.neg(F)),{x:A,y:F}}else if(_===i&&L===4){const A=n.fromBytes(R.subarray(0,n.BYTES)),z=n.fromBytes(R.subarray(n.BYTES,2*n.BYTES));return{x:A,y:z}}else throw new Error(`Point of length ${_} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=v=>pt(Ke(v,e.nByteLength));function p(v){const _=r>>we;return v>_}function d(v){return p(v)?c(-v):v}const b=(v,_,L)=>he(v.slice(_,L));class w{constructor(_,L,R){this.r=_,this.s=L,this.recovery=R,this.assertValidity()}static fromCompact(_){const L=e.nByteLength;return _=fe("compactSignature",_,L*2),new w(b(_,0,L),b(_,L,2*L))}static fromDER(_){const{r:L,s:R}=rt.toSig(fe("DER",_));return new w(L,R)}assertValidity(){if(!g(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!g(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(_){return new w(this.r,this.s,_)}recoverPublicKey(_){const{r:L,s:R,recovery:A}=this,z=B(fe("msgHash",_));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");const F=A===2||A===3?L+e.n:L;if(F>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const W=A&1?"03":"02",Q=l.fromHex(W+h(F)),oe=a(F),X=c(-z*oe),ue=c(R*oe),re=l.BASE.multiplyAndAddUnsafe(Q,X,ue);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return gt(this.toDERHex())}toDERHex(){return rt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return gt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const y={isValidPrivateKey(v){try{return f(v),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const v=zr(e.n);return fs(e.randomBytes(v),e.n)},precompute(v=8,_=l.BASE){return _._setWindowSize(v),_.multiply(BigInt(3)),_}};function E(v,_=!0){return l.fromPrivateKey(v).toRawBytes(_)}function I(v){const _=v instanceof Uint8Array,L=typeof v=="string",R=(_||L)&&v.length;return _?R===o||R===i:L?R===2*o||R===2*i:v instanceof l}function P(v,_,L=!0){if(I(v))throw new Error("first arg must be private key");if(!I(_))throw new Error("second arg must be public key");return l.fromHex(_).multiply(f(v)).toRawBytes(L)}const k=e.bits2int||function(v){const _=he(v),L=v.length*8-e.nBitLength;return L>0?_>>BigInt(L):_},B=e.bits2int_modN||function(v){return c(k(v))},x=In(e.nBitLength);function C(v){if(typeof v!="bigint")throw new Error("bigint expected");if(!(Pe<=v&&v<x))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Ke(v,e.nByteLength)}function U(v,_,L=N){if(["recovered","canonical"].some(se=>se in L))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:A}=e;let{lowS:z,prehash:F,extraEntropy:W}=L;z==null&&(z=!0),v=fe("msgHash",v),F&&(v=fe("prehashed msgHash",R(v)));const Q=B(v),oe=f(_),X=[C(oe),C(Q)];if(W!=null){const se=W===!0?A(n.BYTES):W;X.push(fe("extraEntropy",se))}const ue=tt(...X),re=Q;function ge(se){const ve=k(se);if(!g(ve))return;const Lt=a(ve),Ne=l.BASE.multiply(ve).toAffine(),pe=c(Ne.x);if(pe===Pe)return;const Je=c(Lt*c(re+pe*oe));if(Je===Pe)return;let Ut=(Ne.x===pe?0:2)|Number(Ne.y&we),Ie=Je;return z&&p(Je)&&(Ie=d(Je),Ut^=1),new w(pe,Ie,Ut)}return{seed:ue,k2sig:ge}}const N={lowS:e.lowS,prehash:!1},D={lowS:e.lowS,prehash:!1};function V(v,_,L=N){const{seed:R,k2sig:A}=U(v,_,L),z=e;return Nr(z.hash.outputLen,z.nByteLength,z.hmac)(R,A)}l.BASE._setWindowSize(8);function K(v,_,L,R=D){var Ne;const A=v;if(_=fe("msgHash",_),L=fe("publicKey",L),"strict"in R)throw new Error("options.strict was renamed to lowS");const{lowS:z,prehash:F}=R;let W,Q;try{if(typeof A=="string"||A instanceof Uint8Array)try{W=w.fromDER(A)}catch(pe){if(!(pe instanceof rt.Err))throw pe;W=w.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){const{r:pe,s:Je}=A;W=new w(pe,Je)}else throw new Error("PARSE");Q=l.fromHex(L)}catch(pe){if(pe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(z&&W.hasHighS())return!1;F&&(_=e.hash(_));const{r:oe,s:X}=W,ue=B(_),re=a(X),ge=c(ue*re),se=c(oe*re),ve=(Ne=l.BASE.multiplyAndAddUnsafe(Q,ge,se))==null?void 0:Ne.toAffine();return ve?c(ve.x)===oe:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:P,sign:V,verify:K,ProjectivePoint:l,Signature:w,utils:y}}let Wr=class extends Or{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Ci(e);const r=_n(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?e.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return Mt(this),this.iHash.update(e),this}digestInto(e){Mt(this),Pr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Dr=(t,e,n)=>new Wr(t,e).update(n).digest();Dr.create=(t,e)=>new Wr(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function vs(t){return{hash:t,hmac:(e,...n)=>Dr(t,e,qi(...n)),randomBytes:Lr}}function xs(t,e){const n=r=>ms({...t,...vs(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Kt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Wt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Vr=BigInt(1),Dt=BigInt(2),Fr=(t,e)=>(t+e/Dt)/e;function Gr(t){const e=Kt,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=t*t*t%e,f=l*l*t%e,u=be(f,n,e)*f%e,g=be(u,n,e)*f%e,h=be(g,Dt,e)*l%e,p=be(h,o,e)*h%e,d=be(p,i,e)*p%e,b=be(d,c,e)*d%e,w=be(b,a,e)*b%e,y=be(w,c,e)*d%e,E=be(y,n,e)*f%e,I=be(E,s,e)*p%e,P=be(I,r,e)*l%e,k=be(P,Dt,e);if(!Un.eql(Un.sqr(k),t))throw new Error("Cannot find square root");return k}const Un=us(Kt,void 0,void 0,{sqrt:Gr}),ot=xs({a:BigInt(0),b:BigInt(7),Fp:Un,n:Wt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Wt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Vr*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),c=Fr(i*t,e),a=Fr(-r*t,e);let l=ae(t-c*n-a*o,e),f=ae(-c*r-a*i,e);const u=l>s,g=f>s;if(u&&(l=e-l),g&&(f=e-f),l>s||f>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:l,k2neg:g,k2:f}}}},kn),Vt=BigInt(0),Yr=t=>typeof t=="bigint"&&Vt<t&&t<Kt,Es=t=>typeof t=="bigint"&&Vt<t&&t<Wt,Zr={};function Ft(t,...e){let n=Zr[t];if(n===void 0){const r=kn(Uint8Array.from(t,o=>o.charCodeAt(0)));n=tt(r,r),Zr[t]=n}return kn(tt(n,...e))}const Hn=t=>t.toRawBytes(!0).slice(1),Cn=t=>Ke(t,32),Nn=t=>ae(t,Kt),Pt=t=>ae(t,Wt),Rn=ot.ProjectivePoint,_s=(t,e,n)=>Rn.BASE.multiplyAndAddUnsafe(t,e,n);function qn(t){let e=ot.utils.normPrivateKeyToScalar(t),n=Rn.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:Pt(-e),bytes:Hn(n)}}function Jr(t){if(!Yr(t))throw new Error("bad x: need 0 < x < p");const e=Nn(t*t),n=Nn(e*t+BigInt(7));let r=Gr(n);r%Dt!==Vt&&(r=Nn(-r));const o=new Rn(t,r,Vr);return o.assertValidity(),o}function Qr(...t){return Pt(he(Ft("BIP0340/challenge",...t)))}function ks(t){return qn(t).bytes}function Ss(t,e,n=Lr(32)){const r=fe("message",t),{bytes:o,scalar:i}=qn(e),s=fe("auxRand",n,32),c=Cn(i^he(Ft("BIP0340/aux",s))),a=Ft("BIP0340/nonce",c,o,r),l=Pt(he(a));if(l===Vt)throw new Error("sign failed: k is zero");const{bytes:f,scalar:u}=qn(l),g=Qr(f,o,r),h=new Uint8Array(64);if(h.set(f,0),h.set(Cn(Pt(u+g*i)),32),!Xr(h,r,o))throw new Error("sign: Invalid signature produced");return h}function Xr(t,e,n){const r=fe("signature",t,64),o=fe("message",e),i=fe("publicKey",n,32);try{const s=Jr(he(i)),c=he(r.subarray(0,32));if(!Yr(c))return!1;const a=he(r.subarray(32,64));if(!Es(a))return!1;const l=Qr(Cn(c),Hn(s),o),f=_s(s,a,Pt(-l));return!(!f||!f.hasEvenY()||f.toAffine().x!==c)}catch{return!1}}const de={getPublicKey:ks,sign:Ss,verify:Xr,utils:{randomPrivateKey:ot.utils.randomPrivateKey,lift_x:Jr,pointToBytes:Hn,numberToBytesBE:Ke,bytesToNumberBE:he,taggedHash:Ft,mod:ae}};function $n(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function As(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function eo(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 Ts(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");$n(t.outputLen),$n(t.blockLen)}function Is(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 Ps(t,e){eo(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Se={number:$n,bool:As,bytes:eo,hash:Ts,exists:Is,output:Ps};function Bs(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),a=r?4:0,l=r?0:4;t.setUint32(e+a,s,r),t.setUint32(e+l,c,r)}class Os extends Ar{constructor(e,n,r,o){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=mn(this.buffer)}update(e){Se.exists(this);const{view:n,buffer:r,blockLen:o}=this;e=Tt(e);const i=e.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const a=mn(e);for(;o<=i-s;s+=o)this.process(a,s);continue}r.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Se.exists(this),Se.output(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let u=s;u<o;u++)n[u]=0;Bs(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=mn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)c.setUint32(4*u,f[u],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return e.length=o,e.pos=c,e.finished=i,e.destroyed=s,o%n&&e.buffer.set(r),e}}const Ls=(t,e,n)=>t&e^~t&n,Us=(t,e,n)=>t&e^t&n^e&n,Hs=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]),We=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),De=new Uint32Array(64);class to extends Os{constructor(){super(64,32,8,!1),this.A=We[0]|0,this.B=We[1]|0,this.C=We[2]|0,this.D=We[3]|0,this.E=We[4]|0,this.F=We[5]|0,this.G=We[6]|0,this.H=We[7]|0}get(){const{A:e,B:n,C:r,D:o,E:i,F:s,G:c,H:a}=this;return[e,n,r,o,i,s,c,a]}set(e,n,r,o,i,s,c,a){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,n){for(let u=0;u<16;u++,n+=4)De[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const g=De[u-15],h=De[u-2],p=_e(g,7)^_e(g,18)^g>>>3,d=_e(h,17)^_e(h,19)^h>>>10;De[u]=d+De[u-7]+p+De[u-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:a,G:l,H:f}=this;for(let u=0;u<64;u++){const g=_e(c,6)^_e(c,11)^_e(c,25),h=f+g+Ls(c,a,l)+Hs[u]+De[u]|0,d=(_e(r,2)^_e(r,13)^_e(r,22))+Us(r,o,i)|0;f=l,l=a,a=c,c=s+h|0,s=i,i=o,o=r,r=h+d|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,o,i,s,c,a,l,f)}roundClean(){De.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Cs extends to{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 Be=Tr(()=>new to);Tr(()=>new Cs);var bt=Symbol("verified"),Ns=t=>t instanceof Object;function Rs(t){if(!Ns(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}new TextDecoder("utf-8");var qs=new TextEncoder,$s=class{generateSecretKey(){return de.utils.randomPrivateKey()}getPublicKey(e){return ee(de.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=ee(de.getPublicKey(n)),r.id=Mn(r),r.sig=ee(de.sign(Mn(r),n)),r[bt]=!0,r}verifyEvent(e){if(typeof e[bt]=="boolean")return e[bt];const n=Mn(e);if(n!==e.id)return e[bt]=!1,!1;try{const r=de.verify(e.sig,n,e.pubkey);return e[bt]=r,r}catch{return e[bt]=!1,!1}}};function Ms(t){if(!Rs(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Mn(t){let e=Be(qs.encode(Ms(t)));return ee(e)}var Gt=new $s,zs=Gt.generateSecretKey,zn=Gt.getPublicKey,js=Gt.finalizeEvent;Gt.verifyEvent;var it=Symbol("verified"),Ks=t=>t instanceof Object;function Ws(t){if(!Ks(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}new TextDecoder("utf-8");var Ds=new TextEncoder;function wt(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}var Vs=class{constructor(e){m(this,"value");m(this,"next",null);m(this,"prev",null);this.value=e}},Fs=class{constructor(){m(this,"first");m(this,"last");this.first=null,this.last=null}enqueue(e){const n=new Vs(e);return this.last?this.last===this.first?(this.last=n,this.last.prev=this.first,this.first.next=n):(n.prev=this.last,this.last.next=n,this.last=n):(this.first=n,this.last=n),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const n=this.first;return this.first=null,this.last=null,n.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}},Gs=class{generateSecretKey(){return de.utils.randomPrivateKey()}getPublicKey(e){return ee(de.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=ee(de.getPublicKey(n)),r.id=jn(r),r.sig=ee(de.sign(jn(r),n)),r[it]=!0,r}verifyEvent(e){if(typeof e[it]=="boolean")return e[it];const n=jn(e);if(n!==e.id)return e[it]=!1,!1;try{const r=de.verify(e.sig,n,e.pubkey);return e[it]=r,r}catch{return e[it]=!1,!1}}};function Ys(t){if(!Ws(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function jn(t){let e=Be(Ds.encode(Ys(t)));return ee(e)}var Yt=new Gs;Yt.generateSecretKey,Yt.getPublicKey,Yt.finalizeEvent;var Zs=Yt.verifyEvent,Js=22242;function Qs(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([i,s])=>i===n.slice(1)&&o.indexOf(s)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function Xs(t,e){for(let n=0;n<t.length;n++)if(Qs(t[n],e))return!0;return!1}function ec(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)}function tc(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let i=r+1+o;return t.slice(r+1,i)}function nc(t,e){return{kind:Js,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function rc(){return new Promise((t,e)=>{try{if(typeof MessageChannel<"u"){const n=new MessageChannel,r=()=>{n.port1.removeEventListener("message",r),t()};n.port1.addEventListener("message",r),n.port2.postMessage(0),n.port1.start()}else typeof setImmediate<"u"?setImmediate(t):typeof setTimeout<"u"?setTimeout(t,0):t()}catch(n){console.error("during yield: ",n),e(n)}})}var oc=t=>(t[it]=!0,!0),no=class extends Error{constructor(e,n){super(`Tried to send message '${e} on a closed connection to ${n}.`),this.name="SendingOnClosedConnection"}},ro=class{constructor(e,n){m(this,"url");m(this,"_connected",!1);m(this,"onclose",null);m(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));m(this,"onauth");m(this,"baseEoseTimeout",4400);m(this,"connectionTimeout",4400);m(this,"publishTimeout",4400);m(this,"pingFrequency",29e3);m(this,"pingTimeout",2e4);m(this,"resubscribeBackoff",[1e4,1e4,1e4,2e4,2e4,3e4,6e4]);m(this,"openSubs",new Map);m(this,"enablePing");m(this,"enableReconnect");m(this,"connectionTimeoutHandle");m(this,"reconnectTimeoutHandle");m(this,"pingIntervalHandle");m(this,"reconnectAttempts",0);m(this,"closedIntentionally",!1);m(this,"connectionPromise");m(this,"openCountRequests",new Map);m(this,"openEventPublishes",new Map);m(this,"ws");m(this,"incomingMessageQueue",new Fs);m(this,"queueRunning",!1);m(this,"challenge");m(this,"authPromise");m(this,"serial",0);m(this,"verifyEvent");m(this,"_WebSocket");this.url=wt(e),this.verifyEvent=n.verifyEvent,this._WebSocket=n.websocketImplementation||WebSocket,this.enablePing=n.enablePing,this.enableReconnect=n.enableReconnect||!1}static async connect(e,n){const r=new ro(e,n);return await r.connect(),r}closeAllSubscriptions(e){for(let[n,r]of this.openSubs)r.close(e);this.openSubs.clear();for(let[n,r]of this.openEventPublishes)r.reject(new Error(e));this.openEventPublishes.clear();for(let[n,r]of this.openCountRequests)r.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async reconnect(){const e=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout(async()=>{try{await this.connect()}catch{}},e)}handleHardClose(e){var r;this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const n=this.closedIntentionally;this.closedIntentionally=!1,(r=this.onclose)==null||r.call(this),this.enableReconnect&&!n?this.reconnect():this.closeAllSubscriptions(e)}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((e,n)=>{this.connectionTimeoutHandle=setTimeout(()=>{var r;n("connection timed out"),this.connectionPromise=void 0,(r=this.onclose)==null||r.call(this),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(r){clearTimeout(this.connectionTimeoutHandle),n(r);return}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(this.connectionTimeoutHandle),this._connected=!0;const r=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const o of this.openSubs.values()){if(o.eosed=!1,r)for(let i=0;i<o.filters.length;i++)o.lastEmitted&&(o.filters[i].since=o.lastEmitted+1);o.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval(()=>this.pingpong(),this.pingFrequency)),e()},this.ws.onerror=r=>{clearTimeout(this.connectionTimeoutHandle),n(r.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=r=>{clearTimeout(this.connectionTimeoutHandle),n(r.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}waitForPingPong(){return new Promise(e=>{this.ws.once("pong",()=>e(!0)),this.ws.ping()})}waitForDummyReq(){return new Promise((e,n)=>{if(!this.connectionPromise)return n(new Error(`no connection to ${this.url}, can't ping`));try{const r=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{e(!0),r.close()},onclose(){e(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(r){n(r)}})}async pingpong(){var e,n,r;((e=this.ws)==null?void 0:e.readyState)===1&&(await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise(i=>setTimeout(()=>i(!1),this.pingTimeout))])||((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close()))}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await rc();this.queueRunning=!1}handleNext(){var r,o,i;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=tc(e);if(n){const s=this.openSubs.get(n);if(!s)return;const c=ec(e,"id"),a=(r=s.alreadyHaveEvent)==null?void 0:r.call(s,c);if((o=s.receivedEvent)==null||o.call(s,this,c),a)return}try{let s=JSON.parse(e);switch(s[0]){case"EVENT":{const c=this.openSubs.get(s[1]),a=s[2];this.verifyEvent(a)&&Xs(c.filters,a)&&c.onevent(a),(!c.lastEmitted||c.lastEmitted<a.created_at)&&(c.lastEmitted=a.created_at);return}case"COUNT":{const c=s[1],a=s[2],l=this.openCountRequests.get(c);l&&(l.resolve(a.count),this.openCountRequests.delete(c));return}case"EOSE":{const c=this.openSubs.get(s[1]);if(!c)return;c.receivedEose();return}case"OK":{const c=s[1],a=s[2],l=s[3],f=this.openEventPublishes.get(c);f&&(clearTimeout(f.timeout),a?f.resolve(l):f.reject(new Error(l)),this.openEventPublishes.delete(c));return}case"CLOSED":{const c=s[1],a=this.openSubs.get(c);if(!a)return;a.closed=!0,a.close(s[2]);return}case"NOTICE":{this.onnotice(s[1]);return}case"AUTH":{this.challenge=s[1],this.onauth&&this.auth(this.onauth);return}default:{const c=this.openSubs.get(s[1]);(i=c==null?void 0:c.oncustom)==null||i.call(c,s);return}}}catch{return}}async send(e){if(!this.connectionPromise)throw new no(e,this.url);this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(e)})}async auth(e){const n=this.challenge;if(!n)throw new Error("can't perform auth, no challenge was received");return this.authPromise?this.authPromise:(this.authPromise=new Promise(async(r,o)=>{try{let i=await e(nc(this.url,n)),s=setTimeout(()=>{let c=this.openEventPublishes.get(i.id);c&&(c.reject(new Error("auth timed out")),this.openEventPublishes.delete(i.id))},this.publishTimeout);this.openEventPublishes.set(i.id,{resolve:r,reject:o,timeout:s}),this.send('["AUTH",'+JSON.stringify(i)+"]")}catch(i){console.warn("subscribe auth function failed:",i)}}),this.authPromise)}async publish(e){const n=new Promise((r,o)=>{const i=setTimeout(()=>{const s=this.openEventPublishes.get(e.id);s&&(s.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:r,reject:o,timeout:i})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),n}async count(e,n){this.serial++;const r=(n==null?void 0:n.id)||"count:"+this.serial,o=new Promise((i,s)=>{this.openCountRequests.set(r,{resolve:i,reject:s})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e).substring(1)),o}subscribe(e,n){const r=this.prepareSubscription(e,n);return r.fire(),r}prepareSubscription(e,n){this.serial++;const r=n.id||(n.label?n.label+":":"sub:")+this.serial,o=new ic(this,r,e,n);return this.openSubs.set(r,o),o}close(){var e,n,r;this.closedIntentionally=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(e=this.onclose)==null||e.call(this),((n=this.ws)==null?void 0:n.readyState)===this._WebSocket.OPEN&&((r=this.ws)==null||r.close())}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},ic=class{constructor(e,n,r,o){m(this,"relay");m(this,"id");m(this,"lastEmitted");m(this,"closed",!1);m(this,"eosed",!1);m(this,"filters");m(this,"alreadyHaveEvent");m(this,"receivedEvent");m(this,"onevent");m(this,"oneose");m(this,"onclose");m(this,"oncustom");m(this,"eoseTimeout");m(this,"eoseTimeoutHandle");if(r.length===0)throw new Error("subscription can't be created with zero filters");this.relay=e,this.filters=r,this.id=n,this.alreadyHaveEvent=o.alreadyHaveEvent,this.receivedEvent=o.receivedEvent,this.eoseTimeout=o.eoseTimeout||e.baseEoseTimeout,this.oneose=o.oneose,this.onclose=o.onclose,this.onevent=o.onevent||(i=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,i)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){var e;this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,(e=this.oneose)==null||e.call(this))}close(e="closed by caller"){var n;if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(r){if(!(r instanceof no))throw r}this.closed=!0}this.relay.openSubs.delete(this.id),(n=this.onclose)==null||n.call(this,e)}},sc=class{constructor(e){m(this,"relays",new Map);m(this,"seenOn",new Map);m(this,"trackRelays",!1);m(this,"verifyEvent");m(this,"enablePing");m(this,"enableReconnect");m(this,"automaticallyAuth");m(this,"trustedRelayURLs",new Set);m(this,"_WebSocket");this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1,this.automaticallyAuth=e.automaticallyAuth}async ensureRelay(e,n){e=wt(e);let r=this.relays.get(e);if(r||(r=new ro(e,{verifyEvent:this.trustedRelayURLs.has(e)?oc:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),r.onclose=()=>{r&&!r.enableReconnect&&this.relays.delete(e)},n!=null&&n.connectionTimeout&&(r.connectionTimeout=n.connectionTimeout),this.relays.set(e,r)),this.automaticallyAuth){const o=this.automaticallyAuth(e);o&&(r.onauth=o)}return await r.connect(),r}close(e){e.map(wt).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close(),this.relays.delete(n)})}subscribe(e,n,r){const o=[];for(let i=0;i<e.length;i++){const s=wt(e[i]);o.find(c=>c.url===s)||o.push({url:s,filter:n})}return this.subscribeMap(o,r)}subscribeMany(e,n,r){const o=[],i=[];for(let s=0;s<e.length;s++){const c=wt(e[s]);i.indexOf(c)===-1&&(i.push(c),o.push({url:c,filter:n}))}return this.subscribeMap(o,r)}subscribeMap(e,n){const r=new Map;for(const h of e){const{url:p,filter:d}=h;r.has(p)||r.set(p,[]),r.get(p).push(d)}const o=Array.from(r.entries()).map(([h,p])=>({url:h,filters:p}));this.trackRelays&&(n.receivedEvent=(h,p)=>{let d=this.seenOn.get(p);d||(d=new Set,this.seenOn.set(p,d)),d.add(h)});const i=new Set,s=[],c=[];let a=h=>{var p;c[h]||(c[h]=!0,c.filter(d=>d).length===o.length&&((p=n.oneose)==null||p.call(n),a=()=>{}))};const l=[];let f=(h,p)=>{var d;l[h]||(a(h),l[h]=p,l.filter(b=>b).length===o.length&&((d=n.onclose)==null||d.call(n,l),f=()=>{}))};const u=h=>{var d;if((d=n.alreadyHaveEvent)!=null&&d.call(n,h))return!0;const p=i.has(h);return i.add(h),p},g=Promise.all(o.map(async({url:h,filters:p},d)=>{let b;try{b=await this.ensureRelay(h,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0})}catch(y){f(d,(y==null?void 0:y.message)||String(y));return}let w=b.subscribe(p,{...n,oneose:()=>a(d),onclose:y=>{y.startsWith("auth-required: ")&&n.onauth?b.auth(n.onauth).then(()=>{b.subscribe(p,{...n,oneose:()=>a(d),onclose:E=>{f(d,E)},alreadyHaveEvent:u,eoseTimeout:n.maxWait})}).catch(E=>{f(d,`auth was required and attempted, but failed with: ${E}`)}):f(d,y)},alreadyHaveEvent:u,eoseTimeout:n.maxWait});s.push(w)}));return{async close(h){await g,s.forEach(p=>{p.close(h)})}}}subscribeEose(e,n,r){const o=this.subscribe(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}subscribeManyEose(e,n,r){const o=this.subscribeMany(e,n,{...r,oneose(){o.close("closed automatically on eose")}});return o}async querySync(e,n,r){return new Promise(async o=>{const i=[];this.subscribeEose(e,n,{...r,onevent(s){i.push(s)},onclose(s){o(i)}})})}async get(e,n,r){n.limit=1;const o=await this.querySync(e,n,r);return o.sort((i,s)=>s.created_at-i.created_at),o[0]||null}publish(e,n,r){return e.map(wt).map(async(o,i,s)=>{if(s.indexOf(o)!==i)return Promise.reject("duplicate url");let c=await this.ensureRelay(o);return c.publish(n).catch(async a=>{if(a instanceof Error&&a.message.startsWith("auth-required: ")&&(r!=null&&r.onauth))return await c.auth(r.onauth),c.publish(n);throw a}).then(a=>{if(this.trackRelays){let l=this.seenOn.get(n.id);l||(l=new Set,this.seenOn.set(n.id,l)),l.add(c)}return a})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((n,r)=>e.set(r,n.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}},oo;try{oo=WebSocket}catch{}var cc=class extends sc{constructor(e){super({verifyEvent:Zs,websocketImplementation:oo,...e})}};function Kn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function io(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function so(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function ye(t,...e){if(!so(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 yt(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 Wn(t,e){ye(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */const ne=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),ac=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function Dn(t){if(typeof t!="string")throw new Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ve(t){if(typeof t=="string")t=Dn(t);else if(so(t))t=t.slice();else throw new Error(`Uint8Array expected, got ${typeof t}`);return t}function lc(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function co(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}const uc=(t,e)=>(Object.assign(e,t),e),le=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class fc{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Ve(e),ye(e,32);const n=le(e,0),r=le(e,2),o=le(e,4),i=le(e,6),s=le(e,8),c=le(e,10),a=le(e,12),l=le(e,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|i<<9)&8191,this.r[4]=(i>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|c<<2)&8191,this.r[7]=(c>>>11|a<<5)&8065,this.r[8]=(a>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let f=0;f<8;f++)this.pad[f]=le(e,16+2*f)}process(e,n,r=!1){const o=r?0:2048,{h:i,r:s}=this,c=s[0],a=s[1],l=s[2],f=s[3],u=s[4],g=s[5],h=s[6],p=s[7],d=s[8],b=s[9],w=le(e,n+0),y=le(e,n+2),E=le(e,n+4),I=le(e,n+6),P=le(e,n+8),k=le(e,n+10),B=le(e,n+12),x=le(e,n+14);let C=i[0]+(w&8191),U=i[1]+((w>>>13|y<<3)&8191),N=i[2]+((y>>>10|E<<6)&8191),D=i[3]+((E>>>7|I<<9)&8191),V=i[4]+((I>>>4|P<<12)&8191),K=i[5]+(P>>>1&8191),v=i[6]+((P>>>14|k<<2)&8191),_=i[7]+((k>>>11|B<<5)&8191),L=i[8]+((B>>>8|x<<8)&8191),R=i[9]+(x>>>5|o),A=0,z=A+C*c+U*(5*b)+N*(5*d)+D*(5*p)+V*(5*h);A=z>>>13,z&=8191,z+=K*(5*g)+v*(5*u)+_*(5*f)+L*(5*l)+R*(5*a),A+=z>>>13,z&=8191;let F=A+C*a+U*c+N*(5*b)+D*(5*d)+V*(5*p);A=F>>>13,F&=8191,F+=K*(5*h)+v*(5*g)+_*(5*u)+L*(5*f)+R*(5*l),A+=F>>>13,F&=8191;let W=A+C*l+U*a+N*c+D*(5*b)+V*(5*d);A=W>>>13,W&=8191,W+=K*(5*p)+v*(5*h)+_*(5*g)+L*(5*u)+R*(5*f),A+=W>>>13,W&=8191;let Q=A+C*f+U*l+N*a+D*c+V*(5*b);A=Q>>>13,Q&=8191,Q+=K*(5*d)+v*(5*p)+_*(5*h)+L*(5*g)+R*(5*u),A+=Q>>>13,Q&=8191;let oe=A+C*u+U*f+N*l+D*a+V*c;A=oe>>>13,oe&=8191,oe+=K*(5*b)+v*(5*d)+_*(5*p)+L*(5*h)+R*(5*g),A+=oe>>>13,oe&=8191;let X=A+C*g+U*u+N*f+D*l+V*a;A=X>>>13,X&=8191,X+=K*c+v*(5*b)+_*(5*d)+L*(5*p)+R*(5*h),A+=X>>>13,X&=8191;let ue=A+C*h+U*g+N*u+D*f+V*l;A=ue>>>13,ue&=8191,ue+=K*a+v*c+_*(5*b)+L*(5*d)+R*(5*p),A+=ue>>>13,ue&=8191;let re=A+C*p+U*h+N*g+D*u+V*f;A=re>>>13,re&=8191,re+=K*l+v*a+_*c+L*(5*b)+R*(5*d),A+=re>>>13,re&=8191;let ge=A+C*d+U*p+N*h+D*g+V*u;A=ge>>>13,ge&=8191,ge+=K*f+v*l+_*a+L*c+R*(5*b),A+=ge>>>13,ge&=8191;let se=A+C*b+U*d+N*p+D*h+V*g;A=se>>>13,se&=8191,se+=K*u+v*f+_*l+L*a+R*c,A+=se>>>13,se&=8191,A=(A<<2)+A|0,A=A+z|0,z=A&8191,A=A>>>13,F+=A,i[0]=z,i[1]=F,i[2]=W,i[3]=Q,i[4]=oe,i[5]=X,i[6]=ue,i[7]=re,i[8]=ge,i[9]=se}finalize(){const{h:e,pad:n}=this,r=new Uint16Array(10);let o=e[1]>>>13;e[1]&=8191;for(let c=2;c<10;c++)e[c]+=o,o=e[c]>>>13,e[c]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,r[0]=e[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=e[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let i=(o^1)-1;for(let c=0;c<10;c++)r[c]&=i;i=~i;for(let c=0;c<10;c++)e[c]=e[c]&i|r[c];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+n[0];e[0]=s&65535;for(let c=1;c<8;c++)s=(e[c]+n[c]|0)+(s>>>16)|0,e[c]=s&65535}update(e){yt(this);const{buffer:n,blockLen:r}=this;e=Ve(e);const o=e.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){for(;r<=o-i;i+=r)this.process(e,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){yt(this),Wn(e,this),this.finished=!0;const{buffer:n,h:r}=this;let{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,!0)}this.finalize();let i=0;for(let s=0;s<8;s++)e[i++]=r[s]>>>0,e[i++]=r[s]>>>8;return e}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}}function dc(t){const e=(r,o)=>t(o).update(Ve(r)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}dc(t=>new fc(t));const hc=Dn("expand 16-byte k"),pc=Dn("expand 32-byte k"),gc=ne(hc),bc=ne(pc);function Y(t,e){return t<<e|t>>>32-e}function Vn(t){return t.byteOffset%4===0}const Zt=64,wc=16,ao=2**32-1,lo=new Uint32Array;function yc(t,e,n,r,o,i,s,c){const a=o.length,l=new Uint8Array(Zt),f=ne(l),u=Vn(o)&&Vn(i),g=u?ne(o):lo,h=u?ne(i):lo;for(let p=0;p<a;s++){if(t(e,n,r,f,s,c),s>=ao)throw new Error("arx: counter overflow");const d=Math.min(Zt,a-p);if(u&&d===Zt){const b=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let w=0,y;w<wc;w++)y=b+w,h[y]=g[y]^f[w];p+=Zt;continue}for(let b=0,w;b<d;b++)w=p+b,i[w]=o[w]^l[b];p+=d}}function mc(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=lc({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Kn(o),Kn(s),io(i),io(n),(c,a,l,f,u=0)=>{ye(c),ye(a),ye(l);const g=l.length;if(f||(f=new Uint8Array(g)),ye(f),Kn(u),u<0||u>=ao)throw new Error("arx: counter overflow");if(f.length<g)throw new Error(`arx: output (${f.length}) is shorter than data (${g})`);const h=[];let p=c.length,d,b;if(p===32)d=c.slice(),h.push(d),b=bc;else if(p===16&&n)d=new Uint8Array(32),d.set(c),d.set(c,16),b=gc,h.push(d);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);Vn(a)||(a=a.slice(),h.push(a));const w=ne(d);if(r){if(a.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(b,w,ne(a.subarray(0,16)),w),a=a.subarray(16)}const y=16-o;if(y!==a.length)throw new Error(`arx: nonce must be ${y} or 16 bytes`);if(y!==12){const I=new Uint8Array(12);I.set(a,i?0:12-a.length),a=I,h.push(a)}const E=ne(a);for(yc(t,b,w,E,l,f,u,s);h.length>0;)h.pop().fill(0);return f}}function vc(t,e,n,r,o,i=20){let s=t[0],c=t[1],a=t[2],l=t[3],f=e[0],u=e[1],g=e[2],h=e[3],p=e[4],d=e[5],b=e[6],w=e[7],y=o,E=n[0],I=n[1],P=n[2],k=s,B=c,x=a,C=l,U=f,N=u,D=g,V=h,K=p,v=d,_=b,L=w,R=y,A=E,z=I,F=P;for(let Q=0;Q<i;Q+=2)k=k+U|0,R=Y(R^k,16),K=K+R|0,U=Y(U^K,12),k=k+U|0,R=Y(R^k,8),K=K+R|0,U=Y(U^K,7),B=B+N|0,A=Y(A^B,16),v=v+A|0,N=Y(N^v,12),B=B+N|0,A=Y(A^B,8),v=v+A|0,N=Y(N^v,7),x=x+D|0,z=Y(z^x,16),_=_+z|0,D=Y(D^_,12),x=x+D|0,z=Y(z^x,8),_=_+z|0,D=Y(D^_,7),C=C+V|0,F=Y(F^C,16),L=L+F|0,V=Y(V^L,12),C=C+V|0,F=Y(F^C,8),L=L+F|0,V=Y(V^L,7),k=k+N|0,F=Y(F^k,16),_=_+F|0,N=Y(N^_,12),k=k+N|0,F=Y(F^k,8),_=_+F|0,N=Y(N^_,7),B=B+D|0,R=Y(R^B,16),L=L+R|0,D=Y(D^L,12),B=B+D|0,R=Y(R^B,8),L=L+R|0,D=Y(D^L,7),x=x+V|0,A=Y(A^x,16),K=K+A|0,V=Y(V^K,12),x=x+V|0,A=Y(A^x,8),K=K+A|0,V=Y(V^K,7),C=C+U|0,z=Y(z^C,16),v=v+z|0,U=Y(U^v,12),C=C+U|0,z=Y(z^C,8),v=v+z|0,U=Y(U^v,7);let W=0;r[W++]=s+k|0,r[W++]=c+B|0,r[W++]=a+x|0,r[W++]=l+C|0,r[W++]=f+U|0,r[W++]=u+N|0,r[W++]=g+D|0,r[W++]=h+V|0,r[W++]=p+K|0,r[W++]=d+v|0,r[W++]=b+_|0,r[W++]=w+L|0,r[W++]=y+R|0,r[W++]=E+A|0,r[W++]=I+z|0,r[W++]=P+F|0}const Jt=mc(vc,{counterRight:!1,counterLength:4,allowShortKeys:!1});class uo extends Ar{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Se.hash(e);const r=Tt(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?e.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return Se.exists(this),this.iHash.update(e),this}digestInto(e){Se.exists(this),Se.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Bt=(t,e,n)=>new uo(t,e).update(n).digest();Bt.create=(t,e)=>new uo(t,e);function fo(t,e,n){return Se.hash(t),n===void 0&&(n=new Uint8Array(t.outputLen)),Bt(t,Tt(n),Tt(e))}const Fn=new Uint8Array([0]),ho=new Uint8Array;function po(t,e,n,r=32){if(Se.hash(t),Se.number(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/t.outputLen);n===void 0&&(n=ho);const i=new Uint8Array(o*t.outputLen),s=Bt.create(t,e),c=s._cloneInto(),a=new Uint8Array(s.outputLen);for(let l=0;l<o;l++)Fn[0]=l+1,c.update(l===0?ho:a).update(n).update(Fn).digestInto(a),i.set(a,t.outputLen*l),s._cloneInto(c);return s.destroy(),c.destroy(),a.fill(0),Fn.fill(0),i.slice(0,r)}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mt(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function Oe(...t){const e=(o,i)=>s=>o(i(s)),n=Array.from(t).reverse().reduce((o,i)=>o?e(o,i.encode):i.encode,void 0),r=t.reduce((o,i)=>o?e(o,i.decode):i.decode,void 0);return{encode:n,decode:r}}function Le(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return e.map(n=>{if(mt(n),n<0||n>=t.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${t.length})`);return t[n]})},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("alphabet.decode input should be array of strings");return e.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=t.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${t}`);return r})}}}function Ue(t=""){if(typeof t!="string")throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of e)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return e.join(t)},decode:e=>{if(typeof e!="string")throw new Error("join.decode input should be string");return e.split(t)}}}function Qt(t,e="="){if(mt(t),typeof e!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of n)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);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 go(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function bo(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(s=>{if(mt(s),s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,c=!0;for(let a=r;a<i.length;a++){const l=i[a],f=e*s+l;if(!Number.isSafeInteger(f)||e*s/e!==s||f-l!==e*s)throw new Error("convertRadix: carry overflow");if(s=f%n,i[a]=Math.floor(f/n),!Number.isSafeInteger(i[a])||i[a]*n+s!==f)throw new Error("convertRadix: carry overflow");if(c)i[a]?c=!1:r=a;else continue}if(o.push(s),c)break}for(let s=0;s<t.length-1&&t[s]===0;s++)o.push(0);return o.reverse()}const wo=(t,e)=>e?wo(e,t%e):t,Xt=(t,e)=>t+(e-wo(t,e));function Gn(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(Xt(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Xt(e,n)}`);let o=0,i=0;const s=2**n-1,c=[];for(const a of t){if(mt(a),a>=2**e)throw new Error(`convertRadix2: invalid data word=${a} from=${e}`);if(o=o<<e|a,i+e>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${e}`);for(i+=e;i>=n;i-=n)c.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<<n-i&s,!r&&i>=e)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&c.push(o>>>0),c}function xc(t){return mt(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return bo(Array.from(e),2**8,t)},decode:e=>{if(!Array.isArray(e)||e.length&&typeof e[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(bo(e,t,2**8))}}}function Fe(t,e=!1){if(mt(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Xt(8,t)>32||Xt(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 Gn(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Gn(n,t,8,e))}}}function yo(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Ec=Oe(Fe(4),Le("0123456789ABCDEF"),Ue("")),_c=Oe(Fe(5),Le("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Qt(5),Ue(""));Oe(Fe(5),Le("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Qt(5),Ue("")),Oe(Fe(5),Le("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Ue(""),go(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const He=Oe(Fe(6),Le("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Qt(6),Ue("")),kc=Oe(Fe(6),Le("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Qt(6),Ue("")),Yn=t=>Oe(xc(58),Le(t),Ue("")),Zn=Yn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Yn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Yn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const mo=[0,2,3,5,6,7,9,10,11],Sc={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=Zn.encode(r).padStart(mo[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),o=mo.indexOf(r.length),i=Zn.decode(r);for(let s=0;s<i.length-o;s++)if(i[s]!==0)throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(i.slice(i.length-o)))}return Uint8Array.from(e)}},Jn=Oe(Le("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Ue("")),vo=[996825010,642813549,513874426,1027748829,705979059];function Ot(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<vo.length;r++)(e>>r&1)===1&&(n^=vo[r]);return n}function xo(t,e,n=1){const r=t.length;let o=1;for(let i=0;i<r;i++){const s=t.charCodeAt(i);if(s<33||s>126)throw new Error(`Invalid prefix (${t})`);o=Ot(o)^s>>5}o=Ot(o);for(let i=0;i<r;i++)o=Ot(o)^t.charCodeAt(i)&31;for(let i of e)o=Ot(o)^i;for(let i=0;i<6;i++)o=Ot(o);return o^=n,Jn.encode(Gn([o%2**30],30,5,!1))}function Eo(t){const e=t==="bech32"?1:734539939,n=Fe(5),r=n.decode,o=n.encode,i=yo(r);function s(f,u,g=90){if(typeof f!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);if(!Array.isArray(u)||u.length&&typeof u[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);const h=f.length+7+u.length;if(g!==!1&&h>g)throw new TypeError(`Length ${h} exceeds limit ${g}`);return f=f.toLowerCase(),`${f}1${Jn.encode(u)}${xo(f,u,e)}`}function c(f,u=90){if(typeof f!="string")throw new Error(`bech32.decode input should be string, not ${typeof f}`);if(f.length<8||u!==!1&&f.length>u)throw new TypeError(`Wrong string length: ${f.length} (${f}). Expected (8..${u})`);const g=f.toLowerCase();if(f!==g&&f!==f.toUpperCase())throw new Error("String must be lowercase or uppercase");f=g;const h=f.lastIndexOf("1");if(h===0||h===-1)throw new Error('Letter "1" must be present between prefix and data only');const p=f.slice(0,h),d=f.slice(h+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const b=Jn.decode(d).slice(0,-6),w=xo(p,b,e);if(!d.endsWith(w))throw new Error(`Invalid checksum in ${f}: expected "${w}"`);return{prefix:p,words:b}}const a=yo(c);function l(f){const{prefix:u,words:g}=c(f,!1);return{prefix:u,words:g,bytes:r(g)}}return{encode:s,decode:c,decodeToBytes:l,decodeUnsafe:a,fromWords:r,fromWordsUnsafe:i,toWords:o}}const en=Eo("bech32");Eo("bech32m");const Ac={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},Tc=Oe(Fe(4),Le("0123456789abcdef"),Ue(""),go(t=>{if(typeof t!="string"||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));`${Object.keys({utf8:Ac,hex:Tc,base16:Ec,base32:_c,base64:He,base64url:kc,base58:Zn,base58xmr:Sc}).join(", ")}`;var st=Symbol("verified"),Ic=t=>t instanceof Object;function Pc(t){if(!Ic(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}var Bc=new TextDecoder("utf-8"),_o=new TextEncoder;function vt(t){try{t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.protocol==="http:"?e.protocol="ws:":e.protocol==="https:"&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch{throw new Error(`Invalid URL: ${t}`)}}var Oc=class{constructor(t){m(this,"value");m(this,"next",null);m(this,"prev",null);this.value=t}},Lc=class{constructor(){m(this,"first");m(this,"last");this.first=null,this.last=null}enqueue(t){const e=new Oc(t);return this.last?this.last===this.first?(this.last=e,this.last.prev=this.first,this.first.next=e):(e.prev=this.last,this.last.next=e,this.last=e):(this.first=e,this.last=e),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const t=this.first;return this.first=t.next,this.first&&(this.first.prev=null),t.value}},Uc=class{generateSecretKey(){return de.utils.randomPrivateKey()}getPublicKey(t){return ee(de.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=ee(de.getPublicKey(e)),n.id=Qn(n),n.sig=ee(de.sign(Qn(n),e)),n[st]=!0,n}verifyEvent(t){if(typeof t[st]=="boolean")return t[st];const e=Qn(t);if(e!==t.id)return t[st]=!1,!1;try{const n=de.verify(t.sig,e,t.pubkey);return t[st]=n,n}catch{return t[st]=!1,!1}}};function Hc(t){if(!Pc(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}function Qn(t){let e=Be(_o.encode(Hc(t)));return ee(e)}var tn=new Uc;tn.generateSecretKey;var ko=tn.getPublicKey,Cc=tn.finalizeEvent,So=tn.verifyEvent,Ao=1,To=65535;function Xn(t,e){const n=ot.getSharedSecret(t,"02"+e).subarray(1,33);return fo(Be,n,"nip44-v2")}function Io(t,e){const n=po(Be,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Po(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function Nc(t){if(!Number.isSafeInteger(t)||t<Ao||t>To)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}function Rc(t){const e=_o.encode(t),n=e.length,r=Nc(n),o=new Uint8Array(Po(n)-n);return ht(r,e,o)}function qc(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<Ao||e>To||n.length!==e||t.length!==2+Po(e))throw new Error("invalid padding");return Bc.decode(n)}function Bo(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=ht(n,e);return Bt(Be,t,r)}function $c(t){if(typeof t!="string")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=He.decode(t)}catch(i){throw new Error("invalid base64: "+i.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function Mc(t,e,n=vn(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=Io(e,n),s=Rc(t),c=Jt(r,o,s),a=Bo(i,c,n);return He.encode(ht(new Uint8Array([2]),n,c,a))}function Oo(t,e){const{nonce:n,ciphertext:r,mac:o}=$c(t),{chacha_key:i,chacha_nonce:s,hmac_key:c}=Io(e,n),a=Bo(c,r,n);if(!co(a,o))throw new Error("invalid MAC");const l=Jt(i,s,r);return qc(l)}var zc=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,jc;try{jc=fetch}catch{}var Kc=22242,er=24133;function Wc(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1)return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),o=t[`#${r}`];if(o&&!e.tags.find(([i,s])=>i===n.slice(1)&&o.indexOf(s)!==-1))return!1}return!(t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)}function Dc(t,e){for(let n=0;n<t.length;n++)if(Wc(t[n],e))return!0;return!1}function Vc(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)}function Fc(t){let e=t.slice(0,22).indexOf('"EVENT"');if(e===-1)return null;let n=t.slice(e+7+1).indexOf('"');if(n===-1)return null;let r=e+7+1+n,o=t.slice(r+1,80).indexOf('"');if(o===-1)return null;let i=r+1+o;return t.slice(r+1,i)}function Gc(t,e){return{kind:Kc,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function Yc(){return new Promise((t,e)=>{try{if(typeof MessageChannel<"u"){const n=new MessageChannel,r=()=>{n.port1.removeEventListener("message",r),t()};n.port1.addEventListener("message",r),n.port2.postMessage(0),n.port1.start()}else typeof setImmediate<"u"?setImmediate(t):typeof setTimeout<"u"?setTimeout(t,0):t()}catch(n){console.error("during yield: ",n),e(n)}})}var Zc=t=>(t[st]=!0,!0),Lo=class extends Error{constructor(t,e){super(`Tried to send message '${t} on a closed connection to ${e}.`),this.name="SendingOnClosedConnection"}},Uo=class{constructor(t,e){m(this,"url");m(this,"_connected",!1);m(this,"onclose",null);m(this,"onnotice",t=>console.debug(`NOTICE from ${this.url}: ${t}`));m(this,"onauth");m(this,"baseEoseTimeout",4400);m(this,"connectionTimeout",4400);m(this,"publishTimeout",4400);m(this,"pingFrequency",29e3);m(this,"pingTimeout",2e4);m(this,"resubscribeBackoff",[1e4,1e4,1e4,2e4,2e4,3e4,6e4]);m(this,"openSubs",new Map);m(this,"enablePing");m(this,"enableReconnect");m(this,"connectionTimeoutHandle");m(this,"reconnectTimeoutHandle");m(this,"pingIntervalHandle");m(this,"reconnectAttempts",0);m(this,"closedIntentionally",!1);m(this,"connectionPromise");m(this,"openCountRequests",new Map);m(this,"openEventPublishes",new Map);m(this,"ws");m(this,"incomingMessageQueue",new Lc);m(this,"queueRunning",!1);m(this,"challenge");m(this,"authPromise");m(this,"serial",0);m(this,"verifyEvent");m(this,"_WebSocket");this.url=vt(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket,this.enablePing=e.enablePing,this.enableReconnect=e.enableReconnect||!1}static async connect(t,e){const n=new Uo(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 reconnect(){const t=this.resubscribeBackoff[Math.min(this.reconnectAttempts,this.resubscribeBackoff.length-1)];this.reconnectAttempts++,this.reconnectTimeoutHandle=setTimeout(async()=>{try{await this.connect()}catch{}},t)}handleHardClose(t){var n;this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this._connected=!1,this.connectionPromise=void 0;const e=this.closedIntentionally;this.closedIntentionally=!1,(n=this.onclose)==null||n.call(this),this.enableReconnect&&!e?this.reconnect():this.closeAllSubscriptions(t)}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((t,e)=>{this.connectionTimeoutHandle=setTimeout(()=>{var n;e("connection timed out"),this.connectionPromise=void 0,(n=this.onclose)==null||n.call(this),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(n){clearTimeout(this.connectionTimeoutHandle),e(n);return}this.ws.onopen=()=>{this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),clearTimeout(this.connectionTimeoutHandle),this._connected=!0;const n=this.reconnectAttempts>0;this.reconnectAttempts=0;for(const r of this.openSubs.values()){if(r.eosed=!1,n)for(let o=0;o<r.filters.length;o++)r.lastEmitted&&(r.filters[o].since=r.lastEmitted+1);r.fire()}this.enablePing&&(this.pingIntervalHandle=setInterval(()=>this.pingpong(),this.pingFrequency)),t()},this.ws.onerror=n=>{clearTimeout(this.connectionTimeoutHandle),e(n.message||"websocket error"),this.handleHardClose("relay connection errored")},this.ws.onclose=n=>{clearTimeout(this.connectionTimeoutHandle),e(n.message||"websocket closed"),this.handleHardClose("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)}),this.connectionPromise)}waitForPingPong(){return new Promise(t=>{this.ws.once("pong",()=>t(!0)),this.ws.ping()})}waitForDummyReq(){return new Promise((t,e)=>{if(!this.connectionPromise)return e(new Error(`no connection to ${this.url}, can't ping`));try{const n=this.subscribe([{ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0}],{label:"forced-ping",oneose:()=>{t(!0),n.close()},onclose(){t(!0)},eoseTimeout:this.pingTimeout+1e3})}catch(n){e(n)}})}async pingpong(){var t,e,n;((t=this.ws)==null?void 0:t.readyState)===1&&(await Promise.any([this.ws&&this.ws.ping&&this.ws.once?this.waitForPingPong():this.waitForDummyReq(),new Promise(o=>setTimeout(()=>o(!1),this.pingTimeout))])||((e=this.ws)==null?void 0:e.readyState)===this._WebSocket.OPEN&&((n=this.ws)==null||n.close()))}async runQueue(){for(this.queueRunning=!0;this.handleNext()!==!1;)await Yc();this.queueRunning=!1}handleNext(){var n,r,o;const t=this.incomingMessageQueue.dequeue();if(!t)return!1;const e=Fc(t);if(e){const i=this.openSubs.get(e);if(!i)return;const s=Vc(t,"id"),c=(n=i.alreadyHaveEvent)==null?void 0:n.call(i,s);if((r=i.receivedEvent)==null||r.call(i,this,s),c)return}try{let i=JSON.parse(t);switch(i[0]){case"EVENT":{const s=this.openSubs.get(i[1]),c=i[2];this.verifyEvent(c)&&Dc(s.filters,c)&&s.onevent(c),(!s.lastEmitted||s.lastEmitted<c.created_at)&&(s.lastEmitted=c.created_at);return}case"COUNT":{const s=i[1],c=i[2],a=this.openCountRequests.get(s);a&&(a.resolve(c.count),this.openCountRequests.delete(s));return}case"EOSE":{const s=this.openSubs.get(i[1]);if(!s)return;s.receivedEose();return}case"OK":{const s=i[1],c=i[2],a=i[3],l=this.openEventPublishes.get(s);l&&(clearTimeout(l.timeout),c?l.resolve(a):l.reject(new Error(a)),this.openEventPublishes.delete(s));return}case"CLOSED":{const s=i[1],c=this.openSubs.get(s);if(!c)return;c.closed=!0,c.close(i[2]);return}case"NOTICE":{this.onnotice(i[1]);return}case"AUTH":{this.challenge=i[1],this.onauth&&this.auth(this.onauth);return}default:{const s=this.openSubs.get(i[1]);(o=s==null?void 0:s.oncustom)==null||o.call(s,i);return}}}catch{return}}async send(t){if(!this.connectionPromise)throw new Lo(t,this.url);this.connectionPromise.then(()=>{var e;(e=this.ws)==null||e.send(t)})}async auth(t){const e=this.challenge;if(!e)throw new Error("can't perform auth, no challenge was received");return this.authPromise?this.authPromise:(this.authPromise=new Promise(async(n,r)=>{try{let o=await t(Gc(this.url,e)),i=setTimeout(()=>{let s=this.openEventPublishes.get(o.id);s&&(s.reject(new Error("auth timed out")),this.openEventPublishes.delete(o.id))},this.publishTimeout);this.openEventPublishes.set(o.id,{resolve:n,reject:r,timeout:i}),this.send('["AUTH",'+JSON.stringify(o)+"]")}catch(o){console.warn("subscribe auth function failed:",o)}}),this.authPromise)}async publish(t){const e=new Promise((n,r)=>{const o=setTimeout(()=>{const i=this.openEventPublishes.get(t.id);i&&(i.reject(new Error("publish timed out")),this.openEventPublishes.delete(t.id))},this.publishTimeout);this.openEventPublishes.set(t.id,{resolve:n,reject:r,timeout:o})});return this.send('["EVENT",'+JSON.stringify(t)+"]"),e}async count(t,e){this.serial++;const n=(e==null?void 0:e.id)||"count:"+this.serial,r=new Promise((o,i)=>{this.openCountRequests.set(n,{resolve:o,reject:i})});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 Jc(this,n,t,e);return this.openSubs.set(n,r),r}close(){var t,e,n;this.closedIntentionally=!0,this.reconnectTimeoutHandle&&(clearTimeout(this.reconnectTimeoutHandle),this.reconnectTimeoutHandle=void 0),this.pingIntervalHandle&&(clearInterval(this.pingIntervalHandle),this.pingIntervalHandle=void 0),this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,(t=this.onclose)==null||t.call(this),((e=this.ws)==null?void 0:e.readyState)===this._WebSocket.OPEN&&((n=this.ws)==null||n.close())}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},Jc=class{constructor(t,e,n,r){m(this,"relay");m(this,"id");m(this,"lastEmitted");m(this,"closed",!1);m(this,"eosed",!1);m(this,"filters");m(this,"alreadyHaveEvent");m(this,"receivedEvent");m(this,"onevent");m(this,"oneose");m(this,"onclose");m(this,"oncustom");m(this,"eoseTimeout");m(this,"eoseTimeoutHandle");if(n.length===0)throw new Error("subscription can't be created with zero filters");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||(o=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,o)})}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,(t=this.oneose)==null||t.call(this))}close(t="closed by caller"){var e;if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(n){if(!(n instanceof Lo))throw n}this.closed=!0}this.relay.openSubs.delete(this.id),(e=this.onclose)==null||e.call(this,t)}},Qc=class{constructor(t){m(this,"relays",new Map);m(this,"seenOn",new Map);m(this,"trackRelays",!1);m(this,"verifyEvent");m(this,"enablePing");m(this,"enableReconnect");m(this,"automaticallyAuth");m(this,"trustedRelayURLs",new Set);m(this,"_WebSocket");this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation,this.enablePing=t.enablePing,this.enableReconnect=t.enableReconnect||!1,this.automaticallyAuth=t.automaticallyAuth}async ensureRelay(t,e){t=vt(t);let n=this.relays.get(t);if(n||(n=new Uo(t,{verifyEvent:this.trustedRelayURLs.has(t)?Zc:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing,enableReconnect:this.enableReconnect}),n.onclose=()=>{n&&!n.enableReconnect&&this.relays.delete(t)},e!=null&&e.connectionTimeout&&(n.connectionTimeout=e.connectionTimeout),this.relays.set(t,n)),this.automaticallyAuth){const r=this.automaticallyAuth(t);r&&(n.onauth=r)}return await n.connect(),n}close(t){t.map(vt).forEach(e=>{var n;(n=this.relays.get(e))==null||n.close(),this.relays.delete(e)})}subscribe(t,e,n){const r=[];for(let o=0;o<t.length;o++){const i=vt(t[o]);r.find(s=>s.url===i)||r.push({url:i,filter:e})}return this.subscribeMap(r,n)}subscribeMany(t,e,n){const r=[],o=[];for(let i=0;i<t.length;i++){const s=vt(t[i]);o.indexOf(s)===-1&&(o.push(s),r.push({url:s,filter:e}))}return this.subscribeMap(r,n)}subscribeMap(t,e){const n=new Map;for(const g of t){const{url:h,filter:p}=g;n.has(h)||n.set(h,[]),n.get(h).push(p)}const r=Array.from(n.entries()).map(([g,h])=>({url:g,filters:h}));this.trackRelays&&(e.receivedEvent=(g,h)=>{let p=this.seenOn.get(h);p||(p=new Set,this.seenOn.set(h,p)),p.add(g)});const o=new Set,i=[],s=[];let c=g=>{var h;s[g]||(s[g]=!0,s.filter(p=>p).length===r.length&&((h=e.oneose)==null||h.call(e),c=()=>{}))};const a=[];let l=(g,h)=>{var p;a[g]||(c(g),a[g]=h,a.filter(d=>d).length===r.length&&((p=e.onclose)==null||p.call(e,a),l=()=>{}))};const f=g=>{var p;if((p=e.alreadyHaveEvent)!=null&&p.call(e,g))return!0;const h=o.has(g);return o.add(g),h},u=Promise.all(r.map(async({url:g,filters:h},p)=>{let d;try{d=await this.ensureRelay(g,{connectionTimeout:e.maxWait?Math.max(e.maxWait*.8,e.maxWait-1e3):void 0})}catch(w){l(p,(w==null?void 0:w.message)||String(w));return}let b=d.subscribe(h,{...e,oneose:()=>c(p),onclose:w=>{w.startsWith("auth-required: ")&&e.onauth?d.auth(e.onauth).then(()=>{d.subscribe(h,{...e,oneose:()=>c(p),onclose:y=>{l(p,y)},alreadyHaveEvent:f,eoseTimeout:e.maxWait})}).catch(y=>{l(p,`auth was required and attempted, but failed with: ${y}`)}):l(p,w)},alreadyHaveEvent:f,eoseTimeout:e.maxWait});i.push(b)}));return{async close(g){await u,i.forEach(h=>{h.close(g)})}}}subscribeEose(t,e,n){const r=this.subscribe(t,e,{...n,oneose(){r.close("closed automatically on eose")}});return r}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close("closed automatically on eose")}});return r}async querySync(t,e,n){return new Promise(async r=>{const o=[];this.subscribeEose(t,e,{...n,onevent(i){o.push(i)},onclose(i){r(o)}})})}async get(t,e,n){e.limit=1;const r=await this.querySync(t,e,n);return r.sort((o,i)=>i.created_at-o.created_at),r[0]||null}publish(t,e,n){return t.map(vt).map(async(r,o,i)=>{if(i.indexOf(r)!==o)return Promise.reject("duplicate url");let s=await this.ensureRelay(r);return s.publish(e).catch(async c=>{if(c instanceof Error&&c.message.startsWith("auth-required: ")&&(n!=null&&n.onauth))return await s.auth(n.onauth),s.publish(e);throw c}).then(c=>{if(this.trackRelays){let a=this.seenOn.get(e.id);a||(a=new Set,this.seenOn.set(e.id,a)),a.add(s)}return c})})}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}},Ho;try{Ho=WebSocket}catch{}var Xc=class extends Qc{constructor(t){super({verifyEvent:So,websocketImplementation:Ho,...t})}},Co;try{Co=fetch}catch{}var nn=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%-]*)$/;async function ea(t){let e=t.match(nn);if(e)try{const n=e[1],r=new URLSearchParams(e[2]);return{pubkey:n,relays:r.getAll("relay"),secret:r.get("secret")}}catch{}return ta(t)}async function ta(t){const e=t.match(zc);if(!e)return null;const[n,r="_",o]=e;try{const i=`https://${o}/.well-known/nostr.json?name=${r}`,s=await(await Co(i,{redirect:"error"})).json();let c=s.names[r],a=s.nip46[c]||[];return{pubkey:c,relays:a,secret:null}}catch{return null}}function na(t){if(!t.startsWith("nostrconnect://"))throw new Error('Invalid nostrconnect URI: Must start with "nostrconnect://".');const[e,n]=t.split("?");if(!e||!n)throw new Error("Invalid nostrconnect URI: Missing query string.");const r=e.substring(15);if(!r)throw new Error("Invalid nostrconnect URI: Missing client-pubkey.");const o=new URLSearchParams(n),i=o.getAll("relay");if(i.length===0)throw new Error('Invalid nostrconnect URI: Missing "relay" parameter.');const s=o.get("secret");if(!s)throw new Error('Invalid nostrconnect URI: Missing "secret" parameter.');const c=o.get("perms"),a=c?c.split(","):void 0,l=o.get("name")||void 0,f=o.get("url")||void 0,u=o.get("image")||void 0;return{protocol:"nostrconnect",clientPubkey:r,params:{relays:i,secret:s,perms:a,name:l,url:f,image:u},originalString:t}}var tr=class{constructor(t,e){m(this,"params");m(this,"pool");m(this,"subCloser");m(this,"isOpen");m(this,"serial");m(this,"idPrefix");m(this,"listeners");m(this,"waitingForAuth");m(this,"secretKey");m(this,"conversationKey");m(this,"bp");m(this,"cachedPubKey");this.params=e,this.pool=e.pool||new Xc,this.secretKey=t,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={}}static fromBunker(t,e,n={}){if(e.relays.length===0)throw new Error("No relays specified for this bunker");const r=new tr(t,n);return r.conversationKey=Xn(t,e.pubkey),r.bp=e,r.setupSubscription(n),r}static async fromURI(t,e,n={},r=3e5){const o=new tr(t,n),i=na(e),s=ko(t);return new Promise((c,a)=>{const l=setTimeout(()=>{f.close(),a(new Error(`Connection timed out after ${r/1e3} seconds`))},r),f=o.pool.subscribe(i.params.relays,{kinds:[er],"#p":[s]},{onevent:async u=>{try{const g=Xn(t,u.pubkey),h=Oo(u.content,g);JSON.parse(h).result===i.params.secret&&(clearTimeout(l),f.close(),o.bp={pubkey:u.pubkey,relays:i.params.relays,secret:i.params.secret},o.conversationKey=Xn(t,u.pubkey),o.setupSubscription(n),c(o))}catch(g){console.warn("Failed to process potential connection event",g)}},onclose:()=>{clearTimeout(l),a(new Error("Subscription closed before connection was established."))},maxWait:r})})}setupSubscription(t){const e=this.listeners,n=this.waitingForAuth,r=this.conversationKey;this.subCloser=this.pool.subscribe(this.bp.relays,{kinds:[er],authors:[this.bp.pubkey],"#p":[ko(this.secretKey)]},{onevent:async o=>{const i=JSON.parse(Oo(o.content,r)),{id:s,result:c,error:a}=i;if(c==="auth_url"&&n[s]){delete n[s],t.onauth?t.onauth(a):console.warn(`nostr-tools/nip46: remote signer ${this.bp.pubkey} tried to send an "auth_url"='${a}' but there was no onauth() callback configured.`);return}let l=e[s];l&&(a?l.reject(a):c&&l.resolve(c),delete e[s])},onclose:()=>{this.subCloser=void 0}}),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.subCloser||this.setupSubscription(this.params),this.serial++;const o=`${this.idPrefix}-${this.serial}`,i=Mc(JSON.stringify({id:o,method:t,params:e}),this.conversationKey),s=Cc({kind:er,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(o){r(o)}})}async ping(){let t=await this.sendRequest("ping",[]);if(t!=="pong")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 signEvent(t){let e=await this.sendRequest("sign_event",[JSON.stringify(t)]),n=JSON.parse(e);if(So(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])}},ra=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,oa;try{oa=fetch}catch{}var rn=new TextDecoder("utf-8");new TextEncoder;var No=5e3;function ia(t){var o,i,s,c,a,l,f;let{prefix:e,words:n}=en.decode(t,No),r=new Uint8Array(en.fromWords(n));switch(e){case"nprofile":{let u=nr(r);if(!((o=u[0])!=null&&o[0]))throw new Error("missing TLV 0 for nprofile");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:ee(u[0][0]),relays:u[1]?u[1].map(g=>rn.decode(g)):[]}}}case"nevent":{let u=nr(r);if(!((i=u[0])!=null&&i[0]))throw new Error("missing TLV 0 for nevent");if(u[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(u[2]&&u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(u[3]&&u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:ee(u[0][0]),relays:u[1]?u[1].map(g=>rn.decode(g)):[],author:(s=u[2])!=null&&s[0]?ee(u[2][0]):void 0,kind:(c=u[3])!=null&&c[0]?parseInt(ee(u[3][0]),16):void 0}}}case"naddr":{let u=nr(r);if(!((a=u[0])!=null&&a[0]))throw new Error("missing TLV 0 for naddr");if(!((l=u[2])!=null&&l[0]))throw new Error("missing TLV 2 for naddr");if(u[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!((f=u[3])!=null&&f[0]))throw new Error("missing TLV 3 for naddr");if(u[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:rn.decode(u[0][0]),pubkey:ee(u[2][0]),kind:parseInt(ee(u[3][0]),16),relays:u[1]?u[1].map(g=>rn.decode(g)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:ee(r)};default:throw new Error(`unknown prefix ${e}`)}}function nr(t){let e={},n=t;for(;n.length>0;){let r=n[0],o=n[1],i=n.slice(2,2+o);if(n=n.slice(2+o),i.length<o)throw new Error(`not enough data to read on TLV ${r}`);e[r]=e[r]||[],e[r].push(i)}return e}function sa(t){return aa("npub",Sr(t))}function ca(t,e){let n=en.toWords(e);return en.encode(t,n,No)}function aa(t,e){return ca(t,e)}const xt=[];function la(t,e=M){let n;const r=new Set;function o(c){if(an(t,c)&&(t=c,n)){const a=!xt.length;for(const l of r)l[1](),xt.push(l,t);if(a){for(let l=0;l<xt.length;l+=2)xt[l][0](xt[l+1]);xt.length=0}}}function i(c){o(c(t))}function s(c,a=M){const l=[c,a];return r.add(l),r.size===1&&(n=e(o,i)||M),c(t),()=>{r.delete(l),r.size===0&&n&&(n(),n=null)}}return{set:o,update:i,subscribe:s}}const ua=t=>{const{subscribe:e,set:n}=la(void 0,()=>{const r=window.matchMedia(t);n(r.matches);const o=()=>n(r.matches);return r.addEventListener("change",o),()=>{r.removeEventListener("change",o)}});return{subscribe:e}};function fa(t){let e,n,r;return{c(){e=ln("svg"),n=ln("circle"),r=ln("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(o,i){$(o,e,i),O(e,n),O(e,r)},p:M,i:M,o:M,d(o){o&&q(e)}}}class Ro extends _r{constructor(e){super(),Er(this,e,null,fa,an,{})}}const Ce=16,rr=new Uint8Array(16),Ae=ne(rr),da=225,ha=(t,e,n,r)=>{const o=r&1;return{s3:n<<31|r>>>1,s2:e<<31|n>>>1,s1:t<<31|e>>>1,s0:t>>>1^da<<24&-(o&1)}},me=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function pa(t){t.reverse();const e=t[15]&1;let n=0;for(let r=0;r<t.length;r++){const o=t[r];t[r]=o>>>1|n,n=(o&1)<<7}return t[0]^=-e&225,t}const ga=t=>t>64*1024?8:t>1024?4:2;class qo{constructor(e,n){this.blockLen=Ce,this.outputLen=Ce,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=Ve(e),ye(e,16);const r=ac(e);let o=r.getUint32(0,!1),i=r.getUint32(4,!1),s=r.getUint32(8,!1),c=r.getUint32(12,!1);const a=[];for(let p=0;p<128;p++)a.push({s0:me(o),s1:me(i),s2:me(s),s3:me(c)}),{s0:o,s1:i,s2:s,s3:c}=ha(o,i,s,c);const l=ga(n||1024);if(![1,2,4,8].includes(l))throw new Error(`ghash: wrong window size=${l}, should be 2, 4 or 8`);this.W=l;const u=128/l,g=this.windowSize=2**l,h=[];for(let p=0;p<u;p++)for(let d=0;d<g;d++){let b=0,w=0,y=0,E=0;for(let I=0;I<l;I++){if(!(d>>>l-I-1&1))continue;const{s0:k,s1:B,s2:x,s3:C}=a[l*p+I];b^=k,w^=B,y^=x,E^=C}h.push({s0:b,s1:w,s2:y,s3:E})}this.t=h}_updateBlock(e,n,r,o){e^=this.s0,n^=this.s1,r^=this.s2,o^=this.s3;const{W:i,t:s,windowSize:c}=this;let a=0,l=0,f=0,u=0;const g=(1<<i)-1;let h=0;for(const p of[e,n,r,o])for(let d=0;d<4;d++){const b=p>>>8*d&255;for(let w=8/i-1;w>=0;w--){const y=b>>>i*w&g,{s0:E,s1:I,s2:P,s3:k}=s[h*c+y];a^=E,l^=I,f^=P,u^=k,h+=1}}this.s0=a,this.s1=l,this.s2=f,this.s3=u}update(e){e=Ve(e),yt(this);const n=ne(e),r=Math.floor(e.length/Ce),o=e.length%Ce;for(let i=0;i<r;i++)this._updateBlock(n[i*4+0],n[i*4+1],n[i*4+2],n[i*4+3]);return o&&(rr.set(e.subarray(r*Ce)),this._updateBlock(Ae[0],Ae[1],Ae[2],Ae[3]),Ae.fill(0)),this}destroy(){const{t:e}=this;for(const n of e)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(e){yt(this),Wn(e,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=ne(e);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,e}digest(){const e=new Uint8Array(Ce);return this.digestInto(e),this.destroy(),e}}class ba extends qo{constructor(e,n){e=Ve(e);const r=pa(e.slice());super(r,n),r.fill(0)}update(e){e=Ve(e),yt(this);const n=ne(e),r=e.length%Ce,o=Math.floor(e.length/Ce);for(let i=0;i<o;i++)this._updateBlock(me(n[i*4+3]),me(n[i*4+2]),me(n[i*4+1]),me(n[i*4+0]));return r&&(rr.set(e.subarray(o*Ce)),this._updateBlock(me(Ae[3]),me(Ae[2]),me(Ae[1]),me(Ae[0])),Ae.fill(0)),this}digestInto(e){yt(this),Wn(e,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=ne(e);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,e.reverse()}}function $o(t){const e=(r,o)=>t(o,r.length).update(Ve(r)).digest(),n=t(new Uint8Array(16),0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=(r,o)=>t(r,o),e}$o((t,e)=>new qo(t,e)),$o((t,e)=>new ba(t,e));const Ge=16,wa=283;function or(t){return t<<1^wa&-(t>>7)}function Et(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(e&1),t=or(t);return n}const ir=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=or(r))t[n]=r;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]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return e})(),ya=ir.map((t,e)=>ir.indexOf(e)),ma=t=>t<<24|t>>>8,sr=t=>t<<8|t>>>24;function Mo(t,e){if(t.length!==256)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((l,f)=>e(t[f])),r=n.map(sr),o=r.map(sr),i=o.map(sr),s=new Uint32Array(256*256),c=new Uint32Array(256*256),a=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let f=0;f<256;f++){const u=l*256+f;s[u]=n[l]^r[f],c[u]=o[l]^i[f],a[u]=t[l]<<8|t[f]}return{sbox:t,sbox2:a,T0:n,T1:r,T2:o,T3:i,T01:s,T23:c}}const cr=Mo(ir,t=>Et(t,3)<<24|t<<16|t<<8|Et(t,2)),zo=Mo(ya,t=>Et(t,11)<<24|Et(t,13)<<16|Et(t,9)<<8|Et(t,14)),va=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=or(n))t[e]=n;return t})();function jo(t){ye(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}=cr,r=ne(t),o=r.length,i=c=>Te(n,c,c,c,c),s=new Uint32Array(e+28);s.set(r);for(let c=o;c<s.length;c++){let a=s[c-1];c%o===0?a=i(ma(a))^va[c/o-1]:o>6&&c%o===4&&(a=i(a)),s[c]=s[c-o]^a}return s}function xa(t){const e=jo(t),n=e.slice(),r=e.length,{sbox2:o}=cr,{T0:i,T1:s,T2:c,T3:a}=zo;for(let l=0;l<r;l+=4)for(let f=0;f<4;f++)n[l+f]=e[r-l-4+f];e.fill(0);for(let l=4;l<r-4;l++){const f=n[l],u=Te(o,f,f,f,f);n[l]=i[u&255]^s[u>>>8&255]^c[u>>>16&255]^a[u>>>24]}return n}function Ye(t,e,n,r,o,i){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|i>>>24&255]}function Te(t,e,n,r,o){return t[e&255|n&65280]|t[r>>>16&255|o>>>16&65280]<<16}function Ko(t,e,n,r,o){const{sbox2:i,T01:s,T23:c}=cr;let a=0;e^=t[a++],n^=t[a++],r^=t[a++],o^=t[a++];const l=t.length/4-2;for(let p=0;p<l;p++){const d=t[a++]^Ye(s,c,e,n,r,o),b=t[a++]^Ye(s,c,n,r,o,e),w=t[a++]^Ye(s,c,r,o,e,n),y=t[a++]^Ye(s,c,o,e,n,r);e=d,n=b,r=w,o=y}const f=t[a++]^Te(i,e,n,r,o),u=t[a++]^Te(i,n,r,o,e),g=t[a++]^Te(i,r,o,e,n),h=t[a++]^Te(i,o,e,n,r);return{s0:f,s1:u,s2:g,s3:h}}function Ea(t,e,n,r,o){const{sbox2:i,T01:s,T23:c}=zo;let a=0;e^=t[a++],n^=t[a++],r^=t[a++],o^=t[a++];const l=t.length/4-2;for(let p=0;p<l;p++){const d=t[a++]^Ye(s,c,e,o,r,n),b=t[a++]^Ye(s,c,n,e,o,r),w=t[a++]^Ye(s,c,r,n,e,o),y=t[a++]^Ye(s,c,o,r,n,e);e=d,n=b,r=w,o=y}const f=t[a++]^Te(i,e,o,r,n),u=t[a++]^Te(i,n,e,o,r),g=t[a++]^Te(i,r,n,e,o),h=t[a++]^Te(i,o,r,n,e);return{s0:f,s1:u,s2:g,s3:h}}function Wo(t,e){if(!e)return new Uint8Array(t);if(ye(e),e.length<t)throw new Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);return e}function _a(t){if(ye(t),t.length%Ge!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ge}`)}function ka(t,e,n){let r=t.length;const o=r%Ge;if(!e&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=ne(t);if(e){let a=Ge-o;a||(a=Ge),r=r+a}const s=Wo(r,n),c=ne(s);return{b:i,o:c,out:s}}function Sa(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 i=0;i<r;i++)if(t[n-i-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function Aa(t){const e=new Uint8Array(16),n=ne(e);e.set(t);const r=Ge-t.length;for(let o=Ge-r;o<Ge;o++)e[o]=r;return n}const Do=uc({blockSize:16,nonceLength:16},function(e,n,r={}){ye(e),ye(n,16);const o=!r.disablePadding;return{encrypt:(i,s)=>{const c=jo(e),{b:a,o:l,out:f}=ka(i,o,s),u=ne(n);let g=u[0],h=u[1],p=u[2],d=u[3],b=0;for(;b+4<=a.length;)g^=a[b+0],h^=a[b+1],p^=a[b+2],d^=a[b+3],{s0:g,s1:h,s2:p,s3:d}=Ko(c,g,h,p,d),l[b++]=g,l[b++]=h,l[b++]=p,l[b++]=d;if(o){const w=Aa(i.subarray(b*4));g^=w[0],h^=w[1],p^=w[2],d^=w[3],{s0:g,s1:h,s2:p,s3:d}=Ko(c,g,h,p,d),l[b++]=g,l[b++]=h,l[b++]=p,l[b++]=d}return c.fill(0),f},decrypt:(i,s)=>{_a(i);const c=xa(e),a=ne(n),l=Wo(i.length,s),f=ne(i),u=ne(l);let g=a[0],h=a[1],p=a[2],d=a[3];for(let b=0;b+4<=f.length;){const w=g,y=h,E=p,I=d;g=f[b+0],h=f[b+1],p=f[b+2],d=f[b+3];const{s0:P,s1:k,s2:B,s3:x}=Ea(c,g,h,p,d);u[b++]=P^w,u[b++]=k^y,u[b++]=B^E,u[b++]=x^I}return c.fill(0),Sa(l,o)}}});var Ta=new TextDecoder("utf-8"),Ia=new TextEncoder;function Pa(t,e,n){const r=t instanceof Uint8Array?ee(t):t,o=ot.getSharedSecret(r,"02"+e),i=Vo(o);let s=Uint8Array.from(vn(16)),c=Ia.encode(n),a=Do(i,s).encrypt(c),l=He.encode(new Uint8Array(a)),f=He.encode(new Uint8Array(s.buffer));return`${l}?iv=${f}`}function Ba(t,e,n){const r=t instanceof Uint8Array?ee(t):t;let[o,i]=n.split("?iv="),s=ot.getSharedSecret(r,"02"+e),c=Vo(s),a=He.decode(i),l=He.decode(o),f=Do(c,a).decrypt(l);return Ta.decode(f)}function Vo(t){return t.slice(1,33)}var Oa=new TextDecoder("utf-8"),La=new TextEncoder,Fo=1,Go=65535;function Yo(t,e){const n=ot.getSharedSecret(t,"02"+e).subarray(1,33);return fo(Be,n,"nip44-v2")}function Zo(t,e){const n=po(Be,t,e,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Jo(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("expected positive integer");if(t<=32)return 32;const e=1<<Math.floor(Math.log2(t-1))+1,n=e<=256?32:e/8;return n*(Math.floor((t-1)/n)+1)}function Ua(t){if(!Number.isSafeInteger(t)||t<Fo||t>Go)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}function Ha(t){const e=La.encode(t),n=e.length,r=Ua(n),o=new Uint8Array(Jo(n)-n);return ht(r,e,o)}function Ca(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e<Fo||e>Go||n.length!==e||t.length!==2+Jo(e))throw new Error("invalid padding");return Oa.decode(n)}function Qo(t,e,n){if(n.length!==32)throw new Error("AAD associated data must be 32 bytes");const r=ht(n,e);return Bt(Be,t,r)}function Na(t){if(typeof t!="string")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=He.decode(t)}catch(i){throw new Error("invalid base64: "+i.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(o!==2)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function Ra(t,e,n=vn(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=Zo(e,n),s=Ha(t),c=Jt(r,o,s),a=Qo(i,c,n);return He.encode(ht(new Uint8Array([2]),n,c,a))}function qa(t,e){const{nonce:n,ciphertext:r,mac:o}=Na(t),{chacha_key:i,chacha_nonce:s,hmac_key:c}=Zo(e,n),a=Qo(c,r,n);if(!co(a,o))throw new Error("invalid MAC");const l=Jt(i,s,r);return Ca(l)}const{window:ar}=vi;function $a(t){let e,n,r,o,i,s,c,a,l,f,u,g,h=!t[18]&&!t[11]&&!t[12]&&!t[13]&&Xo(t);const p=[Ga,Fa,Va,Da,Wa,Ka,ja],d=[];function b(w,y){return w[11]?0:w[12]?1:w[13]?2:w[18]?3:w[16]?4:w[19]?6:5}return c=b(t),a=d[c]=p[c](t),{c(){e=H("div"),n=H("button"),r=G("⤫"),i=J(),h&&h.c(),s=J(),a.c(),S(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"),S(e,"class",l="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[24])},m(w,y){$(w,e,y),O(e,n),O(n,r),O(e,i),h&&h.m(e,null),O(e,s),d[c].m(e,null),f=!0,u||(g=ce(n,"click",function(){cn(t[18]?t[29]:t[27])&&(t[18]?t[29]:t[27]).apply(this,arguments)}),u=!0)},p(w,y){t=w,(!f||y[0]&1&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"))&&S(n,"class",o),!t[18]&&!t[11]&&!t[12]&&!t[13]?h?h.p(t,y):(h=Xo(t),h.c(),h.m(e,s)):h&&(h.d(1),h=null);let E=c;c=b(t),c===E?d[c].p(t,y):(qt(),Ee(d[E],1,1,()=>{d[E]=null}),$t(),a=d[c],a?a.p(t,y):(a=d[c]=p[c](t),a.c()),xe(a,1),a.m(e,null)),(!f||y[0]&16777217&&l!==(l="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[24]))&&S(e,"class",l)},i(w){f||(xe(a),f=!0)},o(w){Ee(a),f=!1},d(w){w&&q(e),h&&h.d(),d[c].d(),u=!1,g()}}}function Ma(t){let e,n,r,o,i;const s=[nl,tl,el,Xa],c=[];function a(l,f){return l[10]?0:l[19]?l[2]?3:2:1}return n=a(t),r=c[n]=s[n](t),{c(){e=H("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[24])},m(l,f){$(l,e,f),c[n].m(e,null),i=!0},p(l,f){let u=n;n=a(l),n===u?c[n].p(l,f):(qt(),Ee(c[u],1,1,()=>{c[u]=null}),$t(),r=c[n],r?r.p(l,f):(r=c[n]=s[n](l),r.c()),xe(r,1),r.m(e,null)),(!i||f[0]&16777217&&o!==(o="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-"+l[0]+"-700 hover:bg-"+l[0]+"-800 "+l[24]))&&S(e,"class",o)},i(l){i||(xe(r),i=!0)},o(l){Ee(r),i=!1},d(l){l&&q(e),c[n].d()}}}function za(t){return{c:M,m:M,p:M,i:M,o:M,d:M}}function Xo(t){let e,n,r,o,i;return{c(){e=H("button"),n=G("?"),S(e,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")},m(s,c){$(s,e,c),O(e,n),o||(i=ce(e,"click",t[28]),o=!0)},p(s,c){c[0]&1&&r!==(r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+s[0]+"-600")&&S(e,"class",r)},d(s){s&&q(e),o=!1,i()}}}function ja(t){let e,n,r,o,i,s,c=t[19].npub+"",a,l,f,u,g,h,p,d,b,w,y=(t[19].picture||t[19].name)&&ei(t),E=!t[9]&&ri(t);return{c(){e=H("div"),n=H("div"),n.textContent="You are connected to Nostr as",r=J(),o=H("a"),y&&y.c(),i=J(),s=H("div"),a=G(c),f=J(),u=H("button"),g=G("Disconnect"),p=J(),E&&E.c(),d=un(),S(n,"class","mb-4 text-sm"),S(s,"class","block break-all"),S(o,"target","_blank"),S(o,"href",l="https://nosta.me/"+t[19].npub),S(o,"class","group text-white no-underline"),S(e,"class","text-center"),S(u,"class",h="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")},m(I,P){$(I,e,P),O(e,n),O(e,r),O(e,o),y&&y.m(o,null),O(o,i),O(o,s),O(s,a),$(I,f,P),$(I,u,P),O(u,g),$(I,p,P),E&&E.m(I,P),$(I,d,P),b||(w=ce(u,"click",t[32]),b=!0)},p(I,P){I[19].picture||I[19].name?y?y.p(I,P):(y=ei(I),y.c(),y.m(o,i)):y&&(y.d(1),y=null),P[0]&524288&&c!==(c=I[19].npub+"")&&Me(a,c),P[0]&524288&&l!==(l="https://nosta.me/"+I[19].npub)&&S(o,"href",l),P[0]&1&&h!==(h="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-"+I[0]+"-900 hover:bg-"+I[0]+"-950")&&S(u,"class",h),I[9]?E&&(E.d(1),E=null):E?E.p(I,P):(E=ri(I),E.c(),E.m(d.parentNode,d))},i:M,o:M,d(I){I&&(q(e),q(f),q(u),q(p),q(d)),y&&y.d(),E&&E.d(I),b=!1,w()}}}function Ka(t){let e,n,r,o,i,s,c,a,l,f,u,g,h,p,d,b,w,y=t[17]&&oi(t);const E=[Za,Ya],I=[];function P(x,C){return x[10]?0:1}a=P(t),l=I[a]=E[a](t);let k=t[10]&&t[14]&&ii(t),B=!t[10]&&si(t);return{c(){e=H("div"),e.textContent="How do you want to connect to Nostr?",n=J(),r=H("form"),o=H("input"),i=J(),y&&y.c(),s=J(),c=H("button"),l.c(),g=J(),k&&k.c(),h=J(),B&&B.c(),p=un(),S(e,"class","text-center text-lg"),S(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),S(o,"placeholder","bunker://... or nsec1..."),o.autofocus=!0,o.disabled=t[10],S(o,"autocapitalize","none"),S(c,"class",f="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"),c.disabled=u=!t[23]||t[10],S(r,"class","mb-1 mt-4 flex flex-col")},m(x,C){$(x,e,C),$(x,n,C),$(x,r,C),O(r,o),t[46](o),wr(o,t[4]),O(r,i),y&&y.m(r,null),O(r,s),O(r,c),I[a].m(c,null),O(r,g),k&&k.m(r,null),$(x,h,C),B&&B.m(x,C),$(x,p,C),d=!0,o.focus(),b||(w=[ce(o,"input",t[47]),ce(r,"submit",t[48])],b=!0)},p(x,C){(!d||C[0]&1024)&&(o.disabled=x[10]),C[0]&16&&o.value!==x[4]&&wr(o,x[4]),x[17]?y?y.p(x,C):(y=oi(x),y.c(),y.m(r,s)):y&&(y.d(1),y=null);let U=a;a=P(x),a!==U&&(qt(),Ee(I[U],1,1,()=>{I[U]=null}),$t(),l=I[a],l||(l=I[a]=E[a](x),l.c()),xe(l,1),l.m(c,null)),(!d||C[0]&1&&f!==(f="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-"+x[0]+"-900 hover:bg-"+x[0]+"-950"))&&S(c,"class",f),(!d||C[0]&8389632&&u!==(u=!x[23]||x[10]))&&(c.disabled=u),x[10]&&x[14]?k?k.p(x,C):(k=ii(x),k.c(),k.m(r,null)):k&&(k.d(1),k=null),x[10]?B&&(B.d(1),B=null):B?B.p(x,C):(B=si(x),B.c(),B.m(p.parentNode,p))},i(x){d||(xe(l),d=!0)},o(x){Ee(l),d=!1},d(x){x&&(q(e),q(n),q(r),q(h),q(p)),t[46](null),y&&y.d(),I[a].d(),k&&k.d(),B&&B.d(x),b=!1,$e(w)}}}function Wa(t){let e,n,r,o,i,s,c,a,l,f,u,g,h,p,d;return{c(){e=H("div"),e.textContent="Create a Nostr account",n=J(),r=H("div"),r.textContent=`To use this Nostr app you need a profile. The following button opens a
|
|
2
2
|
wizard that help you to create your keypair and safely manage it in a
|
|
3
|
-
few steps. Are you ready?`,o=
|
|
3
|
+
few steps. Are you ready?`,o=J(),i=H("button"),s=G("Create an account »"),a=J(),l=H("div"),f=G("Do you already have a Nostr address?"),u=H("br"),g=J(),h=H("button"),h.textContent="Login now",S(e,"class","text-center text-lg"),S(r,"class","mt-4 text-base leading-5"),S(i,"class",c="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"),i.disabled=al,S(h,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),S(l,"class","mt-6 text-center text-sm leading-3")},m(b,w){$(b,e,w),$(b,n,w),$(b,r,w),$(b,o,w),$(b,i,w),O(i,s),$(b,a,w),$(b,l,w),O(l,f),O(l,u),O(l,g),O(l,h),p||(d=[ce(i,"click",t[39]),ce(h,"click",t[34])],p=!0)},p(b,w){w[0]&1&&c!==(c="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-"+b[0]+"-900 hover:bg-"+b[0]+"-950")&&S(i,"class",c)},i:M,o:M,d(b){b&&(q(e),q(n),q(r),q(o),q(i),q(a),q(l)),p=!1,$e(d)}}}function Da(t){let e,n,r;return{c(){e=H("div"),e.textContent="What is that?",n=J(),r=H("div"),r.innerHTML=`<p class="mb mt-4">This widget is created with <i>window.nostr.js</i>, a small script
|
|
4
4
|
you can drop in any page that already uses NIP-07 and make it also
|
|
5
5
|
work with NIP-46 automatically when the user doesn't have an
|
|
6
6
|
extension installed.
|
|
7
7
|
<br/>
|
|
8
8
|
It adds a small floating button on the side of the window that users
|
|
9
9
|
can use to create Nostr accuonts or connect to their NIP-46 bunkers.</p> <p class="mt-4">This tool is opensource, get the code from the <a target="_blank" class="underline" href="https://github.com/fiatjaf/window.nostr.js">project's page</a>.</p> <p class="mt-4">You don't know what Nostr is?
|
|
10
|
-
<a target="_blank" class="underline" href="https://www.nostr.com">Learn more</a>.</p>`,S(
|
|
10
|
+
<a target="_blank" class="underline" href="https://www.nostr.com">Learn more</a>.</p>`,S(e,"class","text-center text-lg"),S(r,"class","text-base leading-5")},m(o,i){$(o,e,i),$(o,n,i),$(o,r,i)},p:M,i:M,o:M,d(o){o&&(q(e),q(n),q(r))}}}function Va(t){let e,n,r,o,i,s,c=new URL(t[13]).host+"",a,l,f,u,g,h,p,d,b,w;return{c(){e=H("div"),n=H("div"),n.textContent="An action requires your confirmation",r=J(),o=H("div"),i=G("A new window will now open, taking you to "),s=H("strong"),a=G(c),l=G(`
|
|
11
11
|
where you can approve the current action. If nothing happens, ensure
|
|
12
|
-
your browser is not blocking popups.`),f=
|
|
13
|
-
Afterward, you'll be redirected back to this page.`),g=
|
|
12
|
+
your browser is not blocking popups.`),f=H("br"),u=G(`
|
|
13
|
+
Afterward, you'll be redirected back to this page.`),g=J(),h=H("button"),p=G("Confirm action »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(h,"class",d="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(y,E){$(y,e,E),O(e,n),O(e,r),O(e,o),O(o,i),O(o,s),O(s,a),O(o,l),O(o,f),O(o,u),O(e,g),O(e,h),O(h,p),b||(w=ce(h,"click",t[45]),b=!0)},p(y,E){E[0]&8192&&c!==(c=new URL(y[13]).host+"")&&Me(a,c),E[0]&1&&d!==(d="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-"+y[0]+"-900 hover:bg-"+y[0]+"-950")&&S(h,"class",d)},i:M,o:M,d(y){y&&q(e),b=!1,w()}}}function Fa(t){let e,n,r,o,i,s,c=new URL(t[12]).host+"",a,l,f,u,g,h,p,d,b,w;return{c(){e=H("div"),n=H("div"),n.textContent="Login into a Nostr account",r=J(),o=H("div"),i=G("A new window will now open, taking you to "),s=H("strong"),a=G(c),l=G(`
|
|
14
14
|
where you can login and approve the permissions. If nothing happens,
|
|
15
|
-
ensure your browser is not blocking popups. `),f=
|
|
16
|
-
Afterward, you'll be redirected back to this page.`),g=
|
|
17
|
-
`),s=
|
|
15
|
+
ensure your browser is not blocking popups. `),f=H("br"),u=G(`
|
|
16
|
+
Afterward, you'll be redirected back to this page.`),g=J(),h=H("button"),p=G("Login now »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(h,"class",d="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(y,E){$(y,e,E),O(e,n),O(e,r),O(e,o),O(o,i),O(o,s),O(s,a),O(o,l),O(o,f),O(o,u),O(e,g),O(e,h),O(h,p),b||(w=ce(h,"click",t[44]),b=!0)},p(y,E){E[0]&4096&&c!==(c=new URL(y[12]).host+"")&&Me(a,c),E[0]&1&&d!==(d="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-"+y[0]+"-900 hover:bg-"+y[0]+"-950")&&S(h,"class",d)},i:M,o:M,d(y){y&&q(e),b=!1,w()}}}function Ga(t){let e,n,r,o,i,s,c=new URL(t[11]).host+"",a,l,f,u,g,h,p,d,b,w;return{c(){e=H("div"),n=H("div"),n.textContent="Create a Nostr account",r=J(),o=H("div"),i=G(`A new window will now open, taking you to
|
|
17
|
+
`),s=H("strong"),a=G(c),l=G(`
|
|
18
18
|
where the account creation will occur. If nothing happens, ensure your
|
|
19
19
|
browser is not blocking popups.
|
|
20
|
-
`),f=
|
|
21
|
-
`),
|
|
22
|
-
`),r=
|
|
23
|
-
`),
|
|
20
|
+
`),f=H("br"),u=G(" Afterward, you'll be redirected back to this page."),g=J(),h=H("button"),p=G("Start account creation »"),S(n,"class","text-center text-lg"),S(o,"class","mt-4 text-center text-sm leading-4"),S(h,"class",d="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(y,E){$(y,e,E),O(e,n),O(e,r),O(e,o),O(o,i),O(o,s),O(s,a),O(o,l),O(o,f),O(o,u),O(e,g),O(e,h),O(h,p),b||(w=ce(h,"click",t[43]),b=!0)},p(y,E){E[0]&2048&&c!==(c=new URL(y[11]).host+"")&&Me(a,c),E[0]&1&&d!==(d="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-"+y[0]+"-900 hover:bg-"+y[0]+"-950")&&S(h,"class",d)},i:M,o:M,d(y){y&&q(e),b=!1,w()}}}function ei(t){let e,n,r=t[19].picture&&ti(t),o=t[19].name&&ni(t);return{c(){e=H("div"),r&&r.c(),n=J(),o&&o.c(),S(e,"class","mb-2 flex items-center justify-center gap-2")},m(i,s){$(i,e,s),r&&r.m(e,null),O(e,n),o&&o.m(e,null)},p(i,s){i[19].picture?r?r.p(i,s):(r=ti(i),r.c(),r.m(e,n)):r&&(r.d(1),r=null),i[19].name?o?o.p(i,s):(o=ni(i),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(i){i&&q(e),r&&r.d(),o&&o.d()}}}function ti(t){let e,n,r;return{c(){e=H("img"),lt(e.src,n=t[19].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(o,i){$(o,e,i)},p(o,i){i[0]&524288&&!lt(e.src,n=o[19].picture)&&S(e,"src",n),i[0]&1&&r!==(r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+o[0]+"-100")&&S(e,"class",r)},d(o){o&&q(e)}}}function ni(t){let e,n=t[19].name+"",r;return{c(){e=H("div"),r=G(n),S(e,"class","text-3xl decoration-2 underline-offset-4 group-hover:underline")},m(o,i){$(o,e,i),O(e,r)},p(o,i){i[0]&524288&&n!==(n=o[19].name+"")&&Me(r,n)},d(o){o&&q(e)}}}function ri(t){let e,n,r,o,i=zn(t[8])+"",s;return{c(){e=H("div"),n=G("This webpage is using the public key:"),r=H("br"),o=J(),s=G(i),S(e,"class","mt-6 block break-all text-center text-xs")},m(c,a){$(c,e,a),O(e,n),O(e,r),O(e,o),O(e,s)},p(c,a){a[0]&256&&i!==(i=zn(c[8])+"")&&Me(s,i)},d(c){c&&q(e)}}}function oi(t){let e,n;return{c(){e=H("div"),n=G(t[17]),S(e,"class","my-2 rounded bg-yellow-100 p-2 text-center text-sm leading-4 text-red-400")},m(r,o){$(r,e,o),O(e,n)},p(r,o){o[0]&131072&&Me(n,r[17])},d(r){r&&q(e)}}}function Ya(t){let e;return{c(){e=G("Connect »")},m(n,r){$(n,e,r)},i:M,o:M,d(n){n&&q(e)}}}function Za(t){let e,n,r;return n=new Ro({}),{c(){e=G(`Connecting to bunker
|
|
21
|
+
`),xr(n.$$.fragment)},m(o,i){$(o,e,i),pn(n,o,i),r=!0},i(o){r||(xe(n.$$.fragment,o),r=!0)},o(o){Ee(n.$$.fragment,o),r=!1},d(o){o&&q(e),gn(n,o)}}}function ii(t){let e,n,r,o,i;return{c(){e=H("div"),n=G(`Waiting too much?
|
|
22
|
+
`),r=H("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(s,c){$(s,e,c),O(e,n),O(e,r),o||(i=ce(r,"click",t[35]),o=!0)},p:M,d(s){s&&q(e),o=!1,i()}}}function si(t){let e;function n(i,s){return i[15]?Qa:Ja}let r=n(t),o=r(t);return{c(){e=H("div"),o.c(),S(e,"class","mt-6 text-center text-sm leading-3")},m(i,s){$(i,e,s),o.m(e,null)},p(i,s){r===(r=n(i))&&o?o.p(i,s):(o.d(1),o=r(i),o&&(o.c(),o.m(e,null)))},d(i){i&&q(e),o.d()}}}function Ja(t){let e,n,r,o,i,s;return{c(){e=G("Do you need a Nostr account?"),n=H("br"),r=J(),o=H("button"),o.textContent="Sign up now",S(o,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline")},m(c,a){$(c,e,a),$(c,n,a),$(c,r,a),$(c,o,a),i||(s=ce(o,"click",t[39]),i=!0)},p:M,d(c){c&&(q(e),q(n),q(r),q(o)),i=!1,s()}}}function Qa(t){let e,n,r,o,i,s;return{c(){e=G("Is this bunker provider broken?"),n=H("br"),r=J(),o=H("button"),o.textContent="Clear it",S(o,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline")},m(c,a){$(c,e,a),$(c,n,a),$(c,r,a),$(c,o,a),i||(s=ce(o,"click",t[33]),i=!0)},p:M,d(c){c&&(q(e),q(n),q(r),q(o)),i=!1,s()}}}function Xa(t){let e,n;return{c(){e=H("img"),lt(e.src,n=t[19].picture)||S(e,"src",n),S(e,"alt",""),S(e,"class","h-6 w-6 rounded-full")},m(r,o){$(r,e,o)},p(r,o){o[0]&524288&&!lt(e.src,n=r[19].picture)&&S(e,"src",n)},i:M,o:M,d(r){r&&q(e)}}}function el(t){let e,n,r,o=(t[19].name||t[19].npub.slice(0,7)+"…"+t[19].npub.slice(-4))+"",i;function s(l,f){return l[19].picture?ol:rl}let c=s(t),a=c(t);return{c(){e=H("div"),a.c(),n=J(),r=H("div"),i=G(o),S(r,"class","inline-block max-w-56 overflow-hidden overflow-ellipsis whitespace-nowrap"),S(e,"class","flex items-center px-2")},m(l,f){$(l,e,f),a.m(e,null),O(e,n),O(e,r),O(r,i)},p(l,f){c===(c=s(l))&&a?a.p(l,f):(a.d(1),a=c(l),a&&(a.c(),a.m(e,n))),f[0]&524288&&o!==(o=(l[19].name||l[19].npub.slice(0,7)+"…"+l[19].npub.slice(-4))+"")&&Me(i,o)},i:M,o:M,d(l){l&&q(e),a.d()}}}function tl(t){let e;function n(i,s){return i[2]?sl:il}let r=n(t),o=r(t);return{c(){o.c(),e=un()},m(i,s){o.m(i,s),$(i,e,s)},p(i,s){r!==(r=n(i))&&(o.d(1),o=r(i),o&&(o.c(),o.m(e.parentNode,e)))},i:M,o:M,d(i){i&&q(e),o.d(i)}}}function nl(t){let e,n,r,o;return r=new Ro({}),{c(){e=H("div"),n=G(`Connecting to bunker
|
|
23
|
+
`),xr(r.$$.fragment),S(e,"class","flex items-center px-2")},m(i,s){$(i,e,s),O(e,n),pn(r,e,null),o=!0},p:M,i(i){o||(xe(r.$$.fragment,i),o=!0)},o(i){Ee(r.$$.fragment,i),o=!1},d(i){i&&q(e),gn(r)}}}function rl(t){let e;return{c(){e=H("span"),e.textContent="☉",S(e,"class","mr-2")},m(n,r){$(n,e,r)},p:M,d(n){n&&q(e)}}}function ol(t){let e,n;return{c(){e=H("img"),lt(e.src,n=t[19].picture)||S(e,"src",n),S(e,"alt",""),S(e,"class","mr-2 h-5 w-5 rounded-full")},m(r,o){$(r,e,o)},p(r,o){o[0]&524288&&!lt(e.src,n=r[19].picture)&&S(e,"src",n)},d(r){r&&q(e)}}}function il(t){let e;return{c(){e=H("div"),e.textContent="Connect with Nostr",S(e,"class","flex items-center px-2")},m(n,r){$(n,e,r)},d(n){n&&q(e)}}}function sl(t){let e;return{c(){e=H("div"),e.textContent="N",S(e,"class","w-6 text-center")},m(n,r){$(n,e,r)},d(n){n&&q(e)}}}function cl(t){let e,n,r,o,i,s,c;const a=[za,Ma,$a],l=[];function f(u,g){return!u[22]&&!u[19]&&u[1]?0:u[22]?2:1}return n=f(t),r=l[n]=a[n](t),{c(){e=H("div"),r.c(),S(e,"class","draggable z-[9000] animate-fadein font-sans text-white"),S(e,"style",o="position: fixed; "+(t[22]&&t[5]?"width: 100vw;":"")+"; right: "+(t[22]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[22]&&t[5]?"bottom: 0px":t[21]+":"+t[20]+"px")),yr(e,"cursor-pointer",!t[19]&&!t[22])},m(u,g){$(u,e,g),l[n].m(e,null),t[49](e),i=!0,s||(c=[ce(ar,"click",t[26]),ce(ar,"mouseup",t[38]),ce(ar,"mousemove",t[37]),ce(e,"mousedown",t[36])],s=!0)},p(u,g){let h=n;n=f(u),n===h?l[n].p(u,g):(qt(),Ee(l[h],1,1,()=>{l[h]=null}),$t(),r=l[n],r?r.p(u,g):(r=l[n]=a[n](u),r.c()),xe(r,1),r.m(e,null)),(!i||g[0]&7340072&&o!==(o="position: fixed; "+(u[22]&&u[5]?"width: 100vw;":"")+"; right: "+(u[22]&&u[5]?"0":u[3])+"px; user-select: none; "+(u[22]&&u[5]?"bottom: 0px":u[21]+":"+u[20]+"px")))&&S(e,"style",o),(!i||g[0]&4718592)&&yr(e,"cursor-pointer",!u[19]&&!u[22])},i(u){i||(xe(r),i=!0)},o(u){Ee(r),i=!1},d(u){u&&q(e),l[n].d(),t[49](null),s=!1,$e(c)}}}let al=!1;const ci="We could not connect to a NIP-46 bunker with that url, are you sure it is set up correctly?",ai="We were not able to connect using this address. For it to work it has to come from a NIP-46 provider.",Ze=20;function lr(t){return window.open(t,"window.nostr","width=600,height=800,popup=yes")}function ll(t,e,n){let r,o,i,s,c,a;const l=window.location.hostname,f=window.location.protocol,u=ua("only screen and (max-width: 640px)");mi(t,u,T=>n(5,a=T));const g={ORIGIN:"wnj:origin",CLIENT_SECRET:"wnj:clientSecret",Y_POS:"wnj:ypos",CALLBACK_TOKEN:"wnj:callbackToken",BUNKER_POINTER:"wnj:bunkerPointer"};let h,{accent:p}=e,{position:d="top"}=e,{startHidden:b}=e,{compactMode:w}=e;const y=window,E=new cc;let I,P,k;const B=localStorage.getItem(g.CLIENT_SECRET);B?k=Sr(B):(k=zs(),localStorage.setItem(g.CLIENT_SECRET,ee(k)));let x="closed",C=!1,U,N,D,V=!1,K,v,_,L=null,R=null,A=null,z=!1,F=!1,W,Q,oe=!1,X,ue,re=[],{right:ge=20}=e,se=!1,ve=!1,Lt,Ne,pe;const Je={pool:E,onauth(T){W?n(11,L=T):X?(n(13,A=T),n(41,x="opened")):n(12,R=T)}},Ut=Li(()=>{switch(x){case"justopened":n(41,x="opened");break;case"justclosed":n(41,x="closed");break}},500);function Ie(){n(41,x="justopened"),Ut()}function Ht(){n(41,x="justclosed"),Ut()}function kt(){if(U&&!_){pr();return}Ie()}dr();let bi={isWnj:!0,async getPublicKey(){return new Promise(async(T,j)=>{re.push(j);try{!v&&!_&&kt();const Z=await(await K).getPublicKey();T(Z)}catch(Z){j(Z)}finally{const Z=re.indexOf(j);Z!==-1&&re.splice(Z,1)}})},async signEvent(T){try{return!v&&!_&&kt(),await(await K).signEvent(T)}finally{n(13,A=null),Ht()}},async getRelays(){return{}},nip04:{async encrypt(T,j){return!v&&!_&&kt(),(await K).nip04Encrypt(T,j)},async decrypt(T,j){return!v&&!_&&kt(),(await K).nip04Decrypt(T,j)}},nip44:{async encrypt(T,j){return!v&&!_&&kt(),(await K).nip44Encrypt(T,j)},async decrypt(T,j){return!v&&!_&&kt(),(await K).nip44Decrypt(T,j)}}};function dr(){Ht(),U=null,K=new Promise((T,j)=>{N=T,D=j}),n(19,X=null),n(10,v=!1),n(14,z=!1),n(16,W=!1),_=!1,ue=null,n(17,Q="")}_i(()=>{const T=window.location.hash;if(T.startsWith("#nostr-login=")){const j=T.substring(T.indexOf("=")+1),Z=window.location.href.split("#")[0];history.replaceState(null,"",Z),j.startsWith("bunker://")?(n(4,P=j),C=!0,Ie(),hr()):j.startsWith("nsec1")&&(n(4,P=j),C=!0,Ie(),on())}if(!U){let j=localStorage.getItem(g.BUNKER_POINTER);if(j)if(j.startsWith("nsec1"))n(4,P=j),on(),sn();else{U=JSON.parse(j);let Z=new URL(`bunker://${U.pubkey}`);U.relays.forEach(ct=>{Z.searchParams.append("relay",ct)}),U.secret&&Z.searchParams.set("secret",U.secret),n(4,P=Z.toString()),sn(),pr()}}if(y.nostr&&!y.nostr.isWnj){y.destroyWnj();return}else Object.defineProperty(window,"nostr",{get(){return bi},set(j){bi=j,j.isWnj||y.destroyWnj(),re.forEach(Z=>{Z(new Error("Nostr extension took over, please retry the operation"))}),re=[]},configurable:!0});return()=>{ue&&ue.close()}});function dl(T){Math.abs(o-Ne)>6||Date.now()-pe>600||x==="justopened"||x==="justclosed"||(T.composedPath().find(j=>j.id==="wnj")?Ie():Ht())}function hl(T){Ht(),n(16,W=!1),n(11,L=null),n(12,R=null),n(13,A=null),T.stopPropagation()}function pl(T){n(18,oe=!0),T.stopPropagation()}function gl(T){n(18,oe=!1),T.stopPropagation()}async function hr(T){var j;(j=T==null?void 0:T.preventDefault)==null||j.call(T),n(9,V=!1);try{if(U=await ea(P),!U){P.match(nn)?n(17,Q=ci):n(17,Q=ai);return}I.setCustomValidity(""),n(17,Q=""),await pr(),sn()}catch{P.match(nn)?n(17,Q=ci):n(17,Q=ai),n(10,v=!1)}}function on(T){var j;(j=T==null?void 0:T.preventDefault)==null||j.call(T);try{const Z=P,ct=ia(Z);if(ct.type==="nsec"){const Qe=ct.data,Ol=zn(Qe);n(9,V=!0),K=Promise.resolve({async getPublicKey(){return Ol},async signEvent(Re){return js(Re,Qe)},async nip04Decrypt(Re,at){return Ba(Qe,Re,at)},async nip04Encrypt(Re,at){return Pa(Qe,Re,at)},async nip44Decrypt(Re,at){const gr=Yo(Qe,Re);return qa(at,gr)},async nip44Encrypt(Re,at){const gr=Yo(Qe,Re);return Ra(at,gr)}}),C=!0,Ie(),n(17,Q=""),n(10,v=!1),_=!0,sn(),localStorage.setItem(g.BUNKER_POINTER,Z)}}catch(Z){console.error("failed to decode nsec:",Z)}}async function bl(T){T.preventDefault(),localStorage.removeItem(g.BUNKER_POINTER),dr()}async function wl(T){T.preventDefault(),n(4,P=""),localStorage.removeItem(g.BUNKER_POINTER),n(15,F=!1)}function yl(T){n(16,W=!1)}function ml(){n(14,z=!1),n(10,v=!1),D("connection aborted"),dr(),Ie()}async function pr(T=void 0){T=T||tr.fromBunker(k,U,Je),n(10,v=!0);let j=setTimeout(()=>{n(14,z=!0),n(41,x="opened")},5e3);try{await T.connect(),_=!0,localStorage.setItem(g.BUNKER_POINTER,JSON.stringify(U)),Ht(),N(T)}catch(Z){D((Z==null?void 0:Z.message)||String(Z))}finally{clearTimeout(j),n(10,v=!1),n(14,z=!1),n(11,L=null),n(12,R=null),n(13,A=null),C&&Ie()}}async function sn(){let T;try{T=await(await K).getPublicKey()}catch{n(15,F=!0);return}n(19,X={pubkey:T,npub:sa(T),event:null}),ue=E.subscribeMany(["wss://purplepag.es","wss://indexer.coracle.social","wss://relay.snort.social","wss://relay.nos.social"],{kinds:[0],authors:[T]},{onevent(j){var Z;if(!((((Z=X.event)==null?void 0:Z.created_at)||0)>=j.created_at))try{let{name:ct,picture:Qe}=JSON.parse(j.content);n(19,X.event=j,X),n(19,X.name=ct,X),n(19,X.picture=Qe,X)}catch{}}})}function vl(T){if(i)return;se=!0;const j=h.getBoundingClientRect();Lt=T.clientY-j.top,Ne=o,pe=Date.now()}function xl(T){se&&(r==="top"?n(20,o=T.clientY):n(20,o=window.innerHeight-T.clientY),n(20,o-=Lt),n(42,ve=!0),o<Ze&&n(20,o=Ze),o>window.innerHeight-Ze&&n(20,o=window.innerHeight-Ze))}function El(){if(se=!1,setTimeout(()=>{n(42,ve=!1)},10),ve){const T=h.getBoundingClientRect(),j=window.innerHeight,Z=j/2;T.top<Z?(n(21,r="top"),n(20,o=T.top)):(n(21,r="bottom"),n(20,o=j-T.bottom)),o<Ze&&n(20,o=Ze),localStorage.setItem(g.ORIGIN,r),localStorage.setItem(g.Y_POS,o.toString())}}function _l(){window.location.href=`https://nstart.me?an=${l}&at=web&ac=${f}//${l}&sfb=yes`}const kl=()=>lr(L),Sl=()=>lr(R),Al=()=>{lr(A)};function Tl(T){Nt[T?"unshift":"push"](()=>{I=T,n(7,I)})}function Il(){P=this.value,n(4,P)}const Pl=T=>P.startsWith("nsec1")?on(T):hr(T);function Bl(T){Nt[T?"unshift":"push"](()=>{h=T,n(6,h)})}return t.$$set=T=>{"accent"in T&&n(0,p=T.accent),"position"in T&&n(40,d=T.position),"startHidden"in T&&n(1,b=T.startHidden),"compactMode"in T&&n(2,w=T.compactMode),"right"in T&&n(3,ge=T.right)},t.$$.update=()=>{t.$$.dirty[0]&32|t.$$.dirty[1]&512&&n(21,r=a?"bottom":localStorage.getItem(g.ORIGIN)||d),t.$$.dirty[0]&32&&n(20,o=a?Ze:parseInt(localStorage.getItem(g.Y_POS)||"0")||Ze),t.$$.dirty[1]&1024&&n(22,i=x==="justopened"||x==="opened"),t.$$.dirty[0]&1|t.$$.dirty[1]&2048&&n(24,s=ve?"cursor-grabbing outline-dashed outline-"+p+"-500 outline-1 outline-offset-4":"outline-none"),t.$$.dirty[0]&16&&n(23,c=P&&(P.match(nn)||P.match(ra)||P.startsWith("nsec1")&&P.length===63))},[p,b,w,ge,P,a,h,I,k,V,v,L,R,A,z,F,W,Q,oe,X,o,r,i,c,s,u,dl,hl,pl,gl,hr,on,bl,wl,yl,ml,vl,xl,El,_l,d,x,ve,kl,Sl,Al,Tl,Il,Pl,Bl]}class ul extends _r{constructor(e){super(),Er(this,e,ll,cl,an,{accent:0,position:40,startHidden:1,compactMode:2,right:3},null,[-1,-1,-1])}}const _t=window;_t.destroyWnj=()=>{setTimeout(()=>{fl.$destroy()},1)};const ur=document.createElement("div");ur.style.zIndex="90000",document.body.appendChild(ur);const fr=document.createElement("div");fr.id="wnj";const li=document.createElement("style");li.innerHTML=Xe;const ui=ur.attachShadow({mode:"open"});ui.appendChild(fr),ui.appendChild(li);const fl=new ul({target:fr,props:{accent:((fi=_t.wnjParams)==null?void 0:fi.accent)||"cyan",position:((di=_t.wnjParams)==null?void 0:di.position)==="bottom"?"bottom":"top",startHidden:(hi=_t.wnjParams)==null?void 0:hi.startHidden,compactMode:(pi=_t.wnjParams)==null?void 0:pi.compactMode}});if(!((gi=_t.wnjParams)!=null&&gi.disableOverflowFix)){const t=document.createElement("style"),e=`
|
|
24
24
|
html, body {
|
|
25
25
|
overflow: auto;
|
|
26
26
|
height: 100%;
|
|
27
27
|
}
|
|
28
|
-
`;
|
|
28
|
+
`;t.innerHTML=e,document.head.appendChild(t)}})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "window.nostr.js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/window.nostr.js",
|
|
6
6
|
"devDependencies": {
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"debounce": "2.0.0",
|
|
27
|
-
"nostr-tools": "2.
|
|
27
|
+
"nostr-tools": "2.19.4"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/App.svelte
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
generateSecretKey,
|
|
6
6
|
type VerifiedEvent,
|
|
7
7
|
type NostrEvent,
|
|
8
|
-
getPublicKey
|
|
8
|
+
getPublicKey,
|
|
9
|
+
finalizeEvent
|
|
9
10
|
} from 'nostr-tools/pure'
|
|
10
11
|
import {SimplePool, type SubCloser} from 'nostr-tools/pool'
|
|
11
12
|
import {
|
|
@@ -16,10 +17,13 @@
|
|
|
16
17
|
BUNKER_REGEX
|
|
17
18
|
} from 'nostr-tools/nip46'
|
|
18
19
|
import {NIP05_REGEX} from 'nostr-tools/nip05'
|
|
19
|
-
import {npubEncode} from 'nostr-tools/nip19'
|
|
20
|
+
import {npubEncode, decode} from 'nostr-tools/nip19'
|
|
20
21
|
import {onMount} from 'svelte'
|
|
21
22
|
import mediaQueryStore from './mediaQueryStore.js'
|
|
22
23
|
import Spinner from './Spinner.svelte'
|
|
24
|
+
import type {Signer} from './signer.js'
|
|
25
|
+
import * as nip04 from 'nostr-tools/nip04'
|
|
26
|
+
import * as nip44 from 'nostr-tools/nip44'
|
|
23
27
|
|
|
24
28
|
const currentDomain = window.location.hostname
|
|
25
29
|
const currentProtocol = window.location.protocol
|
|
@@ -61,7 +65,8 @@
|
|
|
61
65
|
let bunkerPointer: BunkerPointer | null
|
|
62
66
|
let resolveBunker: (_: BunkerSigner) => void
|
|
63
67
|
let rejectBunker: (_: string) => void
|
|
64
|
-
let
|
|
68
|
+
let plainkey = false
|
|
69
|
+
let signer: Promise<Signer>
|
|
65
70
|
let connecting: boolean
|
|
66
71
|
let connected: boolean
|
|
67
72
|
let showAuth: string | null = null
|
|
@@ -109,7 +114,8 @@
|
|
|
109
114
|
$: bunkerInputValueIsGood =
|
|
110
115
|
bunkerInputValue &&
|
|
111
116
|
(bunkerInputValue.match(BUNKER_REGEX) ||
|
|
112
|
-
bunkerInputValue.match(NIP05_REGEX)
|
|
117
|
+
bunkerInputValue.match(NIP05_REGEX) ||
|
|
118
|
+
(bunkerInputValue.startsWith('nsec1') && bunkerInputValue.length === 63))
|
|
113
119
|
|
|
114
120
|
const bunkerSignerParams: BunkerSignerParams = {
|
|
115
121
|
pool,
|
|
@@ -168,7 +174,7 @@
|
|
|
168
174
|
|
|
169
175
|
try {
|
|
170
176
|
if (!connecting && !connected) connectOrOpen()
|
|
171
|
-
const result = await (await
|
|
177
|
+
const result = await (await signer).getPublicKey()
|
|
172
178
|
resolve(result)
|
|
173
179
|
} catch (error) {
|
|
174
180
|
reject(error)
|
|
@@ -183,7 +189,7 @@
|
|
|
183
189
|
async signEvent(event: NostrEvent): Promise<VerifiedEvent> {
|
|
184
190
|
try {
|
|
185
191
|
if (!connecting && !connected) connectOrOpen()
|
|
186
|
-
return await (await
|
|
192
|
+
return await (await signer).signEvent(event)
|
|
187
193
|
} finally {
|
|
188
194
|
showConfirmAction = null
|
|
189
195
|
close()
|
|
@@ -197,21 +203,21 @@
|
|
|
197
203
|
nip04: {
|
|
198
204
|
async encrypt(pubkey: string, plaintext: string): Promise<string> {
|
|
199
205
|
if (!connecting && !connected) connectOrOpen()
|
|
200
|
-
return (await
|
|
206
|
+
return (await signer).nip04Encrypt(pubkey, plaintext)
|
|
201
207
|
},
|
|
202
208
|
async decrypt(pubkey: string, ciphertext: string): Promise<string> {
|
|
203
209
|
if (!connecting && !connected) connectOrOpen()
|
|
204
|
-
return (await
|
|
210
|
+
return (await signer).nip04Decrypt(pubkey, ciphertext)
|
|
205
211
|
}
|
|
206
212
|
},
|
|
207
213
|
nip44: {
|
|
208
214
|
async encrypt(pubkey: string, plaintext: string): Promise<string> {
|
|
209
215
|
if (!connecting && !connected) connectOrOpen()
|
|
210
|
-
return (await
|
|
216
|
+
return (await signer).nip44Encrypt(pubkey, plaintext)
|
|
211
217
|
},
|
|
212
218
|
async decrypt(pubkey: string, ciphertext: string): Promise<string> {
|
|
213
219
|
if (!connecting && !connected) connectOrOpen()
|
|
214
|
-
return (await
|
|
220
|
+
return (await signer).nip44Decrypt(pubkey, ciphertext)
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
223
|
}
|
|
@@ -219,7 +225,7 @@
|
|
|
219
225
|
function reset() {
|
|
220
226
|
close()
|
|
221
227
|
bunkerPointer = null
|
|
222
|
-
|
|
228
|
+
signer = new Promise((resolve, reject) => {
|
|
223
229
|
resolveBunker = resolve
|
|
224
230
|
rejectBunker = reject
|
|
225
231
|
})
|
|
@@ -245,36 +251,43 @@
|
|
|
245
251
|
|
|
246
252
|
if (value.startsWith('bunker://')) {
|
|
247
253
|
bunkerInputValue = value
|
|
248
|
-
const event = new SubmitEvent('submit', {
|
|
249
|
-
bubbles: true,
|
|
250
|
-
cancelable: true
|
|
251
|
-
})
|
|
252
254
|
nostrLogin = true
|
|
253
255
|
open()
|
|
254
|
-
handleConnect(
|
|
256
|
+
handleConnect()
|
|
257
|
+
} else if (value.startsWith('nsec1')) {
|
|
258
|
+
bunkerInputValue = value
|
|
259
|
+
nostrLogin = true
|
|
260
|
+
open()
|
|
261
|
+
handleNsec()
|
|
255
262
|
}
|
|
256
263
|
}
|
|
257
264
|
|
|
258
265
|
if (!bunkerPointer) {
|
|
259
266
|
let data = localStorage.getItem(lskeys.BUNKER_POINTER)
|
|
260
267
|
if (data) {
|
|
261
|
-
|
|
268
|
+
if (data.startsWith('nsec1')) {
|
|
269
|
+
bunkerInputValue = data
|
|
270
|
+
handleNsec()
|
|
271
|
+
identify()
|
|
272
|
+
} else {
|
|
273
|
+
bunkerPointer = JSON.parse(data) as BunkerPointer
|
|
262
274
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
275
|
+
// rebuild a bunker url from the pointer data so we can fill in the input
|
|
276
|
+
let bunkerURL = new URL(`bunker://${bunkerPointer.pubkey}`)
|
|
277
|
+
bunkerPointer.relays.forEach(relay => {
|
|
278
|
+
bunkerURL.searchParams.append('relay', relay)
|
|
279
|
+
})
|
|
280
|
+
if (bunkerPointer.secret) {
|
|
281
|
+
bunkerURL.searchParams.set('secret', bunkerPointer.secret)
|
|
282
|
+
}
|
|
283
|
+
bunkerInputValue = bunkerURL.toString()
|
|
284
|
+
// ~
|
|
273
285
|
|
|
274
|
-
|
|
286
|
+
identify()
|
|
275
287
|
|
|
276
|
-
|
|
277
|
-
|
|
288
|
+
// we must connect here so identify() works because we can't rely on the bunker params to read our pubkey
|
|
289
|
+
connect()
|
|
290
|
+
}
|
|
278
291
|
}
|
|
279
292
|
}
|
|
280
293
|
|
|
@@ -345,8 +358,10 @@
|
|
|
345
358
|
ev.stopPropagation()
|
|
346
359
|
}
|
|
347
360
|
|
|
348
|
-
async function handleConnect(ev
|
|
349
|
-
ev
|
|
361
|
+
async function handleConnect(ev?: SubmitEvent) {
|
|
362
|
+
ev?.preventDefault?.()
|
|
363
|
+
plainkey = false
|
|
364
|
+
|
|
350
365
|
try {
|
|
351
366
|
bunkerPointer = await parseBunkerInput(bunkerInputValue)
|
|
352
367
|
if (!bunkerPointer) {
|
|
@@ -375,6 +390,52 @@
|
|
|
375
390
|
}
|
|
376
391
|
}
|
|
377
392
|
|
|
393
|
+
function handleNsec(ev?: SubmitEvent) {
|
|
394
|
+
ev?.preventDefault?.()
|
|
395
|
+
|
|
396
|
+
try {
|
|
397
|
+
const nsec = bunkerInputValue
|
|
398
|
+
const decoded = decode(nsec)
|
|
399
|
+
if (decoded.type === 'nsec') {
|
|
400
|
+
const sk = decoded.data
|
|
401
|
+
const pk = getPublicKey(sk)
|
|
402
|
+
plainkey = true
|
|
403
|
+
signer = Promise.resolve({
|
|
404
|
+
async getPublicKey() {
|
|
405
|
+
return pk
|
|
406
|
+
},
|
|
407
|
+
async signEvent(event) {
|
|
408
|
+
return finalizeEvent(event, sk)
|
|
409
|
+
},
|
|
410
|
+
async nip04Decrypt(thirdPartyPubkey, ciphertext) {
|
|
411
|
+
return nip04.decrypt(sk, thirdPartyPubkey, ciphertext)
|
|
412
|
+
},
|
|
413
|
+
async nip04Encrypt(thirdPartyPubkey, plaintext) {
|
|
414
|
+
return nip04.encrypt(sk, thirdPartyPubkey, plaintext)
|
|
415
|
+
},
|
|
416
|
+
async nip44Decrypt(thirdPartyPubkey, ciphertext) {
|
|
417
|
+
const conv = nip44.getConversationKey(sk, thirdPartyPubkey)
|
|
418
|
+
return nip44.decrypt(ciphertext, conv)
|
|
419
|
+
},
|
|
420
|
+
async nip44Encrypt(thirdPartyPubkey, plaintext) {
|
|
421
|
+
const conv = nip44.getConversationKey(sk, thirdPartyPubkey)
|
|
422
|
+
return nip44.encrypt(plaintext, conv)
|
|
423
|
+
}
|
|
424
|
+
})
|
|
425
|
+
|
|
426
|
+
nostrLogin = true
|
|
427
|
+
open()
|
|
428
|
+
errorMessage = ''
|
|
429
|
+
connecting = false
|
|
430
|
+
connected = true
|
|
431
|
+
identify()
|
|
432
|
+
localStorage.setItem(lskeys.BUNKER_POINTER, nsec)
|
|
433
|
+
}
|
|
434
|
+
} catch (error) {
|
|
435
|
+
console.error('failed to decode nsec:', error)
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
378
439
|
async function handleDisconnect(ev: MouseEvent) {
|
|
379
440
|
ev.preventDefault()
|
|
380
441
|
localStorage.removeItem(lskeys.BUNKER_POINTER)
|
|
@@ -401,7 +462,9 @@
|
|
|
401
462
|
}
|
|
402
463
|
|
|
403
464
|
async function connect(b: BunkerSigner | undefined = undefined) {
|
|
404
|
-
b =
|
|
465
|
+
b =
|
|
466
|
+
b ||
|
|
467
|
+
BunkerSigner.fromBunker(clientSecret, bunkerPointer!, bunkerSignerParams)
|
|
405
468
|
connecting = true
|
|
406
469
|
|
|
407
470
|
let connectionTimeout = setTimeout(() => {
|
|
@@ -435,7 +498,7 @@
|
|
|
435
498
|
async function identify() {
|
|
436
499
|
let pubkey: string
|
|
437
500
|
try {
|
|
438
|
-
pubkey = await (await
|
|
501
|
+
pubkey = await (await signer).getPublicKey()
|
|
439
502
|
} catch (err) {
|
|
440
503
|
hasTriedToConnectButFailed = true
|
|
441
504
|
return
|
|
@@ -450,10 +513,11 @@
|
|
|
450
513
|
metadataSub = pool.subscribeMany(
|
|
451
514
|
[
|
|
452
515
|
'wss://purplepag.es',
|
|
516
|
+
'wss://indexer.coracle.social',
|
|
453
517
|
'wss://relay.snort.social',
|
|
454
518
|
'wss://relay.nos.social'
|
|
455
519
|
],
|
|
456
|
-
|
|
520
|
+
{kinds: [0], authors: [pubkey]},
|
|
457
521
|
{
|
|
458
522
|
onevent(evt) {
|
|
459
523
|
if ((identity!.event?.created_at || 0) >= evt.created_at) return
|
|
@@ -728,11 +792,17 @@
|
|
|
728
792
|
<div class="text-center text-lg">
|
|
729
793
|
How do you want to connect to Nostr?
|
|
730
794
|
</div>
|
|
731
|
-
<form
|
|
795
|
+
<form
|
|
796
|
+
class="mb-1 mt-4 flex flex-col"
|
|
797
|
+
on:submit={ev =>
|
|
798
|
+
bunkerInputValue.startsWith('nsec1')
|
|
799
|
+
? handleNsec(ev)
|
|
800
|
+
: handleConnect(ev)}
|
|
801
|
+
>
|
|
732
802
|
<!-- svelte-ignore a11y-autofocus -->
|
|
733
803
|
<input
|
|
734
804
|
class="box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"
|
|
735
|
-
placeholder="
|
|
805
|
+
placeholder="bunker://... or nsec1..."
|
|
736
806
|
bind:this={bunkerInput}
|
|
737
807
|
bind:value={bunkerInputValue}
|
|
738
808
|
autofocus
|
|
@@ -819,10 +889,12 @@
|
|
|
819
889
|
class="my-2 mt-6 block w-full cursor-pointer rounded border-0 px-2 py-1 text-lg text-white bg-{accent}-900 hover:bg-{accent}-950"
|
|
820
890
|
on:click={handleDisconnect}>Disconnect</button
|
|
821
891
|
>
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
892
|
+
{#if !plainkey}
|
|
893
|
+
<div class="mt-6 block break-all text-center text-xs">
|
|
894
|
+
This webpage is using the public key:<br />
|
|
895
|
+
{getPublicKey(clientSecret)}
|
|
896
|
+
</div>
|
|
897
|
+
{/if}
|
|
826
898
|
{/if}
|
|
827
899
|
</div>
|
|
828
900
|
{/if}
|
package/src/signer.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type {EventTemplate, VerifiedEvent} from 'nostr-tools/pure'
|
|
2
|
+
|
|
3
|
+
export interface Signer {
|
|
4
|
+
getPublicKey(): Promise<string>
|
|
5
|
+
signEvent(event: EventTemplate): Promise<VerifiedEvent>
|
|
6
|
+
nip04Encrypt(thirdPartyPubkey: string, plaintext: string): Promise<string>
|
|
7
|
+
nip04Decrypt(thirdPartyPubkey: string, ciphertext: string): Promise<string>
|
|
8
|
+
nip44Encrypt(thirdPartyPubkey: string, plaintext: string): Promise<string>
|
|
9
|
+
nip44Decrypt(thirdPartyPubkey: string, ciphertext: string): Promise<string>
|
|
10
|
+
}
|