bundle.js raw

   1  var app=function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function i(e){e.forEach(t)}function s(e){return"function"==typeof e}function r(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let o;function l(e,t){return o||(o=document.createElement("a")),o.href=t,e===o.href}function a(t,...n){if(null==t)return e;const i=t.subscribe(...n);return i.unsubscribe?()=>i.unsubscribe():i}function c(e){let t;return a(e,e=>t=e)(),t}function u(e,t,n){e.$$.on_destroy.push(a(t,n))}const d="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function f(e,t){e.appendChild(t)}function h(e,t,n){e.insertBefore(t,n||null)}function p(e){e.parentNode&&e.parentNode.removeChild(e)}function g(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function m(e){return document.createElement(e)}function v(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function y(e){return document.createTextNode(e)}function w(){return y(" ")}function b(){return y("")}function A(e,t,n,i){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}function k(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function I(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function C(e){return""===e?null:+e}function E(e,t){t=""+t,e.data!==t&&(e.data=t)}function x(e,t){e.value=null==t?"":t}function S(e,t,n,i){null==n?e.style.removeProperty(t):e.style.setProperty(t,n,i?"important":"")}function B(e,t,n){for(let n=0;n<e.options.length;n+=1){const i=e.options[n];if(i.__value===t)return void(i.selected=!0)}n&&void 0===t||(e.selectedIndex=-1)}function $(e){const t=e.querySelector(":checked");return t&&t.__value}function F(e,t,n){e.classList[n?"add":"remove"](t)}let D;function Q(e){D=e}function P(){if(!D)throw new Error("Function called outside component initialization");return D}function R(e){P().$$.on_mount.push(e)}function T(e){P().$$.on_destroy.push(e)}function L(){const e=P();return(t,n,{cancelable:i=!1}={})=>{const s=e.$$.callbacks[t];if(s){const r=function(e,t,{bubbles:n=!1,cancelable:i=!1}={}){const s=document.createEvent("CustomEvent");return s.initCustomEvent(e,n,i,t),s}(t,n,{cancelable:i});return s.slice().forEach(t=>{t.call(e,r)}),!r.defaultPrevented}return!0}}function _(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const N=[],M=[];let U=[];const O=[],j=Promise.resolve();let z=!1;function H(){z||(z=!0,j.then(W))}function q(){return H(),j}function G(e){U.push(e)}function J(e){O.push(e)}const K=new Set;let V=0;function W(){if(0!==V)return;const e=D;do{try{for(;V<N.length;){const e=N[V];V++,Q(e),Y(e.$$)}}catch(e){throw N.length=0,V=0,e}for(Q(null),N.length=0,V=0;M.length;)M.pop()();for(let e=0;e<U.length;e+=1){const t=U[e];K.has(t)||(K.add(t),t())}U.length=0}while(N.length);for(;O.length;)O.pop()();z=!1,K.clear(),Q(e)}function Y(e){if(null!==e.fragment){e.update(),i(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(G)}}const Z=new Set;let X;function ee(){X={r:0,c:[],p:X}}function te(){X.r||i(X.c),X=X.p}function ne(e,t){e&&e.i&&(Z.delete(e),e.i(t))}function ie(e,t,n,i){if(e&&e.o){if(Z.has(e))return;Z.add(e),X.c.push(()=>{Z.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}else i&&i()}function se(e,t){e.d(1),t.delete(e.key)}function re(e,t){ie(e,1,1,()=>{t.delete(e.key)})}function oe(e,t,n,s,r,o,l,a,c,u,d,f){let h=e.length,p=o.length,g=h;const m={};for(;g--;)m[e[g].key]=g;const v=[],y=new Map,w=new Map,b=[];for(g=p;g--;){const e=f(r,o,g),i=n(e);let a=l.get(i);a?s&&b.push(()=>a.p(e,t)):(a=u(i,e),a.c()),y.set(i,v[g]=a),i in m&&w.set(i,Math.abs(g-m[i]))}const A=new Set,k=new Set;function I(e){ne(e,1),e.m(a,d),l.set(e.key,e),d=e.first,p--}for(;h&&p;){const t=v[p-1],n=e[h-1],i=t.key,s=n.key;t===n?(d=t.first,h--,p--):y.has(s)?!l.has(i)||A.has(i)?I(t):k.has(s)?h--:w.get(i)>w.get(s)?(k.add(i),I(t)):(A.add(s),h--):(c(n,l),h--)}for(;h--;){const t=e[h];y.has(t.key)||c(t,l)}for(;p;)I(v[p-1]);return i(b),v}function le(e,t,n){const i=e.$$.props[t];void 0!==i&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function ae(e){e&&e.c()}function ce(e,n,r,o){const{fragment:l,after_update:a}=e.$$;l&&l.m(n,r),o||G(()=>{const n=e.$$.on_mount.map(t).filter(s);e.$$.on_destroy?e.$$.on_destroy.push(...n):i(n),e.$$.on_mount=[]}),a.forEach(G)}function ue(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];U.forEach(i=>-1===e.indexOf(i)?t.push(i):n.push(i)),n.forEach(e=>e()),U=t}(n.after_update),i(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function de(t,s,r,o,l,a,c,u=[-1]){const d=D;Q(t);const f=t.$$={fragment:null,ctx:[],props:a,update:e,not_equal:l,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(s.context||(d?d.$$.context:[])),callbacks:n(),dirty:u,skip_bound:!1,root:s.target||d.$$.root};c&&c(f.root);let h=!1;if(f.ctx=r?r(t,s.props||{},(e,n,...i)=>{const s=i.length?i[0]:n;return f.ctx&&l(f.ctx[e],f.ctx[e]=s)&&(!f.skip_bound&&f.bound[e]&&f.bound[e](s),h&&function(e,t){-1===e.$$.dirty[0]&&(N.push(e),H(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}(t,e)),n}):[],f.update(),h=!0,i(f.before_update),f.fragment=!!o&&o(f.ctx),s.target){if(s.hydrate){const e=function(e){return Array.from(e.childNodes)}(s.target);f.fragment&&f.fragment.l(e),e.forEach(p)}else f.fragment&&f.fragment.c();s.intro&&ne(t.$$.fragment),ce(t,s.target,s.anchor,s.customElement),W()}Q(d)}class fe{$destroy(){ue(this,1),this.$destroy=e}$on(t,n){if(!s(n))return e;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const e=i.indexOf(n);-1!==e&&i.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function he(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function pe(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function ge(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")}const me="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,ve=e=>e instanceof Uint8Array,ye=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),we=(e,t)=>e<<32-t|e>>>t;
   2  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function be(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!ve(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let Ae=class{clone(){return this._cloneInto()}};function ke(e){const t=t=>e().update(be(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ie(e=32){if(me&&"function"==typeof me.getRandomValues)return me.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let Ce=class extends Ae{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ye(this.buffer)}update(e){ge(this);const{view:t,buffer:n,blockLen:i}=this,s=(e=be(e)).length;for(let r=0;r<s;){const o=Math.min(i-this.pos,s-r);if(o===i){const t=ye(e);for(;i<=s-r;r+=i)this.process(t,r);continue}n.set(e.subarray(r,r+o),this.pos),this.pos+=o,r+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ge(this),function(e,t){pe(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:r}=this;t[r++]=128,this.buffer.subarray(r).fill(0),this.padOffset>i-r&&(this.process(n,0),r=0);for(let e=r;e<i;e++)t[e]=0;!function(e,t,n,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,i);const s=BigInt(32),r=BigInt(4294967295),o=Number(n>>s&r),l=Number(n&r),a=i?4:0,c=i?0:4;e.setUint32(t+a,o,i),e.setUint32(t+c,l,i)}(n,i-8,BigInt(8*this.length),s),this.process(n,0);const o=ye(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=l/4,c=this.get();if(a>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<a;e++)o.setUint32(4*e,c[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:r,pos:o}=this;return e.length=i,e.pos=o,e.finished=s,e.destroyed=r,i%t&&e.buffer.set(n),e}};const Ee=(e,t,n)=>e&t^~e&n,xe=(e,t,n)=>e&t^e&n^t&n,Se=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$e=new Uint32Array(64);let Fe=class extends Ce{constructor(){super(64,32,8,!1),this.A=0|Be[0],this.B=0|Be[1],this.C=0|Be[2],this.D=0|Be[3],this.E=0|Be[4],this.F=0|Be[5],this.G=0|Be[6],this.H=0|Be[7]}get(){const{A:e,B:t,C:n,D:i,E:s,F:r,G:o,H:l}=this;return[e,t,n,i,s,r,o,l]}set(e,t,n,i,s,r,o,l){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|s,this.F=0|r,this.G=0|o,this.H=0|l}process(e,t){for(let n=0;n<16;n++,t+=4)$e[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=$e[e-15],n=$e[e-2],i=we(t,7)^we(t,18)^t>>>3,s=we(n,17)^we(n,19)^n>>>10;$e[e]=s+$e[e-7]+i+$e[e-16]|0}let{A:n,B:i,C:s,D:r,E:o,F:l,G:a,H:c}=this;for(let e=0;e<64;e++){const t=c+(we(o,6)^we(o,11)^we(o,25))+Ee(o,l,a)+Se[e]+$e[e]|0,u=(we(n,2)^we(n,13)^we(n,22))+xe(n,i,s)|0;c=a,a=l,l=o,o=r+t|0,r=s,s=i,i=n,n=t+u|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,r=r+this.D|0,o=o+this.E|0,l=l+this.F|0,a=a+this.G|0,c=c+this.H|0,this.set(n,i,s,r,o,l,a,c)}roundClean(){$e.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const De=ke(()=>new Fe),Qe=BigInt(0),Pe=BigInt(1),Re=BigInt(2),Te=e=>e instanceof Uint8Array,Le=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));
   3  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function _e(e){if(!Te(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Le[e[n]];return t}function Ne(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function Me(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function Ue(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const i=2*t,s=e.slice(i,i+2),r=Number.parseInt(s,16);if(Number.isNaN(r)||r<0)throw new Error("Invalid byte sequence");n[t]=r}return n}function Oe(e){return Me(_e(e))}function je(e){if(!Te(e))throw new Error("Uint8Array expected");return Me(_e(Uint8Array.from(e).reverse()))}function ze(e,t){return Ue(e.toString(16).padStart(2*t,"0"))}function He(e,t){return ze(e,t).reverse()}function qe(e,t,n){let i;if("string"==typeof t)try{i=Ue(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!Te(t))throw new Error(`${e} must be hex string or Uint8Array`);i=Uint8Array.from(t)}const s=i.length;if("number"==typeof n&&s!==n)throw new Error(`${e} expected ${n} bytes, got ${s}`);return i}function Ge(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!Te(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const Je=e=>(Re<<BigInt(e-1))-Pe,Ke=e=>new Uint8Array(e),Ve=e=>Uint8Array.from(e);function We(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let i=Ke(e),s=Ke(e),r=0;const o=()=>{i.fill(1),s.fill(0),r=0},l=(...e)=>n(s,i,...e),a=(e=Ke())=>{s=l(Ve([0]),e),i=l(),0!==e.length&&(s=l(Ve([1]),e),i=l())},c=()=>{if(r++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=l();const t=i.slice();n.push(t),e+=i.length}return Ge(...n)};return(e,t)=>{let n;for(o(),a(e);!(n=t(c()));)a();return o(),n}}const Ye={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function Ze(e,t,n={}){const i=(t,n,i)=>{const s=Ye[n];if("function"!=typeof s)throw new Error(`Invalid validator "${n}", expected function`);const r=e[t];if(!(i&&void 0===r||s(r,e)))throw new Error(`Invalid param ${String(t)}=${r} (${typeof r}), expected ${n}`)};for(const[e,n]of Object.entries(t))i(e,n,!1);for(const[e,t]of Object.entries(n))i(e,t,!0);return e}var Xe=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&Pe},bitLen:function(e){let t;for(t=0;e>Qe;e>>=Pe,t+=1);return t},bitMask:Je,bitSet:(e,t,n)=>e|(n?Pe:Qe)<<BigInt(t),bytesToHex:_e,bytesToNumberBE:Oe,bytesToNumberLE:je,concatBytes:Ge,createHmacDrbg:We,ensureBytes:qe,equalBytes:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},hexToBytes:Ue,hexToNumber:Me,numberToBytesBE:ze,numberToBytesLE:He,numberToHexUnpadded:Ne,numberToVarBytesBE:function(e){return Ue(Ne(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},validateObject:Ze});
   4  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const et=BigInt(0),tt=BigInt(1),nt=BigInt(2),it=BigInt(3),st=BigInt(4),rt=BigInt(5),ot=BigInt(8);function lt(e,t){const n=e%t;return n>=et?n:t+n}function at(e,t,n){if(n<=et||t<et)throw new Error("Expected power/modulo > 0");if(n===tt)return et;let i=tt;for(;t>et;)t&tt&&(i=i*e%n),e=e*e%n,t>>=tt;return i}function ct(e,t,n){let i=e;for(;t-- >et;)i*=i,i%=n;return i}function ut(e,t){if(e===et||t<=et)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=lt(e,t),i=t,s=et,r=tt;for(;n!==et;){const e=i%n,t=s-r*(i/n);i=n,n=e,s=r,r=t}if(i!==tt)throw new Error("invert: does not exist");return lt(s,t)}function dt(e){if(e%st===it){const t=(e+tt)/st;return function(e,n){const i=e.pow(n,t);if(!e.eql(e.sqr(i),n))throw new Error("Cannot find square root");return i}}if(e%ot===rt){const t=(e-rt)/ot;return function(e,n){const i=e.mul(n,nt),s=e.pow(i,t),r=e.mul(n,s),o=e.mul(e.mul(r,nt),s),l=e.mul(r,e.sub(o,e.ONE));if(!e.eql(e.sqr(l),n))throw new Error("Cannot find square root");return l}}return function(e){const t=(e-tt)/nt;let n,i,s;for(n=e-tt,i=0;n%nt===et;n/=nt,i++);for(s=nt;s<e&&at(s,t,e)!==e-tt;s++);if(1===i){const t=(e+tt)/st;return function(e,n){const i=e.pow(n,t);if(!e.eql(e.sqr(i),n))throw new Error("Cannot find square root");return i}}const r=(n+tt)/nt;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let l=i,a=e.pow(e.mul(e.ONE,s),n),c=e.pow(o,r),u=e.pow(o,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(u);t<l&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(a,tt<<BigInt(l-t-1));a=e.sqr(n),c=e.mul(c,n),u=e.mul(u,a),l=t}return c}}(e)}BigInt(9),BigInt(16);const ft=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ht(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function pt(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function gt(e){const t=pt(e);return t+Math.ceil(t/2)}
   5  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
   6  const mt=BigInt(0),vt=BigInt(1);function yt(e){return function(e){const t=ft.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});Ze(e,t)}(e.Fp),Ze(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ht(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
   7  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:wt,hexToBytes:bt}=Xe,At={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=At;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],i=e.subarray(2,n+2);if(!n||i.length!==n)throw new t("Invalid signature integer: wrong length");if(128&i[0])throw new t("Invalid signature integer: negative");if(0===i[0]&&!(128&i[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:wt(i),l:e.subarray(n+2)}},toSig(e){const{Err:t}=At,n="string"==typeof e?bt(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let i=n.length;if(i<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==i-2)throw new t("Invalid signature: incorrect length");const{d:s,l:r}=At._parseInt(n.subarray(2)),{d:o,l:l}=At._parseInt(r);if(l.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},i=t(n(e.s)),s=t(n(e.r)),r=i.length/2,o=s.length/2,l=n(r),a=n(o);return`30${n(o+r+4)}02${a}${s}02${l}${i}`}},kt=BigInt(0),It=BigInt(1);BigInt(2);const Ct=BigInt(3);function Et(e){const t=function(e){const t=yt(e);Ze(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:i,a:s}=t;if(n){if(!i.eql(s,i.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,i=t.toBytes||((e,t,i)=>{const s=t.toAffine();return Ge(Uint8Array.from([4]),n.toBytes(s.x),n.toBytes(s.y))}),s=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function r(e){const{a:i,b:s}=t,r=n.sqr(e),o=n.mul(r,e);return n.add(n.add(o,n.mul(e,i)),s)}if(!n.eql(n.sqr(t.Gy),r(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"==typeof e&&kt<e&&e<t.n}function l(e){if(!o(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function a(e){const{allowedPrivateKeyLengths:n,nByteLength:i,wrapPrivateKey:s,n:r}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=_e(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*i,"0")}let o;try{o="bigint"==typeof e?e:Oe(qe("private key",e,i))}catch(t){throw new Error(`private key must be ${i} bytes, hex or bigint, not ${typeof e}`)}return s&&(o=lt(o,r)),l(o),o}const c=new Map;function u(e){if(!(e instanceof d))throw new Error("ProjectivePoint expected")}class d{constructor(e,t,i){if(this.px=e,this.py=t,this.pz=i,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==i||!n.isValid(i))throw new Error("z required")}static fromAffine(e){const{x:t,y:i}=e||{};if(!e||!n.isValid(t)||!n.isValid(i))throw new Error("invalid affine point");if(e instanceof d)throw new Error("projective point not allowed");const s=e=>n.eql(e,n.ZERO);return s(t)&&s(i)?d.ZERO:new d(t,i,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(s(qe("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(a(e))}_setWindowSize(e){this._WINDOW_SIZE=e,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:i}=this.toAffine();if(!n.isValid(e)||!n.isValid(i))throw new Error("bad point: x or y not FE");const s=n.sqr(i),o=r(e);if(!n.eql(s,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:i,pz:s}=this,{px:r,py:o,pz:l}=e,a=n.eql(n.mul(t,l),n.mul(r,s)),c=n.eql(n.mul(i,l),n.mul(o,s));return a&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:i}=t,s=n.mul(i,Ct),{px:r,py:o,pz:l}=this;let a=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(r,r),h=n.mul(o,o),p=n.mul(l,l),g=n.mul(r,o);return g=n.add(g,g),u=n.mul(r,l),u=n.add(u,u),a=n.mul(e,u),c=n.mul(s,p),c=n.add(a,c),a=n.sub(h,c),c=n.add(h,c),c=n.mul(a,c),a=n.mul(g,a),u=n.mul(s,u),p=n.mul(e,p),g=n.sub(f,p),g=n.mul(e,g),g=n.add(g,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,p),f=n.mul(f,g),c=n.add(c,f),p=n.mul(o,l),p=n.add(p,p),f=n.mul(p,g),a=n.sub(a,f),u=n.mul(p,h),u=n.add(u,u),u=n.add(u,u),new d(a,c,u)}add(e){u(e);const{px:i,py:s,pz:r}=this,{px:o,py:l,pz:a}=e;let c=n.ZERO,f=n.ZERO,h=n.ZERO;const p=t.a,g=n.mul(t.b,Ct);let m=n.mul(i,o),v=n.mul(s,l),y=n.mul(r,a),w=n.add(i,s),b=n.add(o,l);w=n.mul(w,b),b=n.add(m,v),w=n.sub(w,b),b=n.add(i,r);let A=n.add(o,a);return b=n.mul(b,A),A=n.add(m,y),b=n.sub(b,A),A=n.add(s,r),c=n.add(l,a),A=n.mul(A,c),c=n.add(v,y),A=n.sub(A,c),h=n.mul(p,b),c=n.mul(g,y),h=n.add(c,h),c=n.sub(v,h),h=n.add(v,h),f=n.mul(c,h),v=n.add(m,m),v=n.add(v,m),y=n.mul(p,y),b=n.mul(g,b),v=n.add(v,y),y=n.sub(m,y),y=n.mul(p,y),b=n.add(b,y),m=n.mul(v,b),f=n.add(f,m),m=n.mul(A,b),c=n.mul(w,c),c=n.sub(c,m),m=n.mul(w,v),h=n.mul(A,h),h=n.add(h,m),new d(c,f,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return h.wNAFCached(this,c,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const i=d.ZERO;if(e===kt)return i;if(l(e),e===It)return this;const{endo:s}=t;if(!s)return h.unsafeLadder(this,e);let{k1neg:r,k1:o,k2neg:a,k2:c}=s.splitScalar(e),u=i,f=i,p=this;for(;o>kt||c>kt;)o&It&&(u=u.add(p)),c&It&&(f=f.add(p)),p=p.double(),o>>=It,c>>=It;return r&&(u=u.negate()),a&&(f=f.negate()),f=new d(n.mul(f.px,s.beta),f.py,f.pz),u.add(f)}multiply(e){l(e);let i,s,r=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:l,k2:a}=o.splitScalar(r);let{p:c,f:u}=this.wNAF(t),{p:f,f:p}=this.wNAF(a);c=h.constTimeNegate(e,c),f=h.constTimeNegate(l,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=c.add(f),s=u.add(p)}else{const{p:e,f:t}=this.wNAF(r);i=e,s=t}return d.normalizeZ([i,s])[0]}multiplyAndAddUnsafe(e,t,n){const i=d.BASE,s=(e,t)=>t!==kt&&t!==It&&e.equals(i)?e.multiply(t):e.multiplyUnsafe(t),r=s(this,t).add(s(e,n));return r.is0()?void 0:r}toAffine(e){const{px:t,py:i,pz:s}=this,r=this.is0();null==e&&(e=r?n.ONE:n.inv(s));const o=n.mul(t,e),l=n.mul(i,e),a=n.mul(s,e);if(r)return{x:n.ZERO,y:n.ZERO};if(!n.eql(a,n.ONE))throw new Error("invZ was invalid");return{x:o,y:l}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===It)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===It?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),i(d,this,e)}toHex(e=!0){return _e(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=t.nBitLength,h=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},i=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let i=e.ZERO,s=t;for(;n>mt;)n&vt&&(i=i.add(s)),s=s.double(),n>>=vt;return i},precomputeWindow(e,t){const{windows:n,windowSize:s}=i(t),r=[];let o=e,l=o;for(let e=0;e<n;e++){l=o,r.push(l);for(let e=1;e<s;e++)l=l.add(o),r.push(l);o=l.double()}return r},wNAF(t,s,r){const{windows:o,windowSize:l}=i(t);let a=e.ZERO,c=e.BASE;const u=BigInt(2**t-1),d=2**t,f=BigInt(t);for(let e=0;e<o;e++){const t=e*l;let i=Number(r&u);r>>=f,i>l&&(i-=d,r+=vt);const o=t,h=t+Math.abs(i)-1,p=e%2!=0,g=i<0;0===i?c=c.add(n(p,s[o])):a=a.add(n(g,s[h]))}return{p:a,f:c}},wNAFCached(e,t,n,i){const s=e._WINDOW_SIZE||1;let r=t.get(e);return r||(r=this.precomputeWindow(e,s),1!==s&&t.set(e,i(r))),this.wNAF(s,r,n)}}}(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:r,isWithinCurveOrder:o}}function xt(e){const t=function(e){const t=yt(e);return Ze(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:i}=t,s=n.BYTES+1,r=2*n.BYTES+1;function o(e){return lt(e,i)}function l(e){return ut(e,i)}const{ProjectivePoint:a,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=Et({...t,toBytes(e,t,i){const s=t.toAffine(),r=n.toBytes(s.x),o=Ge;return i?o(Uint8Array.from([t.hasEvenY()?2:3]),r):o(Uint8Array.from([4]),r,n.toBytes(s.y))},fromBytes(e){const t=e.length,i=e[0],o=e.subarray(1);if(t!==s||2!==i&&3!==i){if(t===r&&4===i){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${s} compressed bytes or ${r} uncompressed bytes`)}{const e=Oe(o);if(!(kt<(l=e)&&l<n.ORDER))throw new Error("Point is not on curve");const t=u(e);let s=n.sqrt(t);return!(1&~i)!==((s&It)===It)&&(s=n.neg(s)),{x:e,y:s}}var l}}),f=e=>_e(ze(e,t.nByteLength));function h(e){return e>i>>It}const p=(e,t,n)=>Oe(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=qe("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=At.toSig(qe("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:i,s:s,recovery:r}=this,c=w(qe("msgHash",e));if(null==r||![0,1,2,3].includes(r))throw new Error("recovery id invalid");const u=2===r||3===r?i+t.n:i;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&r?"03":"02",h=a.fromHex(d+f(u)),p=l(u),g=o(-c*p),m=o(s*p),v=a.BASE.multiplyAndAddUnsafe(h,g,m);if(!v)throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ue(this.toDERHex())}toDERHex(){return At.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ue(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const m={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=gt(t.n);return function(e,t,n=!1){const i=e.length,s=pt(t),r=gt(t);if(i<16||i<r||i>1024)throw new Error(`expected ${r}-1024 bytes of input, got ${i}`);const o=lt(n?Oe(e):je(e),t-tt)+tt;return n?He(o,s):ze(o,s)}(t.randomBytes(e),t.n)},precompute:(e=8,t=a.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function v(e){const t=e instanceof Uint8Array,n="string"==typeof e,i=(t||n)&&e.length;return t?i===s||i===r:n?i===2*s||i===2*r:e instanceof a}const y=t.bits2int||function(e){const n=Oe(e),i=8*e.length-t.nBitLength;return i>0?n>>BigInt(i):n},w=t.bits2int_modN||function(e){return o(y(e))},b=Je(t.nBitLength);function A(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(kt<=e&&e<b))throw new Error(`bigint expected < 2^${t.nBitLength}`);return ze(e,t.nByteLength)}function k(e,i,s=I){if(["recovered","canonical"].some(e=>e in s))throw new Error("sign() legacy options not supported");const{hash:r,randomBytes:u}=t;let{lowS:f,prehash:p,extraEntropy:m}=s;null==f&&(f=!0),e=qe("msgHash",e),p&&(e=qe("prehashed msgHash",r(e)));const v=w(e),b=c(i),k=[A(b),A(v)];if(null!=m){const e=!0===m?u(n.BYTES):m;k.push(qe("extraEntropy",e))}const C=Ge(...k),E=v;return{seed:C,k2sig:function(e){const t=y(e);if(!d(t))return;const n=l(t),i=a.BASE.multiply(t).toAffine(),s=o(i.x);if(s===kt)return;const r=o(n*o(E+s*b));if(r===kt)return;let c=(i.x===s?0:2)|Number(i.y&It),u=r;return f&&h(r)&&(u=function(e){return h(e)?o(-e):e}(r),c^=1),new g(s,u,c)}}}const I={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};return a.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return a.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(v(e))throw new Error("first arg must be private key");if(!v(t))throw new Error("second arg must be public key");return a.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,i=I){const{seed:s,k2sig:r}=k(e,n,i),o=t;return We(o.hash.outputLen,o.nByteLength,o.hmac)(s,r)},verify:function(e,n,i,s=C){const r=e;if(n=qe("msgHash",n),i=qe("publicKey",i),"strict"in s)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=s;let d,f;try{if("string"==typeof r||r instanceof Uint8Array)try{d=g.fromDER(r)}catch(e){if(!(e instanceof At.Err))throw e;d=g.fromCompact(r)}else{if("object"!=typeof r||"bigint"!=typeof r.r||"bigint"!=typeof r.s)throw new Error("PARSE");{const{r:e,s:t}=r;d=new g(e,t)}}f=a.fromHex(i)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:h,s:p}=d,m=w(n),v=l(p),y=o(m*v),b=o(h*v),A=a.BASE.multiplyAndAddUnsafe(f,y,b)?.toAffine();return!!A&&o(A.x)===h},ProjectivePoint:a,Signature:g,utils:m}}BigInt(4);let St=class extends Ae{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");he(e.outputLen),he(e.blockLen)}(e);const n=be(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return ge(this),this.iHash.update(e),this}digestInto(e){ge(this),pe(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:i,destroyed:s,blockLen:r,outputLen:o}=this;return e.finished=i,e.destroyed=s,e.blockLen=r,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Bt=(e,t,n)=>new St(e,t).update(n).digest();
   8  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
   9  function $t(e){return{hash:e,hmac:(t,...n)=>Bt(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!ve(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:Ie}}Bt.create=(e,t)=>new St(e,t);
  10  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
  11  const Ft=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Dt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Qt=BigInt(1),Pt=BigInt(2),Rt=(e,t)=>(e+t/Pt)/t;function Tt(e){const t=Ft,n=BigInt(3),i=BigInt(6),s=BigInt(11),r=BigInt(22),o=BigInt(23),l=BigInt(44),a=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=ct(u,n,t)*u%t,f=ct(d,n,t)*u%t,h=ct(f,Pt,t)*c%t,p=ct(h,s,t)*h%t,g=ct(p,r,t)*p%t,m=ct(g,l,t)*g%t,v=ct(m,a,t)*m%t,y=ct(v,l,t)*g%t,w=ct(y,n,t)*u%t,b=ct(w,o,t)*p%t,A=ct(b,i,t)*c%t,k=ct(A,Pt,t);if(!Lt.eql(Lt.sqr(k),e))throw new Error("Cannot find square root");return k}const Lt=function(e,t,n=!1,i={}){if(e<=et)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:r}=ht(e,t);if(r>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=dt(e),l=Object.freeze({ORDER:e,BITS:s,BYTES:r,MASK:Je(s),ZERO:et,ONE:tt,create:t=>lt(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return et<=t&&t<e},is0:e=>e===et,isOdd:e=>(e&tt)===tt,neg:t=>lt(-t,e),eql:(e,t)=>e===t,sqr:t=>lt(t*t,e),add:(t,n)=>lt(t+n,e),sub:(t,n)=>lt(t-n,e),mul:(t,n)=>lt(t*n,e),pow:(e,t)=>function(e,t,n){if(n<et)throw new Error("Expected power > 0");if(n===et)return e.ONE;if(n===tt)return t;let i=e.ONE,s=t;for(;n>et;)n&tt&&(i=e.mul(i,s)),s=e.sqr(s),n>>=tt;return i}(l,e,t),div:(t,n)=>lt(t*ut(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ut(t,e),sqrt:i.sqrt||(e=>o(l,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),i=t.reduce((t,i,s)=>e.is0(i)?t:(n[s]=t,e.mul(t,i)),e.ONE),s=e.inv(i);return t.reduceRight((t,i,s)=>e.is0(i)?t:(n[s]=e.mul(t,n[s]),e.mul(t,i)),s),n}(l,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?He(e,r):ze(e,r),fromBytes:e=>{if(e.length!==r)throw new Error(`Fp.fromBytes: expected ${r}, got ${e.length}`);return n?je(e):Oe(e)}});return Object.freeze(l)}(Ft,void 0,void 0,{sqrt:Tt}),_t=function(e,t){const n=t=>xt({...e,...$t(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Lt,n:Dt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Dt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Qt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),r=n,o=BigInt("0x100000000000000000000000000000000"),l=Rt(r*e,t),a=Rt(-i*e,t);let c=lt(e-l*n-a*s,t),u=lt(-l*i-a*r,t);const d=c>o,f=u>o;if(d&&(c=t-c),f&&(u=t-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}}},De),Nt=BigInt(0),Mt=e=>"bigint"==typeof e&&Nt<e&&e<Ft,Ut={};function Ot(e,...t){let n=Ut[e];if(void 0===n){const t=De(Uint8Array.from(e,e=>e.charCodeAt(0)));n=Ge(t,t),Ut[e]=n}return De(Ge(n,...t))}const jt=e=>e.toRawBytes(!0).slice(1),zt=e=>ze(e,32),Ht=e=>lt(e,Ft),qt=e=>lt(e,Dt),Gt=_t.ProjectivePoint;function Jt(e){let t=_t.utils.normPrivateKeyToScalar(e),n=Gt.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:qt(-t),bytes:jt(n)}}function Kt(e){if(!Mt(e))throw new Error("bad x: need 0 < x < p");const t=Ht(e*e);let n=Tt(Ht(t*e+BigInt(7)));n%Pt!==Nt&&(n=Ht(-n));const i=new Gt(e,n,Qt);return i.assertValidity(),i}function Vt(...e){return qt(Oe(Ot("BIP0340/challenge",...e)))}function Wt(e){return Jt(e).bytes}function Yt(e,t,n=Ie(32)){const i=qe("message",e),{bytes:s,scalar:r}=Jt(t),o=qe("auxRand",n,32),l=zt(r^Oe(Ot("BIP0340/aux",o))),a=Ot("BIP0340/nonce",l,s,i),c=qt(Oe(a));if(c===Nt)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Jt(c),f=Vt(u,s,i),h=new Uint8Array(64);if(h.set(u,0),h.set(zt(qt(d+f*r)),32),!Zt(h,i,s))throw new Error("sign: Invalid signature produced");return h}function Zt(e,t,n){const i=qe("signature",e,64),s=qe("message",t),r=qe("publicKey",n,32);try{const e=Kt(Oe(r)),t=Oe(i.subarray(0,32));if(!Mt(t))return!1;const n=Oe(i.subarray(32,64));if(!("bigint"==typeof(c=n)&&Nt<c&&c<Dt))return!1;const u=Vt(zt(t),jt(e),s),d=(o=e,l=n,a=qt(-u),Gt.BASE.multiplyAndAddUnsafe(o,l,a));return!(!d||!d.hasEvenY()||d.toAffine().x!==t)}catch(e){return!1}var o,l,a,c}const Xt=(()=>({getPublicKey:Wt,sign:Yt,verify:Zt,utils:{randomPrivateKey:_t.utils.randomPrivateKey,lift_x:Kt,pointToBytes:jt,numberToBytesBE:ze,bytesToNumberBE:Oe,taggedHash:Ot,mod:lt}}))(),en="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,tn=e=>e instanceof Uint8Array,nn=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),sn=(e,t)=>e<<32-t|e>>>t;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const rn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function on(e){if(!tn(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=rn[e[n]];return t}function ln(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let t=0;t<n.length;t++){const i=2*t,s=e.slice(i,i+2),r=Number.parseInt(s,16);if(Number.isNaN(r)||r<0)throw new Error("Invalid byte sequence");n[t]=r}return n}function an(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!tn(e))throw new Error("expected Uint8Array, got "+typeof e);return e}function cn(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!tn(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}class un{clone(){return this._cloneInto()}}function dn(e){const t=t=>e().update(an(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function fn(e=32){if(en&&"function"==typeof en.getRandomValues)return en.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function hn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function pn(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}const gn={number:hn,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:pn,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");hn(e.outputLen),hn(e.blockLen)},exists:function(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")},output:function(e,t){pn(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}};class mn extends un{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=nn(this.buffer)}update(e){gn.exists(this);const{view:t,buffer:n,blockLen:i}=this,s=(e=an(e)).length;for(let r=0;r<s;){const o=Math.min(i-this.pos,s-r);if(o===i){const t=nn(e);for(;i<=s-r;r+=i)this.process(t,r);continue}n.set(e.subarray(r,r+o),this.pos),this.pos+=o,r+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){gn.exists(this),gn.output(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:r}=this;t[r++]=128,this.buffer.subarray(r).fill(0),this.padOffset>i-r&&(this.process(n,0),r=0);for(let e=r;e<i;e++)t[e]=0;!function(e,t,n,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,i);const s=BigInt(32),r=BigInt(4294967295),o=Number(n>>s&r),l=Number(n&r),a=i?4:0,c=i?0:4;e.setUint32(t+a,o,i),e.setUint32(t+c,l,i)}(n,i-8,BigInt(8*this.length),s),this.process(n,0);const o=nn(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=l/4,c=this.get();if(a>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<a;e++)o.setUint32(4*e,c[e],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:r,pos:o}=this;return e.length=i,e.pos=o,e.finished=s,e.destroyed=r,i%t&&e.buffer.set(n),e}}const vn=(e,t,n)=>e&t^~e&n,yn=(e,t,n)=>e&t^e&n^t&n,wn=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),bn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),An=new Uint32Array(64);class kn extends mn{constructor(){super(64,32,8,!1),this.A=0|bn[0],this.B=0|bn[1],this.C=0|bn[2],this.D=0|bn[3],this.E=0|bn[4],this.F=0|bn[5],this.G=0|bn[6],this.H=0|bn[7]}get(){const{A:e,B:t,C:n,D:i,E:s,F:r,G:o,H:l}=this;return[e,t,n,i,s,r,o,l]}set(e,t,n,i,s,r,o,l){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|s,this.F=0|r,this.G=0|o,this.H=0|l}process(e,t){for(let n=0;n<16;n++,t+=4)An[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=An[e-15],n=An[e-2],i=sn(t,7)^sn(t,18)^t>>>3,s=sn(n,17)^sn(n,19)^n>>>10;An[e]=s+An[e-7]+i+An[e-16]|0}let{A:n,B:i,C:s,D:r,E:o,F:l,G:a,H:c}=this;for(let e=0;e<64;e++){const t=c+(sn(o,6)^sn(o,11)^sn(o,25))+vn(o,l,a)+wn[e]+An[e]|0,u=(sn(n,2)^sn(n,13)^sn(n,22))+yn(n,i,s)|0;c=a,a=l,l=o,o=r+t|0,r=s,s=i,i=n,n=t+u|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,r=r+this.D|0,o=o+this.E|0,l=l+this.F|0,a=a+this.G|0,c=c+this.H|0,this.set(n,i,s,r,o,l,a,c)}roundClean(){An.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class In extends kn{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const Cn=dn(()=>new kn);dn(()=>new In);var En=Symbol("verified");function xn(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("string"!=typeof n[e])return!1}return!0}new TextDecoder("utf-8");var Sn=new TextEncoder;function Bn(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}var $n=class{value;next=null;prev=null;constructor(e){this.value=e}},Fn=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new $n(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}};function Dn(e){return on(Cn(Sn.encode(function(e){if(!xn(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])}(e))))}var Qn=new class{generateSecretKey(){return Xt.utils.randomPrivateKey()}getPublicKey(e){return on(Xt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=on(Xt.getPublicKey(t)),n.id=Dn(n),n.sig=on(Xt.sign(Dn(n),t)),n[En]=!0,n}verifyEvent(e){if("boolean"==typeof e[En])return e[En];const t=Dn(e);if(t!==e.id)return e[En]=!1,!1;try{const n=Xt.verify(e.sig,t,e.pubkey);return e[En]=n,n}catch(t){return e[En]=!1,!1}}};Qn.generateSecretKey,Qn.getPublicKey,Qn.finalizeEvent;var Pn=Qn.verifyEvent;function Rn(e,t){if(e.ids&&-1===e.ids.indexOf(t.id))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey))return!1;for(let n in e)if("#"===n[0]){let i=e[`#${n.slice(1)}`];if(i&&!t.tags.find(([e,t])=>e===n.slice(1)&&-1!==i.indexOf(t)))return!1}return!(e.since&&t.created_at<e.since)&&!(e.until&&t.created_at>e.until)}async function Tn(){return new Promise(e=>{const t=new MessageChannel,n=()=>{t.port1.removeEventListener("message",n),e()};t.port1.addEventListener("message",n),t.port2.postMessage(0),t.port1.start()})}var Ln,_n=e=>(e[En]=!0,!0),Nn=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},Mn=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);baseEoseTimeout=4400;connectionTimeout=4400;publishTimeout=4400;pingFrequency=2e4;pingTimeout=2e4;openSubs=new Map;enablePing;connectionTimeoutHandle;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new Fn;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=Bn(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing}static async connect(e,t){const n=new Mn(e,t);return await n.connect(),n}closeAllSubscriptions(e){for(let[t,n]of this.openSubs)n.close(e);this.openSubs.clear();for(let[t,n]of this.openEventPublishes)n.reject(new Error(e));this.openEventPublishes.clear();for(let[t,n]of this.openCountRequests)n.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise||(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((e,t)=>{this.connectionTimeoutHandle=setTimeout(()=>{t("connection timed out"),this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(e){return clearTimeout(this.connectionTimeoutHandle),void t(e)}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,this.enablePing&&this.pingpong(),e()},this.ws.onerror=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket error"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection errored")},this.ws.onclose=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket closed"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)})),this.connectionPromise}async waitForPingPong(){return new Promise((e,t)=>{this.ws&&this.ws.on&&this.ws.on("pong",()=>e(!0))||t("ws can't listen for pong"),this.ws&&this.ws.ping&&this.ws.ping()})}async waitForDummyReq(){return new Promise((e,t)=>{const n=this.subscribe([{ids:["a".repeat(64)]}],{oneose:()=>{n.close(),e(!0)},eoseTimeout:this.pingTimeout+1e3})})}async pingpong(){if(1===this.ws?.readyState){await Promise.any([this.ws&&this.ws.ping&&this.ws.on?this.waitForPingPong():this.waitForDummyReq(),new Promise(e=>setTimeout(()=>e(!1),this.pingTimeout))])?setTimeout(()=>this.pingpong(),this.pingFrequency):(this.closeAllSubscriptions("pingpong timed out"),this._connected=!1,this.onclose?.(),this.ws?.close())}}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await Tn();this.queueRunning=!1}handleNext(){const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=function(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let i=t+7+1+n,s=e.slice(i+1,80).indexOf('"');if(-1===s)return null;let r=i+1+s;return e.slice(i+1,r)}(e);if(t){const n=this.openSubs.get(t);if(!n)return;const i=function(e,t){let n=t.length+3,i=e.indexOf(`"${t}":`)+n,s=e.slice(i).indexOf('"')+i+1;return e.slice(s,s+64)}(e,"id"),s=n.alreadyHaveEvent?.(i);if(n.receivedEvent?.(this,i),s)return}try{let t=JSON.parse(e);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return void(this.verifyEvent(n)&&function(e,t){for(let n=0;n<e.length;n++)if(Rn(e[n],t))return!0;return!1}(e.filters,n)&&e.onevent(n))}case"COUNT":{const e=t[1],n=t[2],i=this.openCountRequests.get(e);return void(i&&(i.resolve(n.count),this.openCountRequests.delete(e)))}case"EOSE":{const e=this.openSubs.get(t[1]);if(!e)return;return void e.receivedEose()}case"OK":{const e=t[1],n=t[2],i=t[3],s=this.openEventPublishes.get(e);return void(s&&(clearTimeout(s.timeout),n?s.resolve(i):s.reject(new Error(i)),this.openEventPublishes.delete(e)))}case"CLOSED":{const e=t[1],n=this.openSubs.get(e);if(!n)return;return n.closed=!0,void n.close(t[2])}case"NOTICE":return void this.onnotice(t[1]);case"AUTH":return void(this.challenge=t[1])}}catch(e){return}}async send(e){if(!this.connectionPromise)throw new Nn(e,this.url);this.connectionPromise.then(()=>{this.ws?.send(e)})}async auth(e){const t=this.challenge;if(!t)throw new Error("can't perform auth, no challenge was received");return this.authPromise||(this.authPromise=new Promise(async(n,i)=>{try{let s=await e(function(e,t){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}(this.url,t)),r=setTimeout(()=>{let e=this.openEventPublishes.get(s.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(s.id))},this.publishTimeout);this.openEventPublishes.set(s.id,{resolve:n,reject:i,timeout:r}),this.send('["AUTH",'+JSON.stringify(s)+"]")}catch(e){console.warn("subscribe auth function failed:",e)}})),this.authPromise}async publish(e){const t=new Promise((t,n)=>{const i=setTimeout(()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:i})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;const n=t?.id||"count:"+this.serial,i=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),i}subscribe(e,t){const n=this.prepareSubscription(e,t);return n.fire(),n}prepareSubscription(e,t){this.serial++;const n=t.id||(t.label?t.label+":":"sub:")+this.serial,i=new Un(this,n,e,t);return this.openSubs.set(n,i),i}close(){this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.onclose?.(),this.ws?.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Un=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,i){this.relay=e,this.filters=n,this.id=t,this.alreadyHaveEvent=i.alreadyHaveEvent,this.receivedEvent=i.receivedEvent,this.eoseTimeout=i.eoseTimeout||e.baseEoseTimeout,this.oneose=i.oneose,this.onclose=i.onclose,this.onevent=i.onevent||(e=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,e)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,this.oneose?.())}close(e="closed by caller"){if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(e){if(!(e instanceof Nn))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}},On=class{relays=new Map;seenOn=new Map;trackRelays=!1;verifyEvent;enablePing;trustedRelayURLs=new Set;_WebSocket;constructor(e){this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing}async ensureRelay(e,t){e=Bn(e);let n=this.relays.get(e);return n||(n=new Mn(e,{verifyEvent:this.trustedRelayURLs.has(e)?_n:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing}),n.onclose=()=>{this.relays.delete(e)},t?.connectionTimeout&&(n.connectionTimeout=t.connectionTimeout),this.relays.set(e,n)),await n.connect(),n}close(e){e.map(Bn).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){n.onauth=n.onauth||n.doauth;const i=[];for(let n=0;n<e.length;n++){const s=Bn(e[n]);i.find(e=>e.url===s)||i.push({url:s,filter:t})}return this.subscribeMap(i,n)}subscribeMany(e,t,n){n.onauth=n.onauth||n.doauth;const i=[],s=[];for(let n=0;n<e.length;n++){const r=Bn(e[n]);-1===s.indexOf(r)&&(s.push(r),i.push({url:r,filter:t}))}return this.subscribeMap(i,n)}subscribeMap(e,t){t.onauth=t.onauth||t.doauth;const n=new Map;for(const t of e){const{url:e,filter:i}=t;n.has(e)||n.set(e,[]),n.get(e).push(i)}const i=Array.from(n.entries()).map(([e,t])=>({url:e,filters:t}));this.trackRelays&&(t.receivedEvent=(e,t)=>{let n=this.seenOn.get(t);n||(n=new Set,this.seenOn.set(t,n)),n.add(e)});const s=new Set,r=[],o=[];let l=n=>{o[n]||(o[n]=!0,o.filter(e=>e).length===e.length&&(t.oneose?.(),l=()=>{}))};const a=[];let c=(n,i)=>{a[n]||(l(n),a[n]=i,a.filter(e=>e).length===e.length&&(t.onclose?.(a),c=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=s.has(e);return s.add(e),n},d=Promise.all(i.map(async({url:e,filters:n},i)=>{let s;try{s=await this.ensureRelay(e,{connectionTimeout:t.maxWait?Math.max(.8*t.maxWait,t.maxWait-1e3):void 0})}catch(e){return void c(i,e?.message||String(e))}let o=s.subscribe(n,{...t,oneose:()=>l(i),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?s.auth(t.onauth).then(()=>{s.subscribe(n,{...t,oneose:()=>l(i),onclose:e=>{c(i,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait})}).catch(e=>{c(i,`auth was required and attempted, but failed with: ${e}`)}):c(i,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait});r.push(o)}));return{async close(e){await d,r.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){n.onauth=n.onauth||n.doauth;const i=this.subscribe(e,t,{...n,oneose(){i.close("closed automatically on eose")}});return i}subscribeManyEose(e,t,n){n.onauth=n.onauth||n.doauth;const i=this.subscribeMany(e,t,{...n,oneose(){i.close("closed automatically on eose")}});return i}async querySync(e,t,n){return new Promise(async i=>{const s=[];this.subscribeEose(e,t,{...n,onevent(e){s.push(e)},onclose(e){i(s)}})})}async get(e,t,n){t.limit=1;const i=await this.querySync(e,t,n);return i.sort((e,t)=>t.created_at-e.created_at),i[0]||null}publish(e,t,n){return e.map(Bn).map(async(e,i,s)=>{if(s.indexOf(e)!==i)return Promise.reject("duplicate url");let r=await this.ensureRelay(e);return r.publish(t).catch(async e=>{if(e instanceof Error&&e.message.startsWith("auth-required: ")&&n?.onauth)return await r.auth(n.onauth),r.publish(t);throw e}).then(e=>{if(this.trackRelays){let e=this.seenOn.get(t.id);e||(e=new Set,this.seenOn.set(t.id,e)),e.add(r)}return e})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((t,n)=>e.set(n,t.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}};try{Ln=WebSocket}catch{}var jn=class extends On{constructor(e){super({verifyEvent:Pn,websocketImplementation:Ln,...e})}};
  12  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function zn(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function Hn(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),i=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:i}}function qn(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(zn(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function Gn(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function Jn(e,t="="){if(zn(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let i=n.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,i)}}}function Kn(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function Vn(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const s=[],r=Array.from(e);for(r.forEach(e=>{if(zn(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let s=i;s<r.length;s++){const l=r[s],a=t*e+l;if(!Number.isSafeInteger(a)||t*e/t!==e||a-l!==t*e)throw new Error("convertRadix: carry overflow");if(e=a%n,r[s]=Math.floor(a/n),!Number.isSafeInteger(r[s])||r[s]*n+e!==a)throw new Error("convertRadix: carry overflow");o&&(r[s]?o=!1:i=s)}if(s.push(e),o)break}for(let t=0;t<e.length-1&&0===e[t];t++)s.push(0);return s.reverse()}const Wn=(e,t)=>t?Wn(t,e%t):e,Yn=(e,t)=>e+(t-Wn(e,t));function Zn(e,t,n,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Yn(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Yn(t,n)}`);let s=0,r=0;const o=2**n-1,l=[];for(const i of e){if(zn(i),i>=2**t)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(s=s<<t|i,r+t>32)throw new Error(`convertRadix2: carry overflow pos=${r} from=${t}`);for(r+=t;r>=n;r-=n)l.push((s>>r-n&o)>>>0);s&=2**r-1}if(s=s<<n-r&o,!i&&r>=t)throw new Error("Excess padding");if(!i&&s)throw new Error(`Non-zero padding: ${s}`);return i&&r>0&&l.push(s>>>0),l}function Xn(e,t=!1){if(zn(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Yn(8,e)>32||Yn(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Zn(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Zn(n,e,8,t))}}}function ei(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const ti=Hn(Xn(4),qn("0123456789ABCDEF"),Gn("")),ni=Hn(Xn(5),qn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Jn(5),Gn(""));Hn(Xn(5),qn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Jn(5),Gn("")),Hn(Xn(5),qn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Gn(""),Kn(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const ii=Hn(Xn(6),qn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Jn(6),Gn("")),si=Hn(Xn(6),qn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Jn(6),Gn("")),ri=e=>{return Hn((zn(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Vn(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Vn(e,t,256))}}),qn(e),Gn(""));var t},oi=ri("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");ri("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),ri("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const li=[0,2,3,5,6,7,9,10,11],ai={encode(e){let t="";for(let n=0;n<e.length;n+=8){const i=e.subarray(n,n+8);t+=oi.encode(i).padStart(li[i.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const i=e.slice(n,n+11),s=li.indexOf(i.length),r=oi.decode(i);for(let e=0;e<r.length-s;e++)if(0!==r[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(r.slice(r.length-s)))}return Uint8Array.from(t)}},ci=Hn(qn("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Gn("")),ui=[996825010,642813549,513874426,1027748829,705979059];function di(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<ui.length;e++)1==(t>>e&1)&&(n^=ui[e]);return n}function fi(e,t,n=1){const i=e.length;let s=1;for(let t=0;t<i;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);s=di(s)^n>>5}s=di(s);for(let t=0;t<i;t++)s=di(s)^31&e.charCodeAt(t);for(let e of t)s=di(s)^e;for(let e=0;e<6;e++)s=di(s);return s^=n,ci.encode(Zn([s%2**30],30,5,!1))}function hi(e){const t="bech32"===e?1:734539939,n=Xn(5),i=n.decode,s=n.encode,r=ei(i);function o(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=(e=i).lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const r=e.slice(0,s),o=e.slice(s+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const l=ci.decode(o).slice(0,-6),a=fi(r,l,t);if(!o.endsWith(a))throw new Error(`Invalid checksum in ${e}: expected "${a}"`);return{prefix:r,words:l}}return{encode:function(e,n,i=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const s=e.length+7+n.length;if(!1!==i&&s>i)throw new TypeError(`Length ${s} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${ci.encode(n)}${fi(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:i(n)}},decodeUnsafe:ei(o),fromWords:i,fromWordsUnsafe:r,toWords:s}}const pi=hi("bech32");hi("bech32m");const gi={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:Hn(Xn(4),qn("0123456789abcdef"),Gn(""),Kn(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),base16:ti,base32:ni,base64:ii,base64url:si,base58:oi,base58xmr:ai};function mi(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function vi(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function yi(e,...t){if(!((n=e)instanceof Uint8Array||null!=n&&"object"==typeof n&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}
  13  /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Object.keys(gi).join(", ");const wi=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const bi=16;function Ai(e){return e<<1^283&-(e>>7)}function ki(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=Ai(e);return n}const Ii=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=Ai(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let i=e[255-n];i|=i<<8,t[e[n]]=255&(i^i>>4^i>>5^i>>6^i>>7^99)}return t})(),Ci=Ii.map((e,t)=>Ii.indexOf(t)),Ei=e=>e<<24|e>>>8,xi=e=>e<<8|e>>>24;function Si(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,i)=>t(e[i])),i=n.map(xi),s=i.map(xi),r=s.map(xi),o=new Uint32Array(65536),l=new Uint32Array(65536),a=new Uint16Array(65536);for(let t=0;t<256;t++)for(let c=0;c<256;c++){const u=256*t+c;o[u]=n[t]^i[c],l[u]=s[t]^r[c],a[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:a,T0:n,T1:i,T2:s,T3:r,T01:o,T23:l}}const Bi=Si(Ii,e=>ki(e,3)<<24|e<<16|e<<8|ki(e,2)),$i=Si(Ci,e=>ki(e,11)<<24|ki(e,13)<<16|ki(e,9)<<8|ki(e,14)),Fi=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Ai(n))e[t]=n;return e})();function Di(e){yi(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=Bi,i=wi(e),s=i.length,r=e=>Pi(n,e,e,e,e),o=new Uint32Array(t+28);o.set(i);for(let e=s;e<o.length;e++){let t=o[e-1];e%s===0?t=r(Ei(t))^Fi[e/s-1]:s>6&&e%s===4&&(t=r(t)),o[e]=o[e-s]^t}return o}function Qi(e,t,n,i,s,r){return e[n<<8&65280|i>>>8&255]^t[s>>>8&65280|r>>>24&255]}function Pi(e,t,n,i,s){return e[255&t|65280&n]|e[i>>>16&255|s>>>16&65280]<<16}function Ri(e,t,n,i,s){const{sbox2:r,T01:o,T23:l}=Bi;let a=0;t^=e[a++],n^=e[a++],i^=e[a++],s^=e[a++];const c=e.length/4-2;for(let r=0;r<c;r++){const r=e[a++]^Qi(o,l,t,n,i,s),c=e[a++]^Qi(o,l,n,i,s,t),u=e[a++]^Qi(o,l,i,s,t,n),d=e[a++]^Qi(o,l,s,t,n,i);t=r,n=c,i=u,s=d}return{s0:e[a++]^Pi(r,t,n,i,s),s1:e[a++]^Pi(r,n,i,s,t),s2:e[a++]^Pi(r,i,s,t,n),s3:e[a++]^Pi(r,s,t,n,i)}}function Ti(e,t,n,i,s){const{sbox2:r,T01:o,T23:l}=$i;let a=0;t^=e[a++],n^=e[a++],i^=e[a++],s^=e[a++];const c=e.length/4-2;for(let r=0;r<c;r++){const r=e[a++]^Qi(o,l,t,s,i,n),c=e[a++]^Qi(o,l,n,t,s,i),u=e[a++]^Qi(o,l,i,n,t,s),d=e[a++]^Qi(o,l,s,i,n,t);t=r,n=c,i=u,s=d}return{s0:e[a++]^Pi(r,t,s,i,n),s1:e[a++]^Pi(r,n,t,s,i),s2:e[a++]^Pi(r,i,n,t,s),s3:e[a++]^Pi(r,s,i,n,t)}}function Li(e,t){if(!t)return new Uint8Array(e);if(yi(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);return t}const _i=(Ni={blockSize:16,nonceLength:16},Mi=function(e,t,n={}){yi(e),yi(t,16);const i=!n.disablePadding;return{encrypt:(n,s)=>{const r=Di(e),{b:o,o:l,out:a}=function(e,t,n){let i=e.length;const s=i%bi;if(!t&&0!==s)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const r=wi(e);if(t){let e=bi-s;e||(e=bi),i+=e}const o=Li(i,n);return{b:r,o:wi(o),out:o}}(n,i,s),c=wi(t);let u=c[0],d=c[1],f=c[2],h=c[3],p=0;for(;p+4<=o.length;)u^=o[p+0],d^=o[p+1],f^=o[p+2],h^=o[p+3],({s0:u,s1:d,s2:f,s3:h}=Ri(r,u,d,f,h)),l[p++]=u,l[p++]=d,l[p++]=f,l[p++]=h;if(i){const e=function(e){const t=new Uint8Array(16),n=wi(t);t.set(e);const i=bi-e.length;for(let e=bi-i;e<bi;e++)t[e]=i;return n}(n.subarray(4*p));u^=e[0],d^=e[1],f^=e[2],h^=e[3],({s0:u,s1:d,s2:f,s3:h}=Ri(r,u,d,f,h)),l[p++]=u,l[p++]=d,l[p++]=f,l[p++]=h}return r.fill(0),a},decrypt:(n,s)=>{!function(e){if(yi(e),e.length%bi!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const r=function(e){const t=Di(e),n=t.slice(),i=t.length,{sbox2:s}=Bi,{T0:r,T1:o,T2:l,T3:a}=$i;for(let e=0;e<i;e+=4)for(let s=0;s<4;s++)n[e+s]=t[i-e-4+s];t.fill(0);for(let e=4;e<i-4;e++){const t=n[e],i=Pi(s,t,t,t,t);n[e]=r[255&i]^o[i>>>8&255]^l[i>>>16&255]^a[i>>>24]}return n}(e),o=wi(t),l=Li(n.length,s),a=wi(n),c=wi(l);let u=o[0],d=o[1],f=o[2],h=o[3];for(let e=0;e+4<=a.length;){const t=u,n=d,i=f,s=h;u=a[e+0],d=a[e+1],f=a[e+2],h=a[e+3];const{s0:o,s1:l,s2:p,s3:g}=Ti(r,u,d,f,h);c[e++]=o^t,c[e++]=l^n,c[e++]=p^i,c[e++]=g^s}return r.fill(0),function(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const i=e[n-1];if(i<=0||i>16)throw new Error(`aes/pcks5: wrong padding byte: ${i}`);const s=e.subarray(0,-i);for(let t=0;t<i;t++)if(e[n-t-1]!==i)throw new Error("aes/pcks5: wrong padding");return s}(l,i)}}},Object.assign(Mi,Ni),Mi);var Ni,Mi;const Ui=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Oi=Ui("expand 16-byte k"),ji=Ui("expand 32-byte k"),zi=wi(Oi),Hi=wi(ji);function qi(e,t){return e<<t|e>>>32-t}function Gi(e){return e.byteOffset%4==0}Hi.slice();const Ji=2**32-1,Ki=new Uint32Array;function Vi(e,t){const{allowShortKeys:n,extendNonceFn:i,counterLength:s,counterRight:r,rounds:o}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return mi(s),mi(o),vi(r),vi(n),(t,l,a,c,u=0)=>{yi(t),yi(l),yi(a);const d=a.length;if(c||(c=new Uint8Array(d)),yi(c),mi(u),u<0||u>=Ji)throw new Error("arx: counter overflow");if(c.length<d)throw new Error(`arx: output (${c.length}) is shorter than data (${d})`);const f=[];let h,p,g=t.length;if(32===g)h=t.slice(),f.push(h),p=Hi;else{if(16!==g||!n)throw new Error(`arx: invalid 32-byte key, got length=${g}`);h=new Uint8Array(32),h.set(t),h.set(t,16),p=zi,f.push(h)}Gi(l)||(l=l.slice(),f.push(l));const m=wi(h);if(i){if(24!==l.length)throw new Error("arx: extended nonce must be 24 bytes");i(p,m,wi(l.subarray(0,16)),m),l=l.subarray(16)}const v=16-s;if(v!==l.length)throw new Error(`arx: nonce must be ${v} or 16 bytes`);if(12!==v){const e=new Uint8Array(12);e.set(l,r?0:12-l.length),l=e,f.push(l)}const y=wi(l);for(!function(e,t,n,i,s,r,o,l){const a=s.length,c=new Uint8Array(64),u=wi(c),d=Gi(s)&&Gi(r),f=d?wi(s):Ki,h=d?wi(r):Ki;for(let p=0;p<a;o++){if(e(t,n,i,u,o,l),o>=Ji)throw new Error("arx: counter overflow");const g=Math.min(64,a-p);if(d&&64===g){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,h[t]=f[t]^u[n];p+=64;continue}for(let e,t=0;t<g;t++)e=p+t,r[e]=s[e]^c[t];p+=g}}(e,p,m,y,a,c,u,o);f.length>0;)f.pop().fill(0);return c}}function Wi(e,t,n,i,s,r=20){let o=e[0],l=e[1],a=e[2],c=e[3],u=t[0],d=t[1],f=t[2],h=t[3],p=t[4],g=t[5],m=t[6],v=t[7],y=s,w=n[0],b=n[1],A=n[2],k=o,I=l,C=a,E=c,x=u,S=d,B=f,$=h,F=p,D=g,Q=m,P=v,R=y,T=w,L=b,_=A;for(let e=0;e<r;e+=2)k=k+x|0,R=qi(R^k,16),F=F+R|0,x=qi(x^F,12),k=k+x|0,R=qi(R^k,8),F=F+R|0,x=qi(x^F,7),I=I+S|0,T=qi(T^I,16),D=D+T|0,S=qi(S^D,12),I=I+S|0,T=qi(T^I,8),D=D+T|0,S=qi(S^D,7),C=C+B|0,L=qi(L^C,16),Q=Q+L|0,B=qi(B^Q,12),C=C+B|0,L=qi(L^C,8),Q=Q+L|0,B=qi(B^Q,7),E=E+$|0,_=qi(_^E,16),P=P+_|0,$=qi($^P,12),E=E+$|0,_=qi(_^E,8),P=P+_|0,$=qi($^P,7),k=k+S|0,_=qi(_^k,16),Q=Q+_|0,S=qi(S^Q,12),k=k+S|0,_=qi(_^k,8),Q=Q+_|0,S=qi(S^Q,7),I=I+B|0,R=qi(R^I,16),P=P+R|0,B=qi(B^P,12),I=I+B|0,R=qi(R^I,8),P=P+R|0,B=qi(B^P,7),C=C+$|0,T=qi(T^C,16),F=F+T|0,$=qi($^F,12),C=C+$|0,T=qi(T^C,8),F=F+T|0,$=qi($^F,7),E=E+x|0,L=qi(L^E,16),D=D+L|0,x=qi(x^D,12),E=E+x|0,L=qi(L^E,8),D=D+L|0,x=qi(x^D,7);let N=0;i[N++]=o+k|0,i[N++]=l+I|0,i[N++]=a+C|0,i[N++]=c+E|0,i[N++]=u+x|0,i[N++]=d+S|0,i[N++]=f+B|0,i[N++]=h+$|0,i[N++]=p+F|0,i[N++]=g+D|0,i[N++]=m+Q|0,i[N++]=v+P|0,i[N++]=y+R|0,i[N++]=w+T|0,i[N++]=b+L|0,i[N++]=A+_|0}const Yi=Vi(Wi,{counterRight:!1,counterLength:4,allowShortKeys:!1});class Zi extends un{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,gn.hash(e);const n=an(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return gn.exists(this),this.iHash.update(e),this}digestInto(e){gn.exists(this),gn.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:i,destroyed:s,blockLen:r,outputLen:o}=this;return e.finished=i,e.destroyed=s,e.blockLen=r,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Xi=(e,t,n)=>new Zi(e,t).update(n).digest();Xi.create=(e,t)=>new Zi(e,t);const es=new Uint8Array([0]),ts=new Uint8Array;var ns=Object.defineProperty,is=(e,t)=>{for(var n in t)ns(e,n,{get:t[n],enumerable:!0})},ss=Symbol("verified");function rs(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("string"!=typeof n[e])return!1}return!0}is({},{Queue:()=>hs,QueueNode:()=>fs,binarySearch:()=>ds,bytesToHex:()=>on,hexToBytes:()=>ln,insertEventIntoAscendingList:()=>us,insertEventIntoDescendingList:()=>cs,normalizeURL:()=>as,utf8Decoder:()=>os,utf8Encoder:()=>ls});var os=new TextDecoder("utf-8"),ls=new TextEncoder;function as(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function cs(e,t){const[n,i]=ds(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return i||e.splice(n,0,t),e}function us(e,t){const[n,i]=ds(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return i||e.splice(n,0,t),e}function ds(e,t){let n=0,i=e.length-1;for(;n<=i;){const s=Math.floor((n+i)/2),r=t(e[s]);if(0===r)return[s,!0];r<0?i=s-1:n=s+1}return[n,!1]}var fs=class{value;next=null;prev=null;constructor(e){this.value=e}},hs=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new fs(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}};function ps(e){return on(Cn(ls.encode(function(e){if(!rs(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])}(e))))}var gs=new class{generateSecretKey(){return Xt.utils.randomPrivateKey()}getPublicKey(e){return on(Xt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=on(Xt.getPublicKey(t)),n.id=ps(n),n.sig=on(Xt.sign(ps(n),t)),n[ss]=!0,n}verifyEvent(e){if("boolean"==typeof e[ss])return e[ss];const t=ps(e);if(t!==e.id)return e[ss]=!1,!1;try{const n=Xt.verify(e.sig,t,e.pubkey);return e[ss]=n,n}catch(t){return e[ss]=!1,!1}}},ms=gs.generateSecretKey,vs=gs.getPublicKey,ys=gs.finalizeEvent,ws=gs.verifyEvent,bs={};function As(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function ks(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function Is(e){return 2e4<=e&&e<3e4}function Cs(e){return 3e4<=e&&e<4e4}function Es(e){return As(e)?"regular":ks(e)?"replaceable":Is(e)?"ephemeral":Cs(e)?"parameterized":"unknown"}function xs(e,t){const n=t instanceof Array?t:[t];return rs(e)&&n.includes(e.kind)||!1}is(bs,{Application:()=>Nr,BadgeAward:()=>Ts,BadgeDefinition:()=>Dr,BlockedRelaysList:()=>fr,BookmarkList:()=>cr,Bookmarksets:()=>Br,Calendar:()=>qr,CalendarEventRSVP:()=>Gr,ChannelCreation:()=>Ms,ChannelHideMessage:()=>js,ChannelMessage:()=>Os,ChannelMetadata:()=>Us,ChannelMuteUser:()=>zs,ClassifiedListing:()=>Or,ClientAuth:()=>br,CommunitiesList:()=>ur,CommunityDefinition:()=>Vr,CommunityPostApproval:()=>Zs,Contacts:()=>Fs,CreateOrUpdateProduct:()=>Rr,CreateOrUpdateStall:()=>Pr,Curationsets:()=>$r,Date:()=>zr,DirectMessageRelaysList:()=>mr,DraftClassifiedListing:()=>jr,DraftLong:()=>Lr,Emojisets:()=>_r,EncryptedDirectMessage:()=>Ds,EventDeletion:()=>Qs,FileMetadata:()=>Gs,FileServerPreference:()=>vr,Followsets:()=>Er,GenericRepost:()=>Ns,Genericlists:()=>xr,GiftWrap:()=>qs,HTTPAuth:()=>Cr,Handlerinformation:()=>Kr,Handlerrecommendation:()=>Jr,Highlights:()=>rr,InterestsList:()=>pr,Interestsets:()=>Qr,JobFeedback:()=>tr,JobRequest:()=>Xs,JobResult:()=>er,Label:()=>Ys,LightningPubRPC:()=>wr,LiveChatMessage:()=>Js,LiveEvent:()=>Mr,LongFormArticle:()=>Tr,Metadata:()=>Ss,Mutelist:()=>or,NWCWalletInfo:()=>yr,NWCWalletRequest:()=>Ar,NWCWalletResponse:()=>kr,NostrConnect:()=>Ir,OpenTimestamps:()=>Hs,Pinlist:()=>lr,PrivateDirectMessage:()=>_s,ProblemTracker:()=>Ks,ProfileBadges:()=>Fr,PublicChatsList:()=>dr,Reaction:()=>Rs,RecommendRelay:()=>$s,RelayList:()=>ar,Relaysets:()=>Sr,Report:()=>Vs,Reporting:()=>Ws,Repost:()=>Ps,Seal:()=>Ls,SearchRelaysList:()=>hr,ShortTextNote:()=>Bs,Time:()=>Hr,UserEmojiList:()=>gr,UserStatuses:()=>Ur,Zap:()=>sr,ZapGoal:()=>nr,ZapRequest:()=>ir,classifyKind:()=>Es,isAddressableKind:()=>Cs,isEphemeralKind:()=>Is,isKind:()=>xs,isRegularKind:()=>As,isReplaceableKind:()=>ks});var Ss=0,Bs=1,$s=2,Fs=3,Ds=4,Qs=5,Ps=6,Rs=7,Ts=8,Ls=13,_s=14,Ns=16,Ms=40,Us=41,Os=42,js=43,zs=44,Hs=1040,qs=1059,Gs=1063,Js=1311,Ks=1971,Vs=1984,Ws=1984,Ys=1985,Zs=4550,Xs=5999,er=6999,tr=7e3,nr=9041,ir=9734,sr=9735,rr=9802,or=1e4,lr=10001,ar=10002,cr=10003,ur=10004,dr=10005,fr=10006,hr=10007,pr=10015,gr=10030,mr=10050,vr=10096,yr=13194,wr=21e3,br=22242,Ar=23194,kr=23195,Ir=24133,Cr=27235,Er=3e4,xr=30001,Sr=30002,Br=30003,$r=30004,Fr=30008,Dr=30009,Qr=30015,Pr=30017,Rr=30018,Tr=30023,Lr=30024,_r=30030,Nr=30078,Mr=30311,Ur=30315,Or=30402,jr=30403,zr=31922,Hr=31923,qr=31924,Gr=31925,Jr=31989,Kr=31990,Vr=34550;function Wr(e,t){let n=t.length+3,i=e.indexOf(`"${t}":`)+n,s=e.slice(i).indexOf('"')+i+1;return e.slice(s,s+64)}function Yr(e,t){let n=t.length,i=e.indexOf(`"${t}":`)+n+3,s=e.slice(i),r=Math.min(s.indexOf(","),s.indexOf("}"));return parseInt(s.slice(0,r),10)}function Zr(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let i=t+7+1+n,s=e.slice(i+1,80).indexOf('"');if(-1===s)return null;let r=i+1+s;return e.slice(i+1,r)}function Xr(e,t){return t===Wr(e,"id")}function eo(e,t){return t===Wr(e,"pubkey")}function to(e,t){return t===Yr(e,"kind")}is({},{getHex64:()=>Wr,getInt:()=>Yr,getSubscriptionId:()=>Zr,matchEventId:()=>Xr,matchEventKind:()=>to,matchEventPubkey:()=>eo});function no(e,t){return{kind:br,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}is({},{makeAuthEvent:()=>no});try{WebSocket}catch{}try{WebSocket}catch{}var io={};is(io,{BECH32_REGEX:()=>oo,Bech32MaxSize:()=>ro,NostrTypeGuard:()=>so,decode:()=>ao,decodeNostrURI:()=>lo,encodeBytes:()=>go,naddrEncode:()=>yo,neventEncode:()=>vo,noteEncode:()=>ho,nprofileEncode:()=>mo,npubEncode:()=>fo,nsecEncode:()=>uo});var so={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},ro=5e3,oo=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function lo(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),ao(e)}catch(e){return{type:"invalid",data:null}}}function ao(e){let{prefix:t,words:n}=pi.decode(e,ro),i=new Uint8Array(pi.fromWords(n));switch(t){case"nprofile":{let e=co(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:on(e[0][0]),relays:e[1]?e[1].map(e=>os.decode(e)):[]}}}case"nevent":{let e=co(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:on(e[0][0]),relays:e[1]?e[1].map(e=>os.decode(e)):[],author:e[2]?.[0]?on(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(on(e[3][0]),16):void 0}}}case"naddr":{let e=co(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:os.decode(e[0][0]),pubkey:on(e[2][0]),kind:parseInt(on(e[3][0]),16),relays:e[1]?e[1].map(e=>os.decode(e)):[]}}}case"nsec":return{type:t,data:i};case"npub":case"note":return{type:t,data:on(i)};default:throw new Error(`unknown prefix ${t}`)}}function co(e){let t={},n=e;for(;n.length>0;){let e=n[0],i=n[1],s=n.slice(2,2+i);if(n=n.slice(2+i),s.length<i)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(s)}return t}function uo(e){return go("nsec",e)}function fo(e){return go("npub",ln(e))}function ho(e){return go("note",ln(e))}function po(e,t){let n=pi.toWords(t);return pi.encode(e,n,ro)}function go(e,t){return po(e,t)}function mo(e){return po("nprofile",wo({0:[ln(e.pubkey)],1:(e.relays||[]).map(e=>ls.encode(e))}))}function vo(e){let t;return void 0!==e.kind&&(t=function(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}(e.kind)),po("nevent",wo({0:[ln(e.id)],1:(e.relays||[]).map(e=>ls.encode(e)),2:e.author?[ln(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function yo(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),po("naddr",wo({0:[ls.encode(e.identifier)],1:(e.relays||[]).map(e=>ls.encode(e)),2:[ln(e.pubkey)],3:[new Uint8Array(t)]}))}function wo(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let i=new Uint8Array(n.length+2);i.set([parseInt(e)],0),i.set([n.length],1),i.set(n,2),t.push(i)})}),cn(...t)}var bo={};function Ao(e,t,n){const i=e instanceof Uint8Array?on(e):e,s=Io(_t.getSharedSecret(i,"02"+t));let r=Uint8Array.from(fn(16)),o=ls.encode(n),l=_i(s,r).encrypt(o);return`${ii.encode(new Uint8Array(l))}?iv=${ii.encode(new Uint8Array(r.buffer))}`}function ko(e,t,n){const i=e instanceof Uint8Array?on(e):e;let[s,r]=n.split("?iv="),o=Io(_t.getSharedSecret(i,"02"+t)),l=ii.decode(r),a=ii.decode(s),c=_i(o,l).decrypt(a);return os.decode(c)}function Io(e){return e.slice(1,33)}is(bo,{decrypt:()=>ko,encrypt:()=>Ao});is({},{NIP05_REGEX:()=>Eo,isNip05:()=>xo,isValid:()=>Fo,queryProfile:()=>$o,searchDomain:()=>Bo,useFetchImplementation:()=>So});var Co,Eo=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,xo=e=>Eo.test(e||"");try{Co=fetch}catch(e){}function So(e){Co=e}async function Bo(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,i=await Co(n,{redirect:"manual"});if(200!==i.status)throw Error("Wrong response code");return(await i.json()).names}catch(e){return{}}}async function $o(e){const t=e.match(Eo);if(!t)return null;const[,n="_",i]=t;try{const e=`https://${i}/.well-known/nostr.json?name=${n}`,t=await Co(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const s=await t.json(),r=s.names[n];return r?{pubkey:r,relays:s.relays?.[r]}:null}catch(e){return null}}async function Fo(e,t){const n=await $o(t);return!!n&&n.pubkey===e}function Do(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,i;for(let s=e.tags.length-1;s>=0;s--){const r=e.tags[s];if("e"===r[0]&&r[1]){const[e,s,o,l,a]=r,c={id:s,relays:o?[o]:[],author:a};if("root"===l){t.root=c;continue}if("reply"===l){t.reply=c;continue}if("mention"===l){t.mentions.push(c);continue}n?i=c:n=c,t.mentions.push(c);continue}if("q"===r[0]&&r[1]){const[e,n,i]=r;t.quotes.push({id:n,relays:i?[i]:[]})}"p"===r[0]&&r[1]&&t.profiles.push({pubkey:r[1],relays:r[2]?[r[2]]:[]})}return t.root||(t.root=i||n||t.reply),t.reply||(t.reply=n||t.root),[t.reply,t.root].forEach(e=>{if(!e)return;let n=t.mentions.indexOf(e);if(-1!==n&&t.mentions.splice(n,1),e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays?.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t.mentions.forEach(e=>{if(e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t}is({},{parse:()=>Do});is({},{fetchRelayInformation:()=>Po,useFetchImplementation:()=>Qo});try{fetch}catch{}function Qo(e){0}async function Po(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function Ro(e){let t=0;for(let n=0;n<64;n+=8){const i=parseInt(e.substring(n,n+8),16);if(0!==i){t+=Math.clz32(i);break}t+=32}return t}function To(e,t){let n=0;const i=e,s=["nonce",n.toString(),t.toString()];for(i.tags.push(s);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==i.created_at&&(n=0,i.created_at=e),s[1]=(++n).toString(),i.id=Lo(i),Ro(i.id)>=t)break}return i}function Lo(e){return on(Cn(ls.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}is({},{fastEventHash:()=>Lo,getPow:()=>Ro,minePow:()=>To});is({},{unwrapEvent:()=>al,unwrapManyEvents:()=>cl,wrapEvent:()=>ol,wrapManyEvents:()=>ll});is({},{createRumor:()=>Xo,createSeal:()=>el,createWrap:()=>tl,unwrapEvent:()=>sl,unwrapManyEvents:()=>rl,wrapEvent:()=>nl,wrapManyEvents:()=>il});var _o={};is(_o,{decrypt:()=>Go,encrypt:()=>qo,getConversationKey:()=>Uo,v2:()=>Jo});var No=1,Mo=65535;function Uo(e,t){const n=_t.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return gn.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Xi(e,an(n),an(t))}(Cn,n,"nip44-v2")}function Oo(e,t){const n=function(e,t,n,i=32){if(gn.hash(e),gn.number(i),i>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const s=Math.ceil(i/e.outputLen);void 0===n&&(n=ts);const r=new Uint8Array(s*e.outputLen),o=Xi.create(e,t),l=o._cloneInto(),a=new Uint8Array(o.outputLen);for(let t=0;t<s;t++)es[0]=t+1,l.update(0===t?ts:a).update(n).update(es).digestInto(a),r.set(a,e.outputLen*t),o._cloneInto(l);return o.destroy(),l.destroy(),a.fill(0),es.fill(0),r.slice(0,i)}(Cn,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function jo(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("expected positive integer");if(e<=32)return 32;const t=1<<Math.floor(Math.log2(e-1))+1,n=t<=256?32:t/8;return n*(Math.floor((e-1)/n)+1)}function zo(e){const t=ls.encode(e),n=t.length;return cn(function(e){if(!Number.isSafeInteger(e)||e<No||e>Mo)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t}(n),t,new Uint8Array(jo(n)-n))}function Ho(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const i=cn(n,t);return Xi(Cn,e,i)}function qo(e,t,n=fn(32)){const{chacha_key:i,chacha_nonce:s,hmac_key:r}=Oo(t,n),o=zo(e),l=Yi(i,s,o),a=Ho(r,l,n);return ii.encode(cn(new Uint8Array([2]),n,l,a))}function Go(e,t){const{nonce:n,ciphertext:i,mac:s}=function(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=ii.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const i=n.length;if(i<99||i>65603)throw new Error("invalid data length: "+i);const s=n[0];if(2!==s)throw new Error("unknown encryption version "+s);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:r,chacha_nonce:o,hmac_key:l}=Oo(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let i=0;i<e.length;i++)n|=e[i]^t[i];return 0===n}(Ho(l,i,n),s))throw new Error("invalid MAC");return function(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(t<No||t>Mo||n.length!==t||e.length!==2+jo(t))throw new Error("invalid padding");return os.decode(n)}(Yi(r,o,i))}var Jo={utils:{getConversationKey:Uo,calcPaddedLen:jo},encrypt:qo,decrypt:Go},Ko=()=>Math.round(Date.now()/1e3),Vo=()=>Math.round(Ko()-172800*Math.random()),Wo=(e,t)=>Uo(e,t),Yo=(e,t,n)=>qo(JSON.stringify(e),Wo(t,n)),Zo=(e,t)=>JSON.parse(Go(e.content,Wo(t,e.pubkey)));function Xo(e,t){const n={created_at:Ko(),content:"",tags:[],...e,pubkey:vs(t)};return n.id=ps(n),n}function el(e,t,n){return ys({kind:Ls,content:Yo(e,t,n),created_at:Vo(),tags:[]},t)}function tl(e,t){const n=ms();return ys({kind:qs,content:Yo(e,n,t),created_at:Vo(),tags:[["p",t]]},n)}function nl(e,t,n){return tl(el(Xo(e,t),t,n),n)}function il(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const i=vs(t),s=[nl(e,t,i)];return n.forEach(n=>{s.push(nl(e,t,n))}),s}function sl(e,t){const n=Zo(e,t);return Zo(n,t)}function rl(e,t){let n=[];return e.forEach(e=>{n.push(sl(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function ol(e,t,n,i,s){const r=function(e,t,n,i){const s={created_at:Math.ceil(Date.now()/1e3),kind:_s,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{s.tags.push(t?["p",e,t]:["p",e])}),i&&s.tags.push(["e",i.eventId,i.relayUrl||"","reply"]),n&&s.tags.push(["subject",n]),s}(t,n,i,s);return nl(r,e,t.publicKey)}function ll(e,t,n,i,s){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:vs(e)},...t].map(t=>ol(e,t,n,i,s))}var al=sl,cl=rl;function ul(e,t,n,i){let s;const r=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===Bs?s=Ps:(s=Ns,r.push(["k",String(t.kind)])),ys({kind:s,tags:r,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},i)}function dl(e){if(![Ps,Ns].includes(e.kind))return;let t,n;for(let i=e.tags.length-1;i>=0&&(void 0===t||void 0===n);i--){const s=e.tags[i];s.length>=2&&("e"===s[0]&&void 0===t?t=s:"p"===s[0]&&void 0===n&&(n=s))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function fl(e,{skipVerification:t}={}){const n=dl(e);if(void 0===n||""===e.content)return;let i;try{i=JSON.parse(e.content)}catch(e){return}return i.id===n.id&&(t||ws(i))?i:void 0}is({},{finishRepostEvent:()=>ul,getRepostedEvent:()=>fl,getRepostedEventPointer:()=>dl});is({},{NOSTR_URI_REGEX:()=>hl,parse:()=>gl,test:()=>pl});var hl=new RegExp(`nostr:(${oo.source})`);function pl(e){return"string"==typeof e&&new RegExp(`^${hl.source}$`).test(e)}function gl(e){const t=e.match(new RegExp(`^${hl.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:ao(t[1])}}function ml(e,t,n){const i=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return ys({...e,kind:Rs,tags:[...e.tags??[],...i,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function vl(e){if(e.kind!==Rs)return;let t,n;for(let i=e.tags.length-1;i>=0&&(void 0===t||void 0===n);i--){const s=e.tags[i];s.length>=2&&("e"===s[0]&&void 0===t?t=s:"p"===s[0]&&void 0===n&&(n=s))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}is({},{finishReactionEvent:()=>ml,getReactedEventPointer:()=>vl});is({},{parse:()=>bl});var yl=/\W/m,wl=/\W |\W$|$|,| /m;function*bl(e){const t=e.length;let n=0,i=0;for(;i<t;){let s=e.indexOf(":",i);if(-1===s)break;if("nostr"===e.substring(s-5,s)){const r=e.substring(s+60).match(yl),o=r?s+60+r.index:t;try{let t,{data:r,type:l}=ao(e.substring(s+1,o));switch(l){case"npub":t={pubkey:r};break;case"nsec":case"note":i=o+1;continue;default:t=r}n!==s-5&&(yield{type:"text",text:e.substring(n,s-5)}),yield{type:"reference",pointer:t},i=o,n=i;continue}catch(e){i=s+1;continue}}else if("https"===e.substring(s-5,s)||"http"===e.substring(s-4,s)){const r=e.substring(s+4).match(wl),o=r?s+4+r.index:t,l="s"===e[s-1]?5:4;try{let t=new URL(e.substring(s-l,o));if(-1===t.hostname.indexOf("."))throw new Error("invalid url");if(n!==s-l&&(yield{type:"text",text:e.substring(n,s-l)}),/\.(png|jpe?g|gif|webp)$/i.test(t.pathname)){yield{type:"image",url:t.toString()},i=o,n=i;continue}if(/\.(mp4|avi|webm|mkv)$/i.test(t.pathname)){yield{type:"video",url:t.toString()},i=o,n=i;continue}if(/\.(mp3|aac|ogg|opus)$/i.test(t.pathname)){yield{type:"audio",url:t.toString()},i=o,n=i;continue}yield{type:"url",url:t.toString()},i=o,n=i;continue}catch(e){i=o+1;continue}}else{if("wss"!==e.substring(s-3,s)&&"ws"!==e.substring(s-2,s)){i=s+1;continue}{const r=e.substring(s+4).match(wl),o=r?s+4+r.index:t,l="s"===e[s-1]?3:2;try{let t=new URL(e.substring(s-l,o));if(-1===t.hostname.indexOf("."))throw new Error("invalid ws url");n!==s-l&&(yield{type:"text",text:e.substring(n,s-l)}),yield{type:"relay",url:t.toString()},i=o,n=i;continue}catch(e){i=o+1;continue}}}}n!==t&&(yield{type:"text",text:e.substring(n)})}is({},{channelCreateEvent:()=>Al,channelHideMessageEvent:()=>Cl,channelMessageEvent:()=>Il,channelMetadataEvent:()=>kl,channelMuteUserEvent:()=>El});var Al=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return ys({kind:Ms,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},kl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return ys({kind:Us,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},Il=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),ys({kind:Os,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},Cl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return ys({kind:js,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},El=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return ys({kind:zs,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};is({},{EMOJI_SHORTCODE_REGEX:()=>xl,matchAll:()=>Bl,regex:()=>Sl,replaceAll:()=>$l});var xl=/:(\w+):/,Sl=()=>new RegExp(`\\B${xl.source}\\B`,"g");function*Bl(e){const t=e.matchAll(Sl());for(const e of t)try{const[t,n]=e;yield{shortcode:t,name:n,start:e.index,end:e.index+t.length}}catch(e){}}function $l(e,t){return e.replaceAll(Sl(),(e,n)=>t({shortcode:e,name:n}))}var Fl;is({},{useFetchImplementation:()=>Dl,validateGithub:()=>Ql});try{Fl=fetch}catch{}function Dl(e){Fl=e}async function Ql(e,t,n){try{return await(await Fl(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function Pl(e){const{host:t,pathname:n,searchParams:i}=new URL(e),s=n||t,r=i.get("relay"),o=i.get("secret");if(!s||!r||!o)throw new Error("invalid connection string");return{pubkey:s,relay:r,secret:o}}async function Rl(e,t,n){const i={method:"pay_invoice",params:{invoice:n}},s=Ao(t,e,JSON.stringify(i)),r={kind:Ar,created_at:Math.round(Date.now()/1e3),content:s,tags:[["p",e]]};return ys(r,t)}is({},{makeNwcRequestEvent:()=>Rl,parseConnectionString:()=>Pl});function Tl(e){return e=(e=e.trim().toLowerCase()).normalize("NFKC"),Array.from(e).map(e=>/\p{Letter}/u.test(e)||/\p{Number}/u.test(e)?e:"-").join("")}is({},{normalizeIdentifier:()=>Tl});var Ll;is({},{getSatoshisAmountFromBolt11:()=>jl,getZapEndpoint:()=>Nl,makeZapReceipt:()=>Ol,makeZapRequest:()=>Ml,useFetchImplementation:()=>_l,validateZapRequest:()=>Ul});try{Ll=fetch}catch{}function _l(e){Ll=e}async function Nl(e){try{let t="",{lud06:n,lud16:i}=JSON.parse(e.content);if(n){let{words:e}=pi.decode(n,1e3),i=pi.fromWords(e);t=os.decode(i)}else{if(!i)return null;{let[e,n]=i.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let s=await Ll(t),r=await s.json();if(r.allowsNostr&&r.nostrPubkey)return r.callback}catch(e){}return null}function Ml(e){let t={kind:9734,created_at:Math.round(Date.now()/1e3),content:e.comment||"",tags:[["p","pubkey"in e?e.pubkey:e.event.pubkey],["amount",e.amount.toString()],["relays",...e.relays]]};if("event"in e){if(t.tags.push(["e",e.event.id]),ks(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(Cs(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const i=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(i)}t.tags.push(["k",e.event.kind.toString()])}return t}function Ul(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!rs(t))return"Zap request is not a valid Nostr event.";if(!ws(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let i=t.tags.find(([e,t])=>"e"===e&&t);return i&&!i[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function Ol({zapRequest:e,preimage:t,bolt11:n,paidAt:i}){let s=JSON.parse(e),r=s.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),o={kind:9735,created_at:Math.round(i.getTime()/1e3),content:"",tags:[...r,["P",s.pubkey],["bolt11",n],["description",e]]};return t&&o.tags.push(["preimage",t]),o}function jl(e){if(e.length<50)return 0;const t=(e=e.substring(0,50)).lastIndexOf("1");if(-1===t)return 0;const n=e.substring(0,t);if(!n.startsWith("lnbc"))return 0;const i=n.substring(4);if(i.length<1)return 0;const s=i[i.length-1],r=s.charCodeAt(0)-"0".charCodeAt(0),o=r>=0&&r<=9;let l=i.length-1;if(o&&l++,l<1)return 0;const a=parseInt(i.substring(0,l));switch(s){case"m":return 1e5*a;case"u":return 100*a;case"n":return a/10;case"p":return a/1e4;default:return 1e8*a}}is({},{getToken:()=>Hl,hashPayload:()=>Yl,unpackEventFromToken:()=>Gl,validateEvent:()=>Xl,validateEventKind:()=>Kl,validateEventMethodTag:()=>Wl,validateEventPayloadTag:()=>Zl,validateEventTimestamp:()=>Jl,validateEventUrlTag:()=>Vl,validateToken:()=>ql});var zl="Nostr ";async function Hl(e,t,n,i=!1,s){const r={kind:Cr,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};s&&r.tags.push(["payload",Yl(s)]);const o=await n(r);return(i?zl:"")+ii.encode(ls.encode(JSON.stringify(o)))}async function ql(e,t,n){const i=await Gl(e).catch(e=>{throw e});return await Xl(i,t,n).catch(e=>{throw e})}async function Gl(e){if(!e)throw new Error("Missing token");e=e.replace(zl,"");const t=os.decode(ii.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Jl(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function Kl(e){return e.kind===Cr}function Vl(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function Wl(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function Yl(e){return on(Cn(ls.encode(JSON.stringify(e))))}function Zl(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const i=Yl(t);return n.length>0&&n[1]===i}async function Xl(e,t,n,i){if(!ws(e))throw new Error("Invalid nostr event, signature invalid");if(!Kl(e))throw new Error("Invalid nostr event, kind invalid");if(!Jl(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!Vl(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!Wl(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(i)&&"object"==typeof i&&Object.keys(i).length>0&&!Zl(e,i))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function ea(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function ta(e){return 3e4<=e&&e<4e4}var na=function(e,t){return na=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},na(e,t)};function ia(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}na(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function sa(e,t,n,i){return new(n||(n=Promise))(function(s,r){function o(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,l)}a((i=i.apply(e,t||[])).next())})}function ra(e,t){var n,i,s,r={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=l(0),o.throw=l(1),o.return=l(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(l){return function(a){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(r=0)),r;)try{if(n=1,i&&(s=2&l[0]?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(!(s=r.trys,(s=s.length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){r=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(6===l[0]&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=t.call(e,r)}catch(e){l=[6,e],i=0}finally{n=s=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,a])}}}function oa(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function la(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,s,r=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(e){s={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function aa(e,t,n){if(n||2===arguments.length)for(var i,s=0,r=t.length;s<r;s++)!i&&s in t||(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}function ca(e){return this instanceof ca?(this.v=e,this):new ca(e)}function ua(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,s=n.apply(e,t||[]),r=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(e){return function(t){return Promise.resolve(t).then(e,c)}}),i[Symbol.asyncIterator]=function(){return this},i;function o(e,t){s[e]&&(i[e]=function(t){return new Promise(function(n,i){r.push([e,t,n,i])>1||l(e,t)})},t&&(i[e]=t(i[e])))}function l(e,t){try{(n=s[e](t)).value instanceof ca?Promise.resolve(n.value.v).then(a,c):u(r[0][2],n)}catch(e){u(r[0][3],e)}var n}function a(e){l("next",e)}function c(e){l("throw",e)}function u(e,t){e(t),r.shift(),r.length&&l(r[0][0],r[0][1])}}function da(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=oa(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise(function(i,s){(function(e,t,n,i){Promise.resolve(i).then(function(t){e({value:t,done:n})},t)})(i,s,(t=e[n](t)).done,t.value)})}}}function fa(e){return"function"==typeof e}function ha(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var pa=ha(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n  "):"",this.name="UnsubscriptionError",this.errors=t}});function ga(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var ma=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,i,s;if(!this.closed){this.closed=!0;var r=this._parentage;if(r)if(this._parentage=null,Array.isArray(r))try{for(var o=oa(r),l=o.next();!l.done;l=o.next()){l.value.remove(this)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else r.remove(this);var a=this.initialTeardown;if(fa(a))try{a()}catch(e){s=e instanceof pa?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=oa(c),d=u.next();!d.done;d=u.next()){var f=d.value;try{wa(f)}catch(e){s=null!=s?s:[],e instanceof pa?s=aa(aa([],la(s)),la(e.errors)):s.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}if(s)throw new pa(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)wa(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&ga(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&ga(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),va=ma.EMPTY;function ya(e){return e instanceof ma||e&&"closed"in e&&fa(e.remove)&&fa(e.add)&&fa(e.unsubscribe)}function wa(e){fa(e)?e():e.unsubscribe()}var ba={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Aa={setTimeout:function(e,t){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var s=Aa.delegate;return(null==s?void 0:s.setTimeout)?s.setTimeout.apply(s,aa([e,t],la(n))):setTimeout.apply(void 0,aa([e,t],la(n)))},clearTimeout:function(e){var t=Aa.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function ka(e){Aa.setTimeout(function(){throw e})}function Ia(){}function Ca(e){e()}var Ea=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,ya(t)&&t.add(n)):n.destination=Da,n}return ia(t,e),t.create=function(e,t,n){return new $a(e,t,n)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(ma),xa=Function.prototype.bind;function Sa(e,t){return xa.call(e,t)}var Ba=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Fa(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Fa(e)}else Fa(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Fa(e)}},e}(),$a=function(e){function t(t,n,i){var s,r,o=e.call(this)||this;fa(t)||!t?s={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=i?i:void 0}:o&&ba.useDeprecatedNextContext?((r=Object.create(t)).unsubscribe=function(){return o.unsubscribe()},s={next:t.next&&Sa(t.next,r),error:t.error&&Sa(t.error,r),complete:t.complete&&Sa(t.complete,r)}):s=t;return o.destination=new Ba(s),o}return ia(t,e),t}(Ea);function Fa(e){ka(e)}var Da={closed:!0,next:Ia,error:function(e){throw e},complete:Ia},Qa="function"==typeof Symbol&&Symbol.observable||"@@observable";function Pa(e){return e}var Ra=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var i,s=this,r=(i=e)&&i instanceof Ea||function(e){return e&&fa(e.next)&&fa(e.error)&&fa(e.complete)}(i)&&ya(i)?e:new $a(e,t,n);return Ca(function(){var e=s,t=e.operator,n=e.source;r.add(t?t.call(r,n):n?s._subscribe(r):s._trySubscribe(r))}),r},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=Ta(t))(function(t,i){var s=new $a({next:function(t){try{e(t)}catch(e){i(e),s.unsubscribe()}},error:i,complete:t});n.subscribe(s)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[Qa]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return(0===(e=t).length?Pa:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Ta(e))(function(e,n){var i;t.subscribe(function(e){return i=e},function(e){return n(e)},function(){return e(i)})})},e.create=function(t){return new e(t)},e}();function Ta(e){var t;return null!==(t=null!=e?e:ba.Promise)&&void 0!==t?t:Promise}function La(e){return function(t){if(function(e){return fa(null==e?void 0:e.lift)}(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw new TypeError("Unable to lift unknown Observable type")}}function _a(e,t,n,i,s){return new Na(e,t,n,i,s)}var Na=function(e){function t(t,n,i,s,r,o){var l=e.call(this,t)||this;return l.onFinalize=r,l.shouldUnsubscribe=o,l._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,l._error=s?function(e){try{s(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,l._complete=i?function(){try{i()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,l}return ia(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(Ea),Ma=ha(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ua=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return ia(t,e),t.prototype.lift=function(e){var t=new Oa(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Ma},t.prototype.next=function(e){var t=this;Ca(function(){var n,i;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var s=oa(t.currentObservers),r=s.next();!r.done;r=s.next()){r.value.next(e)}}catch(e){n={error:e}}finally{try{r&&!r.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;Ca(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;Ca(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,i=n.hasError,s=n.isStopped,r=n.observers;return i||s?va:(this.currentObservers=null,r.push(e),new ma(function(){t.currentObservers=null,ga(r,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,i=t.thrownError,s=t.isStopped;n?e.error(i):s&&e.complete()},t.prototype.asObservable=function(){var e=new Ra;return e.source=this,e},t.create=function(e,t){return new Oa(e,t)},t}(Ra),Oa=function(e){function t(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return ia(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:va},t}(Ua),ja={now:function(){return(ja.delegate||Date).now()},delegate:void 0},za=function(e){function t(t,n,i){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===i&&(i=ja);var s=e.call(this)||this;return s._bufferSize=t,s._windowTime=n,s._timestampProvider=i,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=n===1/0,s._bufferSize=Math.max(1,t),s._windowTime=Math.max(1,n),s}return ia(t,e),t.prototype.next=function(t){var n=this,i=n.isStopped,s=n._buffer,r=n._infiniteTimeWindow,o=n._timestampProvider,l=n._windowTime;i||(s.push(t),!r&&s.push(o.now()+l)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,i=this._buffer.slice(),s=0;s<i.length&&!e.closed;s+=n?1:2)e.next(i[s]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,n=e._timestampProvider,i=e._buffer,s=e._infiniteTimeWindow,r=(s?1:2)*t;if(t<1/0&&r<i.length&&i.splice(0,i.length-r),!s){for(var o=n.now(),l=0,a=1;a<i.length&&i[a]<=o;a+=2)l=a;l&&i.splice(0,l+1)}},t}(Ua),Ha=function(e){function t(t,n){return e.call(this)||this}return ia(t,e),t.prototype.schedule=function(e,t){return this},t}(ma),qa={setInterval:function(e,t){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var s=qa.delegate;return(null==s?void 0:s.setInterval)?s.setInterval.apply(s,aa([e,t],la(n))):setInterval.apply(void 0,aa([e,t],la(n)))},clearInterval:function(e){var t=qa.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},Ga=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.pending=!1,i}return ia(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var i=this.id,s=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(s,i,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(s,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),qa.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!=n&&this.delay===n&&!1===this.pending)return t;null!=t&&qa.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n,i=!1;try{this.work(e)}catch(e){i=!0,n=e||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,i=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,ga(i,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Ha),Ja=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=ja.now,e}(),Ka=function(e){function t(t,n){void 0===n&&(n=Ja.now);var i=e.call(this,t,n)||this;return i.actions=[],i._active=!1,i}return ia(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(Ja),Va=new Ka(Ga),Wa=new Ra(function(e){return e.complete()});function Ya(e){return e&&fa(e.schedule)}function Za(e){return e[e.length-1]}function Xa(e){return Ya(Za(e))?e.pop():void 0}function ec(e,t){return"number"==typeof Za(e)?e.pop():t}var tc=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function nc(e){return fa(null==e?void 0:e.then)}function ic(e){return fa(e[Qa])}function sc(e){return Symbol.asyncIterator&&fa(null==e?void 0:e[Symbol.asyncIterator])}function rc(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var oc="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function lc(e){return fa(null==e?void 0:e[oc])}function ac(e){return ua(this,arguments,function(){var t,n,i;return ra(this,function(s){switch(s.label){case 0:t=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,ca(t.read())];case 3:return n=s.sent(),i=n.value,n.done?[4,ca(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,ca(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function cc(e){return fa(null==e?void 0:e.getReader)}function uc(e){if(e instanceof Ra)return e;if(null!=e){if(ic(e))return s=e,new Ra(function(e){var t=s[Qa]();if(fa(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(tc(e))return i=e,new Ra(function(e){for(var t=0;t<i.length&&!e.closed;t++)e.next(i[t]);e.complete()});if(nc(e))return n=e,new Ra(function(e){n.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,ka)});if(sc(e))return dc(e);if(lc(e))return t=e,new Ra(function(e){var n,i;try{for(var s=oa(t),r=s.next();!r.done;r=s.next()){var o=r.value;if(e.next(o),e.closed)return}}catch(e){n={error:e}}finally{try{r&&!r.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}e.complete()});if(cc(e))return dc(ac(e))}var t,n,i,s;throw rc(e)}function dc(e){return new Ra(function(t){(function(e,t){var n,i,s,r;return sa(this,void 0,void 0,function(){var o,l;return ra(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),n=da(e),a.label=1;case 1:return[4,n.next()];case 2:if((i=a.sent()).done)return[3,4];if(o=i.value,t.next(o),t.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return l=a.sent(),s={error:l},[3,11];case 6:return a.trys.push([6,,9,10]),i&&!i.done&&(r=n.return)?[4,r.call(n)]:[3,8];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function fc(e,t,n,i,s){void 0===i&&(i=0),void 0===s&&(s=!1);var r=t.schedule(function(){n(),s?e.add(this.schedule(null,i)):this.unsubscribe()},i);if(e.add(r),!s)return r}function hc(e,t){return void 0===t&&(t=0),La(function(n,i){n.subscribe(_a(i,function(n){return fc(i,e,function(){return i.next(n)},t)},function(){return fc(i,e,function(){return i.complete()},t)},function(n){return fc(i,e,function(){return i.error(n)},t)}))})}function pc(e,t){return void 0===t&&(t=0),La(function(n,i){i.add(e.schedule(function(){return n.subscribe(i)},t))})}function gc(e,t){if(!e)throw new Error("Iterable cannot be null");return new Ra(function(n){fc(n,t,function(){var i=e[Symbol.asyncIterator]();fc(n,t,function(){i.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}function mc(e,t){if(null!=e){if(ic(e))return function(e,t){return uc(e).pipe(pc(t),hc(t))}(e,t);if(tc(e))return function(e,t){return new Ra(function(n){var i=0;return t.schedule(function(){i===e.length?n.complete():(n.next(e[i++]),n.closed||this.schedule())})})}(e,t);if(nc(e))return function(e,t){return uc(e).pipe(pc(t),hc(t))}(e,t);if(sc(e))return gc(e,t);if(lc(e))return function(e,t){return new Ra(function(n){var i;return fc(n,t,function(){i=e[oc](),fc(n,t,function(){var e,t,s;try{t=(e=i.next()).value,s=e.done}catch(e){return void n.error(e)}s?n.complete():n.next(t)},0,!0)}),function(){return fa(null==i?void 0:i.return)&&i.return()}})}(e,t);if(cc(e))return function(e,t){return gc(ac(e),t)}(e,t)}throw rc(e)}function vc(e,t){return t?mc(e,t):uc(e)}function yc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return vc(e,Xa(e))}function wc(e,t){return La(function(n,i){var s=0;n.subscribe(_a(i,function(n){i.next(e.call(t,n,s++))}))})}var bc=Array.isArray;function Ac(e){return wc(function(t){return function(e,t){return bc(t)?e.apply(void 0,aa([],la(t))):e(t)}(e,t)})}var kc=Array.isArray,Ic=Object.getPrototypeOf,Cc=Object.prototype,Ec=Object.keys;function xc(e){if(1===e.length){var t=e[0];if(kc(t))return{args:t,keys:null};if((i=t)&&"object"==typeof i&&Ic(i)===Cc){var n=Ec(t);return{args:n.map(function(e){return t[e]}),keys:n}}}var i;return{args:e,keys:null}}function Sc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Xa(e),i=function(e){return fa(Za(e))?e.pop():void 0}(e),s=xc(e),r=s.args,o=s.keys;if(0===r.length)return vc([],n);var l=new Ra(function(e,t,n){void 0===n&&(n=Pa);return function(i){Bc(t,function(){for(var s=e.length,r=new Array(s),o=s,l=s,a=function(s){Bc(t,function(){var a=vc(e[s],t),c=!1;a.subscribe(_a(i,function(e){r[s]=e,c||(c=!0,l--),l||i.next(n(r.slice()))},function(){--o||i.complete()}))},i)},c=0;c<s;c++)a(c)},i)}}(r,n,o?function(e){return function(e,t){return e.reduce(function(e,n,i){return e[n]=t[i],e},{})}(o,e)}:Pa));return i?l.pipe(Ac(i)):l}function Bc(e,t,n){e?fc(n,e,t):t()}function $c(e,t,n){return void 0===n&&(n=1/0),fa(t)?$c(function(n,i){return wc(function(e,s){return t(n,e,i,s)})(uc(e(n,i)))},n):("number"==typeof t&&(n=t),La(function(t,i){return function(e,t,n,i,s,r,o,l){var a=[],c=0,u=0,d=!1,f=function(){!d||a.length||c||t.complete()},h=function(e){return c<i?p(e):a.push(e)},p=function(e){r&&t.next(e),c++;var l=!1;uc(n(e,u++)).subscribe(_a(t,function(e){null==s||s(e),r?h(e):t.next(e)},function(){l=!0},void 0,function(){if(l)try{c--;for(var e=function(){var e=a.shift();o?fc(t,o,function(){return p(e)}):p(e)};a.length&&c<i;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(_a(t,h,function(){d=!0,f()})),function(){null==l||l()}}(t,i,e,n)}))}function Fc(e){return void 0===e&&(e=1/0),$c(Pa,e)}function Dc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fc(1)(vc(e,Xa(e)))}function Qc(e){return new Ra(function(t){uc(e()).subscribe(t)})}function Pc(e,t,n){void 0===e&&(e=0),void 0===n&&(n=Va);var i=-1;return null!=t&&(Ya(t)?n=t:i=t),new Ra(function(t){var s,r=(s=e)instanceof Date&&!isNaN(s)?+e-n.now():e;r<0&&(r=0);var o=0;return n.schedule(function(){t.closed||(t.next(o++),0<=i?this.schedule(void 0,i):t.complete())},r)})}function Rc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Xa(e),i=ec(e,1/0),s=e;return s.length?1===s.length?uc(s[0]):Fc(i)(vc(s,n)):Wa}function Tc(e,t){return La(function(n,i){var s=0;n.subscribe(_a(i,function(n){return e.call(t,n,s++)&&i.next(n)}))})}function Lc(e){return e<=0?function(){return Wa}:La(function(t,n){var i=0;t.subscribe(_a(n,function(t){++i<=e&&(n.next(t),e<=i&&n.complete())}))})}function _c(e,t){return void 0===t&&(t=Pa),e=null!=e?e:Nc,La(function(n,i){var s,r=!0;n.subscribe(_a(i,function(n){var o=t(n);!r&&e(s,o)||(r=!1,s=o,i.next(n))}))})}function Nc(e,t){return e===t}function Mc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return Dc(t,yc.apply(void 0,aa([],la(e))))}}function Uc(e){return La(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function Oc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Xa(e),i=ec(e,1/0);return La(function(t,s){Fc(i)(vc(aa([t],la(e)),n)).subscribe(s)})}function jc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Oc.apply(void 0,aa([],la(e)))}function zc(e,t){return La(function(e,t,n,i,s){return function(r,o){var l=n,a=t,c=0;r.subscribe(_a(o,function(t){var n=c++;a=l?e(a,t,n):(l=!0,t),i&&o.next(a)},s&&function(){l&&o.next(a),o.complete()}))}}(e,t,arguments.length>=2,!0))}function Hc(e,t){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];if(!0!==t){if(!1!==t){var s=new $a({next:function(){s.unsubscribe(),e()}});return uc(t.apply(void 0,aa([],la(n)))).subscribe(s)}}else e()}function qc(e,t){return La(function(n,i){var s=null,r=0,o=!1,l=function(){return o&&!s&&i.complete()};n.subscribe(_a(i,function(n){null==s||s.unsubscribe();var o=0,a=r++;uc(e(n,a)).subscribe(s=_a(i,function(e){return i.next(t?t(n,e,a,o++):e)},function(){s=null,l()}))},function(){o=!0,l()}))})}function Gc(e,t,n){var i=fa(e)||t||n?{next:e,error:t,complete:n}:e;return i?La(function(e,t){var n;null===(n=i.subscribe)||void 0===n||n.call(i);var s=!0;e.subscribe(_a(t,function(e){var n;null===(n=i.next)||void 0===n||n.call(i,e),t.next(e)},function(){var e;s=!1,null===(e=i.complete)||void 0===e||e.call(i),t.complete()},function(e){var n;s=!1,null===(n=i.error)||void 0===n||n.call(i,e),t.error(e)},function(){var e,t;s&&(null===(e=i.unsubscribe)||void 0===e||e.call(i)),null===(t=i.finalize)||void 0===t||t.call(i)}))}):Pa}function Jc(e,t){return void 0!==e[0]&&void 0!==e[1]&&(!t||e[0]===t)}function Kc(e){return Jc(e,"e")}function Vc(e){return Jc(e,"p")}function Wc(e){return Jc(e,"r")}function Yc(e){return Jc(e,"a")}function Zc(e){return Jc(e,"t")}const Xc=(e,...t)=>t.reduce((e,t)=>{const n=[];for(const i of e)try{const e=t(i);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);var eu=Symbol("verified");function tu(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let e=0;e<n.length;e++)if("string"!=typeof n[e])return!1}return!0}new TextDecoder("utf-8");var nu=new TextEncoder;function iu(e){return on(Cn(nu.encode(function(e){if(!tu(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])}(e))))}var su=new class{generateSecretKey(){return Xt.utils.randomPrivateKey()}getPublicKey(e){return on(Xt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=on(Xt.getPublicKey(t)),n.id=iu(n),n.sig=on(Xt.sign(iu(n),t)),n[eu]=!0,n}verifyEvent(e){if("boolean"==typeof e[eu])return e[eu];const t=iu(e);if(t!==e.id)return e[eu]=!1,!1;try{const n=Xt.verify(e.sig,t,e.pubkey);return e[eu]=n,n}catch(t){return e[eu]=!1,!1}}},ru=su.generateSecretKey,ou=su.getPublicKey;function lu(e,t,n){if(Reflect.has(e,t))return Reflect.get(e,t);{const i=n();return Reflect.set(e,t,i),i}}function au(e,t){const[n,i]=cu(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return i||e.splice(n,0,t),e}function cu(e,t){let n=0,i=e.length-1;for(;n<=i;){const s=Math.floor((n+i)/2),r=t(e[s]);if(0===r)return[s,!0];r<0?i=s-1:n=s+1}return[n,!1]}su.finalizeEvent,su.verifyEvent,new TextDecoder("utf-8"),new TextEncoder;const uu=Symbol.for("event-store"),du=Symbol.for("event-uid"),fu=Symbol.for("replaceable-address"),hu=Symbol.for("from-cache"),pu=Symbol.for("replaceable-identifier");function gu(e){return ea(e)||ta(e)}function mu(e){let t=Reflect.get(e,du);return t||(t=ta(e.kind)||ea(e.kind)?vu(e):e.id,Reflect.set(e,du,t)),t}function vu(e){if(!ta(e.kind)&&!ea(e.kind))throw new Error("Event is not replaceable or addressable");return lu(e,fu,()=>yu(e.kind,e.pubkey,wu(e)))}function yu(e,t,n){return e+":"+t+":"+(n??"")}function wu(e){return lu(e,pu,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function bu(){return Math.round(Date.now()/1e3)}const Au=Symbol("expiration-timestamp");function ku(e){return lu(e,Au,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}var Iu=new TextDecoder("utf-8");new TextEncoder;function Cu(e){let{prefix:t,words:n}=pi.decode(e,5e3),i=new Uint8Array(pi.fromWords(n));switch(t){case"nprofile":{let e=Eu(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:on(e[0][0]),relays:e[1]?e[1].map(e=>Iu.decode(e)):[]}}}case"nevent":{let e=Eu(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:on(e[0][0]),relays:e[1]?e[1].map(e=>Iu.decode(e)):[],author:e[2]?.[0]?on(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(on(e[3][0]),16):void 0}}}case"naddr":{let e=Eu(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Iu.decode(e[0][0]),pubkey:on(e[2][0]),kind:parseInt(on(e[3][0]),16),relays:e[1]?e[1].map(e=>Iu.decode(e)):[]}}}case"nsec":return{type:t,data:i};case"npub":case"note":return{type:t,data:on(i)};default:throw new Error(`unknown prefix ${t}`)}}function Eu(e){let t={},n=e;for(;n.length>0;){let e=n[0],i=n[1],s=n.slice(2,2+i);if(n=n.slice(2+i),s.length<i)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(s)}return t}function xu(e){return Su("npub",ln(e))}function Su(e,t){return function(e,t){let n=pi.toWords(t);return pi.encode(e,n,5e3)}(e,t)}function Bu(e){let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),("80"!==t.port||"ws:"!==t.protocol&&"http:"!==t.protocol)&&("443"!==t.port||"wss:"!==t.protocol&&"https:"!==t.protocol)||(t.port=""),"string"==typeof e?t.toString():t}const $u=Symbol.for("seen-relays");function Fu(e,t){return e[$u]||(e[$u]=new Set),e[$u].add(t),e[$u]}const Du=/^wss?:\/\/([-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}|localhost)\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)$/;function Qu(e){return e.length>=8&&Du.test(e)}function Pu(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)}const Ru="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
  14  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Tu(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}const Lu=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),_u=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Nu(e){if(Tu(e),Lu)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=_u[e[n]];return t}const Mu=48,Uu=57,Ou=65,ju=70,zu=97,Hu=102;function qu(e){return e>=Mu&&e<=Uu?e-Mu:e>=Ou&&e<=ju?e-(Ou-10):e>=zu&&e<=Hu?e-(zu-10):void 0}function Gu(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Lu)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,s=0;t<n;t++,s+=2){const n=qu(e.charCodeAt(s)),r=qu(e.charCodeAt(s+1));if(void 0===n||void 0===r){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}i[t]=16*n+r}return i}function Ju(e,t=!1,n=!0){const i=e.split(":"),s=i[0]?parseInt(i[0]):void 0,r=i[1],o=i[2];if(void 0===s){if(n)return null;throw new Error("Missing kind")}if(void 0===r||""===r){if(n)return null;throw new Error("Missing pubkey")}if(t&&void 0===o){if(n)return null;throw new Error("Missing identifier")}return{kind:s,pubkey:r,identifier:o}}function Ku(e){if(!e[1])throw new Error("Missing coordinate in tag");const t=Ju(e[1],!0,!1);return e[2]&&Qu(e[2])&&(t.relays=[e[2]]),t}function Vu(e){if(!e[1])throw new Error("Missing pubkey in tag");if(!Pu(e[1]))throw new Error("Invalid pubkey");const t={pubkey:e[1]};return e[2]&&Qu(e[2])&&(t.relays=[Bu(e[2])]),t}function Wu(e){return e.kind+":"+e.pubkey+":"+e.identifier}const Yu=Symbol.for("encrypted-content"),Zu={[bs.EncryptedDirectMessage]:"nip04",[bs.Seal]:"nip44",[bs.GiftWrap]:"nip44"};function Xu(e,t){return Zu[e]=t,e}const ed=Yu,td=new Set([Xu(bs.DraftLong,"nip04")]);function nd(e,t){return td.add(Xu(e,t)),e}function id(e){return function(e){return void 0!==Zu[e]}(e)&&td.has(e)}function sd(e){return!!id(e.kind)&&(function(e){return!0===Reflect.has(e,Yu)}(e)&&!0===Reflect.has(e,ed))}function rd(e){if(id(e.kind))return sd(e)?e[Yu]:function(e){return Reflect.get(e,Yu)}(e)}const od=Symbol.for("hidden-tags"),ld=new Set([nd(bs.BookmarkList,"nip04"),nd(bs.InterestsList,"nip04"),nd(bs.Mutelist,"nip04"),nd(bs.CommunitiesList,"nip04"),nd(bs.PublicChatsList,"nip04"),nd(bs.SearchRelaysList,"nip04"),nd(10009,"nip04"),nd(bs.Bookmarksets,"nip04"),nd(bs.Relaysets,"nip04"),nd(bs.Followsets,"nip04"),nd(bs.Curationsets,"nip04"),nd(bs.Interestsets,"nip04")]);function ad(e){return id(e)&&ld.has(e)}function cd(e){return!!ad(e.kind)&&(sd(e)&&Reflect.has(e,"HiddenTagsSymbol"))}function ud(e){if(!ad(e.kind))return;if(cd(e))return e[od];const t=rd(e);if(void 0===t)return;const n=JSON.parse(t);if(!Array.isArray(n))throw new Error("Content is not an array of tags");const i=n.filter(e=>Array.isArray(e)).map(e=>e.map(e=>String(e)));return Reflect.set(e,od,i),i}const dd="abcdefghijklmnopqrstuvwxyz",fd=new Set((dd+dd.toUpperCase()).split("")),hd=Symbol.for("indexable-tags");function pd(e){let t=Reflect.get(e,hd);if(!t){const n=new Set;for(const t of e.tags)t.length>=2&&1===t[0].length&&fd.has(t[0])&&n.add(t[0]+":"+t[1]);t=n,Reflect.set(e,hd,n)}return t}class gd{first=null;items=Object.create(null);last=null;max;resetTtl;size;ttl;constructor(e=0,t=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map(e=>[e,this.get(e)])}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0===--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const n=this.items[e];this.ttl>0&&n.expiry<=Date.now()?this.delete(e):(t=n.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,n=!1,i=this.resetTtl){let s;if(n||this.has(e)){if(s=this.items[e],s.value=t,!1===n&&i&&(s.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==s){const e=this.last,t=s.next,n=s.prev;this.first===s&&(this.first=s.next),s.next=null,s.prev=this.last,e.next=s,null!==n&&(n.next=t),null!==t&&(t.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),s=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1===++this.size?this.first=s:this.last.next=s;return this.last=s,this}values(e=this.keys()){return e.map(e=>this.get(e))}}function md(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vd,yd,wd={exports:{}};function bd(){if(yd)return vd;yd=1;var e=1e3,t=60*e,n=60*t,i=24*n,s=7*i,r=365.25*i;function o(e,t,n,i){var s=t>=1.5*n;return Math.round(e/n)+" "+i+(s?"s":"")}return vd=function(l,a){a=a||{};var c=typeof l;if("string"===c&&l.length>0)return function(o){if((o=String(o)).length>100)return;var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(!l)return;var a=parseFloat(l[1]);switch((l[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*r;case"weeks":case"week":case"w":return a*s;case"days":case"day":case"d":return a*i;case"hours":case"hour":case"hrs":case"hr":case"h":return a*n;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(l);if("number"===c&&isFinite(l))return a.long?function(s){var r=Math.abs(s);if(r>=i)return o(s,r,i,"day");if(r>=n)return o(s,r,n,"hour");if(r>=t)return o(s,r,t,"minute");if(r>=e)return o(s,r,e,"second");return s+" ms"}(l):function(s){var r=Math.abs(s);if(r>=i)return Math.round(s/i)+"d";if(r>=n)return Math.round(s/n)+"h";if(r>=t)return Math.round(s/t)+"m";if(r>=e)return Math.round(s/e)+"s";return s+"ms"}(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))}}var Ad=function(e){function t(e){let i,s,r,o=null;function l(...e){if(!l.enabled)return;const n=l,s=Number(new Date),r=s-(i||s);n.diff=r,n.prev=i,n.curr=s,i=s,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(i,s)=>{if("%%"===i)return"%";o++;const r=t.formatters[s];if("function"==typeof r){const t=e[o];i=r.call(n,t),e.splice(o,1),o--}return i}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return l.namespace=e,l.useColors=t.useColors(),l.color=t.selectColor(e),l.extend=n,l.destroy=t.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(s!==t.namespaces&&(s=t.namespaces,r=t.enabled(e)),r),set:e=>{o=e}}),"function"==typeof t.init&&t.init(l),l}function n(e,n){const i=t(this.namespace+(void 0===n?":":n)+e);return i.log=this.log,i}function i(e,t){let n=0,i=0,s=-1,r=0;for(;n<e.length;)if(i<t.length&&(t[i]===e[n]||"*"===t[i]))"*"===t[i]?(s=i,r=n,i++):(n++,i++);else{if(-1===s)return!1;i=s+1,r++,n=r}for(;i<t.length&&"*"===t[i];)i++;return i===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(i(e,n))return!1;for(const n of t.names)if(i(e,n))return!0;return!1},t.humanize=bd(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let i=0,s=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(i++,"%c"===e&&(s=i))}),t.splice(s,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Ad(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(wd,wd.exports);const kd=md(wd.exports)("applesauce");class Id{log=kd.extend("EventMemory");kinds=new Map;authors=new Map;tags=new gd;created_at=[];kindAuthor=new Map;events=new gd;replaceable=new Map;get size(){return this.events.size}hasEvent(e){return this.events.has(e)}getEvent(e){return this.events.get(e)}hasReplaceable(e,t,n){const i=this.replaceable.get(yu(e,t,n));return!!i&&i.length>0}getReplaceable(e,t,n){const i=yu(e,t,n),s=this.replaceable.get(i);return s?.[0]}getReplaceableHistory(e,t,n){const i=yu(e,t,n);return this.replaceable.get(i)}getByFilters(e){return Array.from(this.getEventsForFilters(Array.isArray(e)?e:[e]))}getTimeline(e){const t=[],n=this.getByFilters(e);for(const e of n)au(t,e);return t}add(e){const t=e.id,n=this.events.get(t);if(n)return n;this.events.set(t,e),this.getKindIndex(e.kind).add(e),this.getAuthorsIndex(e.pubkey).add(e),this.getKindAuthorIndex(e.kind,e.pubkey).add(e);for(const t of pd(e))this.tags.has(t)&&this.getTagIndex(t).add(e);if(au(this.created_at,e),gu(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=yu(e.kind,e.pubkey,t);let i=this.replaceable.get(n);this.replaceable.has(n)||(i=[],this.replaceable.set(n,i)),au(i,e)}return e}remove(e){let t="string"==typeof e?this.events.get(e):e;if(!t)return!1;const n=t.id;if(!this.events.has(n))return!1;this.getAuthorsIndex(t.pubkey).delete(t),this.getKindIndex(t.kind).delete(t);const i=`${t.kind}:${t.pubkey}`;this.kindAuthor.has(i)&&this.kindAuthor.get(i).delete(t);for(const e of pd(t))this.tags.has(e)&&this.getTagIndex(e).delete(t);if(this.removeFromSortedArray(this.created_at,t),this.events.delete(n),gu(t.kind)){const e=t.tags.find(e=>"d"===e[0])?.[1],n=yu(t.kind,t.pubkey,e),i=this.replaceable.get(n);i&&this.removeFromSortedArray(i,t)}return this.claims.delete(t),!0}removeByFilters(e){const t=this.getByFilters(e);let n=0;for(const e of t)this.remove(e)&&n++;return n}update(e){}claims=new WeakMap;touch(e){this.events.has(e.id)&&this.events.set(e.id,e)}claim(e){const t=this.claims.get(e)||0;this.claims.set(e,t+1),this.touch(e)}isClaimed(e){const t=this.claims.get(e);return void 0!==t&&t>0}removeClaim(e){const t=this.claims.get(e);if(void 0!==t&&t>0){const n=t-1;0===n?this.claims.delete(e):this.claims.set(e,n)}}clearClaim(e){this.claims.delete(e)}*unclaimed(){let e=this.events.first;for(;e;){const t=e.value;this.isClaimed(t)||(yield t),e=e.next}return 0}prune(e){let t=0;const n=this.unclaimed();for(const i of n)if(this.remove(i),t++,e&&t>=e)break;return t}getKindIndex(e){return this.kinds.has(e)||this.kinds.set(e,new Set),this.kinds.get(e)}getAuthorsIndex(e){return this.authors.has(e)||this.authors.set(e,new Set),this.authors.get(e)}getKindAuthorIndex(e,t){const n=`${e}:${t}`;return this.kindAuthor.has(n)||this.kindAuthor.set(n,new Set),this.kindAuthor.get(n)}getTagIndex(e){if(!this.tags.has(e)){const t=new Set,n=Date.now();for(const n of this.events.values())pd(n).has(e)&&t.add(n);const i=Date.now()-n;i>100&&this.log(`Built index ${e} took ${i}ms`),this.tags.set(e,t)}return this.tags.get(e)}removeFromSortedArray(e,t){if(0===e.length)return;const n=cu(e,e=>e.created_at-t.created_at);if(n){let i=n[0],s=!1;if(e[i]===t)return void e.splice(i,1);for(let n=i-1;n>=0&&e[n].created_at===t.created_at;n--)if(e[n]===t){e.splice(n,1),s=!0;break}if(s)return;for(let n=i+1;n<e.length&&e[n].created_at===t.created_at;n++)if(e[n]===t)return void e.splice(n,1)}const i=e.indexOf(t);-1!==i&&e.splice(i,1)}*iterateAuthors(e){for(const t of e){const e=this.authors.get(t);if(e)for(const t of e)yield t}}*iterateTag(e,t){for(const n of t){const t=this.getTagIndex(e+":"+n);if(t)for(const e of t)yield e}}*iterateKinds(e){for(const t of e){const e=this.kinds.get(t);if(e)for(const t of e)yield t}}*iterateTime(e,t){let n=0,i=this.created_at.length-1,s=t?cu(this.created_at,e=>e.created_at-t):void 0;s&&(n=s[0]);const r=e?cu(this.created_at,t=>t.created_at-e):void 0;r&&(i=r[0]);for(let s=n;s<=i;s++){const n=this.created_at[s];if(!(void 0!==t&&n.created_at>t)){if(void 0!==e&&n.created_at<e)break;yield n}}}*iterateIds(e){for(const t of e)this.events.has(t)&&(yield this.events.get(t))}getEventsForFilter(e){if(e.search)return new Set;let t=!0,n=new Set;const i=e=>{const i=e instanceof Set?e:new Set(e);if(t)n=i,t=!1;else for(const e of n)i.has(e)||n.delete(e);return n};e.ids&&i(this.iterateIds(e.ids));let s=null;void 0!==e.since&&(s=Array.from(this.iterateTime(e.since,e.until)),i(s));for(const t of fd){const n=e[`&${t}`];if(n?.length)for(const e of n)i(this.iterateTag(t,[e]))}for(const t of fd){const n=e[`#${t}`];if(n?.length){const s=e[`&${t}`],r=s?n.filter(e=>!s.includes(e)):n;r.length>0&&i(this.iterateTag(t,r))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<=20){const t=new Set;for(const n of e.kinds)for(const i of e.authors){const e=`${n}:${i}`,s=this.kindAuthor.get(e);if(s)for(const e of s)t.add(e)}i(t)}else e.authors&&i(this.iterateAuthors(e.authors)),e.kinds&&i(this.iterateKinds(e.kinds));if(void 0===e.since&&void 0!==e.until&&(s=Array.from(this.iterateTime(e.since,e.until)),i(s)),t)return new Set(this.events.values());if(e.limit&&s){const t=new Set;for(const i of s){if(t.size>=e.limit)break;n.has(i)&&t.add(i)}return t}return n}getEventsForFilters(e){if(0===e.length)return new Set;let t=new Set;for(const n of e){const e=this.getEventsForFilter(n);for(const n of e)t.add(n)}return t}reset(){this.events.clear(),this.kinds.clear(),this.authors.clear(),this.kindAuthor.clear(),this.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}}function Cd(e,t){var n,i;if(0===t.length)return e;for(n=0,i=t.length;n<i;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e<0?-2*e:e}function Ed(e,t,n,i){var s,r=Cd(Cd(Cd(e,n),(s=t,Object.prototype.toString.call(s))),typeof t);if(null===t)return Cd(r,"null");if(void 0===t)return Cd(r,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==i.indexOf(t))return Cd(r,"[Circular]"+n);i.push(t);var o=function(e,t,n){return Object.keys(t).sort().reduce(function(e,i){return Ed(e,t[i],i,n)},e)}(r,t,i);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return o;try{return Cd(o,String(t.valueOf()))}catch(e){return Cd(o,"[valueOf exception]"+(e.stack||e.message))}}return Cd(r,t.toString())}var xd=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Ed(0,e,"",[]).toString(16),8)},Sd=md(xd);function Bd(e,t){if(e.ids&&-1===e.ids.indexOf(t.id))return!1;if(e.kinds&&-1===e.kinds.indexOf(t.kind))return!1;if(e.authors&&-1===e.authors.indexOf(t.pubkey))return!1;if(e.since&&t.created_at<e.since)return!1;if(e.until&&t.created_at>e.until)return!1;for(let n in e)if("&"===n[0]){let i=n.slice(1),s=e[n];if(s&&s.length>0){const e=pd(t);for(const t of s)if(!e.has(i+":"+t))return!1}}for(let n in e)if("#"===n[0]){let i=n.slice(1),s=e[n];if(s){const n=e[`&${i}`],r=n?s.filter(e=>!n.includes(e)):s;if(0===r.length)continue;const o=pd(t);if(!1===r.some(e=>o.has(i+":"+e)))return!1}}return!0}function $d(e,t){for(let n=0;n<e.length;n++)if(Bd(e[n],t))return!0;return!1}function Fd(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:10063,pubkey:e.pubkey,relays:e.relays}).pipe(wc(e=>e?function(e){const t=Array.isArray(e)?e:e.tags;return Xc(t,e=>Jc(e,"server")&&URL.canParse(e[1])?new URL("/",e[1]):void 0)}(e):[]))}const Dd=Symbol.for("profile-content");function Qd(e){return lu(e,Dd,()=>{const t=function(e){try{return JSON.parse(e)}catch(e){return}}
  15  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */(e.content);if(t)return t.nip05&&"string"!=typeof t.nip05&&(t.nip05=String(t.nip05)),t.website&&t.website?.length>0&&!1===t.website?.startsWith("http")&&(t.website="https://"+t.website),t})}function Pd(e){return!!e&&((e.kind===bs.Metadata||e.kind===bs.Handlerinformation)&&!!Qd(e))}!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),i=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:i}}function i(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map(n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function s(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function r(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let i=t.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&t[i-1]===n;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,i)}}}function o(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function l(e,n,i){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(i<2)throw new Error(`convertRadix: wrong to=${i}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let s=0;const r=[],o=Array.from(e);for(o.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let r=s;r<o.length;r++){const l=o[r],a=n*e+l;if(!Number.isSafeInteger(a)||n*e/n!==e||a-l!==n*e)throw new Error("convertRadix: carry overflow");if(e=a%i,o[r]=Math.floor(a/i),!Number.isSafeInteger(o[r])||o[r]*i+e!==a)throw new Error("convertRadix: carry overflow");t&&(o[r]?t=!1:s=r)}if(r.push(e),t)break}for(let t=0;t<e.length-1&&0===e[t];t++)r.push(0);return r.reverse()}
  16  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
  17  Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64url=e.base64=e.base32crockford=e.base32hex=e.base32=e.base16=e.utils=e.assertNumber=void 0,e.assertNumber=t;const a=(e,t)=>t?a(t,e%t):e,c=(e,t)=>e+(t-a(e,t));function u(e,n,i,s){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(i<=0||i>32)throw new Error(`convertRadix2: wrong to=${i}`);if(c(n,i)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${i} carryBits=${c(n,i)}`);let r=0,o=0;const l=2**i-1,a=[];for(const s of e){if(t(s),s>=2**n)throw new Error(`convertRadix2: invalid data word=${s} from=${n}`);if(r=r<<n|s,o+n>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${n}`);for(o+=n;o>=i;o-=i)a.push((r>>o-i&l)>>>0);r&=2**o-1}if(r=r<<i-o&l,!s&&o>=n)throw new Error("Excess padding");if(!s&&r)throw new Error(`Non-zero padding: ${r}`);return s&&o>0&&a.push(r>>>0),a}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return l(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(l(t,e,256))}}}function f(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(c(8,e)>32||c(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(t,e,8,n))}}}function h(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function p(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const i=n(t).slice(0,e),s=new Uint8Array(t.length+e);return s.set(t),s.set(i,t.length),s},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const i=t.slice(0,-e),s=n(i).slice(0,e),r=t.slice(-e);for(let t=0;t<e;t++)if(s[t]!==r[t])throw new Error("Invalid checksum");return i}}}e.utils={alphabet:i,chain:n,checksum:p,radix:d,radix2:f,join:s,padding:r},e.base16=n(f(4),i("0123456789ABCDEF"),s("")),e.base32=n(f(5),i("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),r(5),s("")),e.base32hex=n(f(5),i("0123456789ABCDEFGHIJKLMNOPQRSTUV"),r(5),s("")),e.base32crockford=n(f(5),i("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),s(""),o(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),r(6),s("")),e.base64url=n(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),r(6),s(""));const g=e=>n(d(58),i(e),s(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const m=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let i=0;i<t.length;i+=8){const s=t.subarray(i,i+8);n+=e.base58.encode(s).padStart(m[s.length],"1")}return n},decode(t){let n=[];for(let i=0;i<t.length;i+=11){const s=t.slice(i,i+11),r=m.indexOf(s.length),o=e.base58.decode(s);for(let e=0;e<o.length-r;e++)if(0!==o[e])throw new Error("base58xmr: wrong padding");n=n.concat(Array.from(o.slice(o.length-r)))}return Uint8Array.from(n)}};e.base58check=t=>n(p(4,e=>t(t(e))),e.base58);const v=n(i("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),s("")),y=[996825010,642813549,513874426,1027748829,705979059];function w(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e<y.length;e++)1==(t>>e&1)&&(n^=y[e]);return n}function b(e,t,n=1){const i=e.length;let s=1;for(let t=0;t<i;t++){const n=e.charCodeAt(t);if(n<33||n>126)throw new Error(`Invalid prefix (${e})`);s=w(s)^n>>5}s=w(s);for(let t=0;t<i;t++)s=w(s)^31&e.charCodeAt(t);for(let e of t)s=w(s)^e;for(let e=0;e<6;e++)s=w(s);return s^=n,v.encode(u([s%2**30],30,5,!1))}function A(e){const t="bech32"===e?1:734539939,n=f(5),i=n.decode,s=n.encode,r=h(i);function o(e,n=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==n&&e.length>n)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=(e=i).lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const r=e.slice(0,s),o=e.slice(s+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const l=v.decode(o).slice(0,-6),a=b(r,l,t);if(!o.endsWith(a))throw new Error(`Invalid checksum in ${e}: expected "${a}"`);return{prefix:r,words:l}}return{encode:function(e,n,i=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const s=e.length+7+n.length;if(!1!==i&&s>i)throw new TypeError(`Length ${s} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${v.encode(n)}${b(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:i(n)}},decodeUnsafe:h(o),fromWords:i,fromWordsUnsafe:r,toWords:s}}e.bech32=A("bech32"),e.bech32m=A("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),i("0123456789abcdef"),s(""),o(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));const k={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},I=`Invalid encoding type. Available types: ${Object.keys(k).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!k.hasOwnProperty(e))throw new TypeError(I);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return k[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!k.hasOwnProperty(e))throw new TypeError(I);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return k[e].decode(t)},e.bytes=e.stringToBytes}({}),BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const Rd={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(Rd);e<t.length;e++)t[e],Rd[t[e]].toString();const Td=Symbol.for("public-contacts"),Ld=Symbol.for("hidden-contacts");function _d(e){return function(...e){const t=new Map;for(const n of e)if(Array.isArray(n))for(const e of n)e&&t.set(e.pubkey,e);else n&&t.set(n.pubkey,n);return Array.from(t.values())}(function(e){return lu(e,Td,()=>Xc(e.tags,e=>Vc(e)?e:void 0,Vu))}(e),function(e){if(function(e){return cd(e)&&Reflect.has(e,Ld)}(e))return e[Ld];const t=ud(e);if(!t)return;const n=Xc(t,e=>Vc(e)?e:void 0,Vu);return Reflect.set(e,Ld,n),n}(e))}function Nd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Md(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function Ud(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function Od(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function jd(e){if(!Array.isArray(e))throw new Error("array expected")}function zd(e,t){if(!Md(!0,t))throw new Error(`${e}: array of strings expected`)}kd.extend("EncryptedContentCache"),kd.extend("event-cache");const Hd=(e,t)=>0===t?e:Hd(t,e%t),qd=(e,t)=>e+(t-Hd(e,t)),Gd=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Jd(e,t,n,i){if(jd(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(qd(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${qd(t,n)}`);let s=0,r=0;const o=Gd[t],l=Gd[n]-1,a=[];for(const i of e){if(Od(i),i>=o)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(s=s<<t|i,r+t>32)throw new Error(`convertRadix2: carry overflow pos=${r} from=${t}`);for(r+=t;r>=n;r-=n)a.push((s>>r-n&l)>>>0);const e=Gd[r];if(void 0===e)throw new Error("invalid carry");s&=e-1}if(s=s<<n-r&l,!i&&r>=t)throw new Error("Excess padding");if(!i&&s>0)throw new Error(`Non-zero padding: ${s}`);return i&&r>0&&a.push(s>>>0),a}const Kd=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Nd(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}(e),e.toBase64()),decode:e=>((e,t)=>{Ud("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,i=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:i,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(Od(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(qd(8,e)>32||qd(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Nd(n))throw new Error("radix2.encode input should be Uint8Array");return Jd(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!Md(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(Jd(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;zd("alphabet",t);const i=new Map(t.map((e,t)=>[e,t]));return{encode:i=>(jd(i),i.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:t=>(jd(t),t.map(t=>{Ud("alphabet.decode",t);const n=i.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return Od(e),Ud("padding",t),{encode(n){for(zd("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){zd("padding.decode",n);let i=n.length;if(i*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--){if((i-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,i)}}}(6),function(e=""){return Ud("join",e),{encode:t=>(zd("join.decode",t),t.join(e)),decode:t=>(Ud("join.decode",t),t.split(e))}}(""));new TextDecoder;const Vd=Symbol.for("mailboxes-inboxes"),Wd=Symbol.for("mailboxes-outboxes");function Yd(e){return lu(e,Vd,()=>{const t=[];for(const n of e.tags)if(Wc(n))try{const[,e,i]=n;!e||!Qu(e)||t.includes(e)||"read"!==i&&void 0!==i||t.push(Bu(e))}catch{}return t})}function Zd(e){return lu(e,Wd,()=>{const t=[];for(const n of e.tags)if(Wc(n))try{const[e,i,s]=n;"r"!==e||!Qu(i)||t.includes(i)||"write"!==s&&void 0!==s||t.push(Bu(i))}catch{}return t})}const Xd=Symbol.for("mute-public"),ef=Symbol.for("mute-hidden");function tf(e){return{pubkeys:new Set(e.filter(Vc).map(e=>e[1])),threads:new Set(e.filter(Kc).map(e=>e[1])),hashtags:new Set(e.filter(Zc).map(e=>e[1].toLocaleLowerCase())),words:new Set(e.filter(e=>"word"===e[0]&&e[1]).map(e=>e[1].toLocaleLowerCase()))}}function nf(e){const t=function(e){if(function(e){return cd(e)&&Reflect.has(e,ef)}(e))return e[ef];const t=ud(e);if(!t)return;const n=tf(t);return Reflect.set(e,ef,n),n}(e),n=function(e){return lu(e,Xd,()=>tf(e.tags))}(e);return t?function(...e){const t={pubkeys:new Set,threads:new Set,hashtags:new Set,words:new Set};for(const n of e){for(const e of n.pubkeys)t.pubkeys.add(e);for(const e of n.threads)t.threads.add(e);for(const e of n.hashtags)t.hashtags.add(e);for(const e of n.words)t.words.add(e)}return t}(t,n):n}var sf;!function(e){e.nudity="nudity",e.malware="malware",e.profanity="profanity",e.illegal="illegal",e.spam="spam",e.impersonation="impersonation",e.other="other"}(sf||(sf={}));const rf=Symbol.for("nip10-thread-refs");function of(e){if(!e[1])throw new Error("Missing event id in tag");let t={id:e[1]};return e[2]&&Qu(e[2])&&(t.relays=[e[2]]),"e"!==e[0]||"root"!==e[3]&&"reply"!==e[3]&&"mention"!==e[3]||!e[4]||64!==e[4].length||(t.author=e[4]),t}function lf(e){return t=>{const n=new Set;return t.pipe(Gc(t=>{if(void 0!==t)if(Array.isArray(t))for(const i of t)n.has(i)||(n.add(i),e.claim(i));else n.has(t)||(n.add(t),e.claim(t))}),Uc(()=>{for(const t of n)e.removeClaim(t)}))}}function af(e){return t=>{let n;return t.pipe(Gc(t=>{n!==t&&(n&&e.removeClaim(n),t&&e.claim(t),n=t)}),Uc(()=>{n&&e.removeClaim(n)}))}}function cf(){return e=>e.pipe(Tc(e=>null!=e))}function uf(e){return t=>new Ra(n=>{let i=!1;const s=t.subscribe({next:e=>{i=!0,n.next(e)},error:e=>n.error(e),complete:()=>n.complete()});return i||n.next(e),s})}function df(e){return"string"==typeof e&&(e={id:e}),t=>Rc(Qc(()=>function(e,t){const n=e.getEvent(t.id);return n instanceof Promise?vc(n):yc(n)}(t,e)).pipe(function(e,t){return qc(n=>n?yc(n):e.eventLoader?vc(e.eventLoader(t)):Wa)}(t,e),cf()),t.insert$.pipe(Tc(t=>t.id===e.id)),t.remove$.pipe(Tc(t=>t.id===e.id),Lc(1),La(function(e,t){e.subscribe(_a(t,Ia))}),Mc(void 0))).pipe(af(t),_c((e,t)=>e?.id===t?.id),uf(void 0))}function ff(e){return t=>{let n;return Rc(Qc(()=>function(e,t){const n=e.getReplaceable(t.kind,t.pubkey,t.identifier);return n instanceof Promise?vc(n):yc(n)}(t,e)).pipe(function(e,t){return qc(n=>n?yc(n):void 0!==t.identifier?e.addressableLoader?vc(e.addressableLoader(t)).pipe(Tc(e=>!!e)):Wa:e.replaceableLoader?vc(e.replaceableLoader(t)).pipe(Tc(e=>!!e)):Wa)}(t,e),cf()),t.insert$.pipe(Tc(t=>t.pubkey==e.pubkey&&t.kind===e.kind&&(void 0===e.identifier||wu(t)===e.identifier)))).pipe(_c((e,t)=>e.created_at>=t.created_at),Gc(e=>n=e),(i=t.remove$.pipe(Tc(e=>e.id===n?.id)),La(function(e,t){uc(i).subscribe(_a(t,function(){return t.complete()},Ia)),!t.closed&&e.subscribe(t)})),Mc(void 0),function(e){var t,n,i=1/0;return null!=e&&("object"==typeof e?(t=e.count,i=void 0===t?1/0:t,n=e.delay):i=e),i<=0?function(){return Wa}:La(function(e,t){var s,r=0,o=function(){if(null==s||s.unsubscribe(),s=null,null!=n){var e="number"==typeof n?Pc(n):uc(n(r)),i=_a(t,function(){i.unsubscribe(),l()});e.subscribe(i)}else l()},l=function(){var n=!1;s=e.subscribe(_a(t,void 0,function(){++r<i?s?o():n=!0:t.complete()})),n&&o()};l()})}(),af(t),uf(void 0));var i}}function hf(e,t){return e=Array.isArray(e)?e:[e],n=>{const i=new Map;return Qc(()=>{const t=n.getTimeline(e);return t instanceof Promise?vc(t):yc(t)}).pipe(lf(n),jc(n.insert$.pipe(Tc(t=>$d(e,t)),lf(n))),jc(n.remove$.pipe(Tc(t=>$d(e,t)),wc(e=>e.id))),zc((e,n)=>{if("string"==typeof n)return e.filter(e=>e.id!==n);if(Array.isArray(n)){if(!t)for(const e of n)gu(e.kind)&&i.set(mu(e),e);return n}let s=[...e];if(!t&&gu(n.kind)){const t=mu(n),r=i.get(t);if(r&&n.created_at<r.created_at)return e;i.set(t,n),r&&s.slice(s.indexOf(r),1)}return au(s,n),s},[]),_c(),Uc(()=>i.clear()))}}function pf(e){return t=>Sc(Object.fromEntries(e.map(e=>[e,t.model(df,{id:e})])))}function gf(e){return t=>Sc(Object.fromEntries(e.map(e=>[yu(e.kind,e.pubkey,e.identifier),t.model(ff,e)])))}function mf(e){return t=>{let n;return Rc(t.pipe(Gc(e=>n=e)),e.update$.pipe(Tc(e=>e.id===n?.id)))}}function vf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:bs.Contacts,pubkey:e.pubkey,relays:e.relays}).pipe(mf(t),wc(e=>e?_d(e):[]))}function yf(e){return t=>{const n=[{kinds:[1111],"#e":[e.id]}];return ta(e.kind)&&n.push({kinds:[1111],"#a":[vu(e)]}),t.timeline(n)}}function wf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:bs.RelayList,pubkey:e.pubkey,relays:e.relays}).pipe(wc(e=>e&&{inboxes:Yd(e),outboxes:Zd(e)}))}function bf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:bs.Mutelist,pubkey:e.pubkey,relays:e.relays}).pipe(mf(t),wc(e=>e&&nf(e)))}function Af(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:bs.Metadata,pubkey:e.pubkey,relays:e.relays}).pipe(Tc(Pd),wc(e=>e&&Qd(e)),uf(void 0))}function kf(e){return t=>t.timeline(gu(e.kind)?[{kinds:[bs.Reaction],"#e":[e.id]},{kinds:[bs.Reaction],"#a":[mu(e)]}]:[{kinds:[bs.Reaction],"#e":[e.id]}])}const If={kinds:[bs.ShortTextNote]};function Cf(e,t){const n=new Map,i=new Map,{kinds:s}={...If,...t};let r="";const o={},l={kinds:s};var a;return"string"!=typeof(a=e)&&Reflect.has(a,"identifier")&&Reflect.has(a,"pubkey")&&Reflect.has(a,"kind")?(r=Wu(e),o.kinds=[e.kind],o.authors=[e.pubkey],o["#d"]=[e.identifier],l["#a"]=[r]):"string"==typeof e?(r=e,o.ids=[e],l["#e"]=[e]):(r=e.id,o.ids=[e.id],l["#e"]=[e.id]),e=>e.filters([o,l]).pipe(wc(e=>{if(!i.has(mu(e))){const t=function(e){return lu(e,rf,()=>{const t=function(e){const t=e.filter(e=>"e"===e[0]&&e[1]),n=e.filter(e=>"a"===e[0]&&e[1]);let i=t.find(e=>"root"===e[3]),s=t.find(e=>"reply"===e[3]),r=n.find(e=>"root"===e[3]),o=n.find(e=>"reply"===e[3]);if(i&&s||(i=s=i||s),r&&o||(r=o=r||o),!i&&!s){const e=t.filter(e=>!e[3]);e.length>=1&&(i=e[0],s=e[e.length-1]??i)}return{root:i||r?{e:i,a:r}:void 0,reply:s||o?{e:s,a:o}:void 0}}(e.tags);let n,i;if(t.root)try{n={e:t.root.e&&of(t.root.e),a:t.root.a&&Ku(t.root.a)}}catch(e){}if(t.reply)try{i={e:t.reply.e&&of(t.reply.e),a:t.reply.a&&Ku(t.reply.a)}}catch(e){}return{root:n,reply:i}})}(e),s=n.get(mu(e))||new Set,r={event:e,refs:t,replies:s};for(const e of s)e.parent=r;if(t.reply?.e||t.reply?.a){let e=t.reply.e?t.reply.e.id:Wu(t.reply.a);if(r.parent=i.get(e),r.parent)r.parent.replies.add(r);else{let t=n.get(e);t||(t=new Set,n.set(e,t)),t.add(r)}}i.set(mu(e),r)}return{root:i.get(r),all:i}}))}function Ef(e){return class extends e{models=new Map;modelKeepWarm=6e4;model(e,...t){let n=this.models.get(e);n||(n=new Map,this.models.set(e,n));const i=e.getKey?e.getKey(...t):Sd(t);let s=n.get(i);if(!s){const r=()=>{n.get(i)===s&&n.delete(i)};s=e(...t)(this).pipe(Uc(r),function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new Ua}:t,i=e.resetOnError,s=void 0===i||i,r=e.resetOnComplete,o=void 0===r||r,l=e.resetOnRefCountZero,a=void 0===l||l;return function(e){var t,i,r,l=0,c=!1,u=!1,d=function(){null==i||i.unsubscribe(),i=void 0},f=function(){d(),t=r=void 0,c=u=!1},h=function(){var e=t;f(),null==e||e.unsubscribe()};return La(function(e,p){l++,u||c||d();var g=r=null!=r?r:n();p.add(function(){0!==--l||u||c||(i=Hc(h,a))}),g.subscribe(p),!t&&l>0&&(t=new $a({next:function(e){return g.next(e)},error:function(e){u=!0,d(),i=Hc(f,s,e),g.error(e)},complete:function(){c=!0,d(),i=Hc(f,o),g.complete()}}),uc(e).subscribe(t))})(e)}}({connector:()=>new za(1),resetOnComplete:()=>Pc(this.modelKeepWarm),resetOnRefCountZero:()=>Pc(this.modelKeepWarm)})),n.set(i,s)}return s}filters(e,t=!1){e=Array.isArray(e)?e:[e];const n=this.getByFilters(e);return Rc(t?Wa:n&&"function"==typeof n.then?vc(n).pipe($c(e=>vc(Array.from(e)))):vc(Array.from(n)),this.insert$.pipe(Tc(t=>$d(e,t))))}event(e){return"string"==typeof e&&(e={id:e}),this.model(df,e)}replaceable(...e){let t;if(1===e.length)t=e[0];else if(3===e.length||2===e.length){let[n,i,s]=e;t={kind:n,pubkey:i,identifier:s}}if(!t)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(ff,t)}addressable(e){return this.model(ff,e)}timeline(e,t=!1){return this.model(hf,e,t)}profile(e){return this.model(Af,e)}contacts(e){return"string"==typeof e&&(e={pubkey:e}),this.model(vf,e)}mutes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(bf,e)}mailboxes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(wf,e)}blossomServers(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Fd,e)}reactions(e){return this.model(kf,e)}thread(e){return this.model(Cf,e)}comments(e){return this.model(yf,e)}events(e){return this.model(pf,e)}replaceableSet(e){return this.model(gf,e)}}}class xf extends(Ef(class{})){database;memory;keepOldVersions=!1;keepExpired=!1;verifyEvent;insert$=new Ua;update$=new Ua;remove$=new Ua;eventLoader;replaceableLoader;addressableLoader;constructor(e=new Id){super(),e?(this.database=e,this.memory=new Id):this.database=this.memory=new Id,this.insert$.subscribe(e=>{Reflect.set(e,uu,this)}),this.remove$.subscribe(e=>{Reflect.deleteProperty(e,uu)})}mapToMemory(e){if(void 0!==e)return this.memory?this.memory.add(e):e}deletedIds=new Set;deletedCoords=new Map;checkDeleted(e){if("string"==typeof e)return this.deletedIds.has(e);if(this.deletedIds.has(e.id))return!0;if(ta(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=this.deletedCoords.get(yu(e.kind,e.pubkey,t));if(n)return n>e.created_at}return!1}expirations=new Map;addExpiration(e){const t=ku(e);t&&Number.isFinite(t)&&this.expirations.set(e.id,t)}expirationTimeout=null;nextExpirationCheck=null;handleExpiringEvent(e){const t=ku(e);if(!t)return;if(this.expirations.set(e.id,t),this.expirationTimeout&&this.nextExpirationCheck&&this.nextExpirationCheck<t)return;this.expirationTimeout&&clearTimeout(this.expirationTimeout);const n=t-bu();this.expirationTimeout=setTimeout(this.pruneExpired.bind(this),1e3*n+10),this.nextExpirationCheck=t}pruneExpired(){const e=bu();for(const[t,n]of this.expirations)n<=e&&(this.expirations.delete(t),this.remove(t));this.expirationTimeout&&clearTimeout(this.expirationTimeout),this.nextExpirationCheck=null,this.expirationTimeout=null}handleDeleteEvent(e){const t=function(e){return e.tags.filter(Kc).map(e=>e[1])}(e);for(const e of t)this.deletedIds.add(e),this.remove(e);const n=function(e){return e.tags.filter(Yc).map(e=>e[1])}(e);for(const t of n){this.deletedCoords.set(t,Math.max(this.deletedCoords.get(t)??0,e.created_at));const n=Ju(t);if(!n)continue;const i=this.database.getReplaceableHistory(n.kind,n.pubkey,n.identifier)??[];for(const t of i)t.created_at<e.created_at&&this.remove(t)}}static mergeDuplicateEvent(e,t){const n=e[$u];if(n)for(const e of n)Fu(t,e);const i=Reflect.get(e,hu);i&&!Reflect.get(t,hu)&&Reflect.set(t,hu,i)}add(e,t){if(e.kind===bs.EventDeletion&&this.handleDeleteEvent(e),this.checkDeleted(e))return e;const n=ku(e);if(!1===this.keepExpired&&n&&n<=bu())return null;const i=gu(e.kind)?e.tags.find(e=>"d"===e[0])?.[1]:void 0;if(!this.keepOldVersions&&gu(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(t&&t.length>0&&t[0].created_at>=e.created_at)return xf.mergeDuplicateEvent(e,t[0]),t[0]}if(this.verifyEvent&&!1===this.verifyEvent(e))return null;const s=this.memory?.add(e);if(s&&s!==e)return xf.mergeDuplicateEvent(e,s),t&&Fu(s,t),s;const r=this.mapToMemory(this.database.add(e));if(e!==r&&xf.mergeDuplicateEvent(e,r),t&&Fu(r,t),r===e&&this.insert$.next(r),!this.keepOldVersions&&gu(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(t&&t.length>0){const n=Array.from(t).filter(t=>t.created_at<e.created_at);for(const e of n)this.remove(e);if(t.length!==n.length)return t[0]}}return!1===this.keepExpired&&n&&this.handleExpiringEvent(r),r}remove(e){let t=this.memory?.getEvent("string"==typeof e?e:e.id);this.memory&&this.memory.remove(e);const n=this.database.remove(e);return n&&t&&this.remove$.next(t),n}removeByFilters(e){const t=this.getByFilters(e);this.memory&&this.memory.removeByFilters(e);const n=this.database.removeByFilters(e);for(const e of t)this.remove$.next(e);return n}update(e){return!!this.database.add(e)&&(this.database.update?.(e),this.update$.next(e),!0)}hasEvent(e){return this.memory?.hasEvent(e)||this.database.hasEvent(e)}getEvent(e){return this.memory?.getEvent(e)??this.mapToMemory(this.database.getEvent(e))}hasReplaceable(e,t,n){return this.memory?.hasReplaceable(e,t,n)||this.database.hasReplaceable(e,t,n)}getReplaceable(e,t,n){return this.memory?.getReplaceable(e,t,n)??this.mapToMemory(this.database.getReplaceable(e,t,n))}getReplaceableHistory(e,t,n){return this.memory?.getReplaceableHistory(e,t,n)??this.database.getReplaceableHistory(e,t,n)?.map(e=>this.mapToMemory(e)??e)}getByFilters(e){const t=this.database.getByFilters(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}getTimeline(e){const t=this.database.getTimeline(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}touch(e){return this.memory?.touch(e)}claim(e){return this.memory?.claim(e)}isClaimed(e){return this.memory?.isClaimed(e)??!1}removeClaim(e){return this.memory?.removeClaim(e)}clearClaim(e){return this.memory?.clearClaim(e)}unclaimed(){return this.memory?.unclaimed()||function*(){}()}prune(e){return this.memory?.prune(e)??0}removed(e){return this.checkDeleted(e)?Wa:this.remove$.pipe(Tc(t=>t.id===e),Lc(1),$c(()=>Wa))}updated(e){return this.update$.pipe(Tc(t=>t.id===e||t===e))}}function Sf(){let e,t;const n=new Promise((n,i)=>{e=n,t=i});return n.resolve=e,n.reject=t,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var Bf,$f;nd(bs.NostrConnect,"nip44"),function(e){e.GetPublicKey="get_pubic_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(Bf||(Bf={})),function(e){e.Connect="connect",e.CreateAccount="create_account",e.GetPublicKey="get_public_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}($f||($f={}));class Ff{key;constructor(e){this.key=e||ms()}async getPublicKey(){return vs(this.key)}async signEvent(e){return ys(e,this.key)}nip04={encrypt:async(e,t)=>bo.encrypt(this.key,e,t),decrypt:async(e,t)=>bo.decrypt(this.key,e,t)};nip44={encrypt:async(e,t)=>_o.v2.encrypt(t,_o.v2.utils.getConversationKey(this.key,e)),decrypt:async(e,t)=>_o.v2.decrypt(t,_o.v2.utils.getConversationKey(this.key,e))};static fromKey(e){return new Ff(function(e){if(e instanceof Uint8Array)return e;if(Pu(e))return Gu(e);{const t=io.decode(e);if("nsec"!==t.type)throw new Error(`Cant get secret key from ${t.type}`);return t.data}}(e))}}
  18  /*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const Df=BigInt(0),Qf=BigInt(1),Pf=BigInt(2),Rf=BigInt(3),Tf=BigInt(8),Lf=Object.freeze({a:Df,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Qf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),_f=(e,t)=>(e+t/Pf)/t,Nf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=Lf,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Qf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),r=n,o=BigInt("0x100000000000000000000000000000000"),l=_f(r*e,t),a=_f(-i*e,t);let c=ch(e-l*n-a*s,t),u=ch(-l*i-a*r,t);const d=c>o,f=u>o;if(d&&(c=t-c),f&&(u=t-u),c>o||u>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}},Mf=32;function Uf(e){const{a:t,b:n}=Lf,i=ch(e*e),s=ch(i*e);return ch(s+t*e+n)}const Of=Lf.a===Df;function jf(e){if(!(e instanceof zf))throw new TypeError("JacobianPoint expected")}class zf{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof Gf))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Gf.ZERO)?zf.ZERO:new zf(e.x,e.y,Qf)}static toAffineBatch(e){const t=function(e,t=Lf.P){const n=new Array(e.length),i=e.reduce((e,i,s)=>i===Df?e:(n[s]=e,ch(e*i,t)),Qf),s=dh(i,t);return e.reduceRight((e,i,s)=>i===Df?e:(n[s]=ch(e*n[s],t),ch(e*i,t)),s),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return zf.toAffineBatch(e).map(zf.fromAffine)}equals(e){jf(e);const{x:t,y:n,z:i}=this,{x:s,y:r,z:o}=e,l=ch(i*i),a=ch(o*o),c=ch(t*a),u=ch(s*l),d=ch(ch(n*o)*a),f=ch(ch(r*i)*l);return c===u&&d===f}negate(){return new zf(this.x,ch(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,i=ch(e*e),s=ch(t*t),r=ch(s*s),o=e+s,l=ch(Pf*(ch(o*o)-i-r)),a=ch(Rf*i),c=ch(a*a),u=ch(c-Pf*l),d=ch(a*(l-u)-Tf*r),f=ch(Pf*t*n);return new zf(u,d,f)}add(e){jf(e);const{x:t,y:n,z:i}=this,{x:s,y:r,z:o}=e;if(s===Df||r===Df)return this;if(t===Df||n===Df)return e;const l=ch(i*i),a=ch(o*o),c=ch(t*a),u=ch(s*l),d=ch(ch(n*o)*a),f=ch(ch(r*i)*l),h=ch(u-c),p=ch(f-d);if(h===Df)return p===Df?this.double():zf.ZERO;const g=ch(h*h),m=ch(h*g),v=ch(c*g),y=ch(p*p-m-Pf*v),w=ch(p*(v-y)-d*m),b=ch(i*o*h);return new zf(y,w,b)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=zf.ZERO;if("bigint"==typeof e&&e===Df)return t;let n=ah(e);if(n===Qf)return this;if(!Of){let e=t,i=this;for(;n>Df;)n&Qf&&(e=e.add(i)),i=i.double(),n>>=Qf;return e}let{k1neg:i,k1:s,k2neg:r,k2:o}=Nf.splitScalar(n),l=t,a=t,c=this;for(;s>Df||o>Df;)s&Qf&&(l=l.add(c)),o&Qf&&(a=a.add(c)),c=c.double(),s>>=Qf,o>>=Qf;return i&&(l=l.negate()),r&&(a=a.negate()),a=new zf(ch(a.x*Nf.beta),a.y,a.z),l.add(a)}precomputeWindow(e){const t=Of?128/e+1:256/e+1,n=[];let i=this,s=i;for(let r=0;r<t;r++){s=i,n.push(s);for(let t=1;t<2**(e-1);t++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,t){!t&&this.equals(zf.BASE)&&(t=Gf.BASE);const n=t&&t._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=t&&qf.get(t);i||(i=this.precomputeWindow(n),t&&1!==n&&(i=zf.normalizeZ(i),qf.set(t,i)));let s=zf.ZERO,r=zf.BASE;const o=1+(Of?128/n:256/n),l=2**(n-1),a=BigInt(2**n-1),c=2**n,u=BigInt(n);for(let t=0;t<o;t++){const n=t*l;let o=Number(e&a);e>>=u,o>l&&(o-=c,e+=Qf);const d=n,f=n+Math.abs(o)-1,h=t%2!=0,p=o<0;0===o?r=r.add(Hf(h,i[d])):s=s.add(Hf(p,i[f]))}return{p:s,f:r}}multiply(e,t){let n,i,s=ah(e);if(Of){const{k1neg:e,k1:r,k2neg:o,k2:l}=Nf.splitScalar(s);let{p:a,f:c}=this.wNAF(r,t),{p:u,f:d}=this.wNAF(l,t);a=Hf(e,a),u=Hf(o,u),u=new zf(ch(u.x*Nf.beta),u.y,u.z),n=a.add(u),i=c.add(d)}else{const{p:e,f:r}=this.wNAF(s,t);n=e,i=r}return zf.normalizeZ([n,i])[0]}toAffine(e){const{x:t,y:n,z:i}=this,s=this.equals(zf.ZERO);null==e&&(e=s?Tf:dh(i));const r=e,o=ch(r*r),l=ch(o*r),a=ch(t*o),c=ch(n*l),u=ch(i*r);if(s)return Gf.ZERO;if(u!==Qf)throw new Error("invZ was invalid");return new Gf(a,c)}}function Hf(e,t){const n=t.negate();return e?n:t}zf.BASE=new zf(Lf.Gx,Lf.Gy,Qf),zf.ZERO=new zf(Df,Qf,Df);const qf=new WeakMap;class Gf{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,qf.delete(this)}hasEvenY(){return this.y%Pf===Df}static fromCompressedHex(e){const t=32===e.length,n=oh(t?e:e.subarray(1));if(!hh(n))throw new Error("Point is not on curve");let i=function(e){const{P:t}=Lf,n=BigInt(6),i=BigInt(11),s=BigInt(22),r=BigInt(23),o=BigInt(44),l=BigInt(88),a=e*e*e%t,c=a*a*e%t,u=uh(c,Rf)*c%t,d=uh(u,Rf)*c%t,f=uh(d,Pf)*a%t,h=uh(f,i)*f%t,p=uh(h,s)*h%t,g=uh(p,o)*p%t,m=uh(g,l)*g%t,v=uh(m,o)*p%t,y=uh(v,Rf)*c%t,w=uh(y,r)*h%t,b=uh(w,n)*a%t,A=uh(b,Pf);if(A*A%t!==e)throw new Error("Cannot find square root");return A}(Uf(n));const s=(i&Qf)===Qf;if(t)s&&(i=ch(-i));else{!(1&~e[0])!==s&&(i=ch(-i))}const r=new Gf(n,i);return r.assertValidity(),r}static fromUncompressedHex(e){const t=oh(e.subarray(1,33)),n=oh(e.subarray(33,65)),i=new Gf(t,n);return i.assertValidity(),i}static fromHex(e){const t=lh(e),n=t.length,i=t[0];if(n===Mf)return this.fromCompressedHex(t);if(33===n&&(2===i||3===i))return this.fromCompressedHex(t);if(65===n&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(e){return Gf.BASE.multiply(function(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=rh(e)}else{if(!Wf(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=oh(e)}if(!fh(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:i,s:s}=function(e){if(e instanceof Vf)return e.assertValidity(),e;try{return Vf.fromDER(e)}catch(t){return Vf.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const r=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=oh(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:i}=Lf;return n>=i?n-i:n}(lh(e)),{n:o}=Lf,l=2===n||3===n?i+o:i,a=dh(l,o),c=ch(-r*a,o),u=ch(s*a,o),d=1&n?"03":"02",f=Gf.fromHex(d+ih(l)),h=Gf.BASE.multiplyAndAddUnsafe(f,c,u);if(!h)throw new Error("Cannot recover signature: point at infinify");return h.assertValidity(),h}toRawBytes(e=!1){return th(this.toHex(e))}toHex(e=!1){const t=ih(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${ih(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:n}=this;if(!hh(t)||!hh(n))throw new Error(e);const i=ch(n*n);if(ch(i-Uf(t))!==Df)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Gf(this.x,ch(-this.y))}double(){return zf.fromAffine(this).double().toAffine()}add(e){return zf.fromAffine(this).add(zf.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return zf.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const i=zf.fromAffine(this),s=t===Df||t===Qf||this!==Gf.BASE?i.multiplyUnsafe(t):i.multiply(t),r=zf.fromAffine(e).multiplyUnsafe(n),o=s.add(r);return o.equals(zf.ZERO)?void 0:o.toAffine()}}function Jf(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function Kf(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${Zf(e)}`);const t=e[1],n=e.subarray(2,t+2);if(!t||n.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:oh(n),left:e.subarray(t+2)}}Gf.BASE=new Gf(Lf.Gx,Lf.Gy),Gf.ZERO=new Gf(Df,Df);class Vf{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=Wf(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const i=t?Zf(e):e;if(128!==i.length)throw new Error(`${n}: Expected 64-byte hex`);return new Vf(rh(i.slice(0,64)),rh(i.slice(64,128)))}static fromDER(e){const t=Wf(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:i}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${Zf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=Kf(e.subarray(2)),{data:i,left:s}=Kf(n);if(s.length)throw new Error(`Invalid signature: left bytes after parsing: ${Zf(s)}`);return{r:t,s:i}}(t?e:th(e));return new Vf(n,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!fh(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!fh(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=Lf.n>>Qf;return this.s>e}normalizeS(){return this.hasHighS()?new Vf(this.r,ch(-this.s,Lf.n)):this}toDERRawBytes(){return th(this.toDERHex())}toDERHex(){const e=Jf(sh(this.s)),t=Jf(sh(this.r)),n=e.length/2,i=t.length/2,s=sh(n),r=sh(i);return`30${sh(i+n+4)}02${r}${t}02${s}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return th(this.toCompactHex())}toCompactHex(){return ih(this.r)+ih(this.s)}}function Wf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const Yf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Zf(e){!function(e){if(!Wf(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n<e.length;n++)t+=Yf[e[n]];return t}const Xf={_0:48,_9:57,A:65,F:70,a:97,f:102};function eh(e){return e>=Xf._0&&e<=Xf._9?e-Xf._0:e>=Xf.A&&e<=Xf.F?e-(Xf.A-10):e>=Xf.a&&e<=Xf.f?e-(Xf.a-10):void 0}function th(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,s=0;t<n;t++,s+=2){const n=eh(e.charCodeAt(s)),r=eh(e.charCodeAt(s+1));if(void 0===n||void 0===r){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}i[t]=16*n+r}return i}const nh=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function ih(e){if("bigint"!=typeof e)throw new Error("Expected bigint");if(!(Df<=e&&e<nh))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function sh(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function rh(e){if("string"!=typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function oh(e){return rh(Zf(e))}function lh(e){return Wf(e)?Uint8Array.from(e):th(e)}function ah(e){if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"==typeof e&&fh(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function ch(e,t=Lf.P){const n=e%t;return n>=Df?n:t+n}function uh(e,t){const{P:n}=Lf;let i=e;for(;t-- >Df;)i*=i,i%=n;return i}function dh(e,t=Lf.P){if(e===Df||t<=Df)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=ch(e,t),i=t,s=Df,r=Qf;for(;n!==Df;){const e=i%n,t=s-r*(i/n);i=n,n=e,s=r,r=t}if(i!==Qf)throw new Error("invert: does not exist");return ch(s,t)}function fh(e){return Df<e&&e<Lf.n}function hh(e){return Df<e&&e<Lf.P}Gf.BASE._setWindowSize(8);function ph(e){return Gf.fromHex(e).toHex().substring(2)}const gh=new TextDecoder("utf-8"),mh=new TextEncoder;class vh{log=kd.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=ws;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!vh.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const i=Sf();return this.lastCommand=i,this.sendCommand(e,t),setTimeout(()=>{i.reject(new Error("Device timeout")),this.lastCommand===i&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:i}){let s,r=await window.navigator.serial.requestPort();await r.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;r&&r.readable;){const e=new window.TextDecoderStream;r.readable.pipeTo(e.writable),s=e.readable.getReader();const t=this.readFromSerialPort(s);try{for(;;){const{value:e,done:n}=await t("\n");if(e){const{method:t,data:n}=this.parseResponse(e);if("/ping"===t&&this.log("Pong"),-1===vh.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(i&&i())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const o=new window.TextEncoderStream;o.readable.pipeTo(r.writable),this.writer=o.writable.getWriter(),await this.sendCommand(vh.METHOD_PING),await this.sendCommand(vh.METHOD_PING,[window.location.host]),e&&e(),r.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(i="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const s=[];for(t&&(s.push(t),t=void 0);;){const{value:r,done:o}=await e.read();if(r){const e=r.split(i);if(e.length>1)return s.push(e.shift()),t=e.pop(),n=e,{value:s.join("").trim(),done:!1};s.push(r)}if(o)return{value:s.join("").trim(),done:!0}}}}parseResponse(e){const t=e.split(" ")[0];return{method:t,data:e.substring(t.length).trim()}}async nip04Encrypt(e,t){const n=Gu(await this.callMethodOnDevice(vh.METHOD_SHARED_SECRET,[ph(e)]));let i=Uint8Array.from(function(e=32){if(Ru&&"function"==typeof Ru.getRandomValues)return Ru.getRandomValues(new Uint8Array(e));if(Ru&&"function"==typeof Ru.randomBytes)return Uint8Array.from(Ru.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),s=mh.encode(t),r=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),o=await crypto.subtle.encrypt({name:"AES-CBC",iv:i},r,s);return`${Kd.encode(new Uint8Array(o))}?iv=${Kd.encode(new Uint8Array(i.buffer))}`}async nip04Decrypt(e,t){let[n,i]=t.split("?iv=");const s=Gu(await this.callMethodOnDevice(vh.METHOD_SHARED_SECRET,[ph(e)]));let r=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["decrypt"]),o=Kd.decode(n),l=Kd.decode(i),a=await crypto.subtle.decrypt({name:"AES-CBC",iv:l},r,o);return gh.decode(a)}async getPublicKey(){const e=await this.callMethodOnDevice(vh.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(vh.METHOD_RESTORE,[Nu(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:ps({...e,pubkey:t})},i=await this.callMethodOnDevice(vh.METHOD_SIGN_MESSAGE,[n.id]),s={...n,sig:i,pubkey:t};if(!this.verifyEvent(s))throw new Error("Invalid signature");return s}ping(){this.sendCommand(vh.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[vh.METHOD_PUBLIC_KEY,vh.METHOD_SIGN_MESSAGE,vh.METHOD_SHARED_SECRET,vh.METHOD_RESTORE]}const yh=[];function wh(t,n=e){let i;const s=new Set;function o(e){if(r(t,e)&&(t=e,i)){const e=!yh.length;for(const e of s)e[1](),yh.push(e,t);if(e){for(let e=0;e<yh.length;e+=2)yh[e][0](yh[e+1]);yh.length=0}}}return{set:o,update:function(e){o(e(t))},subscribe:function(r,l=e){const a=[r,l];return s.add(a),1===s.size&&(i=n(o)||e),r(t),()=>{s.delete(a),0===s.size&&i&&(i(),i=null)}}}}function bh(t,n,r){const o=!Array.isArray(t),l=o?[t]:t,c=n.length<2;return u=t=>{let r=!1;const u=[];let d=0,f=e;const h=()=>{if(d)return;f();const i=n(o?u[0]:u,t);c?t(i):f=s(i)?i:e},p=l.map((e,t)=>a(e,e=>{u[t]=e,d&=~(1<<t),r&&h()},()=>{d|=1<<t}));return r=!0,h(),function(){i(p),f(),r=!1}},{subscribe:wh(r,u).subscribe};var u}const Ah=wh(localStorage.getItem("relayUrl")||""),kh=wh(!1),Ih=wh(null),Ch=wh("disconnected"),Eh=wh(!0),xh=localStorage.getItem("savedRelays"),Sh=wh(xh?JSON.parse(xh):[]);Ah.subscribe(e=>{e?localStorage.setItem("relayUrl",e):localStorage.removeItem("relayUrl")}),Sh.subscribe(e=>{localStorage.setItem("savedRelays",JSON.stringify(e))});bh([wh(""),wh("")],([e,t])=>t||e),wh(localStorage.getItem("selectedTab")||"export");const Bh=wh(localStorage.getItem("activeView")||"feed");Bh.subscribe(e=>{e&&localStorage.setItem("activeView",e)});const $h=wh(localStorage.getItem("expandedSection")||null);$h.subscribe(e=>{e?localStorage.setItem("expandedSection",e):localStorage.removeItem("expandedSection")});const Fh=wh(!1),Dh=wh(!1),Qh=wh(!1);function Ph(e,t){Sh.update(n=>{const i=n.findIndex(t=>t.url===e),s={url:e,name:t,lastConnected:Date.now()};return i>=0?n[i]=s:n.unshift(s),n})}const Rh="undefined"!=typeof process&&process.env&&!1,Th=("undefined"!=typeof process&&process.env,"");function Lh(){const e=c(Ah);return e?jh(e):window.location.origin}function _h(){const e=c(Ah);if(e)return zh(e);return`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/`}function Nh(){return[_h()]}function Mh(e){const t=e?jh(e):"";Ah.set(t),t&&kh.set(!0)}async function Uh(e){const t=e?jh(e):Lh();try{Ch.set("connecting");const e=await fetch(t,{headers:{Accept:"application/nostr+json"}});if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);const n=await e.json();if(!n.name&&!n.supported_nips)throw new Error("Invalid relay info response");return Ih.set(n),Ch.set("connected"),n}catch(e){return console.error("[config] Failed to fetch relay info:",e),Ch.set("error"),Ih.set(null),null}}async function Oh(e){if(console.log("[config] connectToRelay called with:",e),!e)return{success:!1,error:"URL is required"};const t=jh(e);console.log("[config] Normalized HTTP URL:",t);const n=await Uh(t);if(console.log("[config] fetchRelayInfoFromUrl returned:",n?"success":"null"),n)return Mh(t),{success:!0,info:n};console.log("[config] NIP-11 failed, trying WebSocket connection test");const i=zh(e);console.log("[config] Normalized WS URL:",i);const s=await async function(e){return console.log("[config] Testing WebSocket connection to:",e),new Promise(t=>{let n=!1,i=null;const s=e=>{n||(n=!0,console.log("[config] WebSocket test result:",e),t(e))},r=setTimeout(()=>{console.log("[config] WebSocket connection timed out"),i&&i.close(),s({success:!1,error:"Connection timed out"})},5e3);try{i=new WebSocket(e),i.onopen=()=>{console.log("[config] WebSocket connected successfully"),clearTimeout(r),i.close(),s({success:!0})},i.onerror=e=>{console.log("[config] WebSocket error:",e),clearTimeout(r),s({success:!1,error:"WebSocket connection failed"})},i.onclose=e=>{console.log("[config] WebSocket closed:",e.code,e.reason),clearTimeout(r),1e3===e.code||n||s({success:!1,error:`Connection closed: ${e.reason||"code "+e.code}`})}}catch(e){console.error("[config] WebSocket creation error:",e),clearTimeout(r),s({success:!1,error:e.message||"Failed to create WebSocket"})}})}(i);if(console.log("[config] WebSocket test complete:",s),s.success){Mh(t),Ch.set("connected");const e={name:i};return Ih.set(e),{success:!0,info:e}}return{success:!1,error:s.error||"Could not connect to relay"}}function jh(e){let t=e.trim();return t.startsWith("wss://")?t="https://"+t.slice(6):t.startsWith("ws://")&&(t="http://"+t.slice(5)),t.startsWith("http://")||t.startsWith("https://")||(t="https://"+t),t.replace(/\/$/,"")}function zh(e){let t=e.trim();return t.startsWith("https://")?t="wss://"+t.slice(8):t.startsWith("http://")&&(t="ws://"+t.slice(7)),t.startsWith("ws://")||t.startsWith("wss://")||(t="wss://"+t),t.endsWith("/")||(t+="/"),t}function Hh(){return Nh()}window.location.protocol.startsWith("https");const qh=["wss://relay.damus.io","wss://nos.lol","wss://relay.nostr.band","wss://purplepag.es"],Gh=[{value:0,label:"User Metadata (0)"},{value:3,label:"Follows (3)"},{value:1e4,label:"Mute list (10000)"},{value:10001,label:"Pin list (10001)"},{value:10002,label:"Relay List Metadata (10002)"},{value:10003,label:"Bookmark list (10003)"},{value:10004,label:"Communities list (10004)"},{value:10005,label:"Public chats list (10005)"},{value:10006,label:"Blocked relays list (10006)"},{value:10007,label:"Search relays list (10007)"},{value:10009,label:"User groups (10009)"},{value:10012,label:"Favorite relays list (10012)"},{value:10013,label:"Private event relay list (10013)"},{value:10015,label:"Interests list (10015)"},{value:10019,label:"Nutzap Mint Recommendation (10019)"},{value:10020,label:"Media follows (10020)"},{value:10030,label:"User emoji list (10030)"},{value:10050,label:"Relay list to receive DMs (10050)"},{value:10051,label:"KeyPackage Relays List (10051)"},{value:10063,label:"User server list (10063)"},{value:10096,label:"File storage server list (10096)"},{value:10166,label:"Relay Monitor Announcement (10166)"},{value:10312,label:"Room Presence (10312)"},{value:10377,label:"Proxy Announcement (10377)"},{value:11111,label:"Transport Method Announcement (11111)"},{value:13194,label:"Wallet Info (13194)"},{value:17375,label:"Cashu Wallet Event (17375)"},{value:3e4,label:"Follow sets (30000)"},{value:30001,label:"Generic lists (30001)"},{value:30002,label:"Relay sets (30002)"},{value:30003,label:"Bookmark sets (30003)"},{value:30004,label:"Curation sets (30004)"},{value:30005,label:"Video sets (30005)"},{value:30007,label:"Kind mute sets (30007)"},{value:30008,label:"Profile Badges (30008)"},{value:30009,label:"Badge Definition (30009)"},{value:30015,label:"Interest sets (30015)"},{value:30017,label:"Create or update a stall (30017)"},{value:30018,label:"Create or update a product (30018)"},{value:30019,label:"Marketplace UI/UX (30019)"},{value:30020,label:"Product sold as an auction (30020)"},{value:30023,label:"Long-form Content (30023)"},{value:30024,label:"Draft Long-form Content (30024)"},{value:30030,label:"Emoji sets (30030)"},{value:30040,label:"Curated Publication Index (30040)"},{value:30041,label:"Curated Publication Content (30041)"},{value:30063,label:"Release artifact sets (30063)"},{value:30078,label:"Application-specific Data (30078)"},{value:30166,label:"Relay Discovery (30166)"},{value:30267,label:"App curation sets (30267)"},{value:30311,label:"Live Event (30311)"},{value:30312,label:"Interactive Room (30312)"},{value:30313,label:"Conference Event (30313)"},{value:30315,label:"User Statuses (30315)"},{value:30388,label:"Slide Set (30388)"},{value:30402,label:"Classified Listing (30402)"},{value:30403,label:"Draft Classified Listing (30403)"},{value:30617,label:"Repository announcements (30617)"},{value:30618,label:"Repository state announcements (30618)"},{value:30818,label:"Wiki article (30818)"},{value:30819,label:"Redirects (30819)"},{value:31234,label:"Draft Event (31234)"},{value:31388,label:"Link Set (31388)"},{value:31890,label:"Feed (31890)"},{value:31922,label:"Date-Based Calendar Event (31922)"},{value:31923,label:"Time-Based Calendar Event (31923)"},{value:31924,label:"Calendar (31924)"},{value:31925,label:"Calendar Event RSVP (31925)"},{value:31989,label:"Handler recommendation (31989)"},{value:31990,label:"Handler information (31990)"},{value:32267,label:"Software Application (32267)"},{value:34550,label:"Community Definition (34550)"},{value:37516,label:"Geocache listing (37516)"},{value:38172,label:"Cashu Mint Announcement (38172)"},{value:38173,label:"Fedimint Announcement (38173)"},{value:38383,label:"Peer-to-peer Order events (38383)"},{value:39089,label:"Starter packs (39089)"},{value:39092,label:"Media starter packs (39092)"},{value:39701,label:"Web bookmarks (39701)"}],Jh={0:"User Metadata",1:"Short Text Note",2:"Recommend Relay",3:"Follows",4:"Encrypted Direct Messages",5:"Event Deletion Request",6:"Repost",7:"Reaction",8:"Badge Award",9:"Chat Message",10:"Group Chat Threaded Reply",11:"Thread",12:"Group Thread Reply",13:"Seal",14:"Direct Message",15:"File Message",16:"Generic Repost",17:"Reaction to a website",20:"Picture",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1021:"Bid",1022:"Bid Confirmation",1040:"OpenTimestamps",1063:"File Metadata",1311:"Live Chat Message",1971:"Problem Tracker",1984:"Reporting",1985:"Label",4550:"Community Post Approval",5e3:"Job Request",5999:"Job Request",6e3:"Job Result",6999:"Job Result",7e3:"Job Feedback",9041:"Zap Goal",9734:"Zap Request",9735:"Zap",9882:"Highlights",1e4:"Mute list",10001:"Pin list",10002:"Relay List Metadata",10003:"Bookmarks list",10004:"Communities list",10005:"Public Chats list",10006:"Blocked Relays list",10007:"Search Relays list",10015:"Interests",10030:"User Emoji list",10050:"DM relays",10096:"File Storage Server List",13194:"Wallet Service Info",21e3:"Lightning pub RPC",22242:"Client Authentication",23194:"Wallet Request",23195:"Wallet Response",23196:"Wallet Notification",23197:"Wallet Notification",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Follow sets",30001:"Generic lists",30002:"Relay sets",30003:"Bookmark sets",30004:"Curation sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest sets",30017:"Stall Definition",30018:"Product Definition",30019:"Marketplace UI/UX",30020:"Product sold as an auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34235:"Video Event Horizontal",34236:"Video Event Vertical",34550:"Community Definition"},Kh=3e5;let Vh=null;function Wh(){return Vh||(Vh=new jn),Vh}class Yh{constructor(){this.pool=new jn,this.eventStore=new xf,this.isConnected=!1,this.signer=null,this.authenticatedRelays=new Set,this.relays=[...Hh()]}refreshRelays(){const e=Hh();JSON.stringify(this.relays)!==JSON.stringify(e)&&(console.log("Relay list updated:",e),this.relays=[...e])}reset(){if(console.log("[NostrClient] Resetting for new relay..."),this.pool){try{this.pool.close(this.relays)}catch(e){console.warn("[NostrClient] Error closing old relay connections:",e)}this.pool=null}this.pool=new jn,this.isConnected=!1,this.relays=[...Hh()],console.log("[NostrClient] Reset complete, new relays:",this.relays)}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async authenticateToRelay(e){if(!this.signer)return console.warn("No signer available for auth"),!1;if(this.authenticatedRelays.has(e))return!0;try{const t=await this.pool.ensureRelay(e),n={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t.challenge||""]],content:""},i=await this.signer.signEvent(n);return await t.auth(i),this.authenticatedRelays.add(e),console.log("✓ Authenticated to relay:",e),!0}catch(t){return console.warn("✗ Failed to authenticate to relay:",e,t),!1}}async publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());const n=t||this.relays;let i=await this._tryPublish(e,n);const s=[];for(let e=0;e<i.length;e++){const t=i[e];"rejected"===t.status&&t.reason?.message?.includes("auth-required")&&s.push(n[e])}if(s.length>0&&this.signer){console.log("Auth required for relays:",s);for(const e of s)await this.authenticateToRelay(e);const t=await this._tryPublish(e,s);for(let e=0;e<s.length;e++){const r=n.indexOf(s[e]);r>=0&&(i[r]=t[e])}}let r=0,o=0;for(const e of i)"fulfilled"===e.status?(r++,console.log("✓ Event accepted by relay")):(o++,console.warn("✗ Relay rejected event:",e.reason));if(0===r)throw new Error(`Event rejected by all ${o} relays`);return console.log(`✓ Event published: ${r} OK, ${o} failed`),await rp([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:r,errorCount:o,event:e}}async _tryPublish(e,t){try{const n=this.pool.publish(t,e);return await Promise.allSettled(n)}catch(e){throw console.error("✗ Failed to publish event:",e),e}}async countEvents(e,t){const n=await this.pool.ensureRelay(e);return await n.count(t)}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const Zh=new Yh;function Xh(e,t){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of t){const t=n.get(e.id);(!t||e.created_at>=t.created_at)&&n.set(e.id,e)}return Array.from(n.values()).sort((e,t)=>t.created_at-e.created_at)}const ep="nostrCache",tp=2,np="events";function ip(){return new Promise((e,t)=>{try{const n=indexedDB.open(ep,tp);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let i;i=t.objectStoreNames.contains(np)?n.transaction.objectStore(np):t.createObjectStore(np,{keyPath:"id"}),i.indexNames.contains("byKindAuthor")||i.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),i.indexNames.contains("byKindAuthorCreated")||i.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),i.indexNames.contains("byKind")||i.createIndex("byKind","kind",{unique:!1}),i.indexNames.contains("byAuthor")||i.createIndex("byAuthor","pubkey",{unique:!1}),i.indexNames.contains("byCreatedAt")||i.createIndex("byCreatedAt","created_at",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){console.error("Failed to open IndexedDB",e),t(e)}})}async function sp(e){try{const t=await ip();await new Promise((n,i)=>{const s=t.transaction(np,"readwrite");s.oncomplete=()=>n(),s.onerror=()=>i(s.error),s.objectStore(np).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function rp(e){if(e&&0!==e.length)try{const t=await ip();await new Promise((n,i)=>{const s=t.transaction(np,"readwrite");s.oncomplete=()=>n(),s.onerror=()=>i(s.error);const r=s.objectStore(np);for(const t of e)r.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function op(e){try{const t=await ip(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const i of e){console.log("QueryEventsFromDB: Processing filter:",i);const e=await new Promise((e,n)=>{const s=t.transaction(np,"readonly").objectStore(np),r=[];let o;if(i.kinds&&i.kinds.length>0&&i.authors&&i.authors.length>0){const e=i.kinds[0],t=i.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=s.index("byKindAuthorCreated"),r=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);o=n.openCursor(r,"prev")}else if(i.kinds&&i.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${i.kinds[0]}`);const e=s.index("byKind");o=e.openCursor(IDBKeyRange.only(i.kinds[0]))}else if(i.authors&&i.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${i.authors[0].substring(0,8)}...`);const e=s.index("byAuthor");o=e.openCursor(IDBKeyRange.only(i.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),o=s.openCursor();o.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let s=!0;if(i.kinds&&i.kinds.length>0&&!i.kinds.includes(t.kind)&&(s=!1),i.authors&&i.authors.length>0&&!i.authors.includes(t.pubkey)&&(s=!1),i.since&&t.created_at<i.since&&(s=!1),i.until&&t.created_at>i.until&&(s=!1),i.ids&&i.ids.length>0&&!i.ids.includes(t.id)&&(s=!1),s&&r.push(t),i.limit&&r.length>=i.limit)return console.log(`QueryEventsFromDB: Reached limit of ${i.limit}, found ${r.length} matching events`),void e(r);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${r.length} matching events`),e(r)},o.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",o.error),n(o.error)}});console.log(`QueryEventsFromDB: Found ${e.length} events for this filter`),n.push(...e)}return n.sort((e,t)=>t.created_at-e.created_at),console.log(`QueryEventsFromDB: Returning ${n.length} total events`),n}catch(e){return console.error("QueryEventsFromDB failed:",e),[]}}function lp(e){try{const t=JSON.parse(e.content||"{}");return{name:t.name||t.display_name||"",picture:t.picture||"",banner:t.banner||"",about:t.about||"",nip05:t.nip05||"",lud16:t.lud16||t.lud06||""}}catch(e){return{name:"",picture:"",banner:"",about:"",nip05:"",lud16:""}}}async function ap(e){console.log(`Starting profile fetch for pubkey: ${e}`),console.log("[fetchUserProfile] Current relay list:",Zh.relays);try{const t=await async function(e){try{const t=await ip();return await new Promise((n,i)=>{const s=t.transaction(np,"readonly").objectStore(np).index("byKindAuthorCreated"),r=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),o=s.openCursor(r,"prev");o.onsuccess=()=>{const e=o.result;n(e?e.value:null)},o.onerror=()=>i(o.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return lp(t)}}catch(e){console.warn("Failed to load cached profile",e)}const t=[{kinds:[0],authors:[e],limit:1}];try{const n=await gp(t,{timeout:1e4});if(n.length>0){const t=n[0];return console.log("Profile fetched from local relay:",t),cp(t,e)}}catch(e){console.warn("Failed to fetch profile from local relay:",e)}console.log("Profile not found on local relay, trying fallback relays:",qh);try{const n=await async function(e,t){return console.log("[fetchProfileFromFallbackRelays] Querying fallback relays:",qh),console.log("[fetchProfileFromFallbackRelays] Using filters:",JSON.stringify(t)),new Promise(e=>{const n=[],i=Wh();let s;const r=setTimeout(()=>{s&&s.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),e(n[0])):e(null)},5e3);s=i.subscribeMany(qh,t,{onevent(e){console.log("[fetchProfileFromFallbackRelays] Event received:",e.id?.substring(0,8),"kind:",e.kind,"pubkey:",e.pubkey?.substring(0,8)),n.push(e)},oneose(){console.log(`[fetchProfileFromFallbackRelays] EOSE received, got ${n.length} events`),clearTimeout(r),s&&s.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),console.log("[fetchProfileFromFallbackRelays] Returning best event:",n[0].id?.substring(0,8)),e(n[0])):(console.log("[fetchProfileFromFallbackRelays] No events found"),e(null))}})})}(0,t);if(n)return cp(n,e)}catch(e){console.warn("Failed to fetch profile from fallback relays:",e)}return console.log("No profile found for pubkey:",e),null}async function cp(e,t){await sp(e);try{console.log("Publishing profile event to local relay:",e.id),await Zh.publish(e),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const n=lp(e);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:t,profile:n,event:e}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return n}async function up(e){console.log(`[nostr] Fetching relay list for pubkey: ${e?.substring(0,8)}...`);const t=[{kinds:[10002],authors:[e],limit:1}];try{const e=await gp(t,{timeout:1e4,useCache:!0});if(e.length>0){const t=e.sort((e,t)=>t.created_at-e.created_at)[0];return console.log("[nostr] Relay list found on local relay"),dp(t)}}catch(e){console.warn("[nostr] Failed to fetch relay list from local relay:",e)}console.log("[nostr] Relay list not found locally, trying fallback relays...");try{const e=await fp(t);if(e){await sp(e);try{await Zh.publish(e)}catch(e){console.warn("[nostr] Failed to publish relay list to local relay:",e)}return dp(e)}}catch(e){console.warn("[nostr] Failed to fetch relay list from fallback relays:",e)}return console.log("[nostr] No relay list found for pubkey"),null}function dp(e){if(!e||10002!==e.kind)return null;const t={read:[],write:[],all:[]};for(const n of e.tags)if("r"===n[0]&&n[1]){const e=n[1],i=n[2];"read"===i?t.read.push(e):("write"===i||t.read.push(e),t.write.push(e)),t.all.push({url:e,read:"write"!==i,write:"read"!==i})}return console.log(`[nostr] Parsed relay list: ${t.all.length} relays`),t}async function fp(e){return new Promise(t=>{const n=[],i=Wh();let s;const r=setTimeout(()=>{s&&s.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),t(n[0])):t(null)},5e3);s=i.subscribeMany(qh,e,{onevent(e){n.push(e)},oneose(){clearTimeout(r),s&&s.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),t(n[0])):t(null)}})})}async function hp(e){console.log(`[nostr] Fetching contact list for pubkey: ${e?.substring(0,8)}...`);const t=[{kinds:[3],authors:[e],limit:1}];try{const e=await gp(t,{timeout:1e4,useCache:!0});if(e.length>0){const t=e.sort((e,t)=>t.created_at-e.created_at)[0];return console.log("[nostr] Contact list found on local relay"),pp(t)}}catch(e){console.warn("[nostr] Failed to fetch contact list from local relay:",e)}console.log("[nostr] Contact list not found locally, trying fallback relays...");try{const e=await fp(t);if(e){await sp(e);try{await Zh.publish(e)}catch(e){console.warn("[nostr] Failed to publish contact list to local relay:",e)}return pp(e)}}catch(e){console.warn("[nostr] Failed to fetch contact list from fallback relays:",e)}return console.log("[nostr] No contact list found for pubkey"),null}function pp(e){if(!e||3!==e.kind)return null;const t=[],n={};for(const i of e.tags)if("p"===i[0]&&i[1]){const e=i[1],s=i[2]||null,r=i[3]||null;t.push({pubkey:e,relayUrl:s,petname:r}),s&&(n[s]||(n[s]=[]),n[s].push(e))}let i={};try{e.content&&(i=JSON.parse(e.content))}catch(e){}return console.log(`[nostr] Parsed contact list: ${t.length} follows, ${Object.keys(n).length} relay hints`),{follows:t,relayHints:n,legacyRelays:i,event:e}}async function gp(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",Zh.relays),Zh.isConnected&&0!==Zh.relays.length||(console.warn("Client not connected, initializing..."),await bp());const{timeout:n=3e4,useCache:i=!0}=t;let s=[];if(i)try{s=await op(e),s.length>0&&console.log(`Found ${s.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,i)=>{const r=[];let o=null;const l=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${r.length} relay events`),o&&o.close(),r.length>0&&rp(r).catch(e=>console.warn("Failed to cache events",e));const e=Xh(s,r);t(e)},n);try{const n=Math.random().toString(36).substring(7);if(!Array.isArray(e)||0===e.length)return console.error("❌ Invalid filters: not an array or empty",e),void t(s);const i=e.filter(e=>e&&"object"==typeof e&&!Array.isArray(e));if(i.length!==e.length&&console.warn(`⚠️ Some filters were invalid, filtered ${e.length} -> ${i.length}`,e),0===i.length)return console.error("❌ No valid filters remaining"),void t(s);console.log(`📤 REQ [${n}] to ${Zh.relays.join(", ")}:`,JSON.stringify(["REQ",n,...i],null,2)),o=Zh.pool.subscribeMany(Zh.relays,i,{onevent(e){console.log(`📥 EVENT received for REQ [${n}]:`,{id:e.id?.substring(0,8)+"...",kind:e.kind,pubkey:e.pubkey?.substring(0,8)+"...",created_at:e.created_at,content_preview:e.content?.substring(0,50)}),r.push(e),sp(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${r.length} relay events`),clearTimeout(l),o&&o.close(),r.length>0&&rp(r).catch(e=>console.warn("Failed to cache events",e));const e=Xh(s,r);console.log(`Merged ${s.length} cached + ${r.length} relay = ${e.length} total events`),t(e)}})}catch(e){clearTimeout(l),console.error("Failed to fetch events:",e),i(e)}})}async function mp(e={}){const{limit:t=100,since:n=null,until:i=null,authors:s=null,kinds:r=null,...o}=e,l=Math.floor(Date.now()/1e3),a=n||l-15768e4,c=[{...o}];c[0].since=a,i&&(c[0].until=i),s&&(c[0].authors=s),r&&(c[0].kinds=r),t&&(c[0].limit=t);return await gp(c,{timeout:3e4})}async function vp(e,t={}){const{limit:n=100,since:i=null,until:s=null}=t,r=[{authors:[e]}];i&&(r[0].since=i),s&&(r[0].until=s),n&&(r[0].limit=n);return await gp(r,{timeout:3e4})}async function yp(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const i=await gp(t,{timeout:n});return console.log(`Fetched ${i.length} events`),i.length>0?i[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function wp(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const i=await gp(t,{timeout:n});return console.log(`Fetched ${i.length} delete events`),i}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function bp(){Zh.refreshRelays(),await Zh.connect()}async function Ap(e,t={}){const{timeout:n=3e4,cacheFirst:i=!0,cacheOnly:s=!1}=t;let r=[];if(i||s)try{if(r=await op(e),console.log(`Found ${r.length} events in cache`),s||r.length>0)return r}catch(e){console.warn("Failed to query cache",e)}if(!s){const t=await gp(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return r}async function kp(){console.log("[nostr] Clearing IndexedDB cache...");try{const e=await ip(),t=e.transaction(np,"readwrite").objectStore(np);await new Promise((e,n)=>{const i=t.clear();i.onsuccess=()=>e(),i.onerror=()=>n(i.error)}),console.log("[nostr] IndexedDB cache cleared")}catch(e){console.warn("[nostr] Failed to clear IndexedDB cache",e)}}async function Ip(){try{const e=await ip(),t=e.transaction(np,"readonly").objectStore(np),n=await new Promise((e,n)=>{const i=t.getAll();i.onsuccess=()=>e(i.result),i.onerror=()=>n(i.error)}),i=n.reduce((e,t)=>(e[t.kind]=(e[t.kind]||0)+1,e),{});return console.log("===== IndexedDB Contents ====="),console.log(`Total events: ${n.length}`),console.log("Events by kind:",i),console.log("Kind 0 events:",n.filter(e=>0===e.kind)),console.log("All event IDs:",n.map(e=>({id:e.id.substring(0,8),kind:e.kind,pubkey:e.pubkey.substring(0,8)}))),console.log("=============================="),{total:n.length,byKind:i,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}}var Cp,Ep=Object.freeze({__proto__:null,NostrClient:Yh,PrivateKeySigner:Ff,clearIndexedDBCache:kp,debugIndexedDB:Ip,fetchAllEvents:mp,fetchDeleteEventsByTarget:wp,fetchEventById:yp,fetchEvents:gp,fetchUserContactList:hp,fetchUserEvents:vp,fetchUserProfile:ap,fetchUserRelayList:up,initializeNostrClient:bp,nostrClient:Zh,queryEvents:Ap,queryEventsFromDB:op});
  19  /*!
  20       * hash-wasm (https://www.npmjs.com/package/hash-wasm)
  21       * (c) Dani Biro
  22       * @license MIT
  23       */function xp(e,t,n,i){return new(n||(n=Promise))(function(s,r){function o(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,l)}a((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class Sp{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then(()=>new Promise(e)),new Promise(t=>{e=t})}dispatch(e){return xp(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}const Bp="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,$p=null!==(Cp=Bp.Buffer)&&void 0!==Cp?Cp:null,Fp=Bp.TextEncoder?new Bp.TextEncoder:null;function Dp(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function Qp(e,t){const n=t.length>>1;for(let i=0;i<n;i++){const n=i<<1;e[i]=Dp(t.charCodeAt(n),t.charCodeAt(n+1))}}const Pp="a".charCodeAt(0)-10,Rp="0".charCodeAt(0);function Tp(e,t,n){let i=0;for(let s=0;s<n;s++){let n=t[s]>>>4;e[i++]=n>9?n+Pp:n+Rp,n=15&t[s],e[i++]=n>9?n+Pp:n+Rp}return String.fromCharCode.apply(null,e)}const Lp=null!==$p?e=>{if("string"==typeof e){const t=$p.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if($p.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return Fp.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},_p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Np=new Uint8Array(256);for(let e=0;e<64;e++)Np[_p.charCodeAt(e)]=e;function Mp(e,t=!0){const n=e.length,i=n%3,s=[],r=n-i;for(let t=0;t<r;t+=3){const n=(e[t]<<16&16711680)+(e[t+1]<<8&65280)+(255&e[t+2]),i=_p.charAt(n>>18&63)+_p.charAt(n>>12&63)+_p.charAt(n>>6&63)+_p.charAt(63&n);s.push(i)}if(1===i){const i=e[n-1],r=_p.charAt(i>>2),o=_p.charAt(i<<4&63);s.push(`${r}${o}`),t&&s.push("==")}else if(2===i){const i=(e[n-2]<<8)+e[n-1],r=_p.charAt(i>>10),o=_p.charAt(i>>4&63),l=_p.charAt(i<<2&63);s.push(`${r}${o}${l}`),t&&s.push("=")}return s.join("")}function Up(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,i=new Uint8Array(t);let s=0;for(let t=0;t<n;t+=4){const n=Np[e.charCodeAt(t)],r=Np[e.charCodeAt(t+1)],o=Np[e.charCodeAt(t+2)],l=Np[e.charCodeAt(t+3)];i[s]=n<<2|r>>4,s+=1,i[s]=(15&r)<<4|o>>2,s+=1,i[s]=(3&o)<<6|63&l,s+=1}return i}const Op=16384,jp=new Sp,zp=new Map;function Hp(e,t){return xp(this,void 0,void 0,function*(){let n=null,i=null,s=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const r=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),o=jp.dispatch(()=>xp(this,void 0,void 0,function*(){if(!zp.has(e.name)){const t=Up(e.data),n=WebAssembly.compile(t);zp.set(e.name,n)}const t=yield zp.get(e.name);n=yield WebAssembly.instantiate(t,{})})),l=(e=null)=>{s=!0,n.exports.Hash_Init(e)},a=e=>{if(!s)throw new Error("update() called before init()");(e=>{let t=0;for(;t<e.length;){const s=e.subarray(t,t+Op);t+=s.length,i.set(s),n.exports.Hash_Update(s.length)}})(Lp(e))},c=new Uint8Array(2*t),u=(e,r=null)=>{if(!s)throw new Error("digest() called before init()");return s=!1,n.exports.Hash_Final(r),"binary"===e?i.slice(0,t):Tp(c,i,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength<Op;let f=d;switch(e.name){case"argon2":case"scrypt":f=()=>!0;break;case"blake2b":case"blake2s":f=(e,t)=>t<=512&&d(e);break;case"blake3":f=(e,t)=>0===t&&d(e);break;case"xxhash64":case"xxhash3":case"xxhash128":case"crc64":f=()=>!1}return yield(()=>xp(this,void 0,void 0,function*(){n||(yield o);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;i=new Uint8Array(t,e,Op)}))(),{getMemory:()=>i,writeMemory:(e,t=0)=>{i.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),s=n.exports.memory.buffer;i=new Uint8Array(s,t,e)},init:l,update:a,digest:u,save:()=>{if(!s)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),i=r(),o=n.exports.memory.buffer,l=new Uint8Array(o,t,i),a=new Uint8Array(4+i);return Qp(a,e.hash),a.set(l,4),a},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const i=n.exports.Hash_GetState(),o=r(),l=4+o,a=n.exports.memory.buffer;if(t.length!==l)throw new Error(`Bad state length (expected ${l} bytes, got ${t.length})`);if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n<t.length;n++){const i=n<<1;if(t[n]!==Dp(e.charCodeAt(i),e.charCodeAt(i+1)))return!1}return!0}(e.hash,t.subarray(0,4)))throw new Error("This state was written by an incompatible hash implementation");const c=t.subarray(4);new Uint8Array(a,i,o).set(c),s=!0},calculate:(e,s=null,r=null)=>{if(!f(e,s))return l(s),a(e),u("hex",r);const o=Lp(e);return i.set(o),n.exports.Hash_Calculate(o.length,s,r),Tp(c,i,t)},hashLength:t}})}new Sp;var qp={name:"argon2",data:"AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGFNwOQCUEAIAIpA4gBIAEpA4gBhTcDmAlBACACKQOQASABKQOQAYU3A6AJQQAgAikDmAEgASkDmAGFNwOoCUEAIAIpA6ABIAEpA6ABhTcDsAlBACACKQOoASABKQOoAYU3A7gJQQAgAikDsAEgASkDsAGFNwPACUEAIAIpA7gBIAEpA7gBhTcDyAlBACACKQPAASABKQPAAYU3A9AJQQAgAikDyAEgASkDyAGFNwPYCUEAIAIpA9ABIAEpA9ABhTcD4AlBACACKQPYASABKQPYAYU3A+gJQQAgAikD4AEgASkD4AGFNwPwCUEAIAIpA+gBIAEpA+gBhTcD+AlBACACKQPwASABKQPwAYU3A4AKQQAgAikD+AEgASkD+AGFNwOICkEAIAIpA4ACIAEpA4AChTcDkApBACACKQOIAiABKQOIAoU3A5gKQQAgAikDkAIgASkDkAKFNwOgCkEAIAIpA5gCIAEpA5gChTcDqApBACACKQOgAiABKQOgAoU3A7AKQQAgAikDqAIgASkDqAKFNwO4CkEAIAIpA7ACIAEpA7AChTcDwApBACACKQO4AiABKQO4AoU3A8gKQQAgAikDwAIgASkDwAKFNwPQCkEAIAIpA8gCIAEpA8gChTcD2ApBACACKQPQAiABKQPQAoU3A+AKQQAgAikD2AIgASkD2AKFNwPoCkEAIAIpA+ACIAEpA+AChTcD8ApBACACKQPoAiABKQPoAoU3A/gKQQAgAikD8AIgASkD8AKFNwOAC0EAIAIpA/gCIAEpA/gChTcDiAtBACACKQOAAyABKQOAA4U3A5ALQQAgAikDiAMgASkDiAOFNwOYC0EAIAIpA5ADIAEpA5ADhTcDoAtBACACKQOYAyABKQOYA4U3A6gLQQAgAikDoAMgASkDoAOFNwOwC0EAIAIpA6gDIAEpA6gDhTcDuAtBACACKQOwAyABKQOwA4U3A8ALQQAgAikDuAMgASkDuAOFNwPIC0EAIAIpA8ADIAEpA8ADhTcD0AtBACACKQPIAyABKQPIA4U3A9gLQQAgAikD0AMgASkD0AOFNwPgC0EAIAIpA9gDIAEpA9gDhTcD6AtBACACKQPgAyABKQPgA4U3A/ALQQAgAikD6AMgASkD6AOFNwP4C0EAIAIpA/ADIAEpA/ADhTcDgAxBACACKQP4AyABKQP4A4U3A4gMQQAgAikDgAQgASkDgASFNwOQDEEAIAIpA4gEIAEpA4gEhTcDmAxBACACKQOQBCABKQOQBIU3A6AMQQAgAikDmAQgASkDmASFNwOoDEEAIAIpA6AEIAEpA6AEhTcDsAxBACACKQOoBCABKQOoBIU3A7gMQQAgAikDsAQgASkDsASFNwPADEEAIAIpA7gEIAEpA7gEhTcDyAxBACACKQPABCABKQPABIU3A9AMQQAgAikDyAQgASkDyASFNwPYDEEAIAIpA9AEIAEpA9AEhTcD4AxBACACKQPYBCABKQPYBIU3A+gMQQAgAikD4AQgASkD4ASFNwPwDEEAIAIpA+gEIAEpA+gEhTcD+AxBACACKQPwBCABKQPwBIU3A4ANQQAgAikD+AQgASkD+ASFNwOIDUEAIAIpA4AFIAEpA4AFhTcDkA1BACACKQOIBSABKQOIBYU3A5gNQQAgAikDkAUgASkDkAWFNwOgDUEAIAIpA5gFIAEpA5gFhTcDqA1BACACKQOgBSABKQOgBYU3A7ANQQAgAikDqAUgASkDqAWFNwO4DUEAIAIpA7AFIAEpA7AFhTcDwA1BACACKQO4BSABKQO4BYU3A8gNQQAgAikDwAUgASkDwAWFNwPQDUEAIAIpA8gFIAEpA8gFhTcD2A1BACACKQPQBSABKQPQBYU3A+ANQQAgAikD2AUgASkD2AWFNwPoDUEAIAIpA+AFIAEpA+AFhTcD8A1BACACKQPoBSABKQPoBYU3A/gNQQAgAikD8AUgASkD8AWFNwOADkEAIAIpA/gFIAEpA/gFhTcDiA5BACACKQOABiABKQOABoU3A5AOQQAgAikDiAYgASkDiAaFNwOYDkEAIAIpA5AGIAEpA5AGhTcDoA5BACACKQOYBiABKQOYBoU3A6gOQQAgAikDoAYgASkDoAaFNwOwDkEAIAIpA6gGIAEpA6gGhTcDuA5BACACKQOwBiABKQOwBoU3A8AOQQAgAikDuAYgASkDuAaFNwPIDkEAIAIpA8AGIAEpA8AGhTcD0A5BACACKQPIBiABKQPIBoU3A9gOQQAgAikD0AYgASkD0AaFNwPgDkEAIAIpA9gGIAEpA9gGhTcD6A5BACACKQPgBiABKQPgBoU3A/AOQQAgAikD6AYgASkD6AaFNwP4DkEAIAIpA/AGIAEpA/AGhTcDgA9BACACKQP4BiABKQP4BoU3A4gPQQAgAikDgAcgASkDgAeFNwOQD0EAIAIpA4gHIAEpA4gHhTcDmA9BACACKQOQByABKQOQB4U3A6APQQAgAikDmAcgASkDmAeFNwOoD0EAIAIpA6AHIAEpA6AHhTcDsA9BACACKQOoByABKQOoB4U3A7gPQQAgAikDsAcgASkDsAeFNwPAD0EAIAIpA7gHIAEpA7gHhTcDyA9BACACKQPAByABKQPAB4U3A9APQQAgAikDyAcgASkDyAeFNwPYD0EAIAIpA9AHIAEpA9AHhTcD4A9BACACKQPYByABKQPYB4U3A+gPQQAgAikD4AcgASkD4AeFNwPwD0EAIAIpA+gHIAEpA+gHhTcD+A9BACACKQPwByABKQPwB4U3A4AQQQAgAikD+AcgASkD+AeFNwOIEEGQCEGYCEGgCEGoCEGwCEG4CEHACEHICEHQCEHYCEHgCEHoCEHwCEH4CEGACUGICRACQZAJQZgJQaAJQagJQbAJQbgJQcAJQcgJQdAJQdgJQeAJQegJQfAJQfgJQYAKQYgKEAJBkApBmApBoApBqApBsApBuApBwApByApB0ApB2ApB4ApB6ApB8ApB+ApBgAtBiAsQAkGQC0GYC0GgC0GoC0GwC0G4C0HAC0HIC0HQC0HYC0HgC0HoC0HwC0H4C0GADEGIDBACQZAMQZgMQaAMQagMQbAMQbgMQcAMQcgMQdAMQdgMQeAMQegMQfAMQfgMQYANQYgNEAJBkA1BmA1BoA1BqA1BsA1BuA1BwA1ByA1B0A1B2A1B4A1B6A1B8A1B+A1BgA5BiA4QAkGQDkGYDkGgDkGoDkGwDkG4DkHADkHIDkHQDkHYDkHgDkHoDkHwDkH4DkGAD0GIDxACQZAPQZgPQaAPQagPQbAPQbgPQcAPQcgPQdAPQdgPQeAPQegPQfAPQfgPQYAQQYgQEAJBkAhBmAhBkAlBmAlBkApBmApBkAtBmAtBkAxBmAxBkA1BmA1BkA5BmA5BkA9BmA8QAkGgCEGoCEGgCUGoCUGgCkGoCkGgC0GoC0GgDEGoDEGgDUGoDUGgDkGoDkGgD0GoDxACQbAIQbgIQbAJQbgJQbAKQbgKQbALQbgLQbAMQbgMQbANQbgNQbAOQbgOQbAPQbgPEAJBwAhByAhBwAlByAlBwApByApBwAtByAtBwAxByAxBwA1ByA1BwA5ByA5BwA9ByA8QAkHQCEHYCEHQCUHYCUHQCkHYCkHQC0HYC0HQDEHYDEHQDUHYDUHQDkHYDkHQD0HYDxACQeAIQegIQeAJQegJQeAKQegKQeALQegLQeAMQegMQeANQegNQeAOQegOQeAPQegPEAJB8AhB+AhB8AlB+AlB8ApB+ApB8AtB+AtB8AxB+AxB8A1B+A1B8A5B+A5B8A9B+A8QAkGACUGICUGACkGICkGAC0GIC0GADEGIDEGADUGIDUGADkGIDkGAD0GID0GAEEGIEBACAkACQCADRQ0AA0AgACAEaiIDIAIgBGoiBSkDACABIARqIgYpAwCFIARBkAhqKQMAhSADKQMAhTcDACADQQhqIgMgBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIUgAykDAIU3AwAgBEEQaiIEQYAIRw0ADAILC0EAIQQDQCAAIARqIgMgAiAEaiIFKQMAIAEgBGoiBikDAIUgBEGQCGopAwCFNwMAIANBCGogBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIU3AwAgBEEQaiIEQYAIRw0ACwsL5QcMBX8BfgR/An4BfwF+AX8Bfgd/AX4DfwF+AkBBACgCgAgiAiABQQp0aiIDKAIIIAFHDQAgAygCDCEEIAMoAgAhBUEAIAMoAhQiBq03A7gQQQAgBK0iBzcDsBBBACAFIAEgBUECdG4iCGwiCUECdK03A6gQAkACQAJAAkAgBEUNAEF/IQogBUUNASAIQQNsIQsgCEECdCIErSEMIAWtIQ0gBkF/akECSSEOQgAhDwNAQQAgDzcDkBAgD6chEEIAIRFBACEBA0BBACARNwOgECAPIBGEUCIDIA5xIRIgBkEBRiAPUCITIAZBAkYgEUICVHFxciEUQX8gAUEBakEDcSAIbEF/aiATGyEVIAEgEHIhFiABIAhsIRcgA0EBdCEYQgAhGQNAQQBCADcDwBBBACAZNwOYECAYIQECQCASRQ0AQQBCATcDwBBBkBhBkBBBkCBBABADQZAYQZAYQZAgQQAQA0ECIQELAkAgASAITw0AIAQgGaciGmwgF2ogAWohAwNAIANBACAEIAEbQQAgEVAiGxtqQX9qIRwCQAJAIBQNAEEAKAKACCICIBxBCnQiHGohCgwBCwJAIAFB/wBxIgINAEEAQQApA8AQQgF8NwPAEEGQGEGQEEGQIEEAEANBkBhBkBhBkCBBABADCyAcQQp0IRwgAkEDdEGQGGohCkEAKAKACCECCyACIANBCnRqIAIgHGogAiAKKQMAIh1CIIinIAVwIBogFhsiHCAEbCABIAFBACAZIBytUSIcGyIKIBsbIBdqIAogC2ogExsgAUUgHHJrIhsgFWqtIB1C/////w+DIh0gHX5CIIggG61+QiCIfSAMgqdqQQp0akEBEAMgA0EBaiEDIAggAUEBaiIBRw0ACwsgGUIBfCIZIA1SDQALIBFCAXwiEachASARQgRSDQALIA9CAXwiDyAHUg0AC0EAKAKACCECCyAJQQx0QYB4aiEXIAVBf2oiCkUNAgwBC0EAQgM3A6AQQQAgBEF/aq03A5AQQYB4IRcLIAIgF2ohGyAIQQx0IQhBACEcA0AgCCAcQQFqIhxsQYB4aiEEQQAhAQNAIBsgAWoiAyADKQMAIAIgBCABamopAwCFNwMAIANBCGoiAyADKQMAIAIgBCABQQhyamopAwCFNwMAIAFBCGohAyABQRBqIQEgA0H4B0kNAAsgHCAKRw0ACwsgAiAXaiEbQXghAQNAIAIgAWoiA0EIaiAbIAFqIgRBCGopAwA3AwAgA0EQaiAEQRBqKQMANwMAIANBGGogBEEYaikDADcDACADQSBqIARBIGopAwA3AwAgAUEgaiIBQfgHSQ0ACwsL",hash:"e4cdc523"},Gp={name:"blake2b",data:"AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX8AYAAAAwoJAAECAwECAgABBQQBAQICBg4CfwFBsIsFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACkhhc2hfRmluYWwAAwlIYXNoX0luaXQABQtIYXNoX1VwZGF0ZQAGDUhhc2hfR2V0U3RhdGUABw5IYXNoX0NhbGN1bGF0ZQAIClNUQVRFX1NJWkUDAQrTOAkFAEGACQvrAgIFfwF+AkAgAUEBSA0AAkACQAJAIAFBgAFBACgC4IoBIgJrIgNKDQAgASEEDAELQQBBADYC4IoBAkAgAkH/AEoNACACQeCJAWohBSAAIQRBACEGA0AgBSAELQAAOgAAIARBAWohBCAFQQFqIQUgAyAGQQFqIgZB/wFxSg0ACwtBAEEAKQPAiQEiB0KAAXw3A8CJAUEAQQApA8iJASAHQv9+Vq18NwPIiQFB4IkBEAIgACADaiEAAkAgASADayIEQYEBSA0AIAIgAWohBQNAQQBBACkDwIkBIgdCgAF8NwPAiQFBAEEAKQPIiQEgB0L/flatfDcDyIkBIAAQAiAAQYABaiEAIAVBgH9qIgVBgAJLDQALIAVBgH9qIQQMAQsgBEEATA0BC0EAIQUDQCAFQQAoAuCKAWpB4IkBaiAAIAVqLQAAOgAAIAQgBUEBaiIFQf8BcUoNAAsLQQBBACgC4IoBIARqNgLgigELC78uASR+QQBBACkD0IkBQQApA7CJASIBQQApA5CJAXwgACkDICICfCIDhULr+obav7X2wR+FQiCJIgRCq/DT9K/uvLc8fCIFIAGFQiiJIgYgA3wgACkDKCIBfCIHIASFQjCJIgggBXwiCSAGhUIBiSIKQQApA8iJAUEAKQOoiQEiBEEAKQOIiQF8IAApAxAiA3wiBYVCn9j52cKR2oKbf4VCIIkiC0K7zqqm2NDrs7t/fCIMIASFQiiJIg0gBXwgACkDGCIEfCIOfCAAKQNQIgV8Ig9BACkDwIkBQQApA6CJASIQQQApA4CJASIRfCAAKQMAIgZ8IhKFQtGFmu/6z5SH0QCFQiCJIhNCiJLznf/M+YTqAHwiFCAQhUIoiSIVIBJ8IAApAwgiEHwiFiAThUIwiSIXhUIgiSIYQQApA9iJAUEAKQO4iQEiE0EAKQOYiQF8IAApAzAiEnwiGYVC+cL4m5Gjs/DbAIVCIIkiGkLx7fT4paf9p6V/fCIbIBOFQiiJIhwgGXwgACkDOCITfCIZIBqFQjCJIhogG3wiG3wiHSAKhUIoiSIeIA98IAApA1giCnwiDyAYhUIwiSIYIB18Ih0gDiALhUIwiSIOIAx8Ih8gDYVCAYkiDCAWfCAAKQNAIgt8Ig0gGoVCIIkiFiAJfCIaIAyFQiiJIiAgDXwgACkDSCIJfCIhIBaFQjCJIhYgGyAchUIBiSIMIAd8IAApA2AiB3wiDSAOhUIgiSIOIBcgFHwiFHwiFyAMhUIoiSIbIA18IAApA2giDHwiHCAOhUIwiSIOIBd8IhcgG4VCAYkiGyAZIBQgFYVCAYkiFHwgACkDcCINfCIVIAiFQiCJIhkgH3wiHyAUhUIoiSIUIBV8IAApA3giCHwiFXwgDHwiIoVCIIkiI3wiJCAbhUIoiSIbICJ8IBJ8IiIgFyAYIBUgGYVCMIkiFSAffCIZIBSFQgGJIhQgIXwgDXwiH4VCIIkiGHwiFyAUhUIoiSIUIB98IAV8Ih8gGIVCMIkiGCAXfCIXIBSFQgGJIhR8IAF8IiEgFiAafCIWIBUgHSAehUIBiSIaIBx8IAl8IhyFQiCJIhV8Ih0gGoVCKIkiGiAcfCAIfCIcIBWFQjCJIhWFQiCJIh4gGSAOIBYgIIVCAYkiFiAPfCACfCIPhUIgiSIOfCIZIBaFQiiJIhYgD3wgC3wiDyAOhUIwiSIOIBl8Ihl8IiAgFIVCKIkiFCAhfCAEfCIhIB6FQjCJIh4gIHwiICAiICOFQjCJIiIgJHwiIyAbhUIBiSIbIBx8IAp8IhwgDoVCIIkiDiAXfCIXIBuFQiiJIhsgHHwgE3wiHCAOhUIwiSIOIBkgFoVCAYkiFiAffCAQfCIZICKFQiCJIh8gFSAdfCIVfCIdIBaFQiiJIhYgGXwgB3wiGSAfhUIwiSIfIB18Ih0gFoVCAYkiFiAVIBqFQgGJIhUgD3wgBnwiDyAYhUIgiSIYICN8IhogFYVCKIkiFSAPfCADfCIPfCAHfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBnwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAOIBd8Ig4gDyAYhUIwiSIPICAgFIVCAYkiFCAZfCAKfCIXhUIgiSIYfCIZIBSFQiiJIhQgF3wgC3wiF3wgBXwiICAPIBp8Ig8gHyAOIBuFQgGJIg4gIXwgCHwiGoVCIIkiG3wiHyAOhUIoiSIOIBp8IAx8IhogG4VCMIkiG4VCIIkiISAdIB4gDyAVhUIBiSIPIBx8IAF8IhWFQiCJIhx8Ih0gD4VCKIkiDyAVfCADfCIVIByFQjCJIhwgHXwiHXwiHiAWhUIoiSIWICB8IA18IiAgIYVCMIkiISAefCIeIBogFyAYhUIwiSIXIBl8IhggFIVCAYkiFHwgCXwiGSAchUIgiSIaICR8IhwgFIVCKIkiFCAZfCACfCIZIBqFQjCJIhogHSAPhUIBiSIPICJ8IAR8Ih0gF4VCIIkiFyAbIB98Iht8Ih8gD4VCKIkiDyAdfCASfCIdIBeFQjCJIhcgH3wiHyAPhUIBiSIPIBsgDoVCAYkiDiAVfCATfCIVICOFQiCJIhsgGHwiGCAOhUIoiSIOIBV8IBB8IhV8IAx8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAHfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBogHHwiGiAVIBuFQjCJIhUgHiAWhUIBiSIWIB18IAR8IhuFQiCJIhx8Ih0gFoVCKIkiFiAbfCAQfCIbfCABfCIeIBUgGHwiFSAXIBogFIVCAYkiFCAgfCATfCIYhUIgiSIXfCIaIBSFQiiJIhQgGHwgCXwiGCAXhUIwiSIXhUIgiSIgIB8gISAVIA6FQgGJIg4gGXwgCnwiFYVCIIkiGXwiHyAOhUIoiSIOIBV8IA18IhUgGYVCMIkiGSAffCIffCIhIA+FQiiJIg8gHnwgBXwiHiAghUIwiSIgICF8IiEgGyAchUIwiSIbIB18IhwgFoVCAYkiFiAYfCADfCIYIBmFQiCJIhkgJHwiHSAWhUIoiSIWIBh8IBJ8IhggGYVCMIkiGSAfIA6FQgGJIg4gInwgAnwiHyAbhUIgiSIbIBcgGnwiF3wiGiAOhUIoiSIOIB98IAZ8Ih8gG4VCMIkiGyAafCIaIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAh8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgC3wiFXwgBXwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAh8IiIgGiAgIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGHwgCXwiGIVCIIkiHHwiGiAUhUIoiSIUIBh8IAZ8IhggHIVCMIkiHCAafCIaIBSFQgGJIhR8IAR8IiAgGSAdfCIZIBUgISAPhUIBiSIPIB98IAN8Ih2FQiCJIhV8Ih8gD4VCKIkiDyAdfCACfCIdIBWFQjCJIhWFQiCJIiEgFyAbIBkgFoVCAYkiFiAefCABfCIZhUIgiSIbfCIXIBaFQiiJIhYgGXwgE3wiGSAbhUIwiSIbIBd8Ihd8Ih4gFIVCKIkiFCAgfCAMfCIgICGFQjCJIiEgHnwiHiAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IBJ8Ih0gG4VCIIkiGyAafCIaIA6FQiiJIg4gHXwgC3wiHSAbhUIwiSIbIBcgFoVCAYkiFiAYfCANfCIXICKFQiCJIhggFSAffCIVfCIfIBaFQiiJIhYgF3wgEHwiFyAYhUIwiSIYIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGXwgCnwiFSAchUIgiSIZICN8IhwgD4VCKIkiDyAVfCAHfCIVfCASfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAbIBp8IhogFSAZhUIwiSIVIB4gFIVCAYkiFCAXfCADfCIXhUIgiSIZfCIbIBSFQiiJIhQgF3wgB3wiF3wgAnwiHiAVIBx8IhUgGCAaIA6FQgGJIg4gIHwgC3wiGoVCIIkiGHwiHCAOhUIoiSIOIBp8IAR8IhogGIVCMIkiGIVCIIkiICAfICEgFSAPhUIBiSIPIB18IAZ8IhWFQiCJIh18Ih8gD4VCKIkiDyAVfCAKfCIVIB2FQjCJIh0gH3wiH3wiISAWhUIoiSIWIB58IAx8Ih4gIIVCMIkiICAhfCIhIBogFyAZhUIwiSIXIBt8IhkgFIVCAYkiFHwgEHwiGiAdhUIgiSIbICR8Ih0gFIVCKIkiFCAafCAJfCIaIBuFQjCJIhsgHyAPhUIBiSIPICJ8IBN8Ih8gF4VCIIkiFyAYIBx8Ihh8IhwgD4VCKIkiDyAffCABfCIfIBeFQjCJIhcgHHwiHCAPhUIBiSIPIBggDoVCAYkiDiAVfCAIfCIVICOFQiCJIhggGXwiGSAOhUIoiSIOIBV8IA18IhV8IA18IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAMfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHXwiGyAVIBiFQjCJIhUgISAWhUIBiSIWIB98IBB8IhiFQiCJIh18Ih8gFoVCKIkiFiAYfCAIfCIYfCASfCIhIBUgGXwiFSAXIBsgFIVCAYkiFCAefCAHfCIZhUIgiSIXfCIbIBSFQiiJIhQgGXwgAXwiGSAXhUIwiSIXhUIgiSIeIBwgICAVIA6FQgGJIg4gGnwgAnwiFYVCIIkiGnwiHCAOhUIoiSIOIBV8IAV8IhUgGoVCMIkiGiAcfCIcfCIgIA+FQiiJIg8gIXwgBHwiISAehUIwiSIeICB8IiAgGCAdhUIwiSIYIB98Ih0gFoVCAYkiFiAZfCAGfCIZIBqFQiCJIhogJHwiHyAWhUIoiSIWIBl8IBN8IhkgGoVCMIkiGiAcIA6FQgGJIg4gInwgCXwiHCAYhUIgiSIYIBcgG3wiF3wiGyAOhUIoiSIOIBx8IAN8IhwgGIVCMIkiGCAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAt8IhUgI4VCIIkiFyAdfCIdIBSFQiiJIhQgFXwgCnwiFXwgBHwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAl8IiIgGyAeIBUgF4VCMIkiFSAdfCIXIBSFQgGJIhQgGXwgDHwiGYVCIIkiHXwiGyAUhUIoiSIUIBl8IAp8IhkgHYVCMIkiHSAbfCIbIBSFQgGJIhR8IAN8Ih4gGiAffCIaIBUgICAPhUIBiSIPIBx8IAd8IhyFQiCJIhV8Ih8gD4VCKIkiDyAcfCAQfCIcIBWFQjCJIhWFQiCJIiAgFyAYIBogFoVCAYkiFiAhfCATfCIahUIgiSIYfCIXIBaFQiiJIhYgGnwgDXwiGiAYhUIwiSIYIBd8Ihd8IiEgFIVCKIkiFCAefCAFfCIeICCFQjCJIiAgIXwiISAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIBx8IAt8IhwgGIVCIIkiGCAbfCIbIA6FQiiJIg4gHHwgEnwiHCAYhUIwiSIYIBcgFoVCAYkiFiAZfCABfCIXICKFQiCJIhkgFSAffCIVfCIfIBaFQiiJIhYgF3wgBnwiFyAZhUIwiSIZIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGnwgCHwiFSAdhUIgiSIaICN8Ih0gD4VCKIkiDyAVfCACfCIVfCANfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgCXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAYIBt8IhggFSAahUIwiSIVICEgFIVCAYkiFCAXfCASfCIXhUIgiSIafCIbIBSFQiiJIhQgF3wgCHwiF3wgB3wiISAVIB18IhUgGSAYIA6FQgGJIg4gHnwgBnwiGIVCIIkiGXwiHSAOhUIoiSIOIBh8IAt8IhggGYVCMIkiGYVCIIkiHiAfICAgFSAPhUIBiSIPIBx8IAp8IhWFQiCJIhx8Ih8gD4VCKIkiDyAVfCAEfCIVIByFQjCJIhwgH3wiH3wiICAWhUIoiSIWICF8IAN8IiEgHoVCMIkiHiAgfCIgIBggFyAahUIwiSIXIBt8IhogFIVCAYkiFHwgBXwiGCAchUIgiSIbICR8IhwgFIVCKIkiFCAYfCABfCIYIBuFQjCJIhsgHyAPhUIBiSIPICJ8IAx8Ih8gF4VCIIkiFyAZIB18Ihl8Ih0gD4VCKIkiDyAffCATfCIfIBeFQjCJIhcgHXwiHSAPhUIBiSIPIBkgDoVCAYkiDiAVfCAQfCIVICOFQiCJIhkgGnwiGiAOhUIoiSIOIBV8IAJ8IhV8IBN8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCASfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHHwiGyAVIBmFQjCJIhUgICAWhUIBiSIWIB98IAt8IhmFQiCJIhx8Ih8gFoVCKIkiFiAZfCACfCIZfCAJfCIgIBUgGnwiFSAXIBsgFIVCAYkiFCAhfCAFfCIahUIgiSIXfCIbIBSFQiiJIhQgGnwgA3wiGiAXhUIwiSIXhUIgiSIhIB0gHiAVIA6FQgGJIg4gGHwgEHwiFYVCIIkiGHwiHSAOhUIoiSIOIBV8IAF8IhUgGIVCMIkiGCAdfCIdfCIeIA+FQiiJIg8gIHwgDXwiICAhhUIwiSIhIB58Ih4gGSAchUIwiSIZIB98IhwgFoVCAYkiFiAafCAIfCIaIBiFQiCJIhggJHwiHyAWhUIoiSIWIBp8IAp8IhogGIVCMIkiGCAdIA6FQgGJIg4gInwgBHwiHSAZhUIgiSIZIBcgG3wiF3wiGyAOhUIoiSIOIB18IAd8Ih0gGYVCMIkiGSAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAx8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgBnwiFXwgEnwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IBN8IiIgGyAhIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGnwgBnwiGoVCIIkiHHwiGyAUhUIoiSIUIBp8IBB8IhogHIVCMIkiHCAbfCIbIBSFQgGJIhR8IA18IiEgGCAffCIYIBUgHiAPhUIBiSIPIB18IAJ8Ih2FQiCJIhV8Ih4gD4VCKIkiDyAdfCABfCIdIBWFQjCJIhWFQiCJIh8gFyAZIBggFoVCAYkiFiAgfCADfCIYhUIgiSIZfCIXIBaFQiiJIhYgGHwgBHwiGCAZhUIwiSIZIBd8Ihd8IiAgFIVCKIkiFCAhfCAIfCIhIB+FQjCJIh8gIHwiICAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IAd8Ih0gGYVCIIkiGSAbfCIbIA6FQiiJIg4gHXwgDHwiHSAZhUIwiSIZIBcgFoVCAYkiFiAafCALfCIXICKFQiCJIhogFSAefCIVfCIeIBaFQiiJIhYgF3wgCXwiFyAahUIwiSIaIB58Ih4gFoVCAYkiFiAVIA+FQgGJIg8gGHwgBXwiFSAchUIgiSIYICN8IhwgD4VCKIkiDyAVfCAKfCIVfCACfCIChUIgiSIifCIjIBaFQiiJIhYgAnwgC3wiAiAihUIwiSILICN8IiIgFoVCAYkiFiAZIBt8IhkgFSAYhUIwiSIVICAgFIVCAYkiFCAXfCANfCINhUIgiSIXfCIYIBSFQiiJIhQgDXwgBXwiBXwgEHwiECAVIBx8Ig0gGiAZIA6FQgGJIg4gIXwgDHwiDIVCIIkiFXwiGSAOhUIoiSIOIAx8IBJ8IhIgFYVCMIkiDIVCIIkiFSAeIB8gDSAPhUIBiSINIB18IAl8IgmFQiCJIg98IhogDYVCKIkiDSAJfCAIfCIJIA+FQjCJIgggGnwiD3wiGiAWhUIoiSIWIBB8IAd8IhAgEYUgDCAZfCIHIA6FQgGJIgwgCXwgCnwiCiALhUIgiSILIAUgF4VCMIkiBSAYfCIJfCIOIAyFQiiJIgwgCnwgE3wiEyALhUIwiSIKIA58IguFNwOAiQFBACADIAYgDyANhUIBiSINIAJ8fCICIAWFQiCJIgUgB3wiBiANhUIoiSIHIAJ8fCICQQApA4iJAYUgBCABIBIgCSAUhUIBiSIDfHwiASAIhUIgiSISICJ8IgkgA4VCKIkiAyABfHwiASAShUIwiSIEIAl8IhKFNwOIiQFBACATQQApA5CJAYUgECAVhUIwiSIQIBp8IhOFNwOQiQFBACABQQApA5iJAYUgAiAFhUIwiSICIAZ8IgGFNwOYiQFBACASIAOFQgGJQQApA6CJAYUgAoU3A6CJAUEAIBMgFoVCAYlBACkDqIkBhSAKhTcDqIkBQQAgASAHhUIBiUEAKQOwiQGFIASFNwOwiQFBACALIAyFQgGJQQApA7iJAYUgEIU3A7iJAQvdAgUBfwF+AX8BfgJ/IwBBwABrIgAkAAJAQQApA9CJAUIAUg0AQQBBACkDwIkBIgFBACgC4IoBIgKsfCIDNwPAiQFBAEEAKQPIiQEgAyABVK18NwPIiQECQEEALQDoigFFDQBBAEJ/NwPYiQELQQBCfzcD0IkBAkAgAkH/AEoNAEEAIQQDQCACIARqQeCJAWpBADoAACAEQQFqIgRBgAFBACgC4IoBIgJrSA0ACwtB4IkBEAIgAEEAKQOAiQE3AwAgAEEAKQOIiQE3AwggAEEAKQOQiQE3AxAgAEEAKQOYiQE3AxggAEEAKQOgiQE3AyAgAEEAKQOoiQE3AyggAEEAKQOwiQE3AzAgAEEAKQO4iQE3AzhBACgC5IoBIgVBAUgNAEEAIQRBACECA0AgBEGACWogACAEai0AADoAACAEQQFqIQQgBSACQQFqIgJB/wFxSg0ACwsgAEHAAGokAAv9AwMBfwF+AX8jAEGAAWsiAiQAQQBBgQI7AfKKAUEAIAE6APGKAUEAIAA6APCKAUGQfiEAA0AgAEGAiwFqQgA3AAAgAEH4igFqQgA3AAAgAEHwigFqQgA3AAAgAEEYaiIADQALQQAhAEEAQQApA/CKASIDQoiS853/zPmE6gCFNwOAiQFBAEEAKQP4igFCu86qptjQ67O7f4U3A4iJAUEAQQApA4CLAUKr8NP0r+68tzyFNwOQiQFBAEEAKQOIiwFC8e30+KWn/aelf4U3A5iJAUEAQQApA5CLAULRhZrv+s+Uh9EAhTcDoIkBQQBBACkDmIsBQp/Y+dnCkdqCm3+FNwOoiQFBAEEAKQOgiwFC6/qG2r+19sEfhTcDsIkBQQBBACkDqIsBQvnC+JuRo7Pw2wCFNwO4iQFBACADp0H/AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=",hash:"c6f286e6"};function Jp(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function Kp(e=512,t=null){if(Jp(e))return Promise.reject(Jp(e));let n=null,i=e;if(null!==t){if(n=Lp(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));s=e,r=n.length,i=s|r<<16}var s,r;const o=e/8;return Hp(Gp,o).then(e=>{i>512&&e.writeMemory(n),e.init(i);const t={init:i>512?()=>(e.writeMemory(n),e.init(i),t):()=>(e.init(i),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:o};return t})}new Sp;const Vp=new DataView(new ArrayBuffer(4));function Wp(e){return Vp.setInt32(0,e,!0),new Uint8Array(Vp.buffer)}function Yp(e,t,n){return xp(this,void 0,void 0,function*(){if(n<=64){const e=yield Kp(8*n);return e.update(Wp(n)),e.update(t),e.digest("binary")}const i=Math.ceil(n/32)-2,s=new Uint8Array(n);e.init(),e.update(Wp(n)),e.update(t);let r=e.digest("binary");s.set(r.subarray(0,32),0);for(let t=1;t<i;t++)e.init(),e.update(r),r=e.digest("binary"),s.set(r.subarray(0,32),32*t);const o=n-32*i;let l;return 64===o?(l=e,l.init()):l=yield Kp(8*o),l.update(r),r=l.digest("binary"),s.set(r.subarray(0,o),32*i),s})}function Zp(e){return xp(this,void 0,void 0,function*(){var t;const{parallelism:n,iterations:i,hashLength:s}=e,r=Lp(e.password),o=Lp(e.salt),l=function(e){switch(e){case"d":return 0;case"i":return 1;default:return 2}}(e.hashType),{memorySize:a}=e,c=Lp(null!==(t=e.secret)&&void 0!==t?t:""),[u,d]=yield Promise.all([Hp(qp,1024),Kp(512)]);u.setMemorySize(1024*a+1024);const f=new Uint8Array(24),h=new DataView(f.buffer);h.setInt32(0,n,!0),h.setInt32(4,s,!0),h.setInt32(8,a,!0),h.setInt32(12,i,!0),h.setInt32(16,19,!0),h.setInt32(20,l,!0),u.writeMemory(f,1024*a),d.init(),d.update(f),d.update(Wp(r.length)),d.update(r),d.update(Wp(o.length)),d.update(o),d.update(Wp(c.length)),d.update(c),d.update(Wp(0));const p=4*Math.floor(a/(4*n)),g=new Uint8Array(72),m=d.digest("binary");g.set(m);for(let e=0;e<n;e++){g.set(Wp(0),64),g.set(Wp(e),68);let t=e*p,n=yield Yp(d,g,1024);u.writeMemory(n,1024*t),t+=1,g.set(Wp(1),64),n=yield Yp(d,g,1024),u.writeMemory(n,1024*t)}const v=new Uint8Array(1024);Qp(v,u.calculate(new Uint8Array([]),a));const y=yield Yp(d,v,s);if("hex"===e.outputType){return Tp(new Uint8Array(2*s),y,s)}return"encoded"===e.outputType?function(e,t,n){const i=[`m=${t.memorySize}`,`t=${t.iterations}`,`p=${t.parallelism}`].join(",");return`$argon2${t.hashType}$v=19$${i}$${Mp(e,!1)}$${Mp(n,!1)}`}(o,e,y):y})}function Xp(e){return xp(this,void 0,void 0,function*(){return(e=>{var t;if(!e||"object"!=typeof e)throw new Error("Invalid options parameter. It requires an object.");if(!e.password)throw new Error("Password must be specified");if(e.password=Lp(e.password),e.password.length<1)throw new Error("Password must be specified");if(!e.salt)throw new Error("Salt must be specified");if(e.salt=Lp(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=Lp(null!==(t=e.secret)&&void 0!==t?t:""),!Number.isInteger(e.iterations)||e.iterations<1)throw new Error("Iterations should be a positive number");if(!Number.isInteger(e.parallelism)||e.parallelism<1)throw new Error("Parallelism should be a positive number");if(!Number.isInteger(e.hashLength)||e.hashLength<4)throw new Error("Hash length should be at least 4 bytes.");if(!Number.isInteger(e.memorySize))throw new Error("Memory size should be specified.");if(e.memorySize<8*e.parallelism)throw new Error("Memory size should be at least 8 * parallelism.");if(void 0===e.outputType&&(e.outputType="hex"),!["hex","binary","encoded"].includes(e.outputType))throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary', 'encoded']`)})(e),Zp(Object.assign(Object.assign({},e),{hashType:"id"}))})}new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp,new Sp;const eg={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let tg=null,ng=0;const ig=new Map;async function sg(e,t){try{const n=function(){if(tg)return tg;const e=new Blob(["\n        importScripts('https://cdn.jsdelivr.net/npm/hash-wasm@4.11.0/dist/argon2.umd.min.js');\n\n        const ARGON2_CONFIG = {\n            parallelism: 4,\n            iterations: 8,\n            memorySize: 262144,\n            hashLength: 32,\n            outputType: \"binary\"\n        };\n\n        self.onmessage = async function(e) {\n            const { password, salt, id } = e.data;\n\n            try {\n                const result = await hashwasm.argon2id({\n                    password: password,\n                    salt: new Uint8Array(salt),\n                    ...ARGON2_CONFIG\n                });\n\n                self.postMessage({\n                    id,\n                    success: true,\n                    result: Array.from(result)\n                });\n            } catch (error) {\n                self.postMessage({\n                    id,\n                    success: false,\n                    error: error.message\n                });\n            }\n        };\n    "],{type:"application/javascript"});return tg=new Worker(URL.createObjectURL(e)),tg.onmessage=function(e){const{id:t,success:n,result:i,error:s}=e.data,r=ig.get(t);r&&(ig.delete(t),n?r.resolve(new Uint8Array(i)):r.reject(new Error(s)))},tg.onerror=function(e){console.error("Argon2 worker error:",e)},tg}(),i=++ng;return new Promise((s,r)=>{ig.set(i,{resolve:s,reject:r}),n.postMessage({id:i,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await Xp({password:e,salt:t,...eg})}}const{window:rg}=d;function og(e){let t,n,s,r,o,l,a,c,u,d,g,v,y,b,C,E,x,S,B,$;function D(e,t){return"extension"===e[2]?cg:"npub"===e[2]?ag:lg}let Q=D(e),P=Q(e),R=e[10]&&Ag(e),T=e[11]&&kg(e);return{c(){t=m("div"),n=m("div"),s=m("div"),r=m("h2"),r.textContent="Login to Nostr",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("button"),d.textContent="Extension",g=w(),v=m("button"),v.textContent="Nsec",y=w(),b=m("button"),b.textContent="Read-only",C=w(),E=m("div"),P.c(),x=w(),R&&R.c(),S=w(),T&&T.c(),I(r,"class","svelte-1i9f0z0"),I(l,"class","close-btn svelte-1i9f0z0"),I(s,"class","modal-header svelte-1i9f0z0"),I(d,"class","tab-btn svelte-1i9f0z0"),F(d,"active","extension"===e[2]),I(v,"class","tab-btn svelte-1i9f0z0"),F(v,"active","nsec"===e[2]),I(b,"class","tab-btn svelte-1i9f0z0"),F(b,"active","npub"===e[2]),I(u,"class","tabs svelte-1i9f0z0"),I(E,"class","tab-content svelte-1i9f0z0"),I(c,"class","tab-container svelte-1i9f0z0"),I(n,"class","modal svelte-1i9f0z0"),F(n,"dark-theme",e[1]),I(t,"class","modal-overlay svelte-1i9f0z0"),I(t,"role","button"),I(t,"tabindex","0")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(s,r),f(s,o),f(s,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(u,v),f(u,y),f(u,b),f(c,C),f(c,E),P.m(E,null),f(E,x),R&&R.m(E,null),f(E,S),T&&T.m(E,null),B||($=[A(l,"click",e[18]),A(d,"click",e[28]),A(v,"click",e[29]),A(b,"click",e[30]),A(n,"click",k(e[26])),A(n,"keydown",k(e[27])),A(t,"click",e[18]),A(t,"keydown",e[36])],B=!0)},p(e,t){4&t[0]&&F(d,"active","extension"===e[2]),4&t[0]&&F(v,"active","nsec"===e[2]),4&t[0]&&F(b,"active","npub"===e[2]),Q===(Q=D(e))&&P?P.p(e,t):(P.d(1),P=Q(e),P&&(P.c(),P.m(E,x))),e[10]?R?R.p(e,t):(R=Ag(e),R.c(),R.m(E,S)):R&&(R.d(1),R=null),e[11]?T?T.p(e,t):(T=kg(e),T.c(),T.m(E,null)):T&&(T.d(1),T=null),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&p(t),P.d(),R&&R.d(),T&&T.d(),B=!1,i($)}}}function lg(e){let t;function n(e,t){return e[15]?dg:ug}let i=n(e),s=i(e);return{c(){t=m("div"),s.c(),I(t,"class","nsec-login svelte-1i9f0z0")},m(e,n){h(e,t,n),s.m(t,null)},p(e,r){i===(i=n(e))&&s?s.p(e,r):(s.d(1),s=i(e),s&&(s.c(),s.m(t,null)))},d(e){e&&p(t),s.d()}}}function ag(e){let t,n,s,r,o,l,a,c,u,d,g=e[7]?"Logging in...":"Browse read-only";return{c(){t=m("div"),n=m("p"),n.textContent="Enter an npub to browse in read-only mode.\n                                You won't be able to post or sign events.",s=w(),r=m("input"),o=w(),l=m("button"),a=y(g),I(n,"class","svelte-1i9f0z0"),I(r,"type","text"),I(r,"placeholder","npub1... or hex pubkey"),r.disabled=e[7],I(r,"class","nsec-input svelte-1i9f0z0"),I(l,"class","login-nsec-btn svelte-1i9f0z0"),l.disabled=c=e[7]||!e[13].trim(),I(t,"class","extension-login svelte-1i9f0z0")},m(i,c){h(i,t,c),f(t,n),f(t,s),f(t,r),x(r,e[13]),f(t,o),f(t,l),f(l,a),u||(d=[A(r,"input",e[31]),A(l,"click",e[23])],u=!0)},p(e,t){128&t[0]&&(r.disabled=e[7]),8192&t[0]&&r.value!==e[13]&&x(r,e[13]),128&t[0]&&g!==(g=e[7]?"Logging in...":"Browse read-only")&&E(a,g),8320&t[0]&&c!==(c=e[7]||!e[13].trim())&&(l.disabled=c)},d(e){e&&p(t),u=!1,i(d)}}}function cg(e){let t,n,i,s,r,o,l,a=e[7]?"Connecting...":"Log in using extension";return{c(){t=m("div"),n=m("p"),n.textContent="Login using a NIP-07 compatible browser\n                                extension like nos2x or Alby.",i=w(),s=m("button"),r=y(a),I(n,"class","svelte-1i9f0z0"),I(s,"class","login-extension-btn svelte-1i9f0z0"),s.disabled=e[7],I(t,"class","extension-login svelte-1i9f0z0")},m(a,c){h(a,t,c),f(t,n),f(t,i),f(t,s),f(s,r),o||(l=A(s,"click",e[22]),o=!0)},p(e,t){128&t[0]&&a!==(a=e[7]?"Connecting...":"Log in using extension")&&E(r,a),128&t[0]&&(s.disabled=e[7])},d(e){e&&p(t),o=!1,l()}}}function ug(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,S,B,$,F,D,Q,P,R,T=e[8]?"Generating...":"Generate New Key",L=e[12]&&fg(e),_=e[4]&&hg(e);function N(e,t){return e[9]?mg:e[7]?gg:pg}let M=N(e),U=M(e);return{c(){t=m("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n                                    set a password to encrypt it securely.",n=w(),s=m("button"),r=y(T),l=w(),L&&L.c(),a=w(),c=m("input"),d=w(),g=m("div"),v=m("label"),v.textContent="Encryption Password (optional but recommended):",b=w(),k=m("input"),S=w(),_&&_.c(),B=w(),$=m("small"),$.textContent="Password uses Argon2id with ~3 second derivation time for security.",F=w(),D=m("button"),U.c(),I(t,"class","svelte-1i9f0z0"),I(s,"class","generate-btn svelte-1i9f0z0"),s.disabled=o=e[7]||e[8],I(c,"type","password"),I(c,"placeholder","nsec1..."),c.disabled=u=e[7]||e[9],I(c,"class","nsec-input svelte-1i9f0z0"),I(v,"class","svelte-1i9f0z0"),I(k,"type","password"),I(k,"placeholder","Enter password (min 8 chars)"),k.disabled=C=e[7]||e[9],I(k,"class","password-input svelte-1i9f0z0"),I($,"class","password-hint svelte-1i9f0z0"),I(g,"class","password-section svelte-1i9f0z0"),I(D,"class","login-nsec-btn svelte-1i9f0z0"),D.disabled=Q=e[7]||e[9]||!e[3].trim()},m(i,o){h(i,t,o),h(i,n,o),h(i,s,o),f(s,r),h(i,l,o),L&&L.m(i,o),h(i,a,o),h(i,c,o),x(c,e[3]),h(i,d,o),h(i,g,o),f(g,v),f(g,b),f(g,k),x(k,e[4]),f(g,S),_&&_.m(g,null),f(g,B),f(g,$),h(i,F,o),h(i,D,o),U.m(D,null),P||(R=[A(s,"click",e[21]),A(c,"input",e[33]),A(k,"input",e[34]),A(D,"click",e[24])],P=!0)},p(e,t){256&t[0]&&T!==(T=e[8]?"Generating...":"Generate New Key")&&E(r,T),384&t[0]&&o!==(o=e[7]||e[8])&&(s.disabled=o),e[12]?L?L.p(e,t):(L=fg(e),L.c(),L.m(a.parentNode,a)):L&&(L.d(1),L=null),640&t[0]&&u!==(u=e[7]||e[9])&&(c.disabled=u),8&t[0]&&c.value!==e[3]&&x(c,e[3]),640&t[0]&&C!==(C=e[7]||e[9])&&(k.disabled=C),16&t[0]&&k.value!==e[4]&&x(k,e[4]),e[4]?_?_.p(e,t):(_=hg(e),_.c(),_.m(g,B)):_&&(_.d(1),_=null),M!==(M=N(e))&&(U.d(1),U=M(e),U&&(U.c(),U.m(D,null))),648&t[0]&&Q!==(Q=e[7]||e[9]||!e[3].trim())&&(D.disabled=Q)},d(e){e&&p(t),e&&p(n),e&&p(s),e&&p(l),L&&L.d(e),e&&p(a),e&&p(c),e&&p(d),e&&p(g),_&&_.d(),e&&p(F),e&&p(D),U.d(),P=!1,i(R)}}}function dg(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C=e[16]&&vg(e);function E(e,t){return e[9]?bg:e[7]?wg:yg}let S=E(e),B=S(e);return{c(){t=m("p"),t.textContent="You have a stored encrypted key. Enter your\n                                    password to unlock it.",n=w(),C&&C.c(),s=w(),r=m("input"),l=w(),a=m("button"),B.c(),u=w(),d=m("button"),g=y("Clear stored key & start fresh"),I(t,"class","svelte-1i9f0z0"),I(r,"type","password"),I(r,"placeholder","Enter your password"),r.disabled=o=e[7]||e[9],I(r,"class","password-input svelte-1i9f0z0"),I(a,"class","login-nsec-btn svelte-1i9f0z0"),a.disabled=c=e[7]||e[9]||!e[6],I(d,"class","clear-btn svelte-1i9f0z0"),d.disabled=v=e[7]||e[9]},m(i,o){h(i,t,o),h(i,n,o),C&&C.m(i,o),h(i,s,o),h(i,r,o),x(r,e[6]),h(i,l,o),h(i,a,o),B.m(a,null),h(i,u,o),h(i,d,o),f(d,g),b||(k=[A(r,"input",e[32]),A(a,"click",e[19]),A(d,"click",e[17])],b=!0)},p(e,t){e[16]?C?C.p(e,t):(C=vg(e),C.c(),C.m(s.parentNode,s)):C&&(C.d(1),C=null),640&t[0]&&o!==(o=e[7]||e[9])&&(r.disabled=o),64&t[0]&&r.value!==e[6]&&x(r,e[6]),S!==(S=E(e))&&(B.d(1),B=S(e),B&&(B.c(),B.m(a,null))),704&t[0]&&c!==(c=e[7]||e[9]||!e[6])&&(a.disabled=c),640&t[0]&&v!==(v=e[7]||e[9])&&(d.disabled=v)},d(e){e&&p(t),e&&p(n),C&&C.d(e),e&&p(s),e&&p(r),e&&p(l),e&&p(a),B.d(),e&&p(u),e&&p(d),b=!1,i(k)}}}function fg(e){let t,n,i,s,r;return{c(){t=m("div"),n=m("label"),n.textContent="Your new public key (npub):",i=w(),s=m("code"),r=y(e[12]),I(n,"class","svelte-1i9f0z0"),I(s,"class","npub-display svelte-1i9f0z0"),I(t,"class","generated-info svelte-1i9f0z0")},m(e,o){h(e,t,o),f(t,n),f(t,i),f(t,s),f(s,r)},p(e,t){4096&t[0]&&E(r,e[12])},d(e){e&&p(t)}}}function hg(e){let t,n,i,s;return{c(){t=m("input"),I(t,"type","password"),I(t,"placeholder","Confirm password"),t.disabled=n=e[7]||e[9],I(t,"class","password-input svelte-1i9f0z0")},m(n,r){h(n,t,r),x(t,e[5]),i||(s=A(t,"input",e[35]),i=!0)},p(e,i){640&i[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&i[0]&&t.value!==e[5]&&x(t,e[5])},d(e){e&&p(t),i=!1,s()}}}function pg(e){let t;return{c(){t=y("Log in with nsec")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function gg(e){let t;return{c(){t=y("Logging in...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function mg(e){let t;return{c(){t=y("Deriving key...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function vg(e){let t,n,i,s,r,o,l,a=e[16].slice(0,16)+"",c=e[16].slice(-8)+"";return{c(){t=m("div"),n=m("label"),n.textContent="Stored public key:",i=w(),s=m("code"),r=y(a),o=y("..."),l=y(c),I(n,"class","svelte-1i9f0z0"),I(s,"class","npub-display svelte-1i9f0z0"),I(t,"class","stored-info svelte-1i9f0z0")},m(e,a){h(e,t,a),f(t,n),f(t,i),f(t,s),f(s,r),f(s,o),f(s,l)},p(e,t){65536&t[0]&&a!==(a=e[16].slice(0,16)+"")&&E(r,a),65536&t[0]&&c!==(c=e[16].slice(-8)+"")&&E(l,c)},d(e){e&&p(t)}}}function yg(e){let t;return{c(){t=y("Unlock")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function wg(e){let t;return{c(){t=y("Unlocking...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function bg(e){let t;return{c(){t=y("Deriving key...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Ag(e){let t,n;return{c(){t=m("div"),n=y(e[10]),I(t,"class","message error-message svelte-1i9f0z0")},m(e,i){h(e,t,i),f(t,n)},p(e,t){1024&t[0]&&E(n,e[10])},d(e){e&&p(t)}}}function kg(e){let t,n;return{c(){t=m("div"),n=y(e[11]),I(t,"class","message success-message svelte-1i9f0z0")},m(e,i){h(e,t,i),f(t,n)},p(e,t){2048&t[0]&&E(n,e[11])},d(e){e&&p(t)}}}function Ig(e){let t,n,i,s,r,o,l,a,c,u,d,g=e[14].toFixed(1)+"";return{c(){t=m("div"),n=m("div"),i=m("div"),s=w(),r=m("h3"),r.textContent="Deriving encryption key",o=w(),l=m("div"),a=y(g),c=y("s"),u=w(),d=m("p"),d.textContent="This may take 3-6 seconds for security",I(i,"class","deriving-spinner svelte-1i9f0z0"),I(r,"class","svelte-1i9f0z0"),I(l,"class","deriving-timer svelte-1i9f0z0"),I(d,"class","deriving-note svelte-1i9f0z0"),I(n,"class","deriving-modal svelte-1i9f0z0"),F(n,"dark-theme",e[1]),I(t,"class","deriving-overlay svelte-1i9f0z0")},m(e,p){h(e,t,p),f(t,n),f(n,i),f(n,s),f(n,r),f(n,o),f(n,l),f(l,a),f(l,c),f(n,u),f(n,d)},p(e,t){16384&t[0]&&g!==(g=e[14].toFixed(1)+"")&&E(a,g),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&p(t)}}}function Cg(t){let n,i,s,r,o=t[0]&&og(t),l=t[9]&&Ig(t);return{c(){o&&o.c(),n=w(),l&&l.c(),i=b()},m(e,a){o&&o.m(e,a),h(e,n,a),l&&l.m(e,a),h(e,i,a),s||(r=A(rg,"keydown",t[25]),s=!0)},p(e,t){e[0]?o?o.p(e,t):(o=og(e),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null),e[9]?l?l.p(e,t):(l=Ig(e),l.c(),l.m(i.parentNode,i)):l&&(l.d(1),l=null)},i:e,o:e,d(e){o&&o.d(e),e&&p(n),l&&l.d(e),e&&p(i),s=!1,r()}}}function Eg(e,t,n){const i=L();let{showModal:s=!1}=t,{isDarkTheme:r=!1}=t,o="extension",l="",a="",c="",u="",d=!1,f=!1,h=!1,p="",g="",m="",v="",y="",w=0,b=null,A=null;function k(){n(14,w=0),b=performance.now(),I()}function I(){null!==b&&(n(14,w=(performance.now()-b)/1e3),A=requestAnimationFrame(I))}function C(){b=null,A&&(cancelAnimationFrame(A),A=null)}T(()=>{C()});let E=!1,x="";function S(){n(15,E=!!localStorage.getItem("nostr_privkey_encrypted")),n(16,x=localStorage.getItem("nostr_pubkey")||"")}function B(){n(0,s=!1),n(3,l=""),n(13,y=""),n(4,a=""),n(5,c=""),n(6,u=""),n(10,p=""),n(11,g=""),m="",n(12,v=""),i("close")}function $(e){n(2,o=e),n(10,p=""),n(11,g=""),m="",n(12,v="")}async function F(){n(7,d=!0),n(10,p="");try{const e=y.trim();if(!e)throw new Error("Please enter an npub");let t;if(/^[0-9a-f]{64}$/i.test(e))t=e.toLowerCase();else{const n=Cu(e);if("npub"!==n.type)throw new Error("Invalid npub — expected an npub1... string or 64-char hex pubkey");t=n.data}localStorage.setItem("nostr_auth_method","npub"),localStorage.setItem("nostr_pubkey",t),i("login",{method:"npub",pubkey:t,signer:null}),B()}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}}async function D(){n(7,d=!0),n(10,p=""),n(11,g="");try{if(!l.trim())throw new Error("Please enter your nsec");if(!function(e){if(!e||!e.startsWith("nsec1"))return!1;try{return"nsec"===Cu(e).type}catch{return!1}}(l.trim()))throw new Error("Invalid nsec format or checksum");if(a){if(a.length<8)throw new Error("Password must be at least 8 characters");if(a!==c)throw new Error("Passwords do not match")}const e=Ff.fromKey(l.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),a){n(9,h=!0),k();const e=await async function(e,t){if(!e.startsWith("nsec1"))throw new Error("Invalid nsec format - must start with nsec1");try{if("nsec"!==Cu(e).type)throw new Error("Invalid nsec - wrong type")}catch(e){throw new Error("Invalid nsec - bech32 checksum failed")}const n=crypto.getRandomValues(new Uint8Array(32)),i=crypto.getRandomValues(new Uint8Array(12)),s=await sg(t,n),r=await crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["encrypt"]),o=new TextEncoder,l=await crypto.subtle.encrypt({name:"AES-GCM",iv:i},r,o.encode(e)),a=new Uint8Array(n.length+i.length+l.byteLength);return a.set(n,0),a.set(i,n.length),a.set(new Uint8Array(l),n.length+i.length),btoa(String.fromCharCode(...a))}(l.trim(),a);C(),n(9,h=!1),localStorage.setItem("nostr_privkey_encrypted",e),localStorage.removeItem("nostr_privkey")}else localStorage.setItem("nostr_privkey",l.trim()),localStorage.removeItem("nostr_privkey_encrypted"),n(11,g="Successfully logged in with nsec!");i("login",{method:"nsec",pubkey:t,privateKey:l.trim(),signer:e}),setTimeout(()=>{B()},1500)}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}}R(()=>{S()});return e.$$set=e=>{"showModal"in e&&n(0,s=e.showModal),"isDarkTheme"in e&&n(1,r=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&s&&S()},[s,r,o,l,a,c,u,d,f,h,p,g,v,y,w,E,x,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(15,E=!1),n(16,x=""),n(6,u=""),n(10,p=""),n(11,g="")},B,async function(){n(7,d=!0),n(9,h=!0),k(),n(10,p=""),n(11,g="");try{if(!u)throw new Error("Please enter your password");const e=localStorage.getItem("nostr_privkey_encrypted");if(!e)throw new Error("No encrypted key found");const t=await async function(e,t){const n=new Uint8Array(atob(e).split("").map(e=>e.charCodeAt(0)));if(n.length<60)throw new Error("Invalid encrypted data - too short");const i=n.slice(0,32),s=n.slice(32,44),r=n.slice(44),o=await sg(t,i),l=await crypto.subtle.importKey("raw",o,{name:"AES-GCM"},!1,["decrypt"]);let a;try{a=await crypto.subtle.decrypt({name:"AES-GCM",iv:s},l,r)}catch(e){throw new Error("Decryption failed - invalid password or corrupted data")}const c=(new TextDecoder).decode(a);if(!c.startsWith("nsec1"))throw new Error("Decryption produced invalid data - not an nsec");try{if("nsec"!==Cu(c).type)throw new Error("Decryption produced invalid nsec type")}catch(e){throw new Error("Decryption produced invalid nsec - bech32 checksum failed")}return c}(e,u);C(),n(9,h=!1);const s=Ff.fromKey(t),r=await s.getPublicKey();i("login",{method:"nsec",pubkey:r,privateKey:t,signer:s}),B()}catch(e){C(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,p="Invalid password"):n(10,p=e.message)}finally{n(7,d=!1),n(9,h=!1),C()}},$,async function(){n(8,f=!0),n(10,p=""),n(11,g="");try{const e=ru(),t=Su("nsec",e),i=xu(ou(e));m=t,n(12,v=i),n(3,l=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,p="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,p=""),n(11,g="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(11,g="Successfully logged in with extension!"),i("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{B()},1500))}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}},F,D,function(e){"Escape"===e.key&&B(),"Enter"===e.key&&"nsec"===o&&D(),"Enter"===e.key&&"npub"===o&&F()},function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},()=>$("extension"),()=>$("nsec"),()=>$("npub"),function(){y=this.value,n(13,y)},function(){u=this.value,n(6,u)},function(){l=this.value,n(3,l)},function(){a=this.value,n(4,a)},function(){c=this.value,n(5,c)},e=>"Escape"===e.key&&B()]}class xg extends fe{constructor(e){super(),de(this,e,Eg,Cg,r,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function Sg(e,t,n){const i=e.slice();return i[72]=t[n],i}function Bg(e,t,n){const i=e.slice();return i[75]=t[n],i}function $g(e,t,n){const i=e.slice();return i[72]=t[n],i}function Fg(e,t,n){const i=e.slice();return i[72]=t[n],i}function Dg(e,t,n){const i=e.slice();return i[72]=t[n],i}function Qg(e,t,n){const i=e.slice();return i[72]=t[n],i}function Pg(e,t,n){const i=e.slice();return i[72]=t[n],i}function Rg(e){let t,n,i;return{c(){t=m("div"),n=y(e[3]),I(t,"class",i="message "+e[4]+" svelte-1y8wjwc")},m(e,i){h(e,t,i),f(t,n)},p(e,s){8&s[0]&&E(n,e[3]),16&s[0]&&i!==(i="message "+e[4]+" svelte-1y8wjwc")&&I(t,"class",i)},d(e){e&&p(t)}}}function Tg(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,E,S,B,$,F,D,Q,P,R,T,L,_,N;function M(e,t){return e[5]&&e[5].length>0?_g:Lg}let U=M(e),O=U(e);function j(e,t){return e[8]&&e[8].length>0?Og:Ug}let z=j(e),H=z(e);return{c(){t=m("div"),n=m("div"),s=m("h3"),s.textContent="Banned Pubkeys",r=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=y("Ban Pubkey"),v=w(),b=m("div"),O.c(),k=w(),C=m("div"),E=m("h3"),E.textContent="Allowed Pubkeys",S=w(),B=m("div"),$=m("input"),F=w(),D=m("input"),Q=w(),P=m("button"),R=y("Allow Pubkey"),T=w(),L=m("div"),H.c(),I(s,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","Pubkey (64 hex chars)"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(E,"class","svelte-1y8wjwc"),I($,"type","text"),I($,"placeholder","Pubkey (64 hex chars)"),I($,"class","svelte-1y8wjwc"),I(D,"type","text"),I(D,"placeholder","Reason (optional)"),I(D,"class","svelte-1y8wjwc"),P.disabled=e[2],I(P,"class","svelte-1y8wjwc"),I(B,"class","add-form svelte-1y8wjwc"),I(L,"class","list svelte-1y8wjwc"),I(C,"class","section svelte-1y8wjwc"),I(t,"class","pubkeys-section")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),x(l,e[6]),f(o,a),f(o,c),x(c,e[7]),f(o,u),f(o,d),f(d,g),f(n,v),f(n,b),O.m(b,null),f(t,k),f(t,C),f(C,E),f(C,S),f(C,B),f(B,$),x($,e[9]),f(B,F),f(B,D),x(D,e[10]),f(B,Q),f(B,P),f(P,R),f(C,T),f(C,L),H.m(L,null),_||(N=[A(l,"input",e[43]),A(c,"input",e[44]),A(d,"click",e[25]),A($,"input",e[45]),A(D,"input",e[46]),A(P,"click",e[26])],_=!0)},p(e,t){64&t[0]&&l.value!==e[6]&&x(l,e[6]),128&t[0]&&c.value!==e[7]&&x(c,e[7]),4&t[0]&&(d.disabled=e[2]),U===(U=M(e))&&O?O.p(e,t):(O.d(1),O=U(e),O&&(O.c(),O.m(b,null))),512&t[0]&&$.value!==e[9]&&x($,e[9]),1024&t[0]&&D.value!==e[10]&&x(D,e[10]),4&t[0]&&(P.disabled=e[2]),z===(z=j(e))&&H?H.p(e,t):(H.d(1),H=z(e),H&&(H.c(),H.m(L,null)))},d(e){e&&p(t),O.d(),H.d(),_=!1,i(N)}}}function Lg(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No banned pubkeys configured.</p>",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function _g(e){let t,n=e[5],i=[];for(let t=0;t<n.length;t+=1)i[t]=Mg(Pg(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(32&s[0]){let r;for(n=e[5],r=0;r<n.length;r+=1){const o=Pg(e,n,r);i[r]?i[r].p(o,s):(i[r]=Mg(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function Ng(e){let t,n,i=e[72].reason+"";return{c(){t=m("span"),n=y(i),I(t,"class","reason svelte-1y8wjwc")},m(e,i){h(e,t,i),f(t,n)},p(e,t){32&t[0]&&i!==(i=e[72].reason+"")&&E(n,i)},d(e){e&&p(t)}}}function Mg(e){let t,n,i,s,r,o=e[72].pubkey+"",l=e[72].reason&&Ng(e);return{c(){t=m("div"),n=m("span"),i=y(o),s=w(),l&&l.c(),r=w(),I(n,"class","pubkey svelte-1y8wjwc"),I(t,"class","list-item svelte-1y8wjwc")},m(e,o){h(e,t,o),f(t,n),f(n,i),f(t,s),l&&l.m(t,null),f(t,r)},p(e,n){32&n[0]&&o!==(o=e[72].pubkey+"")&&E(i,o),e[72].reason?l?l.p(e,n):(l=Ng(e),l.c(),l.m(t,r)):l&&(l.d(1),l=null)},d(e){e&&p(t),l&&l.d()}}}function Ug(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No allowed pubkeys configured.</p>",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Og(e){let t,n=e[8],i=[];for(let t=0;t<n.length;t+=1)i[t]=zg(Qg(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(256&s[0]){let r;for(n=e[8],r=0;r<n.length;r+=1){const o=Qg(e,n,r);i[r]?i[r].p(o,s):(i[r]=zg(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function jg(e){let t,n,i=e[72].reason+"";return{c(){t=m("span"),n=y(i),I(t,"class","reason svelte-1y8wjwc")},m(e,i){h(e,t,i),f(t,n)},p(e,t){256&t[0]&&i!==(i=e[72].reason+"")&&E(n,i)},d(e){e&&p(t)}}}function zg(e){let t,n,i,s,r,o=e[72].pubkey+"",l=e[72].reason&&jg(e);return{c(){t=m("div"),n=m("span"),i=y(o),s=w(),l&&l.c(),r=w(),I(n,"class","pubkey svelte-1y8wjwc"),I(t,"class","list-item svelte-1y8wjwc")},m(e,o){h(e,t,o),f(t,n),f(n,i),f(t,s),l&&l.m(t,null),f(t,r)},p(e,n){256&n[0]&&o!==(o=e[72].pubkey+"")&&E(i,o),e[72].reason?l?l.p(e,n):(l=jg(e),l.c(),l.m(t,r)):l&&(l.d(1),l=null)},d(e){e&&p(t),l&&l.d()}}}function Hg(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,E,S,B,$,F,D,Q,P,R,T,L,_,N;function M(e,t){return e[11]&&e[11].length>0?Gg:qg}let U=M(e),O=U(e);let j=function(e){return e[22]&&e[22].length>0?Wg:Vg}(e),z=j(e);return{c(){t=m("div"),n=m("div"),s=m("h3"),s.textContent="Banned Events",r=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=y("Ban Event"),v=w(),b=m("div"),O.c(),k=w(),C=m("div"),E=m("h3"),E.textContent="Allowed Events",S=w(),B=m("div"),$=m("input"),F=w(),D=m("input"),Q=w(),P=m("button"),R=y("Allow Event"),T=w(),L=m("div"),z.c(),I(s,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","Event ID (64 hex chars)"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(E,"class","svelte-1y8wjwc"),I($,"type","text"),I($,"placeholder","Event ID (64 hex chars)"),I($,"class","svelte-1y8wjwc"),I(D,"type","text"),I(D,"placeholder","Reason (optional)"),I(D,"class","svelte-1y8wjwc"),P.disabled=e[2],I(P,"class","svelte-1y8wjwc"),I(B,"class","add-form svelte-1y8wjwc"),I(L,"class","list svelte-1y8wjwc"),I(C,"class","section svelte-1y8wjwc"),I(t,"class","events-section")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),x(l,e[12]),f(o,a),f(o,c),x(c,e[13]),f(o,u),f(o,d),f(d,g),f(n,v),f(n,b),O.m(b,null),f(t,k),f(t,C),f(C,E),f(C,S),f(C,B),f(B,$),x($,e[14]),f(B,F),f(B,D),x(D,e[15]),f(B,Q),f(B,P),f(P,R),f(C,T),f(C,L),z.m(L,null),_||(N=[A(l,"input",e[47]),A(c,"input",e[48]),A(d,"click",e[27]),A($,"input",e[49]),A(D,"input",e[50]),A(P,"click",e[28])],_=!0)},p(e,t){4096&t[0]&&l.value!==e[12]&&x(l,e[12]),8192&t[0]&&c.value!==e[13]&&x(c,e[13]),4&t[0]&&(d.disabled=e[2]),U===(U=M(e))&&O?O.p(e,t):(O.d(1),O=U(e),O&&(O.c(),O.m(b,null))),16384&t[0]&&$.value!==e[14]&&x($,e[14]),32768&t[0]&&D.value!==e[15]&&x(D,e[15]),4&t[0]&&(P.disabled=e[2]),z.p(e,t)},d(e){e&&p(t),O.d(),z.d(),_=!1,i(N)}}}function qg(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No banned events configured.</p>",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Gg(e){let t,n=e[11],i=[];for(let t=0;t<n.length;t+=1)i[t]=Kg(Dg(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(2048&s[0]){let r;for(n=e[11],r=0;r<n.length;r+=1){const o=Dg(e,n,r);i[r]?i[r].p(o,s):(i[r]=Kg(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function Jg(e){let t,n,i=e[72].reason+"";return{c(){t=m("span"),n=y(i),I(t,"class","reason svelte-1y8wjwc")},m(e,i){h(e,t,i),f(t,n)},p(e,t){2048&t[0]&&i!==(i=e[72].reason+"")&&E(n,i)},d(e){e&&p(t)}}}function Kg(e){let t,n,i,s,r,o=e[72].id+"",l=e[72].reason&&Jg(e);return{c(){t=m("div"),n=m("span"),i=y(o),s=w(),l&&l.c(),r=w(),I(n,"class","event-id svelte-1y8wjwc"),I(t,"class","list-item svelte-1y8wjwc")},m(e,o){h(e,t,o),f(t,n),f(n,i),f(t,s),l&&l.m(t,null),f(t,r)},p(e,n){2048&n[0]&&o!==(o=e[72].id+"")&&E(i,o),e[72].reason?l?l.p(e,n):(l=Jg(e),l.c(),l.m(t,r)):l&&(l.d(1),l=null)},d(e){e&&p(t),l&&l.d()}}}function Vg(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No allowed events configured.</p>",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Wg(e){let t,n=e[22],i=[];for(let t=0;t<n.length;t+=1)i[t]=Yg(Fg(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(4194304&s[0]){let r;for(n=e[22],r=0;r<n.length;r+=1){const o=Fg(e,n,r);i[r]?i[r].p(o,s):(i[r]=Yg(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function Yg(t){let n,i,s,r,o,l=t[72].id+"",a=t[72].reason&&function(t){let n,i,s=t[72].reason+"";return{c(){n=m("span"),i=y(s),I(n,"class","reason svelte-1y8wjwc")},m(e,t){h(e,n,t),f(n,i)},p:e,d(e){e&&p(n)}}}(t);return{c(){n=m("div"),i=m("span"),s=y(l),r=w(),a&&a.c(),o=w(),I(i,"class","event-id svelte-1y8wjwc"),I(n,"class","list-item svelte-1y8wjwc")},m(e,t){h(e,n,t),f(n,i),f(i,s),f(n,r),a&&a.m(n,null),f(n,o)},p(e,t){e[72].reason&&a.p(e,t)},d(e){e&&p(n),a&&a.d()}}}function Zg(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C;function E(e,t){return e[16]&&e[16].length>0?em:Xg}let S=E(e),B=S(e);return{c(){t=m("div"),n=m("div"),s=m("h3"),s.textContent="Blocked IPs",r=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=y("Block IP"),v=w(),b=m("div"),B.c(),I(s,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","IP Address"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","ips-section")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),x(l,e[17]),f(o,a),f(o,c),x(c,e[18]),f(o,u),f(o,d),f(d,g),f(n,v),f(n,b),B.m(b,null),k||(C=[A(l,"input",e[51]),A(c,"input",e[52]),A(d,"click",e[29])],k=!0)},p(e,t){131072&t[0]&&l.value!==e[17]&&x(l,e[17]),262144&t[0]&&c.value!==e[18]&&x(c,e[18]),4&t[0]&&(d.disabled=e[2]),S===(S=E(e))&&B?B.p(e,t):(B.d(1),B=S(e),B&&(B.c(),B.m(b,null)))},d(e){e&&p(t),B.d(),k=!1,i(C)}}}function Xg(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No blocked IPs configured.</p>",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function em(e){let t,n=e[16],i=[];for(let t=0;t<n.length;t+=1)i[t]=nm($g(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(65536&s[0]){let r;for(n=e[16],r=0;r<n.length;r+=1){const o=$g(e,n,r);i[r]?i[r].p(o,s):(i[r]=nm(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function tm(e){let t,n,i=e[72].reason+"";return{c(){t=m("span"),n=y(i),I(t,"class","reason svelte-1y8wjwc")},m(e,i){h(e,t,i),f(t,n)},p(e,t){65536&t[0]&&i!==(i=e[72].reason+"")&&E(n,i)},d(e){e&&p(t)}}}function nm(e){let t,n,i,s,r,o=e[72].ip+"",l=e[72].reason&&tm(e);return{c(){t=m("div"),n=m("span"),i=y(o),s=w(),l&&l.c(),r=w(),I(n,"class","ip svelte-1y8wjwc"),I(t,"class","list-item svelte-1y8wjwc")},m(e,o){h(e,t,o),f(t,n),f(n,i),f(t,s),l&&l.m(t,null),f(t,r)},p(e,n){65536&n[0]&&o!==(o=e[72].ip+"")&&E(i,o),e[72].reason?l?l.p(e,n):(l=tm(e),l.c(),l.m(t,r)):l&&(l.d(1),l=null)},d(e){e&&p(t),l&&l.d()}}}function im(e){let t,n,s,r,o,l,a,c,u,d,g,v,b;function k(e,t){return e[19]&&e[19].length>0?rm:sm}let E=k(e),S=E(e);return{c(){t=m("div"),n=m("div"),s=m("h3"),s.textContent="Allowed Event Kinds",r=w(),o=m("div"),l=m("input"),a=w(),c=m("button"),u=y("Allow Kind"),d=w(),g=m("div"),S.c(),I(s,"class","svelte-1y8wjwc"),I(l,"type","number"),I(l,"placeholder","Kind number"),I(l,"class","svelte-1y8wjwc"),c.disabled=e[2],I(c,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(g,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","kinds-section")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),x(l,e[20]),f(o,a),f(o,c),f(c,u),f(n,d),f(n,g),S.m(g,null),v||(b=[A(l,"input",e[53]),A(c,"click",e[30])],v=!0)},p(e,t){1048576&t[0]&&C(l.value)!==e[20]&&x(l,e[20]),4&t[0]&&(c.disabled=e[2]),E===(E=k(e))&&S?S.p(e,t):(S.d(1),S=E(e),S&&(S.c(),S.m(g,null)))},d(e){e&&p(t),S.d(),v=!1,i(b)}}}function sm(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No allowed kinds configured. All kinds are\n                                    allowed by default.</p>",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function rm(e){let t,n=e[19],i=[];for(let t=0;t<n.length;t+=1)i[t]=om(Bg(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(524288&s[0]|1&s[1]){let r;for(n=e[19],r=0;r<n.length;r+=1){const o=Bg(e,n,r);i[r]?i[r].p(o,s):(i[r]=om(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function om(e){let t,n,i,s,r,o,l,a,c,u=e[75]+"";function d(){return e[54](e[75])}return{c(){t=m("div"),n=m("span"),i=y("Kind "),s=y(u),r=w(),o=m("button"),o.textContent="Remove",l=w(),I(n,"class","kind svelte-1y8wjwc"),I(o,"class","remove-btn svelte-1y8wjwc"),I(t,"class","list-item svelte-1y8wjwc")},m(e,u){h(e,t,u),f(t,n),f(n,i),f(n,s),f(t,r),f(t,o),f(t,l),a||(c=A(o,"click",d),a=!0)},p(t,n){e=t,524288&n[0]&&u!==(u=e[75]+"")&&E(s,u)},d(e){e&&p(t),a=!1,c()}}}function lm(e){let t,n,i,s,r,o,l,a,c,u;function d(e,t){return e[21]&&e[21].length>0?cm:am}let g=d(e),v=g(e);return{c(){t=m("div"),n=m("div"),i=m("h3"),i.textContent="Events Needing Moderation",s=w(),r=m("button"),o=y("Refresh"),l=w(),a=m("div"),v.c(),I(i,"class","svelte-1y8wjwc"),r.disabled=e[2],I(a,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","moderation-section")},m(d,p){h(d,t,p),f(t,n),f(n,i),f(n,s),f(n,r),f(r,o),f(n,l),f(n,a),v.m(a,null),c||(u=A(r,"click",e[24]),c=!0)},p(e,t){4&t[0]&&(r.disabled=e[2]),g===(g=d(e))&&v?v.p(e,t):(v.d(1),v=g(e),v&&(v.c(),v.m(a,null)))},d(e){e&&p(t),v.d(),c=!1,u()}}}function am(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No events need moderation at this time.</p>",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function cm(e){let t,n=e[21],i=[];for(let t=0;t<n.length;t+=1)i[t]=dm(Sg(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(2097152&s[0]|12&s[1]){let r;for(n=e[21],r=0;r<n.length;r+=1){const o=Sg(e,n,r);i[r]?i[r].p(o,s):(i[r]=dm(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function um(e){let t,n,i=e[72].reason+"";return{c(){t=m("span"),n=y(i),I(t,"class","reason svelte-1y8wjwc")},m(e,i){h(e,t,i),f(t,n)},p(e,t){2097152&t[0]&&i!==(i=e[72].reason+"")&&E(n,i)},d(e){e&&p(t)}}}function dm(e){let t,n,s,r,o,l,a,c,u,d,g,v,b=e[72].id+"",k=e[72].reason&&um(e);function C(){return e[55](e[72])}function x(){return e[56](e[72])}return{c(){t=m("div"),n=m("span"),s=y(b),r=w(),k&&k.c(),o=w(),l=m("div"),a=m("button"),a.textContent="Allow",c=w(),u=m("button"),u.textContent="Ban",d=w(),I(n,"class","event-id svelte-1y8wjwc"),I(a,"class","svelte-1y8wjwc"),I(u,"class","svelte-1y8wjwc"),I(l,"class","actions svelte-1y8wjwc"),I(t,"class","list-item svelte-1y8wjwc")},m(e,i){h(e,t,i),f(t,n),f(n,s),f(t,r),k&&k.m(t,null),f(t,o),f(t,l),f(l,a),f(l,c),f(l,u),f(t,d),g||(v=[A(a,"click",C),A(u,"click",x)],g=!0)},p(n,i){e=n,2097152&i[0]&&b!==(b=e[72].id+"")&&E(s,b),e[72].reason?k?k.p(e,i):(k=um(e),k.c(),k.m(t,o)):k&&(k.d(1),k=null)},d(e){e&&p(t),k&&k.d(),g=!1,i(v)}}}function fm(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,E,S,B,$,F,D,Q,P,R,T,L,_,N;function M(e,t){return e[2]?pm:hm}let U=M(e),O=U(e);return{c(){t=m("div"),n=m("div"),s=m("h3"),s.textContent="Relay Configuration",r=w(),o=m("div"),l=m("button"),a=y("🔄 Refresh from Relay Info"),c=w(),u=m("div"),d=m("div"),g=m("label"),g.textContent="Relay Name",v=w(),b=m("input"),k=w(),C=m("div"),E=m("label"),E.textContent="Relay Description",S=w(),B=m("textarea"),$=w(),F=m("div"),D=m("label"),D.textContent="Relay Icon URL",Q=w(),P=m("input"),R=w(),T=m("div"),L=m("button"),O.c(),I(s,"class","svelte-1y8wjwc"),l.disabled=e[2],I(l,"class","refresh-btn svelte-1y8wjwc"),I(o,"class","config-actions svelte-1y8wjwc"),I(g,"for","relay-name"),I(g,"class","svelte-1y8wjwc"),I(b,"id","relay-name"),I(b,"type","text"),I(b,"placeholder","Enter relay name"),I(b,"class","svelte-1y8wjwc"),I(d,"class","form-group svelte-1y8wjwc"),I(E,"for","relay-description"),I(E,"class","svelte-1y8wjwc"),I(B,"id","relay-description"),I(B,"placeholder","Enter relay description"),I(B,"class","svelte-1y8wjwc"),I(C,"class","form-group svelte-1y8wjwc"),I(D,"for","relay-icon"),I(D,"class","svelte-1y8wjwc"),I(P,"id","relay-icon"),I(P,"type","url"),I(P,"placeholder","Enter icon URL"),I(P,"class","svelte-1y8wjwc"),I(F,"class","form-group svelte-1y8wjwc"),L.disabled=e[2],I(L,"class","update-all-btn svelte-1y8wjwc"),I(T,"class","config-update-section svelte-1y8wjwc"),I(u,"class","config-form svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","relay-section")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(n,c),f(n,u),f(u,d),f(d,g),f(d,v),f(d,b),x(b,e[0].relay_name),f(u,k),f(u,C),f(C,E),f(C,S),f(C,B),x(B,e[0].relay_description),f(u,$),f(u,F),f(F,D),f(F,Q),f(F,P),x(P,e[0].relay_icon),f(u,R),f(u,T),f(T,L),O.m(L,null),_||(N=[A(l,"click",e[23]),A(b,"input",e[57]),A(B,"input",e[58]),A(P,"input",e[59]),A(L,"click",e[32])],_=!0)},p(e,t){4&t[0]&&(l.disabled=e[2]),1&t[0]&&b.value!==e[0].relay_name&&x(b,e[0].relay_name),1&t[0]&&x(B,e[0].relay_description),1&t[0]&&P.value!==e[0].relay_icon&&x(P,e[0].relay_icon),U!==(U=M(e))&&(O.d(1),O=U(e),O&&(O.c(),O.m(L,null))),4&t[0]&&(L.disabled=e[2])},d(e){e&&p(t),O.d(),_=!1,i(N)}}}function hm(e){let t;return{c(){t=y("💾 Update Configuration")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function pm(e){let t;return{c(){t=y("⏳ Updating...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function gm(t){let n,s,r,o,l,a,c,u,d,g,v,b,k,C,E,x,S,B,$,F,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K=t[3]&&Rg(t),V="pubkeys"===t[1]&&Tg(t),W="events"===t[1]&&Hg(t),Y="ips"===t[1]&&Zg(t),Z="kinds"===t[1]&&im(t),X="moderation"===t[1]&&lm(t),ee="relay"===t[1]&&fm(t);return{c(){n=m("div"),s=m("div"),s.innerHTML='<h2 class="svelte-1y8wjwc">Managed ACL Configuration</h2> \n        <p class="svelte-1y8wjwc">Configure access control using NIP-86 management API</p> \n        <div class="owner-only-notice svelte-1y8wjwc"><strong>Owner Only:</strong> This interface is restricted to relay owners\n            only.</div>',r=w(),K&&K.c(),o=w(),l=m("div"),a=m("button"),c=y("Pubkeys"),d=w(),g=m("button"),v=y("Events"),k=w(),C=m("button"),E=y("IPs"),S=w(),B=m("button"),$=y("Kinds"),D=w(),Q=m("button"),P=y("Moderation"),T=w(),L=m("button"),_=y("Relay Config"),M=w(),U=m("div"),V&&V.c(),O=w(),W&&W.c(),j=w(),Y&&Y.c(),z=w(),Z&&Z.c(),H=w(),X&&X.c(),q=w(),ee&&ee.c(),I(s,"class","header svelte-1y8wjwc"),I(a,"class",u="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),I(g,"class",b="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),I(C,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),I(B,"class",F="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),I(Q,"class",R="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),I(L,"class",N="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),I(l,"class","tabs svelte-1y8wjwc"),I(U,"class","tab-content svelte-1y8wjwc")},m(e,i){h(e,n,i),f(n,s),f(n,r),K&&K.m(n,null),f(n,o),f(n,l),f(l,a),f(a,c),f(l,d),f(l,g),f(g,v),f(l,k),f(l,C),f(C,E),f(l,S),f(l,B),f(B,$),f(l,D),f(l,Q),f(Q,P),f(l,T),f(l,L),f(L,_),f(n,M),f(n,U),V&&V.m(U,null),f(U,O),W&&W.m(U,null),f(U,j),Y&&Y.m(U,null),f(U,z),Z&&Z.m(U,null),f(U,H),X&&X.m(U,null),f(U,q),ee&&ee.m(U,null),G||(J=[A(a,"click",t[37]),A(g,"click",t[38]),A(C,"click",t[39]),A(B,"click",t[40]),A(Q,"click",t[41]),A(L,"click",t[42])],G=!0)},p(e,t){e[3]?K?K.p(e,t):(K=Rg(e),K.c(),K.m(n,o)):K&&(K.d(1),K=null),2&t[0]&&u!==(u="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(a,"class",u),2&t[0]&&b!==(b="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(g,"class",b),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(C,"class",x),2&t[0]&&F!==(F="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(B,"class",F),2&t[0]&&R!==(R="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(Q,"class",R),2&t[0]&&N!==(N="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(L,"class",N),"pubkeys"===e[1]?V?V.p(e,t):(V=Tg(e),V.c(),V.m(U,O)):V&&(V.d(1),V=null),"events"===e[1]?W?W.p(e,t):(W=Hg(e),W.c(),W.m(U,j)):W&&(W.d(1),W=null),"ips"===e[1]?Y?Y.p(e,t):(Y=Zg(e),Y.c(),Y.m(U,z)):Y&&(Y.d(1),Y=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=im(e),Z.c(),Z.m(U,H)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=lm(e),X.c(),X.m(U,q)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=fm(e),ee.c(),ee.m(U,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&p(n),K&&K.d(),V&&V.d(),W&&W.d(),Y&&Y.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),G=!1,i(J)}}}function mm(e,t,n){let{userSigner:i}=t,{userPubkey:s}=t,r="pubkeys",o=!1,l="",a="info",c=[],u="",d="",f=[],h="",p="",g=[],m="",v="",y="",w="",b=[],A="",k="",I=[],E="",x=[],S={relay_name:"",relay_description:"",relay_icon:""};async function B(){try{n(2,o=!0),console.log("Fetching relay info from /");const e=await fetch(Lh()+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,S={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",S),console.log("Loaded relay info:",t),n(3,l="Relay configuration loaded successfully"),n(4,a="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,l=`Failed to fetch relay info: ${e.status}`),n(4,a="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,l=`Failed to fetch relay info: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}}async function $(e,t=[]){try{n(2,o=!0),n(3,l="");const r={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!s)throw new Error("No user pubkey available for authentication.");const n=Lh()+t,r={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:s},o=await i.signEvent(r),l=JSON.stringify(o);return`Nostr ${btoa(l)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(r)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,l=e.message),n(4,a="error"),e}finally{n(2,o=!1)}}async function F(){try{n(5,c=await $("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function D(){try{n(8,f=await $("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function Q(){try{n(11,g=await $("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function P(){try{n(16,b=await $("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function T(){try{n(19,I=await $("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function L(){try{n(2,o=!0),n(21,x=await $("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",x)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,l=`Failed to load moderation events: ${e.message}`),n(4,a="error"),n(21,x=[])}finally{n(2,o=!1)}}async function _(e){try{await $("disallowkind",[e]),n(3,l="Kind disallowed successfully"),n(4,a="success"),await T()}catch(e){console.error("Failed to disallow kind:",e)}}async function N(e){try{await $("allowevent",[e,"Approved from moderation queue"]),n(3,l="Event allowed successfully"),n(4,a="success"),await L()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function M(e){try{await $("banevent",[e,"Banned from moderation queue"]),n(3,l="Event banned successfully"),n(4,a="success"),await L()}catch(e){console.error("Failed to ban event from moderation:",e)}}R(()=>{setTimeout(()=>{B()},100)}),async function(){await Promise.all([F(),D(),Q(),P(),T()])}();return e.$$set=e=>{"userSigner"in e&&n(35,i=e.userSigner),"userPubkey"in e&&n(36,s=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",S)},[S,r,o,l,a,c,u,d,f,h,p,g,m,v,y,w,b,A,k,I,E,x,[],B,L,async function(){if(u)try{await $("banpubkey",[u,d]),n(3,l="Pubkey banned successfully"),n(4,a="success"),n(6,u=""),n(7,d=""),await F()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await $("allowpubkey",[h,p]),n(3,l="Pubkey allowed successfully"),n(4,a="success"),n(9,h=""),n(10,p=""),await D()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await $("banevent",[m,v]),n(3,l="Event banned successfully"),n(4,a="success"),n(12,m=""),n(13,v=""),await Q()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(y)try{await $("allowevent",[y,w]),n(3,l="Event allowed successfully"),n(4,a="success"),n(14,y=""),n(15,w="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(A)try{await $("blockip",[A,k]),n(3,l="IP blocked successfully"),n(4,a="success"),n(17,A=""),n(18,k=""),await P()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!E)return;const e=parseInt(E);if(isNaN(e))return n(3,l="Invalid kind number"),void n(4,a="error");try{await $("allowkind",[e]),n(3,l="Kind allowed successfully"),n(4,a="success"),n(20,E=""),await T()}catch(e){console.error("Failed to allow kind:",e)}},_,async function(){try{n(2,o=!0),n(3,l="");const e=[];if(S.relay_name&&e.push($("changerelayname",[S.relay_name])),S.relay_description&&e.push($("changerelaydescription",[S.relay_description])),S.relay_icon&&e.push($("changerelayicon",[S.relay_icon])),0===e.length)return n(3,l="No changes to update"),void n(4,a="info");await Promise.all(e),n(3,l="Relay configuration updated successfully"),n(4,a="success"),await B()}catch(e){console.error("Failed to update relay configuration:",e),n(3,l=`Failed to update relay configuration: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}},N,M,i,s,()=>n(1,r="pubkeys"),()=>n(1,r="events"),()=>n(1,r="ips"),()=>n(1,r="kinds"),()=>{n(1,r="moderation"),x&&0!==x.length||L()},()=>n(1,r="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){h=this.value,n(9,h)},function(){p=this.value,n(10,p)},function(){m=this.value,n(12,m)},function(){v=this.value,n(13,v)},function(){y=this.value,n(14,y)},function(){w=this.value,n(15,w)},function(){A=this.value,n(17,A)},function(){k=this.value,n(18,k)},function(){E=C(this.value),n(20,E)},e=>_(e),e=>N(e.id),e=>M(e.id),function(){S.relay_name=this.value,n(0,S)},function(){S.relay_description=this.value,n(0,S)},function(){S.relay_icon=this.value,n(0,S)}]}class vm extends fe{constructor(e){super(),de(this,e,mm,gm,r,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}const ym=wh({items:[],unreadCount:0,lastChecked:0}),wm=wh({items:[],unreadCount:0,lastChecked:0}),bm=wh({items:[],unreadCount:0,lastChecked:0}),Am=wh(0),km=wh(0),Im=bh([ym,wm,bm,Am,km],([e,t,n,i,s])=>e.unreadCount+t.unreadCount+n.unreadCount+i+s);function Cm(e,t){e.update(e=>{const n=new Set(e.items.map(e=>e.id)),i=t.filter(e=>!n.has(e.id)),s=i.filter(t=>t.created_at>e.lastChecked).length;return{items:[...i,...e.items].sort((e,t)=>t.created_at-e.created_at).slice(0,100),unreadCount:e.unreadCount+s,lastChecked:e.lastChecked}})}function Em(e){const t={replies:ym,reactions:wm,zaps:bm}[e];t&&t.update(e=>({...e,unreadCount:0,lastChecked:Date.now()}))}function xm(e,t,n){const i=e.slice();return i[27]=t[n],i}function Sm(e){let t,n;return{c(){t=m("span"),n=y(e[3]),I(t,"class","permission-badge svelte-1uzsjdi")},m(e,i){h(e,t,i),f(t,n)},p(e,t){8&t&&E(n,e[3])},d(e){e&&p(t)}}}function Bm(e){let t,n,i,s,r,o;return{c(){t=m("div"),n=m("span"),i=w(),s=m("span"),r=y(e[7]),I(n,"class","relay-status svelte-1uzsjdi"),F(n,"connected","connected"===e[8]),F(n,"error","error"===e[8]),I(s,"class","relay-name svelte-1uzsjdi"),I(t,"class","relay-indicator static svelte-1uzsjdi"),I(t,"title",o="Connected to "+e[7])},m(e,o){h(e,t,o),f(t,n),f(t,i),f(t,s),f(s,r)},p(e,i){256&i&&F(n,"connected","connected"===e[8]),256&i&&F(n,"error","error"===e[8]),128&i&&E(r,e[7]),128&i&&o!==(o="Connected to "+e[7])&&I(t,"title",o)},d(e){e&&p(t)}}}function $m(e){let t,n,i,s,r,o,l,a,c,u,d,g=e[4]&&Fm(e);return{c(){t=m("button"),n=m("span"),i=w(),s=m("span"),r=y(e[7]),o=w(),l=m("span"),l.textContent="▾",a=w(),g&&g.c(),c=b(),I(n,"class","relay-status svelte-1uzsjdi"),F(n,"connected","connected"===e[8]),F(n,"error","error"===e[8]),I(s,"class","relay-name svelte-1uzsjdi"),I(l,"class","dropdown-arrow svelte-1uzsjdi"),F(l,"open",e[4]),I(t,"class","relay-indicator svelte-1uzsjdi"),I(t,"title","Click to switch relays")},m(p,m){h(p,t,m),f(t,n),f(t,i),f(t,s),f(s,r),f(t,o),f(t,l),h(p,a,m),g&&g.m(p,m),h(p,c,m),u||(d=A(t,"click",e[15]),u=!0)},p(e,t){256&t&&F(n,"connected","connected"===e[8]),256&t&&F(n,"error","error"===e[8]),128&t&&E(r,e[7]),16&t&&F(l,"open",e[4]),e[4]?g?g.p(e,t):(g=Fm(e),g.c(),g.m(c.parentNode,c)):g&&(g.d(1),g=null)},d(e){e&&p(t),e&&p(a),g&&g.d(e),e&&p(c),u=!1,d()}}}function Fm(e){let t,n,s,r,o,l=e[10].length>0&&Dm(e);return{c(){t=m("div"),l&&l.c(),n=w(),s=m("button"),s.textContent="Manage Relays...",I(s,"class","dropdown-item manage-btn svelte-1uzsjdi"),I(t,"class","relay-dropdown svelte-1uzsjdi")},m(i,a){h(i,t,a),l&&l.m(t,null),f(t,n),f(t,s),r||(o=[A(s,"click",e[17]),A(t,"click",k(e[21]))],r=!0)},p(e,i){e[10].length>0?l?l.p(e,i):(l=Dm(e),l.c(),l.m(t,n)):l&&(l.d(1),l=null)},d(e){e&&p(t),l&&l.d(),r=!1,i(o)}}}function Dm(e){let t,n,i,s,r,o=e[10],l=[];for(let t=0;t<o.length;t+=1)l[t]=Pm(xm(e,o,t));return{c(){t=m("div"),n=m("div"),n.textContent="Saved Relays",i=w();for(let e=0;e<l.length;e+=1)l[e].c();s=w(),r=m("div"),I(n,"class","dropdown-label svelte-1uzsjdi"),I(t,"class","dropdown-section svelte-1uzsjdi"),I(r,"class","dropdown-divider svelte-1uzsjdi")},m(e,o){h(e,t,o),f(t,n),f(t,i);for(let e=0;e<l.length;e+=1)l[e]&&l[e].m(t,null);h(e,s,o),h(e,r,o)},p(e,n){if(590944&n){let i;for(o=e[10],i=0;i<o.length;i+=1){const s=xm(e,o,i);l[i]?l[i].p(s,n):(l[i]=Pm(s),l[i].c(),l[i].m(t,null))}for(;i<l.length;i+=1)l[i].d(1);l.length=o.length}},d(e){e&&p(t),g(l,e),e&&p(s),e&&p(r)}}}function Qm(e){let t;return{c(){t=m("span"),t.textContent="...",I(t,"class","connecting-indicator svelte-1uzsjdi")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Pm(e){let t,n,i,s,r,o,l,a,c,u=e[27].name+"",d=e[6]===e[27].url&&Qm();function g(){return e[22](e[27])}return{c(){t=m("button"),n=m("span"),i=w(),s=m("span"),r=y(u),o=w(),d&&d.c(),l=w(),I(n,"class","item-status svelte-1uzsjdi"),F(n,"connected",e[19](e[27].url)),I(s,"class","item-url-label svelte-1uzsjdi"),I(t,"class","dropdown-item svelte-1uzsjdi"),t.disabled=e[5],F(t,"current",e[19](e[27].url)),F(t,"connecting",e[6]===e[27].url)},m(e,u){h(e,t,u),f(t,n),f(t,i),f(t,s),f(s,r),f(t,o),d&&d.m(t,null),f(t,l),a||(c=A(t,"click",g),a=!0)},p(i,s){e=i,525312&s&&F(n,"connected",e[19](e[27].url)),1024&s&&u!==(u=e[27].name+"")&&E(r,u),e[6]===e[27].url?d||(d=Qm(),d.c(),d.m(t,l)):d&&(d.d(1),d=null),32&s&&(t.disabled=e[5]),525312&s&&F(t,"current",e[19](e[27].url)),1088&s&&F(t,"connecting",e[6]===e[27].url)},d(e){e&&p(t),d&&d.d(),a=!1,c()}}}function Rm(e){let t,n,i=(e[11]>99?"99+":e[11])+"";return{c(){t=m("span"),n=y(i),I(t,"class","notification-badge svelte-1uzsjdi")},m(e,i){h(e,t,i),f(t,n)},p(e,t){2048&t&&i!==(i=(e[11]>99?"99+":e[11])+"")&&E(n,i)},d(e){e&&p(t)}}}function Tm(t){let n,s,r,o,l,a,c,u,d,g,y,b,k,C,E,x,S,B,$=t[1]&&t[2]&&Sm(t);function D(e,t){return e[9]?$m:Bm}let Q=D(t),P=Q(t),R=t[11]>0&&Rm(t);return{c(){n=m("header"),s=m("div"),r=m("button"),r.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-1uzsjdi"><path d="M3 12h18M3 6h18M3 18h18"></path></svg>',o=w(),$&&$.c(),l=w(),a=m("div"),c=w(),u=m("div"),P.c(),d=w(),g=m("button"),g.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1uzsjdi"><circle cx="11" cy="11" r="8"></circle><path d="M21 21l-4.35-4.35"></path></svg>',y=w(),b=m("button"),k=v("svg"),C=v("path"),E=v("path"),x=w(),R&&R.c(),I(r,"class","mobile-menu-btn svelte-1uzsjdi"),I(r,"aria-label","Toggle menu"),I(a,"class","header-spacer svelte-1uzsjdi"),I(u,"class","relay-dropdown-container svelte-1uzsjdi"),I(g,"class","header-icon-btn svelte-1uzsjdi"),I(g,"title","Search"),I(g,"aria-label","Search"),I(C,"d","M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"),I(E,"d","M13.73 21a2 2 0 0 1-3.46 0"),I(k,"viewBox","0 0 24 24"),I(k,"fill","none"),I(k,"stroke","currentColor"),I(k,"stroke-width","2"),I(k,"stroke-linecap","round"),I(k,"stroke-linejoin","round"),I(k,"class","svelte-1uzsjdi"),I(b,"class","header-icon-btn notification-btn svelte-1uzsjdi"),I(b,"title","Notifications"),I(b,"aria-label","Notifications"),I(s,"class","header-content svelte-1uzsjdi"),I(n,"class","main-header svelte-1uzsjdi"),F(n,"dark-theme",t[0])},m(e,i){h(e,n,i),f(n,s),f(s,r),f(s,o),$&&$.m(s,null),f(s,l),f(s,a),f(s,c),f(s,u),P.m(u,null),f(s,d),f(s,g),f(s,y),f(s,b),f(b,k),f(k,C),f(k,E),f(b,x),R&&R.m(b,null),S||(B=[A(window,"click",t[18]),A(r,"click",t[14]),A(g,"click",t[12]),A(b,"click",t[13])],S=!0)},p(e,[t]){e[1]&&e[2]?$?$.p(e,t):($=Sm(e),$.c(),$.m(s,l)):$&&($.d(1),$=null),Q===(Q=D(e))&&P?P.p(e,t):(P.d(1),P=Q(e),P&&(P.c(),P.m(u,null))),e[11]>0?R?R.p(e,t):(R=Rm(e),R.c(),R.m(b,null)):R&&(R.d(1),R=null),1&t&&F(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&p(n),$&&$.d(),P.d(),R&&R.d(),S=!1,i(B)}}}function Lm(e,t,n){let i,s,r,o,l,a;u(e,Ch,e=>n(8,s=e)),u(e,Ah,e=>n(20,r=e)),u(e,kh,e=>n(9,o=e)),u(e,Sh,e=>n(10,l=e)),u(e,Im,e=>n(11,a=e));let{isDarkTheme:c=!1}=t,{isLoggedIn:d=!1}=t,{userRole:f=""}=t,{currentEffectiveRole:h=""}=t;const p=L();let g=!1,m=!1,v="";function y(){n(4,g=!1)}async function w(e){if(console.log("[Header] switchToRelay called with:",e),m||e===r)console.log("[Header] Skipping - already connecting or same relay");else{n(5,m=!0),n(6,v=e);try{console.log("[Header] Calling connectToRelay...");const t=await Oh(e);if(console.log("[Header] connectToRelay result:",t),t.success){Ph(e,zh(e)),p("relayChanged",{info:t.info}),y()}else console.log("[Header] Connection failed:",t.error)}catch(e){console.error("[Header] Failed to switch relay:",e)}finally{n(5,m=!1),n(6,v="")}}}return e.$$set=e=>{"isDarkTheme"in e&&n(0,c=e.isDarkTheme),"isLoggedIn"in e&&n(1,d=e.isLoggedIn),"userRole"in e&&n(2,f=e.userRole),"currentEffectiveRole"in e&&n(3,h=e.currentEffectiveRole)},e.$$.update=()=>{1048576&e.$$.dirty&&n(7,i=function(e){try{const t=e||Lh();return console.log("[Header] getRelayHost - storeUrl:",e,"resolved url:",t),new URL(t).host}catch{return e||"local"}}(r))},[c,d,f,h,g,m,v,i,s,o,l,a,function(){Fh.update(e=>!e)},function(){Dh.update(e=>!e)},function(){p("toggleMobileMenu")},function(e){e.stopPropagation(),n(4,g=!g)},w,function(e){e.stopPropagation(),y(),p("openRelayModal")},function(e){g&&y()},function(e){return r===e&&"connected"===s},r,function(t){_.call(this,e,t)},e=>w(e.url)]}class _m extends fe{constructor(e){super(),de(this,e,Lm,Tm,r,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3})}}const Nm=wh(localStorage.getItem("activeChatTab")||"inbox");Nm.subscribe(e=>localStorage.setItem("activeChatTab",e));const Mm=wh(new Map),Um=wh(null),Om=wh(!1),jm=wh(new Map),zm=localStorage.getItem("joinedChannels"),Hm=wh(new Set(zm?JSON.parse(zm):[]));Hm.subscribe(e=>localStorage.setItem("joinedChannels",JSON.stringify([...e])));const qm=wh(null),Gm=wh(!1),Jm=bh(Mm,e=>{let t=0;for(const n of e.values())t+=n.unreadCount||0;return t}),Km=bh(jm,e=>{let t=0;for(const n of e.values())n.joined&&(t+=n.unreadCount||0);return t});function Vm(e,t,n){const i=e.slice();return i[33]=t[n],i}function Wm(e,t,n){const i=e.slice();return i[36]=t[n],i}function Ym(t){let n,i,s;return{c(){n=m("div"),I(n,"class","mobile-overlay svelte-1uh113i")},m(e,r){h(e,n,r),i||(s=A(n,"click",t[23]),i=!0)},p:e,d(e){e&&p(n),i=!1,s()}}}function Zm(t){let n,i,s;return{c(){n=m("button"),n.textContent="Log in",I(n,"class","login-button svelte-1uh113i")},m(e,r){h(e,n,r),i||(s=A(n,"click",t[24]),i=!0)},p:e,d(e){e&&p(n),i=!1,s()}}}function Xm(e){let t,n,i,s,r,o,l=uv(e[1],e[2])+"";function a(e,t){return e[1]?.picture?tv:ev}let c=a(e),u=c(e);return{c(){t=m("button"),u.c(),n=w(),i=m("span"),s=y(l),I(i,"class","user-name svelte-1uh113i"),I(t,"class","user-button svelte-1uh113i")},m(l,a){h(l,t,a),u.m(t,null),f(t,n),f(t,i),f(i,s),r||(o=A(t,"click",e[13]),r=!0)},p(e,i){c===(c=a(e))&&u?u.p(e,i):(u.d(1),u=c(e),u&&(u.c(),u.m(t,n))),6&i[0]&&l!==(l=uv(e[1],e[2])+"")&&E(s,l)},d(e){e&&p(t),u.d(),r=!1,o()}}}function ev(e){let t,n,i=uv(e[1],e[2]).charAt(0).toUpperCase()+"";return{c(){t=m("div"),n=y(i),I(t,"class","user-avatar-placeholder svelte-1uh113i")},m(e,i){h(e,t,i),f(t,n)},p(e,t){6&t[0]&&i!==(i=uv(e[1],e[2]).charAt(0).toUpperCase()+"")&&E(n,i)},d(e){e&&p(t)}}}function tv(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[1].picture)||I(t,"src",n),I(t,"alt","avatar"),I(t,"class","user-avatar svelte-1uh113i")},m(e,n){h(e,t,n)},p(e,i){2&i[0]&&!l(t.src,n=e[1].picture)&&I(t,"src",n)},d(e){e&&p(t)}}}function nv(e){let t,n,i=e[6]===e[33].id?"▾":"▸";return{c(){t=m("span"),n=y(i),I(t,"class","section-chevron svelte-1uh113i")},m(e,i){h(e,t,i),f(t,n)},p(e,t){96&t[0]&&i!==(i=e[6]===e[33].id?"▾":"▸")&&E(n,i)},d(e){e&&p(t)}}}function iv(e){let t,n,i=e[11](e[33].id)+"";return{c(){t=m("span"),n=y(i),I(t,"class","unread-badge svelte-1uh113i")},m(e,i){h(e,t,i),f(t,n)},p(e,t){32&t[0]&&i!==(i=e[11](e[33].id)+"")&&E(n,i)},d(e){e&&p(t)}}}function sv(e){let t,n,i,s=e[33].children,r=[];for(let t=0;t<s.length;t+=1)r[t]=ov(Wm(e,s,t));return{c(){t=m("div");for(let e=0;e<r.length;e+=1)r[e].c();n=w(),i=m("div"),I(i,"class","section-boundary svelte-1uh113i"),I(t,"class","section-children svelte-1uh113i")},m(e,s){h(e,t,s);for(let e=0;e<r.length;e+=1)r[e]&&r[e].m(t,null);f(t,n),f(t,i)},p(e,i){if(5280&i[0]){let o;for(s=e[33].children,o=0;o<s.length;o+=1){const l=Wm(e,s,o);r[o]?r[o].p(l,i):(r[o]=ov(l),r[o].c(),r[o].m(t,n))}for(;o<r.length;o+=1)r[o].d(1);r.length=s.length}},d(e){e&&p(t),g(r,e)}}}function rv(e){let t,n,i=e[12](e[36].id)+"";return{c(){t=m("span"),n=y(i),I(t,"class","unread-badge small svelte-1uh113i")},m(e,i){h(e,t,i),f(t,n)},p(e,t){32&t[0]&&i!==(i=e[12](e[36].id)+"")&&E(n,i)},d(e){e&&p(t)}}}function ov(e){let t,n,i,s,r,o,l=e[36].label+"",a=e[12](e[36].id)>0,c=a&&rv(e);function u(){return e[27](e[36])}return{c(){t=m("button"),n=m("span"),i=y(l),s=w(),c&&c.c(),I(n,"class","child-label svelte-1uh113i"),I(t,"class","child-item svelte-1uh113i"),F(t,"active",e[7]===e[36].id)},m(e,l){h(e,t,l),f(t,n),f(n,i),f(t,s),c&&c.m(t,null),r||(o=A(t,"click",u),r=!0)},p(n,s){e=n,32&s[0]&&l!==(l=e[36].label+"")&&E(i,l),32&s[0]&&(a=e[12](e[36].id)>0),a?c?c.p(e,s):(c=rv(e),c.c(),c.m(t,null)):c&&(c.d(1),c=null),160&s[0]&&F(t,"active",e[7]===e[36].id)},d(e){e&&p(t),c&&c.d(),r=!1,o()}}}function lv(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b=e[33].icon+"",k=e[33].label+"",C=e[11](e[33].id)>0,x=e[33].children&&nv(e),S=C&&iv(e);function B(){return e[25](e[33])}let $=e[33].children&&e[6]===e[33].id&&sv(e);return{c(){t=m("div"),n=m("button"),i=m("span"),s=y(b),r=w(),o=m("span"),l=y(k),a=w(),x&&x.c(),c=w(),S&&S.c(),u=w(),$&&$.c(),d=w(),I(i,"class","section-icon svelte-1uh113i"),I(o,"class","section-label svelte-1uh113i"),I(n,"class","section-header svelte-1uh113i"),F(n,"active",e[7]===e[33].id||e[33].children&&e[33].children.some(e[26])),I(t,"class","nav-section svelte-1uh113i"),F(t,"expanded",e[6]===e[33].id)},m(e,p){h(e,t,p),f(t,n),f(n,i),f(i,s),f(n,r),f(n,o),f(o,l),f(n,a),x&&x.m(n,null),f(n,c),S&&S.m(n,null),f(t,u),$&&$.m(t,null),f(t,d),g||(v=A(n,"click",B),g=!0)},p(i,r){e=i,32&r[0]&&b!==(b=e[33].icon+"")&&E(s,b),32&r[0]&&k!==(k=e[33].label+"")&&E(l,k),e[33].children?x?x.p(e,r):(x=nv(e),x.c(),x.m(n,c)):x&&(x.d(1),x=null),32&r[0]&&(C=e[11](e[33].id)>0),C?S?S.p(e,r):(S=iv(e),S.c(),S.m(n,null)):S&&(S.d(1),S=null),160&r[0]&&F(n,"active",e[7]===e[33].id||e[33].children&&e[33].children.some(e[26])),e[33].children&&e[6]===e[33].id?$?$.p(e,r):($=sv(e),$.c(),$.m(t,d)):$&&($.d(1),$=null),96&r[0]&&F(t,"expanded",e[6]===e[33].id)},d(e){e&&p(t),x&&x.d(),S&&S.d(),$&&$.d(),g=!1,v()}}}function av(e){let t,n;return{c(){t=m("span"),n=y(e[3]),I(t,"class","version-text svelte-1uh113i")},m(e,i){h(e,t,i),f(t,n)},p(e,t){8&t[0]&&E(n,e[3])},d(e){e&&p(t)}}}function cv(t){let n,i,s,r,o,l,a,c,u,d,v,y,b,k=t[4]&&Ym(t);function C(e,t){return e[0]?Xm:Zm}let E=C(t),x=E(t),S=t[5],B=[];for(let e=0;e<S.length;e+=1)B[e]=lv(Vm(t,S,e));let $=t[3]&&av(t);return{c(){n=m("nav"),k&&k.c(),i=w(),s=m("div"),r=m("div"),x.c(),o=w(),l=m("div");for(let e=0;e<B.length;e+=1)B[e].c();a=w(),c=m("div"),u=m("button"),d=m("span"),d.textContent="smesh",v=w(),$&&$.c(),I(r,"class","sidebar-user svelte-1uh113i"),I(l,"class","nav-sections svelte-1uh113i"),I(d,"class","logo-text svelte-1uh113i"),I(u,"class","logo-button svelte-1uh113i"),I(u,"title","About smesh"),I(c,"class","sidebar-footer svelte-1uh113i"),I(s,"class","sidebar-content svelte-1uh113i"),I(n,"class","sidebar-accordion svelte-1uh113i"),F(n,"mobile-open",t[4])},m(e,p){h(e,n,p),k&&k.m(n,null),f(n,i),f(n,s),f(s,r),x.m(r,null),f(s,o),f(s,l);for(let e=0;e<B.length;e+=1)B[e]&&B[e].m(l,null);f(s,a),f(s,c),f(c,u),f(u,d),f(u,v),$&&$.m(u,null),y||(b=A(u,"click",t[14]),y=!0)},p(e,t){if(e[4]?k?k.p(e,t):(k=Ym(e),k.c(),k.m(n,i)):k&&(k.d(1),k=null),E===(E=C(e))&&x?x.p(e,t):(x.d(1),x=E(e),x&&(x.c(),x.m(r,null))),7904&t[0]){let n;for(S=e[5],n=0;n<S.length;n+=1){const i=Vm(e,S,n);B[n]?B[n].p(i,t):(B[n]=lv(i),B[n].c(),B[n].m(l,null))}for(;n<B.length;n+=1)B[n].d(1);B.length=S.length}e[3]?$?$.p(e,t):($=av(e),$.c(),$.m(u,null)):$&&($.d(1),$=null),16&t[0]&&F(n,"mobile-open",e[4])},i:e,o:e,d(e){e&&p(n),k&&k.d(),x.d(),g(B,e),$&&$.d(),y=!1,b()}}}function uv(e,t){return e?.name?e.name:e?.display_name?e.display_name:t?t.slice(0,8)+"...":"Anonymous"}function dv(e,t,n){let i,s,r,o,l,a;u(e,Km,e=>n(28,r=e)),u(e,Jm,e=>n(29,o=e)),u(e,$h,e=>n(6,l=e)),u(e,Bh,e=>n(7,a=e));let{isLoggedIn:c=!1}=t,{userProfile:d=null}=t,{userPubkey:f=""}=t,{currentEffectiveRole:h=""}=t,{version:p=""}=t,{mobileOpen:g=!1}=t,{aclMode:m=""}=t,{sprocketEnabled:v=!1}=t,{policyEnabled:y=!1}=t,{nrcEnabled:w=!1}=t,{blossomEnabled:b=!0}=t,{isOrlyRelay:A=!0}=t;const k=L(),I=[{id:"feed",icon:"⚡",label:"Feed",children:null},{id:"chat",icon:"💬",label:"Chat",children:[{id:"chat-inbox",label:"Inbox"},{id:"chat-channels",label:"Channels"}]},{id:"library",icon:"📚",label:"Library",children:[{id:"library-my",label:"My Library"},{id:"library-bookmarks",label:"Bookmarks"},{id:"library-new",label:"New"}]}];function C(e){Bh.set(e),k("navigate",e),g&&k("closeMobileMenu")}function E(e){var t;e.children?(t=e.id,$h.update(e=>e===t?null:t)):C(e.id)}function x(e){C(e)}return e.$$set=e=>{"isLoggedIn"in e&&n(0,c=e.isLoggedIn),"userProfile"in e&&n(1,d=e.userProfile),"userPubkey"in e&&n(2,f=e.userPubkey),"currentEffectiveRole"in e&&n(15,h=e.currentEffectiveRole),"version"in e&&n(3,p=e.version),"mobileOpen"in e&&n(4,g=e.mobileOpen),"aclMode"in e&&n(16,m=e.aclMode),"sprocketEnabled"in e&&n(17,v=e.sprocketEnabled),"policyEnabled"in e&&n(18,y=e.policyEnabled),"nrcEnabled"in e&&n(19,w=e.nrcEnabled),"blossomEnabled"in e&&n(20,b=e.blossomEnabled),"isOrlyRelay"in e&&n(21,A=e.isOrlyRelay)},e.$$.update=()=>{4161537&e.$$.dirty[0]&&n(22,i=function(e,t,n,i,s,r,o,l){if(!e)return[];const a=[];return a.push({id:"admin-export",label:"Export"}),"admin"!==t&&"owner"!==t||a.push({id:"admin-import",label:"Import"}),"read"!==t&&"write"!==t&&"admin"!==t&&"owner"!==t||a.push({id:"admin-events",label:"Events"}),o&&a.push({id:"admin-blossom",label:"Blossom"}),"read"!==t&&a.push({id:"admin-compose",label:"Compose"}),a.push({id:"admin-recovery",label:"Recovery"}),"owner"===t&&l&&("managed"===n&&a.push({id:"admin-managed-acl",label:"Managed ACL"}),"curating"===n&&a.push({id:"admin-curation",label:"Curation"}),i&&a.push({id:"admin-sprocket",label:"Sprocket"}),s&&a.push({id:"admin-policy",label:"Policy"}),r&&a.push({id:"admin-relay-connect",label:"Relay Connect"}),a.push({id:"admin-logs",label:"Logs"})),a}(c,h,m,v,y,w,b,A)),4194304&e.$$.dirty[0]&&n(5,s=[...I,...i.length>0?[{id:"admin",icon:"⚙️",label:"Admin",children:i}]:[]])},[c,d,f,p,g,s,l,a,k,E,x,function(e){return"chat"===e?o+r:0},function(e){return"chat-inbox"===e?o:"chat-channels"===e?r:0},function(){Qh.update(e=>!e),k("toggleUserMenu")},function(){k("showAbout")},h,m,v,y,w,b,A,i,()=>k("closeMobileMenu"),()=>k("openLoginModal"),e=>E(e),e=>a===e.id,e=>x(e.id)]}class fv extends fe{constructor(e){super(),de(this,e,dv,cv,r,{isLoggedIn:0,userProfile:1,userPubkey:2,currentEffectiveRole:15,version:3,mobileOpen:4,aclMode:16,sprocketEnabled:17,policyEnabled:18,nrcEnabled:19,blossomEnabled:20,isOrlyRelay:21},null,[-1,-1])}}function hv(e,t,n){const i=e.slice();return i[16]=t[n],i}function pv(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,F,D,Q,P,R,T,L,_,N=Iv(e[1],e[2])+"",M=e[5]?"☀️":"🌙",U=e[5]?"Light Mode":"Dark Mode";function O(e,t){return e[1]?.picture?mv:gv}let j=O(e),z=j(e),H=e[1]?.nip05&&vv(e),q=e[3]&&yv(e),G=e[3]&&"read"!==e[3]&&wv(e),J=e[7]&&Av(e);return{c(){t=m("div"),n=w(),s=m("div"),r=m("div"),z.c(),o=w(),l=m("div"),a=m("div"),c=y(N),u=w(),H&&H.c(),d=w(),q&&q.c(),g=w(),v=m("div"),b=w(),k=m("button"),C=m("span"),x=y(M),S=w(),B=m("span"),$=y(U),F=w(),G&&G.c(),D=w(),J&&J.c(),Q=w(),P=m("div"),R=w(),T=m("button"),T.innerHTML='<span class="menu-item-icon svelte-1eu2j72">⏻</span> \n            <span>Log out</span>',I(t,"class","menu-overlay svelte-1eu2j72"),I(a,"class","menu-display-name svelte-1eu2j72"),I(l,"class","menu-profile-info svelte-1eu2j72"),I(r,"class","menu-profile svelte-1eu2j72"),I(v,"class","menu-divider svelte-1eu2j72"),I(C,"class","menu-item-icon svelte-1eu2j72"),I(k,"class","menu-item svelte-1eu2j72"),I(P,"class","menu-divider svelte-1eu2j72"),I(T,"class","menu-item danger svelte-1eu2j72"),I(s,"class","user-menu svelte-1eu2j72")},m(i,p){h(i,t,p),h(i,n,p),h(i,s,p),f(s,r),z.m(r,null),f(r,o),f(r,l),f(l,a),f(a,c),f(l,u),H&&H.m(l,null),f(l,d),q&&q.m(l,null),f(s,g),f(s,v),f(s,b),f(s,k),f(k,C),f(C,x),f(k,S),f(k,B),f(B,$),f(s,F),G&&G.m(s,null),f(s,D),J&&J.m(s,null),f(s,Q),f(s,P),f(s,R),f(s,T),L||(_=[A(t,"click",e[13]),A(k,"click",e[10]),A(T,"click",e[9])],L=!0)},p(e,t){j===(j=O(e))&&z?z.p(e,t):(z.d(1),z=j(e),z&&(z.c(),z.m(r,o))),6&t&&N!==(N=Iv(e[1],e[2])+"")&&E(c,N),e[1]?.nip05?H?H.p(e,t):(H=vv(e),H.c(),H.m(l,d)):H&&(H.d(1),H=null),e[3]?q?q.p(e,t):(q=yv(e),q.c(),q.m(l,null)):q&&(q.d(1),q=null),32&t&&M!==(M=e[5]?"☀️":"🌙")&&E(x,M),32&t&&U!==(U=e[5]?"Light Mode":"Dark Mode")&&E($,U),e[3]&&"read"!==e[3]?G?G.p(e,t):(G=wv(e),G.c(),G.m(s,D)):G&&(G.d(1),G=null),e[7]?J?J.p(e,t):(J=Av(e),J.c(),J.m(s,Q)):J&&(J.d(1),J=null)},d(e){e&&p(t),e&&p(n),e&&p(s),z.d(),H&&H.d(),q&&q.d(),G&&G.d(),J&&J.d(),L=!1,i(_)}}}function gv(e){let t,n,i=Iv(e[1],e[2]).charAt(0).toUpperCase()+"";return{c(){t=m("div"),n=y(i),I(t,"class","menu-avatar-placeholder svelte-1eu2j72")},m(e,i){h(e,t,i),f(t,n)},p(e,t){6&t&&i!==(i=Iv(e[1],e[2]).charAt(0).toUpperCase()+"")&&E(n,i)},d(e){e&&p(t)}}}function mv(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[1].picture)||I(t,"src",n),I(t,"alt","avatar"),I(t,"class","menu-avatar svelte-1eu2j72")},m(e,n){h(e,t,n)},p(e,i){2&i&&!l(t.src,n=e[1].picture)&&I(t,"src",n)},d(e){e&&p(t)}}}function vv(e){let t,n,i=e[1].nip05+"";return{c(){t=m("div"),n=y(i),I(t,"class","menu-nip05 svelte-1eu2j72")},m(e,i){h(e,t,i),f(t,n)},p(e,t){2&t&&i!==(i=e[1].nip05+"")&&E(n,i)},d(e){e&&p(t)}}}function yv(e){let t,n;return{c(){t=m("div"),n=y(e[4]),I(t,"class","menu-role svelte-1eu2j72")},m(e,i){h(e,t,i),f(t,n)},p(e,t){16&t&&E(n,e[4])},d(e){e&&p(t)}}}function wv(e){let t,n,i,s=e[8](),r=[];for(let t=0;t<s.length;t+=1)r[t]=bv(hv(e,s,t));return{c(){t=m("div"),t.textContent="View as Role",n=w();for(let e=0;e<r.length;e+=1)r[e].c();i=b(),I(t,"class","menu-section-label svelte-1eu2j72")},m(e,s){h(e,t,s),h(e,n,s);for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,s);h(e,i,s)},p(e,t){if(2328&t){let n;for(s=e[8](),n=0;n<s.length;n+=1){const o=hv(e,s,n);r[n]?r[n].p(o,t):(r[n]=bv(o),r[n].c(),r[n].m(i.parentNode,i))}for(;n<r.length;n+=1)r[n].d(1);r.length=s.length}},d(e){e&&p(t),e&&p(n),g(r,e),e&&p(i)}}}function bv(e){let t,n,i,s,r,o,l,a,c,u,d=e[4]===e[16]?"●":"○",g=e[16].charAt(0).toUpperCase()+e[16].slice(1)+"",v=e[16]===e[3]?" (Default)":"";function b(){return e[14](e[16])}return{c(){t=m("button"),n=m("span"),i=y(d),s=w(),r=m("span"),o=y(g),l=y(v),a=w(),I(n,"class","menu-item-icon svelte-1eu2j72"),I(t,"class","menu-item svelte-1eu2j72"),F(t,"active",e[4]===e[16])},m(e,d){h(e,t,d),f(t,n),f(n,i),f(t,s),f(t,r),f(r,o),f(r,l),f(t,a),c||(u=A(t,"click",b),c=!0)},p(n,s){e=n,16&s&&d!==(d=e[4]===e[16]?"●":"○")&&E(i,d),8&s&&v!==(v=e[16]===e[3]?" (Default)":"")&&E(l,v),272&s&&F(t,"active",e[4]===e[16])},d(e){e&&p(t),c=!1,u()}}}function Av(t){let n,i,s,r,o;return{c(){n=m("div"),i=w(),s=m("button"),s.innerHTML='<span class="menu-item-icon svelte-1eu2j72">🔗</span> \n                <span>Change Relay</span>',I(n,"class","menu-divider svelte-1eu2j72"),I(s,"class","menu-item svelte-1eu2j72")},m(e,l){h(e,n,l),h(e,i,l),h(e,s,l),r||(o=A(s,"click",t[12]),r=!0)},p:e,d(e){e&&p(n),e&&p(i),e&&p(s),r=!1,o()}}}function kv(t){let n,i=t[6]&&t[0]&&pv(t);return{c(){i&&i.c(),n=b()},m(e,t){i&&i.m(e,t),h(e,n,t)},p(e,[t]){e[6]&&e[0]?i?i.p(e,t):(i=pv(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&p(n)}}}function Iv(e,t){return e?.name?e.name:e?.display_name?e.display_name:t?t.slice(0,8)+"...":"Anonymous"}function Cv(e,t,n){let i,s;u(e,Qh,e=>n(6,i=e)),u(e,kh,e=>n(7,s=e));let{isLoggedIn:r=!1}=t,{userProfile:o=null}=t,{userPubkey:l=""}=t,{userRole:a=""}=t,{currentEffectiveRole:c=""}=t,{isDarkTheme:d=!1}=t;const f=L();function h(e){f("setViewAsRole",e===a?"":e)}return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"userProfile"in e&&n(1,o=e.userProfile),"userPubkey"in e&&n(2,l=e.userPubkey),"userRole"in e&&n(3,a=e.userRole),"currentEffectiveRole"in e&&n(4,c=e.currentEffectiveRole),"isDarkTheme"in e&&n(5,d=e.isDarkTheme)},[r,o,l,a,c,d,i,s,function(){const e=["owner","admin","write","read"],t=e.indexOf(a);return-1===t?["read"]:e.slice(t)},function(){Qh.set(!1),f("logout")},function(){f("toggleTheme")},h,function(){Qh.set(!1),f("openRelayModal")},function(){Qh.set(!1)},e=>h(e)]}class Ev extends fe{constructor(e){super(),de(this,e,Cv,kv,r,{isLoggedIn:0,userProfile:1,userPubkey:2,userRole:3,currentEffectiveRole:4,isDarkTheme:5})}}function xv(e){let t,n,s,r,o,l,a,c,u,d,g,v,y,b,C=e[1]&&Sv(e),E=e[2]&&Bv(e);return{c(){t=m("div"),n=m("div"),s=m("button"),s.textContent="x",r=w(),o=m("div"),l=m("div"),l.textContent="smesh",a=w(),c=m("div"),c.textContent="distributed operating system",u=w(),C&&C.c(),d=w(),E&&E.c(),g=w(),v=m("div"),v.textContent="Powered by ORLY",I(s,"class","close-btn svelte-20qztm"),I(l,"class","about-logo svelte-20qztm"),I(c,"class","about-tagline svelte-20qztm"),I(v,"class","about-footer svelte-20qztm"),I(o,"class","about-content"),I(n,"class","about-modal svelte-20qztm"),I(t,"class","about-overlay svelte-20qztm")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(o,a),f(o,c),f(o,u),C&&C.m(o,null),f(o,d),E&&E.m(o,null),f(o,g),f(o,v),y||(b=[A(s,"click",e[4]),A(n,"click",k(e[6])),A(t,"click",e[4])],y=!0)},p(e,t){e[1]?C?C.p(e,t):(C=Sv(e),C.c(),C.m(o,d)):C&&(C.d(1),C=null),e[2]?E?E.p(e,t):(E=Bv(e),E.c(),E.m(o,g)):E&&(E.d(1),E=null)},d(e){e&&p(t),C&&C.d(),E&&E.d(),y=!1,i(b)}}}function Sv(e){let t,n,i;return{c(){t=m("div"),n=y("v"),i=y(e[1]),I(t,"class","about-version svelte-20qztm")},m(e,s){h(e,t,s),f(t,n),f(t,i)},p(e,t){2&t&&E(i,e[1])},d(e){e&&p(t)}}}function Bv(e){let t,n,i,s,r,o,l,a=(e[2].name||"Relay")+"",c=e[2].description&&$v(e);return{c(){t=m("div"),n=m("div"),i=y(a),s=w(),c&&c.c(),r=w(),o=m("div"),l=y(e[3]),I(n,"class","relay-name svelte-20qztm"),I(o,"class","relay-url svelte-20qztm"),I(t,"class","about-relay svelte-20qztm")},m(e,a){h(e,t,a),f(t,n),f(n,i),f(t,s),c&&c.m(t,null),f(t,r),f(t,o),f(o,l)},p(e,n){4&n&&a!==(a=(e[2].name||"Relay")+"")&&E(i,a),e[2].description?c?c.p(e,n):(c=$v(e),c.c(),c.m(t,r)):c&&(c.d(1),c=null),8&n&&E(l,e[3])},d(e){e&&p(t),c&&c.d()}}}function $v(e){let t,n,i=e[2].description+"";return{c(){t=m("div"),n=y(i),I(t,"class","relay-desc svelte-20qztm")},m(e,i){h(e,t,i),f(t,n)},p(e,t){4&t&&i!==(i=e[2].description+"")&&E(n,i)},d(e){e&&p(t)}}}function Fv(t){let n,i,s,r=t[0]&&xv(t);return{c(){r&&r.c(),n=b()},m(e,o){r&&r.m(e,o),h(e,n,o),i||(s=A(window,"keydown",t[5]),i=!0)},p(e,[t]){e[0]?r?r.p(e,t):(r=xv(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:e,o:e,d(e){r&&r.d(e),e&&p(n),i=!1,s()}}}function Dv(e,t,n){let i,s;u(e,Ih,e=>n(2,i=e)),u(e,Ah,e=>n(3,s=e));let{show:r=!1}=t,{version:o=""}=t;const l=L();function a(){l("close")}return e.$$set=e=>{"show"in e&&n(0,r=e.show),"version"in e&&n(1,o=e.version)},[r,o,i,s,a,function(e){"Escape"===e.key&&a()},function(t){_.call(this,e,t)}]}class Qv extends fe{constructor(e){super(),de(this,e,Dv,Fv,r,{show:0,version:1})}}function Pv(e){let t,n,s,r,o,l,a,c,u,d,g,y,b=e[2].trim().length>0,k=b&&Rv();return{c(){t=m("div"),n=m("div"),s=v("svg"),r=v("circle"),o=v("path"),l=w(),a=m("input"),c=w(),u=m("button"),u.textContent="x",d=w(),k&&k.c(),I(r,"cx","11"),I(r,"cy","11"),I(r,"r","8"),I(o,"d","M21 21l-4.35-4.35"),I(s,"class","search-icon svelte-1pk7luz"),I(s,"viewBox","0 0 24 24"),I(s,"fill","none"),I(s,"stroke","currentColor"),I(s,"stroke-width","2"),I(s,"stroke-linecap","round"),I(s,"stroke-linejoin","round"),I(a,"type","text"),I(a,"placeholder","Search notes, profiles, channels, publications..."),I(a,"class","search-input svelte-1pk7luz"),I(u,"class","search-close svelte-1pk7luz"),I(n,"class","search-bar svelte-1pk7luz"),I(t,"class","search-overlay svelte-1pk7luz")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(s,r),f(s,o),f(n,l),f(n,a),e[5](a),x(a,e[2]),f(n,c),f(n,u),f(t,d),k&&k.m(t,null),g||(y=[A(a,"input",e[6]),A(a,"keydown",e[7]),A(u,"click",e[3])],g=!0)},p(e,n){4&n&&a.value!==e[2]&&x(a,e[2]),4&n&&(b=e[2].trim().length>0),b?k||(k=Rv(),k.c(),k.m(t,null)):k&&(k.d(1),k=null)},d(n){n&&p(t),e[5](null),k&&k.d(),g=!1,i(y)}}}function Rv(e){let t;return{c(){t=m("div"),t.innerHTML='<div class="search-placeholder svelte-1pk7luz">Search results will appear here.</div>',I(t,"class","search-results-panel svelte-1pk7luz")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Tv(t){let n,i=t[1]&&Pv(t);return{c(){i&&i.c(),n=b()},m(e,t){i&&i.m(e,t),h(e,n,t)},p(e,[t]){e[1]?i?i.p(e,t):(i=Pv(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&p(n)}}}function Lv(e,t,n){let i;u(e,Fh,e=>n(1,i=e));const s=L();let r,o="";function l(){Fh.set(!1),n(2,o="")}function a(){o.trim()&&s("search",o.trim())}return e.$$.update=()=>{3&e.$$.dirty&&i&&q().then(()=>{r&&r.focus()})},[r,i,o,l,a,function(e){M[e?"unshift":"push"](()=>{r=e,n(0,r)})},function(){o=this.value,n(2,o)},e=>{"Escape"===e.key&&l(),"Enter"===e.key&&a()}]}class _v extends fe{constructor(e){super(),de(this,e,Lv,Tv,r,{})}}function Nv(e,t,n){const i=e.slice();return i[17]=t[n],i}function Mv(e,t,n){const i=e.slice();return i[17]=t[n],i}function Uv(e,t,n){const i=e.slice();return i[17]=t[n],i}function Ov(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,y,b,C,E,x,S,B,$,F,D,Q,P,R,T=e[1]>0&&jv(e),L=e[2].unreadCount>0&&zv(e);function _(e,t){return 0===e[2].items.length?qv:Hv}let N=_(e),M=N(e),U=e[3].unreadCount>0&&Jv(e);function O(e,t){return 0===e[3].items.length?Vv:Kv}let j=O(e),z=j(e),H=e[4].unreadCount>0&&Yv(e);function q(e,t){return 0===e[4].items.length?Xv:Zv}let G=q(e),J=G(e),K=(e[5]>0||e[6]>0)&&ty(e);return{c(){t=m("div"),n=m("div"),i=m("span"),i.textContent="Notifications",s=w(),T&&T.c(),r=w(),o=m("div"),l=m("div"),a=m("div"),c=m("span"),c.textContent="Replies",u=w(),L&&L.c(),d=w(),M.c(),g=w(),v=m("div"),y=m("div"),b=m("span"),b.textContent="Reactions",C=w(),U&&U.c(),E=w(),z.c(),x=w(),S=m("div"),B=m("div"),$=m("span"),$.textContent="Zaps",F=w(),H&&H.c(),D=w(),J.c(),Q=w(),K&&K.c(),I(i,"class","notif-title svelte-9k95fl"),I(n,"class","notif-header svelte-9k95fl"),I(c,"class","section-label svelte-9k95fl"),I(a,"class","section-header svelte-9k95fl"),I(l,"class","notif-section svelte-9k95fl"),I(b,"class","section-label svelte-9k95fl"),I(y,"class","section-header svelte-9k95fl"),I(v,"class","notif-section svelte-9k95fl"),I($,"class","section-label svelte-9k95fl"),I(B,"class","section-header svelte-9k95fl"),I(S,"class","notif-section svelte-9k95fl"),I(o,"class","notif-body svelte-9k95fl"),I(t,"class","notification-dropdown svelte-9k95fl")},m(p,m){h(p,t,m),f(t,n),f(n,i),f(n,s),T&&T.m(n,null),f(t,r),f(t,o),f(o,l),f(l,a),f(a,c),f(a,u),L&&L.m(a,null),f(l,d),M.m(l,null),f(o,g),f(o,v),f(v,y),f(y,b),f(y,C),U&&U.m(y,null),f(v,E),z.m(v,null),f(o,x),f(o,S),f(S,B),f(B,$),f(B,F),H&&H.m(B,null),f(S,D),J.m(S,null),f(o,Q),K&&K.m(o,null),P||(R=A(t,"click",k(e[12])),P=!0)},p(e,t){e[1]>0?T?T.p(e,t):(T=jv(e),T.c(),T.m(n,null)):T&&(T.d(1),T=null),e[2].unreadCount>0?L?L.p(e,t):(L=zv(e),L.c(),L.m(a,null)):L&&(L.d(1),L=null),N===(N=_(e))&&M?M.p(e,t):(M.d(1),M=N(e),M&&(M.c(),M.m(l,null))),e[3].unreadCount>0?U?U.p(e,t):(U=Jv(e),U.c(),U.m(y,null)):U&&(U.d(1),U=null),j===(j=O(e))&&z?z.p(e,t):(z.d(1),z=j(e),z&&(z.c(),z.m(v,null))),e[4].unreadCount>0?H?H.p(e,t):(H=Yv(e),H.c(),H.m(B,null)):H&&(H.d(1),H=null),G===(G=q(e))&&J?J.p(e,t):(J.d(1),J=G(e),J&&(J.c(),J.m(S,null))),e[5]>0||e[6]>0?K?K.p(e,t):(K=ty(e),K.c(),K.m(o,null)):K&&(K.d(1),K=null)},d(e){e&&p(t),T&&T.d(),L&&L.d(),M.d(),U&&U.d(),z.d(),H&&H.d(),J.d(),K&&K.d(),P=!1,R()}}}function jv(t){let n,i,s;return{c(){n=m("button"),n.textContent="Mark all read",I(n,"class","mark-all-btn svelte-9k95fl")},m(e,r){h(e,n,r),i||(s=A(n,"click",t[8]),i=!0)},p:e,d(e){e&&p(n),i=!1,s()}}}function zv(e){let t,n,i,s,r,o,l=e[2].unreadCount+"";return{c(){t=m("span"),n=y(l),i=w(),s=m("button"),s.textContent="read",I(t,"class","section-count svelte-9k95fl"),I(s,"class","section-read svelte-9k95fl")},m(l,a){h(l,t,a),f(t,n),h(l,i,a),h(l,s,a),r||(o=A(s,"click",e[13]),r=!0)},p(e,t){4&t&&l!==(l=e[2].unreadCount+"")&&E(n,l)},d(e){e&&p(t),e&&p(i),e&&p(s),r=!1,o()}}}function Hv(e){let t,n=[],i=new Map,s=e[2].items.slice(0,10);const r=e=>e[17].id;for(let t=0;t<s.length;t+=1){let o=Uv(e,s,t),l=r(o);i.set(l,n[t]=Gv(l,o))}return{c(){for(let e=0;e<n.length;e+=1)n[e].c();t=b()},m(e,i){for(let t=0;t<n.length;t+=1)n[t]&&n[t].m(e,i);h(e,t,i)},p(e,o){4&o&&(s=e[2].items.slice(0,10),n=oe(n,o,r,1,e,s,i,t.parentNode,se,Gv,t,Uv))},d(e){for(let t=0;t<n.length;t+=1)n[t].d(e);e&&p(t)}}}function qv(t){let n;return{c(){n=m("div"),n.textContent="No replies yet.",I(n,"class","notif-empty svelte-9k95fl")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Gv(e,t){let n,i,s,r,o,l,a,c,u,d,g=oy(t[17].content)+"",v=ry(t[17].created_at)+"";return{key:e,first:null,c(){n=m("div"),i=m("div"),i.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-9k95fl"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>',s=w(),r=m("div"),o=m("span"),l=y(g),a=w(),c=m("span"),u=y(v),d=w(),I(i,"class","notif-icon reply-icon svelte-9k95fl"),I(o,"class","notif-text svelte-9k95fl"),I(c,"class","notif-time svelte-9k95fl"),I(r,"class","notif-content svelte-9k95fl"),I(n,"class","notif-item svelte-9k95fl"),this.first=n},m(e,t){h(e,n,t),f(n,i),f(n,s),f(n,r),f(r,o),f(o,l),f(r,a),f(r,c),f(c,u),f(n,d)},p(e,n){t=e,4&n&&g!==(g=oy(t[17].content)+"")&&E(l,g),4&n&&v!==(v=ry(t[17].created_at)+"")&&E(u,v)},d(e){e&&p(n)}}}function Jv(e){let t,n,i,s,r,o,l=e[3].unreadCount+"";return{c(){t=m("span"),n=y(l),i=w(),s=m("button"),s.textContent="read",I(t,"class","section-count svelte-9k95fl"),I(s,"class","section-read svelte-9k95fl")},m(l,a){h(l,t,a),f(t,n),h(l,i,a),h(l,s,a),r||(o=A(s,"click",e[14]),r=!0)},p(e,t){8&t&&l!==(l=e[3].unreadCount+"")&&E(n,l)},d(e){e&&p(t),e&&p(i),e&&p(s),r=!1,o()}}}function Kv(e){let t,n=[],i=new Map,s=e[3].items.slice(0,10);const r=e=>e[17].id;for(let t=0;t<s.length;t+=1){let o=Mv(e,s,t),l=r(o);i.set(l,n[t]=Wv(l,o))}return{c(){for(let e=0;e<n.length;e+=1)n[e].c();t=b()},m(e,i){for(let t=0;t<n.length;t+=1)n[t]&&n[t].m(e,i);h(e,t,i)},p(e,o){8&o&&(s=e[3].items.slice(0,10),n=oe(n,o,r,1,e,s,i,t.parentNode,se,Wv,t,Mv))},d(e){for(let t=0;t<n.length;t+=1)n[t].d(e);e&&p(t)}}}function Vv(t){let n;return{c(){n=m("div"),n.textContent="No reactions yet.",I(n,"class","notif-empty svelte-9k95fl")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Wv(e,t){let n,i,s,r,o,l,a,c,u,d,g=(t[17].content||"+")+"",v=ry(t[17].created_at)+"";return{key:e,first:null,c(){n=m("div"),i=m("div"),i.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-9k95fl"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path></svg>',s=w(),r=m("div"),o=m("span"),l=y(g),a=w(),c=m("span"),u=y(v),d=w(),I(i,"class","notif-icon react-icon svelte-9k95fl"),I(o,"class","notif-text svelte-9k95fl"),I(c,"class","notif-time svelte-9k95fl"),I(r,"class","notif-content svelte-9k95fl"),I(n,"class","notif-item svelte-9k95fl"),this.first=n},m(e,t){h(e,n,t),f(n,i),f(n,s),f(n,r),f(r,o),f(o,l),f(r,a),f(r,c),f(c,u),f(n,d)},p(e,n){t=e,8&n&&g!==(g=(t[17].content||"+")+"")&&E(l,g),8&n&&v!==(v=ry(t[17].created_at)+"")&&E(u,v)},d(e){e&&p(n)}}}function Yv(e){let t,n,i,s,r,o,l=e[4].unreadCount+"";return{c(){t=m("span"),n=y(l),i=w(),s=m("button"),s.textContent="read",I(t,"class","section-count svelte-9k95fl"),I(s,"class","section-read svelte-9k95fl")},m(l,a){h(l,t,a),f(t,n),h(l,i,a),h(l,s,a),r||(o=A(s,"click",e[15]),r=!0)},p(e,t){16&t&&l!==(l=e[4].unreadCount+"")&&E(n,l)},d(e){e&&p(t),e&&p(i),e&&p(s),r=!1,o()}}}function Zv(e){let t,n=[],i=new Map,s=e[4].items.slice(0,10);const r=e=>e[17].id;for(let t=0;t<s.length;t+=1){let o=Nv(e,s,t),l=r(o);i.set(l,n[t]=ey(l,o))}return{c(){for(let e=0;e<n.length;e+=1)n[e].c();t=b()},m(e,i){for(let t=0;t<n.length;t+=1)n[t]&&n[t].m(e,i);h(e,t,i)},p(e,o){16&o&&(s=e[4].items.slice(0,10),n=oe(n,o,r,1,e,s,i,t.parentNode,se,ey,t,Nv))},d(e){for(let t=0;t<n.length;t+=1)n[t].d(e);e&&p(t)}}}function Xv(t){let n;return{c(){n=m("div"),n.textContent="No zaps yet.",I(n,"class","notif-empty svelte-9k95fl")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function ey(e,t){let n,i,s,r,o,l,a,c,u,d=ry(t[17].created_at)+"";return{key:e,first:null,c(){n=m("div"),i=m("div"),i.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-9k95fl"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>',s=w(),r=m("div"),o=m("span"),o.textContent="Zap received",l=w(),a=m("span"),c=y(d),u=w(),I(i,"class","notif-icon zap-icon svelte-9k95fl"),I(o,"class","notif-text svelte-9k95fl"),I(a,"class","notif-time svelte-9k95fl"),I(r,"class","notif-content svelte-9k95fl"),I(n,"class","notif-item svelte-9k95fl"),this.first=n},m(e,t){h(e,n,t),f(n,i),f(n,s),f(n,r),f(r,o),f(r,l),f(r,a),f(a,c),f(n,u)},p(e,n){t=e,16&n&&d!==(d=ry(t[17].created_at)+"")&&E(c,d)},d(e){e&&p(n)}}}function ty(e){let t,n,i,s,r=e[5]>0&&ny(e),o=e[6]>0&&iy(e);return{c(){t=m("div"),n=m("div"),n.innerHTML='<span class="section-label svelte-9k95fl">Messages</span>',i=w(),r&&r.c(),s=w(),o&&o.c(),I(n,"class","section-header svelte-9k95fl"),I(t,"class","notif-section svelte-9k95fl")},m(e,l){h(e,t,l),f(t,n),f(t,i),r&&r.m(t,null),f(t,s),o&&o.m(t,null)},p(e,n){e[5]>0?r?r.p(e,n):(r=ny(e),r.c(),r.m(t,s)):r&&(r.d(1),r=null),e[6]>0?o?o.p(e,n):(o=iy(e),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(e){e&&p(t),r&&r.d(),o&&o.d()}}}function ny(e){let t,n,i,s,r,o,l,a,c=e[5]>1?"s":"";return{c(){t=m("div"),n=m("div"),n.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-9k95fl"><rect x="2" y="4" width="20" height="16" rx="2"></rect><path d="M22 7l-10 7L2 7"></path></svg>',i=w(),s=m("div"),r=m("span"),o=y(e[5]),l=y(" unread message"),a=y(c),I(n,"class","notif-icon dm-icon svelte-9k95fl"),I(r,"class","notif-text svelte-9k95fl"),I(s,"class","notif-content svelte-9k95fl"),I(t,"class","notif-item svelte-9k95fl")},m(e,c){h(e,t,c),f(t,n),f(t,i),f(t,s),f(s,r),f(r,o),f(r,l),f(r,a)},p(e,t){32&t&&E(o,e[5]),32&t&&c!==(c=e[5]>1?"s":"")&&E(a,c)},d(e){e&&p(t)}}}function iy(e){let t,n,i,s,r,o,l,a,c=e[6]>1?"s":"";return{c(){t=m("div"),n=m("div"),n.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-9k95fl"><path d="M4 9h16M4 15h16M10 3L8 21M16 3l-2 18"></path></svg>',i=w(),s=m("div"),r=m("span"),o=y(e[6]),l=y(" unread channel message"),a=y(c),I(n,"class","notif-icon channel-icon svelte-9k95fl"),I(r,"class","notif-text svelte-9k95fl"),I(s,"class","notif-content svelte-9k95fl"),I(t,"class","notif-item svelte-9k95fl")},m(e,c){h(e,t,c),f(t,n),f(t,i),f(t,s),f(s,r),f(r,o),f(r,l),f(r,a)},p(e,t){64&t&&E(o,e[6]),64&t&&c!==(c=e[6]>1?"s":"")&&E(a,c)},d(e){e&&p(t)}}}function sy(t){let n,i,s,r=t[0]&&Ov(t);return{c(){r&&r.c(),n=b()},m(e,o){r&&r.m(e,o),h(e,n,o),i||(s=A(window,"click",t[7]),i=!0)},p(e,[t]){e[0]?r?r.p(e,t):(r=Ov(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:e,o:e,d(e){r&&r.d(e),e&&p(n),i=!1,s()}}}function ry(e){if(!e)return"";const t=Math.floor(Date.now()/1e3)-e;return t<60?"now":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function oy(e,t=60){return!e||e.length<=t?e||"":e.slice(0,t)+"..."}function ly(e,t,n){let i,s,r,o,l,a,c;u(e,Dh,e=>n(0,i=e)),u(e,Im,e=>n(1,s=e)),u(e,ym,e=>n(2,r=e)),u(e,wm,e=>n(3,o=e)),u(e,bm,e=>n(4,l=e)),u(e,Jm,e=>n(5,a=e)),u(e,Km,e=>n(6,c=e));let{userPubkey:d=""}=t,{isLoggedIn:f=!1}=t,h=!1;async function p(){n(11,h=!0);try{const[e,t,n]=await Promise.all([gp([{kinds:[1],"#p":[d],limit:30}],{timeout:1e4,useCache:!1}),gp([{kinds:[7],"#p":[d],limit:30}],{timeout:1e4,useCache:!1}),gp([{kinds:[9735],"#p":[d],limit:30}],{timeout:1e4,useCache:!1})]);e?.length&&Cm(ym,e),t?.length&&function(e){Cm(wm,e)}(t),n?.length&&function(e){Cm(bm,e)}(n)}catch(e){console.error("[Notifications] Fetch error:",e)}}return e.$$set=e=>{"userPubkey"in e&&n(9,d=e.userPubkey),"isLoggedIn"in e&&n(10,f=e.isLoggedIn)},e.$$.update=()=>{3585&e.$$.dirty&&i&&f&&d&&!h&&p()},[i,s,r,o,l,a,c,function(){i&&Dh.set(!1)},function(){!function(){const e=Date.now();ym.update(t=>({...t,unreadCount:0,lastChecked:e})),wm.update(t=>({...t,unreadCount:0,lastChecked:e})),bm.update(t=>({...t,unreadCount:0,lastChecked:e}))}()},d,f,h,function(t){_.call(this,e,t)},()=>Em("replies"),()=>Em("reactions"),()=>Em("zaps")]}class ay extends fe{constructor(e){super(),de(this,e,ly,sy,r,{userPubkey:9,isLoggedIn:10})}}function cy(e,t,n){const i=e.slice();return i[17]=t[n],i}function uy(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,F,D,Q,P,R,T;function L(e,t){return e[1]?.picture?fy:dy}let _=L(e),N=_(e),M=e[1]?.nip05&&hy(e);function U(e,t){return e[3]&&!e[2]?gy:py}let O=U(e),j=O(e);return{c(){t=m("article"),n=m("div"),s=m("div"),N.c(),r=w(),o=m("div"),l=m("span"),a=y(e[7]),c=w(),M&&M.c(),u=w(),d=m("span"),g=y(e[6]),b=w(),k=m("div"),j.c(),C=w(),x=m("div"),S=m("button"),S.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-5hyftz"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path></svg>',B=w(),$=m("button"),$.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-5hyftz"><polyline points="17 1 21 5 17 9"></polyline><path d="M3 11V9a4 4 0 0 1 4-4h14"></path><polyline points="7 23 3 19 7 15"></polyline><path d="M21 13v2a4 4 0 0 1-4 4H3"></path></svg>',F=w(),D=m("button"),D.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-5hyftz"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"></path></svg>',Q=w(),P=m("button"),P.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-5hyftz"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>',I(l,"class","author-name svelte-5hyftz"),I(o,"class","author-info svelte-5hyftz"),I(s,"class","note-author svelte-5hyftz"),I(d,"class","note-time svelte-5hyftz"),I(d,"title",v=new Date(1e3*e[0].created_at).toLocaleString()),I(n,"class","note-header svelte-5hyftz"),I(k,"class","note-body svelte-5hyftz"),I(S,"class","action-btn reply-btn svelte-5hyftz"),I(S,"title","Reply"),I($,"class","action-btn repost-btn svelte-5hyftz"),I($,"title","Repost"),I(D,"class","action-btn react-btn svelte-5hyftz"),I(D,"title","React"),I(P,"class","action-btn zap-btn svelte-5hyftz"),I(P,"title","Zap"),I(x,"class","note-actions svelte-5hyftz"),I(t,"class","note-card svelte-5hyftz")},m(i,p){h(i,t,p),f(t,n),f(n,s),N.m(s,null),f(s,r),f(s,o),f(o,l),f(l,a),f(o,c),M&&M.m(o,null),f(n,u),f(n,d),f(d,g),f(t,b),f(t,k),j.m(k,null),f(t,C),f(t,x),f(x,S),f(x,B),f(x,$),f(x,F),f(x,D),f(x,Q),f(x,P),R||(T=[A(S,"click",e[8]),A($,"click",e[10]),A(D,"click",e[9]),A(P,"click",e[11])],R=!0)},p(e,t){_===(_=L(e))&&N?N.p(e,t):(N.d(1),N=_(e),N&&(N.c(),N.m(s,r))),128&t&&E(a,e[7]),e[1]?.nip05?M?M.p(e,t):(M=hy(e),M.c(),M.m(o,null)):M&&(M.d(1),M=null),64&t&&E(g,e[6]),1&t&&v!==(v=new Date(1e3*e[0].created_at).toLocaleString())&&I(d,"title",v),O===(O=U(e))&&j?j.p(e,t):(j.d(1),j=O(e),j&&(j.c(),j.m(k,null)))},d(e){e&&p(t),N.d(),M&&M.d(),j.d(),R=!1,i(T)}}}function dy(e){let t,n,i=e[7].charAt(0).toUpperCase()+"";return{c(){t=m("div"),n=y(i),I(t,"class","author-avatar-placeholder svelte-5hyftz")},m(e,i){h(e,t,i),f(t,n)},p(e,t){128&t&&i!==(i=e[7].charAt(0).toUpperCase()+"")&&E(n,i)},d(e){e&&p(t)}}}function fy(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[1].picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","author-avatar svelte-5hyftz")},m(e,n){h(e,t,n)},p(e,i){2&i&&!l(t.src,n=e[1].picture)&&I(t,"src",n)},d(e){e&&p(t)}}}function hy(e){let t,n,i=e[1].nip05+"";return{c(){t=m("span"),n=y(i),I(t,"class","author-nip05 svelte-5hyftz")},m(e,i){h(e,t,i),f(t,n)},p(e,t){2&t&&i!==(i=e[1].nip05+"")&&E(n,i)},d(e){e&&p(t)}}}function py(e){let t,n,i,s=e[4].length>0&&my(e);return{c(){t=m("div"),n=w(),s&&s.c(),i=b(),I(t,"class","note-text svelte-5hyftz")},m(r,o){h(r,t,o),t.innerHTML=e[5],h(r,n,o),s&&s.m(r,o),h(r,i,o)},p(e,n){32&n&&(t.innerHTML=e[5]),e[4].length>0?s?s.p(e,n):(s=my(e),s.c(),s.m(i.parentNode,i)):s&&(s.d(1),s=null)},d(e){e&&p(t),e&&p(n),s&&s.d(e),e&&p(i)}}}function gy(e){let t,n,i,s,r,o,l,a;return{c(){t=m("div"),n=m("span"),i=y("CW: "),s=y(e[3]),r=w(),o=m("button"),o.textContent="Show",I(o,"class","svelte-5hyftz"),I(t,"class","content-warning svelte-5hyftz")},m(c,u){h(c,t,u),f(t,n),f(n,i),f(n,s),f(t,r),f(t,o),l||(a=A(o,"click",e[14]),l=!0)},p(e,t){8&t&&E(s,e[3])},d(e){e&&p(t),l=!1,a()}}}function my(e){let t,n=e[4],i=[];for(let t=0;t<n.length;t+=1)i[t]=vy(cy(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","note-images svelte-5hyftz"),F(t,"gallery",e[4].length>1)},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(16&s){let r;for(n=e[4],r=0;r<n.length;r+=1){const o=cy(e,n,r);i[r]?i[r].p(o,s):(i[r]=vy(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}16&s&&F(t,"gallery",e[4].length>1)},d(e){e&&p(t),g(i,e)}}}function vy(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[17])||I(t,"src",n),I(t,"alt",""),I(t,"class","note-image svelte-5hyftz"),I(t,"loading","lazy")},m(e,n){h(e,t,n)},p(e,i){16&i&&!l(t.src,n=e[17])&&I(t,"src",n)},d(e){e&&p(t)}}}function yy(t){let n,i=t[0]&&uy(t);return{c(){i&&i.c(),n=b()},m(e,t){i&&i.m(e,t),h(e,n,t)},p(e,[t]){e[0]?i?i.p(e,t):(i=uy(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&p(n)}}}function wy(e,t,n){let i,s,r,o,l,a,{event:c=null}=t,{userPubkey:u=""}=t,{profiles:d=new Map}=t;const f=L();let h=!1;return e.$$set=e=>{"event"in e&&n(0,c=e.event),"userPubkey"in e&&n(12,u=e.userPubkey),"profiles"in e&&n(13,d=e.profiles)},e.$$.update=()=>{var t,u;8193&e.$$.dirty&&n(1,i=d.get(c?.pubkey)||null),3&e.$$.dirty&&n(7,(t=i,u=c?.pubkey,s=t?.name?t.name:t?.display_name?t.display_name:u?u.slice(0,8)+"...":"Anonymous")),1&e.$$.dirty&&n(6,r=function(e){if(!e)return"";const t=Math.floor(Date.now()/1e3)-e;return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:t<604800?`${Math.floor(t/86400)}d`:new Date(1e3*e).toLocaleDateString()}(c?.created_at)),1&e.$$.dirty&&n(5,o=function(e){let t=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return t=t.replace(/(https?:\/\/[^\s<]+)/g,'<a href="$1" target="_blank" rel="noopener noreferrer" class="note-link">$1</a>'),t=t.replace(/nostr:(npub1[a-z0-9]+|note1[a-z0-9]+|nevent1[a-z0-9]+|nprofile1[a-z0-9]+|naddr1[a-z0-9]+)/g,'<span class="nostr-ref">$&</span>'),t=t.replace(/\n/g,"<br>"),t}(c?.content||"")),e.$$.dirty,1&e.$$.dirty&&n(4,l=[...(c?.content||"").matchAll(/https?:\/\/[^\s<]+\.(jpg|jpeg|png|gif|webp|svg)(\?[^\s<]*)?/gi)||[]].map(e=>e[0])),1&e.$$.dirty&&n(3,a=c?.tags?.find(e=>"content-warning"===e[0])?.[1]||null)},[c,i,h,a,l,o,r,s,function(){f("reply",c)},function(){f("reaction",c)},function(){f("repost",c)},function(){f("zap",c)},u,d,()=>n(2,h=!0)]}class by extends fe{constructor(e){super(),de(this,e,wy,yy,r,{event:0,userPubkey:12,profiles:13})}}const Ay=wh([]),ky=wh(!1),Iy=wh(!0),Cy=wh(Math.floor(Date.now()/1e3));const{Map:Ey}=d;function xy(e,t,n){const i=e.slice();return i[17]=t[n],i}function Sy(e){let t,n,i,s,r,o=[],l=new Ey,a=e[3];const c=e=>e[17].id;for(let t=0;t<a.length;t+=1){let n=xy(e,a,t),i=c(n);l.set(i,o[t]=Fy(i,n))}let u=e[7]&&Dy(),d=!e[6]&&e[3].length>0&&Qy(),f=!e[7]&&0===e[3].length&&Py();return{c(){for(let e=0;e<o.length;e+=1)o[e].c();t=w(),u&&u.c(),n=w(),d&&d.c(),i=w(),f&&f.c(),s=b()},m(e,l){for(let t=0;t<o.length;t+=1)o[t]&&o[t].m(e,l);h(e,t,l),u&&u.m(e,l),h(e,n,l),d&&d.m(e,l),h(e,i,l),f&&f.m(e,l),h(e,s,l),r=!0},p(e,r){26&r&&(a=e[3],ee(),o=oe(o,r,c,1,e,a,l,t.parentNode,re,Fy,t,xy),te()),e[7]?u||(u=Dy(),u.c(),u.m(n.parentNode,n)):u&&(u.d(1),u=null),!e[6]&&e[3].length>0?d||(d=Qy(),d.c(),d.m(i.parentNode,i)):d&&(d.d(1),d=null),e[7]||0!==e[3].length?f&&(f.d(1),f=null):f||(f=Py(),f.c(),f.m(s.parentNode,s))},i(e){if(!r){for(let e=0;e<a.length;e+=1)ne(o[e]);r=!0}},o(e){for(let e=0;e<o.length;e+=1)ie(o[e]);r=!1},d(e){for(let t=0;t<o.length;t+=1)o[t].d(e);e&&p(t),u&&u.d(e),e&&p(n),d&&d.d(e),e&&p(i),f&&f.d(e),e&&p(s)}}}function By(t){let n;return{c(){n=m("div"),n.innerHTML='<p class="svelte-lta52u">You aren&#39;t following anyone yet.</p> \n            <p class="feed-hint svelte-lta52u">Follow some people to see their notes here.</p>',I(n,"class","feed-empty svelte-lta52u")},m(e,t){h(e,n,t)},p:e,i:e,o:e,d(e){e&&p(n)}}}function $y(t){let n;return{c(){n=m("div"),n.innerHTML='<p class="svelte-lta52u">Log in to see your feed.</p>',I(n,"class","feed-empty svelte-lta52u")},m(e,t){h(e,n,t)},p:e,i:e,o:e,d(e){e&&p(n)}}}function Fy(e,t){let n,i,s;return i=new by({props:{event:t[17],userPubkey:t[1],profiles:t[4]}}),{key:e,first:null,c(){n=b(),ae(i.$$.fragment),this.first=n},m(e,t){h(e,n,t),ce(i,e,t),s=!0},p(e,n){t=e;const s={};8&n&&(s.event=t[17]),2&n&&(s.userPubkey=t[1]),16&n&&(s.profiles=t[4]),i.$set(s)},i(e){s||(ne(i.$$.fragment,e),s=!0)},o(e){ie(i.$$.fragment,e),s=!1},d(e){e&&p(n),ue(i,e)}}}function Dy(e){let t;return{c(){t=m("div"),t.innerHTML='<div class="spinner svelte-lta52u"></div>',I(t,"class","feed-loading svelte-lta52u")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Qy(e){let t;return{c(){t=m("div"),t.textContent="No more notes.",I(t,"class","feed-end svelte-lta52u")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Py(e){let t;return{c(){t=m("div"),t.innerHTML='<p class="svelte-lta52u">No notes from your follows yet.</p>',I(t,"class","feed-empty svelte-lta52u")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Ry(e){let t,n,s,r,o,l,a,c,u,d,g,v,b=e[7]?"...":"Refresh";const k=[$y,By,Sy],C=[];function x(e,t){return e[0]?0===e[2].length?1:2:0}return c=x(e),u=C[c]=k[c](e),{c(){t=m("div"),n=m("div"),s=m("h2"),s.textContent="Feed",r=w(),o=m("button"),l=y(b),a=w(),u.c(),I(s,"class","svelte-lta52u"),I(o,"class","refresh-btn svelte-lta52u"),o.disabled=e[7],I(n,"class","feed-header svelte-lta52u"),I(t,"class","feed-view svelte-lta52u")},m(i,u){h(i,t,u),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(t,a),C[c].m(t,null),e[12](t),d=!0,g||(v=[A(o,"click",e[9]),A(t,"scroll",e[8])],g=!0)},p(e,[n]){(!d||128&n)&&b!==(b=e[7]?"...":"Refresh")&&E(l,b),(!d||128&n)&&(o.disabled=e[7]);let i=c;c=x(e),c===i?C[c].p(e,n):(ee(),ie(C[i],1,1,()=>{C[i]=null}),te(),u=C[c],u?u.p(e,n):(u=C[c]=k[c](e),u.c()),ne(u,1),u.m(t,null))},i(e){d||(ne(u),d=!0)},o(e){ie(u),d=!1},d(n){n&&p(t),C[c].d(),e[12](null),g=!1,i(v)}}}function Ty(e,t,n){let i,s,r,o,l;u(e,Cy,e=>n(13,s=e)),u(e,Iy,e=>n(6,r=e)),u(e,ky,e=>n(7,o=e)),u(e,Ay,e=>n(3,l=e));let a,{isLoggedIn:c=!1}=t,{userPubkey:d=""}=t,{userContactList:f=null}=t,h=new Map,p=!1;async function g(){if(!o&&0!==i.length){ky.set(!0);try{const t=await gp([{kinds:[1],authors:i,limit:40}],{timeout:15e3,useCache:!1});t&&t.length>0&&(e=t,Ay.update(t=>{const n=new Set(t.map(e=>e.id));return[...e.filter(e=>!n.has(e.id)),...t].sort((e,t)=>t.created_at-e.created_at)}),v(t))}catch(e){console.error("[Feed] Error loading feed:",e)}finally{ky.set(!1)}var e}}async function m(){if(!o&&r&&0!==i.length){ky.set(!0);try{const e=await gp([{kinds:[1],authors:i,until:s,limit:40}],{timeout:15e3,useCache:!1});e&&(!function(e){if(0===e.length)return void Iy.set(!1);Ay.update(t=>{const n=new Set(t.map(e=>e.id)),i=e.filter(e=>!n.has(e.id));return[...t,...i].sort((e,t)=>t.created_at-e.created_at)});const t=e.reduce((e,t)=>Math.min(e,t.created_at),1/0);Cy.set(t)}(e),v(e))}catch(e){console.error("[Feed] Error loading more:",e)}finally{ky.set(!1)}}}async function v(e){const t=new Set;for(const n of e)n.pubkey&&!h.has(n.pubkey)&&t.add(n.pubkey);for(const e of t)try{const t=await ap(e);t&&(h.set(e,t),n(4,h))}catch{}}return R(()=>{c&&i.length>0&&0===l.length&&g()}),e.$$set=e=>{"isLoggedIn"in e&&n(0,c=e.isLoggedIn),"userPubkey"in e&&n(1,d=e.userPubkey),"userContactList"in e&&n(10,f=e.userContactList)},e.$$.update=()=>{var t;1024&e.$$.dirty&&n(2,(t=f,i=t?.tags?t.tags.filter(e=>"p"===e[0]&&e[1]).map(e=>e[1]):[])),2061&e.$$.dirty&&c&&i.length>0&&!p&&(n(11,p=!0),0===l.length&&g())},[c,d,i,l,h,a,r,o,function(e){const t=e.target;t.scrollHeight-t.scrollTop-t.clientHeight<200&&m()},function(){Ay.set([]),ky.set(!1),Iy.set(!0),Cy.set(Math.floor(Date.now()/1e3)),n(11,p=!1),g()},f,p,function(e){M[e?"unshift":"push"](()=>{a=e,n(5,a)})}]}class Ly extends fe{constructor(e){super(),de(this,e,Ty,Ry,r,{isLoggedIn:0,userPubkey:1,userContactList:10})}}const{Map:_y}=d;function Ny(e,t,n){const i=e.slice();return i[24]=t[n],i}function My(e,t,n){const i=e.slice();return i[27]=t[n],i}function Uy(e){let t,n=[],i=new _y,s=e[6];const r=e=>e[27].pubkey;for(let t=0;t<s.length;t+=1){let o=My(e,s,t),l=r(o);i.set(l,n[t]=Jy(l,o))}return{c(){for(let e=0;e<n.length;e+=1)n[e].c();t=b()},m(e,i){for(let t=0;t<n.length;t+=1)n[t]&&n[t].m(e,i);h(e,t,i)},p(e,o){1864&o&&(s=e[6],n=oe(n,o,r,1,e,s,i,t.parentNode,se,Jy,t,My))},d(e){for(let t=0;t<n.length;t+=1)n[t].d(e);e&&p(t)}}}function Oy(t){let n;return{c(){n=m("div"),n.textContent="No conversations yet.",I(n,"class","inbox-empty svelte-kf3eu2")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function jy(t){let n;return{c(){n=m("div"),n.innerHTML='<div class="spinner svelte-kf3eu2"></div>',I(n,"class","inbox-loading svelte-kf3eu2")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function zy(t){let n;return{c(){n=m("div"),n.textContent="Log in to see your messages.",I(n,"class","inbox-empty svelte-kf3eu2")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Hy(e){let t,n,i=e[8](e[27].pubkey).charAt(0).toUpperCase()+"";return{c(){t=m("div"),n=y(i),I(t,"class","conv-avatar-placeholder svelte-kf3eu2")},m(e,i){h(e,t,i),f(t,n)},p(e,t){64&t&&i!==(i=e[8](e[27].pubkey).charAt(0).toUpperCase()+"")&&E(n,i)},d(e){e&&p(t)}}}function qy(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[9](e[27].pubkey))||I(t,"src",n),I(t,"alt",""),I(t,"class","conv-avatar svelte-kf3eu2")},m(e,n){h(e,t,n)},p(e,i){64&i&&!l(t.src,n=e[9](e[27].pubkey))&&I(t,"src",n)},d(e){e&&p(t)}}}function Gy(e){let t,n,i=e[27].unreadCount+"";return{c(){t=m("span"),n=y(i),I(t,"class","conv-badge svelte-kf3eu2")},m(e,i){h(e,t,i),f(t,n)},p(e,t){64&t&&i!==(i=e[27].unreadCount+"")&&E(n,i)},d(e){e&&p(t)}}}function Jy(e,t){let n,i,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B=t[8](t[27].pubkey)+"",$=Xy(t[27].lastMessage?.created_at)+"",D=ew(t[27].lastMessage?.decrypted||t[27].lastMessage?.content||"")+"";function Q(e,t){return 64&t&&(i=null),null==i&&(i=!!e[9](e[27].pubkey)),i?qy:Hy}let P=Q(t,-1),R=P(t),T=t[27].unreadCount>0&&Gy(t);function L(){return t[17](t[27])}return{key:e,first:null,c(){n=m("div"),R.c(),s=w(),r=m("div"),o=m("div"),l=m("span"),a=y(B),c=w(),u=m("span"),d=y($),g=w(),v=m("div"),b=y(D),k=w(),T&&T.c(),C=w(),I(l,"class","conv-name svelte-kf3eu2"),I(u,"class","conv-time svelte-kf3eu2"),I(o,"class","conv-header-row svelte-kf3eu2"),I(v,"class","conv-preview svelte-kf3eu2"),I(r,"class","conv-info svelte-kf3eu2"),I(n,"class","conversation-item svelte-kf3eu2"),F(n,"active",t[3]===t[27].pubkey),this.first=n},m(e,t){h(e,n,t),R.m(n,null),f(n,s),f(n,r),f(r,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(r,g),f(r,v),f(v,b),f(n,k),T&&T.m(n,null),f(n,C),x||(S=A(n,"click",L),x=!0)},p(e,i){P===(P=Q(t=e,i))&&R?R.p(t,i):(R.d(1),R=P(t),R&&(R.c(),R.m(n,s))),64&i&&B!==(B=t[8](t[27].pubkey)+"")&&E(a,B),64&i&&$!==($=Xy(t[27].lastMessage?.created_at)+"")&&E(d,$),64&i&&D!==(D=ew(t[27].lastMessage?.decrypted||t[27].lastMessage?.content||"")+"")&&E(b,D),t[27].unreadCount>0?T?T.p(t,i):(T=Gy(t),T.c(),T.m(n,C)):T&&(T.d(1),T=null),72&i&&F(n,"active",t[3]===t[27].pubkey)},d(e){e&&p(n),R.d(),T&&T.d(),x=!1,S()}}}function Ky(e){let t,n,s,r,o,l,a,c,u,d,g,b,k,C,S,B,$,F,D,Q,P,R,T,L,_=e[8](e[3])+"",N=[],M=new _y;function U(e,t){return 8&t&&(l=null),null==l&&(l=!!e[9](e[3])),l?Wy:Vy}let O=U(e,-1),j=O(e),z=e[2];const H=e=>e[24].id;for(let t=0;t<z.length;t+=1){let n=Ny(e,z,t),i=H(n);M.set(i,N[t]=Yy(i,n))}return{c(){t=m("div"),n=m("div"),s=m("button"),s.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-kf3eu2"><polyline points="15 18 9 12 15 6"></polyline></svg>',r=w(),o=m("div"),j.c(),a=w(),c=m("span"),u=y(_),d=w(),g=m("div");for(let e=0;e<N.length;e+=1)N[e].c();b=w(),k=m("div"),C=w(),S=m("div"),B=m("textarea"),$=w(),F=m("button"),D=v("svg"),Q=v("line"),P=v("polygon"),I(s,"class","back-btn svelte-kf3eu2"),I(c,"class","thread-name svelte-kf3eu2"),I(o,"class","thread-user svelte-kf3eu2"),I(n,"class","thread-header svelte-kf3eu2"),I(g,"class","messages-container svelte-kf3eu2"),I(B,"placeholder","Type a message..."),I(B,"rows","1"),B.disabled=e[5],I(B,"class","svelte-kf3eu2"),I(Q,"x1","22"),I(Q,"y1","2"),I(Q,"x2","11"),I(Q,"y2","13"),I(P,"points","22 2 15 22 11 13 2 9 22 2"),I(D,"viewBox","0 0 24 24"),I(D,"fill","none"),I(D,"stroke","currentColor"),I(D,"stroke-width","2"),I(D,"class","svelte-kf3eu2"),I(F,"class","send-btn svelte-kf3eu2"),F.disabled=R=e[5]||!e[4].trim(),I(S,"class","compose-bar svelte-kf3eu2"),I(t,"class","message-thread svelte-kf3eu2")},m(i,l){h(i,t,l),f(t,n),f(n,s),f(n,r),f(n,o),j.m(o,null),f(o,a),f(o,c),f(c,u),f(t,d),f(t,g);for(let e=0;e<N.length;e+=1)N[e]&&N[e].m(g,null);f(g,b),f(g,k),e[18](k),f(t,C),f(t,S),f(S,B),x(B,e[4]),f(S,$),f(S,F),f(F,D),f(D,Q),f(D,P),T||(L=[A(s,"click",e[11]),A(B,"input",e[19]),A(B,"keydown",e[13]),A(F,"click",e[12])],T=!0)},p(e,t){O===(O=U(e,t))&&j?j.p(e,t):(j.d(1),j=O(e),j&&(j.c(),j.m(o,a))),8&t&&_!==(_=e[8](e[3])+"")&&E(u,_),4&t&&(z=e[2],N=oe(N,t,H,1,e,z,M,g,se,Yy,b,Ny)),32&t&&(B.disabled=e[5]),16&t&&x(B,e[4]),48&t&&R!==(R=e[5]||!e[4].trim())&&(F.disabled=R)},d(n){n&&p(t),j.d();for(let e=0;e<N.length;e+=1)N[e].d();e[18](null),T=!1,i(L)}}}function Vy(e){let t,n,i=e[8](e[3]).charAt(0).toUpperCase()+"";return{c(){t=m("div"),n=y(i),I(t,"class","thread-avatar-placeholder svelte-kf3eu2")},m(e,i){h(e,t,i),f(t,n)},p(e,t){8&t&&i!==(i=e[8](e[3]).charAt(0).toUpperCase()+"")&&E(n,i)},d(e){e&&p(t)}}}function Wy(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[9](e[3]))||I(t,"src",n),I(t,"alt",""),I(t,"class","thread-avatar svelte-kf3eu2")},m(e,n){h(e,t,n)},p(e,i){8&i&&!l(t.src,n=e[9](e[3]))&&I(t,"src",n)},d(e){e&&p(t)}}}function Yy(e,t){let n,i,s,r,o,l,a,c=(t[24].decrypted||t[24].content)+"",u=Xy(t[24].created_at)+"";return{key:e,first:null,c(){n=m("div"),i=m("div"),s=m("div"),r=y(c),o=w(),l=m("span"),a=y(u),I(s,"class","message-text"),I(l,"class","message-time svelte-kf3eu2"),I(i,"class","message-bubble svelte-kf3eu2"),I(n,"class","message svelte-kf3eu2"),F(n,"mine",t[24].isMine),F(n,"theirs",!t[24].isMine),this.first=n},m(e,t){h(e,n,t),f(n,i),f(i,s),f(s,r),f(i,o),f(i,l),f(l,a)},p(e,i){t=e,4&i&&c!==(c=(t[24].decrypted||t[24].content)+"")&&E(r,c),4&i&&u!==(u=Xy(t[24].created_at)+"")&&E(a,u),4&i&&F(n,"mine",t[24].isMine),4&i&&F(n,"theirs",!t[24].isMine)},d(e){e&&p(n)}}}function Zy(t){let n,i,s;function r(e,t){return e[0]?e[7]?jy:0===e[6].length?Oy:Uy:zy}let o=r(t),l=o(t),a=t[3]&&Ky(t);return{c(){n=m("div"),i=m("div"),l.c(),s=w(),a&&a.c(),I(i,"class","conversation-list svelte-kf3eu2"),F(i,"hidden-mobile",t[3]),I(n,"class","inbox svelte-kf3eu2"),F(n,"has-selected",t[3])},m(e,t){h(e,n,t),f(n,i),l.m(i,null),f(n,s),a&&a.m(n,null)},p(e,[t]){o===(o=r(e))&&l?l.p(e,t):(l.d(1),l=o(e),l&&(l.c(),l.m(i,null))),8&t&&F(i,"hidden-mobile",e[3]),e[3]?a?a.p(e,t):(a=Ky(e),a.c(),a.m(n,null)):a&&(a.d(1),a=null),8&t&&F(n,"has-selected",e[3])},i:e,o:e,d(e){e&&p(n),l.d(),a&&a.d()}}}function Xy(e){if(!e)return"";const t=new Date(1e3*e),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric"})}function ew(e,t=50){return!e||e.length<=t?e:e.slice(0,t)+"..."}function tw(e,t,n){let i,s,r,o,l;u(e,Um,e=>n(3,r=e)),u(e,Om,e=>n(7,o=e)),u(e,Mm,e=>n(16,l=e));let a,{isLoggedIn:c=!1}=t,{userPubkey:d=""}=t,{userSigner:f=null}=t,h=new Map,p="",g=!1,m=!1;function v(e){Um.set(e)}async function y(){if(p.trim()&&r&&f&&!g){n(5,g=!0);try{const e=p.trim(),t=r;let i;if(!f.nip04Encrypt)throw new Error("Signer does not support NIP-04 encryption");i=await f.nip04Encrypt(t,e);const s={kind:4,created_at:Math.floor(Date.now()/1e3),tags:[["p",t]],content:i},o=await f.signEvent(s);await Zh.publish(o),Mm.update(n=>{const i=n.get(t)||{messages:[],lastRead:0,unreadCount:0,protocol:"nip04"};return i.messages.push({...o,decrypted:e,isMine:!0}),n.set(t,i),new Map(n)}),n(4,p="")}catch(e){console.error("[Inbox] Failed to send message:",e)}finally{n(5,g=!1)}}}R(()=>{c&&d&&!m&&(m=!0,async function(){if(o||!d)return;Om.set(!0);try{const[e,t]=await Promise.all([gp([{kinds:[4],authors:[d],limit:200}],{timeout:15e3,useCache:!1}),gp([{kinds:[4],"#p":[d],limit:200}],{timeout:15e3,useCache:!1})]),n=[...e||[],...t||[]];if(0===n.length)return void Om.set(!1);const i=new Map;for(const e of n){const t=e.pubkey===d?e.tags.find(e=>"p"===e[0])?.[1]:e.pubkey;if(!t)continue;i.has(t)||i.set(t,{messages:[],lastRead:0,unreadCount:0,protocol:"nip04"});let n=e.content;try{f?.nip04Decrypt&&(n=await f.nip04Decrypt(t,e.content))}catch{n="[encrypted]"}i.get(t).messages.push({...e,decrypted:n,isMine:e.pubkey===d})}for(const e of i.values())e.messages.sort((e,t)=>e.created_at-t.created_at);Mm.set(i);!async function(e){for(const t of e)if(!h.has(t))try{const e=await ap(t);e&&h.set(t,e)}catch{}}([...i.keys()])}catch(e){console.error("[Inbox] Error loading DMs:",e)}finally{Om.set(!1)}}())});return e.$$set=e=>{"isLoggedIn"in e&&n(0,c=e.isLoggedIn),"userPubkey"in e&&n(14,d=e.userPubkey),"userSigner"in e&&n(15,f=e.userSigner)},e.$$.update=()=>{var t;65536&e.$$.dirty&&n(6,i=function(e){const t=[];for(const[n,i]of e.entries()){if(!i.messages||0===i.messages.length)continue;const e=i.messages[i.messages.length-1];t.push({pubkey:n,lastMessage:e,unreadCount:i.unreadCount||0,protocol:i.protocol||"nip04"})}return t.sort((e,t)=>(t.lastMessage?.created_at||0)-(e.lastMessage?.created_at||0)),t}(l)),65544&e.$$.dirty&&n(2,s=r&&l.get(r)?.messages||[]),6&e.$$.dirty&&s.length>0&&a&&q().then(()=>{a&&a.scrollIntoView({behavior:"smooth"})}),8&e.$$.dirty&&r&&(t=r,Mm.update(e=>{const n=e.get(t);return n&&(n.lastRead=Date.now(),n.unreadCount=0,e.set(t,n)),new Map(e)}))},[c,a,s,r,p,g,i,o,function(e){const t=h.get(e);return t?.name?t.name:t?.display_name?t.display_name:e?.slice(0,12)+"..."},function(e){return h.get(e)?.picture||null},v,function(){Um.set(null)},y,function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),y())},d,f,l,e=>v(e.pubkey),function(e){M[e?"unshift":"push"](()=>{a=e,n(1,a)})},function(){p=this.value,n(4,p)}]}class nw extends fe{constructor(e){super(),de(this,e,tw,Zy,r,{isLoggedIn:0,userPubkey:14,userSigner:15})}}const{Map:iw}=d;function sw(e,t,n){const i=e.slice();return i[42]=t[n],i}function rw(e,t,n){const i=e.slice();return i[45]=t[n],i}function ow(e,t,n){const i=e.slice();return i[42]=t[n],i}function lw(e){let t,n=[],i=new iw,s=e[11];const r=e=>e[42].id;for(let t=0;t<s.length;t+=1){let o=ow(e,s,t),l=r(o);i.set(l,n[t]=fw(l,o))}return{c(){for(let e=0;e<n.length;e+=1)n[e].c();t=b()},m(e,i){for(let t=0;t<n.length;t+=1)n[t]&&n[t].m(e,i);h(e,t,i)},p(e,o){296968&o[0]&&(s=e[11],n=oe(n,o,r,1,e,s,i,t.parentNode,se,fw,t,ow))},d(e){for(let t=0;t<n.length;t+=1)n[t].d(e);e&&p(t)}}}function aw(t){let n,i,s,r,o;return{c(){n=m("div"),i=y("No channels joined.\n                "),s=m("button"),s.textContent="Discover channels",I(s,"class","discover-link svelte-16xoyqs"),I(n,"class","channels-empty svelte-16xoyqs")},m(e,l){h(e,n,l),f(n,i),f(n,s),r||(o=A(s,"click",t[13]),r=!0)},p:e,d(e){e&&p(n),r=!1,o()}}}function cw(t){let n;return{c(){n=m("div"),n.innerHTML='<div class="spinner svelte-16xoyqs"></div>',I(n,"class","channels-loading svelte-16xoyqs")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function uw(t){let n;return{c(){n=m("div"),n.textContent="Log in to use channels.",I(n,"class","channels-empty svelte-16xoyqs")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function dw(e){let t,n,i=e[42].unreadCount+"";return{c(){t=m("span"),n=y(i),I(t,"class","channel-badge svelte-16xoyqs")},m(e,i){h(e,t,i),f(t,n)},p(e,t){2048&t[0]&&i!==(i=e[42].unreadCount+"")&&E(n,i)},d(e){e&&p(t)}}}function fw(e,t){let n,s,r,o,l,a,c,u,d,g,v,b,C=t[42].name+"",x=t[42].unreadCount>0&&dw(t);function S(){return t[29](t[42])}function B(){return t[30](t[42])}return{key:e,first:null,c(){n=m("div"),s=m("div"),s.textContent="#",r=w(),o=m("div"),l=m("span"),a=y(C),c=w(),x&&x.c(),u=w(),d=m("button"),d.textContent="x",g=w(),I(s,"class","channel-icon svelte-16xoyqs"),I(l,"class","channel-name svelte-16xoyqs"),I(o,"class","channel-info svelte-16xoyqs"),I(d,"class","channel-leave svelte-16xoyqs"),I(d,"title","Leave channel"),I(n,"class","channel-item svelte-16xoyqs"),F(n,"active",t[3]===t[42].id),this.first=n},m(e,t){h(e,n,t),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(n,c),x&&x.m(n,null),f(n,u),f(n,d),f(n,g),v||(b=[A(d,"click",k(S)),A(n,"click",B)],v=!0)},p(e,i){t=e,2048&i[0]&&C!==(C=t[42].name+"")&&E(a,C),t[42].unreadCount>0?x?x.p(t,i):(x=dw(t),x.c(),x.m(n,u)):x&&(x.d(1),x=null),2056&i[0]&&F(n,"active",t[3]===t[42].id)},d(e){e&&p(n),x&&x.d(),v=!1,i(b)}}}function hw(e){let t,n,s,r,o,l,a,c,u,d,g,b,k,C,S,B,$,F,D,Q,P,R,T,L,_,N=(e[10].name||e[3].slice(0,12))+"",M=[],U=new iw,O=e[10].about&&pw(e),j=e[2];const z=e=>e[45].id;for(let t=0;t<j.length;t+=1){let n=rw(e,j,t),i=z(n);U.set(i,M[t]=gw(i,n))}return{c(){t=m("div"),n=m("div"),s=m("button"),s.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-16xoyqs"><polyline points="15 18 9 12 15 6"></polyline></svg>',r=w(),o=m("div"),l=m("span"),a=y("# "),c=y(N),u=w(),O&&O.c(),d=w(),g=m("div");for(let e=0;e<M.length;e+=1)M[e].c();b=w(),k=m("div"),C=w(),S=m("div"),B=m("textarea"),F=w(),D=m("button"),Q=v("svg"),P=v("line"),R=v("polygon"),I(s,"class","back-btn svelte-16xoyqs"),I(l,"class","thread-channel-name svelte-16xoyqs"),I(o,"class","thread-channel-info svelte-16xoyqs"),I(n,"class","thread-header svelte-16xoyqs"),I(g,"class","messages-container svelte-16xoyqs"),I(B,"placeholder",$="Message #"+(e[10].name||"channel")+"..."),I(B,"rows","1"),B.disabled=e[5],I(B,"class","svelte-16xoyqs"),I(P,"x1","22"),I(P,"y1","2"),I(P,"x2","11"),I(P,"y2","13"),I(R,"points","22 2 15 22 11 13 2 9 22 2"),I(Q,"viewBox","0 0 24 24"),I(Q,"fill","none"),I(Q,"stroke","currentColor"),I(Q,"stroke-width","2"),I(Q,"class","svelte-16xoyqs"),I(D,"class","send-btn svelte-16xoyqs"),D.disabled=T=e[5]||!e[4].trim(),I(S,"class","compose-bar svelte-16xoyqs"),I(t,"class","channel-thread svelte-16xoyqs")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(l,c),f(o,u),O&&O.m(o,null),f(t,d),f(t,g);for(let e=0;e<M.length;e+=1)M[e]&&M[e].m(g,null);f(g,b),f(g,k),e[31](k),f(t,C),f(t,S),f(S,B),x(B,e[4]),f(S,F),f(S,D),f(D,Q),f(Q,P),f(Q,R),L||(_=[A(s,"click",e[19]),A(B,"input",e[32]),A(B,"keydown",e[21]),A(D,"click",e[20])],L=!0)},p(e,t){1032&t[0]&&N!==(N=(e[10].name||e[3].slice(0,12))+"")&&E(c,N),e[10].about?O?O.p(e,t):(O=pw(e),O.c(),O.m(o,null)):O&&(O.d(1),O=null),131076&t[0]&&(j=e[2],M=oe(M,t,z,1,e,j,U,g,se,gw,b,rw)),1024&t[0]&&$!==($="Message #"+(e[10].name||"channel")+"...")&&I(B,"placeholder",$),32&t[0]&&(B.disabled=e[5]),16&t[0]&&x(B,e[4]),48&t[0]&&T!==(T=e[5]||!e[4].trim())&&(D.disabled=T)},d(n){n&&p(t),O&&O.d();for(let e=0;e<M.length;e+=1)M[e].d();e[31](null),L=!1,i(_)}}}function pw(e){let t,n,i=e[10].about+"";return{c(){t=m("span"),n=y(i),I(t,"class","thread-channel-about svelte-16xoyqs")},m(e,i){h(e,t,i),f(t,n)},p(e,t){1024&t[0]&&i!==(i=e[10].about+"")&&E(n,i)},d(e){e&&p(t)}}}function gw(e,t){let n,i,s,r,o,l,a,c,u,d,g=t[17](t[45].pubkey)+"",v=Cw(t[45].created_at)+"",b=t[45].content+"";return{key:e,first:null,c(){n=m("div"),i=m("div"),s=m("span"),r=y(g),o=w(),l=m("span"),a=y(v),c=w(),u=m("div"),d=y(b),I(s,"class","msg-name svelte-16xoyqs"),I(l,"class","msg-time svelte-16xoyqs"),I(i,"class","msg-author svelte-16xoyqs"),I(u,"class","msg-content svelte-16xoyqs"),I(n,"class","channel-message svelte-16xoyqs"),this.first=n},m(e,t){h(e,n,t),f(n,i),f(i,s),f(s,r),f(i,o),f(i,l),f(l,a),f(n,c),f(n,u),f(u,d)},p(e,n){t=e,4&n[0]&&g!==(g=t[17](t[45].pubkey)+"")&&E(r,g),4&n[0]&&v!==(v=Cw(t[45].created_at)+"")&&E(a,v),4&n[0]&&b!==(b=t[45].content+"")&&E(d,b)},d(e){e&&p(n)}}}function mw(e){let t,n,s,r,o,l,a,c,u;function d(e,t){return e[9]?ww:0===e[8].length?yw:vw}let g=d(e),v=g(e);return{c(){t=m("div"),n=m("div"),s=m("div"),r=m("h3"),r.textContent="Discover Channels",o=w(),l=m("button"),l.textContent="x",a=w(),v.c(),I(r,"class","svelte-16xoyqs"),I(l,"class","discovery-close svelte-16xoyqs"),I(s,"class","discovery-header svelte-16xoyqs"),I(n,"class","discovery-panel svelte-16xoyqs"),I(t,"class","discovery-overlay svelte-16xoyqs")},m(i,d){h(i,t,d),f(t,n),f(n,s),f(s,r),f(s,o),f(s,l),f(n,a),v.m(n,null),c||(u=[A(l,"click",e[33]),A(n,"click",k(e[28])),A(t,"click",e[35])],c=!0)},p(e,t){g===(g=d(e))&&v?v.p(e,t):(v.d(1),v=g(e),v&&(v.c(),v.m(n,null)))},d(e){e&&p(t),v.d(),c=!1,i(u)}}}function vw(e){let t,n=[],i=new iw,s=e[8];const r=e=>e[42].id;for(let t=0;t<s.length;t+=1){let o=sw(e,s,t),l=r(o);i.set(l,n[t]=Aw(l,o))}return{c(){t=m("div");for(let e=0;e<n.length;e+=1)n[e].c();I(t,"class","discovery-list svelte-16xoyqs")},m(e,i){h(e,t,i);for(let e=0;e<n.length;e+=1)n[e]&&n[e].m(t,null)},p(e,o){16640&o[0]&&(s=e[8],n=oe(n,o,r,1,e,s,i,t,se,Aw,null,sw))},d(e){e&&p(t);for(let e=0;e<n.length;e+=1)n[e].d()}}}function yw(t){let n;return{c(){n=m("div"),n.textContent="No new channels found.",I(n,"class","channels-empty svelte-16xoyqs")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function ww(t){let n;return{c(){n=m("div"),n.innerHTML='<div class="spinner svelte-16xoyqs"></div>',I(n,"class","channels-loading svelte-16xoyqs")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function bw(e){let t,n,i=e[42].about+"";return{c(){t=m("span"),n=y(i),I(t,"class","discovery-about svelte-16xoyqs")},m(e,i){h(e,t,i),f(t,n)},p(e,t){256&t[0]&&i!==(i=e[42].about+"")&&E(n,i)},d(e){e&&p(t)}}}function Aw(e,t){let n,i,s,r,o,l,a,c,u,d,g,v=t[42].name+"",b=t[42].about&&bw(t);function k(){return t[34](t[42])}return{key:e,first:null,c(){n=m("div"),i=m("div"),s=m("span"),r=y("# "),o=y(v),l=w(),b&&b.c(),a=w(),c=m("button"),c.textContent="Join",u=w(),I(s,"class","discovery-name svelte-16xoyqs"),I(i,"class","discovery-info svelte-16xoyqs"),I(c,"class","join-btn svelte-16xoyqs"),I(n,"class","discovery-item svelte-16xoyqs"),this.first=n},m(e,t){h(e,n,t),f(n,i),f(i,s),f(s,r),f(s,o),f(i,l),b&&b.m(i,null),f(n,a),f(n,c),f(n,u),d||(g=A(c,"click",k),d=!0)},p(e,n){t=e,256&n[0]&&v!==(v=t[42].name+"")&&E(o,v),t[42].about?b?b.p(t,n):(b=bw(t),b.c(),b.m(i,null)):b&&(b.d(1),b=null)},d(e){e&&p(n),b&&b.d(),d=!1,g()}}}function kw(t){let n,s,r,o,l,a,c,u,d,g;return{c(){n=m("div"),s=m("div"),r=m("p"),r.textContent="Leave this channel?",o=w(),l=m("div"),a=m("button"),a.textContent="Cancel",c=w(),u=m("button"),u.textContent="Leave",I(r,"class","svelte-16xoyqs"),I(a,"class","cancel-btn svelte-16xoyqs"),I(u,"class","leave-btn svelte-16xoyqs"),I(l,"class","confirm-actions svelte-16xoyqs"),I(s,"class","confirm-panel svelte-16xoyqs"),I(n,"class","discovery-overlay svelte-16xoyqs")},m(e,i){h(e,n,i),f(n,s),f(s,r),f(s,o),f(s,l),f(l,a),f(l,c),f(l,u),d||(g=[A(a,"click",t[36]),A(u,"click",t[16]),A(s,"click",k(t[27])),A(n,"click",t[37])],d=!0)},p:e,d(e){e&&p(n),d=!1,i(g)}}}function Iw(t){let n,i,s,r,o,l,a,c,u,d,g,v;function y(e,t){return e[0]?e[12]?cw:0===e[11].length?aw:lw:uw}let b=y(t),k=b(t),C=t[3]&&hw(t),E=t[7]&&mw(t),x=t[6]&&kw(t);return{c(){n=m("div"),i=m("div"),s=m("div"),r=m("span"),r.textContent="Channels",o=w(),l=m("button"),l.textContent="+",a=w(),k.c(),c=w(),C&&C.c(),u=w(),E&&E.c(),d=w(),x&&x.c(),I(l,"class","discover-btn svelte-16xoyqs"),I(s,"class","channel-list-header svelte-16xoyqs"),I(i,"class","channel-list svelte-16xoyqs"),F(i,"hidden-mobile",t[3]),I(n,"class","channels svelte-16xoyqs"),F(n,"has-selected",t[3])},m(e,p){h(e,n,p),f(n,i),f(i,s),f(s,r),f(s,o),f(s,l),f(i,a),k.m(i,null),f(n,c),C&&C.m(n,null),f(n,u),E&&E.m(n,null),f(n,d),x&&x.m(n,null),g||(v=A(l,"click",t[13]),g=!0)},p(e,t){b===(b=y(e))&&k?k.p(e,t):(k.d(1),k=b(e),k&&(k.c(),k.m(i,null))),8&t[0]&&F(i,"hidden-mobile",e[3]),e[3]?C?C.p(e,t):(C=hw(e),C.c(),C.m(n,u)):C&&(C.d(1),C=null),e[7]?E?E.p(e,t):(E=mw(e),E.c(),E.m(n,d)):E&&(E.d(1),E=null),e[6]?x?x.p(e,t):(x=kw(e),x.c(),x.m(n,null)):x&&(x.d(1),x=null),8&t[0]&&F(n,"has-selected",e[3])},i:e,o:e,d(e){e&&p(n),k.d(),C&&C.d(),E&&E.d(),x&&x.d(),g=!1,v()}}}function Cw(e){if(!e)return"";const t=new Date(1e3*e),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric"})}function Ew(e,t,n){let i,s,r,o,l,a,c,d;u(e,qm,e=>n(3,l=e)),u(e,Hm,e=>n(25,a=e)),u(e,jm,e=>n(26,c=e)),u(e,Gm,e=>n(12,d=e));let f,{isLoggedIn:h=!1}=t,{userPubkey:p=""}=t,{userSigner:g=null}=t,m=new Map,v="",y=!1,w=!1,b=null,A=!1,k=[],I=!1;async function C(){if(!d){Gm.set(!0);try{const e=[...a];if(0===e.length)return void Gm.set(!1);const t=await gp([{kinds:[40],ids:e,limit:100}],{timeout:1e4,useCache:!1}),n=await gp([{kinds:[41],"#e":e,limit:100}],{timeout:1e4,useCache:!1}),i=new Map(c);for(const e of t||[])try{const t=JSON.parse(e.content),n=i.get(e.id)||{messages:[],lastRead:0,unreadCount:0,joined:!0};n.metadata=t,n.metadata._creator=e.pubkey,n.joined=!0,i.set(e.id,n)}catch{}for(const e of n||[]){const t=e.tags.find(e=>"e"===e[0])?.[1];if(t&&i.has(t))try{const n=JSON.parse(e.content),s=i.get(t);s.metadata?._creator===e.pubkey&&(s.metadata={...s.metadata,...n,_creator:e.pubkey},i.set(t,s))}catch{}}const s=await gp([{kinds:[42],"#e":e,limit:200}],{timeout:15e3,useCache:!1}),r=new Set;for(const e of s||[]){const t=e.tags.find(e=>"e"===e[0]&&("root"===e[3]||!e[3])),n=t?.[1];if(!n||!i.has(n))continue;const s=i.get(n);s.messages.find(t=>t.id===e.id)||(s.messages.push(e),r.add(e.pubkey))}for(const e of i.values())e.messages.sort((e,t)=>e.created_at-t.created_at);jm.set(i),async function(e){for(const t of e)if(!m.has(t))try{const e=await ap(t);e&&m.set(t,e)}catch{}}([...r])}catch(e){console.error("[Channels] Error loading channels:",e)}finally{Gm.set(!1)}}}function E(e){!function(e){Hm.update(t=>(t.add(e),new Set(t)))}(e),n(7,A=!1),C()}function x(e){n(6,b=e)}function S(e){qm.set(e)}async function B(){if(v.trim()&&l&&g&&!y){n(5,y=!0);try{const e=v.trim(),t=l,i={kind:42,created_at:Math.floor(Date.now()/1e3),tags:[["e",t,"","root"]],content:e},s=await g.signEvent(i);await Zh.publish(s),jm.update(e=>{const n=e.get(t);return n&&!n.messages.find(e=>e.id===s.id)&&(n.messages.push(s),e.set(t,{...n})),new Map(e)}),n(4,v="")}catch(e){console.error("[Channels] Send error:",e)}finally{n(5,y=!1)}}}R(()=>{h&&!w&&(w=!0,C())});return e.$$set=e=>{"isLoggedIn"in e&&n(0,h=e.isLoggedIn),"userPubkey"in e&&n(22,p=e.userPubkey),"userSigner"in e&&n(23,g=e.userSigner)},e.$$.update=()=>{var t;100663296&e.$$.dirty[0]&&n(11,i=function(e,t){const n=[];for(const[i,s]of e.entries()){if(!t.has(i))continue;const e=s.messages?.length>0?s.messages[s.messages.length-1]:null;n.push({id:i,name:s.metadata?.name||i.slice(0,12)+"...",about:s.metadata?.about||"",picture:s.metadata?.picture||null,lastMessage:e,unreadCount:s.unreadCount||0})}return n.sort((e,t)=>(t.lastMessage?.created_at||0)-(e.lastMessage?.created_at||0)),n}(c,a)),67108872&e.$$.dirty[0]&&n(24,s=l?c.get(l):null),16777216&e.$$.dirty[0]&&n(2,r=s?.messages||[]),16777216&e.$$.dirty[0]&&n(10,o=s?.metadata||{}),6&e.$$.dirty[0]&&r.length>0&&f&&q().then(()=>{f&&f.scrollIntoView({behavior:"smooth"})}),8&e.$$.dirty[0]&&l&&(t=l,jm.update(e=>{const n=e.get(t);return n&&(n.lastRead=Date.now(),n.unreadCount=0,e.set(t,n)),new Map(e)}),localStorage.setItem(`channel-lastread-${t}`,Date.now().toString()))},[h,f,r,l,v,y,b,A,k,I,o,i,d,async function(){n(7,A=!0),n(9,I=!0),n(8,k=[]);try{const e=await gp([{kinds:[40],limit:50}],{timeout:1e4,useCache:!1});for(const t of e||[])if(!a.has(t.id))try{const e=JSON.parse(t.content);k.push({id:t.id,name:e.name||t.id.slice(0,12)+"...",about:e.about||"",picture:e.picture||null,creator:t.pubkey})}catch{}}catch(e){console.error("[Channels] Discovery error:",e)}finally{n(9,I=!1)}},E,x,function(){var e;b&&(e=b,Hm.update(t=>(t.delete(e),new Set(t))),qm.update(t=>t===e?null:t),jm.update(e=>(e.delete(b),new Map(e))),n(6,b=null))},function(e){const t=m.get(e);return t?.name?t.name:t?.display_name?t.display_name:e?.slice(0,10)+"..."},S,function(){qm.set(null)},B,function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),B())},p,g,s,a,c,function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},e=>x(e.id),e=>S(e.id),function(e){M[e?"unshift":"push"](()=>{f=e,n(1,f)})},function(){v=this.value,n(4,v)},()=>n(7,A=!1),e=>E(e.id),()=>n(7,A=!1),()=>n(6,b=null),()=>n(6,b=null)]}class xw extends fe{constructor(e){super(),de(this,e,Ew,Iw,r,{isLoggedIn:0,userPubkey:22,userSigner:23},null,[-1,-1])}}function Sw(e){let t,n;return t=new xw({props:{isLoggedIn:e[0],userPubkey:e[1],userSigner:e[2]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};1&n&&(i.isLoggedIn=e[0]),2&n&&(i.userPubkey=e[1]),4&n&&(i.userSigner=e[2]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function Bw(e){let t,n;return t=new nw({props:{isLoggedIn:e[0],userPubkey:e[1],userSigner:e[2]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};1&n&&(i.isLoggedIn=e[0]),2&n&&(i.userPubkey=e[1]),4&n&&(i.userSigner=e[2]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function $w(e){let t,n,s,r,o,l,a,c,u,d,g,v;const y=[Bw,Sw],b=[];function k(e,t){return"inbox"===e[3]?0:1}return c=k(e),u=b[c]=y[c](e),{c(){t=m("div"),n=m("div"),s=m("button"),s.textContent="Inbox",r=w(),o=m("button"),o.textContent="Channels",l=w(),a=m("div"),u.c(),I(s,"class","chat-tab svelte-1jnm3cc"),F(s,"active","inbox"===e[3]),I(o,"class","chat-tab svelte-1jnm3cc"),F(o,"active","channels"===e[3]),I(n,"class","chat-tabs svelte-1jnm3cc"),I(a,"class","chat-content svelte-1jnm3cc"),I(t,"class","chat-view svelte-1jnm3cc")},m(i,u){h(i,t,u),f(t,n),f(n,s),f(n,r),f(n,o),f(t,l),f(t,a),b[c].m(a,null),d=!0,g||(v=[A(s,"click",e[4]),A(o,"click",e[5])],g=!0)},p(e,[t]){(!d||8&t)&&F(s,"active","inbox"===e[3]),(!d||8&t)&&F(o,"active","channels"===e[3]);let n=c;c=k(e),c===n?b[c].p(e,t):(ee(),ie(b[n],1,1,()=>{b[n]=null}),te(),u=b[c],u?u.p(e,t):(u=b[c]=y[c](e),u.c()),ne(u,1),u.m(a,null))},i(e){d||(ne(u),d=!0)},o(e){ie(u),d=!1},d(e){e&&p(t),b[c].d(),g=!1,i(v)}}}function Fw(e,t,n){let i;u(e,Nm,e=>n(3,i=e));let{isLoggedIn:s=!1}=t,{userPubkey:r=""}=t,{userSigner:o=null}=t;return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"userPubkey"in e&&n(1,r=e.userPubkey),"userSigner"in e&&n(2,o=e.userSigner)},[s,r,o,i,()=>Nm.set("inbox"),()=>Nm.set("channels")]}class Dw extends fe{constructor(e){super(),de(this,e,Fw,$w,r,{isLoggedIn:0,userPubkey:1,userSigner:2})}}const Qw=wh("my-library"),Pw=wh(null),Rw=wh(null),Tw=wh(!1),Lw=wh(null),_w=wh([]),Nw=wh(0),Mw=wh([]),Uw=wh(!1);function Ow(e,t,n){const i=e.slice();return i[16]=t[n],i}function jw(e,t,n){const i=e.slice();return i[19]=t[n],i}function zw(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B=[],$=new Map,D=(e[1]?e[3].find(e[12])?.title||"Documents":"All Documents")+"",Q=e[2].length+"",P=1!==e[2].length?"s":"",R=e[3];const T=e=>e[19].dtag;for(let t=0;t<R.length;t+=1){let n=jw(e,R,t),i=T(n);$.set(i,B[t]=Gw(i,n))}function L(e,t){return 0===e[2].length?Kw:Jw}let _=L(e),N=_(e);return{c(){t=m("div"),n=m("div"),n.textContent="Categories",i=w(),s=m("button"),s.textContent="All",r=w();for(let e=0;e<B.length;e+=1)B[e].c();o=w(),l=m("div"),a=m("div"),c=m("h3"),u=y(D),d=w(),g=m("span"),v=y(Q),b=y(" document"),k=y(P),C=w(),N.c(),I(n,"class","category-header svelte-1chwztk"),I(s,"class","category-item svelte-1chwztk"),F(s,"active",!e[1]),I(t,"class","category-sidebar svelte-1chwztk"),I(c,"class","svelte-1chwztk"),I(g,"class","docs-count svelte-1chwztk"),I(a,"class","docs-header svelte-1chwztk"),I(l,"class","document-list svelte-1chwztk")},m(p,m){h(p,t,m),f(t,n),f(t,i),f(t,s),f(t,r);for(let e=0;e<B.length;e+=1)B[e]&&B[e].m(t,null);h(p,o,m),h(p,l,m),f(l,a),f(a,c),f(c,u),f(a,d),f(a,g),f(g,v),f(g,b),f(g,k),f(l,C),N.m(l,null),x||(S=A(s,"click",e[10]),x=!0)},p(e,n){2&n&&F(s,"active",!e[1]),74&n&&(R=e[3],B=oe(B,n,T,1,e,R,$,t,se,Gw,null,jw)),10&n&&D!==(D=(e[1]?e[3].find(e[12])?.title||"Documents":"All Documents")+"")&&E(u,D),4&n&&Q!==(Q=e[2].length+"")&&E(v,Q),4&n&&P!==(P=1!==e[2].length?"s":"")&&E(k,P),_===(_=L(e))&&N?N.p(e,n):(N.d(1),N=_(e),N&&(N.c(),N.m(l,null)))},d(e){e&&p(t);for(let e=0;e<B.length;e+=1)B[e].d();e&&p(o),e&&p(l),N.d(),x=!1,S()}}}function Hw(t){let n;return{c(){n=m("div"),n.innerHTML='<div class="spinner svelte-1chwztk"></div>',I(n,"class","library-loading svelte-1chwztk")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function qw(t){let n;return{c(){n=m("div"),n.textContent="Log in to access your library.",I(n,"class","library-empty svelte-1chwztk")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Gw(e,t){let n,i,s,r,o,l,a,c,u,d=t[19].title+"",g=(t[19].publications?.length||0)+"";function v(){return t[11](t[19])}return{key:e,first:null,c(){n=m("button"),i=m("span"),s=y(d),r=w(),o=m("span"),l=y(g),a=w(),I(i,"class","cat-name"),I(o,"class","cat-count svelte-1chwztk"),I(n,"class","category-item svelte-1chwztk"),F(n,"active",t[1]===t[19].dtag),this.first=n},m(e,t){h(e,n,t),f(n,i),f(i,s),f(n,r),f(n,o),f(o,l),f(n,a),c||(u=A(n,"click",v),c=!0)},p(e,i){t=e,8&i&&d!==(d=t[19].title+"")&&E(s,d),8&i&&g!==(g=(t[19].publications?.length||0)+"")&&E(l,g),10&i&&F(n,"active",t[1]===t[19].dtag)},d(e){e&&p(n),c=!1,u()}}}function Jw(e){let t,n=[],i=new Map,s=e[2];const r=e=>e[16].dtag;for(let t=0;t<s.length;t+=1){let o=Ow(e,s,t),l=r(o);i.set(l,n[t]=Ww(l,o))}return{c(){for(let e=0;e<n.length;e+=1)n[e].c();t=b()},m(e,i){for(let t=0;t<n.length;t+=1)n[t]&&n[t].m(e,i);h(e,t,i)},p(e,o){36&o&&(s=e[2],n=oe(n,o,r,1,e,s,i,t.parentNode,se,Ww,t,Ow))},d(e){for(let t=0;t<n.length;t+=1)n[t].d(e);e&&p(t)}}}function Kw(t){let n;return{c(){n=m("div"),n.innerHTML='<p class="svelte-1chwztk">No publications yet.</p> \n                    <p class="hint svelte-1chwztk">Create your first publication from the &quot;New&quot; tab in Library.</p>',I(n,"class","library-empty svelte-1chwztk")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Vw(e){let t,n,i,s,r,o,l=30023===e[16].event.kind?"Article":"Publication",a=new Date(1e3*e[16].event.created_at).toLocaleDateString()+"";return{c(){t=m("div"),n=m("span"),i=y(l),s=w(),r=m("span"),o=y(a),I(n,"class","doc-kind svelte-1chwztk"),I(r,"class","doc-date"),I(t,"class","doc-meta svelte-1chwztk")},m(e,l){h(e,t,l),f(t,n),f(n,i),f(t,s),f(t,r),f(r,o)},p(e,t){4&t&&l!==(l=30023===e[16].event.kind?"Article":"Publication")&&E(i,l),4&t&&a!==(a=new Date(1e3*e[16].event.created_at).toLocaleDateString()+"")&&E(o,a)},d(e){e&&p(t)}}}function Ww(e,t){let n,i,s,r,o,l,a,c=t[16].title+"",u=t[16].event&&Vw(t);function d(){return t[13](t[16])}return{key:e,first:null,c(){n=m("div"),i=m("div"),s=y(c),r=w(),u&&u.c(),o=w(),I(i,"class","doc-title svelte-1chwztk"),I(n,"class","doc-card svelte-1chwztk"),this.first=n},m(e,t){h(e,n,t),f(n,i),f(i,s),f(n,r),u&&u.m(n,null),f(n,o),l||(a=A(n,"click",d),l=!0)},p(e,i){t=e,4&i&&c!==(c=t[16].title+"")&&E(s,c),t[16].event?u?u.p(t,i):(u=Vw(t),u.c(),u.m(n,o)):u&&(u.d(1),u=null)},d(e){e&&p(n),u&&u.d(),l=!1,a()}}}function Yw(t){let n;function i(e,t){return e[0]?e[4]?Hw:zw:qw}let s=i(t),r=s(t);return{c(){n=m("div"),r.c(),I(n,"class","my-library svelte-1chwztk")},m(e,t){h(e,n,t),r.m(n,null)},p(e,[t]){s===(s=i(e))&&r?r.p(e,t):(r.d(1),r=s(e),r&&(r.c(),r.m(n,null)))},i:e,o:e,d(e){e&&p(n),r.d()}}}function Zw(e,t,n){let i,s,r,o,l;u(e,Rw,e=>n(1,r=e)),u(e,Tw,e=>n(4,o=e)),u(e,Pw,e=>n(9,l=e));let{isLoggedIn:a=!1}=t,{userPubkey:c=""}=t,{userSigner:d=null}=t,f=!1;async function h(e){if(e.event)try{const t=(e.event.tags||[]).filter(e=>"a"===e[0]&&e[1]?.startsWith("30041:")),n=[];if(t.length>0){const i=await gp([{kinds:[30041],authors:[e.event.pubkey],limit:100}],{timeout:1e4,useCache:!1});for(const e of t){const t=e[1]?.split(":"),s=t?.slice(2).join(":"),r=(i||[]).find(e=>(e.tags||[]).find(e=>"d"===e[0]&&e[1]===s));r&&n.push(r)}}if(0===n.length){const t=(e.event.tags||[]).find(e=>"d"===e[0])?.[1],i=await gp([{kinds:[30023],authors:[e.event.pubkey],"#d":[t],limit:1}],{timeout:1e4,useCache:!1});i?.length>0&&n.push(i[0])}!function(e,t){Lw.set(e),_w.set(t),Nw.set(0),Qw.set("reader")}(e.event,n)}catch(e){console.error("[Library] Error opening publication:",e)}}function p(e){Rw.set(r===e?null:e)}R(()=>{a&&c&&!f&&(f=!0,async function(){if(o||!c)return;Tw.set(!0);try{const e=await gp([{kinds:[30040],authors:[c],limit:100}],{timeout:15e3,useCache:!1});if(!e||0===e.length)return void Pw.set({categories:[{dtag:"uncategorized",title:"Uncategorized",publications:[]}]});const t=e.find(e=>(e.tags||[]).find(e=>"d"===e[0]&&"library-root"===e[1])),n=[],i=new Set;if(t){const s=(t.tags||[]).filter(e=>"a"===e[0]);for(const t of s){const[,s]=t,r=s?.split(":");if(!r||r.length<3)continue;const o=r.slice(2).join(":"),l=e.find(e=>(e.tags||[]).find(e=>"d"===e[0]&&e[1]===o));if(l){const t=(l.tags||[]).find(e=>"title"===e[0])?.[1]||o,s=(l.tags||[]).filter(e=>"a"===e[0]),r=[];for(const t of s){const n=t[1]?.split(":");if(!n||n.length<3)continue;const s=n.slice(2).join(":");i.add(s);const o=e.find(e=>(e.tags||[]).find(e=>"d"===e[0]&&e[1]===s));o&&r.push({dtag:s,title:(o.tags||[]).find(e=>"title"===e[0])?.[1]||s,event:o})}n.push({dtag:o,title:t,publications:r}),i.add(o)}}}const s=[];for(const t of e){const e=(t.tags||[]).find(e=>"d"===e[0])?.[1];e&&"library-root"!==e&&!i.has(e)&&s.push({dtag:e,title:(t.tags||[]).find(e=>"title"===e[0])?.[1]||e,event:t})}(s.length>0||0===n.length)&&n.push({dtag:"uncategorized",title:"Uncategorized",publications:s}),Pw.set({categories:n})}catch(e){console.error("[Library] Error loading:",e)}finally{Tw.set(!1)}}())});return e.$$set=e=>{"isLoggedIn"in e&&n(0,a=e.isLoggedIn),"userPubkey"in e&&n(7,c=e.userPubkey),"userSigner"in e&&n(8,d=e.userSigner)},e.$$.update=()=>{512&e.$$.dirty&&n(3,i=l?.categories||[]),514&e.$$.dirty&&n(2,s=function(e,t){if(!t?.categories)return[];if(!e)return t.categories.flatMap(e=>e.publications||[]);const n=t.categories.find(t=>t.dtag===e);return n?.publications||[]}(r,l))},[a,r,s,i,o,h,p,c,d,l,()=>Rw.set(null),e=>p(e.dtag),e=>e.dtag===r,e=>h(e)]}class Xw extends fe{constructor(e){super(),de(this,e,Zw,Yw,r,{isLoggedIn:0,userPubkey:7,userSigner:8})}}function eb(e,t,n){const i=e.slice();return i[20]=t[n],i}function tb(e,t){let n,i,s,r,o,l=t[20].title+"";function a(){return t[19](t[20])}return{key:e,first:null,c(){n=m("button"),i=y(l),s=w(),I(n,"class","toc-item svelte-1tnxelv"),F(n,"active",t[0]===t[20].index),this.first=n},m(e,t){h(e,n,t),f(n,i),f(n,s),r||(o=A(n,"click",a),r=!0)},p(e,s){t=e,32&s&&l!==(l=t[20].title+"")&&E(i,l),33&s&&F(n,"active",t[0]===t[20].index)},d(e){e&&p(n),r=!1,o()}}}function nb(e){let t,n,i,s,r=e[0]+1+"";return{c(){t=m("span"),n=y(r),i=y(" / "),s=y(e[2]),I(t,"class","section-indicator svelte-1tnxelv")},m(e,r){h(e,t,r),f(t,n),f(t,i),f(t,s)},p(e,t){1&t&&r!==(r=e[0]+1+"")&&E(n,r),4&t&&E(s,e[2])},d(e){e&&p(t)}}}function ib(e){let t;return{c(){t=m("div"),I(t,"class","rendered-content svelte-1tnxelv")},m(n,i){h(n,t,i),t.innerHTML=e[4]},p(e,n){16&n&&(t.innerHTML=e[4])},d(e){e&&p(t)}}}function sb(t){let n;return{c(){n=m("div"),n.textContent="No content available for this publication.",I(n,"class","reader-empty svelte-1tnxelv")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function rb(e){let t,n,s,r,o,l,a,c,u,d;return{c(){t=m("div"),n=m("button"),s=y("Previous"),o=w(),l=m("button"),a=y("Next"),I(n,"class","nav-btn svelte-1tnxelv"),n.disabled=r=0===e[0],I(l,"class","nav-btn svelte-1tnxelv"),l.disabled=c=e[0]>=e[2]-1,I(t,"class","section-nav svelte-1tnxelv")},m(i,r){h(i,t,r),f(t,n),f(n,s),f(t,o),f(t,l),f(l,a),u||(d=[A(n,"click",e[8]),A(l,"click",e[9])],u=!0)},p(e,t){1&t&&r!==(r=0===e[0])&&(n.disabled=r),5&t&&c!==(c=e[0]>=e[2]-1)&&(l.disabled=c)},d(e){e&&p(t),u=!1,i(d)}}}function ob(t){let n,i,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$=[],F=new Map,D=t[5];const Q=e=>e[20].index;for(let e=0;e<D.length;e+=1){let n=eb(t,D,e),i=Q(n);F.set(i,$[e]=tb(i,n))}let P=t[2]>1&&nb(t);function R(e,t){return 0===e[1].length?sb:ib}let T=R(t),L=T(t),_=t[2]>1&&rb(t);return{c(){n=m("div"),i=m("div"),s=m("button"),s.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-1tnxelv"><polyline points="15 18 9 12 15 6"></polyline></svg>\n            Back',r=w(),o=m("div"),l=y(t[6]),a=w();for(let e=0;e<$.length;e+=1)$[e].c();c=w(),u=m("div"),d=m("div"),g=m("h2"),v=y(t[3]),b=w(),P&&P.c(),k=w(),C=m("div"),L.c(),x=w(),_&&_.c(),I(s,"class","back-link svelte-1tnxelv"),I(o,"class","toc-title svelte-1tnxelv"),I(i,"class","reader-toc svelte-1tnxelv"),I(g,"class","svelte-1tnxelv"),I(d,"class","content-header svelte-1tnxelv"),I(C,"class","content-body svelte-1tnxelv"),I(u,"class","reader-content svelte-1tnxelv"),I(n,"class","reader svelte-1tnxelv")},m(e,p){h(e,n,p),f(n,i),f(i,s),f(i,r),f(i,o),f(o,l),f(i,a);for(let e=0;e<$.length;e+=1)$[e]&&$[e].m(i,null);f(n,c),f(n,u),f(u,d),f(d,g),f(g,v),f(d,b),P&&P.m(d,null),f(u,k),f(u,C),L.m(C,null),f(u,x),_&&_.m(u,null),S||(B=A(s,"click",t[10]),S=!0)},p(e,[t]){64&t&&E(l,e[6]),161&t&&(D=e[5],$=oe($,t,Q,1,e,D,F,i,se,tb,null,eb)),8&t&&E(v,e[3]),e[2]>1?P?P.p(e,t):(P=nb(e),P.c(),P.m(d,null)):P&&(P.d(1),P=null),T===(T=R(e))&&L?L.p(e,t):(L.d(1),L=T(e),L&&(L.c(),L.m(C,null))),e[2]>1?_?_.p(e,t):(_=rb(e),_.c(),_.m(u,null)):_&&(_.d(1),_=null)},i:e,o:e,d(e){e&&p(n);for(let e=0;e<$.length;e+=1)$[e].d();P&&P.d(),L.d(),_&&_.d(),S=!1,B()}}}function lb(e,t,n){let i,s,r,o,l,a,c,d,f,h,p,g,m;u(e,Nw,e=>n(16,p=e)),u(e,_w,e=>n(17,g=e)),u(e,Lw,e=>n(18,m=e));let{isLoggedIn:v=!1}=t,{userPubkey:y=""}=t;function w(e){Nw.set(e)}return e.$$set=e=>{"isLoggedIn"in e&&n(11,v=e.isLoggedIn),"userPubkey"in e&&n(12,y=e.userPubkey)},e.$$.update=()=>{262144&e.$$.dirty&&n(15,i=m),131072&e.$$.dirty&&n(1,s=g),65536&e.$$.dirty&&n(0,r=p),3&e.$$.dirty&&n(13,o=s[r]||null),2&e.$$.dirty&&n(2,l=s.length),32768&e.$$.dirty&&n(6,a=i?(i.tags||[]).find(e=>"title"===e[0])?.[1]||"Untitled":""),32768&e.$$.dirty&&n(14,c=i&&(i.tags||[]).find(e=>"format"===e[0])?.[1]||"markdown"),2&e.$$.dirty&&n(5,d=s.map((e,t)=>({index:t,title:(e.tags||[]).find(e=>"title"===e[0])?.[1]||`Section ${t+1}`}))),24576&e.$$.dirty&&n(4,f=o?function(e,t){if(!e)return'<p class="empty-section">Empty section.</p>';let n=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return"asciidoc"===t?(n=n.replace(/^= (.+)$/gm,"<h1>$1</h1>"),n=n.replace(/^== (.+)$/gm,"<h2>$1</h2>"),n=n.replace(/^=== (.+)$/gm,"<h3>$1</h3>"),n=n.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/\*(.+?)\*/g,"<em>$1</em>"),n=n.replace(/`(.+?)`/g,"<code>$1</code>"),n=n.replace(/\n\n/g,"</p><p>"),n=`<p>${n}</p>`):(n=n.replace(/^### (.+)$/gm,"<h3>$1</h3>"),n=n.replace(/^## (.+)$/gm,"<h2>$1</h2>"),n=n.replace(/^# (.+)$/gm,"<h1>$1</h1>"),n=n.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),n=n.replace(/\*(.+?)\*/g,"<em>$1</em>"),n=n.replace(/`(.+?)`/g,"<code>$1</code>"),n=n.replace(/^\- (.+)$/gm,"<li>$1</li>"),n=n.replace(/(<li>.*<\/li>)/s,"<ul>$1</ul>"),n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener">$1</a>'),n=n.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="content-image" />'),n=n.replace(/\n\n/g,"</p><p>"),n=`<p>${n}</p>`),n=n.replace(/\n/g,"<br>"),n}(o.content,c):""),8193&e.$$.dirty&&n(3,h=o?(o.tags||[]).find(e=>"title"===e[0])?.[1]||`Section ${r+1}`:"")},[r,s,l,h,f,d,a,w,function(){r>0&&Nw.set(r-1)},function(){r<l-1&&Nw.set(r+1)},function(){Qw.set("my-library")},v,y,o,c,i,p,g,m,e=>w(e.index)]}class ab extends fe{constructor(e){super(),de(this,e,lb,ob,r,{isLoggedIn:11,userPubkey:12})}}function cb(e,t,n){const i=e.slice();return i[7]=t[n],i}function ub(e,t,n){const i=e.slice();return i[10]=t[n],i}function db(e){let t,n,i=[],s=new Map,r=e[1];const o=e=>e[10].id;for(let t=0;t<r.length;t+=1){let n=ub(e,r,t),l=o(n);s.set(l,i[t]=gb(l,n))}let l=e[3].filter(Ab),a=[];for(let t=0;t<l.length;t+=1)a[t]=mb(cb(e,l,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();n=w();for(let e=0;e<a.length;e+=1)a[e].c();I(t,"class","bookmark-list svelte-2jr8xp")},m(e,s){h(e,t,s);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null);f(t,n);for(let e=0;e<a.length;e+=1)a[e]&&a[e].m(t,null)},p(e,c){if(2&c&&(r=e[1],i=oe(i,c,o,1,e,r,s,t,se,gb,n,ub)),8&c){let n;for(l=e[3].filter(Ab),n=0;n<l.length;n+=1){const i=cb(e,l,n);a[n]?a[n].p(i,c):(a[n]=mb(i),a[n].c(),a[n].m(t,null))}for(;n<a.length;n+=1)a[n].d(1);a.length=l.length}},d(e){e&&p(t);for(let e=0;e<i.length;e+=1)i[e].d();g(a,e)}}}function fb(t){let n;return{c(){n=m("div"),n.innerHTML='<p class="svelte-2jr8xp">No bookmarks yet.</p> \n            <p class="hint svelte-2jr8xp">Bookmark notes and articles to find them here.</p>',I(n,"class","bookmarks-empty svelte-2jr8xp")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function hb(t){let n;return{c(){n=m("div"),n.innerHTML='<div class="spinner svelte-2jr8xp"></div>',I(n,"class","bookmarks-loading svelte-2jr8xp")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function pb(t){let n;return{c(){n=m("div"),n.textContent="Log in to see your bookmarks.",I(n,"class","bookmarks-empty svelte-2jr8xp")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function gb(e,t){let n,i,s,r,o,l,a,c,u,d,g,v,b,A,k,C=yb(t[10].kind)+"",x=wb(t[10].content)+"",S=t[10].pubkey?.slice(0,10)+"",B=bb(t[10].created_at)+"";return{key:e,first:null,c(){n=m("div"),i=m("div"),s=y(C),r=w(),o=m("div"),l=y(x),a=w(),c=m("div"),u=m("span"),d=y(S),g=y("..."),v=w(),b=m("span"),A=y(B),k=w(),I(i,"class","bookmark-kind svelte-2jr8xp"),I(o,"class","bookmark-content svelte-2jr8xp"),I(u,"class","bookmark-author"),I(b,"class","bookmark-date"),I(c,"class","bookmark-meta svelte-2jr8xp"),I(n,"class","bookmark-item svelte-2jr8xp"),this.first=n},m(e,t){h(e,n,t),f(n,i),f(i,s),f(n,r),f(n,o),f(o,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(c,v),f(c,b),f(b,A),f(n,k)},p(e,n){t=e,2&n&&C!==(C=yb(t[10].kind)+"")&&E(s,C),2&n&&x!==(x=wb(t[10].content)+"")&&E(l,x),2&n&&S!==(S=t[10].pubkey?.slice(0,10)+"")&&E(d,S),2&n&&B!==(B=bb(t[10].created_at)+"")&&E(A,B)},d(e){e&&p(n)}}}function mb(e){let t,n,i,s,r,o,l=e[7][1]+"";return{c(){t=m("div"),n=m("div"),n.textContent="Reference",i=w(),s=m("div"),r=y(l),o=w(),I(n,"class","bookmark-kind svelte-2jr8xp"),I(s,"class","bookmark-content bookmark-ref svelte-2jr8xp"),I(t,"class","bookmark-item svelte-2jr8xp")},m(e,l){h(e,t,l),f(t,n),f(t,i),f(t,s),f(s,r),f(t,o)},p(e,t){8&t&&l!==(l=e[7][1]+"")&&E(r,l)},d(e){e&&p(t)}}}function vb(t){let n,i,s,r,o,l,a,c,u,d=t[3].length+"",g=1!==t[3].length?"s":"";function v(e,t){return e[0]?e[2]?hb:0===e[1].length&&0===e[3].length?fb:db:pb}let b=v(t),A=b(t);return{c(){n=m("div"),i=m("div"),s=m("h2"),s.textContent="Bookmarks",r=w(),o=m("span"),l=y(d),a=y(" item"),c=y(g),u=w(),A.c(),I(s,"class","svelte-2jr8xp"),I(o,"class","bookmark-count svelte-2jr8xp"),I(i,"class","bookmarks-header svelte-2jr8xp"),I(n,"class","bookmarks-view svelte-2jr8xp")},m(e,t){h(e,n,t),f(n,i),f(i,s),f(i,r),f(i,o),f(o,l),f(o,a),f(o,c),f(n,u),A.m(n,null)},p(e,[t]){8&t&&d!==(d=e[3].length+"")&&E(l,d),8&t&&g!==(g=1!==e[3].length?"s":"")&&E(c,g),b===(b=v(e))&&A?A.p(e,t):(A.d(1),A=b(e),A&&(A.c(),A.m(n,null)))},i:e,o:e,d(e){e&&p(n),A.d()}}}function yb(e){switch(e){case 1:return"Note";case 30023:return"Article";case 30040:return"Publication";case 30041:return"Section";default:return`Kind ${e}`}}function wb(e,t=120){return!e||e.length<=t?e||"":e.slice(0,t)+"..."}function bb(e){return e?new Date(1e3*e).toLocaleDateString():""}const Ab=e=>"a"===e[0];function kb(e,t,n){let i,s;u(e,Uw,e=>n(2,i=e)),u(e,Mw,e=>n(3,s=e));let{isLoggedIn:r=!1}=t,{userPubkey:o=""}=t,l=!1,a=[];return R(()=>{r&&o&&!l&&(l=!0,async function(){if(i||!o)return;Uw.set(!0);try{const e=await gp([{kinds:[10003],authors:[o],limit:1}],{timeout:1e4,useCache:!1});if(!e||0===e.length)return void Uw.set(!1);const t=e.sort((e,t)=>t.created_at-e.created_at)[0],i=(t.tags||[]).filter(e=>"e"===e[0]),s=(t.tags||[]).filter(e=>"a"===e[0]);if(Mw.set([...i,...s]),i.length>0){const e=i.map(e=>e[1]).filter(Boolean),t=await gp([{ids:e,limit:100}],{timeout:1e4,useCache:!1});n(1,a=(t||[]).sort((e,t)=>t.created_at-e.created_at))}}catch(e){console.error("[Bookmarks] Error:",e)}finally{Uw.set(!1)}}())}),e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"userPubkey"in e&&n(4,o=e.userPubkey)},[r,a,i,s,o]}class Ib extends fe{constructor(e){super(),de(this,e,kb,vb,r,{isLoggedIn:0,userPubkey:4})}}function Cb(e){let t,n;return t=new Xw({props:{isLoggedIn:e[0],userPubkey:e[1],userSigner:e[2]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};1&n&&(i.isLoggedIn=e[0]),2&n&&(i.userPubkey=e[1]),4&n&&(i.userSigner=e[2]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function Eb(e){let t,n;return t=new Ib({props:{isLoggedIn:e[0],userPubkey:e[1]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};1&n&&(i.isLoggedIn=e[0]),2&n&&(i.userPubkey=e[1]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function xb(e){let t,n;return t=new ab({props:{isLoggedIn:e[0],userPubkey:e[1]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};1&n&&(i.isLoggedIn=e[0]),2&n&&(i.userPubkey=e[1]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function Sb(e){let t,n,i,s;const r=[xb,Eb,Cb],o=[];function l(e,t){return"reader"===e[3]?0:"bookmarks"===e[3]?1:2}return n=l(e),i=o[n]=r[n](e),{c(){t=m("div"),i.c(),I(t,"class","library-view svelte-1f4dq2i")},m(e,i){h(e,t,i),o[n].m(t,null),s=!0},p(e,[s]){let a=n;n=l(e),n===a?o[n].p(e,s):(ee(),ie(o[a],1,1,()=>{o[a]=null}),te(),i=o[n],i?i.p(e,s):(i=o[n]=r[n](e),i.c()),ne(i,1),i.m(t,null))},i(e){s||(ne(i),s=!0)},o(e){ie(i),s=!1},d(e){e&&p(t),o[n].d()}}}function Bb(e,t,n){let i;u(e,Qw,e=>n(3,i=e));let{isLoggedIn:s=!1}=t,{userPubkey:r=""}=t,{userSigner:o=null}=t,{subView:l="my-library"}=t;return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"userPubkey"in e&&n(1,r=e.userPubkey),"userSigner"in e&&n(2,o=e.userSigner),"subView"in e&&n(4,l=e.subView)},e.$$.update=()=>{16&e.$$.dirty&&("my-library"===l?Qw.set("my-library"):"bookmarks"===l?Qw.set("bookmarks"):"new"===l&&Qw.set("editor"))},[s,r,o,i,l]}class $b extends fe{constructor(e){super(),de(this,e,Bb,Sb,r,{isLoggedIn:0,userPubkey:1,userSigner:2,subView:4})}}function Fb(t){let n,i,s,r,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access export functionality.",s=w(),r=m("button"),r.textContent="Log In",I(i,"class","svelte-wlgkm9"),I(r,"class","login-btn svelte-wlgkm9"),I(n,"class","login-prompt svelte-wlgkm9")},m(e,a){h(e,n,a),f(n,i),f(n,s),f(n,r),o||(l=A(r,"click",t[6]),o=!0)},p:e,d(e){e&&p(n),o=!1,l()}}}function Db(e){let t,n,i=e[0]&&Qb(e),s=e[2]&&Tb(e);return{c(){i&&i.c(),t=w(),s&&s.c(),n=b()},m(e,r){i&&i.m(e,r),h(e,t,r),s&&s.m(e,r),h(e,n,r)},p(e,r){e[0]?i?i.p(e,r):(i=Qb(e),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null),e[2]?s?s.p(e,r):(s=Tb(e),s.c(),s.m(n.parentNode,n)):s&&(s.d(1),s=null)},d(e){i&&i.d(e),e&&p(t),s&&s.d(e),e&&p(n)}}}function Qb(e){let t,n,i,s,r,o,l,a;function c(e,t){return e[1]?Rb:Pb}let u=c(e),d=u(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Export My Events",i=w(),s=m("p"),s.textContent="Download your personal events as a JSONL file.",r=w(),o=m("button"),d.c(),I(n,"class","svelte-wlgkm9"),I(s,"class","svelte-wlgkm9"),I(o,"class","export-btn svelte-wlgkm9"),o.disabled=e[1],I(t,"class","export-section svelte-wlgkm9")},m(c,u){h(c,t,u),f(t,n),f(t,i),f(t,s),f(t,r),f(t,o),d.m(o,null),l||(a=A(o,"click",e[4]),l=!0)},p(e,t){u!==(u=c(e))&&(d.d(1),d=u(e),d&&(d.c(),d.m(o,null))),2&t&&(o.disabled=e[1])},d(e){e&&p(t),d.d(),l=!1,a()}}}function Pb(e){let t;return{c(){t=y("Export My Events")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Rb(e){let t;return{c(){t=y("Exporting...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Tb(e){let t,n,i,s,r,o,l,a;function c(e,t){return e[1]?_b:Lb}let u=c(e),d=u(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Export All Events",i=w(),s=m("p"),s.textContent="Download the complete database as a JSONL file. This includes\n                all events from all users.",r=w(),o=m("button"),d.c(),I(n,"class","svelte-wlgkm9"),I(s,"class","svelte-wlgkm9"),I(o,"class","export-btn svelte-wlgkm9"),o.disabled=e[1],I(t,"class","export-section svelte-wlgkm9")},m(c,u){h(c,t,u),f(t,n),f(t,i),f(t,s),f(t,r),f(t,o),d.m(o,null),l||(a=A(o,"click",e[5]),l=!0)},p(e,t){u!==(u=c(e))&&(d.d(1),d=u(e),d&&(d.c(),d.m(o,null))),2&t&&(o.disabled=e[1])},d(e){e&&p(t),d.d(),l=!1,a()}}}function Lb(e){let t;return{c(){t=y("Export All Events")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function _b(e){let t;return{c(){t=y("Exporting...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Nb(t){let n;function i(e,t){return e[3]?Db:Fb}let s=i(t),r=s(t);return{c(){r.c(),n=b()},m(e,t){r.m(e,t),h(e,n,t)},p(e,[t]){s===(s=i(e))&&r?r.p(e,t):(r.d(1),r=s(e),r&&(r.c(),r.m(n.parentNode,n)))},i:e,o:e,d(e){r.d(e),e&&p(n)}}}function Mb(e,t,n){let i,s,{isLoggedIn:r=!1}=t,{currentEffectiveRole:o=""}=t,{aclMode:l=""}=t,{isExporting:a=!1}=t;const c=L();return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,o=e.currentEffectiveRole),"aclMode"in e&&n(8,l=e.aclMode),"isExporting"in e&&n(1,a=e.isExporting)},e.$$.update=()=>{257&e.$$.dirty&&n(3,i="none"===l||r),384&e.$$.dirty&&n(2,s="none"===l||"admin"===o||"owner"===o)},[r,a,s,i,function(){c("exportMyEvents")},function(){c("exportAllEvents")},function(){c("openLoginModal")},o,l]}class Ub extends fe{constructor(e){super(),de(this,e,Mb,Nb,r,{isLoggedIn:0,currentEffectiveRole:7,aclMode:8,isExporting:1})}}function Ob(t){let n,i,s,r,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Import Events",s=w(),r=m("p"),r.textContent="Please log in to access import functionality.",o=w(),l=m("button"),l.textContent="Log In",I(i,"class","recovery-header svelte-l7uaow"),I(r,"class","recovery-description svelte-l7uaow"),I(l,"class","login-btn svelte-l7uaow"),I(n,"class","login-prompt svelte-l7uaow")},m(e,u){h(e,n,u),f(n,i),f(n,s),f(n,r),f(n,o),f(n,l),a||(c=A(l,"click",t[6]),a=!0)},p:e,d(e){e&&p(n),a=!1,c()}}}function jb(t){let n;return{c(){n=m("div"),n.innerHTML='<h3 class="recovery-header svelte-l7uaow">Import Events</h3> \n            <p class="recovery-description svelte-l7uaow">Admin or owner permission required for import functionality.</p>',I(n,"class","permission-denied svelte-l7uaow")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function zb(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C=e[2]&&Hb(e);return{c(){t=m("h3"),t.textContent="Import Events",n=w(),s=m("p"),s.textContent="Upload a JSONL file to import events into the database.",r=w(),o=m("div"),l=m("input"),a=w(),c=m("div"),u=m("button"),d=y("Import Events"),v=w(),C&&C.c(),I(t,"class","svelte-l7uaow"),I(s,"class","svelte-l7uaow"),I(l,"type","file"),I(l,"id","import-file"),I(l,"accept",".jsonl,.txt"),I(l,"class","svelte-l7uaow"),I(u,"class","import-btn svelte-l7uaow"),u.disabled=g=!e[1]||"Uploading..."===e[2],I(c,"class","import-row svelte-l7uaow"),I(o,"class","recovery-controls-card svelte-l7uaow")},m(i,p){h(i,t,p),h(i,n,p),h(i,s,p),h(i,r,p),h(i,o,p),f(o,l),f(o,a),f(o,c),f(c,u),f(u,d),f(c,v),C&&C.m(c,null),b||(k=[A(l,"change",e[4]),A(u,"click",e[5])],b=!0)},p(e,t){6&t&&g!==(g=!e[1]||"Uploading..."===e[2])&&(u.disabled=g),e[2]?C?C.p(e,t):(C=Hb(e),C.c(),C.m(c,null)):C&&(C.d(1),C=null)},d(e){e&&p(t),e&&p(n),e&&p(s),e&&p(r),e&&p(o),C&&C.d(),b=!1,i(k)}}}function Hb(e){let t,n;return{c(){t=m("span"),n=y(e[2]),I(t,"class","import-message svelte-l7uaow"),F(t,"uploading","Uploading..."===e[2]),F(t,"success","Upload complete"===e[2]),F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,i){h(e,t,i),f(t,n)},p(e,i){4&i&&E(n,e[2]),4&i&&F(t,"uploading","Uploading..."===e[2]),4&i&&F(t,"success","Upload complete"===e[2]),4&i&&F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&p(t)}}}function qb(t){let n;function i(e,t){return e[3]?zb:e[0]?jb:Ob}let s=i(t),r=s(t);return{c(){n=m("div"),r.c(),I(n,"class","import-section svelte-l7uaow")},m(e,t){h(e,n,t),r.m(n,null)},p(e,[t]){s===(s=i(e))&&r?r.p(e,t):(r.d(1),r=s(e),r&&(r.c(),r.m(n,null)))},i:e,o:e,d(e){e&&p(n),r.d()}}}function Gb(e,t,n){let i,{isLoggedIn:s=!1}=t,{currentEffectiveRole:r=""}=t,{selectedFile:o=null}=t,{aclMode:l=""}=t,{importMessage:a=""}=t;const c=L();return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,r=e.currentEffectiveRole),"selectedFile"in e&&n(1,o=e.selectedFile),"aclMode"in e&&n(8,l=e.aclMode),"importMessage"in e&&n(2,a=e.importMessage)},e.$$.update=()=>{385&e.$$.dirty&&n(3,i="none"===l||s&&("admin"===r||"owner"===r))},[s,o,a,i,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},r,l]}class Jb extends fe{constructor(e){super(),de(this,e,Gb,qb,r,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const Kb={0:"Profile Metadata",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete Request",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1063:"File Metadata",1311:"Live Chat Message",1984:"Reporting",1985:"Label",9734:"Zap Request",9735:"Zap Receipt",1e4:"Mute List",10001:"Pin List",10002:"Relay List Metadata",10003:"Bookmark List",10004:"Communities List",10005:"Public Chats List",10006:"Blocked Relays List",10007:"Search Relays List",10009:"User Groups",10015:"Interests List",10030:"User Emoji List",13194:"Wallet Info",22242:"Client Auth",23194:"Wallet Request",23195:"Wallet Response",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People List",30001:"Categorized Bookmarks",30002:"Categorized Relay List",30003:"Bookmark Sets",30004:"Curation Sets",30005:"Video Sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest Sets",30017:"Create/Update Stall",30018:"Create/Update Product",30019:"Marketplace UI/UX",30020:"Product Sold As Auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji Sets",30063:"Release Artifact Sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30388:"Slide Set",30402:"Classified Listing",30403:"Draft Classified Listing",30617:"Repository Announcement",30618:"Repository State Announcement",30818:"Wiki Article",30819:"Redirects",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler Recommendation",31990:"Handler Information",34550:"Community Definition",34551:"Community Post Approval"};function Vb(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function Wb(e){const t=new Date(1e3*e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Yb(e){return Math.floor(new Date(e).getTime()/1e3)}function Zb(e,t,n){const i=e.slice();return i[62]=t[n],i[64]=n,i}function Xb(e,t,n){const i=e.slice();return i[65]=t[n],i}function eA(e,t,n){const i=e.slice();return i[68]=t[n],i}function tA(e,t,n){const i=e.slice();return i[71]=t[n],i}function nA(e,t,n){const i=e.slice();return i[71]=t[n].kind,i[74]=t[n].name,i}function iA(e){let t,n,i,s,r,o,l=e[20],a=[];for(let t=0;t<l.length;t+=1)a[t]=sA(nA(e,l,t));return{c(){t=m("div"),n=m("input"),i=w(),s=m("div");for(let e=0;e<a.length;e+=1)a[e].c();I(n,"type","text"),I(n,"placeholder","Search kinds..."),I(n,"class","filter-input kind-search svelte-1a1v6k0"),I(s,"class","kinds-list svelte-1a1v6k0"),I(t,"class","kinds-picker svelte-1a1v6k0")},m(l,c){h(l,t,c),f(t,n),x(n,e[9]),f(t,i),f(t,s);for(let e=0;e<a.length;e+=1)a[e]&&a[e].m(s,null);r||(o=A(n,"input",e[40]),r=!0)},p(e,t){if(512&t[0]&&n.value!==e[9]&&x(n,e[9]),9437186&t[0]){let n;for(l=e[20],n=0;n<l.length;n+=1){const i=nA(e,l,n);a[n]?a[n].p(i,t):(a[n]=sA(i),a[n].c(),a[n].m(s,null))}for(;n<a.length;n+=1)a[n].d(1);a.length=l.length}},d(e){e&&p(t),g(a,e),r=!1,o()}}}function sA(e){let t,n,i,s,r,o,l,a,c,u,d,g,v=e[71]+"",b=e[74]+"";function k(){return e[41](e[71])}return{c(){t=m("label"),n=m("input"),s=w(),r=m("span"),o=y(v),l=w(),a=m("span"),c=y(b),u=w(),I(n,"type","checkbox"),n.checked=i=e[1].includes(e[71]),I(n,"class","svelte-1a1v6k0"),I(r,"class","kind-number svelte-1a1v6k0"),I(a,"class","kind-name svelte-1a1v6k0"),I(t,"class","kind-checkbox svelte-1a1v6k0")},m(e,i){h(e,t,i),f(t,n),f(t,s),f(t,r),f(r,o),f(t,l),f(t,a),f(a,c),f(t,u),d||(g=A(n,"change",k),d=!0)},p(t,s){e=t,1048578&s[0]&&i!==(i=e[1].includes(e[71]))&&(n.checked=i),1048576&s[0]&&v!==(v=e[71]+"")&&E(o,v),1048576&s[0]&&b!==(b=e[74]+"")&&E(c,b)},d(e){e&&p(t),d=!1,g()}}}function rA(e){let t,n=e[1],i=[];for(let t=0;t<n.length;t+=1)i[t]=oA(tA(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","chips-container svelte-1a1v6k0")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(16777218&s[0]){let r;for(n=e[1],r=0;r<n.length;r+=1){const o=tA(e,n,r);i[r]?i[r].p(o,s):(i[r]=oA(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function oA(e){let t,n,i,s,r,o,l,a,c,u,d=e[71]+"",g=(Kb[e[71]]||`Kind ${e[71]}`)+"";function v(){return e[42](e[71])}return{c(){t=m("div"),n=m("span"),i=y(d),s=y(": "),r=y(g),o=w(),l=m("button"),l.textContent="×",a=w(),I(n,"class","chip-text svelte-1a1v6k0"),I(l,"class","chip-remove svelte-1a1v6k0"),I(t,"class","chip svelte-1a1v6k0")},m(e,d){h(e,t,d),f(t,n),f(n,i),f(n,s),f(n,r),f(t,o),f(t,l),f(t,a),c||(u=A(l,"click",v),c=!0)},p(t,n){e=t,2&n[0]&&d!==(d=e[71]+"")&&E(i,d),2&n[0]&&g!==(g=(Kb[e[71]]||`Kind ${e[71]}`)+"")&&E(r,g)},d(e){e&&p(t),c=!1,u()}}}function lA(e){let t,n;return{c(){t=m("div"),n=y(e[17]),I(t,"class","error-message svelte-1a1v6k0")},m(e,i){h(e,t,i),f(t,n)},p(e,t){131072&t[0]&&E(n,e[17])},d(e){e&&p(t)}}}function aA(e){let t,n=e[2],i=[];for(let t=0;t<n.length;t+=1)i[t]=cA(eA(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","list-items svelte-1a1v6k0")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(67108868&s[0]){let r;for(n=e[2],r=0;r<n.length;r+=1){const o=eA(e,n,r);i[r]?i[r].p(o,s):(i[r]=cA(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function cA(e){let t,n,i,s,r,o,l,a,c=e[68]+"";function u(){return e[45](e[68])}return{c(){t=m("div"),n=m("span"),i=y(c),s=w(),r=m("button"),r.textContent="×",o=w(),I(n,"class","list-item-text svelte-1a1v6k0"),I(r,"class","list-item-remove svelte-1a1v6k0"),I(t,"class","list-item svelte-1a1v6k0")},m(e,c){h(e,t,c),f(t,n),f(n,i),f(t,s),f(t,r),f(t,o),l||(a=A(r,"click",u),l=!0)},p(t,n){e=t,4&n[0]&&c!==(c=e[68]+"")&&E(i,c)},d(e){e&&p(t),l=!1,a()}}}function uA(e){let t,n;return{c(){t=m("div"),n=y(e[18]),I(t,"class","error-message svelte-1a1v6k0")},m(e,i){h(e,t,i),f(t,n)},p(e,t){262144&t[0]&&E(n,e[18])},d(e){e&&p(t)}}}function dA(e){let t,n=e[3],i=[];for(let t=0;t<n.length;t+=1)i[t]=fA(Xb(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","list-items svelte-1a1v6k0")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(268435464&s[0]){let r;for(n=e[3],r=0;r<n.length;r+=1){const o=Xb(e,n,r);i[r]?i[r].p(o,s):(i[r]=fA(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function fA(e){let t,n,i,s,r,o,l,a,c=e[65]+"";function u(){return e[48](e[65])}return{c(){t=m("div"),n=m("span"),i=y(c),s=w(),r=m("button"),r.textContent="×",o=w(),I(n,"class","list-item-text svelte-1a1v6k0"),I(r,"class","list-item-remove svelte-1a1v6k0"),I(t,"class","list-item svelte-1a1v6k0")},m(e,c){h(e,t,c),f(t,n),f(n,i),f(t,s),f(t,r),f(t,o),l||(a=A(r,"click",u),l=!0)},p(t,n){e=t,8&n[0]&&c!==(c=e[65]+"")&&E(i,c)},d(e){e&&p(t),l=!1,a()}}}function hA(e){let t,n;return{c(){t=m("div"),n=y(e[19]),I(t,"class","error-message svelte-1a1v6k0")},m(e,i){h(e,t,i),f(t,n)},p(e,t){524288&t[0]&&E(n,e[19])},d(e){e&&p(t)}}}function pA(e){let t,n=e[4],i=[];for(let t=0;t<n.length;t+=1)i[t]=gA(Zb(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","list-items svelte-1a1v6k0")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(1073741840&s[0]){let r;for(n=e[4],r=0;r<n.length;r+=1){const o=Zb(e,n,r);i[r]?i[r].p(o,s):(i[r]=gA(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function gA(e){let t,n,i,s,r,o,l,a,c,u,d,g=e[62].name+"",v=e[62].value+"";function b(){return e[52](e[64])}return{c(){t=m("div"),n=m("span"),i=y("#"),s=y(g),r=y(": "),o=y(v),l=w(),a=m("button"),a.textContent="×",c=w(),I(n,"class","list-item-text svelte-1a1v6k0"),I(a,"class","list-item-remove svelte-1a1v6k0"),I(t,"class","list-item svelte-1a1v6k0")},m(e,p){h(e,t,p),f(t,n),f(n,i),f(n,s),f(n,r),f(n,o),f(t,l),f(t,a),f(t,c),u||(d=A(a,"click",b),u=!0)},p(t,n){e=t,16&n[0]&&g!==(g=e[62].name+"")&&E(s,g),16&n[0]&&v!==(v=e[62].value+"")&&E(o,v)},d(e){e&&p(t),u=!1,d()}}}function mA(t){let n,i,s;return{c(){n=m("button"),n.textContent="×",I(n,"class","clear-timestamp-btn svelte-1a1v6k0")},m(e,r){h(e,n,r),i||(s=A(n,"click",t[53]),i=!0)},p:e,d(e){e&&p(n),i=!1,s()}}}function vA(t){let n,i,s;return{c(){n=m("button"),n.textContent="×",I(n,"class","clear-timestamp-btn svelte-1a1v6k0")},m(e,r){h(e,n,r),i||(s=A(n,"click",t[54]),i=!0)},p:e,d(e){e&&p(n),i=!1,s()}}}function yA(e){let t,n,s,r,o,l,a,c,u,d=e[11]&&wA(e);return{c(){t=m("div"),n=m("label"),n.textContent="Filter JSON",s=w(),r=m("textarea"),o=w(),d&&d.c(),l=w(),a=m("button"),a.textContent="Apply JSON",I(n,"for","json-editor"),I(n,"class","svelte-1a1v6k0"),I(r,"id","json-editor"),I(r,"class","json-editor svelte-1a1v6k0"),I(r,"placeholder",'{"kinds": [1], "limit": 100}'),I(r,"rows","8"),I(a,"class","apply-json-btn svelte-1a1v6k0"),I(t,"class","json-editor-section svelte-1a1v6k0")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),x(r,e[10]),f(t,o),d&&d.m(t,null),f(t,l),f(t,a),c||(u=[A(r,"input",e[56]),A(a,"click",e[22])],c=!0)},p(e,n){1024&n[0]&&x(r,e[10]),e[11]?d?d.p(e,n):(d=wA(e),d.c(),d.m(t,l)):d&&(d.d(1),d=null)},d(e){e&&p(t),d&&d.d(),c=!1,i(u)}}}function wA(e){let t,n;return{c(){t=m("div"),n=y(e[11]),I(t,"class","json-error svelte-1a1v6k0")},m(e,i){h(e,t,i),f(t,n)},p(e,t){2048&t[0]&&E(n,e[11])},d(e){e&&p(t)}}}function bA(t){let n,s,r,o,l,a,c,u,d,g,v,b,k,S,B,$,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K,V,W,Y,Z,X,ee,te,ne,ie,se,re,oe,le,ae,ce,ue,de,fe,he,pe,ge,me,ve,ye,we,be,Ae,ke,Ie,Ce,Ee,xe,Se,Be,$e,Fe,De,Qe,Pe,Re,Te,Le,_e,Ne,Me,Ue=t[12]?"▼":"▶",Oe=t[1].length+"",je=t[12]&&iA(t),ze=t[1].length>0&&rA(t),He=t[17]&&lA(t),qe=t[2].length>0&&aA(t),Ge=t[18]&&uA(t),Je=t[3].length>0&&dA(t),Ke=t[19]&&hA(t),Ve=t[4].length>0&&pA(t),We=t[5]&&mA(t),Ye=t[6]&&vA(t),Ze=t[8]&&yA(t);return{c(){n=m("div"),s=m("div"),r=m("div"),o=m("label"),o.textContent="Search Text (NIP-50)",l=w(),a=m("div"),c=m("input"),u=w(),d=m("label"),d.textContent="Event Kinds",g=w(),v=m("div"),b=m("button"),k=y(Ue),S=y(" Select Kinds ("),B=y(Oe),$=y(" selected)"),D=w(),je&&je.c(),Q=w(),ze&&ze.c(),P=w(),R=m("label"),R.textContent="Authors (Pubkeys)",T=w(),L=m("div"),_=m("div"),N=m("input"),M=w(),U=m("button"),U.textContent="Add",O=w(),He&&He.c(),j=w(),qe&&qe.c(),z=w(),H=m("label"),H.textContent="Event IDs",q=w(),G=m("div"),J=m("div"),K=m("input"),V=w(),W=m("button"),W.textContent="Add",Y=w(),Ge&&Ge.c(),Z=w(),Je&&Je.c(),X=w(),ee=m("label"),ee.textContent="Tags (#e, #p, #a)",te=w(),ne=m("div"),ie=m("div"),se=m("span"),se.textContent="#",re=w(),oe=m("input"),le=w(),ae=m("input"),ce=w(),ue=m("button"),ue.textContent="Add",de=w(),Ke&&Ke.c(),fe=w(),Ve&&Ve.c(),he=w(),pe=m("label"),pe.textContent="Since",ge=w(),me=m("div"),ve=m("input"),ye=w(),We&&We.c(),we=w(),be=m("label"),be.textContent="Until",Ae=w(),ke=m("div"),Ie=m("input"),Ce=w(),Ye&&Ye.c(),Ee=w(),xe=m("label"),xe.textContent="Limit",Se=w(),Be=m("div"),$e=m("input"),Fe=w(),Ze&&Ze.c(),De=w(),Qe=m("div"),Pe=m("button"),Pe.textContent="🧹",Re=w(),Te=m("div"),Le=w(),_e=m("button"),_e.textContent="</>",I(o,"for","search-text"),I(o,"class","svelte-1a1v6k0"),I(c,"id","search-text"),I(c,"type","text"),I(c,"placeholder","Search events..."),I(c,"class","filter-input svelte-1a1v6k0"),I(a,"class","field-content svelte-1a1v6k0"),I(d,"class","svelte-1a1v6k0"),I(b,"class","picker-toggle-btn svelte-1a1v6k0"),I(v,"class","field-content svelte-1a1v6k0"),I(R,"class","svelte-1a1v6k0"),I(N,"type","text"),I(N,"placeholder","64 character hex pubkey..."),I(N,"class","filter-input svelte-1a1v6k0"),I(N,"maxlength","64"),I(U,"class","add-btn svelte-1a1v6k0"),I(_,"class","input-group svelte-1a1v6k0"),I(L,"class","field-content svelte-1a1v6k0"),I(H,"class","svelte-1a1v6k0"),I(K,"type","text"),I(K,"placeholder","64 character hex event ID..."),I(K,"class","filter-input svelte-1a1v6k0"),I(K,"maxlength","64"),I(W,"class","add-btn svelte-1a1v6k0"),I(J,"class","input-group svelte-1a1v6k0"),I(G,"class","field-content svelte-1a1v6k0"),I(ee,"class","svelte-1a1v6k0"),I(se,"class","hash-prefix svelte-1a1v6k0"),I(oe,"type","text"),I(oe,"placeholder","Tag"),I(oe,"class","filter-input tag-name-input svelte-1a1v6k0"),I(oe,"maxlength","1"),I(ae,"type","text"),I(ae,"placeholder","Value..."),I(ae,"class","filter-input tag-value-input svelte-1a1v6k0"),I(ue,"class","add-btn svelte-1a1v6k0"),I(ie,"class","tag-input-group svelte-1a1v6k0"),I(ne,"class","field-content svelte-1a1v6k0"),I(pe,"for","since-timestamp"),I(pe,"class","svelte-1a1v6k0"),I(ve,"id","since-timestamp"),I(ve,"type","datetime-local"),ve.value=t[32](),I(ve,"class","filter-input svelte-1a1v6k0"),I(me,"class","field-content timestamp-field svelte-1a1v6k0"),I(be,"for","until-timestamp"),I(be,"class","svelte-1a1v6k0"),I(Ie,"id","until-timestamp"),I(Ie,"type","datetime-local"),Ie.value=t[33](),I(Ie,"class","filter-input svelte-1a1v6k0"),I(ke,"class","field-content timestamp-field svelte-1a1v6k0"),I(xe,"for","limit"),I(xe,"class","svelte-1a1v6k0"),I($e,"id","limit"),I($e,"type","number"),I($e,"placeholder","Max events to return"),I($e,"class","filter-input svelte-1a1v6k0"),I($e,"min","1"),I(Be,"class","field-content svelte-1a1v6k0"),I(r,"class","filter-grid svelte-1a1v6k0"),I(s,"class","filter-content svelte-1a1v6k0"),I(Pe,"class","clear-all-btn svelte-1a1v6k0"),I(Pe,"title","Clear all filters"),I(Te,"class","spacer svelte-1a1v6k0"),I(_e,"class","json-toggle-btn svelte-1a1v6k0"),I(_e,"title","Edit filter JSON"),F(_e,"active",t[8]),I(Qe,"class","clear-column svelte-1a1v6k0"),I(n,"class","filter-builder svelte-1a1v6k0")},m(e,i){h(e,n,i),f(n,s),f(s,r),f(r,o),f(r,l),f(r,a),f(a,c),x(c,t[0]),f(r,u),f(r,d),f(r,g),f(r,v),f(v,b),f(b,k),f(b,S),f(b,B),f(b,$),f(v,D),je&&je.m(v,null),f(v,Q),ze&&ze.m(v,null),f(r,P),f(r,R),f(r,T),f(r,L),f(L,_),f(_,N),x(N,t[13]),f(_,M),f(_,U),f(L,O),He&&He.m(L,null),f(L,j),qe&&qe.m(L,null),f(r,z),f(r,H),f(r,q),f(r,G),f(G,J),f(J,K),x(K,t[14]),f(J,V),f(J,W),f(G,Y),Ge&&Ge.m(G,null),f(G,Z),Je&&Je.m(G,null),f(r,X),f(r,ee),f(r,te),f(r,ne),f(ne,ie),f(ie,se),f(ie,re),f(ie,oe),x(oe,t[15]),f(ie,le),f(ie,ae),x(ae,t[16]),f(ie,ce),f(ie,ue),f(ne,de),Ke&&Ke.m(ne,null),f(ne,fe),Ve&&Ve.m(ne,null),f(r,he),f(r,pe),f(r,ge),f(r,me),f(me,ve),f(me,ye),We&&We.m(me,null),f(r,we),f(r,be),f(r,Ae),f(r,ke),f(ke,Ie),f(ke,Ce),Ye&&Ye.m(ke,null),f(r,Ee),f(r,xe),f(r,Se),f(r,Be),f(Be,$e),x($e,t[7]),f(r,Fe),Ze&&Ze.m(r,null),f(n,De),f(n,Qe),f(Qe,Pe),f(Qe,Re),f(Qe,Te),f(Qe,Le),f(Qe,_e),Ne||(Me=[A(c,"input",t[38]),A(b,"click",t[39]),A(N,"input",t[43]),A(N,"keydown",t[44]),A(U,"click",t[25]),A(K,"input",t[46]),A(K,"keydown",t[47]),A(W,"click",t[27]),A(oe,"input",t[49]),A(ae,"input",t[50]),A(ae,"keydown",t[51]),A(ue,"click",t[29]),A(ve,"change",t[34]),A(Ie,"change",t[35]),A($e,"input",t[55]),A(Pe,"click",t[31]),A(_e,"click",t[57])],Ne=!0)},p(e,t){1&t[0]&&c.value!==e[0]&&x(c,e[0]),4096&t[0]&&Ue!==(Ue=e[12]?"▼":"▶")&&E(k,Ue),2&t[0]&&Oe!==(Oe=e[1].length+"")&&E(B,Oe),e[12]?je?je.p(e,t):(je=iA(e),je.c(),je.m(v,Q)):je&&(je.d(1),je=null),e[1].length>0?ze?ze.p(e,t):(ze=rA(e),ze.c(),ze.m(v,null)):ze&&(ze.d(1),ze=null),8192&t[0]&&N.value!==e[13]&&x(N,e[13]),e[17]?He?He.p(e,t):(He=lA(e),He.c(),He.m(L,j)):He&&(He.d(1),He=null),e[2].length>0?qe?qe.p(e,t):(qe=aA(e),qe.c(),qe.m(L,null)):qe&&(qe.d(1),qe=null),16384&t[0]&&K.value!==e[14]&&x(K,e[14]),e[18]?Ge?Ge.p(e,t):(Ge=uA(e),Ge.c(),Ge.m(G,Z)):Ge&&(Ge.d(1),Ge=null),e[3].length>0?Je?Je.p(e,t):(Je=dA(e),Je.c(),Je.m(G,null)):Je&&(Je.d(1),Je=null),32768&t[0]&&oe.value!==e[15]&&x(oe,e[15]),65536&t[0]&&ae.value!==e[16]&&x(ae,e[16]),e[19]?Ke?Ke.p(e,t):(Ke=hA(e),Ke.c(),Ke.m(ne,fe)):Ke&&(Ke.d(1),Ke=null),e[4].length>0?Ve?Ve.p(e,t):(Ve=pA(e),Ve.c(),Ve.m(ne,null)):Ve&&(Ve.d(1),Ve=null),e[5]?We?We.p(e,t):(We=mA(e),We.c(),We.m(me,null)):We&&(We.d(1),We=null),e[6]?Ye?Ye.p(e,t):(Ye=vA(e),Ye.c(),Ye.m(ke,null)):Ye&&(Ye.d(1),Ye=null),128&t[0]&&C($e.value)!==e[7]&&x($e,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=yA(e),Ze.c(),Ze.m(r,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&F(_e,"active",e[8])},i:e,o:e,d(e){e&&p(n),je&&je.d(),ze&&ze.d(),He&&He.d(),qe&&qe.d(),Ge&&Ge.d(),Je&&Je.d(),Ke&&Ke.d(),Ve&&Ve.d(),We&&We.d(),Ye&&Ye.d(),Ze&&Ze.d(),Ne=!1,i(Me)}}}function AA(e,t,n){let i,s;const r=L();let{searchText:o=""}=t,{selectedKinds:l=[]}=t,{pubkeys:a=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:h=null}=t,{showJsonEditor:p=!1}=t,g="",m="",v=!1,y="",w="",b="",A="",k="",I="",E="",x="",S=null,B=!1;function $(e){l.includes(e)?n(1,l=l.filter(t=>t!==e)):n(1,l=[...l,e].sort((e,t)=>e-t))}function F(e){n(1,l=l.filter(t=>t!==e))}function D(){const e=w.trim();e&&(Vb(e,64)?a.includes(e)?n(17,I="Pubkey already added"):(n(2,a=[...a,e]),n(13,w=""),n(17,I="")):n(17,I="Invalid pubkey: must be 64 character hex string"))}function Q(e){n(2,a=a.filter(t=>t!==e))}function P(){const e=b.trim();e&&(Vb(e,64)?c.includes(e)?n(18,E="Event ID already added"):(n(3,c=[...c,e]),n(14,b=""),n(18,E="")):n(18,E="Invalid event ID: must be 64 character hex string"))}function R(e){n(3,c=c.filter(t=>t!==e))}function _(){const e=A.trim(),t=k.trim();e&&t&&(/^[a-zA-Z]$/.test(e)?u.some(n=>n.name===e&&n.value===t)?n(19,x="Tag already added"):(n(4,u=[...u,{name:e,value:t}]),n(15,A=""),n(16,k=""),n(19,x="")):n(19,x="Invalid tag name: must be single letter a-z or A-Z"))}function N(e){n(4,u=u.filter((t,n)=>n!==e))}function M(){r("apply",{searchText:o,selectedKinds:l,pubkeys:a,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:h})}T(()=>{S&&clearTimeout(S)});return e.$$set=e=>{"searchText"in e&&n(0,o=e.searchText),"selectedKinds"in e&&n(1,l=e.selectedKinds),"pubkeys"in e&&n(2,a=e.pubkeys),"eventIds"in e&&n(3,c=e.eventIds),"tags"in e&&n(4,u=e.tags),"sinceTimestamp"in e&&n(5,d=e.sinceTimestamp),"untilTimestamp"in e&&n(6,f=e.untilTimestamp),"limit"in e&&n(7,h=e.limit),"showJsonEditor"in e&&n(8,p=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&p){const e=function(){const e={};return l.length>0&&(e.kinds=l),a.length>0&&(e.authors=a),c.length>0&&(e.ids=c),d&&(e.since=d),f&&(e.until=f),h&&(e.limit=h),o&&(e.search=o),u.forEach(t=>{const n=`#${t.name}`;e[n]||(e[n]=[]),e[n].push(t.value)}),e}();n(10,g=JSON.stringify(e,null,2))}255&e.$$.dirty[0]|32&e.$$.dirty[1]&&(B?(S&&clearTimeout(S),S=setTimeout(()=>{M()},1e3)):n(36,B=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,s=i.filter(e=>e.kind.toString().includes(y)||e.name.toLowerCase().includes(y.toLowerCase())))},n(37,i=Object.entries(Kb).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[o,l,a,c,u,d,f,h,p,y,g,m,v,w,b,A,k,I,E,x,s,r,function(){try{const e=JSON.parse(g);n(11,m=""),n(1,l=e.kinds||[]),n(2,a=e.authors||[]),n(3,c=e.ids||[]),n(5,d=e.since||null),n(6,f=e.until||null),n(7,h=e.limit||null),n(0,o=e.search||""),n(4,u=[]),Object.keys(e).forEach(t=>{if(t.startsWith("#")&&2===t.length){const n=t.slice(1);(Array.isArray(e[t])?e[t]:[e[t]]).forEach(e=>{u.push({name:n,value:String(e)})})}}),n(4,u),S&&clearTimeout(S),M()}catch(e){n(11,m="Invalid JSON: "+e.message)}},$,F,D,Q,P,R,_,N,function(){n(0,o=""),n(1,l=[]),n(2,a=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,h=null),r("clear")},function(){return d?Wb(d):""},function(){return f?Wb(f):""},function(e){const t=e.target.value;n(5,d=t?Yb(t):null)},function(e){const t=e.target.value;n(6,f=t?Yb(t):null)},B,i,function(){o=this.value,n(0,o)},()=>n(12,v=!v),function(){y=this.value,n(9,y)},e=>$(e),e=>F(e),function(){w=this.value,n(13,w)},e=>"Enter"===e.key&&D(),e=>Q(e),function(){b=this.value,n(14,b)},e=>"Enter"===e.key&&P(),e=>R(e),function(){A=this.value,n(15,A)},function(){k=this.value,n(16,k)},e=>"Enter"===e.key&&_(),e=>N(e),()=>n(5,d=null),()=>n(6,f=null),function(){h=C(this.value),n(7,h)},function(){g=this.value,n(10,g),n(8,p)},()=>r("toggleJson")]}class kA extends fe{constructor(e){super(),de(this,e,AA,bA,r,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function IA(e,t,n){const i=e.slice();return i[28]=t[n],i}function CA(e,t,n){const i=e.slice();return i[31]=t[n],i}function EA(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No events found.</p>",I(n,"class","no-events svelte-1xhi5rf")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function xA(e){let t,n=e[3],i=[];for(let t=0;t<n.length;t+=1)i[t]=PA(IA(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(3614&s[0]){let r;for(n=e[3],r=0;r<n.length;r+=1){const o=IA(e,n,r);i[r]?i[r].p(o,s):(i[r]=PA(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function SA(e){let t,n,i=OA(e[28].content)+"";return{c(){t=m("div"),n=y(i),I(t,"class","event-content-single-line svelte-1xhi5rf")},m(e,i){h(e,t,i),f(t,n)},p(e,t){8&t[0]&&i!==(i=OA(e[28].content)+"")&&E(n,i)},d(e){e&&p(t)}}}function BA(e){let t,n,i,s=e[28].tags&&e[28].tags.length>0&&$A(e);return{c(){t=m("div"),n=m("span"),n.textContent="🗑️ Delete Event",i=w(),s&&s.c(),I(n,"class","delete-event-label svelte-1xhi5rf"),I(t,"class","delete-event-info svelte-1xhi5rf")},m(e,r){h(e,t,r),f(t,n),f(t,i),s&&s.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?s?s.p(e,n):(s=$A(e),s.c(),s.m(t,null)):s&&(s.d(1),s=null)},d(e){e&&p(t),s&&s.d()}}}function $A(e){let t,n=e[28].tags.filter(jA),i=[];for(let t=0;t<n.length;t+=1)i[t]=FA(CA(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","delete-targets svelte-1xhi5rf")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(8&s[0]){let r;for(n=e[28].tags.filter(jA),r=0;r<n.length;r+=1){const o=CA(e,n,r);i[r]?i[r].p(o,s):(i[r]=FA(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function FA(e){let t,n,i,s,r,o=e[31][1].slice(0,8)+"",l=e[31][1].slice(-8)+"";return{c(){t=m("span"),n=y("Target: "),i=y(o),s=y("..."),r=y(l),I(t,"class","delete-target svelte-1xhi5rf")},m(e,o){h(e,t,o),f(t,n),f(t,i),f(t,s),f(t,r)},p(e,t){8&t[0]&&o!==(o=e[31][1].slice(0,8)+"")&&E(i,o),8&t[0]&&l!==(l=e[31][1].slice(-8)+"")&&E(r,l)},d(e){e&&p(t)}}}function DA(e){let t,n,i;function s(){return e[19](e[28])}return{c(){t=m("button"),t.textContent="🗑️",I(t,"class","delete-btn svelte-1xhi5rf")},m(e,r){h(e,t,r),n||(i=A(t,"click",k(s)),n=!0)},p(t,n){e=t},d(e){e&&p(t),n=!1,i()}}}function QA(e){let t,n,i,s,r,o,l,a,c=JSON.stringify(e[28],null,2)+"";function u(...t){return e[22](e[28],...t)}return{c(){t=m("div"),n=m("div"),i=m("pre"),s=y(c),r=w(),o=m("button"),o.textContent="📋",I(i,"class","event-json svelte-1xhi5rf"),I(o,"class","copy-json-btn svelte-1xhi5rf"),I(o,"title","Copy minified JSON to clipboard"),I(n,"class","json-container svelte-1xhi5rf"),I(t,"class","events-view-details svelte-1xhi5rf")},m(e,c){h(e,t,c),f(t,n),f(n,i),f(i,s),f(n,r),f(n,o),l||(a=A(o,"click",k(u)),l=!0)},p(t,n){e=t,8&n[0]&&c!==(c=JSON.stringify(e[28],null,2)+"")&&E(s,c)},d(e){e&&p(t),l=!1,a()}}}function PA(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,D,Q,P,R,T,L=NA(e[28].pubkey)+"",_=e[28].kind+"",N=MA(e[28].kind)+"",M=UA(e[28].created_at)+"",U=e[4].has(e[28].id);function O(e,t){return 5===e[28].kind?BA:SA}let j=O(e),z=j(e),H=5!==e[28].kind&&("admin"===e[1]||"owner"===e[1]||"write"===e[1]&&e[28].pubkey&&e[28].pubkey===e[2])&&DA(e);function q(){return e[20](e[28])}function G(...t){return e[21](e[28],...t)}let J=U&&QA(e);return{c(){t=m("div"),n=m("div"),s=m("div"),s.innerHTML='<div class="avatar-placeholder svelte-1xhi5rf">👤</div>',r=w(),o=m("div"),l=m("div"),a=y(L),c=w(),u=m("div"),d=m("span"),g=y(_),v=w(),b=m("span"),k=y(N),C=w(),x=m("div"),S=m("div"),B=y(M),$=w(),z.c(),D=w(),H&&H.c(),Q=w(),J&&J.c(),P=w(),I(s,"class","events-view-avatar svelte-1xhi5rf"),I(l,"class","events-view-author svelte-1xhi5rf"),I(d,"class","kind-number svelte-1xhi5rf"),F(d,"delete-event",5===e[28].kind),I(b,"class","kind-name svelte-1xhi5rf"),I(u,"class","events-view-kind svelte-1xhi5rf"),I(o,"class","events-view-info svelte-1xhi5rf"),I(S,"class","event-timestamp svelte-1xhi5rf"),I(x,"class","events-view-content svelte-1xhi5rf"),I(n,"class","events-view-row svelte-1xhi5rf"),I(n,"role","button"),I(n,"tabindex","0"),I(t,"class","events-view-item svelte-1xhi5rf"),F(t,"expanded",e[4].has(e[28].id))},m(e,i){h(e,t,i),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(d,g),f(u,v),f(u,b),f(b,k),f(n,C),f(n,x),f(x,S),f(S,B),f(x,$),z.m(x,null),f(n,D),H&&H.m(n,null),f(t,Q),J&&J.m(t,null),f(t,P),R||(T=[A(n,"click",q),A(n,"keydown",G)],R=!0)},p(i,s){e=i,8&s[0]&&L!==(L=NA(e[28].pubkey)+"")&&E(a,L),8&s[0]&&_!==(_=e[28].kind+"")&&E(g,_),8&s[0]&&F(d,"delete-event",5===e[28].kind),8&s[0]&&N!==(N=MA(e[28].kind)+"")&&E(k,N),8&s[0]&&M!==(M=UA(e[28].created_at)+"")&&E(B,M),j===(j=O(e))&&z?z.p(e,s):(z.d(1),z=j(e),z&&(z.c(),z.m(x,null))),5!==e[28].kind&&("admin"===e[1]||"owner"===e[1]||"write"===e[1]&&e[28].pubkey&&e[28].pubkey===e[2])?H?H.p(e,s):(H=DA(e),H.c(),H.m(n,null)):H&&(H.d(1),H=null),24&s[0]&&(U=e[4].has(e[28].id)),U?J?J.p(e,s):(J=QA(e),J.c(),J.m(t,P)):J&&(J.d(1),J=null),24&s[0]&&F(t,"expanded",e[4].has(e[28].id))},d(e){e&&p(t),z.d(),H&&H.d(),J&&J.d(),R=!1,i(T)}}}function RA(e){let t;return{c(){t=m("div"),t.innerHTML='<div class="spinner svelte-1xhi5rf"></div> \n                    <p>Loading events...</p>',I(t,"class","loading-events svelte-1xhi5rf")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function TA(e){let t;return{c(){t=y("🔄")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function LA(e){let t;return{c(){t=m("div"),I(t,"class","spinner svelte-1xhi5rf")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function _A(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,E,x,S,B,$,D,Q,P,R,T,L,_,N;function M(e,t){return e[3].length>0?xA:e[5]?void 0:EA}let U=M(e),O=U&&U(e),j=e[5]&&RA();function z(e,t){return e[5]?LA:TA}a=new kA({props:{showJsonEditor:e[7]}}),a.$on("apply",e[16]),a.$on("clear",e[17]),a.$on("toggleJson",e[15]);let H=z(e),q=H(e);return{c(){t=m("div"),n=m("div"),O&&O.c(),s=w(),j&&j.c(),r=w(),o=m("div"),l=m("div"),ae(a.$$.fragment),c=w(),u=m("div"),d=m("div"),g=m("button"),g.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-1xhi5rf"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon></svg>',v=w(),b=m("div"),k=m("label"),C=m("input"),E=w(),x=m("span"),S=w(),B=m("span"),B.textContent="Only show my events",$=w(),D=m("div"),Q=m("button"),P=y("🔄 Load More"),R=w(),T=m("button"),q.c(),I(n,"class","events-view-content svelte-1xhi5rf"),I(l,"class","filter-panel svelte-1xhi5rf"),F(l,"open",e[6]),I(g,"class","filter-btn svelte-1xhi5rf"),I(g,"title","Filter events"),F(g,"active",e[6]),I(C,"type","checkbox"),I(C,"class","svelte-1xhi5rf"),I(x,"class","toggle-slider svelte-1xhi5rf"),I(B,"class","toggle-label svelte-1xhi5rf"),I(k,"class","toggle-container svelte-1xhi5rf"),I(b,"class","events-view-toggle svelte-1xhi5rf"),I(d,"class","events-view-left svelte-1xhi5rf"),I(Q,"class","refresh-btn svelte-1xhi5rf"),Q.disabled=e[5],I(T,"class","reload-btn svelte-1xhi5rf"),T.disabled=e[5],I(D,"class","events-view-buttons svelte-1xhi5rf"),I(u,"class","events-view-header svelte-1xhi5rf"),I(o,"class","events-view-footer svelte-1xhi5rf"),I(t,"class","events-view-container svelte-1xhi5rf")},m(i,p){h(i,t,p),f(t,n),O&&O.m(n,null),f(n,s),j&&j.m(n,null),f(t,r),f(t,o),f(o,l),ce(a,l,null),f(o,c),f(o,u),f(u,d),f(d,g),f(d,v),f(d,b),f(b,k),f(k,C),C.checked=e[0],f(k,E),f(k,x),f(k,S),f(k,B),f(u,$),f(u,D),f(D,Q),f(Q,P),f(D,R),f(D,T),q.m(T,null),L=!0,_||(N=[A(n,"scroll",e[8]),A(g,"click",e[14]),A(C,"change",e[23]),A(C,"change",e[24]),A(Q,"click",e[25]),A(T,"click",e[26])],_=!0)},p(e,t){U===(U=M(e))&&O?O.p(e,t):(O&&O.d(1),O=U&&U(e),O&&(O.c(),O.m(n,s))),e[5]?j||(j=RA(),j.c(),j.m(n,null)):j&&(j.d(1),j=null);const i={};128&t[0]&&(i.showJsonEditor=e[7]),a.$set(i),(!L||64&t[0])&&F(l,"open",e[6]),(!L||64&t[0])&&F(g,"active",e[6]),1&t[0]&&(C.checked=e[0]),(!L||32&t[0])&&(Q.disabled=e[5]),H!==(H=z(e))&&(q.d(1),q=H(e),q&&(q.c(),q.m(T,null))),(!L||32&t[0])&&(T.disabled=e[5])},i(e){L||(ne(a.$$.fragment,e),L=!0)},o(e){ie(a.$$.fragment,e),L=!1},d(e){e&&p(t),O&&O.d(),j&&j.d(),ue(a),q.d(),_=!1,i(N)}}}function NA(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function MA(e){return{0:"Profile",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1984:"Reporting",9734:"Zap Request",9735:"Zap",1e4:"Mute List",10001:"Pin List",10002:"Relay List",22242:"Client Auth",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People",30001:"Categorized Bookmarks",30008:"Profile Badges",30009:"Badge Definition",30017:"Create or update a stall",30018:"Create or update a product",30023:"Long-form Content",30024:"Draft Long-form Content",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34550:"Community Definition"}[e]||`Kind ${e}`}function UA(e){return new Date(1e3*e).toLocaleString()}function OA(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const jA=e=>"e"===e[0];function zA(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:s=""}=t,{userPubkey:r=""}=t,{filteredEvents:o=[]}=t,{expandedEvents:l=new Set}=t,{isLoadingEvents:a=!1}=t,{showOnlyMyEvents:c=!1}=t,{showFilterBuilder:u=!1}=t;const d=L();let f=!1;function h(e){d("toggleEventExpansion",e)}function p(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function v(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(18,i=e.isLoggedIn),"userRole"in e&&n(1,s=e.userRole),"userPubkey"in e&&n(2,r=e.userPubkey),"filteredEvents"in e&&n(3,o=e.filteredEvents),"expandedEvents"in e&&n(4,l=e.expandedEvents),"isLoadingEvents"in e&&n(5,a=e.isLoadingEvents),"showOnlyMyEvents"in e&&n(0,c=e.showOnlyMyEvents),"showFilterBuilder"in e&&n(6,u=e.showFilterBuilder)},[c,s,r,o,l,a,u,f,function(e){d("scroll",e)},h,p,g,m,v,function(){d("toggleFilterBuilder")},function(){n(7,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},i,e=>p(e.id),e=>h(e.id),(e,t)=>"Enter"===t.key&&h(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{v(!1,c&&r?[r]:null)},()=>{v(!0,c&&r?[r]:null)}]}class HA extends fe{constructor(e){super(),de(this,e,zA,_A,r,{isLoggedIn:18,userRole:1,userPubkey:2,filteredEvents:3,expandedEvents:4,isLoadingEvents:5,showOnlyMyEvents:0,showFilterBuilder:6},null,[-1,-1])}}const qA=[{kind:0,name:"Metadata",description:"User profile information (name, about, picture, nip05, etc.)",nip:"01",isReplaceable:!0,template:{kind:0,content:"",tags:[]}},{kind:1,name:"Short Text Note",description:"Short-form text post (like a tweet)",nip:"01",template:{kind:1,content:"",tags:[]}},{kind:2,name:"Recommend Relay",description:"Relay recommendation",nip:"01",deprecated:!0,template:{kind:2,content:"",tags:[]}},{kind:3,name:"Follows",description:"Following list with optional relay hints",nip:"02",isReplaceable:!0,template:{kind:3,content:"",tags:[]}},{kind:4,name:"Encrypted Direct Message",description:"Private message using NIP-04 encryption",nip:"04",deprecated:!0,template:{kind:4,content:"",tags:[]}},{kind:5,name:"Event Deletion Request",description:"Request to delete events",nip:"09",template:{kind:5,content:"",tags:[]}},{kind:6,name:"Repost",description:"Share/repost another text note",nip:"18",template:{kind:6,content:"",tags:[]}},{kind:7,name:"Reaction",description:"Like, emoji reaction to an event",nip:"25",template:{kind:7,content:"",tags:[]}},{kind:8,name:"Badge Award",description:"Award a badge to someone",nip:"58",template:{kind:8,content:"",tags:[]}},{kind:9,name:"Chat Message",description:"Chat message",nip:"C7",template:{kind:9,content:"",tags:[]}},{kind:10,name:"Group Chat Threaded Reply",description:"Threaded reply in group chat",nip:"29",deprecated:!0,template:{kind:10,content:"",tags:[]}},{kind:11,name:"Thread",description:"Thread event",nip:"7D",template:{kind:11,content:"",tags:[]}},{kind:12,name:"Group Thread Reply",description:"Reply in group thread",nip:"29",deprecated:!0,template:{kind:12,content:"",tags:[]}},{kind:13,name:"Seal",description:"Sealed/encrypted event wrapper",nip:"59",template:{kind:13,content:"",tags:[]}},{kind:14,name:"Direct Message",description:"Private direct message using NIP-17",nip:"17",template:{kind:14,content:"",tags:[]}},{kind:15,name:"File Message",description:"File message in DMs",nip:"17",template:{kind:15,content:"",tags:[]}},{kind:16,name:"Generic Repost",description:"Repost any event kind",nip:"18",template:{kind:16,content:"",tags:[]}},{kind:17,name:"Reaction to Website",description:"Reaction to a website URL",nip:"25",template:{kind:17,content:"",tags:[]}},{kind:20,name:"Picture",description:"Picture-first feed post",nip:"68",template:{kind:20,content:"",tags:[]}},{kind:21,name:"Video Event",description:"Horizontal video event",nip:"71",template:{kind:21,content:"",tags:[]}},{kind:22,name:"Short-form Video",description:"Short-form portrait video (like TikTok)",nip:"71",template:{kind:22,content:"",tags:[]}},{kind:40,name:"Channel Creation",description:"Create a public chat channel",nip:"28",template:{kind:40,content:"",tags:[]}},{kind:41,name:"Channel Metadata",description:"Set channel name, about, picture",nip:"28",template:{kind:41,content:"",tags:[]}},{kind:42,name:"Channel Message",description:"Post message in channel",nip:"28",template:{kind:42,content:"",tags:[]}},{kind:43,name:"Channel Hide Message",description:"Hide a message in channel",nip:"28",template:{kind:43,content:"",tags:[]}},{kind:44,name:"Channel Mute User",description:"Mute a user in channel",nip:"28",template:{kind:44,content:"",tags:[]}},{kind:62,name:"Request to Vanish",description:"Request permanent deletion of all user data",nip:"62",template:{kind:62,content:"",tags:[]}},{kind:64,name:"Chess (PGN)",description:"Chess game in PGN format",nip:"64",template:{kind:64,content:"",tags:[]}},{kind:443,name:"KeyPackage",description:"Marmot protocol key package",nip:null,spec:"Marmot",template:{kind:443,content:"",tags:[]}},{kind:444,name:"Welcome Message",description:"Marmot protocol welcome message",nip:null,spec:"Marmot",template:{kind:444,content:"",tags:[]}},{kind:445,name:"Group Event",description:"Marmot protocol group event",nip:null,spec:"Marmot",template:{kind:445,content:"",tags:[]}},{kind:818,name:"Merge Requests",description:"Git merge request",nip:"54",template:{kind:818,content:"",tags:[]}},{kind:1018,name:"Poll Response",description:"Response to a poll",nip:"88",template:{kind:1018,content:"",tags:[]}},{kind:1021,name:"Bid",description:"Auction bid",nip:"15",template:{kind:1021,content:"",tags:[]}},{kind:1022,name:"Bid Confirmation",description:"Confirmation of auction bid",nip:"15",template:{kind:1022,content:"",tags:[]}},{kind:1040,name:"OpenTimestamps",description:"OpenTimestamps attestation",nip:"03",template:{kind:1040,content:"",tags:[]}},{kind:1059,name:"Gift Wrap",description:"Encrypted gift-wrapped event",nip:"59",template:{kind:1059,content:"",tags:[]}},{kind:1060,name:"Gift Wrap (Kind 4)",description:"Gift wrap variant for NIP-04 compatibility",nip:"59",template:{kind:1060,content:"",tags:[]}},{kind:1063,name:"File Metadata",description:"Metadata for shared files",nip:"94",template:{kind:1063,content:"",tags:[]}},{kind:1068,name:"Poll",description:"Create a poll",nip:"88",template:{kind:1068,content:"",tags:[]}},{kind:1111,name:"Comment",description:"Comment on events or external content",nip:"22",template:{kind:1111,content:"",tags:[]}},{kind:1222,name:"Voice Message",description:"Voice message",nip:"A0",template:{kind:1222,content:"",tags:[]}},{kind:1244,name:"Voice Message Comment",description:"Comment on voice message",nip:"A0",template:{kind:1244,content:"",tags:[]}},{kind:1311,name:"Live Chat Message",description:"Message in live stream chat",nip:"53",template:{kind:1311,content:"",tags:[]}},{kind:1337,name:"Code Snippet",description:"Code snippet post",nip:"C0",template:{kind:1337,content:"",tags:[]}},{kind:1517,name:"Bitcoin Block",description:"Bitcoin block data",nip:null,spec:"Nostrocket",template:{kind:1517,content:"",tags:[]}},{kind:1617,name:"Patches",description:"Git patches",nip:"34",template:{kind:1617,content:"",tags:[]}},{kind:1618,name:"Pull Requests",description:"Git pull request",nip:"34",template:{kind:1618,content:"",tags:[]}},{kind:1619,name:"Pull Request Updates",description:"Updates to git pull request",nip:"34",template:{kind:1619,content:"",tags:[]}},{kind:1621,name:"Issues",description:"Git issues",nip:"34",template:{kind:1621,content:"",tags:[]}},{kind:1622,name:"Git Replies",description:"Replies on git objects",nip:"34",deprecated:!0,template:{kind:1622,content:"",tags:[]}},{kind:1630,name:"Status",description:"Git status",nip:"34",template:{kind:1630,content:"",tags:[]}},{kind:1631,name:"Status",description:"Git status",nip:"34",template:{kind:1631,content:"",tags:[]}},{kind:1632,name:"Status",description:"Git status",nip:"34",template:{kind:1632,content:"",tags:[]}},{kind:1633,name:"Status",description:"Git status",nip:"34",template:{kind:1633,content:"",tags:[]}},{kind:1808,name:"Live Stream",description:"Live streaming event",nip:null,spec:"zap.stream",template:{kind:1808,content:"",tags:[]}},{kind:1971,name:"Problem Tracker",description:"Problem tracking",nip:null,spec:"Nostrocket",template:{kind:1971,content:"",tags:[]}},{kind:1984,name:"Reporting",description:"Report content or users",nip:"56",template:{kind:1984,content:"",tags:[]}},{kind:1985,name:"Label",description:"Label/tag content with namespace",nip:"32",template:{kind:1985,content:"",tags:[]}},{kind:1986,name:"Relay Reviews",description:"Reviews of relays",nip:null,template:{kind:1986,content:"",tags:[]}},{kind:1987,name:"AI Embeddings",description:"AI embeddings/vector lists",nip:null,spec:"NKBIP-02",template:{kind:1987,content:"",tags:[]}},{kind:2003,name:"Torrent",description:"Torrent magnet link",nip:"35",template:{kind:2003,content:"",tags:[]}},{kind:2004,name:"Torrent Comment",description:"Comment on torrent",nip:"35",template:{kind:2004,content:"",tags:[]}},{kind:2022,name:"Coinjoin Pool",description:"Coinjoin coordination",nip:null,spec:"joinstr",template:{kind:2022,content:"",tags:[]}},{kind:4550,name:"Community Post Approval",description:"Approve post in community",nip:"72",template:{kind:4550,content:"",tags:[]}},{kind:5e3,name:"Job Request",description:"Data vending machine job request (start of range)",nip:"90",template:{kind:5e3,content:"",tags:[]}},{kind:6e3,name:"Job Result",description:"Data vending machine job result (start of range)",nip:"90",template:{kind:6e3,content:"",tags:[]}},{kind:7e3,name:"Job Feedback",description:"Feedback on job request/result",nip:"90",template:{kind:7e3,content:"",tags:[]}},{kind:7374,name:"Reserved Cashu Wallet Tokens",description:"Reserved Cashu wallet tokens",nip:"60",template:{kind:7374,content:"",tags:[]}},{kind:7375,name:"Cashu Wallet Tokens",description:"Cashu wallet tokens",nip:"60",template:{kind:7375,content:"",tags:[]}},{kind:7376,name:"Cashu Wallet History",description:"Cashu wallet transaction history",nip:"60",template:{kind:7376,content:"",tags:[]}},{kind:7516,name:"Geocache Log",description:"Geocaching log entry",nip:null,spec:"geocaching",template:{kind:7516,content:"",tags:[]}},{kind:7517,name:"Geocache Proof of Find",description:"Proof of geocache find",nip:null,spec:"geocaching",template:{kind:7517,content:"",tags:[]}},{kind:8e3,name:"Add User",description:"Add user to group",nip:"43",template:{kind:8e3,content:"",tags:[]}},{kind:8001,name:"Remove User",description:"Remove user from group",nip:"43",template:{kind:8001,content:"",tags:[]}},{kind:9e3,name:"Group Control Events",description:"Group control events (start of range)",nip:"29",template:{kind:9e3,content:"",tags:[]}},{kind:9041,name:"Zap Goal",description:"Fundraising goal for zaps",nip:"75",template:{kind:9041,content:"",tags:[]}},{kind:9321,name:"Nutzap",description:"Cashu nutzap",nip:"61",template:{kind:9321,content:"",tags:[]}},{kind:9467,name:"Tidal Login",description:"Tidal streaming login",nip:null,spec:"Tidal-nostr",template:{kind:9467,content:"",tags:[]}},{kind:9734,name:"Zap Request",description:"Request Lightning payment",nip:"57",template:{kind:9734,content:"",tags:[]}},{kind:9735,name:"Zap",description:"Lightning payment receipt",nip:"57",template:{kind:9735,content:"",tags:[]}},{kind:9802,name:"Highlights",description:"Highlighted text selection",nip:"84",template:{kind:9802,content:"",tags:[]}},{kind:1e4,name:"Mute List",description:"List of muted users/content",nip:"51",isReplaceable:!0,template:{kind:1e4,content:"",tags:[]}},{kind:10001,name:"Pin List",description:"Pinned events",nip:"51",isReplaceable:!0,template:{kind:10001,content:"",tags:[]}},{kind:10002,name:"Relay List Metadata",description:"User's preferred relays for read/write",nip:"65",isReplaceable:!0,template:{kind:10002,content:"",tags:[]}},{kind:10003,name:"Bookmark List",description:"Bookmarked events",nip:"51",isReplaceable:!0,template:{kind:10003,content:"",tags:[]}},{kind:10004,name:"Communities List",description:"Communities user belongs to",nip:"51",isReplaceable:!0,template:{kind:10004,content:"",tags:[]}},{kind:10005,name:"Public Chats List",description:"Public chats user is in",nip:"51",isReplaceable:!0,template:{kind:10005,content:"",tags:[]}},{kind:10006,name:"Blocked Relays List",description:"Relays user has blocked",nip:"51",isReplaceable:!0,template:{kind:10006,content:"",tags:[]}},{kind:10007,name:"Search Relays List",description:"Preferred search relays",nip:"51",isReplaceable:!0,template:{kind:10007,content:"",tags:[]}},{kind:10008,name:"Relay Group Configuration",description:"Relay group configuration",nip:null,isReplaceable:!0,template:{kind:10008,content:"",tags:[]}},{kind:10009,name:"User Groups",description:"Groups user belongs to",nip:"29",isReplaceable:!0,template:{kind:10009,content:"",tags:[]}},{kind:10012,name:"Favorite Relays List",description:"User's favorite relays",nip:"51",isReplaceable:!0,template:{kind:10012,content:"",tags:[]}},{kind:10013,name:"Private Event Relay List",description:"Relays for private events",nip:"37",isReplaceable:!0,template:{kind:10013,content:"",tags:[]}},{kind:10015,name:"Interests List",description:"User interests/topics",nip:"51",isReplaceable:!0,template:{kind:10015,content:"",tags:[]}},{kind:10019,name:"Nutzap Mint Recommendation",description:"Recommended Cashu mints for nutzaps",nip:"61",isReplaceable:!0,template:{kind:10019,content:"",tags:[]}},{kind:10020,name:"Media Follows",description:"Followed media accounts",nip:"51",isReplaceable:!0,template:{kind:10020,content:"",tags:[]}},{kind:10030,name:"User Emoji List",description:"Custom emoji list",nip:"51",isReplaceable:!0,template:{kind:10030,content:"",tags:[]}},{kind:10050,name:"DM Relays List",description:"Relays to receive DMs on",nip:"17",isReplaceable:!0,template:{kind:10050,content:"",tags:[]}},{kind:10051,name:"KeyPackage Relays List",description:"Marmot key package relays",nip:null,isReplaceable:!0,spec:"Marmot",template:{kind:10051,content:"",tags:[]}},{kind:10063,name:"User Server List",description:"Blossom server list",nip:null,isReplaceable:!0,spec:"Blossom",template:{kind:10063,content:"",tags:[]}},{kind:10096,name:"File Storage Server List",description:"File storage servers",nip:"96",isReplaceable:!0,deprecated:!0,template:{kind:10096,content:"",tags:[]}},{kind:10166,name:"Relay Monitor Announcement",description:"Relay monitoring announcement",nip:"66",isReplaceable:!0,template:{kind:10166,content:"",tags:[]}},{kind:10312,name:"Room Presence",description:"Presence in live room",nip:"53",isReplaceable:!0,template:{kind:10312,content:"",tags:[]}},{kind:10377,name:"Proxy Announcement",description:"Nostr proxy announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:10377,content:"",tags:[]}},{kind:11111,name:"Transport Method Announcement",description:"Transport method announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:11111,content:"",tags:[]}},{kind:12345,name:"Relay Policy Configuration",description:"Relay-internal policy configuration (admin only)",nip:null,isReplaceable:!0,spec:"orly",template:{kind:12345,content:"",tags:[]}},{kind:13004,name:"JWT Binding",description:"Link between JWT certificate and pubkey",nip:null,isReplaceable:!0,template:{kind:13004,content:"",tags:[]}},{kind:13194,name:"Wallet Service Info",description:"NWC wallet service information",nip:"47",isReplaceable:!0,template:{kind:13194,content:"",tags:[]}},{kind:13534,name:"Membership Lists",description:"Group membership lists",nip:"43",isReplaceable:!0,template:{kind:13534,content:"",tags:[]}},{kind:14388,name:"User Sound Effect Lists",description:"Sound effect lists",nip:null,isReplaceable:!0,spec:"Corny Chat",template:{kind:14388,content:"",tags:[]}},{kind:17375,name:"Cashu Wallet Event",description:"Cashu wallet event",nip:"60",isReplaceable:!0,template:{kind:17375,content:"",tags:[]}},{kind:21e3,name:"Lightning Pub RPC",description:"Lightning.Pub RPC",nip:null,isEphemeral:!0,spec:"Lightning.Pub",template:{kind:21e3,content:"",tags:[]}},{kind:22242,name:"Client Authentication",description:"Authenticate to relay",nip:"42",isEphemeral:!0,template:{kind:22242,content:"",tags:[]}},{kind:23194,name:"Wallet Request",description:"NWC wallet request",nip:"47",isEphemeral:!0,template:{kind:23194,content:"",tags:[]}},{kind:23195,name:"Wallet Response",description:"NWC wallet response",nip:"47",isEphemeral:!0,template:{kind:23195,content:"",tags:[]}},{kind:23196,name:"Wallet Notification (NIP-04)",description:"NWC wallet notification (NIP-04 encrypted)",nip:"47",isEphemeral:!0,template:{kind:23196,content:"",tags:[]}},{kind:23197,name:"Wallet Notification",description:"NWC wallet notification",nip:"47",isEphemeral:!0,template:{kind:23197,content:"",tags:[]}},{kind:24133,name:"Nostr Connect",description:"Remote signer connection",nip:"46",isEphemeral:!0,template:{kind:24133,content:"",tags:[]}},{kind:24242,name:"Blobs Stored on Mediaservers",description:"Blossom blob storage",nip:null,isEphemeral:!0,spec:"Blossom",template:{kind:24242,content:"",tags:[]}},{kind:27235,name:"HTTP Auth",description:"Authenticate HTTP requests",nip:"98",isEphemeral:!0,template:{kind:27235,content:"",tags:[]}},{kind:28934,name:"Join Request",description:"Request to join group",nip:"43",isEphemeral:!0,template:{kind:28934,content:"",tags:[]}},{kind:28935,name:"Invite Request",description:"Invite to group",nip:"43",isEphemeral:!0,template:{kind:28935,content:"",tags:[]}},{kind:28936,name:"Leave Request",description:"Leave group request",nip:"43",isEphemeral:!0,template:{kind:28936,content:"",tags:[]}},{kind:3e4,name:"Follow Sets",description:"Categorized people lists",nip:"51",isAddressable:!0,template:{kind:3e4,content:"",tags:[["d","identifier"]]}},{kind:30001,name:"Generic Lists",description:"Generic categorized lists",nip:"51",isAddressable:!0,deprecated:!0,template:{kind:30001,content:"",tags:[["d","identifier"]]}},{kind:30002,name:"Relay Sets",description:"Categorized relay lists",nip:"51",isAddressable:!0,template:{kind:30002,content:"",tags:[["d","identifier"]]}},{kind:30003,name:"Bookmark Sets",description:"Categorized bookmark lists",nip:"51",isAddressable:!0,template:{kind:30003,content:"",tags:[["d","identifier"]]}},{kind:30004,name:"Curation Sets",description:"Curated content sets",nip:"51",isAddressable:!0,template:{kind:30004,content:"",tags:[["d","identifier"]]}},{kind:30005,name:"Video Sets",description:"Video playlists",nip:"51",isAddressable:!0,template:{kind:30005,content:"",tags:[["d","identifier"]]}},{kind:30007,name:"Kind Mute Sets",description:"Muted event kinds",nip:"51",isAddressable:!0,template:{kind:30007,content:"",tags:[["d","identifier"]]}},{kind:30008,name:"Profile Badges",description:"Badges displayed on profile",nip:"58",isAddressable:!0,template:{kind:30008,content:"",tags:[["d","identifier"]]}},{kind:30009,name:"Badge Definition",description:"Define a badge/achievement",nip:"58",isAddressable:!0,template:{kind:30009,content:"",tags:[["d","identifier"]]}},{kind:30015,name:"Interest Sets",description:"Interest/topic sets",nip:"51",isAddressable:!0,template:{kind:30015,content:"",tags:[["d","identifier"]]}},{kind:30017,name:"Stall",description:"Marketplace stall definition",nip:"15",isAddressable:!0,template:{kind:30017,content:"",tags:[["d","identifier"]]}},{kind:30018,name:"Product",description:"Marketplace product listing",nip:"15",isAddressable:!0,template:{kind:30018,content:"",tags:[["d","identifier"]]}},{kind:30019,name:"Marketplace UI/UX",description:"Marketplace interface settings",nip:"15",isAddressable:!0,template:{kind:30019,content:"",tags:[["d","identifier"]]}},{kind:30020,name:"Product Sold as Auction",description:"Auction product listing",nip:"15",isAddressable:!0,template:{kind:30020,content:"",tags:[["d","identifier"]]}},{kind:30023,name:"Long-form Content",description:"Blog post, article in markdown",nip:"23",isAddressable:!0,template:{kind:30023,content:"",tags:[["d","identifier"]]}},{kind:30024,name:"Draft Long-form Content",description:"Draft article",nip:"23",isAddressable:!0,template:{kind:30024,content:"",tags:[["d","identifier"]]}},{kind:30030,name:"Emoji Sets",description:"Custom emoji sets",nip:"51",isAddressable:!0,template:{kind:30030,content:"",tags:[["d","identifier"]]}},{kind:30040,name:"Curated Publication Index",description:"Publication index",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30040,content:"",tags:[["d","identifier"]]}},{kind:30041,name:"Curated Publication Content",description:"Publication content",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30041,content:"",tags:[["d","identifier"]]}},{kind:30063,name:"Release Artifact Sets",description:"Software release artifacts",nip:"51",isAddressable:!0,template:{kind:30063,content:"",tags:[["d","identifier"]]}},{kind:30078,name:"Application-specific Data",description:"App-specific key-value storage",nip:"78",isAddressable:!0,template:{kind:30078,content:"",tags:[["d","identifier"]]}},{kind:30166,name:"Relay Discovery",description:"Relay discovery/monitoring",nip:"66",isAddressable:!0,template:{kind:30166,content:"",tags:[["d","identifier"]]}},{kind:30267,name:"App Curation Sets",description:"Curated app sets",nip:"51",isAddressable:!0,template:{kind:30267,content:"",tags:[["d","identifier"]]}},{kind:30311,name:"Live Event",description:"Live streaming event",nip:"53",isAddressable:!0,template:{kind:30311,content:"",tags:[["d","identifier"]]}},{kind:30312,name:"Interactive Room",description:"Interactive live room",nip:"53",isAddressable:!0,template:{kind:30312,content:"",tags:[["d","identifier"]]}},{kind:30313,name:"Conference Event",description:"Conference/meetup event",nip:"53",isAddressable:!0,template:{kind:30313,content:"",tags:[["d","identifier"]]}},{kind:30315,name:"User Statuses",description:"User status updates",nip:"38",isAddressable:!0,template:{kind:30315,content:"",tags:[["d","identifier"]]}},{kind:30388,name:"Slide Set",description:"Presentation slides",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:30388,content:"",tags:[["d","identifier"]]}},{kind:30402,name:"Classified Listing",description:"Classified ad listing",nip:"99",isAddressable:!0,template:{kind:30402,content:"",tags:[["d","identifier"]]}},{kind:30403,name:"Draft Classified Listing",description:"Draft classified ad",nip:"99",isAddressable:!0,template:{kind:30403,content:"",tags:[["d","identifier"]]}},{kind:30617,name:"Repository Announcements",description:"Git repository announcement",nip:"34",isAddressable:!0,template:{kind:30617,content:"",tags:[["d","identifier"]]}},{kind:30618,name:"Repository State Announcements",description:"Git repository state",nip:"34",isAddressable:!0,template:{kind:30618,content:"",tags:[["d","identifier"]]}},{kind:30818,name:"Wiki Article",description:"Wiki article",nip:"54",isAddressable:!0,template:{kind:30818,content:"",tags:[["d","identifier"]]}},{kind:30819,name:"Redirects",description:"URL redirects",nip:"54",isAddressable:!0,template:{kind:30819,content:"",tags:[["d","identifier"]]}},{kind:31234,name:"Draft Event",description:"Draft of any event",nip:"37",isAddressable:!0,template:{kind:31234,content:"",tags:[["d","identifier"]]}},{kind:31388,name:"Link Set",description:"Link collection",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:31388,content:"",tags:[["d","identifier"]]}},{kind:31890,name:"Feed",description:"Custom feed definition",nip:null,isAddressable:!0,spec:"NUD: Custom Feeds",template:{kind:31890,content:"",tags:[["d","identifier"]]}},{kind:31922,name:"Date-Based Calendar Event",description:"All-day calendar event",nip:"52",isAddressable:!0,template:{kind:31922,content:"",tags:[["d","identifier"]]}},{kind:31923,name:"Time-Based Calendar Event",description:"Calendar event with time",nip:"52",isAddressable:!0,template:{kind:31923,content:"",tags:[["d","identifier"]]}},{kind:31924,name:"Calendar",description:"Calendar definition",nip:"52",isAddressable:!0,template:{kind:31924,content:"",tags:[["d","identifier"]]}},{kind:31925,name:"Calendar Event RSVP",description:"RSVP to calendar event",nip:"52",isAddressable:!0,template:{kind:31925,content:"",tags:[["d","identifier"]]}},{kind:31989,name:"Handler Recommendation",description:"Recommended app for event kind",nip:"89",isAddressable:!0,template:{kind:31989,content:"",tags:[["d","identifier"]]}},{kind:31990,name:"Handler Information",description:"App handler declaration",nip:"89",isAddressable:!0,template:{kind:31990,content:"",tags:[["d","identifier"]]}},{kind:32123,name:"WaveLake Track",description:"WaveLake music track",nip:null,isAddressable:!0,spec:"WaveLake",template:{kind:32123,content:"",tags:[["d","identifier"]]}},{kind:32267,name:"Software Application",description:"Software application listing",nip:null,isAddressable:!0,template:{kind:32267,content:"",tags:[["d","identifier"]]}},{kind:32388,name:"User Room Favorites",description:"Favorite rooms",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:32388,content:"",tags:[["d","identifier"]]}},{kind:33388,name:"High Scores",description:"Game high scores",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:33388,content:"",tags:[["d","identifier"]]}},{kind:34235,name:"Video Event Horizontal",description:"Horizontal video event",nip:"71",isAddressable:!0,template:{kind:34235,content:"",tags:[["d","identifier"]]}},{kind:34236,name:"Video Event Vertical",description:"Vertical video event",nip:"71",isAddressable:!0,template:{kind:34236,content:"",tags:[["d","identifier"]]}},{kind:34388,name:"Sound Effects",description:"Sound effect definitions",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:34388,content:"",tags:[["d","identifier"]]}},{kind:34550,name:"Community Definition",description:"Define a community",nip:"72",isAddressable:!0,template:{kind:34550,content:"",tags:[["d","identifier"]]}},{kind:37516,name:"Geocache Listing",description:"Geocache location listing",nip:null,isAddressable:!0,spec:"geocaching",template:{kind:37516,content:"",tags:[["d","identifier"]]}},{kind:38172,name:"Cashu Mint Announcement",description:"Cashu mint announcement",nip:"87",isAddressable:!0,template:{kind:38172,content:"",tags:[["d","identifier"]]}},{kind:38173,name:"Fedimint Announcement",description:"Fedimint announcement",nip:"87",isAddressable:!0,template:{kind:38173,content:"",tags:[["d","identifier"]]}},{kind:38383,name:"Peer-to-peer Order Events",description:"P2P trading orders",nip:"69",isAddressable:!0,template:{kind:38383,content:"",tags:[["d","identifier"]]}},{kind:39e3,name:"Group Metadata Events",description:"Group metadata (start of range)",nip:"29",isAddressable:!0,template:{kind:39e3,content:"",tags:[["d","identifier"]]}},{kind:39089,name:"Starter Packs",description:"Starter pack lists",nip:"51",isAddressable:!0,template:{kind:39089,content:"",tags:[["d","identifier"]]}},{kind:39092,name:"Media Starter Packs",description:"Media starter packs",nip:"51",isAddressable:!0,template:{kind:39092,content:"",tags:[["d","identifier"]]}},{kind:39701,name:"Web Bookmarks",description:"Web URL bookmarks",nip:"B0",isAddressable:!0,template:{kind:39701,content:"",tags:[["d","identifier"]]}},{kind:39998,name:"ACL Event",description:"Access control list event",nip:null,isAddressable:!0,template:{kind:39998,content:"",tags:[["d","identifier"]]}}];function GA(e,t=null){const n=function(e){return qA.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||"<your_pubkey_here>"}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||"<your_pubkey_here>"}}const JA=[{id:"all",name:"All Kinds",filter:()=>!0},{id:"regular",name:"Regular Events (0-9999)",filter:e=>e.kind<1e4&&!e.isReplaceable},{id:"replaceable",name:"Replaceable (10000-19999)",filter:e=>e.isReplaceable},{id:"ephemeral",name:"Ephemeral (20000-29999)",filter:e=>e.isEphemeral},{id:"addressable",name:"Addressable (30000-39999)",filter:e=>e.isAddressable},{id:"social",name:"Social",filter:e=>[0,1,3,6,7].includes(e.kind)},{id:"messaging",name:"Messaging",filter:e=>[4,9,10,11,12,14,15,40,41,42].includes(e.kind)},{id:"lists",name:"Lists",filter:e=>e.name.toLowerCase().includes("list")||e.name.toLowerCase().includes("set")},{id:"marketplace",name:"Marketplace",filter:e=>[30017,30018,30019,30020,1021,1022,30402,30403].includes(e.kind)},{id:"lightning",name:"Lightning/Zaps",filter:e=>[9734,9735,9041,9321,7374,7375,7376].includes(e.kind)},{id:"media",name:"Media",filter:e=>[20,21,22,1063,1222,1244].includes(e.kind)},{id:"git",name:"Git/Code",filter:e=>[818,1337,1617,1618,1619,1621,1622,30617,30618].includes(e.kind)},{id:"calendar",name:"Calendar",filter:e=>[31922,31923,31924,31925].includes(e.kind)},{id:"groups",name:"Groups",filter:e=>e.kind>=9e3&&e.kind<=9030||e.kind>=39e3&&e.kind<=39009}];function KA(e,t,n){const i=e.slice();return i[13]=t[n],i}function VA(e,t,n){const i=e.slice();return i[16]=t[n],i}function WA(e){let t,n,s,r,o,l,a,c,u,d,v,b,k,C,S,B,$,F,D,Q,P,R,T,L,_,N=e[3].length+"",M=1!==e[3].length?"s":"",U=JA,O=[];for(let t=0;t<U.length;t+=1)O[t]=YA(VA(e,U,t));function j(e,t){return 0===e[3].length?XA:ZA}let z=j(e),H=z(e);return{c(){t=m("div"),n=m("div"),s=m("div"),r=m("h2"),r.textContent="Generate Event Template",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("input"),v=w(),b=m("div");for(let e=0;e<O.length;e+=1)O[e].c();k=w(),C=m("div"),S=m("div"),H.c(),B=w(),$=m("div"),F=m("span"),D=y(N),Q=y(" event type"),P=y(M),R=w(),T=m("button"),T.textContent="Cancel",I(r,"class","svelte-1l0q0nc"),I(l,"class","close-btn svelte-1l0q0nc"),I(s,"class","modal-header svelte-1l0q0nc"),I(d,"type","text"),I(d,"placeholder","Search by name, description, or kind number..."),I(d,"class","search-input svelte-1l0q0nc"),I(u,"class","search-box svelte-1l0q0nc"),I(b,"class","category-tabs svelte-1l0q0nc"),I(c,"class","modal-filters svelte-1l0q0nc"),I(S,"class","kinds-list svelte-1l0q0nc"),I(C,"class","modal-body svelte-1l0q0nc"),I(F,"class","result-count svelte-1l0q0nc"),I(T,"class","cancel-btn svelte-1l0q0nc"),I($,"class","modal-footer svelte-1l0q0nc"),I(n,"class","modal-content svelte-1l0q0nc"),I(t,"class","modal-backdrop svelte-1l0q0nc")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(s,r),f(s,o),f(s,l),f(n,a),f(n,c),f(c,u),f(u,d),x(d,e[1]),f(c,v),f(c,b);for(let e=0;e<O.length;e+=1)O[e]&&O[e].m(b,null);f(n,k),f(n,C),f(C,S),H.m(S,null),f(n,B),f(n,$),f($,F),f(F,D),f(F,Q),f(F,P),f($,R),f($,T),L||(_=[A(l,"click",e[5]),A(d,"input",e[9]),A(T,"click",e[5]),A(t,"click",e[7])],L=!0)},p(e,t){if(2&t&&d.value!==e[1]&&x(d,e[1]),4&t){let n;for(U=JA,n=0;n<U.length;n+=1){const i=VA(e,U,n);O[n]?O[n].p(i,t):(O[n]=YA(i),O[n].c(),O[n].m(b,null))}for(;n<O.length;n+=1)O[n].d(1);O.length=U.length}z===(z=j(e))&&H?H.p(e,t):(H.d(1),H=z(e),H&&(H.c(),H.m(S,null))),8&t&&N!==(N=e[3].length+"")&&E(D,N),8&t&&M!==(M=1!==e[3].length?"s":"")&&E(P,M)},d(e){e&&p(t),g(O,e),H.d(),L=!1,i(_)}}}function YA(e){let t,n,i,s,r,o=e[16].name+"";function l(){return e[10](e[16])}return{c(){t=m("button"),n=y(o),i=w(),I(t,"class","category-tab svelte-1l0q0nc"),F(t,"active",e[2]===e[16].id)},m(e,o){h(e,t,o),f(t,n),f(t,i),s||(r=A(t,"click",l),s=!0)},p(n,i){e=n,4&i&&F(t,"active",e[2]===e[16].id)},d(e){e&&p(t),s=!1,r()}}}function ZA(e){let t,n=e[3],i=[];for(let t=0;t<n.length;t+=1)i[t]=tk(KA(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(24&s){let r;for(n=e[3],r=0;r<n.length;r+=1){const o=KA(e,n,r);i[r]?i[r].p(o,s):(i[r]=tk(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function XA(e){let t,n,i,s;return{c(){t=m("div"),n=y('No event kinds found matching "'),i=y(e[1]),s=y('"'),I(t,"class","no-results svelte-1l0q0nc")},m(e,r){h(e,t,r),f(t,n),f(t,i),f(t,s)},p(e,t){2&t&&E(i,e[1])},d(e){e&&p(t)}}}function ek(e){let t,n,i,s=e[13].nip+"";return{c(){t=m("span"),n=y("NIP-"),i=y(s),I(t,"class","nip-badge svelte-1l0q0nc")},m(e,s){h(e,t,s),f(t,n),f(t,i)},p(e,t){8&t&&s!==(s=e[13].nip+"")&&E(i,s)},d(e){e&&p(t)}}}function tk(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$=e[13].kind+"",F=sk(e[13])+"",D=e[13].name+"",Q=e[13].description+"",P=e[13].nip&&"XX"!==e[13].nip&&ek(e);function R(){return e[11](e[13])}return{c(){t=m("button"),n=m("div"),i=m("span"),s=y("Kind "),r=y($),o=w(),l=m("span"),a=y(F),u=w(),P&&P.c(),d=w(),g=m("div"),v=y(D),b=w(),k=m("div"),C=y(Q),x=w(),I(i,"class","kind-number svelte-1l0q0nc"),I(l,"class",c="kind-badge "+ik(e[13])+" svelte-1l0q0nc"),I(n,"class","kind-header svelte-1l0q0nc"),I(g,"class","kind-name svelte-1l0q0nc"),I(k,"class","kind-description svelte-1l0q0nc"),I(t,"class","kind-item svelte-1l0q0nc")},m(e,c){h(e,t,c),f(t,n),f(n,i),f(i,s),f(i,r),f(n,o),f(n,l),f(l,a),f(n,u),P&&P.m(n,null),f(t,d),f(t,g),f(g,v),f(t,b),f(t,k),f(k,C),f(t,x),S||(B=A(t,"click",R),S=!0)},p(t,i){e=t,8&i&&$!==($=e[13].kind+"")&&E(r,$),8&i&&F!==(F=sk(e[13])+"")&&E(a,F),8&i&&c!==(c="kind-badge "+ik(e[13])+" svelte-1l0q0nc")&&I(l,"class",c),e[13].nip&&"XX"!==e[13].nip?P?P.p(e,i):(P=ek(e),P.c(),P.m(n,null)):P&&(P.d(1),P=null),8&i&&D!==(D=e[13].name+"")&&E(v,D),8&i&&Q!==(Q=e[13].description+"")&&E(C,Q)},d(e){e&&p(t),P&&P.d(),S=!1,B()}}}function nk(t){let n,i,s,r=t[0]&&WA(t);return{c(){r&&r.c(),n=b()},m(e,o){r&&r.m(e,o),h(e,n,o),i||(s=A(window,"keydown",t[6]),i=!0)},p(e,[t]){e[0]?r?r.p(e,t):(r=WA(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:e,o:e,d(e){r&&r.d(e),e&&p(n),i=!1,s()}}}function ik(e){return e.isAddressable?"badge-addressable":e.isReplaceable?"badge-replaceable":e.kind>=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function sk(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function rk(e,t,n){let{isOpen:i=!1}=t,{userPubkey:s=""}=t;const r=L();let o="",l="all",a=qA;function c(e){const t=GA(e.kind,s);r("select",{kind:e,template:t}),u()}function u(){n(0,i=!1),n(1,o=""),n(2,l="all"),r("close")}return e.$$set=e=>{"isOpen"in e&&n(0,i=e.isOpen),"userPubkey"in e&&n(8,s=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=qA;const t=JA.find(e=>e.id===l);if(t&&(e=e.filter(t.filter)),o.trim()){const t=o.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.kind.toString().includes(t)||e.nip&&e.nip.includes(t))}n(3,a=e)}},[i,o,l,a,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},s,function(){o=this.value,n(1,o)},e=>n(2,l=e.id),e=>c(e)]}class ok extends fe{constructor(e){super(),de(this,e,rk,nk,r,{isOpen:0,userPubkey:8})}}function lk(e){let t,n,i,s,r,o,l,a,c,u;return{c(){t=m("div"),n=m("div"),i=m("span"),i.textContent="⚠",s=w(),r=m("span"),o=y(e[1]),l=w(),a=m("button"),a.textContent="×",I(i,"class","error-icon svelte-1t01h7c"),I(r,"class","error-message svelte-1t01h7c"),I(n,"class","error-content svelte-1t01h7c"),I(a,"class","error-dismiss svelte-1t01h7c"),I(t,"class","error-banner svelte-1t01h7c")},m(d,p){h(d,t,p),f(t,n),f(n,i),f(n,s),f(n,r),f(r,o),f(t,l),f(t,a),c||(u=A(a,"click",e[11]),c=!0)},p(e,t){2&t&&E(o,e[1])},d(e){e&&p(t),c=!1,u()}}}function ak(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,E,S,B,$,F,D,Q,P,R=e[1]&&lk(e);function T(t){e[16](t)}let L={userPubkey:e[3]};return void 0!==e[4]&&(L.isOpen=e[4]),$=new ok({props:L}),M.push(()=>le($,"isOpen",T)),$.$on("select",e[9]),$.$on("close",e[10]),{c(){t=m("div"),n=m("div"),s=m("button"),s.textContent="Generate Template",r=w(),o=m("button"),o.textContent="Reformat",l=w(),a=m("button"),a.textContent="Sign",c=w(),u=m("label"),d=m("input"),g=y("\n            This relay only"),v=w(),b=m("button"),b.textContent="Publish",k=w(),R&&R.c(),C=w(),E=m("div"),S=m("textarea"),B=w(),ae($.$$.fragment),I(s,"class","compose-btn template-btn svelte-1t01h7c"),I(o,"class","compose-btn reformat-btn svelte-1t01h7c"),I(a,"class","compose-btn sign-btn svelte-1t01h7c"),I(d,"type","checkbox"),I(d,"class","svelte-1t01h7c"),I(u,"class","local-only-label svelte-1t01h7c"),I(b,"class","compose-btn publish-btn svelte-1t01h7c"),I(n,"class","compose-header svelte-1t01h7c"),I(S,"class","compose-textarea svelte-1t01h7c"),I(S,"placeholder","Enter your Nostr event JSON here, or click 'Generate Template' to start with a template..."),I(S,"spellcheck","false"),I(E,"class","compose-editor svelte-1t01h7c"),I(t,"class","compose-view svelte-1t01h7c")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(n,l),f(n,a),f(n,c),f(n,u),f(u,d),d.checked=e[2],f(u,g),f(n,v),f(n,b),f(t,k),R&&R.m(t,null),f(t,C),f(t,E),f(E,S),x(S,e[0]),h(i,B,p),ce($,i,p),D=!0,Q||(P=[A(s,"click",e[8]),A(o,"click",e[5]),A(a,"click",e[6]),A(d,"change",e[14]),A(b,"click",e[7]),A(S,"input",e[15])],Q=!0)},p(e,[n]){4&n&&(d.checked=e[2]),e[1]?R?R.p(e,n):(R=lk(e),R.c(),R.m(t,C)):R&&(R.d(1),R=null),1&n&&x(S,e[0]);const i={};8&n&&(i.userPubkey=e[3]),!F&&16&n&&(F=!0,i.isOpen=e[4],J(()=>F=!1)),$.$set(i)},i(e){D||(ne($.$$.fragment,e),D=!0)},o(e){ie($.$$.fragment,e),D=!1},d(e){e&&p(t),R&&R.d(),e&&p(B),ue($,e),Q=!1,i(P)}}}function ck(e,t,n){let{composeEventJson:i=""}=t,{userPubkey:s=""}=t,{userRole:r=""}=t,{policyEnabled:o=!1}=t,{publishError:l=""}=t,{localOnly:a=!0}=t;const c=L();let u=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,i=e.composeEventJson),"userPubkey"in e&&n(3,s=e.userPubkey),"userRole"in e&&n(12,r=e.userRole),"policyEnabled"in e&&n(13,o=e.policyEnabled),"publishError"in e&&n(1,l=e.publishError),"localOnly"in e&&n(2,a=e.localOnly)},[i,l,a,s,u,function(){c("reformatJson")},function(){c("signEvent")},function(){c("publishEvent")},function(){n(4,u=!0)},function(e){const{kind:t,template:s}=e.detail;n(0,i=JSON.stringify(s,null,2)),c("templateSelected",{kind:t,template:s})},function(){n(4,u=!1)},function(){n(1,l=""),c("clearError")},r,o,function(){a=this.checked,n(2,a)},function(){i=this.value,n(0,i)},function(e){u=e,n(4,u)}]}class uk extends fe{constructor(e){super(),de(this,e,ck,ak,r,{composeEventJson:0,userPubkey:3,userRole:12,policyEnabled:13,publishError:1,localOnly:2})}}function dk(e,t,n){const i=e.slice();return i[23]=t[n],i}function fk(t){let n,i,s,r,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access sprocket management.",s=w(),r=m("button"),r.textContent="Log In",I(i,"class","svelte-fiaj1r"),I(r,"class","login-btn svelte-fiaj1r"),I(n,"class","login-prompt svelte-fiaj1r")},m(e,a){h(e,n,a),f(n,i),f(n,s),f(n,r),o||(l=A(r,"click",t[18]),o=!0)},p:e,d(e){e&&p(n),o=!1,l()}}}function hk(e){let t,n,i,s,r,o,l,a,c,u=(e[2]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="❌ Owner permission required for sprocket management.",i=w(),s=m("p"),s.innerHTML='To enable sprocket functionality, set the <code class="svelte-fiaj1r">ORLY_OWNERS</code> environment variable with your npub when starting the relay.',r=w(),o=m("p"),l=y("Current user role: "),a=m("strong"),c=y(u),I(n,"class","svelte-fiaj1r"),I(s,"class","svelte-fiaj1r"),I(o,"class","svelte-fiaj1r"),I(t,"class","permission-denied svelte-fiaj1r")},m(e,u){h(e,t,u),f(t,n),f(t,i),f(t,s),f(t,r),f(t,o),f(o,l),f(o,a),f(a,c)},p(e,t){4&t&&u!==(u=(e[2]||"none")+"")&&E(c,u)},d(e){e&&p(t)}}}function pk(e){let t,n,s,r,o,l,a,c,u,d,v,b,k,C,S,B,$,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K,V,W,Y,Z,X,ee,te,ne,ie,se,re,oe,le,ae,ce,ue,de,fe,he,pe,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ve=e[3]?.script_exists?"✅ Exists":"❌ Not found",ye=e[3]?.pid&&gk(e),we=e[6]&&mk(e),be=e[8],Ae=[];for(let t=0;t<be.length;t+=1)Ae[t]=wk(dk(e,be,t));return{c(){t=m("div"),n=m("div"),s=m("h3"),s.textContent="Script Editor",r=w(),o=m("div"),l=m("button"),a=y("🔄 Restart"),c=w(),u=m("button"),d=y("🗑️ Delete Script"),b=w(),k=m("div"),C=m("h4"),C.textContent="Upload Script",S=w(),B=m("div"),$=m("input"),D=w(),Q=m("button"),P=y("📤 Upload & Update"),T=w(),L=m("div"),_=m("div"),N=m("span"),N.textContent="Status:",M=w(),U=m("span"),O=y(me),j=w(),ye&&ye.c(),z=w(),H=m("div"),q=m("span"),q.textContent="Script:",G=w(),J=m("span"),K=y(ve),V=w(),W=m("div"),Y=m("textarea"),Z=w(),X=m("div"),ee=m("button"),te=y("💾 Save & Update"),ne=w(),ie=m("button"),se=y("📥 Load Current"),re=w(),we&&we.c(),oe=w(),le=m("div"),ae=m("h3"),ae.textContent="Script Versions",ce=w(),ue=m("div");for(let e=0;e<Ae.length;e+=1)Ae[e].c();de=w(),fe=m("button"),he=y("🔄 Refresh Versions"),I(s,"class","svelte-fiaj1r"),I(l,"class","sprocket-btn restart-btn svelte-fiaj1r"),l.disabled=e[4],I(u,"class","sprocket-btn delete-btn svelte-fiaj1r"),u.disabled=v=e[4]||!e[3]?.script_exists,I(o,"class","sprocket-controls svelte-fiaj1r"),I(n,"class","sprocket-header svelte-fiaj1r"),I(C,"class","svelte-fiaj1r"),I($,"type","file"),I($,"id","sprocket-upload-file"),I($,"accept",".sh,.bash"),$.disabled=e[4],I($,"class","svelte-fiaj1r"),I(Q,"class","sprocket-btn upload-btn svelte-fiaj1r"),Q.disabled=R=e[4]||!e[5],I(B,"class","upload-controls svelte-fiaj1r"),I(k,"class","sprocket-upload-section svelte-fiaj1r"),I(N,"class","status-label svelte-fiaj1r"),I(U,"class","status-value svelte-fiaj1r"),F(U,"running",e[3]?.is_running),I(_,"class","status-item svelte-fiaj1r"),I(q,"class","status-label svelte-fiaj1r"),I(J,"class","status-value svelte-fiaj1r"),I(H,"class","status-item svelte-fiaj1r"),I(L,"class","sprocket-status svelte-fiaj1r"),I(Y,"class","script-editor svelte-fiaj1r"),I(Y,"placeholder","#!/bin/bash # Enter your sprocket script here..."),Y.disabled=e[4],I(W,"class","script-editor-container svelte-fiaj1r"),I(ee,"class","sprocket-btn save-btn svelte-fiaj1r"),ee.disabled=e[4],I(ie,"class","sprocket-btn load-btn svelte-fiaj1r"),ie.disabled=e[4],I(X,"class","script-actions svelte-fiaj1r"),I(t,"class","sprocket-section svelte-fiaj1r"),I(ue,"class","versions-list svelte-fiaj1r"),I(fe,"class","sprocket-btn refresh-btn svelte-fiaj1r"),fe.disabled=e[4],I(le,"class","sprocket-section svelte-fiaj1r")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(t,b),f(t,k),f(k,C),f(k,S),f(k,B),f(B,$),f(B,D),f(B,Q),f(Q,P),f(t,T),f(t,L),f(L,_),f(_,N),f(_,M),f(_,U),f(U,O),f(L,j),ye&&ye.m(L,null),f(L,z),f(L,H),f(H,q),f(H,G),f(H,J),f(J,K),f(t,V),f(t,W),f(W,Y),x(Y,e[0]),f(t,Z),f(t,X),f(X,ee),f(ee,te),f(X,ne),f(X,ie),f(ie,se),f(t,re),we&&we.m(t,null),h(i,oe,p),h(i,le,p),f(le,ae),f(le,ce),f(le,ue);for(let e=0;e<Ae.length;e+=1)Ae[e]&&Ae[e].m(ue,null);f(le,de),f(le,fe),f(fe,he),pe||(ge=[A(l,"click",e[9]),A(u,"click",e[10]),A($,"change",e[11]),A(Q,"click",e[12]),A(Y,"input",e[19]),A(ee,"click",e[13]),A(ie,"click",e[14]),A(fe,"click",e[15])],pe=!0)},p(e,n){if(16&n&&(l.disabled=e[4]),24&n&&v!==(v=e[4]||!e[3]?.script_exists)&&(u.disabled=v),16&n&&($.disabled=e[4]),48&n&&R!==(R=e[4]||!e[5])&&(Q.disabled=R),8&n&&me!==(me=e[3]?.is_running?"🟢 Running":"🔴 Stopped")&&E(O,me),8&n&&F(U,"running",e[3]?.is_running),e[3]?.pid?ye?ye.p(e,n):(ye=gk(e),ye.c(),ye.m(L,z)):ye&&(ye.d(1),ye=null),8&n&&ve!==(ve=e[3]?.script_exists?"✅ Exists":"❌ Not found")&&E(K,ve),16&n&&(Y.disabled=e[4]),1&n&&x(Y,e[0]),16&n&&(ee.disabled=e[4]),16&n&&(ie.disabled=e[4]),e[6]?we?we.p(e,n):(we=mk(e),we.c(),we.m(t,null)):we&&(we.d(1),we=null),196880&n){let t;for(be=e[8],t=0;t<be.length;t+=1){const i=dk(e,be,t);Ae[t]?Ae[t].p(i,n):(Ae[t]=wk(i),Ae[t].c(),Ae[t].m(ue,null))}for(;t<Ae.length;t+=1)Ae[t].d(1);Ae.length=be.length}16&n&&(fe.disabled=e[4])},d(e){e&&p(t),ye&&ye.d(),we&&we.d(),e&&p(oe),e&&p(le),g(Ae,e),pe=!1,i(ge)}}}function gk(e){let t,n,i,s,r,o=e[3].pid+"";return{c(){t=m("div"),n=m("span"),n.textContent="PID:",i=w(),s=m("span"),r=y(o),I(n,"class","status-label svelte-fiaj1r"),I(s,"class","status-value svelte-fiaj1r"),I(t,"class","status-item svelte-fiaj1r")},m(e,o){h(e,t,o),f(t,n),f(t,i),f(t,s),f(s,r)},p(e,t){8&t&&o!==(o=e[3].pid+"")&&E(r,o)},d(e){e&&p(t)}}}function mk(e){let t,n;return{c(){t=m("div"),n=y(e[6]),I(t,"class","sprocket-message svelte-fiaj1r"),F(t,"error","error"===e[7])},m(e,i){h(e,t,i),f(t,n)},p(e,i){64&i&&E(n,e[6]),128&i&&F(t,"error","error"===e[7])},d(e){e&&p(t)}}}function vk(e){let t;return{c(){t=m("span"),t.textContent="Current",I(t,"class","current-badge svelte-fiaj1r")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function yk(e){let t,n,i,s;function r(){return e[21](e[23])}return{c(){t=m("button"),n=y("🗑️ Delete"),I(t,"class","version-btn delete-btn svelte-fiaj1r"),t.disabled=e[4]},m(e,o){h(e,t,o),f(t,n),i||(s=A(t,"click",r),i=!0)},p(n,i){e=n,16&i&&(t.disabled=e[4])},d(e){e&&p(t),i=!1,s()}}}function wk(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,k,C,x=e[23].name+"",S=new Date(e[23].modified).toLocaleString()+"",B=e[23].is_current&&vk();function $(){return e[20](e[23])}let D=!e[23].is_current&&yk(e);return{c(){t=m("div"),n=m("div"),i=m("div"),s=y(x),r=w(),o=m("div"),l=y(S),a=w(),B&&B.c(),c=w(),u=m("div"),d=m("button"),g=y("📥 Load"),v=w(),D&&D.c(),b=w(),I(i,"class","version-name svelte-fiaj1r"),I(o,"class","version-date svelte-fiaj1r"),I(n,"class","version-info svelte-fiaj1r"),I(d,"class","version-btn load-btn svelte-fiaj1r"),d.disabled=e[4],I(u,"class","version-actions svelte-fiaj1r"),I(t,"class","version-item svelte-fiaj1r"),F(t,"current",e[23].is_current)},m(e,p){h(e,t,p),f(t,n),f(n,i),f(i,s),f(n,r),f(n,o),f(o,l),f(o,a),B&&B.m(o,null),f(t,c),f(t,u),f(u,d),f(d,g),f(u,v),D&&D.m(u,null),f(t,b),k||(C=A(d,"click",$),k=!0)},p(n,i){e=n,256&i&&x!==(x=e[23].name+"")&&E(s,x),256&i&&S!==(S=new Date(e[23].modified).toLocaleString()+"")&&E(l,S),e[23].is_current?B||(B=vk(),B.c(),B.m(o,null)):B&&(B.d(1),B=null),16&i&&(d.disabled=e[4]),e[23].is_current?D&&(D.d(1),D=null):D?D.p(e,i):(D=yk(e),D.c(),D.m(u,null)),256&i&&F(t,"current",e[23].is_current)},d(e){e&&p(t),B&&B.d(),D&&D.d(),k=!1,C()}}}function bk(t){let n,i,s;function r(e,t){return e[1]&&"owner"===e[2]?pk:e[1]?hk:fk}let o=r(t),l=o(t);return{c(){n=m("div"),i=m("h2"),i.textContent="Sprocket Script Management",s=w(),l.c(),I(i,"class","svelte-fiaj1r"),I(n,"class","sprocket-view svelte-fiaj1r")},m(e,t){h(e,n,t),f(n,i),f(n,s),l.m(n,null)},p(e,[t]){o===(o=r(e))&&l?l.p(e,t):(l.d(1),l=o(e),l&&(l.c(),l.m(n,null)))},i:e,o:e,d(e){e&&p(n),l.d()}}}function Ak(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:s=""}=t,{sprocketStatus:r=null}=t,{isLoadingSprocket:o=!1}=t,{sprocketUploadFile:l=null}=t,{sprocketScript:a=""}=t,{sprocketMessage:c=""}=t,{sprocketMessageType:u=""}=t,{sprocketVersions:d=[]}=t;const f=L();function h(e){f("loadVersion",e)}function p(e){f("deleteVersion",e)}return e.$$set=e=>{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,s=e.userRole),"sprocketStatus"in e&&n(3,r=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,o=e.isLoadingSprocket),"sprocketUploadFile"in e&&n(5,l=e.sprocketUploadFile),"sprocketScript"in e&&n(0,a=e.sprocketScript),"sprocketMessage"in e&&n(6,c=e.sprocketMessage),"sprocketMessageType"in e&&n(7,u=e.sprocketMessageType),"sprocketVersions"in e&&n(8,d=e.sprocketVersions)},[a,i,s,r,o,l,c,u,d,function(){f("restartSprocket")},function(){f("deleteSprocket")},function(e){f("sprocketFileSelect",e)},function(){f("uploadSprocketScript")},function(){f("saveSprocket")},function(){f("loadSprocket")},function(){f("loadVersions")},h,p,function(){f("openLoginModal")},function(){a=this.value,n(0,a)},e=>h(e),e=>p(e.name)]}class kk extends fe{constructor(e){super(),de(this,e,Ak,bk,r,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function Ik(e,t,n){const i=e.slice();return i[26]=t[n],i}function Ck(e,t,n){const i=e.slice();return i[29]=t[n],i}function Ek(e,t,n){const i=e.slice();return i[32]=t[n],i}function xk(t){let n,i,s,r,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access policy configuration.",s=w(),r=m("button"),r.textContent="Log In",I(i,"class","svelte-gkxvxc"),I(r,"class","login-btn svelte-gkxvxc"),I(n,"class","login-prompt svelte-gkxvxc")},m(e,a){h(e,n,a),f(n,i),f(n,s),f(n,r),o||(l=A(r,"click",t[16]),o=!0)},p:e,d(e){e&&p(n),o=!1,l()}}}function Sk(e){let t,n,i,s,r,o,l,a,c,u=(e[3]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",i=w(),s=m("p"),s.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n                to the <code class="svelte-gkxvxc">policy_admins</code> list.',r=w(),o=m("p"),l=y("Current user role: "),a=m("strong"),c=y(u),I(n,"class","svelte-gkxvxc"),I(s,"class","svelte-gkxvxc"),I(o,"class","svelte-gkxvxc"),I(t,"class","permission-denied svelte-gkxvxc")},m(e,u){h(e,t,u),f(t,n),f(t,i),f(t,s),f(t,r),f(t,o),f(o,l),f(o,a),f(a,c)},p(e,t){8&t[0]&&u!==(u=(e[3]||"none")+"")&&E(c,u)},d(e){e&&p(t)}}}function Bk(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,S,B,$,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K,V,W,Y,Z,X,ee,te,ne,ie,se,re,oe,le,ae,ce,ue,de,fe,he,pe,ge,me,ve,ye,we,be,Ae,ke,Ie,Ce,Ee,xe,Se,Be,$e,Fe,De,Qe,Pe,Re=e[5]?"Policy Enabled":"Policy Disabled",Te=e[10].length+"",Le=e[4]&&$k(),_e=e[9].length>0&&Fk(e),Ne=e[7]&&Qk(e);function Me(e,t){return 0===e[1].length?Rk:Pk}let Ue=Me(e),Oe=Ue(e);function je(e,t){return 0===e[10].length?_k:Lk}let ze=je(e),He=ze(e);return{c(){t=m("div"),n=m("div"),s=m("h3"),s.textContent="Policy Editor",r=w(),o=m("div"),l=m("span"),a=y(Re),c=w(),Le&&Le.c(),u=w(),d=m("div"),d.innerHTML='<p class="svelte-gkxvxc">Edit the policy JSON below and click &quot;Save &amp; Publish&quot; to update the relay&#39;s policy configuration.\n                    Changes are applied immediately after validation.</p> \n                <p class="info-note svelte-gkxvxc">Policy updates are published as kind 12345 events and require policy admin permissions.</p>',g=w(),v=m("div"),b=m("textarea"),k=w(),_e&&_e.c(),C=w(),S=m("div"),B=m("button"),$=y("Load Current"),D=w(),Q=m("button"),P=y("Format JSON"),R=w(),T=m("button"),L=y("Validate"),_=w(),N=m("button"),M=y("Save & Publish"),U=w(),Ne&&Ne.c(),O=w(),j=m("div"),z=m("h3"),z.textContent="Policy Administrators",H=w(),q=m("div"),q.innerHTML='<p class="svelte-gkxvxc">Policy admins can update the relay&#39;s policy configuration via kind 12345 events.\n                    Their follows get whitelisted if <code>policy_follow_whitelist_enabled</code> is true in the policy.</p> \n                <p class="info-note svelte-gkxvxc"><strong>Note:</strong> Policy admins are separate from relay admins (ORLY_ADMINS).\n                    Changes here update the JSON editor - click &quot;Save &amp; Publish&quot; to apply.</p>',G=w(),J=m("div"),Oe.c(),K=w(),V=m("div"),W=m("input"),Y=w(),Z=m("button"),X=y("+ Add Admin"),te=w(),ne=m("div"),ie=m("h3"),ie.textContent="Policy Follow Whitelist",se=w(),re=m("div"),re.innerHTML='<p class="svelte-gkxvxc">Pubkeys followed by policy admins (kind 3 events).\n                    These get automatic read+write access when rules have <code>write_allow_follows: true</code>.</p>',oe=w(),le=m("div"),ae=m("span"),ce=y(Te),ue=y(" pubkey(s) in whitelist"),de=w(),fe=m("button"),he=y("🔄 Refresh Follows"),pe=w(),ge=m("div"),He.c(),me=w(),ve=m("div"),ye=m("h3"),ye.textContent="Policy Reference",we=w(),be=m("div"),Ae=m("h4"),Ae.textContent="Structure Overview",ke=w(),Ie=m("ul"),Ie.innerHTML='<li class="svelte-gkxvxc"><code class="svelte-gkxvxc">kind.whitelist</code> - Only allow these event kinds (takes precedence)</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">kind.blacklist</code> - Deny these event kinds (if no whitelist)</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">global</code> - Rules applied to all events</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">rules</code> - Per-kind rules (keyed by kind number as string)</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">default_policy</code> - &quot;allow&quot; or &quot;deny&quot; when no rules match</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">policy_admins</code> - Hex pubkeys that can update policy</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">policy_follow_whitelist_enabled</code> - Enable follow-based access</li>',Ce=w(),Ee=m("h4"),Ee.textContent="Rule Fields",xe=w(),Se=m("ul"),Se.innerHTML='<li class="svelte-gkxvxc"><code class="svelte-gkxvxc">description</code> - Human-readable rule description</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">write_allow</code> / <code class="svelte-gkxvxc">write_deny</code> - Pubkey lists for write access</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">read_allow</code> / <code class="svelte-gkxvxc">read_deny</code> - Pubkey lists for read access</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">write_allow_follows</code> - Grant access to policy admin follows</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">size_limit</code> - Max total event size in bytes</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">content_limit</code> - Max content field size in bytes</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_expiry</code> - Max expiry offset in seconds</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_age_of_event</code> - Max age of created_at in seconds</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_age_event_in_future</code> - Max future offset in seconds</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">must_have_tags</code> - Required tag letters (e.g., [&quot;d&quot;, &quot;t&quot;])</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">tag_validation</code> - Regex patterns for tag values</li> \n                    <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">script</code> - Path to external validation script</li>',Be=w(),$e=m("h4"),$e.textContent="Example Policy",Fe=w(),De=m("pre"),De.textContent=`${e[20]}`,I(s,"class","svelte-gkxvxc"),I(l,"class","status-badge svelte-gkxvxc"),F(l,"enabled",e[5]),I(o,"class","policy-status svelte-gkxvxc"),I(n,"class","policy-header svelte-gkxvxc"),I(d,"class","policy-info svelte-gkxvxc"),I(b,"class","policy-editor svelte-gkxvxc"),I(b,"placeholder","Loading policy configuration..."),b.disabled=e[6],I(b,"spellcheck","false"),I(v,"class","editor-container svelte-gkxvxc"),I(B,"class","policy-btn load-btn svelte-gkxvxc"),B.disabled=e[6],I(Q,"class","policy-btn format-btn svelte-gkxvxc"),Q.disabled=e[6],I(T,"class","policy-btn validate-btn svelte-gkxvxc"),T.disabled=e[6],I(N,"class","policy-btn save-btn svelte-gkxvxc"),N.disabled=e[6],I(S,"class","policy-actions svelte-gkxvxc"),I(t,"class","policy-section svelte-gkxvxc"),I(q,"class","policy-info svelte-gkxvxc"),I(J,"class","admin-list svelte-gkxvxc"),I(W,"type","text"),I(W,"placeholder","npub or hex pubkey"),W.disabled=e[6],I(W,"class","svelte-gkxvxc"),I(Z,"class","policy-btn add-btn svelte-gkxvxc"),Z.disabled=ee=e[6]||!e[11].trim(),I(V,"class","add-admin svelte-gkxvxc"),I(j,"class","policy-section svelte-gkxvxc"),I(re,"class","policy-info svelte-gkxvxc"),I(ae,"class","follows-count svelte-gkxvxc"),I(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],I(le,"class","follows-header svelte-gkxvxc"),I(ge,"class","follows-list svelte-gkxvxc"),I(ne,"class","policy-section svelte-gkxvxc"),I(Ae,"class","svelte-gkxvxc"),I(Ie,"class","field-list svelte-gkxvxc"),I(Ee,"class","svelte-gkxvxc"),I(Se,"class","field-list svelte-gkxvxc"),I($e,"class","svelte-gkxvxc"),I(De,"class","example-json svelte-gkxvxc"),I(be,"class","reference-content svelte-gkxvxc"),I(ve,"class","policy-section svelte-gkxvxc")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(o,c),Le&&Le.m(o,null),f(t,u),f(t,d),f(t,g),f(t,v),f(v,b),x(b,e[0]),f(t,k),_e&&_e.m(t,null),f(t,C),f(t,S),f(S,B),f(B,$),f(S,D),f(S,Q),f(Q,P),f(S,R),f(S,T),f(T,L),f(S,_),f(S,N),f(N,M),f(t,U),Ne&&Ne.m(t,null),h(i,O,p),h(i,j,p),f(j,z),f(j,H),f(j,q),f(j,G),f(j,J),Oe.m(J,null),f(j,K),f(j,V),f(V,W),x(W,e[11]),f(V,Y),f(V,Z),f(Z,X),h(i,te,p),h(i,ne,p),f(ne,ie),f(ne,se),f(ne,re),f(ne,oe),f(ne,le),f(le,ae),f(ae,ce),f(ae,ue),f(le,de),f(le,fe),f(fe,he),f(ne,pe),f(ne,ge),He.m(ge,null),h(i,me,p),h(i,ve,p),f(ve,ye),f(ve,we),f(ve,be),f(be,Ae),f(be,ke),f(be,Ie),f(be,Ce),f(be,Ee),f(be,xe),f(be,Se),f(be,Be),f(be,$e),f(be,Fe),f(be,De),Qe||(Pe=[A(b,"input",e[21]),A(B,"click",e[12]),A(Q,"click",e[15]),A(T,"click",e[13]),A(N,"click",e[14]),A(W,"input",e[23]),A(W,"keydown",e[24]),A(Z,"click",e[18]),A(fe,"click",e[17])],Qe=!0)},p(e,n){32&n[0]&&Re!==(Re=e[5]?"Policy Enabled":"Policy Disabled")&&E(a,Re),32&n[0]&&F(l,"enabled",e[5]),e[4]?Le||(Le=$k(),Le.c(),Le.m(o,null)):Le&&(Le.d(1),Le=null),64&n[0]&&(b.disabled=e[6]),1&n[0]&&x(b,e[0]),e[9].length>0?_e?_e.p(e,n):(_e=Fk(e),_e.c(),_e.m(t,C)):_e&&(_e.d(1),_e=null),64&n[0]&&(B.disabled=e[6]),64&n[0]&&(Q.disabled=e[6]),64&n[0]&&(T.disabled=e[6]),64&n[0]&&(N.disabled=e[6]),e[7]?Ne?Ne.p(e,n):(Ne=Qk(e),Ne.c(),Ne.m(t,null)):Ne&&(Ne.d(1),Ne=null),Ue===(Ue=Me(e))&&Oe?Oe.p(e,n):(Oe.d(1),Oe=Ue(e),Oe&&(Oe.c(),Oe.m(J,null))),64&n[0]&&(W.disabled=e[6]),2048&n[0]&&W.value!==e[11]&&x(W,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Te!==(Te=e[10].length+"")&&E(ce,Te),64&n[0]&&(fe.disabled=e[6]),ze===(ze=je(e))&&He?He.p(e,n):(He.d(1),He=ze(e),He&&(He.c(),He.m(ge,null)))},d(e){e&&p(t),Le&&Le.d(),_e&&_e.d(),Ne&&Ne.d(),e&&p(O),e&&p(j),Oe.d(),e&&p(te),e&&p(ne),He.d(),e&&p(me),e&&p(ve),Qe=!1,i(Pe)}}}function $k(e){let t;return{c(){t=m("span"),t.textContent="Policy Admin",I(t,"class","admin-badge svelte-gkxvxc")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function Fk(e){let t,n,i,s,r=e[9],o=[];for(let t=0;t<r.length;t+=1)o[t]=Dk(Ek(e,r,t));return{c(){t=m("div"),n=m("h4"),n.textContent="Validation Errors:",i=w(),s=m("ul");for(let e=0;e<o.length;e+=1)o[e].c();I(n,"class","svelte-gkxvxc"),I(s,"class","svelte-gkxvxc"),I(t,"class","validation-errors svelte-gkxvxc")},m(e,r){h(e,t,r),f(t,n),f(t,i),f(t,s);for(let e=0;e<o.length;e+=1)o[e]&&o[e].m(s,null)},p(e,t){if(512&t[0]){let n;for(r=e[9],n=0;n<r.length;n+=1){const i=Ek(e,r,n);o[n]?o[n].p(i,t):(o[n]=Dk(i),o[n].c(),o[n].m(s,null))}for(;n<o.length;n+=1)o[n].d(1);o.length=r.length}},d(e){e&&p(t),g(o,e)}}}function Dk(e){let t,n,i=e[32]+"";return{c(){t=m("li"),n=y(i),I(t,"class","svelte-gkxvxc")},m(e,i){h(e,t,i),f(t,n)},p(e,t){512&t[0]&&i!==(i=e[32]+"")&&E(n,i)},d(e){e&&p(t)}}}function Qk(e){let t,n;return{c(){t=m("div"),n=y(e[7]),I(t,"class","policy-message svelte-gkxvxc"),F(t,"error","error"===e[8]),F(t,"success","success"===e[8])},m(e,i){h(e,t,i),f(t,n)},p(e,i){128&i[0]&&E(n,e[7]),256&i[0]&&F(t,"error","error"===e[8]),256&i[0]&&F(t,"success","success"===e[8])},d(e){e&&p(t)}}}function Pk(e){let t,n=e[1],i=[];for(let t=0;t<n.length;t+=1)i[t]=Tk(Ck(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(524354&s[0]){let r;for(n=e[1],r=0;r<n.length;r+=1){const o=Ck(e,n,r);i[r]?i[r].p(o,s):(i[r]=Tk(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function Rk(t){let n;return{c(){n=m("p"),n.textContent="No policy admins configured",I(n,"class","no-items svelte-gkxvxc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Tk(e){let t,n,i,s,r,o,l,a,c,u,d,g,v=e[29].substring(0,16)+"",b=e[29].substring(e[29].length-8)+"";function k(){return e[22](e[29])}return{c(){t=m("div"),n=m("span"),i=y(v),s=y("..."),r=y(b),l=w(),a=m("button"),c=y("✕"),u=w(),I(n,"class","admin-pubkey svelte-gkxvxc"),I(n,"title",o=e[29]),I(a,"class","remove-btn svelte-gkxvxc"),a.disabled=e[6],I(a,"title","Remove admin"),I(t,"class","admin-item svelte-gkxvxc")},m(e,o){h(e,t,o),f(t,n),f(n,i),f(n,s),f(n,r),f(t,l),f(t,a),f(a,c),f(t,u),d||(g=A(a,"click",k),d=!0)},p(t,s){e=t,2&s[0]&&v!==(v=e[29].substring(0,16)+"")&&E(i,v),2&s[0]&&b!==(b=e[29].substring(e[29].length-8)+"")&&E(r,b),2&s[0]&&o!==(o=e[29])&&I(n,"title",o),64&s[0]&&(a.disabled=e[6])},d(e){e&&p(t),d=!1,g()}}}function Lk(e){let t,n=e[10],i=[];for(let t=0;t<n.length;t+=1)i[t]=Nk(Ik(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","follows-grid svelte-gkxvxc")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(1024&s[0]){let r;for(n=e[10],r=0;r<n.length;r+=1){const o=Ik(e,n,r);i[r]?i[r].p(o,s):(i[r]=Nk(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function _k(t){let n;return{c(){n=m("p"),n.textContent='No follows loaded. Click "Refresh Follows" to load from database.',I(n,"class","no-items svelte-gkxvxc")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Nk(e){let t,n,i,s,r,o,l=e[26].substring(0,12)+"",a=e[26].substring(e[26].length-6)+"";return{c(){t=m("div"),n=y(l),i=y("..."),s=y(a),r=w(),I(t,"class","follow-item svelte-gkxvxc"),I(t,"title",o=e[26])},m(e,o){h(e,t,o),f(t,n),f(t,i),f(t,s),f(t,r)},p(e,i){1024&i[0]&&l!==(l=e[26].substring(0,12)+"")&&E(n,l),1024&i[0]&&a!==(a=e[26].substring(e[26].length-6)+"")&&E(s,a),1024&i[0]&&o!==(o=e[26])&&I(t,"title",o)},d(e){e&&p(t)}}}function Mk(t){let n,i,s;function r(e,t){return e[2]&&("owner"===e[3]||e[4])?Bk:e[2]?Sk:xk}let o=r(t),l=o(t);return{c(){n=m("div"),i=m("h2"),i.textContent="Policy Configuration",s=w(),l.c(),I(i,"class","svelte-gkxvxc"),I(n,"class","policy-view svelte-gkxvxc")},m(e,t){h(e,n,t),f(n,i),f(n,s),l.m(n,null)},p(e,t){o===(o=r(e))&&l?l.p(e,t):(l.d(1),l=o(e),l&&(l.c(),l.m(n,null)))},i:e,o:e,d(e){e&&p(n),l.d()}}}function Uk(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:s=""}=t,{isPolicyAdmin:r=!1}=t,{policyEnabled:o=!1}=t,{policyJson:l=""}=t,{isLoadingPolicy:a=!1}=t,{policyMessage:c=""}=t,{policyMessageType:u=""}=t,{validationErrors:d=[]}=t,{policyAdmins:f=[]}=t,{policyFollows:h=[]}=t;const p=L();let g="";function m(){g.trim()&&(p("addPolicyAdmin",g.trim()),n(11,g=""))}function v(e){p("removePolicyAdmin",e)}return e.$$set=e=>{"isLoggedIn"in e&&n(2,i=e.isLoggedIn),"userRole"in e&&n(3,s=e.userRole),"isPolicyAdmin"in e&&n(4,r=e.isPolicyAdmin),"policyEnabled"in e&&n(5,o=e.policyEnabled),"policyJson"in e&&n(0,l=e.policyJson),"isLoadingPolicy"in e&&n(6,a=e.isLoadingPolicy),"policyMessage"in e&&n(7,c=e.policyMessage),"policyMessageType"in e&&n(8,u=e.policyMessageType),"validationErrors"in e&&n(9,d=e.validationErrors),"policyAdmins"in e&&n(1,f=e.policyAdmins),"policyFollows"in e&&n(10,h=e.policyFollows)},e.$$.update=()=>{if(1&e.$$.dirty[0])try{if(l){const e=JSON.parse(l);n(1,f=e.policy_admins||[])}}catch(e){}},[l,f,i,s,r,o,a,c,u,d,h,g,function(){p("loadPolicy")},function(){p("validatePolicy")},function(){p("savePolicy")},function(){p("formatJson")},function(){p("openLoginModal")},function(){p("refreshFollows")},m,v,'{\n  "kind": {\n    "whitelist": [0, 1, 3, 6, 7, 10002],\n    "blacklist": []\n  },\n  "global": {\n    "description": "Global rules applied to all events",\n    "size_limit": 65536,\n    "max_age_of_event": 86400,\n    "max_age_event_in_future": 300\n  },\n  "rules": {\n    "1": {\n      "description": "Kind 1 (short text notes)",\n      "content_limit": 8192,\n      "write_allow_follows": true\n    },\n    "30023": {\n      "description": "Long-form articles",\n      "content_limit": 100000,\n      "tag_validation": {\n        "d": "^[a-z0-9-]{1,64}$",\n        "t": "^[a-z0-9-]{1,32}$"\n      }\n    }\n  },\n  "default_policy": "allow",\n  "policy_admins": ["<your-hex-pubkey>"],\n  "policy_follow_whitelist_enabled": true\n}',function(){l=this.value,n(0,l)},e=>v(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class Ok extends fe{constructor(e){super(),de(this,e,Uk,Mk,r,{isLoggedIn:2,userRole:3,isPolicyAdmin:4,policyEnabled:5,policyJson:0,isLoadingPolicy:6,policyMessage:7,policyMessageType:8,validationErrors:9,policyAdmins:1,policyFollows:10},null,[-1,-1])}}const jk=[{id:"social",name:"Social/Notes",description:"User profiles, notes, follows, reposts, reactions, and relay lists",kinds:[0,1,3,6,7,10002]},{id:"dm",name:"Direct Messages",description:"Encrypted direct messages (legacy and NIP-17 gift-wrapped)",kinds:[4,14,1059]},{id:"longform",name:"Long-form Content",description:"Blog posts and article drafts",kinds:[30023,30024]},{id:"media",name:"Media",description:"File metadata and media attachments",kinds:[1063,20,21,22]},{id:"marketplace_nip15",name:"Marketplace (NIP-15)",description:"Legacy NIP-15 stalls and products",kinds:[30017,30018,30019,30020]},{id:"marketplace_nip99",name:"Marketplace (NIP-99/Gamma)",description:"NIP-99 classified listings, collections, shipping, reviews (Plebeian Market)",kinds:[30402,30403,30405,30406,31555]},{id:"order_communication",name:"Order Communication",description:"Gamma Markets order messages and payment receipts (kinds 16, 17)",kinds:[16,17]},{id:"groups_nip29",name:"Group Messaging (NIP-29)",description:"Simple relay-based group chat messages",kinds:[9,10,11,12]},{id:"groups_nip72",name:"Communities (NIP-72)",description:"Community definitions and threaded discussions",kinds:[34550,1111,4550]},{id:"lists",name:"Lists/Bookmarks",description:"Mute lists, pin lists, and parameterized list events",kinds:[1e4,10001,3e4,30001]}];function zk(e,t,n){const i=e.slice();return i[90]=t[n],i}function Hk(e,t,n){const i=e.slice();return i[98]=t[n],i}function qk(e,t,n){const i=e.slice();return i[93]=t[n],i}function Gk(e,t,n){const i=e.slice();return i[103]=t[n],i}function Jk(e,t,n){const i=e.slice();return i[106]=t[n],i}function Kk(e,t,n){const i=e.slice();return i[106]=t[n],i}function Vk(e,t,n){const i=e.slice();return i[93]=t[n],i}function Wk(e,t,n){const i=e.slice();return i[90]=t[n],i}function Yk(e){let t,n,i;return{c(){t=m("div"),n=y(e[2]),I(t,"class",i="message "+e[3]+" svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n)},p(e,s){4&s[0]&&E(n,e[2]),8&s[0]&&i!==(i="message "+e[3]+" svelte-1i0huu3")&&I(t,"class",i)},d(e){e&&p(t)}}}function Zk(e){let t;function n(e,t){return e[5]?tI:eI}let i=n(e),s=i(e);return{c(){s.c(),t=b()},m(e,n){s.m(e,n),h(e,t,n)},p(e,r){i===(i=n(e))&&s?s.p(e,r):(s.d(1),s=i(e),s&&(s.c(),s.m(t.parentNode,t)))},d(e){s.d(e),e&&p(t)}}}function Xk(e){let t,n,s,r,o,l,a,c,u,d,v,y,b,k,E,S,B,$,F,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K,V,W,Y,Z,X=jk,ee=[];for(let t=0;t<X.length;t+=1)ee[t]=jI(Wk(e,X,t));function te(e,t){return e[1]?HI:zI}let ne=te(e),ie=ne(e);return{c(){t=m("div"),n=m("div"),n.innerHTML='<h3 class="svelte-1i0huu3">Initial Configuration</h3> \n                <p class="svelte-1i0huu3">Configure curating mode before the relay will accept events. Select which event kinds to allow and set rate limiting parameters.</p>',s=w(),r=m("div"),o=m("h4"),o.textContent="Allowed Event Kinds",l=w(),a=m("p"),a.textContent="Select categories of events to allow. At least one must be selected.",c=w(),u=m("div");for(let e=0;e<ee.length;e+=1)ee[e].c();d=w(),v=m("div"),y=m("label"),y.textContent='Custom Kinds (comma-separated, ranges allowed e.g., "100, 200-300")',b=w(),k=m("input"),E=w(),S=m("div"),B=m("h4"),B.textContent="Rate Limiting",$=w(),F=m("div"),D=m("div"),Q=m("label"),Q.textContent="Daily Event Limit (unclassified users)",P=w(),R=m("input"),T=w(),L=m("div"),_=m("div"),N=m("label"),N.textContent="First IP Ban Duration (hours)",M=w(),U=m("input"),O=w(),j=m("div"),z=m("label"),z.textContent="Second+ IP Ban Duration (hours)",H=w(),q=m("input"),G=w(),J=m("div"),K=m("button"),ie.c(),V=w(),W=m("p"),W.textContent="This will publish a kind 30078 event to activate curating mode.",I(n,"class","setup-header svelte-1i0huu3"),I(o,"class","svelte-1i0huu3"),I(a,"class","help-text svelte-1i0huu3"),I(u,"class","category-grid svelte-1i0huu3"),I(y,"for","custom-kinds"),I(y,"class","svelte-1i0huu3"),I(k,"id","custom-kinds"),I(k,"type","text"),I(k,"placeholder","e.g., 100, 200-250, 500"),I(k,"class","svelte-1i0huu3"),I(v,"class","custom-kinds svelte-1i0huu3"),I(r,"class","config-section svelte-1i0huu3"),I(B,"class","svelte-1i0huu3"),I(Q,"for","daily-limit"),I(Q,"class","svelte-1i0huu3"),I(R,"id","daily-limit"),I(R,"type","number"),I(R,"min","1"),I(R,"class","svelte-1i0huu3"),I(D,"class","form-group svelte-1i0huu3"),I(F,"class","form-row svelte-1i0huu3"),I(N,"for","first-ban"),I(N,"class","svelte-1i0huu3"),I(U,"id","first-ban"),I(U,"type","number"),I(U,"min","1"),I(U,"class","svelte-1i0huu3"),I(_,"class","form-group svelte-1i0huu3"),I(z,"for","second-ban"),I(z,"class","svelte-1i0huu3"),I(q,"id","second-ban"),I(q,"type","number"),I(q,"min","1"),I(q,"class","svelte-1i0huu3"),I(j,"class","form-group svelte-1i0huu3"),I(L,"class","form-row svelte-1i0huu3"),I(S,"class","config-section svelte-1i0huu3"),I(K,"class","publish-btn svelte-1i0huu3"),K.disabled=e[1],I(W,"class","publish-note svelte-1i0huu3"),I(J,"class","publish-section svelte-1i0huu3"),I(t,"class","setup-section svelte-1i0huu3")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),f(r,o),f(r,l),f(r,a),f(r,c),f(r,u);for(let e=0;e<ee.length;e+=1)ee[e]&&ee[e].m(u,null);f(r,d),f(r,v),f(v,y),f(v,b),f(v,k),x(k,e[11].custom_kinds),f(t,E),f(t,S),f(S,B),f(S,$),f(S,F),f(F,D),f(D,Q),f(D,P),f(D,R),x(R,e[11].daily_limit),f(S,T),f(S,L),f(L,_),f(_,N),f(_,M),f(_,U),x(U,e[11].first_ban_hours),f(L,O),f(L,j),f(j,z),f(j,H),f(j,q),x(q,e[11].second_ban_hours),f(t,G),f(t,J),f(J,K),ie.m(K,null),f(J,V),f(J,W),Y||(Z=[A(k,"input",e[47]),A(R,"input",e[48]),A(U,"input",e[49]),A(q,"input",e[50]),A(K,"click",e[33])],Y=!0)},p(e,t){if(2048&t[0]|2&t[1]){let n;for(X=jk,n=0;n<X.length;n+=1){const i=Wk(e,X,n);ee[n]?ee[n].p(i,t):(ee[n]=jI(i),ee[n].c(),ee[n].m(u,null))}for(;n<ee.length;n+=1)ee[n].d(1);ee.length=X.length}2048&t[0]&&k.value!==e[11].custom_kinds&&x(k,e[11].custom_kinds),2048&t[0]&&C(R.value)!==e[11].daily_limit&&x(R,e[11].daily_limit),2048&t[0]&&C(U.value)!==e[11].first_ban_hours&&x(U,e[11].first_ban_hours),2048&t[0]&&C(q.value)!==e[11].second_ban_hours&&x(q,e[11].second_ban_hours),ne!==(ne=te(e))&&(ie.d(1),ie=ne(e),ie&&(ie.c(),ie.m(K,null))),2&t[0]&&(K.disabled=e[1])},d(e){e&&p(t),g(ee,e),ie.d(),Y=!1,i(Z)}}}function eI(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K=e[12].length+"",V=e[15].length+"",W=e[18].length+"",Y=e[19].length+"",Z=e[20].length+"",X="trusted"===e[0]&&nI(e),ee="blacklist"===e[0]&&lI(e),te="unclassified"===e[0]&&fI(e),ne="spam"===e[0]&&mI(e),ie="ips"===e[0]&&AI(e),se="settings"===e[0]&&SI(e);return{c(){t=m("div"),n=m("button"),s=y("Trusted ("),r=y(K),o=y(")"),l=w(),a=m("button"),c=y("Blacklist ("),u=y(V),d=y(")"),g=w(),v=m("button"),b=y("Unclassified ("),k=y(W),C=y(")"),x=w(),S=m("button"),B=y("Spam ("),$=y(Y),D=y(")"),Q=w(),P=m("button"),R=y("Blocked IPs ("),T=y(Z),L=y(")"),_=w(),N=m("button"),N.textContent="Settings",M=w(),U=m("div"),X&&X.c(),O=w(),ee&&ee.c(),j=w(),te&&te.c(),z=w(),ne&&ne.c(),H=w(),ie&&ie.c(),q=w(),se&&se.c(),I(n,"class","tab svelte-1i0huu3"),F(n,"active","trusted"===e[0]),I(a,"class","tab svelte-1i0huu3"),F(a,"active","blacklist"===e[0]),I(v,"class","tab svelte-1i0huu3"),F(v,"active","unclassified"===e[0]),I(S,"class","tab svelte-1i0huu3"),F(S,"active","spam"===e[0]),I(P,"class","tab svelte-1i0huu3"),F(P,"active","ips"===e[0]),I(N,"class","tab svelte-1i0huu3"),F(N,"active","settings"===e[0]),I(t,"class","tabs svelte-1i0huu3"),I(U,"class","tab-content svelte-1i0huu3")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(t,l),f(t,a),f(a,c),f(a,u),f(a,d),f(t,g),f(t,v),f(v,b),f(v,k),f(v,C),f(t,x),f(t,S),f(S,B),f(S,$),f(S,D),f(t,Q),f(t,P),f(P,R),f(P,T),f(P,L),f(t,_),f(t,N),h(i,M,p),h(i,U,p),X&&X.m(U,null),f(U,O),ee&&ee.m(U,null),f(U,j),te&&te.m(U,null),f(U,z),ne&&ne.m(U,null),f(U,H),ie&&ie.m(U,null),f(U,q),se&&se.m(U,null),G||(J=[A(n,"click",e[52]),A(a,"click",e[53]),A(v,"click",e[54]),A(S,"click",e[55]),A(P,"click",e[56]),A(N,"click",e[57])],G=!0)},p(e,t){4096&t[0]&&K!==(K=e[12].length+"")&&E(r,K),1&t[0]&&F(n,"active","trusted"===e[0]),32768&t[0]&&V!==(V=e[15].length+"")&&E(u,V),1&t[0]&&F(a,"active","blacklist"===e[0]),262144&t[0]&&W!==(W=e[18].length+"")&&E(k,W),1&t[0]&&F(v,"active","unclassified"===e[0]),524288&t[0]&&Y!==(Y=e[19].length+"")&&E($,Y),1&t[0]&&F(S,"active","spam"===e[0]),1048576&t[0]&&Z!==(Z=e[20].length+"")&&E(T,Z),1&t[0]&&F(P,"active","ips"===e[0]),1&t[0]&&F(N,"active","settings"===e[0]),"trusted"===e[0]?X?X.p(e,t):(X=nI(e),X.c(),X.m(U,O)):X&&(X.d(1),X=null),"blacklist"===e[0]?ee?ee.p(e,t):(ee=lI(e),ee.c(),ee.m(U,j)):ee&&(ee.d(1),ee=null),"unclassified"===e[0]?te?te.p(e,t):(te=fI(e),te.c(),te.m(U,z)):te&&(te.d(1),te=null),"spam"===e[0]?ne?ne.p(e,t):(ne=mI(e),ne.c(),ne.m(U,H)):ne&&(ne.d(1),ne=null),"ips"===e[0]?ie?ie.p(e,t):(ie=AI(e),ie.c(),ie.m(U,q)):ie&&(ie.d(1),ie=null),"settings"===e[0]?se?se.p(e,t):(se=SI(e),se.c(),se.m(U,null)):se&&(se.d(1),se=null)},d(e){e&&p(t),e&&p(M),e&&p(U),X&&X.d(),ee&&ee.d(),te&&te.d(),ne&&ne.d(),ie&&ie.d(),se&&se.d(),G=!1,i(J)}}}function tI(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$=GI(e[5])+"";function F(e,t){return"trusted"===e[6]?PI:"blacklisted"===e[6]?QI:DI}let D=F(e),Q=D(e);function P(e,t){return e[9]&&0===e[7].length?LI:0===e[7].length?TI:RI}let R=P(e),T=R(e);return{c(){t=m("div"),n=m("div"),i=m("div"),s=m("button"),s.textContent="← Back",r=w(),o=m("h3"),o.textContent="User Events",l=w(),a=m("span"),c=y($),u=w(),d=m("span"),g=y(e[8]),v=y(" events"),b=w(),k=m("div"),Q.c(),C=w(),x=m("div"),T.c(),I(s,"class","back-btn svelte-1i0huu3"),I(o,"class","svelte-1i0huu3"),I(a,"class","detail-pubkey svelte-1i0huu3"),I(a,"title",e[5]),I(d,"class","detail-count svelte-1i0huu3"),I(i,"class","detail-header-left svelte-1i0huu3"),I(k,"class","detail-header-right svelte-1i0huu3"),I(n,"class","detail-header svelte-1i0huu3"),I(x,"class","events-list svelte-1i0huu3"),I(t,"class","user-detail-view svelte-1i0huu3")},m(p,m){h(p,t,m),f(t,n),f(n,i),f(i,s),f(i,r),f(i,o),f(i,l),f(i,a),f(a,c),f(i,u),f(i,d),f(d,g),f(d,v),f(n,b),f(n,k),Q.m(k,null),f(t,C),f(t,x),T.m(x,null),S||(B=A(s,"click",e[36]),S=!0)},p(e,t){32&t[0]&&$!==($=GI(e[5])+"")&&E(c,$),32&t[0]&&I(a,"title",e[5]),256&t[0]&&E(g,e[8]),D===(D=F(e))&&Q?Q.p(e,t):(Q.d(1),Q=D(e),Q&&(Q.c(),Q.m(k,null))),R===(R=P(e))&&T?T.p(e,t):(T.d(1),T=R(e),T&&(T.c(),T.m(x,null)))},d(e){e&&p(t),Q.d(),T.d(),S=!1,B()}}}function nI(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,E;function S(e,t){return e[12].length>0?sI:iI}let B=S(e),$=B(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Trusted Publishers",s=w(),r=m("p"),r.textContent="Trusted users can publish unlimited events without rate limiting.",o=w(),l=m("div"),a=m("input"),c=w(),u=m("input"),d=w(),g=m("button"),v=y("Trust"),b=w(),k=m("div"),$.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(a,"type","text"),I(a,"placeholder","Pubkey (64 hex chars)"),I(a,"class","svelte-1i0huu3"),I(u,"type","text"),I(u,"placeholder","Note (optional)"),I(u,"class","svelte-1i0huu3"),g.disabled=e[1],I(g,"class","svelte-1i0huu3"),I(l,"class","add-form svelte-1i0huu3"),I(k,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),f(t,o),f(t,l),f(l,a),x(a,e[13]),f(l,c),f(l,u),x(u,e[14]),f(l,d),f(l,g),f(g,v),f(t,b),f(t,k),$.m(k,null),C||(E=[A(a,"input",e[58]),A(u,"input",e[59]),A(g,"click",e[60])],C=!0)},p(e,t){8192&t[0]&&a.value!==e[13]&&x(a,e[13]),16384&t[0]&&u.value!==e[14]&&x(u,e[14]),2&t[0]&&(g.disabled=e[1]),B===(B=S(e))&&$?$.p(e,t):($.d(1),$=B(e),$&&($.c(),$.m(k,null)))},d(e){e&&p(t),$.d(),C=!1,i(E)}}}function iI(t){let n;return{c(){n=m("div"),n.textContent="No trusted pubkeys yet.",I(n,"class","empty svelte-1i0huu3")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function sI(e){let t,n=e[12],i=[];for(let t=0;t<n.length;t+=1)i[t]=oI(Kk(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(67112960&s[0]|16&s[1]){let r;for(n=e[12],r=0;r<n.length;r+=1){const o=Kk(e,n,r);i[r]?i[r].p(o,s):(i[r]=oI(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function rI(e){let t,n,i=e[106].note+"";return{c(){t=m("span"),n=y(i),I(t,"class","note svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n)},p(e,t){4096&t[0]&&i!==(i=e[106].note+"")&&E(n,i)},d(e){e&&p(t)}}}function oI(e){let t,n,s,r,o,l,a,c,u,d,g,v,b=GI(e[106].pubkey)+"",C=e[106].note&&rI(e);function x(){return e[61](e[106])}function S(){return e[62](e[106])}return{c(){t=m("div"),n=m("div"),s=m("span"),r=y(b),l=w(),C&&C.c(),a=w(),c=m("div"),u=m("button"),u.textContent="Remove",d=w(),I(s,"class","pubkey svelte-1i0huu3"),I(s,"title",o=e[106].pubkey),I(n,"class","item-main svelte-1i0huu3"),I(u,"class","btn-danger svelte-1i0huu3"),I(c,"class","item-actions svelte-1i0huu3"),I(t,"class","list-item clickable svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n),f(n,s),f(s,r),f(n,l),C&&C.m(n,null),f(t,a),f(t,c),f(c,u),f(t,d),g||(v=[A(u,"click",k(x)),A(t,"click",S)],g=!0)},p(t,i){e=t,4096&i[0]&&b!==(b=GI(e[106].pubkey)+"")&&E(r,b),4096&i[0]&&o!==(o=e[106].pubkey)&&I(s,"title",o),e[106].note?C?C.p(e,i):(C=rI(e),C.c(),C.m(n,null)):C&&(C.d(1),C=null)},d(e){e&&p(t),C&&C.d(),g=!1,i(v)}}}function lI(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,E;function S(e,t){return e[15].length>0?cI:aI}let B=S(e),$=B(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Blacklisted Publishers",s=w(),r=m("p"),r.textContent="Blacklisted users cannot publish any events.",o=w(),l=m("div"),a=m("input"),c=w(),u=m("input"),d=w(),g=m("button"),v=y("Blacklist"),b=w(),k=m("div"),$.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(a,"type","text"),I(a,"placeholder","Pubkey (64 hex chars)"),I(a,"class","svelte-1i0huu3"),I(u,"type","text"),I(u,"placeholder","Reason (optional)"),I(u,"class","svelte-1i0huu3"),g.disabled=e[1],I(g,"class","svelte-1i0huu3"),I(l,"class","add-form svelte-1i0huu3"),I(k,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),f(t,o),f(t,l),f(l,a),x(a,e[16]),f(l,c),f(l,u),x(u,e[17]),f(l,d),f(l,g),f(g,v),f(t,b),f(t,k),$.m(k,null),C||(E=[A(a,"input",e[63]),A(u,"input",e[64]),A(g,"click",e[65])],C=!0)},p(e,t){65536&t[0]&&a.value!==e[16]&&x(a,e[16]),131072&t[0]&&u.value!==e[17]&&x(u,e[17]),2&t[0]&&(g.disabled=e[1]),B===(B=S(e))&&$?$.p(e,t):($.d(1),$=B(e),$&&($.c(),$.m(k,null)))},d(e){e&&p(t),$.d(),C=!1,i(E)}}}function aI(t){let n;return{c(){n=m("div"),n.textContent="No blacklisted pubkeys.",I(n,"class","empty svelte-1i0huu3")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function cI(e){let t,n=e[15],i=[];for(let t=0;t<n.length;t+=1)i[t]=dI(Jk(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(268468224&s[0]|16&s[1]){let r;for(n=e[15],r=0;r<n.length;r+=1){const o=Jk(e,n,r);i[r]?i[r].p(o,s):(i[r]=dI(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function uI(e){let t,n,i=e[106].reason+"";return{c(){t=m("span"),n=y(i),I(t,"class","reason svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n)},p(e,t){32768&t[0]&&i!==(i=e[106].reason+"")&&E(n,i)},d(e){e&&p(t)}}}function dI(e){let t,n,s,r,o,l,a,c,u,d,g,v,b=GI(e[106].pubkey)+"",C=e[106].reason&&uI(e);function x(){return e[66](e[106])}function S(){return e[67](e[106])}return{c(){t=m("div"),n=m("div"),s=m("span"),r=y(b),l=w(),C&&C.c(),a=w(),c=m("div"),u=m("button"),u.textContent="Remove",d=w(),I(s,"class","pubkey svelte-1i0huu3"),I(s,"title",o=e[106].pubkey),I(n,"class","item-main svelte-1i0huu3"),I(u,"class","btn-success svelte-1i0huu3"),I(c,"class","item-actions svelte-1i0huu3"),I(t,"class","list-item clickable svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n),f(n,s),f(s,r),f(n,l),C&&C.m(n,null),f(t,a),f(t,c),f(c,u),f(t,d),g||(v=[A(u,"click",k(x)),A(t,"click",S)],g=!0)},p(t,i){e=t,32768&i[0]&&b!==(b=GI(e[106].pubkey)+"")&&E(r,b),32768&i[0]&&o!==(o=e[106].pubkey)&&I(s,"title",o),e[106].reason?C?C.p(e,i):(C=uI(e),C.c(),C.m(n,null)):C&&(C.d(1),C=null)},d(e){e&&p(t),C&&C.d(),g=!1,i(v)}}}function fI(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C;function E(e,t){return e[18].length>0?pI:hI}let x=E(e),S=x(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Unclassified Users",s=w(),r=m("p"),r.textContent="Users who have posted events but haven't been classified. Sorted by event count.",o=w(),l=m("div"),a=m("button"),c=y("Refresh"),u=w(),d=m("button"),g=y("Scan Database"),v=w(),b=m("div"),S.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(a,"class","refresh-btn svelte-1i0huu3"),a.disabled=e[1],I(d,"class","scan-btn svelte-1i0huu3"),d.disabled=e[1],I(l,"class","button-row svelte-1i0huu3"),I(b,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),f(t,o),f(t,l),f(l,a),f(a,c),f(l,u),f(l,d),f(d,g),f(t,v),f(t,b),S.m(b,null),k||(C=[A(a,"click",e[21]),A(d,"click",e[22])],k=!0)},p(e,t){2&t[0]&&(a.disabled=e[1]),2&t[0]&&(d.disabled=e[1]),x===(x=E(e))&&S?S.p(e,t):(S.d(1),S=x(e),S&&(S.c(),S.m(b,null)))},d(e){e&&p(t),S.d(),k=!1,i(C)}}}function hI(t){let n;return{c(){n=m("div"),n.textContent="No unclassified users.",I(n,"class","empty svelte-1i0huu3")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function pI(e){let t,n=e[18],i=[];for(let t=0;t<n.length;t+=1)i[t]=gI(Gk(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(168034304&s[0]|16&s[1]){let r;for(n=e[18],r=0;r<n.length;r+=1){const o=Gk(e,n,r);i[r]?i[r].p(o,s):(i[r]=gI(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function gI(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,C,x,S,B,$=GI(e[103].pubkey)+"",F=e[103].event_count+"";function D(){return e[68](e[103])}function Q(){return e[69](e[103])}function P(){return e[70](e[103])}return{c(){t=m("div"),n=m("div"),s=m("span"),r=y($),l=w(),a=m("span"),c=y(F),u=y(" events"),d=w(),g=m("div"),v=m("button"),v.textContent="Trust",b=w(),C=m("button"),C.textContent="Blacklist",x=w(),I(s,"class","pubkey svelte-1i0huu3"),I(s,"title",o=e[103].pubkey),I(a,"class","event-count svelte-1i0huu3"),I(n,"class","item-main svelte-1i0huu3"),I(v,"class","btn-success svelte-1i0huu3"),I(C,"class","btn-danger svelte-1i0huu3"),I(g,"class","item-actions svelte-1i0huu3"),I(t,"class","list-item clickable svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n),f(n,s),f(s,r),f(n,l),f(n,a),f(a,c),f(a,u),f(t,d),f(t,g),f(g,v),f(g,b),f(g,C),f(t,x),S||(B=[A(v,"click",k(D)),A(C,"click",k(Q)),A(t,"click",P)],S=!0)},p(t,n){e=t,262144&n[0]&&$!==($=GI(e[103].pubkey)+"")&&E(r,$),262144&n[0]&&o!==(o=e[103].pubkey)&&I(s,"title",o),262144&n[0]&&F!==(F=e[103].event_count+"")&&E(c,F)},d(e){e&&p(t),S=!1,i(B)}}}function mI(e){let t,n,i,s,r,o,l,a,c,u,d;function g(e,t){return e[19].length>0?yI:vI}let v=g(e),b=v(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Spam Events",i=w(),s=m("p"),s.textContent="Events flagged as spam are hidden from query results but remain in the database.",r=w(),o=m("button"),l=y("Refresh"),a=w(),c=m("div"),b.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],I(c,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(p,g){h(p,t,g),f(t,n),f(t,i),f(t,s),f(t,r),f(t,o),f(o,l),f(t,a),f(t,c),b.m(c,null),u||(d=A(o,"click",e[23]),u=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),v===(v=g(e))&&b?b.p(e,t):(b.d(1),b=v(e),b&&(b.c(),b.m(c,null)))},d(e){e&&p(t),b.d(),u=!1,d()}}}function vI(t){let n;return{c(){n=m("div"),n.textContent="No spam events flagged.",I(n,"class","empty svelte-1i0huu3")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function yI(e){let t,n=e[19],i=[];for(let t=0;t<n.length;t+=1)i[t]=bI(qk(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(1611137024&s[0]){let r;for(n=e[19],r=0;r<n.length;r+=1){const o=qk(e,n,r);i[r]?i[r].p(o,s):(i[r]=bI(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function wI(e){let t,n,i=e[93].reason+"";return{c(){t=m("span"),n=y(i),I(t,"class","reason svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n)},p(e,t){524288&t[0]&&i!==(i=e[93].reason+"")&&E(n,i)},d(e){e&&p(t)}}}function bI(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,F=GI(e[93].event_id)+"",D=GI(e[93].pubkey)+"",Q=e[93].reason&&wI(e);function P(){return e[71](e[93])}function R(){return e[72](e[93])}return{c(){t=m("div"),n=m("div"),s=m("span"),r=y(F),l=w(),a=m("span"),c=y("by "),u=y(D),g=w(),Q&&Q.c(),v=w(),b=m("div"),k=m("button"),k.textContent="Unmark",C=w(),x=m("button"),x.textContent="Delete",S=w(),I(s,"class","event-id svelte-1i0huu3"),I(s,"title",o=e[93].event_id),I(a,"class","pubkey svelte-1i0huu3"),I(a,"title",d=e[93].pubkey),I(n,"class","item-main svelte-1i0huu3"),I(k,"class","btn-success svelte-1i0huu3"),I(x,"class","btn-danger svelte-1i0huu3"),I(b,"class","item-actions svelte-1i0huu3"),I(t,"class","list-item svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n),f(n,s),f(s,r),f(n,l),f(n,a),f(a,c),f(a,u),f(n,g),Q&&Q.m(n,null),f(t,v),f(t,b),f(b,k),f(b,C),f(b,x),f(t,S),B||($=[A(k,"click",P),A(x,"click",R)],B=!0)},p(t,i){e=t,524288&i[0]&&F!==(F=GI(e[93].event_id)+"")&&E(r,F),524288&i[0]&&o!==(o=e[93].event_id)&&I(s,"title",o),524288&i[0]&&D!==(D=GI(e[93].pubkey)+"")&&E(u,D),524288&i[0]&&d!==(d=e[93].pubkey)&&I(a,"title",d),e[93].reason?Q?Q.p(e,i):(Q=wI(e),Q.c(),Q.m(n,null)):Q&&(Q.d(1),Q=null)},d(e){e&&p(t),Q&&Q.d(),B=!1,i($)}}}function AI(e){let t,n,i,s,r,o,l,a,c,u,d;function g(e,t){return e[20].length>0?II:kI}let v=g(e),b=v(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Blocked IP Addresses",i=w(),s=m("p"),s.textContent="IP addresses blocked due to rate limit violations.",r=w(),o=m("button"),l=y("Refresh"),a=w(),c=m("div"),b.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],I(c,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(p,g){h(p,t,g),f(t,n),f(t,i),f(t,s),f(t,r),f(t,o),f(o,l),f(t,a),f(t,c),b.m(c,null),u||(d=A(o,"click",e[24]),u=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),v===(v=g(e))&&b?b.p(e,t):(b.d(1),b=v(e),b&&(b.c(),b.m(c,null)))},d(e){e&&p(t),b.d(),u=!1,d()}}}function kI(t){let n;return{c(){n=m("div"),n.textContent="No blocked IPs.",I(n,"class","empty svelte-1i0huu3")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function II(e){let t,n=e[20],i=[];for(let t=0;t<n.length;t+=1)i[t]=xI(Hk(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(1048576&s[0]|1&s[1]){let r;for(n=e[20],r=0;r<n.length;r+=1){const o=Hk(e,n,r);i[r]?i[r].p(o,s):(i[r]=xI(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function CI(e){let t,n,i=e[98].reason+"";return{c(){t=m("span"),n=y(i),I(t,"class","reason svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n)},p(e,t){1048576&t[0]&&i!==(i=e[98].reason+"")&&E(n,i)},d(e){e&&p(t)}}}function EI(e){let t,n,i,s=JI(e[98].expires_at)+"";return{c(){t=m("span"),n=y("Expires: "),i=y(s),I(t,"class","expires svelte-1i0huu3")},m(e,s){h(e,t,s),f(t,n),f(t,i)},p(e,t){1048576&t[0]&&s!==(s=JI(e[98].expires_at)+"")&&E(i,s)},d(e){e&&p(t)}}}function xI(e){let t,n,i,s,r,o,l,a,c,u,d,g,v=e[98].ip+"",b=e[98].reason&&CI(e),k=e[98].expires_at&&EI(e);function C(){return e[73](e[98])}return{c(){t=m("div"),n=m("div"),i=m("span"),s=y(v),r=w(),b&&b.c(),o=w(),k&&k.c(),l=w(),a=m("div"),c=m("button"),c.textContent="Unblock",u=w(),I(i,"class","ip svelte-1i0huu3"),I(n,"class","item-main svelte-1i0huu3"),I(c,"class","btn-success svelte-1i0huu3"),I(a,"class","item-actions svelte-1i0huu3"),I(t,"class","list-item svelte-1i0huu3")},m(e,p){h(e,t,p),f(t,n),f(n,i),f(i,s),f(n,r),b&&b.m(n,null),f(n,o),k&&k.m(n,null),f(t,l),f(t,a),f(a,c),f(t,u),d||(g=A(c,"click",C),d=!0)},p(t,i){e=t,1048576&i[0]&&v!==(v=e[98].ip+"")&&E(s,v),e[98].reason?b?b.p(e,i):(b=CI(e),b.c(),b.m(n,o)):b&&(b.d(1),b=null),e[98].expires_at?k?k.p(e,i):(k=EI(e),k.c(),k.m(n,null)):k&&(k.d(1),k=null)},d(e){e&&p(t),b&&b.d(),k&&k.d(),d=!1,g()}}}function SI(e){let t,n,s,r,o,l,a,c,u,d,v,y,b,k,E,S,B,$,F,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K,V,W,Y=jk,Z=[];for(let t=0;t<Y.length;t+=1)Z[t]=BI(zk(e,Y,t));function X(e,t){return e[1]?FI:$I}let ee=X(e),te=ee(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Curating Configuration",s=w(),r=m("p"),r.textContent="Update curating mode settings. Changes will publish a new configuration event.",o=w(),l=m("div"),a=m("h4"),a.textContent="Allowed Event Kinds",c=w(),u=m("div");for(let e=0;e<Z.length;e+=1)Z[e].c();d=w(),v=m("div"),y=m("label"),y.textContent="Custom Kinds",b=w(),k=m("input"),E=w(),S=m("div"),B=m("h4"),B.textContent="Rate Limiting",$=w(),F=m("div"),D=m("div"),Q=m("label"),Q.textContent="Daily Event Limit",P=w(),R=m("input"),T=w(),L=m("div"),_=m("div"),N=m("label"),N.textContent="First Ban (hours)",M=w(),U=m("input"),O=w(),j=m("div"),z=m("label"),z.textContent="Second+ Ban (hours)",H=w(),q=m("input"),G=w(),J=m("div"),K=m("button"),te.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(a,"class","svelte-1i0huu3"),I(u,"class","category-grid svelte-1i0huu3"),I(y,"for","custom-kinds-edit"),I(y,"class","svelte-1i0huu3"),I(k,"id","custom-kinds-edit"),I(k,"type","text"),I(k,"placeholder","e.g., 100, 200-250, 500"),I(k,"class","svelte-1i0huu3"),I(v,"class","custom-kinds svelte-1i0huu3"),I(l,"class","config-section svelte-1i0huu3"),I(B,"class","svelte-1i0huu3"),I(Q,"for","daily-limit-edit"),I(Q,"class","svelte-1i0huu3"),I(R,"id","daily-limit-edit"),I(R,"type","number"),I(R,"min","1"),I(R,"class","svelte-1i0huu3"),I(D,"class","form-group svelte-1i0huu3"),I(F,"class","form-row svelte-1i0huu3"),I(N,"for","first-ban-edit"),I(N,"class","svelte-1i0huu3"),I(U,"id","first-ban-edit"),I(U,"type","number"),I(U,"min","1"),I(U,"class","svelte-1i0huu3"),I(_,"class","form-group svelte-1i0huu3"),I(z,"for","second-ban-edit"),I(z,"class","svelte-1i0huu3"),I(q,"id","second-ban-edit"),I(q,"type","number"),I(q,"min","1"),I(q,"class","svelte-1i0huu3"),I(j,"class","form-group svelte-1i0huu3"),I(L,"class","form-row svelte-1i0huu3"),I(S,"class","config-section svelte-1i0huu3"),I(K,"class","publish-btn svelte-1i0huu3"),K.disabled=e[1],I(J,"class","publish-section svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),f(t,o),f(t,l),f(l,a),f(l,c),f(l,u);for(let e=0;e<Z.length;e+=1)Z[e]&&Z[e].m(u,null);f(l,d),f(l,v),f(v,y),f(v,b),f(v,k),x(k,e[11].custom_kinds),f(t,E),f(t,S),f(S,B),f(S,$),f(S,F),f(F,D),f(D,Q),f(D,P),f(D,R),x(R,e[11].daily_limit),f(S,T),f(S,L),f(L,_),f(_,N),f(_,M),f(_,U),x(U,e[11].first_ban_hours),f(L,O),f(L,j),f(j,z),f(j,H),f(j,q),x(q,e[11].second_ban_hours),f(t,G),f(t,J),f(J,K),te.m(K,null),V||(W=[A(k,"input",e[75]),A(R,"input",e[76]),A(U,"input",e[77]),A(q,"input",e[78]),A(K,"click",e[34])],V=!0)},p(e,t){if(2048&t[0]|2&t[1]){let n;for(Y=jk,n=0;n<Y.length;n+=1){const i=zk(e,Y,n);Z[n]?Z[n].p(i,t):(Z[n]=BI(i),Z[n].c(),Z[n].m(u,null))}for(;n<Z.length;n+=1)Z[n].d(1);Z.length=Y.length}2048&t[0]&&k.value!==e[11].custom_kinds&&x(k,e[11].custom_kinds),2048&t[0]&&C(R.value)!==e[11].daily_limit&&x(R,e[11].daily_limit),2048&t[0]&&C(U.value)!==e[11].first_ban_hours&&x(U,e[11].first_ban_hours),2048&t[0]&&C(q.value)!==e[11].second_ban_hours&&x(q,e[11].second_ban_hours),ee!==(ee=X(e))&&(te.d(1),te=ee(e),te&&(te.c(),te.m(K,null))),2&t[0]&&(K.disabled=e[1])},d(e){e&&p(t),g(Z,e),te.d(),V=!1,i(W)}}}function BI(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,k=e[90].name+"",C=e[90].kinds.join(", ")+"";function E(){return e[74](e[90])}return{c(){t=m("label"),n=m("input"),s=w(),r=m("div"),o=m("span"),l=y(k),a=w(),c=m("span"),u=y("Kinds: "),d=y(C),g=w(),I(n,"type","checkbox"),n.checked=i=e[11].categories.includes(e[90].id),I(n,"class","svelte-1i0huu3"),I(o,"class","category-name svelte-1i0huu3"),I(c,"class","category-kinds svelte-1i0huu3"),I(r,"class","category-info svelte-1i0huu3"),I(t,"class","category-item svelte-1i0huu3"),F(t,"selected",e[11].categories.includes(e[90].id))},m(e,i){h(e,t,i),f(t,n),f(t,s),f(t,r),f(r,o),f(o,l),f(r,a),f(r,c),f(c,u),f(c,d),f(t,g),v||(b=A(n,"change",E),v=!0)},p(s,r){e=s,2048&r[0]&&i!==(i=e[11].categories.includes(e[90].id))&&(n.checked=i),2048&r[0]&&F(t,"selected",e[11].categories.includes(e[90].id))},d(e){e&&p(t),v=!1,b()}}}function $I(e){let t;return{c(){t=y("Update Configuration")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function FI(e){let t;return{c(){t=y("Updating...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function DI(t){let n,s,r,o,l;return{c(){n=m("button"),n.textContent="Trust",s=w(),r=m("button"),r.textContent="Blacklist",I(n,"class","btn-success svelte-1i0huu3"),I(r,"class","btn-danger svelte-1i0huu3")},m(e,i){h(e,n,i),h(e,s,i),h(e,r,i),o||(l=[A(n,"click",t[39]),A(r,"click",t[40])],o=!0)},p:e,d(e){e&&p(n),e&&p(s),e&&p(r),o=!1,i(l)}}}function QI(e){let t,n,s,r,o,l,a,c,u;return{c(){t=m("button"),n=y("Delete All Events"),r=w(),o=m("button"),o.textContent="Remove from Blacklist",l=w(),a=m("button"),a.textContent="Trust",I(t,"class","btn-delete-all svelte-1i0huu3"),t.disabled=s=e[1]||0===e[8],I(o,"class","btn-success svelte-1i0huu3"),I(a,"class","btn-success svelte-1i0huu3")},m(i,s){h(i,t,s),f(t,n),h(i,r,s),h(i,o,s),h(i,l,s),h(i,a,s),c||(u=[A(t,"click",e[43]),A(o,"click",e[42]),A(a,"click",e[39])],c=!0)},p(e,n){258&n[0]&&s!==(s=e[1]||0===e[8])&&(t.disabled=s)},d(e){e&&p(t),e&&p(r),e&&p(o),e&&p(l),e&&p(a),c=!1,i(u)}}}function PI(t){let n,s,r,o,l;return{c(){n=m("button"),n.textContent="Remove Trust",s=w(),r=m("button"),r.textContent="Blacklist",I(n,"class","btn-danger svelte-1i0huu3"),I(r,"class","btn-danger svelte-1i0huu3")},m(e,i){h(e,n,i),h(e,s,i),h(e,r,i),o||(l=[A(n,"click",t[41]),A(r,"click",t[40])],o=!0)},p:e,d(e){e&&p(n),e&&p(s),e&&p(r),o=!1,i(l)}}}function RI(e){let t,n,i=e[7],s=[];for(let t=0;t<i.length;t+=1)s[t]=UI(Vk(e,i,t));let r=e[7].length<e[8]&&OI(e);return{c(){for(let e=0;e<s.length;e+=1)s[e].c();t=w(),r&&r.c(),n=b()},m(e,i){for(let t=0;t<s.length;t+=1)s[t]&&s[t].m(e,i);h(e,t,i),r&&r.m(e,i),h(e,n,i)},p(e,o){if(1152&o[0]|128&o[1]){let n;for(i=e[7],n=0;n<i.length;n+=1){const r=Vk(e,i,n);s[n]?s[n].p(r,o):(s[n]=UI(r),s[n].c(),s[n].m(t.parentNode,t))}for(;n<s.length;n+=1)s[n].d(1);s.length=i.length}e[7].length<e[8]?r?r.p(e,o):(r=OI(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},d(e){g(s,e),e&&p(t),r&&r.d(e),e&&p(n)}}}function TI(t){let n;return{c(){n=m("div"),n.textContent="No events found for this user.",I(n,"class","empty svelte-1i0huu3")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function LI(t){let n;return{c(){n=m("div"),n.textContent="Loading events...",I(n,"class","loading svelte-1i0huu3")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function _I(e){let t,n,i,s=KI(e[93].content)+"";return{c(){t=m("pre"),n=y(s),i=y("..."),I(t,"class","svelte-1i0huu3")},m(e,s){h(e,t,s),f(t,n),f(t,i)},p(e,t){128&t[0]&&s!==(s=KI(e[93].content)+"")&&E(n,s)},d(e){e&&p(t)}}}function NI(e){let t,n,i=(e[93].content||"(empty)")+"";return{c(){t=m("pre"),n=y(i),I(t,"class","svelte-1i0huu3")},m(e,i){h(e,t,i),f(t,n)},p(e,t){128&t[0]&&i!==(i=(e[93].content||"(empty)")+"")&&E(n,i)},d(e){e&&p(t)}}}function MI(e){let t,n,i,s,r=e[10][e[93].id]?"Show less":"Show more";function o(){return e[51](e[93])}return{c(){t=m("button"),n=y(r),I(t,"class","expand-btn svelte-1i0huu3")},m(e,r){h(e,t,r),f(t,n),i||(s=A(t,"click",o),i=!0)},p(t,i){e=t,1152&i[0]&&r!==(r=e[10][e[93].id]?"Show less":"Show more")&&E(n,r)},d(e){e&&p(t),i=!1,s()}}}function UI(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,A,k=WI(e[93].kind)+"",C=GI(e[93].id)+"",x=JI(1e3*e[93].created_at)+"",S=VI(e[93].content);function B(e,t){return 1152&t[0]&&(b=null),null==b&&(b=!(!e[10][e[93].id]&&VI(e[93].content))),b?NI:_I}let $=B(e,[-1,-1,-1,-1]),D=$(e),Q=S&&MI(e);return{c(){t=m("div"),n=m("div"),i=m("span"),s=y(k),r=w(),o=m("span"),l=y(C),c=w(),u=m("span"),d=y(x),g=w(),v=m("div"),D.c(),A=w(),Q&&Q.c(),I(i,"class","event-kind svelte-1i0huu3"),I(o,"class","event-id svelte-1i0huu3"),I(o,"title",a=e[93].id),I(u,"class","event-time svelte-1i0huu3"),I(n,"class","event-header svelte-1i0huu3"),I(v,"class","event-content svelte-1i0huu3"),F(v,"expanded",e[10][e[93].id]),I(t,"class","event-item svelte-1i0huu3")},m(e,a){h(e,t,a),f(t,n),f(n,i),f(i,s),f(n,r),f(n,o),f(o,l),f(n,c),f(n,u),f(u,d),f(t,g),f(t,v),D.m(v,null),f(t,A),Q&&Q.m(t,null)},p(e,n){128&n[0]&&k!==(k=WI(e[93].kind)+"")&&E(s,k),128&n[0]&&C!==(C=GI(e[93].id)+"")&&E(l,C),128&n[0]&&a!==(a=e[93].id)&&I(o,"title",a),128&n[0]&&x!==(x=JI(1e3*e[93].created_at)+"")&&E(d,x),$===($=B(e,n))&&D?D.p(e,n):(D.d(1),D=$(e),D&&(D.c(),D.m(v,null))),1152&n[0]&&F(v,"expanded",e[10][e[93].id]),128&n[0]&&(S=VI(e[93].content)),S?Q?Q.p(e,n):(Q=MI(e),Q.c(),Q.m(t,null)):Q&&(Q.d(1),Q=null)},d(e){e&&p(t),D.d(),Q&&Q.d()}}}function OI(e){let t,n,i,s,r,o=e[9]?"Loading...":`Load more (${e[7].length} of ${e[8]})`;return{c(){t=m("div"),n=m("button"),i=y(o),n.disabled=e[9],I(n,"class","svelte-1i0huu3"),I(t,"class","load-more svelte-1i0huu3")},m(o,l){h(o,t,l),f(t,n),f(n,i),s||(r=A(n,"click",e[37]),s=!0)},p(e,t){896&t[0]&&o!==(o=e[9]?"Loading...":`Load more (${e[7].length} of ${e[8]})`)&&E(i,o),512&t[0]&&(n.disabled=e[9])},d(e){e&&p(t),s=!1,r()}}}function jI(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,k,C,E,x=e[90].name+"",S=e[90].description+"",B=e[90].kinds.join(", ")+"";function $(){return e[46](e[90])}return{c(){t=m("label"),n=m("input"),s=w(),r=m("div"),o=m("span"),l=y(x),a=w(),c=m("span"),u=y(S),d=w(),g=m("span"),v=y("Kinds: "),b=y(B),k=w(),I(n,"type","checkbox"),n.checked=i=e[11].categories.includes(e[90].id),I(n,"class","svelte-1i0huu3"),I(o,"class","category-name svelte-1i0huu3"),I(c,"class","category-desc svelte-1i0huu3"),I(g,"class","category-kinds svelte-1i0huu3"),I(r,"class","category-info svelte-1i0huu3"),I(t,"class","category-item svelte-1i0huu3"),F(t,"selected",e[11].categories.includes(e[90].id))},m(e,i){h(e,t,i),f(t,n),f(t,s),f(t,r),f(r,o),f(o,l),f(r,a),f(r,c),f(c,u),f(r,d),f(r,g),f(g,v),f(g,b),f(t,k),C||(E=A(n,"change",$),C=!0)},p(s,r){e=s,2048&r[0]&&i!==(i=e[11].categories.includes(e[90].id))&&(n.checked=i),2048&r[0]&&F(t,"selected",e[11].categories.includes(e[90].id))},d(e){e&&p(t),C=!1,E()}}}function zI(e){let t;return{c(){t=y("Publish Configuration")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function HI(e){let t;return{c(){t=y("Publishing...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function qI(t){let n,i,s,r,o=t[2]&&Yk(t);function l(e,t){return e[4]?Zk:Xk}let a=l(t),c=a(t);return{c(){n=m("div"),i=m("h2"),i.textContent="Curation Mode",s=w(),o&&o.c(),r=w(),c.c(),I(i,"class","svelte-1i0huu3"),I(n,"class","curation-view svelte-1i0huu3")},m(e,t){h(e,n,t),f(n,i),f(n,s),o&&o.m(n,null),f(n,r),c.m(n,null)},p(e,t){e[2]?o?o.p(e,t):(o=Yk(e),o.c(),o.m(n,r)):o&&(o.d(1),o=null),a===(a=l(e))&&c?c.p(e,t):(c.d(1),c=a(e),c&&(c.c(),c.m(n,null)))},i:e,o:e,d(e){e&&p(n),o&&o.d(),c.d()}}}function GI(e){return!e||e.length<16?e:`${e.slice(0,8)}...${e.slice(-8)}`}function JI(e){return e?new Date(e).toLocaleString():""}function KI(e,t=6){if(!e)return"";const n=e.split("\n");if(n.length<=t&&e.length<=100*t)return e;let i=n.slice(0,t).join("\n");return i.length>100*t&&(i=i.substring(0,100*t)),i}function VI(e,t=6){if(!e)return!1;return e.split("\n").length>t||e.length>100*t}function WI(e){return{0:"Metadata",1:"Text Note",3:"Follow List",4:"Encrypted DM",6:"Repost",7:"Reaction",14:"Chat Message",16:"Order Message",17:"Payment Receipt",1063:"File Metadata",10002:"Relay List",30017:"Stall",30018:"Product (NIP-15)",30023:"Long-form",30078:"App Data",30402:"Product (NIP-99)",30405:"Collection",30406:"Shipping",31555:"Review"}[e]||`Kind ${e}`}function YI(e,t,n){let{userSigner:i}=t,{userPubkey:s}=t,r="trusted",o=!1,l="",a="info",c=!1,u=null,d=null,f=[],h=0,p=0,g=!1,m={},v={daily_limit:50,first_ban_hours:1,second_ban_hours:168,categories:[],custom_kinds:"",kind_ranges:[]},y=[],w="",b="",A=[],k="",I="",E=[],x=[],S=[];async function B(e,t=[]){try{n(1,o=!0),n(2,l="");const r={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available. Please log in with a Nostr extension.");if(!s)throw new Error("No user pubkey available.");const n=Lh()+t,r={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:s},o=await i.signEvent(r);return`Nostr ${btoa(JSON.stringify(o))}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(r)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(2,l=e.message),n(3,a="error"),e}finally{n(1,o=!1)}}async function $(){await Promise.all([F(),D(),Q(),P(),T()])}async function F(){try{n(12,y=await B("listtrustedpubkeys"))}catch(e){console.error("Failed to load trusted pubkeys:",e),n(12,y=[])}}async function D(){try{n(15,A=await B("listblacklistedpubkeys"))}catch(e){console.error("Failed to load blacklisted pubkeys:",e),n(15,A=[])}}async function Q(){try{n(18,E=await B("listunclassifiedusers"))}catch(e){console.error("Failed to load unclassified users:",e),n(18,E=[])}}async function P(){try{n(19,x=await B("listspamevents"))}catch(e){console.error("Failed to load spam events:",e),n(19,x=[])}}async function T(){try{n(20,S=await B("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e),n(20,S=[])}}async function L(e=null,t=""){const i=e||w,s=e?t:b;if(i)try{await B("trustpubkey",[i,s]),n(2,l="Pubkey trusted successfully"),n(3,a="success"),n(13,w=""),n(14,b=""),await F(),await Q()}catch(e){console.error("Failed to trust pubkey:",e)}}async function _(e){try{await B("untrustpubkey",[e]),n(2,l="Pubkey untrusted"),n(3,a="success"),await F()}catch(e){console.error("Failed to untrust pubkey:",e)}}async function N(e=null,t=""){const i=e||k,s=e?t:I;if(i)try{await B("blacklistpubkey",[i,s]),n(2,l="Pubkey blacklisted"),n(3,a="success"),n(16,k=""),n(17,I=""),await D(),await Q()}catch(e){console.error("Failed to blacklist pubkey:",e)}}async function M(e){try{await B("unblacklistpubkey",[e]),n(2,l="Pubkey removed from blacklist"),n(3,a="success"),await D()}catch(e){console.error("Failed to remove from blacklist:",e)}}async function U(e){try{await B("unmarkspam",[e]),n(2,l="Spam mark removed"),n(3,a="success"),await P()}catch(e){console.error("Failed to unmark spam:",e)}}async function O(e){if(confirm("Permanently delete this event?"))try{await B("deleteevent",[e]),n(2,l="Event deleted"),n(3,a="success"),await P()}catch(e){console.error("Failed to delete event:",e)}}async function j(e){try{await B("unblockip",[e]),n(2,l="IP unblocked"),n(3,a="success"),await T()}catch(e){console.error("Failed to unblock IP:",e)}}function z(e){v.categories.includes(e)?n(11,v.categories=v.categories.filter(t=>t!==e),v):n(11,v.categories=[...v.categories,e],v)}async function H(){if(!i||!s)return n(2,l="Please log in with a Nostr extension to publish configuration"),void n(3,a="error");if(0===v.categories.length&&!v.custom_kinds.trim())return n(2,l="Please select at least one kind category or enter custom kinds"),void n(3,a="error");try{n(1,o=!0),n(2,l="");const e=[["d","curating-config"],["daily_limit",String(v.daily_limit)],["first_ban_hours",String(v.first_ban_hours)],["second_ban_hours",String(v.second_ban_hours)]];for(const t of v.categories)e.push(["kind_category",t]);const t=function(e){if(!e||!e.trim())return[];const t=new Set,n=e.split(",").map(e=>e.trim());for(const e of n)if(e)if(e.includes("-")){const[n,i]=e.split("-").map(e=>parseInt(e.trim(),10));if(!isNaN(n)&&!isNaN(i)&&n<=i&&i-n<=1e3)for(let e=n;e<=i;e++)t.add(e)}else{const n=parseInt(e,10);isNaN(n)||t.add(n)}return Array.from(t).sort((e,t)=>e-t)}(v.custom_kinds);for(const n of t)e.push(["kind",String(n)]);const r={kind:30078,created_at:Math.floor(Date.now()/1e3),tags:e,content:"Curating relay configuration",pubkey:s},u=await i.signEvent(r),d=new WebSocket(_h());await new Promise((e,t)=>{d.onopen=()=>{d.send(JSON.stringify(["EVENT",u]))},d.onmessage=n=>{const i=JSON.parse(n.data);"OK"===i[0]&&(!0===i[2]?e():t(new Error(i[3]||"Event rejected")))},d.onerror=e=>t(new Error("WebSocket error")),setTimeout(()=>t(new Error("Timeout")),1e4)}),d.close(),n(2,l="Configuration published successfully"),n(3,a="success"),n(4,c=!0),await $()}catch(e){console.error("Failed to publish configuration:",e),n(2,l=`Failed to publish: ${e.message}`),n(3,a="error")}finally{n(1,o=!1)}}function q(e,t="info"){n(2,l=e),n(3,a=t)}async function G(e,t){console.log("openUserDetail called:",e,t),n(5,u=e),n(6,d=t),n(7,f=[]),n(8,h=0),p=0,n(10,m={}),console.log("selectedUser set to:",u),await K()}function J(){n(5,u=null),n(6,d=null),n(7,f=[]),n(8,h=0),p=0,n(10,m={})}async function K(){if(console.log("loadUserEvents called, selectedUser:",u,"loadingEvents:",g),u&&!g)try{n(9,g=!0),console.log("Calling geteventsforpubkey API...");const e=await B("geteventsforpubkey",[u,100,p]);console.log("API result:",e),e&&(n(7,f=0===p?e.events||[]:[...f,...e.events||[]]),n(8,h=e.total||0))}catch(e){console.error("Failed to load user events:",e),q("Failed to load events: "+e.message,"error")}finally{n(9,g=!1)}}function V(e){n(10,m={...m,[e]:!m[e]})}R(async()=>{await async function(){try{const e=await B("isconfigured");n(4,c=!0===e),c&&(await async function(){try{const e=await B("getcuratingconfig");e&&n(11,v={daily_limit:e.daily_limit||50,first_ban_hours:e.first_ban_hours||1,second_ban_hours:e.second_ban_hours||168,categories:e.categories||[],custom_kinds:e.custom_kinds?e.custom_kinds.join(", "):"",kind_ranges:e.kind_ranges||[]})}catch(e){console.error("Failed to load config:",e)}}(),await $())}catch(e){console.error("Failed to check configuration:",e),n(4,c=!1)}}()});return e.$$set=e=>{"userSigner"in e&&n(44,i=e.userSigner),"userPubkey"in e&&n(45,s=e.userPubkey)},[r,o,l,a,c,u,d,f,h,g,m,v,y,w,b,A,k,I,E,x,S,Q,async function(){try{const e=await B("scanpubkeys");q(`Database scanned: ${e.total_pubkeys} pubkeys, ${e.total_events} events (${e.skipped} skipped)`,"success"),await Q()}catch(e){console.error("Failed to scan database:",e),q("Failed to scan database: "+e.message,"error")}},P,T,L,_,N,M,U,O,j,z,H,async function(){await H()},G,J,async function(){p=f.length,await K()},V,async function(){await L(u,""),await $(),J()},async function(){await N(u,""),await $(),J()},async function(){await _(u),await $(),J()},async function(){await M(u),await $(),J()},async function(){if(confirm(`Delete ALL ${h} events from this user? This cannot be undone.`))try{n(1,o=!0);q(`Deleted ${(await B("deleteeventsforpubkey",[u])).deleted} events`,"success"),n(7,f=[]),n(8,h=0),p=0,await K()}catch(e){console.error("Failed to delete events:",e),q("Failed to delete events: "+e.message,"error")}finally{n(1,o=!1)}},i,s,e=>z(e.id),function(){v.custom_kinds=this.value,n(11,v)},function(){v.daily_limit=C(this.value),n(11,v)},function(){v.first_ban_hours=C(this.value),n(11,v)},function(){v.second_ban_hours=C(this.value),n(11,v)},e=>V(e.id),()=>n(0,r="trusted"),()=>n(0,r="blacklist"),()=>n(0,r="unclassified"),()=>n(0,r="spam"),()=>n(0,r="ips"),()=>n(0,r="settings"),function(){w=this.value,n(13,w)},function(){b=this.value,n(14,b)},()=>L(),e=>_(e.pubkey),e=>G(e.pubkey,"trusted"),function(){k=this.value,n(16,k)},function(){I=this.value,n(17,I)},()=>N(),e=>M(e.pubkey),e=>G(e.pubkey,"blacklisted"),e=>L(e.pubkey,""),e=>N(e.pubkey,""),e=>G(e.pubkey,"unclassified"),e=>U(e.event_id),e=>O(e.event_id),e=>j(e.ip),e=>z(e.id),function(){v.custom_kinds=this.value,n(11,v)},function(){v.daily_limit=C(this.value),n(11,v)},function(){v.first_ban_hours=C(this.value),n(11,v)},function(){v.second_ban_hours=C(this.value),n(11,v)}]}class ZI extends fe{constructor(e){super(),de(this,e,YI,qI,r,{userSigner:44,userPubkey:45},null,[-1,-1,-1,-1])}}class XI{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,i,s]=n;e&&i?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!i&&(console.error("Authentication failed:",s),this.authPromise&&(this.authPromise.reject(new Error(s||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const i=["EVENT",e];this.ws.send(JSON.stringify(i));const s=this.ws.onmessage,r=setTimeout(()=>{this.ws.onmessage=s,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async i=>{try{const o=JSON.parse(i.data),[l,a,c,u]=o;if("OK"===l&&a===e.id)if(c)clearTimeout(r),this.ws.onmessage=s,console.log("Event published successfully:",a),t({success:!0,eventId:a,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required"))return void console.log("Authentication required, waiting for AUTH challenge...");clearTimeout(r),this.ws.onmessage=s,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===l){this.challenge=o[1],console.log("Received AUTH challenge during publish:",this.challenge);try{await this.authenticate(),console.log("Authentication successful, retrying event publish...");const t=["EVENT",e];this.ws.send(JSON.stringify(t))}catch(e){clearTimeout(r),this.ws.onmessage=s,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(o)}catch(e){clearTimeout(r),this.ws.onmessage=s,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function eC(e,t,n,i){const s=new XI(e,n,i);try{await s.connect();return await s.publishEvent(t)}finally{s.close()}}function tC(e,t,n){const i=e.slice();return i[103]=t[n],i}function nC(e,t,n){const i=e.slice();return i[109]=t[n],i}function iC(e,t,n){const i=e.slice();return i[106]=t[n],i}function sC(t){let n,i,s,r,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to view your Blossom storage.",s=w(),r=m("button"),r.textContent="Log In",I(i,"class","svelte-1lyqnmz"),I(r,"class","login-btn svelte-1lyqnmz"),I(n,"class","login-prompt svelte-1lyqnmz")},m(e,a){h(e,n,a),f(n,i),f(n,s),f(n,r),o||(l=A(r,"click",t[38]),o=!0)},p:e,d(e){e&&p(n),o=!1,l()}}}function rC(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,k,C=e[0]||e[22]?"Loading...":"Refresh";function x(e,t){return e[1]?aC:e[20]?lC:oC}let S=x(e),B=S(e),$=(!e[20]||e[1])&&uC(e),F=e[29]&&!e[20]&&!e[1]&&fC(e),D=!e[20]&&!e[1]&&hC(e),Q=e[7]&&gC(e);function P(e,t){return e[20]&&!e[1]?vC:mC}let R=P(e),T=R(e);return{c(){t=m("div"),n=m("div"),B.c(),i=w(),s=m("div"),$&&$.c(),r=w(),F&&F.c(),o=w(),l=m("button"),a=y("🔄 "),c=y(C),d=w(),D&&D.c(),g=w(),Q&&Q.c(),v=w(),T.c(),I(l,"class","refresh-btn svelte-1lyqnmz"),l.disabled=u=e[0]||e[22],I(s,"class","header-buttons svelte-1lyqnmz"),I(n,"class","header-section svelte-1lyqnmz"),I(t,"class","blossom-view svelte-1lyqnmz")},m(u,p){h(u,t,p),f(t,n),B.m(n,null),f(n,i),f(n,s),$&&$.m(s,null),f(s,r),F&&F.m(s,null),f(s,o),f(s,l),f(l,a),f(l,c),f(t,d),D&&D.m(t,null),f(t,g),Q&&Q.m(t,null),f(t,v),T.m(t,null),b||(k=A(l,"click",e[49]),b=!0)},p(e,a){S===(S=x(e))&&B?B.p(e,a):(B.d(1),B=S(e),B&&(B.c(),B.m(n,i))),!e[20]||e[1]?$?$.p(e,a):($=uC(e),$.c(),$.m(s,r)):$&&($.d(1),$=null),!e[29]||e[20]||e[1]?F&&(F.d(1),F=null):F?F.p(e,a):(F=fC(e),F.c(),F.m(s,o)),4194305&a[0]&&C!==(C=e[0]||e[22]?"Loading...":"Refresh")&&E(c,C),4194305&a[0]&&u!==(u=e[0]||e[22])&&(l.disabled=u),e[20]||e[1]?D&&(D.d(1),D=null):D?D.p(e,a):(D=hC(e),D.c(),D.m(t,g)),e[7]?Q?Q.p(e,a):(Q=gC(e),Q.c(),Q.m(t,v)):Q&&(Q.d(1),Q=null),R===(R=P(e))&&T?T.p(e,a):(T.d(1),T=R(e),T&&(T.c(),T.m(t,null)))},d(e){e&&p(t),B.d(),$&&$.d(),F&&F.d(),D&&D.d(),Q&&Q.d(),T.d(),b=!1,k()}}}function oC(t){let n;return{c(){n=m("h3"),n.textContent="Blossom Media Storage",I(n,"class","svelte-1lyqnmz")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function lC(t){let n,i,s,r,o;return{c(){n=m("button"),n.textContent="← Back",i=w(),s=m("h3"),s.textContent="All Users Storage",I(n,"class","back-btn svelte-1lyqnmz"),I(s,"class","svelte-1lyqnmz")},m(e,l){h(e,n,l),h(e,i,l),h(e,s,l),r||(o=A(n,"click",t[46]),r=!0)},p:e,d(e){e&&p(n),e&&p(i),e&&p(s),r=!1,o()}}}function aC(e){let t,n,i,s,r,o,l,a=(e[1].profile?.name||aE(e[44](e[1].pubkey)))+"",c=e[1].profile?.picture&&cC(e);return{c(){t=m("button"),t.textContent="← Back",n=w(),i=m("h3"),c&&c.c(),s=w(),r=y(a),I(t,"class","back-btn svelte-1lyqnmz"),I(i,"class","user-header svelte-1lyqnmz")},m(a,u){h(a,t,u),h(a,n,u),h(a,i,u),c&&c.m(i,null),f(i,s),f(i,r),o||(l=A(t,"click",e[48]),o=!0)},p(e,t){e[1].profile?.picture?c?c.p(e,t):(c=cC(e),c.c(),c.m(i,s)):c&&(c.d(1),c=null),2&t[0]&&a!==(a=(e[1].profile?.name||aE(e[44](e[1].pubkey)))+"")&&E(r,a)},d(e){e&&p(t),e&&p(n),e&&p(i),c&&c.d(),o=!1,l()}}}function cC(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[1].profile.picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","header-avatar svelte-1lyqnmz")},m(e,n){h(e,t,n)},p(e,i){2&i[0]&&!l(t.src,n=e[1].profile.picture)&&I(t,"src",n)},d(e){e&&p(t)}}}function uC(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k="date"===e[2]?"desc"===e[3]?"↓":"↑":"",C="size"===e[2]?"desc"===e[3]?"↓":"↑":"",x="desc"===e[3]?"↓":"↑",S=e[5].size>0&&dC(e);return{c(){S&&S.c(),t=w(),n=m("select"),s=m("option"),r=y("Date "),o=y(k),l=m("option"),a=y("Size "),c=y(C),u=w(),d=m("button"),g=y(x),s.__value="date",s.value=s.__value,l.__value="size",l.value=l.__value,I(n,"class","sort-select svelte-1lyqnmz"),void 0===e[2]&&G(()=>e[69].call(n)),I(d,"class","sort-order-btn svelte-1lyqnmz"),I(d,"title","Toggle sort order")},m(i,p){S&&S.m(i,p),h(i,t,p),h(i,n,p),f(n,s),f(s,r),f(s,o),f(n,l),f(l,a),f(l,c),B(n,e[2],!0),h(i,u,p),h(i,d,p),f(d,g),v||(b=[A(n,"change",e[69]),A(d,"click",e[70])],v=!0)},p(e,i){e[5].size>0?S?S.p(e,i):(S=dC(e),S.c(),S.m(t.parentNode,t)):S&&(S.d(1),S=null),12&i[0]&&k!==(k="date"===e[2]?"desc"===e[3]?"↓":"↑":"")&&E(o,k),12&i[0]&&C!==(C="size"===e[2]?"desc"===e[3]?"↓":"↑":"")&&E(c,C),4&i[0]&&B(n,e[2]),8&i[0]&&x!==(x="desc"===e[3]?"↓":"↑")&&E(g,x)},d(e){S&&S.d(e),e&&p(t),e&&p(n),e&&p(u),e&&p(d),v=!1,i(b)}}}function dC(e){let t,n,i,s,r=e[25]?"Deleting...":`Delete Selected (${e[5].size})`;return{c(){t=m("button"),n=y(r),I(t,"class","delete-selected-btn svelte-1lyqnmz"),t.disabled=e[25]},m(r,o){h(r,t,o),f(t,n),i||(s=A(t,"click",e[51]),i=!0)},p(e,i){33554464&i[0]&&r!==(r=e[25]?"Deleting...":`Delete Selected (${e[5].size})`)&&E(n,r),33554432&i[0]&&(t.disabled=e[25])},d(e){e&&p(t),i=!1,s()}}}function fC(e){let t,n,i,s;return{c(){t=m("button"),n=y("Admin"),I(t,"class","admin-btn svelte-1lyqnmz"),t.disabled=e[0]},m(r,o){h(r,t,o),f(t,n),i||(s=A(t,"click",e[45]),i=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&p(t),i=!1,s()}}}function hC(e){let t,n,s,r,o,l,a,c,u,d,g=e[8].length>0&&pC(e);return{c(){t=m("div"),n=m("span"),n.textContent="Upload new files",s=w(),r=m("input"),o=w(),g&&g.c(),l=w(),a=m("button"),c=y("Select Files"),I(n,"class","upload-label svelte-1lyqnmz"),I(r,"type","file"),r.multiple=!0,I(r,"class","file-input-hidden svelte-1lyqnmz"),I(a,"class","select-btn svelte-1lyqnmz"),a.disabled=e[9],I(t,"class","upload-section svelte-1lyqnmz")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),e[71](r),f(t,o),g&&g.m(t,null),f(t,l),f(t,a),f(a,c),u||(d=[A(r,"change",e[41]),A(a,"click",e[42])],u=!0)},p(e,n){e[8].length>0?g?g.p(e,n):(g=pC(e),g.c(),g.m(t,l)):g&&(g.d(1),g=null),512&n[0]&&(a.disabled=e[9])},d(n){n&&p(t),e[71](null),g&&g.d(),u=!1,i(d)}}}function pC(e){let t,n,i,s,r,o,l,a,c=e[8].length+"",u=(e[9]?e[10]:"Upload")+"";return{c(){t=m("span"),n=y(c),i=y(" file(s) selected"),s=w(),r=m("button"),o=y(u),I(t,"class","selected-count svelte-1lyqnmz"),I(r,"class","upload-btn svelte-1lyqnmz"),r.disabled=e[9]},m(c,u){h(c,t,u),f(t,n),f(t,i),h(c,s,u),h(c,r,u),f(r,o),l||(a=A(r,"click",e[43]),l=!0)},p(e,t){256&t[0]&&c!==(c=e[8].length+"")&&E(n,c),1536&t[0]&&u!==(u=(e[9]?e[10]:"Upload")+"")&&E(o,u),512&t[0]&&(r.disabled=e[9])},d(e){e&&p(t),e&&p(s),e&&p(r),l=!1,a()}}}function gC(e){let t,n;return{c(){t=m("div"),n=y(e[7]),I(t,"class","error-message svelte-1lyqnmz")},m(e,i){h(e,t,i),f(t,n)},p(e,t){128&t[0]&&E(n,e[7])},d(e){e&&p(t)}}}function mC(e){let t;function n(e,t){return e[0]&&0===e[28].length?bC:0===e[28].length?wC:yC}let i=n(e),s=i(e);return{c(){s.c(),t=b()},m(e,n){s.m(e,n),h(e,t,n)},p(e,r){i===(i=n(e))&&s?s.p(e,r):(s.d(1),s=i(e),s&&(s.c(),s.m(t.parentNode,t)))},d(e){s.d(e),e&&p(t)}}}function vC(e){let t;function n(e,t){return e[22]?$C:0===e[21].length?BC:SC}let i=n(e),s=i(e);return{c(){s.c(),t=b()},m(e,n){s.m(e,n),h(e,t,n)},p(e,r){i===(i=n(e))&&s?s.p(e,r):(s.d(1),s=i(e),s&&(s.c(),s.m(t.parentNode,t)))},d(e){s.d(e),e&&p(t)}}}function yC(e){let t,n,i=e[28],s=[];for(let t=0;t<i.length;t+=1)s[t]=EC(nC(e,i,t));let r=e[26]&&xC(e);return{c(){t=m("div");for(let e=0;e<s.length;e+=1)s[e].c();n=w(),r&&r.c(),I(t,"class","blob-list svelte-1lyqnmz")},m(e,i){h(e,t,i);for(let e=0;e<s.length;e+=1)s[e]&&s[e].m(t,null);f(t,n),r&&r.m(t,null)},p(e,o){if(1476919328&o[0]|524640&o[1]){let r;for(i=e[28],r=0;r<i.length;r+=1){const l=nC(e,i,r);s[r]?s[r].p(l,o):(s[r]=EC(l),s[r].c(),s[r].m(t,n))}for(;r<s.length;r+=1)s[r].d(1);s.length=i.length}e[26]?r?r.p(e,o):(r=xC(e),r.c(),r.m(t,null)):r&&(r.d(1),r=null)},d(e){e&&p(t),g(s,e),r&&r.d()}}}function wC(e){let t,n,i,s=e[1]?"No files found for this user.":"No files found in your Blossom storage.";return{c(){t=m("div"),n=m("p"),i=y(s),I(t,"class","empty-state svelte-1lyqnmz")},m(e,s){h(e,t,s),f(t,n),f(n,i)},p(e,t){2&t[0]&&s!==(s=e[1]?"No files found for this user.":"No files found in your Blossom storage.")&&E(i,s)},d(e){e&&p(t)}}}function bC(t){let n;return{c(){n=m("div"),n.textContent="Loading blobs...",I(n,"class","loading svelte-1lyqnmz")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function AC(e){let t,n,i=rE(e[109].type)+"";return{c(){t=m("span"),n=y(i),I(t,"class","thumbnail-icon svelte-1lyqnmz")},m(e,i){h(e,t,i),f(t,n)},p(e,t){268435456&t[0]&&i!==(i=rE(e[109].type)+"")&&E(n,i)},d(e){e&&p(t)}}}function kC(e){let t,n;return{c(){t=m("video"),l(t.src,n=e[36](e[109]))||I(t,"src",n),I(t,"class","thumbnail-video svelte-1lyqnmz"),t.muted=!0,I(t,"preload","metadata")},m(e,n){h(e,t,n)},p(e,i){268435456&i[0]&&!l(t.src,n=e[36](e[109]))&&I(t,"src",n)},d(e){e&&p(t)}}}function IC(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[37](e[109]))||I(t,"src",n),I(t,"alt",""),I(t,"class","thumbnail-img svelte-1lyqnmz"),I(t,"loading","lazy")},m(e,n){h(e,t,n)},p(e,i){268435456&i[0]&&!l(t.src,n=e[37](e[109]))&&I(t,"src",n)},d(e){e&&p(t)}}}function CC(e){let t;return{c(){t=m("span"),t.textContent="responsive",I(t,"class","responsive-chip svelte-1lyqnmz")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function EC(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,C,x,S,B,$,D,Q,P,R,T,L,_,N,M,U,O,j,z,H=e[109].sha256+"",q=iE(e[109].sha256)+"",G=tE(e[109].size)+"",J=(e[109].type||"unknown")+"",K=nE(e[109].uploaded)+"",V=e[19].has(e[109].sha256);function W(...t){return e[74](e[109],...t)}function Y(e,t){return 268435456&t[0]&&(l=null),268435456&t[0]&&(a=null),null==l&&(l=!("image"!==sE(e[109].type))),l?IC:(null==a&&(a=!("video"!==sE(e[109].type))),a?kC:AC)}let Z=Y(e,[-1,-1,-1,-1]),X=Z(e),ee=V&&CC();function te(){return e[75](e[109])}function ne(){return e[76](e[109])}function ie(...t){return e[77](e[109],...t)}return{c(){t=m("div"),n=m("input"),r=w(),o=m("div"),X.c(),c=w(),u=m("div"),d=m("div"),g=m("span"),v=y(H),b=w(),C=m("span"),x=y(q),B=w(),$=m("div"),D=m("span"),Q=y(G),P=w(),R=m("span"),T=y(J),L=w(),_=m("span"),N=y(K),M=w(),ee&&ee.c(),U=w(),O=m("button"),O.textContent="X",I(n,"type","checkbox"),I(n,"class","blob-checkbox svelte-1lyqnmz"),n.checked=(e[27],s=e[5].has(e[109].sha256)),I(o,"class","blob-thumbnail svelte-1lyqnmz"),I(g,"class","hash-full svelte-1lyqnmz"),I(C,"class","hash-truncated svelte-1lyqnmz"),I(d,"class","blob-hash svelte-1lyqnmz"),I(d,"title",S=e[109].sha256),I(D,"class","blob-size"),I(R,"class","blob-type"),I(_,"class","blob-date svelte-1lyqnmz"),I($,"class","blob-meta svelte-1lyqnmz"),I(u,"class","blob-info svelte-1lyqnmz"),I(O,"class","delete-btn svelte-1lyqnmz"),I(O,"title","Delete"),I(t,"class","blob-item svelte-1lyqnmz"),I(t,"role","button"),I(t,"tabindex","0"),F(t,"selected",(e[27],e[5].has(e[109].sha256)))},m(i,s){h(i,t,s),f(t,n),f(t,r),f(t,o),X.m(o,null),f(t,c),f(t,u),f(u,d),f(d,g),f(g,v),f(d,b),f(d,C),f(C,x),f(u,B),f(u,$),f($,D),f(D,Q),f($,P),f($,R),f(R,T),f($,L),f($,_),f(_,N),f($,M),ee&&ee.m($,null),f(t,U),f(t,O),j||(z=[A(n,"change",W),A(n,"keypress",k(e[68])),A(O,"click",k(te)),A(t,"click",ne),A(t,"keypress",ie)],j=!0)},p(i,r){e=i,402653216&r[0]&&s!==(e[27],s=e[5].has(e[109].sha256))&&(n.checked=s),Z===(Z=Y(e,r))&&X?X.p(e,r):(X.d(1),X=Z(e),X&&(X.c(),X.m(o,null))),268435456&r[0]&&H!==(H=e[109].sha256+"")&&E(v,H),268435456&r[0]&&q!==(q=iE(e[109].sha256)+"")&&E(x,q),268435456&r[0]&&S!==(S=e[109].sha256)&&I(d,"title",S),268435456&r[0]&&G!==(G=tE(e[109].size)+"")&&E(Q,G),268435456&r[0]&&J!==(J=(e[109].type||"unknown")+"")&&E(T,J),268435456&r[0]&&K!==(K=nE(e[109].uploaded)+"")&&E(N,K),268959744&r[0]&&(V=e[19].has(e[109].sha256)),V?ee||(ee=CC(),ee.c(),ee.m($,null)):ee&&(ee.d(1),ee=null),402653216&r[0]&&F(t,"selected",(e[27],e[5].has(e[109].sha256)))},d(e){e&&p(t),X.d(),ee&&ee.d(),j=!1,i(z)}}}function xC(t){let n;return{c(){n=m("div"),n.innerHTML='<span class="loading-more svelte-1lyqnmz">Loading more...</span>',I(n,"class","scroll-sentinel svelte-1lyqnmz")},m(e,i){h(e,n,i),t[78](n)},p:e,d(e){e&&p(n),t[78](null)}}}function SC(e){let t,n=e[21],i=[];for(let t=0;t<n.length;t+=1)i[t]=QC(iC(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","admin-users-list svelte-1lyqnmz")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(2097152&s[0]|73728&s[1]){let r;for(n=e[21],r=0;r<n.length;r+=1){const o=iC(e,n,r);i[r]?i[r].p(o,s):(i[r]=QC(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function BC(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No users have uploaded files yet.</p>",I(n,"class","empty-state svelte-1lyqnmz")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function $C(t){let n;return{c(){n=m("div"),n.textContent="Loading user statistics...",I(n,"class","loading svelte-1lyqnmz")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function FC(t){let n;return{c(){n=m("div"),I(n,"class","user-avatar-placeholder svelte-1lyqnmz")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function DC(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[106].profile.picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","user-avatar svelte-1lyqnmz")},m(e,n){h(e,t,n)},p(e,i){2097152&i[0]&&!l(t.src,n=e[106].profile.picture)&&I(t,"src",n)},d(e){e&&p(t)}}}function QC(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,F,D,Q,P,R,T,L=(e[106].profile?.name||aE(e[44](e[106].pubkey)))+"",_=e[44](e[106].pubkey)+"",N=aE(e[44](e[106].pubkey))+"",M=e[106].blob_count+"",U=tE(e[106].total_size_bytes)+"";function O(e,t){return e[106].profile?.picture?DC:FC}let j=O(e),z=j(e);function H(){return e[72](e[106])}function q(...t){return e[73](e[106],...t)}return{c(){t=m("div"),n=m("div"),z.c(),s=w(),r=m("div"),o=m("div"),l=y(L),a=w(),c=m("div"),u=m("span"),d=y(_),g=w(),v=m("span"),b=y(N),C=w(),x=m("div"),S=m("span"),B=y(M),$=y(" files"),F=w(),D=m("span"),Q=y(U),P=w(),I(n,"class","user-avatar-container svelte-1lyqnmz"),I(o,"class","user-name svelte-1lyqnmz"),I(u,"class","npub-full svelte-1lyqnmz"),I(v,"class","npub-truncated svelte-1lyqnmz"),I(c,"class","user-npub svelte-1lyqnmz"),I(c,"title",k=e[106].pubkey),I(r,"class","user-info svelte-1lyqnmz"),I(S,"class","blob-count svelte-1lyqnmz"),I(D,"class","total-size svelte-1lyqnmz"),I(x,"class","user-stats svelte-1lyqnmz"),I(t,"class","user-stat-item svelte-1lyqnmz"),I(t,"role","button"),I(t,"tabindex","0")},m(e,i){h(e,t,i),f(t,n),z.m(n,null),f(t,s),f(t,r),f(r,o),f(o,l),f(r,a),f(r,c),f(c,u),f(u,d),f(c,g),f(c,v),f(v,b),f(t,C),f(t,x),f(x,S),f(S,B),f(S,$),f(x,F),f(x,D),f(D,Q),f(t,P),R||(T=[A(t,"click",H),A(t,"keypress",q)],R=!0)},p(t,i){j===(j=O(e=t))&&z?z.p(e,i):(z.d(1),z=j(e),z&&(z.c(),z.m(n,null))),2097152&i[0]&&L!==(L=(e[106].profile?.name||aE(e[44](e[106].pubkey)))+"")&&E(l,L),2097152&i[0]&&_!==(_=e[44](e[106].pubkey)+"")&&E(d,_),2097152&i[0]&&N!==(N=aE(e[44](e[106].pubkey))+"")&&E(b,N),2097152&i[0]&&k!==(k=e[106].pubkey)&&I(c,"title",k),2097152&i[0]&&M!==(M=e[106].blob_count+"")&&E(B,M),2097152&i[0]&&U!==(U=tE(e[106].total_size_bytes)+"")&&E(Q,U)},d(e){e&&p(t),z.d(),R=!1,i(T)}}}function PC(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,C,x,S,B,$,F,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K,V,W,Y,Z,X,ee,te,ne,ie=iE(e[13].sha256)+"",se=(e[13].type||"unknown")+"",re="image"===sE(e[13].type),oe=tE(e[13].size)+"",le=nE(e[13].uploaded)+"",ae="image"===sE(e[13].type),ce="image"===sE(e[13].type),ue=re&&RC(e);function de(e,t){return 8192&t[0]&&(S=null),8192&t[0]&&(B=null),8192&t[0]&&($=null),null==S&&(S=!("image"!==sE(e[13].type))),S?NC:(null==B&&(B=!("video"!==sE(e[13].type))),B?_C:(null==$&&($=!("audio"!==sE(e[13].type))),$?LC:TC))}let fe=de(e,[-1,-1,-1,-1]),he=fe(e),pe=ae&&MC(e),ge=ce&&qC(e);return{c(){t=m("div"),n=m("div"),s=m("div"),r=m("div"),o=m("span"),l=y(ie),a=w(),c=m("span"),u=y(se),d=w(),g=m("div"),ue&&ue.c(),v=w(),b=m("button"),b.textContent="X",C=w(),x=m("div"),he.c(),F=w(),D=m("div"),Q=m("div"),P=m("span"),R=y("Size: "),T=y(oe),L=w(),_=m("span"),N=y("Uploaded: "),M=y(le),U=w(),pe&&pe.c(),O=w(),j=m("div"),z=m("input"),q=w(),G=m("button"),G.textContent="Copy",J=w(),K=m("div"),V=m("a"),W=y("Open in New Tab"),Z=w(),ge&&ge.c(),X=w(),ee=m("button"),ee.textContent="Delete",I(o,"class","modal-hash svelte-1lyqnmz"),I(c,"class","modal-type svelte-1lyqnmz"),I(r,"class","modal-title svelte-1lyqnmz"),I(b,"class","close-btn svelte-1lyqnmz"),I(g,"class","modal-controls svelte-1lyqnmz"),I(s,"class","modal-header svelte-1lyqnmz"),I(x,"class","modal-body svelte-1lyqnmz"),I(Q,"class","blob-details svelte-1lyqnmz"),I(z,"type","text"),z.readOnly=!0,z.value=H=e[36](e[13]),I(z,"class","blob-url-input svelte-1lyqnmz"),I(G,"class","copy-btn svelte-1lyqnmz"),I(j,"class","blob-url-section svelte-1lyqnmz"),I(V,"href",Y=e[36](e[13])),I(V,"target","_blank"),I(V,"rel","noopener noreferrer"),I(V,"class","action-btn svelte-1lyqnmz"),I(ee,"class","action-btn danger svelte-1lyqnmz"),I(K,"class","modal-actions svelte-1lyqnmz"),I(D,"class","modal-footer svelte-1lyqnmz"),I(n,"class","modal-content svelte-1lyqnmz"),I(n,"role","dialog"),I(t,"class","modal-overlay svelte-1lyqnmz"),I(t,"role","button"),I(t,"tabindex","0")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(s,r),f(r,o),f(o,l),f(r,a),f(r,c),f(c,u),f(s,d),f(s,g),ue&&ue.m(g,null),f(g,v),f(g,b),f(n,C),f(n,x),he.m(x,null),f(n,F),f(n,D),f(D,Q),f(Q,P),f(P,R),f(P,T),f(Q,L),f(Q,_),f(_,N),f(_,M),f(D,U),pe&&pe.m(D,null),f(D,O),f(D,j),f(j,z),f(j,q),f(j,G),f(D,J),f(D,K),f(K,V),f(V,W),f(K,Z),ge&&ge.m(K,null),f(K,X),f(K,ee),te||(ne=[A(b,"click",e[31]),A(z,"click",dE),A(G,"click",e[80]),A(ee,"click",e[83]),A(n,"click",k(e[66])),A(n,"keypress",k(e[67])),A(t,"click",e[31]),A(t,"keypress",e[84])],te=!0)},p(e,t){8192&t[0]&&ie!==(ie=iE(e[13].sha256)+"")&&E(l,ie),8192&t[0]&&se!==(se=(e[13].type||"unknown")+"")&&E(u,se),8192&t[0]&&(re="image"===sE(e[13].type)),re?ue?ue.p(e,t):(ue=RC(e),ue.c(),ue.m(g,v)):ue&&(ue.d(1),ue=null),fe===(fe=de(e,t))&&he?he.p(e,t):(he.d(1),he=fe(e),he&&(he.c(),he.m(x,null))),8192&t[0]&&oe!==(oe=tE(e[13].size)+"")&&E(T,oe),8192&t[0]&&le!==(le=nE(e[13].uploaded)+"")&&E(M,le),8192&t[0]&&(ae="image"===sE(e[13].type)),ae?pe?pe.p(e,t):(pe=MC(e),pe.c(),pe.m(D,O)):pe&&(pe.d(1),pe=null),8192&t[0]&&H!==(H=e[36](e[13]))&&z.value!==H&&(z.value=H),8192&t[0]&&Y!==(Y=e[36](e[13]))&&I(V,"href",Y),8192&t[0]&&(ce="image"===sE(e[13].type)),ce?ge?ge.p(e,t):(ge=qC(e),ge.c(),ge.m(K,X)):ge&&(ge.d(1),ge=null)},d(e){e&&p(t),ue&&ue.d(),he.d(),pe&&pe.d(),ge&&ge.d(),te=!1,i(ne)}}}function RC(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k=Math.round(100*e[14])+"";return{c(){t=m("button"),n=y("-"),r=w(),o=m("span"),l=y(k),a=y("%"),c=w(),u=m("button"),d=y("+"),I(t,"class","zoom-btn svelte-1lyqnmz"),t.disabled=s=e[14]<=VC,I(o,"class","zoom-level svelte-1lyqnmz"),I(u,"class","zoom-btn svelte-1lyqnmz"),u.disabled=g=e[14]>=WC},m(i,s){h(i,t,s),f(t,n),h(i,r,s),h(i,o,s),f(o,l),f(o,a),h(i,c,s),h(i,u,s),f(u,d),v||(b=[A(t,"click",e[34]),A(u,"click",e[33])],v=!0)},p(e,n){16384&n[0]&&s!==(s=e[14]<=VC)&&(t.disabled=s),16384&n[0]&&k!==(k=Math.round(100*e[14])+"")&&E(l,k),16384&n[0]&&g!==(g=e[14]>=WC)&&(u.disabled=g)},d(e){e&&p(t),e&&p(r),e&&p(o),e&&p(c),e&&p(u),v=!1,i(b)}}}function TC(e){let t,n,i,s,r,o,l,a,c,u=rE(e[13].type)+"";return{c(){t=m("div"),n=m("div"),i=y(u),s=w(),r=m("p"),r.textContent="Preview not available for this file type.",o=w(),l=m("a"),a=y("Download File"),I(n,"class","file-icon svelte-1lyqnmz"),I(l,"href",c=e[36](e[13])),I(l,"target","_blank"),I(l,"rel","noopener noreferrer"),I(l,"class","download-link svelte-1lyqnmz"),I(t,"class","file-preview svelte-1lyqnmz")},m(e,c){h(e,t,c),f(t,n),f(n,i),f(t,s),f(t,r),f(t,o),f(t,l),f(l,a)},p(e,t){8192&t[0]&&u!==(u=rE(e[13].type)+"")&&E(i,u),8192&t[0]&&c!==(c=e[36](e[13]))&&I(l,"href",c)},d(e){e&&p(t)}}}function LC(e){let t,n,i;return{c(){t=m("div"),n=m("audio"),n.controls=!0,l(n.src,i=e[36](e[13]))||I(n,"src",i),I(n,"class","svelte-1lyqnmz"),I(t,"class","media-container audio svelte-1lyqnmz")},m(e,i){h(e,t,i),f(t,n)},p(e,t){8192&t[0]&&!l(n.src,i=e[36](e[13]))&&I(n,"src",i)},d(e){e&&p(t)}}}function _C(e){let t,n,i,s;return{c(){t=m("div"),n=m("video"),i=m("track"),I(i,"kind","captions"),n.controls=!0,l(n.src,s=e[36](e[13]))||I(n,"src",s),I(n,"class","svelte-1lyqnmz"),I(t,"class","media-container svelte-1lyqnmz")},m(e,s){h(e,t,s),f(t,n),f(n,i)},p(e,t){8192&t[0]&&!l(n.src,s=e[36](e[13]))&&I(n,"src",s)},d(e){e&&p(t)}}}function NC(e){let t,n,i;return{c(){t=m("div"),n=m("img"),l(n.src,i=e[36](e[13]))||I(n,"src",i),I(n,"alt","Blob content"),I(n,"class","svelte-1lyqnmz"),I(t,"class","media-container svelte-1lyqnmz"),S(t,"transform","scale("+e[14]+")")},m(e,i){h(e,t,i),f(t,n)},p(e,s){8192&s[0]&&!l(n.src,i=e[36](e[13]))&&I(n,"src",i),16384&s[0]&&S(t,"transform","scale("+e[14]+")")},d(e){e&&p(t)}}}function MC(e){let t,n,i,s,r,o=e[16]&&UC();function l(e,t){return e[15].length>0?jC:e[16]?void 0:OC}let a=l(e),c=a&&a(e);return{c(){t=m("div"),n=m("div"),i=m("span"),i.textContent="Responsive Variants",s=w(),o&&o.c(),r=w(),c&&c.c(),I(i,"class","variants-title svelte-1lyqnmz"),I(n,"class","variants-header svelte-1lyqnmz"),I(t,"class","variants-section svelte-1lyqnmz")},m(e,l){h(e,t,l),f(t,n),f(n,i),f(n,s),o&&o.m(n,null),f(t,r),c&&c.m(t,null)},p(e,i){e[16]?o||(o=UC(),o.c(),o.m(n,null)):o&&(o.d(1),o=null),a===(a=l(e))&&c?c.p(e,i):(c&&c.d(1),c=a&&a(e),c&&(c.c(),c.m(t,null)))},d(e){e&&p(t),o&&o.d(),c&&c.d()}}}function UC(e){let t;return{c(){t=m("span"),t.textContent="Loading...",I(t,"class","variants-loading svelte-1lyqnmz")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function OC(t){let n;return{c(){n=m("div"),n.textContent='No responsive variants found. Use "Migrate Images" to create them.',I(n,"class","variants-empty svelte-1lyqnmz")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function jC(e){let t,n=e[15],i=[];for(let t=0;t<n.length;t+=1)i[t]=HC(tC(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","variants-list svelte-1lyqnmz")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(163840&s[0]|2&s[1]){let r;for(n=e[15],r=0;r<n.length;r+=1){const o=tC(e,n,r);i[r]?i[r].p(o,s):(i[r]=HC(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function zC(e){let t,n,i=tE(e[103].size)+"";return{c(){t=m("span"),n=y(i),I(t,"class","variant-size svelte-1lyqnmz")},m(e,i){h(e,t,i),f(t,n)},p(e,t){32768&t[0]&&i!==(i=tE(e[103].size)+"")&&E(n,i)},d(e){e&&p(t)}}}function HC(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,k,C=lE(e[103])+"",x=e[103].width+"",S=e[103].height+"",B=e[17]===e[103].sha256?"Copied!":"Copy URL",$=e[103].size&&zC(e);function D(){return e[79](e[103])}return{c(){t=m("div"),n=m("span"),i=y(C),s=w(),r=m("span"),o=y(x),l=y("×"),a=y(S),c=w(),$&&$.c(),u=w(),d=m("button"),g=y(B),v=w(),I(n,"class","variant-label svelte-1lyqnmz"),I(r,"class","variant-dims svelte-1lyqnmz"),I(d,"class","variant-copy-btn svelte-1lyqnmz"),F(d,"copied",e[17]===e[103].sha256),I(t,"class","variant-item svelte-1lyqnmz")},m(e,p){h(e,t,p),f(t,n),f(n,i),f(t,s),f(t,r),f(r,o),f(r,l),f(r,a),f(t,c),$&&$.m(t,null),f(t,u),f(t,d),f(d,g),f(t,v),b||(k=A(d,"click",D),b=!0)},p(n,s){e=n,32768&s[0]&&C!==(C=lE(e[103])+"")&&E(i,C),32768&s[0]&&x!==(x=e[103].width+"")&&E(o,x),32768&s[0]&&S!==(S=e[103].height+"")&&E(a,S),e[103].size?$?$.p(e,s):($=zC(e),$.c(),$.m(t,u)):$&&($.d(1),$=null),163840&s[0]&&B!==(B=e[17]===e[103].sha256?"Copied!":"Copy URL")&&E(g,B),163840&s[0]&&F(d,"copied",e[17]===e[103].sha256)},d(e){e&&p(t),$&&$.d(),b=!1,k()}}}function qC(e){let t;function n(e,t){return 0===e[15].length?JC:GC}let i=n(e),s=i(e);return{c(){s.c(),t=b()},m(e,n){s.m(e,n),h(e,t,n)},p(e,r){i===(i=n(e))&&s?s.p(e,r):(s.d(1),s=i(e),s&&(s.c(),s.m(t.parentNode,t)))},d(e){s.d(e),e&&p(t)}}}function GC(e){let t,n,i,s,r=e[18]?"Deleting...":"Delete Variants";return{c(){t=m("button"),n=y(r),I(t,"class","action-btn warning svelte-1lyqnmz"),t.disabled=e[18]},m(r,o){h(r,t,o),f(t,n),i||(s=A(t,"click",e[82]),i=!0)},p(e,i){262144&i[0]&&r!==(r=e[18]?"Deleting...":"Delete Variants")&&E(n,r),262144&i[0]&&(t.disabled=e[18])},d(e){e&&p(t),i=!1,s()}}}function JC(e){let t,n,i,s,r=(e[23]?e[24]:"Generate Variants")+"";return{c(){t=m("button"),n=y(r),I(t,"class","action-btn primary svelte-1lyqnmz"),t.disabled=e[23]},m(r,o){h(r,t,o),f(t,n),i||(s=A(t,"click",e[81]),i=!0)},p(e,i){25165824&i[0]&&r!==(r=(e[23]?e[24]:"Generate Variants")+"")&&E(n,r),8388608&i[0]&&(t.disabled=e[23])},d(e){e&&p(t),i=!1,s()}}}function KC(t){let n,i,s,r;function o(e,t){return e[6]?rC:sC}let l=o(t),a=l(t),c=t[12]&&t[13]&&PC(t);return{c(){a.c(),n=w(),c&&c.c(),i=b()},m(e,o){a.m(e,o),h(e,n,o),c&&c.m(e,o),h(e,i,o),s||(r=A(window,"keydown",t[35]),s=!0)},p(e,t){l===(l=o(e))&&a?a.p(e,t):(a.d(1),a=l(e),a&&(a.c(),a.m(n.parentNode,n))),e[12]&&e[13]?c?c.p(e,t):(c=PC(e),c.c(),c.m(i.parentNode,i)):c&&(c.d(1),c=null)},i:e,o:e,d(e){a.d(e),e&&p(n),c&&c.d(e),e&&p(i),s=!1,r()}}}const VC=.25,WC=4,YC=256;async function ZC(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const i=Math.floor(Date.now()/1e3),s=[["t",t],["expiration",(i+60).toString()]];n&&s.push(["x",n]);const r={kind:24242,created_at:i,tags:s,content:`Blossom ${t} operation`},o=await e.signEvent(r);return btoa(JSON.stringify(o))}catch(e){return console.error("Error creating Blossom auth:",e),null}}function XC(e){let t=null;const n=[];if(30063===e.kind){const i=e.tags.find(e=>"d"===e[0]);t=i?.[1];for(const t of e.tags)"x"===t[0]&&t[1]&&n.push(t[1])}else if(1063===e.kind)for(const i of e.tags)if("imeta"===i[0]){const e=i.find(e=>e.startsWith("variant ")),s=i.find(e=>e.startsWith("x "));if(s){const i=s.substring(2);n.push(i),"variant original"===e&&(t=i)}}else"x"===i[0]&&i[1]&&(n.includes(i[1])||n.push(i[1]));return{originalHash:t,allHashes:n}}function eE(e,t,n){for(const i of e){const{originalHash:e,allHashes:s}=XC(i);if(e){t.add(e);for(const t of s)t!==e&&n.add(t)}}}function tE(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,i=e;for(;i>=1024&&n<t.length-1;)i/=1024,n++;return`${i.toFixed(0===n?0:1)} ${t[n]}`}function nE(e){return e?new Date(1e3*e).toLocaleString():"Unknown"}function iE(e){return e?`${e.slice(0,8)}...${e.slice(-8)}`:""}function sE(e){return e?e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"file":"unknown"}function rE(e){switch(sE(e)){case"image":return"🖼️";case"video":return"🎬";case"audio":return"🎵";default:return"📄"}}function oE(e){const t={};for(let n=1;n<e.length;n++){const i=e[n],s=i.indexOf(" ");if(s>0){const e=i.substring(0,s),n=i.substring(s+1);t[e]=n}}return t}function lE(e){return{thumb:"Thumbnail",mobile:"Mobile","mobile-lg":"Mobile+",desktop:"Desktop","desktop-lg":"Desktop+",original:"Original"}[e.variant]||e.variant}function aE(e){return e?`${e.slice(0,12)}...${e.slice(-8)}`:""}async function cE(e){const t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,"0")).join("")}async function uE(e,t,n=.85){const{width:i,height:s}=e;let r,o,l,a=i,c=s;return i>t&&(a=t,c=Math.round(s*t/i)),"undefined"!=typeof OffscreenCanvas?(r=new OffscreenCanvas(a,c),o=r.getContext("2d",{alpha:!1})):(r=document.createElement("canvas"),r.width=a,r.height=c,o=r.getContext("2d",{alpha:!1})),o.imageSmoothingEnabled=!0,o.imageSmoothingQuality="high",o.drawImage(e,0,0,a,c),l="undefined"!=typeof OffscreenCanvas&&r instanceof OffscreenCanvas?await r.convertToBlob({type:"image/jpeg",quality:n}):await new Promise(e=>r.toBlob(e,"image/jpeg",n)),{blob:l,width:a,height:c}}const dE=e=>e.target.select();function fE(e,t,n){let i,s,r,o,l,a,c,u,{isLoggedIn:d=!1}=t,{userPubkey:f=""}=t,{userSigner:h=null}=t,{currentEffectiveRole:p=""}=t;const g=L();let m,v=[],y=!1,w="",b=[],A=!1,k="",I=!1,C=null,E=1,x=[],S=!1,B=null,F=!1,D=new Set,Q=new Set;const P=new Map;let N,U,O=!1,j=[],z=!1,H=null,q=[],G="date",J="desc",K=40,V="",W=!1;function Y(){U&&U.disconnect(),N&&(U=new IntersectionObserver(e=>{e[0].isIntersecting&&c&&n(60,K+=40)},{rootMargin:"0px 0px 150% 0px"}),U.observe(N))}async function Z(e,t=!1){try{const i=Nh(),s=i[0],r=Zh.getPool(),o=t?new Set(D):new Set,l=t?new Set(Q):new Set,a={kinds:[30063,1063],authors:[e]};let c;try{c=await Zh.countEvents(s,a),console.log("Binding event COUNT:",c)}catch(e){console.warn("COUNT not supported, falling back to sequential fetch:",e),c=null}if(null!==c&&c<=YC){const e=await r.querySync(i,{...a,limit:YC});eE(e,o,l),console.log("Found responsive blobs:",o.size,"variants to hide:",l.size,"total:",e.length)}else{const e=Math.floor(128),t=c||512,s=Math.max(2,Math.ceil(t/e)),u=await r.querySync(i,{...a,limit:YC});if(0===u.length)return n(19,D=o),void n(58,Q=l);let d=0,f=1/0;for(const e of u)e.created_at>d&&(d=e.created_at),e.created_at<f&&(f=e.created_at);if(u.length<YC)eE(u,o,l);else{const e=f-(d-f),t=d+1,n=Math.ceil((t-e)/s),u=[];for(let i=0;i<s;i++){const r=e+i*n,o=i===s-1?t:e+(i+1)*n-1;u.push({...a,since:r,until:o,limit:YC})}const h=await Promise.all(u.map(e=>r.querySync(i,e)));let p=0;const g=[];for(let e=0;e<h.length;e++){const t=h[e];if(p+=t.length,eE(t,o,l),t.length>=YC){let n=1/0;for(const e of t)e.created_at<n&&(n=e.created_at);g.push({since:u[e].since,until:n-1})}}if(g.length>0&&(null===c||p<c)){console.log("Re-querying",g.length,"saturated windows");const e=await Promise.all(g.map(e=>r.querySync(i,{...a,since:e.since,until:e.until,limit:YC})));for(const t of e)p+=t.length,eE(t,o,l)}console.log("Found responsive blobs:",o.size,"variants to hide:",l.size,"total fetched:",p)}}n(19,D=o),n(58,Q=l)}catch(e){console.warn("Failed to load responsive blob info:",e),t||(n(19,D=new Set),n(58,Q=new Set))}}async function X(){if(f){console.log("loadBlobs: starting, userSigner available:",!!h),n(0,y=!0),n(7,w="");try{await Z(f,!0);const e=`${Lh()}/blossom/list/${f}`,t=await ZC(h,"list"),i=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!i.ok)throw new Error(`Failed to load blobs: ${i.statusText}`);const s=await i.json(),r=Array.isArray(s)?s:[];n(57,v=[...r].sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))),console.log("Loaded blobs:",v.length)}catch(e){console.error("Error loading blobs:",e),n(7,w=e.message||"Failed to load blobs")}finally{n(0,y=!1)}}else console.log("loadBlobs: no userPubkey, skipping")}function ee(e){n(13,C=e),n(14,E=1),n(12,I=!0),n(15,x=[]),n(17,B=null),"image"===sE(e.type)&&ie(e.sha256)}function te(){n(12,I=!1),n(13,C=null),n(14,E=1),n(15,x=[]),n(17,B=null)}R(()=>{i&&!W&&(n(62,W=!0),X())}),T(()=>{U&&U.disconnect()});let ne=null;async function ie(e){ne=e,n(16,S=!0),n(15,x=[]);try{const t=Nh(),i=Zh.getPool(),s=H?.pubkey||f,r={kinds:[30063],"#d":[e],limit:10};s&&(r.authors=[s]);const o={kinds:[1063],"#x":[e],limit:10};s&&(o.authors=[s]),console.log("Querying for variants with filters:",JSON.stringify([r,o]));const[l,a]=await Promise.all([i.querySync(t,r),i.querySync(t,o)]);let c=[...l,...a];if(ne!==e)return void console.log("Variant fetch cancelled - different blob selected");if(console.log(`Found ${c.length} binding events from relay`),0===c.length){const t=P.get(e),n=Date.now();if(t&&n-t.timestamp<3e5)console.log(`Cache is fresh (${t.hasVariants?"had":"no"} variants), trusting relay result`);else{console.log("No events from relay, cache stale, checking IndexedDB...");try{const{queryEventsFromDB:e}=await Promise.resolve().then(function(){return Ep}),t=await e([r,o]);t.length>0&&(console.log(`Found ${t.length} binding events in IndexedDB cache`),c=t)}catch(e){console.warn("Failed to query IndexedDB cache:",e)}}}if(P.set(e,{timestamp:Date.now(),hasVariants:c.length>0}),ne!==e)return;if(0===c.length)return D.has(e)&&(console.log(`Removing ${e} from responsiveBlobs (no binding events found)`),n(19,D=new Set([...D].filter(t=>t!==e)))),void n(16,S=!1);const u=c.reduce((e,t)=>e.created_at>t.created_at?e:t),d=[];for(const e of u.tags){if("imeta"!==e[0])continue;const t=oE(e);if(!t.url||!t.x||!t.dim)continue;const n=t.dim.match(/^(\d+)x(\d+)$/);n&&d.push({variant:t.variant||"original",url:t.url,sha256:t.x,width:parseInt(n[1],10),height:parseInt(n[2],10),mimeType:t.m||"image/jpeg",size:t.size?parseInt(t.size,10):null})}if(ne!==e)return;d.sort((e,t)=>e.width-t.width),n(15,x=d)}catch(e){console.error("Failed to fetch variants:",e)}ne===e&&n(16,S=!1)}async function se(e){try{await navigator.clipboard.writeText(e.url),n(17,B=e.sha256),setTimeout(()=>{B===e.sha256&&n(17,B=null)},2e3)}catch(e){console.error("Failed to copy:",e)}}function re(){E<WC&&n(14,E=Math.min(WC,E+.25))}function oe(){E>VC&&n(14,E=Math.max(VC,E-.25))}function le(e){return e.url?e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:e.url.startsWith("/")?`${Lh()}${e.url}`:`http://${e.url}`:`${Lh()}/blossom/${e.sha256}`}async function ae(e){const t=D.has(e.sha256)||x.length>0,i=t?`Delete blob ${iE(e.sha256)} and all its responsive variants?`:`Delete blob ${iE(e.sha256)}?`;if(confirm(i))try{if(t){let t=x.filter(t=>t.sha256!==e.sha256).map(e=>e.sha256),i=null;if(0===t.length&&D.has(e.sha256))try{const n=Nh(),s=Zh.getPool(),r={kinds:[30063],"#d":[e.sha256],authors:f?[f]:void 0,limit:1},o={kinds:[1063],"#x":[e.sha256],authors:f?[f]:void 0,limit:1},[l,a]=await Promise.all([s.querySync(n,r),s.querySync(n,o)]),c=[...l,...a];if(c.length>0){i=c.reduce((e,t)=>e.created_at>t.created_at?e:t);for(const n of i.tags)"x"===n[0]&&n[1]&&n[1]!==e.sha256&&t.push(n[1])}}catch(e){console.warn("Failed to query variants for deletion:",e)}for(const e of t)try{const t=`${Lh()}/blossom/${e}`,n=await ZC(h,"delete",e);await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}}),console.log("Deleted variant:",e)}catch(t){console.warn("Failed to delete variant:",e,t)}try{const t=[];i?30063===i.kind?t.push(["a",`30063:${f}:${e.sha256}`]):t.push(["e",i.id]):t.push(["a",`30063:${f}:${e.sha256}`]);const n={kind:5,created_at:Math.floor(Date.now()/1e3),content:"Deleted responsive variants",tags:t},s=await h.signEvent(n),r=Nh()[0];await eC(r,s,h,f),console.log("Published deletion event for binding:",s.id)}catch(e){console.warn("Failed to publish deletion event:",e)}n(19,D=new Set([...D].filter(t=>t!==e.sha256))),n(58,Q=new Set([...Q].filter(e=>!t.includes(e))))}const i=`${Lh()}/blossom/${e.sha256}`,s=await ZC(h,"delete",e.sha256),r=await fetch(i,{method:"DELETE",headers:s?{Authorization:`Nostr ${s}`}:{}});if(!r.ok)throw new Error(`Failed to delete: ${r.statusText}`);console.log("Delete successful, removing blob from list:",e.sha256),n(57,v=v.filter(t=>t.sha256!==e.sha256)),console.log("Blobs after filter:",v.length),C?.sha256===e.sha256&&te()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function ce(e){if(confirm("Delete all responsive variants for this image?\n\nThis will remove all generated sizes (thumbnail, mobile, desktop) but keep the original.")){n(18,F=!0);try{const t=`${Lh()}/blossom/delete-variants/${e.sha256}`,i=await ZC(h,"delete",e.sha256),s=await fetch(t,{method:"DELETE",headers:i?{Authorization:`Nostr ${i}`}:{}});if(!s.ok){const e=s.headers.get("X-Reason")||s.statusText;throw new Error(e)}const r=await s.json();console.log("Delete variants result:",r),n(15,x=[]),alert(`Deleted ${r.deleted} variants.`)}catch(e){console.error("Error deleting variants:",e),alert(`Failed to delete variants: ${e.message}`)}finally{n(18,F=!1)}}}const ue=["image/jpeg","image/png","image/webp","image/bmp","image/tiff","image/avif","image/heic","image/heif"];function de(e){return ue.includes(e)}async function fe(e,t,i){const s=`[${t+1}/${i}] ${e.name}`,r=`${Lh()}/blossom/upload`;n(10,k=`${s}: Computing hash...`);const o=await e.arrayBuffer(),l=await cE(o);n(10,k=`${s}: Processing image...`);const a=await createImageBitmap(e),c=a.width,u=a.height,d=[];for(const{name:e,maxWidth:t}of Ae){if(c<=t)continue;n(10,k=`${s}: Creating ${e} variant...`);const i=await uE(a,t),r=await i.blob.arrayBuffer(),o=await cE(r);d.push({name:e,blob:i.blob,hash:o,width:i.width,height:i.height})}a.close();const p=[{variant:"original",sha256:l,url:`${Lh()}/blossom/${l}`,width:c,height:u,mimeType:e.type||"image/jpeg",size:e.size},...d.map(e=>({variant:e.name,sha256:e.hash,url:`${Lh()}/blossom/${e.hash}.jpg`,width:e.width,height:e.height,mimeType:"image/jpeg",size:e.blob.size}))];if(console.log("Variants created:",p.length,p.map(e=>e.variant)),p.length>1){n(10,k=`${s}: Publishing binding event...`);const e={kind:1063,created_at:Math.floor(Date.now()/1e3),content:"",tags:[...p.map(e=>["imeta",`url ${e.url}`,`x ${e.sha256}`,`m ${e.mimeType}`,`dim ${e.width}x${e.height}`,`variant ${e.variant}`,`size ${e.size}`]),...p.map(e=>["x",e.sha256])]},t=await h.signEvent(e),i=Nh()[0],r=await eC(i,t,h,f);console.log("Binding event published:",t.id,r),n(19,D=new Set([...D,l]));const o=p.filter(e=>e.sha256!==l).map(e=>e.sha256);n(58,Q=new Set([...Q,...o]))}n(10,k=`${s}: Uploading original...`);const g=await ZC(h,"upload",l),m=await fetch(r,{method:"PUT",headers:{"Content-Type":e.type||"application/octet-stream","X-SHA-256":l,...g?{Authorization:`Nostr ${g}`}:{}},body:e});if(!m.ok){const e=m.headers.get("X-Reason")||m.statusText;throw new Error(e)}const v=await m.json();for(const e of d){n(10,k=`${s}: Uploading ${e.name}...`);const t=`${Lh()}/blossom/${e.hash}`;if(!(await fetch(t,{method:"HEAD"})).ok){const t=await ZC(h,"upload",e.hash),n=await fetch(r,{method:"PUT",headers:{"Content-Type":"image/jpeg","X-SHA-256":e.hash,...t?{Authorization:`Nostr ${t}`}:{}},body:e.blob});n.ok||console.warn(`Failed to upload ${e.name} variant:`,n.statusText)}}return v}async function he(){n(22,z=!0),n(7,w="");try{const e=`${Lh()}/blossom/admin/users`,t=await ZC(h,"admin"),i=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!i.ok)throw new Error(`Failed to load user stats: ${i.statusText}`);n(21,j=await i.json());for(const e of j)ap(e.pubkey).then(t=>{e.profile=t||{name:"",picture:""},n(21,j)}).catch(()=>{e.profile={name:"",picture:""}})}catch(e){console.error("Error fetching admin user stats:",e),n(7,w=e.message||"Failed to load user stats")}finally{n(22,z=!1)}}async function pe(e){n(0,y=!0),n(7,w="");try{await Z(e,!1);const t=`${Lh()}/blossom/list/${e}`,i=await ZC(h,"list"),s=await fetch(t,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!s.ok)throw new Error(`Failed to load user blobs: ${s.statusText}`);const r=await s.json();n(59,q=[...r].sort((e,t)=>(t.uploaded||0)-(e.uploaded||0)))}catch(e){console.error("Error loading user blobs:",e),n(7,w=e.message||"Failed to load user blobs")}finally{n(0,y=!1)}}async function ge(e){n(1,H={pubkey:e.pubkey,profile:e.profile}),await pe(e.pubkey)}let me=!1,ve="",ye=new Set,we=!1;function be(e,t){t.stopPropagation(),ye.has(e)?ye.delete(e):ye.add(e),n(5,ye)}const Ae=[{name:"thumb",maxWidth:128},{name:"mobile-sm",maxWidth:512},{name:"mobile-lg",maxWidth:1024},{name:"desktop-sm",maxWidth:1536},{name:"desktop-md",maxWidth:2048},{name:"desktop-lg",maxWidth:2560}];async function ke(e){if(confirm("Generate responsive variants for this image?\n\nThis will create thumb (128px), mobile (512px), desktop (1280px), and original variants.")){n(23,me=!0),n(24,ve="Loading image..."),n(7,w="");try{const t=le(e),i=await fetch(t);if(!i.ok)throw new Error("Failed to fetch original image");const s=await i.blob();n(24,ve="Processing image...");const r=await createImageBitmap(s),o=r.width,l=r.height,a=[];for(let e=0;e<Ae.length;e++){const{name:t,maxWidth:i}=Ae[e];if(o<=i)continue;n(24,ve=`Creating ${t}...`);const s=await uE(r,i),l=await s.blob.arrayBuffer(),c=await cE(l);a.push({name:t,blob:s.blob,hash:c,width:s.width,height:s.height})}r.close();const c=[{variant:"original",sha256:e.sha256,url:t,width:o,height:l,mimeType:e.type||"image/jpeg",size:s.size},...a.map(e=>({variant:e.name,sha256:e.hash,url:`${Lh()}/blossom/${e.hash}.jpg`,width:e.width,height:e.height,mimeType:"image/jpeg",size:e.blob.size}))];if(c.length<=1)return n(24,ve="Image too small for variants"),void setTimeout(()=>{n(24,ve="")},2e3);n(24,ve="Publishing binding event...");const u={kind:1063,created_at:Math.floor(Date.now()/1e3),content:"",tags:[...c.map(e=>["imeta",`url ${e.url}`,`x ${e.sha256}`,`m ${e.mimeType}`,`dim ${e.width}x${e.height}`,`variant ${e.variant}`,`size ${e.size}`]),...c.map(e=>["x",e.sha256])]},d=await h.signEvent(u),p=Nh()[0],g=await eC(p,d,h,f);console.log("Binding event published:",d.id,g),n(19,D=new Set([...D,e.sha256]));const m=c.filter(t=>t.sha256!==e.sha256).map(e=>e.sha256);n(58,Q=new Set([...Q,...m]));const v=`${Lh()}/blossom/upload`;for(const e of a){n(24,ve=`Uploading ${e.name}...`);const t=`${Lh()}/blossom/${e.hash}`;if(!(await fetch(t,{method:"HEAD"})).ok){const t=await ZC(h,"upload",e.hash),n=await fetch(v,{method:"PUT",headers:{"Content-Type":"image/jpeg","X-SHA-256":e.hash,...t?{Authorization:`Nostr ${t}`}:{}},body:e.blob});n.ok||console.warn(`Failed to upload ${e.name}:`,n.statusText)}}n(24,ve="Done!"),await ie(e.sha256),setTimeout(()=>{n(24,ve="")},2e3)}catch(e){console.error("Error generating variants:",e),n(7,w=e.message||"Failed to generate variants")}finally{n(23,me=!1)}}}return e.$$set=e=>{"isLoggedIn"in e&&n(53,d=e.isLoggedIn),"userPubkey"in e&&n(54,f=e.userPubkey),"userSigner"in e&&n(55,h=e.userSigner),"currentEffectiveRole"in e&&n(56,p=e.currentEffectiveRole)},e.$$.update=()=>{var t,h,g;if(12582912&e.$$.dirty[1]&&n(6,i=d&&f),33554432&e.$$.dirty[1]&&n(29,s="admin"===p||"owner"===p),2&e.$$.dirty[0]|335544320&e.$$.dirty[1]&&n(65,r=H?q:v),134217728&e.$$.dirty[1]|8&e.$$.dirty[2]&&n(64,(Q.size,o=r.filter(e=>!Q.has(e.sha256)))),12&e.$$.dirty[0]|4&e.$$.dirty[2]&&n(63,(h=G,g=J,l=(t=o)&&0!==t.length?[...t].sort((e,t)=>{let n=0;return"date"===h?n=(e.uploaded||0)-(t.uploaded||0):"size"===h&&(n=(e.size||0)-(t.size||0)),"desc"===g?-n:n}):t)),14&e.$$.dirty[0]|1073741824&e.$$.dirty[1]){const e=`${G}-${J}-${H?.pubkey||""}`;e!==V&&(n(61,V=e),n(60,K=40))}536870912&e.$$.dirty[1]|2&e.$$.dirty[2]&&n(28,a=l?l.slice(0,K):[]),536870912&e.$$.dirty[1]|2&e.$$.dirty[2]&&n(26,c=l&&K<l.length),32&e.$$.dirty[0]&&n(27,u=ye.size),16&e.$$.dirty[0]&&N&&Y(),65&e.$$.dirty[0]|1&e.$$.dirty[2]&&(!i||W||y||(n(62,W=!0),X()))},[y,H,G,J,N,ye,i,w,b,A,k,m,I,C,E,x,S,B,F,D,O,j,z,me,ve,we,c,u,a,s,ee,te,se,re,oe,function(e){I&&("Escape"===e.key?te():"+"===e.key||"="===e.key?re():"-"===e.key&&oe())},le,function(e){const t=le(e),n=t.includes("?")?"&":"?";return`${t}${n}w=128`},function(){g("openLoginModal")},ae,ce,function(e){n(8,b=Array.from(e.target.files))},function(){m?.click()},async function(){if(0===b.length)return;n(9,A=!0),n(7,w="");const e=[],t=[];for(let i=0;i<b.length;i++){const s=b[i];try{if(de(s.type)){const t=await fe(s,i,b.length);console.log("Upload with variants complete:",t),e.push(t)}else{n(10,k=`Uploading ${i+1}/${b.length}: ${s.name}`);const t=`${Lh()}/blossom/upload`,r=await ZC(h,"upload"),o=await fetch(t,{method:"PUT",headers:{"Content-Type":s.type||"application/octet-stream",...r?{Authorization:`Nostr ${r}`}:{}},body:s});if(!o.ok){const e=o.headers.get("X-Reason")||o.statusText;throw new Error(e)}const l=await o.json();console.log("Upload response:",l),e.push(l)}}catch(e){console.error(`Error uploading ${s.name}:`,e),t.push({name:s.name,error:e.message})}}n(9,A=!1),n(10,k=""),n(8,b=[]),m&&n(11,m.value="",m),e.length>0&&(console.log("Upload complete, refreshing blob list..."),await X(),console.log("Blob list refresh complete, blobs count:",v.length)),t.length>0&&n(7,w=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return xu(e)}catch(t){return iE(e)}},function(){n(20,O=!0),he()},async function(){n(20,O=!1),n(21,j=[]),n(1,H=null),n(59,q=[]),f&&await Z(f,!1)},ge,function(){n(1,H=null),n(59,q=[])},function(){H?pe(H.pubkey):O?he():X()},be,async function(){if(0===ye.size)return;if(!confirm(`Delete ${ye.size} selected file(s)? This cannot be undone.`))return;n(25,we=!0),n(7,w="");let e=0,t=0;const i=Array.from(ye);for(const n of i)try{const i=`${Lh()}/blossom/${n}`,s=await ZC(h,"delete",n),r=await fetch(i,{method:"DELETE",headers:s?{Authorization:`Nostr ${s}`}:{}});r.ok?e++:(console.error(`Delete failed for ${n}: ${r.status} ${r.statusText}`),t++)}catch(e){console.error(`Failed to delete ${n}:`,e),t++}n(5,ye=new Set);try{H?await pe(H.pubkey):await X()}catch(e){console.error("Failed to refresh blobs:",e)}n(25,we=!1),t>0&&n(7,w=`Deleted ${e}, failed ${t}`)},ke,d,f,h,p,v,Q,q,K,V,W,l,o,r,function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},function(){G=$(this),n(2,G)},()=>n(3,J="desc"===J?"asc":"desc"),function(e){M[e?"unshift":"push"](()=>{m=e,n(11,m)})},e=>ge(e),(e,t)=>"Enter"===t.key&&ge(e),(e,t)=>be(e.sha256,t),e=>ae(e),e=>ee(e),(e,t)=>"Enter"===t.key&&ee(e),function(e){M[e?"unshift":"push"](()=>{N=e,n(4,N)})},e=>se(e),()=>{navigator.clipboard.writeText(le(C))},()=>ke(C),()=>ce(C),()=>ae(C),e=>"Enter"===e.key&&te()]}class hE extends fe{constructor(e){super(),de(this,e,fE,KC,r,{isLoggedIn:53,userPubkey:54,userSigner:55,currentEffectiveRole:56},null,[-1,-1,-1,-1])}}function pE(e,t,n){const i=e.slice();return i[29]=t[n],i}function gE(e,t,n){const i=e.slice();return i[32]=t[n],i}function mE(e){let t,n,i;function s(e,t){return e[0]?yE:wE}let r=s(e),o=r(e);return{c(){t=m("div"),n=m("p"),n.textContent="Log viewer is only available to relay owners.",i=w(),o.c(),I(n,"class","svelte-16teo8i"),I(t,"class","login-prompt svelte-16teo8i")},m(e,s){h(e,t,s),f(t,n),f(t,i),o.m(t,null)},p(e,n){r===(r=s(e))&&o?o.p(e,n):(o.d(1),o=r(e),o&&(o.c(),o.m(t,null)))},d(e){e&&p(t),o.d()}}}function vE(e){let t,n,s,r,o,l,a,c,u,d,v,b,k,C,x,S,$,F,D,Q,P,R,T,L,_,N,M,U,O,j,z,H=e[3]?"Loading...":"Refresh",q=e[2].length+"",J=e[12],K=[];for(let t=0;t<J.length;t+=1)K[t]=bE(gE(e,J,t));let V=e[7]&&AE(e);function W(e,t){return 0!==e[2].length||e[3]?kE:IE}let Y=W(e),Z=Y(e);return{c(){t=m("div"),n=m("div"),s=m("h3"),s.textContent="Logs",r=w(),o=m("div"),l=m("div"),a=m("label"),a.textContent="Level:",c=w(),u=m("select");for(let e=0;e<K.length;e+=1)K[e].c();d=w(),v=m("button"),b=y("Clear"),C=w(),x=m("button"),S=y("🔄 "),$=y(H),F=w(),V&&V.c(),D=w(),Q=m("div"),P=y("Showing "),R=y(q),T=y(" of "),L=y(e[6]),_=y(" logs (Level: "),N=y(e[8]),M=y(")"),U=w(),O=m("div"),Z.c(),I(s,"class","svelte-16teo8i"),I(a,"for","log-level"),I(a,"class","svelte-16teo8i"),I(u,"id","log-level"),I(u,"class","svelte-16teo8i"),void 0===e[9]&&G(()=>e[18].call(u)),I(l,"class","level-selector svelte-16teo8i"),I(v,"class","clear-btn svelte-16teo8i"),v.disabled=k=e[3]||0===e[2].length,I(x,"class","refresh-btn svelte-16teo8i"),x.disabled=e[3],I(o,"class","header-controls svelte-16teo8i"),I(n,"class","header-section svelte-16teo8i"),I(Q,"class","log-info svelte-16teo8i"),I(O,"class","log-list svelte-16teo8i"),I(t,"class","log-view svelte-16teo8i")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(l,c),f(l,u);for(let e=0;e<K.length;e+=1)K[e]&&K[e].m(u,null);B(u,e[9],!0),f(o,d),f(o,v),f(v,b),f(o,C),f(o,x),f(x,S),f(x,$),f(t,F),V&&V.m(t,null),f(t,D),f(t,Q),f(Q,P),f(Q,R),f(Q,T),f(Q,L),f(Q,_),f(Q,N),f(Q,M),f(t,U),f(t,O),Z.m(O,null),e[21](O),j||(z=[A(u,"change",e[18]),A(u,"change",e[14]),A(v,"click",e[15]),A(x,"click",e[19])],j=!0)},p(e,n){if(4096&n[0]){let t;for(J=e[12],t=0;t<J.length;t+=1){const i=gE(e,J,t);K[t]?K[t].p(i,n):(K[t]=bE(i),K[t].c(),K[t].m(u,null))}for(;t<K.length;t+=1)K[t].d(1);K.length=J.length}4608&n[0]&&B(u,e[9]),12&n[0]&&k!==(k=e[3]||0===e[2].length)&&(v.disabled=k),8&n[0]&&H!==(H=e[3]?"Loading...":"Refresh")&&E($,H),8&n[0]&&(x.disabled=e[3]),e[7]?V?V.p(e,n):(V=AE(e),V.c(),V.m(t,D)):V&&(V.d(1),V=null),4&n[0]&&q!==(q=e[2].length+"")&&E(R,q),64&n[0]&&E(L,e[6]),256&n[0]&&E(N,e[8]),Y===(Y=W(e))&&Z?Z.p(e,n):(Z.d(1),Z=Y(e),Z&&(Z.c(),Z.m(O,null)))},d(n){n&&p(t),g(K,n),V&&V.d(),Z.d(),e[21](null),j=!1,i(z)}}}function yE(e){let t,n,i,s;return{c(){t=m("p"),n=y("Your role ("),i=y(e[1]),s=y(") does not have access to this feature."),I(t,"class","access-denied svelte-16teo8i")},m(e,r){h(e,t,r),f(t,n),f(t,i),f(t,s)},p(e,t){2&t[0]&&E(i,e[1])},d(e){e&&p(t)}}}function wE(t){let n,i,s;return{c(){n=m("button"),n.textContent="Log In",I(n,"class","login-btn svelte-16teo8i")},m(e,r){h(e,n,r),i||(s=A(n,"click",t[16]),i=!0)},p:e,d(e){e&&p(n),i=!1,s()}}}function bE(t){let n,i,s=t[32]+"";return{c(){n=m("option"),i=y(s),n.__value=t[32],n.value=n.__value},m(e,t){h(e,n,t),f(n,i)},p:e,d(e){e&&p(n)}}}function AE(e){let t,n;return{c(){t=m("div"),n=y(e[7]),I(t,"class","error-message svelte-16teo8i")},m(e,i){h(e,t,i),f(t,n)},p(e,t){128&t[0]&&E(n,e[7])},d(e){e&&p(t)}}}function kE(e){let t,n,i=e[2],s=[];for(let t=0;t<i.length;t+=1)s[t]=EE(pE(e,i,t));function r(e,t){return e[3]?BE:e[5]?SE:xE}let o=r(e),l=o(e);return{c(){for(let e=0;e<s.length;e+=1)s[e].c();t=w(),n=m("div"),l.c(),I(n,"class","load-more-trigger svelte-16teo8i")},m(i,r){for(let e=0;e<s.length;e+=1)s[e]&&s[e].m(i,r);h(i,t,r),h(i,n,r),l.m(n,null),e[20](n)},p(e,a){if(4&a[0]){let n;for(i=e[2],n=0;n<i.length;n+=1){const r=pE(e,i,n);s[n]?s[n].p(r,a):(s[n]=EE(r),s[n].c(),s[n].m(t.parentNode,t))}for(;n<s.length;n+=1)s[n].d(1);s.length=i.length}o!==(o=r(e))&&(l.d(1),l=o(e),l&&(l.c(),l.m(n,null)))},d(i){g(s,i),i&&p(t),i&&p(n),l.d(),e[20](null)}}}function IE(t){let n;return{c(){n=m("div"),n.innerHTML="<p>No logs available.</p>",I(n,"class","empty-state svelte-16teo8i")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function CE(e){let t,n,i,s,r=e[29].file+"",o=e[29].line+"";return{c(){t=m("span"),n=y(r),i=y(":"),s=y(o),I(t,"class","log-location svelte-16teo8i")},m(e,r){h(e,t,r),f(t,n),f(t,i),f(t,s)},p(e,t){4&t[0]&&r!==(r=e[29].file+"")&&E(n,r),4&t[0]&&o!==(o=e[29].line+"")&&E(s,o)},d(e){e&&p(t)}}}function EE(e){let t,n,i,s,r,o,l,a,c,u,d,g=FE(e[29].timestamp)+"",v=e[29].level+"",b=e[29].message+"",A=e[29].file&&CE(e);return{c(){t=m("div"),n=m("span"),i=y(g),s=w(),r=m("span"),o=y(v),a=w(),A&&A.c(),c=w(),u=m("span"),d=y(b),I(n,"class","log-timestamp svelte-16teo8i"),I(r,"class",l="log-level "+DE(e[29].level)+" svelte-16teo8i"),I(u,"class","log-message svelte-16teo8i"),I(t,"class","log-entry svelte-16teo8i")},m(e,l){h(e,t,l),f(t,n),f(n,i),f(t,s),f(t,r),f(r,o),f(t,a),A&&A.m(t,null),f(t,c),f(t,u),f(u,d)},p(e,n){4&n[0]&&g!==(g=FE(e[29].timestamp)+"")&&E(i,g),4&n[0]&&v!==(v=e[29].level+"")&&E(o,v),4&n[0]&&l!==(l="log-level "+DE(e[29].level)+" svelte-16teo8i")&&I(r,"class",l),e[29].file?A?A.p(e,n):(A=CE(e),A.c(),A.m(t,c)):A&&(A.d(1),A=null),4&n[0]&&b!==(b=e[29].message+"")&&E(d,b)},d(e){e&&p(t),A&&A.d()}}}function xE(e){let t;return{c(){t=m("span"),t.textContent="End of logs"},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function SE(e){let t;return{c(){t=m("span"),t.textContent="Scroll for more"},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function BE(e){let t;return{c(){t=m("span"),t.textContent="Loading more..."},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function $E(t){let n;function i(e,t){return e[4]?vE:mE}let s=i(t),r=s(t);return{c(){r.c(),n=b()},m(e,t){r.m(e,t),h(e,n,t)},p(e,t){s===(s=i(e))&&r?r.p(e,t):(r.d(1),r=s(e),r&&(r.c(),r.m(n.parentNode,n)))},i:e,o:e,d(e){r.d(e),e&&p(n)}}}function FE(e){if(!e)return"";return new Date(e).toLocaleString()}function DE(e){switch(e?.toUpperCase()){case"TRC":case"TRACE":return"level-trace";case"DBG":case"DEBUG":return"level-debug";case"INF":case"INFO":default:return"level-info";case"WRN":case"WARN":return"level-warn";case"ERR":case"ERROR":return"level-error";case"FTL":case"FATAL":return"level-fatal"}}function QE(e,t,n){let i,{isLoggedIn:s=!1}=t,{userRole:r=""}=t,{userSigner:o=null}=t;const l=L();let a=[],c=!1,u=!0,d=0,f=0,h="",p="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let v,y,w;async function b(e="GET",t="/api/logs"){if(!o)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${Lh()}${t}`],["method",e]],content:""},i=await o.signEvent(n);return btoa(JSON.stringify(i))}catch(e){return console.error("Error creating auth header:",e),null}}async function A(e=!1){if(!c){n(3,c=!0),n(7,h=""),e&&(d=0,n(2,a=[]));try{const t=`/api/logs?offset=${d}&limit=100`,i=await b("GET",t),s=`${Lh()}${t}`,r=await fetch(s,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!r.ok)throw new Error(`Failed to load logs: ${r.statusText}`);const o=await r.json();n(2,a=e?o.logs||[]:[...a,...o.logs||[]]),n(6,f=o.total||0),n(5,u=o.has_more||!1),d=a.length}catch(e){console.error("Error loading logs:",e),n(7,h=e.message||"Failed to load logs")}finally{n(3,c=!1)}}}async function k(){try{const e=await fetch(`${Lh()}/api/logs/level`);if(e.ok){const t=await e.json();n(8,p=t.level||"info"),n(9,g=p)}}catch(e){console.error("Error loading log level:",e)}}R(()=>{i&&(A(!0),k(),function(){if(!y)return;w=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&A(!1)},{threshold:.1}),w.observe(y)}())}),T(()=>{w&&w.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"userRole"in e&&n(1,r=e.userRole),"userSigner"in e&&n(17,o=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,i=s&&"owner"===r),28&e.$$.dirty[0]&&i&&0===a.length&&!c&&(A(!0),k())},[s,r,a,c,i,u,f,h,p,g,v,y,m,A,async function(){if(g!==p)try{const e=await b("POST","/api/logs/level"),t=await fetch(`${Lh()}/api/logs/level`,{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Nostr ${e}`}:{}},body:JSON.stringify({level:g})});if(!t.ok)throw new Error(`Failed to set log level: ${t.statusText}`);const i=await t.json();n(8,p=i.level),n(9,g=p)}catch(e){console.error("Error setting log level:",e),n(7,h=e.message||"Failed to set log level"),n(9,g=p)}},async function(){if(confirm("Are you sure you want to clear all logs?"))try{const e=await b("POST","/api/logs/clear"),t=await fetch(`${Lh()}/api/logs/clear`,{method:"POST",headers:e?{Authorization:`Nostr ${e}`}:{}});if(!t.ok)throw new Error(`Failed to clear logs: ${t.statusText}`);n(2,a=[]),d=0,n(5,u=!1),n(6,f=0)}catch(e){console.error("Error clearing logs:",e),n(7,h=e.message||"Failed to clear logs")}},function(){l("openLoginModal")},o,function(){g=$(this),n(9,g),n(12,m)},()=>A(!0),function(e){M[e?"unshift":"push"](()=>{y=e,n(11,y)})},function(e){M[e?"unshift":"push"](()=>{v=e,n(10,v)})}]}class PE extends fe{constructor(e){super(),de(this,e,QE,$E,r,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}async function RE(e,t,n,i){if(!e||!t)return console.log("createNIP98Auth: No signer or pubkey available",{hasSigner:!!e,hasPubkey:!!t}),null;try{const t={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",i],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,i);const s=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:s.id,pubkey:s.pubkey,kind:s.kind,created_at:s.created_at,tags:s.tags,hasSig:!!s.sig});const r=JSON.stringify(s);return btoa(r)}catch(e){return console.error("createNIP98Auth: Error:",e),null}}async function TE(){try{const e=await fetch(Lh(),{headers:{Accept:"application/nostr+json"}});if(e.ok)return await e.json()}catch(e){console.error("Error fetching relay info:",e)}return null}async function LE(){const e=Lh();console.log("[api] fetchNRCConfig using base URL:",e);try{const t=await fetch(`${e}/api/nrc/config`);if(t.ok)return await t.json()}catch(e){console.error("Error fetching NRC config:",e)}return{enabled:!1,badger_required:!0}}function _E(e){return Jh[e]||`Kind ${e}`}function NE(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function ME(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function UE(e){return e?new Date(1e3*e).toLocaleString():""}async function OE(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){console.error("Failed to copy to clipboard:",t);try{const t=document.createElement("textarea");return t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch(e){return console.error("Fallback copy also failed:",e),!1}}}function jE(e,t=!0){if(!e)return;const n=e.textContent,i=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=i},2e3)}function zE(e,t,n){const i=e.slice();return i[34]=t[n],i}function HE(e){let t,n,s,r,o,l,a,c,u,d,g,v,k,C,S,B,$,F,D,Q,P,R,T,L,_,N,M,U,O,j,z,H,q,G,J,K=(e[5].rendezvous_url||"Not configured")+"",V=e[4].length+"";function W(e,t){return 0===e[4].length?VE:KE}let Y=W(e),Z=Y(e),X=e[7]&&ZE(e);return{c(){t=m("div"),n=m("div"),n.innerHTML='<span class="status-label svelte-1rsf7jk">Status:</span> \n                <span class="status-value enabled svelte-1rsf7jk">Enabled</span>',s=w(),r=m("div"),o=m("span"),o.textContent="Rendezvous:",l=w(),a=m("span"),c=y(K),u=w(),d=m("div"),g=m("h3"),g.textContent="Create New Connection",v=w(),k=m("div"),C=m("div"),S=m("label"),S.textContent="Device Label",B=w(),$=m("input"),F=w(),D=m("button"),Q=y("+ Create Connection"),R=w(),T=m("div"),L=m("h3"),_=y("Connections ("),N=y(V),M=y(")"),U=w(),Z.c(),O=w(),j=m("button"),z=y("Refresh"),H=w(),X&&X.c(),q=b(),I(n,"class","status-item svelte-1rsf7jk"),I(o,"class","status-label svelte-1rsf7jk"),I(a,"class","status-value svelte-1rsf7jk"),I(r,"class","status-item svelte-1rsf7jk"),I(t,"class","config-status svelte-1rsf7jk"),I(g,"class","svelte-1rsf7jk"),I(S,"for","new-label"),I(S,"class","svelte-1rsf7jk"),I($,"type","text"),I($,"id","new-label"),I($,"placeholder","e.g., Phone, Laptop, Tablet"),$.disabled=e[6],I($,"class","svelte-1rsf7jk"),I(C,"class","form-group svelte-1rsf7jk"),I(D,"class","create-btn svelte-1rsf7jk"),D.disabled=P=e[6]||!e[9].trim(),I(k,"class","create-form svelte-1rsf7jk"),I(d,"class","section svelte-1rsf7jk"),I(L,"class","svelte-1rsf7jk"),I(j,"class","refresh-btn svelte-1rsf7jk"),j.disabled=e[6],I(T,"class","section svelte-1rsf7jk")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),f(r,o),f(r,l),f(r,a),f(a,c),h(i,u,p),h(i,d,p),f(d,g),f(d,v),f(d,k),f(k,C),f(C,S),f(C,B),f(C,$),x($,e[9]),f(k,F),f(k,D),f(D,Q),h(i,R,p),h(i,T,p),f(T,L),f(L,_),f(L,N),f(L,M),f(T,U),Z.m(T,null),f(T,O),f(T,j),f(j,z),h(i,H,p),X&&X.m(i,p),h(i,q,p),G||(J=[A($,"input",e[27]),A(D,"click",e[14]),A(j,"click",e[13])],G=!0)},p(e,t){32&t[0]&&K!==(K=(e[5].rendezvous_url||"Not configured")+"")&&E(c,K),64&t[0]&&($.disabled=e[6]),512&t[0]&&$.value!==e[9]&&x($,e[9]),576&t[0]&&P!==(P=e[6]||!e[9].trim())&&(D.disabled=P),16&t[0]&&V!==(V=e[4].length+"")&&E(N,V),Y===(Y=W(e))&&Z?Z.p(e,t):(Z.d(1),Z=Y(e),Z&&(Z.c(),Z.m(T,O))),64&t[0]&&(j.disabled=e[6]),e[7]?X?X.p(e,t):(X=ZE(e),X.c(),X.m(q.parentNode,q)):X&&(X.d(1),X=null)},d(e){e&&p(t),e&&p(u),e&&p(d),e&&p(R),e&&p(T),Z.d(),e&&p(H),X&&X.d(e),e&&p(q),G=!1,i(J)}}}function qE(e){let t,n,i,s,r,o,l,a=(e[1]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="Owner permission required for relay connection management.",i=w(),s=m("p"),r=y("Current role: "),o=m("strong"),l=y(a),I(n,"class","svelte-1rsf7jk"),I(s,"class","svelte-1rsf7jk"),I(t,"class","permission-denied svelte-1rsf7jk")},m(e,a){h(e,t,a),f(t,n),f(t,i),f(t,s),f(s,r),f(s,o),f(o,l)},p(e,t){2&t[0]&&a!==(a=(e[1]||"none")+"")&&E(l,a)},d(e){e&&p(t)}}}function GE(t){let n,i,s,r,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to manage relay connections.",s=w(),r=m("button"),r.textContent="Log In",I(i,"class","svelte-1rsf7jk"),I(r,"class","login-btn svelte-1rsf7jk"),I(n,"class","login-prompt svelte-1rsf7jk")},m(e,a){h(e,n,a),f(n,i),f(n,s),f(n,r),o||(l=A(r,"click",t[19]),o=!0)},p:e,d(e){e&&p(n),o=!1,l()}}}function JE(e){let t;function n(e,t){return e[3]?ex:XE}let i=n(e),s=i(e);return{c(){t=m("div"),s.c(),I(t,"class","not-enabled svelte-1rsf7jk")},m(e,n){h(e,t,n),s.m(t,null)},p(e,r){i!==(i=n(e))&&(s.d(1),s=i(e),s&&(s.c(),s.m(t,null)))},d(e){e&&p(t),s.d()}}}function KE(e){let t,n=e[4],i=[];for(let t=0;t<n.length;t+=1)i[t]=YE(zE(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","connections-list svelte-1rsf7jk")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(98384&s[0]){let r;for(n=e[4],r=0;r<n.length;r+=1){const o=zE(e,n,r);i[r]?i[r].p(o,s):(i[r]=YE(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function VE(t){let n;return{c(){n=m("p"),n.textContent="No connections yet. Create one to get started.",I(n,"class","no-connections svelte-1rsf7jk")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function WE(e){let t,n,i,s=ix(e[34].last_used)+"";return{c(){t=m("span"),n=y("Last used: "),i=y(s),I(t,"class","detail")},m(e,s){h(e,t,s),f(t,n),f(t,i)},p(e,t){16&t[0]&&s!==(s=ix(e[34].last_used)+"")&&E(i,s)},d(e){e&&p(t)}}}function YE(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,F,D,Q,P,R,T,L=e[34].label+"",_=e[34].id.substring(0,8)+"",N=ix(e[34].created_at)+"",M=e[34].last_used&&WE(e);function U(){return e[28](e[34])}function O(){return e[29](e[34])}return{c(){t=m("div"),n=m("div"),s=m("div"),r=y(L),o=w(),l=m("div"),a=m("span"),c=y("ID: "),u=y(_),d=y("..."),g=w(),v=m("span"),b=y("Created: "),k=y(N),C=w(),M&&M.c(),x=w(),S=m("div"),B=m("button"),$=y("Show URI"),F=w(),D=m("button"),Q=y("Delete"),P=w(),I(s,"class","connection-label svelte-1rsf7jk"),I(a,"class","detail"),I(v,"class","detail"),I(l,"class","connection-details svelte-1rsf7jk"),I(n,"class","connection-info svelte-1rsf7jk"),I(B,"class","action-btn show-uri-btn svelte-1rsf7jk"),B.disabled=e[6],I(B,"title","Show connection URI"),I(D,"class","action-btn delete-btn svelte-1rsf7jk"),D.disabled=e[6],I(D,"title","Delete connection"),I(S,"class","connection-actions svelte-1rsf7jk"),I(t,"class","connection-item svelte-1rsf7jk")},m(e,i){h(e,t,i),f(t,n),f(n,s),f(s,r),f(n,o),f(n,l),f(l,a),f(a,c),f(a,u),f(a,d),f(l,g),f(l,v),f(v,b),f(v,k),f(l,C),M&&M.m(l,null),f(t,x),f(t,S),f(S,B),f(B,$),f(S,F),f(S,D),f(D,Q),f(t,P),R||(T=[A(B,"click",U),A(D,"click",O)],R=!0)},p(t,n){e=t,16&n[0]&&L!==(L=e[34].label+"")&&E(r,L),16&n[0]&&_!==(_=e[34].id.substring(0,8)+"")&&E(u,_),16&n[0]&&N!==(N=ix(e[34].created_at)+"")&&E(k,N),e[34].last_used?M?M.p(e,n):(M=WE(e),M.c(),M.m(l,null)):M&&(M.d(1),M=null),64&n[0]&&(B.disabled=e[6]),64&n[0]&&(D.disabled=e[6])},d(e){e&&p(t),M&&M.d(),R=!1,i(T)}}}function ZE(e){let t,n;return{c(){t=m("div"),n=y(e[7]),I(t,"class","message svelte-1rsf7jk"),F(t,"error","error"===e[8]),F(t,"success","success"===e[8])},m(e,i){h(e,t,i),f(t,n)},p(e,i){128&i[0]&&E(n,e[7]),256&i[0]&&F(t,"error","error"===e[8]),256&i[0]&&F(t,"success","success"===e[8])},d(e){e&&p(t)}}}function XE(e){let t,n,i;return{c(){t=m("p"),t.textContent="NRC is not enabled on this relay.",n=w(),i=m("p"),i.innerHTML='Set <code class="svelte-1rsf7jk">ORLY_NRC_ENABLED=true</code> and configure <code class="svelte-1rsf7jk">ORLY_NRC_RENDEZVOUS_URL</code> to enable.',I(t,"class","svelte-1rsf7jk"),I(i,"class","svelte-1rsf7jk")},m(e,s){h(e,t,s),h(e,n,s),h(e,i,s)},d(e){e&&p(t),e&&p(n),e&&p(i)}}}function ex(e){let t,n,i;return{c(){t=m("p"),t.textContent="NRC requires the Badger database backend.",n=w(),i=m("p"),i.innerHTML='Set <code class="svelte-1rsf7jk">ORLY_DB_TYPE=badger</code> to enable NRC functionality.',I(t,"class","svelte-1rsf7jk"),I(i,"class","svelte-1rsf7jk")},m(e,s){h(e,t,s),h(e,n,s),h(e,i,s)},d(e){e&&p(t),e&&p(n),e&&p(i)}}}function tx(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,C,x,S,B,$;return{c(){t=m("div"),n=m("div"),s=m("h3"),r=y('Connection URI for "'),o=y(e[12]),l=y('"'),a=w(),c=m("p"),c.textContent="Copy this URI to your Nostr client to connect to this relay remotely.\n                Keep it secret - anyone with this URI can access your relay.",u=w(),d=m("div"),g=m("textarea"),v=w(),b=m("div"),C=m("button"),C.textContent="Copy to Clipboard",x=w(),S=m("button"),S.textContent="Close",I(s,"class","svelte-1rsf7jk"),I(c,"class","modal-description svelte-1rsf7jk"),g.readOnly=!0,g.value=e[11],I(g,"class","svelte-1rsf7jk"),I(d,"class","uri-display svelte-1rsf7jk"),I(C,"class","copy-btn svelte-1rsf7jk"),I(S,"class","close-btn svelte-1rsf7jk"),I(b,"class","modal-actions svelte-1rsf7jk"),I(n,"class","modal svelte-1rsf7jk"),I(t,"class","modal-overlay svelte-1rsf7jk")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(s,r),f(s,o),f(s,l),f(n,a),f(n,c),f(n,u),f(n,d),f(d,g),f(n,v),f(n,b),f(b,C),f(b,x),f(b,S),B||($=[A(C,"click",e[17]),A(S,"click",e[18]),A(n,"click",k(e[26])),A(t,"click",e[18])],B=!0)},p(e,t){4096&t[0]&&E(o,e[12]),2048&t[0]&&(g.value=e[11])},d(e){e&&p(t),B=!1,i($)}}}function nx(t){let n,i,s,r,o,l,a;function c(e,t){return e[2]?e[0]?"owner"!==e[1]?qE:HE:GE:JE}let u=c(t),d=u(t),g=t[10]&&tx(t);return{c(){n=m("div"),i=m("h2"),i.textContent="Relay Connect",s=w(),r=m("p"),r.textContent="Nostr Relay Connect (NRC) allows remote access to this relay through a public relay tunnel.\n        Create connection strings for your devices to sync securely.",o=w(),d.c(),l=w(),g&&g.c(),a=b(),I(i,"class","svelte-1rsf7jk"),I(r,"class","description svelte-1rsf7jk"),I(n,"class","relay-connect-view svelte-1rsf7jk")},m(e,t){h(e,n,t),f(n,i),f(n,s),f(n,r),f(n,o),d.m(n,null),h(e,l,t),g&&g.m(e,t),h(e,a,t)},p(e,t){u===(u=c(e))&&d?d.p(e,t):(d.d(1),d=u(e),d&&(d.c(),d.m(n,null))),e[10]?g?g.p(e,t):(g=tx(e),g.c(),g.m(a.parentNode,a)):g&&(g.d(1),g=null)},i:e,o:e,d(e){e&&p(n),d.d(),e&&p(l),g&&g.d(e),e&&p(a)}}}function ix(e){return e?new Date(1e3*e).toLocaleString():"Never"}function sx(e,t,n){let i,s;u(e,Ah,e=>n(25,s=e));let{isLoggedIn:r=!1}=t,{userRole:o=""}=t,{userSigner:l=null}=t,{userPubkey:a=""}=t;const c=L();let d=!1,f=!1,h=[],p={},g=!1,m="",v="info",y="",w=!1,b="",A="",k=!1,I="";async function C(){console.log("[RelayConnectView] loadNRCConfig called, current relayUrl:",s);try{const e=await LE();console.log("[RelayConnectView] NRC config result:",e),n(2,d=e.enabled),n(3,f=e.badger_required),d&&r&&"owner"===o&&await E()}catch(e){console.error("Failed to load NRC config:",e)}}async function E(){if(r&&l&&a){n(6,g=!0);try{const e=await async function(e,t){const n=`${Lh()}/api/nrc/connections`,i=await RE(e,t,"GET",n),s=await fetch(n,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to get NRC connections: ${s.statusText}`)}return await s.json()}(l,a);n(4,h=e.connections||[]),n(5,p=e.config||{})}catch(e){B(`Failed to load connections: ${e.message}`,"error")}finally{n(6,g=!1)}}}async function x(e,t){if(confirm(`Are you sure you want to delete the connection "${t}"? This will revoke access for any device using this connection.`)){n(6,g=!0);try{await async function(e,t,n){const i=`${Lh()}/api/nrc/connections/${n}`,s=await RE(e,t,"DELETE",i),r=await fetch(i,{method:"DELETE",headers:s?{Authorization:`Nostr ${s}`}:{}});if(!r.ok){const e=await r.text();throw new Error(e||`Failed to delete NRC connection: ${r.statusText}`)}return await r.json()}(l,a,e),await E(),B(`Connection "${t}" deleted`,"success")}catch(e){B(`Failed to delete connection: ${e.message}`,"error")}finally{n(6,g=!1)}}}async function S(e,t){n(6,g=!0);try{const i=await async function(e,t,n){const i=`${Lh()}/api/nrc/connections/${n}/uri`,s=await RE(e,t,"GET",i),r=await fetch(i,{headers:s?{Authorization:`Nostr ${s}`}:{}});if(!r.ok){const e=await r.text();throw new Error(e||`Failed to get NRC URI: ${r.statusText}`)}return await r.json()}(l,a,e);n(11,b=i.uri),n(12,A=t),n(10,w=!0)}catch(e){B(`Failed to get URI: ${e.message}`,"error")}finally{n(6,g=!1)}}function B(e,t="info"){n(7,m=e),n(8,v=t),setTimeout(()=>{m===e&&n(7,m="")},5e3)}R(async()=>{n(23,I=s||""),await C(),n(22,k=!0)});return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"userRole"in e&&n(1,o=e.userRole),"userSigner"in e&&n(20,l=e.userSigner),"userPubkey"in e&&n(21,a=e.userPubkey)},e.$$.update=()=>{33554432&e.$$.dirty[0]&&n(24,i=s),29360128&e.$$.dirty[0]&&k&&i!==I&&(n(23,I=i),console.log("[RelayConnectView] Relay changed, reloading..."),n(4,h=[]),n(5,p={}),n(2,d=!1),C()),7&e.$$.dirty[0]&&r&&"owner"===o&&d&&E()},[r,o,d,f,h,p,g,m,v,y,w,b,A,E,async function(){if(y.trim()){n(6,g=!0);try{const e=await async function(e,t,n){const i=`${Lh()}/api/nrc/connections`,s=await RE(e,t,"POST",i),r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...s?{Authorization:`Nostr ${s}`}:{}},body:JSON.stringify({label:n})});if(!r.ok){const e=await r.text();throw new Error(e||`Failed to create NRC connection: ${r.statusText}`)}return await r.json()}(l,a,y.trim());n(11,b=e.uri),n(12,A=e.label),n(10,w=!0),n(9,y=""),await E(),B(`Connection "${e.label}" created successfully`,"success")}catch(e){B(`Failed to create connection: ${e.message}`,"error")}finally{n(6,g=!1)}}else B("Please enter a label for the connection","error")},x,S,async function(e){const t=await OE(b);jE(e.target.closest("button"),t),t||B("Failed to copy to clipboard","error")},function(){n(10,w=!1),n(11,b=""),n(12,A="")},function(){c("openLoginModal")},l,a,k,I,i,s,function(t){_.call(this,e,t)},function(){y=this.value,n(9,y)},e=>S(e.id,e.label),e=>x(e.id,e.label)]}class rx extends fe{constructor(e){super(),de(this,e,sx,nx,r,{isLoggedIn:0,userRole:1,userSigner:20,userPubkey:21},null,[-1,-1])}}function ox(e){let t,n,i,s,r,o,l,a,c,u,d;return{c(){t=m("div"),n=m("div"),i=m("h3"),i.textContent="Active Filter",s=w(),r=m("button"),r.textContent="🧹 Sweep",o=w(),l=m("div"),a=m("pre"),c=y(e[2]),I(i,"class","svelte-1tyqaa5"),I(r,"class","sweep-btn svelte-1tyqaa5"),I(r,"title","Clear filter"),I(n,"class","filter-display-header svelte-1tyqaa5"),I(a,"class","filter-json svelte-1tyqaa5"),I(l,"class","filter-json-container svelte-1tyqaa5"),I(t,"class","filter-display svelte-1tyqaa5")},m(p,g){h(p,t,g),f(t,n),f(n,i),f(n,s),f(n,r),f(t,o),f(t,l),f(l,a),f(a,c),u||(d=A(r,"click",e[3]),u=!0)},p(e,t){4&t&&E(c,e[2])},d(e){e&&p(t),u=!1,d()}}}function lx(t){let n,i=t[0]&&t[1]&&ox(t);return{c(){i&&i.c(),n=b()},m(e,t){i&&i.m(e,t),h(e,n,t)},p(e,[t]){e[0]&&e[1]?i?i.p(e,t):(i=ox(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&p(n)}}}function ax(e,t,n){let i,s;const r=L();let{filter:o={}}=t,{showFilter:l=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,o=e.filter),"showFilter"in e&&n(0,l=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,i=function(e){return JSON.stringify(e,null,2)}(o)),16&e.$$.dirty&&n(1,s=Object.keys(o).length>0)},[l,s,i,function(){r("sweep")},o]}class cx extends fe{constructor(e){super(),de(this,e,ax,lx,r,{filter:4,showFilter:0})}}function ux(e,t,n){const i=e.slice();return i[20]=t[n],i}function dx(e){let t,n,s,r,o,l,a,c,u,d,g,v,y,b,C,E,S,B,$,D,Q,P,R,T,L,_;function N(e,t){return e[3]&&!e[5]?hx:fx}let M=N(e),U=M(e),O=e[4]&&px(e);function j(e,t){return e[6].length>0?mx:gx}let z=j(e),H=z(e);return{c(){t=m("div"),n=m("div"),s=m("div"),r=m("h2"),r.textContent="Relay Manager",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("div"),d.textContent="Add Relay",g=w(),v=m("div"),y=m("input"),b=w(),C=m("button"),U.c(),S=w(),O&&O.c(),B=w(),$=m("div"),D=m("div"),D.textContent="Saved Relays",Q=w(),H.c(),P=w(),R=m("div"),T=m("button"),T.textContent="Done",I(r,"class","svelte-6a0diz"),I(l,"class","close-btn svelte-6a0diz"),I(s,"class","modal-header svelte-6a0diz"),I(d,"class","section-header svelte-6a0diz"),I(y,"type","text"),I(y,"placeholder","wss://relay.example.com"),y.disabled=e[3],I(y,"class","url-input svelte-6a0diz"),I(C,"class","add-btn svelte-6a0diz"),C.disabled=E=e[3]||!e[2].trim(),I(v,"class","input-row svelte-6a0diz"),I(u,"class","add-relay-section svelte-6a0diz"),I(D,"class","section-header svelte-6a0diz"),I($,"class","saved-relays-section svelte-6a0diz"),I(T,"class","done-btn svelte-6a0diz"),I(R,"class","button-group svelte-6a0diz"),I(c,"class","modal-content svelte-6a0diz"),I(n,"class","modal svelte-6a0diz"),F(n,"dark",e[1]),I(t,"class","modal-overlay svelte-6a0diz")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(s,r),f(s,o),f(s,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(u,v),f(v,y),x(y,e[2]),f(v,b),f(v,C),U.m(C,null),f(c,S),O&&O.m(c,null),f(c,B),f(c,$),f($,D),f($,Q),H.m($,null),f(c,P),f(c,R),f(R,T),L||(_=[A(l,"click",e[7]),A(y,"input",e[14]),A(y,"keydown",e[11]),A(C,"click",e[9]),A(T,"click",e[7]),A(n,"click",k(e[13])),A(t,"click",e[7])],L=!0)},p(e,t){8&t&&(y.disabled=e[3]),4&t&&y.value!==e[2]&&x(y,e[2]),M!==(M=N(e))&&(U.d(1),U=M(e),U&&(U.c(),U.m(C,null))),12&t&&E!==(E=e[3]||!e[2].trim())&&(C.disabled=E),e[4]?O?O.p(e,t):(O=px(e),O.c(),O.m(c,B)):O&&(O.d(1),O=null),z===(z=j(e))&&H?H.p(e,t):(H.d(1),H=z(e),H&&(H.c(),H.m($,null))),2&t&&F(n,"dark",e[1])},d(e){e&&p(t),U.d(),O&&O.d(),H.d(),L=!1,i(_)}}}function fx(e){let t;return{c(){t=y("Add")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function hx(e){let t;return{c(){t=y("Adding...")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function px(e){let t,n;return{c(){t=m("div"),n=y(e[4]),I(t,"class","error-message svelte-6a0diz")},m(e,i){h(e,t,i),f(t,n)},p(e,t){16&t&&E(n,e[4])},d(e){e&&p(t)}}}function gx(t){let n;return{c(){n=m("div"),n.textContent="No saved relays. Add one above to get started.",I(n,"class","empty-state svelte-6a0diz")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function mx(e){let t,n=e[6],i=[];for(let t=0;t<n.length;t+=1)i[t]=wx(ux(e,n,t));return{c(){t=m("div");for(let e=0;e<i.length;e+=1)i[e].c();I(t,"class","saved-relays-list svelte-6a0diz")},m(e,n){h(e,t,n);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null)},p(e,s){if(5480&s){let r;for(n=e[6],r=0;r<n.length;r+=1){const o=ux(e,n,r);i[r]?i[r].p(o,s):(i[r]=wx(o),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){e&&p(t),g(i,e)}}}function vx(e){let t;return{c(){t=m("span"),t.textContent="Connecting...",I(t,"class","connecting-badge svelte-6a0diz")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function yx(e){let t;return{c(){t=m("span"),t.textContent="Connected",I(t,"class","current-badge svelte-6a0diz")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function wx(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C=e[20].name+"";function x(e,t){return 64&t&&(c=null),null==c&&(c=!!e[12](e[20].url)),c?yx:e[5]===e[20].url?vx:void 0}let S=x(e,-1),B=S&&S(e);function $(){return e[15](e[20])}function D(...t){return e[16](e[20],...t)}return{c(){t=m("div"),n=m("button"),s=m("span"),r=w(),o=m("span"),l=y(C),a=w(),B&&B.c(),u=w(),d=m("button"),g=y("Remove"),v=w(),I(s,"class","relay-status-dot svelte-6a0diz"),F(s,"connected",e[12](e[20].url)),I(o,"class","relay-url-label svelte-6a0diz"),I(n,"class","relay-connect-btn svelte-6a0diz"),n.disabled=e[3],I(n,"title","Click to connect"),I(d,"class","relay-remove-btn svelte-6a0diz"),I(d,"title","Remove relay"),d.disabled=e[3],I(t,"class","relay-item svelte-6a0diz"),F(t,"current",e[12](e[20].url)),F(t,"connecting",e[5]===e[20].url)},m(e,i){h(e,t,i),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(n,a),B&&B.m(n,null),f(t,u),f(t,d),f(d,g),f(t,v),b||(k=[A(n,"click",$),A(d,"click",D)],b=!0)},p(i,r){e=i,4160&r&&F(s,"connected",e[12](e[20].url)),64&r&&C!==(C=e[20].name+"")&&E(l,C),S!==(S=x(e,r))&&(B&&B.d(1),B=S&&S(e),B&&(B.c(),B.m(n,null))),8&r&&(n.disabled=e[3]),8&r&&(d.disabled=e[3]),4160&r&&F(t,"current",e[12](e[20].url)),96&r&&F(t,"connecting",e[5]===e[20].url)},d(e){e&&p(t),B&&B.d(),b=!1,i(k)}}}function bx(t){let n,i=t[0]&&dx(t);return{c(){i&&i.c(),n=b()},m(e,t){i&&i.m(e,t),h(e,n,t)},p(e,[t]){e[0]?i?i.p(e,t):(i=dx(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&p(n)}}}function Ax(e,t,n){let i,s,r;u(e,Ch,e=>n(17,i=e)),u(e,Ah,e=>n(18,s=e)),u(e,Sh,e=>n(6,r=e));const o=L();let{showModal:l=!1}=t,{isDarkTheme:a=!1}=t,c="",d=!1,f="",h="";function p(){n(0,l=!1),n(4,f=""),o("close")}async function g(e=null){const t=e||c.trim();if(t){n(3,d=!0),n(5,h=t),n(4,f="");try{const e=await Oh(t);if(e.success){Ph(t,zh(t)),n(2,c=""),o("connected",{info:e.info}),p()}else n(4,f=e.error||"Failed to connect")}catch(e){n(4,f=e.message||"Connection failed")}finally{n(3,d=!1),n(5,h="")}}else n(4,f="Please enter a relay URL")}async function m(){const e=c.trim();if(e){n(3,d=!0),n(4,f="");try{const t=await Oh(e);if(t.success){Ph(e,zh(e)),n(2,c=""),o("connected",{info:t.info})}else n(4,f=t.error||"Failed to connect")}catch(e){n(4,f=e.message||"Connection failed")}finally{n(3,d=!1)}}else n(4,f="Please enter a relay URL")}function v(e,t){t.stopPropagation(),function(e){Sh.update(t=>t.filter(t=>t.url!==e))}(e)}return e.$$set=e=>{"showModal"in e&&n(0,l=e.showModal),"isDarkTheme"in e&&n(1,a=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty&&l&&(n(2,c=""),n(4,f=""))},[l,a,c,d,f,h,r,p,g,m,v,function(e){"Enter"!==e.key||d?"Escape"===e.key&&p():m()},function(e){return s===e&&"connected"===i},function(t){_.call(this,e,t)},function(){c=this.value,n(2,c),n(0,l)},e=>g(e.url),(e,t)=>v(e.url,t)]}class kx extends fe{constructor(e){super(),de(this,e,Ax,bx,r,{showModal:0,isDarkTheme:1})}}function Ix(e,t,n){const i=e.slice();return i[202]=t[n],i}function Cx(e,t,n){const i=e.slice();return i[212]=t[n],i}function Ex(e,t,n){const i=e.slice();return i[205]=t[n],i}function xx(e,t,n){const i=e.slice();i[205]=t[n];const s=i[65](i[205]);return i[206]=s,i}function Sx(e,t,n){const i=e.slice();return i[209]=t[n],i}function Bx(t){let n;function i(e,t){return e[1]?Rx:Px}let s=i(t),r=s(t);return{c(){n=m("div"),r.c(),I(n,"class","welcome-message svelte-4k872n")},m(e,t){h(e,n,t),r.m(n,null)},p(e,t){s===(s=i(e))&&r?r.p(e,t):(r.d(1),r=s(e),r&&(r.c(),r.m(n,null)))},i:e,o:e,d(e){e&&p(n),r.d()}}}function $x(e){let t,n,i,s,r;const o=[Kx,Jx,Gx,qx,Hx,zx,jx,Ox,Ux,Mx,Nx,_x,Lx,Tx],l=[];function a(e,n){return 96&n[0]&&(t=null),"export"===e[5]?0:"import"===e[5]?1:"events"===e[5]?2:"blossom"===e[5]?3:"compose"===e[5]?4:"managed-acl"===e[5]?5:"curation"===e[5]?6:"sprocket"===e[5]?7:"policy"===e[5]?8:"relay-connect"===e[5]?9:"logs"===e[5]?10:"recovery"===e[5]?11:(null==t&&(t=!!e[6].some(e[123])),t?12:13)}return n=a(e,[-1,-1,-1,-1,-1,-1,-1]),i=l[n]=o[n](e),{c(){i.c(),s=b()},m(e,t){l[n].m(e,t),h(e,s,t),r=!0},p(e,t){let r=n;n=a(e,t),n===r?l[n].p(e,t):(ee(),ie(l[r],1,1,()=>{l[r]=null}),te(),i=l[n],i?i.p(e,t):(i=l[n]=o[n](e),i.c()),ne(i,1),i.m(s.parentNode,s))},i(e){r||(ne(i),r=!0)},o(e){ie(i),r=!1},d(e){l[n].d(e),e&&p(s)}}}function Fx(e){let t,n;return t=new $b({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[19],subView:e[52].replace("library-","")}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),524288&n[0]&&(i.userSigner=e[19]),2097152&n[1]&&(i.subView=e[52].replace("library-","")),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function Dx(e){let t,n;return t=new Dw({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[19]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),524288&n[0]&&(i.userSigner=e[19]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function Qx(e){let t,n;return t=new Ly({props:{isLoggedIn:e[1],userPubkey:e[2],userContactList:e[18]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),262144&n[0]&&(i.userContactList=e[18]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function Px(t){let n;return{c(){n=m("p"),n.textContent="Log in to access your user dashboard",I(n,"class","svelte-4k872n")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Rx(e){let t,n,i,s=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=m("p"),n=y("Welcome "),i=y(s),I(t,"class","svelte-4k872n")},m(e,s){h(e,t,s),f(t,n),f(t,i)},p(e,t){12&t[0]&&s!==(s=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(i,s)},d(e){e&&p(t)}}}function Tx(t){let n;return{c(){n=m("div"),n.innerHTML='<p class="svelte-4k872n">Select a tab from the Admin section.</p>',I(n,"class","welcome-message svelte-4k872n")},m(e,t){h(e,n,t)},p:e,i:e,o:e,d(e){e&&p(n)}}}function Lx(e){let t,n,i=e[6],s=[];for(let t=0;t<i.length;t+=1)s[t]=iS(Cx(e,i,t));const r=e=>ie(s[e],1,1,()=>{s[e]=null});return{c(){for(let e=0;e<s.length;e+=1)s[e].c();t=b()},m(e,i){for(let t=0;t<s.length;t+=1)s[t]&&s[t].m(e,i);h(e,t,i),n=!0},p(e,n){if(33554548&n[0]|385875968&n[1]|896&n[3]){let o;for(i=e[6],o=0;o<i.length;o+=1){const r=Cx(e,i,o);s[o]?(s[o].p(r,n),ne(s[o],1)):(s[o]=iS(r),s[o].c(),ne(s[o],1),s[o].m(t.parentNode,t))}for(ee(),o=i.length;o<s.length;o+=1)r(o);te()}},i(e){if(!n){for(let e=0;e<i.length;e+=1)ne(s[e]);n=!0}},o(e){s=s.filter(Boolean);for(let e=0;e<s.length;e+=1)ie(s[e]);n=!1},d(e){g(s,e),e&&p(t)}}}function _x(t){let n,s,r,o,l,a,c,u,d,v,y,b,k,E,S,$,F,D,Q=null!==t[43]&&void 0!==t[43]&&t[43]>=0||""!==t[44]&&parseInt(t[44])>=0,P=Gh,R=[];for(let e=0;e<P.length;e+=1)R[e]=sS(Sx(t,P,e));let T=Q&&rS(t);return{c(){n=m("div"),s=m("div"),s.innerHTML='<h3 class="svelte-4k872n">Event Recovery</h3> \n                    <p class="svelte-4k872n">Search and recover old versions of replaceable events</p>',r=w(),o=m("div"),l=m("div"),a=m("div"),c=m("label"),c.textContent="Select Event Kind:",u=w(),d=m("select"),v=m("option"),v.textContent="Choose a replaceable kind...";for(let e=0;e<R.length;e+=1)R[e].c();y=w(),b=m("div"),k=m("label"),k.textContent="Or enter custom kind number:",E=w(),S=m("input"),$=w(),T&&T.c(),I(c,"for","recovery-kind"),I(c,"class","svelte-4k872n"),v.__value=null,v.value=v.__value,I(d,"id","recovery-kind"),I(d,"class","svelte-4k872n"),void 0===t[43]&&G(()=>t[135].call(d)),I(a,"class","kind-selector svelte-4k872n"),I(k,"for","custom-kind"),I(k,"class","svelte-4k872n"),I(S,"id","custom-kind"),I(S,"type","number"),I(S,"placeholder","e.g., 10001"),I(S,"min","0"),I(S,"class","svelte-4k872n"),I(b,"class","custom-kind-input svelte-4k872n"),I(l,"class","recovery-controls svelte-4k872n"),I(o,"class","recovery-controls-card svelte-4k872n"),I(n,"class","recovery-tab svelte-4k872n")},m(e,i){h(e,n,i),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(a,c),f(a,u),f(a,d),f(d,v);for(let e=0;e<R.length;e+=1)R[e]&&R[e].m(d,null);B(d,t[43],!0),f(l,y),f(l,b),f(b,k),f(b,E),f(b,S),x(S,t[44]),f(n,$),T&&T.m(n,null),F||(D=[A(d,"change",t[135]),A(d,"change",t[63]),A(S,"input",t[136]),A(S,"input",t[64])],F=!0)},p(e,t){if(0&t){let n;for(P=Gh,n=0;n<P.length;n+=1){const i=Sx(e,P,n);R[n]?R[n].p(i,t):(R[n]=sS(i),R[n].c(),R[n].m(d,null))}for(;n<R.length;n+=1)R[n].d(1);R.length=P.length}4096&t[1]&&B(d,e[43]),8192&t[1]&&C(S.value)!==e[44]&&x(S,e[44]),12288&t[1]&&(Q=null!==e[43]&&void 0!==e[43]&&e[43]>=0||""!==e[44]&&parseInt(e[44])>=0),Q?T?T.p(e,t):(T=rS(e),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},i:e,o:e,d(e){e&&p(n),g(R,e),T&&T.d(),F=!1,i(D)}}}function Nx(t){let n,i,s=t[53],o=pS(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),h(e,n,t),i=!0},p(t,i){4194304&i[1]&&r(s,s=t[53])?(ee(),ie(o,1,1,e),te(),o=pS(t),o.c(),ne(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ne(o),i=!0)},o(e){ie(o),i=!1},d(e){e&&p(n),o.d(e)}}}function Mx(t){let n,i,s=t[53],o=gS(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),h(e,n,t),i=!0},p(t,i){4194304&i[1]&&r(s,s=t[53])?(ee(),ie(o,1,1,e),te(),o=gS(t),o.c(),ne(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ne(o),i=!0)},o(e){ie(o),i=!1},d(e){e&&p(n),o.d(e)}}}function Ux(e){let t,n,i;function s(t){e[134](t)}let r={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:HS,policyEnabled:e[9],isLoadingPolicy:e[34],policyMessage:e[35],policyMessageType:e[36],validationErrors:e[37],policyFollows:e[38]};return void 0!==e[33]&&(r.policyJson=e[33]),t=new Ok({props:r}),M.push(()=>le(t,"policyJson",s)),t.$on("loadPolicy",e[78]),t.$on("validatePolicy",e[79]),t.$on("savePolicy",e[80]),t.$on("formatJson",e[81]),t.$on("addPolicyAdmin",e[82]),t.$on("removePolicyAdmin",e[83]),t.$on("refreshFollows",e[84]),t.$on("openLoginModal",e[89]),{c(){ae(t.$$.fragment)},m(e,n){ce(t,e,n),i=!0},p(e,i){const s={};2&i[0]&&(s.isLoggedIn=e[1]),16&i[0]&&(s.userRole=e[4]),512&i[0]&&(s.policyEnabled=e[9]),8&i[1]&&(s.isLoadingPolicy=e[34]),16&i[1]&&(s.policyMessage=e[35]),32&i[1]&&(s.policyMessageType=e[36]),64&i[1]&&(s.validationErrors=e[37]),128&i[1]&&(s.policyFollows=e[38]),!n&&4&i[1]&&(n=!0,s.policyJson=e[33],J(()=>n=!1)),t.$set(s)},i(e){i||(ne(t.$$.fragment,e),i=!0)},o(e){ie(t.$$.fragment,e),i=!1},d(e){ue(t,e)}}}function Ox(e){let t,n,i;function s(t){e[131](t)}let r={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[27],isLoadingSprocket:e[29],sprocketUploadFile:e[32],sprocketMessage:e[30],sprocketMessageType:e[31],sprocketVersions:e[28]};return void 0!==e[26]&&(r.sprocketScript=e[26]),t=new kk({props:r}),M.push(()=>le(t,"sprocketScript",s)),t.$on("restartSprocket",e[73]),t.$on("deleteSprocket",e[74]),t.$on("sprocketFileSelect",e[85]),t.$on("uploadSprocketScript",e[86]),t.$on("saveSprocket",e[72]),t.$on("loadSprocket",e[71]),t.$on("loadVersions",e[75]),t.$on("loadVersion",e[132]),t.$on("deleteVersion",e[133]),t.$on("openLoginModal",e[89]),{c(){ae(t.$$.fragment)},m(e,n){ce(t,e,n),i=!0},p(e,i){const s={};2&i[0]&&(s.isLoggedIn=e[1]),16&i[0]&&(s.userRole=e[4]),134217728&i[0]&&(s.sprocketStatus=e[27]),536870912&i[0]&&(s.isLoadingSprocket=e[29]),2&i[1]&&(s.sprocketUploadFile=e[32]),1073741824&i[0]&&(s.sprocketMessage=e[30]),1&i[1]&&(s.sprocketMessageType=e[31]),268435456&i[0]&&(s.sprocketVersions=e[28]),!n&&67108864&i[0]&&(n=!0,s.sprocketScript=e[26],J(()=>n=!1)),t.$set(s)},i(e){i||(ne(t.$$.fragment,e),i=!0)},o(e){ie(t.$$.fragment,e),i=!1},d(e){ue(t,e)}}}function jx(e){let t,n,i,s;const r=[yS,vS,mS],o=[];function l(e,t){return"curating"!==e[12]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=r[n](e),{c(){t=m("div"),i.c(),I(t,"class","curation-view-container")},m(e,i){h(e,t,i),o[n].m(t,null),s=!0},p(e,s){let a=n;n=l(e),n===a?o[n].p(e,s):(ee(),ie(o[a],1,1,()=>{o[a]=null}),te(),i=o[n],i?i.p(e,s):(i=o[n]=r[n](e),i.c()),ne(i,1),i.m(t,null))},i(e){s||(ne(i),s=!0)},o(e){ie(i),s=!1},d(e){e&&p(t),o[n].d()}}}function zx(e){let t,n,i,s;const r=[kS,AS,bS],o=[];function l(e,t){return"managed"!==e[12]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=r[n](e),{c(){t=m("div"),i.c(),I(t,"class","managed-acl-view svelte-4k872n")},m(e,i){h(e,t,i),o[n].m(t,null),s=!0},p(e,s){let a=n;n=l(e),n===a?o[n].p(e,s):(ee(),ie(o[a],1,1,()=>{o[a]=null}),te(),i=o[n],i?i.p(e,s):(i=o[n]=r[n](e),i.c()),ne(i,1),i.m(t,null))},i(e){s||(ne(i),s=!0)},o(e){ie(i),s=!1},d(e){e&&p(t),o[n].d()}}}function Hx(e){let t,n,i,s;function r(t){e[129](t)}function o(t){e[130](t)}let l={userPubkey:e[2],userRole:e[4],policyEnabled:e[9],publishError:e[41]};return void 0!==e[40]&&(l.composeEventJson=e[40]),void 0!==e[42]&&(l.localOnly=e[42]),t=new uk({props:l}),M.push(()=>le(t,"composeEventJson",r)),M.push(()=>le(t,"localOnly",o)),t.$on("reformatJson",e[110]),t.$on("signEvent",e[111]),t.$on("publishEvent",e[112]),t.$on("clearError",e[113]),{c(){ae(t.$$.fragment)},m(e,n){ce(t,e,n),s=!0},p(e,s){const r={};4&s[0]&&(r.userPubkey=e[2]),16&s[0]&&(r.userRole=e[4]),512&s[0]&&(r.policyEnabled=e[9]),1024&s[1]&&(r.publishError=e[41]),!n&&512&s[1]&&(n=!0,r.composeEventJson=e[40],J(()=>n=!1)),!i&&2048&s[1]&&(i=!0,r.localOnly=e[42],J(()=>i=!1)),t.$set(r)},i(e){s||(ne(t.$$.fragment,e),s=!0)},o(e){ie(t.$$.fragment,e),s=!1},d(e){ue(t,e)}}}function qx(t){let n,i,s=t[53],o=CS(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),h(e,n,t),i=!0},p(t,i){4194304&i[1]&&r(s,s=t[53])?(ee(),ie(o,1,1,e),te(),o=CS(t),o.c(),ne(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ne(o),i=!0)},o(e){ie(o),i=!1},d(e){e&&p(n),o.d(e)}}}function Gx(e){let t,n,i,s;const r=[SS,xS,ES],o=[];function l(e,t){return!e[1]||"read"!==e[4]&&"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?e[1]&&!e[4]?1:2:0}return t=l(e),n=o[t]=r[t](e),{c(){n.c(),i=b()},m(e,n){o[t].m(e,n),h(e,i,n),s=!0},p(e,s){let a=t;t=l(e),t===a?o[t].p(e,s):(ee(),ie(o[a],1,1,()=>{o[a]=null}),te(),n=o[t],n?n.p(e,s):(n=o[t]=r[t](e),n.c()),ne(n,1),n.m(i.parentNode,i))},i(e){s||(ne(n),s=!0)},o(e){ie(n),s=!1},d(e){o[t].d(e),e&&p(i)}}}function Jx(e){let t,n;return t=new Jb({props:{isLoggedIn:e[1],currentEffectiveRole:e[13],selectedFile:e[23],aclMode:e[12],importMessage:e[24]}}),t.$on("fileSelect",e[106]),t.$on("importEvents",e[107]),t.$on("openLoginModal",e[89]),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),8192&n[0]&&(i.currentEffectiveRole=e[13]),8388608&n[0]&&(i.selectedFile=e[23]),4096&n[0]&&(i.aclMode=e[12]),16777216&n[0]&&(i.importMessage=e[24]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function Kx(e){let t,n;return t=new Ub({props:{isLoggedIn:e[1],currentEffectiveRole:e[13],aclMode:e[12],isExporting:e[49]}}),t.$on("exportMyEvents",e[105]),t.$on("exportAllEvents",e[104]),t.$on("openLoginModal",e[89]),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),8192&n[0]&&(i.currentEffectiveRole=e[13]),4096&n[0]&&(i.aclMode=e[12]),262144&n[1]&&(i.isExporting=e[49]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function Vx(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,F,D,Q=e[212].label+"",P=e[55].get(e[212].id)?.isLoading,R=!e[55].get(e[212].id)?.hasMore&&e[55].get(e[212].id)?.events?.length>0;function T(){return e[140](e[212])}function L(e,t){return 64&t[0]&&(k=null),64&t[0]&&(C=null),null==k&&(k=!!(e[55].get(e[212].id)?.events?.length>0)),k?Yx:(null==C&&(C=!e[55].get(e[212].id)?.isLoading),C?Wx:void 0)}g=new cx({props:{filter:e[55].get(e[212].id)?.filter||{}}}),g.$on("sweep",function(){return e[141](e[212])});let _=L(e,[-1,-1,-1,-1,-1,-1,-1]),N=_&&_(e),M=P&&tS(),U=R&&nS();function O(...t){return e[146](e[212],...t)}return{c(){t=m("div"),n=m("div"),s=m("h2"),r=y("🔍 "),o=y(Q),l=w(),a=m("button"),c=y("🔄 Refresh"),d=w(),ae(g.$$.fragment),v=w(),b=m("div"),N&&N.c(),x=w(),M&&M.c(),S=w(),U&&U.c(),B=w(),I(s,"class","svelte-4k872n"),I(a,"class","refresh-btn svelte-4k872n"),a.disabled=u=e[55].get(e[212].id)?.isLoading,I(n,"class","search-results-header svelte-4k872n"),I(b,"class","search-results-content svelte-4k872n"),I(t,"class","search-results-view svelte-4k872n")},m(e,i){h(e,t,i),f(t,n),f(n,s),f(s,r),f(s,o),f(n,l),f(n,a),f(a,c),f(t,d),ce(g,t,null),f(t,v),f(t,b),N&&N.m(b,null),f(b,x),M&&M.m(b,null),f(b,S),U&&U.m(b,null),f(t,B),$=!0,F||(D=[A(a,"click",T),A(b,"scroll",O)],F=!0)},p(t,n){e=t,(!$||64&n[0])&&Q!==(Q=e[212].label+"")&&E(o,Q),(!$||64&n[0]&&u!==(u=e[55].get(e[212].id)?.isLoading))&&(a.disabled=u);const i={};64&n[0]&&(i.filter=e[55].get(e[212].id)?.filter||{}),g.$set(i),_===(_=L(e,n))&&N?N.p(e,n):(N&&N.d(1),N=_&&_(e),N&&(N.c(),N.m(b,x))),64&n[0]&&(P=e[55].get(e[212].id)?.isLoading),P?M||(M=tS(),M.c(),M.m(b,S)):M&&(M.d(1),M=null),64&n[0]&&(R=!e[55].get(e[212].id)?.hasMore&&e[55].get(e[212].id)?.events?.length>0),R?U||(U=nS(),U.c(),U.m(b,null)):U&&(U.d(1),U=null)},i(e){$||(ne(g.$$.fragment,e),$=!0)},o(e){ie(g.$$.fragment,e),$=!1},d(e){e&&p(t),ue(g),N&&N.d(),M&&M.d(),U&&U.d(),F=!1,i(D)}}}function Wx(t){let n;return{c(){n=m("div"),n.innerHTML='<p class="svelte-4k872n">No search results found.</p>',I(n,"class","no-search-results svelte-4k872n")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function Yx(e){let t,n=e[55].get(e[212].id).events,i=[];for(let t=0;t<n.length;t+=1)i[t]=eS(Ex(e,n,t));return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=b()},m(e,n){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,n);h(e,t,n)},p(e,s){if(33554516&s[0]|385875968&s[1]){let r;for(n=e[55].get(e[212].id).events,r=0;r<n.length;r+=1){const o=Ex(e,n,r);i[r]?i[r].p(o,s):(i[r]=eS(o),i[r].c(),i[r].m(t.parentNode,t))}for(;r<i.length;r+=1)i[r].d(1);i.length=n.length}},d(e){g(i,e),e&&p(t)}}}function Zx(e){let t,n,i;function s(){return e[142](e[205])}return{c(){t=m("button"),t.textContent="🗑️",I(t,"class","delete-btn svelte-4k872n")},m(e,r){h(e,t,r),n||(i=A(t,"click",k(s)),n=!0)},p(t,n){e=t},d(e){e&&p(t),n=!1,i()}}}function Xx(e){let t,n,i,s,r,o,l,a,c=JSON.stringify(e[205],null,2)+"";function u(...t){return e[145](e[205],...t)}return{c(){t=m("div"),n=m("div"),i=m("pre"),s=y(c),r=w(),o=m("button"),o.textContent="📋",I(i,"class","event-json svelte-4k872n"),I(o,"class","copy-json-btn svelte-4k872n"),I(o,"title","Copy minified JSON to clipboard"),I(n,"class","json-container svelte-4k872n"),I(t,"class","search-result-details svelte-4k872n")},m(e,c){h(e,t,c),f(t,n),f(n,i),f(i,s),f(n,r),f(n,o),l||(a=A(o,"click",k(u)),l=!0)},p(t,n){e=t,64&n[0]&&c!==(c=JSON.stringify(e[205],null,2)+"")&&E(s,c)},d(e){e&&p(t),l=!1,a()}}}function eS(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B,$,D,Q,P,R,T,L,_,N=NE(e[205].pubkey)+"",M=e[205].kind+"",U=_E(e[205].kind)+"",O=UE(e[205].created_at)+"",j=ME(e[205].content)+"",z=e[25].has(e[205].id),H=5!==e[205].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[205].pubkey&&e[205].pubkey===e[2])&&Zx(e);function q(){return e[143](e[205])}function G(...t){return e[144](e[205],...t)}let J=z&&Xx(e);return{c(){t=m("div"),n=m("div"),s=m("div"),s.innerHTML='<div class="avatar-placeholder svelte-4k872n">👤</div>',r=w(),o=m("div"),l=m("div"),a=y(N),c=w(),u=m("div"),d=m("span"),g=y(M),v=w(),b=m("span"),k=y(U),C=w(),x=m("div"),S=m("div"),B=y(O),$=w(),D=m("div"),Q=y(j),P=w(),H&&H.c(),R=w(),J&&J.c(),T=w(),I(s,"class","search-result-avatar svelte-4k872n"),I(l,"class","search-result-author svelte-4k872n"),I(d,"class","kind-number svelte-4k872n"),I(b,"class","kind-name svelte-4k872n"),I(u,"class","search-result-kind svelte-4k872n"),I(o,"class","search-result-info svelte-4k872n"),I(S,"class","event-timestamp svelte-4k872n"),I(D,"class","event-content-single-line svelte-4k872n"),I(x,"class","search-result-content svelte-4k872n"),I(n,"class","search-result-row svelte-4k872n"),I(n,"role","button"),I(n,"tabindex","0"),I(t,"class","search-result-item svelte-4k872n"),F(t,"expanded",e[25].has(e[205].id))},m(e,i){h(e,t,i),f(t,n),f(n,s),f(n,r),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(d,g),f(u,v),f(u,b),f(b,k),f(n,C),f(n,x),f(x,S),f(S,B),f(x,$),f(x,D),f(D,Q),f(n,P),H&&H.m(n,null),f(t,R),J&&J.m(t,null),f(t,T),L||(_=[A(n,"click",q),A(n,"keydown",G)],L=!0)},p(i,s){e=i,64&s[0]&&N!==(N=NE(e[205].pubkey)+"")&&E(a,N),64&s[0]&&M!==(M=e[205].kind+"")&&E(g,M),64&s[0]&&U!==(U=_E(e[205].kind)+"")&&E(k,U),64&s[0]&&O!==(O=UE(e[205].created_at)+"")&&E(B,O),64&s[0]&&j!==(j=ME(e[205].content)+"")&&E(Q,j),5!==e[205].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[205].pubkey&&e[205].pubkey===e[2])?H?H.p(e,s):(H=Zx(e),H.c(),H.m(n,null)):H&&(H.d(1),H=null),33554496&s[0]&&(z=e[25].has(e[205].id)),z?J?J.p(e,s):(J=Xx(e),J.c(),J.m(t,T)):J&&(J.d(1),J=null),33554496&s[0]|16777216&s[1]&&F(t,"expanded",e[25].has(e[205].id))},d(e){e&&p(t),H&&H.d(),J&&J.d(),L=!1,i(_)}}}function tS(e){let t;return{c(){t=m("div"),t.innerHTML='<div class="loading-spinner svelte-4k872n"></div> \n                                    <p class="svelte-4k872n">Searching...</p>',I(t,"class","loading-search-results svelte-4k872n")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function nS(e){let t;return{c(){t=m("div"),t.innerHTML='<p class="svelte-4k872n">No more search results to load.</p>',I(t,"class","end-of-search-results svelte-4k872n")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function iS(e){let t,n,i=e[212].id===e[5]&&Vx(e);return{c(){i&&i.c(),t=b()},m(e,s){i&&i.m(e,s),h(e,t,s),n=!0},p(e,n){e[212].id===e[5]?i?(i.p(e,n),96&n[0]&&ne(i,1)):(i=Vx(e),i.c(),ne(i,1),i.m(t.parentNode,t)):i&&(ee(),ie(i,1,1,()=>{i=null}),te())},i(e){n||(ne(i),n=!0)},o(e){ie(i),n=!1},d(e){i&&i.d(e),e&&p(t)}}}function sS(t){let n,i,s=t[209].label+"";return{c(){n=m("option"),i=y(s),n.__value=t[209].value,n.value=n.__value},m(e,t){h(e,n,t),f(n,i)},p:e,d(e){e&&p(n)}}}function rS(e){let t;function n(e,t){return e[46]?aS:0===e[45].length?lS:oS}let i=n(e),s=i(e);return{c(){t=m("div"),s.c(),I(t,"class","recovery-results svelte-4k872n")},m(e,n){h(e,t,n),s.m(t,null)},p(e,r){i===(i=n(e))&&s?s.p(e,r):(s.d(1),s=i(e),s&&(s.c(),s.m(t,null)))},d(e){e&&p(t),s.d()}}}function oS(e){let t,n,i,s=e[45],r=[];for(let t=0;t<s.length;t+=1)r[t]=fS(xx(e,s,t));let o=e[47]&&hS(e);return{c(){t=m("div");for(let e=0;e<r.length;e+=1)r[e].c();n=w(),o&&o.c(),i=b(),I(t,"class","events-list svelte-4k872n")},m(e,s){h(e,t,s);for(let e=0;e<r.length;e+=1)r[e]&&r[e].m(t,null);h(e,n,s),o&&o.m(e,s),h(e,i,s)},p(e,n){if(8192&n[0]|1140867072&n[1]|9&n[2]){let i;for(s=e[45],i=0;i<s.length;i+=1){const o=xx(e,s,i);r[i]?r[i].p(o,n):(r[i]=fS(o),r[i].c(),r[i].m(t,null))}for(;i<r.length;i+=1)r[i].d(1);r.length=s.length}e[47]?o?o.p(e,n):(o=hS(e),o.c(),o.m(i.parentNode,i)):o&&(o.d(1),o=null)},d(e){e&&p(t),g(r,e),e&&p(n),o&&o.d(e),e&&p(i)}}}function lS(t){let n;return{c(){n=m("div"),n.textContent="No events found for this kind",I(n,"class","no-events svelte-4k872n")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function aS(t){let n;return{c(){n=m("div"),n.textContent="Loading events...",I(n,"class","loading svelte-4k872n")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function cS(e){let t;return{c(){t=y("Current Version")},m(e,n){h(e,t,n)},d(e){e&&p(t)}}}function uS(e){let t,n,i,s,r;function o(){return e[137](e[205])}let l="read"!==e[13]&&dS(e);return{c(){t=m("button"),t.textContent="🌐 Repost to All",n=w(),l&&l.c(),i=b(),I(t,"class","repost-all-button svelte-4k872n")},m(e,a){h(e,t,a),h(e,n,a),l&&l.m(e,a),h(e,i,a),s||(r=A(t,"click",o),s=!0)},p(t,n){"read"!==(e=t)[13]?l?l.p(e,n):(l=dS(e),l.c(),l.m(i.parentNode,i)):l&&(l.d(1),l=null)},d(e){e&&p(t),e&&p(n),l&&l.d(e),e&&p(i),s=!1,r()}}}function dS(e){let t,n,i;function s(){return e[138](e[205])}return{c(){t=m("button"),t.textContent="🔄 Repost",I(t,"class","repost-button svelte-4k872n")},m(e,r){h(e,t,r),n||(i=A(t,"click",s),n=!0)},p(t,n){e=t},d(e){e&&p(t),n=!1,i()}}}function fS(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,b,C,x,S,B,$=new Date(1e3*e[205].created_at).toLocaleString()+"",D=JSON.stringify(e[205],null,2)+"",Q=e[206]&&cS(),P=!e[206]&&uS(e);function R(...t){return e[139](e[205],...t)}return{c(){t=m("div"),n=m("div"),i=m("div"),s=m("span"),Q&&Q.c(),r=w(),o=m("span"),l=y($),a=w(),c=m("div"),P&&P.c(),u=w(),d=m("button"),d.textContent="📋 Copy JSON",g=w(),v=m("div"),b=m("pre"),C=y(D),x=w(),I(s,"class","event-kind svelte-4k872n"),I(o,"class","event-timestamp svelte-4k872n"),I(i,"class","event-header-left svelte-4k872n"),I(d,"class","copy-json-btn svelte-4k872n"),I(c,"class","event-header-actions svelte-4k872n"),I(n,"class","event-header svelte-4k872n"),I(b,"class","event-json svelte-4k872n"),I(v,"class","event-content svelte-4k872n"),I(t,"class","event-item svelte-4k872n"),F(t,"old-version",!e[206])},m(e,p){h(e,t,p),f(t,n),f(n,i),f(i,s),Q&&Q.m(s,null),f(i,r),f(i,o),f(o,l),f(n,a),f(n,c),P&&P.m(c,null),f(c,u),f(c,d),f(t,g),f(t,v),f(v,b),f(b,C),f(t,x),S||(B=A(d,"click",k(R)),S=!0)},p(n,i){(e=n)[206]?Q||(Q=cS(),Q.c(),Q.m(s,null)):Q&&(Q.d(1),Q=null),16384&i[1]&&$!==($=new Date(1e3*e[205].created_at).toLocaleString()+"")&&E(l,$),e[206]?P&&(P.d(1),P=null):P?P.p(e,i):(P=uS(e),P.c(),P.m(c,u)),16384&i[1]&&D!==(D=JSON.stringify(e[205],null,2)+"")&&E(C,D),16384&i[1]|8&i[2]&&F(t,"old-version",!e[206])},d(e){e&&p(t),Q&&Q.d(),P&&P.d(),S=!1,B()}}}function hS(e){let t,n,i,s;return{c(){t=m("button"),n=y("Load More Events"),I(t,"class","load-more svelte-4k872n"),t.disabled=e[46]},m(r,o){h(r,t,o),f(t,n),i||(s=A(t,"click",e[60]),i=!0)},p(e,n){32768&n[1]&&(t.disabled=e[46])},d(e){e&&p(t),i=!1,s()}}}function pS(e){let t,n;return t=new PE({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[19]}}),t.$on("openLoginModal",e[89]),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),524288&n[0]&&(i.userSigner=e[19]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function gS(e){let t,n;return t=new rx({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[19],userPubkey:e[2]}}),t.$on("openLoginModal",e[89]),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),524288&n[0]&&(i.userSigner=e[19]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function mS(t){let n,i,s,r,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in with owner permissions to access\n                            curation configuration.",s=w(),r=m("button"),r.textContent="Log In",I(r,"class","login-btn svelte-4k872n"),I(n,"class","access-denied svelte-4k872n")},m(e,a){h(e,n,a),f(n,i),f(n,s),f(n,r),o||(l=A(r,"click",t[89]),o=!0)},p:e,i:e,o:e,d(e){e&&p(n),o=!1,l()}}}function vS(t){let n,i,s=t[53],o=wS(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),h(e,n,t),i=!0},p(t,i){4194304&i[1]&&r(s,s=t[53])?(ee(),ie(o,1,1,e),te(),o=wS(t),o.c(),ne(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ne(o),i=!0)},o(e){ie(o),i=!1},d(e){e&&p(n),o.d(e)}}}function yS(t){let n,i,s,r,o,l,a,c,u,d,g,v=(t[12]||"unknown")+"";return{c(){n=m("div"),i=m("h3"),i.textContent="Curating Mode Not Active",s=w(),r=m("p"),r.textContent='To use the Curation interface, you need to set\n                            the ACL mode to "curating" in your relay\n                            configuration.',o=w(),l=m("p"),a=y("Current ACL mode: "),c=m("strong"),u=y(v),d=w(),g=m("p"),g.innerHTML='Please set <code class="svelte-4k872n">ORLY_ACL_MODE=curating</code> in your\n                            environment variables and restart the relay.',I(i,"class","svelte-4k872n"),I(r,"class","svelte-4k872n"),I(l,"class","svelte-4k872n"),I(g,"class","svelte-4k872n"),I(n,"class","acl-mode-warning svelte-4k872n")},m(e,t){h(e,n,t),f(n,i),f(n,s),f(n,r),f(n,o),f(n,l),f(l,a),f(l,c),f(c,u),f(n,d),f(n,g)},p(e,t){4096&t[0]&&v!==(v=(e[12]||"unknown")+"")&&E(u,v)},i:e,o:e,d(e){e&&p(n)}}}function wS(e){let t,n;return t=new ZI({props:{userSigner:e[19],userPubkey:e[2]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};524288&n[0]&&(i.userSigner=e[19]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function bS(t){let n,i,s,r,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in with owner permissions to access\n                            managed ACL configuration.",s=w(),r=m("button"),r.textContent="Log In",I(r,"class","login-btn svelte-4k872n"),I(n,"class","access-denied svelte-4k872n")},m(e,a){h(e,n,a),f(n,i),f(n,s),f(n,r),o||(l=A(r,"click",t[89]),o=!0)},p:e,i:e,o:e,d(e){e&&p(n),o=!1,l()}}}function AS(t){let n,i,s=t[53],o=IS(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),h(e,n,t),i=!0},p(t,i){4194304&i[1]&&r(s,s=t[53])?(ee(),ie(o,1,1,e),te(),o=IS(t),o.c(),ne(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ne(o),i=!0)},o(e){ie(o),i=!1},d(e){e&&p(n),o.d(e)}}}function kS(t){let n,i,s,r,o,l,a,c,u,d,g,v=(t[12]||"unknown")+"";return{c(){n=m("div"),i=m("h3"),i.textContent="⚠️ Managed ACL Mode Not Active",s=w(),r=m("p"),r.textContent='To use the Managed ACL interface, you need to set\n                            the ACL mode to "managed" in your relay\n                            configuration.',o=w(),l=m("p"),a=y("Current ACL mode: "),c=m("strong"),u=y(v),d=w(),g=m("p"),g.innerHTML='Please set <code class="svelte-4k872n">ORLY_ACL_MODE=managed</code> in your\n                            environment variables and restart the relay.',I(i,"class","svelte-4k872n"),I(r,"class","svelte-4k872n"),I(l,"class","svelte-4k872n"),I(g,"class","svelte-4k872n"),I(n,"class","acl-mode-warning svelte-4k872n")},m(e,t){h(e,n,t),f(n,i),f(n,s),f(n,r),f(n,o),f(n,l),f(l,a),f(l,c),f(c,u),f(n,d),f(n,g)},p(e,t){4096&t[0]&&v!==(v=(e[12]||"unknown")+"")&&E(u,v)},i:e,o:e,d(e){e&&p(n)}}}function IS(e){let t,n;return t=new vm({props:{userSigner:e[19],userPubkey:e[2]}}),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};524288&n[0]&&(i.userSigner=e[19]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function CS(e){let t,n;return t=new hE({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[19],currentEffectiveRole:e[13]}}),t.$on("openLoginModal",e[89]),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),524288&n[0]&&(i.userSigner=e[19]),8192&n[0]&&(i.currentEffectiveRole=e[13]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function ES(t){let n;return{c(){n=m("div"),n.innerHTML="<p>Read, write, admin, or owner permission required to view events.</p>",I(n,"class","permission-denied svelte-4k872n")},m(e,t){h(e,n,t)},p:e,i:e,o:e,d(e){e&&p(n)}}}function xS(t){let n;return{c(){n=m("div"),n.innerHTML='<div class="spinner svelte-4k872n"></div> \n                    <p>Checking permissions...</p>',I(n,"class","events-loading-permissions svelte-4k872n")},m(e,t){h(e,n,t)},p:e,i:e,o:e,d(e){e&&p(n)}}}function SS(e){let t,n;return t=new HA({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[51],expandedEvents:e[25],isLoadingEvents:e[7],showOnlyMyEvents:zS,showFilterBuilder:e[22]}}),t.$on("scroll",e[109]),t.$on("toggleEventExpansion",e[125]),t.$on("deleteEvent",e[126]),t.$on("copyEventToClipboard",e[127]),t.$on("toggleChange",e[58]),t.$on("loadAllEvents",e[128]),t.$on("toggleFilterBuilder",e[96]),t.$on("filterApply",e[98]),t.$on("filterClear",e[99]),{c(){ae(t.$$.fragment)},m(e,i){ce(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),4&n[0]&&(i.userPubkey=e[2]),1048576&n[1]&&(i.filteredEvents=e[51]),33554432&n[0]&&(i.expandedEvents=e[25]),128&n[0]&&(i.isLoadingEvents=e[7]),4194304&n[0]&&(i.showFilterBuilder=e[22]),t.$set(i)},i(e){n||(ne(t.$$.fragment,e),n=!0)},o(e){ie(t.$$.fragment,e),n=!1},d(e){ue(t,e)}}}function BS(e){let t,n,s,r,o,l,a,c,u,d,g;function v(e,t){return e[3]?FS:e[1]&&e[2]?$S:void 0}let y=v(e),b=y&&y(e),C=e[54]&&NS(e);return{c(){t=m("div"),n=m("div"),s=m("div"),r=m("h2"),r.textContent="Settings",o=w(),l=m("button"),l.textContent="✕",a=w(),c=m("div"),b&&b.c(),u=w(),C&&C.c(),I(r,"class","svelte-4k872n"),I(l,"class","close-btn svelte-4k872n"),I(s,"class","drawer-header svelte-4k872n"),I(c,"class","drawer-content"),I(n,"class","settings-drawer svelte-4k872n"),F(n,"dark-theme",e[0]),I(t,"class","drawer-overlay svelte-4k872n"),I(t,"role","button"),I(t,"tabindex","0")},m(i,p){h(i,t,p),f(t,n),f(n,s),f(s,r),f(s,o),f(s,l),f(n,a),f(n,c),b&&b.m(c,null),f(c,u),C&&C.m(c,null),d||(g=[A(l,"click",e[93]),A(n,"click",k(e[121])),A(n,"keydown",k(e[122])),A(t,"click",e[93]),A(t,"keydown",e[149])],d=!0)},p(e,t){y===(y=v(e))&&b?b.p(e,t):(b&&b.d(1),b=y&&y(e),b&&(b.c(),b.m(c,u))),e[54]?C?C.p(e,t):(C=NS(e),C.c(),C.m(c,null)):C&&(C.d(1),C=null),1&t[0]&&F(n,"dark-theme",e[0])},d(e){e&&p(t),b&&b.d(),C&&C.d(),d=!1,i(g)}}}function $S(e){let t,n,s,r,o,l,a,c,u,d,g,v,b,k,C,x,S,B=e[2].slice(0,16)+"",$=e[2].slice(-8)+"";return{c(){t=m("div"),n=m("button"),n.textContent="Log out",s=w(),r=m("h3"),r.textContent="Profile Loading",o=w(),l=m("p"),l.textContent="Your profile metadata is being loaded...",a=w(),c=m("button"),c.textContent="Retry Loading Profile",u=w(),d=m("div"),g=m("strong"),g.textContent="Public Key:",v=w(),b=y(B),k=y("..."),C=y($),I(n,"class","logout-btn floating svelte-4k872n"),I(r,"class","svelte-4k872n"),I(l,"class","svelte-4k872n"),I(c,"class","retry-profile-btn svelte-4k872n"),I(d,"class","user-pubkey-display svelte-4k872n"),I(t,"class","profile-loading-section svelte-4k872n")},m(i,p){h(i,t,p),f(t,n),f(t,s),f(t,r),f(t,o),f(t,l),f(t,a),f(t,c),f(t,u),f(t,d),f(d,g),f(d,v),f(d,b),f(d,k),f(d,C),x||(S=[A(n,"click",e[91]),A(c,"click",e[103])],x=!0)},p(e,t){4&t[0]&&B!==(B=e[2].slice(0,16)+"")&&E(b,B),4&t[0]&&$!==($=e[2].slice(-8)+"")&&E(C,$)},d(e){e&&p(t),x=!1,i(S)}}}function FS(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,k,C,x=(e[3].name||"Unknown User")+"",S=e[3].banner&&DS(e);function B(e,t){return e[3].picture?PS:QS}let $=B(e),F=$(e),D=e[3].nip05&&RS(e),Q=e[3].about&&TS(e),P=e[4]&&"read"!==e[4]&&LS(e);return{c(){t=m("div"),n=m("div"),S&&S.c(),i=w(),s=m("button"),s.textContent="Log out",r=w(),F.c(),o=w(),l=m("div"),a=m("h3"),c=y(x),u=w(),D&&D.c(),d=w(),Q&&Q.c(),g=w(),P&&P.c(),v=b(),I(s,"class","logout-btn floating svelte-4k872n"),I(a,"class","profile-username svelte-4k872n"),I(l,"class","name-row svelte-4k872n"),I(n,"class","profile-hero svelte-4k872n"),I(t,"class","profile-section svelte-4k872n")},m(p,m){h(p,t,m),f(t,n),S&&S.m(n,null),f(n,i),f(n,s),f(n,r),F.m(n,null),f(n,o),f(n,l),f(l,a),f(a,c),f(l,u),D&&D.m(l,null),f(t,d),Q&&Q.m(t,null),h(p,g,m),P&&P.m(p,m),h(p,v,m),k||(C=A(s,"click",e[91]),k=!0)},p(e,s){e[3].banner?S?S.p(e,s):(S=DS(e),S.c(),S.m(n,i)):S&&(S.d(1),S=null),$===($=B(e))&&F?F.p(e,s):(F.d(1),F=$(e),F&&(F.c(),F.m(n,o))),8&s[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&E(c,x),e[3].nip05?D?D.p(e,s):(D=RS(e),D.c(),D.m(l,null)):D&&(D.d(1),D=null),e[3].about?Q?Q.p(e,s):(Q=TS(e),Q.c(),Q.m(t,null)):Q&&(Q.d(1),Q=null),e[4]&&"read"!==e[4]?P?P.p(e,s):(P=LS(e),P.c(),P.m(v.parentNode,v)):P&&(P.d(1),P=null)},d(e){e&&p(t),S&&S.d(),F.d(),D&&D.d(),Q&&Q.d(),e&&p(g),P&&P.d(e),e&&p(v),k=!1,C()}}}function DS(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[3].banner)||I(t,"src",n),I(t,"alt","Profile banner"),I(t,"class","profile-banner svelte-4k872n")},m(e,n){h(e,t,n)},p(e,i){8&i[0]&&!l(t.src,n=e[3].banner)&&I(t,"src",n)},d(e){e&&p(t)}}}function QS(t){let n;return{c(){n=m("div"),n.textContent="👤",I(n,"class","profile-avatar-placeholder overlap svelte-4k872n")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function PS(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[3].picture)||I(t,"src",n),I(t,"alt","User avatar"),I(t,"class","profile-avatar overlap svelte-4k872n")},m(e,n){h(e,t,n)},p(e,i){8&i[0]&&!l(t.src,n=e[3].picture)&&I(t,"src",n)},d(e){e&&p(t)}}}function RS(e){let t,n,i=e[3].nip05+"";return{c(){t=m("span"),n=y(i),I(t,"class","profile-nip05-inline svelte-4k872n")},m(e,i){h(e,t,i),f(t,n)},p(e,t){8&t[0]&&i!==(i=e[3].nip05+"")&&E(n,i)},d(e){e&&p(t)}}}function TS(e){let t,n;return{c(){t=m("div"),n=m("p"),I(n,"class","profile-about svelte-4k872n"),I(t,"class","about-card svelte-4k872n")},m(i,s){h(i,t,s),f(t,n),n.innerHTML=e[50]},p(e,t){524288&t[1]&&(n.innerHTML=e[50])},d(e){e&&p(t)}}}function LS(e){let t,n,i,s,r,o,l=e[115](),a=[];for(let t=0;t<l.length;t+=1)a[t]=_S(Ix(e,l,t));return{c(){t=m("div"),n=m("h3"),n.textContent="View as Role",i=w(),s=m("p"),s.textContent="See the interface as it appears for different\n                                permission levels:",r=w(),o=m("div");for(let e=0;e<a.length;e+=1)a[e].c();I(n,"class","svelte-4k872n"),I(s,"class","svelte-4k872n"),I(o,"class","radio-group svelte-4k872n"),I(t,"class","view-as-section svelte-4k872n")},m(e,l){h(e,t,l),f(t,n),f(t,i),f(t,s),f(t,r),f(t,o);for(let e=0;e<a.length;e+=1)a[e]&&a[e].m(o,null)},p(e,t){if(8208&t[0]|6291456&t[3]){let n;for(l=e[115](),n=0;n<l.length;n+=1){const i=Ix(e,l,n);a[n]?a[n].p(i,t):(a[n]=_S(i),a[n].c(),a[n].m(o,null))}for(;n<a.length;n+=1)a[n].d(1);a.length=l.length}},d(e){e&&p(t),g(a,e)}}}function _S(e){let t,n,i,s,r,o,l,a,c,u=e[202].charAt(0).toUpperCase()+e[202].slice(1)+"",d=e[202]===e[4]?" (Default)":"";function g(){return e[147](e[202])}return{c(){t=m("label"),n=m("input"),s=w(),r=y(u),o=y(d),l=w(),I(n,"type","radio"),I(n,"name","viewAsRole"),n.value=e[202],n.checked=i=e[13]===e[202],I(n,"class","svelte-4k872n"),I(t,"class","radio-label svelte-4k872n")},m(e,i){h(e,t,i),f(t,n),f(t,s),f(t,r),f(t,o),f(t,l),a||(c=A(n,"change",g),a=!0)},p(t,s){e=t,8192&s[0]&&i!==(i=e[13]===e[202])&&(n.checked=i),16&s[0]&&d!==(d=e[202]===e[4]?" (Default)":"")&&E(o,d)},d(e){e&&p(t),a=!1,c()}}}function NS(e){let t,n,i,s,r,o,l,a,c=e[14]?"Change Relay":"Connect to Relay";function u(e,t){return e[14]?US:MS}let d=u(e),g=d(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Connected Relay",i=w(),g.c(),s=w(),r=m("button"),o=y(c),I(n,"class","svelte-4k872n"),I(r,"class","change-relay-btn svelte-4k872n"),I(t,"class","relay-section svelte-4k872n")},m(c,u){h(c,t,u),f(t,n),f(t,i),g.m(t,null),f(t,s),f(t,r),f(r,o),l||(a=A(r,"click",e[148]),l=!0)},p(e,n){d===(d=u(e))&&g?g.p(e,n):(g.d(1),g=d(e),g&&(g.c(),g.m(t,s))),16384&n[0]&&c!==(c=e[14]?"Change Relay":"Connect to Relay")&&E(o,c)},d(e){e&&p(t),g.d(),l=!1,a()}}}function MS(t){let n;return{c(){n=m("div"),n.innerHTML='<span class="status-dot disconnected svelte-4k872n"></span>\n                                Not connected',I(n,"class","relay-disconnected svelte-4k872n")},m(e,t){h(e,n,t)},p:e,d(e){e&&p(n)}}}function US(e){let t,n,i,s,r,o,l,a=(e[14].name||"Unknown relay")+"",c=e[14].description&&OS(e);return{c(){t=m("div"),n=m("div"),i=y(a),s=w(),c&&c.c(),r=w(),o=m("div"),l=y(e[53]),I(n,"class","relay-name svelte-4k872n"),I(o,"class","relay-url svelte-4k872n"),I(t,"class","relay-info-card svelte-4k872n")},m(e,a){h(e,t,a),f(t,n),f(n,i),f(t,s),c&&c.m(t,null),f(t,r),f(t,o),f(o,l)},p(e,n){16384&n[0]&&a!==(a=(e[14].name||"Unknown relay")+"")&&E(i,a),e[14].description?c?c.p(e,n):(c=OS(e),c.c(),c.m(t,r)):c&&(c.d(1),c=null),4194304&n[1]&&E(l,e[53])},d(e){e&&p(t),c&&c.d()}}}function OS(e){let t,n,i=e[14].description+"";return{c(){t=m("div"),n=y(i),I(t,"class","relay-description svelte-4k872n")},m(e,i){h(e,t,i),f(t,n)},p(e,t){16384&t[0]&&i!==(i=e[14].description+"")&&E(n,i)},d(e){e&&p(t)}}}function jS(e){let t,n,i,s,r,o,l,a,c,u,d,g,v,y,b,A,k,C,E,x,S,B,$,D,Q,P,R;t=new _m({props:{isDarkTheme:e[0],isLoggedIn:e[1],userRole:e[4],currentEffectiveRole:e[13]}}),t.$on("openRelayModal",e[68]),t.$on("relayChanged",e[67]),t.$on("toggleMobileMenu",e[94]),i=new Ev({props:{isLoggedIn:e[1],userProfile:e[3],userPubkey:e[2],userRole:e[4],currentEffectiveRole:e[13],isDarkTheme:e[0]}}),i.$on("logout",e[91]),i.$on("toggleTheme",e[66]),i.$on("setViewAsRole",e[124]),i.$on("openRelayModal",e[68]),o=new fv({props:{isLoggedIn:e[1],userProfile:e[3],userPubkey:e[2],currentEffectiveRole:e[13],version:e[39],mobileOpen:e[21],aclMode:e[12],sprocketEnabled:e[8],policyEnabled:e[9],nrcEnabled:e[10],blossomEnabled:e[11],isOrlyRelay:e[15]}}),o.$on("navigate",e[87]),o.$on("closeMobileMenu",e[95]),o.$on("showAbout",e[88]),o.$on("openLoginModal",e[89]);const T=[Qx,Dx,Fx,$x,Bx],L=[];function _(e,t){return 2097152&t[1]&&(c=null),2097152&t[1]&&(u=null),2097152&t[1]&&(d=null),"feed"===e[52]?0:(null==c&&(c=!!e[52]?.startsWith("chat-")),c?1:(null==u&&(u=!!e[52]?.startsWith("library-")),u?2:(null==d&&(d=!!e[52]?.startsWith("admin-")),d?3:4)))}g=_(e,[-1,-1,-1,-1,-1,-1,-1]),v=L[g]=T[g](e);let N=e[20]&&BS(e);function U(t){e[150](t)}let O={isDarkTheme:e[0]};function j(t){e[151](t)}void 0!==e[16]&&(O.showModal=e[16]),A=new xg({props:O}),M.push(()=>le(A,"showModal",U)),A.$on("login",e[90]),A.$on("close",e[92]);let z={isDarkTheme:e[0]};return void 0!==e[17]&&(z.showModal=e[17]),E=new kx({props:z}),M.push(()=>le(E,"showModal",j)),E.$on("connected",e[70]),E.$on("close",e[69]),B=new Qv({props:{show:e[48],version:e[39]}}),B.$on("close",e[152]),D=new ay({props:{userPubkey:e[2],isLoggedIn:e[1]}}),P=new _v({}),P.$on("search",e[153]),{c(){ae(t.$$.fragment),n=w(),ae(i.$$.fragment),s=w(),r=m("div"),ae(o.$$.fragment),l=w(),a=m("main"),v.c(),y=w(),N&&N.c(),b=w(),ae(A.$$.fragment),C=w(),ae(E.$$.fragment),S=w(),ae(B.$$.fragment),$=w(),ae(D.$$.fragment),Q=w(),ae(P.$$.fragment),I(a,"class","main-content svelte-4k872n"),I(r,"class","app-container svelte-4k872n"),F(r,"dark-theme",e[0])},m(e,c){ce(t,e,c),h(e,n,c),ce(i,e,c),h(e,s,c),h(e,r,c),ce(o,r,null),f(r,l),f(r,a),L[g].m(a,null),h(e,y,c),N&&N.m(e,c),h(e,b,c),ce(A,e,c),h(e,C,c),ce(E,e,c),h(e,S,c),ce(B,e,c),h(e,$,c),ce(D,e,c),h(e,Q,c),ce(P,e,c),R=!0},p(e,n){const s={};1&n[0]&&(s.isDarkTheme=e[0]),2&n[0]&&(s.isLoggedIn=e[1]),16&n[0]&&(s.userRole=e[4]),8192&n[0]&&(s.currentEffectiveRole=e[13]),t.$set(s);const l={};2&n[0]&&(l.isLoggedIn=e[1]),8&n[0]&&(l.userProfile=e[3]),4&n[0]&&(l.userPubkey=e[2]),16&n[0]&&(l.userRole=e[4]),8192&n[0]&&(l.currentEffectiveRole=e[13]),1&n[0]&&(l.isDarkTheme=e[0]),i.$set(l);const c={};2&n[0]&&(c.isLoggedIn=e[1]),8&n[0]&&(c.userProfile=e[3]),4&n[0]&&(c.userPubkey=e[2]),8192&n[0]&&(c.currentEffectiveRole=e[13]),256&n[1]&&(c.version=e[39]),2097152&n[0]&&(c.mobileOpen=e[21]),4096&n[0]&&(c.aclMode=e[12]),256&n[0]&&(c.sprocketEnabled=e[8]),512&n[0]&&(c.policyEnabled=e[9]),1024&n[0]&&(c.nrcEnabled=e[10]),2048&n[0]&&(c.blossomEnabled=e[11]),32768&n[0]&&(c.isOrlyRelay=e[15]),o.$set(c);let u=g;g=_(e,n),g===u?L[g].p(e,n):(ee(),ie(L[u],1,1,()=>{L[u]=null}),te(),v=L[g],v?v.p(e,n):(v=L[g]=T[g](e),v.c()),ne(v,1),v.m(a,null)),(!R||1&n[0])&&F(r,"dark-theme",e[0]),e[20]?N?N.p(e,n):(N=BS(e),N.c(),N.m(b.parentNode,b)):N&&(N.d(1),N=null);const d={};1&n[0]&&(d.isDarkTheme=e[0]),!k&&65536&n[0]&&(k=!0,d.showModal=e[16],J(()=>k=!1)),A.$set(d);const f={};1&n[0]&&(f.isDarkTheme=e[0]),!x&&131072&n[0]&&(x=!0,f.showModal=e[17],J(()=>x=!1)),E.$set(f);const h={};131072&n[1]&&(h.show=e[48]),256&n[1]&&(h.version=e[39]),B.$set(h);const p={};4&n[0]&&(p.userPubkey=e[2]),2&n[0]&&(p.isLoggedIn=e[1]),D.$set(p)},i(e){R||(ne(t.$$.fragment,e),ne(i.$$.fragment,e),ne(o.$$.fragment,e),ne(v),ne(A.$$.fragment,e),ne(E.$$.fragment,e),ne(B.$$.fragment,e),ne(D.$$.fragment,e),ne(P.$$.fragment,e),R=!0)},o(e){ie(t.$$.fragment,e),ie(i.$$.fragment,e),ie(o.$$.fragment,e),ie(v),ie(A.$$.fragment,e),ie(E.$$.fragment,e),ie(B.$$.fragment,e),ie(D.$$.fragment,e),ie(P.$$.fragment,e),R=!1},d(e){ue(t,e),e&&p(n),ue(i,e),e&&p(s),e&&p(r),ue(o),L[g].d(),e&&p(y),N&&N.d(e),e&&p(b),ue(A,e),e&&p(C),ue(E,e),e&&p(S),ue(B,e),e&&p($),ue(D,e),e&&p(Q),ue(P,e)}}}let zS=!1,HS=!1;function qS(e,t,n){let i,s,r,o,l,a,d,f,h,p;u(e,Ih,e=>n(14,a=e)),u(e,Eh,e=>n(15,d=e)),u(e,Bh,e=>n(52,f=e)),u(e,Ah,e=>n(53,h=e)),u(e,kh,e=>n(54,p=e)),"undefined"!=typeof window&&(window.debugIndexedDB=Ip);let g=!1,m=!1,v=!1,y=!1,w="",b="",A=null,k=null,I=null,E="",x=null,S=!1,B=!1,F=localStorage.getItem("selectedTab")||"export";{const e=localStorage.getItem("activeView")||"feed",t={"admin-export":"export","admin-import":"import","admin-events":"events","admin-blossom":"blossom","admin-compose":"compose","admin-recovery":"recovery","admin-managed-acl":"managed-acl","admin-curation":"curation","admin-sprocket":"sprocket","admin-policy":"policy","admin-relay-connect":"relay-connect","admin-logs":"logs"};t[e]&&(F=t[e])}let D=!1,Q={},P=[],R=[],T=null,L="",N=new Set,M=!1,U=!0,O=null,j="",z=new Map,H=[],q=0,G=[],J=!1,K=!0,V=null,W="",Y=null,Z=[],X=!1,ee="",te="info",ne=!1,ie=null,se="",re=!1,oe=!1,le="",ae="info",ce=[],ue=[],de=!1,fe=!0,he="",pe="",ge="",me="",ve=!0,ye=null,we="",be=[],Ae=!1,ke=!0,Ie=null;function Ce(e){N.has(e)?N.delete(e):N.add(e),n(25,N)}async function Ee(e,t){const n=JSON.stringify(e),i=await OE(n);jE(t.target.closest(".copy-json-btn"),i),i||alert("Failed to copy to clipboard. Please copy manually.")}async function xe(e){if(!y)return void alert("Please log in first");const t=R.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===E||"owner"===E||"write"===E&&t.pubkey&&t.pubkey===w){if(confirm("Are you sure you want to delete this event?"))try{if(!x)throw new Error("Signer not available for signing");const i={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",i),console.log("User pubkey:",w),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const s=await x.signEvent(i);console.log("Signed delete event:",s),console.log("Signed delete event pubkey:",s.pubkey),console.log("Delete event tags:",s.tags);const r=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await eC(r,s,x,w);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const o=t.pubkey&&t.pubkey===w;if(o){const t=await Zh.publish(s);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await yp(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await wp(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===w);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(116,R=R.filter(t=>t.id!==e)),G=G.filter(t=>t.id!==e),H=H.filter(t=>t.id!==e);for(const[t,n]of z)n.events&&(n.events=n.events.filter(t=>t.id!==e),z.set(t,n));Pe(),console.log("Reloading events to show delete event...");const i=zS&&y&&w?[w]:null;await it(!0,i),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=new Yh;await i.connectToRelay(t);const r=await i.publish(s);if(console.log("Delete event published to local relay only:",r),!(r.success&&r.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await yp(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${r.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await wp(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===w);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(116,R=R.filter(t=>t.id!==e)),G=G.filter(t=>t.id!==e),H=H.filter(t=>t.id!==e);for(const[t,n]of z)n.events&&(n.events=n.events.filter(t=>t.id!==e),z.set(t,n));Pe(),console.log("Reloading events to show delete event...");const t=zS&&y&&w?[w]:null;await it(!0,t),alert("Event deleted successfully (local relay only - admin/owner deleting other user's event)")}}}catch(e){console.error("Failed to delete event:",e),alert("Failed to delete event: "+e.message)}}else alert("You do not have permission to delete this event")}async function Se(){const e=we?parseInt(we):ye;if(null==e||isNaN(e))console.log("No valid kind to load, kindToUse:",e);else if(y){console.log("Loading recovery events for kind:",e,"user:",w),n(46,Ae=!0);try{const t=[{kinds:[e],authors:[w],limit:100}];Ie&&(t[0].until=Ie),console.log("Recovery filters:",t);const i=await Ap(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",i.length),console.log("Recovery events kinds:",i.map(e=>e.kind)),n(45,be=Ie?[...be,...i]:i),i.length>0?(Ie=Math.min(...i.map(e=>e.created_at)),n(47,ke=100===i.length)):n(47,ke=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(46,Ae=!1)}}else console.log("Not logged in, cannot load recovery events")}async function Be(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const i={...e};if(i.created_at=Math.floor(Date.now()/1e3),i.id="",i.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(i.tags=i.tags.filter(e=>"d"!==e[0]),i.tags.push(t))}if(x){const e=await x.signEvent(i);console.log("Signed event for repost:",e);const s=await Zh.publish(e,[t]);console.log("Repost publish result:",s),s.success&&s.okCount>0?(alert("Event reposted successfully!"),n(47,ke=!1),await Se()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event:",e),alert("Error reposting event: "+e.message)}}async function $e(e){if(confirm("Are you sure you want to repost this event to all your write relays?"))try{const t=await async function(){if(!w)return[];try{const e=await op([{kinds:[10002],authors:[w],limit:1}]);if(0===e.length)return console.log("No relay list event found for user"),[];const t=e[0];console.log("Found relay list event:",t);const n=[];for(const e of t.tags)if("r"===e[0]&&e.length>=2){const t=e[1],i=e.length>=3?e[2]:null;i&&"write"!==i||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),i=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,s=[i,...t.filter(e=>e!==i)];1===s.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",s,e);const r={...e};if(r.created_at=Math.floor(Date.now()/1e3),r.id="",r.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(r.tags=r.tags.filter(e=>"d"!==e[0]),r.tags.push(t))}if(x){const e=await x.signEvent(r);console.log("Signed event for repost to all:",e);const t=await Zh.publish(e,s);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${s.length} relays!`),n(47,ke=!1),await Se()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event to all:",e),alert("Error reposting event to all: "+e.message)}}let Fe="auto";if("undefined"!=typeof window&&window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");g=e.matches,e.addEventListener("change",e=>{"auto"===Fe&&n(0,g=e.matches)}),(async()=>{try{const e=await TE();e?.theme&&"auto"!==e.theme&&(Fe=e.theme,n(0,g="dark"===e.theme)),e&&"boolean"==typeof e.blossom_enabled&&n(11,fe=e.blossom_enabled)}catch(e){console.log("Could not fetch relay theme config:",e)}})()}if("undefined"!=typeof localStorage){const e=localStorage.getItem("nostr_auth_method"),t=localStorage.getItem("nostr_pubkey");e&&t&&(y=!0,w=t,b=e,"extension"===e&&window.nostr&&(x=window.nostr)),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const i=JSON.parse(t);i.selectedTab&&je.some(e=>e.id===i.selectedTab)&&n(5,F=i.selectedTab),i.expandedEvents&&n(25,N=new Set(i.expandedEvents)),i.globalEventsCache&&(H=i.globalEventsCache),i.globalCacheTimestamp&&(q=i.globalCacheTimestamp),void 0!==i.hasMoreEvents&&(U=i.hasMoreEvents),i.oldestEventTimestamp&&(O=i.oldestEventTimestamp),void 0!==i.hasMoreMyEvents&&(K=i.hasMoreMyEvents),i.oldestMyEventTimestamp&&(V=i.oldestMyEventTimestamp),H.length>0&&((e=q)&&Date.now()-e<Kh)&&n(116,R=H)}}catch(e){console.error("Failed to load persistent state:",e)}var e}(),async function(){if(c(kh)){if(c(kh)&&!c(Ah))return void n(17,v=!0);await Uh()}else await Uh();await De()}()}async function De(){y&&await Ye(),await Xe(),async function(){try{const e=await fetch(`${Lh()}/api/sprocket/config`,{method:"GET",headers:{"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(8,ne=t.enabled)}else 404===e.status&&n(8,ne=!1)}catch(e){n(8,ne=!1)}}(),async function(){try{const e=await LE();n(10,de=e.enabled)}catch(e){n(10,de=!1)}}(),async function(){try{const e=await fetch(`${Lh()}/api/policy/config`,{method:"GET",headers:{"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(9,re=t.enabled||!1)}else 404===e.status&&n(9,re=!1)}catch(e){n(9,re=!1)}}(),async function(){try{const e=await TE();e&&e.version&&n(39,pe=e.version)}catch(e){console.error("Error fetching relay version:",e)}}()}function Qe(){n(17,v=!0)}function Pe(){if("undefined"==typeof localStorage)return;const e={selectedTab:F,expandedEvents:Array.from(N),globalEventsCache:H,globalCacheTimestamp:q,hasMoreEvents:U,oldestEventTimestamp:O};localStorage.setItem("app_state",JSON.stringify(e))}function Re(e){H=e.sort((e,t)=>t.created_at-e.created_at),q=Date.now(),Pe()}async function Te(){if(y&&"owner"===E&&ne)try{n(29,X=!0);const e=await fetch(`${Lh()}/api/sprocket/status`,{method:"GET",headers:{Authorization:`Nostr ${await lt("GET",`${Lh()}/api/sprocket/status`)}`,"Content-Type":"application/json"}});e.ok?n(27,Y=await e.json()):Me("Failed to load sprocket status","error")}catch(e){Me(`Error loading sprocket status: ${e.message}`,"error")}finally{n(29,X=!1)}}async function Le(){if(y&&"owner"===E)try{n(29,X=!0);const e=await fetch(`${Lh()}/api/sprocket/versions`,{method:"GET",headers:{Authorization:`Nostr ${await lt("GET",`${Lh()}/api/sprocket/versions`)}`,"Content-Type":"application/json"}});e.ok?n(28,Z=await e.json()):Me("Failed to load versions","error")}catch(e){Me(`Error loading versions: ${e.message}`,"error")}finally{n(29,X=!1)}}async function _e(e){y&&"owner"===E&&(n(26,W=e.content),Me(`Loaded version: ${e.name}`,"success"))}async function Ne(e){if(y&&"owner"===E&&confirm(`Are you sure you want to delete version ${e}?`))try{n(29,X=!0);const t=await fetch(`${Lh()}/api/sprocket/delete-version`,{method:"POST",headers:{Authorization:`Nostr ${await lt("POST",`${Lh()}/api/sprocket/delete-version`)}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)Me(`Version ${e} deleted successfully`,"success"),await Le();else{Me(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){Me(`Error deleting version: ${e.message}`,"error")}finally{n(29,X=!1)}}function Me(e,t="info"){n(30,ee=e),n(31,te=t),setTimeout(()=>{n(30,ee="")},5e3)}function Ue(e,t="info"){n(35,le=e),n(36,ae=t),"error"!==t&&setTimeout(()=>{n(35,le="")},5e3)}async function Oe(){if(n(37,ce=[]),!se.trim())return n(37,ce=["Policy JSON is empty"]),Ue("Validation failed","error"),!1;try{const e=JSON.parse(se);if("object"!=typeof e||null===e)return n(37,ce=["Policy must be a JSON object"]),Ue("Validation failed","error"),!1;if(e.policy_admins)if(Array.isArray(e.policy_admins))for(const t of e.policy_admins)"string"==typeof t&&/^[0-9a-fA-F]{64}$/.test(t)||ce.push(`Invalid policy_admin pubkey: ${t}`);else ce.push("policy_admins must be an array");if(e.rules)if("object"!=typeof e.rules)ce.push("rules must be an object");else for(const[t,n]of Object.entries(e.rules))if(/^\d+$/.test(t)||ce.push(`Invalid kind number: ${t}`),n.tag_validation&&"object"==typeof n.tag_validation)for(const[e,t]of Object.entries(n.tag_validation))try{new RegExp(t)}catch(n){ce.push(`Invalid regex for tag '${e}': ${t}`)}return e.default_policy&&!["allow","deny"].includes(e.default_policy)&&ce.push("default_policy must be 'allow' or 'deny'"),ce.length>0?(Ue("Validation failed - see errors below","error"),!1):(Ue("Validation passed","success"),!0)}catch(e){return n(37,ce=[`JSON parse error: ${e.message}`]),Ue("Invalid JSON syntax","error"),!1}}const je=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"curation",icon:"📋",label:"Curation",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"relay-connect",icon:"🔗",label:"Relay Connect",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];const ze={"admin-export":"export","admin-import":"import","admin-events":"events","admin-blossom":"blossom","admin-compose":"compose","admin-recovery":"recovery","admin-managed-acl":"managed-acl","admin-curation":"curation","admin-sprocket":"sprocket","admin-policy":"policy","admin-relay-connect":"relay-connect","admin-logs":"logs"};let He=!1;function qe(){n(20,S=!1)}function Ge(e,t){const i=`search-${Date.now()}`,s={id:i,icon:"🔍",label:t,isSearchTab:!0,filter:e};n(6,P=[...P,s]),n(5,F=i),z.set(i,{filter:e,events:[],isLoading:!1,hasMore:!0,oldestTimestamp:null}),Ke(i,!0)}function Je(e){var t;t=e,n(6,P=P.filter(e=>e.id!==t)),z.delete(t),F===t&&n(5,F="export")}async function Ke(e,t=!0){const n=z.get(e);if(n&&!n.isLoading){n.isLoading=!0,z.set(e,n);try{const i={...n.filter};!t&&n.oldestTimestamp&&(i.until=n.oldestTimestamp),t||(i.limit=200),console.log("Loading search results with filter:",i);const s=await gp([i],{timeout:3e4});if(console.log("Received search results:",s.length,"events"),n.events=t?s.sort((e,t)=>t.created_at-e.created_at):[...n.events,...s].sort((e,t)=>t.created_at-e.created_at),s.length>0){const e=Math.min(...s.map(e=>e.created_at));(!n.oldestTimestamp||e<n.oldestTimestamp)&&(n.oldestTimestamp=e)}n.hasMore=s.length===(t?i.limit||100:200),n.isLoading=!1,z.set(e,n)}catch(t){console.error("Failed to load search results:",t),n.isLoading=!1,z.set(e,n),alert("Failed to load search results: "+t.message)}}}function Ve(e,t){const{scrollTop:n,scrollHeight:i,clientHeight:s}=e.target;if(i-n-s<100){const e=z.get(t);e&&!e.isLoading&&e.hasMore&&async function(e){await Ke(e,!1)}(t)}}async function We(){if(y&&w&&!A)try{console.log("Auto-fetching profile for:",w),await bp(),n(3,A=await ap(w)),console.log("Profile auto-loaded:",A)}catch(e){console.error("Failed to auto-load profile:",e)}}async function Ye(){if(y&&w){if("npub"===b)return n(4,E="read"),void console.log("User role: read (npub read-only login)");try{const e=`${Lh()}/api/permissions/${w}`,t=await fetch(e);if(t.ok){const e=await t.json();n(4,E=e.permission||""),Eh.set(!0),console.log("User role loaded:",E),console.log("Is owner?","owner"===E)}else 404===t.status?(console.log("ORLY API not available, using NIP-11 fallback"),Eh.set(!1),n(4,E=Ze())):(console.error("Failed to fetch user role:",t.status),n(4,E=""))}catch(e){console.log("Error fetching user role, using NIP-11 fallback:",e.message),Eh.set(!1),n(4,E=Ze())}}else n(4,E="")}function Ze(){if(!a)return"write";const e=a.limitation||{};return!1!==e.auth_required&&e.auth_required?y?(console.log("NIP-11: Auth required and user is logged in, granting write access"),"write"):"read":(console.log("NIP-11: No auth required, granting write access"),"write")}async function Xe(){try{const e=await fetch(`${Lh()}/api/acl-mode`);if(e.ok){const t=await e.json();n(12,he=t.acl_mode||""),console.log("ACL mode loaded:",he)}else 404===e.status?(console.log("ACL API not available, defaulting to 'none'"),n(12,he="none")):(console.error("Failed to fetch ACL mode:",e.status),n(12,he=""))}catch(e){console.log("Error fetching ACL mode, defaulting to 'none':",e.message),n(12,he="none")}}let et=!1;async function tt(e=[]){if("none"===he||y)if("none"===he||0!==e.length||"admin"===l||"owner"===l){if("none"===he||!y){let t=`${Lh()}/api/export`;if(e.length>0){t+=`?${e.map(e=>`pubkey=${encodeURIComponent(e)}`).join("&")}`}const n=document.createElement("a");return n.href=t,n.download="",document.body.appendChild(n),n.click(),void document.body.removeChild(n)}n(49,et=!0);try{const t=`${Lh()}/api/export`,n={"Content-Type":"application/json"};n.Authorization=await ot(t,"POST");const i=await fetch(t,{method:"POST",headers:n,body:JSON.stringify({pubkeys:e})});if(!i.ok)throw new Error(`Export failed: ${i.status} ${i.statusText}`);const s=await i.blob(),r=window.URL.createObjectURL(s),o=document.createElement("a");o.href=r;const l=i.headers.get("Content-Disposition");let a="events.jsonl";if(l){const e=l.match(/filename="([^"]+)"/);e&&(a=e[1])}o.download=a,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(r)}catch(e){console.error("Export failed:",e),alert("Export failed: "+e.message)}finally{n(49,et=!1)}}else alert("Admin or owner permission required to export all events");else alert("Please log in first")}async function nt(e=!1){if(y){if(!J){J=!0,e&&(V=null);try{const t=await vp(w,{limit:e?1e3:200,until:e?null:V});if(G=e?t.sort((e,t)=>t.created_at-e.created_at):[...G,...t].sort((e,t)=>t.created_at-e.created_at),t.length>0){const e=Math.min(...t.map(e=>e.created_at));(!V||e<V)&&(V=e)}K=t.length===(e?1e3:200),e&&K&&setTimeout(()=>{if("myevents"===F){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&async function(){!J&&K&&await nt(!1)}()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{J=!1}}}else alert("Please log in first")}async function it(e=!1,t=null){if(!y||"read"!==E&&"write"!==E&&"admin"!==E&&"owner"!==E)alert("Read, write, admin, or owner permission required");else if(!M){n(7,M=!0),e&&(O=null);try{console.log("Loading events with authors filter:",t,"including delete events");const i=e?Math.floor(Date.now()/1e3):O,s=Q.authors||t,r=await mp({...Q,limit:e?100:200,until:Q.until||i,authors:s});if(console.log("Received events:",r.length,"events"),t&&r.length>0){const e=r.filter(e=>e.pubkey&&e.pubkey!==w);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",r.length)}if(e?(n(116,R=r.sort((e,t)=>t.created_at-e.created_at)),Re(r)):(n(116,R=[...R,...r].sort((e,t)=>t.created_at-e.created_at)),Re(R)),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!O||e<O)&&(O=e)}U=r.length===(e?1e3:200),e&&U&&setTimeout(()=>{if("events"===F){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&st()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,M=!1)}}}async function st(){await it(!1)}let rt=!1;async function ot(e,t){if(!y||!w)throw new Error("Not logged in");if(!x)throw new Error("No valid signer available");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",e],["method",t.toUpperCase()]],content:"",pubkey:w},i=await x.signEvent(n),s=JSON.stringify(i);return`Nostr ${btoa(s)}`}async function lt(e,t){if(!y||!w)throw new Error("Not logged in");if(!x)throw new Error("No valid signer available");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",t],["method",e.toUpperCase()]],content:"",pubkey:w},i=await x.signEvent(n),s=JSON.stringify(i);return btoa(s)}function at(e,t){const n=e.toLowerCase();if(n.includes("policy")||n.includes("blocked")||n.includes("denied")){let n=`Policy Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} may be restricted by the relay's policy configuration.`),re&&(n+="\n\nThe relay has policy enforcement enabled. Contact a relay administrator to allow this event kind or adjust your permissions."),n}if(n.includes("auth")||n.includes("permission")||n.includes("unauthorized"))return`Permission Error: ${e}\n\nYour current permissions may not allow publishing this type of event. Current role: ${E||"unknown"}. Contact a relay administrator to upgrade your permissions.`;if(n.includes("kind")||n.includes("not allowed")||n.includes("restricted")){let n=`Event Type Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} is not currently allowed on this relay.`),n+="\n\nThe relay administrator may need to update the policy configuration to allow this event kind.",n}return n.includes("rate")||n.includes("limit")||n.includes("too many")?`Rate Limit Error: ${e}\n\nPlease wait a moment before trying again.`:n.includes("size")||n.includes("too large")||n.includes("content")?`Size Limit Error: ${e}\n\nThe event may exceed the relay's size limits. Try reducing the content length.`:`Publishing failed: ${e}`}function ct(e){n(117,j=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",l)}j=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(16384&e.$$.dirty[0]&&a&&"boolean"==typeof a.blossom_enabled&&n(11,fe=a.blossom_enabled),6&e.$$.dirty[0]|8388608&e.$$.dirty[3]&&n(51,i=R.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(50,s=A?.about?(t=A.about,t?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):"").replace(/\n{2,}/g,"<br>"):""),16&e.$$.dirty[0]|16777216&e.$$.dirty[3]&&n(13,l=j&&""!==j?j:E),48914&e.$$.dirty[0]|16777216&e.$$.dirty[3]&&n(120,r=je.filter(e=>{const t=l;if(e.requiresAdmin&&(!y||"admin"!==t&&"owner"!==t))return!1;if(e.requiresOwner&&(!y||"owner"!==t))return!1;if(e.requiresWrite&&(!y||"read"===t))return!1;return!(["sprocket","policy","managed-acl","curation","logs","relay-connect"].includes(e.id)&&!d)&&(!("sprocket"===e.id&&!ne)&&(!("policy"===e.id&&!re)&&(!("relay-connect"===e.id&&!de)&&(("managed-acl"!==e.id||"managed"===he)&&(("curation"!==e.id||"curating"===he)&&(!("blossom"===e.id&&!fe)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:y,userRole:E,viewAsRole:j,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0)))))))})),64&e.$$.dirty[0]|134217728&e.$$.dirty[3]&&n(119,o=[...r,...P]),4114&e.$$.dirty[0]|201326592&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:y,userRole:E,aclMode:he,filteredBaseTabs:r.map(e=>e.id),allTabs:o.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(g?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&y&&w&&!A&&We(),182&e.$$.dirty[0]|41943040&e.$$.dirty[3]&&"events"===F&&y&&("read"===E||"write"===E||"admin"===E||"owner"===E)&&0===R.length&&!rt&&!M){n(118,rt=!0);it(!0,null)}32&e.$$.dirty[0]|8388608&e.$$.dirty[3]&&("events"!==F||"events"===F&&R.length>0)&&n(118,rt=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",F)},[g,y,w,A,E,F,P,M,ne,re,de,fe,he,l,a,d,m,v,I,x,S,B,D,T,L,N,W,Y,Z,X,ee,te,ie,se,oe,le,ae,ce,ue,pe,ge,me,ve,ye,we,be,Ae,ke,He,et,s,i,f,h,p,z,Ce,Ee,async function(){console.log("Toggle changed, showOnlyMyEvents:",zS),n(118,rt=!1),await it(!0,null)},xe,Se,Be,$e,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",ye),null!=ye?(n(44,we=""),n(45,be=[]),Ie=null,n(47,ke=!0),Se()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",we);const e=parseInt(we);""!==we&&!isNaN(e)&&e>=0&&(n(43,ye=null),n(45,be=[]),Ie=null,n(47,ke=!0),Se())},function(e){const t=be.filter(t=>t.kind===e.kind&&t.pubkey===e.pubkey),n=Math.max(...t.map(e=>e.created_at));return e.created_at===n},function(){n(0,g=!g),Fe=g?"dark":"light"},async function(e){console.log("Relay changed:",e.detail?.info?.name),Zh.reset(),await kp(),H=[],q=0,n(118,rt=!1),n(116,R=[]),G=[],U=!0,K=!0,O=null,z.clear(),n(6,P=[]),De(),"events"===F&&y?it(!0):"myevents"===F&&y&&nt(!0)},Qe,function(){n(17,v=!1)},async function(e){console.log("Connected to relay:",e.detail?.info?.name),Zh&&Zh.refreshRelays(),await De()},async function(){if(y&&"owner"===E)try{n(29,X=!0);const e=await fetch(`${Lh()}/api/sprocket/status`,{method:"GET",headers:{Authorization:`Nostr ${await lt("GET",`${Lh()}/api/sprocket/status`)}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(26,W=t.script_content||""),n(27,Y=t),Me("Script loaded successfully","success")}else Me("Failed to load script","error")}catch(e){Me(`Error loading script: ${e.message}`,"error")}finally{n(29,X=!1)}},async function(){if(y&&"owner"===E)try{n(29,X=!0);const e=await fetch(`${Lh()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await lt("POST",`${Lh()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:W});if(e.ok)Me("Script saved and updated successfully","success"),await Te(),await Le();else{Me(`Failed to save script: ${await e.text()}`,"error")}}catch(e){Me(`Error saving script: ${e.message}`,"error")}finally{n(29,X=!1)}},async function(){if(y&&"owner"===E)try{n(29,X=!0);const e=await fetch(`${Lh()}/api/sprocket/restart`,{method:"POST",headers:{Authorization:`Nostr ${await lt("POST",`${Lh()}/api/sprocket/restart`)}`,"Content-Type":"application/json"}});if(e.ok)Me("Sprocket restarted successfully","success"),await Te();else{Me(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){Me(`Error restarting sprocket: ${e.message}`,"error")}finally{n(29,X=!1)}},async function(){if(y&&"owner"===E&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(29,X=!0);const e=await fetch(`${Lh()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await lt("POST",`${Lh()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(26,W=""),Me("Sprocket script deleted successfully","success"),await Te(),await Le();else{Me(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){Me(`Error deleting script: ${e.message}`,"error")}finally{n(29,X=!1)}},Le,_e,Ne,async function(){if(y&&("owner"===E||HS))try{n(34,oe=!0),n(37,ce=[]);const e={kinds:[12345],limit:1},t=await Ap(e);if(t&&t.length>0){n(33,se=t[0].content);try{n(33,se=JSON.stringify(JSON.parse(se),null,2))}catch(e){}Ue("Policy loaded successfully","success")}else{const e=await fetch(`${Lh()}/api/policy`,{method:"GET",headers:{Authorization:`Nostr ${await lt("GET",`${Lh()}/api/policy`)}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(33,se=JSON.stringify(t,null,2)),Ue("Policy loaded from file","success")}else Ue("No policy configuration found","info"),n(33,se="")}}catch(e){Ue(`Error loading policy: ${e.message}`,"error")}finally{n(34,oe=!1)}},Oe,async function(){if(!y||"owner"!==E&&!HS)return;if(await Oe())try{n(34,oe=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:se},t=await eC(e,x);t.success?Ue("Policy updated successfully","success"):Ue(`Failed to publish policy: ${t.error||"Unknown error"}`,"error")}catch(e){Ue(`Error saving policy: ${e.message}`,"error")}finally{n(34,oe=!1)}},function(){try{const e=JSON.parse(se);n(33,se=JSON.stringify(e,null,2)),Ue("JSON formatted","success")}catch(e){Ue(`Cannot format: ${e.message}`,"error")}},function(e){const t=e.detail;if(!t)return void Ue("Please enter a pubkey","error");const i=function(e){if(!e)return null;if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(e.startsWith("npub1"))try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(5);let i=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");i.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}i=i.slice(0,-30);const s=[];for(let e=0;e+8<=i.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|i[e+n];s.push(t)}return s.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(i&&64===i.length)try{const e=JSON.parse(se||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(i))return void Ue("Admin already in list","warning");e.policy_admins.push(i),n(33,se=JSON.stringify(e,null,2)),Ue("Admin added - click 'Save & Publish' to apply","info")}catch(e){Ue(`Error adding admin: ${e.message}`,"error")}else Ue("Invalid pubkey format. Use hex (64 chars) or npub","error")},function(e){const t=e.detail;try{const e=JSON.parse(se||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(33,se=JSON.stringify(e,null,2)),Ue("Admin removed - click 'Save & Publish' to apply","info"))}catch(e){Ue(`Error removing admin: ${e.message}`,"error")}},async function(){if(y&&("owner"===E||HS))try{n(34,oe=!0),n(38,ue=[]);let e=[];try{e=JSON.parse(se||"{}").policy_admins||[]}catch(e){return void Ue("Cannot parse policy JSON to get admins","error")}if(0===e.length)return void Ue("No policy admins configured","warning");const t={kinds:[3],authors:e,limit:e.length},i=await Ap(t),s=new Set;for(const e of i)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&s.add(t[1]);n(38,ue=Array.from(s)),Ue(`Loaded ${ue.length} follows from ${i.length} admin(s)`,"success")}catch(e){Ue(`Error loading follows: ${e.message}`,"error")}finally{n(34,oe=!1)}},function(e){n(32,ie=e.target.files[0])},async function(){if(y&&"owner"===E&&ie)try{n(29,X=!0);const e=await ie.text(),t=await fetch(`${Lh()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await lt("POST",`${Lh()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(26,W=e),Me("Script uploaded and updated successfully","success"),await Te(),await Le();else{Me(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){Me(`Error uploading script: ${e.message}`,"error")}finally{n(29,X=!1),n(32,ie=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},function(e){const t=e.detail;var i;Bh.set(t),"chat-inbox"===t?Nm.set("inbox"):"chat-channels"===t&&Nm.set("channels"),ze[t]&&(n(5,F=i=ze[t]),"sprocket"===i&&y&&"owner"===E&&ne&&(Te(),Le()),Pe())},function(){n(48,He=!0)},function(){y||n(16,m=!0)},async function(e){const{method:t,pubkey:i,privateKey:s,signer:r}=e.detail;n(1,y=!0),n(2,w=i),b=t,n(19,x=r),n(16,m=!1);try{if(await bp(),"extension"===t&&r)Zh.setSigner(r);else if("nsec"===t&&s){const e=new Ff(s);Zh.setSigner(e)}n(3,A=await ap(i)),console.log("Profile loaded:",A),k=await up(i),k&&console.log("User relay list loaded:",k.all.length,"relays"),n(18,I=await hp(i)),I&&console.log("User contact list loaded:",I.follows.length,"follows")}catch(e){console.error("Failed to load profile:",e)}if(await Ye(),await Xe(),"events"===F){n(118,rt=!1);it(!0,null)}},function(){n(1,y=!1),n(2,w=""),b="",n(3,A=null),k=null,n(18,I=null),n(4,E=""),n(19,x=null),userPrivkey=null,n(20,S=!1),G=[],n(116,R=[]),H=[],q=0,Pe(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(16,m=!1)},qe,function(){n(21,B=!B)},function(){n(21,B=!1)},function(){n(22,D=!D)},Ge,function(e){const{searchText:t,selectedKinds:n,pubkeys:i,eventIds:s,tags:r,sinceTimestamp:o,untilTimestamp:l,limit:a}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:i=[],tags:s=[],since:r=null,until:o=null,limit:l=null}){const a={};return e&&e.trim()&&(a.search=e.trim()),t&&t.length>0&&(a.kinds=t),n&&n.length>0&&(a.authors=n),i&&i.length>0&&(a.ids=i),s&&s.length>0&&s.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;a[t]||(a[t]=[]),a[t].push(e.value)}}),r&&(a.since=r),o&&(a.until=o),l&&l>0&&(a.limit=l),a}({searchText:t,kinds:n,authors:i,ids:s,tags:r,since:o,until:l,limit:a||100});Q=c,it(!0,null)},function(){Q={},it(!0,null)},Je,Ke,Ve,We,async function(){await tt([])},async function(){await tt([w])},function(e){n(23,T=e.detail.target.files[0])},async function(){if("none"!==he&&(!y||"admin"!==E&&"owner"!==E))return n(24,L="Admin or owner permission required"),void setTimeout(()=>{n(24,L="")},5e3);if(!T)return n(24,L="Please select a file"),void setTimeout(()=>{n(24,L="")},5e3);try{n(24,L="Uploading...");const e={};"none"!==he&&y&&(e.Authorization=await ot(`${Lh()}/api/import`,"POST"));const t=new FormData;t.append("file",T);const i=await fetch(`${Lh()}/api/import`,{method:"POST",headers:e,body:t});if(!i.ok)throw new Error(`Import failed: ${i.status} ${i.statusText}`);await i.json();n(24,L="Upload complete"),n(23,T=null),document.getElementById("import-file").value="",setTimeout(()=>{n(24,L="")},5e3)}catch(e){console.error("Import failed:",e),n(24,L="Import failed: "+e.message),setTimeout(()=>{n(24,L="")},5e3)}},it,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:i}=e.target;n-t-i<100&&st()},function(){try{if(!ge.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(ge);n(40,ge=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!ge.trim())return void alert("Please enter an event to sign");if(!y||!w)return void alert("Please log in to sign events");if(!x)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(ge);e.pubkey=w,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await x.signEvent(e);n(40,ge=JSON.stringify(t,null,2)),alert("Event signed successfully!")}catch(e){console.error("Error signing event:",e),alert("Error signing event: "+e.message)}},async function(){n(41,me="");try{if(!ge.trim())return void n(41,me="Please enter an event to publish");if(!y)return void n(41,me="Please log in to publish events");if(!x)return void n(41,me="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(ge)}catch(e){return void n(41,me=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(41,me='Event must be signed before publishing. Please click "Sign" first.');if("read"===E)return void n(41,me=`Permission denied: Your current role is "${E}" which does not allow publishing events. Contact a relay administrator to upgrade your permissions.`);const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=await eC(t,e,x,w);if(i.success)if(n(41,me=""),ve)alert("Event published to this relay only.");else{try{await Zh.publish(e)}catch(e){console.warn("Broadcast to other relays failed:",e)}alert("Event published and broadcast to relays!")}else{const t=i.reason||"Unknown error";n(41,me=at(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(41,me=at(t,null))}},function(){n(41,me="")},ct,function(){const e=["owner","admin","write","read"],t=e.indexOf(E);return-1===t?["read"]:e.slice(t)},R,j,rt,o,r,function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},e=>e.id===F,e=>ct(e.detail),e=>Ce(e.detail),e=>xe(e.detail),e=>Ee(e.detail.event,e.detail.e),e=>it(e.detail.refresh,e.detail.authors),function(e){ge=e,n(40,ge)},function(e){ve=e,n(42,ve)},function(e){W=e,n(26,W)},e=>_e(e.detail),e=>Ne(e.detail),function(e){se=e,n(33,se)},function(){ye=$(this),n(43,ye)},function(){we=C(this.value),n(44,we)},e=>$e(e),e=>Be(e),(e,t)=>Ee(e,t),e=>Ke(e.id,!0),e=>Je(e.id),e=>xe(e.id),e=>Ce(e.id),(e,t)=>"Enter"===t.key&&Ce(e.id),(e,t)=>Ee(e,t),(e,t)=>Ve(t,e.id),e=>ct(e===E?"":e),()=>{qe(),Qe()},e=>"Escape"===e.key&&qe(),function(e){m=e,n(16,m)},function(e){v=e,n(17,v)},()=>n(48,He=!1),e=>{Ge({search:e.detail},`Search: ${e.detail}`)}]}!function(){const e=!!localStorage.getItem("relayUrl"),t="file:"===window.location.protocol,n=!["3334","7777","443","80",""].includes(window.location.port),i=Rh||e||t||n;kh.set(i),Th&&!c(Ah)&&Ah.set(Th),console.log("[config] Initialized:",{standaloneMode:i,buildStandalone:Rh,hasStoredRelay:e,isNonRelayPort:n,port:window.location.port,relayUrl:c(Ah)||"(same origin)"})}();return new class extends fe{constructor(e){super(),de(this,e,qS,jS,r,{},null,[-1,-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}();
  24  //# sourceMappingURL=bundle.js.map
  25