window.nostr.js 0.2.2 → 0.3.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/README.md CHANGED
@@ -18,6 +18,11 @@ The script supports some optional configurations to personalize the design:
18
18
  // The only accepted value is 'bottom', default is top
19
19
  accent: 'green',
20
20
  // Supported values: cyan (default), green, purple, red, orange, neutral, stone
21
+ startHidden: true,
22
+ // If the host page has a button that call `getPublicKey` to start a
23
+ // login procedure, the minimized widget can be hidden until connected
24
+ compactMode: true,
25
+ // Show the minimized widget in a compact form
21
26
  disableOverflowFix: true,
22
27
  // If the host page on mobile has an horizontal scrolling, the floating
23
28
  // element/modal are pushed to the extreme right/bottom and exit the
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-CY_Kjibn.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-CqzFrdff.js"></script>
8
8
  </head>
9
9
  <body
10
10
  style="
@@ -1,19 +1,19 @@
1
- var _a=Object.defineProperty;var ka=(Me,R,Te)=>R in Me?_a(Me,R,{enumerable:!0,configurable:!0,writable:!0,value:Te}):Me[R]=Te;var E=(Me,R,Te)=>(ka(Me,typeof R!="symbol"?R+"":R,Te),Te);(function(){"use strict";var ko,So,Ao;const Me='*,: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}.m-auto{margin:auto}.mx-2{margin-left:.5rem;margin-right:.5rem}.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}.w-10{width:2.5rem}.w-40{width:10rem}.w-5{width:1.25rem}.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-row{flex-direction:row}.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-4{padding-left:1rem;padding-right:1rem}.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-2xl{font-size:1.5rem;line-height:2rem}.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 R(){}function Te(e){return e()}function Mn(){return Object.create(null)}function Ne(e){e.forEach(Te)}function Kt(e){return typeof e=="function"}function Dt(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}let xt;function Et(e,t){return e===t?!0:(xt||(xt=document.createElement("a")),xt.href=t,e===xt.href)}function Oo(e){return Object.keys(e).length===0}function To(e,...t){if(e==null){for(const r of t)r(void 0);return R}const n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function No(e,t,n){e.$$.on_destroy.push(To(t,n))}const Lo=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function k(e,t){e.appendChild(t)}function q(e,t,n){e.insertBefore(t,n||null)}function H(e){e.parentNode&&e.parentNode.removeChild(e)}function Po(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function N(e){return document.createElement(e)}function Wt(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function $(e){return document.createTextNode(e)}function M(){return $(" ")}function Co(){return $("")}function Y(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function x(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Uo(e){return Array.from(e.childNodes)}function Le(e,t){t=""+t,e.data!==t&&(e.data=t)}function Je(e,t){e.value=t??""}function Kn(e,t,n){for(let r=0;r<e.options.length;r+=1){const o=e.options[r];if(o.__value===t){o.selected=!0;return}}(!n||t!==void 0)&&(e.selectedIndex=-1)}function Ro(e){const t=e.querySelector(":checked");return t&&t.__value}function Dn(e,t,n){e.classList.toggle(t,!!n)}let at;function lt(e){at=e}function Ho(){if(!at)throw new Error("Function called outside component initialization");return at}function qo(e){Ho().$$.on_mount.push(e)}const Qe=[],ut=[];let Xe=[];const Wn=[],$o=Promise.resolve();let Vt=!1;function jo(){Vt||(Vt=!0,$o.then(Vn))}function _t(e){Xe.push(e)}const Gt=new Set;let et=0;function Vn(){if(et!==0)return;const e=at;do{try{for(;et<Qe.length;){const t=Qe[et];et++,lt(t),zo(t.$$)}}catch(t){throw Qe.length=0,et=0,t}for(lt(null),Qe.length=0,et=0;ut.length;)ut.pop()();for(let t=0;t<Xe.length;t+=1){const n=Xe[t];Gt.has(n)||(Gt.add(n),n())}Xe.length=0}while(Qe.length);for(;Wn.length;)Wn.pop()();Vt=!1,Gt.clear(),lt(e)}function zo(e){if(e.fragment!==null){e.update(),Ne(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(_t)}}function Mo(e){const t=[],n=[];Xe.forEach(r=>e.indexOf(r)===-1?t.push(r):n.push(r)),n.forEach(r=>r()),Xe=t}const kt=new Set;let Ke;function St(){Ke={r:0,c:[],p:Ke}}function At(){Ke.r||Ne(Ke.c),Ke=Ke.p}function he(e,t){e&&e.i&&(kt.delete(e),e.i(t))}function ge(e,t,n,r){if(e&&e.o){if(kt.has(e))return;kt.add(e),Ke.c.push(()=>{kt.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function Gn(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}function Zn(e){e&&e.c()}function Zt(e,t,n){const{fragment:r,after_update:o}=e.$$;r&&r.m(t,n),_t(()=>{const i=e.$$.on_mount.map(Te).filter(Kt);e.$$.on_destroy?e.$$.on_destroy.push(...i):Ne(i),e.$$.on_mount=[]}),o.forEach(_t)}function Yt(e,t){const n=e.$$;n.fragment!==null&&(Mo(n.after_update),Ne(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ko(e,t){e.$$.dirty[0]===-1&&(Qe.push(e),jo(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Yn(e,t,n,r,o,i,s=null,c=[-1]){const a=at;lt(e);const l=e.$$={fragment:null,ctx:[],props:i,update:R,not_equal:o,bound:Mn(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(a?a.$$.context:[])),callbacks:Mn(),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&&Ko(e,u)),g}):[],l.update(),f=!0,Ne(l.before_update),l.fragment=r?r(l.ctx):!1,t.target){if(t.hydrate){const u=Uo(t.target);l.fragment&&l.fragment.l(u),u.forEach(H)}else l.fragment&&l.fragment.c();t.intro&&he(e.$$.fragment),Zt(e,t.target,t.anchor),Vn()}lt(a)}class Fn{constructor(){E(this,"$$");E(this,"$$set")}$destroy(){Yt(this,1),this.$destroy=R}$on(t,n){if(!Kt(n))return R;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&&!Oo(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Do="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Do);function Wo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ft={exports:{}};function Jn(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}Ft.exports.debounce=Jn,Ft.exports=Jn;var Vo=Ft.exports;const Qn=Wo(Vo),Jt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xn=e=>e instanceof Uint8Array,Qt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),pe=(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 Go=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function te(e){if(!Xn(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Go[e[n]];return t}function Xt(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 Zo(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function er(e){if(typeof e=="string"&&(e=Zo(e)),!Xn(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}let Yo=class{clone(){return this._cloneInto()}};function tr(e){const t=r=>e().update(er(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Fo(e=32){if(Jt&&typeof Jt.getRandomValues=="function")return Jt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function nr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function rr(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 Jo(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");nr(e.outputLen),nr(e.blockLen)}function Bt(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 Qo(e,t){rr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const en=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const or=e=>e instanceof Uint8Array,tn=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),be=(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 Xo(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function nn(e){if(typeof e=="string"&&(e=Xo(e)),!or(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}function ei(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!or(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}class ir{clone(){return this._cloneInto()}}function ti(e){const t=r=>e().update(nn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function sr(e=32){if(en&&typeof en.getRandomValues=="function")return en.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function ni(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 ri=class extends ir{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=tn(this.buffer)}update(t){Bt(this);const{view:n,buffer:r,blockLen:o}=this;t=nn(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=tn(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){Bt(this),Qo(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;ni(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=tn(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 oi=(e,t,n)=>e&t^~e&n,ii=(e,t,n)=>e&t^e&n^t&n,si=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]),Pe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ce=new Uint32Array(64);let ci=class extends ri{constructor(){super(64,32,8,!1),this.A=Pe[0]|0,this.B=Pe[1]|0,this.C=Pe[2]|0,this.D=Pe[3]|0,this.E=Pe[4]|0,this.F=Pe[5]|0,this.G=Pe[6]|0,this.H=Pe[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)Ce[u]=t.getUint32(n,!1);for(let u=16;u<64;u++){const g=Ce[u-15],h=Ce[u-2],b=be(g,7)^be(g,18)^g>>>3,d=be(h,17)^be(h,19)^h>>>10;Ce[u]=d+Ce[u-7]+b+Ce[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=be(c,6)^be(c,11)^be(c,25),h=f+g+oi(c,a,l)+si[u]+Ce[u]|0,d=(be(r,2)^be(r,13)^be(r,22))+ii(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(){Ce.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const rn=ti(()=>new ci);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cr=BigInt(0),It=BigInt(1),ai=BigInt(2),Ot=e=>e instanceof Uint8Array,li=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function tt(e){if(!Ot(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=li[e[n]];return t}function ar(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function on(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function nt(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 re(e){return on(tt(e))}function sn(e){if(!Ot(e))throw new Error("Uint8Array expected");return on(tt(Uint8Array.from(e).reverse()))}function Ue(e,t){return nt(e.toString(16).padStart(t*2,"0"))}function cn(e,t){return Ue(e,t).reverse()}function ui(e){return nt(ar(e))}function X(e,t,n){let r;if(typeof t=="string")try{r=nt(t)}catch(i){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Ot(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 De(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!Ot(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function fi(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 di(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function hi(e){let t;for(t=0;e>cr;e>>=It,t+=1);return t}function gi(e,t){return e>>BigInt(t)&It}const pi=(e,t,n)=>e|(n?It:cr)<<BigInt(t),an=e=>(ai<<BigInt(e-1))-It,ln=e=>new Uint8Array(e),lr=e=>Uint8Array.from(e);function ur(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=ln(e),o=ln(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},c=(...u)=>n(o,r,...u),a=(u=ln())=>{o=c(lr([0]),u),r=c(),u.length!==0&&(o=c(lr([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 De(...g)};return(u,g)=>{s(),a(u);let h;for(;!(h=g(l()));)a();return s(),h}}const bi={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 ft(e,t,n={}){const r=(o,i,s)=>{const c=bi[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 wi=Object.freeze(Object.defineProperty({__proto__:null,bitGet:gi,bitLen:hi,bitMask:an,bitSet:pi,bytesToHex:tt,bytesToNumberBE:re,bytesToNumberLE:sn,concatBytes:De,createHmacDrbg:ur,ensureBytes:X,equalBytes:fi,hexToBytes:nt,hexToNumber:on,numberToBytesBE:Ue,numberToBytesLE:cn,numberToHexUnpadded:ar,numberToVarBytesBE:ui,utf8ToBytes:di,validateObject:ft},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const F=BigInt(0),Z=BigInt(1),We=BigInt(2),yi=BigInt(3),un=BigInt(4),fr=BigInt(5),dr=BigInt(8);BigInt(9),BigInt(16);function J(e,t){const n=e%t;return n>=F?n:t+n}function mi(e,t,n){if(n<=F||t<F)throw new Error("Expected power/modulo > 0");if(n===Z)return F;let r=Z;for(;t>F;)t&Z&&(r=r*e%n),e=e*e%n,t>>=Z;return r}function le(e,t,n){let r=e;for(;t-- >F;)r*=r,r%=n;return r}function fn(e,t){if(e===F||t<=F)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=J(e,t),r=t,o=F,i=Z;for(;n!==F;){const c=r/n,a=r%n,l=o-i*c;r=n,n=a,o=i,i=l}if(r!==Z)throw new Error("invert: does not exist");return J(o,t)}function vi(e){const t=(e-Z)/We;let n,r,o;for(n=e-Z,r=0;n%We===F;n/=We,r++);for(o=We;o<e&&mi(o,t,e)!==e-Z;o++);if(r===1){const s=(e+Z)/un;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+Z)/We;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,Z<<BigInt(l-h-1));f=c.sqr(b),u=c.mul(u,b),g=c.mul(g,f),l=h}return u}}function xi(e){if(e%un===yi){const t=(e+Z)/un;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%dr===fr){const t=(e-fr)/dr;return function(r,o){const i=r.mul(o,We),s=r.pow(i,t),c=r.mul(o,s),a=r.mul(r.mul(c,We),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 vi(e)}const Ei=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function _i(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Ei.reduce((r,o)=>(r[o]="function",r),t);return ft(e,n)}function ki(e,t,n){if(n<F)throw new Error("Expected power > 0");if(n===F)return e.ONE;if(n===Z)return t;let r=e.ONE,o=t;for(;n>F;)n&Z&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Z;return r}function Si(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 hr(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Ai(e,t,n=!1,r={}){if(e<=F)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=hr(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=xi(e),c=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:an(o),ZERO:F,ONE:Z,create:a=>J(a,e),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return F<=a&&a<e},is0:a=>a===F,isOdd:a=>(a&Z)===Z,neg:a=>J(-a,e),eql:(a,l)=>a===l,sqr:a=>J(a*a,e),add:(a,l)=>J(a+l,e),sub:(a,l)=>J(a-l,e),mul:(a,l)=>J(a*l,e),pow:(a,l)=>ki(c,a,l),div:(a,l)=>J(a*fn(l,e),e),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>fn(a,e),sqrt:r.sqrt||(a=>s(c,a)),invertBatch:a=>Si(c,a),cmov:(a,l,f)=>f?l:a,toBytes:a=>n?cn(a,i):Ue(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return n?sn(a):re(a)}});return Object.freeze(c)}function gr(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 pr(e){const t=gr(e);return t+Math.ceil(t/2)}function Bi(e,t,n=!1){const r=e.length,o=gr(t),i=pr(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=n?re(e):sn(e),c=J(s,t-Z)+Z;return n?cn(c,o):Ue(c,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ii=BigInt(0),dn=BigInt(1);function Oi(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>Ii;)i&dn&&(s=s.add(c)),c=c.double(),i>>=dn;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+=dn);const y=d,w=d+Math.abs(p)-1,_=b%2!==0,T=p<0;p===0?f=f.add(n(_,i[y])):l=l.add(n(T,i[w]))}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 br(e){return _i(e.Fp),ft(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...hr(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ti(e){const t=br(e);ft(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:Ni,hexToBytes:Li}=wi,Ve={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=Ve;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:Ni(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=Ve,n=typeof e=="string"?Li(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}=Ve._parseInt(n.subarray(2)),{d:s,l:c}=Ve._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}`}},xe=BigInt(0),ue=BigInt(1);BigInt(2);const wr=BigInt(3);BigInt(4);function Pi(e){const t=Ti(e),{Fp:n}=t,r=t.toBytes||((b,d,p)=>{const y=d.toAffine();return De(Uint8Array.from([4]),n.toBytes(y.x),n.toBytes(y.y))}),o=t.fromBytes||(b=>{const d=b.subarray(1),p=n.fromBytes(d.subarray(0,n.BYTES)),y=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:p,y}});function i(b){const{a:d,b:p}=t,y=n.sqr(b),w=n.mul(y,b);return n.add(n.add(w,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"&&xe<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:y,n:w}=t;if(d&&typeof b!="bigint"){if(b instanceof Uint8Array&&(b=tt(b)),typeof b!="string"||!d.includes(b.length))throw new Error("Invalid key");b=b.padStart(p*2,"0")}let _;try{_=typeof b=="bigint"?b:re(X("private key",b,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof b}`)}return y&&(_=J(_,w)),c(_),_}const l=new Map;function f(b){if(!(b instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,p,y){if(this.px=d,this.py=p,this.pz=y,d==null||!n.isValid(d))throw new Error("x required");if(p==null||!n.isValid(p))throw new Error("y required");if(y==null||!n.isValid(y))throw new Error("z required")}static fromAffine(d){const{x:p,y}=d||{};if(!d||!n.isValid(p)||!n.isValid(y))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");const w=_=>n.eql(_,n.ZERO);return w(p)&&w(y)?u.ZERO:new u(p,y,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const p=n.invertBatch(d.map(y=>y.pz));return d.map((y,w)=>y.toAffine(p[w])).map(u.fromAffine)}static fromHex(d){const p=u.fromAffine(o(X("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 y=n.sqr(p),w=i(d);if(!n.eql(y,w))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:y,pz:w}=this,{px:_,py:T,pz:L}=d,A=n.eql(n.mul(p,L),n.mul(_,w)),v=n.eql(n.mul(y,L),n.mul(T,w));return A&&v}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b:p}=t,y=n.mul(p,wr),{px:w,py:_,pz:T}=this;let L=n.ZERO,A=n.ZERO,v=n.ZERO,m=n.mul(w,w),B=n.mul(_,_),C=n.mul(T,T),P=n.mul(w,_);return P=n.add(P,P),v=n.mul(w,T),v=n.add(v,v),L=n.mul(d,v),A=n.mul(y,C),A=n.add(L,A),L=n.sub(B,A),A=n.add(B,A),A=n.mul(L,A),L=n.mul(P,L),v=n.mul(y,v),C=n.mul(d,C),P=n.sub(m,C),P=n.mul(d,P),P=n.add(P,v),v=n.add(m,m),m=n.add(v,m),m=n.add(m,C),m=n.mul(m,P),A=n.add(A,m),C=n.mul(_,T),C=n.add(C,C),m=n.mul(C,P),L=n.sub(L,m),v=n.mul(C,B),v=n.add(v,v),v=n.add(v,v),new u(L,A,v)}add(d){f(d);const{px:p,py:y,pz:w}=this,{px:_,py:T,pz:L}=d;let A=n.ZERO,v=n.ZERO,m=n.ZERO;const B=t.a,C=n.mul(t.b,wr);let P=n.mul(p,_),K=n.mul(y,T),V=n.mul(w,L),oe=n.add(p,y),S=n.add(_,T);oe=n.mul(oe,S),S=n.add(P,K),oe=n.sub(oe,S),S=n.add(p,w);let O=n.add(_,L);return S=n.mul(S,O),O=n.add(P,V),S=n.sub(S,O),O=n.add(y,w),A=n.add(T,L),O=n.mul(O,A),A=n.add(K,V),O=n.sub(O,A),m=n.mul(B,S),A=n.mul(C,V),m=n.add(A,m),A=n.sub(K,m),m=n.add(K,m),v=n.mul(A,m),K=n.add(P,P),K=n.add(K,P),V=n.mul(B,V),S=n.mul(C,S),K=n.add(K,V),V=n.sub(P,V),V=n.mul(B,V),S=n.add(S,V),P=n.mul(K,S),v=n.add(v,P),P=n.mul(O,S),A=n.mul(oe,A),A=n.sub(A,P),P=n.mul(oe,K),m=n.mul(O,m),m=n.add(m,P),new u(A,v,m)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return h.wNAFCached(this,l,d,p=>{const y=n.invertBatch(p.map(w=>w.pz));return p.map((w,_)=>w.toAffine(y[_])).map(u.fromAffine)})}multiplyUnsafe(d){const p=u.ZERO;if(d===xe)return p;if(c(d),d===ue)return this;const{endo:y}=t;if(!y)return h.unsafeLadder(this,d);let{k1neg:w,k1:_,k2neg:T,k2:L}=y.splitScalar(d),A=p,v=p,m=this;for(;_>xe||L>xe;)_&ue&&(A=A.add(m)),L&ue&&(v=v.add(m)),m=m.double(),_>>=ue,L>>=ue;return w&&(A=A.negate()),T&&(v=v.negate()),v=new u(n.mul(v.px,y.beta),v.py,v.pz),A.add(v)}multiply(d){c(d);let p=d,y,w;const{endo:_}=t;if(_){const{k1neg:T,k1:L,k2neg:A,k2:v}=_.splitScalar(p);let{p:m,f:B}=this.wNAF(L),{p:C,f:P}=this.wNAF(v);m=h.constTimeNegate(T,m),C=h.constTimeNegate(A,C),C=new u(n.mul(C.px,_.beta),C.py,C.pz),y=m.add(C),w=B.add(P)}else{const{p:T,f:L}=this.wNAF(p);y=T,w=L}return u.normalizeZ([y,w])[0]}multiplyAndAddUnsafe(d,p,y){const w=u.BASE,_=(L,A)=>A===xe||A===ue||!L.equals(w)?L.multiplyUnsafe(A):L.multiply(A),T=_(this,p).add(_(d,y));return T.is0()?void 0:T}toAffine(d){const{px:p,py:y,pz:w}=this,_=this.is0();d==null&&(d=_?n.ONE:n.inv(w));const T=n.mul(p,d),L=n.mul(y,d),A=n.mul(w,d);if(_)return{x:n.ZERO,y:n.ZERO};if(!n.eql(A,n.ONE))throw new Error("invZ was invalid");return{x:T,y:L}}isTorsionFree(){const{h:d,isTorsionFree:p}=t;if(d===ue)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===ue?this:p?p(u,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return this.assertValidity(),r(u,this,d)}toHex(d=!0){return tt(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=Oi(u,t.endo?Math.ceil(g/2):g);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:s}}function Ci(e){const t=br(e);return ft(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ui(e){const t=Ci(e),{Fp:n,n:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(S){return xe<S&&S<n.ORDER}function c(S){return J(S,r)}function a(S){return fn(S,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:g}=Pi({...t,toBytes(S,O,U){const j=O.toAffine(),z=n.toBytes(j.x),D=De;return U?D(Uint8Array.from([O.hasEvenY()?2:3]),z):D(Uint8Array.from([4]),z,n.toBytes(j.y))},fromBytes(S){const O=S.length,U=S[0],j=S.subarray(1);if(O===o&&(U===2||U===3)){const z=re(j);if(!s(z))throw new Error("Point is not on curve");const D=u(z);let Q=n.sqrt(D);const W=(Q&ue)===ue;return(U&1)===1!==W&&(Q=n.neg(Q)),{x:z,y:Q}}else if(O===i&&U===4){const z=n.fromBytes(j.subarray(0,n.BYTES)),D=n.fromBytes(j.subarray(n.BYTES,2*n.BYTES));return{x:z,y:D}}else throw new Error(`Point of length ${O} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=S=>tt(Ue(S,t.nByteLength));function b(S){const O=r>>ue;return S>O}function d(S){return b(S)?c(-S):S}const p=(S,O,U)=>re(S.slice(O,U));class y{constructor(O,U,j){this.r=O,this.s=U,this.recovery=j,this.assertValidity()}static fromCompact(O){const U=t.nByteLength;return O=X("compactSignature",O,U*2),new y(p(O,0,U),p(O,U,2*U))}static fromDER(O){const{r:U,s:j}=Ve.toSig(X("DER",O));return new y(U,j)}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(O){return new y(this.r,this.s,O)}recoverPublicKey(O){const{r:U,s:j,recovery:z}=this,D=v(X("msgHash",O));if(z==null||![0,1,2,3].includes(z))throw new Error("recovery id invalid");const Q=z===2||z===3?U+t.n:U;if(Q>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const W=z&1?"03":"02",ae=l.fromHex(W+h(Q)),ie=a(Q),Ae=c(-D*ie),Be=c(j*ie),se=l.BASE.multiplyAndAddUnsafe(ae,Ae,Be);if(!se)throw new Error("point at infinify");return se.assertValidity(),se}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return nt(this.toDERHex())}toDERHex(){return Ve.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return nt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const w={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const S=pr(t.n);return Bi(t.randomBytes(S),t.n)},precompute(S=8,O=l.BASE){return O._setWindowSize(S),O.multiply(BigInt(3)),O}};function _(S,O=!0){return l.fromPrivateKey(S).toRawBytes(O)}function T(S){const O=S instanceof Uint8Array,U=typeof S=="string",j=(O||U)&&S.length;return O?j===o||j===i:U?j===2*o||j===2*i:S instanceof l}function L(S,O,U=!0){if(T(S))throw new Error("first arg must be private key");if(!T(O))throw new Error("second arg must be public key");return l.fromHex(O).multiply(f(S)).toRawBytes(U)}const A=t.bits2int||function(S){const O=re(S),U=S.length*8-t.nBitLength;return U>0?O>>BigInt(U):O},v=t.bits2int_modN||function(S){return c(A(S))},m=an(t.nBitLength);function B(S){if(typeof S!="bigint")throw new Error("bigint expected");if(!(xe<=S&&S<m))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Ue(S,t.nByteLength)}function C(S,O,U=P){if(["recovered","canonical"].some(me=>me in U))throw new Error("sign() legacy options not supported");const{hash:j,randomBytes:z}=t;let{lowS:D,prehash:Q,extraEntropy:W}=U;D==null&&(D=!0),S=X("msgHash",S),Q&&(S=X("prehashed msgHash",j(S)));const ae=v(S),ie=f(O),Ae=[B(ie),B(ae)];if(W!=null){const me=W===!0?z(n.BYTES):W;Ae.push(X("extraEntropy",me))}const Be=De(...Ae),se=ae;function ct(me){const Ie=A(me);if(!g(Ie))return;const mt=a(Ie),Oe=l.BASE.multiply(Ie).toAffine(),ee=c(Oe.x);if(ee===xe)return;const de=c(mt*c(se+ee*ie));if(de===xe)return;let Fe=(Oe.x===ee?0:2)|Number(Oe.y&ue),vt=de;return D&&b(de)&&(vt=d(de),Fe^=1),new y(ee,vt,Fe)}return{seed:Be,k2sig:ct}}const P={lowS:t.lowS,prehash:!1},K={lowS:t.lowS,prehash:!1};function V(S,O,U=P){const{seed:j,k2sig:z}=C(S,O,U),D=t;return ur(D.hash.outputLen,D.nByteLength,D.hmac)(j,z)}l.BASE._setWindowSize(8);function oe(S,O,U,j=K){var Oe;const z=S;if(O=X("msgHash",O),U=X("publicKey",U),"strict"in j)throw new Error("options.strict was renamed to lowS");const{lowS:D,prehash:Q}=j;let W,ae;try{if(typeof z=="string"||z instanceof Uint8Array)try{W=y.fromDER(z)}catch(ee){if(!(ee instanceof Ve.Err))throw ee;W=y.fromCompact(z)}else if(typeof z=="object"&&typeof z.r=="bigint"&&typeof z.s=="bigint"){const{r:ee,s:de}=z;W=new y(ee,de)}else throw new Error("PARSE");ae=l.fromHex(U)}catch(ee){if(ee.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(D&&W.hasHighS())return!1;Q&&(O=t.hash(O));const{r:ie,s:Ae}=W,Be=v(O),se=a(Ae),ct=c(Be*se),me=c(ie*se),Ie=(Oe=l.BASE.multiplyAndAddUnsafe(ae,ct,me))==null?void 0:Oe.toAffine();return Ie?c(Ie.x)===ie:!1}return{CURVE:t,getPublicKey:_,getSharedSecret:L,sign:V,verify:oe,ProjectivePoint:l,Signature:y,utils:w}}class yr extends ir{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Jo(t);const r=nn(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 Bt(this),this.iHash.update(t),this}digestInto(t){Bt(this),rr(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 mr=(e,t,n)=>new yr(e,t).update(n).digest();mr.create=(e,t)=>new yr(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ri(e){return{hash:e,hmac:(t,...n)=>mr(e,t,ei(...n)),randomBytes:sr}}function Hi(e,t){const n=r=>Ui({...e,...Ri(r)});return Object.freeze({...n(t),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Tt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Nt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),vr=BigInt(1),Lt=BigInt(2),xr=(e,t)=>(e+t/Lt)/t;function Er(e){const t=Tt,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=le(f,n,t)*f%t,g=le(u,n,t)*f%t,h=le(g,Lt,t)*l%t,b=le(h,o,t)*h%t,d=le(b,i,t)*b%t,p=le(d,c,t)*d%t,y=le(p,a,t)*p%t,w=le(y,c,t)*d%t,_=le(w,n,t)*f%t,T=le(_,s,t)*b%t,L=le(T,r,t)*l%t,A=le(L,Lt,t);if(!hn.eql(hn.sqr(A),e))throw new Error("Cannot find square root");return A}const hn=Ai(Tt,void 0,void 0,{sqrt:Er}),dt=Hi({a:BigInt(0),b:BigInt(7),Fp:hn,n:Nt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Nt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-vr*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),c=xr(i*e,t),a=xr(-r*e,t);let l=J(e-c*n-a*o,t),f=J(-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}}}},rn),Pt=BigInt(0),_r=e=>typeof e=="bigint"&&Pt<e&&e<Tt,qi=e=>typeof e=="bigint"&&Pt<e&&e<Nt,kr={};function Ct(e,...t){let n=kr[e];if(n===void 0){const r=rn(Uint8Array.from(e,o=>o.charCodeAt(0)));n=De(r,r),kr[e]=n}return rn(De(n,...t))}const gn=e=>e.toRawBytes(!0).slice(1),pn=e=>Ue(e,32),bn=e=>J(e,Tt),ht=e=>J(e,Nt),wn=dt.ProjectivePoint,$i=(e,t,n)=>wn.BASE.multiplyAndAddUnsafe(e,t,n);function yn(e){let t=dt.utils.normPrivateKeyToScalar(e),n=wn.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:ht(-t),bytes:gn(n)}}function Sr(e){if(!_r(e))throw new Error("bad x: need 0 < x < p");const t=bn(e*e),n=bn(t*e+BigInt(7));let r=Er(n);r%Lt!==Pt&&(r=bn(-r));const o=new wn(e,r,vr);return o.assertValidity(),o}function Ar(...e){return ht(re(Ct("BIP0340/challenge",...e)))}function ji(e){return yn(e).bytes}function zi(e,t,n=sr(32)){const r=X("message",e),{bytes:o,scalar:i}=yn(t),s=X("auxRand",n,32),c=pn(i^re(Ct("BIP0340/aux",s))),a=Ct("BIP0340/nonce",c,o,r),l=ht(re(a));if(l===Pt)throw new Error("sign failed: k is zero");const{bytes:f,scalar:u}=yn(l),g=Ar(f,o,r),h=new Uint8Array(64);if(h.set(f,0),h.set(pn(ht(u+g*i)),32),!Br(h,r,o))throw new Error("sign: Invalid signature produced");return h}function Br(e,t,n){const r=X("signature",e,64),o=X("message",t),i=X("publicKey",n,32);try{const s=Sr(re(i)),c=re(r.subarray(0,32));if(!_r(c))return!1;const a=re(r.subarray(32,64));if(!qi(a))return!1;const l=Ar(pn(c),gn(s),o),f=$i(s,a,ht(-l));return!(!f||!f.hasEvenY()||f.toAffine().x!==c)}catch{return!1}}const ne={getPublicKey:ji,sign:zi,verify:Br,utils:{randomPrivateKey:dt.utils.randomPrivateKey,lift_x:Sr,pointToBytes:gn,numberToBytesBE:Ue,bytesToNumberBE:re,taggedHash:Ct,mod:J}};function mn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Mi(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Ir(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 Ki(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");mn(e.outputLen),mn(e.blockLen)}function Di(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 Wi(e,t){Ir(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const vn={number:mn,bool:Mi,bytes:Ir,hash:Ki,exists:Di,output:Wi};function Vi(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 Gi extends Yo{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=Qt(this.buffer)}update(t){vn.exists(this);const{view:n,buffer:r,blockLen:o}=this;t=er(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=Qt(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){vn.exists(this),vn.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;Vi(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=Qt(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 Zi=(e,t,n)=>e&t^~e&n,Yi=(e,t,n)=>e&t^e&n^t&n,Fi=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]),Re=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),He=new Uint32Array(64);class Or extends Gi{constructor(){super(64,32,8,!1),this.A=Re[0]|0,this.B=Re[1]|0,this.C=Re[2]|0,this.D=Re[3]|0,this.E=Re[4]|0,this.F=Re[5]|0,this.G=Re[6]|0,this.H=Re[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)He[u]=t.getUint32(n,!1);for(let u=16;u<64;u++){const g=He[u-15],h=He[u-2],b=pe(g,7)^pe(g,18)^g>>>3,d=pe(h,17)^pe(h,19)^h>>>10;He[u]=d+He[u-7]+b+He[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=pe(c,6)^pe(c,11)^pe(c,25),h=f+g+Zi(c,a,l)+Fi[u]+He[u]|0,d=(pe(r,2)^pe(r,13)^pe(r,22))+Yi(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(){He.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Ji extends Or{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 xn=tr(()=>new Or);tr(()=>new Ji);var rt=Symbol("verified"),Qi=e=>e instanceof Object;function Xi(e){if(!Qi(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 es=new TextEncoder,ts=class{generateSecretKey(){return ne.utils.randomPrivateKey()}getPublicKey(t){return te(ne.getPublicKey(t))}finalizeEvent(t,n){const r=t;return r.pubkey=te(ne.getPublicKey(n)),r.id=En(r),r.sig=te(ne.sign(En(r),n)),r[rt]=!0,r}verifyEvent(t){if(typeof t[rt]=="boolean")return t[rt];const n=En(t);if(n!==t.id)return t[rt]=!1,!1;try{const r=ne.verify(t.sig,n,t.pubkey);return t[rt]=r,r}catch{return t[rt]=!1,!1}}};function ns(e){if(!Xi(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 En(e){let t=xn(es.encode(ns(e)));return te(t)}var Ut=new ts,rs=Ut.generateSecretKey,Tr=Ut.getPublicKey;Ut.finalizeEvent,Ut.verifyEvent;var Ge=Symbol("verified"),os=e=>e instanceof Object;function is(e){if(!os(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 ss=new TextEncoder;function gt(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 cs=class{constructor(t){E(this,"value");E(this,"next",null);E(this,"prev",null);this.value=t}},as=class{constructor(){E(this,"first");E(this,"last");this.first=null,this.last=null}enqueue(t){const n=new cs(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}},ls=class{generateSecretKey(){return ne.utils.randomPrivateKey()}getPublicKey(t){return te(ne.getPublicKey(t))}finalizeEvent(t,n){const r=t;return r.pubkey=te(ne.getPublicKey(n)),r.id=_n(r),r.sig=te(ne.sign(_n(r),n)),r[Ge]=!0,r}verifyEvent(t){if(typeof t[Ge]=="boolean")return t[Ge];const n=_n(t);if(n!==t.id)return t[Ge]=!1,!1;try{const r=ne.verify(t.sig,n,t.pubkey);return t[Ge]=r,r}catch{return t[Ge]=!1,!1}}};function us(e){if(!is(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 _n(e){let t=xn(ss.encode(us(e)));return te(t)}var Rt=new ls;Rt.generateSecretKey,Rt.getPublicKey,Rt.finalizeEvent;var fs=Rt.verifyEvent,ds=22242;function hs(e,t){if(e.ids&&e.ids.indexOf(t.id)===-1&&!e.ids.some(n=>t.id.startsWith(n))||e.kinds&&e.kinds.indexOf(t.kind)===-1||e.authors&&e.authors.indexOf(t.pubkey)===-1&&!e.authors.some(n=>t.pubkey.startsWith(n)))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 gs(e,t){for(let n=0;n<e.length;n++)if(hs(e[n],t))return!0;return!1}function ps(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 bs(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 ws(e,t){return{kind:ds,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}async function ys(){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 ms=e=>(e[Ge]=!0,!0),Nr;try{Nr=WebSocket}catch{}var Lr=class{constructor(t,n){E(this,"url");E(this,"_connected",!1);E(this,"onclose",null);E(this,"onnotice",t=>console.debug(`NOTICE from ${this.url}: ${t}`));E(this,"_onauth",null);E(this,"baseEoseTimeout",4400);E(this,"connectionTimeout",4400);E(this,"openSubs",new Map);E(this,"connectionTimeoutHandle");E(this,"connectionPromise");E(this,"openCountRequests",new Map);E(this,"openEventPublishes",new Map);E(this,"ws");E(this,"incomingMessageQueue",new as);E(this,"queueRunning",!1);E(this,"challenge");E(this,"serial",0);E(this,"verifyEvent");this.url=gt(t),this.verifyEvent=n.verifyEvent}static async connect(t,n){const r=new Lr(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 Nr(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),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 ys();this.queueRunning=!1}handleNext(){var r,o,i;const t=this.incomingMessageQueue.dequeue();if(!t)return!1;const n=bs(t);if(n){const s=this.openSubs.get(n);if(!s)return;const c=ps(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)&&gs(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);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(ws(this.url,this.challenge)),r=new Promise((o,i)=>{this.openEventPublishes.set(n.id,{resolve:o,reject:i})});return this.send('["AUTH",'+JSON.stringify(n)+"]"),r}async publish(t){const n=new Promise((r,o)=>{this.openEventPublishes.set(t.id,{resolve:r,reject:o})});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)+"]"),o}subscribe(t,n){const r=this.prepareSubscription(t,n);return r.fire(),r}prepareSubscription(t,n){this.serial++;const r=n.id||"sub:"+this.serial,o=new vs(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()}},vs=class{constructor(t,n,r,o){E(this,"relay");E(this,"id");E(this,"closed",!1);E(this,"eosed",!1);E(this,"filters");E(this,"alreadyHaveEvent");E(this,"receivedEvent");E(this,"onevent");E(this,"oneose");E(this,"onclose");E(this,"eoseTimeout");E(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)}},xs=class{constructor(t){E(this,"relays",new Map);E(this,"seenOn",new Map);E(this,"trackRelays",!1);E(this,"verifyEvent");E(this,"trustedRelayURLs",new Set);this.verifyEvent=t.verifyEvent}async ensureRelay(t,n){t=gt(t);let r=this.relays.get(t);return r||(r=new Lr(t,{verifyEvent:this.trustedRelayURLs.has(t)?ms:this.verifyEvent}),n!=null&&n.connectionTimeout&&(r.connectionTimeout=n.connectionTimeout),this.relays.set(t,r)),await r.connect(),r}close(t){t.map(gt).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]=!0,s.filter(b=>b).length===i&&((h=n.oneose)==null||h.call(n),c=()=>{})};const a=[];let l=(g,h)=>{var b;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=gt(d);let y;try{y=await this.ensureRelay(d,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0})}catch(_){l(h,(_==null?void 0:_.message)||String(_));return}let w=y.subscribe(p,{...n,oneose:()=>c(h),onclose:_=>l(h,_),alreadyHaveEvent:f,eoseTimeout:n.maxWait});o.push(w)}));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(gt).map(async(r,o,i)=>i.indexOf(r)!==o?Promise.reject("duplicate url"):(await this.ensureRelay(r)).publish(n))}},Es=class extends xs{constructor(){super({verifyEvent:fs})}};function Pr(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Ze(e,...t){if(!Pr(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 Ht(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 Cr(e,t){Ze(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 ce=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),_s=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 ks(e){if(typeof e!="string")throw new Error(`string expected, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function pt(e){if(typeof e=="string")e=ks(e);else if(Pr(e))e=e.slice();else throw new Error(`Uint8Array expected, got ${typeof e}`);return e}const Ss=(e,t)=>(Object.assign(t,e),t),Ee=16,kn=new Uint8Array(16),we=ce(kn),As=225,Bs=(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^As<<24&-(o&1)}},fe=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function Is(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 Os=e=>e>64*1024?8:e>1024?4:2;class Ur{constructor(t,n){this.blockLen=Ee,this.outputLen=Ee,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,t=pt(t),Ze(t,16);const r=_s(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:fe(o),s1:fe(i),s2:fe(s),s3:fe(c)}),{s0:o,s1:i,s2:s,s3:c}=Bs(o,i,s,c);const l=Os(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,y=0,w=0,_=0;for(let T=0;T<l;T++){if(!(d>>>l-T-1&1))continue;const{s0:A,s1:v,s2:m,s3:B}=a[l*b+T];p^=A,y^=v,w^=m,_^=B}h.push({s0:p,s1:y,s2:w,s3:_})}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 y=8/i-1;y>=0;y--){const w=p>>>i*y&g,{s0:_,s1:T,s2:L,s3:A}=s[h*c+w];a^=_,l^=T,f^=L,u^=A,h+=1}}this.s0=a,this.s1=l,this.s2=f,this.s3=u}update(t){t=pt(t),Ht(this);const n=ce(t),r=Math.floor(t.length/Ee),o=t.length%Ee;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&&(kn.set(t.subarray(r*Ee)),this._updateBlock(we[0],we[1],we[2],we[3]),we.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){Ht(this),Cr(t,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=ce(t);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,t}digest(){const t=new Uint8Array(Ee);return this.digestInto(t),this.destroy(),t}}class Ts extends Ur{constructor(t,n){t=pt(t);const r=Is(t.slice());super(r,n),r.fill(0)}update(t){t=pt(t),Ht(this);const n=ce(t),r=t.length%Ee,o=Math.floor(t.length/Ee);for(let i=0;i<o;i++)this._updateBlock(fe(n[i*4+3]),fe(n[i*4+2]),fe(n[i*4+1]),fe(n[i*4+0]));return r&&(kn.set(t.subarray(o*Ee)),this._updateBlock(fe(we[3]),fe(we[2]),fe(we[1]),fe(we[0])),we.fill(0)),this}digestInto(t){Ht(this),Cr(t,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=ce(t);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,t.reverse()}}function Rr(e){const t=(r,o)=>e(o,r.length).update(pt(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}Rr((e,t)=>new Ur(e,t)),Rr((e,t)=>new Ts(e,t));const qe=16,Ns=283;function Sn(e){return e<<1^Ns&-(e>>7)}function ot(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Sn(e);return n}const An=(()=>{let e=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Sn(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})(),Ls=An.map((e,t)=>An.indexOf(t)),Ps=e=>e<<24|e>>>8,Bn=e=>e<<8|e>>>24;function Hr(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(Bn),o=r.map(Bn),i=o.map(Bn),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 In=Hr(An,e=>ot(e,3)<<24|e<<16|e<<8|ot(e,2)),qr=Hr(Ls,e=>ot(e,11)<<24|ot(e,13)<<16|ot(e,9)<<8|ot(e,14)),Cs=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Sn(n))e[t]=n;return e})();function $r(e){Ze(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}=In,r=ce(e),o=r.length,i=c=>ye(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(Ps(a))^Cs[c/o-1]:o>6&&c%o===4&&(a=i(a)),s[c]=s[c-o]^a}return s}function Us(e){const t=$r(e),n=t.slice(),r=t.length,{sbox2:o}=In,{T0:i,T1:s,T2:c,T3:a}=qr;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=ye(o,f,f,f,f);n[l]=i[u&255]^s[u>>>8&255]^c[u>>>16&255]^a[u>>>24]}return n}function $e(e,t,n,r,o,i){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|i>>>24&255]}function ye(e,t,n,r,o){return e[t&255|n&65280]|e[r>>>16&255|o>>>16&65280]<<16}function jr(e,t,n,r,o){const{sbox2:i,T01:s,T23:c}=In;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++]^$e(s,c,t,n,r,o),p=e[a++]^$e(s,c,n,r,o,t),y=e[a++]^$e(s,c,r,o,t,n),w=e[a++]^$e(s,c,o,t,n,r);t=d,n=p,r=y,o=w}const f=e[a++]^ye(i,t,n,r,o),u=e[a++]^ye(i,n,r,o,t),g=e[a++]^ye(i,r,o,t,n),h=e[a++]^ye(i,o,t,n,r);return{s0:f,s1:u,s2:g,s3:h}}function Rs(e,t,n,r,o){const{sbox2:i,T01:s,T23:c}=qr;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++]^$e(s,c,t,o,r,n),p=e[a++]^$e(s,c,n,t,o,r),y=e[a++]^$e(s,c,r,n,t,o),w=e[a++]^$e(s,c,o,r,n,t);t=d,n=p,r=y,o=w}const f=e[a++]^ye(i,t,o,r,n),u=e[a++]^ye(i,n,t,o,r),g=e[a++]^ye(i,r,n,t,o),h=e[a++]^ye(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(Ze(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);return t}function Hs(e){if(Ze(e),e.length%qe!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${qe}`)}function qs(e,t,n){let r=e.length;const o=r%qe;if(!t&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=ce(e);if(t){let a=qe-o;a||(a=qe),r=r+a}const s=zr(r,n),c=ce(s);return{b:i,o:c,out:s}}function $s(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 js(e){const t=new Uint8Array(16),n=ce(t);t.set(e);const r=qe-e.length;for(let o=qe-r;o<qe;o++)t[o]=r;return n}const Mr=Ss({blockSize:16,nonceLength:16},function(t,n,r={}){Ze(t),Ze(n,16);const o=!r.disablePadding;return{encrypt:(i,s)=>{const c=$r(t),{b:a,o:l,out:f}=qs(i,o,s),u=ce(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}=jr(c,g,h,b,d),l[p++]=g,l[p++]=h,l[p++]=b,l[p++]=d;if(o){const y=js(i.subarray(p*4));g^=y[0],h^=y[1],b^=y[2],d^=y[3],{s0:g,s1:h,s2:b,s3:d}=jr(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)=>{Hs(i);const c=Us(t),a=ce(n),l=zr(i.length,s),f=ce(i),u=ce(l);let g=a[0],h=a[1],b=a[2],d=a[3];for(let p=0;p+4<=f.length;){const y=g,w=h,_=b,T=d;g=f[p+0],h=f[p+1],b=f[p+2],d=f[p+3];const{s0:L,s1:A,s2:v,s3:m}=Rs(c,g,h,b,d);u[p++]=L^y,u[p++]=A^w,u[p++]=v^_,u[p++]=m^T}return c.fill(0),$s(l,o)}}});/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function it(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function _e(...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 ke(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(it(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 Se(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 qt(e,t="="){if(it(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 Kr(e){if(typeof e!="function")throw new Error("normalize fn should be function");return{encode:t=>t,decode:t=>e(t)}}function Dr(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(it(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 Wr=(e,t)=>t?Wr(t,e%t):e,$t=(e,t)=>e+(t-Wr(e,t));function On(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($t(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${$t(t,n)}`);let o=0,i=0;const s=2**n-1,c=[];for(const a of e){if(it(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 zs(e){return it(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Dr(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(Dr(t,e,2**8))}}}function je(e,t=!1){if(it(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if($t(8,e)>32||$t(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 On(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(On(n,e,8,t))}}}function Vr(e){if(typeof e!="function")throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch{}}}const Ms=_e(je(4),ke("0123456789ABCDEF"),Se("")),Ks=_e(je(5),ke("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),qt(5),Se(""));_e(je(5),ke("0123456789ABCDEFGHIJKLMNOPQRSTUV"),qt(5),Se("")),_e(je(5),ke("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Se(""),Kr(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const bt=_e(je(6),ke("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),qt(6),Se("")),Ds=_e(je(6),ke("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),qt(6),Se("")),Tn=e=>_e(zs(58),ke(e),Se("")),Nn=Tn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Tn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Tn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Gr=[0,2,3,5,6,7,9,10,11],Ws={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=Nn.encode(r).padStart(Gr[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=Gr.indexOf(r.length),i=Nn.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)}},Ln=_e(ke("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Se("")),Zr=[996825010,642813549,513874426,1027748829,705979059];function wt(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<Zr.length;r++)(t>>r&1)===1&&(n^=Zr[r]);return n}function Yr(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=wt(o)^s>>5}o=wt(o);for(let i=0;i<r;i++)o=wt(o)^e.charCodeAt(i)&31;for(let i of t)o=wt(o)^i;for(let i=0;i<6;i++)o=wt(o);return o^=n,Ln.encode(On([o%2**30],30,5,!1))}function Fr(e){const t=e==="bech32"?1:734539939,n=je(5),r=n.decode,o=n.encode,i=Vr(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${Ln.encode(u)}${Yr(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=Ln.decode(d).slice(0,-6),y=Yr(b,p,t);if(!d.endsWith(y))throw new Error(`Invalid checksum in ${f}: expected "${y}"`);return{prefix:b,words:p}}const a=Vr(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 Jr=Fr("bech32");Fr("bech32m");const Vs={encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)},Gs=_e(je(4),ke("0123456789abcdef"),Se(""),Kr(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:Vs,hex:Gs,base16:Ms,base32:Ks,base64:bt,base64url:Ds,base58:Nn,base58xmr:Ws}).join(", ")}`;var Ye=Symbol("verified"),Zs=e=>e instanceof Object;function Ys(e){if(!Zs(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 Fs=new TextDecoder("utf-8"),Qr=new TextEncoder;function yt(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 Js=class{constructor(e){E(this,"value");E(this,"next",null);E(this,"prev",null);this.value=e}},Qs=class{constructor(){E(this,"first");E(this,"last");this.first=null,this.last=null}enqueue(e){const t=new Js(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}},Xs=class{generateSecretKey(){return ne.utils.randomPrivateKey()}getPublicKey(e){return te(ne.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=te(ne.getPublicKey(t)),n.id=Pn(n),n.sig=te(ne.sign(Pn(n),t)),n[Ye]=!0,n}verifyEvent(e){if(typeof e[Ye]=="boolean")return e[Ye];const t=Pn(e);if(t!==e.id)return e[Ye]=!1,!1;try{const n=ne.verify(e.sig,t,e.pubkey);return e[Ye]=n,n}catch{return e[Ye]=!1,!1}}};function ec(e){if(!Ys(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 Pn(e){let t=xn(Qr.encode(ec(e)));return te(t)}var jt=new Xs,tc=jt.generateSecretKey,nc=jt.getPublicKey,rc=jt.finalizeEvent,Xr=jt.verifyEvent;async function oc(e,t,n){const r=e instanceof Uint8Array?te(e):e,o=dt.getSharedSecret(r,"02"+t),i=eo(o);let s=Uint8Array.from(Fo(16)),c=Qr.encode(n),a=Mr(i,s).encrypt(c),l=bt.encode(new Uint8Array(a)),f=bt.encode(new Uint8Array(s.buffer));return`${l}?iv=${f}`}async function ic(e,t,n){const r=e instanceof Uint8Array?te(e):e;let[o,i]=n.split("?iv="),s=dt.getSharedSecret(r,"02"+t),c=eo(s),a=bt.decode(i),l=bt.decode(o),f=Mr(c,a).decrypt(l);return Fs.decode(f)}function eo(e){return e.slice(1,33)}var sc=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,cc;try{cc=fetch}catch{}var ac=22242,Cn=24133,lc=31990;function uc(e,t){if(e.ids&&e.ids.indexOf(t.id)===-1&&!e.ids.some(n=>t.id.startsWith(n))||e.kinds&&e.kinds.indexOf(t.kind)===-1||e.authors&&e.authors.indexOf(t.pubkey)===-1&&!e.authors.some(n=>t.pubkey.startsWith(n)))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 fc(e,t){for(let n=0;n<e.length;n++)if(uc(e[n],t))return!0;return!1}function dc(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 hc(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 gc(e,t){return{kind:ac,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}async function pc(){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 bc=e=>(e[Ye]=!0,!0),to;try{to=WebSocket}catch{}var no=class{constructor(e,t){E(this,"url");E(this,"_connected",!1);E(this,"onclose",null);E(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));E(this,"_onauth",null);E(this,"baseEoseTimeout",4400);E(this,"connectionTimeout",4400);E(this,"openSubs",new Map);E(this,"connectionTimeoutHandle");E(this,"connectionPromise");E(this,"openCountRequests",new Map);E(this,"openEventPublishes",new Map);E(this,"ws");E(this,"incomingMessageQueue",new Qs);E(this,"queueRunning",!1);E(this,"challenge");E(this,"serial",0);E(this,"verifyEvent");this.url=yt(e),this.verifyEvent=t.verifyEvent}static async connect(e,t){const n=new no(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 to(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),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 pc();this.queueRunning=!1}handleNext(){var n,r,o;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=hc(e);if(t){const i=this.openSubs.get(t);if(!i)return;const s=dc(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)&&fc(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);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(gc(this.url,this.challenge)),n=new Promise((r,o)=>{this.openEventPublishes.set(t.id,{resolve:r,reject:o})});return this.send('["AUTH",'+JSON.stringify(t)+"]"),n}async publish(e){const t=new Promise((n,r)=>{this.openEventPublishes.set(e.id,{resolve:n,reject:r})});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)+"]"),r}subscribe(e,t){const n=this.prepareSubscription(e,t);return n.fire(),n}prepareSubscription(e,t){this.serial++;const n=t.id||"sub:"+this.serial,r=new wc(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()}},wc=class{constructor(e,t,n,r){E(this,"relay");E(this,"id");E(this,"closed",!1);E(this,"eosed",!1);E(this,"filters");E(this,"alreadyHaveEvent");E(this,"receivedEvent");E(this,"onevent");E(this,"oneose");E(this,"onclose");E(this,"eoseTimeout");E(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)}},yc=class{constructor(e){E(this,"relays",new Map);E(this,"seenOn",new Map);E(this,"trackRelays",!1);E(this,"verifyEvent");E(this,"trustedRelayURLs",new Set);this.verifyEvent=e.verifyEvent}async ensureRelay(e,t){e=yt(e);let n=this.relays.get(e);return n||(n=new no(e,{verifyEvent:this.trustedRelayURLs.has(e)?bc:this.verifyEvent}),t!=null&&t.connectionTimeout&&(n.connectionTimeout=t.connectionTimeout),this.relays.set(e,n)),await n.connect(),n}close(e){e.map(yt).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]=!0,i.filter(h=>h).length===o&&((g=t.oneose)==null||g.call(t),s=()=>{})};const c=[];let a=(u,g)=>{var h;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=yt(b);let p;try{p=await this.ensureRelay(b,{connectionTimeout:t.maxWait?Math.max(t.maxWait*.8,t.maxWait-1e3):void 0})}catch(w){a(g,(w==null?void 0:w.message)||String(w));return}let y=p.subscribe(d,{...t,oneose:()=>s(g),onclose:w=>a(g,w),alreadyHaveEvent:l,eoseTimeout:t.maxWait});r.push(y)}));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(yt).map(async(n,r,o)=>o.indexOf(n)!==r?Promise.reject("duplicate url"):(await this.ensureRelay(n)).publish(t))}},mc=class extends yc{constructor(){super({verifyEvent:Xr})}},ro;try{ro=fetch}catch{}var zt=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%]*)$/,vc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;async function xc(e){let t=e.match(zt);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 oo(e)}async function oo(e){const t=e.match(sc);if(!t)return null;const[n,r="_",o]=t;try{const i=`https://${o}/.well-known/nostr.json?name=${r}`,s=await(await ro(i,{redirect:"error"})).json();let c=s.names[r],a=s.nip46[c]||[];return{pubkey:c,relays:a,secret:null}}catch{return null}}var io=class{constructor(e,t,n={}){E(this,"pool");E(this,"subCloser");E(this,"isOpen");E(this,"serial");E(this,"idPrefix");E(this,"listeners");E(this,"waitingForAuth");E(this,"secretKey");E(this,"bp");if(t.relays.length===0)throw new Error("no relays are specified for this bunker");this.pool=n.pool||new mc,this.secretKey=e,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;this.subCloser=this.pool.subscribeMany(this.bp.relays,[{kinds:[Cn],"#p":[nc(this.secretKey)]}],{async onevent(i){const{id:s,result:c,error:a}=JSON.parse(await ic(e,i.pubkey,i.content));if(c==="auth_url"&&o[s]){delete o[s],n.onauth?n.onauth(a):console.warn(`nostr-tools/nip46: remote signer ${t.pubkey} tried to send an "auth_url"='${a}' but there was no onauth() callback configured.`);return}let l=r[s];l&&(a?l.reject(a):c&&l.resolve(c),delete r[s])}}),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=await oc(this.secretKey,this.bp.pubkey,JSON.stringify({id:o,method:e,params:t})),s=rc({kind:Cn,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.bp.pubkey}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(n.pubkey===this.bp.pubkey&&Xr(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 nip44GetKey(e){let t=await this.sendRequest("nip44_get_key",[e]);return Xt(t)}async nip44Encrypt(e,t){return await this.sendRequest("nip44_encrypt",[e,t])}async nip44Decrypt(e,t){return await this.sendRequest("nip44_encrypt",[e,t])}};async function Ec(e,t,n,r,o){if(o&&!vc.test(o))throw new Error("Invalid email");let i=tc(),s=new io(i,e.bunkerPointer,t),c=await s.sendRequest("create_account",[n,r,o||""]);return s.bp.pubkey=c,await s.connect(),s}async function _c(e,t){const n=await e.querySync(t,{kinds:[lc],"#k":[Cn.toString()]});return n.sort((o,i)=>i.created_at-o.created_at),(await Promise.all(n.map(async(o,i)=>{try{const s=JSON.parse(o.content);try{if(n.findIndex(a=>JSON.parse(a.content).nip05===s.nip05)!==i)return}catch{}const c=await oo(s.nip05);if(c&&c.pubkey===o.pubkey&&c.relays.length)return{bunkerPointer:c,nip05:s.nip05,domain:s.nip05.split("@")[1],name:s.name||s.display_name,picture:s.picture,about:s.about,website:s.website,local:!1}}catch{return}}))).filter(o=>o!==void 0)}var so=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,co;try{co=fetch}catch{}async function kc(e){var i;const t=e.match(so);if(!t)return null;const[n,r="_",o]=t;try{const s=`https://${o}/.well-known/nostr.json?name=${r}`,c=await(await co(s,{redirect:"error"})).json();let a=c.names[r];return a?{pubkey:a,relays:(i=c.relays)==null?void 0:i[a]}:null}catch{return null}}new TextDecoder("utf-8"),new TextEncoder;var Sc=5e3;function Ac(e){return Ic("npub",Xt(e))}function Bc(e,t){let n=Jr.toWords(t);return Jr.encode(e,n,Sc)}function Ic(e,t){return Bc(e,t)}const st=[];function Oc(e,t=R){let n;const r=new Set;function o(c){if(Dt(e,c)&&(e=c,n)){const a=!st.length;for(const l of r)l[1](),st.push(l,e);if(a){for(let l=0;l<st.length;l+=2)st[l][0](st[l+1]);st.length=0}}}function i(c){o(c(e))}function s(c,a=R){const l=[c,a];return r.add(l),r.size===1&&(n=t(o,i)||R),c(e),()=>{r.delete(l),r.size===0&&n&&(n(),n=null)}}return{set:o,update:i,subscribe:s}}const Tc=e=>{const{subscribe:t,set:n}=Oc(void 0,()=>{let r=window.matchMedia(e);n(r.matches);const o=()=>n(r.matches);return"addEventListener"in r?r.addEventListener("change",o):r.addListener(o),()=>{"removeEventListener"in r?r.removeEventListener("change",o):r.removeListener(o)}});return{subscribe:t}};function Nc(e){let t,n,r;return{c(){t=Wt("svg"),n=Wt("circle"),r=Wt("path"),x(n,"class","opacity-25"),x(n,"cx","12"),x(n,"cy","12"),x(n,"r","10"),x(n,"stroke","currentColor"),x(n,"stroke-width","4"),x(r,"class","opacity-75"),x(r,"fill","currentColor"),x(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"),x(t,"class","ml-2 h-5 w-5 animate-spin text-white"),x(t,"xmlns","http://www.w3.org/2000/svg"),x(t,"fill","none"),x(t,"viewBox","0 0 24 24")},m(o,i){q(o,t,i),k(t,n),k(t,r)},p:R,i:R,o:R,d(o){o&&H(t)}}}class ao extends Fn{constructor(t){super(),Yn(this,t,null,Nc,Dt,{})}}const{window:Un}=Lo;function lo(e,t,n){const r=e.slice();return r[76]=t[n],r}function Lc(e){let t,n,r,o,i,s,c,a,l,f,u,g,h=!e[18]&&!e[11]&&!e[12]&&!e[13]&&uo(e);const b=[jc,$c,qc,Hc,Rc,Uc,Cc],d=[];function p(y,w){return y[11]?0:y[12]?1:y[13]?2:y[18]?3:y[15]?4:y[19]?6:5}return c=p(e),a=d[c]=b[c](e),{c(){t=N("div"),n=N("button"),r=$("⤫"),i=M(),h&&h.c(),s=M(),a.c(),x(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+e[0]+"-600"),x(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 from-"+e[0]+"-900 to-"+e[0]+"-700 "+e[25])},m(y,w){q(y,t,w),k(t,n),k(n,r),k(t,i),h&&h.m(t,null),k(t,s),d[c].m(t,null),f=!0,u||(g=Y(n,"click",function(){Kt(e[18]?e[30]:e[28])&&(e[18]?e[30]:e[28]).apply(this,arguments)}),u=!0)},p(y,w){e=y,(!f||w[0]&1&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+e[0]+"-600"))&&x(n,"class",o),!e[18]&&!e[11]&&!e[12]&&!e[13]?h?h.p(e,w):(h=uo(e),h.c(),h.m(t,s)):h&&(h.d(1),h=null);let _=c;c=p(e),c===_?d[c].p(e,w):(St(),ge(d[_],1,1,()=>{d[_]=null}),At(),a=d[c],a?a.p(e,w):(a=d[c]=b[c](e),a.c()),he(a,1),a.m(t,null)),(!f||w[0]&33554433&&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 from-"+e[0]+"-900 to-"+e[0]+"-700 "+e[25]))&&x(t,"class",l)},i(y){f||(he(a),f=!0)},o(y){ge(a),f=!1},d(y){y&&H(t),h&&h.d(),d[c].d(),u=!1,g()}}}function Pc(e){let t,n,r,o,i;const s=[Wc,Dc,Kc],c=[];function a(l,f){return l[10]?0:l[19]?2:1}return n=a(e),r=c[n]=s[n](e),{c(){t=N("div"),r.c(),x(t,"class",o="rounded px-4 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[25])},m(l,f){q(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):(St(),ge(c[u],1,1,()=>{c[u]=null}),At(),r=c[n],r?r.p(l,f):(r=c[n]=s[n](l),r.c()),he(r,1),r.m(t,null)),(!i||f[0]&33554433&&o!==(o="rounded px-4 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[25]))&&x(t,"class",o)},i(l){i||(he(r),i=!0)},o(l){ge(r),i=!1},d(l){l&&H(t),c[n].d()}}}function uo(e){let t,n,r,o,i;return{c(){t=N("button"),n=$("?"),x(t,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+e[0]+"-600")},m(s,c){q(s,t,c),k(t,n),o||(i=Y(t,"click",e[29]),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")&&x(t,"class",r)},d(s){s&&H(t),o=!1,i()}}}function Cc(e){let t,n,r,o,i,s,c=e[19].npub+"",a,l,f,u,g,h,b,d,p,y,w,_=Tr(e[9])+"",T,L,A,v=(e[19].picture||e[19].name)&&fo(e);return{c(){t=N("div"),n=N("div"),n.textContent="You are connected to Nostr as",r=M(),o=N("a"),v&&v.c(),i=M(),s=N("div"),a=$(c),f=M(),u=N("button"),g=$("Disconnect"),b=M(),d=N("div"),p=$("This webpage is using the public key:"),y=N("br"),w=M(),T=$(_),x(n,"class","mb-4 text-sm"),x(s,"class","block break-all"),x(o,"target","_blank"),x(o,"href",l="https://nosta.me/"+e[19].npub),x(o,"class","group text-white no-underline"),x(t,"class","text-center"),x(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"),x(d,"class","mt-6 block break-all text-center text-sm")},m(m,B){q(m,t,B),k(t,n),k(t,r),k(t,o),v&&v.m(o,null),k(o,i),k(o,s),k(s,a),q(m,f,B),q(m,u,B),k(u,g),q(m,b,B),q(m,d,B),k(d,p),k(d,y),k(d,w),k(d,T),L||(A=Y(u,"click",e[32]),L=!0)},p(m,B){m[19].picture||m[19].name?v?v.p(m,B):(v=fo(m),v.c(),v.m(o,i)):v&&(v.d(1),v=null),B[0]&524288&&c!==(c=m[19].npub+"")&&Le(a,c),B[0]&524288&&l!==(l="https://nosta.me/"+m[19].npub)&&x(o,"href",l),B[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")&&x(u,"class",h),B[0]&512&&_!==(_=Tr(m[9])+"")&&Le(T,_)},i:R,o:R,d(m){m&&(H(t),H(f),H(u),H(b),H(d)),v&&v.d(),L=!1,A()}}}function Uc(e){let t,n,r,o,i,s,c,a,l,f,u,g,h,b,d,p,y,w=e[17]&&po(e);const _=[Mc,zc],T=[];function L(m,B){return m[10]?0:1}a=L(e),l=T[a]=_[a](e);let A=e[10]&&e[14]&&bo(e),v=!e[10]&&wo(e);return{c(){t=N("div"),t.textContent="How do you want to connect to Nostr?",n=M(),r=N("form"),o=N("input"),i=M(),w&&w.c(),s=M(),c=N("button"),l.c(),g=M(),A&&A.c(),h=M(),v&&v.c(),b=Co(),x(t,"class","text-center text-lg"),x(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),x(o,"placeholder","user@provider or bunker://..."),o.autofocus=!0,o.disabled=e[10],x(o,"autocapitalize","none"),x(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[24]||e[10],x(r,"class","mb-1 mt-4 flex flex-col")},m(m,B){q(m,t,B),q(m,n,B),q(m,r,B),k(r,o),e[50](o),Je(o,e[2]),k(r,i),w&&w.m(r,null),k(r,s),k(r,c),T[a].m(c,null),k(r,g),A&&A.m(r,null),q(m,h,B),v&&v.m(m,B),q(m,b,B),d=!0,o.focus(),p||(y=[Y(o,"input",e[51]),Y(r,"submit",e[31])],p=!0)},p(m,B){(!d||B[0]&1024)&&(o.disabled=m[10]),B[0]&4&&o.value!==m[2]&&Je(o,m[2]),m[17]?w?w.p(m,B):(w=po(m),w.c(),w.m(r,s)):w&&(w.d(1),w=null);let C=a;a=L(m),a!==C&&(St(),ge(T[C],1,1,()=>{T[C]=null}),At(),l=T[a],l||(l=T[a]=_[a](m),l.c()),he(l,1),l.m(c,null)),(!d||B[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"))&&x(c,"class",f),(!d||B[0]&16778240&&u!==(u=!m[24]||m[10]))&&(c.disabled=u),m[10]&&m[14]?A?A.p(m,B):(A=bo(m),A.c(),A.m(r,null)):A&&(A.d(1),A=null),m[10]?v&&(v.d(1),v=null):v?v.p(m,B):(v=wo(m),v.c(),v.m(b.parentNode,b))},i(m){d||(he(l),d=!0)},o(m){ge(l),d=!1},d(m){m&&(H(t),H(n),H(r),H(h),H(b)),e[50](null),w&&w.d(),T[a].d(),A&&A.d(),v&&v.d(m),p=!1,Ne(y)}}}function Rc(e){let t,n,r,o,i,s,c,a,l,f,u,g,h,b,d,p,y,w,_,T,L,A,v=Gn(e[20]),m=[];for(let B=0;B<v.length;B+=1)m[B]=yo(lo(e,v,B));return{c(){t=N("div"),t.textContent="Create a Nostr account",n=M(),r=N("form"),o=N("div"),i=N("input"),s=M(),c=N("div"),c.textContent="@",a=M(),l=N("select");for(let B=0;B<m.length;B+=1)m[B].c();f=M(),u=N("button"),g=$("Continue »"),d=M(),p=N("div"),y=$("Do you already have a Nostr address?"),w=N("br"),_=M(),T=N("button"),T.textContent="Login now",x(t,"class","text-center text-lg"),x(i,"class","box-border w-40 rounded px-2 py-1 text-lg text-neutral-800 outline-none"),x(i,"placeholder","bob"),i.autofocus=!0,x(i,"autocapitalize","none"),x(c,"class","mx-2 text-2xl"),x(l,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),e[8]===void 0&&_t(()=>e[49].call(l)),x(o,"class","flex flex-row"),x(u,"class",h="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-"+e[0]+"-900 hover:bg-"+e[0]+"-950"),u.disabled=b=!e[8]||!e[7]||e[16],x(r,"class","mb-1 mt-4"),x(T,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),x(p,"class","mt-6 text-center text-sm leading-3")},m(B,C){q(B,t,C),q(B,n,C),q(B,r,C),k(r,o),k(o,i),e[47](i),Je(i,e[7]),k(o,s),k(o,c),k(o,a),k(o,l);for(let P=0;P<m.length;P+=1)m[P]&&m[P].m(l,null);Kn(l,e[8],!0),k(r,f),k(r,u),k(u,g),q(B,d,C),q(B,p,C),k(p,y),k(p,w),k(p,_),k(p,T),i.focus(),L||(A=[Y(i,"input",e[48]),Y(i,"input",e[36]),Y(l,"change",e[49]),Y(r,"submit",e[35]),Y(T,"click",e[34])],L=!0)},p(B,C){if(C[0]&128&&i.value!==B[7]&&Je(i,B[7]),C[0]&1048576){v=Gn(B[20]);let P;for(P=0;P<v.length;P+=1){const K=lo(B,v,P);m[P]?m[P].p(K,C):(m[P]=yo(K),m[P].c(),m[P].m(l,null))}for(;P<m.length;P+=1)m[P].d(1);m.length=v.length}C[0]&1048832&&Kn(l,B[8]),C[0]&1&&h!==(h="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")&&x(u,"class",h),C[0]&1114496&&b!==(b=!B[8]||!B[7]||B[16])&&(u.disabled=b)},i:R,o:R,d(B){B&&(H(t),H(n),H(r),H(d),H(p)),e[47](null),Po(m,B),L=!1,Ne(A)}}}function Hc(e){let t,n,r;return{c(){t=N("div"),t.textContent="What is that?",n=M(),r=N("div"),r.innerHTML=`<p class="mb mt-4">This widget is created with <i>window.nostr.js</i>, a small script
1
+ var Ta=Object.defineProperty;var Na=(Ke,L,Te)=>L in Ke?Ta(Ke,L,{enumerable:!0,configurable:!0,writable:!0,value:Te}):Ke[L]=Te;var x=(Ke,L,Te)=>(Na(Ke,typeof L!="symbol"?L+"":L,Te),Te);(function(){"use strict";var So,Ao,Bo,Io,Oo;const Ke='*,: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}.m-auto{margin:auto}.mx-2{margin-left:.5rem;margin-right:.5rem}.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-40{width:10rem}.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-row{flex-direction:row}.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-2xl{font-size:1.5rem;line-height:2rem}.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 L(){}function Te(t){return t()}function Kn(){return Object.create(null)}function Ne(t){t.forEach(Te)}function Dt(t){return typeof t=="function"}function Wt(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let _t;function Xe(t,e){return t===e?!0:(_t||(_t=document.createElement("a")),_t.href=e,t===_t.href)}function Co(t){return Object.keys(t).length===0}function Lo(t,...e){if(t==null){for(const r of e)r(void 0);return L}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function Uo(t,e,n){t.$$.on_destroy.push(Lo(e,n))}const Ro=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function k(t,e){t.appendChild(e)}function q(t,e,n){t.insertBefore(e,n||null)}function R(t){t.parentNode&&t.parentNode.removeChild(t)}function Ho(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function N(t){return document.createElement(t)}function Vt(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function j(t){return document.createTextNode(t)}function $(){return j(" ")}function qo(){return j("")}function J(t,e,n,r){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n,r)}function v(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function jo(t){return Array.from(t.childNodes)}function Pe(t,e){e=""+e,t.data!==e&&(t.data=e)}function et(t,e){t.value=e??""}function Dn(t,e,n){for(let r=0;r<t.options.length;r+=1){const o=t.options[r];if(o.__value===e){o.selected=!0;return}}(!n||e!==void 0)&&(t.selectedIndex=-1)}function Mo(t){const e=t.querySelector(":checked");return e&&e.__value}function Wn(t,e,n){t.classList.toggle(e,!!n)}let ft;function dt(t){ft=t}function zo(){if(!ft)throw new Error("Function called outside component initialization");return ft}function $o(t){zo().$$.on_mount.push(t)}const tt=[],ht=[];let nt=[];const Vn=[],Ko=Promise.resolve();let Gt=!1;function Do(){Gt||(Gt=!0,Ko.then(Gn))}function kt(t){nt.push(t)}const Zt=new Set;let rt=0;function Gn(){if(rt!==0)return;const t=ft;do{try{for(;rt<tt.length;){const e=tt[rt];rt++,dt(e),Wo(e.$$)}}catch(e){throw tt.length=0,rt=0,e}for(dt(null),tt.length=0,rt=0;ht.length;)ht.pop()();for(let e=0;e<nt.length;e+=1){const n=nt[e];Zt.has(n)||(Zt.add(n),n())}nt.length=0}while(tt.length);for(;Vn.length;)Vn.pop()();Gt=!1,Zt.clear(),dt(t)}function Wo(t){if(t.fragment!==null){t.update(),Ne(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(kt)}}function Vo(t){const e=[],n=[];nt.forEach(r=>t.indexOf(r)===-1?e.push(r):n.push(r)),n.forEach(r=>r()),nt=e}const St=new Set;let De;function At(){De={r:0,c:[],p:De}}function Bt(){De.r||Ne(De.c),De=De.p}function de(t,e){t&&t.i&&(St.delete(t),t.i(e))}function be(t,e,n,r){if(t&&t.o){if(St.has(t))return;St.add(t),De.c.push(()=>{St.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}else r&&r()}function Zn(t){return(t==null?void 0:t.length)!==void 0?t:Array.from(t)}function Yn(t){t&&t.c()}function Yt(t,e,n){const{fragment:r,after_update:o}=t.$$;r&&r.m(e,n),kt(()=>{const i=t.$$.on_mount.map(Te).filter(Dt);t.$$.on_destroy?t.$$.on_destroy.push(...i):Ne(i),t.$$.on_mount=[]}),o.forEach(kt)}function Ft(t,e){const n=t.$$;n.fragment!==null&&(Vo(n.after_update),Ne(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Go(t,e){t.$$.dirty[0]===-1&&(tt.push(t),Do(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Fn(t,e,n,r,o,i,s=null,c=[-1]){const a=ft;dt(t);const l=t.$$={fragment:null,ctx:[],props:i,update:L,not_equal:o,bound:Kn(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(a?a.$$.context:[])),callbacks:Kn(),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 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&&Go(t,u)),g}):[],l.update(),f=!0,Ne(l.before_update),l.fragment=r?r(l.ctx):!1,e.target){if(e.hydrate){const u=jo(e.target);l.fragment&&l.fragment.l(u),u.forEach(R)}else l.fragment&&l.fragment.c();e.intro&&de(t.$$.fragment),Yt(t,e.target,e.anchor),Gn()}dt(a)}class Jn{constructor(){x(this,"$$");x(this,"$$set")}$destroy(){Ft(this,1),this.$destroy=L}$on(e,n){if(!Dt(n))return L;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&&!Co(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Zo="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Zo);function Yo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Jt={exports:{}};function Qn(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,b=i;o=void 0,i=void 0,a=t.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=t.apply(u,g),clearTimeout(s),s=void 0},f}Jt.exports.debounce=Qn,Jt.exports=Qn;var Fo=Jt.exports;const Xn=Yo(Fo),Qt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const er=t=>t instanceof Uint8Array,Xt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),we=(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 Jo=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ne(t){if(!er(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=Jo[t[n]];return e}function en(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 Qo(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function tr(t){if(typeof t=="string"&&(t=Qo(t)),!er(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}let Xo=class{clone(){return this._cloneInto()}};function nr(t){const e=r=>t().update(tr(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ei(t=32){if(Qt&&typeof Qt.getRandomValues=="function")return Qt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function rr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function or(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 ti(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rr(t.outputLen),rr(t.blockLen)}function It(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){or(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const tn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ir=t=>t instanceof Uint8Array,nn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ye=(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 rn(t){if(typeof t=="string"&&(t=ri(t)),!ir(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function oi(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!ir(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class sr{clone(){return this._cloneInto()}}function ii(t){const e=r=>t().update(rn(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function cr(t=32){if(tn&&typeof tn.getRandomValues=="function")return tn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function si(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 ci=class extends sr{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=nn(this.buffer)}update(e){It(this);const{view:n,buffer:r,blockLen:o}=this;e=rn(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=nn(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){It(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;si(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=nn(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 ai=(t,e,n)=>t&e^~t&n,li=(t,e,n)=>t&e^t&n^e&n,ui=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]),Ce=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Le=new Uint32Array(64);let fi=class extends ci{constructor(){super(64,32,8,!1),this.A=Ce[0]|0,this.B=Ce[1]|0,this.C=Ce[2]|0,this.D=Ce[3]|0,this.E=Ce[4]|0,this.F=Ce[5]|0,this.G=Ce[6]|0,this.H=Ce[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)Le[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const g=Le[u-15],h=Le[u-2],b=ye(g,7)^ye(g,18)^g>>>3,d=ye(h,17)^ye(h,19)^h>>>10;Le[u]=d+Le[u-7]+b+Le[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=ye(c,6)^ye(c,11)^ye(c,25),h=f+g+ai(c,a,l)+ui[u]+Le[u]|0,d=(ye(r,2)^ye(r,13)^ye(r,22))+li(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(){Le.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const on=ii(()=>new fi);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ar=BigInt(0),Ot=BigInt(1),di=BigInt(2),Tt=t=>t instanceof Uint8Array,hi=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ot(t){if(!Tt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=hi[t[n]];return e}function lr(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 it(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 oe(t){return sn(ot(t))}function cn(t){if(!Tt(t))throw new Error("Uint8Array expected");return sn(ot(Uint8Array.from(t).reverse()))}function Ue(t,e){return it(t.toString(16).padStart(e*2,"0"))}function an(t,e){return Ue(t,e).reverse()}function gi(t){return it(lr(t))}function te(t,e,n){let r;if(typeof e=="string")try{r=it(e)}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Tt(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 We(...t){const e=new Uint8Array(t.reduce((r,o)=>r+o.length,0));let n=0;return t.forEach(r=>{if(!Tt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}function pi(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 bi(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function wi(t){let e;for(e=0;t>ar;t>>=Ot,e+=1);return e}function yi(t,e){return t>>BigInt(e)&Ot}const mi=(t,e,n)=>t|(n?Ot:ar)<<BigInt(e),ln=t=>(di<<BigInt(t-1))-Ot,un=t=>new Uint8Array(t),ur=t=>Uint8Array.from(t);function fr(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=un(t),o=un(t),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},c=(...u)=>n(o,r,...u),a=(u=un())=>{o=c(ur([0]),u),r=c(),u.length!==0&&(o=c(ur([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 We(...g)};return(u,g)=>{s(),a(u);let h;for(;!(h=g(l()));)a();return s(),h}}const vi={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 gt(t,e,n={}){const r=(o,i,s)=>{const c=vi[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 xi=Object.freeze(Object.defineProperty({__proto__:null,bitGet:yi,bitLen:wi,bitMask:ln,bitSet:mi,bytesToHex:ot,bytesToNumberBE:oe,bytesToNumberLE:cn,concatBytes:We,createHmacDrbg:fr,ensureBytes:te,equalBytes:pi,hexToBytes:it,hexToNumber:sn,numberToBytesBE:Ue,numberToBytesLE:an,numberToHexUnpadded:lr,numberToVarBytesBE:gi,utf8ToBytes:bi,validateObject:gt},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Q=BigInt(0),W=BigInt(1),Ve=BigInt(2),Ei=BigInt(3),fn=BigInt(4),dr=BigInt(5),hr=BigInt(8);BigInt(9),BigInt(16);function X(t,e){const n=t%e;return n>=Q?n:e+n}function _i(t,e,n){if(n<=Q||e<Q)throw new Error("Expected power/modulo > 0");if(n===W)return Q;let r=W;for(;e>Q;)e&W&&(r=r*t%n),t=t*t%n,e>>=W;return r}function ae(t,e,n){let r=t;for(;e-- >Q;)r*=r,r%=n;return r}function dn(t,e){if(t===Q||e<=Q)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=X(t,e),r=e,o=Q,i=W;for(;n!==Q;){const c=r/n,a=r%n,l=o-i*c;r=n,n=a,o=i,i=l}if(r!==W)throw new Error("invert: does not exist");return X(o,e)}function ki(t){const e=(t-W)/Ve;let n,r,o;for(n=t-W,r=0;n%Ve===Q;n/=Ve,r++);for(o=Ve;o<t&&_i(o,e,t)!==t-W;o++);if(r===1){const s=(t+W)/fn;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+W)/Ve;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 b=c.pow(f,W<<BigInt(l-h-1));f=c.sqr(b),u=c.mul(u,b),g=c.mul(g,f),l=h}return u}}function Si(t){if(t%fn===Ei){const e=(t+W)/fn;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%hr===dr){const e=(t-dr)/hr;return function(r,o){const i=r.mul(o,Ve),s=r.pow(i,e),c=r.mul(o,s),a=r.mul(r.mul(c,Ve),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 ki(t)}const Ai=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bi(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Ai.reduce((r,o)=>(r[o]="function",r),e);return gt(t,n)}function Ii(t,e,n){if(n<Q)throw new Error("Expected power > 0");if(n===Q)return t.ONE;if(n===W)return e;let r=t.ONE,o=e;for(;n>Q;)n&W&&(r=t.mul(r,o)),o=t.sqr(o),n>>=W;return r}function Oi(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 gr(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Ti(t,e,n=!1,r={}){if(t<=Q)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:o,nByteLength:i}=gr(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Si(t),c=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:ln(o),ZERO:Q,ONE:W,create:a=>X(a,t),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return Q<=a&&a<t},is0:a=>a===Q,isOdd:a=>(a&W)===W,neg:a=>X(-a,t),eql:(a,l)=>a===l,sqr:a=>X(a*a,t),add:(a,l)=>X(a+l,t),sub:(a,l)=>X(a-l,t),mul:(a,l)=>X(a*l,t),pow:(a,l)=>Ii(c,a,l),div:(a,l)=>X(a*dn(l,t),t),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>dn(a,t),sqrt:r.sqrt||(a=>s(c,a)),invertBatch:a=>Oi(c,a),cmov:(a,l,f)=>f?l:a,toBytes:a=>n?an(a,i):Ue(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return n?cn(a):oe(a)}});return Object.freeze(c)}function pr(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 br(t){const e=pr(t);return e+Math.ceil(e/2)}function Ni(t,e,n=!1){const r=t.length,o=pr(e),i=br(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=n?oe(t):cn(t),c=X(s,e-W)+W;return n?an(c,o):Ue(c,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pi=BigInt(0),hn=BigInt(1);function Ci(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>Pi;)i&hn&&(s=s.add(c)),c=c.double(),i>>=hn;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 b=0;b<c;b++){const d=b*a;let p=Number(s&u);s>>=h,p>a&&(p-=g,s+=hn);const y=d,w=d+Math.abs(p)-1,E=b%2!==0,O=p<0;p===0?f=f.add(n(E,i[y])):l=l.add(n(O,i[w]))}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 wr(t){return Bi(t.Fp),gt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...gr(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Li(t){const e=wr(t);gt(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:Ui,hexToBytes:Ri}=xi,Ge={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=Ge;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:Ui(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=Ge,n=typeof t=="string"?Ri(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}=Ge._parseInt(n.subarray(2)),{d:s,l:c}=Ge._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}`}},Ee=BigInt(0),le=BigInt(1);BigInt(2);const yr=BigInt(3);BigInt(4);function Hi(t){const e=Li(t),{Fp:n}=e,r=e.toBytes||((b,d,p)=>{const y=d.toAffine();return We(Uint8Array.from([4]),n.toBytes(y.x),n.toBytes(y.y))}),o=e.fromBytes||(b=>{const d=b.subarray(1),p=n.fromBytes(d.subarray(0,n.BYTES)),y=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:p,y}});function i(b){const{a:d,b:p}=e,y=n.sqr(b),w=n.mul(y,b);return n.add(n.add(w,n.mul(b,d)),p)}if(!n.eql(n.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(b){return typeof b=="bigint"&&Ee<b&&b<e.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:y,n:w}=e;if(d&&typeof b!="bigint"){if(b instanceof Uint8Array&&(b=ot(b)),typeof b!="string"||!d.includes(b.length))throw new Error("Invalid key");b=b.padStart(p*2,"0")}let E;try{E=typeof b=="bigint"?b:oe(te("private key",b,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof b}`)}return y&&(E=X(E,w)),c(E),E}const l=new Map;function f(b){if(!(b instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,p,y){if(this.px=d,this.py=p,this.pz=y,d==null||!n.isValid(d))throw new Error("x required");if(p==null||!n.isValid(p))throw new Error("y required");if(y==null||!n.isValid(y))throw new Error("z required")}static fromAffine(d){const{x:p,y}=d||{};if(!d||!n.isValid(p)||!n.isValid(y))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");const w=E=>n.eql(E,n.ZERO);return w(p)&&w(y)?u.ZERO:new u(p,y,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const p=n.invertBatch(d.map(y=>y.pz));return d.map((y,w)=>y.toAffine(p[w])).map(u.fromAffine)}static fromHex(d){const p=u.fromAffine(o(te("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(e.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 y=n.sqr(p),w=i(d);if(!n.eql(y,w))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:y,pz:w}=this,{px:E,py:O,pz:P}=d,S=n.eql(n.mul(p,P),n.mul(E,w)),_=n.eql(n.mul(y,P),n.mul(O,w));return S&&_}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b:p}=e,y=n.mul(p,yr),{px:w,py:E,pz:O}=this;let P=n.ZERO,S=n.ZERO,_=n.ZERO,m=n.mul(w,w),A=n.mul(E,E),C=n.mul(O,O),U=n.mul(w,E);return U=n.add(U,U),_=n.mul(w,O),_=n.add(_,_),P=n.mul(d,_),S=n.mul(y,C),S=n.add(P,S),P=n.sub(A,S),S=n.add(A,S),S=n.mul(P,S),P=n.mul(U,P),_=n.mul(y,_),C=n.mul(d,C),U=n.sub(m,C),U=n.mul(d,U),U=n.add(U,_),_=n.add(m,m),m=n.add(_,m),m=n.add(m,C),m=n.mul(m,U),S=n.add(S,m),C=n.mul(E,O),C=n.add(C,C),m=n.mul(C,U),P=n.sub(P,m),_=n.mul(C,A),_=n.add(_,_),_=n.add(_,_),new u(P,S,_)}add(d){f(d);const{px:p,py:y,pz:w}=this,{px:E,py:O,pz:P}=d;let S=n.ZERO,_=n.ZERO,m=n.ZERO;const A=e.a,C=n.mul(e.b,yr);let U=n.mul(p,E),G=n.mul(y,O),Z=n.mul(w,P),Y=n.add(p,y),B=n.add(E,O);Y=n.mul(Y,B),B=n.add(U,G),Y=n.sub(Y,B),B=n.add(p,w);let T=n.add(E,P);return B=n.mul(B,T),T=n.add(U,Z),B=n.sub(B,T),T=n.add(y,w),S=n.add(O,P),T=n.mul(T,S),S=n.add(G,Z),T=n.sub(T,S),m=n.mul(A,B),S=n.mul(C,Z),m=n.add(S,m),S=n.sub(G,m),m=n.add(G,m),_=n.mul(S,m),G=n.add(U,U),G=n.add(G,U),Z=n.mul(A,Z),B=n.mul(C,B),G=n.add(G,Z),Z=n.sub(U,Z),Z=n.mul(A,Z),B=n.add(B,Z),U=n.mul(G,B),_=n.add(_,U),U=n.mul(T,B),S=n.mul(Y,S),S=n.sub(S,U),U=n.mul(Y,G),m=n.mul(T,m),m=n.add(m,U),new u(S,_,m)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return h.wNAFCached(this,l,d,p=>{const y=n.invertBatch(p.map(w=>w.pz));return p.map((w,E)=>w.toAffine(y[E])).map(u.fromAffine)})}multiplyUnsafe(d){const p=u.ZERO;if(d===Ee)return p;if(c(d),d===le)return this;const{endo:y}=e;if(!y)return h.unsafeLadder(this,d);let{k1neg:w,k1:E,k2neg:O,k2:P}=y.splitScalar(d),S=p,_=p,m=this;for(;E>Ee||P>Ee;)E&le&&(S=S.add(m)),P&le&&(_=_.add(m)),m=m.double(),E>>=le,P>>=le;return w&&(S=S.negate()),O&&(_=_.negate()),_=new u(n.mul(_.px,y.beta),_.py,_.pz),S.add(_)}multiply(d){c(d);let p=d,y,w;const{endo:E}=e;if(E){const{k1neg:O,k1:P,k2neg:S,k2:_}=E.splitScalar(p);let{p:m,f:A}=this.wNAF(P),{p:C,f:U}=this.wNAF(_);m=h.constTimeNegate(O,m),C=h.constTimeNegate(S,C),C=new u(n.mul(C.px,E.beta),C.py,C.pz),y=m.add(C),w=A.add(U)}else{const{p:O,f:P}=this.wNAF(p);y=O,w=P}return u.normalizeZ([y,w])[0]}multiplyAndAddUnsafe(d,p,y){const w=u.BASE,E=(P,S)=>S===Ee||S===le||!P.equals(w)?P.multiplyUnsafe(S):P.multiply(S),O=E(this,p).add(E(d,y));return O.is0()?void 0:O}toAffine(d){const{px:p,py:y,pz:w}=this,E=this.is0();d==null&&(d=E?n.ONE:n.inv(w));const O=n.mul(p,d),P=n.mul(y,d),S=n.mul(w,d);if(E)return{x:n.ZERO,y:n.ZERO};if(!n.eql(S,n.ONE))throw new Error("invZ was invalid");return{x:O,y:P}}isTorsionFree(){const{h:d,isTorsionFree:p}=e;if(d===le)return!0;if(p)return p(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:d,clearCofactor:p}=e;return d===le?this:p?p(u,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),r(u,this,d)}toHex(d=!0){return ot(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=Ci(u,e.endo?Math.ceil(g/2):g);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:s}}function qi(t){const e=wr(t);return gt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ji(t){const e=qi(t),{Fp:n,n:r}=e,o=n.BYTES+1,i=2*n.BYTES+1;function s(B){return Ee<B&&B<n.ORDER}function c(B){return X(B,r)}function a(B){return dn(B,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:g}=Hi({...e,toBytes(B,T,H){const z=T.toAffine(),M=n.toBytes(z.x),K=We;return H?K(Uint8Array.from([T.hasEvenY()?2:3]),M):K(Uint8Array.from([4]),M,n.toBytes(z.y))},fromBytes(B){const T=B.length,H=B[0],z=B.subarray(1);if(T===o&&(H===2||H===3)){const M=oe(z);if(!s(M))throw new Error("Point is not on curve");const K=u(M);let ee=n.sqrt(K);const V=(ee&le)===le;return(H&1)===1!==V&&(ee=n.neg(ee)),{x:M,y:ee}}else if(T===i&&H===4){const M=n.fromBytes(z.subarray(0,n.BYTES)),K=n.fromBytes(z.subarray(n.BYTES,2*n.BYTES));return{x:M,y:K}}else throw new Error(`Point of length ${T} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=B=>ot(Ue(B,e.nByteLength));function b(B){const T=r>>le;return B>T}function d(B){return b(B)?c(-B):B}const p=(B,T,H)=>oe(B.slice(T,H));class y{constructor(T,H,z){this.r=T,this.s=H,this.recovery=z,this.assertValidity()}static fromCompact(T){const H=e.nByteLength;return T=te("compactSignature",T,H*2),new y(p(T,0,H),p(T,H,2*H))}static fromDER(T){const{r:H,s:z}=Ge.toSig(te("DER",T));return new y(H,z)}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(T){return new y(this.r,this.s,T)}recoverPublicKey(T){const{r:H,s:z,recovery:M}=this,K=_(te("msgHash",T));if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");const ee=M===2||M===3?H+e.n:H;if(ee>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const V=M&1?"03":"02",fe=l.fromHex(V+h(ee)),F=a(ee),he=c(-K*F),ge=c(z*F),pe=l.BASE.multiplyAndAddUnsafe(fe,he,ge);if(!pe)throw new Error("point at infinify");return pe.assertValidity(),pe}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return it(this.toDERHex())}toDERHex(){return Ge.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return it(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const w={isValidPrivateKey(B){try{return f(B),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const B=br(e.n);return Ni(e.randomBytes(B),e.n)},precompute(B=8,T=l.BASE){return T._setWindowSize(B),T.multiply(BigInt(3)),T}};function E(B,T=!0){return l.fromPrivateKey(B).toRawBytes(T)}function O(B){const T=B instanceof Uint8Array,H=typeof B=="string",z=(T||H)&&B.length;return T?z===o||z===i:H?z===2*o||z===2*i:B instanceof l}function P(B,T,H=!0){if(O(B))throw new Error("first arg must be private key");if(!O(T))throw new Error("second arg must be public key");return l.fromHex(T).multiply(f(B)).toRawBytes(H)}const S=e.bits2int||function(B){const T=oe(B),H=B.length*8-e.nBitLength;return H>0?T>>BigInt(H):T},_=e.bits2int_modN||function(B){return c(S(B))},m=ln(e.nBitLength);function A(B){if(typeof B!="bigint")throw new Error("bigint expected");if(!(Ee<=B&&B<m))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Ue(B,e.nByteLength)}function C(B,T,H=U){if(["recovered","canonical"].some(ce=>ce in H))throw new Error("sign() legacy options not supported");const{hash:z,randomBytes:M}=e;let{lowS:K,prehash:ee,extraEntropy:V}=H;K==null&&(K=!0),B=te("msgHash",B),ee&&(B=te("prehashed msgHash",z(B)));const fe=_(B),F=f(T),he=[A(F),A(fe)];if(V!=null){const ce=V===!0?M(n.BYTES):V;he.push(te("extraEntropy",ce))}const ge=We(...he),pe=fe;function Je(ce){const Be=S(ce);if(!g(Be))return;const Et=a(Be),Ie=l.BASE.multiply(Be).toAffine(),ie=c(Ie.x);if(ie===Ee)return;const Oe=c(Et*c(pe+ie*F));if(Oe===Ee)return;let Qe=(Ie.x===ie?0:2)|Number(Ie.y&le),$e=Oe;return K&&b(Oe)&&($e=d(Oe),Qe^=1),new y(ie,$e,Qe)}return{seed:ge,k2sig:Je}}const U={lowS:e.lowS,prehash:!1},G={lowS:e.lowS,prehash:!1};function Z(B,T,H=U){const{seed:z,k2sig:M}=C(B,T,H),K=e;return fr(K.hash.outputLen,K.nByteLength,K.hmac)(z,M)}l.BASE._setWindowSize(8);function Y(B,T,H,z=G){var Ie;const M=B;if(T=te("msgHash",T),H=te("publicKey",H),"strict"in z)throw new Error("options.strict was renamed to lowS");const{lowS:K,prehash:ee}=z;let V,fe;try{if(typeof M=="string"||M instanceof Uint8Array)try{V=y.fromDER(M)}catch(ie){if(!(ie instanceof Ge.Err))throw ie;V=y.fromCompact(M)}else if(typeof M=="object"&&typeof M.r=="bigint"&&typeof M.s=="bigint"){const{r:ie,s:Oe}=M;V=new y(ie,Oe)}else throw new Error("PARSE");fe=l.fromHex(H)}catch(ie){if(ie.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(K&&V.hasHighS())return!1;ee&&(T=e.hash(T));const{r:F,s:he}=V,ge=_(T),pe=a(he),Je=c(ge*pe),ce=c(F*pe),Be=(Ie=l.BASE.multiplyAndAddUnsafe(fe,Je,ce))==null?void 0:Ie.toAffine();return Be?c(Be.x)===F:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:P,sign:Z,verify:Y,ProjectivePoint:l,Signature:y,utils:w}}class mr extends sr{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,ti(e);const r=rn(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 It(this),this.iHash.update(e),this}digestInto(e){It(this),or(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 vr=(t,e,n)=>new mr(t,e).update(n).digest();vr.create=(t,e)=>new mr(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Mi(t){return{hash:t,hmac:(e,...n)=>vr(t,e,oi(...n)),randomBytes:cr}}function zi(t,e){const n=r=>ji({...t,...Mi(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Pt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xr=BigInt(1),Ct=BigInt(2),Er=(t,e)=>(t+e/Ct)/e;function _r(t){const e=Nt,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=ae(f,n,e)*f%e,g=ae(u,n,e)*f%e,h=ae(g,Ct,e)*l%e,b=ae(h,o,e)*h%e,d=ae(b,i,e)*b%e,p=ae(d,c,e)*d%e,y=ae(p,a,e)*p%e,w=ae(y,c,e)*d%e,E=ae(w,n,e)*f%e,O=ae(E,s,e)*b%e,P=ae(O,r,e)*l%e,S=ae(P,Ct,e);if(!gn.eql(gn.sqr(S),t))throw new Error("Cannot find square root");return S}const gn=Ti(Nt,void 0,void 0,{sqrt:_r}),pt=zi({a:BigInt(0),b:BigInt(7),Fp:gn,n:Pt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Pt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-xr*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),c=Er(i*t,e),a=Er(-r*t,e);let l=X(t-c*n-a*o,e),f=X(-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}}}},on),Lt=BigInt(0),kr=t=>typeof t=="bigint"&&Lt<t&&t<Nt,$i=t=>typeof t=="bigint"&&Lt<t&&t<Pt,Sr={};function Ut(t,...e){let n=Sr[t];if(n===void 0){const r=on(Uint8Array.from(t,o=>o.charCodeAt(0)));n=We(r,r),Sr[t]=n}return on(We(n,...e))}const pn=t=>t.toRawBytes(!0).slice(1),bn=t=>Ue(t,32),wn=t=>X(t,Nt),bt=t=>X(t,Pt),yn=pt.ProjectivePoint,Ki=(t,e,n)=>yn.BASE.multiplyAndAddUnsafe(t,e,n);function mn(t){let e=pt.utils.normPrivateKeyToScalar(t),n=yn.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:bt(-e),bytes:pn(n)}}function Ar(t){if(!kr(t))throw new Error("bad x: need 0 < x < p");const e=wn(t*t),n=wn(e*t+BigInt(7));let r=_r(n);r%Ct!==Lt&&(r=wn(-r));const o=new yn(t,r,xr);return o.assertValidity(),o}function Br(...t){return bt(oe(Ut("BIP0340/challenge",...t)))}function Di(t){return mn(t).bytes}function Wi(t,e,n=cr(32)){const r=te("message",t),{bytes:o,scalar:i}=mn(e),s=te("auxRand",n,32),c=bn(i^oe(Ut("BIP0340/aux",s))),a=Ut("BIP0340/nonce",c,o,r),l=bt(oe(a));if(l===Lt)throw new Error("sign failed: k is zero");const{bytes:f,scalar:u}=mn(l),g=Br(f,o,r),h=new Uint8Array(64);if(h.set(f,0),h.set(bn(bt(u+g*i)),32),!Ir(h,r,o))throw new Error("sign: Invalid signature produced");return h}function Ir(t,e,n){const r=te("signature",t,64),o=te("message",e),i=te("publicKey",n,32);try{const s=Ar(oe(i)),c=oe(r.subarray(0,32));if(!kr(c))return!1;const a=oe(r.subarray(32,64));if(!$i(a))return!1;const l=Br(bn(c),pn(s),o),f=Ki(s,a,bt(-l));return!(!f||!f.hasEvenY()||f.toAffine().x!==c)}catch{return!1}}const re={getPublicKey:Di,sign:Wi,verify:Ir,utils:{randomPrivateKey:pt.utils.randomPrivateKey,lift_x:Ar,pointToBytes:pn,numberToBytesBE:Ue,bytesToNumberBE:oe,taggedHash:Ut,mod:X}};function vn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Vi(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Or(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 Gi(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");vn(t.outputLen),vn(t.blockLen)}function Zi(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 Yi(t,e){Or(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const xn={number:vn,bool:Vi,bytes:Or,hash:Gi,exists:Zi,output:Yi};function Fi(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 Ji extends Xo{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=Xt(this.buffer)}update(e){xn.exists(this);const{view:n,buffer:r,blockLen:o}=this;e=tr(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=Xt(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){xn.exists(this),xn.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;Fi(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=Xt(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 Qi=(t,e,n)=>t&e^~t&n,Xi=(t,e,n)=>t&e^t&n^e&n,es=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]),Re=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),He=new Uint32Array(64);class Tr extends Ji{constructor(){super(64,32,8,!1),this.A=Re[0]|0,this.B=Re[1]|0,this.C=Re[2]|0,this.D=Re[3]|0,this.E=Re[4]|0,this.F=Re[5]|0,this.G=Re[6]|0,this.H=Re[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)He[u]=e.getUint32(n,!1);for(let u=16;u<64;u++){const g=He[u-15],h=He[u-2],b=we(g,7)^we(g,18)^g>>>3,d=we(h,17)^we(h,19)^h>>>10;He[u]=d+He[u-7]+b+He[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=we(c,6)^we(c,11)^we(c,25),h=f+g+Qi(c,a,l)+es[u]+He[u]|0,d=(we(r,2)^we(r,13)^we(r,22))+Xi(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(){He.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class ts extends Tr{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const En=nr(()=>new Tr);nr(()=>new ts);var st=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]=="object")return!1}return!0}new TextDecoder("utf-8");var os=new TextEncoder,is=class{generateSecretKey(){return re.utils.randomPrivateKey()}getPublicKey(e){return ne(re.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=ne(re.getPublicKey(n)),r.id=_n(r),r.sig=ne(re.sign(_n(r),n)),r[st]=!0,r}verifyEvent(e){if(typeof e[st]=="boolean")return e[st];const n=_n(e);if(n!==e.id)return e[st]=!1,!1;try{const r=re.verify(e.sig,n,e.pubkey);return e[st]=r,r}catch{return e[st]=!1,!1}}};function ss(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 _n(t){let e=En(os.encode(ss(t)));return ne(e)}var Rt=new is,cs=Rt.generateSecretKey,Nr=Rt.getPublicKey;Rt.finalizeEvent,Rt.verifyEvent;var Ze=Symbol("verified"),as=t=>t instanceof Object;function ls(t){if(!as(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}new TextDecoder("utf-8");var us=new TextEncoder;function wt(t){t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}var fs=class{constructor(e){x(this,"value");x(this,"next",null);x(this,"prev",null);this.value=e}},ds=class{constructor(){x(this,"first");x(this,"last");this.first=null,this.last=null}enqueue(e){const n=new fs(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,e.value}},hs=class{generateSecretKey(){return re.utils.randomPrivateKey()}getPublicKey(e){return ne(re.getPublicKey(e))}finalizeEvent(e,n){const r=e;return r.pubkey=ne(re.getPublicKey(n)),r.id=kn(r),r.sig=ne(re.sign(kn(r),n)),r[Ze]=!0,r}verifyEvent(e){if(typeof e[Ze]=="boolean")return e[Ze];const n=kn(e);if(n!==e.id)return e[Ze]=!1,!1;try{const r=re.verify(e.sig,n,e.pubkey);return e[Ze]=r,r}catch{return e[Ze]=!1,!1}}};function gs(t){if(!ls(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 kn(t){let e=En(us.encode(gs(t)));return ne(e)}var Ht=new hs;Ht.generateSecretKey,Ht.getPublicKey,Ht.finalizeEvent;var ps=Ht.verifyEvent,bs=22242;function ws(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1&&!t.ids.some(n=>e.id.startsWith(n))||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1&&!t.authors.some(n=>e.pubkey.startsWith(n)))return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),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 ys(t,e){for(let n=0;n<t.length;n++)if(ws(t[n],e))return!0;return!1}function ms(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 vs(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 xs(t,e){return{kind:bs,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function Es(){return new Promise(t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()})}var _s=t=>(t[Ze]=!0,!0),Pr;try{Pr=WebSocket}catch{}var Cr=class{constructor(e,n){x(this,"url");x(this,"_connected",!1);x(this,"onclose",null);x(this,"onnotice",e=>console.debug(`NOTICE from ${this.url}: ${e}`));x(this,"_onauth",null);x(this,"baseEoseTimeout",4400);x(this,"connectionTimeout",4400);x(this,"openSubs",new Map);x(this,"connectionTimeoutHandle");x(this,"connectionPromise");x(this,"openCountRequests",new Map);x(this,"openEventPublishes",new Map);x(this,"ws");x(this,"incomingMessageQueue",new ds);x(this,"queueRunning",!1);x(this,"challenge");x(this,"serial",0);x(this,"verifyEvent");this.url=wt(e),this.verifyEvent=n.verifyEvent}static async connect(e,n){const r=new Cr(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 connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=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 Pr(this.url)}catch(r){n(r);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,e()},this.ws.onerror=r=>{var o;n(r.message),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 Es();this.queueRunning=!1}handleNext(){var r,o,i;const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const n=vs(e);if(n){const s=this.openSubs.get(n);if(!s)return;const c=ms(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)&&ys(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);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(e){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{var n;(n=this.ws)==null||n.send(e)})}async auth(e){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const n=await e(xs(this.url,this.challenge)),r=new Promise((o,i)=>{this.openEventPublishes.set(n.id,{resolve:o,reject:i})});return this.send('["AUTH",'+JSON.stringify(n)+"]"),r}async publish(e){const n=new Promise((r,o)=>{this.openEventPublishes.set(e.id,{resolve:r,reject:o})});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)+"]"),o}subscribe(e,n){const r=this.prepareSubscription(e,n);return r.fire(),r}prepareSubscription(e,n){this.serial++;const r=n.id||"sub:"+this.serial,o=new ks(this,r,e,n);return this.openSubs.set(r,o),o}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()}},ks=class{constructor(e,n,r,o){x(this,"relay");x(this,"id");x(this,"closed",!1);x(this,"eosed",!1);x(this,"filters");x(this,"alreadyHaveEvent");x(this,"receivedEvent");x(this,"onevent");x(this,"oneose");x(this,"onclose");x(this,"eoseTimeout");x(this,"eoseTimeoutHandle");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;!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,e)}},Ss=class{constructor(e){x(this,"relays",new Map);x(this,"seenOn",new Map);x(this,"trackRelays",!1);x(this,"verifyEvent");x(this,"trustedRelayURLs",new Set);this.verifyEvent=e.verifyEvent}async ensureRelay(e,n){e=wt(e);let r=this.relays.get(e);return r||(r=new Cr(e,{verifyEvent:this.trustedRelayURLs.has(e)?_s:this.verifyEvent}),n!=null&&n.connectionTimeout&&(r.connectionTimeout=n.connectionTimeout),this.relays.set(e,r)),await r.connect(),r}close(e){e.map(wt).forEach(n=>{var r;(r=this.relays.get(n))==null||r.close()})}subscribeMany(e,n,r){return this.subscribeManyMap(Object.fromEntries(e.map(o=>[o,n])),r)}subscribeManyMap(e,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(e).length,s=[];let c=g=>{var h;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;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(e).map(async(g,h,b)=>{if(b.indexOf(g)!==h){l(h,"duplicate url");return}let[d,p]=g;d=wt(d);let y;try{y=await this.ensureRelay(d,{connectionTimeout:n.maxWait?Math.max(n.maxWait*.8,n.maxWait-1e3):void 0})}catch(E){l(h,(E==null?void 0:E.message)||String(E));return}let w=y.subscribe(p,{...n,oneose:()=>c(h),onclose:E=>l(h,E),alreadyHaveEvent:f,eoseTimeout:n.maxWait});o.push(w)}));return{async close(){await u,o.forEach(g=>{g.close()})}}}subscribeManyEose(e,n,r){const o=this.subscribeMany(e,n,{...r,oneose(){o.close()}});return o}async querySync(e,n,r){return new Promise(async o=>{const i=[];this.subscribeManyEose(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){return e.map(wt).map(async(r,o,i)=>i.indexOf(r)!==o?Promise.reject("duplicate url"):(await this.ensureRelay(r)).publish(n))}},As=class extends Ss{constructor(){super({verifyEvent:ps})}};function Lr(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ye(t,...e){if(!Lr(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 qt(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 Ur(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 se=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Bs=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 Is(t){if(typeof t!="string")throw new Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function yt(t){if(typeof t=="string")t=Is(t);else if(Lr(t))t=t.slice();else throw new Error(`Uint8Array expected, got ${typeof t}`);return t}const Os=(t,e)=>(Object.assign(e,t),e),_e=16,Sn=new Uint8Array(16),me=se(Sn),Ts=225,Ns=(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^Ts<<24&-(o&1)}},ue=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0;function Ps(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 Cs=t=>t>64*1024?8:t>1024?4:2;class Rr{constructor(e,n){this.blockLen=_e,this.outputLen=_e,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=yt(e),Ye(e,16);const r=Bs(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 b=0;b<128;b++)a.push({s0:ue(o),s1:ue(i),s2:ue(s),s3:ue(c)}),{s0:o,s1:i,s2:s,s3:c}=Ns(o,i,s,c);const l=Cs(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,y=0,w=0,E=0;for(let O=0;O<l;O++){if(!(d>>>l-O-1&1))continue;const{s0:S,s1:_,s2:m,s3:A}=a[l*b+O];p^=S,y^=_,w^=m,E^=A}h.push({s0:p,s1:y,s2:w,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 b of[e,n,r,o])for(let d=0;d<4;d++){const p=b>>>8*d&255;for(let y=8/i-1;y>=0;y--){const w=p>>>i*y&g,{s0:E,s1:O,s2:P,s3:S}=s[h*c+w];a^=E,l^=O,f^=P,u^=S,h+=1}}this.s0=a,this.s1=l,this.s2=f,this.s3=u}update(e){e=yt(e),qt(this);const n=se(e),r=Math.floor(e.length/_e),o=e.length%_e;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&&(Sn.set(e.subarray(r*_e)),this._updateBlock(me[0],me[1],me[2],me[3]),me.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){qt(this),Ur(e,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=se(e);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,e}digest(){const e=new Uint8Array(_e);return this.digestInto(e),this.destroy(),e}}class Ls extends Rr{constructor(e,n){e=yt(e);const r=Ps(e.slice());super(r,n),r.fill(0)}update(e){e=yt(e),qt(this);const n=se(e),r=e.length%_e,o=Math.floor(e.length/_e);for(let i=0;i<o;i++)this._updateBlock(ue(n[i*4+3]),ue(n[i*4+2]),ue(n[i*4+1]),ue(n[i*4+0]));return r&&(Sn.set(e.subarray(o*_e)),this._updateBlock(ue(me[3]),ue(me[2]),ue(me[1]),ue(me[0])),me.fill(0)),this}digestInto(e){qt(this),Ur(e,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=se(e);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,e.reverse()}}function Hr(t){const e=(r,o)=>t(o,r.length).update(yt(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}Hr((t,e)=>new Rr(t,e)),Hr((t,e)=>new Ls(t,e));const qe=16,Us=283;function An(t){return t<<1^Us&-(t>>7)}function ct(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(e&1),t=An(t);return n}const Bn=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=An(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})(),Rs=Bn.map((t,e)=>Bn.indexOf(e)),Hs=t=>t<<24|t>>>8,In=t=>t<<8|t>>>24;function qr(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(In),o=r.map(In),i=o.map(In),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 On=qr(Bn,t=>ct(t,3)<<24|t<<16|t<<8|ct(t,2)),jr=qr(Rs,t=>ct(t,11)<<24|ct(t,13)<<16|ct(t,9)<<8|ct(t,14)),qs=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=An(n))t[e]=n;return t})();function Mr(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}=On,r=se(t),o=r.length,i=c=>ve(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(Hs(a))^qs[c/o-1]:o>6&&c%o===4&&(a=i(a)),s[c]=s[c-o]^a}return s}function js(t){const e=Mr(t),n=e.slice(),r=e.length,{sbox2:o}=On,{T0:i,T1:s,T2:c,T3:a}=jr;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=ve(o,f,f,f,f);n[l]=i[u&255]^s[u>>>8&255]^c[u>>>16&255]^a[u>>>24]}return n}function je(t,e,n,r,o,i){return t[n<<8&65280|r>>>8&255]^e[o>>>8&65280|i>>>24&255]}function ve(t,e,n,r,o){return t[e&255|n&65280]|t[r>>>16&255|o>>>16&65280]<<16}function zr(t,e,n,r,o){const{sbox2:i,T01:s,T23:c}=On;let a=0;e^=t[a++],n^=t[a++],r^=t[a++],o^=t[a++];const l=t.length/4-2;for(let b=0;b<l;b++){const d=t[a++]^je(s,c,e,n,r,o),p=t[a++]^je(s,c,n,r,o,e),y=t[a++]^je(s,c,r,o,e,n),w=t[a++]^je(s,c,o,e,n,r);e=d,n=p,r=y,o=w}const f=t[a++]^ve(i,e,n,r,o),u=t[a++]^ve(i,n,r,o,e),g=t[a++]^ve(i,r,o,e,n),h=t[a++]^ve(i,o,e,n,r);return{s0:f,s1:u,s2:g,s3:h}}function Ms(t,e,n,r,o){const{sbox2:i,T01:s,T23:c}=jr;let a=0;e^=t[a++],n^=t[a++],r^=t[a++],o^=t[a++];const l=t.length/4-2;for(let b=0;b<l;b++){const d=t[a++]^je(s,c,e,o,r,n),p=t[a++]^je(s,c,n,e,o,r),y=t[a++]^je(s,c,r,n,e,o),w=t[a++]^je(s,c,o,r,n,e);e=d,n=p,r=y,o=w}const f=t[a++]^ve(i,e,o,r,n),u=t[a++]^ve(i,n,e,o,r),g=t[a++]^ve(i,r,n,e,o),h=t[a++]^ve(i,o,r,n,e);return{s0:f,s1:u,s2:g,s3:h}}function $r(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 zs(t){if(Ye(t),t.length%qe!==0)throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${qe}`)}function $s(t,e,n){let r=t.length;const o=r%qe;if(!e&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=se(t);if(e){let a=qe-o;a||(a=qe),r=r+a}const s=$r(r,n),c=se(s);return{b:i,o:c,out:s}}function Ks(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 Ds(t){const e=new Uint8Array(16),n=se(e);e.set(t);const r=qe-t.length;for(let o=qe-r;o<qe;o++)e[o]=r;return n}const Kr=Os({blockSize:16,nonceLength:16},function(e,n,r={}){Ye(e),Ye(n,16);const o=!r.disablePadding;return{encrypt:(i,s)=>{const c=Mr(e),{b:a,o:l,out:f}=$s(i,o,s),u=se(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}=zr(c,g,h,b,d),l[p++]=g,l[p++]=h,l[p++]=b,l[p++]=d;if(o){const y=Ds(i.subarray(p*4));g^=y[0],h^=y[1],b^=y[2],d^=y[3],{s0:g,s1:h,s2:b,s3:d}=zr(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=js(e),a=se(n),l=$r(i.length,s),f=se(i),u=se(l);let g=a[0],h=a[1],b=a[2],d=a[3];for(let p=0;p+4<=f.length;){const y=g,w=h,E=b,O=d;g=f[p+0],h=f[p+1],b=f[p+2],d=f[p+3];const{s0:P,s1:S,s2:_,s3:m}=Ms(c,g,h,b,d);u[p++]=P^y,u[p++]=S^w,u[p++]=_^E,u[p++]=m^O}return c.fill(0),Ks(l,o)}}});/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function at(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function ke(...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 Se(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(at(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 Ae(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 jt(t,e="="){if(at(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 Dr(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function Wr(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(at(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 Vr=(t,e)=>e?Vr(e,t%e):t,Mt=(t,e)=>t+(e-Vr(t,e));function Tn(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(Mt(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Mt(e,n)}`);let o=0,i=0;const s=2**n-1,c=[];for(const a of t){if(at(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 Ws(t){return at(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Wr(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(Wr(e,t,2**8))}}}function Me(t,e=!1){if(at(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Mt(8,t)>32||Mt(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 Tn(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(Tn(n,t,8,e))}}}function Gr(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const Vs=ke(Me(4),Se("0123456789ABCDEF"),Ae("")),Gs=ke(Me(5),Se("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),jt(5),Ae(""));ke(Me(5),Se("0123456789ABCDEFGHIJKLMNOPQRSTUV"),jt(5),Ae("")),ke(Me(5),Se("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Ae(""),Dr(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const mt=ke(Me(6),Se("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),jt(6),Ae("")),Zs=ke(Me(6),Se("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),jt(6),Ae("")),Nn=t=>ke(Ws(58),Se(t),Ae("")),Pn=Nn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Nn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Nn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Zr=[0,2,3,5,6,7,9,10,11],Ys={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=Pn.encode(r).padStart(Zr[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=Zr.indexOf(r.length),i=Pn.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)}},Cn=ke(Se("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Ae("")),Yr=[996825010,642813549,513874426,1027748829,705979059];function vt(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<Yr.length;r++)(e>>r&1)===1&&(n^=Yr[r]);return n}function Fr(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=vt(o)^s>>5}o=vt(o);for(let i=0;i<r;i++)o=vt(o)^t.charCodeAt(i)&31;for(let i of e)o=vt(o)^i;for(let i=0;i<6;i++)o=vt(o);return o^=n,Cn.encode(Tn([o%2**30],30,5,!1))}function Jr(t){const e=t==="bech32"?1:734539939,n=Me(5),r=n.decode,o=n.encode,i=Gr(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${Cn.encode(u)}${Fr(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 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=Cn.decode(d).slice(0,-6),y=Fr(b,p,e);if(!d.endsWith(y))throw new Error(`Invalid checksum in ${f}: expected "${y}"`);return{prefix:b,words:p}}const a=Gr(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 Qr=Jr("bech32");Jr("bech32m");const Fs={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},Js=ke(Me(4),Se("0123456789abcdef"),Ae(""),Dr(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:Fs,hex:Js,base16:Vs,base32:Gs,base64:mt,base64url:Zs,base58:Pn,base58xmr:Ys}).join(", ")}`;var Fe=Symbol("verified"),Qs=t=>t instanceof Object;function Xs(t){if(!Qs(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}var ec=new TextDecoder("utf-8"),Xr=new TextEncoder;function xt(t){t.indexOf("://")===-1&&(t="wss://"+t);let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),(e.port==="80"&&e.protocol==="ws:"||e.port==="443"&&e.protocol==="wss:")&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}var tc=class{constructor(t){x(this,"value");x(this,"next",null);x(this,"prev",null);this.value=t}},nc=class{constructor(){x(this,"first");x(this,"last");this.first=null,this.last=null}enqueue(t){const e=new tc(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,t.value}},rc=class{generateSecretKey(){return re.utils.randomPrivateKey()}getPublicKey(t){return ne(re.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=ne(re.getPublicKey(e)),n.id=Ln(n),n.sig=ne(re.sign(Ln(n),e)),n[Fe]=!0,n}verifyEvent(t){if(typeof t[Fe]=="boolean")return t[Fe];const e=Ln(t);if(e!==t.id)return t[Fe]=!1,!1;try{const n=re.verify(t.sig,e,t.pubkey);return t[Fe]=n,n}catch{return t[Fe]=!1,!1}}};function oc(t){if(!Xs(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 Ln(t){let e=En(Xr.encode(oc(t)));return ne(e)}var zt=new rc,ic=zt.generateSecretKey,sc=zt.getPublicKey,cc=zt.finalizeEvent,eo=zt.verifyEvent;async function ac(t,e,n){const r=t instanceof Uint8Array?ne(t):t,o=pt.getSharedSecret(r,"02"+e),i=to(o);let s=Uint8Array.from(ei(16)),c=Xr.encode(n),a=Kr(i,s).encrypt(c),l=mt.encode(new Uint8Array(a)),f=mt.encode(new Uint8Array(s.buffer));return`${l}?iv=${f}`}async function lc(t,e,n){const r=t instanceof Uint8Array?ne(t):t;let[o,i]=n.split("?iv="),s=pt.getSharedSecret(r,"02"+e),c=to(s),a=mt.decode(i),l=mt.decode(o),f=Kr(c,a).decrypt(l);return ec.decode(f)}function to(t){return t.slice(1,33)}var uc=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,fc;try{fc=fetch}catch{}var dc=22242,Un=24133,hc=31990;function gc(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1&&!t.ids.some(n=>e.id.startsWith(n))||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1&&!t.authors.some(n=>e.pubkey.startsWith(n)))return!1;for(let n in t)if(n[0]==="#"){let r=n.slice(1),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 pc(t,e){for(let n=0;n<t.length;n++)if(gc(t[n],e))return!0;return!1}function bc(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 wc(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 yc(t,e){return{kind:dc,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function mc(){return new Promise(t=>{const e=new MessageChannel,n=()=>{e.port1.removeEventListener("message",n),t()};e.port1.addEventListener("message",n),e.port2.postMessage(0),e.port1.start()})}var vc=t=>(t[Fe]=!0,!0),no;try{no=WebSocket}catch{}var ro=class{constructor(t,e){x(this,"url");x(this,"_connected",!1);x(this,"onclose",null);x(this,"onnotice",t=>console.debug(`NOTICE from ${this.url}: ${t}`));x(this,"_onauth",null);x(this,"baseEoseTimeout",4400);x(this,"connectionTimeout",4400);x(this,"openSubs",new Map);x(this,"connectionTimeoutHandle");x(this,"connectionPromise");x(this,"openCountRequests",new Map);x(this,"openEventPublishes",new Map);x(this,"ws");x(this,"incomingMessageQueue",new nc);x(this,"queueRunning",!1);x(this,"challenge");x(this,"serial",0);x(this,"verifyEvent");this.url=xt(t),this.verifyEvent=e.verifyEvent}static async connect(t,e){const n=new ro(t,e);return await n.connect(),n}closeAllSubscriptions(t){for(let[e,n]of this.openSubs)n.close(t);this.openSubs.clear();for(let[e,n]of this.openEventPublishes)n.reject(new Error(t));this.openEventPublishes.clear();for(let[e,n]of this.openCountRequests)n.reject(new Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise?this.connectionPromise:(this.challenge=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 no(this.url)}catch(n){e(n);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=n=>{var r;e(n.message),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 mc();this.queueRunning=!1}handleNext(){var n,r,o;const t=this.incomingMessageQueue.dequeue();if(!t)return!1;const e=wc(t);if(e){const i=this.openSubs.get(e);if(!i)return;const s=bc(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)&&pc(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);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(t){if(!this.connectionPromise)throw new Error("sending on closed connection");this.connectionPromise.then(()=>{var e;(e=this.ws)==null||e.send(t)})}async auth(t){if(!this.challenge)throw new Error("can't perform auth, no challenge was received");const e=await t(yc(this.url,this.challenge)),n=new Promise((r,o)=>{this.openEventPublishes.set(e.id,{resolve:r,reject:o})});return this.send('["AUTH",'+JSON.stringify(e)+"]"),n}async publish(t){const e=new Promise((n,r)=>{this.openEventPublishes.set(t.id,{resolve:n,reject:r})});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)+"]"),r}subscribe(t,e){const n=this.prepareSubscription(t,e);return n.fire(),n}prepareSubscription(t,e){this.serial++;const n=e.id||"sub:"+this.serial,r=new xc(this,n,t,e);return this.openSubs.set(n,r),r}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()}},xc=class{constructor(t,e,n,r){x(this,"relay");x(this,"id");x(this,"closed",!1);x(this,"eosed",!1);x(this,"filters");x(this,"alreadyHaveEvent");x(this,"receivedEvent");x(this,"onevent");x(this,"oneose");x(this,"onclose");x(this,"eoseTimeout");x(this,"eoseTimeoutHandle");this.relay=t,this.filters=n,this.id=e,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||t.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.onevent||(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;!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),(e=this.onclose)==null||e.call(this,t)}},Ec=class{constructor(t){x(this,"relays",new Map);x(this,"seenOn",new Map);x(this,"trackRelays",!1);x(this,"verifyEvent");x(this,"trustedRelayURLs",new Set);this.verifyEvent=t.verifyEvent}async ensureRelay(t,e){t=xt(t);let n=this.relays.get(t);return n||(n=new ro(t,{verifyEvent:this.trustedRelayURLs.has(t)?vc:this.verifyEvent}),e!=null&&e.connectionTimeout&&(n.connectionTimeout=e.connectionTimeout),this.relays.set(t,n)),await n.connect(),n}close(t){t.map(xt).forEach(e=>{var n;(n=this.relays.get(e))==null||n.close()})}subscribeMany(t,e,n){return this.subscribeManyMap(Object.fromEntries(t.map(r=>[r,e])),n)}subscribeManyMap(t,e){this.trackRelays&&(e.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(t).length,i=[];let s=u=>{var g;i[u]=!0,i.filter(h=>h).length===o&&((g=e.oneose)==null||g.call(e),s=()=>{})};const c=[];let a=(u,g)=>{var h;s(u),c[u]=g,c.filter(b=>b).length===o&&((h=e.onclose)==null||h.call(e,c),a=()=>{})};const l=u=>{var h;if((h=e.alreadyHaveEvent)!=null&&h.call(e,u))return!0;const g=n.has(u);return n.add(u),g},f=Promise.all(Object.entries(t).map(async(u,g,h)=>{if(h.indexOf(u)!==g){a(g,"duplicate url");return}let[b,d]=u;b=xt(b);let p;try{p=await this.ensureRelay(b,{connectionTimeout:e.maxWait?Math.max(e.maxWait*.8,e.maxWait-1e3):void 0})}catch(w){a(g,(w==null?void 0:w.message)||String(w));return}let y=p.subscribe(d,{...e,oneose:()=>s(g),onclose:w=>a(g,w),alreadyHaveEvent:l,eoseTimeout:e.maxWait});r.push(y)}));return{async close(){await f,r.forEach(u=>{u.close()})}}}subscribeManyEose(t,e,n){const r=this.subscribeMany(t,e,{...n,oneose(){r.close()}});return r}async querySync(t,e,n){return new Promise(async r=>{const o=[];this.subscribeManyEose(t,[e],{...n,onevent(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){return t.map(xt).map(async(n,r,o)=>o.indexOf(n)!==r?Promise.reject("duplicate url"):(await this.ensureRelay(n)).publish(e))}},_c=class extends Ec{constructor(){super({verifyEvent:eo})}},oo;try{oo=fetch}catch{}var $t=/^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%]*)$/,kc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;async function Sc(t){let e=t.match($t);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 io(t)}async function io(t){const e=t.match(uc);if(!e)return null;const[n,r="_",o]=e;try{const i=`https://${o}/.well-known/nostr.json?name=${r}`,s=await(await oo(i,{redirect:"error"})).json();let c=s.names[r],a=s.nip46[c]||[];return{pubkey:c,relays:a,secret:null}}catch{return null}}var so=class{constructor(t,e,n={}){x(this,"pool");x(this,"subCloser");x(this,"isOpen");x(this,"serial");x(this,"idPrefix");x(this,"listeners");x(this,"waitingForAuth");x(this,"secretKey");x(this,"bp");if(e.relays.length===0)throw new Error("no relays are specified for this bunker");this.pool=n.pool||new _c,this.secretKey=t,this.bp=e,this.isOpen=!1,this.idPrefix=Math.random().toString(36).substring(7),this.serial=0,this.listeners={},this.waitingForAuth={};const r=this.listeners,o=this.waitingForAuth;this.subCloser=this.pool.subscribeMany(this.bp.relays,[{kinds:[Un],"#p":[sc(this.secretKey)]}],{async onevent(i){const{id:s,result:c,error:a}=JSON.parse(await lc(t,i.pubkey,i.content));if(c==="auth_url"&&o[s]){delete o[s],n.onauth?n.onauth(a):console.warn(`nostr-tools/nip46: remote signer ${e.pubkey} tried to send an "auth_url"='${a}' but there was no onauth() callback configured.`);return}let l=r[s];l&&(a?l.reject(a):c&&l.resolve(c),delete r[s])}}),this.isOpen=!0}async close(){this.isOpen=!1,this.subCloser.close()}async sendRequest(t,e){return new Promise(async(n,r)=>{try{if(!this.isOpen)throw new Error("this signer is not open anymore, create a new one");this.serial++;const o=`${this.idPrefix}-${this.serial}`,i=await ac(this.secretKey,this.bp.pubkey,JSON.stringify({id:o,method:t,params:e})),s=cc({kind:Un,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.bp.pubkey}async getRelays(){return JSON.parse(await this.sendRequest("get_relays",[]))}async signEvent(t){let e=await this.sendRequest("sign_event",[JSON.stringify(t)]),n=JSON.parse(e);if(n.pubkey===this.bp.pubkey&&eo(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 nip44GetKey(t){let e=await this.sendRequest("nip44_get_key",[t]);return en(e)}async nip44Encrypt(t,e){return await this.sendRequest("nip44_encrypt",[t,e])}async nip44Decrypt(t,e){return await this.sendRequest("nip44_encrypt",[t,e])}};async function Ac(t,e,n,r,o){if(o&&!kc.test(o))throw new Error("Invalid email");let i=ic(),s=new so(i,t.bunkerPointer,e),c=await s.sendRequest("create_account",[n,r,o||""]);return s.bp.pubkey=c,await s.connect(),s}async function Bc(t,e){const n=await t.querySync(e,{kinds:[hc],"#k":[Un.toString()]});return n.sort((o,i)=>i.created_at-o.created_at),(await Promise.all(n.map(async(o,i)=>{try{const s=JSON.parse(o.content);try{if(n.findIndex(a=>JSON.parse(a.content).nip05===s.nip05)!==i)return}catch{}const c=await io(s.nip05);if(c&&c.pubkey===o.pubkey&&c.relays.length)return{bunkerPointer:c,nip05:s.nip05,domain:s.nip05.split("@")[1],name:s.name||s.display_name,picture:s.picture,about:s.about,website:s.website,local:!1}}catch{return}}))).filter(o=>o!==void 0)}var co=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,ao;try{ao=fetch}catch{}async function Ic(t){var i;const e=t.match(co);if(!e)return null;const[n,r="_",o]=e;try{const s=`https://${o}/.well-known/nostr.json?name=${r}`,c=await(await ao(s,{redirect:"error"})).json();let a=c.names[r];return a?{pubkey:a,relays:(i=c.relays)==null?void 0:i[a]}:null}catch{return null}}new TextDecoder("utf-8"),new TextEncoder;var Oc=5e3;function Tc(t){return Pc("npub",en(t))}function Nc(t,e){let n=Qr.toWords(e);return Qr.encode(t,n,Oc)}function Pc(t,e){return Nc(t,e)}const lt=[];function Cc(t,e=L){let n;const r=new Set;function o(c){if(Wt(t,c)&&(t=c,n)){const a=!lt.length;for(const l of r)l[1](),lt.push(l,t);if(a){for(let l=0;l<lt.length;l+=2)lt[l][0](lt[l+1]);lt.length=0}}}function i(c){o(c(t))}function s(c,a=L){const l=[c,a];return r.add(l),r.size===1&&(n=e(o,i)||L),c(t),()=>{r.delete(l),r.size===0&&n&&(n(),n=null)}}return{set:o,update:i,subscribe:s}}const Lc=t=>{const{subscribe:e,set:n}=Cc(void 0,()=>{let r=window.matchMedia(t);n(r.matches);const o=()=>n(r.matches);return"addEventListener"in r?r.addEventListener("change",o):r.addListener(o),()=>{"removeEventListener"in r?r.removeEventListener("change",o):r.removeListener(o)}});return{subscribe:e}};function Uc(t){let e,n,r;return{c(){e=Vt("svg"),n=Vt("circle"),r=Vt("path"),v(n,"class","opacity-25"),v(n,"cx","12"),v(n,"cy","12"),v(n,"r","10"),v(n,"stroke","currentColor"),v(n,"stroke-width","4"),v(r,"class","opacity-75"),v(r,"fill","currentColor"),v(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"),v(e,"class","ml-2 h-5 w-5 animate-spin text-white"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"fill","none"),v(e,"viewBox","0 0 24 24")},m(o,i){q(o,e,i),k(e,n),k(e,r)},p:L,i:L,o:L,d(o){o&&R(e)}}}class lo extends Jn{constructor(e){super(),Fn(this,e,null,Uc,Wt,{})}}const{window:Rn}=Ro;function uo(t,e,n){const r=t.slice();return r[78]=e[n],r}function Rc(t){let e,n,r,o,i,s,c,a,l,f,u,g,h=!t[20]&&!t[13]&&!t[14]&&!t[15]&&fo(t);const b=[Wc,Dc,Kc,$c,zc,Mc,jc],d=[];function p(y,w){return y[13]?0:y[14]?1:y[15]?2:y[20]?3:y[17]?4:y[21]?6:5}return c=p(t),a=d[c]=b[c](t),{c(){e=N("div"),n=N("button"),r=j("⤫"),i=$(),h&&h.c(),s=$(),a.c(),v(n,"class",o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"),v(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 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[27])},m(y,w){q(y,e,w),k(e,n),k(n,r),k(e,i),h&&h.m(e,null),k(e,s),d[c].m(e,null),f=!0,u||(g=J(n,"click",function(){Dt(t[20]?t[32]:t[30])&&(t[20]?t[32]:t[30]).apply(this,arguments)}),u=!0)},p(y,w){t=y,(!f||w[0]&1&&o!==(o="absolute right-2 top-0 cursor-pointer bg-transparent text-3xl text-"+t[0]+"-600"))&&v(n,"class",o),!t[20]&&!t[13]&&!t[14]&&!t[15]?h?h.p(t,w):(h=fo(t),h.c(),h.m(e,s)):h&&(h.d(1),h=null);let E=c;c=p(t),c===E?d[c].p(t,w):(At(),be(d[E],1,1,()=>{d[E]=null}),Bt(),a=d[c],a?a.p(t,w):(a=d[c]=b[c](t),a.c()),de(a,1),a.m(e,null)),(!f||w[0]&134217729&&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 from-"+t[0]+"-900 to-"+t[0]+"-700 "+t[27]))&&v(e,"class",l)},i(y){f||(de(a),f=!0)},o(y){be(a),f=!1},d(y){y&&R(e),h&&h.d(),d[c].d(),u=!1,g()}}}function Hc(t){let e,n,r,o,i;const s=[Qc,Jc,Fc,Yc,Zc],c=[];function a(l,f){return l[12]?0:!l[21]&&!l[2]?1:!l[21]&&l[2]?2:l[2]?4:3}return n=a(t),r=c[n]=s[n](t),{c(){e=N("div"),r.c(),v(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[27])},m(l,f){q(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):(At(),be(c[u],1,1,()=>{c[u]=null}),Bt(),r=c[n],r?r.p(l,f):(r=c[n]=s[n](l),r.c()),de(r,1),r.m(e,null)),(!i||f[0]&134217729&&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[27]))&&v(e,"class",o)},i(l){i||(de(r),i=!0)},o(l){be(r),i=!1},d(l){l&&R(e),c[n].d()}}}function qc(t){return{c:L,m:L,p:L,i:L,o:L,d:L}}function fo(t){let e,n,r,o,i;return{c(){e=N("button"),n=j("?"),v(e,"class",r="absolute bottom-1 right-3 cursor-pointer bg-transparent text-xl text-"+t[0]+"-600")},m(s,c){q(s,e,c),k(e,n),o||(i=J(e,"click",t[31]),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")&&v(e,"class",r)},d(s){s&&R(e),o=!1,i()}}}function jc(t){let e,n,r,o,i,s,c=t[21].npub+"",a,l,f,u,g,h,b,d,p,y,w,E=Nr(t[11])+"",O,P,S,_=(t[21].picture||t[21].name)&&ho(t);return{c(){e=N("div"),n=N("div"),n.textContent="You are connected to Nostr as",r=$(),o=N("a"),_&&_.c(),i=$(),s=N("div"),a=j(c),f=$(),u=N("button"),g=j("Disconnect"),b=$(),d=N("div"),p=j("This webpage is using the public key:"),y=N("br"),w=$(),O=j(E),v(n,"class","mb-4 text-sm"),v(s,"class","block break-all"),v(o,"target","_blank"),v(o,"href",l="https://nosta.me/"+t[21].npub),v(o,"class","group text-white no-underline"),v(e,"class","text-center"),v(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"),v(d,"class","mt-6 block break-all text-center text-sm")},m(m,A){q(m,e,A),k(e,n),k(e,r),k(e,o),_&&_.m(o,null),k(o,i),k(o,s),k(s,a),q(m,f,A),q(m,u,A),k(u,g),q(m,b,A),q(m,d,A),k(d,p),k(d,y),k(d,w),k(d,O),P||(S=J(u,"click",t[34]),P=!0)},p(m,A){m[21].picture||m[21].name?_?_.p(m,A):(_=ho(m),_.c(),_.m(o,i)):_&&(_.d(1),_=null),A[0]&2097152&&c!==(c=m[21].npub+"")&&Pe(a,c),A[0]&2097152&&l!==(l="https://nosta.me/"+m[21].npub)&&v(o,"href",l),A[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")&&v(u,"class",h),A[0]&2048&&E!==(E=Nr(m[11])+"")&&Pe(O,E)},i:L,o:L,d(m){m&&(R(e),R(f),R(u),R(b),R(d)),_&&_.d(),P=!1,S()}}}function Mc(t){let e,n,r,o,i,s,c,a,l,f,u,g,h,b,d,p,y,w=t[19]&&bo(t);const E=[Gc,Vc],O=[];function P(m,A){return m[12]?0:1}a=P(t),l=O[a]=E[a](t);let S=t[12]&&t[16]&&wo(t),_=!t[12]&&yo(t);return{c(){e=N("div"),e.textContent="How do you want to connect to Nostr?",n=$(),r=N("form"),o=N("input"),i=$(),w&&w.c(),s=$(),c=N("button"),l.c(),g=$(),S&&S.c(),h=$(),_&&_.c(),b=qo(),v(e,"class","text-center text-lg"),v(o,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),v(o,"placeholder","user@provider or bunker://..."),o.autofocus=!0,o.disabled=t[12],v(o,"autocapitalize","none"),v(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[26]||t[12],v(r,"class","mb-1 mt-4 flex flex-col")},m(m,A){q(m,e,A),q(m,n,A),q(m,r,A),k(r,o),t[52](o),et(o,t[4]),k(r,i),w&&w.m(r,null),k(r,s),k(r,c),O[a].m(c,null),k(r,g),S&&S.m(r,null),q(m,h,A),_&&_.m(m,A),q(m,b,A),d=!0,o.focus(),p||(y=[J(o,"input",t[53]),J(r,"submit",t[33])],p=!0)},p(m,A){(!d||A[0]&4096)&&(o.disabled=m[12]),A[0]&16&&o.value!==m[4]&&et(o,m[4]),m[19]?w?w.p(m,A):(w=bo(m),w.c(),w.m(r,s)):w&&(w.d(1),w=null);let C=a;a=P(m),a!==C&&(At(),be(O[C],1,1,()=>{O[C]=null}),Bt(),l=O[a],l||(l=O[a]=E[a](m),l.c()),de(l,1),l.m(c,null)),(!d||A[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"))&&v(c,"class",f),(!d||A[0]&67112960&&u!==(u=!m[26]||m[12]))&&(c.disabled=u),m[12]&&m[16]?S?S.p(m,A):(S=wo(m),S.c(),S.m(r,null)):S&&(S.d(1),S=null),m[12]?_&&(_.d(1),_=null):_?_.p(m,A):(_=yo(m),_.c(),_.m(b.parentNode,b))},i(m){d||(de(l),d=!0)},o(m){be(l),d=!1},d(m){m&&(R(e),R(n),R(r),R(h),R(b)),t[52](null),w&&w.d(),O[a].d(),S&&S.d(),_&&_.d(m),p=!1,Ne(y)}}}function zc(t){let e,n,r,o,i,s,c,a,l,f,u,g,h,b,d,p,y,w,E,O,P,S,_=Zn(t[22]),m=[];for(let A=0;A<_.length;A+=1)m[A]=mo(uo(t,_,A));return{c(){e=N("div"),e.textContent="Create a Nostr account",n=$(),r=N("form"),o=N("div"),i=N("input"),s=$(),c=N("div"),c.textContent="@",a=$(),l=N("select");for(let A=0;A<m.length;A+=1)m[A].c();f=$(),u=N("button"),g=j("Continue »"),d=$(),p=N("div"),y=j("Do you already have a Nostr address?"),w=N("br"),E=$(),O=N("button"),O.textContent="Login now",v(e,"class","text-center text-lg"),v(i,"class","box-border w-40 rounded px-2 py-1 text-lg text-neutral-800 outline-none"),v(i,"placeholder","bob"),i.autofocus=!0,v(i,"autocapitalize","none"),v(c,"class","mx-2 text-2xl"),v(l,"class","box-border w-full rounded px-2 py-1 text-lg text-neutral-800 outline-none"),t[10]===void 0&&kt(()=>t[51].call(l)),v(o,"class","flex flex-row"),v(u,"class",h="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"),u.disabled=b=!t[10]||!t[9]||t[18],v(r,"class","mb-1 mt-4"),v(O,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),v(p,"class","mt-6 text-center text-sm leading-3")},m(A,C){q(A,e,C),q(A,n,C),q(A,r,C),k(r,o),k(o,i),t[49](i),et(i,t[9]),k(o,s),k(o,c),k(o,a),k(o,l);for(let U=0;U<m.length;U+=1)m[U]&&m[U].m(l,null);Dn(l,t[10],!0),k(r,f),k(r,u),k(u,g),q(A,d,C),q(A,p,C),k(p,y),k(p,w),k(p,E),k(p,O),i.focus(),P||(S=[J(i,"input",t[50]),J(i,"input",t[38]),J(l,"change",t[51]),J(r,"submit",t[37]),J(O,"click",t[36])],P=!0)},p(A,C){if(C[0]&512&&i.value!==A[9]&&et(i,A[9]),C[0]&4194304){_=Zn(A[22]);let U;for(U=0;U<_.length;U+=1){const G=uo(A,_,U);m[U]?m[U].p(G,C):(m[U]=mo(G),m[U].c(),m[U].m(l,null))}for(;U<m.length;U+=1)m[U].d(1);m.length=_.length}C[0]&4195328&&Dn(l,A[10]),C[0]&1&&h!==(h="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-"+A[0]+"-900 hover:bg-"+A[0]+"-950")&&v(u,"class",h),C[0]&4457984&&b!==(b=!A[10]||!A[9]||A[18])&&(u.disabled=b)},i:L,o:L,d(A){A&&(R(e),R(n),R(r),R(d),R(p)),t[49](null),Ho(m,A),P=!1,Ne(S)}}}function $c(t){let e,n,r;return{c(){e=N("div"),e.textContent="What is that?",n=$(),r=N("div"),r.innerHTML=`<p class="mb mt-4">This widget is created with <i>window.nostr.js</i>, a small script
2
2
  you can drop in any page that already uses NIP-07 and make it also
3
3
  work with NIP-46 automatically when the user doesn&#39;t have an
4
4
  extension installed.
5
5
  <br/>
6
6
  It adds a small floating button on the side of the window that users
7
7
  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&#39;s page</a>.</p> <p class="mt-4">You don&#39;t know what Nostr is?
8
- <a target="_blank" class="underline" href="https://www.nostr.com">Learn more</a>.</p>`,x(t,"class","text-center text-lg"),x(r,"class","text-base leading-5")},m(o,i){q(o,t,i),q(o,n,i),q(o,r,i)},p:R,i:R,o:R,d(o){o&&(H(t),H(n),H(r))}}}function qc(e){let t,n,r,o,i,s,c=new URL(e[13]).host+"",a,l,f,u,g,h,b,d,p,y;return{c(){t=N("div"),n=N("div"),n.textContent="An action requires your confirmation",r=M(),o=N("div"),i=$("Now you a new window will bring you to "),s=N("strong"),a=$(c),l=$(" where you can approve the current action. If nothing happens check that if your browser is blocking popups, pleaase."),f=N("br"),u=$(`
9
- After that you will be returned to this page.`),g=M(),h=N("button"),b=$("Confirm action »"),x(n,"class","text-center text-lg"),x(o,"class","mt-4 text-center text-sm leading-4"),x(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-"+e[0]+"-900 hover:bg-"+e[0]+"-950"),x(t,"class","m-auto w-full")},m(w,_){q(w,t,_),k(t,n),k(t,r),k(t,o),k(o,i),k(o,s),k(s,a),k(o,l),k(o,f),k(o,u),k(t,g),k(t,h),k(h,b),p||(y=Y(h,"click",e[46]),p=!0)},p(w,_){_[0]&8192&&c!==(c=new URL(w[13]).host+"")&&Le(a,c),_[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-"+w[0]+"-900 hover:bg-"+w[0]+"-950")&&x(h,"class",d)},i:R,o:R,d(w){w&&H(t),p=!1,y()}}}function $c(e){let t,n,r,o,i,s,c=new URL(e[12]).host+"",a,l,f,u,g,h,b,d,p,y;return{c(){t=N("div"),n=N("div"),n.textContent="Login into a Nostr account",r=M(),o=N("div"),i=$("Now you a new window will bring you to "),s=N("strong"),a=$(c),l=$(" where you can login and approve the permissions. If nothing happens check that if your browser is blocking popups, pleaase."),f=N("br"),u=$(`
10
- After that you will be returned to this page.`),g=M(),h=N("button"),b=$("Login now »"),x(n,"class","text-center text-lg"),x(o,"class","mt-4 text-center text-sm leading-4"),x(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-"+e[0]+"-900 hover:bg-"+e[0]+"-950"),x(t,"class","m-auto w-full")},m(w,_){q(w,t,_),k(t,n),k(t,r),k(t,o),k(o,i),k(o,s),k(s,a),k(o,l),k(o,f),k(o,u),k(t,g),k(t,h),k(h,b),p||(y=Y(h,"click",e[45]),p=!0)},p(w,_){_[0]&4096&&c!==(c=new URL(w[12]).host+"")&&Le(a,c),_[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-"+w[0]+"-900 hover:bg-"+w[0]+"-950")&&x(h,"class",d)},i:R,o:R,d(w){w&&H(t),p=!1,y()}}}function jc(e){let t,n,r,o,i,s,c=new URL(e[11]).host+"",a,l,f,u,g,h,b,d,p,y;return{c(){t=N("div"),n=N("div"),n.textContent="Create a Nostr account",r=M(),o=N("div"),i=$("Now you a new window will bring you to "),s=N("strong"),a=$(c),l=$(" where the account creation will take place. If nothing happens check that if your browser is blocking popups, pleaase."),f=N("br"),u=$(`
11
- After that you will be returned to this page.`),g=M(),h=N("button"),b=$("Start account creation »"),x(n,"class","text-center text-lg"),x(o,"class","mt-4 text-center text-sm leading-4"),x(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-"+e[0]+"-900 hover:bg-"+e[0]+"-950"),x(t,"class","m-auto w-full")},m(w,_){q(w,t,_),k(t,n),k(t,r),k(t,o),k(o,i),k(o,s),k(s,a),k(o,l),k(o,f),k(o,u),k(t,g),k(t,h),k(h,b),p||(y=Y(h,"click",e[44]),p=!0)},p(w,_){_[0]&2048&&c!==(c=new URL(w[11]).host+"")&&Le(a,c),_[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-"+w[0]+"-900 hover:bg-"+w[0]+"-950")&&x(h,"class",d)},i:R,o:R,d(w){w&&H(t),p=!1,y()}}}function fo(e){let t,n,r=e[19].picture&&ho(e),o=e[19].name&&go(e);return{c(){t=N("div"),r&&r.c(),n=M(),o&&o.c(),x(t,"class","mb-2 flex items-center justify-center gap-2")},m(i,s){q(i,t,s),r&&r.m(t,null),k(t,n),o&&o.m(t,null)},p(i,s){i[19].picture?r?r.p(i,s):(r=ho(i),r.c(),r.m(t,n)):r&&(r.d(1),r=null),i[19].name?o?o.p(i,s):(o=go(i),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(i){i&&H(t),r&&r.d(),o&&o.d()}}}function ho(e){let t,n,r;return{c(){t=N("img"),Et(t.src,n=e[19].picture)||x(t,"src",n),x(t,"alt",""),x(t,"class",r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+e[0]+"-100")},m(o,i){q(o,t,i)},p(o,i){i[0]&524288&&!Et(t.src,n=o[19].picture)&&x(t,"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")&&x(t,"class",r)},d(o){o&&H(t)}}}function go(e){let t,n=e[19].name+"",r;return{c(){t=N("div"),r=$(n),x(t,"class","text-3xl decoration-2 underline-offset-4 group-hover:underline")},m(o,i){q(o,t,i),k(t,r)},p(o,i){i[0]&524288&&n!==(n=o[19].name+"")&&Le(r,n)},d(o){o&&H(t)}}}function po(e){let t,n;return{c(){t=N("div"),n=$(e[17]),x(t,"class","my-2 rounded bg-yellow-100 p-2 text-center text-sm leading-4 text-red-400")},m(r,o){q(r,t,o),k(t,n)},p(r,o){o[0]&131072&&Le(n,r[17])},d(r){r&&H(t)}}}function zc(e){let t;return{c(){t=$("Connect »")},m(n,r){q(n,t,r)},i:R,o:R,d(n){n&&H(t)}}}function Mc(e){let t,n,r;return n=new ao({}),{c(){t=$(`Connecting to bunker
12
- `),Zn(n.$$.fragment)},m(o,i){q(o,t,i),Zt(n,o,i),r=!0},i(o){r||(he(n.$$.fragment,o),r=!0)},o(o){ge(n.$$.fragment,o),r=!1},d(o){o&&H(t),Yt(n,o)}}}function bo(e){let t,n,r,o,i;return{c(){t=N("div"),n=$(`Waiting too much?
13
- `),r=N("button"),r.textContent="Cancel the connection",x(r,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),x(t,"class","mt-6 text-center text-sm leading-3")},m(s,c){q(s,t,c),k(t,n),k(t,r),o||(i=Y(r,"click",e[37]),o=!0)},p:R,d(s){s&&H(t),o=!1,i()}}}function wo(e){let t,n,r,o,i,s,c;return{c(){t=N("div"),n=$("Do you need a Nostr account?"),r=N("br"),o=M(),i=N("button"),i.textContent="Sign up now",x(i,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),x(t,"class","mt-6 text-center text-sm leading-3")},m(a,l){q(a,t,l),k(t,n),k(t,r),k(t,o),k(t,i),s||(c=Y(i,"click",e[33]),s=!0)},p:R,d(a){a&&H(t),s=!1,c()}}}function yo(e){let t,n,r;return{c(){t=N("option"),x(t,"label",n=e[76].domain),t.__value=r=e[76],Je(t,t.__value),x(t,"class","px-2 py-1 text-lg")},m(o,i){q(o,t,i)},p(o,i){i[0]&1048576&&n!==(n=o[76].domain)&&x(t,"label",n),i[0]&1048576&&r!==(r=o[76])&&(t.__value=r,Je(t,t.__value))},d(o){o&&H(t)}}}function Kc(e){let t,n,r,o=(e[19].name||e[19].npub.slice(0,7)+"…"+e[19].npub.slice(-4))+"",i;function s(l,f){return l[19].picture?Gc:Vc}let c=s(e),a=c(e);return{c(){t=N("div"),a.c(),n=M(),r=N("div"),i=$(o),x(r,"class","max-w-56 overflow-hidden whitespace-nowrap overflow-ellipsis inline-block"),x(t,"class","flex items-center")},m(l,f){q(l,t,f),a.m(t,null),k(t,n),k(t,r),k(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(t,n))),f[0]&524288&&o!==(o=(l[19].name||l[19].npub.slice(0,7)+"…"+l[19].npub.slice(-4))+"")&&Le(i,o)},i:R,o:R,d(l){l&&H(t),a.d()}}}function Dc(e){let t;return{c(){t=$("Connect with Nostr")},m(n,r){q(n,t,r)},p:R,i:R,o:R,d(n){n&&H(t)}}}function Wc(e){let t,n,r,o;return r=new ao({}),{c(){t=N("div"),n=$(`Connecting to bunker
14
- `),Zn(r.$$.fragment),x(t,"class","flex items-center")},m(i,s){q(i,t,s),k(t,n),Zt(r,t,null),o=!0},p:R,i(i){o||(he(r.$$.fragment,i),o=!0)},o(i){ge(r.$$.fragment,i),o=!1},d(i){i&&H(t),Yt(r)}}}function Vc(e){let t;return{c(){t=$("☉")},m(n,r){q(n,t,r)},p:R,d(n){n&&H(t)}}}function Gc(e){let t,n;return{c(){t=N("img"),Et(t.src,n=e[19].picture)||x(t,"src",n),x(t,"alt",""),x(t,"class","mr-2 h-5 w-5 rounded-full")},m(r,o){q(r,t,o)},p(r,o){o[0]&524288&&!Et(t.src,n=r[19].picture)&&x(t,"src",n)},d(r){r&&H(t)}}}function Zc(e){let t,n,r,o,i,s,c;const a=[Pc,Lc],l=[];function f(u,g){return u[23]?1:0}return n=f(e),r=l[n]=a[n](e),{c(){t=N("div"),r.c(),x(t,"class","draggable animate-fadein font-sans text-white"),x(t,"style",o="position: fixed; "+(e[23]&&e[3]?"width: 100vw;":"")+"; right: "+(e[23]&&e[3]?"0":e[1])+"px; user-select: none; "+(e[23]&&e[3]?"bottom: 0px":e[22]+":"+e[21]+"px")),Dn(t,"cursor-pointer",!e[19]&&!e[23])},m(u,g){q(u,t,g),l[n].m(t,null),e[52](t),i=!0,s||(c=[Y(Un,"click",e[27]),Y(Un,"mouseup",e[40]),Y(Un,"mousemove",e[39]),Y(t,"mousedown",e[38])],s=!0)},p(u,g){let h=n;n=f(u),n===h?l[n].p(u,g):(St(),ge(l[h],1,1,()=>{l[h]=null}),At(),r=l[n],r?r.p(u,g):(r=l[n]=a[n](u),r.c()),he(r,1),r.m(t,null)),(!i||g[0]&14680074&&o!==(o="position: fixed; "+(u[23]&&u[3]?"width: 100vw;":"")+"; right: "+(u[23]&&u[3]?"0":u[1])+"px; user-select: none; "+(u[23]&&u[3]?"bottom: 0px":u[22]+":"+u[21]+"px")))&&x(t,"style",o),(!i||g[0]&8912896)&&Dn(t,"cursor-pointer",!u[19]&&!u[23])},i(u){i||(he(r),i=!0)},o(u){ge(r),i=!1},d(u){u&&H(t),l[n].d(),e[52](null),s=!1,Ne(c)}}}const mo="We could not connect to a NIP-46 bunker with that url, are you sure it is set up correctly?",vo="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 Rn(e){return window.open(e,"window.nostr","width=600,height=800,popup=yes")}function Yc(e,t,n){let r,o,i,s,c,a;const l=Tc("only screen and (max-width: 640px)");No(e,l,I=>n(3,a=I));const f={ORIGIN:"wnj:origin",CLIENT_SECRET:"wnj:clientSecret",Y_POS:"wnj:ypos",CALLBACK_TOKEN:"wnj:callbackToken",BUNKER_POINTER:"wnj:bunkerPointer"};let u,{accent:g}=t,{position:h="top"}=t;const b=window,d=new Es;let p,y,w,_,T,L;const A=localStorage.getItem(f.CLIENT_SECRET);A?L=Xt(A):(L=rs(),localStorage.setItem(f.CLIENT_SECRET,te(L)));let v="closed",m,B,C,P,K,V,oe=null,S=null,O=null,U=!1,j,z,D,Q=!1,W,ae,ie=[],{right:Ae=20}=t,Be=!1,se=!1,ct,me,Ie;const mt={pool:d,onauth(I){j?n(11,oe=I):W?(n(13,O=I),n(23,i=!0)):n(12,S=I)}},Oe=Qn(()=>{switch(v){case"justopened":n(42,v="opened");break;case"justclosed":n(42,v="closed");break}},500);function ee(){n(42,v="justopened"),Oe()}function de(){n(42,v="justclosed"),Oe()}function Fe(){if(m&&!V){jn();return}ee()}$n();let vt={isWnj:!0,async getPublicKey(){return m?m.pubkey:(!K&&!V&&ee(),(await P).bp.pubkey)},async signEvent(I){try{return!K&&!V&&Fe(),await(await P).signEvent(I)}finally{n(13,O=null),de()}},async getRelays(){return!K&&!V&&Fe(),(await P).getRelays()},nip04:{async encrypt(I,G){return!K&&!V&&Fe(),(await P).nip04Encrypt(I,G)},async decrypt(I,G){return!K&&!V&&Fe(),(await P).nip04Decrypt(I,G)}}};function $n(){de(),m=null,P=new Promise((I,G)=>{B=I,C=G}),n(19,W=null),n(10,K=!1),n(14,U=!1),n(15,j=!1),V=!1,ae=null,n(17,D="")}qo(()=>{if(!m){let I=localStorage.getItem(f.BUNKER_POINTER);I&&(m=JSON.parse(I),zn())}if(b.nostr&&!b.nostr.isWnj){b.destroyWnj();return}else Object.defineProperty(window,"nostr",{get(){return vt},set(I){vt=I,I.isWnj||b.destroyWnj()},configurable:!0});return()=>{ae&&ae.close()}});function Xc(I){Math.abs(o-me)>6||Date.now()-Ie>600||v==="justopened"||v==="justclosed"||(I.composedPath().find(G=>G.id==="wnj")?ee():de())}function ea(I){de(),n(15,j=!1),n(11,oe=null),n(12,S=null),n(13,O=null),I.stopPropagation()}function ta(I){n(18,Q=!0),I.stopPropagation()}function na(I){n(18,Q=!1),I.stopPropagation()}async function ra(I){I.preventDefault();try{if(m=await xc(p.value),!m){p.value.match(zt)?n(17,D=mo):n(17,D=vo);return}p.setCustomValidity(""),n(17,D=""),await jn(),zn()}catch{p.value.match(zt)?n(17,D=mo):n(17,D=vo),n(10,K=!1)}}async function oa(I){I.preventDefault(),localStorage.removeItem(f.BUNKER_POINTER),$n()}async function ia(I){I.preventDefault(),n(15,j=!0),ie.length===0&&(n(20,ie=await _c(d,["wss://relay.nostr.band","wss://nos.lol","wss://nostr-pub.wellorder.net"])),n(8,T=ie[0]))}function sa(I){n(15,j=!1)}async function ca(I){if(I.preventDefault(),!T)return;n(16,z=!0);let G=await Ec(T,mt,w.value,T.domain,void 0);n(16,z=!1),ee(),n(15,j=!1),m=G.bp,zn(),jn(G)}const aa=Qn(async()=>{T&&w.value.length>0&&(await kc(w.value+"@"+T.domain)?w.setCustomValidity(`'${w.value}' is already taken.`):w.setCustomValidity(""))},500);function la(){n(14,U=!1),n(10,K=!1),C("connection aborted"),$n()}async function jn(I=void 0){I=I||new io(L,m,mt),n(10,K=!0);let G=setTimeout(()=>{n(14,U=!0),n(23,i=!0)},5e3);try{await I.connect(),V=!0,localStorage.setItem(f.BUNKER_POINTER,JSON.stringify(m)),de(),B(I)}catch(ve){C((ve==null?void 0:ve.message)||String(ve))}finally{clearTimeout(G),n(10,K=!1),n(14,U=!1),n(11,oe=null),n(12,S=null),n(13,O=null)}}function zn(I=null){let G=m.pubkey;n(19,W={pubkey:G,npub:Ac(G),event:null}),ae=d.subscribeMany(["wss://purplepag.es","wss://relay.snort.social","wss://relay.nos.social"],[{kinds:[0],authors:[G]}],{onevent(ve){var Bo;if(!((((Bo=W.event)==null?void 0:Bo.created_at)||0)>=ve.created_at))try{let{name:Io,picture:Ea}=JSON.parse(ve.content);n(19,W.event=ve,W),n(19,W.name=Io,W),n(19,W.picture=Ea,W),I==null||I(),I=null}catch{}}})}function ua(I){if(i)return;Be=!0;const G=u.getBoundingClientRect();ct=I.clientY-G.top,me=o,Ie=Date.now()}function fa(I){Be&&(r==="top"?n(21,o=I.clientY):n(21,o=window.innerHeight-I.clientY),n(21,o-=ct),n(43,se=!0),o<ze&&n(21,o=ze),o>window.innerHeight-ze&&n(21,o=window.innerHeight-ze))}function da(){if(Be=!1,setTimeout(()=>{n(43,se=!1)},10),se){const I=u.getBoundingClientRect(),G=window.innerHeight,ve=G/2;I.top<ve?(n(22,r="top"),n(21,o=I.top)):(n(22,r="bottom"),n(21,o=G-I.bottom)),o<ze&&n(21,o=ze),localStorage.setItem(f.ORIGIN,r),localStorage.setItem(f.Y_POS,o.toString())}}const ha=()=>Rn(oe),ga=()=>Rn(S),pa=()=>{Rn(O)};function ba(I){ut[I?"unshift":"push"](()=>{w=I,n(6,w)})}function wa(){_=this.value,n(7,_)}function ya(){T=Ro(this),n(8,T),n(20,ie)}function ma(I){ut[I?"unshift":"push"](()=>{p=I,n(5,p)})}function va(){y=this.value,n(2,y)}function xa(I){ut[I?"unshift":"push"](()=>{u=I,n(4,u)})}return e.$$set=I=>{"accent"in I&&n(0,g=I.accent),"position"in I&&n(41,h=I.position),"right"in I&&n(1,Ae=I.right)},e.$$.update=()=>{e.$$.dirty[0]&8|e.$$.dirty[1]&1024&&n(22,r=a?"bottom":localStorage.getItem(f.ORIGIN)||h),e.$$.dirty[0]&8&&n(21,o=a?ze:parseInt(localStorage.getItem(f.Y_POS)||"0")||ze),e.$$.dirty[1]&2048&&n(23,i=v==="justopened"||v==="opened"),e.$$.dirty[0]&1|e.$$.dirty[1]&4096&&n(25,s=se?"cursor-grabbing outline-dashed outline-"+g+"-500 outline-1 outline-offset-4":"outline-none"),e.$$.dirty[0]&4&&n(24,c=y&&(y.match(zt)||y.match(so)))},[g,Ae,y,a,u,p,w,_,T,L,K,oe,S,O,U,j,z,D,Q,W,ie,o,r,i,c,s,l,Xc,ea,ta,na,ra,oa,ia,sa,ca,aa,la,ua,fa,da,h,v,se,ha,ga,pa,ba,wa,ya,ma,va,xa]}class Fc extends Fn{constructor(t){super(),Yn(this,t,Yc,Zc,Dt,{accent:0,position:41,right:1},null,[-1,-1,-1])}}const Mt=window;Mt.destroyWnj=()=>{setTimeout(()=>{Jc.$destroy()},1)};const Hn=document.createElement("div");Hn.style.zIndex="90000",document.body.appendChild(Hn);const qn=document.createElement("div");qn.id="wnj";const xo=document.createElement("style");xo.innerHTML=Me;const Eo=Hn.attachShadow({mode:"open"});Eo.appendChild(qn),Eo.appendChild(xo);const Jc=new Fc({target:qn,props:{accent:((ko=Mt.wnjParams)==null?void 0:ko.accent)||"cyan",position:((So=Mt.wnjParams)==null?void 0:So.position)==="bottom"?"bottom":"top"}});if(!((Ao=Mt.wnjParams)!=null&&Ao.disableOverflowFix)){var _o=document.createElement("style"),Qc=`
8
+ <a target="_blank" class="underline" href="https://www.nostr.com">Learn more</a>.</p>`,v(e,"class","text-center text-lg"),v(r,"class","text-base leading-5")},m(o,i){q(o,e,i),q(o,n,i),q(o,r,i)},p:L,i:L,o:L,d(o){o&&(R(e),R(n),R(r))}}}function Kc(t){let e,n,r,o,i,s,c=new URL(t[15]).host+"",a,l,f,u,g,h,b,d,p,y;return{c(){e=N("div"),n=N("div"),n.textContent="An action requires your confirmation",r=$(),o=N("div"),i=j("Now you a new window will bring you to "),s=N("strong"),a=j(c),l=j(" where you can approve the current action. If nothing happens check that if your browser is blocking popups, pleaase."),f=N("br"),u=j(`
9
+ After that you will be returned to this page.`),g=$(),h=N("button"),b=j("Confirm action »"),v(n,"class","text-center text-lg"),v(o,"class","mt-4 text-center text-sm leading-4"),v(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"),v(e,"class","m-auto w-full")},m(w,E){q(w,e,E),k(e,n),k(e,r),k(e,o),k(o,i),k(o,s),k(s,a),k(o,l),k(o,f),k(o,u),k(e,g),k(e,h),k(h,b),p||(y=J(h,"click",t[48]),p=!0)},p(w,E){E[0]&32768&&c!==(c=new URL(w[15]).host+"")&&Pe(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-"+w[0]+"-900 hover:bg-"+w[0]+"-950")&&v(h,"class",d)},i:L,o:L,d(w){w&&R(e),p=!1,y()}}}function Dc(t){let e,n,r,o,i,s,c=new URL(t[14]).host+"",a,l,f,u,g,h,b,d,p,y;return{c(){e=N("div"),n=N("div"),n.textContent="Login into a Nostr account",r=$(),o=N("div"),i=j("Now you a new window will bring you to "),s=N("strong"),a=j(c),l=j(" where you can login and approve the permissions. If nothing happens check that if your browser is blocking popups, pleaase."),f=N("br"),u=j(`
10
+ After that you will be returned to this page.`),g=$(),h=N("button"),b=j("Login now »"),v(n,"class","text-center text-lg"),v(o,"class","mt-4 text-center text-sm leading-4"),v(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"),v(e,"class","m-auto w-full")},m(w,E){q(w,e,E),k(e,n),k(e,r),k(e,o),k(o,i),k(o,s),k(s,a),k(o,l),k(o,f),k(o,u),k(e,g),k(e,h),k(h,b),p||(y=J(h,"click",t[47]),p=!0)},p(w,E){E[0]&16384&&c!==(c=new URL(w[14]).host+"")&&Pe(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-"+w[0]+"-900 hover:bg-"+w[0]+"-950")&&v(h,"class",d)},i:L,o:L,d(w){w&&R(e),p=!1,y()}}}function Wc(t){let e,n,r,o,i,s,c=new URL(t[13]).host+"",a,l,f,u,g,h,b,d,p,y;return{c(){e=N("div"),n=N("div"),n.textContent="Create a Nostr account",r=$(),o=N("div"),i=j("Now you a new window will bring you to "),s=N("strong"),a=j(c),l=j(" where the account creation will take place. If nothing happens check that if your browser is blocking popups, pleaase."),f=N("br"),u=j(`
11
+ After that you will be returned to this page.`),g=$(),h=N("button"),b=j("Start account creation »"),v(n,"class","text-center text-lg"),v(o,"class","mt-4 text-center text-sm leading-4"),v(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"),v(e,"class","m-auto w-full")},m(w,E){q(w,e,E),k(e,n),k(e,r),k(e,o),k(o,i),k(o,s),k(s,a),k(o,l),k(o,f),k(o,u),k(e,g),k(e,h),k(h,b),p||(y=J(h,"click",t[46]),p=!0)},p(w,E){E[0]&8192&&c!==(c=new URL(w[13]).host+"")&&Pe(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-"+w[0]+"-900 hover:bg-"+w[0]+"-950")&&v(h,"class",d)},i:L,o:L,d(w){w&&R(e),p=!1,y()}}}function ho(t){let e,n,r=t[21].picture&&go(t),o=t[21].name&&po(t);return{c(){e=N("div"),r&&r.c(),n=$(),o&&o.c(),v(e,"class","mb-2 flex items-center justify-center gap-2")},m(i,s){q(i,e,s),r&&r.m(e,null),k(e,n),o&&o.m(e,null)},p(i,s){i[21].picture?r?r.p(i,s):(r=go(i),r.c(),r.m(e,n)):r&&(r.d(1),r=null),i[21].name?o?o.p(i,s):(o=po(i),o.c(),o.m(e,null)):o&&(o.d(1),o=null)},d(i){i&&R(e),r&&r.d(),o&&o.d()}}}function go(t){let e,n,r;return{c(){e=N("img"),Xe(e.src,n=t[21].picture)||v(e,"src",n),v(e,"alt",""),v(e,"class",r="h-10 w-10 rounded-full border-2 border-solid border-transparent group-hover:border-"+t[0]+"-100")},m(o,i){q(o,e,i)},p(o,i){i[0]&2097152&&!Xe(e.src,n=o[21].picture)&&v(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")&&v(e,"class",r)},d(o){o&&R(e)}}}function po(t){let e,n=t[21].name+"",r;return{c(){e=N("div"),r=j(n),v(e,"class","text-3xl decoration-2 underline-offset-4 group-hover:underline")},m(o,i){q(o,e,i),k(e,r)},p(o,i){i[0]&2097152&&n!==(n=o[21].name+"")&&Pe(r,n)},d(o){o&&R(e)}}}function bo(t){let e,n;return{c(){e=N("div"),n=j(t[19]),v(e,"class","my-2 rounded bg-yellow-100 p-2 text-center text-sm leading-4 text-red-400")},m(r,o){q(r,e,o),k(e,n)},p(r,o){o[0]&524288&&Pe(n,r[19])},d(r){r&&R(e)}}}function Vc(t){let e;return{c(){e=j("Connect »")},m(n,r){q(n,e,r)},i:L,o:L,d(n){n&&R(e)}}}function Gc(t){let e,n,r;return n=new lo({}),{c(){e=j(`Connecting to bunker
12
+ `),Yn(n.$$.fragment)},m(o,i){q(o,e,i),Yt(n,o,i),r=!0},i(o){r||(de(n.$$.fragment,o),r=!0)},o(o){be(n.$$.fragment,o),r=!1},d(o){o&&R(e),Ft(n,o)}}}function wo(t){let e,n,r,o,i;return{c(){e=N("div"),n=j(`Waiting too much?
13
+ `),r=N("button"),r.textContent="Cancel the connection",v(r,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),v(e,"class","mt-6 text-center text-sm leading-3")},m(s,c){q(s,e,c),k(e,n),k(e,r),o||(i=J(r,"click",t[39]),o=!0)},p:L,d(s){s&&R(e),o=!1,i()}}}function yo(t){let e,n,r,o,i,s,c;return{c(){e=N("div"),n=j("Do you need a Nostr account?"),r=N("br"),o=$(),i=N("button"),i.textContent="Sign up now",v(i,"class","cursor-pointer border-0 bg-transparent text-sm text-white underline"),v(e,"class","mt-6 text-center text-sm leading-3")},m(a,l){q(a,e,l),k(e,n),k(e,r),k(e,o),k(e,i),s||(c=J(i,"click",t[35]),s=!0)},p:L,d(a){a&&R(e),s=!1,c()}}}function mo(t){let e,n,r;return{c(){e=N("option"),v(e,"label",n=t[78].domain),e.__value=r=t[78],et(e,e.__value),v(e,"class","px-2 py-1 text-lg")},m(o,i){q(o,e,i)},p(o,i){i[0]&4194304&&n!==(n=o[78].domain)&&v(e,"label",n),i[0]&4194304&&r!==(r=o[78])&&(e.__value=r,et(e,e.__value))},d(o){o&&R(e)}}}function Zc(t){let e,n;return{c(){e=N("img"),Xe(e.src,n=t[21].picture)||v(e,"src",n),v(e,"alt",""),v(e,"class","h-6 w-6 rounded-full")},m(r,o){q(r,e,o)},p(r,o){o[0]&2097152&&!Xe(e.src,n=r[21].picture)&&v(e,"src",n)},i:L,o:L,d(r){r&&R(e)}}}function Yc(t){let e,n,r,o=(t[21].name||t[21].npub.slice(0,7)+"…"+t[21].npub.slice(-4))+"",i;function s(l,f){return l[21].picture?ea:Xc}let c=s(t),a=c(t);return{c(){e=N("div"),a.c(),n=$(),r=N("div"),i=j(o),v(r,"class","max-w-56 overflow-hidden whitespace-nowrap overflow-ellipsis inline-block"),v(e,"class","flex px-2 items-center")},m(l,f){q(l,e,f),a.m(e,null),k(e,n),k(e,r),k(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]&2097152&&o!==(o=(l[21].name||l[21].npub.slice(0,7)+"…"+l[21].npub.slice(-4))+"")&&Pe(i,o)},i:L,o:L,d(l){l&&R(e),a.d()}}}function Fc(t){let e;return{c(){e=N("div"),e.textContent="N",v(e,"class","w-6 text-center")},m(n,r){q(n,e,r)},p:L,i:L,o:L,d(n){n&&R(e)}}}function Jc(t){let e;return{c(){e=N("div"),e.textContent="Connect with Nostr",v(e,"class","flex px-2 items-center")},m(n,r){q(n,e,r)},p:L,i:L,o:L,d(n){n&&R(e)}}}function Qc(t){let e,n,r,o;return r=new lo({}),{c(){e=N("div"),n=j(`Connecting to bunker
14
+ `),Yn(r.$$.fragment),v(e,"class","flex px-2 items-center")},m(i,s){q(i,e,s),k(e,n),Yt(r,e,null),o=!0},p:L,i(i){o||(de(r.$$.fragment,i),o=!0)},o(i){be(r.$$.fragment,i),o=!1},d(i){i&&R(e),Ft(r)}}}function Xc(t){let e;return{c(){e=j("☉")},m(n,r){q(n,e,r)},p:L,d(n){n&&R(e)}}}function ea(t){let e,n;return{c(){e=N("img"),Xe(e.src,n=t[21].picture)||v(e,"src",n),v(e,"alt",""),v(e,"class","mr-2 h-5 w-5 rounded-full")},m(r,o){q(r,e,o)},p(r,o){o[0]&2097152&&!Xe(e.src,n=r[21].picture)&&v(e,"src",n)},d(r){r&&R(e)}}}function ta(t){let e,n,r,o,i,s,c;const a=[qc,Hc,Rc],l=[];function f(u,g){return!u[25]&&!u[21]&&u[1]?0:u[25]?2:1}return n=f(t),r=l[n]=a[n](t),{c(){e=N("div"),r.c(),v(e,"class","draggable animate-fadein font-sans text-white"),v(e,"style",o="position: fixed; "+(t[25]&&t[5]?"width: 100vw;":"")+"; right: "+(t[25]&&t[5]?"0":t[3])+"px; user-select: none; "+(t[25]&&t[5]?"bottom: 0px":t[24]+":"+t[23]+"px")),Wn(e,"cursor-pointer",!t[21]&&!t[25])},m(u,g){q(u,e,g),l[n].m(e,null),t[54](e),i=!0,s||(c=[J(Rn,"click",t[29]),J(Rn,"mouseup",t[42]),J(Rn,"mousemove",t[41]),J(e,"mousedown",t[40])],s=!0)},p(u,g){let h=n;n=f(u),n===h?l[n].p(u,g):(At(),be(l[h],1,1,()=>{l[h]=null}),Bt(),r=l[n],r?r.p(u,g):(r=l[n]=a[n](u),r.c()),de(r,1),r.m(e,null)),(!i||g[0]&58720296&&o!==(o="position: fixed; "+(u[25]&&u[5]?"width: 100vw;":"")+"; right: "+(u[25]&&u[5]?"0":u[3])+"px; user-select: none; "+(u[25]&&u[5]?"bottom: 0px":u[24]+":"+u[23]+"px")))&&v(e,"style",o),(!i||g[0]&35651584)&&Wn(e,"cursor-pointer",!u[21]&&!u[25])},i(u){i||(de(r),i=!0)},o(u){be(r),i=!1},d(u){u&&R(e),l[n].d(),t[54](null),s=!1,Ne(c)}}}const vo="We could not connect to a NIP-46 bunker with that url, are you sure it is set up correctly?",xo="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 Hn(t){return window.open(t,"window.nostr","width=600,height=800,popup=yes")}function na(t,e,n){let r,o,i,s,c,a;const l=Lc("only screen and (max-width: 640px)");Uo(t,l,I=>n(5,a=I));const f={ORIGIN:"wnj:origin",CLIENT_SECRET:"wnj:clientSecret",Y_POS:"wnj:ypos",CALLBACK_TOKEN:"wnj:callbackToken",BUNKER_POINTER:"wnj:bunkerPointer"};let u,{accent:g}=e,{position:h="top"}=e,{startHidden:b}=e,{compactMode:d}=e;const p=window,y=new As;let w,E,O,P,S,_;const m=localStorage.getItem(f.CLIENT_SECRET);m?_=en(m):(_=cs(),localStorage.setItem(f.CLIENT_SECRET,ne(_)));let A="closed",C,U,G,Z,Y,B,T=null,H=null,z=null,M=!1,K,ee,V,fe=!1,F,he,ge=[],{right:pe=20}=e,Je=!1,ce=!1,Be,Et,Ie;const ie={pool:y,onauth(I){K?n(13,T=I):F?(n(15,z=I),n(25,i=!0)):n(14,H=I)}},Oe=Xn(()=>{switch(A){case"justopened":n(44,A="opened");break;case"justclosed":n(44,A="closed");break}},500);function Qe(){n(44,A="justopened"),Oe()}function $e(){n(44,A="justclosed"),Oe()}function Kt(){if(C&&!B){zn();return}Qe()}Mn();let To={isWnj:!0,async getPublicKey(){return C?C.pubkey:(!Y&&!B&&Qe(),(await Z).bp.pubkey)},async signEvent(I){try{return!Y&&!B&&Kt(),await(await Z).signEvent(I)}finally{n(15,z=null),$e()}},async getRelays(){return!Y&&!B&&Kt(),(await Z).getRelays()},nip04:{async encrypt(I,D){return!Y&&!B&&Kt(),(await Z).nip04Encrypt(I,D)},async decrypt(I,D){return!Y&&!B&&Kt(),(await Z).nip04Decrypt(I,D)}}};function Mn(){$e(),C=null,Z=new Promise((I,D)=>{U=I,G=D}),n(21,F=null),n(12,Y=!1),n(16,M=!1),n(17,K=!1),B=!1,he=null,n(19,V="")}$o(()=>{if(!C){let I=localStorage.getItem(f.BUNKER_POINTER);I&&(C=JSON.parse(I),$n())}if(p.nostr&&!p.nostr.isWnj){p.destroyWnj();return}else Object.defineProperty(window,"nostr",{get(){return To},set(I){To=I,I.isWnj||p.destroyWnj()},configurable:!0});return()=>{he&&he.close()}});function sa(I){Math.abs(o-Et)>6||Date.now()-Ie>600||A==="justopened"||A==="justclosed"||(I.composedPath().find(D=>D.id==="wnj")?Qe():$e())}function ca(I){$e(),n(17,K=!1),n(13,T=null),n(14,H=null),n(15,z=null),I.stopPropagation()}function aa(I){n(20,fe=!0),I.stopPropagation()}function la(I){n(20,fe=!1),I.stopPropagation()}async function ua(I){I.preventDefault();try{if(C=await Sc(w.value),!C){w.value.match($t)?n(19,V=vo):n(19,V=xo);return}w.setCustomValidity(""),n(19,V=""),await zn(),$n()}catch{w.value.match($t)?n(19,V=vo):n(19,V=xo),n(12,Y=!1)}}async function fa(I){I.preventDefault(),localStorage.removeItem(f.BUNKER_POINTER),Mn()}async function da(I){I.preventDefault(),n(17,K=!0),ge.length===0&&(n(22,ge=await Bc(y,["wss://relay.nostr.band","wss://nos.lol","wss://nostr-pub.wellorder.net"])),n(10,S=ge[0]))}function ha(I){n(17,K=!1)}async function ga(I){if(I.preventDefault(),!S)return;n(18,ee=!0);let D=await Ac(S,ie,O.value,S.domain,void 0);n(18,ee=!1),Qe(),n(17,K=!1),C=D.bp,$n(),zn(D)}const pa=Xn(async()=>{S&&O.value.length>0&&(await Ic(O.value+"@"+S.domain)?O.setCustomValidity(`'${O.value}' is already taken.`):O.setCustomValidity(""))},500);function ba(){n(16,M=!1),n(12,Y=!1),G("connection aborted"),Mn()}async function zn(I=void 0){I=I||new so(_,C,ie),n(12,Y=!0);let D=setTimeout(()=>{n(16,M=!0),n(25,i=!0)},5e3);try{await I.connect(),B=!0,localStorage.setItem(f.BUNKER_POINTER,JSON.stringify(C)),$e(),U(I)}catch(xe){G((xe==null?void 0:xe.message)||String(xe))}finally{clearTimeout(D),n(12,Y=!1),n(16,M=!1),n(13,T=null),n(14,H=null),n(15,z=null)}}function $n(I=null){let D=C.pubkey;n(21,F={pubkey:D,npub:Tc(D),event:null}),he=y.subscribeMany(["wss://purplepag.es","wss://relay.snort.social","wss://relay.nos.social"],[{kinds:[0],authors:[D]}],{onevent(xe){var No;if(!((((No=F.event)==null?void 0:No.created_at)||0)>=xe.created_at))try{let{name:Po,picture:Oa}=JSON.parse(xe.content);n(21,F.event=xe,F),n(21,F.name=Po,F),n(21,F.picture=Oa,F),I==null||I(),I=null}catch{}}})}function wa(I){if(i)return;Je=!0;const D=u.getBoundingClientRect();Be=I.clientY-D.top,Et=o,Ie=Date.now()}function ya(I){Je&&(r==="top"?n(23,o=I.clientY):n(23,o=window.innerHeight-I.clientY),n(23,o-=Be),n(45,ce=!0),o<ze&&n(23,o=ze),o>window.innerHeight-ze&&n(23,o=window.innerHeight-ze))}function ma(){if(Je=!1,setTimeout(()=>{n(45,ce=!1)},10),ce){const I=u.getBoundingClientRect(),D=window.innerHeight,xe=D/2;I.top<xe?(n(24,r="top"),n(23,o=I.top)):(n(24,r="bottom"),n(23,o=D-I.bottom)),o<ze&&n(23,o=ze),localStorage.setItem(f.ORIGIN,r),localStorage.setItem(f.Y_POS,o.toString())}}const va=()=>Hn(T),xa=()=>Hn(H),Ea=()=>{Hn(z)};function _a(I){ht[I?"unshift":"push"](()=>{O=I,n(8,O)})}function ka(){P=this.value,n(9,P)}function Sa(){S=Mo(this),n(10,S),n(22,ge)}function Aa(I){ht[I?"unshift":"push"](()=>{w=I,n(7,w)})}function Ba(){E=this.value,n(4,E)}function Ia(I){ht[I?"unshift":"push"](()=>{u=I,n(6,u)})}return t.$$set=I=>{"accent"in I&&n(0,g=I.accent),"position"in I&&n(43,h=I.position),"startHidden"in I&&n(1,b=I.startHidden),"compactMode"in I&&n(2,d=I.compactMode),"right"in I&&n(3,pe=I.right)},t.$$.update=()=>{t.$$.dirty[0]&32|t.$$.dirty[1]&4096&&n(24,r=a?"bottom":localStorage.getItem(f.ORIGIN)||h),t.$$.dirty[0]&32&&n(23,o=a?ze:parseInt(localStorage.getItem(f.Y_POS)||"0")||ze),t.$$.dirty[1]&8192&&n(25,i=A==="justopened"||A==="opened"),t.$$.dirty[0]&1|t.$$.dirty[1]&16384&&n(27,s=ce?"cursor-grabbing outline-dashed outline-"+g+"-500 outline-1 outline-offset-4":"outline-none"),t.$$.dirty[0]&16&&n(26,c=E&&(E.match($t)||E.match(co)))},[g,b,d,pe,E,a,u,w,O,P,S,_,Y,T,H,z,M,K,ee,V,fe,F,ge,o,r,i,c,s,l,sa,ca,aa,la,ua,fa,da,ha,ga,pa,ba,wa,ya,ma,h,A,ce,va,xa,Ea,_a,ka,Sa,Aa,Ba,Ia]}class ra extends Jn{constructor(e){super(),Fn(this,e,na,ta,Wt,{accent:0,position:43,startHidden:1,compactMode:2,right:3},null,[-1,-1,-1])}}const ut=window;ut.destroyWnj=()=>{setTimeout(()=>{oa.$destroy()},1)};const qn=document.createElement("div");qn.style.zIndex="90000",document.body.appendChild(qn);const jn=document.createElement("div");jn.id="wnj";const Eo=document.createElement("style");Eo.innerHTML=Ke;const _o=qn.attachShadow({mode:"open"});_o.appendChild(jn),_o.appendChild(Eo);const oa=new ra({target:jn,props:{accent:((So=ut.wnjParams)==null?void 0:So.accent)||"cyan",position:((Ao=ut.wnjParams)==null?void 0:Ao.position)==="bottom"?"bottom":"top",startHidden:!!((Bo=ut.wnjParams)!=null&&Bo.startHidden),compactMode:!!((Io=ut.wnjParams)!=null&&Io.compactMode)}});if(!((Oo=ut.wnjParams)!=null&&Oo.disableOverflowFix)){var ko=document.createElement("style"),ia=`
15
15
  html, body {
16
16
  overflow: auto;
17
17
  height: 100%;
18
18
  }
19
- `;_o.innerHTML=Qc,document.head.appendChild(_o)}})();
19
+ `;ko.innerHTML=ia,document.head.appendChild(ko)}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "window.nostr.js",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "dist/window.nostr.js",
6
6
  "devDependencies": {
package/src/App.svelte CHANGED
@@ -42,6 +42,8 @@
42
42
  | 'top'
43
43
  | 'bottom'
44
44
  | null) || position
45
+ export let startHidden: boolean
46
+ export let compactMode: boolean
45
47
 
46
48
  const win = window as any
47
49
  const pool = new SimplePool()
@@ -522,20 +524,26 @@
522
524
  bind:this={myself}
523
525
  >
524
526
  <!-- Close status ################### -->
525
- {#if !opened}
527
+ {#if !opened && !identity && startHidden}
528
+ <!-- Show nothing -->
529
+ {:else if !opened}
526
530
  <div
527
- class="rounded px-4 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-{accent}-700 hover:bg-{accent}-800 {movingStyle}"
531
+ class="rounded px-2 py-2 shadow-[0_0px_10px_0px_rgba(0,0,0,0.3)] transition-all duration-200 bg-{accent}-700 hover:bg-{accent}-800 {movingStyle}"
528
532
  >
529
533
  <!-- Connecting view ################### -->
530
534
  {#if connecting}
531
- <div class="flex items-center">
535
+ <div class="flex px-2 items-center">
532
536
  Connecting to bunker
533
537
  <Spinner />
534
538
  </div>
535
- {:else if !identity}
536
- Connect with Nostr
537
- {:else}
538
- <div class="flex items-center">
539
+ {:else if !identity && !compactMode}
540
+ <div class="flex px-2 items-center">
541
+ Connect with Nostr
542
+ </div>
543
+ {:else if !identity && compactMode}
544
+ <div class="w-6 text-center">N</div>
545
+ {:else if !compactMode}
546
+ <div class="flex px-2 items-center">
539
547
  {#if identity.picture}
540
548
  <img
541
549
  src={identity.picture}
@@ -550,6 +558,12 @@
550
558
  identity.npub.slice(0, 7) + '…' + identity.npub.slice(-4)}
551
559
  </div>
552
560
  </div>
561
+ {:else}
562
+ <img
563
+ src={identity.picture}
564
+ alt=""
565
+ class="h-6 w-6 rounded-full"
566
+ />
553
567
  {/if}
554
568
  </div>
555
569
 
package/src/main.ts CHANGED
@@ -36,7 +36,9 @@ const app = new App({
36
36
  target: mountPoint,
37
37
  props: {
38
38
  accent: win.wnjParams?.accent || 'cyan',
39
- position: win.wnjParams?.position === 'bottom' ? 'bottom' : 'top'
39
+ position: win.wnjParams?.position === 'bottom' ? 'bottom' : 'top',
40
+ startHidden: win.wnjParams?.startHidden ? true : false,
41
+ compactMode: win.wnjParams?.compactMode ? true : false,
40
42
  }
41
43
  })
42
44