SOURCE / PINNED RELEASE
Made of little things.
Bubbles
- Release
- 6680b33d3a58…
- 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" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="dark" />
<meta name="description" content="A follows feed as a constellation: notes as bubbles, read through the host's outbox." />
<meta name="napplet-requires" content="identity,outbox,resource,storage" />
<title>Bubbles</title>
<script type="module" crossorigin>function Js(){const e=window;if(!e.napplet)throw new Error("window.napplet is unavailable -- runtime did not inject the napplet namespace");return e.napplet}function Y(e){const o=Js()[e];if(!o)throw new Error(`window.napplet.${String(e)} is unavailable -- runtime did not inject this domain`);return o}var xn={getItem(e){return Y("storage").getItem(e)},setItem(e,t){return Y("storage").setItem(e,t)},removeItem(e){return Y("storage").removeItem(e)},keys(){return Y("storage").keys()},instance:{getItem(e){return Y("storage").instance.getItem(e)},setItem(e,t){return Y("storage").instance.setItem(e,t)},removeItem(e){return Y("storage").instance.removeItem(e)},keys(){return Y("storage").instance.keys()}}},To={getPublicKey(){return Y("identity").getPublicKey()},onChanged(e){return Y("identity").onChanged(e)},getRelays(){return Y("identity").getRelays()},getProfile(){return Y("identity").getProfile()},getFollows(){return Y("identity").getFollows()},getList(e){return Y("identity").getList(e)},getZaps(){return Y("identity").getZaps()},getMutes(){return Y("identity").getMutes()},getBlocked(){return Y("identity").getBlocked()},getBadges(){return Y("identity").getBadges()}},Ks={info(){return Y("resource").info()},bytes(e,t){return Y("resource").bytes(e,t)},bytesMany(e,t){return Y("resource").bytesMany(e,t)},bytesAsObjectURL(e){return Y("resource").bytesAsObjectURL(e)}},Qs={discover(e){return Y("cvm").discover(e)},request(e,t,o){return Y("cvm").request(e,t,o)},listTools(e,t){return Y("cvm").listTools(e,t)},callTool(e,t,o,n){return Y("cvm").callTool(e,t,o,n)},listResources(e,t){return Y("cvm").listResources(e,t)},readResource(e,t,o){return Y("cvm").readResource(e,t,o)},close(e){return Y("cvm").close(e)},onEvent(e){return Y("cvm").onEvent(e)},registry:{list(e){return Y("cvm").registry.list(e)},has(e,t){return Y("cvm").registry.has(e,t)},describe(e,t){return Y("cvm").registry.describe(e,t)},call(e,t,o,n){return Y("cvm").registry.call(e,t,o,n)}}},ei={getEvent(e,t){return Y("outbox").getEvent(e,t)},query(e,t){return Y("outbox").query(e,t)},subscribe(e,t){return Y("outbox").subscribe(e,t)},publish(e,t){return Y("outbox").publish(e,t)},resolveRelays(e){return Y("outbox").resolveRelays(e)}};/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ti(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Pn(e,t=""){if(!Number.isSafeInteger(e)||e<0){const o=t&&`"${t}" `;throw new Error(`${o}expected integer >= 0, got ${e}`)}}function le(e,t,o=""){const n=ti(e),r=e?.length,s=t!==void 0;if(!n||s&&r!==t){const i=o&&`"${o}" `,a=s?` of length ${t}`:"",l=n?`length=${r}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+l)}return e}function Po(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ni(e,t){le(e,void 0,"digestInto() output");const o=t.outputLen;if(e.length<o)throw new Error('"digestInto() output" expected to be of length >='+o)}function Sn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function dn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ge(e,t){return e<<32-t|e>>>t}const wr=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",oi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ae(e){if(le(e),wr)return e.toHex();let t="";for(let o=0;o<e.length;o++)t+=oi[e[o]];return t}const we={_0:48,_9:57,A:65,F:70,a:97,f:102};function jo(e){if(e>=we._0&&e<=we._9)return e-we._0;if(e>=we.A&&e<=we.F)return e-(we.A-10);if(e>=we.a&&e<=we.f)return e-(we.a-10)}function Re(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(wr)return Uint8Array.fromHex(e);const t=e.length,o=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(o);for(let r=0,s=0;r<o;r++,s+=2){const i=jo(e.charCodeAt(s)),a=jo(e.charCodeAt(s+1));if(i===void 0||a===void 0){const l=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}n[r]=i*16+a}return n}function Mt(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];le(r),t+=r.length}const o=new Uint8Array(t);for(let n=0,r=0;n<e.length;n++){const s=e[n];o.set(s,r),r+=s.length}return o}function ri(e,t={}){const o=(r,s)=>e(s).update(r).digest(),n=e(void 0);return o.outputLen=n.outputLen,o.blockLen=n.blockLen,o.create=r=>e(r),Object.assign(o,t),Object.freeze(o)}function Er(e=32){const t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}const si=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function ii(e,t,o){return e&t^~e&o}function ai(e,t,o){return e&t^e&o^t&o}class ci{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,o,n,r){this.blockLen=t,this.outputLen=o,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=dn(this.buffer)}update(t){Po(this),le(t);const{view:o,buffer:n,blockLen:r}=this,s=t.length;for(let i=0;i<s;){const a=Math.min(r-this.pos,s-i);if(a===r){const l=dn(t);for(;r<=s-i;i+=r)this.process(l,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===r&&(this.process(o,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Po(this),ni(t,this),this.finished=!0;const{buffer:o,view:n,blockLen:r,isLE:s}=this;let{pos:i}=this;o[i++]=128,Sn(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let c=i;c<r;c++)o[c]=0;n.setBigUint64(r-8,BigInt(this.length*8),s),this.process(n,0);const a=dn(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const d=l/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<d;c++)a.setUint32(4*c,f[c],s)}digest(){const{buffer:t,outputLen:o}=this;this.digestInto(t);const n=t.slice(0,o);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:o,buffer:n,length:r,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=r,t.pos=a,r%o&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const Se=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),li=Uint32Array.from([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]),ke=new Uint32Array(64);class di extends ci{constructor(t){super(64,t,8,!1)}get(){const{A:t,B:o,C:n,D:r,E:s,F:i,G:a,H:l}=this;return[t,o,n,r,s,i,a,l]}set(t,o,n,r,s,i,a,l){this.A=t|0,this.B=o|0,this.C=n|0,this.D=r|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,o){for(let c=0;c<16;c++,o+=4)ke[c]=t.getUint32(o,!1);for(let c=16;c<64;c++){const h=ke[c-15],m=ke[c-2],y=ge(h,7)^ge(h,18)^h>>>3,b=ge(m,17)^ge(m,19)^m>>>10;ke[c]=b+ke[c-7]+y+ke[c-16]|0}let{A:n,B:r,C:s,D:i,E:a,F:l,G:d,H:f}=this;for(let c=0;c<64;c++){const h=ge(a,6)^ge(a,11)^ge(a,25),m=f+h+ii(a,l,d)+li[c]+ke[c]|0,b=(ge(n,2)^ge(n,13)^ge(n,22))+ai(n,r,s)|0;f=d,d=l,l=a,a=i+m|0,i=s,s=r,r=n,n=m+b|0}n=n+this.A|0,r=r+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,l=l+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(n,r,s,i,a,l,d,f)}roundClean(){Sn(ke)}destroy(){this.set(0,0,0,0,0,0,0,0),Sn(this.buffer)}}class ui extends di{A=Se[0]|0;B=Se[1]|0;C=Se[2]|0;D=Se[3]|0;E=Se[4]|0;F=Se[5]|0;G=Se[6]|0;H=Se[7]|0;constructor(){super(32)}}const kn=ri(()=>new ui,si(1));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const jn=BigInt(0),An=BigInt(1);function Do(e,t=""){if(typeof e!="boolean"){const o=t&&`"${t}" `;throw new Error(o+"expected boolean, got type="+typeof e)}return e}function fi(e){if(typeof e=="bigint"){if(!mi(e))throw new Error("positive bigint expected, got "+e)}else Pn(e);return e}function vr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?jn:BigInt("0x"+e)}function Dn(e){return vr(ae(e))}function xr(e){return vr(ae(hi(le(e)).reverse()))}function Un(e,t){Pn(t),e=fi(e);const o=Re(e.toString(16).padStart(t*2,"0"));if(o.length!==t)throw new Error("number too large");return o}function Sr(e,t){return Un(e,t).reverse()}function hi(e){return Uint8Array.from(e)}function pi(e){return Uint8Array.from(e,(t,o)=>{const n=t.charCodeAt(0);if(t.length!==1||n>127)throw new Error(`string contains non-ASCII character "${e[o]}" with code ${n} at position ${o}`);return n})}const mi=e=>typeof e=="bigint"&&jn<=e;function gi(e){let t;for(t=0;e>jn;e>>=An,t+=1);return t}const kr=e=>(An<<BigInt(e))-An;function Ar(e,t={},o={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(s,i,a){const l=e[s];if(a&&l===void 0)return;const d=typeof l;if(d!==i||l===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${d}`)}const r=(s,i)=>Object.entries(s).forEach(([a,l])=>n(a,l,i));r(t,!1),r(o,!0)}function Uo(e){const t=new WeakMap;return(o,...n)=>{const r=t.get(o);if(r!==void 0)return r;const s=e(o,...n);return t.set(o,s),s}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ce=BigInt(0),se=BigInt(1),Oe=BigInt(2),Rr=BigInt(3),Mr=BigInt(4),Ir=BigInt(5),bi=BigInt(7),_r=BigInt(8),yi=BigInt(9),$r=BigInt(16);function me(e,t){const o=e%t;return o>=ce?o:t+o}function he(e,t,o){let n=e;for(;t-- >ce;)n*=n,n%=o;return n}function Ho(e,t){if(e===ce)throw new Error("invert: expected non-zero number");if(t<=ce)throw new Error("invert: expected positive modulus, got "+t);let o=me(e,t),n=t,r=ce,s=se;for(;o!==ce;){const a=n/o,l=n%o,d=r-s*a;n=o,o=l,r=s,s=d}if(n!==se)throw new Error("invert: does not exist");return me(r,t)}function Hn(e,t,o){if(!e.eql(e.sqr(t),o))throw new Error("Cannot find square root")}function Nr(e,t){const o=(e.ORDER+se)/Mr,n=e.pow(t,o);return Hn(e,n,t),n}function wi(e,t){const o=(e.ORDER-Ir)/_r,n=e.mul(t,Oe),r=e.pow(n,o),s=e.mul(t,r),i=e.mul(e.mul(s,Oe),r),a=e.mul(s,e.sub(i,e.ONE));return Hn(e,a,t),a}function Ei(e){const t=Lt(e),o=Or(e),n=o(t,t.neg(t.ONE)),r=o(t,n),s=o(t,t.neg(n)),i=(e+bi)/$r;return(a,l)=>{let d=a.pow(l,i),f=a.mul(d,n);const c=a.mul(d,r),h=a.mul(d,s),m=a.eql(a.sqr(f),l),y=a.eql(a.sqr(c),l);d=a.cmov(d,f,m),f=a.cmov(h,c,y);const b=a.eql(a.sqr(f),l),g=a.cmov(d,f,b);return Hn(a,g,l),g}}function Or(e){if(e<Rr)throw new Error("sqrt is not defined for small field");let t=e-se,o=0;for(;t%Oe===ce;)t/=Oe,o++;let n=Oe;const r=Lt(e);for(;qo(r,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(o===1)return Nr;let s=r.pow(n,t);const i=(t+se)/Oe;return function(l,d){if(l.is0(d))return d;if(qo(l,d)!==1)throw new Error("Cannot find square root");let f=o,c=l.mul(l.ONE,s),h=l.pow(d,t),m=l.pow(d,i);for(;!l.eql(h,l.ONE);){if(l.is0(h))return l.ZERO;let y=1,b=l.sqr(h);for(;!l.eql(b,l.ONE);)if(y++,b=l.sqr(b),y===f)throw new Error("Cannot find square root");const g=se<<BigInt(f-y-1),E=l.pow(c,g);f=y,c=l.sqr(E),h=l.mul(h,c),m=l.mul(m,E)}return m}}function vi(e){return e%Mr===Rr?Nr:e%_r===Ir?wi:e%$r===yi?Ei(e):Or(e)}const xi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Si(e){const t={ORDER:"bigint",BYTES:"number",BITS:"number"},o=xi.reduce((n,r)=>(n[r]="function",n),t);return Ar(e,o),e}function ki(e,t,o){if(o<ce)throw new Error("invalid exponent, negatives unsupported");if(o===ce)return e.ONE;if(o===se)return t;let n=e.ONE,r=t;for(;o>ce;)o&se&&(n=e.mul(n,r)),r=e.sqr(r),o>>=se;return n}function Br(e,t,o=!1){const n=new Array(t.length).fill(o?e.ZERO:void 0),r=t.reduce((i,a,l)=>e.is0(a)?i:(n[l]=i,e.mul(i,a)),e.ONE),s=e.inv(r);return t.reduceRight((i,a,l)=>e.is0(a)?i:(n[l]=e.mul(i,n[l]),e.mul(i,a)),s),n}function qo(e,t){const o=(e.ORDER-se)/Oe,n=e.pow(t,o),r=e.eql(n,e.ONE),s=e.eql(n,e.ZERO),i=e.eql(n,e.neg(e.ONE));if(!r&&!s&&!i)throw new Error("invalid Legendre symbol result");return r?1:s?0:-1}function Ai(e,t){t!==void 0&&Pn(t);const o=t!==void 0?t:e.toString(2).length,n=Math.ceil(o/8);return{nBitLength:o,nByteLength:n}}class Ri{ORDER;BITS;BYTES;isLE;ZERO=ce;ONE=se;_lengths;_sqrt;_mod;constructor(t,o={}){if(t<=ce)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,o!=null&&typeof o=="object"&&(typeof o.BITS=="number"&&(n=o.BITS),typeof o.sqrt=="function"&&(this.sqrt=o.sqrt),typeof o.isLE=="boolean"&&(this.isLE=o.isLE),o.allowedLengths&&(this._lengths=o.allowedLengths?.slice()),typeof o.modFromBytes=="boolean"&&(this._mod=o.modFromBytes));const{nBitLength:r,nByteLength:s}=Ai(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=r,this.BYTES=s,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return me(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return ce<=t&&t<this.ORDER}is0(t){return t===ce}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&se)===se}neg(t){return me(-t,this.ORDER)}eql(t,o){return t===o}sqr(t){return me(t*t,this.ORDER)}add(t,o){return me(t+o,this.ORDER)}sub(t,o){return me(t-o,this.ORDER)}mul(t,o){return me(t*o,this.ORDER)}pow(t,o){return ki(this,t,o)}div(t,o){return me(t*Ho(o,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,o){return t+o}subN(t,o){return t-o}mulN(t,o){return t*o}inv(t){return Ho(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=vi(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?Sr(t,this.BYTES):Un(t,this.BYTES)}fromBytes(t,o=!1){le(t);const{_lengths:n,BYTES:r,isLE:s,ORDER:i,_mod:a}=this;if(n){if(!n.includes(t.length)||t.length>r)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);const d=new Uint8Array(r);d.set(t,s?0:d.length-t.length),t=d}if(t.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);let l=s?xr(t):Dn(t);if(a&&(l=me(l,i)),!o&&!this.isValid(l))throw new Error("invalid field element: outside of range 0..ORDER");return l}invertBatch(t){return Br(this,t)}cmov(t,o,n){return n?o:t}}function Lt(e,t={}){return new Ri(e,t)}function Cr(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Mi(e){const t=Cr(e);return t+Math.ceil(t/2)}function Ii(e,t,o=!1){le(e);const n=e.length,r=Cr(t),s=Mi(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);const i=o?xr(e):Dn(e),a=me(i,t-se)+se;return o?Sr(a,r):Un(a,r)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ge=BigInt(0),Be=BigInt(1);function It(e,t){const o=t.negate();return e?o:t}function Go(e,t){const o=Br(e.Fp,t.map(n=>n.Z));return t.map((n,r)=>e.fromAffine(n.toAffine(o[r])))}function Lr(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function un(e,t){Lr(e,t);const o=Math.ceil(t/e)+1,n=2**(e-1),r=2**e,s=kr(e),i=BigInt(e);return{windows:o,windowSize:n,mask:s,maxNumber:r,shiftBy:i}}function Yo(e,t,o){const{windowSize:n,mask:r,maxNumber:s,shiftBy:i}=o;let a=Number(e&r),l=e>>i;a>n&&(a-=s,l+=Be);const d=t*n,f=d+Math.abs(a)-1,c=a===0,h=a<0,m=t%2!==0;return{nextN:l,offset:f,isZero:c,isNeg:h,isNegF:m,offsetF:d}}const fn=new WeakMap,Tr=new WeakMap;function hn(e){return Tr.get(e)||1}function Fo(e){if(e!==Ge)throw new Error("invalid wNAF")}class _i{BASE;ZERO;Fn;bits;constructor(t,o){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=o}_unsafeLadder(t,o,n=this.ZERO){let r=t;for(;o>Ge;)o&Be&&(n=n.add(r)),r=r.double(),o>>=Be;return n}precomputeWindow(t,o){const{windows:n,windowSize:r}=un(o,this.bits),s=[];let i=t,a=i;for(let l=0;l<n;l++){a=i,s.push(a);for(let d=1;d<r;d++)a=a.add(i),s.push(a);i=a.double()}return s}wNAF(t,o,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,s=this.BASE;const i=un(t,this.bits);for(let a=0;a<i.windows;a++){const{nextN:l,offset:d,isZero:f,isNeg:c,isNegF:h,offsetF:m}=Yo(n,a,i);n=l,f?s=s.add(It(h,o[m])):r=r.add(It(c,o[d]))}return Fo(n),{p:r,f:s}}wNAFUnsafe(t,o,n,r=this.ZERO){const s=un(t,this.bits);for(let i=0;i<s.windows&&n!==Ge;i++){const{nextN:a,offset:l,isZero:d,isNeg:f}=Yo(n,i,s);if(n=a,!d){const c=o[l];r=r.add(f?c.negate():c)}}return Fo(n),r}getPrecomputes(t,o,n){let r=fn.get(o);return r||(r=this.precomputeWindow(o,t),t!==1&&(typeof n=="function"&&(r=n(r)),fn.set(o,r))),r}cached(t,o,n){const r=hn(t);return this.wNAF(r,this.getPrecomputes(r,t,n),o)}unsafe(t,o,n,r){const s=hn(t);return s===1?this._unsafeLadder(t,o,r):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),o,r)}createCache(t,o){Lr(o,this.bits),Tr.set(t,o),fn.delete(t)}hasCache(t){return hn(t)!==1}}function $i(e,t,o,n){let r=t,s=e.ZERO,i=e.ZERO;for(;o>Ge||n>Ge;)o&Be&&(s=s.add(r)),n&Be&&(i=i.add(r)),r=r.double(),o>>=Be,n>>=Be;return{p1:s,p2:i}}function Wo(e,t,o){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Si(t),t}else return Lt(e,{isLE:o})}function Ni(e,t,o={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const l of["p","n","h"]){const d=t[l];if(!(typeof d=="bigint"&&d>Ge))throw new Error(`CURVE.${l} must be positive bigint`)}const r=Wo(t.p,o.Fp,n),s=Wo(t.n,o.Fn,n),a=["Gx","Gy","a","b"];for(const l of a)if(!r.isValid(t[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:r,Fn:s}}function Oi(e,t){return function(n){const r=e(n);return{secretKey:r,publicKey:t(r)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zo=(e,t)=>(e+(e>=0?t:-t)/Ci)/t;function Bi(e,t,o){const[[n,r],[s,i]]=t,a=zo(i*e,o),l=zo(-r*e,o);let d=e-a*n-l*s,f=-a*r-l*i;const c=d<et,h=f<et;c&&(d=-d),h&&(f=-f);const m=kr(Math.ceil(gi(o)/2))+St;if(d<et||d>=m||f<et||f>=m)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:c,k1:d,k2neg:h,k2:f}}const et=BigInt(0),St=BigInt(1),Ci=BigInt(2),bt=BigInt(3),Li=BigInt(4);function Ti(e,t={}){const o=Ni("weierstrass",e,t),{Fp:n,Fn:r}=o;let s=o.CURVE;const{h:i,n:a}=s;Ar(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:l}=t;if(l&&(!n.is0(s.a)||typeof l.beta!="bigint"||!Array.isArray(l.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const d=ji(n,r);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(C,v,I){const{x:D,y:x}=v.toAffine(),B=n.toBytes(D);if(Do(I,"isCompressed"),I){f();const R=!n.isOdd(x);return Mt(Pi(R),B)}else return Mt(Uint8Array.of(4),B,n.toBytes(x))}function h(C){le(C,void 0,"Point");const{publicKey:v,publicKeyUncompressed:I}=d,D=C.length,x=C[0],B=C.subarray(1);if(D===v&&(x===2||x===3)){const R=n.fromBytes(B);if(!n.isValid(R))throw new Error("bad point: is not on curve, wrong x");const P=b(R);let $;try{$=n.sqrt(P)}catch(G){const Q=G instanceof Error?": "+G.message:"";throw new Error("bad point: is not on curve, sqrt error"+Q)}f();const U=n.isOdd($);return(x&1)===1!==U&&($=n.neg($)),{x:R,y:$}}else if(D===I&&x===4){const R=n.BYTES,P=n.fromBytes(B.subarray(0,R)),$=n.fromBytes(B.subarray(R,R*2));if(!g(P,$))throw new Error("bad point: is not on curve");return{x:P,y:$}}else throw new Error(`bad point: got length ${D}, expected compressed=${v} or uncompressed=${I}`)}const m=t.toBytes||c,y=t.fromBytes||h;function b(C){const v=n.sqr(C),I=n.mul(v,C);return n.add(n.add(I,n.mul(C,s.a)),s.b)}function g(C,v){const I=n.sqr(v),D=b(C);return n.eql(I,D)}if(!g(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const E=n.mul(n.pow(s.a,bt),Li),_=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(E,_)))throw new Error("bad curve params: a or b");function A(C,v,I=!1){if(!n.isValid(v)||I&&n.is0(v))throw new Error(`bad point coordinate ${C}`);return v}function O(C){if(!(C instanceof T))throw new Error("Weierstrass Point expected")}function F(C){if(!l||!l.basises)throw new Error("no endo");return Bi(C,l.basises,r.ORDER)}const M=Uo((C,v)=>{const{X:I,Y:D,Z:x}=C;if(n.eql(x,n.ONE))return{x:I,y:D};const B=C.is0();v==null&&(v=B?n.ONE:n.inv(x));const R=n.mul(I,v),P=n.mul(D,v),$=n.mul(x,v);if(B)return{x:n.ZERO,y:n.ZERO};if(!n.eql($,n.ONE))throw new Error("invZ was invalid");return{x:R,y:P}}),K=Uo(C=>{if(C.is0()){if(t.allowInfinityPoint&&!n.is0(C.Y))return;throw new Error("bad point: ZERO")}const{x:v,y:I}=C.toAffine();if(!n.isValid(v)||!n.isValid(I))throw new Error("bad point: x or y not field elements");if(!g(v,I))throw new Error("bad point: equation left != right");if(!C.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function X(C,v,I,D,x){return I=new T(n.mul(I.X,C),I.Y,I.Z),v=It(D,v),I=It(x,I),v.add(I)}class T{static BASE=new T(s.Gx,s.Gy,n.ONE);static ZERO=new T(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=r;X;Y;Z;constructor(v,I,D){this.X=A("x",v),this.Y=A("y",I,!0),this.Z=A("z",D),Object.freeze(this)}static CURVE(){return s}static fromAffine(v){const{x:I,y:D}=v||{};if(!v||!n.isValid(I)||!n.isValid(D))throw new Error("invalid affine point");if(v instanceof T)throw new Error("projective point not allowed");return n.is0(I)&&n.is0(D)?T.ZERO:new T(I,D,n.ONE)}static fromBytes(v){const I=T.fromAffine(y(le(v,void 0,"point")));return I.assertValidity(),I}static fromHex(v){return T.fromBytes(Re(v))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(v=8,I=!0){return J.createCache(this,v),I||this.multiply(bt),this}assertValidity(){K(this)}hasEvenY(){const{y:v}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(v)}equals(v){O(v);const{X:I,Y:D,Z:x}=this,{X:B,Y:R,Z:P}=v,$=n.eql(n.mul(I,P),n.mul(B,x)),U=n.eql(n.mul(D,P),n.mul(R,x));return $&&U}negate(){return new T(this.X,n.neg(this.Y),this.Z)}double(){const{a:v,b:I}=s,D=n.mul(I,bt),{X:x,Y:B,Z:R}=this;let P=n.ZERO,$=n.ZERO,U=n.ZERO,j=n.mul(x,x),G=n.mul(B,B),Q=n.mul(R,R),W=n.mul(x,B);return W=n.add(W,W),U=n.mul(x,R),U=n.add(U,U),P=n.mul(v,U),$=n.mul(D,Q),$=n.add(P,$),P=n.sub(G,$),$=n.add(G,$),$=n.mul(P,$),P=n.mul(W,P),U=n.mul(D,U),Q=n.mul(v,Q),W=n.sub(j,Q),W=n.mul(v,W),W=n.add(W,U),U=n.add(j,j),j=n.add(U,j),j=n.add(j,Q),j=n.mul(j,W),$=n.add($,j),Q=n.mul(B,R),Q=n.add(Q,Q),j=n.mul(Q,W),P=n.sub(P,j),U=n.mul(Q,G),U=n.add(U,U),U=n.add(U,U),new T(P,$,U)}add(v){O(v);const{X:I,Y:D,Z:x}=this,{X:B,Y:R,Z:P}=v;let $=n.ZERO,U=n.ZERO,j=n.ZERO;const G=s.a,Q=n.mul(s.b,bt);let W=n.mul(I,B),H=n.mul(D,R),oe=n.mul(x,P),fe=n.add(I,D),ee=n.add(B,R);fe=n.mul(fe,ee),ee=n.add(W,H),fe=n.sub(fe,ee),ee=n.add(I,x);let re=n.add(B,P);return ee=n.mul(ee,re),re=n.add(W,oe),ee=n.sub(ee,re),re=n.add(D,x),$=n.add(R,P),re=n.mul(re,$),$=n.add(H,oe),re=n.sub(re,$),j=n.mul(G,ee),$=n.mul(Q,oe),j=n.add($,j),$=n.sub(H,j),j=n.add(H,j),U=n.mul($,j),H=n.add(W,W),H=n.add(H,W),oe=n.mul(G,oe),ee=n.mul(Q,ee),H=n.add(H,oe),oe=n.sub(W,oe),oe=n.mul(G,oe),ee=n.add(ee,oe),W=n.mul(H,ee),U=n.add(U,W),W=n.mul(re,ee),$=n.mul(fe,$),$=n.sub($,W),W=n.mul(fe,H),j=n.mul(re,j),j=n.add(j,W),new T($,U,j)}subtract(v){return this.add(v.negate())}is0(){return this.equals(T.ZERO)}multiply(v){const{endo:I}=t;if(!r.isValidNot0(v))throw new Error("invalid scalar: out of range");let D,x;const B=R=>J.cached(this,R,P=>Go(T,P));if(I){const{k1neg:R,k1:P,k2neg:$,k2:U}=F(v),{p:j,f:G}=B(P),{p:Q,f:W}=B(U);x=G.add(W),D=X(I.beta,j,Q,R,$)}else{const{p:R,f:P}=B(v);D=R,x=P}return Go(T,[D,x])[0]}multiplyUnsafe(v){const{endo:I}=t,D=this;if(!r.isValid(v))throw new Error("invalid scalar: out of range");if(v===et||D.is0())return T.ZERO;if(v===St)return D;if(J.hasCache(this))return this.multiply(v);if(I){const{k1neg:x,k1:B,k2neg:R,k2:P}=F(v),{p1:$,p2:U}=$i(T,D,B,P);return X(I.beta,$,U,x,R)}else return J.unsafe(D,v)}toAffine(v){return M(this,v)}isTorsionFree(){const{isTorsionFree:v}=t;return i===St?!0:v?v(T,this):J.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:v}=t;return i===St?this:v?v(T,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(v=!0){return Do(v,"isCompressed"),this.assertValidity(),m(T,this,v)}toHex(v=!0){return ae(this.toBytes(v))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const te=r.BITS,J=new _i(T,t.endo?Math.ceil(te/2):te);return T.BASE.precompute(8),T}function Pi(e){return Uint8Array.of(e?2:3)}function ji(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Tt={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Di={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Ui=BigInt(0),Rn=BigInt(2);function Hi(e){const t=Tt.p,o=BigInt(3),n=BigInt(6),r=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),l=BigInt(88),d=e*e*e%t,f=d*d*e%t,c=he(f,o,t)*f%t,h=he(c,o,t)*f%t,m=he(h,Rn,t)*d%t,y=he(m,r,t)*m%t,b=he(y,s,t)*y%t,g=he(b,a,t)*b%t,E=he(g,l,t)*g%t,_=he(E,a,t)*b%t,A=he(_,o,t)*f%t,O=he(A,i,t)*y%t,F=he(O,n,t)*d%t,M=he(F,Rn,t);if(!_t.eql(_t.sqr(M),e))throw new Error("Cannot find square root");return M}const _t=Lt(Tt.p,{sqrt:Hi}),Fe=Ti(Tt,{Fp:_t,endo:Di}),Vo={};function $t(e,...t){let o=Vo[e];if(o===void 0){const n=kn(pi(e));o=Mt(n,n),Vo[e]=o}return kn(Mt(o,...t))}const qn=e=>e.toBytes(!0).slice(1),Gn=e=>e%Rn===Ui;function Mn(e){const{Fn:t,BASE:o}=Fe,n=t.fromBytes(e),r=o.multiply(n);return{scalar:Gn(r.y)?n:t.neg(n),bytes:qn(r)}}function Pr(e){const t=_t;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const o=t.create(e*e),n=t.create(o*e+BigInt(7));let r=t.sqrt(n);Gn(r)||(r=t.neg(r));const s=Fe.fromAffine({x:e,y:r});return s.assertValidity(),s}const nt=Dn;function jr(...e){return Fe.Fn.create(nt($t("BIP0340/challenge",...e)))}function Xo(e){return Mn(e).bytes}function qi(e,t,o=Er(32)){const{Fn:n}=Fe,r=le(e,void 0,"message"),{bytes:s,scalar:i}=Mn(t),a=le(o,32,"auxRand"),l=n.toBytes(i^nt($t("BIP0340/aux",a))),d=$t("BIP0340/nonce",l,s,r),{bytes:f,scalar:c}=Mn(d),h=jr(f,s,r),m=new Uint8Array(64);if(m.set(f,0),m.set(n.toBytes(n.create(c+h*i)),32),!Dr(m,r,s))throw new Error("sign: Invalid signature produced");return m}function Dr(e,t,o){const{Fp:n,Fn:r,BASE:s}=Fe,i=le(e,64,"signature"),a=le(t,void 0,"message"),l=le(o,32,"publicKey");try{const d=Pr(nt(l)),f=nt(i.subarray(0,32));if(!n.isValidNot0(f))return!1;const c=nt(i.subarray(32,64));if(!r.isValidNot0(c))return!1;const h=jr(r.toBytes(f),qn(d),a),m=s.multiplyUnsafe(c).add(d.multiplyUnsafe(r.neg(h))),{x:y,y:b}=m.toAffine();return!(m.is0()||!Gn(b)||y!==f)}catch{return!1}}const Ze=(()=>{const o=(n=Er(48))=>Ii(n,Tt.n);return{keygen:Oi(o,Xo),getPublicKey:Xo,sign:qi,verify:Dr,Point:Fe,utils:{randomSecretKey:o,taggedHash:$t,lift_x:Pr,pointToBytes:qn},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();new TextDecoder("utf-8");var Gi=new TextEncoder;function Yi(e){if(e.length!==64)return!1;for(let t=0;t<64;t++){let o=e.charCodeAt(t);if(isNaN(o)||o<48||o>102||o>57&&o<97)return!1}return!0}var Ue=Symbol("verified"),Fi=e=>e instanceof Object;function Wi(e){if(!Fi(e)||typeof e.kind!="number"||typeof e.content!="string"||typeof e.created_at!="number"||typeof e.pubkey!="string"||!Yi(e.pubkey)||!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let o=e.tags[t];if(!Array.isArray(o))return!1;for(let n=0;n<o.length;n++)if(typeof o[n]!="string")return!1}return!0}var zi=class{generateSecretKey(){return Ze.utils.randomSecretKey()}getPublicKey(e){return ae(Ze.getPublicKey(e))}finalizeEvent(e,t){const o=e;return o.pubkey=ae(Ze.getPublicKey(t)),o.id=pn(o),o.sig=ae(Ze.sign(Re(pn(o)),t)),o[Ue]=!0,o}verifyEvent(e){if(typeof e[Ue]=="boolean")return e[Ue];try{const t=pn(e);if(t!==e.id)return e[Ue]=!1,!1;const o=Ze.verify(Re(e.sig),Re(t),Re(e.pubkey));return e[Ue]=o,o}catch{return e[Ue]=!1,!1}}};function Vi(e){if(!Wi(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function pn(e){let t=kn(Gi.encode(Vi(e)));return ae(t)}var Pt=new zi;Pt.generateSecretKey;Pt.getPublicKey;Pt.finalizeEvent;var Ur=Pt.verifyEvent;const z={profile:0,note:1,contacts:3,repost:6,reaction:7,relayList:10002,judgement:30078},Xi=100,Zi=1440*60*1e3,Ji=30,Hr=50,qr=Hr,Yn=1e4,Ki=50,jt="325d6744f52fcdfa368d6da687240adc0cccdfa26316a734abdb2e9fe444eca5",Qi="bubbles:judgements",Dt="I work on a decentralized AI marketplace, so my work is a lot about LLMs and AI agents. We also do Bitcoin payments using Lightning and Cashu. I want the posts that are relevant to that work at the top, and the ones that are not at the bottom.";function Gr(e,t){const{timeoutMs:o,signal:n,onEvent:r,onClose:s}=t;return n?.aborted?Promise.resolve([]):new Promise((i,a)=>{const l=ei.subscribe(e,{timeoutMs:o}),d=new Map;let f=!1;function c(y,b){if(!f){f=!0,clearTimeout(m),n?.removeEventListener("abort",h);try{l.close(),y&&s?.(y),b?a(b.error):i(n?.aborted?[]:[...d.values()])}catch(g){a(g)}}}const h=()=>c(),m=setTimeout(c,o);l.on("event",({event:y})=>{if(!(f||!y||d.has(y.id))){d.set(y.id,y);try{r?.(y)}catch(b){c(void 0,{error:b})}}}),l.on("closed",c),n?.addEventListener("abort",h,{once:!0}),n?.aborted&&h()})}const ea="judge_notes",Yr="jev-latest",ta=4,na=4e3,oa=["wss://nos.lol","wss://relay.damus.io","wss://relay.primal.net","wss://nostr.mom"],ra=/^[0-9a-f]{64}$/,Fn=e=>`bubbles:jev:v1:${e}`,kt={prompt:Dt,model:Yr,baseUrl:""};function sa(e,t,o=jt){if(!(e.kind!==z.judgement||e.pubkey!==o||e.tags.find(([n])=>n==="d")?.[1]!==Fn(t)))try{const{build:n,relevant:r}=JSON.parse(e.content);if(typeof n=="number"&&typeof r=="number"&&n>=0&&n<=1&&r>=0&&r<=1)return{build:n,relevant:r}}catch{}}function Fr(e){if(e.jev&&(e.jev.prompt!==Dt||e.jev.model!==Yr))return new Map;const t=new Set(Object.values(e.threads??{}).flatMap(o=>o.map(({id:n})=>n)));return new Map(e.events.filter(({kind:o,id:n})=>o===z.note&&ra.test(n)&&!t.has(n)&&!e.judgements?.[n]).map(o=>[o.id,o]))}function Wr(e,t,o,n,r){if(r.aborted)return 0;const s=new Map([...t].map(l=>[Fn(l),l])),i={};for(const l of e){if(!l||typeof l!="object")continue;const d=l;if(!Array.isArray(d.tags)||!d.tags.every(m=>Array.isArray(m)))continue;const f=d.tags.find(([m])=>m==="d")?.[1],c=f&&s.get(f);if(!c||!o.has(c))continue;const h=sa(d,c);h&&Ur(d)&&(i[c]=h,o.delete(c))}const a=Object.keys(i).length;return a&&n(i),a}async function zr(e,t,o){if(!e.size||o.aborted)return 0;try{const n=await Gr([{kinds:[z.judgement],authors:[jt],"#d":[...e.keys()].map(Fn),limit:e.size}],{timeoutMs:4e3,signal:o,onClose:r=>console.info("Bubbles could not read cached Jev scores",r)});return Wr(n.sort((r,s)=>s.created_at-r.created_at||r.id.localeCompare(s.id)),e.keys(),e,t,o)}catch(n){return console.info("Bubbles could not read cached Jev scores",n),0}}function ia(e,t,o){return zr(Fr(e),t,o)}async function aa(e,t,o){const n=Fr(e);await zr(n,t,o);const r={pubkey:jt,relays:oa};for(const s of ca(n.values())){if(o.aborted)break;try{const i=await Qs.callTool(r,ea,{notes:s},{timeoutMs:25e3,payment:"deny",initialize:!1});if(i.isError){console.info("Bubbles Jev CVM declined the batch",i.content);break}const a=i.content.find(d=>d.type==="text")?.text,l=i.structuredContent??(typeof a=="string"?JSON.parse(a):null);if(!l||typeof l!="object"||!("events"in l)||!Array.isArray(l.events)||!l.events.length||!Wr(l.events,s.map(({id:d})=>d),n,t,o))break}catch(i){console.info("Bubbles Jev CVM unavailable",i);break}}}function*ca(e){const t=new TextEncoder,o=2e4;let n=[],r=0;for(const{id:s,pubkey:i,kind:a,created_at:l,tags:d,content:f,sig:c}of e){if(!f.trim()||f.length>na)continue;const h={id:s,pubkey:i,kind:a,created_at:l,tags:d,content:f,sig:c},m=t.encode(JSON.stringify(h)).length+1;m>o||!Ur(h)||((n.length>=ta||r+m>o)&&(yield n,n=[],r=0),n.push(h),r+=m)}n.length&&(yield n)}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Vr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Xr(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(o=>typeof o=="string"):t.every(o=>Number.isSafeInteger(o)):!1}function la(e){if(typeof e!="function")throw new Error("function expected");return!0}function it(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Zr(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function In(e){if(!Array.isArray(e))throw new Error("array expected")}function Jr(e,t){if(!Xr(!0,t))throw new Error(`${e}: array of strings expected`)}function Kr(e,t){if(!Xr(!1,t))throw new Error(`${e}: array of numbers expected`)}function da(...e){const t=s=>s,o=(s,i)=>a=>s(i(a)),n=e.map(s=>s.encode).reduceRight(o,t),r=e.map(s=>s.decode).reduce(o,t);return{encode:n,decode:r}}function ua(e){const t=typeof e=="string"?e.split(""):e,o=t.length;Jr("alphabet",t);const n=new Map(t.map((r,s)=>[r,s]));return{encode:r=>(In(r),r.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=o)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:r=>(In(r),r.map(s=>{it("alphabet.decode",s);const i=n.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return i}))}}function fa(e=""){return it("join",e),{encode:t=>(Jr("join.decode",t),t.join(e)),decode:t=>(it("join.decode",t),t.split(e))}}const Qr=(e,t)=>t===0?e:Qr(t,e%t),Nt=(e,t)=>e+(t-Qr(e,t)),At=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function _n(e,t,o,n){if(In(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(o<=0||o>32)throw new Error(`convertRadix2: wrong to=${o}`);if(Nt(t,o)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${o} carryBits=${Nt(t,o)}`);let r=0,s=0;const i=At[t],a=At[o]-1,l=[];for(const d of e){if(Zr(d),d>=i)throw new Error(`convertRadix2: invalid data word=${d} from=${t}`);if(r=r<<t|d,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=o;s-=o)l.push((r>>s-o&a)>>>0);const f=At[s];if(f===void 0)throw new Error("invalid carry");r&=f-1}if(r=r<<o-s&a,!n&&s>=t)throw new Error("Excess padding");if(!n&&r>0)throw new Error(`Non-zero padding: ${r}`);return n&&s>0&&l.push(r>>>0),l}function ha(e,t=!1){if(Zr(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Nt(8,e)>32||Nt(e,8)>32)throw new Error("radix2: carry overflow");return{encode:o=>{if(!Vr(o))throw new Error("radix2.encode input should be Uint8Array");return _n(Array.from(o),8,e,!t)},decode:o=>(Kr("radix2.decode",o),Uint8Array.from(_n(o,e,8,t)))}}function Zo(e){return la(e),function(...t){try{return e.apply(null,t)}catch{}}}const $n=da(ua("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),fa("")),Jo=[996825010,642813549,513874426,1027748829,705979059];function Je(e){const t=e>>25;let o=(e&33554431)<<5;for(let n=0;n<Jo.length;n++)(t>>n&1)===1&&(o^=Jo[n]);return o}function Ko(e,t,o=1){const n=e.length;let r=1;for(let s=0;s<n;s++){const i=e.charCodeAt(s);if(i<33||i>126)throw new Error(`Invalid prefix (${e})`);r=Je(r)^i>>5}r=Je(r);for(let s=0;s<n;s++)r=Je(r)^e.charCodeAt(s)&31;for(let s of t)r=Je(r)^s;for(let s=0;s<6;s++)r=Je(r);return r^=o,$n.encode(_n([r%At[30]],30,5,!1))}function pa(e){const t=e==="bech32"?1:734539939,o=ha(5),n=o.decode,r=o.encode,s=Zo(n);function i(c,h,m=90){it("bech32.encode prefix",c),Vr(h)&&(h=Array.from(h)),Kr("bech32.encode",h);const y=c.length;if(y===0)throw new TypeError(`Invalid prefix length ${y}`);const b=y+7+h.length;if(m!==!1&&b>m)throw new TypeError(`Length ${b} exceeds limit ${m}`);const g=c.toLowerCase(),E=Ko(g,h,t);return`${g}1${$n.encode(h)}${E}`}function a(c,h=90){it("bech32.decode input",c);const m=c.length;if(m<8||h!==!1&&m>h)throw new TypeError(`invalid string length: ${m} (${c}). Expected (8..${h})`);const y=c.toLowerCase();if(c!==y&&c!==c.toUpperCase())throw new Error("String must be lowercase or uppercase");const b=y.lastIndexOf("1");if(b===0||b===-1)throw new Error('Letter "1" must be present between prefix and data only');const g=y.slice(0,b),E=y.slice(b+1);if(E.length<6)throw new Error("Data must be at least 6 characters long");const _=$n.decode(E).slice(0,-6),A=Ko(g,_,t);if(!E.endsWith(A))throw new Error(`Invalid checksum in ${c}: expected "${A}"`);return{prefix:g,words:_}}const l=Zo(a);function d(c){const{prefix:h,words:m}=a(c,!1);return{prefix:h,words:m,bytes:n(m)}}function f(c,h){return i(c,r(h))}return{encode:i,decode:a,encodeFromBytes:f,decodeToBytes:d,decodeUnsafe:l,fromWords:n,fromWordsUnsafe:s,toWords:r}}const Ot=pa("bech32");var yt=new TextDecoder("utf-8");new TextEncoder;var es=5e3;function Wn(e){let{prefix:t,words:o}=Ot.decode(e,es),n=new Uint8Array(Ot.fromWords(o));switch(t){case"nprofile":{let r=mn(n);if(!r[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(r[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:ae(r[0][0]),relays:r[1]?r[1].map(s=>yt.decode(s)):[]}}}case"nevent":{let r=mn(n);if(!r[0]?.[0])throw new Error("missing TLV 0 for nevent");if(r[0][0].length!==32)throw new Error("TLV 0 should be 32 bytes");if(r[2]&&r[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(r[3]&&r[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:ae(r[0][0]),relays:r[1]?r[1].map(s=>yt.decode(s)):[],author:r[2]?.[0]?ae(r[2][0]):void 0,kind:r[3]?.[0]?parseInt(ae(r[3][0]),16):void 0}}}case"naddr":{let r=mn(n);if(!r[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!r[2]?.[0])throw new Error("missing TLV 2 for naddr");if(r[2][0].length!==32)throw new Error("TLV 2 should be 32 bytes");if(!r[3]?.[0])throw new Error("missing TLV 3 for naddr");if(r[3][0].length!==4)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:yt.decode(r[0][0]),pubkey:ae(r[2][0]),kind:parseInt(ae(r[3][0]),16),relays:r[1]?r[1].map(s=>yt.decode(s)):[]}}}case"nsec":return{type:t,data:n};case"npub":case"note":return{type:t,data:ae(n)};default:throw new Error(`unknown prefix ${t}`)}}function mn(e){let t={},o=e;for(;o.length>0;){if(o.length<2)throw new Error("not enough data to read TLV");let n=o[0],r=o[1],s=o.slice(2,2+r);if(o=o.slice(2+r),s.length<r)throw new Error(`not enough data to read on TLV ${n}`);t[n]=t[n]||[],t[n].push(s)}return t}function ma(e){return ns("npub",Re(e))}function ts(e){return ns("note",Re(e))}function ga(e,t){let o=Ot.toWords(t);return Ot.encode(e,o,es)}function ns(e,t){return ga(e,t)}function ba(e){const t=Wn(e);if(!t)throw new Error(`not a NIP-19 pointer: ${e}`);return t}function zn(e){return ma(e)}function ya(e){return ts(e)}function wa(e){const t=ba(e.trim());if(t.type!=="note")throw new Error(`not a note id: ${e}`);return t.data}function Ut(e){try{return JSON.parse(e.content)}catch{return}}function Ea(e){const t=[],o=/nostr:(npub1[a-z0-9]+|nprofile1[a-z0-9]+|note1[a-z0-9]+)/gi;for(const n of e.matchAll(o)){const r=n[1];if(r)try{t.push(Wn(r))}catch{}}return t}function os(e){if(e.type==="npub")return e.data;if(e.type==="nprofile")return e.data.pubkey}function va(e){try{return ts(e)}catch{return e}}function xa(e){try{const t=Wn(e),o=os(t);return o?{pubkey:o}:void 0}catch{return}}const Sa={nostrLink:/nostr:(npub1[a-z0-9]+|nprofile1[a-z0-9]+|note1[a-z0-9]+)/gi};function qe(e,t){const o=[];for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}function rs(e,t,o){const n=new Set(t.map(i=>i.id)),r=new Map;for(const i of e){if(i.kind!==o)continue;let a;for(const d of i.tags)d[0]==="e"&&d[1]&&n.has(d[1])&&(a=d[1]);if(!a)continue;let l=r.get(a);l||r.set(a,l=new Map),l.set(i.id,i)}const s=new Map;for(const[i,a]of r){const l=[...a.values()].sort((d,f)=>d.created_at-f.created_at);l.length>0&&s.set(i,l)}return s}function ka(e,t){const o=rs(e,t,z.reaction),n={};for(const[r,s]of o)n[r]=s.map(i=>({id:i.id,pubkey:i.pubkey,content:i.content}));return n}function ot(e){let t,o;for(const n of e.tags){if(n[0]!=="e"||!n[1])continue;const r=n[3];r!=="mention"&&(r==="reply"&&(t=n[1]),o=n[1])}return t??o}const ss=32;function Aa(e,t){const o=e.known.get(t);return o?ot(o):void 0}function Ra(e,t){const o=[t],n=new Set([t]);for(;o.length<=ss;){const r=Aa(e,o[o.length-1]);if(!r||n.has(r)||!e.known.has(r))break;o.push(r),n.add(r)}return o}async function Ma(e,t){const{known:o,runQuery:n,idsPerRequest:r,replyLimit:s,log:i}=e;let a=new Set;for(const g of t){const E=ot(g);E&&!o.has(E)&&a.add(E)}for(let g=0;a.size>0&&g<ss;g++){const E=[...a];a=new Set;for(const _ of qe(E,r))for(const A of await n({kinds:[z.note],ids:_})){const O=ot(A);O&&!o.has(O)&&a.add(O)}}const l=new Map,d=new Map,f=new Map,c=(g,E)=>{const _=o.get(g);if(!_||(l.set(g,E),!E.parent))return;const A=d.get(E.parent)??[];A.push({id:g,pubkey:_.pubkey,parent:E.parent,created_at:_.created_at}),d.set(E.parent,A),f.set(E.root,(f.get(E.root)??0)+1)};for(const g of t){const E=Ra(e,g.id),_=E[E.length-1];for(const[A,O]of E.entries())l.has(O)||c(O,{parent:E[A+1],root:_})}const h=[...l.keys()];for(let g=0;g<h.length;g+=r){const E=h.slice(g,g+r),_=await n({kinds:[z.note],"#e":E,limit:s});for(const A of _){if(l.has(A.id))continue;const O=ot(A);if(!O)continue;const F=l.get(O);F&&((f.get(F.root)??0)>=s||(c(A.id,{parent:O,root:F.root}),h.push(A.id)))}}const m={},y=[];for(const[g,E]of l){if(E.parent)continue;y.push(g);const _=[],A=new Set([g]),O=F=>{for(const M of d.get(F)??[])A.has(M.id)||(A.add(M.id),_.push(M),O(M.id))};O(g),_.length>0&&(_.sort((F,M)=>F.created_at-M.created_at),m[g]=_)}const b=Object.values(m).reduce((g,E)=>g+E.length,0);return i(`threads: ${Object.keys(m).length} roots with ${b} replies (from ${y.length} roots)`),{threads:m,roots:y}}function is(e){const t=[];for(const o of Ea(e)){const n=os(o);n&&t.push(n)}return t}function Ia(e){let t;for(const o of e.tags)o[0]==="e"&&o[1]&&(t=o[1]);return t}function _a(e,t){const o={};for(const[n,r]of rs(e,t,z.repost))o[n]=r.map(s=>({id:s.id,pubkey:s.pubkey}));return o}async function $a(e){const{known:t,follows:o,noteLimit:n,repostLimit:r,idsPerRequest:s,runQuery:i,log:a}=e,l=[...t.values()].filter(m=>m.kind===z.note&&o.has(m.pubkey)).sort((m,y)=>y.created_at-m.created_at).slice(0,n),d=new Map;for(const m of t.values()){if(m.kind!==z.repost||!o.has(m.pubkey))continue;const y=Ia(m);if(!y||t.has(y))continue;const b=d.get(y);(!b||b.created_at<m.created_at)&&d.set(y,m)}const f=[...d.entries()].sort((m,y)=>y[1].created_at-m[1].created_at).slice(0,r).map(([m])=>m);if(f.length>0){a(`fetching ${f.length} notes the follows reposted`);for(const m of qe(f,s))await i({kinds:[z.note],ids:m})}const c=f.map(m=>t.get(m)).filter(m=>!!m),h=[...l,...c].sort((m,y)=>y.created_at-m.created_at);return{notes:l,repostNotes:c,kept:h}}function gn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Qo=e=>Math.min(1,Math.max(0,e));async function as(e,t,o){if(e.length===0)return null;const r=(await t({kinds:[z.judgement],authors:[jt],"#d":[Qi],limit:1})).filter(d=>d.kind===z.judgement).sort((d,f)=>f.created_at-d.created_at)[0];if(!r)return o("no batch judgements published"),null;let s;try{s=JSON.parse(r.content)}catch{return o(`judgement event ${r.id.slice(0,8)}… has a body that is not JSON — ignoring it`),null}if(!gn(s)||!gn(s.judgements))return o("judgement event has no usable readings map — ignoring it"),null;const i=new Set(e),a={};for(const[d,f]of Object.entries(s.judgements)){if(!i.has(d)||!gn(f))continue;const{build:c,relevant:h}=f;typeof c!="number"||!Number.isFinite(c)||typeof h!="number"||!Number.isFinite(h)||(a[d]={build:Qo(c),relevant:Qo(h)})}const l=Object.keys(a).length;return l===0?(o(`the judgements published ${new Date(r.created_at*1e3).toISOString()} cover none of this feed's roots`),null):(o(`read ${l}/${e.length} judgements (published ${new Date(r.created_at*1e3).toISOString()})`),{judgements:a,jev:{baseUrl:"",model:typeof s.model=="string"?s.model:"jev-latest",prompt:typeof s.prompt=="string"?s.prompt:Dt}})}function Na(e,t={}){const{timeoutMs:o=Yn,signal:n,log:r=()=>{}}=t;return as(e,s=>Vn([s],{timeoutMs:o,signal:n},r),r)}async function Vn(e,t,o){try{return await Gr(e,{...t,onClose:n=>o(`outbox subscription closed: ${n}`)})}catch(n){return o(`outbox subscription failed: ${n instanceof Error?n.message:String(n)}`),[]}}async function Oa(e={}){const{pubkey:t=await To.getPublicKey(),noteLimit:o=Xi,since:n=Math.floor((Date.now()-Zi)/1e3),authorsPerRequest:r=Hr,replyLimit:s=Ki,repostLimit:i=Ji,timeoutMs:a=Yn,signal:l,log:d=()=>{},onProgress:f=()=>{}}=e,c=new Map,h={stage:"notes",follows:0,profiles:0,batches:0,batchesTotal:0,notes:0,threads:0,replies:0},m=()=>{let N=0;for(const L of c.values())L.kind===z.note&&(N+=1);return N},y=()=>{f({...h})},b=(N,L)=>Vn(N,{timeoutMs:a,signal:l,onEvent(ie){c.set(ie.id,ie),ie.kind===z.note&&L?.()}},d),g=(N,L)=>b([N]),E=await To.getFollows();if(E.length===0)throw new Error("the account follows nobody yet — follow someone to give the field something to draw");d(`reading ${E.length} follows through the outbox`);const _=qe(E,r),A=Math.max(r,150),O=Math.ceil(o/_.length)+r,F=n===null?{}:{since:n};h.follows=E.length,h.batchesTotal=_.length,y();let M=!1;const K=Promise.resolve().then(async()=>{for(const N of qe(E,qr))await g({kinds:[z.profile],authors:N,limit:N.length});M=!0,h.profiles=[...c.values()].filter(N=>N.kind===z.profile).length,y(),d(`${h.profiles} profiles (${E.length} follows)`)}),X=new Set(E);let T=new Set;const te=()=>{if(!e.onPreview)return;const N=[...c.values()].filter(L=>L.kind===z.note&&X.has(L.pubkey)&&!ot(L)).sort((L,ie)=>ie.created_at-L.created_at).slice(0,o);N.some(L=>!T.has(L.id))&&(T=new Set(N.map(L=>L.id)),e.onPreview(N))};for(const N of _)await b([{kinds:[z.note],authors:N,limit:O,...F},{kinds:[z.repost],authors:N,limit:O,...F}],te),h.batches+=1,h.notes=m(),y();h.stage="reposts",y();const{repostNotes:J,kept:C}=await $a({known:c,follows:X,noteLimit:o,repostLimit:i,idsPerRequest:r,runQuery:g,log:d});h.notes=C.length,h.stage="threads",y();const{threads:v,roots:I}=await Ma({known:c,runQuery:g,idsPerRequest:A,replyLimit:s,log:d},C);h.threads=Object.keys(v).length,h.replies=Object.values(v).reduce((N,L)=>N+L.length,0),h.stage="activity",y();const D=I.map(N=>c.get(N)).filter(N=>!!N);e.onPreview&&!T.size&&D.length&&o>0&&e.onPreview([...D].sort((N,L)=>L.created_at-N.created_at).slice(0,o));const[x,B,R]=await Promise.all([I.length?g({kinds:[z.reaction],"#e":I,limit:500}):[],I.length?g({kinds:[z.repost],"#e":I,limit:500}):[],as(I,g,d)]);M||(h.stage="profiles",y()),await K;const P=ka(x,D),$=_a(B,D),U=new Set([...C.map(N=>N.id),...I,...Object.values(v).flatMap(N=>N.map(L=>L.id))]),j=[...U].map(N=>c.get(N)).filter(N=>!!N),G=[...new Set([...D.map(N=>N.pubkey),...Object.values(v).flatMap(N=>N.map(L=>L.pubkey))])],Q=[...new Set(Object.values($).flatMap(N=>N.map(L=>L.pubkey)))],W=[...new Set(j.flatMap(N=>is(N.content)))],H=new Set([...c.values()].filter(N=>N.kind===z.profile).map(N=>N.pubkey)),oe=[...new Set([...G,...Q,...W])].filter(N=>!H.has(N));oe.length&&(h.stage="profiles",y());for(const N of qe(oe,r))await g({kinds:[z.profile],authors:N,limit:N.length}),h.profiles=[...c.values()].filter(L=>L.kind===z.profile).length,y();const fe=[...c.values()].filter(N=>N.kind===z.note&&U.has(N.id)).sort((N,L)=>L.created_at-N.created_at),ee=[...c.values()].filter(N=>N.kind===z.profile),re=[...ee,...fe],Z=Object.values(v).reduce((N,L)=>N+L.length,0);return d(`built ${fe.length} notes (${J.length} reposted by a follow) in ${I.length} roots, ${Object.keys(v).length} threads with ${Z} replies and ${ee.length} profiles`),{version:2,generatedAt:Date.now(),relays:[],profileRelays:[],npub:zn(t),pubkey:t,contacts:{id:"",created_at:0,follows:E},since:n,events:re,...R?{judgements:R.judgements,jev:R.jev}:{},reactions:P,reposts:$,threads:v,stats:{follows:E.length,notes:C.length,repostNotes:J.length,profiles:ee.length,events:re.length,threads:Object.keys(v).length,replies:Z}}}function er(e){const t=new Set(e.events.filter(n=>n.kind===z.profile).map(n=>n.pubkey)),o=new Set([e.pubkey]);for(const n of e.events)if(n.kind===z.note){o.add(n.pubkey);for(const r of is(n.content))o.add(r)}for(const n of Object.values(e.threads??{}))for(const r of n)o.add(r.pubkey);for(const n of Object.values(e.reposts??{}))for(const r of n)o.add(r.pubkey);return[...o].filter(n=>!t.has(n))}async function Ba(e,t={}){const{timeoutMs:o=Yn,signal:n,log:r=()=>{}}=t;if(e.length===0)return[];const s=[];for(const i of qe(e,qr)){const a=await Vn([{kinds:[z.profile],authors:i,limit:i.length}],{timeoutMs:o,signal:n},r);for(const l of a)l.kind===z.profile&&s.push(l)}return r(`asked for ${e.length} profiles, got ${s.length}`),s}function Ca(e,t){const o=new Map;for(const r of e.events)r.kind===z.profile&&o.set(r.pubkey,r);let n=0;for(const r of t){if(r.kind!==z.profile)continue;const s=o.get(r.pubkey);if(s&&s.created_at>=r.created_at)continue;const i=e.events.findIndex(a=>a.kind===z.profile&&a.pubkey===r.pubkey);i>=0?e.events[i]=r:e.events.push(r),o.set(r.pubkey,r),n+=1}return n}const Xn=new Map;async function La(){try{const e=await xn.keys(),t=await Promise.all(e.map(async o=>[o,await xn.getItem(o)]));for(const[o,n]of t)n!==null&&Xn.set(o,n)}catch{}}function Ht(e){return Xn.get(e)??null}function qt(e,t){Xn.set(e,t);try{xn.setItem(e,t).catch(()=>{})}catch{}}const cs="bubbles.seen",ls="bubbles.hideSeen",ds=1,wt=5e3;function Ta(e){const t=new Set(e),o=new Set(fs().filter(i=>t.has(i))),n=[];function r(){const i=[...o].filter(a=>t.has(a)).slice(-4e3);qt(cs,JSON.stringify({v:ds,ids:i}))}function s(){r();for(const i of n)i()}return{has:i=>o.has(i),mark(i){!t.has(i)||o.has(i)||(o.add(i),s())},forget(i){o.delete(i)&&s()},reset(){o.size!==0&&(o.clear(),s())},onChange(i){n.push(i)}}}function us(){return Ht(ls)!=="false"}function Pa(e){qt(ls,String(e))}function ja(e){const t=document.createElement("p");t.className="hud-seen-row";const o=document.createElement("button");o.type="button",o.className="hud-seen",o.textContent="hide seen",o.title="read a note and it dims; hide the ones you have read so the rest get the room (h)",o.addEventListener("click",()=>e.onToggle(!e.isHiding()));const n=document.createElement("span");n.className="hud-seen-count",n.setAttribute("aria-live","polite");const r=document.createElement("button");r.type="button",r.className="hud-seen-reset",r.textContent="reset",r.title="forget every note you have read",r.addEventListener("click",()=>e.onReset()),t.append(o,n,r);function s(){const{seen:i,total:a}=e.counts(),l=e.isHiding();o.setAttribute("aria-pressed",String(l)),n.textContent=i===0?a>0?`nothing read yet · ${a} in the field`:"nothing read yet":i>=a?`all ${a} notes read`:`${i} of ${a} notes read`,r.hidden=i===0}return s(),{element:t,refresh:s}}function fs(){const e=Ht(cs);if(!e)return[];try{const t=JSON.parse(e);return t.v!==ds||!Array.isArray(t.ids)?[]:t.ids.filter(o=>typeof o=="string")}catch{return[]}}function Da(){const e=new Map;return{add(t){e.set(t.id,t)},getEvent(t){return e.get(t)},getReplaceable(t,o){let n;for(const r of e.values())r.kind!==t||r.pubkey!==o||(!n||r.created_at>n.created_at)&&(n=r);return n}}}const hs=["build","fun","relevant","irrelevant"];function Zn(e){const t=Math.max(0,Math.floor((Date.now()-e.getTime())/1e3));if(t<60)return`${t}s ago`;const o=Math.floor(t/60);if(o<60)return`${o}m ago`;const n=Math.floor(o/60);if(n<24)return`${n}h ago`;const r=Math.floor(n/24);return r<30?`${r}d ago`:e.toLocaleDateString()}function Jn(e){return`${e.slice(0,8)}…${e.slice(-6)}`}function Ua(e,t=Date.now()){if(e===null)return"all time";const o=Math.max(0,t-e*1e3)/864e5;if(o>=1.5)return`last ${Math.round(o)}d`;if(o>=1)return"last 24h";const n=o*24;return n>=1?`last ${Math.round(n)}h`:`last ${Math.max(1,Math.round(n*60))}m`}function Ha(e){const t=document.createElement("div");t.className="hud-prompt-row";const o=document.createElement("span");o.className="hud-prompt-label";const n=document.createElement("span");n.className="hud-prompt-text";const r=document.createElement("span");return r.className="hud-status",t.append(o,n,r),{element:t,refresh(s){const i=Object.keys(s.judgements??{}).length;o.textContent=i>0?"judged against":"not judged yet",n.textContent=n.title=s.jev?.prompt??Dt,r.textContent=`${i}/${e} notes`},dispose:()=>t.remove()}}function tr(e){const t=document.createElement("button");t.type="button",t.className="hud-toggle",t.textContent=e.label,t.title=e.title,t.addEventListener("click",()=>{e.onChange(t.getAttribute("aria-pressed")!=="true")});function o(n){t.setAttribute("aria-pressed",String(n))}return o(e.pressed),{element:t,set:o}}const qa={follow:22,repel:5e3,repelRange:120,stiffness:1400,damping:14,holdDamping:12,hold:26,bond:4e3,maxSpeed:900,wall:40},Ga=2;class Bt{bubbles=[];poles=[];centroid={x:0,y:0};bounds={minX:0,minY:0,maxX:0,maxY:0};tuning={...qa};fixedStep=1/120;constructor(t=[]){this.bubbles.push(...t)}static pole(t,o=0,n=0){return{id:t,x:o,y:n}}static bubble(t,o,n,r,s,i=1){return{id:t,x:o,y:n,vx:0,vy:0,r,weights:s,hidden:!1,tailDepth:0,hold:0,holdX:o,holdY:n,scale:i,scaleTarget:i,ax:0,ay:0}}targetFor(t){const o=this.middle();if(this.poles.length<2)return{x:o.x,y:o.y};let n=o.x,r=o.y;const s=Math.min(t.length,this.poles.length);for(let i=0;i+1<s;i+=2){const a=this.poles[i],l=this.poles[i+1],d=Math.max(0,t[i]??0),f=Math.max(0,t[i+1]??0),c=d+f;if(c<=1e-9)continue;const h=(f-d)/c;n+=(l.x-a.x)/2*h,r+=(l.y-a.y)/2*h}return{x:n,y:r}}middle(){if(this.poles.length===0)return{x:this.centroid.x,y:this.centroid.y};let t=0,o=0;for(const n of this.poles)t+=n.x,o+=n.y;return{x:t/this.poles.length,y:o/this.poles.length}}bubbleAt(t,o){let n,r=1/0;for(const s of this.bubbles){if(s.hidden)continue;const i=t-s.x,a=o-s.y,l=s.r*Math.max(s.scale,1)+4;i*i+a*a>l*l||s.r<r&&(n=s,r=s.r)}return n}maxSpeed(){let t=0;for(const o of this.bubbles){const n=Math.sqrt(o.vx*o.vx+o.vy*o.vy);n>t&&(t=n)}return t}isSettled(t=Ga){if(this.maxSpeed()>t)return!1;for(const o of this.bubbles)if(o.hold>0||Math.abs(o.scale-o.scaleTarget)>.002)return!1;return!0}step(t){const o=Math.min(6,Math.max(1,Math.ceil(t/this.fixedStep))),n=t/o;for(let r=0;r<o;r++)this.integrate(n);this.easeScale(t)}easeScale(t){const o=1-Math.exp(-16*t);for(const n of this.bubbles)n.scale+=(n.scaleTarget-n.scale)*o}freeze(){for(const t of this.bubbles)t.vx=0,t.vy=0,t.ax=0,t.ay=0;this.measure()}measure(){const{bubbles:t,centroid:o}=this;let n=0,r=0;for(const i of t)n+=i.x,r+=i.y;const s=Math.max(1,t.length);o.x=n/s,o.y=r/s}integrate(t){const{bubbles:o,bounds:n,tuning:r}=this;if(o.length===0)return;this.measure();const s=o.filter(c=>!c.hidden);if(s.length===0)return;const i=s.filter(c=>c.bond),a=s.filter(c=>!c.bond),l=new Map(s.map(c=>[c.id,c]));for(const c of s){if(c.bond){c.ax=0,c.ay=0;continue}const h=this.targetFor(c.weights);c.ax=(h.x-c.x)*r.follow,c.ay=(h.y-c.y)*r.follow}const d=r.repelRange,f=a.length;for(let c=0;c<f;c++){const h=a[c];for(let m=c+1;m<f;m++){const y=a[m],b=h.r+y.r;let g=y.x-h.x,E=y.y-h.y;const _=b+d,A=g*g+E*E;if(A>_*_)continue;let O=Math.sqrt(A);if(O<1e-4){const I=(c*7+m*13)%360*(Math.PI/180);g=Math.cos(I),E=Math.sin(I),O=1}const F=g/O,M=E/O,K=h.r*h.r,X=y.r*y.r,T=X/(K+X),te=K/(K+X),J=Math.max(0,b-O),C=1-Math.max(0,O-b)/r.repelRange,v=r.repel*C*C+J*r.stiffness;h.ax-=F*v*T,h.ay-=M*v*T,y.ax+=F*v*te,y.ay+=M*v*te}}if(i.length>0)for(const c of i){const h=c.bond,m=l.get(h.id);m&&(c.hold>0||(c.ax+=(m.x+h.dx-c.x)*r.bond,c.ay+=(m.y+h.dy-c.y)*r.bond))}for(const c of s){c.hold>0&&(c.ax+=(c.holdX-c.x)*r.hold*c.hold,c.ay+=(c.holdY-c.y)*r.hold*c.hold);const h=n.minX+c.r,m=n.maxX-c.r,y=n.minY+c.r,b=n.maxY-c.r-c.tailDepth;c.x<h&&(c.ax+=(h-c.x)*r.wall),c.x>m&&(c.ax-=(c.x-m)*r.wall),c.y<y&&(c.ay+=(y-c.y)*r.wall),c.y>b&&(c.ay-=(c.y-b)*r.wall),c.vx+=c.ax*t,c.vy+=c.ay*t;const g=c.hold>0?r.holdDamping:r.damping,E=Math.exp(-g*t);c.vx*=E,c.vy*=E;const _=Math.sqrt(c.vx*c.vx+c.vy*c.vy);if(_>r.maxSpeed){const A=r.maxSpeed/_;c.vx*=A,c.vy*=A}c.x+=c.vx*t,c.y+=c.vy*t,c.x<h?(c.x=h,c.vx<0&&(c.vx=0)):c.x>m&&(c.x=m,c.vx>0&&(c.vx=0)),c.y<y?(c.y=y,c.vy<0&&(c.vy=0)):c.y>b&&(c.y=b,c.vy>0&&(c.vy=0))}}}const Ye=44,Gt=1.6,Me=1/4,Ya=Me*.8,Ee=Ye*Ya,Fa=1.06,Wa=1.1,ps=3,za={build:"Build",fun:"Fun",relevant:"Relevance",irrelevant:"Irrelevant"},Va={build:"Useful",fun:"Fun"};function Kn(e,t=1/0){const o=new Map;for(const[n,r]of e.entries()){const s=Xa(r.content),i=o.get(s);i?i.count++:o.set(s,{count:1,first:n})}return[...o].sort((n,r)=>r[1].count-n[1].count||n[1].first-r[1].first).slice(0,t===1/0?void 0:Math.max(0,t)).map(([n,r])=>({glyph:n,count:r.count}))}function Xa(e){const t=e.trim();if(t===""||t==="+")return"♥";if(t==="-")return"▼";if(t.startsWith(":")&&t.endsWith(":")||/^https?:\/\//i.test(t))return"♥";const o=Array.from(t);let n=1;for(;n<o.length;){const r=o[n].codePointAt(0),i=o[n-1].codePointAt(0)===8205||r===65039||r===65038||r===8205,a=r>=127995&&r<=127999;if(!i&&!a)break;n++}return o.slice(0,n).join("")}function ms(e){const t=e.filter(s=>s.judgement),o=[...t].sort((s,i)=>bn(i.judgement??null)-bn(s.judgement??null));let n=0,r=null;for(const[s,i]of o.entries()){const a=bn(i.judgement??null);(r===null||a!==r)&&(n=s+1,r=a),i.rank={place:n,of:t.length}}}function Za(e){const t=new Map,o=[];for(const b of e.events)if(b.kind===z.profile){const g=t.get(b.pubkey);(!g||b.created_at>g.created_at)&&t.set(b.pubkey,b)}else b.kind===z.note&&o.push(b);o.sort((b,g)=>g.created_at-b.created_at);const n=e.reactions??{},r=e.reposts??{},s=e.threads??{},i=new Set(e.contacts?.follows??[]);i.add(e.pubkey);const a=new Map(o.map(b=>[b.id,b])),l=b=>{const g=t.get(b);return g?Ut(g):void 0},d=b=>Ce(l(b),b),f=new Map,c=new Set;for(const b of Object.values(e.threads??{}))for(const g of b){c.add(g.id);const E=f.get(g.parent)??[];E.push(g),f.set(g.parent,E)}const h=o.reduce((b,g)=>{if(c.has(g.id))return b;const E=(n[g.id]?.length??0)+(s[g.id]?.length??0);return Math.max(b,E)},0),m=(b,g)=>{const E=a.get(b.id);if(!E||g.has(b.id))return null;g.add(b.id);const _=(f.get(b.id)??[]).map(O=>m(O,g)).filter(O=>O!==null),A=l(E.pubkey);return{root:!1,placement:i.has(E.pubkey)?"face":"hidden",count:1,id:E.id,pubkey:E.pubkey,name:Ce(A,E.pubkey),picture:A?.picture??A?.image,hue:rt(E.pubkey),radius:Ee,parent:b.parent,parentName:d(b.parent),event:E,children:_}},y=o.filter(b=>!c.has(b.id)).map(b=>{const g=l(b.pubkey),E=e.judgements?.[b.id]??null,_=n[b.id]??[],A=(r[b.id]??[]).map(X=>{const T=l(X.pubkey);return{pubkey:X.pubkey,name:Ce(T,X.pubkey),picture:T?.picture??T?.image,hue:rt(X.pubkey)}}),O=A.filter(X=>i.has(X.pubkey)),F=new Set([b.id]),M=(f.get(b.id)??[]).map(X=>m(X,F)).filter(X=>X!==null);Ja(M);const K=Ka(_.length+Yt({children:M}),h);return{root:!0,id:b.id,pubkey:b.pubkey,name:Ce(g,b.pubkey),picture:g?.picture??g?.image,hue:rt(b.pubkey),baseRadius:K,radius:K,reactions:_,reposts:O,repostsHidden:A.length-O.length,event:b,judgement:E,weights:eo(E),children:M,tail:gs(M,K)}});return ms(y),y}function ct(e,t,o){const n=t*2,r=Math.max(2,Math.floor(e*2/n)),s=[];for(let i=0;i<o;i++){const a=Math.floor(i/r),l=Math.min(r,o-a*r);s.push({dx:(i%r-(l-1)/2)*n,dy:e+t+a*n})}return s}function gs(e,t){const o=Qn(e),n=o.filter(a=>a.placement==="face").length,r=o.filter(a=>a.placement==="hidden").length,i=ct(t,Ee,n).at(-1);return{shown:n,chip:r>0?{dx:i?i.dx+Ee+ps:0,dy:i?i.dy:t+Ee,align:i?"left":"center",count:r}:void 0,depth:i?i.dy+Ee:0}}function Ja(e){const t=Qn(e).filter(r=>r.placement==="face"),o=new Map,n=new Map;for(const r of t){const s=o.get(r.pubkey);(!s||r.event.created_at>=s.event.created_at)&&o.set(r.pubkey,r),n.set(r.pubkey,(n.get(r.pubkey)??0)+1)}for(const r of t){const s=o.get(r.pubkey);!s||s===r?r.count=n.get(r.pubkey)??1:r.placement="repeat"}}function Qn(e){const t=[],o=[...e];for(;o.length>0;){const n=o.shift();t.push(n),o.push(...n.children)}return t}function Ka(e,t){const o=t>0?Math.min(1,Math.max(0,e)/t):0,n=Me+(Gt-Me)*o;return Ye*n}function bn(e){const t=Nn(e?.build),o=Nn(e?.relevant);return t+(o-.5)}const Qa=.7;function ec(e){return eo({build:Math.min(1,Math.max(0,e)),relevant:.5})}const tc=.09,nc=4;function oc(e,t,o){const n=Math.PI*Ee*Ee;let r=0;for(const i of e)r+=Math.PI*i.radius*i.radius+i.tail.shown*n;const s=r/(tc*Math.max(1,t));return Math.round(Math.min(Math.max(s,o),o*nc))}function Et(e,t,o=new Set){const n=Ye*Me,r=Ye*Gt,s=t?rc(e,o):null;for(const i of e)i.radius=Math.min(r,Math.max(n,i.baseRadius)),i.weights=t?ec((i.root?s.get(i.id):void 0)??.5):eo(i.judgement),i.tail=gs(i.children,i.radius)}function rc(e,t=new Set){const o=e.filter(l=>l.root&&l.rank&&!t.has(l.id));o.sort((l,d)=>(l.rank.place??0)-(d.rank.place??0));const n=new Map,r=o.length;let s=0,i=0,a=null;for(const l of o){(a===null||l.rank.place!==a)&&(i=s,a=l.rank.place);const d=r<=1?1:1-i/(r-1);n.set(l.id,1-Math.pow(1-d,Qa)),s++}return n}function Ce(e,t){for(const o of[e?.display_name,e?.displayName,e?.name])if(o&&o.trim())return o;return Jn(t)}function Nn(e,t=.5){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):t}function eo(e){const t=Nn,o=t(e?.build),n=t(e?.relevant),r=[o,1-o,n,1-n],s=r.reduce((i,a)=>i+a,0);return s<=1e-9?r.map(()=>1/r.length):r.map(i=>i/s)}function rt(e){let t=0;for(let o=0;o<e.length;o++)t=(t*31+e.charCodeAt(o))%1e5;return 190+t%141}function sc(e){const t=[],o=n=>{t.push(n);for(const r of n.children)o(r)};for(const n of e)o(n);return t}function Yt(e){let t=0;for(const o of e.children)t+=1+Yt(o);return t}function ic(e,t,o=.6){const n=Math.PI*(3-Math.sqrt(5)),r=[],s=new Map;for(const[i,a]of e.entries()){const l=t(a.weights),d=i*n,f=o*a.radius,c=Bt.bubble(a.id,l.x+Math.cos(d)*f,l.y+Math.sin(d)*f,a.radius,a.weights);c.tailDepth=a.tail.depth,s.set(a.id,c),r.push(c)}for(const i of e){const a=s.get(i.id);if(!a)continue;const l=Qn(i.children).filter(f=>f.placement==="face"),d=ct(a.r,Ee,i.tail.shown);for(const[f,c]of l.entries()){const{dx:h,dy:m}=d[f],y=Bt.bubble(c.id,a.x+h,a.y+m,c.radius,[]);y.bond={id:a.id,dx:h,dy:m},s.set(c.id,y),r.push(y)}}return r}function ac(e,t){const o=new Map;for(const l of t.events){if(l.kind!==z.profile)continue;const d=o.get(l.pubkey);(!d||l.created_at>d.created_at)&&o.set(l.pubkey,l)}const n=l=>{const d=o.get(l),f=d?Ut(d):void 0;return{name:Ce(f,l),picture:f?.picture??f?.image}};let r=0;const s=new Map,i=[],a=l=>{i.push(l);for(const d of l.children)a(d)};for(const l of e)a(l);for(const l of i){const d=n(l.pubkey);s.set(l.id,d.name),(l.name!==d.name||l.picture!==d.picture)&&(r+=1),l.name=d.name,l.picture=d.picture}for(const l of i){if(l.root)continue;const d=s.get(l.parent);d&&d!==l.parentName&&(l.parentName=d,r+=1)}for(const l of e)for(const d of l.reposts){const f=n(d.pubkey);(d.name!==f.name||d.picture!==f.picture)&&(r+=1),d.name=f.name,d.picture=f.picture}return r}const On=new Map,Bn=new Set;function lt(e){const t=On.get(e);if(t)return t;const o=Ks.bytes(e).then(n=>{const r=URL.createObjectURL(n);return Bn.add(r),r});return On.set(e,o),o}function bs(){for(const e of Bn)URL.revokeObjectURL(e);Bn.clear(),On.clear()}class cc{constructor(t){this.onReady=t}entries=new Map;get(t){if(!t)return{url:"",element:null,state:"empty"};const o=this.entries.get(t);if(o)return o;const n={url:t,element:null,state:"loading"};return this.entries.set(t,n),this.load(t,n),n}async load(t,o){try{const n=await lt(t);if(o.state!=="loading")return;const r=new Image;r.decoding="async",r.addEventListener("load",()=>{o.state=r.naturalWidth>0?"ready":"failed",this.onReady()}),r.addEventListener("error",()=>{o.state="failed",this.onReady()}),o.element=r,r.src=n}catch{o.state="failed",this.onReady()}}dispose(){for(const t of this.entries.values())t.element&&(t.element.src="");this.entries.clear()}}const lc=/\.(mp4|webm|mov|m4v|mp3|m4a|ogg|wav|pdf|zip|epub|apk)(\?|#|$)/i,dc=["nostr.build","nostrcheck.me","void.cat","blossom","nostr.download","imgur.com","catbox.moe","media.tenor.com","pbs.twimg.com"],uc=/\bhttps?:\/\/[^\s<>()"']+/gi;function fc(e){if(lc.test(e))return!1;const t=e.split(/[?#]/)[0]??e;if(/\.(png|jpe?g|gif|webp|avif|bmp)$/i.test(t))return!0;const o=hc(e);return o!==null&&dc.some(n=>o.endsWith(n))}function hc(e){try{return new URL(e).host.toLowerCase()}catch{return null}}function pc(e,t=3){const o=[];let n=e;for(const s of e.matchAll(uc)){const i=s[0];fc(i)&&(o.includes(i)||o.push(i),n=n.replace(new RegExp(`\\s*${mc(i)}\\s*`)," "))}const r=o.slice(0,t);return{text:n.replace(/[ \t]+/g," ").replace(/\n{3,}/g,`
`).trim(),images:r,extra:o.length-r.length}}function mc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gc(e){const t=[];let o=0;for(const n of e.matchAll(Sa.nostrLink)){const r=xa(n[1]);if(!r)continue;const s=n.index??0;s>o&&t.push({kind:"text",text:e.slice(o,s)}),t.push({kind:"mention",pubkey:r.pubkey,raw:n[0]}),o=s+n[0].length}return o<e.length&&t.push({kind:"text",text:e.slice(o)}),t}const bc=60,yn=8;function yc(e,t){const o=document.createElement("aside");o.className="panel",o.tabIndex=-1,o.setAttribute("role","region"),o.setAttribute("aria-label","selected note");const n=document.createElement("button");n.className="panel-close",n.type="button",n.title="close (esc)",n.setAttribute("aria-label","close"),n.textContent="×",n.addEventListener("click",()=>t.onClose());const r=document.createElement("button");r.className="panel-expand",r.type="button",r.title="expand (e)",r.setAttribute("aria-label","expand the note"),r.setAttribute("aria-pressed","false"),r.addEventListener("click",()=>K(!_));const s=document.createElement("header");s.className="panel-head";const i=document.createElement("div");i.className="panel-dwell",i.setAttribute("aria-hidden","true");const a=document.createElement("span");a.className="panel-avatar";const l=document.createElement("h2");l.className="panel-name";const d=document.createElement("button");d.type="button",d.className="panel-author",d.title="open their profile",d.append(a,l);const f=document.createElement("p");f.className="panel-meta";const c=document.createElement("button");c.type="button",c.className="panel-seen",c.textContent="seen",c.title="mark this thread unread",c.hidden=!0,c.addEventListener("click",()=>t.onUnsee?.()),s.append(n,r,d,f,c);const h=document.createElement("div");h.className="panel-notes",o.append(i,s,h);let m=null,y=null,b=null,g=null,E=0,_=!1;d.addEventListener("click",()=>{g&&t.onProfile?.(g)});const A=new ResizeObserver(()=>{m=null,t.onResize?.()});A.observe(o);function O(){if(!g)return;const x=g.root?[Ec(g),xc(g),or(g)]:[`replying to ${g.parentName}`,or(g)];f.textContent=x.filter(Boolean).join(" · ")}function F(x){b!==x.id&&(b=x.id,m=null,y=null,X(0),o.classList.remove("open"),o.offsetWidth),o.classList.add("open"),g=x,o.style.setProperty("--hue",String(x.hue)),o.setAttribute("aria-label",`${x.root?"note":"reply"} by ${x.name}`),l.textContent=x.name,d.setAttribute("aria-label",`open the profile of ${x.name}`),rr(a,x.picture,x.name),O();const B=[],R=C(t.ancestors?.(x)??[]);R&&B.push(R),B.push(kc(x,e,"reactions"in x?x.reactions:[]));const P=I(x);P&&B.push(P),h.replaceChildren(...B)}function M(){o.classList.remove("open"),b=null,g=null,y=null}function K(x){_!==x&&(_=x,o.dataset.expanded=x?"true":"false",r.title=x?"collapse (e)":"expand (e)",r.setAttribute("aria-label",x?"collapse the note":"expand the note"),r.setAttribute("aria-pressed",x?"true":"false"),m=null,y=null,t.onExpand?.(x),o.classList.contains("open")&&(o.classList.remove("open"),o.offsetWidth,o.classList.add("open")))}function X(x){const B=Math.max(0,Math.min(1,x));B!==E&&(E=B,i.style.transform=`scaleX(${B})`)}function T(x){c.hidden=!x}function te(){return m??={width:o.offsetWidth,height:o.offsetHeight}}function J(x){y&&y.left===x.left&&y.top===x.top&&y.side===x.side||(y=x,o.style.left=`${x.left}px`,o.style.top=`${x.top}px`,o.dataset.side=x.side,o.style.transformOrigin=wc[x.side])}function C(x){if(x.length===0)return null;const B=document.createElement("div");B.className="panel-context",B.setAttribute("aria-label","the thread this answers");const R=x[0],P=x.slice(-2),$=x.length-1-P.length,U=$>0?[R,null,...P]:x;for(const j of U){if(!j){const G=document.createElement("p");G.className="panel-context-gap",G.textContent=`… ${$} more repl${$===1?"y":"ies"} above`,B.append(G);continue}B.append(v(j,j.root))}return B}function v(x,B){const R=document.createElement("button");R.type="button",R.className="panel-context-row",R.style.setProperty("--hue",String(x.hue));const P=B?"root event":"reply event",$=nr(x.event.content);R.setAttribute("aria-label",`${P} by ${x.name}: ${$}`);const U=document.createElement("span");U.className="panel-context-role",U.textContent=P;const j=document.createElement("span");j.className="panel-context-name",j.textContent=x.name;const G=document.createElement("span");return G.className="panel-context-text",G.textContent=$||"(empty note)",R.append(U,j,G),R.addEventListener("click",()=>t.onSelect?.(x.id)),R}function I(x){if(x.children.length===0)return null;const B=Yt(x),R=document.createElement("div");R.className="panel-replies";const P=document.createElement("p");P.className="panel-replies-head",P.textContent=`${B} repl${B===1?"y":"ies"}`,R.append(P);let $=0;const U=(j,G)=>{for(const Q of j){if($>=bc)return;$++,R.append(D(Q,G)),U(Q.children,G+1)}};if(U(x.children,0),B>$){const j=document.createElement("p");j.className="panel-replies-more",j.textContent=`+${B-$} more replies`,R.append(j)}return R}function D(x,B){const R=document.createElement("button");R.type="button",R.className="panel-reply",R.style.setProperty("--hue",String(x.hue)),R.style.setProperty("--indent",`${B*12}px`);const P=nr(x.event.content);R.setAttribute("aria-label",`reply by ${x.name}: ${P}`);const $=document.createElement("span");$.className="panel-reply-avatar",rr($,x.picture,x.name);const U=document.createElement("span");U.className="panel-reply-body";const j=document.createElement("span");j.className="panel-reply-name",j.textContent=x.name;const G=document.createElement("span");return G.className="panel-reply-text",G.textContent=P||"(empty note)",U.append(j,G),R.append($,U),R.addEventListener("click",()=>t.onSelect?.(x.id)),R}return{element:o,get open(){return o.classList.contains("open")},get expanded(){return _},setExpanded:K,size:te,show:F,place:J,setDwell:X,setSeen:T,refreshMeta:O,hide:M,dispose:()=>{A.disconnect(),o.remove()}}}const wc={left:"right center",right:"left center",above:"bottom center",below:"top center",center:"center"};function nr(e){return e.replace(/\s+/g," ").trim().slice(0,90)}function Ec(e){const t=e.judgement;if(!t)return"not judged";const o=s=>`${Math.round(s*100)}%`,n=e.rank;return`${n?`${vc(n.place)} · `:""}${o(t.build)} build · ${o(t.relevant)} relevant`}function vc(e){const t=Math.abs(e)%100,o=t>=11&&t<=13?"th":e%10===1?"st":e%10===2?"nd":e%10===3?"rd":"th";return`${e}${o}`}function xc(e){const t=e.reactions.length,o=e.reposts.length+e.repostsHidden,n=[];return t>0&&n.push(`${t} reaction${t===1?"":"s"}`),o>0&&n.push(`${o} repost${o===1?"":"s"}`),n.join(" · ")}function or(e){const t=Yt(e);return t===0?"":`${t} repl${t===1?"y":"ies"}`}function wn(e){return(Array.from(e.trim())[0]??"?").toUpperCase()}function rr(e,t,o){if(e.textContent=wn(o),!t)return;const n=new Image;n.alt="",n.decoding="async",n.addEventListener("error",()=>{n.remove(),e.textContent=wn(o)}),e.textContent="",e.append(n),lt(t).then(r=>{n.src=r}).catch(()=>{n.remove(),e.textContent=wn(o)})}function Sc(e){const t=Kn(e);if(t.length===0)return null;const o=document.createElement("div");o.className="panel-reactions",o.setAttribute("aria-label",`${e.length} reaction${e.length===1?"":"s"}`);for(const{glyph:n,count:r}of t.slice(0,yn)){const s=document.createElement("span");s.className="panel-reaction",s.title=`${n} ×${r}`,s.setAttribute("aria-label",`${r} with ${n}`);const i=document.createElement("span");i.className="panel-reaction-glyph",i.textContent=n,i.setAttribute("aria-hidden","true");const a=document.createElement("span");a.className="panel-reaction-count",a.textContent=String(r),a.setAttribute("aria-hidden","true"),s.append(i,a),o.append(s)}if(t.length>yn){const n=document.createElement("span");n.className="panel-reaction-more",n.textContent=`+${t.length-yn} more`,o.append(n)}return o}function kc(e,t,o=[]){const n=document.createElement("article");n.className="panel-note";const r=document.createElement("div");if(r.className="panel-note-head",!e.root){const f=document.createElement("span");f.className="panel-note-reply",f.textContent="reply",r.append(f)}const s=document.createElement("a");s.className="panel-note-time",s.href=`https://njump.me/${va(e.event.id)}`,s.target="_blank",s.rel="noreferrer",s.title=new Date(e.event.created_at*1e3).toISOString(),s.textContent=Zn(new Date(e.event.created_at*1e3)),r.append(s),n.append(r);const{text:i,images:a,extra:l}=pc(e.event.content);if(i){const f=document.createElement("p");f.className="panel-note-text",Rc(f,i,t),n.append(f)}else if(a.length===0){const f=document.createElement("p");f.className="panel-note-text muted",f.textContent=e.event.content.trim()||"(empty note)",n.append(f)}for(const f of a){const c=new Image;c.className="panel-note-image",c.loading="lazy",c.decoding="async",c.alt="";const h=()=>c.replaceWith(Ic(f));c.addEventListener("error",h),n.append(c),lt(f).then(m=>{c.src=m}).catch(h)}if(l>0){const f=document.createElement("p");f.className="panel-note-more",f.textContent=`+${l} more media`,n.append(f)}const d=Sc(o);return d&&n.append(d),n}function Ac(e,t){const o=t.getReplaceable(z.profile,e);return Ce(o?Ut(o):void 0,e)}function Rc(e,t,o){for(const n of gc(t)){if(n.kind==="text"){e.append(n.text);continue}e.append(Mc(n.pubkey,o))}}function Mc(e,t){const o=zn(e),n=document.createElement("a");return n.className="panel-mention",n.href=`https://njump.me/${o}`,n.target="_blank",n.rel="noreferrer",n.title=o,n.style.setProperty("--hue",String(rt(e))),n.textContent=Ac(e,t),n}function Ic(e){const t=document.createElement("a");t.className="panel-note-link",t.href=e,t.target="_blank",t.rel="noreferrer";try{t.textContent=new URL(e).host}catch{t.textContent=e}return t}function _c(e,t){const o=document.createElement("aside");o.className="profile-card",o.tabIndex=-1,o.setAttribute("role","region"),o.setAttribute("aria-label","profile");const n=document.createElement("button");n.className="profile-close",n.type="button",n.title="close (esc)",n.setAttribute("aria-label","close"),n.textContent="×",n.addEventListener("click",()=>t.onClose());const r=document.createElement("div");r.className="profile-banner",r.setAttribute("aria-hidden","true");const s=document.createElement("div");s.className="profile-body";const i=document.createElement("span");i.className="profile-avatar";const a=document.createElement("h2");a.className="profile-name";const l=document.createElement("p");l.className="profile-handle";const d=document.createElement("p");d.className="profile-about";const f=document.createElement("div");f.className="profile-links",s.append(i,a,l,d,f),o.append(r,n,s);let c=null,h=null,m=null;const y=new ResizeObserver(()=>{c=null,t.onResize?.()});y.observe(o);function b(A){m!==A&&(m=A,c=null,h=null,o.classList.remove("open"),o.offsetWidth),o.classList.add("open");const O=rt(A);o.style.setProperty("--hue",String(O));const F=e.getReplaceable(z.profile,A),M=F?Ut(F):void 0,K=zn(A),X=Ce(M,A);o.setAttribute("aria-label",`profile of ${X}`);const T=M?.picture??M?.image;Tc(i,T,X),a.textContent=X;const te=Nc(M,X);l.textContent=te,l.hidden=te==="";const J=M?.about?.trim();if(d.textContent=J??"",d.hidden=!J,Oc(r,M?.banner),f.replaceChildren(...Cc(A,M,K)),!M){const C=document.createElement("p");C.className="profile-missing",C.textContent="no profile published — this is what the snapshot has",f.append(C)}}function g(){o.classList.remove("open"),m=null,h=null}function E(){return c??={width:o.offsetWidth,height:o.offsetHeight}}function _(A){h&&h.left===A.left&&h.top===A.top&&h.side===A.side||(h=A,o.style.left=`${A.left}px`,o.style.top=`${A.top}px`,o.dataset.side=A.side,o.style.transformOrigin=$c[A.side])}return{element:o,get open(){return o.classList.contains("open")},show:b,place:_,size:E,hide:g,dispose:()=>{y.disconnect(),o.remove()}}}const $c={left:"right center",right:"left center",above:"bottom center",below:"top center",center:"center"};function Nc(e,t){const o=[],n=e?.name?.trim();n&&n!==t&&o.push(`@${n}`);const r=e?.nip05?.trim();return r&&o.push(r),o.join(" · ")}function Oc(e,t){if(e.classList.toggle("has-image",!!t),!t){e.style.backgroundImage="";return}lt(t).then(o=>{e.style.backgroundImage=`url("${Bc(o)}")`}).catch(()=>{e.classList.remove("has-image"),e.style.backgroundImage=""})}function Bc(e){return e.replace(/["\\]/g,"\\$&")}function Cc(e,t,o){const n=[],r=t?.website?.trim();r&&n.push(En(r,Lc(r),"their link"));const s=t?.lud16?.trim()||t?.lud06?.trim();return s&&n.push(En(`lightning:${s}`,`⚡ ${s}`,"send sats")),n.push(En(`https://njump.me/${o}`,Jn(e),"their profile on njump")),n}function En(e,t,o){const n=document.createElement("a");return n.className="profile-link",n.href=e,n.target="_blank",n.rel="noreferrer",n.title=o,n.textContent=t,n}function Lc(e){try{return new URL(e).host}catch{return e}}function vn(e){return(Array.from(e.trim())[0]??"?").toUpperCase()}function Tc(e,t,o){if(e.textContent=vn(o),!t)return;const n=new Image;n.alt="",n.decoding="async",n.addEventListener("error",()=>{n.remove(),e.textContent=vn(o)}),e.textContent="",e.append(n),lt(t).then(r=>{n.src=r}).catch(()=>{n.remove(),e.textContent=vn(o)})}const Ie='ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif',Pc='"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif',st="169, 112, 255",jc=58,Ke=200,Dc={build:{rgb:"255, 138, 61",alpha:.95},fun:{rgb:"72, 158, 255",alpha:.95},relevant:{rgb:"236, 240, 255",alpha:.9},irrelevant:{rgb:"150, 152, 172",alpha:.4}},Uc=.062,Hc=28,qc=58;function Rt(e,t){return Math.max(Hc,Math.min(qc,Math.min(e,t)*Uc))}function ys(e){return Math.round(e*.95)}const Ft=Ee,Gc=264,ws=1.14,Yc=.42,Fc=0,sr=.94,tt=1.1,Wc=.65,vt=6,zc=.36,Vc=.55,Xc=.42,to=Ft*ws+tt/2,Es=3,Ct=.6,vs=.82,ir=`700 11px ${Ie}`,Wt=.4,Zc=.55,Jc=`700 8px ${Ie}`,Kc=.92,Qc=1.16,ar=Math.PI/4,cr="hsl(38 96% 60%)",el="hsl(26 62% 10%)",tl=4.8,nl=9.4,ol=.16;function rl(e,t){const{field:o,width:n,height:r}=t;e.clearRect(0,0,n,r),sl(e,t),il(e,t),al(e,t);const s=t.selected,i=t.hovered,a=[...o.bubbles].filter(d=>!d.hidden).sort((d,f)=>f.r-d.r),l=[];for(const d of a){const f=t.bubbles.get(d.id);if(!f)continue;const c=d.id===i,h=d.id===s;if(c||h){l.push(d);continue}lr(e,t,d,f,"rest")}for(const d of l){const f=t.bubbles.get(d.id);f&&lr(e,t,d,f,d.id===s?"selected":"hovered")}for(const d of a){const f=t.bubbles.get(d.id);if(!t.reactionBadges)break;f&&"reactions"in f&&f.reactions.length>0&&hl(e,d,f,at(t,d.id))}for(const d of a){if(!t.strangerCounts)break;const f=t.bubbles.get(d.id);if(!f?.root)continue;const c=at(t,d.id);f.tail.chip&&ur(e,d,{...f.tail.chip},c);const h=f.repostsHidden;if(h>0){const m=dl(d.r,f.reposts.length,h);m&&ur(e,d,m,c)}}gl(e,t,l),ml(e,t),bl(e,t)}function at(e,t){return e.dimmed.has(t)&&t!==e.selected&&t!==e.hovered}function sl(e,t){const{field:o}=t;if(o.poles.length===0)return;const n=t.phone?o.poles.slice(0,2):o.poles;for(const r of n){const s=e.createRadialGradient(r.x,r.y,0,r.x,r.y,Ke);s.addColorStop(0,`rgba(${st}, 0.10)`),s.addColorStop(.45,`rgba(${st}, 0.035)`),s.addColorStop(1,`rgba(${st}, 0)`),e.fillStyle=s,e.fillRect(r.x-Ke,r.y-Ke,Ke*2,Ke*2)}}function il(e,t){const{width:o,height:n}=t,r=Rt(o,n),s=ys(r),i=o/2,a=n/2,l=t.phone?{build:{x:i,y:s,angle:0},fun:{x:i,y:n-s,angle:0},relevant:{x:i,y:a,angle:0},irrelevant:{x:i,y:a,angle:0}}:{build:{x:s,y:a,angle:-Math.PI/2},fun:{x:o-s,y:a,angle:Math.PI/2},relevant:{x:i,y:s,angle:0},irrelevant:{x:i,y:n-s,angle:0}},d=t.phone?["build","fun"]:hs;e.save(),e.textAlign="center",e.textBaseline="middle",e.font=`700 ${r}px ${Ie}`,e.letterSpacing=`${r*.14}px`;for(const f of d){const c=l[f],h=Dc[f],y=((t.phone?Va[f]:void 0)??za[f]).toUpperCase();e.save(),e.translate(c.x,c.y),e.rotate(c.angle);for(const[b,g]of[[r*.9,.5],[r*.35,.75]])e.shadowColor=`rgba(${h.rgb}, ${h.alpha*g})`,e.shadowBlur=b,e.fillStyle=`rgba(${h.rgb}, ${h.alpha*g})`,e.fillText(y,0,0);e.shadowBlur=0,e.shadowColor="transparent",e.fillStyle=`rgba(248, 248, 255, ${h.alpha})`,e.fillText(y,0,0),e.restore()}e.restore(),e.letterSpacing="0px"}function al(e,t){const{field:o,held:n,anchorDrag:r}=t,s=o.bubbles.filter(l=>!l.bond&&!l.hidden);if(s.length<2)return;const i=n!==null||r,a=o.tuning.repelRange+(i?jc:0);e.lineCap="round";for(let l=0;l<s.length;l++){const d=s[l];for(let f=l+1;f<s.length;f++){const c=s[f],h=d.r+c.r,m=h+a,y=c.x-d.x,b=c.y-d.y,g=y*y+b*b;if(g>m*m)continue;const E=Math.sqrt(g)||1,_=no(1-(E-h)/Math.max(1,a)),A=at(t,d.id)||at(t,c.id)?.35:1,O=(.04+.28*_*(i?1:.3))*A;e.strokeStyle=`rgba(${st}, ${O.toFixed(3)})`,e.lineWidth=.7+_*1.3,e.beginPath(),e.moveTo(d.x,d.y),e.lineTo(c.x,c.y),e.stroke()}}}function lr(e,t,o,n,r){const s=o.r,i=r==="selected",a=r==="hovered",l=at(t,o.id);e.save(),e.translate(o.x,o.y),e.scale(o.scale,o.scale),l&&(e.globalAlpha=Wt),e.beginPath(),e.arc(0,0,s,0,Math.PI*2),e.shadowColor=i?`hsla(${n.hue}, 90%, 62%, 0.55)`:"rgba(0, 0, 0, 0.5)",e.shadowBlur=i?34:a?20:14,e.shadowOffsetY=i||a?0:4,e.fillStyle=`hsl(${n.hue} 30% 10%)`,e.fill(),e.shadowColor="transparent",e.shadowBlur=0,e.shadowOffsetY=0;const d=t.images.get(n.picture),f=d.state==="ready"&&d.element;if(e.save(),e.beginPath(),e.arc(0,0,s,0,Math.PI*2),e.clip(),f){const h=d.element,m=Math.max(s*2/h.naturalWidth,s*2/h.naturalHeight),y=h.naturalWidth*m,b=h.naturalHeight*m;e.drawImage(h,-y/2,-b/2,y,b)}else pl(e,n,s);if(l&&(e.beginPath(),e.arc(0,0,s,0,Math.PI*2),e.fillStyle=`rgba(8, 8, 12, ${Zc})`,e.fill()),e.restore(),e.beginPath(),e.arc(0,0,s-.5,0,Math.PI*2),e.lineWidth=1,e.strokeStyle="rgba(255, 255, 255, 0.10)",e.stroke(),!n.root&&n.count>1){e.textAlign="right",e.textBaseline="alphabetic",e.font=Jc,e.shadowColor="rgba(0, 0, 0, 0.95)",e.shadowBlur=4,e.lineJoin="round",e.strokeStyle="rgba(8, 8, 12, 0.75)",e.lineWidth=2;const h=`×${n.count}`,m=s*Kc,y=s*Qc;e.strokeText(h,m,y),e.fillStyle="rgba(255, 255, 255, 0.96)",e.fillText(h,m,y),e.shadowColor="transparent",e.shadowBlur=0}const c="reposts"in n?n.reposts:[];if(ll(e,t,s,c,"repostsHidden"in n?n.repostsHidden:0),i||a){const h=i?.72+.28*Math.sin(t.time*2.4):1;e.beginPath(),e.arc(0,0,s+1.5,0,Math.PI*2),e.lineWidth=i?3:2,e.strokeStyle=`hsla(${n.hue}, 92%, 70%, ${(i?.95:.8)*h})`,e.stroke(),i&&(e.beginPath(),e.arc(0,0,s+6,0,Math.PI*2),e.lineWidth=1,e.strokeStyle=`hsla(${n.hue}, 92%, 70%, ${.3*h})`,e.stroke())}else e.beginPath(),e.arc(0,0,s+.5,0,Math.PI*2),e.lineWidth=1.5,e.strokeStyle=l?"rgba(255, 255, 255, 0.05)":"rgba(255, 255, 255, 0.13)",e.stroke();"judgement"in n&&n.judgement===null&&cl(e,s,l),e.restore()}function cl(e,t,o){const n=Math.min(nl,Math.max(tl,t*ol)),r=n*1.72;e.save(),o&&(e.globalAlpha=Wt*.8),e.translate(Math.cos(ar)*t,Math.sin(ar)*t),e.beginPath(),e.moveTo(0,-r*.62),e.lineTo(-n,r*.38),e.lineTo(n,r*.38),e.closePath(),e.lineJoin="round",e.lineWidth=Math.max(1.2,n*.34),e.strokeStyle="rgba(8, 8, 12, 0.88)",e.stroke(),e.fillStyle=cr,e.fill(),e.strokeStyle=cr,e.stroke();const s=Math.max(1.15,n*.26);e.fillStyle=el,e.beginPath(),e.roundRect(-s/2,-r*.2,s,r*.3,s/2),e.fill(),e.beginPath(),e.arc(0,r*.26,s*.55,0,Math.PI*2),e.fill(),e.restore()}function ll(e,t,o,n,r){if(n.length===0&&r===0)return;const s=Ft,i=ct(o,to,Math.max(1,n.length));for(const[a,l]of i.entries()){const d=n[a];if(!d)break;ul(e,t,l.dx,-l.dy,s,d)}}function Cn(e,t){const o=[],n=e.scale,r=ct(e.r,to,Math.max(1,t.reposts.length));for(const[s,i]of t.reposts.entries()){const a=r[s];if(!a)break;o.push({repost:i,x:e.x+a.dx*n,y:e.y-a.dy*n,r:Ft*n})}return o}function dl(e,t,o){const n=to;if(t===0)return{dx:0,dy:-(e+n),align:"center",count:o};const r=ct(e,n,t).at(-1);return{dx:r.dx+n+ps,dy:-r.dy,align:"left",count:o}}function dr(e,t){const o=Gc,n=Math.PI/2,r=Ft,s=r*ws,i=s*Yc,a=r*Fc,l=t==="near";e.lineCap="round",e.lineJoin="round";const d=(v,I)=>{e.beginPath(),e.ellipse(0,a,s,i,0,v,I)};if(!l){e.strokeStyle=`hsla(${o}, 85%, 62%, 0.5)`,e.lineWidth=Wc,e.shadowColor=`hsla(${o}, 100%, 62%, 0.5)`,e.shadowBlur=vt*.4,e.beginPath(),e.ellipse(0,a,s*sr,i*sr,0,Math.PI,Math.PI*2),e.stroke(),e.shadowBlur=0,e.shadowColor="transparent";return}const f=e.createLinearGradient(0,a,0,a+i);f.addColorStop(0,`hsl(${o} 92% 58%)`),f.addColorStop(.55,`hsl(${o} 98% 72%)`),f.addColorStop(1,`hsl(${o} 100% 90%)`),e.strokeStyle=f,e.shadowColor=`hsla(${o}, 100%, 62%, 0.9)`;for(const[v,I]of[[tt,vt],[tt,vt*.35]])e.lineWidth=v,e.shadowBlur=I,d(0,n),e.stroke(),d(n+Xc,Math.PI),e.stroke();e.shadowBlur=0,e.shadowColor="transparent";const c=s*zc,h=Vc,m=Math.cos(n),y=Math.sin(n),b=-s*y,g=i*m,E=Math.hypot(b,g)||1,_=b/E,A=g/E,O=s*m,F=a+i*y,M=-_*c,K=-A*c,X=M*Math.cos(h)-K*Math.sin(h),T=M*Math.sin(h)+K*Math.cos(h),te=M*Math.cos(h)+K*Math.sin(h),J=-M*Math.sin(h)+K*Math.cos(h),C=(v,I,D)=>{e.strokeStyle=v,e.lineWidth=I,e.shadowColor=`hsla(${o}, 100%, 65%, 0.95)`,e.shadowBlur=D,e.lineJoin="miter",e.miterLimit=4,e.beginPath(),e.moveTo(O+X,F+T),e.lineTo(O,F),e.lineTo(O+te,F+J),e.stroke()};C("rgba(8, 9, 14, 0.75)",tt+1.1,0),C(`hsl(${o} 100% 88%)`,tt,vt*.8),e.shadowBlur=0,e.shadowColor="transparent"}function ul(e,t,o,n,r,s){e.save(),e.translate(o,n),dr(e,"far"),e.beginPath(),e.arc(0,0,r,0,Math.PI*2),e.fillStyle="rgba(10, 10, 15, 0.94)",e.fill();const i=t.images.get(s.picture),a=i.state==="ready"?i.element:null;if(e.save(),e.beginPath(),e.arc(0,0,r-.5,0,Math.PI*2),e.clip(),a){const l=Math.max(r*2/a.naturalWidth,r*2/a.naturalHeight),d=a.naturalWidth*l,f=a.naturalHeight*l;e.drawImage(a,-d/2,-f/2,d,f)}else e.fillStyle=`hsl(${s.hue} 40% 16%)`,e.fillRect(-r,-r,r*2,r*2),e.fillStyle=`hsl(${s.hue} 92% 78%)`,e.font=`700 ${Math.round(r*1.1)}px ${Ie}`,e.textAlign="center",e.textBaseline="middle",e.fillText("↻",0,.5);e.restore(),dr(e,"near"),e.restore()}const xs=`14px ${Pc}`,Ss=`700 12px ${Ie}`,ks=6,As=2,Rs=5,Ms=24;function fl(e,t,o){if(t.reactions.length===0)return null;const n=Kn(t.reactions,Es).map(f=>f.glyph),r=ks*2+n.reduce((f,c)=>f+o(c,xs),0)+Math.max(0,n.length-1)*As+Rs+o(String(t.reactions.length),Ss),s=(e.r/Ye-Me)/(Gt-Me),i=Ct+(vs-Ct)*no(s),a=e.x+e.r*e.scale,l=r*i,d=Ms*i;return{left:a-l/2,top:e.y-d/2,width:l,height:d}}function hl(e,t,o,n){if(o.reactions.length===0)return;const r=Kn(o.reactions,Es).map(_=>_.glyph),s=String(o.reactions.length),i=xs,a=Ss,l=ks,d=As,f=Rs,c=Ms;e.save(),n&&(e.globalAlpha=Wt*.6),e.font=i;const h=r.map(_=>e.measureText(_).width),m=h.reduce((_,A)=>_+A,0)+(r.length-1)*d;e.font=a;const y=l*2+m+f+e.measureText(s).width,b=(t.r/Ye-Me)/(Gt-Me),g=Ct+(vs-Ct)*no(b);e.translate(t.x+t.r*t.scale,t.y),e.scale(g,g),e.beginPath(),e.roundRect(-y/2,-c/2,y,c,c/2),e.fillStyle="rgba(12, 12, 18, 0.94)",e.shadowColor="rgba(0, 0, 0, 0.55)",e.shadowBlur=6,e.fill(),e.shadowColor="transparent",e.shadowBlur=0,e.lineWidth=1,e.strokeStyle=`hsla(${o.hue}, 85%, 72%, 0.6)`,e.stroke(),e.textAlign="left",e.textBaseline="middle",e.font=i,e.fillStyle="rgba(244, 244, 250, 0.96)";let E=-y/2+l;for(const[_,A]of r.entries())e.fillText(A,E,1),E+=h[_]+d;e.font=a,e.fillStyle=`hsl(${o.hue} 92% 80%)`,e.fillText(s,E-d+f,1),e.restore()}function ur(e,t,o,n){const r=`+${o.count}`,s=20,i=7;e.save(),n&&(e.globalAlpha=Wt*.6),e.font=ir;const a=Math.max(s,i*2+e.measureText(r).width),l=o.align==="left"?0:-a/2;e.translate(t.x+o.dx,t.y+o.dy),e.beginPath(),e.roundRect(l,-s/2,a,s,s/2),e.fillStyle="rgba(12, 12, 18, 0.9)",e.shadowColor="rgba(0, 0, 0, 0.45)",e.shadowBlur=5,e.fill(),e.shadowColor="transparent",e.shadowBlur=0,e.lineWidth=1,e.strokeStyle=`rgba(${st}, 0.5)`,e.stroke(),e.textAlign="center",e.textBaseline="middle",e.font=ir,e.fillStyle="rgba(228, 224, 240, 0.92)",e.fillText(r,l+a/2,1),e.restore()}function pl(e,t,o){const n=e.createRadialGradient(-o*.3,-o*.45,o*.1,0,0,o);n.addColorStop(0,`hsl(${t.hue} 48% 38%)`),n.addColorStop(1,`hsl(${t.hue} 34% 14%)`),e.fillStyle=n,e.fillRect(-o,-o,o*2,o*2);const r=(Array.from(t.name.trim())[0]??"?").toUpperCase();e.fillStyle="rgba(255, 255, 255, 0.82)",e.font=`600 ${Math.round(o*.8)}px ${Ie}`,e.textAlign="center",e.textBaseline="middle",e.fillText(r,0,o*.04)}function ml(e,t){const o=t.hoveredRepost;if(!o)return;const n=t.field.bubbles.find(c=>c.id===o.bubbleId);if(!n||n.hidden)return;const r=t.bubbles.get(o.bubbleId);if(!r?.root)return;const s=Cn(n,r).find(c=>c.repost.pubkey===o.pubkey);if(!s)return;e.beginPath(),e.arc(s.x,s.y,s.r+2,0,Math.PI*2),e.lineWidth=2,e.strokeStyle=`hsla(${s.repost.hue}, 92%, 70%, 0.95)`,e.stroke();const i=s.repost.name;e.font=`600 13px ${Ie}`;const a=e.measureText(i).width+20,l=23;let d=s.y-s.r-9-l/2;d-l/2<6&&(d=s.y+s.r+9+l/2);const f=Math.min(Math.max(s.x,a/2+6),Math.max(a/2+6,t.width-a/2-6));e.beginPath(),e.roundRect(f-a/2,d-l/2,a,l,l/2),e.fillStyle="rgba(10, 10, 15, 0.9)",e.fill(),e.strokeStyle=`hsla(${s.repost.hue}, 92%, 70%, 0.7)`,e.lineWidth=1,e.stroke(),e.fillStyle="rgba(238, 238, 246, 0.97)",e.textAlign="center",e.textBaseline="middle",e.fillText(i,f,d+.5)}function gl(e,t,o){for(const n of o){const r=t.bubbles.get(n.id);if(!r)continue;const s=n.id===t.selected;e.font=`600 13px ${Ie}`;const i=r.name,a=e.measureText(i).width+20,l=23,d=n.r*n.scale;let f=n.y+d+9+l/2;f+l/2>t.height-6&&(f=n.y-d-9-l/2);const c=Math.min(Math.max(n.x,a/2+6),Math.max(a/2+6,t.width-a/2-6));e.beginPath(),e.roundRect(c-a/2,f-l/2,a,l,l/2),e.fillStyle="rgba(10, 10, 15, 0.9)",e.fill(),e.strokeStyle=s?`hsla(${r.hue}, 92%, 70%, 0.7)`:"rgba(255, 255, 255, 0.14)",e.lineWidth=1,e.stroke(),e.fillStyle="rgba(238, 238, 246, 0.97)",e.textAlign="center",e.textBaseline="middle",e.fillText(i,c,f+.5)}}function bl(e,t){const{pointer:o,held:n,field:r}=t;if(!o)return;const s=n?r.bubbles.find(i=>i.id===n):void 0;s&&(e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(o.x,o.y),e.strokeStyle="rgba(255, 255, 255, 0.28)",e.lineWidth=1,e.setLineDash([3,4]),e.stroke(),e.beginPath(),e.arc(o.x,o.y,12,0,Math.PI*2),e.strokeStyle="rgba(255, 255, 255, 0.22)",e.stroke(),e.setLineDash([]))}function no(e){return e<0?0:e>1?1:e}const yl=15,fr=24,xt=6,Is="bubbles.reactionBadges",_s="bubbles.strangerCounts",wl=660,Ae=18,be=12,El=7200,vl=1e7,xl=2,Sl=.3,kl=3,hr=40,pr=14;function Al(e,t,o){const n=Za(t),r=sc(n),s=new Map(r.map(u=>[u.id,u])),i=Ta(r.map(u=>u.id));let a=us(),l=new Set,d=!1,f=!1,c=Il(),h=Rl();const m=Da();for(const u of t.events)m.add(u);let y=null,b=null,g=null,E=null,_=null,A=null,O=!1,F=null;const M={x:0,y:0,vx:0,vy:0};let K=null,X=!1,T=null,te=!1,J=0,C=0,v=0,I=!1,D=!1,x=0,B=0,R=!0,P=0,$=performance.now(),U=0,j=0;const G={id:null,elapsed:0};let Q=!1;const W=document.createElement("div");W.className="space-scroll";const H=document.createElement("canvas");H.className="space-canvas",H.tabIndex=0,H.setAttribute("role","img");function oe(){const u=xe().size,p=u===0?"":`, ${u} read and hidden`;return`${r.length} notes floating between ${d?"two":"four"} poles${p}`}H.setAttribute("aria-label",oe());const fe=H.getContext("2d");if(!fe)throw new Error("this browser has no 2d canvas context");const ee=fe,re=new cc(()=>{R=!0}),Z=new Bt;Z.poles.push(...hs.map(u=>Bt.pole(u)));function N(u){const p=[];let w="parent"in u?u.parent:void 0;for(;w&&p.length<64;){const S=s.get(w);if(!S)break;p.push(S),w="parent"in S?S.parent:void 0}return p.reverse()}const L=yc(m,{ancestors:u=>N(u),onClose:()=>de(null),onSelect:u=>de(u,"click"),onProfile:u=>bo(u.pubkey,sn(u.id)?.id??u.id),onResize:()=>ve(),onExpand:()=>{ve(),R=!0},onUnsee:()=>Fs()}),ie=_c(m,{onClose:()=>Xe(),onResize:()=>ve()}),dt=document.createElement("header");dt.className="hud";const Le=document.createElement("a");Le.className="hud-account",Le.href=`https://njump.me/${t.npub}`,Le.target="_blank",Le.rel="noreferrer",Le.textContent=t.npub;const zt=document.createElement("p");zt.className="hud-stats";const Bs=Object.keys(t.threads??{}).length,oo=Object.values(t.threads??{}).reduce((u,p)=>u+p.length,0),ro=t.stats?.repostNotes??0,Cs=ro>0?`, ${ro} reposted`:"";zt.textContent=`${r.length} notes (${Ua(t.since)}${Cs}) · `+(oo>0?`${Bs} threads, ${oo} replies · `:"")+`fetched ${Zn(new Date(t.generatedAt))}`;const ut=Ha(n.length);ut.refresh(t);const so=ja({counts:()=>({seen:n.filter(u=>i.has(u.id)).length,total:n.length}),isHiding:()=>a,onToggle:u=>vo(u),onReset:()=>i.reset()}),io=tr({label:"emoji reactions",title:"the emoji and the count on each bubble — a note you open still lists them all",pressed:c,onChange:u=>Gs(u)}),ao=tr({label:"non-follow counts",title:"the +N beside the replies and reposts from people you don't follow — a note you open still lists them all",pressed:h,onChange:u=>Ys(u)}),Te=document.createElement("button");Te.type="button",Te.className="hud-repair";const ft=document.createElement("span");ft.className="hud-repair-status",ft.setAttribute("aria-live","polite");const Vt=document.createElement("div");Vt.className="hud-repair-row",Vt.append(Te,ft);let Pe=!1;const Xt=new AbortController;function Zt(){const u=er(t).length;Te.disabled=Pe||u===0,Te.textContent=Pe?"fetching profiles…":"fetch missing profiles",!Pe&&(ft.textContent=u===0?"all faces present":`${u} missing`)}Zt();async function Ls(){if(Pe)return;const u=er(t);if(u.length!==0){Pe=!0,Zt();try{const p=await Ba(u,{signal:Xt.signal,log:k=>console.info(k)});if(Xt.signal.aborted)return;const w=Ca(t,p);for(const k of p)m.add(k);const S=ac(n,t);console.info(`profiles: ${w} stored, ${S} faces filled in of ${u.length} asked for`),De()}catch(p){console.warn("Bubbles could not fetch profiles",{error:p})}finally{Pe=!1,Zt()}}}Te.addEventListener("click",()=>{Ls()});const je=document.createElement("button");je.type="button",je.className="hud-repair";const ht=document.createElement("span");ht.className="hud-repair-status",ht.setAttribute("aria-live","polite");const Jt=document.createElement("div");Jt.className="hud-repair-row",Jt.append(je,ht);const co=new AbortController;let We=!1,Kt=!1;const Qt=()=>n.filter(({id:u})=>!t.judgements?.[u]);function pt(){const u=Qt().length;je.disabled=We||u===0,je.textContent=We?"fetching judgments…":"fetch missing judgments",ht.textContent=u===0?"all notes judged":Kt?`${u} missing · no new judgments found`:`${u} missing`}pt();async function Ts(){if(We)return;const u=Qt();if(u.length===0)return;const{signal:p}=co,w=new Set(u.map(({id:q})=>q));let S=0;function k(q,V){if(p.aborted||t.jev&&(t.jev.prompt!==V.prompt||t.jev.model!==V.model))return;const ne=Object.entries(q).filter(([ye])=>w.has(ye)&&!t.judgements?.[ye]);ne.length&&(t.judgements={...t.judgements,...Object.fromEntries(ne)},t.jev??=V,S+=ne.length,Lo())}We=!0,Kt=!1,pt();try{const q=await Na([...w],{signal:p});q&&k(q.judgements,q.jev),!p.aborted&&Qt().length>0&&await ia(t,V=>k(V,kt),p)}catch(q){console.warn("Bubbles could not fetch published judgments",{error:q})}finally{We=!1,Kt=S===0,p.aborted||pt()}}je.addEventListener("click",()=>{Ts()});const _e=document.createElement("div");_e.className="hud-menu",_e.id="feed-menu",_e.hidden=!0,_e.append(zt,Le,ut.element,lo(),so.element,io.element,ao.element,lo(),Vt,Jt);const pe=document.createElement("button");pe.type="button",pe.className="hud-burger",pe.title="settings",pe.setAttribute("aria-label","settings and account"),pe.setAttribute("aria-controls","feed-menu"),pe.setAttribute("aria-expanded","false"),pe.addEventListener("click",()=>en(!f));function lo(){const u=document.createElement("span");return u.className="hud-menu-rule",u.setAttribute("aria-hidden","true"),u}function en(u,p=!1){f!==u&&(f=u,_e.hidden=!u,pe.setAttribute("aria-expanded",u?"true":"false"),!u&&p&&pe.focus())}function uo(u){if(!f)return;const p=u.target;p&&(_e.contains(p)||pe.contains(p)||en(!1))}document.addEventListener("pointerdown",uo),dt.append(pe,_e);const ze=document.createElement("p");ze.className="hint",ze.textContent="drag a face to pull it · click to read · click a repost face for their profile · h hides the ones you have read · ↑↓ roots, ←→ thread";const Ve=document.createElement("div");Ve.className="sr-only",Ve.setAttribute("role","list");const tn=new Map;for(const u of r){const p=document.createElement("button");p.type="button",p.textContent=u.name;const w=u.event.content.split(`
`)[0]?.slice(0,100)??"",S=u.root?"note":"reply";p.setAttribute("aria-label",`${S} by ${u.name}: ${w}`),p.addEventListener("focus",()=>de(u.id,"click")),p.addEventListener("click",()=>de(u.id,"click")),tn.set(u.id,p),Ve.append(p)}W.append(H,L.element,ie.element),e.classList.add("space"),e.append(W,dt,ze,Ve);function fo(){return{x:0,y:0,w:J,h:C}}function nn(){return{top:W.scrollTop,height:v}}function on(u){return ys(u)+u*.8}function ho(u){const p=Rt(u.w,u.h),w=on(p),S=u.x+u.w/2,k=u.y+u.h/2,q=d?u.h/2-w:Math.min(u.w/2-w,u.h/2-w);return{cx:S,cy:k,rx:Math.max(60,u.w/2-w),arm:Ps(u,Math.max(60,q),k)}}function po(u){return d?[{x:u.cx,y:u.cy-u.arm},{x:u.cx,y:u.cy+u.arm},{x:u.cx,y:u.cy},{x:u.cx,y:u.cy}]:[{x:u.cx-u.rx,y:u.cy},{x:u.cx+u.rx,y:u.cy},{x:u.cx,y:u.cy-u.arm},{x:u.cx,y:u.cy+u.arm}]}function Ps(u,p,w){const S=d?on(Rt(u.w,u.h)):0,k=u.y+u.h-8-S;let q=p;const V=xe();for(const ne of n){if(V.has(ne.id))continue;const ye=ne.tail.depth,ue=js(ne);ye===0||ue<=.01||(q=Math.min(q,(k-w-ye)/ue))}return Math.max(60,q)}function js(u){const[p,w]=d?[0,1]:[2,3],S=u.weights[p]??0,k=u.weights[w]??0,q=S+k;return q<=1e-9?0:(k-S)/q}function mo(){const u=ho(fo()),p=po(u);let w=!1;for(const[S,k]of Z.poles.entries()){const q=p[S]??{x:u.cx,y:u.cy},V=q.x+M.x,ne=q.y+M.y;(Math.abs(k.x-V)>.01||Math.abs(k.y-ne)>.01)&&(w=!0),k.x=V,k.y=ne}return w}function Ds(u,p){const w=fo(),S=8,k=po(ho(w)),q=Math.min(...k.map(ue=>ue.x)),V=Math.max(...k.map(ue=>ue.x)),ne=Math.min(...k.map(ue=>ue.y)),ye=Math.max(...k.map(ue=>ue.y));return{x:Math.min(Math.max(u,S-q),w.x+w.w-S-V),y:Math.min(Math.max(p,S-ne),w.y+w.h-S-ye)}}function Us(){Z.bubbles.length=0,E=null,y=null,Et(n,d,xe()),Z.bubbles.push(...ic(n,w=>Z.targetFor(w)));for(const w of Z.bubbles)w.scaleTarget=cn(w.id);wo();const u=Z.bubbles.length,p=Math.min(El,Math.max(1,Math.floor(vl/Math.max(1,u*(u-1)))));for(let w=0;w<p;w++)Z.step(1/60);Z.freeze(),I=!0}function De(){D=!0,x=0,B=0}function rn(){const u=e.getBoundingClientRect(),p=Math.max(320,Math.round(u.width)),w=Math.max(320,Math.round(u.height)),S=Math.min(2,window.devicePixelRatio||1),k=p<wl,q=k!==d;d=k,q&&Et(n,d,xe());const V=xe(),ne=d?oc(n.filter(Zs=>!V.has(Zs.id)),p,w):w,ye=J!==p||C!==ne||v!==w;J=p,C=ne,v=w,W.classList.toggle("scrolls",C>v),H.width=Math.round(J*S),H.height=Math.round(C*S),H.style.width=`${J}px`,H.style.height=`${C}px`,ee.setTransform(S,0,0,S,0,0);const ue=d?on(Rt(J,C)):0;Z.bounds={minX:8,minY:8+ue,maxX:J-8,maxY:C-8-ue},d&&L.setExpanded(!1),q&&H.setAttribute("aria-label",oe());const Xs=mo();!I||q?Us():(ye||Xs)&&De(),ve(),R=!0}function sn(u){const p=new Set;let w=s.get(u);for(;w&&!p.has(w.id);){p.add(w.id);const S=Z.bubbles.find(k=>k.id===w.id);if(S)return S;w="parent"in w?s.get(w.parent):void 0}return null}function Hs(){if(!L.open||!g)return;if(L.expanded){L.place({left:J-L.size().width-be,top:be,side:"right"});return}const u=sn(g);if(!u)return;const p=mr({x:u.x,y:u.y,r:u.r*u.scale},L.size(),{width:J,...nn()});L.place(p)}function ve(){Hs(),go()}function go(){if(!ie.open||!A)return;const u=Z.bubbles.find(w=>w.id===A.anchorId);if(!u||u.hidden){Xe();return}let p={x:u.x,y:u.y,r:u.r*u.scale};if(A.bead){const w=s.get(A.anchorId),S=w?.root&&Cn(u,w).find(k=>k.repost.pubkey===A.bead.pubkey);S&&(p={x:S.x,y:S.y,r:S.r})}ie.place(mr(p,ie.size(),{width:J,...nn()}))}function bo(u,p,w){A={pubkey:u,anchorId:p,bead:w},de(null),ie.show(u),go(),R=!0}function Xe(){!A&&!ie.open||(A=null,ie.hide(),mt(),R=!0)}function qs(u){if(!d||v>=C)return;const p=nn(),w=40;if(u.y>=p.top+w&&u.y<=p.top+p.height-w)return;const S=u.r+u.tailDepth,k=u.y-S/2+u.r,q=Math.max(0,Math.min(Math.round(k-p.height/2),C-p.height)),V=window.matchMedia("(prefers-reduced-motion: reduce)").matches;W.scrollTo({top:q,behavior:V?"auto":"smooth"})}function yo(){return new Set(n.filter(u=>i.has(u.id)).map(u=>u.id))}function xe(){const u=new Set;if(!a)return u;const p=g??A?.anchorId??null,w=p?$e(p)?.id??null:null;for(const S of yo())S!==w&&u.add(S);return u}function wo(){const u=yo(),p=xe();let w=!1;for(const k of Z.bubbles){const q=k.bond?.id??k.id,V=p.has(q);k.hidden!==V&&(k.hidden=V,k.vx=0,k.vy=0,k.ax=0,k.ay=0,w=!0)}l=new Set;const S=new Set;for(const k of Z.bubbles){if(k.hidden){S.add(k.id);continue}const q=k.bond?.id??k.id;u.has(q)&&l.add(k.id)}for(const[k,q]of tn)q.hidden=S.has(k);return w}function mt(){const u=wo();d?(Et(n,!0,xe()),rn()):u&&De(),g&&L.setSeen(Eo(g)),so.refresh(),ve(),R=!0}function Eo(u){const p=$e(u);return p?i.has(p.id):!1}function vo(u){a!==u&&(a=u,Pa(u),mt())}function Gs(u){c!==u&&(c=u,_l(u),io.set(u),R=!0)}function Ys(u){h!==u&&(h=u,Ml(u),ao.set(u),R=!0)}function Fs(){const u=g?$e(g):null;u&&(Q=!1,G.id=null,G.elapsed=0,L.setDwell(0),i.forget(u.id))}i.onChange(mt);function de(u,p="link"){if(u!==null&&Xe(),g!==u){g=u;for(const S of Z.bubbles)S.scaleTarget=cn(S.id);for(const[S,k]of tn)S===u?k.setAttribute("aria-current","true"):k.removeAttribute("aria-current");if(u){const S=s.get(u);if(S){L.show(S),L.setSeen(Eo(u));const k=sn(u);k&&qs(k),ve()}ze.classList.add("spent")}else L.hide();const w=u?`#${ya(u)}`:location.pathname;try{history.replaceState(null,"",w)}catch{}if(G.id=null,G.elapsed=0,Q=u!==null&&p==="keys",Q)L.setDwell(0);else if(u){const S=$e(u);S&&i.mark(S.id),L.setDwell(1)}else L.setDwell(0);mt()}R=!0}function an(){const u=location.hash.replace(/^#/,"").trim();if(!u){de(null);return}let p;try{p=wa(u)}catch{return}s.has(p)&&de(p,"link")}function cn(u){return u===g?Wa:u===y?Fa:1}function xo(u){if(y!==u){y=u;for(const p of Z.bubbles)p.scaleTarget=cn(p.id);H.style.cursor=u?"grab":O?"grabbing":"default",R=!0}}function So(u){const p=Z.bubbles.filter(V=>!V.bond&&!V.hidden).sort((V,ne)=>V.y-ne.y||V.x-ne.x);if(p.length===0)return;const w=g?$e(g):null,S=w?p.findIndex(V=>V.id===w.id):-1,k=S<0?u>0?0:p.length-1:S+u,q=p[(k+p.length)%p.length];q&&de(q.id,"keys")}function ko(u){if(!g)return;const p=$e(g);if(!p)return;const w=V=>!Z.bubbles.find(ne=>ne.id===V)?.hidden,S=[p.id,...Ws(p)].filter(w);if(S.length===0)return;const k=Math.max(0,S.indexOf(g)),q=S[(k+u+S.length)%S.length];q&&de(q,"keys")}function $e(u){const p=new Set;let w=s.get(u);for(;w&&"parent"in w&&!p.has(w.id);)p.add(w.id),w=s.get(w.parent);return w&&w.root?w:null}function Ws(u){const p=[],w=S=>{for(const k of S)k.placement==="face"&&p.push(k.id),w(k.children)};return w(u.children),p}function zs(u,p){ee.save(),ee.font=p;const w=ee.measureText(u).width;return ee.restore(),w}function Ao(u,p){if(c)for(const w of Z.bubbles){if(w.hidden)continue;const S=s.get(w.id);if(!S?.root||S.reactions.length===0||Math.abs(p-w.y)>fr||u<w.x||u>w.x+w.r+fr*2)continue;const k=fl(w,S,zs);if(k&&u>=k.left-xt&&u<=k.left+k.width+xt&&p>=k.top-xt&&p<=k.top+k.height+xt)return w}return Z.bubbleAt(u,p)}function Ro(u,p){for(const w of Z.bubbles){if(w.hidden)continue;const S=s.get(w.id);if(!(!S?.root||S.reposts.length===0)&&!(p>w.y)&&!(u<w.x-w.r*6||u>w.x+w.r*6)){for(const k of Cn(w,S))if(Math.hypot(u-k.x,p-k.y)<=k.r+2)return{bubble:w,repost:k.repost}}}}function ln(u){const p=H.getBoundingClientRect();return{x:u.clientX-p.left,y:u.clientY-p.top}}function Mo(u){if(u.button!==0)return;const p=ln(u);K=p,T={x:p.x,y:p.y,time:u.timeStamp},te=!1,H.setPointerCapture(u.pointerId);const w=Ro(p.x,p.y);if(w)E=w.bubble,_=w.repost,w.bubble.hold=1,w.bubble.holdX=w.bubble.x,w.bubble.holdY=w.bubble.y,H.style.cursor="pointer";else{const S=Ao(p.x,p.y);S?(E=S,S.hold=1,S.holdX=S.x,S.holdY=S.y,H.style.cursor="grabbing"):(O=!0,F={x:p.x-M.x,y:p.y-M.y},M.vx=0,M.vy=0,H.style.cursor="grabbing")}R=!0}function Io(u){const p=ln(u);K=p;const w=T?Math.hypot(p.x-T.x,p.y-T.y):0;if(E)(te||w>=7)&&(te=!0,E.holdX=gr(p.x,J),E.holdY=gr(p.y,C),De());else if(O&&F){if(te||w>=7){te=!0;const S=Ds(p.x-F.x,p.y-F.y);M.x=S.x,M.y=S.y}}else{const S=Ro(p.x,p.y);b=S?{bubbleId:S.bubble.id,pubkey:S.repost.pubkey}:null,xo(S?null:Ao(p.x,p.y)?.id??null),H.style.cursor=S?"pointer":y?"grab":O?"grabbing":"default"}R=!0}function gt(u){H.hasPointerCapture(u.pointerId)&&H.releasePointerCapture(u.pointerId);const p=ln(u),w=T?Math.hypot(p.x-T.x,p.y-T.y):0,S=T?u.timeStamp-T.time<450:!1,k=w<7&&S,q=E,V=_;_=null,T=null,te=!1,q?(q.hold=0,E=null,k&&(V?bo(V.pubkey,q.id,V):de(q.id,"click"))):O&&(O=!1,F=null,k&&(de(null),Xe())),H.style.cursor=y?"grab":"default",R=!0}function _o(u){if(u.key==="Escape"){f?en(!1,!0):A?Xe():L.expanded?L.setExpanded(!1):g&&de(null);return}if(u.key==="ArrowDown")So(1);else if(u.key==="ArrowUp")So(-1);else if(u.key==="ArrowRight")ko(1);else if(u.key==="ArrowLeft")ko(-1);else if(u.key==="h"||u.key==="H")vo(!a);else if((u.key==="e"||u.key==="E")&&!d)L.setExpanded(!L.expanded);else return;u.preventDefault()}function $o(){X=!0}function No(){X=!1,!(E||O)&&(K=null,b=null,xo(null),R=!0)}function Oo(u){j=requestAnimationFrame(Oo);const p=Math.min(.05,(u-$)/1e3);$=u,P+=p,Q&&g&&!document.hidden&&(G.id!==g&&(G.id=g,G.elapsed=0),G.elapsed<wt&&(G.elapsed=Math.min(wt,G.elapsed+p*1e3),G.elapsed>=wt&&i.mark($e(g)?.id??g)),L.setDwell(G.elapsed/wt)),!O&&(M.x!==0||M.y!==0)&&(M.vx+=(-M.x*hr-M.vx*pr)*p,M.vy+=(-M.y*hr-M.vy*pr)*p,M.x+=M.vx*p,M.y+=M.vy*p,Math.hypot(M.x,M.y)<.2&&Math.hypot(M.vx,M.vy)<2&&(M.x=0,M.y=0,M.vx=0,M.vy=0));const w=mo();w&&De(),D?(Z.step(p),te||w||M.x!==0||M.y!==0?(x=0,B=0):(x+=p,B=Z.maxSpeed()<xl?B+p:0,(B>=Sl||x>=kl)&&(Z.freeze(),D=!1))):Z.easeScale(p);const S=Z.bubbles.some(V=>Math.abs(V.scale-V.scaleTarget)>.002),k=D&&!Z.isSettled(12);!(E!==null||O||M.x!==0||M.y!==0||X||S||k)&&!R&&u-U<1e3/yl||(R=!1,U=u,ve(),rl(ee,{field:Z,bubbles:s,images:re,width:J,height:C,hovered:y,hoveredRepost:b,selected:g,held:E?.id??null,anchorDrag:O,pointer:K,time:P,dimmed:l,phone:d,reactionBadges:c,strangerCounts:h}))}const Bo=new ResizeObserver(()=>rn());Bo.observe(e),rn();const Co=()=>ve();W.addEventListener("scroll",Co,{passive:!0}),H.addEventListener("pointerdown",Mo),H.addEventListener("pointermove",Io),H.addEventListener("pointerup",gt),H.addEventListener("pointercancel",gt),H.addEventListener("pointerenter",$o),H.addEventListener("pointerleave",No),window.addEventListener("keydown",_o),window.addEventListener("hashchange",an),o&&s.has(o)?de(o,"click"):an(),j=requestAnimationFrame(Oo);function Lo(){for(const u of n)u.judgement=t.judgements?.[u.id]??null;ms(n),Et(n,d,xe());for(const u of Z.bubbles){const p=s.get(u.id);p?.root&&(u.weights=p.weights)}ut.refresh(t),pt(),L.refreshMeta(),De(),R=!0}function Vs(){co.abort(),Xt.abort(),cancelAnimationFrame(j),Bo.disconnect(),H.removeEventListener("pointerdown",Mo),H.removeEventListener("pointermove",Io),H.removeEventListener("pointerup",gt),H.removeEventListener("pointercancel",gt),H.removeEventListener("pointerenter",$o),H.removeEventListener("pointerleave",No),window.removeEventListener("keydown",_o),window.removeEventListener("hashchange",an),document.removeEventListener("pointerdown",uo),L.dispose(),ie.dispose(),ut.dispose(),re.dispose(),bs(),W.removeEventListener("scroll",Co),dt.remove(),ze.remove(),Ve.remove(),W.remove()}return{dispose:Vs,refreshJudgements:Lo}}function mr(e,t,o){const n=o.top+o.height,r={left:e.x-e.r-Ae-be-t.width,right:o.width-be-(e.x+e.r+Ae)-t.width,below:n-be-(e.y+e.r+Ae)-t.height,above:e.y-e.r-Ae-be-o.top-t.height,center:0},s=e.x>=o.width/2?["right","left"]:["left","right"],i=e.y>=o.top+o.height/2?["above","below"]:["below","above"],a=(h,m)=>r[m]-r[h],d=[...s.sort(a),...i.sort(a)].find(h=>r[h]>=0)??s[0],f=r[d]>=0,c={left:d==="left"?e.x-e.r-Ae-t.width:d==="right"?e.x+e.r+Ae:e.x-t.width/2,top:d==="above"?e.y-e.r-Ae-t.height:d==="below"?e.y+e.r+Ae:e.y-t.height/2};return{left:br(c.left,be,o.width-be-t.width),top:br(c.top,o.top+be,n-be-t.height),side:f?d:"center"}}function Rl(){return Ht(_s)==="true"}function Ml(e){qt(_s,String(e))}function Il(){return Ht(Is)==="true"}function _l(e){qt(Is,String(e))}function gr(e,t){const o=Math.min(48,t*.15);return Math.min(Math.max(e,o),t-o)}function br(e,t,o){return Math.min(Math.max(e,t),Math.max(t,o))}function $l(e){const t=document.createElement("section");t.className="feed-boot";const o=document.createElement("div"),n=document.createElement("small");n.textContent="BUBBLES";const r=document.createElement("h1");r.textContent="Reading your feed…";const s=document.createElement("div");s.className="boot-indicator";const i=document.createElement("span");i.className="boot-spinner",i.setAttribute("aria-hidden","true");const a=document.createElement("p");a.className="boot-stage",a.setAttribute("role","status"),a.textContent="Looking up your follows…";const l=document.createElement("p");l.className="boot-status",s.append(i,a,l);const d=document.createElement("p");d.className="boot-hint",d.textContent="Open a note to read it while the field fills in.",d.hidden=!0;const f=document.createElement("button");f.type="button",f.hidden=!0;const c=document.createElement("div");o.append(n,r,s,d,f,c),t.append(o),e.replaceChildren(t);let h=!1;const m=()=>{c.childElementCount&&(h=!0)};c.addEventListener("pointerdown",m),c.addEventListener("focusin",m),t.addEventListener("scroll",m);function y(b,g){f.textContent=b,f.onclick=g,f.hidden=!1}return{status(b,g=""){a.textContent!==b&&(a.textContent=b),g&&(l.textContent=g)},preview(b){if(h)return;if(!b.length){r.textContent="Reading your feed…",d.hidden=!0,c.replaceChildren();return}r.textContent="First notes in your feed",d.hidden=!1;const g=b.slice(0,8).map(E=>{const _=document.createElement("details");_.className="boot-note",_.dataset.noteId=E.id,_.name="boot-reading";const A=document.createElement("summary"),O=document.createElement("small");O.textContent=`${Jn(E.pubkey)} · ${Zn(new Date(E.created_at*1e3))}`;const F=document.createElement("span"),M=E.content.trim()||"(no text)";F.textContent=M.slice(0,180)+(M.length>180?"…":"");const K=document.createElement("p");return K.textContent=M,A.append(O,F),_.append(A,K),_});c.replaceChildren(...g)},ready(b){if(!h)return b();i.hidden=!0,l.hidden=!0,a.textContent="Your field is ready. Finish reading here or open it now.",d.hidden=!0,y("Open bubble field",()=>b(c.querySelector("details[open]")?.dataset.noteId))},fail(b){i.hidden=!0,l.hidden=!0,r.textContent="Could not finish loading the field",d.hidden=!0,a.textContent=`${b} — this feed needs the host’s outbox.`,y("Reload to try again",()=>location.reload()),e.replaceChildren(t)},remove(){t.remove(),f.onclick=null,c.replaceChildren()}}}const $s=document.querySelector("#app");if(!$s)throw new Error("#app is missing from index.html");const Ns=$s;function Qe(e,t,o=`${t}s`){return`${e} ${e===1?t:o}`}function Nl(e){const t=[Qe(e.follows,"follow")];return e.profiles>0&&t.push(Qe(e.profiles,"profile")),e.batches<e.batchesTotal&&t.push(`${e.batches}/${e.batchesTotal} batches`),e.notes>0&&t.push(Qe(e.notes,"note")),e.threads>0&&t.push(Qe(e.threads,"thread")),e.replies>0&&t.push(Qe(e.replies,"reply","replies")),t.join(" · ")}const Ol={notes:"Loading notes from your follows…",reposts:"Finding reposted notes…",threads:"Loading conversation threads…",activity:"Loading reactions, reposts, and rankings…",profiles:"Loading remaining profiles…"},He=$l(Ns);let Ln,Ne=!1;const Tn=new AbortController;function Os(){Ne=!0,Tn.abort(),Ln?.(),Ln=void 0,bs()}window.addEventListener("pagehide",Os);window.addEventListener("beforeunload",Os);function yr(e){Ne||(console.warn("Bubbles could not read the feed",{error:e}),He.fail(e instanceof Error?e.message:String(e)))}try{let e,t;const o=r=>{if(Ne)return;const s=t;s?He.preview(r.filter(i=>!s.has(i.id))):e=r},[,n]=await Promise.all([La().then(()=>{t=new Set(us()?fs():[]),e&&o(e),e=void 0}),Oa({signal:Tn.signal,log:r=>console.info(r),onProgress:r=>{Ne||He.status(Ol[r.stage],Nl(r))},onPreview:o}).then(r=>(!Ne&&!t&&He.status("Loading your reading preferences…"),r))]);if(!Ne){let r;He.ready(s=>{if(!Ne)try{r=Al(Ns,n,s),Ln=r.dispose,He.remove()}catch(i){yr(i)}}),aa(n,s=>{n.jev&&(n.jev.prompt!==kt.prompt||n.jev.model!==kt.model)||Object.keys(s).some(i=>!n.judgements?.[i])&&(n.judgements={...s,...n.judgements},n.jev??=kt,r?.refreshJudgements())},Tn.signal).catch(s=>console.warn("Bubbles judgement backfill failed",s))}}catch(e){yr(e)}
</script>
<style>:root{--bg: #0a0a0d;--panel: #16161c;--border: rgba(255, 255, 255, .075);--text: #e8e8ee;--muted: #86869a;--accent: #a970ff;--hue: 270;--font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;--mono: ui-monospace, SFMono-Regular, Menlo, monospace;color-scheme:dark}*{box-sizing:border-box}html,body{height:100%}body{margin:0;overflow:hidden;background:radial-gradient(130% 110% at 50% -10%,#17171f,#0d0d12 52%,#08080a);color:var(--text);font:15px/1.5 var(--font);-webkit-font-smoothing:antialiased}:focus-visible{outline:2px solid hsl(var(--hue) 90% 66% / .85);outline-offset:2px}#app.space{position:fixed;inset:0;overflow:hidden}.space-scroll{position:absolute;inset:0;overflow:hidden}.space-scroll.scrolls{overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.14) transparent}.space-canvas{position:absolute;top:0;left:0;display:block;touch-action:none;cursor:default}.hud{position:absolute;top:0;left:0;right:0;padding:22px 26px;pointer-events:none}.hud-account{display:inline-block;max-width:min(46vw,420px);margin-top:3px;overflow:hidden;color:var(--muted);font:11px/1.6 var(--mono);text-decoration:none;text-overflow:ellipsis;white-space:nowrap;pointer-events:auto}.hud-account:hover{color:var(--accent)}.hud-stats{margin:6px 0 0;color:var(--muted);font-size:11px;letter-spacing:.01em}.hud-burger{position:absolute;top:20px;right:24px;width:34px;height:34px;padding:0;border:1px solid rgba(255,255,255,.12);border-radius:50%;background:#0c0c118c;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);color:var(--muted);cursor:pointer;pointer-events:auto;transition:color .15s ease,border-color .15s ease,background .15s ease}.hud-burger:before{content:"";position:absolute;top:50%;left:50%;width:15px;height:1.5px;margin:-.75px 0 0 -7.5px;border-radius:2px;background:currentColor;box-shadow:0 -5px 0 currentColor,0 5px 0 currentColor}.hud-burger:hover{border-color:#ffffff47;background:#ffffff14;color:var(--text)}.hud-burger[aria-expanded=true]{border-color:#a970ff8c;background:#a970ff24;color:var(--text)}.hud-menu{position:absolute;top:64px;right:24px;z-index:4;display:flex;flex-direction:column;align-items:flex-start;gap:13px;max-width:min(86vw,340px);padding:16px 18px;border:1px solid rgba(255,255,255,.085);border-radius:14px;background:#0f0f15e6;-webkit-backdrop-filter:blur(22px) saturate(1.35);backdrop-filter:blur(22px) saturate(1.35);box-shadow:0 26px 55px -22px #000000e6,0 2px 10px #00000059;pointer-events:auto}.hud-menu[hidden]{display:none}.hud-menu .hud-account{display:block;max-width:100%;margin-top:0}.hud-menu .hud-prompt-row,.hud-menu .hud-seen-row{flex-wrap:wrap;gap:8px 10px;margin:0;max-width:100%}.hud-menu .hud-stats{margin:0;max-width:100%;line-height:1.6}.hud-menu .hud-status,.hud-menu .hud-seen-count{max-width:100%}.hud-menu-rule{width:100%;height:1px;background:#ffffff13}.hud-prompt-row{display:flex;align-items:baseline;gap:8px;margin:10px 0 0;pointer-events:auto}.hud-prompt-label{flex:none;color:var(--muted);font-size:10px;letter-spacing:.08em;text-transform:uppercase}.hud-prompt-text{flex:1;min-width:0;overflow:hidden;color:var(--text);font-size:11px;text-overflow:ellipsis;white-space:nowrap}.hud-status{flex:none;max-width:min(38vw,340px);overflow:hidden;color:var(--muted);font-size:11px;text-overflow:ellipsis;white-space:nowrap}.hud-seen-row{display:flex;align-items:center;gap:10px;margin:8px 0 0;pointer-events:auto}.hud-toggle,.hud-seen{display:inline-flex;align-items:center;gap:7px;padding:4px 11px;border:1px solid var(--border);border-radius:999px;background:#0c0c1199;color:var(--text);font:11px var(--font);letter-spacing:.01em;cursor:pointer;transition:border-color .2s ease,color .2s ease}.hud-toggle:before,.hud-seen:before{content:"";width:7px;height:7px;border:1px solid var(--muted);border-radius:50%;transition:background .2s ease,border-color .2s ease,box-shadow .2s ease}.hud-toggle:hover,.hud-seen:hover{border-color:#a970ff80;color:#fff}.hud-toggle[aria-pressed=true],.hud-seen[aria-pressed=true]{border-color:#a970ff8c;color:#fff}.hud-toggle[aria-pressed=true]:before,.hud-seen[aria-pressed=true]:before{border-color:var(--accent);background:var(--accent);box-shadow:0 0 9px #a970ffd9}.hud-seen-count{max-width:min(30vw,260px);overflow:hidden;color:var(--muted);font-size:11px;letter-spacing:.01em;text-overflow:ellipsis;white-space:nowrap}.hud-seen-reset{padding:0;border:0;border-bottom:1px dotted rgba(134,134,154,.6);background:none;color:var(--muted);font:11px var(--font);cursor:pointer}.hud-repair-row{display:flex;align-items:center;flex-wrap:wrap;gap:8px 10px;margin:0;max-width:100%;pointer-events:auto}.hud-repair{display:inline-flex;align-items:center;gap:7px;padding:4px 11px;border:1px solid var(--border);border-radius:999px;background:#0c0c1199;color:var(--text);font:11px var(--font);letter-spacing:.01em;cursor:pointer;transition:border-color .2s ease,color .2s ease}.hud-repair:before{content:"";width:7px;height:7px;border:1px solid var(--muted);border-radius:50%}.hud-repair:hover:not(:disabled){border-color:#a970ff80;color:#fff}.hud-repair:disabled{color:var(--muted);cursor:default}.hud-repair:disabled:before{border-color:#a970ff8c;background:#a970ff8c;box-shadow:0 0 9px #a970ff8c}.hud-repair-status{color:var(--muted);font-size:11px;letter-spacing:.01em}.hud-seen-reset[hidden]{display:none}.hud-seen-reset:hover{color:var(--text)}.hint{position:absolute;bottom:22px;left:50%;transform:translate(-50%);margin:0;padding:7px 15px;border:1px solid var(--border);border-radius:999px;background:#0c0c118c;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);color:var(--muted);font-size:12px;white-space:nowrap;pointer-events:none;transition:opacity .6s ease,transform .6s ease}.hint.spent{opacity:0;transform:translate(-50%) translateY(8px)}.panel{position:absolute;left:0;top:0;display:flex;flex-direction:column;width:min(430px,92vw);max-height:min(560px,80vh);overflow:hidden;border:1px solid rgba(255,255,255,.085);border-radius:18px;background:#0f0f15db;-webkit-backdrop-filter:blur(22px) saturate(1.35);backdrop-filter:blur(22px) saturate(1.35);box-shadow:0 30px 60px -24px #000000e6,0 2px 10px #00000059;opacity:0;visibility:hidden;transform:scale(.97);transition:opacity .16s ease,transform .18s cubic-bezier(.22,.8,.24,1),visibility 0s linear .18s}.panel[data-side=right]{transform:translate(-8px) scale(.98)}.panel[data-side=left]{transform:translate(8px) scale(.98)}.panel[data-side=below]{transform:translateY(-8px) scale(.98)}.panel[data-side=above]{transform:translateY(8px) scale(.98)}.panel.open{opacity:1;visibility:visible;transform:none;transition:opacity .16s ease,transform .18s cubic-bezier(.22,.8,.24,1),visibility 0s}.panel-dwell{position:absolute;top:0;left:0;right:0;height:2px;border-radius:18px 18px 0 0;background:#a970ffcc;transform:scaleX(0);transform-origin:left center;pointer-events:none}.panel-seen{grid-column:1 / -1;justify-self:start;padding:3px 9px;border:1px solid rgba(169,112,255,.45);border-radius:999px;background:#a970ff1f;color:#d6c4fff2;font:600 9px var(--font);letter-spacing:.14em;text-transform:uppercase;cursor:pointer;transition:background .15s ease,border-color .15s ease}.panel-seen[hidden]{display:none}.panel-seen:hover{border-color:#a970ffcc;background:#a970ff3d}.panel:before{content:"";position:absolute;inset:0;pointer-events:none;background:radial-gradient(130% 42% at 78% -12%,hsl(var(--hue) 90% 62% / .2),transparent 68%)}.panel-head{position:relative;flex:none;display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:10px 12px;padding:20px 26px 16px;border-bottom:1px solid var(--border)}.panel-close{position:absolute;top:16px;right:16px;width:30px;height:30px;padding:0;border:1px solid rgba(255,255,255,.12);border-radius:50%;background:#ffffff0a;color:var(--muted);font:400 18px/1 var(--font);cursor:pointer;transition:color .15s ease,border-color .15s ease,background .15s ease}.panel-close:hover{border-color:#ffffff47;background:#ffffff17;color:var(--text)}.panel-expand{position:absolute;top:16px;right:52px;width:30px;height:30px;padding:0;border:1px solid rgba(255,255,255,.12);border-radius:50%;background:#ffffff0a;cursor:pointer;transition:border-color .15s ease,background .15s ease}.panel-expand:before{content:"";position:absolute;inset:8px 7px;border:1.5px solid var(--muted);border-radius:3px;transition:border-color .15s ease}.panel-expand:after{content:"";position:absolute;top:9.5px;bottom:9.5px;left:17.5px;width:1.5px;border-radius:1px;background:var(--muted);transition:left .2s cubic-bezier(.22,.8,.24,1),background .15s ease}.panel-expand:hover{border-color:#ffffff47;background:#ffffff17}.panel-expand:hover:before{border-color:var(--text)}.panel-expand:hover:after,.panel[data-expanded=true] .panel-expand:after{left:11.5px;background:var(--text)}.panel[data-expanded=true]{width:min(50vw,780px);height:calc(100vh - 24px);max-height:none}.panel[data-expanded=true] .panel-note-text,.panel[data-expanded=true] .panel-empty,.panel[data-expanded=true] .panel-reply-text{max-width:62ch}.panel[data-expanded=true] .panel-note-image{max-height:68vh}.panel-avatar{grid-column:1;display:grid;width:42px;height:42px;place-items:center;overflow:hidden;border:2px solid hsl(var(--hue) 90% 66% / .65);border-radius:50%;background:hsl(var(--hue) 30% 16%);box-shadow:0 0 26px hsl(var(--hue) 90% 60% / .28);color:hsl(var(--hue) 90% 80%);font-size:16px;font-weight:600}.panel-avatar img,.panel-reply-avatar img{display:block;width:100%;height:100%;object-fit:cover}.panel-name{grid-column:2;margin:0;padding-right:78px;font-size:16px;font-weight:600;letter-spacing:-.01em;overflow-wrap:anywhere}.panel-author{grid-column:1 / -1;display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:10px 12px;width:100%;padding:0;border:0;border-radius:12px;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer}.panel-author:hover .panel-name,.panel-author:focus-visible .panel-name{color:hsl(var(--hue) 85% 82%)}.panel-author:focus-visible{outline:1px solid hsla(var(--hue),85%,70%,.6);outline-offset:4px}.panel-meta{grid-column:1 / -1;margin:0;padding-right:78px;color:var(--muted);font-size:10px;letter-spacing:.1em;text-transform:uppercase}.panel-notes{position:relative;flex:1;min-height:0;padding:2px 26px 30px;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.14) transparent}.panel-notes::-webkit-scrollbar{width:10px}.panel-notes::-webkit-scrollbar-thumb{border:3px solid transparent;border-radius:999px;background:#ffffff29;background-clip:content-box}.panel-note{padding:18px 0;border-bottom:1px solid rgba(255,255,255,.055)}.panel-note:last-child{border-bottom:0}.panel-note-head{display:flex;align-items:center;gap:8px;margin-bottom:7px}.panel-note-reply{padding:1px 8px;border:1px solid rgba(255,255,255,.13);border-radius:999px;color:var(--muted);font-size:9px;letter-spacing:.09em;text-transform:uppercase}.panel-note-time{color:var(--muted);font:11px/1.5 var(--mono);text-decoration:none}.panel-note-time:hover{color:var(--text)}.panel-note-text{margin:0;font-size:14px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}.panel-note-text.muted{color:var(--muted)}.panel-mention{padding:1px 6px;border:1px solid hsl(var(--hue) 80% 70% / .3);border-radius:999px;background:hsl(var(--hue) 60% 60% / .13);color:hsl(var(--hue) 90% 82%);font-size:13px;white-space:nowrap;text-decoration:none}.panel-mention:hover{border-color:hsl(var(--hue) 90% 72% / .6);background:hsl(var(--hue) 60% 60% / .22)}.panel-note-image{display:block;width:100%;max-height:58vh;margin-top:11px;border:1px solid rgba(255,255,255,.08);border-radius:12px;background:#00000059;object-fit:contain}.panel-reactions{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:14px}.panel-reaction{display:inline-flex;align-items:center;gap:5px;padding:3px 9px 3px 8px;border:1px solid rgba(255,255,255,.09);border-radius:999px;background:#ffffff09}.panel-reaction-glyph{font-size:13px;line-height:1.3}.panel-reaction-count{color:var(--muted);font:600 11px/1.3 var(--mono)}.panel-reaction-more{color:var(--muted);font-size:11px}.panel-note-link,.panel-note-more{display:inline-block;margin-top:8px;color:var(--muted);font:11px/1.6 var(--mono)}.panel-note-link:hover{color:var(--accent)}.panel-empty{margin:26px 0 0;color:var(--muted);font-size:13px}.panel-context{display:flex;flex-direction:column;gap:1px;margin:2px 0 14px;padding:2px 0 2px 9px;border-left:2px solid var(--border)}.panel-context-row{display:grid;grid-template-columns:auto auto minmax(0,1fr);gap:8px;align-items:baseline;width:100%;padding:5px 8px;border:1px solid transparent;border-radius:8px;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer}.panel-context-row:hover,.panel-context-row:focus-visible{border-color:hsla(var(--hue),80%,70%,.3);background:hsla(var(--hue),70%,60%,.06);outline:none}.panel-context-role{color:var(--accent);font-size:9.5px;letter-spacing:.09em;text-transform:uppercase;white-space:nowrap}.panel-context-name{max-width:14ch;overflow:hidden;color:#e8e8eea8;font-size:12px;white-space:nowrap;text-overflow:ellipsis}.panel-context-text{overflow:hidden;color:#e8e8ee70;font-size:12.5px;white-space:nowrap;text-overflow:ellipsis}.panel-context-gap{margin:3px 8px;color:var(--muted);font-size:10px;letter-spacing:.09em;text-transform:uppercase}.panel-replies{padding:14px 0 4px}.panel-replies-head,.panel-replies-more{margin:0 0 8px;color:var(--muted);font-size:10px;letter-spacing:.1em;text-transform:uppercase}.panel-replies-more{margin:10px 0 0}.panel-reply{display:flex;gap:9px;align-items:flex-start;width:100%;padding:7px 8px 7px calc(8px + var(--indent, 0px));border:1px solid transparent;border-radius:10px;background:none;color:inherit;font:inherit;text-align:left;cursor:pointer}.panel-reply:hover,.panel-reply:focus-visible{border-color:hsla(var(--hue),80%,70%,.35);background:hsla(var(--hue),70%,60%,.07);outline:none}.panel-reply-avatar{flex:none;display:grid;width:22px;height:22px;margin-top:1px;place-items:center;overflow:hidden;border-radius:50%;background:hsl(var(--hue) 34% 18%);color:hsl(var(--hue) 92% 80%);font-size:11px;font-weight:600}.panel-reply-body{display:flex;min-width:0;flex-direction:column;gap:2px}.panel-reply-name{color:hsl(var(--hue) 80% 82%);font-size:12px;font-weight:600}.panel-reply-text{color:#e8e8f0b8;font-size:12px;line-height:1.45;overflow-wrap:anywhere}.profile-card{position:absolute;left:0;top:0;display:flex;flex-direction:column;width:min(340px,92vw);max-height:min(520px,80vh);overflow:hidden;border:1px solid rgba(255,255,255,.085);border-radius:18px;background:#0f0f15e6;-webkit-backdrop-filter:blur(22px) saturate(1.35);backdrop-filter:blur(22px) saturate(1.35);box-shadow:0 30px 60px -24px #000000e6,0 2px 10px #00000059;opacity:0;visibility:hidden;transform:scale(.97);transition:opacity .16s ease,transform .18s cubic-bezier(.22,.8,.24,1),visibility 0s linear .18s}.profile-card[data-side=right]{transform:translate(-8px) scale(.98)}.profile-card[data-side=left]{transform:translate(8px) scale(.98)}.profile-card[data-side=below]{transform:translateY(-8px) scale(.98)}.profile-card[data-side=above]{transform:translateY(8px) scale(.98)}.profile-card.open{opacity:1;visibility:visible;transform:none;transition:opacity .16s ease,transform .18s cubic-bezier(.22,.8,.24,1),visibility 0s}.profile-banner{position:absolute;top:0;left:0;right:0;height:86px;background-image:linear-gradient(hsl(var(--hue) 58% 30%),hsl(var(--hue) 42% 14%));background-size:cover;background-position:center}.profile-banner.has-image:after{content:"";position:absolute;inset:0;background:linear-gradient(to bottom,#0f0f1500 40%,#0f0f15eb)}.profile-close{position:absolute;top:12px;right:12px;z-index:2;width:28px;height:28px;padding:0;border:1px solid rgba(255,255,255,.16);border-radius:50%;background:#00000059;color:var(--text);font:400 17px/1 var(--font);cursor:pointer;transition:border-color .15s ease,background .15s ease}.profile-close:hover{border-color:#ffffff52;background:#0000008c}.profile-body{position:relative;display:flex;flex:1 1 auto;min-height:0;flex-direction:column;gap:7px;padding:56px 22px 22px;overflow-y:auto;overscroll-behavior:contain}.profile-avatar{display:grid;width:64px;height:64px;place-items:center;overflow:hidden;border:2px solid hsl(var(--hue) 90% 66% / .75);border-radius:50%;background:hsl(var(--hue) 30% 16%);box-shadow:0 0 34px hsl(var(--hue) 90% 60% / .3);color:hsl(var(--hue) 92% 82%);font-size:24px;font-weight:600}.profile-avatar img{display:block;width:100%;height:100%;object-fit:cover}.profile-name{margin:3px 0 0;font-size:20px;font-weight:650;letter-spacing:-.01em;overflow-wrap:anywhere}.profile-handle{margin:0;color:hsl(var(--hue) 70% 78%);font:11px/1.5 var(--mono);overflow-wrap:anywhere}.profile-handle[hidden],.profile-about[hidden]{display:none}.profile-about{margin:4px 0 0;color:#e8e8f0d1;font-size:13px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere}.profile-links{display:flex;flex-direction:column;gap:6px;margin-top:8px}.profile-link{display:inline-block;max-width:100%;padding:5px 10px;border:1px solid hsla(var(--hue),70%,70%,.24);border-radius:9px;background:hsla(var(--hue),60%,60%,.08);color:hsl(var(--hue) 88% 82%);font:11px/1.4 var(--mono);text-decoration:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;transition:border-color .15s ease,background .15s ease}.profile-link:hover{border-color:hsla(var(--hue),85%,72%,.55);background:hsla(var(--hue),60%,60%,.16)}.profile-missing{margin:6px 0 0;color:var(--muted);font-size:11px;letter-spacing:.04em}.boot{position:absolute;inset:0;display:grid;place-content:center;gap:6px;padding:24px;text-align:center;color:var(--muted);font-size:14px}.boot-status{min-height:1.5em;font:12px/1.6 var(--mono);font-variant-numeric:tabular-nums}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;border:0;clip-path:inset(50%);white-space:nowrap}@media(prefers-reduced-motion:reduce){.panel,.profile-card,.hint,.panel-close,.panel-expand,.panel-expand:before,.panel-expand:after{transition:none}.hud-burger{transition:none}}@media(max-width:659px){.panel-expand{display:none}.hud-burger{top:14px;right:16px}.hud-menu{top:56px;right:16px}.space-canvas{touch-action:pan-y}.panel-name,.panel-meta{padding-right:40px}}@media(max-width:560px){.hud{padding:16px 18px}.hud-account{max-width:60vw}.hint{max-width:92vw;overflow:hidden;text-overflow:ellipsis}.panel-head{padding:20px 20px 16px}.panel-notes{padding:0 20px 40px}}.feed-boot{position:absolute;inset:0;overflow:auto;padding:clamp(24px,8vh,80px) 20px;overflow-wrap:anywhere}.feed-boot>div{max-width:40rem;margin:auto}.feed-boot small{color:var(--muted);font:12px/1.5 var(--mono)}.feed-boot>div>small{color:var(--accent);letter-spacing:.18em}.feed-boot h1{margin:.45em 0;font-size:clamp(22px,4vw,32px)}.feed-boot .boot-status{color:var(--muted)}.boot-hint{margin:.5em 0 1.5em}.feed-boot button{padding:.65em 1.15em;margin-bottom:14px;border:1px solid rgba(169,112,255,.55);border-radius:8px;background:#31213f;color:var(--text);font:inherit;cursor:pointer}.boot-note{border-top:1px solid var(--border)}.boot-note summary{padding:14px 0;cursor:pointer}.boot-note summary span{display:block;margin-top:5px}.boot-note[open] summary span{display:none}.boot-note p{white-space:pre-wrap;margin:0 0 16px}.boot-indicator{position:sticky;top:0;z-index:1;display:grid;grid-template-columns:auto 1fr;align-items:center;gap:2px 10px;padding:10px 12px;background:#191421;border:1px solid rgba(169,112,255,.35);border-radius:8px}.boot-indicator p{grid-column:2;margin:0}.boot-indicator p:empty{display:none}.boot-stage{font-weight:600}.boot-spinner{grid-area:1 / 1;width:14px;height:14px;border:2px solid rgba(169,112,255,.32);border-top-color:var(--accent);border-radius:50%;animation:boot-spin .8s linear infinite}@keyframes boot-spin{to{transform:rotate(1turn)}}@media(prefers-reduced-motion:reduce){.boot-spinner{animation:none}}
</style>
</head>
<body>
<main id="app" class="space">
<p class="boot">loading the room…</p>
</main>
</body>
</html>
