SOURCE / PINNED RELEASE
Made of little things.
Simple Profile
- Release
- c16eab90ff45…
- Author-recorded commit
- Not provided
- License
- Check the original source
The hash-verified playable HTML, which may contain bundled or minified code. This view does not execute it.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" /><title>Simple Profile</title><meta name="description" content="A Nostr profile: who someone is, how many they follow, and Follow."><meta name="napplet-id" content="simpleprofile"><meta name="napplet-archetype" content="profile"><meta name="napplet-intent" content="napplet:profile/open"><meta name="napplet-requires" content="outbox relay"><meta name="napplet-optional" content="identity inc link resource theme"><link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAMAAADDpiTIAAAARVBMVEXbJ3fxrsz88fb65O7oeKrtk7vkXZn////dNYD2yd3hUJHfQojma6L41uX88vfvocTzu9TqhrPvoMPzvNXqhbL41+bmaqF8KGNSAAAACXBIWXMAAAsSAAALEgHS3X78AAAHbElEQVR42u3d61bbRhAA4JVkaRC2fMPw/o9aoElLmoYQsHWb7/vTk9N/mmE1O7NalwIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsybZr27Z/EfH6n+d/dlvPJUPoN+1xiF8Yju1GGqw5+FUTv9VUmzvPan2ezkN82HB+8sTW5P7cxB9qzvee20pW/ssQnzJcvAuWr6viCyrLwMLD38cX9Z2nmDj8UiB9+KXAQt1VcUWVcnBhLnVcVX3xTJe07x/i6gYbgsU4x02cPdllNH6GuJHBpGgBdnXcTL3zfJMu/14D2Zd/r4FFVP913FxtNzBb3QjxlwHztYmRbDzr1PGXARnL/x+1nvfcnGJU1oC8678MEP8XmoLJ9v92g+IvA+bpbpL4P2eAY0Lz0MdEes9+DtqYjHbADHQxIWVA2gLg2xeEyoC0BcDfjiJQMnWAf3YSg7wvAHvByR1jcpUoJN0BfOfDwek0c0iARhwStoC0g2ZgW88jAWonxadRxUyoA6fZAs4l/raCqSsAVUDaHpAlwAJgCbAAWAJKzimQmZAm4NuvxkVkXPcxM84GjeswtwQ4iMmo6rklgJHQqHYxOz4VKxnHAAYCyccAbwhL6jeAk0Gp9wD2AeMa5pgAekG5S4AI84DUJYCNYPISQBGQvARQBIwnZkpkSp7vgUwE1YCqwOI0oJOBxSTIPKikuhQk3BpmE2AboBGsGWwXaCIsASSABJAAEkAClHX/OIRWoEagVqAEkAASQAJIAAkgASSAXUD4MUF9AH0ACSABJIAEkAASYFRb5wGKE0FOBCX26Exgbg9zTYAHsfFdAIlbgRqByfeBdoG+Dqbkuyg6XBZafBwYPg1MXwWqAZM3g/18YO4i4FFciptCKWkvifFVSMn9hbhZcEk9DzIJSr4RtAkc9R2wn1v894KSuxmoDZh8H2ASmLsXZBCUvBfkMFDJPQ8wB8hdBioBky8BFoDcS4AFIPkSYAHIvQRYAJIvARaA3L0AJ0FK6pHQ3kGAknoqbA5cUv96jG/Cp3QffixQHWgKlLkOnPi6kEcV4NQvgUl3AnsvgNw7ATuAkrojrAecuwxQAOQuAxQAycsAHwPmzgAF4IycxN9WwAZABoi/DBB/GSD+xWTQBNBuUP0vA8Q/m26v/5vb3Y1PCfbmPyXz74ko/1K/BvbugUn9GrD8L2c3cINFYK/6X9IicPW24MGf/8IqgaseFHv09l+e09XeA/uTp7nI90B7lRTYt1b/5VaDX75PslH7ZU4B4V+BXfXJN8G+cu53JcXA5hM/MPGw8epfke3pj9qD/cnFT+tbB3aHD/UGHg9W/hUnQdu/UxU2fbuz8K/f/a6t+r7/pzbcP/+janeOegAAAAAAAMB63HfPDAFzuOu6S9v2L4b/Pw0wvP7Ptt10nUMBq9Ft2vbYf+Jz0b4/tu2TL4IWHfq++fp3Ic+nhDbSYGGL/eXc19f9NrTuzxcvhgXYbqombqapNk4Lz7imv2nw3ySBfcMMg3851jGa+niRBHP68GfM4P+TBJVPh2YS/el+NOooBxJHXw6IvhyYztNMov8tB55EZNQ//ksTM9NcLAOjNXuqOmaorjSJRln7+5it3psg39rvTTDm/Z91zF59lgK3uvZvAeF/TQEXC97CZiHhf00Bt8vN78bHkWsBKXBNXR+L0ztGdC33Cwz/awoYGc/z6v/xVKrBL9vVsWCN98AX//yPsXC6Al8q/ppYPIvA5//8z7EKFoG8f/4WgfR//haBT+79m1iVRk9gtY1/44GyrB+Anoofns7Q+9MXvEL8h1ipQQZ8pPyrY7VqpeDvy79YM6Xg75xj5c5i/J4qVq8S5dTxlwHZ4y8DssdfBmSPv6Zgwv3ff9gN5o6/DMgefxmQPf4y4Mf+fyRkLvDv/K/JmACN2eB3x0jpKPJlved/PuIk9i+6SEsZ8FIA1HkToFYGlNJHYr34t5FaqwBIrlMA5Ja8DDhEeofM8d+Kf8TWDiC3xDuBnei/2JkB5dZoAYRmQMYKsBb6b1vBrSFwbkc9QP3AdFSAbwwWAEtAMg+C/taDJrCGsCmQmZAxsLFwDicRj9RfCtkD5p4IGAMmHwo6BxCpzwXYAybfCVaCHamvDrIHzF0G3ot1pP5U0EmgyH0yaBDqyDwUtgf4pTsXQmkHOwkQTgXYBGYdCZoDmAc4ChKOhZgEawbaBBoIKQHC8XB9YN1gXYAwEjYIMA5YCzF+n7MA4UyATYBeoE2AbYBNgIGgTYBtgE2AbYBNgG1AcTGMaYAEkADFgVCNAG0AjQAJIAEkgASQABJAJzgcCSnuhgk3xUgACSABJIAEkACGgcaBVgArQPFlaPg+tLgkepFOq06A7V6E37ffuifeAqAMVAKu1p0MeC/+GS6KO6kDfvX+P5UUtqeDZeDnP/7DKedPCAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMBn/QXP4TscqWUT2QAAAABJRU5ErkJggg==" type="image/png">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<script type="module" crossorigin>var ss=Object.defineProperty;var as=(t,e,n)=>e in t?ss(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var k=(t,e,n)=>as(t,typeof e!="symbol"?e+"":e,n);/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const wi=t=>t instanceof Uint8Array,cn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),ie=(t,e)=>t<<32-e|t>>>e,cs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!cs)throw new Error("Non little-endian hardware is not supported");const us=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function re(t){if(!wi(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=us[t[n]];return e}function fs(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const i=r*2,o=t.slice(i,i+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function ls(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function mi(t){if(typeof t=="string"&&(t=ls(t)),!wi(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}let ds=class{clone(){return this._cloneInto()}};function vi(t){const e=r=>t().update(mi(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function it(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function ye(...t){const e=(i,o)=>s=>i(o(s)),n=Array.from(t).reverse().reduce((i,o)=>i?e(i,o.encode):o.encode,void 0),r=t.reduce((i,o)=>i?e(i,o.decode):o.decode,void 0);return{encode:n,decode:r}}function be(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(it(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 ge(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 Vt(t,e="="){if(it(t),typeof e!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let i of n)if(typeof i!="string")throw new Error(`padding.decode: non-string input=${i}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function xi(t){if(typeof t!="function")throw new Error("normalize fn should be function");return{encode:e=>e,decode:e=>t(e)}}function Ir(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const i=[],o=Array.from(t);for(o.forEach(s=>{if(it(s),s<0||s>=e)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let c=r;c<o.length;c++){const u=o[c],l=e*s+u;if(!Number.isSafeInteger(l)||e*s/e!==s||l-u!==e*s)throw new Error("convertRadix: carry overflow");if(s=l%n,o[c]=Math.floor(l/n),!Number.isSafeInteger(o[c])||o[c]*n+s!==l)throw new Error("convertRadix: carry overflow");if(a)o[c]?a=!1:r=c;else continue}if(i.push(s),a)break}for(let s=0;s<t.length-1&&t[s]===0;s++)i.push(0);return i.reverse()}const Ei=(t,e)=>e?Ei(e,t%e):t,Rt=(t,e)=>t+(e-Ei(t,e));function Sn(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(Rt(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${Rt(e,n)}`);let i=0,o=0;const s=2**n-1,a=[];for(const c of t){if(it(c),c>=2**e)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(i=i<<e|c,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)a.push((i>>o-n&s)>>>0);i&=2**o-1}if(i=i<<n-o&s,!r&&o>=e)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&a.push(i>>>0),a}function hs(t){return it(t),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Ir(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(Ir(e,t,2**8))}}}function Ue(t,e=!1){if(it(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Rt(8,t)>32||Rt(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 Sn(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(Sn(n,t,8,e))}}}function $r(t){if(typeof t!="function")throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch{}}}const ps=ye(Ue(4),be("0123456789ABCDEF"),ge("")),ys=ye(Ue(5),be("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Vt(5),ge(""));ye(Ue(5),be("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Vt(5),ge(""));ye(Ue(5),be("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),ge(""),xi(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const bs=ye(Ue(6),be("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Vt(6),ge("")),gs=ye(Ue(6),be("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Vt(6),ge("")),Gn=t=>ye(hs(58),be(t),ge("")),An=Gn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Gn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");Gn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Br=[0,2,3,5,6,7,9,10,11],ws={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=An.encode(r).padStart(Br[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),i=Br.indexOf(r.length),o=An.decode(r);for(let s=0;s<o.length-i;s++)if(o[s]!==0)throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(o.slice(o.length-i)))}return Uint8Array.from(e)}},In=ye(be("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),ge("")),_r=[996825010,642813549,513874426,1027748829,705979059];function ct(t){const e=t>>25;let n=(t&33554431)<<5;for(let r=0;r<_r.length;r++)(e>>r&1)===1&&(n^=_r[r]);return n}function Cr(t,e,n=1){const r=t.length;let i=1;for(let o=0;o<r;o++){const s=t.charCodeAt(o);if(s<33||s>126)throw new Error(`Invalid prefix (${t})`);i=ct(i)^s>>5}i=ct(i);for(let o=0;o<r;o++)i=ct(i)^t.charCodeAt(o)&31;for(let o of e)i=ct(i)^o;for(let o=0;o<6;o++)i=ct(i);return i^=n,In.encode(Sn([i%2**30],30,5,!1))}function ki(t){const e=t==="bech32"?1:734539939,n=Ue(5),r=n.decode,i=n.encode,o=$r(r);function s(l,f,h=90){if(typeof l!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof l}`);if(!Array.isArray(f)||f.length&&typeof f[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof f}`);const y=l.length+7+f.length;if(h!==!1&&y>h)throw new TypeError(`Length ${y} exceeds limit ${h}`);return l=l.toLowerCase(),`${l}1${In.encode(f)}${Cr(l,f,e)}`}function a(l,f=90){if(typeof l!="string")throw new Error(`bech32.decode input should be string, not ${typeof l}`);if(l.length<8||f!==!1&&l.length>f)throw new TypeError(`Wrong string length: ${l.length} (${l}). Expected (8..${f})`);const h=l.toLowerCase();if(l!==h&&l!==l.toUpperCase())throw new Error("String must be lowercase or uppercase");l=h;const y=l.lastIndexOf("1");if(y===0||y===-1)throw new Error('Letter "1" must be present between prefix and data only');const p=l.slice(0,y),d=l.slice(y+1);if(d.length<6)throw new Error("Data must be at least 6 characters long");const b=In.decode(d).slice(0,-6),g=Cr(p,b,e);if(!d.endsWith(g))throw new Error(`Invalid checksum in ${l}: expected "${g}"`);return{prefix:p,words:b}}const c=$r(a);function u(l){const{prefix:f,words:h}=a(l,!1);return{prefix:f,words:h,bytes:r(h)}}return{encode:s,decode:a,decodeToBytes:u,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:o,toWords:i}}const Nt=ki("bech32");ki("bech32m");const ms={encode:t=>new TextDecoder().decode(t),decode:t=>new TextEncoder().encode(t)},vs=ye(Ue(4),be("0123456789abcdef"),ge(""),xi(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()})),xs={utf8:ms,hex:vs,base16:ps,base32:ys,base64:bs,base64url:gs,base58:An,base58xmr:ws};`${Object.keys(xs).join(", ")}`;var Bt=new TextDecoder("utf-8");new TextEncoder;var Si=5e3;function Kt(t){var i,o,s,a,c,u,l;let{prefix:e,words:n}=Nt.decode(t,Si),r=new Uint8Array(Nt.fromWords(n));switch(e){case"nprofile":{let f=un(r);if(!((i=f[0])!=null&&i[0]))throw new Error("missing TLV 0 for nprofile");if(f[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:re(f[0][0]),relays:f[1]?f[1].map(h=>Bt.decode(h)):[]}}}case"nevent":{let f=un(r);if(!((o=f[0])!=null&&o[0]))throw new Error("missing TLV 0 for nevent");if(f[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(f[2]&&f[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(f[3]&&f[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:re(f[0][0]),relays:f[1]?f[1].map(h=>Bt.decode(h)):[],author:(s=f[2])!=null&&s[0]?re(f[2][0]):void 0,kind:(a=f[3])!=null&&a[0]?parseInt(re(f[3][0]),16):void 0}}}case"naddr":{let f=un(r);if(!((c=f[0])!=null&&c[0]))throw new Error("missing TLV 0 for naddr");if(!((u=f[2])!=null&&u[0]))throw new Error("missing TLV 2 for naddr");if(f[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!((l=f[3])!=null&&l[0]))throw new Error("missing TLV 3 for naddr");if(f[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Bt.decode(f[0][0]),pubkey:re(f[2][0]),kind:parseInt(re(f[3][0]),16),relays:f[1]?f[1].map(h=>Bt.decode(h)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:re(r)};default:throw new Error(`unknown prefix ${e}`)}}function un(t){let e={},n=t;for(;n.length>0;){let r=n[0],i=n[1],o=n.slice(2,2+i);if(n=n.slice(2+i),o.length<i)throw new Error(`not enough data to read on TLV ${r}`);e[r]=e[r]||[],e[r].push(o)}return e}function Ai(t){return ks("npub",fs(t))}function Es(t,e){let n=Nt.toWords(e);return Nt.encode(t,n,Si)}function ks(t,e){return Es(t,e)}var $n=function(t,e){return $n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},$n(t,e)};function ue(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");$n(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Ss(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(l){try{u(r.next(l))}catch(f){s(f)}}function c(l){try{u(r.throw(l))}catch(f){s(f)}}function u(l){l.done?o(l.value):i(l.value).then(a,c)}u((r=r.apply(t,e||[])).next())})}function Ii(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(l){return c([u,l])}}function c(u){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(n=0)),n;)try{if(r=1,i&&(o=u[0]&2?i.return:u[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,u[1])).done)return o;switch(i=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){n.label=u[1];break}if(u[0]===6&&n.label<o[1]){n.label=o[1],o=u;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(u);break}o[2]&&n.ops.pop(),n.trys.pop();continue}u=e.call(t,n)}catch(l){u=[6,l],i=0}finally{r=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function tt(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function Oe(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function et(t){return this instanceof et?(this.v=t,this):new et(t)}function As(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(y){return function(p){return Promise.resolve(p).then(y,f)}}function a(y,p){r[y]&&(i[y]=function(d){return new Promise(function(b,g){o.push([y,d,b,g])>1||c(y,d)})},p&&(i[y]=p(i[y])))}function c(y,p){try{u(r[y](p))}catch(d){h(o[0][3],d)}}function u(y){y.value instanceof et?Promise.resolve(y.value.v).then(l,f):h(o[0][2],y)}function l(y){c("next",y)}function f(y){c("throw",y)}function h(y,p){y(p),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Is(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof tt=="function"?tt(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=t[o]&&function(s){return new Promise(function(a,c){s=t[o](s),i(a,c,s.done,s.value)})}}function i(o,s,a,c){Promise.resolve(c).then(function(u){o({value:u,done:a})},s)}}function N(t){return typeof t=="function"}function Zn(t){var e=function(r){Error.call(r),r.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var fn=Zn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
`+n.map(function(r,i){return i+1+") "+r.toString()}).join(`
`):"",this.name="UnsubscriptionError",this.errors=n}});function Ut(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var we=(function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=tt(s),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(d){e={error:d}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else s.remove(this);var l=this.initialTeardown;if(N(l))try{l()}catch(d){o=d instanceof fn?d.errors:[d]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var h=tt(f),y=h.next();!y.done;y=h.next()){var p=y.value;try{Lr(p)}catch(d){o=o??[],d instanceof fn?o=Oe(Oe([],Te(o)),Te(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{y&&!y.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}}if(o)throw new fn(o)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)Lr(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Ut(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Ut(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})(),$i=we.EMPTY;function Bi(t){return t instanceof we||t&&"closed"in t&&N(t.remove)&&N(t.add)&&N(t.unsubscribe)}function Lr(t){N(t)?t():t.unsubscribe()}var $s={Promise:void 0},Bs={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Oe([t,e],Te(n)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function _i(t){Bs.setTimeout(function(){throw t})}function Bn(){}function Ct(t){t()}var Xn=(function(t){ue(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Bi(n)&&n.add(r)):r.destination=Ls,r}return e.create=function(n,r,i){return new yt(n,r,i)},e.prototype.next=function(n){this.isStopped||this._next(n)},e.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e})(we),_s=(function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(r){_t(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){_t(r)}else _t(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){_t(n)}},t})(),yt=(function(t){ue(e,t);function e(n,r,i){var o=t.call(this)||this,s;return N(n)||!n?s={next:n??void 0,error:r??void 0,complete:i??void 0}:s=n,o.destination=new _s(s),o}return e})(Xn);function _t(t){_i(t)}function Cs(t){throw t}var Ls={closed:!0,next:Bn,error:Cs,complete:Bn},Jn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function me(t){return t}function Ts(t){return t.length===0?me:t.length===1?t[0]:function(n){return t.reduce(function(r,i){return i(r)},n)}}var P=(function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(e,n,r){var i=this,o=Rs(e)?e:new yt(e,n,r);return Ct(function(){var s=i,a=s.operator,c=s.source;o.add(a?a.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var r=this;return n=Tr(n),new n(function(i,o){var s=new yt({next:function(a){try{e(a)}catch(c){o(c),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[Jn]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Ts(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=Tr(e),new e(function(r,i){var o;n.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},t.create=function(e){return new t(e)},t})();function Tr(t){var e;return(e=t??$s.Promise)!==null&&e!==void 0?e:Promise}function Os(t){return t&&N(t.next)&&N(t.error)&&N(t.complete)}function Rs(t){return t&&t instanceof Xn||Os(t)&&Bi(t)}function Ns(t){return N(t==null?void 0:t.lift)}function H(t){return function(e){if(Ns(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function D(t,e,n,r,i){return new Us(t,e,n,r,i)}var Us=(function(t){ue(e,t);function e(n,r,i,o,s,a){var c=t.call(this,n)||this;return c.onFinalize=s,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){n.error(l)}}:t.prototype._next,c._error=o?function(u){try{o(u)}catch(l){n.error(l)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=i?function(){try{i()}catch(u){n.error(u)}finally{this.unsubscribe()}}:t.prototype._complete,c}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e})(Xn),Ms=Zn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ce=(function(t){ue(e,t);function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return e.prototype.lift=function(n){var r=new Or(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new Ms},e.prototype.next=function(n){var r=this;Ct(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=tt(r.currentObservers),a=s.next();!a.done;a=s.next()){var c=a.value;c.next(n)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},e.prototype.error=function(n){var r=this;Ct(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},e.prototype.complete=function(){var n=this;Ct(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,i=this,o=i.hasError,s=i.isStopped,a=i.observers;return o||s?$i:(this.currentObservers=null,a.push(n),new we(function(){r.currentObservers=null,Ut(a,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?n.error(o):s&&n.complete()},e.prototype.asObservable=function(){var n=new P;return n.source=this,n},e.create=function(n,r){return new Or(n,r)},e})(P),Or=(function(t){ue(e,t);function e(n,r){var i=t.call(this)||this;return i.destination=n,i.source=r,i}return e.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},e.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},e.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},e.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:$i},e})(ce),_n=(function(t){ue(e,t);function e(n){var r=t.call(this)||this;return r._value=n,r}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(n){var r=t.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},e.prototype.getValue=function(){var n=this,r=n.hasError,i=n.thrownError,o=n._value;if(r)throw i;return this._throwIfClosed(),o},e.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},e})(ce),Qn={now:function(){return(Qn.delegate||Date).now()},delegate:void 0},Rr=(function(t){ue(e,t);function e(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=Qn);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=i,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return e.prototype.next=function(n){var r=this,i=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,c=r._windowTime;i||(o.push(n),!s&&o.push(a.now()+c)),this._trimBuffer(),t.prototype.next.call(this,n)},e.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),i=this,o=i._infiniteTimeWindow,s=i._buffer,a=s.slice(),c=0;c<a.length&&!n.closed;c+=o?1:2)n.next(a[c]);return this._checkFinalizedStatuses(n),r},e.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,i=n._timestampProvider,o=n._buffer,s=n._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<o.length&&o.splice(0,o.length-a),!s){for(var c=i.now(),u=0,l=1;l<o.length&&o[l]<=c;l+=2)u=l;u&&o.splice(0,u+1)}},e})(ce),Ps=(function(t){ue(e,t);function e(n,r){return t.call(this)||this}return e.prototype.schedule=function(n,r){return this},e})(we),Nr={setInterval:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Oe([t,e],Te(n)))},clearInterval:function(t){return clearInterval(t)},delegate:void 0},Hs=(function(t){ue(e,t);function e(n,r){var i=t.call(this,n,r)||this;return i.scheduler=n,i.work=r,i.pending=!1,i}return e.prototype.schedule=function(n,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},e.prototype.requestAsyncId=function(n,r,i){return i===void 0&&(i=0),Nr.setInterval(n.flush.bind(n,this),i)},e.prototype.recycleAsyncId=function(n,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&Nr.clearInterval(r)},e.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(n,r){var i=!1,o;try{this.work(n)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},e.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,i=n.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Ut(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e})(Ps),Ur=(function(){function t(e,n){n===void 0&&(n=t.now),this.schedulerActionCtor=e,this.now=n}return t.prototype.schedule=function(e,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,e).schedule(r,n)},t.now=Qn.now,t})(),js=(function(t){ue(e,t);function e(n,r){r===void 0&&(r=Ur.now);var i=t.call(this,n,r)||this;return i.actions=[],i._active=!1,i}return e.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,i){for(;n=r.shift();)n.unsubscribe();throw i}},e})(Ur),zs=new js(Hs),qs=zs,er=new P(function(t){return t.complete()});function Fs(t){return t&&N(t.schedule)}function tr(t){return t[t.length-1]}function Ds(t){return N(tr(t))?t.pop():void 0}function ot(t){return Fs(tr(t))?t.pop():void 0}function Ci(t,e){return typeof tr(t)=="number"?t.pop():e}var Li=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function Ti(t){return N(t==null?void 0:t.then)}function Oi(t){return N(t[Jn])}function Ri(t){return Symbol.asyncIterator&&N(t==null?void 0:t[Symbol.asyncIterator])}function Ni(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Vs(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ui=Vs();function Mi(t){return N(t==null?void 0:t[Ui])}function Pi(t){return As(this,arguments,function(){var n,r,i,o;return Ii(this,function(s){switch(s.label){case 0:n=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,et(n.read())];case 3:return r=s.sent(),i=r.value,o=r.done,o?[4,et(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,et(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Hi(t){return N(t==null?void 0:t.getReader)}function te(t){if(t instanceof P)return t;if(t!=null){if(Oi(t))return Ks(t);if(Li(t))return Ws(t);if(Ti(t))return Ys(t);if(Ri(t))return ji(t);if(Mi(t))return Gs(t);if(Hi(t))return Zs(t)}throw Ni(t)}function Ks(t){return new P(function(e){var n=t[Jn]();if(N(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Ws(t){return new P(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function Ys(t){return new P(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,_i)})}function Gs(t){return new P(function(e){var n,r;try{for(var i=tt(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.next(s),e.closed)return}}catch(a){n={error:a}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}e.complete()})}function ji(t){return new P(function(e){Xs(t,e).catch(function(n){return e.error(n)})})}function Zs(t){return ji(Pi(t))}function Xs(t,e){var n,r,i,o;return Ss(this,void 0,void 0,function(){var s,a;return Ii(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=Is(t),c.label=1;case 1:return[4,n.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(s=r.value,e.next(s),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Ce(t,e,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var o=e.schedule(function(){n(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(o),!i)return o}function zi(t,e){return e===void 0&&(e=0),H(function(n,r){n.subscribe(D(r,function(i){return Ce(r,t,function(){return r.next(i)},e)},function(){return Ce(r,t,function(){return r.complete()},e)},function(i){return Ce(r,t,function(){return r.error(i)},e)}))})}function qi(t,e){return e===void 0&&(e=0),H(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function Js(t,e){return te(t).pipe(qi(e),zi(e))}function Qs(t,e){return te(t).pipe(qi(e),zi(e))}function ea(t,e){return new P(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function ta(t,e){return new P(function(n){var r;return Ce(n,e,function(){r=t[Ui](),Ce(n,e,function(){var i,o,s;try{i=r.next(),o=i.value,s=i.done}catch(a){n.error(a);return}s?n.complete():n.next(o)},0,!0)}),function(){return N(r==null?void 0:r.return)&&r.return()}})}function Fi(t,e){if(!t)throw new Error("Iterable cannot be null");return new P(function(n){Ce(n,e,function(){var r=t[Symbol.asyncIterator]();Ce(n,e,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function na(t,e){return Fi(Pi(t),e)}function ra(t,e){if(t!=null){if(Oi(t))return Js(t,e);if(Li(t))return ea(t,e);if(Ti(t))return Qs(t,e);if(Ri(t))return Fi(t,e);if(Mi(t))return ta(t,e);if(Hi(t))return na(t,e)}throw Ni(t)}function V(t,e){return e?ra(t,e):te(t)}function bt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=ot(t);return V(t,n)}var ia=Zn(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function oa(t,e){var n=typeof e=="object";return new Promise(function(r,i){var o=!1,s;t.subscribe({next:function(a){s=a,o=!0},error:i,complete:function(){o?r(s):n?r(e.defaultValue):i(new ia)}})})}function sa(t){return t instanceof Date&&!isNaN(t)}function fe(t,e){return H(function(n,r){var i=0;n.subscribe(D(r,function(o){r.next(t.call(e,o,i++))}))})}var aa=Array.isArray;function ca(t,e){return aa(e)?t.apply(void 0,Oe([],Te(e))):t(e)}function ua(t){return fe(function(e){return ca(t,e)})}var fa=Array.isArray,la=Object.getPrototypeOf,da=Object.prototype,ha=Object.keys;function pa(t){if(t.length===1){var e=t[0];if(fa(e))return{args:e,keys:null};if(ya(e)){var n=ha(e);return{args:n.map(function(r){return e[r]}),keys:n}}}return{args:t,keys:null}}function ya(t){return t&&typeof t=="object"&&la(t)===da}function ba(t,e){return t.reduce(function(n,r,i){return n[r]=e[i],n},{})}function ga(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=ot(t),r=Ds(t),i=pa(t),o=i.args,s=i.keys;if(o.length===0)return V([],n);var a=new P(wa(o,n,s?function(c){return ba(s,c)}:me));return r?a.pipe(ua(r)):a}function wa(t,e,n){return n===void 0&&(n=me),function(r){Mr(e,function(){for(var i=t.length,o=new Array(i),s=i,a=i,c=function(l){Mr(e,function(){var f=V(t[l],e),h=!1;f.subscribe(D(r,function(y){o[l]=y,h||(h=!0,a--),a||r.next(n(o.slice()))},function(){--s||r.complete()}))},r)},u=0;u<i;u++)c(u)},r)}}function Mr(t,e,n){t?Ce(n,t,e):e()}function ma(t,e,n,r,i,o,s,a){var c=[],u=0,l=0,f=!1,h=function(){f&&!c.length&&!u&&e.complete()},y=function(d){return u<r?p(d):c.push(d)},p=function(d){u++;var b=!1;te(n(d,l++)).subscribe(D(e,function(g){e.next(g)},function(){b=!0},void 0,function(){if(b)try{u--;for(var g=function(){var x=c.shift();s||p(x)};c.length&&u<r;)g();h()}catch(x){e.error(x)}}))};return t.subscribe(D(e,y,function(){f=!0,h()})),function(){}}function Wt(t,e,n){return n===void 0&&(n=1/0),N(e)?Wt(function(r,i){return fe(function(o,s){return e(r,o,i,s)})(te(t(r,i)))},n):(typeof e=="number"&&(n=e),H(function(r,i){return ma(r,i,t,n)}))}function nr(t){return t===void 0&&(t=1/0),Wt(me,t)}function va(){return nr(1)}function Pr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return va()(V(t,ot(t)))}function st(t){return new P(function(e){te(t()).subscribe(e)})}function Mt(t,e,n){return t===void 0&&(t=0),n===void 0&&(n=qs),new P(function(r){var i=sa(t)?+t-n.now():t;i<0&&(i=0);var o=0;return n.schedule(function(){r.closed||(r.next(o++),r.complete())},i)})}function nt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=ot(t),r=Ci(t,1/0),i=t;return i.length?i.length===1?te(i[0]):nr(r)(V(i,n)):er}function pe(t,e){return H(function(n,r){var i=0;n.subscribe(D(r,function(o){return t.call(e,o,i++)&&r.next(o)}))})}function Di(t,e,n,r,i){return function(o,s){var a=n,c=e,u=0;o.subscribe(D(s,function(l){var f=u++;c=a?t(c,l,f):(a=!0,l),r&&s.next(c)},i&&(function(){a&&s.next(c),s.complete()})))}}function xa(t,e){return H(Di(t,e,arguments.length>=2,!1,!0))}var Ea=function(t,e){return t.push(e),t};function ka(){return H(function(t,e){xa(Ea,[])(t).subscribe(e)})}function Sa(t){return t<=0?function(){return er}:H(function(e,n){var r=0;e.subscribe(D(n,function(i){++r<=t&&(n.next(i),t<=r&&n.complete())}))})}function Yt(t,e){return e===void 0&&(e=me),t=t??Aa,H(function(n,r){var i,o=!0;n.subscribe(D(r,function(s){var a=e(s);(o||!t(i,a))&&(o=!1,i=a,r.next(s))}))})}function Aa(t,e){return t===e}function Gt(t){return H(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function Ia(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=ot(t),r=Ci(t,1/0);return H(function(i,o){nr(r)(V(Oe([i],Te(t)),n)).subscribe(o)})}function Cn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ia.apply(void 0,Oe([],Te(t)))}function $a(t){t===void 0&&(t=1/0);var e;t&&typeof t=="object"?e=t:e={count:t};var n=e.count,r=n===void 0?1/0:n,i=e.delay,o=e.resetOnSuccess,s=o===void 0?!1:o;return r<=0?me:H(function(a,c){var u=0,l,f=function(){var h=!1;l=a.subscribe(D(c,function(y){s&&(u=0),c.next(y)},void 0,function(y){if(u++<r){var p=function(){l?(l.unsubscribe(),l=null,f()):h=!0};if(i!=null){var d=typeof i=="number"?Mt(i):te(i(y,u)),b=D(c,function(){b.unsubscribe(),p()},function(){c.complete()});d.subscribe(b)}else p()}else c.error(y)})),h&&(l.unsubscribe(),l=null,f())};f()})}function Ba(t,e){return H(Di(t,e,arguments.length>=2,!0))}function _a(t){t===void 0&&(t={});var e=t.connector,n=e===void 0?function(){return new ce}:e,r=t.resetOnError,i=r===void 0?!0:r,o=t.resetOnComplete,s=o===void 0?!0:o,a=t.resetOnRefCountZero,c=a===void 0?!0:a;return function(u){var l,f,h,y=0,p=!1,d=!1,b=function(){f==null||f.unsubscribe(),f=void 0},g=function(){b(),l=h=void 0,p=d=!1},x=function(){var E=l;g(),E==null||E.unsubscribe()};return H(function(E,_){y++,!d&&!p&&b();var I=h=h??n();_.add(function(){y--,y===0&&!d&&!p&&(f=ln(x,c))}),I.subscribe(_),!l&&y>0&&(l=new yt({next:function(v){return I.next(v)},error:function(v){d=!0,b(),f=ln(g,i,v),I.error(v)},complete:function(){p=!0,b(),f=ln(g,s),I.complete()}}),te(E).subscribe(l))})(u)}}function ln(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(e===!0){t();return}if(e!==!1){var i=new yt({next:function(){i.unsubscribe(),t()}});return te(e.apply(void 0,Oe([],Te(n)))).subscribe(i)}}function Ca(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=ot(t);return H(function(r,i){(n?Pr(t,r,n):Pr(t,r)).subscribe(i)})}function La(t,e){return H(function(n,r){var i=null,o=0,s=!1,a=function(){return s&&!i&&r.complete()};n.subscribe(D(r,function(c){i==null||i.unsubscribe();var u=0,l=o++;te(t(c,l)).subscribe(i=D(r,function(f){return r.next(e?e(c,f,l,u++):f)},function(){i=null,a()}))},function(){s=!0,a()}))})}function Ta(t){return H(function(e,n){te(t).subscribe(D(n,function(){return n.complete()},Bn)),!n.closed&&e.subscribe(n)})}function Zt(t,e,n){var r=N(t)||e||n?{next:t,error:e,complete:n}:t;return r?H(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;i.subscribe(D(o,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),o.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),o.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),o.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):me}const rr=/^[0-9a-f]{64}$/i,Vi=/^([0-9a-f]{64})(?:\.([a-z0-9]{1,8}))?$/i;function mt(t){try{const e=new URL(t);return e.protocol==="https:"||e.protocol==="http:"?e:null}catch{return null}}function Ki(t,e,n){var u,l;if(/^blossom:/i.test(t))return Na(t,e,n);const r=mt(t);if(r&&Yi(r.hostname))return null;const i=r?decodeURIComponent(r.pathname.split("/").pop()??""):"",o=Vi.exec(i);let s;if(o&&(s=o[1].toLowerCase()),!s)return null;let a=(u=o==null?void 0:o[2])==null?void 0:u.toLowerCase();if(!a){const f=/\.([a-z0-9]{1,8})$/i.exec(i);a=(l=f==null?void 0:f[1])==null?void 0:l.toLowerCase()}const c=[];return r&&c.push(`xs=${r.origin}`),n&&rr.test(n)&&c.push(`as=${n.toLowerCase()}`),`blossom:${s}${a?`.${a}`:""}${c.length?`?${c.join("&")}`:""}`}const Oa=/^blossom:(?:sha256:)?([0-9a-f]{64})(?:\.([a-z0-9]{1,8}))?(?:\?(.*))?$/i;function Ra(t){const e=t.trim();if(!e)return null;const n=mt(/^https?:\/\//i.test(e)?e:`https://${e}`);return!n||!(n.hostname.includes(".")||n.hostname==="localhost")?null:n.origin}function Xt(t){const e=Oa.exec(t.trim());if(!e)return null;const n={sha:e[1].toLowerCase(),xs:[],as:[]};e[2]&&(n.ext=e[2].toLowerCase());for(const r of(e[3]??"").split("&")){const i=r.indexOf("=");if(i<=0)continue;const o=r.slice(0,i).toLowerCase();let s=r.slice(i+1);try{s=decodeURIComponent(s)}catch{}if(o==="xs"){const a=Ra(s);a&&!n.xs.includes(a)&&n.xs.length<3&&n.xs.push(a)}else if(o==="as"){const a=s.toLowerCase();rr.test(a)&&!n.as.includes(a)&&n.as.length<3&&n.as.push(a)}else o==="sz"&&/^\d+$/.test(s)&&s!=="0"&&(n.sz??(n.sz=s))}return n}function Na(t,e,n){const r=Xt(t);if(!r)return null;const i=r.as.length?r.as:n&&rr.test(n)?[n.toLowerCase()]:[],o=r.sz??void 0,s=[...r.xs.map(a=>`xs=${a}`),...i.map(a=>`as=${a}`),...o?[`sz=${o}`]:[]];return`blossom:${r.sha}${r.ext?`.${r.ext}`:""}${s.length?`?${s.join("&")}`:""}`}const Hr=/^(?:jpe?g|png|gif|webp|avif)$/i;function Wi(t){const e=Xt(t);if(e)return!e.ext||Hr.test(e.ext);const n=mt(t);if(!n||Yi(n.hostname))return!1;let r="";try{r=decodeURIComponent(n.pathname.split("/").pop()??"")}catch{return!1}const i=Vi.exec(r);return!!i&&(!i[2]||Hr.test(i[2]))}function Yi(t){const e=t.toLowerCase();return e==="nostr.build"||e.endsWith(".nostr.build")}function Ua(t){const e=/^blossom:(?:sha256:)?([0-9a-f]{64})/i.exec(t);return e?e[1].toLowerCase():null}function Gi(t){return t.replace(/^blossom:(?:sha256:)?([0-9a-f]{64})\.[a-z0-9]{1,8}/i,"blossom:$1")}function Zi(t){const e=t==null?void 0:t.trim().toLowerCase();if(e){if(e.startsWith("image/")||/^(?:jpe?g|png|gif|webp|avif|heic|heif|bmp)$/.test(e))return!0;if(/^(?:video|audio|text|application)\//.test(e))return!1}}function Ma(t){const e=t==null?void 0:t.trim().toLowerCase();if(e){if(e.startsWith("video/")||/^(?:mp4|webm|mov|quicktime|m4v)$/.test(e))return!0;if(Zi(e)||/^(?:audio|text|application)\//.test(e))return!1}}const jr=/\.(?:mp4|webm|mov|m4v)$/i;function Xi(t){const e=Xt(t);if(e)return!!e.ext&&jr.test(`.${e.ext}`);const n=mt(t);return!!n&&jr.test(n.pathname)}function Pa(t){const e=mt(t);return!!e&&/\.(?:jpe?g|png|gif|webp|avif)$/i.test(e.pathname)}const ir=0,he=3,Ha=10002,Ln=/^[0-9a-f]{64}$/,ja=/^[0-9a-f]{128}$/;function Ji(t){return typeof t=="string"&&Ln.test(t)}function Qi(t){var n;if(!t||t.kind!==he)return[];const e=new Set;for(const r of t.tags){const i=(n=r[1])==null?void 0:n.toLowerCase();r[0]==="p"&&Ji(i)&&e.add(i)}return[...e]}function za(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.id=="string"&&Ln.test(e.id)&&typeof e.pubkey=="string"&&Ln.test(e.pubkey)&&typeof e.sig=="string"&&ja.test(e.sig)&&typeof e.kind=="number"&&Number.isInteger(e.kind)&&typeof e.created_at=="number"&&typeof e.content=="string"&&Array.isArray(e.tags)&&e.tags.every(n=>Array.isArray(n)&&n.every(r=>typeof r=="string"))}function le(t,e=500){return typeof t=="string"&&t.trim()?t.trim().slice(0,e):void 0}function qa(t){if(t.kind!==ir)return null;let e;try{const n=JSON.parse(t.content);if(typeof n!="object"||n===null)return null;e=n}catch{return null}return{pubkey:t.pubkey,name:le(e.name,80),displayName:le(e.display_name,80)??le(e.displayName,80),picture:le(e.picture,2e3),banner:le(e.banner,2e3),about:le(e.about,4e3),nip05:le(e.nip05,200),website:le(e.website,500),lud16:le(e.lud16,200),createdAt:t.created_at}}function Fa(t,e,n){const r=e.toLowerCase(),i=a=>{var c;return a[0]==="p"&&((c=a[1])==null?void 0:c.toLowerCase())===r},o=t.tags.filter(a=>!i(a)),s=n?[...o,["p",r]]:o;return{kind:he,content:t.content,tags:s,created_at:Math.floor(Date.now()/1e3)}}function Da(){const t=new Map;function e(i,o){if(t.has(i))throw new Error(`NAP domain "${i}" is already registered`);t.set(i,o)}function n(i){const o=i.type.indexOf(".");if(o<=0)return!1;const s=i.type.slice(0,o),a=t.get(s);return a?(a(i),!0):!1}function r(){return Array.from(t.keys())}return{registerNap:e,dispatch:n,getRegisteredDomains:r}}var Va=Da(),Ve=Va.registerNap,Ka="relay";function or(){var e;const t=window;if(!((e=t.napplet)!=null&&e.relay))throw new Error("window.napplet.relay is unavailable -- runtime did not inject the relay domain");return t.napplet.relay}function Wa(t,e,n,r){return or().subscribe(t,e,n,r)}function Ya(t,e){return or().publish(t,e)}function Ga(t){return or().query(t)}Ve(Ka,t=>{});var Za="identity";function eo(){var e;const t=window;if(!((e=t.napplet)!=null&&e.identity))throw new Error("window.napplet.identity is unavailable -- runtime did not inject this domain");return t.napplet.identity}function Xa(){return eo().getPublicKey()}function Ja(t){return eo().onChanged(t)}Ve(Za,t=>{});var Qa="inc";function ec(){var e;const t=window;if(!((e=t.napplet)!=null&&e.inc))throw new Error("window.napplet.inc is unavailable -- runtime did not inject this domain");return t.napplet.inc}function tc(t,e){return ec().on(t,e)}Ve(Qa,t=>{});var nc="theme";function to(){var e;const t=window;if(!((e=t.napplet)!=null&&e.theme))throw new Error("window.napplet.theme is unavailable -- runtime did not inject this domain");return t.napplet.theme}function rc(){return to().get()}function ic(t){return to().onChanged(t)}Ve(nc,t=>{});var oc="resource";function no(){var e;const t=window;if(!((e=t.napplet)!=null&&e.resource))throw new Error("window.napplet.resource is unavailable -- runtime did not inject this domain");return t.napplet.resource}function sc(){return no().info()}function ro(t,e){return no().bytes(t,e)}Ve(oc,t=>{});var ac="outbox";function sr(){var e;const t=window;if(!((e=t.napplet)!=null&&e.outbox))throw new Error("window.napplet.outbox is unavailable -- runtime did not inject this domain");return t.napplet.outbox}function cc(t,e){return sr().query(t,e)}function uc(t,e){return sr().subscribe(t,e)}function fc(t,e){return sr().publish(t,e)}Ve(ac,t=>{});var lc="link";function dc(){var e;const t=window;if(!((e=t.napplet)!=null&&e.link))throw new Error("window.napplet.link is unavailable -- runtime did not inject this domain");return t.napplet.link}function hc(t,e){return dc().open(t,e)}Ve(lc,t=>{});const Tn=/^[0-9a-f]{64}$/i,pc=/^wss?:\/\/[^\s/?#]+[^\s]*$/i,yc=/^(npub|nprofile)1[023456789acdefghjklmnpqrstuvwxyz]+$/i,ar=5;function On(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&pc.test(e.trim())).map(e=>e.trim()):[]}function zr(t){const e=t.trim().replace(/^nostr:/i,"");if(Tn.test(e))return{pubkey:e.toLowerCase(),relays:[]};if(!yc.test(e))return null;try{const n=Kt(e.toLowerCase());if(n.type==="npub")return{pubkey:n.data,relays:[]};if(n.type==="nprofile"&&Tn.test(n.data.pubkey))return{pubkey:n.data.pubkey,relays:On(n.data.relays)}}catch{}return null}function cr(t,e=0){if(typeof t=="string")return zr(t);if(typeof t!="object"||t===null||Array.isArray(t)||e>2)return null;const n=t;if(n.target!==void 0){const o=cr(n.target,e+1);if(o)return qr(o,On(n.relays))}const r=[];for(const o of["pubkey","npub","nprofile","uri","value"]){const s=n[o];if(typeof s!="string")continue;const a=zr(s);a&&(o==="pubkey"&&!Tn.test(s.trim())||r.push(a))}if(!r.length)return null;const i=r[0].pubkey;return r.some(o=>o.pubkey!==i)?null:qr({pubkey:i,relays:[]},[...r.flatMap(o=>o.relays),...On(n.relays)])}function qr(t,e){return{pubkey:t.pubkey,relays:[...new Set([...t.relays,...e])].slice(0,ar)}}function ur(t){const e=/^(?:([\w.+-]+)@)?([a-z0-9-]+(?:\.[a-z0-9-]+)+)$/i.exec(t.trim());return e?{name:(e[1]??"_").toLowerCase(),domain:e[2].toLowerCase()}:null}function bc(t){const e=ur(t);return e?e.name==="_"?e.domain:`${e.name}@${e.domain}`:t}function gc(t){const e=ur(t);return e?`https://${e.domain}/.well-known/nostr.json?name=${encodeURIComponent(e.name)}`:null}function wc(t,e,n){var a;const r=ur(e);if(!r||typeof t!="object"||t===null)return!1;const i=t.names;if(typeof i!="object"||i===null)return!1;const o=i,s=o[r.name]??((a=Object.entries(o).find(([c])=>c.toLowerCase()===r.name))==null?void 0:a[1]);return typeof s=="string"&&s.toLowerCase()===n.toLowerCase()}function mc(t){const e=t==null?void 0:t.trim().replace(/^lightning:/i,"");return e&&/^[\w.+-]+@[a-z0-9-]+(?:\.[a-z0-9-]+)+$/i.test(e)?e.toLowerCase():null}function vc(t){const e=t==null?void 0:t.trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:/^[a-z0-9-]+(\.[a-z0-9-]+)+(\/\S*)?$/i.test(e)?`https://${e}`:null;if(!n)return null;try{const r=new URL(n);return r.protocol==="https:"||r.protocol==="http:"?r.href:null}catch{return null}}function xc(t,e=12,n=6){return t.length>e+n+1?`${t.slice(0,e)}…${t.slice(-n)}`:t}function Ec(t){return`${t.toLocaleString("en-US")} following`}function io(){return window.napplet}function z(t,e){var r;const n=(r=io())==null?void 0:r[t];return typeof(n==null?void 0:n[e])=="function"}function kc(){return typeof io()=="object"}async function Sc(){return z("identity","getPublicKey")&&await Xa()||""}function Ac(t){if(!z("identity","onChanged"))return()=>{};try{const e=Ja(t);return()=>e.close()}catch{return()=>{}}}async function Ic(t){try{if(z("outbox","publish")){const e=await fc(t);return e.ok?e.event?{ok:!0,event:e.event}:{ok:!0}:{ok:!1,error:e.error||"publish refused"}}return z("relay","publish")?(await Ya(t),{ok:!0}):{ok:!1,error:"This shell cannot publish."}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}let Fr;function $c(){return Fr??(Fr=(async()=>{if(z("resource","info"))try{return await sc()}catch{return}})()),Fr}function oo(){return $c().then(t=>!!(t!=null&&t.schemes.some(e=>e.scheme==="https"&&e.enabled!==!1)))}const Bc="napplet:profile/open";function _c(t){if(!z("inc","on"))return()=>{};try{const e=tc(Bc,n=>t(n.payload,n.sender));return()=>e.close()}catch{return()=>{}}}const Dr=new Map;function Cc(t,e){const n=`${t.toLowerCase()} ${e}`;let r=Dr.get(n);return r||(r=(async()=>{const i=gc(t);if(!i||!z("resource","bytes")||!await oo())return!1;try{const o=await ro(i);return o.size>256*1024?!1:wc(JSON.parse(await o.text()),t,e)}catch{return!1}})(),Dr.set(n,r)),r}async function Lc(t){var e,n;try{if((e=navigator.clipboard)!=null&&e.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",document.body.append(r),r.select();const i=((n=document.execCommand)==null?void 0:n.call(document,"copy"))??!1;return r.remove(),i}catch{return!1}}async function Tc(t){if(!z("link","open"))return!1;try{return(await hc(t)).status==="opened"}catch{return!1}}const Oc=5e3,Rc=10;function so(t){var e,n;return{...(e=t.authors)!=null&&e.length?{authors:t.authors}:{},...(n=t.relays)!=null&&n.length?{relays:[...new Set(t.relays)].slice(0,Rc)}:{}}}class Nc extends Error{}function ao(t,e={}){if(z("outbox","subscribe")){const n=new P(r=>{const i=so(e),o=uc(t,Object.keys(i).length?i:void 0);let s=!0;return o.on("event",a=>{a!=null&&a.event&&r.next(a.event)}),o.on("closed",a=>{s&&r.error(new Nc(a??""))}),()=>{s=!1,o.close()}});return st(()=>n).pipe($a({delay:r=>{var o;const i=r instanceof Error?r.message:"";return(o=e.onNotice)==null||o.call(e,`Profile read closed by the shell${i?`: ${i}`:""}. Reopening…`),Mt(Oc)}}))}return z("relay","subscribe")?new P(n=>{const r=Wa(t,i=>(i==null?void 0:i.event)&&n.next(i.event),()=>{});return()=>r.close()}):new P(()=>{var n;(n=e.onNotice)==null||n.call(e,"This shell offers no way to read relays (no outbox or relay domain).")})}function Uc(t,e={}){return st(async()=>{if(z("outbox","query"))try{const n=await cc(t,{...so(e),timeoutMs:e.timeoutMs??6e3});if(n.events.length||!z("relay","query"))return n.events.map(r=>r.event)}catch(n){if(!z("relay","query"))throw n}return z("relay","query")?(await Ga(t)).map(n=>n.event):[]}).pipe(Wt(n=>V(n.filter(Boolean))))}function Mc(t){return t<1e4&&t!==0&&t!==3}function co(t){return t===0||t===3||1e4<=t&&t<2e4}function uo(t){return 3e4<=t&&t<4e4}var fo=0,Pc=3,Hc=4,lo=5,jc=13,zc=1059,qc=1e4,Fc=10002,Dc=10003,Vc=10004,Kc=10005,Wc=10007,Yc=10015,Gc=3e4,Zc=30002,Xc=30003,Jc=30004,Qc=30015,eu=30024,tu=31990;function Vr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function ho(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 nu(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Vr(t.outputLen),Vr(t.blockLen)}function Pt(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 ru(t,e){ho(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const dn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const po=t=>t instanceof Uint8Array,hn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),oe=(t,e)=>t<<32-e|t>>>e,iu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!iu)throw new Error("Non little-endian hardware is not supported");function ou(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function fr(t){if(typeof t=="string"&&(t=ou(t)),!po(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function su(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!po(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}class yo{clone(){return this._cloneInto()}}function au(t){const e=r=>t().update(fr(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function bo(t=32){if(dn&&typeof dn.getRandomValues=="function")return dn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function cu(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}let uu=class extends yo{constructor(e,n,r,i){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=hn(this.buffer)}update(e){Pt(this);const{view:n,buffer:r,blockLen:i}=this;e=fr(e);const o=e.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const c=hn(e);for(;i<=o-s;s+=i)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Pt(this),ru(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:o}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let f=s;f<i;f++)n[f]=0;cu(r,i-8,BigInt(this.length*8),o),this.process(r,0);const a=hn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)a.setUint32(4*f,l[f],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%n&&e.buffer.set(r),e}};const fu=(t,e,n)=>t&e^~t&n,lu=(t,e,n)=>t&e^t&n^e&n,du=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]),Se=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ae=new Uint32Array(64);let hu=class extends uu{constructor(){super(64,32,8,!1),this.A=Se[0]|0,this.B=Se[1]|0,this.C=Se[2]|0,this.D=Se[3]|0,this.E=Se[4]|0,this.F=Se[5]|0,this.G=Se[6]|0,this.H=Se[7]|0}get(){const{A:e,B:n,C:r,D:i,E:o,F:s,G:a,H:c}=this;return[e,n,r,i,o,s,a,c]}set(e,n,r,i,o,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let f=0;f<16;f++,n+=4)Ae[f]=e.getUint32(n,!1);for(let f=16;f<64;f++){const h=Ae[f-15],y=Ae[f-2],p=oe(h,7)^oe(h,18)^h>>>3,d=oe(y,17)^oe(y,19)^y>>>10;Ae[f]=d+Ae[f-7]+p+Ae[f-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const h=oe(a,6)^oe(a,11)^oe(a,25),y=l+h+fu(a,c,u)+du[f]+Ae[f]|0,d=(oe(r,2)^oe(r,13)^oe(r,22))+lu(r,i,o)|0;l=u,u=c,c=a,a=s+y|0,s=o,o=i,i=r,r=y+d|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,i,o,s,a,c,u,l)}roundClean(){Ae.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Rn=au(()=>new hu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0);const pu=BigInt(1),yu=BigInt(2),Jt=t=>t instanceof Uint8Array,bu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function rt(t){if(!Jt(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=bu[t[n]];return e}function lr(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}function gt(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(e/2);for(let r=0;r<n.length;r++){const i=r*2,o=t.slice(i,i+2),s=Number.parseInt(o,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function K(t){return lr(rt(t))}function dr(t){if(!Jt(t))throw new Error("Uint8Array expected");return lr(rt(Uint8Array.from(t).reverse()))}function Re(t,e){return gt(t.toString(16).padStart(e*2,"0"))}function hr(t,e){return Re(t,e).reverse()}function q(t,e,n){let r;if(typeof e=="string")try{r=gt(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(Jt(e))r=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(`${t} expected ${n} bytes, got ${i}`);return r}function Fe(...t){const e=new Uint8Array(t.reduce((r,i)=>r+i.length,0));let n=0;return t.forEach(r=>{if(!Jt(r))throw new Error("Uint8Array expected");e.set(r,n),n+=r.length}),e}const pr=t=>(yu<<BigInt(t-1))-pu,pn=t=>new Uint8Array(t),Kr=t=>Uint8Array.from(t);function go(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=pn(t),i=pn(t),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...f)=>n(i,r,...f),c=(f=pn())=>{i=a(Kr([0]),f),r=a(),f.length!==0&&(i=a(Kr([1]),f),r=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const h=[];for(;f<e;){r=a();const y=r.slice();h.push(y),f+=r.length}return Fe(...h)};return(f,h)=>{s(),c(f);let y;for(;!(y=h(u()));)c();return s(),y}}const gu={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 vt(t,e,n={}){const r=(i,o,s)=>{const a=gu[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);const c=t[i];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`)};for(const[i,o]of Object.entries(e))r(i,o,!1);for(const[i,o]of Object.entries(n))r(i,o,!0);return t}const wu=Object.freeze(Object.defineProperty({__proto__:null,bitMask:pr,bytesToHex:rt,bytesToNumberBE:K,bytesToNumberLE:dr,concatBytes:Fe,createHmacDrbg:go,ensureBytes:q,hexToBytes:gt,hexToNumber:lr,numberToBytesBE:Re,numberToBytesLE:hr,validateObject:vt},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const M=BigInt(0),R=BigInt(1),He=BigInt(2),mu=BigInt(3),Nn=BigInt(4),Wr=BigInt(5),Yr=BigInt(8);BigInt(9);BigInt(16);function j(t,e){const n=t%e;return n>=M?n:e+n}function vu(t,e,n){if(n<=M||e<M)throw new Error("Expected power/modulo > 0");if(n===R)return M;let r=R;for(;e>M;)e&R&&(r=r*t%n),t=t*t%n,e>>=R;return r}function J(t,e,n){let r=t;for(;e-- >M;)r*=r,r%=n;return r}function Un(t,e){if(t===M||e<=M)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=j(t,e),r=e,i=M,o=R;for(;n!==M;){const a=r/n,c=r%n,u=i-o*a;r=n,n=c,i=o,o=u}if(r!==R)throw new Error("invert: does not exist");return j(i,e)}function xu(t){const e=(t-R)/He;let n,r,i;for(n=t-R,r=0;n%He===M;n/=He,r++);for(i=He;i<t&&vu(i,e,t)!==t-R;i++);if(r===1){const s=(t+R)/Nn;return function(c,u){const l=c.pow(u,s);if(!c.eql(c.sqr(l),u))throw new Error("Cannot find square root");return l}}const o=(n+R)/He;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=r,l=a.pow(a.mul(a.ONE,i),n),f=a.pow(c,o),h=a.pow(c,n);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let y=1;for(let d=a.sqr(h);y<u&&!a.eql(d,a.ONE);y++)d=a.sqr(d);const p=a.pow(l,R<<BigInt(u-y-1));l=a.sqr(p),f=a.mul(f,p),h=a.mul(h,l),u=y}return f}}function Eu(t){if(t%Nn===mu){const e=(t+R)/Nn;return function(r,i){const o=r.pow(i,e);if(!r.eql(r.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%Yr===Wr){const e=(t-Wr)/Yr;return function(r,i){const o=r.mul(i,He),s=r.pow(o,e),a=r.mul(i,s),c=r.mul(r.mul(a,He),s),u=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(u),i))throw new Error("Cannot find square root");return u}}return xu(t)}const ku=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Su(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=ku.reduce((r,i)=>(r[i]="function",r),e);return vt(t,n)}function Au(t,e,n){if(n<M)throw new Error("Expected power > 0");if(n===M)return t.ONE;if(n===R)return e;let r=t.ONE,i=e;for(;n>M;)n&R&&(r=t.mul(r,i)),i=t.sqr(i),n>>=R;return r}function Iu(t,e){const n=new Array(e.length),r=e.reduce((o,s,a)=>t.is0(s)?o:(n[a]=o,t.mul(o,s)),t.ONE),i=t.inv(r);return e.reduceRight((o,s,a)=>t.is0(s)?o:(n[a]=t.mul(o,n[a]),t.mul(o,s)),i),n}function wo(t,e){const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function $u(t,e,n=!1,r={}){if(t<=M)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=wo(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Eu(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:pr(i),ZERO:M,ONE:R,create:c=>j(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return M<=c&&c<t},is0:c=>c===M,isOdd:c=>(c&R)===R,neg:c=>j(-c,t),eql:(c,u)=>c===u,sqr:c=>j(c*c,t),add:(c,u)=>j(c+u,t),sub:(c,u)=>j(c-u,t),mul:(c,u)=>j(c*u,t),pow:(c,u)=>Au(a,c,u),div:(c,u)=>j(c*Un(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Un(c,t),sqrt:r.sqrt||(c=>s(a,c)),invertBatch:c=>Iu(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>n?hr(c,o):Re(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return n?dr(c):K(c)}});return Object.freeze(a)}function mo(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 vo(t){const e=mo(t);return e+Math.ceil(e/2)}function Bu(t,e,n=!1){const r=t.length,i=mo(e),o=vo(e);if(r<16||r<o||r>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const s=n?K(t):dr(t),a=j(s,e-R)+R;return n?hr(a,i):Re(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _u=BigInt(0),yn=BigInt(1);function Cu(t,e){const n=(i,o)=>{const s=o.negate();return i?s:o},r=i=>{const o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:n,unsafeLadder(i,o){let s=t.ZERO,a=i;for(;o>_u;)o&yn&&(s=s.add(a)),a=a.double(),o>>=yn;return s},precomputeWindow(i,o){const{windows:s,windowSize:a}=r(o),c=[];let u=i,l=u;for(let f=0;f<s;f++){l=u,c.push(l);for(let h=1;h<a;h++)l=l.add(u),c.push(l);u=l.double()}return c},wNAF(i,o,s){const{windows:a,windowSize:c}=r(i);let u=t.ZERO,l=t.BASE;const f=BigInt(2**i-1),h=2**i,y=BigInt(i);for(let p=0;p<a;p++){const d=p*c;let b=Number(s&f);s>>=y,b>c&&(b-=h,s+=yn);const g=d,x=d+Math.abs(b)-1,E=p%2!==0,_=b<0;b===0?l=l.add(n(E,o[g])):u=u.add(n(_,o[x]))}return{p:u,f:l}},wNAFCached(i,o,s,a){const c=i._WINDOW_SIZE||1;let u=o.get(i);return u||(u=this.precomputeWindow(i,c),c!==1&&o.set(i,a(u))),this.wNAF(c,u,s)}}}function xo(t){return Su(t.Fp),vt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...wo(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Lu(t){const e=xo(t);vt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Tu,hexToBytes:Ou}=wu,je={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:e}=je;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:Tu(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=je,n=typeof t=="string"?Ou(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=je._parseInt(n.subarray(2)),{d:s,l:a}=je._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){const e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,n=u=>{const l=u.toString(16);return l.length&1?`0${l}`:l},r=e(n(t.s)),i=e(n(t.r)),o=r.length/2,s=i.length/2,a=n(o),c=n(s);return`30${n(s+o+4)}02${c}${i}02${a}${r}`}},de=BigInt(0),ee=BigInt(1);BigInt(2);const Gr=BigInt(3);BigInt(4);function Ru(t){const e=Lu(t),{Fp:n}=e,r=e.toBytes||((p,d,b)=>{const g=d.toAffine();return Fe(Uint8Array.from([4]),n.toBytes(g.x),n.toBytes(g.y))}),i=e.fromBytes||(p=>{const d=p.subarray(1),b=n.fromBytes(d.subarray(0,n.BYTES)),g=n.fromBytes(d.subarray(n.BYTES,2*n.BYTES));return{x:b,y:g}});function o(p){const{a:d,b}=e,g=n.sqr(p),x=n.mul(g,p);return n.add(n.add(x,n.mul(p,d)),b)}if(!n.eql(n.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(p){return typeof p=="bigint"&&de<p&&p<e.n}function a(p){if(!s(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(p){const{allowedPrivateKeyLengths:d,nByteLength:b,wrapPrivateKey:g,n:x}=e;if(d&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=rt(p)),typeof p!="string"||!d.includes(p.length))throw new Error("Invalid key");p=p.padStart(b*2,"0")}let E;try{E=typeof p=="bigint"?p:K(q("private key",p,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof p}`)}return g&&(E=j(E,x)),a(E),E}const u=new Map;function l(p){if(!(p instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(d,b,g){if(this.px=d,this.py=b,this.pz=g,d==null||!n.isValid(d))throw new Error("x required");if(b==null||!n.isValid(b))throw new Error("y required");if(g==null||!n.isValid(g))throw new Error("z required")}static fromAffine(d){const{x:b,y:g}=d||{};if(!d||!n.isValid(b)||!n.isValid(g))throw new Error("invalid affine point");if(d instanceof f)throw new Error("projective point not allowed");const x=E=>n.eql(E,n.ZERO);return x(b)&&x(g)?f.ZERO:new f(b,g,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){const b=n.invertBatch(d.map(g=>g.pz));return d.map((g,x)=>g.toAffine(b[x])).map(f.fromAffine)}static fromHex(d){const b=f.fromAffine(i(q("pointHex",d)));return b.assertValidity(),b}static fromPrivateKey(d){return f.BASE.multiply(c(d))}_setWindowSize(d){this._WINDOW_SIZE=d,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:d,y:b}=this.toAffine();if(!n.isValid(d)||!n.isValid(b))throw new Error("bad point: x or y not FE");const g=n.sqr(b),x=o(d);if(!n.eql(g,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:d}=this.toAffine();if(n.isOdd)return!n.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);const{px:b,py:g,pz:x}=this,{px:E,py:_,pz:I}=d,v=n.eql(n.mul(b,I),n.mul(E,x)),A=n.eql(n.mul(g,I),n.mul(_,x));return v&&A}negate(){return new f(this.px,n.neg(this.py),this.pz)}double(){const{a:d,b}=e,g=n.mul(b,Gr),{px:x,py:E,pz:_}=this;let I=n.ZERO,v=n.ZERO,A=n.ZERO,B=n.mul(x,x),X=n.mul(E,E),O=n.mul(_,_),C=n.mul(x,E);return C=n.add(C,C),A=n.mul(x,_),A=n.add(A,A),I=n.mul(d,A),v=n.mul(g,O),v=n.add(I,v),I=n.sub(X,v),v=n.add(X,v),v=n.mul(I,v),I=n.mul(C,I),A=n.mul(g,A),O=n.mul(d,O),C=n.sub(B,O),C=n.mul(d,C),C=n.add(C,A),A=n.add(B,B),B=n.add(A,B),B=n.add(B,O),B=n.mul(B,C),v=n.add(v,B),O=n.mul(E,_),O=n.add(O,O),B=n.mul(O,C),I=n.sub(I,B),A=n.mul(O,X),A=n.add(A,A),A=n.add(A,A),new f(I,v,A)}add(d){l(d);const{px:b,py:g,pz:x}=this,{px:E,py:_,pz:I}=d;let v=n.ZERO,A=n.ZERO,B=n.ZERO;const X=e.a,O=n.mul(e.b,Gr);let C=n.mul(b,E),W=n.mul(g,_),Y=n.mul(x,I),ve=n.add(b,g),w=n.add(E,_);ve=n.mul(ve,w),w=n.add(C,W),ve=n.sub(ve,w),w=n.add(b,x);let m=n.add(E,I);return w=n.mul(w,m),m=n.add(C,Y),w=n.sub(w,m),m=n.add(g,x),v=n.add(_,I),m=n.mul(m,v),v=n.add(W,Y),m=n.sub(m,v),B=n.mul(X,w),v=n.mul(O,Y),B=n.add(v,B),v=n.sub(W,B),B=n.add(W,B),A=n.mul(v,B),W=n.add(C,C),W=n.add(W,C),Y=n.mul(X,Y),w=n.mul(O,w),W=n.add(W,Y),Y=n.sub(C,Y),Y=n.mul(X,Y),w=n.add(w,Y),C=n.mul(W,w),A=n.add(A,C),C=n.mul(m,w),v=n.mul(ve,v),v=n.sub(v,C),C=n.mul(ve,W),B=n.mul(m,B),B=n.add(B,C),new f(v,A,B)}subtract(d){return this.add(d.negate())}is0(){return this.equals(f.ZERO)}wNAF(d){return y.wNAFCached(this,u,d,b=>{const g=n.invertBatch(b.map(x=>x.pz));return b.map((x,E)=>x.toAffine(g[E])).map(f.fromAffine)})}multiplyUnsafe(d){const b=f.ZERO;if(d===de)return b;if(a(d),d===ee)return this;const{endo:g}=e;if(!g)return y.unsafeLadder(this,d);let{k1neg:x,k1:E,k2neg:_,k2:I}=g.splitScalar(d),v=b,A=b,B=this;for(;E>de||I>de;)E&ee&&(v=v.add(B)),I&ee&&(A=A.add(B)),B=B.double(),E>>=ee,I>>=ee;return x&&(v=v.negate()),_&&(A=A.negate()),A=new f(n.mul(A.px,g.beta),A.py,A.pz),v.add(A)}multiply(d){a(d);let b=d,g,x;const{endo:E}=e;if(E){const{k1neg:_,k1:I,k2neg:v,k2:A}=E.splitScalar(b);let{p:B,f:X}=this.wNAF(I),{p:O,f:C}=this.wNAF(A);B=y.constTimeNegate(_,B),O=y.constTimeNegate(v,O),O=new f(n.mul(O.px,E.beta),O.py,O.pz),g=B.add(O),x=X.add(C)}else{const{p:_,f:I}=this.wNAF(b);g=_,x=I}return f.normalizeZ([g,x])[0]}multiplyAndAddUnsafe(d,b,g){const x=f.BASE,E=(I,v)=>v===de||v===ee||!I.equals(x)?I.multiplyUnsafe(v):I.multiply(v),_=E(this,b).add(E(d,g));return _.is0()?void 0:_}toAffine(d){const{px:b,py:g,pz:x}=this,E=this.is0();d==null&&(d=E?n.ONE:n.inv(x));const _=n.mul(b,d),I=n.mul(g,d),v=n.mul(x,d);if(E)return{x:n.ZERO,y:n.ZERO};if(!n.eql(v,n.ONE))throw new Error("invZ was invalid");return{x:_,y:I}}isTorsionFree(){const{h:d,isTorsionFree:b}=e;if(d===ee)return!0;if(b)return b(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:d,clearCofactor:b}=e;return d===ee?this:b?b(f,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return this.assertValidity(),r(f,this,d)}toHex(d=!0){return rt(this.toRawBytes(d))}}f.BASE=new f(e.Gx,e.Gy,n.ONE),f.ZERO=new f(n.ZERO,n.ONE,n.ZERO);const h=e.nBitLength,y=Cu(f,e.endo?Math.ceil(h/2):h);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function Nu(t){const e=xo(t);return vt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Uu(t){const e=Nu(t),{Fp:n,n:r}=e,i=n.BYTES+1,o=2*n.BYTES+1;function s(w){return de<w&&w<n.ORDER}function a(w){return j(w,r)}function c(w){return Un(w,r)}const{ProjectivePoint:u,normPrivateKeyToScalar:l,weierstrassEquation:f,isWithinCurveOrder:h}=Ru({...e,toBytes(w,m,$){const T=m.toAffine(),L=n.toBytes(T.x),U=Fe;return $?U(Uint8Array.from([m.hasEvenY()?2:3]),L):U(Uint8Array.from([4]),L,n.toBytes(T.y))},fromBytes(w){const m=w.length,$=w[0],T=w.subarray(1);if(m===i&&($===2||$===3)){const L=K(T);if(!s(L))throw new Error("Point is not on curve");const U=f(L);let G=n.sqrt(U);const Z=(G&ee)===ee;return($&1)===1!==Z&&(G=n.neg(G)),{x:L,y:G}}else if(m===o&&$===4){const L=n.fromBytes(T.subarray(0,n.BYTES)),U=n.fromBytes(T.subarray(n.BYTES,2*n.BYTES));return{x:L,y:U}}else throw new Error(`Point of length ${m} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),y=w=>rt(Re(w,e.nByteLength));function p(w){const m=r>>ee;return w>m}function d(w){return p(w)?a(-w):w}const b=(w,m,$)=>K(w.slice(m,$));class g{constructor(m,$,T){this.r=m,this.s=$,this.recovery=T,this.assertValidity()}static fromCompact(m){const $=e.nByteLength;return m=q("compactSignature",m,$*2),new g(b(m,0,$),b(m,$,2*$))}static fromDER(m){const{r:$,s:T}=je.toSig(q("DER",m));return new g($,T)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new g(this.r,this.s,m)}recoverPublicKey(m){const{r:$,s:T,recovery:L}=this,U=A(q("msgHash",m));if(L==null||![0,1,2,3].includes(L))throw new Error("recovery id invalid");const G=L===2||L===3?$+e.n:$;if(G>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const Z=(L&1)===0?"02":"03",xe=u.fromHex(Z+y(G)),Ee=c(G),We=a(-U*Ee),at=a(T*Ee),ke=u.BASE.multiplyAndAddUnsafe(xe,We,at);if(!ke)throw new Error("point at infinify");return ke.assertValidity(),ke}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return gt(this.toDERHex())}toDERHex(){return je.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return gt(this.toCompactHex())}toCompactHex(){return y(this.r)+y(this.s)}}const x={isValidPrivateKey(w){try{return l(w),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const w=vo(e.n);return Bu(e.randomBytes(w),e.n)},precompute(w=8,m=u.BASE){return m._setWindowSize(w),m.multiply(BigInt(3)),m}};function E(w,m=!0){return u.fromPrivateKey(w).toRawBytes(m)}function _(w){const m=w instanceof Uint8Array,$=typeof w=="string",T=(m||$)&&w.length;return m?T===i||T===o:$?T===2*i||T===2*o:w instanceof u}function I(w,m,$=!0){if(_(w))throw new Error("first arg must be private key");if(!_(m))throw new Error("second arg must be public key");return u.fromHex(m).multiply(l(w)).toRawBytes($)}const v=e.bits2int||function(w){const m=K(w),$=w.length*8-e.nBitLength;return $>0?m>>BigInt($):m},A=e.bits2int_modN||function(w){return a(v(w))},B=pr(e.nBitLength);function X(w){if(typeof w!="bigint")throw new Error("bigint expected");if(!(de<=w&&w<B))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Re(w,e.nByteLength)}function O(w,m,$=C){if(["recovered","canonical"].some(Me=>Me in $))throw new Error("sign() legacy options not supported");const{hash:T,randomBytes:L}=e;let{lowS:U,prehash:G,extraEntropy:Z}=$;U==null&&(U=!0),w=q("msgHash",w),G&&(w=q("prehashed msgHash",T(w)));const xe=A(w),Ee=l(m),We=[X(Ee),X(xe)];if(Z!=null){const Me=Z===!0?L(n.BYTES):Z;We.push(q("extraEntropy",Me))}const at=Fe(...We),ke=xe;function an(Me){const Ye=v(Me);if(!h(Ye))return;const kr=c(Ye),Ge=u.BASE.multiply(Ye).toAffine(),ne=a(Ge.x);if(ne===de)return;const Ze=a(kr*a(ke+ne*Ee));if(Ze===de)return;let Sr=(Ge.x===ne?0:2)|Number(Ge.y&ee),Ar=Ze;return U&&p(Ze)&&(Ar=d(Ze),Sr^=1),new g(ne,Ar,Sr)}return{seed:at,k2sig:an}}const C={lowS:e.lowS,prehash:!1},W={lowS:e.lowS,prehash:!1};function Y(w,m,$=C){const{seed:T,k2sig:L}=O(w,m,$),U=e;return go(U.hash.outputLen,U.nByteLength,U.hmac)(T,L)}u.BASE._setWindowSize(8);function ve(w,m,$,T=W){var Ge;const L=w;if(m=q("msgHash",m),$=q("publicKey",$),"strict"in T)throw new Error("options.strict was renamed to lowS");const{lowS:U,prehash:G}=T;let Z,xe;try{if(typeof L=="string"||L instanceof Uint8Array)try{Z=g.fromDER(L)}catch(ne){if(!(ne instanceof je.Err))throw ne;Z=g.fromCompact(L)}else if(typeof L=="object"&&typeof L.r=="bigint"&&typeof L.s=="bigint"){const{r:ne,s:Ze}=L;Z=new g(ne,Ze)}else throw new Error("PARSE");xe=u.fromHex($)}catch(ne){if(ne.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(U&&Z.hasHighS())return!1;G&&(m=e.hash(m));const{r:Ee,s:We}=Z,at=A(m),ke=c(We),an=a(at*ke),Me=a(Ee*ke),Ye=(Ge=u.BASE.multiplyAndAddUnsafe(xe,an,Me))==null?void 0:Ge.toAffine();return Ye?a(Ye.x)===Ee:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:I,sign:Y,verify:ve,ProjectivePoint:u,Signature:g,utils:x}}class Eo extends yo{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,nu(e);const r=fr(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(r.length>i?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return Pt(this),this.iHash.update(e),this}digestInto(e){Pt(this),ho(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ko=(t,e,n)=>new Eo(t,e).update(n).digest();ko.create=(t,e)=>new Eo(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Mu(t){return{hash:t,hmac:(e,...n)=>ko(t,e,su(...n)),randomBytes:bo}}function Pu(t,e){const n=r=>Uu({...t,...Mu(r)});return Object.freeze({...n(e),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ht=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),So=BigInt(1),jt=BigInt(2),Zr=(t,e)=>(t+e/jt)/e;function Ao(t){const e=Qt,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,l=u*u*t%e,f=J(l,n,e)*l%e,h=J(f,n,e)*l%e,y=J(h,jt,e)*u%e,p=J(y,i,e)*y%e,d=J(p,o,e)*p%e,b=J(d,a,e)*d%e,g=J(b,c,e)*b%e,x=J(g,a,e)*d%e,E=J(x,n,e)*l%e,_=J(E,s,e)*p%e,I=J(_,r,e)*u%e,v=J(I,jt,e);if(!Mn.eql(Mn.sqr(v),t))throw new Error("Cannot find square root");return v}const Mn=$u(Qt,void 0,void 0,{sqrt:Ao}),yr=Pu({a:BigInt(0),b:BigInt(7),Fp:Mn,n:Ht,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Ht,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-So*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Zr(o*t,e),c=Zr(-r*t,e);let u=j(t-a*n-c*i,e),l=j(-a*r-c*o,e);const f=u>s,h=l>s;if(f&&(u=e-u),h&&(l=e-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:u,k2neg:h,k2:l}}}},Rn),en=BigInt(0),Io=t=>typeof t=="bigint"&&en<t&&t<Qt,Hu=t=>typeof t=="bigint"&&en<t&&t<Ht,Xr={};function zt(t,...e){let n=Xr[t];if(n===void 0){const r=Rn(Uint8Array.from(t,i=>i.charCodeAt(0)));n=Fe(r,r),Xr[t]=n}return Rn(Fe(n,...e))}const br=t=>t.toRawBytes(!0).slice(1),Pn=t=>Re(t,32),bn=t=>j(t,Qt),wt=t=>j(t,Ht),gr=yr.ProjectivePoint,ju=(t,e,n)=>gr.BASE.multiplyAndAddUnsafe(t,e,n);function Hn(t){let e=yr.utils.normPrivateKeyToScalar(t),n=gr.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:wt(-e),bytes:br(n)}}function $o(t){if(!Io(t))throw new Error("bad x: need 0 < x < p");const e=bn(t*t),n=bn(e*t+BigInt(7));let r=Ao(n);r%jt!==en&&(r=bn(-r));const i=new gr(t,r,So);return i.assertValidity(),i}function Bo(...t){return wt(K(zt("BIP0340/challenge",...t)))}function zu(t){return Hn(t).bytes}function qu(t,e,n=bo(32)){const r=q("message",t),{bytes:i,scalar:o}=Hn(e),s=q("auxRand",n,32),a=Pn(o^K(zt("BIP0340/aux",s))),c=zt("BIP0340/nonce",a,i,r),u=wt(K(c));if(u===en)throw new Error("sign failed: k is zero");const{bytes:l,scalar:f}=Hn(u),h=Bo(l,i,r),y=new Uint8Array(64);if(y.set(l,0),y.set(Pn(wt(f+h*o)),32),!_o(y,r,i))throw new Error("sign: Invalid signature produced");return y}function _o(t,e,n){const r=q("signature",t,64),i=q("message",e),o=q("publicKey",n,32);try{const s=$o(K(o)),a=K(r.subarray(0,32));if(!Io(a))return!1;const c=K(r.subarray(32,64));if(!Hu(c))return!1;const u=Bo(Pn(a),br(s),i),l=ju(s,c,wt(-u));return!(!l||!l.hasEvenY()||l.toAffine().x!==a)}catch{return!1}}const ut={getPublicKey:zu,sign:qu,verify:_o,utils:{randomPrivateKey:yr.utils.randomPrivateKey,lift_x:$o,pointToBytes:br,numberToBytesBE:Re,bytesToNumberBE:K,taggedHash:zt,mod:j}};function jn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Fu(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function Co(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 Du(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");jn(t.outputLen),jn(t.blockLen)}function Vu(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 Ku(t,e){Co(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const gn={number:jn,bool:Fu,bytes:Co,hash:Du,exists:Vu,output:Ku};function Wu(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}class Yu extends ds{constructor(e,n,r,i){super(),this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=cn(this.buffer)}update(e){gn.exists(this);const{view:n,buffer:r,blockLen:i}=this;e=mi(e);const o=e.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const c=cn(e);for(;i<=o-s;s+=i)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){gn.exists(this),gn.output(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:o}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let f=s;f<i;f++)n[f]=0;Wu(r,i-8,BigInt(this.length*8),o),this.process(r,0);const a=cn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)a.setUint32(4*f,l[f],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%n&&e.buffer.set(r),e}}const Gu=(t,e,n)=>t&e^~t&n,Zu=(t,e,n)=>t&e^t&n^e&n,Xu=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]),Ie=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$e=new Uint32Array(64);class Lo extends Yu{constructor(){super(64,32,8,!1),this.A=Ie[0]|0,this.B=Ie[1]|0,this.C=Ie[2]|0,this.D=Ie[3]|0,this.E=Ie[4]|0,this.F=Ie[5]|0,this.G=Ie[6]|0,this.H=Ie[7]|0}get(){const{A:e,B:n,C:r,D:i,E:o,F:s,G:a,H:c}=this;return[e,n,r,i,o,s,a,c]}set(e,n,r,i,o,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let f=0;f<16;f++,n+=4)$e[f]=e.getUint32(n,!1);for(let f=16;f<64;f++){const h=$e[f-15],y=$e[f-2],p=ie(h,7)^ie(h,18)^h>>>3,d=ie(y,17)^ie(y,19)^y>>>10;$e[f]=d+$e[f-7]+p+$e[f-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){const h=ie(a,6)^ie(a,11)^ie(a,25),y=l+h+Gu(a,c,u)+Xu[f]+$e[f]|0,d=(ie(r,2)^ie(r,13)^ie(r,22))+Zu(r,i,o)|0;l=u,u=c,c=a,a=s+y|0,s=o,o=i,i=r,r=y+d|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(r,i,o,s,a,c,u,l)}roundClean(){$e.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Ju extends Lo{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 Qu=vi(()=>new Lo);vi(()=>new Ju);var Pe=Symbol("verified"),ef=t=>t instanceof Object;function tf(t){if(!ef(t)||typeof t.kind!="number"||typeof t.content!="string"||typeof t.created_at!="number"||typeof t.pubkey!="string"||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let n=t.tags[e];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]!="string")return!1}return!0}new TextDecoder("utf-8");var nf=new TextEncoder,rf=class{generateSecretKey(){return ut.utils.randomPrivateKey()}getPublicKey(t){return re(ut.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=re(ut.getPublicKey(e)),n.id=wn(n),n.sig=re(ut.sign(wn(n),e)),n[Pe]=!0,n}verifyEvent(t){if(typeof t[Pe]=="boolean")return t[Pe];const e=wn(t);if(e!==t.id)return t[Pe]=!1,!1;try{const n=ut.verify(t.sig,e,t.pubkey);return t[Pe]=n,n}catch{return t[Pe]=!1,!1}}};function of(t){if(!tf(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 wn(t){let e=Qu(nf.encode(of(t)));return re(e)}var tn=new rf;tn.generateSecretKey;tn.getPublicKey;tn.finalizeEvent;var sf=tn.verifyEvent;function Ke(t,e,n){if(Reflect.has(t,e))return Reflect.get(t,e);{const r=n();return Reflect.set(t,e,r),r}}new TextDecoder("utf-8");new TextEncoder;function Lt(t,e){const[n,r]=Tt(t,i=>e.id===i.id?0:e.created_at===i.created_at?-1:i.created_at-e.created_at);return r||t.splice(n,0,e),t}function Tt(t,e){let n=0,r=t.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),o=e(t[i]);if(o===0)return[i,!0];o<0?r=i-1:n=i+1}return[n,!1]}const Jr=Symbol.for("event-store"),Qr=Symbol.for("event-uid"),af=Symbol.for("replaceable-address"),cf=Symbol.for("from-cache"),uf=Symbol.for("replaceable-identifier");function ae(t){return co(t)||uo(t)}function ff(t){let e=Reflect.get(t,Qr);return e||(ae(t.kind)?e=lf(t)??t.id:e=t.id,Reflect.set(t,Qr,e)),e}function lf(t){return ae(t.kind)?Ke(t,af,()=>Je(t.kind,t.pubkey,ze(t))):null}function Je(t,e,n){return t+":"+e+":"+(n??"")}function ze(t){return Ke(t,uf,()=>{var e;return((e=t.tags.find(n=>n[0]==="d"))==null?void 0:e[1])??""})}const wr=Symbol.for("encrypted-content"),To={[Hc]:"nip04",[jc]:"nip44",[zc]:"nip44"};function Oo(t,e){return To[t]=e,t}function df(t){return To[t]!==void 0}function hf(t){return Reflect.get(t,wr)}function Ot(){return Math.round(Date.now()/1e3)}function nn(t,e){return t[0]!==void 0&&t[1]!==void 0&&(e?t[0]===e:!0)}function pf(t){return nn(t,"e")}function Ro(t){return nn(t,"p")}function No(t){return nn(t,"r")}function yf(t){return nn(t,"a")}const Uo=(t,...e)=>e.reduce((n,r)=>{const i=[];for(const o of n)try{const s=r(o);if(s===void 0)continue;i.push(s)}catch{}return i},t);function xt(t){let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),(e.port==="80"&&(e.protocol==="ws:"||e.protocol==="http:")||e.port==="443"&&(e.protocol==="wss:"||e.protocol==="https:"))&&(e.port=""),typeof t=="string"?e.toString():e}const zn=Symbol.for("seen-relays");function ei(t,e){let n=Reflect.get(t,zn);return n?(n.add(e),n):(n=new Set([e]),Reflect.set(t,zn,n),n)}function bf(t){return Reflect.get(t,zn)}const gf=/^wss?:\/\/([-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}|localhost)\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)$/;function Et(t){return t.length>=8&&gf.test(t)}function mr(t){return!t||t.length!==64?!1:!!t.toLowerCase().match(/^[0-9a-f]{64}$/)}function wf(t,e=!1){const n=t.split(":"),r=n[0]?parseInt(n[0]):void 0,i=n[1];if(r===void 0||i===void 0||i===""||!mr(i))return null;const o=n.slice(2).join(":");return e&&o===""?null:{kind:r,pubkey:i,identifier:o}}function mf(t){const e=t[1];if(!e||!mr(e))return null;const n={id:e};return t[2]&&Et(t[2])&&(n.relays=[xt(t[2])]),n}function vf(t){if(!t[1])return null;const e=wf(t[1]);return e?(t[2]&&Et(t[2])&&(e.relays=[xt(t[2])]),e):null}function Mo(t){const e=t[1];if(!e||!mr(e))return null;const n={pubkey:e};return t[2]&&Et(t[2])&&(n.relays=[xt(t[2])]),n}function xf(t){return typeof t=="object"&&t!==null&&"identifier"in t&&"pubkey"in t&&"kind"in t&&typeof t.identifier=="string"&&typeof t.pubkey=="string"&&typeof t.kind=="number"}function dt(t){return typeof t=="object"&&t!==null&&"id"in t&&typeof t.id=="string"}function ti(t,e){return dt(e)?t.id===e.id&&(e.author?t.pubkey===e.author:!0):t.kind===e.kind&&t.pubkey===e.pubkey&&ze(t)===(e.identifier??"")}const ni=wr,Po=new Set([Oo(eu,"nip04")]);function Q(t,e){return Po.add(Oo(t,e)),t}function Ho(t){return df(t)&&Po.has(t)}function Ef(t){if(Ho(t.kind))return ni in t?Reflect.get(t,ni):hf(t)}const kf=10009,mn=Symbol.for("hidden-tags"),Sf=new Set([Q(Dc,"nip04"),Q(Yc,"nip04"),Q(qc,"nip04"),Q(Vc,"nip04"),Q(Kc,"nip04"),Q(Wc,"nip04"),Q(kf,"nip04"),Q(Xc,"nip04"),Q(Zc,"nip04"),Q(Gc,"nip04"),Q(Jc,"nip04"),Q(Qc,"nip04")]);function Af(t){return Ho(t)&&Sf.has(t)}function If(t){if(!Af(t.kind))return;if(mn in t)return t[mn];const e=Ef(t);if(e===void 0)return;const n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Content is not an array of tags");const r=n.filter(i=>Array.isArray(i)).map(i=>i.map(o=>String(o)));return Reflect.set(t,mn,r),r}const $f=Symbol.for("public-contacts"),vn=Symbol.for("hidden-contacts");function Bf(...t){const e=new Map;for(const n of t)if(Array.isArray(n))for(const r of n)r&&e.set(r.pubkey,r);else n&&e.set(n.pubkey,n);return Array.from(e.values())}function _f(t){return Bf(Cf(t),Lf(t))}function Cf(t){return Ke(t,$f,()=>Uo(t.tags,e=>Ro(e)?e:void 0,e=>Mo(e)??void 0))}function Lf(t){if(vn in t)return t[vn];const e=If(t);if(!e)return;const n=Uo(e,r=>Ro(r)?r:void 0,r=>Mo(r)??void 0);return Reflect.set(t,vn,n),n}function Tf(t){return t.tags.filter(pf).map(mf).filter(e=>e!==null).map(e=>(e.author=t.pubkey,e))}function Of(t){return t.tags.filter(yf).map(vf).filter(e=>e!==null).filter(e=>e.pubkey===t.pubkey)}function kt(t){const e=(()=>{});return e.enabled=!1,e.namespace=t,e.log=()=>{},e.extend=(n,r=":")=>kt(`${t}${r}${n}`),e.destroy=()=>!0,e}kt.enable=t=>{};kt.disable=()=>"";kt.enabled=t=>!1;const jo=kt("applesauce");jo.extend("event-cache");const Rf=Symbol("expiration-timestamp");function qn(t){return Ke(t,Rf,()=>{var n;const e=(n=t.tags.find(r=>r[0]==="expiration"))==null?void 0:n[1];return e?parseInt(e):void 0})}function Nf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const ri="abcdefghijklmnopqrstuvwxyz",Fn=new Set((ri+ri.toUpperCase()).split("")),ii=Symbol.for("indexable-tags");function ht(t){let e=Reflect.get(t,ii);if(!e){const n=new Set;for(const r of t.tags)r.length>=2&&r[0].length===1&&Fn.has(r[0])&&n.add(r[0]+":"+r[1]);e=n,Reflect.set(t,ii,n)}return e}function Uf(t,e){if(t.ids&&t.ids.indexOf(e.id)===-1||t.kinds&&t.kinds.indexOf(e.kind)===-1||t.authors&&t.authors.indexOf(e.pubkey)===-1||t.since&&e.created_at<t.since||t.until&&e.created_at>t.until)return!1;for(let n in t)if(n[0]==="&"){let r=n.slice(1),i=t[n];if(i&&i.length>0){const o=ht(e);for(const s of i)if(!o.has(r+":"+s))return!1}}for(let n in t)if(n[0]==="#"){let r=n.slice(1),i=t[n];if(i){const o=`&${r}`,s=t[o],a=s?i.filter(u=>!s.includes(u)):i;if(a.length===0)continue;const c=ht(e);if(a.some(u=>c.has(r+":"+u))===!1)return!1}}return!0}function Dn(t,e){for(let n=0;n<t.length;n++)if(Uf(t[n],e))return!0;return!1}function Mf(t){try{return JSON.parse(t)}catch{return}}class oi{constructor(e=0,n=0,r=!1){k(this,"first",null);k(this,"items",Object.create(null));k(this,"last",null);k(this,"max");k(this,"resetTtl");k(this,"size");k(this,"ttl");this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=r,this.size=0,this.ttl=n}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const n=this.items[e];delete this.items[e],this.size--,n.prev!==null&&(n.prev.next=n.next),n.next!==null&&(n.next.prev=n.prev),this.first===n&&(this.first=n.next),this.last===n&&(this.last=n.prev)}return this}entries(e=this.keys()){return e.map(n=>[n,this.get(n)])}evict(e=!1){if(e||this.size>0){const n=this.first;delete this.items[n.key],--this.size===0?(this.first=null,this.last=null):(this.first=n.next,this.first.prev=null)}return this}expiresAt(e){let n;return this.has(e)&&(n=this.items[e].expiry),n}get(e){let n;if(this.has(e)){const r=this.items[e];this.ttl>0&&r.expiry<=Date.now()?this.delete(e):(n=r.value,this.set(e,n,!0))}return n}has(e){return e in this.items}keys(){const e=[];let n=this.first;for(;n!==null;)e.push(n.key),n=n.next;return e}set(e,n,r=!1,i=this.resetTtl){let o;if(r||this.has(e)){if(o=this.items[e],o.value=n,r===!1&&i&&(o.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==o){const s=this.last,a=o.next,c=o.prev;this.first===o&&(this.first=o.next),o.next=null,o.prev=this.last,s.next=o,c!==null&&(c.next=a),a!==null&&(a.prev=c)}}else this.max>0&&this.size===this.max&&this.evict(!0),o=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:n},++this.size===1?this.first=o:this.last.next=o;return this.last=o,this}values(e=this.keys()){return e.map(n=>this.get(n))}}const Pf=Symbol.for("mailboxes-inboxes"),Hf=Symbol.for("mailboxes-outboxes");function jf(t){return Ke(t,Pf,()=>{const e=[];for(const n of t.tags)if(No(n))try{const[,r,i]=n;r&&Et(r)&&!e.includes(r)&&(i==="read"||i===void 0)&&e.push(xt(r))}catch{}return e})}function zf(t){return Ke(t,Hf,()=>{const e=[];for(const n of t.tags)if(No(n))try{const[r,i,o]=n;r==="r"&&Et(i)&&!e.includes(i)&&(o==="write"||o===void 0)&&e.push(xt(i))}catch{}return e})}const qf=Symbol.for("profile-content");function zo(t){return Ke(t,qf,()=>{var n,r;const e=Mf(t.content);if(e)return e.nip05&&typeof e.nip05!="string"&&(e.nip05=String(e.nip05)),e.website&&((n=e.website)==null?void 0:n.length)>0&&((r=e.website)==null?void 0:r.startsWith("http"))===!1&&(e.website="https://"+e.website),e})}function Ff(t){return!(!t||t.kind!==fo&&t.kind!==tu||!zo(t))}var xn,si;function Df(){if(si)return xn;si=1;function t(s,a){for(;s.length<a;)s="0"+s;return s}function e(s,a){var c,u,l;if(a.length===0)return s;for(c=0,l=a.length;c<l;c++)u=a.charCodeAt(c),s=(s<<5)-s+u,s|=0;return s<0?s*-2:s}function n(s,a,c){return Object.keys(a).sort().reduce(u,s);function u(l,f){return r(l,a[f],f,c)}}function r(s,a,c,u){var l=e(e(e(s,c),i(a)),typeof a);if(a===null)return e(l,"null");if(a===void 0)return e(l,"undefined");if(typeof a=="object"||typeof a=="function"){if(u.indexOf(a)!==-1)return e(l,"[Circular]"+c);u.push(a);var f=n(l,a,u);if(!("valueOf"in a)||typeof a.valueOf!="function")return f;try{return e(f,String(a.valueOf()))}catch(h){return e(f,"[valueOf exception]"+(h.stack||h.message))}}return e(l,a.toString())}function i(s){return Object.prototype.toString.call(s)}function o(s){return t(r(0,s,"",[]).toString(16),8)}return xn=o,xn}var Vf=Df();const Kf=Nf(Vf);class Wf{constructor(){k(this,"deleted$");k(this,"deletedSubject",new ce);k(this,"deletedIds",new Map);k(this,"deletedIdentifiers",new Map);this.deleted$=this.deletedSubject.asObservable()}add(e){if(e.kind!==lo)return[];const n=e.pubkey,r=[],i=Tf(e);if(i.length>0){let s=this.deletedIds.get(n);s||(s=new Set,this.deletedIds.set(n,s));for(const a of i){s.add(a.id);const c={pointer:a,until:e.created_at};r.push(c),this.deletedSubject.next(c)}}const o=Of(e);if(o.length>0){let s=this.deletedIdentifiers.get(n);s||(s=new Map,this.deletedIdentifiers.set(n,s));for(const a of o){const c=a.kind+"|"+a.identifier;s.set(c,e.created_at);const u={pointer:a,until:e.created_at};r.push(u),this.deletedSubject.next(u)}}return r}check(e){const n=e.pubkey;if(co(e.kind)||uo(e.kind)){const r=this.deletedIdentifiers.get(n);if(!r)return!1;const i=ze(e),o=e.kind+"|"+i,s=r.get(o);return s===void 0?!1:s>=e.created_at}else{const r=this.deletedIds.get(n);return r?r.has(e.id):!1}}filter(e){return e.filter(n=>this.check(n)===!1)}}class ai{constructor(){k(this,"log",jo.extend("EventMemory"));k(this,"kinds",new Map);k(this,"authors",new Map);k(this,"tags",new oi);k(this,"created_at",[]);k(this,"kindAuthor",new Map);k(this,"events",new oi);k(this,"replaceable",new Map);k(this,"claims",new WeakMap)}get size(){return this.events.size}hasEvent(e){return this.events.has(e)}getEvent(e){return this.events.get(e)}hasReplaceable(e,n,r){const i=this.replaceable.get(Je(e,n,r));return!!i&&i.length>0}getReplaceable(e,n,r){const i=Je(e,n,r),o=this.replaceable.get(i);return o==null?void 0:o[0]}getReplaceableHistory(e,n,r){const i=Je(e,n,r);return this.replaceable.get(i)}getByFilters(e){return Array.from(this.getEventsForFilters(Array.isArray(e)?e:[e]))}getTimeline(e){const n=[],r=this.getByFilters(e);for(const i of r)Lt(n,i);return n}add(e){var i;const n=e.id,r=this.events.get(n);if(r)return r;this.events.set(n,e),this.getKindIndex(e.kind).add(e),this.getAuthorsIndex(e.pubkey).add(e),this.getKindAuthorIndex(e.kind,e.pubkey).add(e);for(const o of ht(e))this.tags.has(o)&&this.getTagIndex(o).add(e);if(Lt(this.created_at,e),ae(e.kind)){const o=(i=e.tags.find(c=>c[0]==="d"))==null?void 0:i[1],s=Je(e.kind,e.pubkey,o);let a=this.replaceable.get(s);this.replaceable.has(s)||(a=[],this.replaceable.set(s,a)),Lt(a,e)}return e}remove(e){var c;let n=typeof e=="string"?this.events.get(e):e;if(!n)return!1;const r=n.id;if(!this.events.has(r))return!1;const i=this.authors.get(n.pubkey);i&&(i.delete(n),i.size===0&&this.authors.delete(n.pubkey));const o=this.kinds.get(n.kind);o&&(o.delete(n),o.size===0&&this.kinds.delete(n.kind));const s=`${n.kind}:${n.pubkey}`,a=this.kindAuthor.get(s);a&&(a.delete(n),a.size===0&&this.kindAuthor.delete(s));for(const u of ht(n))if(this.tags.has(u)){const l=this.getTagIndex(u);l.delete(n),l.size===0&&this.tags.delete(u)}if(this.removeFromSortedArray(this.created_at,n),this.events.delete(r),ae(n.kind)){const u=(c=n.tags.find(h=>h[0]==="d"))==null?void 0:c[1],l=Je(n.kind,n.pubkey,u),f=this.replaceable.get(l);f&&(this.removeFromSortedArray(f,n),f.length===0&&this.replaceable.delete(l))}return this.claims.delete(n),!0}removeByFilters(e){const n=this.getByFilters(e);let r=0;for(const i of n)this.remove(i)&&r++;return r}update(e){}touch(e){this.events.has(e.id)&&this.events.set(e.id,e)}claim(e){const n=this.claims.get(e)||0;this.claims.set(e,n+1),this.touch(e)}isClaimed(e){const n=this.claims.get(e);return n!==void 0&&n>0}removeClaim(e){const n=this.claims.get(e);if(n!==void 0&&n>0){const r=n-1;r===0?this.claims.delete(e):this.claims.set(e,r)}}clearClaim(e){this.claims.delete(e)}*unclaimed(){let e=0,n=this.events.first;for(;n;){const r=n.value;this.isClaimed(r)||(yield r),n=n.next}return e}prune(e){let n=0;const r=this.unclaimed();for(const i of r)if(this.remove(i),n++,e&&n>=e)break;return n}getKindIndex(e){return this.kinds.has(e)||this.kinds.set(e,new Set),this.kinds.get(e)}getAuthorsIndex(e){return this.authors.has(e)||this.authors.set(e,new Set),this.authors.get(e)}getKindAuthorIndex(e,n){const r=`${e}:${n}`;return this.kindAuthor.has(r)||this.kindAuthor.set(r,new Set),this.kindAuthor.get(r)}getTagIndex(e){if(!this.tags.has(e)){const n=new Set,r=Date.now();for(const o of this.events.values())ht(o).has(e)&&n.add(o);const i=Date.now()-r;i>100&&this.log(`Built index ${e} took ${i}ms`),this.tags.set(e,n)}return this.tags.get(e)}removeFromSortedArray(e,n){if(e.length===0)return;const r=Tt(e,o=>o.created_at-n.created_at);if(r){let o=r[0],s=!1;if(e[o]===n){e.splice(o,1);return}for(let a=o-1;a>=0&&e[a].created_at===n.created_at;a--)if(e[a]===n){e.splice(a,1),s=!0;break}if(s)return;for(let a=o+1;a<e.length&&e[a].created_at===n.created_at;a++)if(e[a]===n){e.splice(a,1);return}}const i=e.indexOf(n);i!==-1&&e.splice(i,1)}*iterateAuthors(e){for(const n of e){const r=this.authors.get(n);if(r)for(const i of r)yield i}}*iterateTag(e,n){for(const r of n){const i=this.getTagIndex(e+":"+r);if(i)for(const o of i)yield o}}*iterateKinds(e){for(const n of e){const r=this.kinds.get(n);if(r)for(const i of r)yield i}}*iterateTime(e,n){if(this.created_at.length===0)return;let r=0,i=this.created_at.length-1,o=n?Tt(this.created_at,a=>a.created_at-n):void 0;o&&(r=Math.max(0,Math.min(o[0],this.created_at.length-1)));const s=e?Tt(this.created_at,a=>a.created_at-e):void 0;if(s&&(i=Math.max(0,Math.min(s[0],this.created_at.length-1))),!(r>i))for(let a=r;a<=i;a++){const c=this.created_at[a];if(!(n!==void 0&&c.created_at>n)){if(e!==void 0&&c.created_at<e)break;yield c}}}*iterateIds(e){for(const n of e)this.events.has(n)&&(yield this.events.get(n))}getEventsForFilter(e){if(e.search)return new Set;let n=!0,r=new Set;const i=s=>{const a=s instanceof Set?s:new Set(s);if(n)r=a,n=!1;else for(const c of r)a.has(c)||r.delete(c);return r};e.ids&&i(this.iterateIds(e.ids));let o=null;e.since!==void 0&&(o=Array.from(this.iterateTime(e.since,e.until)),i(o));for(const s of Fn){const a=`&${s}`,c=e[a];if(c!=null&&c.length)for(const u of c)i(this.iterateTag(s,[u]))}for(const s of Fn){const a=`#${s}`,c=e[a];if(c!=null&&c.length){const u=`&${s}`,l=e[u],f=l?c.filter(h=>!l.includes(h)):c;f.length>0&&i(this.iterateTag(s,f))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<=20){const s=new Set;for(const a of e.kinds)for(const c of e.authors){const u=`${a}:${c}`,l=this.kindAuthor.get(u);if(l)for(const f of l)s.add(f)}i(s)}else e.authors&&i(this.iterateAuthors(e.authors)),e.kinds&&i(this.iterateKinds(e.kinds));if(e.since===void 0&&e.until!==void 0&&(o=Array.from(this.iterateTime(e.since,e.until)),i(o)),n)return new Set(this.events.values());if(e.limit&&o){const s=new Set;for(const a of o){if(s.size>=e.limit)break;r.has(a)&&s.add(a)}return s}return r}getEventsForFilters(e){if(e.length===0)return new Set;let n=new Set;for(const r of e){const i=this.getEventsForFilter(r);for(const o of i)n.add(o)}return n}reset(){this.events.clear(),this.kinds.clear(),this.authors.clear(),this.kindAuthor.clear(),this.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}}function ci(t){return e=>{const n=new Set;return e.pipe(Zt(r=>{if(r!==void 0)if(Array.isArray(r))for(const i of r)n.has(i)||(n.add(i),t.claim(i));else n.has(r)||(n.add(r),t.claim(r))}),Gt(()=>{for(const r of n)t.removeClaim(r)}))}}function qo(t){return e=>{let n;return e.pipe(Zt(r=>{n!==r&&(n&&t.removeClaim(n),r&&t.claim(r),n=r)}),Gt(()=>{n&&t.removeClaim(n)}))}}function Yf(t,e){const n=t.getEvent(e.id);return n instanceof Promise?V(n):bt(n)}function Gf(t,e){const n=t.getReplaceable(e.kind,e.pubkey,e.identifier);return n instanceof Promise?V(n):bt(n)}function Zf(t,e){const n=t.getByFilters(e);return n instanceof Promise?V(n).pipe(Wt(r=>V(r))):V(n)}function Fo(t,e){return La(n=>n||!t.eventLoader?bt(n):V(t.eventLoader(e)).pipe(Ca(void 0)))}function Xf(t){return typeof t=="string"&&(t={id:t}),e=>nt(st(()=>Yf(e,t)).pipe(e.eventLoader?Fo(e,t):me),e.insert$.pipe(pe(n=>n.id===t.id)),e.remove$.pipe(pe(n=>n.id===t.id),Sa(1),fe(()=>{}))).pipe(Yt((n,r)=>(n==null?void 0:n.id)===(r==null?void 0:r.id)),qo(e))}function Jf(t){return e=>{let n;return nt(st(()=>Gf(e,t)).pipe(e.eventLoader?Fo(e,t):me),e.insert$.pipe(pe(r=>r.pubkey==t.pubkey&&r.kind===t.kind&&(t.identifier!==void 0?ze(r)===t.identifier:!0)))).pipe(Zt(r=>n=r),Cn(e.remove$.pipe(pe(r=>r.id===(n==null?void 0:n.id)),fe(()=>{}))),Yt((r,i)=>r===void 0||i===void 0?r===i:i.created_at<r.created_at),qo(e))}}function Qf(t,e){return t=Array.isArray(t)?t:[t],n=>{const r=new Map,i=o=>e?o.id:ff(o);return st(()=>{const o=n.getTimeline(t);return o instanceof Promise?V(o):bt(o)}).pipe(ci(n),Cn(n.insert$.pipe(pe(o=>Dn(t,o)),ci(n))),Cn(n.remove$.pipe(pe(o=>Dn(t,o)),fe(o=>o.id))),Ba((o,s)=>{var l;if(typeof s=="string"){const f=o.find(h=>h.id===s);if(f){const h=i(f);((l=r.get(h))==null?void 0:l.id)===s&&r.delete(h)}return o.filter(h=>h.id!==s)}if(Array.isArray(s)){r.clear();for(const f of s)r.set(i(f),f);return[...s]}let a=[...o];const c=i(s),u=r.get(c);if(u&&(!ae(s.kind)||!e&&s.created_at<u.created_at))return[...o];if(!e&&ae(s.kind)){if(r.set(c,s),u){const f=a.indexOf(u);f!==-1&&a.splice(f,1)}}else r.set(c,s);return Lt(a,s),a},[]),Yt(),Gt(()=>r.clear()))}}function el(t,e=!1){return t=Array.isArray(t)?t:[t],n=>{const r=e?er:st(()=>Zf(n,t)),i=n.insert$.pipe(pe(o=>Dn(t,o)));return nt(r,i)}}function tl(t){return e=>{let n;return nt(e.pipe(Zt(r=>n=r)),t.update$.pipe(pe(r=>r.id===(n==null?void 0:n.id))))}}function nl(t){return typeof t=="string"&&(t={pubkey:t}),e=>e.replaceable({kind:Pc,pubkey:t.pubkey,relays:t.relays}).pipe(tl(e),fe(n=>n?_f(n):[]))}function rl(t){return typeof t=="string"&&(t={pubkey:t}),e=>e.replaceable({kind:Fc,pubkey:t.pubkey,relays:t.relays}).pipe(fe(n=>n&&{inboxes:jf(n),outboxes:zf(n)}))}function il(t){return typeof t=="string"&&(t={pubkey:t}),e=>e.replaceable({kind:fo,pubkey:t.pubkey,relays:t.relays}).pipe(pe(Ff),fe(n=>n&&zo(n)))}class ol{constructor(){k(this,"models",new Map);k(this,"modelKeepWarm",6e4);k(this,"destroy$",new Rr(1))}model(e,...n){let r=this.models.get(e);r||(r=new Map,this.models.set(e,r));const i=e.getKey?e.getKey(...n):Kf(n);let o=r.get(i);if(!o){const s=()=>{r.get(i)===o&&r.delete(i)};o=e(...n)(this).pipe(Gt(s),_a({connector:()=>new Rr(1),resetOnComplete:()=>nt(Mt(this.modelKeepWarm),this.destroy$),resetOnRefCountZero:()=>nt(Mt(this.modelKeepWarm),this.destroy$)}),Ta(this.destroy$)),r.set(i,o)}return o}filters(e,n=!1){return Array.isArray(e)||(e=[e]),this.model(el,e,n)}event(e){return typeof e=="string"||dt(e)?this.model(Xf,e):this.replaceable(e)}replaceable(...e){let n;if(e.length===1)n=e[0];else if(e.length===3||e.length===2){let[r,i,o]=e;n={kind:r,pubkey:i,identifier:o}}if(!n)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(Jf,n)}addressable(e){return this.replaceable(e)}timeline(e,n=!1){return this.model(Qf,e,n)}profile(e){return this.model(il,e)}contacts(e){return typeof e=="string"&&(e={pubkey:e}),this.model(nl,e)}mailboxes(e){return typeof e=="string"&&(e={pubkey:e}),this.model(rl,e)}dispose(){this.destroy$.next(),this.destroy$.complete()}}class sl{constructor(){k(this,"expired$");k(this,"expiredSubject");k(this,"expirations",new Map);k(this,"timer",null);k(this,"nextCheck",null);this.expiredSubject=new ce,this.expired$=this.expiredSubject.asObservable()}track(e){const n=qn(e);if(!n||!Number.isFinite(n))return;const r=Ot();if(n<=r||(this.expirations.set(e.id,n),this.timer&&this.nextCheck&&this.nextCheck<=n))return;this.timer&&clearTimeout(this.timer);const i=n-r;i>0&&(this.timer=setTimeout(this.emitNotifications.bind(this),i*1e3+10),this.nextCheck=n)}forget(e){this.expirations.delete(e)}check(e){const n=qn(e);return n?n<=Ot():!1}dispose(){this.timer&&clearTimeout(this.timer),this.timer=null,this.nextCheck=null,this.expirations.clear(),this.expiredSubject.complete()}[Symbol.dispose](){this.dispose()}emitNotifications(){const e=Ot();let n=1/0;for(const[r,i]of this.expirations)i<=e?(this.expirations.delete(r),this.expiredSubject.next(r)):i<n&&(n=i);if(n!==1/0){this.timer&&clearTimeout(this.timer),this.nextCheck=null,this.timer=null;const r=n-e;r>0&&(this.timer=setTimeout(this.emitNotifications.bind(this),r*1e3+10),this.nextCheck=n)}}}class pt extends ol{constructor(n){super();k(this,"database");k(this,"memory");k(this,"deletes");k(this,"expiration");k(this,"keepOldVersions",!1);k(this,"keepExpired",!1);k(this,"keepDeleted",!1);k(this,"_verifyEventMethod",sf);k(this,"insert$",new ce);k(this,"update$",new ce);k(this,"remove$",new ce);k(this,"eventLoader");k(this,"internalSubscriptions",new we);n!=null&&n.database?(this.database=n.database,this.memory=new ai):this.database=this.memory=new ai,(n==null?void 0:n.keepDeleted)!==void 0&&(this.keepDeleted=n.keepDeleted),(n==null?void 0:n.keepExpired)!==void 0&&(this.keepExpired=n.keepExpired),(n==null?void 0:n.keepOldVersions)!==void 0&&(this.keepOldVersions=n.keepOldVersions),n!=null&&n.verifyEvent&&(this.verifyEvent=n.verifyEvent),this.deletes=(n==null?void 0:n.deleteManager)??new Wf,this.internalSubscriptions.add(this.deletes.deleted$.subscribe(this.handleDeleteNotification.bind(this))),this.expiration=(n==null?void 0:n.expirationManager)??new sl,this.internalSubscriptions.add(this.expiration.expired$.subscribe(this.handleExpiredNotification.bind(this)))}get verifyEvent(){return this._verifyEventMethod}set verifyEvent(n){this._verifyEventMethod=n,n===void 0&&console.warn("[applesauce-core] EventStore.verifyEvent is undefined; signature checks are disabled.")}mapToMemory(n){if(n!==void 0)return this.memory?this.memory.add(n):n}handleDeleteNotification({pointer:n,until:r}){if(!this.keepDeleted){if(dt(n)){const i=this.getEvent(n.id);i&&r>=i.created_at&&ti(i,n)&&this.remove(i)}else if(xf(n)){const i=this.getReplaceableHistory(n.kind,n.pubkey,n.identifier);if(i)for(const o of i)r>=o.created_at&&ti(o,n)&&this.remove(o)}}}handleExpiredNotification(n){this.keepExpired||this.remove(n)}static copySymbolsToDuplicateEvent(n,r){if(n.kind!==r.kind)throw new Error("Source and destination events must have the same kind");if(Mc(n.kind)&&n.id!==r.id)throw new Error("Source and destination events must have the same ID");if(ae(n.kind)&&n.pubkey!==r.pubkey&&ze(n)!==ze(r))throw new Error("Source and destination events must have the same pubkey and replaceable identifier");let i=!1;const o=bf(n);if(o){for(const a of o)ei(r,a);i=!0}const s=[cf,Pe,wr];for(const a of s)a in n&&!(a in r)&&(Reflect.set(r,a,Reflect.get(n,a)),i=!0);return i}add(n,r){if(n.kind===lo)return this.deletes.add(n),n;if(this.deletes.check(n))return n;const i=qn(n);if(this.keepExpired===!1&&i&&i<=Ot())return null;r&&ei(n,r);const o=ae(n.kind)?ze(n):void 0;if(this.keepOldVersions===!1&&ae(n.kind)){const c=this.database.getReplaceableHistory(n.kind,n.pubkey,o);if(c&&c.length>0){let u=c[0];for(const f of c)(f.created_at>u.created_at||f.created_at===u.created_at&&f.id<u.id)&&(u=f);if(!(n.created_at>u.created_at||n.created_at===u.created_at&&n.id<u.id))return pt.copySymbolsToDuplicateEvent(n,u)&&this.update(u),u}}if(this.verifyEvent&&this.verifyEvent(n)===!1)return null;const s=this.memory.add(n);if(s&&s!==n)return pt.copySymbolsToDuplicateEvent(n,s)&&this.update(s),s;const a=this.mapToMemory(this.database.add(n));if(a===n?(Reflect.set(a,Jr,this),this.insert$.next(a)):pt.copySymbolsToDuplicateEvent(n,a)&&this.update(a),this.keepOldVersions===!1&&ae(n.kind)){const c=this.database.getReplaceableHistory(n.kind,n.pubkey,o);if(c&&c.length>0){let u=c[0];for(const f of c)(f.created_at>u.created_at||f.created_at===u.created_at&&f.id<u.id)&&(u=f);const l=c.filter(f=>f!==u);for(const f of l)this.remove(f);if(l.length>0)return u}}return this.keepExpired===!1&&i!==void 0&&this.expiration.track(a),a}remove(n){const r=typeof n=="string"?n:n.id;let i=this.memory.getEvent(r);this.expiration.forget(r),i&&Reflect.deleteProperty(i,Jr),this.memory!==this.database&&this.memory.remove(n);const o=this.database.remove(n);return o&&i&&this.remove$.next(i),o}removeByFilters(n){const r=this.getByFilters(n);for(const o of r)this.expiration.forget(o.id);this.memory!==this.database&&this.memory.removeByFilters(n);const i=this.database.removeByFilters(n);for(const o of r)this.remove$.next(o);return i}update(n){var i,o;return this.database.add(n)?((o=(i=this.database).update)==null||o.call(i,n),this.update$.next(n),!0):!1}hasEvent(n){return typeof n=="string"?this.memory.hasEvent(n)||this.database.hasEvent(n):dt(n)?this.memory.hasEvent(n.id)||this.database.hasEvent(n.id):this.hasReplaceable(n.kind,n.pubkey,n.identifier)}getEvent(n){return typeof n=="string"?this.memory.getEvent(n)??this.mapToMemory(this.database.getEvent(n)):dt(n)?this.memory.getEvent(n.id)??this.mapToMemory(this.database.getEvent(n.id)):this.getReplaceable(n.kind,n.pubkey,n.identifier)}hasReplaceable(n,r,i){return this.memory.hasReplaceable(n,r,i)||this.database.hasReplaceable(n,r,i)}getReplaceable(n,r,i){return this.memory.getReplaceable(n,r,i)??this.mapToMemory(this.database.getReplaceable(n,r,i))}getReplaceableHistory(n,r,i){var o;return this.memory.getReplaceableHistory(n,r,i)??((o=this.database.getReplaceableHistory(n,r,i))==null?void 0:o.map(s=>this.mapToMemory(s)??s))}getByFilters(n){const r=this.database.getByFilters(n);return this.memory?r.map(i=>this.mapToMemory(i)):r}getTimeline(n){const r=this.database.getTimeline(n);return this.memory?r.map(i=>this.mapToMemory(i)):r}touch(n){return this.memory.touch(n)}claim(n){return this.memory.claim(n)}isClaimed(n){return this.memory.isClaimed(n)??!1}removeClaim(n){return this.memory.removeClaim(n)}clearClaim(n){return this.memory.clearClaim(n)}unclaimed(){return this.memory.unclaimed()||(function*(){})()}prune(n){return this.memory.prune(n)??0}dispose(){var r,i;const n=this.eventLoader;n&&typeof n[Symbol.dispose]=="function"&&n[Symbol.dispose](),this.eventLoader=void 0,super.dispose(),this.internalSubscriptions.unsubscribe(),(i=(r=this.expiration).dispose)==null||i.call(r),this.insert$.complete(),this.update$.complete(),this.remove$.complete()}[Symbol.dispose](){this.dispose()}}function al(){return new pt({verifyEvent:t=>za(t)})}function cl(t,e){return t?{follows:Qi(t),known:!0,source:"contacts"}:e!=null&&e.length?{follows:[...new Set(e)],known:!0,source:"identity"}:{follows:[],known:!1,source:"none"}}function ul(t,e){return t.known===e.known&&t.source===e.source&&t.follows.length===e.follows.length&&t.follows.every((n,r)=>n===e.follows[r])}function fl(t,e,n){return ga([t.replaceable(he,e),n]).pipe(fe(([r,i])=>cl((r==null?void 0:r.pubkey)===e?r:void 0,i)),Yt(ul))}function ll(t,e){const n=[];for(const r of e){const i=qa(r);if(!i)continue;const o=t.get(i.pubkey);o&&o.createdAt>=i.createdAt||(t.set(i.pubkey,i),(!o||o.name!==i.name||o.displayName!==i.displayName||o.picture!==i.picture||o.about!==i.about||o.nip05!==i.nip05||o.banner!==i.banner||o.website!==i.website||o.lud16!==i.lud16)&&n.push(i.pubkey))}return n}const St=al();function qt(t){if(!(!t||!Ji(t.pubkey)))return St.add(t)??void 0}const Ne=new Map,dl=St.timeline({kinds:[ir]}).pipe(fe(t=>ll(Ne,t)));function hl(t){return St.replaceable(he,t)}const De=new _n(!1);function pl(){oo().then(t=>{t&&!De.value&&De.next(!0)})}function yl(t,e,n){return ao([{kinds:[ir,he,Ha],authors:[t]}],{authors:[t],relays:e,...n?{onNotice:n}:{}}).subscribe(r=>qt(r))}function bl(t,e){const n=new we;n.add(ao([{kinds:[he],authors:[t]}],{authors:[t]}).subscribe(i=>qt(i)));const r=new _n({follows:[],known:!1,source:"none"});return n.add(fl(St,t,new _n(void 0)).subscribe(i=>r.next(i))),{me:t,follows$:r,close:()=>n.unsubscribe()}}async function gl(t,e,n){try{const o=await oa(Uc([{kinds:[he],authors:[t],limit:1}],{authors:[t],timeoutMs:8e3}).pipe(ka()),{defaultValue:[]});for(const s of o)s.kind===he&&s.pubkey===t&&qt(s)}catch{}const r=St.getReplaceable(he,t);if(!r)return{ok:!1,error:"Couldn't load your follow list, so it was left as it is."};const i=await Ic(Fa(r,e,n));return i.ok&&qt(i.event),i}function S(t,e=null,...n){const r=document.createElement(t);if(e)for(const[i,o]of Object.entries(e))r.setAttribute(i,o);for(const i of n)i!=null&&i!==!1&&r.append(i);return r}const rn=t=>document.getElementById(t),wl={back:'<path d="M15 5l-7 7 7 7"/>',globe:'<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c2.5 2.6 3.8 5.6 3.8 9s-1.3 6.4-3.8 9c-2.5-2.6-3.8-5.6-3.8-9S9.5 5.6 12 3z"/>',copy:'<rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V6a2 2 0 0 1 2-2h9"/>',check:'<path d="M5 12.5l4.5 4.5L19 7.5"/>',bolt:'<path d="M13 3 5 13.5h6L10 21l8-10.5h-6z"/>',verified:'<path fill="currentColor" stroke="none" d="M12 2.5l2.4 1.8 3-.1.9 2.9 2.4 1.8-1 2.9 1 2.9-2.4 1.8-.9 2.9-3-.1L12 21.5l-2.4-1.8-3 .1-.9-2.9-2.4-1.8 1-2.9-1-2.9 2.4-1.8.9-2.9 3 .1z"/><path d="M8.3 12.2l2.5 2.5 4.9-5" style="stroke: var(--bg)" stroke-width="2" fill="none"/>'};function qe(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");return e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("aria-hidden","true"),e.classList.add("icon"),e.innerHTML=wl[t],e}class ml{constructor(e,n=4){k(this,"done",new Map);k(this,"failed",new Map);k(this,"jobs",new Map);k(this,"running",0);this.load=e,this.max=n}loaded(e){return this.done.get(e)}hasFailed(e){return this.failed.has(e)}get stats(){return{running:this.running,queued:this.jobs.size-this.running}}want(e,n){const r=this.done.get(e);if(r!==void 0)return n.ready(r),()=>{};if(this.failed.has(e))return n.fail(this.failed.get(e)),()=>{};let i=this.jobs.get(e);i||this.jobs.set(e,i={key:e,waiters:new Set,running:!1}),i.waiters.add(n),this.pump();const o=i;return()=>this.release(o,n)}release(e,n){var r;!e.waiters.delete(n)||e.waiters.size>0||(e.running?(r=e.controller)==null||r.abort():this.jobs.get(e.key)===e&&this.jobs.delete(e.key))}next(){let e;for(const n of this.jobs.values())if(!n.running){for(const r of n.waiters)if(r.isVisible())return n;e??(e=n)}return e}pump(){for(;this.running<this.max;){const e=this.next();if(!e)return;this.start(e)}}start(e){const n=new AbortController;e.running=!0,e.controller=n,this.running++,this.load(e.key,n.signal).then(r=>{this.done.set(e.key,r),this.finish(e);for(const i of e.waiters)i.ready(r)},r=>{if(n.signal.aborted){this.running--,e.running=!1,e.controller=void 0,e.waiters.size===0&&this.jobs.delete(e.key),this.pump();return}this.failed.set(e.key,r),this.finish(e);for(const i of e.waiters)i.fail(r)})}finish(e){this.running--,this.jobs.delete(e.key),this.pump()}}const vl=300,xl=4;async function El(t){const e=t.type.toLowerCase();if(e.includes("svg")||e&&!e.startsWith("image/")&&e!=="application/octet-stream")return!1;const n=new TextDecoder().decode(await t.slice(0,1024).arrayBuffer()).toLowerCase();return!n.includes("<svg")&&!n.trimStart().startsWith("<?xml")&&!n.trimStart().startsWith("<")}function kl(t){return Ua(t)??t}const Vn=new Map,Kn=new ml(async(t,e)=>{if(!z("resource","bytes"))throw new Error("no resource domain");const n=await ro(Vn.get(t)??t,{signal:e});if(n.size===0||!await El(n))throw new Error("not a raster image");return URL.createObjectURL(n)},xl);function Do(t){const e=kl(t);return Vn.has(e)||Vn.set(e,t),e}const Vo=new WeakMap,_e=new WeakMap,ui=new Set;function Sl(t){if(!t.isConnected)return!1;const e=t.getBoundingClientRect();return e.bottom>0&&e.top<(window.innerHeight||0)&&e.width+e.height>0}function on(t,e){const n=t.parentElement;!n||n.classList.contains("avatar")||n.classList.toggle("is-loading",e)}function Al(t,e){_e.delete(t),Le==null||Le.unobserve(t);const n=()=>{t.src=e,t.classList.add("loaded"),on(t,!1)};if(ui.has(e)||typeof Image!="function"){n();return}const r=new Image;r.decoding="async",r.src=e,(typeof r.decode=="function"?r.decode():Promise.resolve()).catch(()=>{}).then(()=>{ui.add(e),n()})}function Il(t){var e;_e.delete(t),Le==null||Le.unobserve(t),on(t,!1),(e=Vo.get(t))==null||e(t)}function Ko(t){const e=t.dataset.res;if(!e||_e.has(t)||t.classList.contains("loaded"))return;_e.set(t,()=>{}),on(t,!0);const n=Kn.want(Do(e),{isVisible:()=>Sl(t),ready:r=>Al(t,r),fail:()=>Il(t)});_e.has(t)&&_e.set(t,n)}function $l(t){const e=_e.get(t);e&&(_e.delete(t),on(t,!1),e())}const Le=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{for(const e of t){const n=e.target;e.isIntersecting?Ko(n):$l(n)}},{rootMargin:`${vl}px 0px`}):void 0;function Wo(t,e,n){t.dataset.res=e,t.decoding="async",n&&Vo.set(t,n);const r=Do(e),i=Kn.loaded(r);if(i!==void 0){t.src=i,t.classList.add("loaded");return}if(Kn.hasFailed(r)){queueMicrotask(()=>n==null?void 0:n(t));return}Le?Le.observe(t):Ko(t)}const Qe=/^[0-9a-f]{64}$/i,Bl=/^wss?:\/\/\S+$/;function Wn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&Bl.test(e)).slice(0,5):[]}function fi(t){const e=t.trim().replace(/^nostr:/i,"");if(Qe.test(e))return{id:e.toLowerCase(),relays:[]};if(!/^(note|nevent|naddr)1[023456789acdefghjklmnpqrstuvwxyz]+$/i.test(e))return null;try{const n=Kt(e.toLowerCase());if(n.type==="note")return{id:n.data,relays:[]};if(n.type==="nevent")return{id:n.data.id,relays:Wn(n.data.relays),...n.data.author?{author:n.data.author}:{},...n.data.kind!==void 0?{kind:n.data.kind}:{}};if(n.type==="naddr")return{relays:Wn(n.data.relays),author:n.data.pubkey,kind:n.data.kind,address:{kind:n.data.kind,pubkey:n.data.pubkey,identifier:n.data.identifier}}}catch{}return null}function Yo(t,e=0){if(typeof t=="string")return fi(t);if(typeof t!="object"||t===null||e>2)return null;const n=t;if(n.target!==void 0){const s=Yo(n.target,e+1);if(s)return s}let r=null;for(const s of["id","eventId","event_id","note","nevent","naddr","uri","url","value"])if(typeof n[s]=="string"&&(r=fi(n[s]),r))break;if(!r&&typeof n.event=="object"&&n.event!==null){const s=n.event;typeof s.id=="string"&&Qe.test(s.id)&&(r={id:s.id.toLowerCase(),relays:[],...typeof s.pubkey=="string"&&Qe.test(s.pubkey)?{author:s.pubkey.toLowerCase()}:{}})}if(!r&&typeof n.kind=="number"&&typeof n.pubkey=="string"&&Qe.test(n.pubkey)&&typeof n.identifier=="string"&&(r={relays:[],author:n.pubkey.toLowerCase(),kind:n.kind,address:{kind:n.kind,pubkey:n.pubkey.toLowerCase(),identifier:n.identifier}}),!r)return null;const i=[...new Set([...r.relays,...Wn(n.relays)])].slice(0,5),o=r.author??(typeof n.author=="string"&&Qe.test(n.author)?n.author.toLowerCase():typeof n.pubkey=="string"&&Qe.test(n.pubkey)?n.pubkey.toLowerCase():void 0);return{...r,relays:i,...o?{author:o}:{}}}const lt=50,_l=/^[a-z0-9-]{1,13}$/,Cl=/^[0-9a-z]+$/,Ll=(BigInt(1)<<BigInt(256))-BigInt(1);function Tl(t){if(t.length!==lt||!Cl.test(t))return null;let e=BigInt(0);const n=BigInt(36);for(const r of t)e=e*n+BigInt(parseInt(r,36));return e>Ll?null:e.toString(16).padStart(64,"0")}function Ol(t){return _l.test(t)&&!t.endsWith("-")}function Rl(t){const e=t.toLowerCase();if(e.startsWith("npub1"))try{const i=Kt(e);if(i.type==="npub")return{pubkey:i.data}}catch{}if(e.length<=lt||e.length>lt+13)return null;const n=e.slice(lt);if(!Ol(n))return null;const r=Tl(e.slice(0,lt));return r?{pubkey:r,identifier:n}:null}function Nl(t){const e=t.toLowerCase().replace(/\.$/,""),n=e.indexOf(".");if(n<=0)return null;const r=e.slice(0,n),i=e.slice(n+1),o=i.split(".");return i==="nsite"||o.length>=2&&o.some(a=>a.includes("nsite"))?{label:r,gateway:i}:null}function Ul(t){const e=Nl(t);return!!e&&Rl(e.label)!==null}const Ml=new RegExp("(https?:\\/\\/[^\\s<>\"'`]+)|nostr:((?:npub1|nprofile1|note1|nevent1|naddr1)[023456789acdefghjklmnpqrstuvwxyz]+)|(blossom:(?:sha256:)?[0-9a-f]{64}(?:\\.[a-z0-9]{1,8})?(?:\\?[^\\s<>\"'`]*)?)|((?<![\\w@.\\/:%+-])(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,24}(?::\\d{1,5})?(?:\\/[^\\s<>\"'`]*)?)","gi"),Pl=/[.,;:!?)\]}'"]+$/;function Hl(t){try{const e=Kt(t);if(e.type==="npub")return{pubkey:e.data,relays:[]};if(e.type==="nprofile")return{pubkey:e.data.pubkey,relays:e.data.relays??[]}}catch{}return null}function Go(t,e){const n=e?{imeta:e}:{},r=Ma(e==null?void 0:e.m),i=Zi(e==null?void 0:e.m);return r||r===void 0&&i===void 0&&Xi(t)?{type:"video",url:t,...n}:i??(Pa(t)||Wi(t))?{type:"image",url:t,...n}:null}function jl(t,e){return Go(t,e.get(t))??{type:"link",url:t}}function zl(t){return Xt(t)?Xi(t)?{type:"video",url:t}:Wi(t)?{type:"image",url:t}:null:null}function ql(t,e){const n=`https://${t}`;let r;try{r=new URL(n)}catch{return null}if(r.pathname.length>1){const i=Go(n,e.get(n)??e.get(t));if(i)return i}return Ul(r.hostname)?{type:"link",url:n}:null}function Fl(t,e=new Map){var o;const n=[],r=s=>{if(!s)return;const a=n[n.length-1];(a==null?void 0:a.type)==="text"?a.text+=s:n.push({type:"text",text:s})};let i=0;for(const s of t.matchAll(Ml)){const a=s.index??0;if(r(t.slice(i,a)),i=a+s[0].length,s[1]||s[3]||s[4]){let c=s[0];const u=((o=Pl.exec(c))==null?void 0:o[0])??"";u&&(c=c.slice(0,-u.length));const l=s[1]?jl(c,e):s[3]?zl(c):ql(c,e);l?n.push(l):r(c),r(u)}else if(/^n(?:pub|profile)1/i.test(s[2])){const c=Hl(s[2]);c?n.push({type:"profile",...c,text:s[0]}):r(s[0])}else{const c=Yo(s[2]);c?n.push({type:"note",pointer:c,text:s[0]}):r(s[0])}}return r(t.slice(i)),n}const Zo={openProfile:(t,e)=>{}};function Dl(t){const e=Ai(t);return`${e.slice(0,10)}…${e.slice(-4)}`}function At(t){const e=Ne.get(t);return(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Dl(t)}function Vl(t,e){const n=S("span",{class:`avatar avatar-${e}`,"data-pk":t,"data-role":"avatar"});return vr(n,t),n}const Kl="🥀";function vr(t,e){var u;const n=(At(e).replace(/^npub1/,"")[0]??"?").toUpperCase(),r=S("span",{class:"avatar-initial"},n);t.replaceChildren(r),t.classList.remove("avatar-wilted"),t.style.setProperty("--hue",String(parseInt(e.slice(0,4),16)%360));const i=(u=Ne.get(e))==null?void 0:u.picture;if(!i)return;const o=()=>{r.textContent=Kl,t.classList.add("avatar-wilted")},s=Ki(i,null,e),a=s?Gi(s):De.value&&i.startsWith("https://")?i:null;if(!a){o();return}const c=S("img",{alt:"",decoding:"async"});t.append(c),Wo(c,a,l=>{l.remove(),o()})}function Wl(t){for(const e of document.querySelectorAll(`[data-pk="${t}"]`)){const n=e.dataset.role;n==="name"?e.textContent=At(t):n==="avatar"&&vr(e,t)}}De.subscribe(t=>{if(t)for(const e of document.querySelectorAll('[data-role="avatar"][data-pk]'))e.querySelector("img")||vr(e,e.dataset.pk)});function Xo(t,e){const n=e??t.replace(/^https?:\/\//,"");if(!z("link","open"))return S("span",{class:"link-text"},n);const r=S("button",{type:"button",class:"link"},n);return r.addEventListener("click",async i=>{i.stopPropagation(),await Tc(t)||r.classList.add("link-refused")}),r}function Yl(t,e,...n){const r=S("button",{type:"button",class:"profile-link","aria-label":`Open profile of ${At(t)}`},...n);return r.addEventListener("click",i=>{i.stopPropagation(),Zo.openProfile(t,e)}),r}function Gl(t){const e=t.replace(/^nostr:/,"");return e.length>20?`${e.slice(0,12)}…${e.slice(-4)}`:e}function Zl(t){const e=S("div",{class:"content"});for(const i of Fl(t))if(i.type==="text")e.append(i.text);else if(i.type==="link"||i.type==="image"||i.type==="video")e.append(i.url.startsWith("https://")||i.url.startsWith("http://")?Xo(i.url):S("span",{class:"link-text"},i.url));else if(i.type==="profile"){const o=S("span",{"data-pk":i.pubkey,"data-role":"name"},At(i.pubkey));e.append(Yl(i.pubkey,i.relays,"@",o))}else e.append(S("span",{class:"link-text"},Gl(i.text)));const n=e.firstChild,r=e.lastChild;return n instanceof Text&&(n.data=n.data.replace(/^\s+/,"")),r instanceof Text&&(r.data=r.data.replace(/\s+$/,"")),e}const Xl={background:"#ffffff",text:"#0f172a",primary:"#059669"},Jl={background:"#000000",text:"#ffffff",primary:"#34d399"},Ql=/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;function Ft(t){let e=t.slice(1);return e.length===3&&(e=[...e].map(n=>n+n).join("")),[0,2,4].map(n=>parseInt(e.slice(n,n+2),16))}function li(t){const[e,n,r]=Ft(t).map(i=>{const o=i/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*e+.7152*n+.0722*r}function di(t,e,n){const[r,i]=[Ft(t),Ft(n)],o=s=>Math.round((r[s]*e+i[s]*(100-e))/100);return`rgb(${o(0)}, ${o(1)}, ${o(2)})`}function En(t,e){const[n,r,i]=Ft(t);return`rgba(${n}, ${r}, ${i}, ${e/100})`}function Xe(t){var l,f,h,y;const n=((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-color-scheme: dark)").matches)??!1?Jl:Xl,r=(p,d)=>p&&Ql.test(p)?p:d,i=r((f=t==null?void 0:t.colors)==null?void 0:f.background,n.background),o=r((h=t==null?void 0:t.colors)==null?void 0:h.text,n.text),s=r((y=t==null?void 0:t.colors)==null?void 0:y.primary,n.primary),a=li(i)<.35,c=document.documentElement,u=(p,d)=>c.style.setProperty(p,d);u("--bg",i),u("--text",o),u("--primary",s),u("--on-primary",li(s)>.45?"#000000":"#ffffff"),u("--surface",di(o,a?8:4,i)),u("--border",En(o,a?18:12)),u("--muted",di(o,60,i)),u("--primary-soft",En(s,16)),u("--scrim",En("#000000",a?70:45)),c.style.colorScheme=a?"dark":"light"}function hi(){var t;if(Xe(void 0),!z("theme","get")){(t=window.matchMedia)==null||t.call(window,"(prefers-color-scheme: dark)").addEventListener("change",()=>Xe(void 0));return}try{rc().then(Xe,()=>Xe(void 0)),ic(Xe)}catch{Xe(void 0)}}const F=[];let Dt=0,kn=new we,se="",Be,Yn=!1,pi=0;const ed=Date.now();let sn=!1;const xr=new Map,Jo=new ce,yi=rn("status"),td=rn("signin"),ft=rn("view"),Qo=rn("pasteBar");function Er(t){yi.textContent=t??"",yi.hidden=!t}function It(){return F[F.length-1]}function es(t){const e=It();e&&(e.scrollY=window.scrollY),F.push(t);try{history.pushState({simpleprofilePage:F.length},""),Dt++}catch{}$t()}function ts(t){F.splice(0,F.length,...t?[t]:[]),$t()}function ns(){if(!(F.length<2)){if(Dt>0){history.back();return}rs()}}function rs(){var t;F.length<2||(F.pop(),$t((t=It())==null?void 0:t.scrollY))}window.addEventListener("popstate",()=>{Dt>0&&Dt--,rs()});document.addEventListener("keydown",t=>{t.key!=="Escape"||F.length<2||(sn=!0,ns(),t.preventDefault())});function is(t,e){var n;if(sn=!0,((n=It())==null?void 0:n.pubkey)===t){window.scrollTo({top:0,behavior:"smooth"});return}es({pubkey:t,relays:e.slice(0,ar),scrollY:0})}Zo.openProfile=is;function nd(t){const e=cr(t);if(!e)return;const n=It();if((n==null?void 0:n.pubkey)===e.pubkey){const o=[...new Set([...n.relays,...e.relays])].slice(0,ar);o.length!==n.relays.length&&(n.relays=o,$t(window.scrollY));return}const r={pubkey:e.pubkey,relays:e.relays,scrollY:0};F.length===0||F.length===1&&F[0].home&&!sn&&Date.now()-ed<3e3?ts(r):es(r)}function $t(t){var n;kn.unsubscribe(),kn=new we;const e=It();td.hidden=!!e||!Yn||!!se,ft.hidden=!e,ft.replaceChildren(),Qo.hidden=!Yn&&!e,e&&(Er(null),F.length>1&&ft.append(rd()),ft.append(sd(e,kn)),window.scrollTo(0,t??0),(n=ft.querySelector(".back"))==null||n.focus({preventScroll:!0}))}function rd(){const t=S("button",{type:"button",class:"back","aria-label":"Back"},qe("back"),S("span",null,"Back"));return t.addEventListener("click",()=>{sn=!0,ns()}),S("div",{class:"detail-bar"},t)}function id(){const t=S("input",{type:"text",class:"paste-input",placeholder:"Paste an npub or nprofile","aria-label":"npub or nprofile",autocomplete:"off",autocapitalize:"off",spellcheck:"false",enterkeyhint:"go"}),e=S("button",{type:"submit",class:"paste-go"},"Open"),n=S("div",{class:"paste-note",role:"status","aria-live":"polite"}),r=S("form",{class:"paste",role:"search"},n,S("div",{class:"paste-row"},t,e));return r.addEventListener("submit",i=>{i.preventDefault();const o=cr(t.value);if(!o){n.textContent="That is not an npub or nprofile.";return}n.textContent="",t.value="",t.blur(),is(o.pubkey,o.relays)}),r}function od(){const t=window.visualViewport;if(!t)return;const e=()=>{const n=Math.max(0,window.innerHeight-t.height-t.offsetTop);document.documentElement.style.setProperty("--keyboard",`${Math.round(n)}px`)};t.addEventListener("resize",e),t.addEventListener("scroll",e),e()}function sd(t,e){const n=t.pubkey,r=Ai(n);e.add(yl(n,t.relays,p=>Er(p)));const i=S("div",{class:"banner"});i.style.setProperty("--hue",String(parseInt(n.slice(0,4),16)%360));const o=S("div",{class:"profile-actions"}),s=S("h1",{class:"profile-name","data-pk":n,"data-role":"name"},At(n)),a=S("div",{class:"profile-nip05"}),c=S("div",{class:"profile-about"}),u=S("div",{class:"profile-meta"}),l=S("div",{class:"profile-counts"},S("span",{class:"count-pending"},"… following")),f=S("header",{class:"profile-head","data-profile":n},i,S("div",{class:"profile-top"},Vl(n,"xl")),S("div",{class:"profile-id"},s,a,l),o,c,u,S("div",{class:"profile-npub"},S("code",{class:"npub",title:r},xc(r)),os(r,"Copy npub")));let h="";const y=()=>{const p=Ne.get(n),d=`${(p==null?void 0:p.createdAt)??0}:${De.value}`;d!==h&&(h=d,ad(i,n),cd(a,n,e),c.replaceChildren(...p!=null&&p.about?[Zl(p.about)]:[]),c.hidden=!(p!=null&&p.about),ud(u,n))};return y(),e.add(Jo.subscribe(p=>p===n&&y())),e.add(De.subscribe(()=>y())),e.add(hl(n).subscribe(p=>{(p==null?void 0:p.pubkey)===n&&l.replaceChildren(S("span",{class:"count"},Ec(Qi(p).length)))})),se&&Be&&n!==se&&o.append(ld(n,Be,e)),o.hidden=!o.childNodes.length,f}function ad(t,e){var s;const n=((s=Ne.get(e))==null?void 0:s.banner)??"",r=n?Ki(n,null,e):null,i=r?Gi(r):De.value&&n.startsWith("https://")?n:"";if(t.dataset.src===i||(t.dataset.src=i,t.replaceChildren(),!i))return;const o=S("img",{alt:"",decoding:"async"});t.append(o),Wo(o,i,a=>a.remove())}function cd(t,e,n){var o;const r=(o=Ne.get(e))==null?void 0:o.nip05;if(t.replaceChildren(),t.classList.remove("verified"),t.removeAttribute("title"),t.hidden=!r,!r)return;t.append(S("span",{class:"nip05-text"},bc(r)));let i=!0;n.add(()=>i=!1),Cc(r,e).then(s=>{var a;!i||!s||((a=Ne.get(e))==null?void 0:a.nip05)!==r||!t.isConnected||t.classList.contains("verified")||(t.classList.add("verified"),t.title="Verified NIP-05 address",t.prepend(S("span",{class:"nip05-badge",role:"img","aria-label":"Verified"},qe("verified"))))})}function ud(t,e){const n=Ne.get(e);t.replaceChildren();const r=vc(n==null?void 0:n.website);r&&t.append(S("div",{class:"meta-row"},qe("globe"),Xo(r,r.replace(/^https?:\/\//,"").replace(/\/$/,""))));const i=mc(n==null?void 0:n.lud16);i&&t.append(S("div",{class:"meta-row"},qe("bolt"),S("span",{class:"meta-text"},i),os(i,"Copy lightning address"))),t.hidden=!t.childNodes.length}function os(t,e){const n=S("button",{type:"button",class:"copy-btn","aria-label":e},qe("copy"),S("span",null,"Copy"));let r;return n.addEventListener("click",async()=>{const i=await Lc(t);window.clearTimeout(r),n.replaceChildren(qe(i?"check":"copy"),S("span",null,i?"Copied":"Copy failed")),n.classList.toggle("done",i),r=window.setTimeout(()=>{n.replaceChildren(qe("copy"),S("span",null,"Copy")),n.classList.remove("done")},1600)}),n}function bi(t,e){return xr.get(e)??t.follows$.value.follows.includes(e)}const fd=8e3;function ld(t,e,n){const r=S("button",{type:"button",class:"follow-btn"}),i=S("div",{class:"follow-note",role:"status","aria-live":"polite"});i.hidden=!0;let o=!1,s=e.follows$.value.known;const a=()=>{if(o)return;const u=bi(e,t);r.textContent=u?"Following":"Follow",r.classList.toggle("on",u),r.setAttribute("aria-pressed",String(u)),r.disabled=!s};n.add(e.follows$.subscribe(u=>{u.known&&(s=!0),a()}));const c=window.setTimeout(()=>{s=!0,a()},fd);return n.add(()=>window.clearTimeout(c)),r.addEventListener("click",async()=>{if(o)return;const u=!bi(e,t);o=!0,r.disabled=!0,r.textContent=u?"Following…":"Unfollowing…",i.hidden=!0;const l=await gl(e.me,t,u);l.ok&&xr.set(t,u),o=!1,s=!0,a(),l.ok||(i.textContent=l.error??"That did not work.",i.hidden=!1)}),a(),S("div",{class:"follow"},r,i)}async function gi(){const t=++pi,e=await Sc();if(t!==pi)return;Yn=!0,e!==se&&(Be==null||Be.close(),Be=void 0,xr.clear()),se=e,se&&!Be&&(Be=bl(se));const n=F[0];!n||n.home?ts(se?{pubkey:se,relays:[],scrollY:0,home:!0}:void 0):$t(window.scrollY)}kc()?(_c(t=>queueMicrotask(()=>nd(t))),hi(),Qo.append(id()),od(),dl.subscribe(t=>{for(const e of t)Wl(e),Jo.next(e)}),Ac(t=>{t!==se&&gi()}),pl(),gi()):(hi(),Er("Simple Profile runs inside a napplet shell such as Myco. Open it from there."));
</script>
<style>:root{--bg: #ffffff;--text: #0f172a;--primary: #059669;--on-primary: #ffffff;--surface: #f5f6f8;--border: rgba(15, 23, 42, .12);--muted: #64748b;--primary-soft: rgba(5, 150, 105, .16);--scrim: rgba(0, 0, 0, .45);--font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif}@media(prefers-color-scheme:dark){:root{--bg: #000000;--text: #ffffff;--primary: #34d399;--on-primary: #000000;--surface: #141414;--border: rgba(255, 255, 255, .18);--muted: #999999;--primary-soft: rgba(52, 211, 153, .16);--scrim: rgba(0, 0, 0, .7)}}*{box-sizing:border-box}html,body{margin:0;background:var(--bg);color:var(--text);font:15px/1.45 var(--font);-webkit-text-size-adjust:100%}button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}.app{min-height:100vh}.status{padding:16px;color:var(--muted);text-align:center}.signin{min-height:calc(100vh - 76px - env(safe-area-inset-bottom));display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;padding:32px 24px;text-align:center}.signin[hidden]{display:none}.signin-icon{width:72px;height:72px;color:var(--muted);margin-bottom:8px}.signin-title{margin:0;font-size:18px;font-weight:600;color:var(--text)}.signin-text{margin:0;max-width:280px;color:var(--muted)}.icon{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex:none}.content{white-space:pre-wrap;overflow-wrap:anywhere;margin-top:2px}.link,.profile-link{text-align:left}.content .link,.content .profile-link{color:var(--primary);display:inline;overflow-wrap:anywhere}.link-refused{text-decoration:line-through}.link-text{color:var(--muted);overflow-wrap:anywhere}.avatar{position:relative;display:inline-grid;place-items:center;border-radius:50%;overflow:hidden;background:hsl(var(--hue, 160) 45% 45%);color:#fff;flex:none}.avatar-sm{width:20px;height:20px;font-size:11px}.avatar-md{width:40px;height:40px;font-size:17px}.avatar-lg{width:72px;height:72px;font-size:30px}.avatar-wilted .avatar-initial{line-height:1;filter:grayscale(.6) saturate(.6)}.avatar-wilted.avatar-sm .avatar-initial{font-size:10px}.avatar-wilted.avatar-md .avatar-initial{font-size:19px}.avatar-wilted.avatar-lg .avatar-initial{font-size:34px}.avatar img{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;object-fit:cover;opacity:0}.avatar img.loaded{opacity:1}@media(min-width:640px){.app{max-width:640px;margin:0 auto}}button:focus-visible,[role=button]:focus-visible{outline:2px solid var(--primary);outline-offset:2px;border-radius:6px}.content .link,.content .profile-link{padding:12px 2px;margin:-12px -2px}.detail-bar{position:sticky;top:0;z-index:5;background:var(--bg);border-bottom:1px solid var(--border);padding:2px 4px}.back{display:inline-flex;align-items:center;gap:4px;min-height:44px;min-width:44px;padding:0 14px 0 8px;border-radius:22px;font-weight:600}.back:active{background:var(--surface)}.back .icon{width:22px;height:22px}.is-loading{position:relative}.is-loading:after{content:"";position:absolute;left:50%;top:50%;width:20px;height:20px;margin:-10px 0 0 -10px;border:2px solid var(--muted);border-top-color:transparent;border-radius:50%;opacity:.35;animation:simpleprofile-spin .9s linear infinite;pointer-events:none}@keyframes simpleprofile-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.is-loading:after{animation:none;border-top-color:var(--muted);opacity:.2}}.view[hidden]{display:none}.avatar-xl{width:88px;height:88px;font-size:36px}.avatar-wilted.avatar-xl .avatar-initial{font-size:42px}.profile-head{padding:0 0 12px;border-bottom:1px solid var(--border)}.banner{aspect-ratio:3 / 1;max-height:200px;width:100%;overflow:hidden;background:linear-gradient(135deg,hsl(var(--hue, 160) 40% 42%),hsl(calc(var(--hue, 160) + 40) 45% 30%))}.banner img{display:block;width:100%;height:100%;object-fit:cover;opacity:0;transition:opacity .16s ease-out}.banner img.loaded{opacity:1}.profile-top{display:flex;justify-content:center;padding:0 16px;margin-top:-44px;height:92px}.profile-top .avatar{box-shadow:0 0 0 4px var(--bg)}.profile-actions{display:flex;justify-content:center;padding:12px 16px 0}.profile-actions[hidden]{display:none}.profile-id{padding:8px 16px 0;text-align:center}.profile-name{margin:0;font-size:22px;line-height:1.25;font-weight:700;min-height:1.25em;overflow-wrap:anywhere}.profile-nip05{display:flex;align-items:center;justify-content:center;gap:4px;margin-top:2px;color:var(--muted);font-size:14px;overflow-wrap:anywhere}.profile-nip05[hidden],.profile-about[hidden],.profile-meta[hidden]{display:none}.nip05-badge{display:inline-flex;color:var(--primary)}.nip05-badge .icon{width:16px;height:16px;stroke:none}.profile-about{padding:14px 16px 0}.profile-about .content{white-space:pre-wrap}.profile-meta{display:flex;flex-direction:column;gap:0;padding:6px 16px 0;font-size:14px}.meta-row{display:flex;align-items:center;gap:8px;min-height:44px;overflow-wrap:anywhere}.meta-row>.icon{width:18px;height:18px;color:var(--muted)}.meta-row .link{min-height:44px;text-align:left;color:var(--primary)}.meta-text{min-width:0}.profile-npub{display:flex;align-items:center;justify-content:center;gap:8px;padding:4px 16px 0;min-height:44px}.npub{font-size:13px;color:var(--muted);user-select:all;-webkit-user-select:all}.copy-btn{display:inline-flex;align-items:center;gap:4px;min-height:44px;min-width:44px;padding:0 10px;border-radius:22px;color:var(--muted);font-size:13px;font-weight:600}.copy-btn .icon{width:16px;height:16px}.copy-btn.done{color:var(--primary)}.copy-btn:active{background:var(--surface)}.profile-counts{margin-top:4px;font-size:14px;min-height:22px}.profile-counts .count{font-weight:600}.count-pending{color:var(--muted)}.follow{display:flex;flex-direction:column;align-items:center;gap:4px}.follow-btn{min-height:44px;min-width:112px;padding:10px 20px;border-radius:999px;border:1px solid var(--primary);background:var(--primary);color:var(--on-primary);font:600 15px/1 var(--font)}.follow-btn.on{background:var(--surface);border-color:var(--border);color:var(--text)}.follow-btn:disabled{opacity:.6}.follow-note{max-width:280px;color:var(--muted);font-size:12px;text-align:center}.follow-note[hidden]{display:none}.app{padding-bottom:calc(76px + env(safe-area-inset-bottom))}.paste-bar{position:fixed;left:0;right:0;bottom:var(--keyboard, 0px);z-index:6;background:var(--bg);border-top:1px solid var(--border);padding:8px 12px calc(8px + env(safe-area-inset-bottom))}.paste-bar[hidden]{display:none}.paste{max-width:640px;margin:0 auto}.paste-row{display:flex;gap:8px}.paste-input{flex:1;min-width:0;min-height:44px;padding:0 14px;border-radius:22px;border:1px solid var(--border);background:var(--surface);color:var(--text);font:16px/1 var(--font)}.paste-input:focus{outline:2px solid var(--primary);outline-offset:0}.paste-go{min-height:44px;min-width:64px;padding:0 16px;border-radius:22px;background:var(--primary);color:var(--on-primary);font-weight:600}.paste-note{color:var(--muted);font-size:13px;padding:0 6px 6px}.paste-note:empty{display:none}
</style>
</head>
<body>
<!-- The runtime shows the napplet's name: no masthead, the profile starts at the top. -->
<main id="app" class="app">
<div id="status" class="status" role="status" aria-live="polite" hidden></div>
<!-- Shown when no one is logged in to the shell and no profile was handed over. -->
<section id="signin" class="signin" role="status" aria-live="polite" hidden>
<svg class="signin-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<circle cx="12" cy="12" r="10.5" fill="none" stroke="currentColor" stroke-width="1.5" />
<circle cx="12" cy="9.5" r="3.5" fill="none" stroke="currentColor" stroke-width="1.5" />
<path d="M5.6 19.1c1.4-2.6 3.8-4.1 6.4-4.1s5 1.5 6.4 4.1" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
</svg>
<h1 class="signin-title">You're not logged in</h1>
<p class="signin-text">Log in to this app's shell to see your own profile, or paste someone's npub below.</p>
</section>
<!-- The profile on screen. Back returns to the one before. -->
<section id="view" class="view" hidden></section>
</main>
<!-- Paste an npub or nprofile: fixed at the bottom, above the keyboard when it opens. -->
<div id="pasteBar" class="paste-bar" hidden></div>
</body>
</html>
