|
|
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Object.keys(tr).join(", ");const ir=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 sr=16;function ar(e){return e<<1^283&-(e>>7)}function lr(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=ar(e);return n}const cr=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=ar(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return t})(),ur=cr.map((e,t)=>cr.indexOf(t)),dr=e=>e<<24|e>>>8,fr=e=>e<<8|e>>>24;function hr(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(fr),o=r.map(fr),i=o.map(fr),s=new Uint32Array(65536),a=new Uint32Array(65536),l=new Uint16Array(65536);for(let t=0;t<256;t++)for(let c=0;c<256;c++){const u=256*t+c;s[u]=n[t]^r[c],a[u]=o[t]^i[c],l[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:l,T0:n,T1:r,T2:o,T3:i,T01:s,T23:a}}const pr=hr(cr,e=>lr(e,3)<<24|e<<16|e<<8|lr(e,2)),yr=hr(ur,e=>lr(e,11)<<24|lr(e,13)<<16|lr(e,9)<<8|lr(e,14)),gr=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=ar(n))e[t]=n;return e})();function wr(e){or(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}=pr,r=ir(e),o=r.length,i=e=>mr(n,e,e,e,e),s=new Uint32Array(t+28);s.set(r);for(let e=o;e<s.length;e++){let t=s[e-1];e%o===0?t=i(dr(t))^gr[e/o-1]:o>6&&e%o===4&&(t=i(t)),s[e]=s[e-o]^t}return s}function vr(e,t,n,r,o,i){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|i>>>24&255]}function mr(e,t,n,r,o){return e[255&t|65280&n]|e[r>>>16&255|o>>>16&65280]<<16}function br(e,t,n,r,o){const{sbox2:i,T01:s,T23:a}=pr;let l=0;t^=e[l++],n^=e[l++],r^=e[l++],o^=e[l++];const c=e.length/4-2;for(let i=0;i<c;i++){const i=e[l++]^vr(s,a,t,n,r,o),c=e[l++]^vr(s,a,n,r,o,t),u=e[l++]^vr(s,a,r,o,t,n),d=e[l++]^vr(s,a,o,t,n,r);t=i,n=c,r=u,o=d}return{s0:e[l++]^mr(i,t,n,r,o),s1:e[l++]^mr(i,n,r,o,t),s2:e[l++]^mr(i,r,o,t,n),s3:e[l++]^mr(i,o,t,n,r)}}function Er(e,t,n,r,o){const{sbox2:i,T01:s,T23:a}=yr;let l=0;t^=e[l++],n^=e[l++],r^=e[l++],o^=e[l++];const c=e.length/4-2;for(let i=0;i<c;i++){const i=e[l++]^vr(s,a,t,o,r,n),c=e[l++]^vr(s,a,n,t,o,r),u=e[l++]^vr(s,a,r,n,t,o),d=e[l++]^vr(s,a,o,r,n,t);t=i,n=c,r=u,o=d}return{s0:e[l++]^mr(i,t,o,r,n),s1:e[l++]^mr(i,n,t,o,r),s2:e[l++]^mr(i,r,n,t,o),s3:e[l++]^mr(i,o,r,n,t)}}function xr(e,t){if(!t)return new Uint8Array(e);if(or(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);return t}const kr=(Sr={blockSize:16,nonceLength:16},Cr=function(e,t,n={}){or(e),or(t,16);const r=!n.disablePadding;return{encrypt:(n,o)=>{const i=wr(e),{b:s,o:a,out:l}=function(e,t,n){let r=e.length;const o=r%sr;if(!t&&0!==o)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=ir(e);if(t){let e=sr-o;e||(e=sr),r+=e}const s=xr(r,n);return{b:i,o:ir(s),out:s}}(n,r,o),c=ir(t);let u=c[0],d=c[1],f=c[2],h=c[3],p=0;for(;p+4<=s.length;)u^=s[p+0],d^=s[p+1],f^=s[p+2],h^=s[p+3],({s0:u,s1:d,s2:f,s3:h}=br(i,u,d,f,h)),a[p++]=u,a[p++]=d,a[p++]=f,a[p++]=h;if(r){const e=function(e){const t=new Uint8Array(16),n=ir(t);t.set(e);const r=sr-e.length;for(let e=sr-r;e<sr;e++)t[e]=r;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}=br(i,u,d,f,h)),a[p++]=u,a[p++]=d,a[p++]=f,a[p++]=h}return i.fill(0),l},decrypt:(n,o)=>{!function(e){if(or(e),e.length%sr!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const i=function(e){const t=wr(e),n=t.slice(),r=t.length,{sbox2:o}=pr,{T0:i,T1:s,T2:a,T3:l}=yr;for(let e=0;e<r;e+=4)for(let o=0;o<4;o++)n[e+o]=t[r-e-4+o];t.fill(0);for(let e=4;e<r-4;e++){const t=n[e],r=mr(o,t,t,t,t);n[e]=i[255&r]^s[r>>>8&255]^a[r>>>16&255]^l[r>>>24]}return n}(e),s=ir(t),a=xr(n.length,o),l=ir(n),c=ir(a);let u=s[0],d=s[1],f=s[2],h=s[3];for(let e=0;e+4<=l.length;){const t=u,n=d,r=f,o=h;u=l[e+0],d=l[e+1],f=l[e+2],h=l[e+3];const{s0:s,s1:a,s2:p,s3:y}=Er(i,u,d,f,h);c[e++]=s^t,c[e++]=a^n,c[e++]=p^r,c[e++]=y^o}return i.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 r=e[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}(a,r)}}},Object.assign(Cr,Sr),Cr);var Sr,Cr;const Ar=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),jr=Ar("expand 16-byte k"),Tr=Ar("expand 32-byte k"),_r=ir(jr),$r=ir(Tr);function Ir(e,t){return e<<t|e>>>32-t}function Rr(e){return e.byteOffset%4==0}$r.slice();const Or=2**32-1,Pr=new Uint32Array;function Br(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=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 nr(o),nr(s),rr(i),rr(n),(t,a,l,c,u=0)=>{or(t),or(a),or(l);const d=l.length;if(c||(c=new Uint8Array(d)),or(c),nr(u),u<0||u>=Or)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,y=t.length;if(32===y)h=t.slice(),f.push(h),p=$r;else{if(16!==y||!n)throw new Error(`arx: invalid 32-byte key, got length=${y}`);h=new Uint8Array(32),h.set(t),h.set(t,16),p=_r,f.push(h)}Rr(a)||(a=a.slice(),f.push(a));const g=ir(h);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,g,ir(a.subarray(0,16)),g),a=a.subarray(16)}const w=16-o;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,i?0:12-a.length),a=e,f.push(a)}const v=ir(a);for(!function(e,t,n,r,o,i,s,a){const l=o.length,c=new Uint8Array(64),u=ir(c),d=Rr(o)&&Rr(i),f=d?ir(o):Pr,h=d?ir(i):Pr;for(let p=0;p<l;s++){if(e(t,n,r,u,s,a),s>=Or)throw new Error("arx: counter overflow");const y=Math.min(64,l-p);if(d&&64===y){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<y;t++)e=p+t,i[e]=o[e]^c[t];p+=y}}(e,p,g,v,l,c,u,s);f.length>0;)f.pop().fill(0);return c}}function Nr(e,t,n,r,o,i=20){let s=e[0],a=e[1],l=e[2],c=e[3],u=t[0],d=t[1],f=t[2],h=t[3],p=t[4],y=t[5],g=t[6],w=t[7],v=o,m=n[0],b=n[1],E=n[2],x=s,k=a,S=l,C=c,A=u,j=d,T=f,_=h,$=p,I=y,R=g,O=w,P=v,B=m,N=b,L=E;for(let e=0;e<i;e+=2)x=x+A|0,P=Ir(P^x,16),$=$+P|0,A=Ir(A^$,12),x=x+A|0,P=Ir(P^x,8),$=$+P|0,A=Ir(A^$,7),k=k+j|0,B=Ir(B^k,16),I=I+B|0,j=Ir(j^I,12),k=k+j|0,B=Ir(B^k,8),I=I+B|0,j=Ir(j^I,7),S=S+T|0,N=Ir(N^S,16),R=R+N|0,T=Ir(T^R,12),S=S+T|0,N=Ir(N^S,8),R=R+N|0,T=Ir(T^R,7),C=C+_|0,L=Ir(L^C,16),O=O+L|0,_=Ir(_^O,12),C=C+_|0,L=Ir(L^C,8),O=O+L|0,_=Ir(_^O,7),x=x+j|0,L=Ir(L^x,16),R=R+L|0,j=Ir(j^R,12),x=x+j|0,L=Ir(L^x,8),R=R+L|0,j=Ir(j^R,7),k=k+T|0,P=Ir(P^k,16),O=O+P|0,T=Ir(T^O,12),k=k+T|0,P=Ir(P^k,8),O=O+P|0,T=Ir(T^O,7),S=S+_|0,B=Ir(B^S,16),$=$+B|0,_=Ir(_^$,12),S=S+_|0,B=Ir(B^S,8),$=$+B|0,_=Ir(_^$,7),C=C+A|0,N=Ir(N^C,16),I=I+N|0,A=Ir(A^I,12),C=C+A|0,N=Ir(N^C,8),I=I+N|0,A=Ir(A^I,7);let U=0;r[U++]=s+x|0,r[U++]=a+k|0,r[U++]=l+S|0,r[U++]=c+C|0,r[U++]=u+A|0,r[U++]=d+j|0,r[U++]=f+T|0,r[U++]=h+_|0,r[U++]=p+$|0,r[U++]=y+I|0,r[U++]=g+R|0,r[U++]=w+O|0,r[U++]=v+P|0,r[U++]=m+B|0,r[U++]=b+N|0,r[U++]=E+L|0}const Lr=Br(Nr,{counterRight:!1,counterLength:4,allowShortKeys:!1});class Ur extends Gt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,en.hash(e);const n=Vt(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 r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return en.exists(this),this.iHash.update(e),this}digestInto(e){en.exists(this),en.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:r,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Fr=(e,t,n)=>new Ur(e,t).update(n).digest();Fr.create=(e,t)=>new Ur(e,t);const Mr=new Uint8Array([0]),Dr=new Uint8Array;var Hr=Object.defineProperty,qr=(e,t)=>{for(var n in t)Hr(e,n,{get:t[n],enumerable:!0})},zr=Symbol("verified");function Kr(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}qr({},{Queue:()=>Xr,QueueNode:()=>Qr,binarySearch:()=>Yr,bytesToHex:()=>Kt,hexToBytes:()=>Wt,insertEventIntoAscendingList:()=>Zr,insertEventIntoDescendingList:()=>Gr,normalizeURL:()=>Jr,utf8Decoder:()=>Wr,utf8Encoder:()=>Vr});var Wr=new TextDecoder("utf-8"),Vr=new TextEncoder;function Jr(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 Gr(e,t){const[n,r]=Yr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function Zr(e,t){const[n,r]=Yr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return r||e.splice(n,0,t),e}function Yr(e,t){let n=0,r=e.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t(e[o]);if(0===i)return[o,!0];i<0?r=o-1:n=o+1}return[n,!1]}var Qr=class{value;next=null;prev=null;constructor(e){this.value=e}},Xr=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new Qr(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 eo(e){return Kt(un(Vr.encode(function(e){if(!Kr(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 to=new class{generateSecretKey(){return Ft.utils.randomPrivateKey()}getPublicKey(e){return Kt(Ft.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Kt(Ft.getPublicKey(t)),n.id=eo(n),n.sig=Kt(Ft.sign(eo(n),t)),n[zr]=!0,n}verifyEvent(e){if("boolean"==typeof e[zr])return e[zr];const t=eo(e);if(t!==e.id)return e[zr]=!1,!1;try{const n=Ft.verify(e.sig,t,e.pubkey);return e[zr]=n,n}catch(t){return e[zr]=!1,!1}}},no=to.generateSecretKey,ro=to.getPublicKey,oo=to.finalizeEvent,io=to.verifyEvent,so={};function ao(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function lo(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function co(e){return 2e4<=e&&e<3e4}function uo(e){return 3e4<=e&&e<4e4}function fo(e){return ao(e)?"regular":lo(e)?"replaceable":co(e)?"ephemeral":uo(e)?"parameterized":"unknown"}function ho(e,t){const n=t instanceof Array?t:[t];return Kr(e)&&n.includes(e.kind)||!1}qr(so,{Application:()=>Ci,BadgeAward:()=>xo,BadgeDefinition:()=>vi,BlockedRelaysList:()=>Xo,BookmarkList:()=>Zo,Bookmarksets:()=>yi,Calendar:()=>Ri,CalendarEventRSVP:()=>Oi,ChannelCreation:()=>Ao,ChannelHideMessage:()=>_o,ChannelMessage:()=>To,ChannelMetadata:()=>jo,ChannelMuteUser:()=>$o,ClassifiedListing:()=>Ti,ClientAuth:()=>ai,CommunitiesList:()=>Yo,CommunityDefinition:()=>Ni,CommunityPostApproval:()=>Fo,Contacts:()=>wo,CreateOrUpdateProduct:()=>Ei,CreateOrUpdateStall:()=>bi,Curationsets:()=>gi,Date:()=>$i,DirectMessageRelaysList:()=>ri,DraftClassifiedListing:()=>_i,DraftLong:()=>ki,Emojisets:()=>Si,EncryptedDirectMessage:()=>vo,EventDeletion:()=>mo,FileMetadata:()=>Oo,FileServerPreference:()=>oi,Followsets:()=>fi,GenericRepost:()=>Co,Genericlists:()=>hi,GiftWrap:()=>Ro,HTTPAuth:()=>di,Handlerinformation:()=>Bi,Handlerrecommendation:()=>Pi,Highlights:()=>Wo,InterestsList:()=>ti,Interestsets:()=>mi,JobFeedback:()=>Ho,JobRequest:()=>Mo,JobResult:()=>Do,Label:()=>Uo,LightningPubRPC:()=>si,LiveChatMessage:()=>Po,LiveEvent:()=>Ai,LongFormArticle:()=>xi,Metadata:()=>po,Mutelist:()=>Vo,NWCWalletInfo:()=>ii,NWCWalletRequest:()=>li,NWCWalletResponse:()=>ci,NostrConnect:()=>ui,OpenTimestamps:()=>Io,Pinlist:()=>Jo,PrivateDirectMessage:()=>So,ProblemTracker:()=>Bo,ProfileBadges:()=>wi,PublicChatsList:()=>Qo,Reaction:()=>Eo,RecommendRelay:()=>go,RelayList:()=>Go,Relaysets:()=>pi,Report:()=>No,Reporting:()=>Lo,Repost:()=>bo,Seal:()=>ko,SearchRelaysList:()=>ei,ShortTextNote:()=>yo,Time:()=>Ii,UserEmojiList:()=>ni,UserStatuses:()=>ji,Zap:()=>Ko,ZapGoal:()=>qo,ZapRequest:()=>zo,classifyKind:()=>fo,isAddressableKind:()=>uo,isEphemeralKind:()=>co,isKind:()=>ho,isRegularKind:()=>ao,isReplaceableKind:()=>lo});var po=0,yo=1,go=2,wo=3,vo=4,mo=5,bo=6,Eo=7,xo=8,ko=13,So=14,Co=16,Ao=40,jo=41,To=42,_o=43,$o=44,Io=1040,Ro=1059,Oo=1063,Po=1311,Bo=1971,No=1984,Lo=1984,Uo=1985,Fo=4550,Mo=5999,Do=6999,Ho=7e3,qo=9041,zo=9734,Ko=9735,Wo=9802,Vo=1e4,Jo=10001,Go=10002,Zo=10003,Yo=10004,Qo=10005,Xo=10006,ei=10007,ti=10015,ni=10030,ri=10050,oi=10096,ii=13194,si=21e3,ai=22242,li=23194,ci=23195,ui=24133,di=27235,fi=3e4,hi=30001,pi=30002,yi=30003,gi=30004,wi=30008,vi=30009,mi=30015,bi=30017,Ei=30018,xi=30023,ki=30024,Si=30030,Ci=30078,Ai=30311,ji=30315,Ti=30402,_i=30403,$i=31922,Ii=31923,Ri=31924,Oi=31925,Pi=31989,Bi=31990,Ni=34550;function Li(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}function Ui(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,o=e.slice(r),i=Math.min(o.indexOf(","),o.indexOf("}"));return parseInt(o.slice(0,i),10)}function Fi(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 r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return e.slice(r+1,i)}function Mi(e,t){return t===Li(e,"id")}function Di(e,t){return t===Li(e,"pubkey")}function Hi(e,t){return t===Ui(e,"kind")}qr({},{getHex64:()=>Li,getInt:()=>Ui,getSubscriptionId:()=>Fi,matchEventId:()=>Mi,matchEventKind:()=>Hi,matchEventPubkey:()=>Di});function qi(e,t){return{kind:ai,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}qr({},{makeAuthEvent:()=>qi});try{WebSocket}catch{}try{WebSocket}catch{}var zi={};qr(zi,{BECH32_REGEX:()=>Vi,Bech32MaxSize:()=>Wi,NostrTypeGuard:()=>Ki,decode:()=>Gi,decodeNostrURI:()=>Ji,encodeBytes:()=>ts,naddrEncode:()=>os,neventEncode:()=>rs,noteEncode:()=>Xi,nprofileEncode:()=>ns,npubEncode:()=>Qi,nsecEncode:()=>Yi});var Ki={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||"")},Wi=5e3,Vi=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function Ji(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),Gi(e)}catch(e){return{type:"invalid",data:null}}}function Gi(e){let{prefix:t,words:n}=er.decode(e,Wi),r=new Uint8Array(er.fromWords(n));switch(t){case"nprofile":{let e=Zi(r);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:Kt(e[0][0]),relays:e[1]?e[1].map(e=>Wr.decode(e)):[]}}}case"nevent":{let e=Zi(r);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:Kt(e[0][0]),relays:e[1]?e[1].map(e=>Wr.decode(e)):[],author:e[2]?.[0]?Kt(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(Kt(e[3][0]),16):void 0}}}case"naddr":{let e=Zi(r);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:Wr.decode(e[0][0]),pubkey:Kt(e[2][0]),kind:parseInt(Kt(e[3][0]),16),relays:e[1]?e[1].map(e=>Wr.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:Kt(r)};default:throw new Error(`unknown prefix ${t}`)}}function Zi(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],o=n.slice(2,2+r);if(n=n.slice(2+r),o.length<r)throw new Error(`not enough data to read on TLV ${e}`);t[e]=t[e]||[],t[e].push(o)}return t}function Yi(e){return ts("nsec",e)}function Qi(e){return ts("npub",Wt(e))}function Xi(e){return ts("note",Wt(e))}function es(e,t){let n=er.toWords(t);return er.encode(e,n,Wi)}function ts(e,t){return es(e,t)}function ns(e){return es("nprofile",is({0:[Wt(e.pubkey)],1:(e.relays||[]).map(e=>Vr.encode(e))}))}function rs(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)),es("nevent",is({0:[Wt(e.id)],1:(e.relays||[]).map(e=>Vr.encode(e)),2:e.author?[Wt(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function os(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),es("naddr",is({0:[Vr.encode(e.identifier)],1:(e.relays||[]).map(e=>Vr.encode(e)),2:[Wt(e.pubkey)],3:[new Uint8Array(t)]}))}function is(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),Jt(...t)}var ss={};function as(e,t,n){const r=e instanceof Uint8Array?Kt(e):e,o=cs(kt.getSharedSecret(r,"02"+t));let i=Uint8Array.from(Yt(16)),s=Vr.encode(n),a=kr(o,i).encrypt(s);return`${qn.encode(new Uint8Array(a))}?iv=${qn.encode(new Uint8Array(i.buffer))}`}function ls(e,t,n){const r=e instanceof Uint8Array?Kt(e):e;let[o,i]=n.split("?iv="),s=cs(kt.getSharedSecret(r,"02"+t)),a=qn.decode(i),l=qn.decode(o),c=kr(s,a).decrypt(l);return Wr.decode(c)}function cs(e){return e.slice(1,33)}qr(ss,{decrypt:()=>ls,encrypt:()=>as});qr({},{NIP05_REGEX:()=>ds,isNip05:()=>fs,isValid:()=>gs,queryProfile:()=>ys,searchDomain:()=>ps,useFetchImplementation:()=>hs});var us,ds=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,fs=e=>ds.test(e||"");try{us=fetch}catch(e){}function hs(e){us=e}async function ps(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await us(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function ys(e){const t=e.match(ds);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await us(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const o=await t.json(),i=o.names[n];return i?{pubkey:i,relays:o.relays?.[i]}:null}catch(e){return null}}async function gs(e,t){const n=await ys(t);return!!n&&n.pubkey===e}function ws(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let o=e.tags.length-1;o>=0;o--){const i=e.tags[o];if("e"===i[0]&&i[1]){const[e,o,s,a,l]=i,c={id:o,relays:s?[s]:[],author:l};if("root"===a){t.root=c;continue}if("reply"===a){t.reply=c;continue}if("mention"===a){t.mentions.push(c);continue}n?r=c:n=c,t.mentions.push(c);continue}if("q"===i[0]&&i[1]){const[e,n,r]=i;t.quotes.push({id:n,relays:r?[r]:[]})}"p"===i[0]&&i[1]&&t.profiles.push({pubkey:i[1],relays:i[2]?[i[2]]:[]})}return t.root||(t.root=r||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}qr({},{parse:()=>ws});qr({},{fetchRelayInformation:()=>ms,useFetchImplementation:()=>vs});try{fetch}catch{}function vs(e){0}async function ms(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function bs(e){let t=0;for(let n=0;n<64;n+=8){const r=parseInt(e.substring(n,n+8),16);if(0!==r){t+=Math.clz32(r);break}t+=32}return t}function Es(e,t){let n=0;const r=e,o=["nonce",n.toString(),t.toString()];for(r.tags.push(o);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),o[1]=(++n).toString(),r.id=xs(r),bs(r.id)>=t)break}return r}function xs(e){return Kt(un(Vr.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}qr({},{fastEventHash:()=>xs,getPow:()=>bs,minePow:()=>Es});qr({},{unwrapEvent:()=>Js,unwrapManyEvents:()=>Gs,wrapEvent:()=>Ws,wrapManyEvents:()=>Vs});qr({},{createRumor:()=>Fs,createSeal:()=>Ms,createWrap:()=>Ds,unwrapEvent:()=>zs,unwrapManyEvents:()=>Ks,wrapEvent:()=>Hs,wrapManyEvents:()=>qs});var ks={};qr(ks,{decrypt:()=>Rs,encrypt:()=>Is,getConversationKey:()=>As,v2:()=>Os});var Ss=1,Cs=65535;function As(e,t){const n=kt.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return en.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Fr(e,Vt(n),Vt(t))}(un,n,"nip44-v2")}function js(e,t){const n=function(e,t,n,r=32){if(en.hash(e),en.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/e.outputLen);void 0===n&&(n=Dr);const i=new Uint8Array(o*e.outputLen),s=Fr.create(e,t),a=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let t=0;t<o;t++)Mr[0]=t+1,a.update(0===t?Dr:l).update(n).update(Mr).digestInto(l),i.set(l,e.outputLen*t),s._cloneInto(a);return s.destroy(),a.destroy(),l.fill(0),Mr.fill(0),i.slice(0,r)}(un,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function Ts(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 _s(e){const t=Vr.encode(e),n=t.length;return Jt(function(e){if(!Number.isSafeInteger(e)||e<Ss||e>Cs)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(Ts(n)-n))}function $s(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=Jt(n,t);return Fr(un,e,r)}function Is(e,t,n=Yt(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=js(t,n),s=_s(e),a=Lr(r,o,s),l=$s(i,a,n);return qn.encode(Jt(new Uint8Array([2]),n,a,l))}function Rs(e,t){const{nonce:n,ciphertext:r,mac:o}=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=qn.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(2!==o)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:i,chacha_nonce:s,hmac_key:a}=js(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}($s(a,r,n),o))throw new Error("invalid MAC");return function(e){const t=new DataView(e.buffer).getUint16(0),n=e.subarray(2,2+t);if(t<Ss||t>Cs||n.length!==t||e.length!==2+Ts(t))throw new Error("invalid padding");return Wr.decode(n)}(Lr(i,s,r))}var Os={utils:{getConversationKey:As,calcPaddedLen:Ts},encrypt:Is,decrypt:Rs},Ps=()=>Math.round(Date.now()/1e3),Bs=()=>Math.round(Ps()-172800*Math.random()),Ns=(e,t)=>As(e,t),Ls=(e,t,n)=>Is(JSON.stringify(e),Ns(t,n)),Us=(e,t)=>JSON.parse(Rs(e.content,Ns(t,e.pubkey)));function Fs(e,t){const n={created_at:Ps(),content:"",tags:[],...e,pubkey:ro(t)};return n.id=eo(n),n}function Ms(e,t,n){return oo({kind:ko,content:Ls(e,t,n),created_at:Bs(),tags:[]},t)}function Ds(e,t){const n=no();return oo({kind:Ro,content:Ls(e,n,t),created_at:Bs(),tags:[["p",t]]},n)}function Hs(e,t,n){return Ds(Ms(Fs(e,t),t,n),n)}function qs(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=ro(t),o=[Hs(e,t,r)];return n.forEach(n=>{o.push(Hs(e,t,n))}),o}function zs(e,t){const n=Us(e,t);return Us(n,t)}function Ks(e,t){let n=[];return e.forEach(e=>{n.push(zs(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function Ws(e,t,n,r,o){const i=function(e,t,n,r){const o={created_at:Math.ceil(Date.now()/1e3),kind:So,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{o.tags.push(t?["p",e,t]:["p",e])}),r&&o.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&o.tags.push(["subject",n]),o}(t,n,r,o);return Hs(i,e,t.publicKey)}function Vs(e,t,n,r,o){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:ro(e)},...t].map(t=>Ws(e,t,n,r,o))}var Js=zs,Gs=Ks;function Zs(e,t,n,r){let o;const i=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===yo?o=bo:(o=Co,i.push(["k",String(t.kind)])),oo({kind:o,tags:i,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},r)}function Ys(e){if(![bo,Co].includes(e.kind))return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function Qs(e,{skipVerification:t}={}){const n=Ys(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||io(r))?r:void 0}qr({},{finishRepostEvent:()=>Zs,getRepostedEvent:()=>Qs,getRepostedEventPointer:()=>Ys});qr({},{NOSTR_URI_REGEX:()=>Xs,parse:()=>ta,test:()=>ea});var Xs=new RegExp(`nostr:(${Vi.source})`);function ea(e){return"string"==typeof e&&new RegExp(`^${Xs.source}$`).test(e)}function ta(e){const t=e.match(new RegExp(`^${Xs.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:Gi(t[1])}}function na(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return oo({...e,kind:Eo,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function ra(e){if(e.kind!==Eo)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}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}qr({},{finishReactionEvent:()=>na,getReactedEventPointer:()=>ra});qr({},{parse:()=>sa});var oa=/\W/m,ia=/\W |\W$|$|,| /m;function*sa(e){const t=e.length;let n=0,r=0;for(;r<t;){let o=e.indexOf(":",r);if(-1===o)break;if("nostr"===e.substring(o-5,o)){const i=e.substring(o+60).match(oa),s=i?o+60+i.index:t;try{let t,{data:i,type:a}=Gi(e.substring(o+1,s));switch(a){case"npub":t={pubkey:i};break;case"nsec":case"note":r=s+1;continue;default:t=i}n!==o-5&&(yield{type:"text",text:e.substring(n,o-5)}),yield{type:"reference",pointer:t},r=s,n=r;continue}catch(e){r=o+1;continue}}else if("https"===e.substring(o-5,o)||"http"===e.substring(o-4,o)){const i=e.substring(o+4).match(ia),s=i?o+4+i.index:t,a="s"===e[o-1]?5:4;try{let t=new URL(e.substring(o-a,s));if(-1===t.hostname.indexOf("."))throw new Error("invalid url");if(n!==o-a&&(yield{type:"text",text:e.substring(n,o-a)}),/\.(png|jpe?g|gif|webp)$/i.test(t.pathname)){yield{type:"image",url:t.toString()},r=s,n=r;continue}if(/\.(mp4|avi|webm|mkv)$/i.test(t.pathname)){yield{type:"video",url:t.toString()},r=s,n=r;continue}if(/\.(mp3|aac|ogg|opus)$/i.test(t.pathname)){yield{type:"audio",url:t.toString()},r=s,n=r;continue}yield{type:"url",url:t.toString()},r=s,n=r;continue}catch(e){r=s+1;continue}}else{if("wss"!==e.substring(o-3,o)&&"ws"!==e.substring(o-2,o)){r=o+1;continue}{const i=e.substring(o+4).match(ia),s=i?o+4+i.index:t,a="s"===e[o-1]?3:2;try{let t=new URL(e.substring(o-a,s));if(-1===t.hostname.indexOf("."))throw new Error("invalid ws url");n!==o-a&&(yield{type:"text",text:e.substring(n,o-a)}),yield{type:"relay",url:t.toString()},r=s,n=r;continue}catch(e){r=s+1;continue}}}}n!==t&&(yield{type:"text",text:e.substring(n)})}qr({},{channelCreateEvent:()=>aa,channelHideMessageEvent:()=>ua,channelMessageEvent:()=>ca,channelMetadataEvent:()=>la,channelMuteUserEvent:()=>da});var aa=(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 oo({kind:Ao,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},la=(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 oo({kind:jo,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},ca=(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"]),oo({kind:To,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},ua=(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 oo({kind:_o,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},da=(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 oo({kind:$o,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};qr({},{EMOJI_SHORTCODE_REGEX:()=>fa,matchAll:()=>pa,regex:()=>ha,replaceAll:()=>ya});var fa=/:(\w+):/,ha=()=>new RegExp(`\\B${fa.source}\\B`,"g");function*pa(e){const t=e.matchAll(ha());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 ya(e,t){return e.replaceAll(ha(),(e,n)=>t({shortcode:e,name:n}))}var ga;qr({},{useFetchImplementation:()=>wa,validateGithub:()=>va});try{ga=fetch}catch{}function wa(e){ga=e}async function va(e,t,n){try{return await(await ga(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function ma(e){const{host:t,pathname:n,searchParams:r}=new URL(e),o=n||t,i=r.get("relay"),s=r.get("secret");if(!o||!i||!s)throw new Error("invalid connection string");return{pubkey:o,relay:i,secret:s}}async function ba(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},o=as(t,e,JSON.stringify(r)),i={kind:li,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",e]]};return oo(i,t)}qr({},{makeNwcRequestEvent:()=>ba,parseConnectionString:()=>ma});function Ea(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("")}qr({},{normalizeIdentifier:()=>Ea});var xa;qr({},{getSatoshisAmountFromBolt11:()=>Ta,getZapEndpoint:()=>Sa,makeZapReceipt:()=>ja,makeZapRequest:()=>Ca,useFetchImplementation:()=>ka,validateZapRequest:()=>Aa});try{xa=fetch}catch{}function ka(e){xa=e}async function Sa(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=er.decode(n,1e3),r=er.fromWords(e);t=Wr.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let o=await xa(t),i=await o.json();if(i.allowsNostr&&i.nostrPubkey)return i.callback}catch(e){}return null}function Ca(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]),lo(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(uo(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 r=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(r)}t.tags.push(["k",e.event.kind.toString()])}return t}function Aa(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!Kr(t))return"Zap request is not a valid Nostr event.";if(!io(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 r=t.tags.find(([e,t])=>"e"===e&&t);return r&&!r[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 ja({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let o=JSON.parse(e),i=o.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),s={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...i,["P",o.pubkey],["bolt11",n],["description",e]]};return t&&s.tags.push(["preimage",t]),s}function Ta(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 r=n.substring(4);if(r.length<1)return 0;const o=r[r.length-1],i=o.charCodeAt(0)-"0".charCodeAt(0),s=i>=0&&i<=9;let a=r.length-1;if(s&&a++,a<1)return 0;const l=parseInt(r.substring(0,a));switch(o){case"m":return 1e5*l;case"u":return 100*l;case"n":return l/10;case"p":return l/1e4;default:return 1e8*l}}qr({},{getToken:()=>$a,hashPayload:()=>La,unpackEventFromToken:()=>Ra,validateEvent:()=>Fa,validateEventKind:()=>Pa,validateEventMethodTag:()=>Na,validateEventPayloadTag:()=>Ua,validateEventTimestamp:()=>Oa,validateEventUrlTag:()=>Ba,validateToken:()=>Ia});var _a="Nostr ";async function $a(e,t,n,r=!1,o){const i={kind:di,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};o&&i.tags.push(["payload",La(o)]);const s=await n(i);return(r?_a:"")+qn.encode(Vr.encode(JSON.stringify(s)))}async function Ia(e,t,n){const r=await Ra(e).catch(e=>{throw e});return await Fa(r,t,n).catch(e=>{throw e})}async function Ra(e){if(!e)throw new Error("Missing token");e=e.replace(_a,"");const t=Wr.decode(qn.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Oa(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function Pa(e){return e.kind===di}function Ba(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function Na(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function La(e){return Kt(un(Vr.encode(JSON.stringify(e))))}function Ua(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const r=La(t);return n.length>0&&n[1]===r}async function Fa(e,t,n,r){if(!io(e))throw new Error("Invalid nostr event, signature invalid");if(!Pa(e))throw new Error("Invalid nostr event, kind invalid");if(!Oa(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!Ba(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!Na(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!Ua(e,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function Ma(e){return 3e4<=e&&e<4e4}var Da=function(e,t){return Da=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])},Da(e,t)};function Ha(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}Da(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function qa(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})}function za(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}function Ka(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Wa(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function Va(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function Ja(e){return this instanceof Ja?(this.v=e,this):new Ja(e)}function Ga(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,c)}}),r[Symbol.asyncIterator]=function(){return this},r;function s(e,t){o[e]&&(r[e]=function(t){return new Promise(function(n,r){i.push([e,t,n,r])>1||a(e,t)})},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof Ja?Promise.resolve(n.value.v).then(l,c):u(i[0][2],n)}catch(e){u(i[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function Za(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Ka(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,o){(function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)})(r,o,(t=e[n](t)).done,t.value)})}}}function Ya(e){return"function"==typeof e}function Qa(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 Xa=Qa(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 el(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var tl=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,r,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var s=Ka(i),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else i.remove(this);var l=this.initialTeardown;if(Ya(l))try{l()}catch(e){o=e instanceof Xa?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=Ka(c),d=u.next();!d.done;d=u.next()){var f=d.value;try{ol(f)}catch(e){o=null!=o?o:[],e instanceof Xa?o=Va(Va([],Wa(o)),Wa(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(o)throw new Xa(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ol(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)&&el(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&el(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),nl=tl.EMPTY;function rl(e){return e instanceof tl||e&&"closed"in e&&Ya(e.remove)&&Ya(e.add)&&Ya(e.unsubscribe)}function ol(e){Ya(e)?e():e.unsubscribe()}var il={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},sl={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=sl.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,Va([e,t],Wa(n))):setTimeout.apply(void 0,Va([e,t],Wa(n)))},clearTimeout:function(e){var t=sl.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function al(e){sl.setTimeout(function(){throw e})}function ll(){}function cl(e){e()}var ul=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,rl(t)&&t.add(n)):n.destination=gl,n}return Ha(t,e),t.create=function(e,t,n){return new pl(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}(tl),dl=Function.prototype.bind;function fl(e,t){return dl.call(e,t)}var hl=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){yl(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){yl(e)}else yl(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){yl(e)}},e}(),pl=function(e){function t(t,n,r){var o,i,s=e.call(this)||this;Ya(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:s&&il.useDeprecatedNextContext?((i=Object.create(t)).unsubscribe=function(){return s.unsubscribe()},o={next:t.next&&fl(t.next,i),error:t.error&&fl(t.error,i),complete:t.complete&&fl(t.complete,i)}):o=t;return s.destination=new hl(o),s}return Ha(t,e),t}(ul);function yl(e){al(e)}var gl={closed:!0,next:ll,error:function(e){throw e},complete:ll},wl="function"==typeof Symbol&&Symbol.observable||"@@observable";function vl(e){return e}var ml=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 r,o=this,i=(r=e)&&r instanceof ul||function(e){return e&&Ya(e.next)&&Ya(e.error)&&Ya(e.complete)}(r)&&rl(r)?e:new pl(e,t,n);return cl(function(){var e=o,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?o._subscribe(i):o._trySubscribe(i))}),i},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=bl(t))(function(t,r){var o=new pl({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.subscribe(o)})},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[wl]=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?vl: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=bl(e))(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function bl(e){var t;return null!==(t=null!=e?e:il.Promise)&&void 0!==t?t:Promise}function El(e){return function(t){if(function(e){return Ya(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 xl(e,t,n,r,o){return new kl(e,t,n,r,o)}var kl=function(e){function t(t,n,r,o,i,s){var a=e.call(this,t)||this;return a.onFinalize=i,a.shouldUnsubscribe=s,a._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return Ha(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}(ul),Sl=Qa(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Cl=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 Ha(t,e),t.prototype.lift=function(e){var t=new Al(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Sl},t.prototype.next=function(e){var t=this;cl(function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=Ka(t.currentObservers),i=o.next();!i.done;i=o.next()){i.value.next(e)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;cl(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;cl(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,r=n.hasError,o=n.isStopped,i=n.observers;return r||o?nl:(this.currentObservers=null,i.push(e),new tl(function(){t.currentObservers=null,el(i,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new ml;return e.source=this,e},t.create=function(e,t){return new Al(e,t)},t}(ml),Al=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return Ha(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:nl},t}(Cl),jl={now:function(){return(jl.delegate||Date).now()},delegate:void 0},Tl=function(e){function t(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=jl);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=n,o._timestampProvider=r,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,n),o}return Ha(t,e),t.prototype.next=function(t){var n=this,r=n.isStopped,o=n._buffer,i=n._infiniteTimeWindow,s=n._timestampProvider,a=n._windowTime;r||(o.push(t),!i&&o.push(s.now()+a)),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,r=this._buffer.slice(),o=0;o<r.length&&!e.closed;o+=n?1:2)e.next(r[o]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,n=e._timestampProvider,r=e._buffer,o=e._infiniteTimeWindow,i=(o?1:2)*t;if(t<1/0&&i<r.length&&r.splice(0,r.length-i),!o){for(var s=n.now(),a=0,l=1;l<r.length&&r[l]<=s;l+=2)a=l;a&&r.splice(0,a+1)}},t}(Cl),_l=function(e){function t(t,n){return e.call(this)||this}return Ha(t,e),t.prototype.schedule=function(e,t){return this},t}(tl),$l={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=$l.delegate;return(null==o?void 0:o.setInterval)?o.setInterval.apply(o,Va([e,t],Wa(n))):setInterval.apply(void 0,Va([e,t],Wa(n)))},clearInterval:function(e){var t=$l.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},Il=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return Ha(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(o,r,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),$l.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&&$l.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,r=!1;try{this.work(e)}catch(e){r=!0,n=e||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,r=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,el(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(_l),Rl=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=jl.now,e}(),Ol=function(e){function t(t,n){void 0===n&&(n=Rl.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return Ha(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}(Rl),Pl=new Ol(Il),Bl=new ml(function(e){return e.complete()});function Nl(e){return e&&Ya(e.schedule)}function Ll(e){return e[e.length-1]}function Ul(e){return Nl(Ll(e))?e.pop():void 0}function Fl(e,t){return"number"==typeof Ll(e)?e.pop():t}var Ml=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function Dl(e){return Ya(null==e?void 0:e.then)}function Hl(e){return Ya(e[wl])}function ql(e){return Symbol.asyncIterator&&Ya(null==e?void 0:e[Symbol.asyncIterator])}function zl(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 Kl="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Wl(e){return Ya(null==e?void 0:e[Kl])}function Vl(e){return Ga(this,arguments,function(){var t,n,r;return za(this,function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Ja(t.read())];case 3:return n=o.sent(),r=n.value,n.done?[4,Ja(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Ja(r)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Jl(e){return Ya(null==e?void 0:e.getReader)}function Gl(e){if(e instanceof ml)return e;if(null!=e){if(Hl(e))return o=e,new ml(function(e){var t=o[wl]();if(Ya(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(Ml(e))return r=e,new ml(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()});if(Dl(e))return n=e,new ml(function(e){n.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,al)});if(ql(e))return Zl(e);if(Wl(e))return t=e,new ml(function(e){var n,r;try{for(var o=Ka(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}e.complete()});if(Jl(e))return Zl(Vl(e))}var t,n,r,o;throw zl(e)}function Zl(e){return new ml(function(t){(function(e,t){var n,r,o,i;return qa(this,void 0,void 0,function(){var s,a;return za(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=Za(e),l.label=1;case 1:return[4,n.next()];case 2:if((r=l.sent()).done)return[3,4];if(s=r.value,t.next(s),t.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),o={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(i=n.return)?[4,i.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})})(e,t).catch(function(e){return t.error(e)})})}function Yl(e,t,n,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var i=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(i),!o)return i}function Ql(e,t){return void 0===t&&(t=0),El(function(n,r){n.subscribe(xl(r,function(n){return Yl(r,e,function(){return r.next(n)},t)},function(){return Yl(r,e,function(){return r.complete()},t)},function(n){return Yl(r,e,function(){return r.error(n)},t)}))})}function Xl(e,t){return void 0===t&&(t=0),El(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function ec(e,t){if(!e)throw new Error("Iterable cannot be null");return new ml(function(n){Yl(n,t,function(){var r=e[Symbol.asyncIterator]();Yl(n,t,function(){r.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}function tc(e,t){if(null!=e){if(Hl(e))return function(e,t){return Gl(e).pipe(Xl(t),Ql(t))}(e,t);if(Ml(e))return function(e,t){return new ml(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}(e,t);if(Dl(e))return function(e,t){return Gl(e).pipe(Xl(t),Ql(t))}(e,t);if(ql(e))return ec(e,t);if(Wl(e))return function(e,t){return new ml(function(n){var r;return Yl(n,t,function(){r=e[Kl](),Yl(n,t,function(){var e,t,o;try{t=(e=r.next()).value,o=e.done}catch(e){return void n.error(e)}o?n.complete():n.next(t)},0,!0)}),function(){return Ya(null==r?void 0:r.return)&&r.return()}})}(e,t);if(Jl(e))return function(e,t){return ec(Vl(e),t)}(e,t)}throw zl(e)}function nc(e,t){return t?tc(e,t):Gl(e)}function rc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return nc(e,Ul(e))}function oc(e,t){return El(function(n,r){var o=0;n.subscribe(xl(r,function(n){r.next(e.call(t,n,o++))}))})}var ic=Array.isArray;function sc(e){return oc(function(t){return function(e,t){return ic(t)?e.apply(void 0,Va([],Wa(t))):e(t)}(e,t)})}var ac=Array.isArray,lc=Object.getPrototypeOf,cc=Object.prototype,uc=Object.keys;function dc(e){if(1===e.length){var t=e[0];if(ac(t))return{args:t,keys:null};if((r=t)&&"object"==typeof r&&lc(r)===cc){var n=uc(t);return{args:n.map(function(e){return t[e]}),keys:n}}}var r;return{args:e,keys:null}}function fc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ul(e),r=function(e){return Ya(Ll(e))?e.pop():void 0}(e),o=dc(e),i=o.args,s=o.keys;if(0===i.length)return nc([],n);var a=new ml(function(e,t,n){void 0===n&&(n=vl);return function(r){hc(t,function(){for(var o=e.length,i=new Array(o),s=o,a=o,l=function(o){hc(t,function(){var l=nc(e[o],t),c=!1;l.subscribe(xl(r,function(e){i[o]=e,c||(c=!0,a--),a||r.next(n(i.slice()))},function(){--s||r.complete()}))},r)},c=0;c<o;c++)l(c)},r)}}(i,n,s?function(e){return function(e,t){return e.reduce(function(e,n,r){return e[n]=t[r],e},{})}(s,e)}:vl));return r?a.pipe(sc(r)):a}function hc(e,t,n){e?Yl(n,e,t):t()}function pc(e,t,n){return void 0===n&&(n=1/0),Ya(t)?pc(function(n,r){return oc(function(e,o){return t(n,e,r,o)})(Gl(e(n,r)))},n):("number"==typeof t&&(n=t),El(function(t,r){return function(e,t,n,r,o,i,s,a){var l=[],c=0,u=0,d=!1,f=function(){!d||l.length||c||t.complete()},h=function(e){return c<r?p(e):l.push(e)},p=function(e){i&&t.next(e),c++;var a=!1;Gl(n(e,u++)).subscribe(xl(t,function(e){null==o||o(e),i?h(e):t.next(e)},function(){a=!0},void 0,function(){if(a)try{c--;for(var e=function(){var e=l.shift();s?Yl(t,s,function(){return p(e)}):p(e)};l.length&&c<r;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(xl(t,h,function(){d=!0,f()})),function(){null==a||a()}}(t,r,e,n)}))}function yc(e){return void 0===e&&(e=1/0),pc(vl,e)}function gc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return yc(1)(nc(e,Ul(e)))}function wc(e){return new ml(function(t){Gl(e()).subscribe(t)})}function vc(e,t,n){void 0===e&&(e=0),void 0===n&&(n=Pl);var r=-1;return null!=t&&(Nl(t)?n=t:r=t),new ml(function(t){var o,i=(o=e)instanceof Date&&!isNaN(o)?+e-n.now():e;i<0&&(i=0);var s=0;return n.schedule(function(){t.closed||(t.next(s++),0<=r?this.schedule(void 0,r):t.complete())},i)})}function mc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ul(e),r=Fl(e,1/0),o=e;return o.length?1===o.length?Gl(o[0]):yc(r)(nc(o,n)):Bl}function bc(e,t){return El(function(n,r){var o=0;n.subscribe(xl(r,function(n){return e.call(t,n,o++)&&r.next(n)}))})}function Ec(e){return e<=0?function(){return Bl}:El(function(t,n){var r=0;t.subscribe(xl(n,function(t){++r<=e&&(n.next(t),e<=r&&n.complete())}))})}function xc(e,t){return void 0===t&&(t=vl),e=null!=e?e:kc,El(function(n,r){var o,i=!0;n.subscribe(xl(r,function(n){var s=t(n);!i&&e(o,s)||(i=!1,o=s,r.next(n))}))})}function kc(e,t){return e===t}function Sc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return gc(t,rc.apply(void 0,Va([],Wa(e))))}}function Cc(e){return El(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function Ac(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ul(e),r=Fl(e,1/0);return El(function(t,o){yc(r)(nc(Va([t],Wa(e)),n)).subscribe(o)})}function jc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ac.apply(void 0,Va([],Wa(e)))}function Tc(e,t){return El(function(e,t,n,r,o){return function(i,s){var a=n,l=t,c=0;i.subscribe(xl(s,function(t){var n=c++;l=a?e(l,t,n):(a=!0,t),r&&s.next(l)},o&&function(){a&&s.next(l),s.complete()}))}}(e,t,arguments.length>=2,!0))}function _c(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!0!==t){if(!1!==t){var o=new pl({next:function(){o.unsubscribe(),e()}});return Gl(t.apply(void 0,Va([],Wa(n)))).subscribe(o)}}else e()}function $c(e,t){return El(function(n,r){var o=null,i=0,s=!1,a=function(){return s&&!o&&r.complete()};n.subscribe(xl(r,function(n){null==o||o.unsubscribe();var s=0,l=i++;Gl(e(n,l)).subscribe(o=xl(r,function(e){return r.next(t?t(n,e,l,s++):e)},function(){o=null,a()}))},function(){s=!0,a()}))})}function Ic(e,t,n){var r=Ya(e)||t||n?{next:e,error:t,complete:n}:e;return r?El(function(e,t){var n;null===(n=r.subscribe)||void 0===n||n.call(r);var o=!0;e.subscribe(xl(t,function(e){var n;null===(n=r.next)||void 0===n||n.call(r,e),t.next(e)},function(){var e;o=!1,null===(e=r.complete)||void 0===e||e.call(r),t.complete()},function(e){var n;o=!1,null===(n=r.error)||void 0===n||n.call(r,e),t.error(e)},function(){var e,t;o&&(null===(e=r.unsubscribe)||void 0===e||e.call(r)),null===(t=r.finalize)||void 0===t||t.call(r)}))}):vl}function Rc(e,t){return void 0!==e[0]&&void 0!==e[1]&&(!t||e[0]===t)}function Oc(e){return Rc(e,"e")}function Pc(e){return Rc(e,"p")}function Bc(e){return Rc(e,"r")}function Nc(e){return Rc(e,"a")}function Lc(e){return Rc(e,"t")}const Uc=(e,...t)=>t.reduce((e,t)=>{const n=[];for(const r of e)try{const e=t(r);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);function Fc(e,t,n){if(Reflect.has(e,t))return Reflect.get(e,t);{const r=n();return Reflect.set(e,t,r),r}}function Mc(e,t){const[n,r]=Dc(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function Dc(e,t){let n=0,r=e.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t(e[o]);if(0===i)return[o,!0];i<0?r=o-1:n=o+1}return[n,!1]}new TextDecoder("utf-8"),new TextEncoder;const Hc=Symbol.for("event-store"),qc=Symbol.for("event-uid"),zc=Symbol.for("replaceable-address"),Kc=Symbol.for("from-cache"),Wc=Symbol.for("replaceable-identifier");function Vc(e){return function(e){return[0,3].includes(e)||1e4<=e&&e<2e4}(e)||Ma(e)}function Jc(e){let t=Reflect.get(e,qc);return t||(t=Vc(e.kind)?Gc(e):e.id,Reflect.set(e,qc,t)),t}function Gc(e){if(!Vc(e.kind))throw new Error("Event is not replaceable or addressable");return Fc(e,zc,()=>{const t=Ma(e.kind)?Yc(e):void 0;return Zc(e.kind,e.pubkey,t)})}function Zc(e,t,n){return e+":"+t+":"+(n??"")}function Yc(e){return Fc(e,Wc,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function Qc(){return Math.round(Date.now()/1e3)}const Xc=Symbol("expiration-timestamp");function eu(e){return Fc(e,Xc,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}function tu(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 nu=Symbol.for("seen-relays");function ru(e,t){return e[nu]||(e[nu]=new Set),e[nu].add(t),e[nu]}const ou=/^wss?:\/\/([-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}|localhost)\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)$/;function iu(e){return e.length>=8&&ou.test(e)}function su(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)} |
|
|
function Ff(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Mf(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function Df(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function Hf(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function qf(e){if(!Array.isArray(e))throw new Error("array expected")}function zf(e,t){if(!Mf(!0,t))throw new Error(`${e}: array of strings expected`)}wf.BASE._setWindowSize(8);const Kf=(e,t)=>0===t?e:Kf(t,e%t),Wf=(e,t)=>e+(t-Kf(e,t)),Vf=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Jf(e,t,n,r){if(qf(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(Wf(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Wf(t,n)}`);let o=0,i=0;const s=Vf[t],a=Vf[n]-1,l=[];for(const r of e){if(Hf(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<<t|r,i+t>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)l.push((o>>i-n&a)>>>0);const e=Vf[i];if(void 0===e)throw new Error("invalid carry");o&=e-1}if(o=o<<n-i&a,!r&&i>=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&l.push(o>>>0),l}const Gf=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Ff(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)=>{Df("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,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(Hf(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Wf(8,e)>32||Wf(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Ff(n))throw new Error("radix2.encode input should be Uint8Array");return Jf(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!Mf(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(Jf(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;zf("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(qf(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(qf(t),t.map(t=>{Df("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return Hf(e),Df("padding",t),{encode(n){for(zf("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){zf("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}(6),function(e=""){return Df("join",e),{encode:t=>(zf("join.decode",t),t.join(e)),decode:t=>(Df("join.decode",t),t.split(e))}}(""));function Zf(e){return wf.fromHex(e).toHex().substring(2)}const Yf=new TextDecoder("utf-8"),Qf=new TextEncoder;class Xf{log=Ku.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=io;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!Xf.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 r=Ud();return this.lastCommand=r,this.sendCommand(e,t),setTimeout(()=>{r.reject(new Error("Device timeout")),this.lastCommand===r&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:r}){let o,i=await window.navigator.serial.requestPort();await i.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;i&&i.readable;){const e=new window.TextDecoderStream;i.readable.pipeTo(e.writable),o=e.readable.getReader();const t=this.readFromSerialPort(o);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===Xf.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(r&&r())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const s=new window.TextEncoderStream;s.readable.pipeTo(i.writable),this.writer=s.writable.getWriter(),await this.sendCommand(Xf.METHOD_PING),await this.sendCommand(Xf.METHOD_PING,[window.location.host]),e&&e(),i.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(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const o=[];for(t&&(o.push(t),t=void 0);;){const{value:i,done:s}=await e.read();if(i){const e=i.split(r);if(e.length>1)return o.push(e.shift()),t=e.pop(),n=e,{value:o.join("").trim(),done:!1};o.push(i)}if(s)return{value:o.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=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let r=Uint8Array.from(function(e=32){if(Hd&&"function"==typeof Hd.getRandomValues)return Hd.getRandomValues(new Uint8Array(e));if(Hd&&"function"==typeof Hd.randomBytes)return Uint8Array.from(Hd.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),o=Qf.encode(t),i=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},i,o);return`${Gf.encode(new Uint8Array(s))}?iv=${Gf.encode(new Uint8Array(r.buffer))}`}async nip04Decrypt(e,t){let[n,r]=t.split("?iv=");const o=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let i=await crypto.subtle.importKey("raw",o,{name:"AES-CBC"},!1,["decrypt"]),s=Gf.decode(n),a=Gf.decode(r),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:a},i,s);return Yf.decode(l)}async getPublicKey(){const e=await this.callMethodOnDevice(Xf.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(Xf.METHOD_RESTORE,[Wd(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:eo({...e,pubkey:t})},r=await this.callMethodOnDevice(Xf.METHOD_SIGN_MESSAGE,[n.id]),o={...n,sig:r,pubkey:t};if(!this.verifyEvent(o))throw new Error("Invalid signature");return o}ping(){this.sendCommand(Xf.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=[Xf.METHOD_PUBLIC_KEY,Xf.METHOD_SIGN_MESSAGE,Xf.METHOD_SHARED_SECRET,Xf.METHOD_RESTORE]}const eh=[`wss://${window.location.host}/`];class th{constructor(){this.pool=new Tn,this.eventStore=new Ld,this.isConnected=!1,this.signer=null,this.relays=[...eh]}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 publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());try{const n=t||this.relays,r=this.pool.publish(n,e);return await Promise.allSettled(r),console.log("✓ Event published successfully"),await lh([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const nh=new th,rh="nostrCache",oh=2,ih="events";function sh(){return new Promise((e,t)=>{try{const n=indexedDB.open(rh,oh);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let r;r=t.objectStoreNames.contains(ih)?n.transaction.objectStore(ih):t.createObjectStore(ih,{keyPath:"id"}),r.indexNames.contains("byKindAuthor")||r.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),r.indexNames.contains("byKindAuthorCreated")||r.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),r.indexNames.contains("byKind")||r.createIndex("byKind","kind",{unique:!1}),r.indexNames.contains("byAuthor")||r.createIndex("byAuthor","pubkey",{unique:!1}),r.indexNames.contains("byCreatedAt")||r.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 ah(e){try{const t=await sh();await new Promise((n,r)=>{const o=t.transaction(ih,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error),o.objectStore(ih).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function lh(e){if(e&&0!==e.length)try{const t=await sh();await new Promise((n,r)=>{const o=t.transaction(ih,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error);const i=o.objectStore(ih);for(const t of e)i.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function ch(e){try{const t=await sh(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const r of e){console.log("QueryEventsFromDB: Processing filter:",r);const e=await new Promise((e,n)=>{const o=t.transaction(ih,"readonly").objectStore(ih),i=[];let s;if(r.kinds&&r.kinds.length>0&&r.authors&&r.authors.length>0){const e=r.kinds[0],t=r.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=o.index("byKindAuthorCreated"),i=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);s=n.openCursor(i,"prev")}else if(r.kinds&&r.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${r.kinds[0]}`);const e=o.index("byKind");s=e.openCursor(IDBKeyRange.only(r.kinds[0]))}else if(r.authors&&r.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${r.authors[0].substring(0,8)}...`);const e=o.index("byAuthor");s=e.openCursor(IDBKeyRange.only(r.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),s=o.openCursor();s.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let o=!0;if(r.kinds&&r.kinds.length>0&&!r.kinds.includes(t.kind)&&(o=!1),r.authors&&r.authors.length>0&&!r.authors.includes(t.pubkey)&&(o=!1),r.since&&t.created_at<r.since&&(o=!1),r.until&&t.created_at>r.until&&(o=!1),r.ids&&r.ids.length>0&&!r.ids.includes(t.id)&&(o=!1),o&&i.push(t),r.limit&&i.length>=r.limit)return console.log(`QueryEventsFromDB: Reached limit of ${r.limit}, found ${i.length} matching events`),void e(i);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${i.length} matching events`),e(i)},s.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",s.error),n(s.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 uh(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 dh(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await sh();return await new Promise((n,r)=>{const o=t.transaction(ih,"readonly").objectStore(ih).index("byKindAuthorCreated"),i=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),s=o.openCursor(i,"prev");s.onsuccess=()=>{const e=s.result;n(e?e.value:null)},s.onerror=()=>r(s.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return uh(t)}}catch(e){console.warn("Failed to load cached profile",e)}try{const t=[{kinds:[0],authors:[e],limit:1}],n=await fh(t,{timeout:1e4});if(n.length>0){const t=n[0];console.log("Profile fetched:",t),await ah(t);try{console.log("Publishing profile event to local relay:",t.id),await nh.publish(t),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const r=uh(t);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:r,event:t}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return r}throw new Error("No profile found")}catch(e){throw console.error("Failed to fetch profile:",e),e}}async function fh(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",nh.relays),nh.isConnected&&0!==nh.relays.length||(console.warn("Client not connected, initializing..."),await yh());const{timeout:n=3e4,useCache:r=!0}=t;if(r)try{const t=await ch(e);t.length>0&&console.log(`Found ${t.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,r)=>{const o=[],i=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${o.length} events`),sub.close(),o.length>0&&lh(o).catch(e=>console.warn("Failed to cache events",e)),t(o)},n);try{const n=Math.random().toString(36).substring(7);console.log(`📤 REQ [${n}]:`,JSON.stringify(["REQ",n,...e],null,2));const r=nh.pool.subscribeMany(nh.relays,e,{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)}),o.push(e),ah(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${o.length} events`),clearTimeout(i),r.close(),o.length>0&&lh(o).catch(e=>console.warn("Failed to cache events",e)),t(o)}})}catch(e){clearTimeout(i),console.error("Failed to fetch events:",e),r(e)}})}async function hh(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 r=await fh(t,{timeout:n});return console.log(`Fetched ${r.length} events`),r.length>0?r[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function ph(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 r=await fh(t,{timeout:n});return console.log(`Fetched ${r.length} delete events`),r}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function yh(){await nh.connect()}async function gh(){try{const e=await sh(),t=e.transaction(ih,"readonly").objectStore(ih),n=await new Promise((e,n)=>{const r=t.getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)}),r=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:",r),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:r,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}}const{window:wh}=l;function vh(e){let t,n,o,i,s,a,l,f,p,g,b,E,x,k,C,A,j,T;function _(e,t){return"extension"===e[2]?bh:mh}let $=_(e),I=$(e),R=e[5]&&Eh(e),O=e[6]&&xh(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Login to Nostr",s=y(),a=h("button"),a.textContent="×",l=y(),f=h("div"),p=h("div"),g=h("button"),g.textContent="Extension",b=y(),E=h("button"),E.textContent="Nsec",x=y(),k=h("div"),I.c(),C=y(),R&&R.c(),A=y(),O&&O.c(),m(i,"class","svelte-1wl3v5c"),m(a,"class","close-btn svelte-1wl3v5c"),m(o,"class","modal-header svelte-1wl3v5c"),m(g,"class","tab-btn svelte-1wl3v5c"),S(g,"active","extension"===e[2]),m(E,"class","tab-btn svelte-1wl3v5c"),S(E,"active","nsec"===e[2]),m(p,"class","tabs svelte-1wl3v5c"),m(k,"class","tab-content svelte-1wl3v5c"),m(f,"class","tab-container svelte-1wl3v5c"),m(n,"class","modal svelte-1wl3v5c"),S(n,"dark-theme",e[1]),m(t,"class","modal-overlay svelte-1wl3v5c"),m(t,"role","button"),m(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),c(f,p),c(p,g),c(p,b),c(p,E),c(f,x),c(f,k),I.m(k,null),c(k,C),R&&R.m(k,null),c(k,A),O&&O.m(k,null),j||(T=[w(a,"click",e[7]),w(g,"click",e[14]),w(E,"click",e[15]),w(n,"click",v(e[12])),w(n,"keydown",v(e[13])),w(t,"click",e[7]),w(t,"keydown",e[17])],j=!0)},p(e,t){4&t&&S(g,"active","extension"===e[2]),4&t&&S(E,"active","nsec"===e[2]),$===($=_(e))&&I?I.p(e,t):(I.d(1),I=$(e),I&&(I.c(),I.m(k,C))),e[5]?R?R.p(e,t):(R=Eh(e),R.c(),R.m(k,A)):R&&(R.d(1),R=null),e[6]?O?O.p(e,t):(O=xh(e),O.c(),O.m(k,null)):O&&(O.d(1),O=null),2&t&&S(n,"dark-theme",e[1])},d(e){e&&d(t),I.d(),R&&R.d(),O&&O.d(),j=!1,r(T)}}}function mh(e){let t,n,o,i,s,a,l,f,g,v,b=e[4]?"Logging in...":"Log in with nsec";return{c(){t=h("div"),n=h("p"),n.textContent="Enter your nsec (private key) to login. This\n will be stored securely in your browser.",o=y(),i=h("input"),s=y(),a=h("button"),l=p(b),m(n,"class","svelte-1wl3v5c"),m(i,"type","password"),m(i,"placeholder","nsec1..."),i.disabled=e[4],m(i,"class","nsec-input svelte-1wl3v5c"),m(a,"class","login-nsec-btn svelte-1wl3v5c"),a.disabled=f=e[4]||!e[3].trim(),m(t,"class","nsec-login svelte-1wl3v5c")},m(r,d){u(r,t,d),c(t,n),c(t,o),c(t,i),x(i,e[3]),c(t,s),c(t,a),c(a,l),g||(v=[w(i,"input",e[16]),w(a,"click",e[10])],g=!0)},p(e,t){16&t&&(i.disabled=e[4]),8&t&&i.value!==e[3]&&x(i,e[3]),16&t&&b!==(b=e[4]?"Logging in...":"Log in with nsec")&&E(l,b),24&t&&f!==(f=e[4]||!e[3].trim())&&(a.disabled=f)},d(e){e&&d(t),g=!1,r(v)}}}function bh(e){let t,n,r,o,i,s,a,l=e[4]?"Connecting...":"Log in using extension";return{c(){t=h("div"),n=h("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",r=y(),o=h("button"),i=p(l),m(n,"class","svelte-1wl3v5c"),m(o,"class","login-extension-btn svelte-1wl3v5c"),o.disabled=e[4],m(t,"class","extension-login svelte-1wl3v5c")},m(l,d){u(l,t,d),c(t,n),c(t,r),c(t,o),c(o,i),s||(a=w(o,"click",e[9]),s=!0)},p(e,t){16&t&&l!==(l=e[4]?"Connecting...":"Log in using extension")&&E(i,l),16&t&&(o.disabled=e[4])},d(e){e&&d(t),s=!1,a()}}}function Eh(e){let t,n;return{c(){t=h("div"),n=p(e[5]),m(t,"class","message error-message svelte-1wl3v5c")},m(e,r){u(e,t,r),c(t,n)},p(e,t){32&t&&E(n,e[5])},d(e){e&&d(t)}}}function xh(e){let t,n;return{c(){t=h("div"),n=p(e[6]),m(t,"class","message success-message svelte-1wl3v5c")},m(e,r){u(e,t,r),c(t,n)},p(e,t){64&t&&E(n,e[6])},d(e){e&&d(t)}}}function kh(t){let n,r,o,i=t[0]&&vh(t);return{c(){i&&i.c(),n=g()},m(e,s){i&&i.m(e,s),u(e,n,s),r||(o=w(wh,"keydown",t[11]),r=!0)},p(e,[t]){e[0]?i?i.p(e,t):(i=vh(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&&d(n),r=!1,o()}}}function Sh(e,t,n){const r=T();let{showModal:o=!1}=t,{isDarkTheme:i=!1}=t,s="extension",a="",l=!1,c="",u="";function d(){n(0,o=!1),n(3,a=""),n(5,c=""),n(6,u=""),r("close")}function f(e){n(2,s=e),n(5,c=""),n(6,u="")}async function h(){n(4,l=!0),n(5,c=""),n(6,u="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!(e=a.trim()).startsWith("nsec1")||(e.length<60||e.length>70))throw new Error('Invalid nsec format. Must start with "nsec1"');const t=Dd.fromKey(a.trim()),o=await t.getPublicKey();localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",o),localStorage.setItem("nostr_privkey",a.trim()),n(6,u="Successfully logged in with nsec!"),r("login",{method:"nsec",pubkey:o,privateKey:a.trim(),signer:t}),setTimeout(()=>{d()},1500)}catch(e){n(5,c=e.message)}finally{n(4,l=!1)}var e}return e.$$set=e=>{"showModal"in e&&n(0,o=e.showModal),"isDarkTheme"in e&&n(1,i=e.isDarkTheme)},[o,i,s,a,l,c,u,d,f,async function(){n(4,l=!0),n(5,c=""),n(6,u="");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(6,u="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{d()},1500))}catch(e){n(5,c=e.message)}finally{n(4,l=!1)}},h,function(e){"Escape"===e.key&&d(),"Enter"===e.key&&"nsec"===s&&h()},function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},()=>f("extension"),()=>f("nsec"),function(){a=this.value,n(3,a)},e=>"Escape"===e.key&&d()]}class Ch extends Q{constructor(e){super(),Y(this,e,Sh,kh,i,{showModal:0,isDarkTheme:1})}}function Ah(e,t,n){const r=e.slice();return r[72]=t[n],r}function jh(e,t,n){const r=e.slice();return r[75]=t[n],r}function Th(e,t,n){const r=e.slice();return r[72]=t[n],r}function _h(e,t,n){const r=e.slice();return r[72]=t[n],r}function $h(e,t,n){const r=e.slice();return r[72]=t[n],r}function Ih(e,t,n){const r=e.slice();return r[72]=t[n],r}function Rh(e,t,n){const r=e.slice();return r[72]=t[n],r}function Oh(e){let t,n,r;return{c(){t=h("div"),n=p(e[3]),m(t,"class",r="message "+e[4]+" svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,o){8&o[0]&&E(n,e[3]),16&o[0]&&r!==(r="message "+e[4]+" svelte-1smaj3x")&&m(t,"class",r)},d(e){e&&d(t)}}}function Ph(e){let t,n,o,i,s,a,l,f,g,v,b,E,k,S,C,A,j,T,_,$,I,R,O,P,B,N,L,U;function F(e,t){return e[5]&&e[5].length>0?Nh:Bh}let M=F(e),D=M(e);function H(e,t){return e[8]&&e[8].length>0?Mh:Fh}let q=H(e),z=q(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Banned Pubkeys",i=y(),s=h("div"),a=h("input"),l=y(),f=h("input"),g=y(),v=h("button"),b=p("Ban Pubkey"),E=y(),k=h("div"),D.c(),S=y(),C=h("div"),A=h("h3"),A.textContent="Allowed Pubkeys",j=y(),T=h("div"),_=h("input"),$=y(),I=h("input"),R=y(),O=h("button"),P=p("Allow Pubkey"),B=y(),N=h("div"),z.c(),m(o,"class","svelte-1smaj3x"),m(a,"type","text"),m(a,"placeholder","Pubkey (64 hex chars)"),m(a,"class","svelte-1smaj3x"),m(f,"type","text"),m(f,"placeholder","Reason (optional)"),m(f,"class","svelte-1smaj3x"),v.disabled=e[2],m(v,"class","svelte-1smaj3x"),m(s,"class","add-form svelte-1smaj3x"),m(k,"class","list svelte-1smaj3x"),m(n,"class","section svelte-1smaj3x"),m(A,"class","svelte-1smaj3x"),m(_,"type","text"),m(_,"placeholder","Pubkey (64 hex chars)"),m(_,"class","svelte-1smaj3x"),m(I,"type","text"),m(I,"placeholder","Reason (optional)"),m(I,"class","svelte-1smaj3x"),O.disabled=e[2],m(O,"class","svelte-1smaj3x"),m(T,"class","add-form svelte-1smaj3x"),m(N,"class","list svelte-1smaj3x"),m(C,"class","section svelte-1smaj3x"),m(t,"class","pubkeys-section")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),x(a,e[6]),c(s,l),c(s,f),x(f,e[7]),c(s,g),c(s,v),c(v,b),c(n,E),c(n,k),D.m(k,null),c(t,S),c(t,C),c(C,A),c(C,j),c(C,T),c(T,_),x(_,e[9]),c(T,$),c(T,I),x(I,e[10]),c(T,R),c(T,O),c(O,P),c(C,B),c(C,N),z.m(N,null),L||(U=[w(a,"input",e[43]),w(f,"input",e[44]),w(v,"click",e[25]),w(_,"input",e[45]),w(I,"input",e[46]),w(O,"click",e[26])],L=!0)},p(e,t){64&t[0]&&a.value!==e[6]&&x(a,e[6]),128&t[0]&&f.value!==e[7]&&x(f,e[7]),4&t[0]&&(v.disabled=e[2]),M===(M=F(e))&&D?D.p(e,t):(D.d(1),D=M(e),D&&(D.c(),D.m(k,null))),512&t[0]&&_.value!==e[9]&&x(_,e[9]),1024&t[0]&&I.value!==e[10]&&x(I,e[10]),4&t[0]&&(O.disabled=e[2]),q===(q=H(e))&&z?z.p(e,t):(z.d(1),z=q(e),z&&(z.c(),z.m(N,null)))},d(e){e&&d(t),D.d(),z.d(),L=!1,r(U)}}}function Bh(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No banned pubkeys configured.</p>",m(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Nh(e){let t,n=e[5],r=[];for(let t=0;t<n.length;t+=1)r[t]=Uh(Rh(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(32&o[0]){let i;for(n=e[5],i=0;i<n.length;i+=1){const s=Rh(e,n,i);r[i]?r[i].p(s,o):(r[i]=Uh(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function Lh(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=p(r),m(t,"class","reason svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,t){32&t[0]&&r!==(r=e[72].reason+"")&&E(n,r)},d(e){e&&d(t)}}}function Uh(e){let t,n,r,o,i,s=e[72].pubkey+"",a=e[72].reason&&Lh(e);return{c(){t=h("div"),n=h("span"),r=p(s),o=y(),a&&a.c(),i=y(),m(n,"class","pubkey svelte-1smaj3x"),m(t,"class","list-item svelte-1smaj3x")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(t,o),a&&a.m(t,null),c(t,i)},p(e,n){32&n[0]&&s!==(s=e[72].pubkey+"")&&E(r,s),e[72].reason?a?a.p(e,n):(a=Lh(e),a.c(),a.m(t,i)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function Fh(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No allowed pubkeys configured.</p>",m(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Mh(e){let t,n=e[8],r=[];for(let t=0;t<n.length;t+=1)r[t]=Hh(Ih(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(256&o[0]){let i;for(n=e[8],i=0;i<n.length;i+=1){const s=Ih(e,n,i);r[i]?r[i].p(s,o):(r[i]=Hh(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function Dh(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=p(r),m(t,"class","reason svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,t){256&t[0]&&r!==(r=e[72].reason+"")&&E(n,r)},d(e){e&&d(t)}}}function Hh(e){let t,n,r,o,i,s=e[72].pubkey+"",a=e[72].reason&&Dh(e);return{c(){t=h("div"),n=h("span"),r=p(s),o=y(),a&&a.c(),i=y(),m(n,"class","pubkey svelte-1smaj3x"),m(t,"class","list-item svelte-1smaj3x")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(t,o),a&&a.m(t,null),c(t,i)},p(e,n){256&n[0]&&s!==(s=e[72].pubkey+"")&&E(r,s),e[72].reason?a?a.p(e,n):(a=Dh(e),a.c(),a.m(t,i)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function qh(e){let t,n,o,i,s,a,l,f,g,v,b,E,k,S,C,A,j,T,_,$,I,R,O,P,B,N,L,U;function F(e,t){return e[11]&&e[11].length>0?Kh:zh}let M=F(e),D=M(e);let H=function(e){return e[22]&&e[22].length>0?Gh:Jh}(e),q=H(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Banned Events",i=y(),s=h("div"),a=h("input"),l=y(),f=h("input"),g=y(),v=h("button"),b=p("Ban Event"),E=y(),k=h("div"),D.c(),S=y(),C=h("div"),A=h("h3"),A.textContent="Allowed Events",j=y(),T=h("div"),_=h("input"),$=y(),I=h("input"),R=y(),O=h("button"),P=p("Allow Event"),B=y(),N=h("div"),q.c(),m(o,"class","svelte-1smaj3x"),m(a,"type","text"),m(a,"placeholder","Event ID (64 hex chars)"),m(a,"class","svelte-1smaj3x"),m(f,"type","text"),m(f,"placeholder","Reason (optional)"),m(f,"class","svelte-1smaj3x"),v.disabled=e[2],m(v,"class","svelte-1smaj3x"),m(s,"class","add-form svelte-1smaj3x"),m(k,"class","list svelte-1smaj3x"),m(n,"class","section svelte-1smaj3x"),m(A,"class","svelte-1smaj3x"),m(_,"type","text"),m(_,"placeholder","Event ID (64 hex chars)"),m(_,"class","svelte-1smaj3x"),m(I,"type","text"),m(I,"placeholder","Reason (optional)"),m(I,"class","svelte-1smaj3x"),O.disabled=e[2],m(O,"class","svelte-1smaj3x"),m(T,"class","add-form svelte-1smaj3x"),m(N,"class","list svelte-1smaj3x"),m(C,"class","section svelte-1smaj3x"),m(t,"class","events-section")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),x(a,e[12]),c(s,l),c(s,f),x(f,e[13]),c(s,g),c(s,v),c(v,b),c(n,E),c(n,k),D.m(k,null),c(t,S),c(t,C),c(C,A),c(C,j),c(C,T),c(T,_),x(_,e[14]),c(T,$),c(T,I),x(I,e[15]),c(T,R),c(T,O),c(O,P),c(C,B),c(C,N),q.m(N,null),L||(U=[w(a,"input",e[47]),w(f,"input",e[48]),w(v,"click",e[27]),w(_,"input",e[49]),w(I,"input",e[50]),w(O,"click",e[28])],L=!0)},p(e,t){4096&t[0]&&a.value!==e[12]&&x(a,e[12]),8192&t[0]&&f.value!==e[13]&&x(f,e[13]),4&t[0]&&(v.disabled=e[2]),M===(M=F(e))&&D?D.p(e,t):(D.d(1),D=M(e),D&&(D.c(),D.m(k,null))),16384&t[0]&&_.value!==e[14]&&x(_,e[14]),32768&t[0]&&I.value!==e[15]&&x(I,e[15]),4&t[0]&&(O.disabled=e[2]),q.p(e,t)},d(e){e&&d(t),D.d(),q.d(),L=!1,r(U)}}}function zh(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No banned events configured.</p>",m(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Kh(e){let t,n=e[11],r=[];for(let t=0;t<n.length;t+=1)r[t]=Vh($h(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(2048&o[0]){let i;for(n=e[11],i=0;i<n.length;i+=1){const s=$h(e,n,i);r[i]?r[i].p(s,o):(r[i]=Vh(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function Wh(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=p(r),m(t,"class","reason svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,t){2048&t[0]&&r!==(r=e[72].reason+"")&&E(n,r)},d(e){e&&d(t)}}}function Vh(e){let t,n,r,o,i,s=e[72].id+"",a=e[72].reason&&Wh(e);return{c(){t=h("div"),n=h("span"),r=p(s),o=y(),a&&a.c(),i=y(),m(n,"class","event-id svelte-1smaj3x"),m(t,"class","list-item svelte-1smaj3x")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(t,o),a&&a.m(t,null),c(t,i)},p(e,n){2048&n[0]&&s!==(s=e[72].id+"")&&E(r,s),e[72].reason?a?a.p(e,n):(a=Wh(e),a.c(),a.m(t,i)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function Jh(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No allowed events configured.</p>",m(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Gh(e){let t,n=e[22],r=[];for(let t=0;t<n.length;t+=1)r[t]=Zh(_h(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(4194304&o[0]){let i;for(n=e[22],i=0;i<n.length;i+=1){const s=_h(e,n,i);r[i]?r[i].p(s,o):(r[i]=Zh(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function Zh(t){let n,r,o,i,s,a=t[72].id+"",l=t[72].reason&&function(t){let n,r,o=t[72].reason+"";return{c(){n=h("span"),r=p(o),m(n,"class","reason svelte-1smaj3x")},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}(t);return{c(){n=h("div"),r=h("span"),o=p(a),i=y(),l&&l.c(),s=y(),m(r,"class","event-id svelte-1smaj3x"),m(n,"class","list-item svelte-1smaj3x")},m(e,t){u(e,n,t),c(n,r),c(r,o),c(n,i),l&&l.m(n,null),c(n,s)},p(e,t){e[72].reason&&l.p(e,t)},d(e){e&&d(n),l&&l.d()}}}function Yh(e){let t,n,o,i,s,a,l,f,g,v,b,E,k,S,C;function A(e,t){return e[16]&&e[16].length>0?Xh:Qh}let j=A(e),T=j(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Blocked IPs",i=y(),s=h("div"),a=h("input"),l=y(),f=h("input"),g=y(),v=h("button"),b=p("Block IP"),E=y(),k=h("div"),T.c(),m(o,"class","svelte-1smaj3x"),m(a,"type","text"),m(a,"placeholder","IP Address"),m(a,"class","svelte-1smaj3x"),m(f,"type","text"),m(f,"placeholder","Reason (optional)"),m(f,"class","svelte-1smaj3x"),v.disabled=e[2],m(v,"class","svelte-1smaj3x"),m(s,"class","add-form svelte-1smaj3x"),m(k,"class","list svelte-1smaj3x"),m(n,"class","section svelte-1smaj3x"),m(t,"class","ips-section")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),x(a,e[17]),c(s,l),c(s,f),x(f,e[18]),c(s,g),c(s,v),c(v,b),c(n,E),c(n,k),T.m(k,null),S||(C=[w(a,"input",e[51]),w(f,"input",e[52]),w(v,"click",e[29])],S=!0)},p(e,t){131072&t[0]&&a.value!==e[17]&&x(a,e[17]),262144&t[0]&&f.value!==e[18]&&x(f,e[18]),4&t[0]&&(v.disabled=e[2]),j===(j=A(e))&&T?T.p(e,t):(T.d(1),T=j(e),T&&(T.c(),T.m(k,null)))},d(e){e&&d(t),T.d(),S=!1,r(C)}}}function Qh(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No blocked IPs configured.</p>",m(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Xh(e){let t,n=e[16],r=[];for(let t=0;t<n.length;t+=1)r[t]=tp(Th(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(65536&o[0]){let i;for(n=e[16],i=0;i<n.length;i+=1){const s=Th(e,n,i);r[i]?r[i].p(s,o):(r[i]=tp(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function ep(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=p(r),m(t,"class","reason svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,t){65536&t[0]&&r!==(r=e[72].reason+"")&&E(n,r)},d(e){e&&d(t)}}}function tp(e){let t,n,r,o,i,s=e[72].ip+"",a=e[72].reason&&ep(e);return{c(){t=h("div"),n=h("span"),r=p(s),o=y(),a&&a.c(),i=y(),m(n,"class","ip svelte-1smaj3x"),m(t,"class","list-item svelte-1smaj3x")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(t,o),a&&a.m(t,null),c(t,i)},p(e,n){65536&n[0]&&s!==(s=e[72].ip+"")&&E(r,s),e[72].reason?a?a.p(e,n):(a=ep(e),a.c(),a.m(t,i)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function np(e){let t,n,o,i,s,a,l,f,g,v,E,k,S;function C(e,t){return e[19]&&e[19].length>0?op:rp}let A=C(e),j=A(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Allowed Event Kinds",i=y(),s=h("div"),a=h("input"),l=y(),f=h("button"),g=p("Allow Kind"),v=y(),E=h("div"),j.c(),m(o,"class","svelte-1smaj3x"),m(a,"type","number"),m(a,"placeholder","Kind number"),m(a,"class","svelte-1smaj3x"),f.disabled=e[2],m(f,"class","svelte-1smaj3x"),m(s,"class","add-form svelte-1smaj3x"),m(E,"class","list svelte-1smaj3x"),m(n,"class","section svelte-1smaj3x"),m(t,"class","kinds-section")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),x(a,e[20]),c(s,l),c(s,f),c(f,g),c(n,v),c(n,E),j.m(E,null),k||(S=[w(a,"input",e[53]),w(f,"click",e[30])],k=!0)},p(e,t){1048576&t[0]&&b(a.value)!==e[20]&&x(a,e[20]),4&t[0]&&(f.disabled=e[2]),A===(A=C(e))&&j?j.p(e,t):(j.d(1),j=A(e),j&&(j.c(),j.m(E,null)))},d(e){e&&d(t),j.d(),k=!1,r(S)}}}function rp(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No allowed kinds configured. All kinds are\n allowed by default.</p>",m(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function op(e){let t,n=e[19],r=[];for(let t=0;t<n.length;t+=1)r[t]=ip(jh(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(524288&o[0]|1&o[1]){let i;for(n=e[19],i=0;i<n.length;i+=1){const s=jh(e,n,i);r[i]?r[i].p(s,o):(r[i]=ip(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function ip(e){let t,n,r,o,i,s,a,l,f,g=e[75]+"";function v(){return e[54](e[75])}return{c(){t=h("div"),n=h("span"),r=p("Kind "),o=p(g),i=y(),s=h("button"),s.textContent="Remove",a=y(),m(n,"class","kind svelte-1smaj3x"),m(s,"class","remove-btn svelte-1smaj3x"),m(t,"class","list-item svelte-1smaj3x")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,o),c(t,i),c(t,s),c(t,a),l||(f=w(s,"click",v),l=!0)},p(t,n){e=t,524288&n[0]&&g!==(g=e[75]+"")&&E(o,g)},d(e){e&&d(t),l=!1,f()}}}function sp(e){let t,n,r,o,i,s,a,l,f,g;function v(e,t){return e[21]&&e[21].length>0?lp:ap}let b=v(e),E=b(e);return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Events Needing Moderation",o=y(),i=h("button"),s=p("Refresh"),a=y(),l=h("div"),E.c(),m(r,"class","svelte-1smaj3x"),i.disabled=e[2],m(l,"class","list svelte-1smaj3x"),m(n,"class","section svelte-1smaj3x"),m(t,"class","moderation-section")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,o),c(n,i),c(i,s),c(n,a),c(n,l),E.m(l,null),f||(g=w(i,"click",e[24]),f=!0)},p(e,t){4&t[0]&&(i.disabled=e[2]),b===(b=v(e))&&E?E.p(e,t):(E.d(1),E=b(e),E&&(E.c(),E.m(l,null)))},d(e){e&&d(t),E.d(),f=!1,g()}}}function ap(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No events need moderation at this time.</p>",m(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function lp(e){let t,n=e[21],r=[];for(let t=0;t<n.length;t+=1)r[t]=up(Ah(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(2097152&o[0]|12&o[1]){let i;for(n=e[21],i=0;i<n.length;i+=1){const s=Ah(e,n,i);r[i]?r[i].p(s,o):(r[i]=up(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function cp(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=p(r),m(t,"class","reason svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,t){2097152&t[0]&&r!==(r=e[72].reason+"")&&E(n,r)},d(e){e&&d(t)}}}function up(e){let t,n,o,i,s,a,l,f,g,v,b,x,k=e[72].id+"",S=e[72].reason&&cp(e);function C(){return e[55](e[72])}function A(){return e[56](e[72])}return{c(){t=h("div"),n=h("span"),o=p(k),i=y(),S&&S.c(),s=y(),a=h("div"),l=h("button"),l.textContent="Allow",f=y(),g=h("button"),g.textContent="Ban",v=y(),m(n,"class","event-id svelte-1smaj3x"),m(l,"class","svelte-1smaj3x"),m(g,"class","svelte-1smaj3x"),m(a,"class","actions svelte-1smaj3x"),m(t,"class","list-item svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n),c(n,o),c(t,i),S&&S.m(t,null),c(t,s),c(t,a),c(a,l),c(a,f),c(a,g),c(t,v),b||(x=[w(l,"click",C),w(g,"click",A)],b=!0)},p(n,r){e=n,2097152&r[0]&&k!==(k=e[72].id+"")&&E(o,k),e[72].reason?S?S.p(e,r):(S=cp(e),S.c(),S.m(t,s)):S&&(S.d(1),S=null)},d(e){e&&d(t),S&&S.d(),b=!1,r(x)}}}function dp(e){let t,n,o,i,s,a,l,f,g,v,b,E,k,S,C,A,j,T,_,$,I,R,O,P,B,N,L,U;function F(e,t){return e[2]?hp:fp}let M=F(e),D=M(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Relay Configuration",i=y(),s=h("div"),a=h("button"),l=p("🔄 Refresh from Relay Info"),f=y(),g=h("div"),v=h("div"),b=h("label"),b.textContent="Relay Name",E=y(),k=h("input"),S=y(),C=h("div"),A=h("label"),A.textContent="Relay Description",j=y(),T=h("textarea"),_=y(),$=h("div"),I=h("label"),I.textContent="Relay Icon URL",R=y(),O=h("input"),P=y(),B=h("div"),N=h("button"),D.c(),m(o,"class","svelte-1smaj3x"),a.disabled=e[2],m(a,"class","refresh-btn svelte-1smaj3x"),m(s,"class","config-actions svelte-1smaj3x"),m(b,"class","svelte-1smaj3x"),m(k,"type","text"),m(k,"placeholder","Enter relay name"),m(k,"class","svelte-1smaj3x"),m(v,"class","form-group svelte-1smaj3x"),m(A,"class","svelte-1smaj3x"),m(T,"placeholder","Enter relay description"),m(T,"class","svelte-1smaj3x"),m(C,"class","form-group svelte-1smaj3x"),m(I,"class","svelte-1smaj3x"),m(O,"type","url"),m(O,"placeholder","Enter icon URL"),m(O,"class","svelte-1smaj3x"),m($,"class","form-group svelte-1smaj3x"),N.disabled=e[2],m(N,"class","update-all-btn svelte-1smaj3x"),m(B,"class","config-update-section svelte-1smaj3x"),m(g,"class","config-form svelte-1smaj3x"),m(n,"class","section svelte-1smaj3x"),m(t,"class","relay-section")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(n,f),c(n,g),c(g,v),c(v,b),c(v,E),c(v,k),x(k,e[0].relay_name),c(g,S),c(g,C),c(C,A),c(C,j),c(C,T),x(T,e[0].relay_description),c(g,_),c(g,$),c($,I),c($,R),c($,O),x(O,e[0].relay_icon),c(g,P),c(g,B),c(B,N),D.m(N,null),L||(U=[w(a,"click",e[23]),w(k,"input",e[57]),w(T,"input",e[58]),w(O,"input",e[59]),w(N,"click",e[32])],L=!0)},p(e,t){4&t[0]&&(a.disabled=e[2]),1&t[0]&&k.value!==e[0].relay_name&&x(k,e[0].relay_name),1&t[0]&&x(T,e[0].relay_description),1&t[0]&&O.value!==e[0].relay_icon&&x(O,e[0].relay_icon),M!==(M=F(e))&&(D.d(1),D=M(e),D&&(D.c(),D.m(N,null))),4&t[0]&&(N.disabled=e[2])},d(e){e&&d(t),D.d(),L=!1,r(U)}}}function fp(e){let t;return{c(){t=p("💾 Update Configuration")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function hp(e){let t;return{c(){t=p("⏳ Updating...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function pp(t){let n,o,i,s,a,l,f,g,v,b,E,x,k,S,C,A,j,T,_,$,I,R,O,P,B,N,L,U,F,M,D,H,q,z,K,W,V,J=t[3]&&Oh(t),G="pubkeys"===t[1]&&Ph(t),Z="events"===t[1]&&qh(t),Y="ips"===t[1]&&Yh(t),Q="kinds"===t[1]&&np(t),X="moderation"===t[1]&&sp(t),ee="relay"===t[1]&&dp(t);return{c(){n=h("div"),o=h("div"),o.innerHTML='<h2 class="svelte-1smaj3x">Managed ACL Configuration</h2> \n <p class="svelte-1smaj3x">Configure access control using NIP-86 management API</p> \n <div class="owner-only-notice svelte-1smaj3x"><strong>Owner Only:</strong> This interface is restricted to relay owners\n only.</div>',i=y(),J&&J.c(),s=y(),a=h("div"),l=h("button"),f=p("Pubkeys"),v=y(),b=h("button"),E=p("Events"),k=y(),S=h("button"),C=p("IPs"),j=y(),T=h("button"),_=p("Kinds"),I=y(),R=h("button"),O=p("Moderation"),B=y(),N=h("button"),L=p("Relay Config"),F=y(),M=h("div"),G&&G.c(),D=y(),Z&&Z.c(),H=y(),Y&&Y.c(),q=y(),Q&&Q.c(),z=y(),X&&X.c(),K=y(),ee&&ee.c(),m(o,"class","header svelte-1smaj3x"),m(l,"class",g="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1smaj3x"),m(b,"class",x="tab "+("events"===t[1]?"active":"")+" svelte-1smaj3x"),m(S,"class",A="tab "+("ips"===t[1]?"active":"")+" svelte-1smaj3x"),m(T,"class",$="tab "+("kinds"===t[1]?"active":"")+" svelte-1smaj3x"),m(R,"class",P="tab "+("moderation"===t[1]?"active":"")+" svelte-1smaj3x"),m(N,"class",U="tab "+("relay"===t[1]?"active":"")+" svelte-1smaj3x"),m(a,"class","tabs svelte-1smaj3x"),m(M,"class","tab-content svelte-1smaj3x")},m(e,r){u(e,n,r),c(n,o),c(n,i),J&&J.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,v),c(a,b),c(b,E),c(a,k),c(a,S),c(S,C),c(a,j),c(a,T),c(T,_),c(a,I),c(a,R),c(R,O),c(a,B),c(a,N),c(N,L),c(n,F),c(n,M),G&&G.m(M,null),c(M,D),Z&&Z.m(M,null),c(M,H),Y&&Y.m(M,null),c(M,q),Q&&Q.m(M,null),c(M,z),X&&X.m(M,null),c(M,K),ee&&ee.m(M,null),W||(V=[w(l,"click",t[37]),w(b,"click",t[38]),w(S,"click",t[39]),w(T,"click",t[40]),w(R,"click",t[41]),w(N,"click",t[42])],W=!0)},p(e,t){e[3]?J?J.p(e,t):(J=Oh(e),J.c(),J.m(n,s)):J&&(J.d(1),J=null),2&t[0]&&g!==(g="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1smaj3x")&&m(l,"class",g),2&t[0]&&x!==(x="tab "+("events"===e[1]?"active":"")+" svelte-1smaj3x")&&m(b,"class",x),2&t[0]&&A!==(A="tab "+("ips"===e[1]?"active":"")+" svelte-1smaj3x")&&m(S,"class",A),2&t[0]&&$!==($="tab "+("kinds"===e[1]?"active":"")+" svelte-1smaj3x")&&m(T,"class",$),2&t[0]&&P!==(P="tab "+("moderation"===e[1]?"active":"")+" svelte-1smaj3x")&&m(R,"class",P),2&t[0]&&U!==(U="tab "+("relay"===e[1]?"active":"")+" svelte-1smaj3x")&&m(N,"class",U),"pubkeys"===e[1]?G?G.p(e,t):(G=Ph(e),G.c(),G.m(M,D)):G&&(G.d(1),G=null),"events"===e[1]?Z?Z.p(e,t):(Z=qh(e),Z.c(),Z.m(M,H)):Z&&(Z.d(1),Z=null),"ips"===e[1]?Y?Y.p(e,t):(Y=Yh(e),Y.c(),Y.m(M,q)):Y&&(Y.d(1),Y=null),"kinds"===e[1]?Q?Q.p(e,t):(Q=np(e),Q.c(),Q.m(M,z)):Q&&(Q.d(1),Q=null),"moderation"===e[1]?X?X.p(e,t):(X=sp(e),X.c(),X.m(M,K)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=dp(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),J&&J.d(),G&&G.d(),Z&&Z.d(),Y&&Y.d(),Q&&Q.d(),X&&X.d(),ee&&ee.d(),W=!1,r(V)}}}function yp(e,t,n){let{userSigner:r}=t,{userPubkey:o}=t,i="pubkeys",s=!1,a="",l="info",c=[],u="",d="",f=[],h="",p="",y=[],g="",w="",v="",m="",E=[],x="",k="",S=[],C="",A=[],T={relay_name:"",relay_description:"",relay_icon:""};var _;async function $(){try{n(2,s=!0),console.log("Fetching relay info from /");const e=await fetch(window.location.origin+"/",{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,T={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",T),console.log("Loaded relay info:",t),n(3,a="Relay configuration loaded successfully"),n(4,l="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,a=`Failed to fetch relay info: ${e.status}`),n(4,l="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,a=`Failed to fetch relay info: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}}async function I(e,t=[]){try{n(2,s=!0),n(3,a="");const i={method:e,params:t},l=await async function(e,t){if(!r)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!o)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,i={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:o},s=await r.signEvent(i),a=JSON.stringify(s);return`Nostr ${btoa(a)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:l},body:JSON.stringify(i)});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,a=e.message),n(4,l="error"),e}finally{n(2,s=!1)}}async function R(){try{n(5,c=await I("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function O(){try{n(8,f=await I("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function P(){try{n(11,y=await I("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function B(){try{n(16,E=await I("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function N(){try{n(19,S=await I("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function L(){try{n(2,s=!0),n(21,A=await I("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",A)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,a=`Failed to load moderation events: ${e.message}`),n(4,l="error"),n(21,A=[])}finally{n(2,s=!1)}}async function U(e){try{await I("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,l="success"),await N()}catch(e){console.error("Failed to disallow kind:",e)}}async function F(e){try{await I("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,l="success"),await L()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function M(e){try{await I("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,l="success"),await L()}catch(e){console.error("Failed to ban event from moderation:",e)}}_=()=>{setTimeout(()=>{$()},100)},j().$$.on_mount.push(_),async function(){await Promise.all([R(),O(),P(),B(),N()])}();return e.$$set=e=>{"userSigner"in e&&n(35,r=e.userSigner),"userPubkey"in e&&n(36,o=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",T)},[T,i,s,a,l,c,u,d,f,h,p,y,g,w,v,m,E,x,k,S,C,A,[],$,L,async function(){if(u)try{await I("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,l="success"),n(6,u=""),n(7,d=""),await R()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await I("allowpubkey",[h,p]),n(3,a="Pubkey allowed successfully"),n(4,l="success"),n(9,h=""),n(10,p=""),await O()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(g)try{await I("banevent",[g,w]),n(3,a="Event banned successfully"),n(4,l="success"),n(12,g=""),n(13,w=""),await P()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(v)try{await I("allowevent",[v,m]),n(3,a="Event allowed successfully"),n(4,l="success"),n(14,v=""),n(15,m="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(x)try{await I("blockip",[x,k]),n(3,a="IP blocked successfully"),n(4,l="success"),n(17,x=""),n(18,k=""),await B()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!C)return;const e=parseInt(C);if(isNaN(e))return n(3,a="Invalid kind number"),void n(4,l="error");try{await I("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,l="success"),n(20,C=""),await N()}catch(e){console.error("Failed to allow kind:",e)}},U,async function(){try{n(2,s=!0),n(3,a="");const e=[];if(T.relay_name&&e.push(I("changerelayname",[T.relay_name])),T.relay_description&&e.push(I("changerelaydescription",[T.relay_description])),T.relay_icon&&e.push(I("changerelayicon",[T.relay_icon])),0===e.length)return n(3,a="No changes to update"),void n(4,l="info");await Promise.all(e),n(3,a="Relay configuration updated successfully"),n(4,l="success"),await $()}catch(e){console.error("Failed to update relay configuration:",e),n(3,a=`Failed to update relay configuration: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}},F,M,r,o,()=>n(1,i="pubkeys"),()=>n(1,i="events"),()=>n(1,i="ips"),()=>n(1,i="kinds"),()=>{n(1,i="moderation"),A&&0!==A.length||L()},()=>n(1,i="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(){g=this.value,n(12,g)},function(){w=this.value,n(13,w)},function(){v=this.value,n(14,v)},function(){m=this.value,n(15,m)},function(){x=this.value,n(17,x)},function(){k=this.value,n(18,k)},function(){C=b(this.value),n(20,C)},e=>U(e),e=>F(e.id),e=>M(e.id),function(){T.relay_name=this.value,n(0,T)},function(){T.relay_description=this.value,n(0,T)},function(){T.relay_icon=this.value,n(0,T)}]}class gp extends Q{constructor(e){super(),Y(this,e,yp,pp,i,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}class wp{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,r,o]=n;e&&r?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!r&&(console.error("Authentication failed:",o),this.authPromise&&(this.authPromise.reject(new Error(o||"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 r=["EVENT",e];this.ws.send(JSON.stringify(r));const o=this.ws.onmessage,i=setTimeout(()=>{this.ws.onmessage=o,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async r=>{try{const s=JSON.parse(r.data),[a,l,c,u]=s;if("OK"===a&&l===e.id)if(clearTimeout(i),this.ws.onmessage=o,c)console.log("Event published successfully:",l),t({success:!0,eventId:l,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required")){console.log("Authentication required, attempting to authenticate...");try{await this.authenticate();const t=["EVENT",e];return void this.ws.send(JSON.stringify(t))}catch(e){return void n(new Error(`Authentication failed: ${e.message}`))}}n(new Error(`Publish failed: ${u}`))}else await this.handleMessage(s)}catch(e){clearTimeout(i),this.ws.onmessage=o,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function vp(e,t,n,r){const o=new wp(e,n,r);try{await o.connect();return await o.publishEvent(t)}finally{o.close()}}function mp(e,t,n){const r=e.slice();return r[150]=t[n],r}function bp(e,t,n){const r=e.slice();return r[168]=t[n],r}function Ep(e,t,n){const r=e.slice();return r[153]=t[n],r}function xp(e,t,n){const r=e.slice();r[153]=t[n];const o=r[46](r[153]);return r[162]=o,r}function kp(e,t,n){const r=e.slice();return r[165]=t[n],r}function Sp(e,t,n){const r=e.slice();return r[159]=t[n],r}function Cp(e,t,n){const r=e.slice();return r[153]=t[n],r}function Ap(e,t,n){const r=e.slice();return r[156]=t[n],r}function jp(e,t,n){const r=e.slice();return r[173]=t[n],r}function Tp(e){let t,n,r,o=e[1]&&e[4]&&$p(e);return{c(){t=h("div"),n=h("span"),r=p("ORLY? dashboard\n "),o&&o.c(),m(n,"class","app-title svelte-d3wb0j"),m(t,"class","header-title svelte-d3wb0j")},m(e,i){u(e,t,i),c(t,n),c(n,r),o&&o.m(n,null)},p(e,t){e[1]&&e[4]?o?o.p(e,t):(o=$p(e),o.c(),o.m(n,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function _p(e){let t,n,o,i;return{c(){t=h("div"),n=h("input"),m(n,"type","text"),m(n,"class","search-input svelte-d3wb0j"),m(n,"placeholder","Search..."),m(t,"class","search-input-container svelte-d3wb0j")},m(r,s){u(r,t,s),c(t,n),x(n,e[16]),o||(i=[w(n,"input",e[87]),w(n,"keydown",e[65])],o=!0)},p(e,t){65536&t[0]&&n.value!==e[16]&&x(n,e[16])},d(e){e&&d(t),o=!1,r(i)}}}function $p(e){let t,n;return{c(){t=h("span"),n=p(e[10]),m(t,"class","permission-badge svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n)},p(e,t){1024&t[0]&&E(n,e[10])},d(e){e&&d(t)}}}function Ip(t){let n,r,o;return{c(){n=h("button"),n.textContent="Log in",m(n,"class","login-btn svelte-d3wb0j")},m(e,i){u(e,n,i),r||(o=w(n,"click",t[58]),r=!0)},p:e,d(e){e&&d(n),r=!1,o()}}}function Rp(e){let t,n,r,o,i,s,a,l=(e[3]?.name||e[2].slice(0,8)+"...")+"";function f(e,t){return e[3]?.picture?Pp:Op}let g=f(e),v=g(e);return{c(){t=h("div"),n=h("button"),v.c(),r=y(),o=h("span"),i=p(l),m(o,"class","user-name svelte-d3wb0j"),m(n,"class","user-profile-btn svelte-d3wb0j"),m(t,"class","user-info svelte-d3wb0j")},m(l,d){u(l,t,d),c(t,n),v.m(n,null),c(n,r),c(n,o),c(o,i),s||(a=w(n,"click",e[62]),s=!0)},p(e,t){g===(g=f(e))&&v?v.p(e,t):(v.d(1),v=g(e),v&&(v.c(),v.m(n,r))),12&t[0]&&l!==(l=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(i,l)},d(e){e&&d(t),v.d(),s=!1,a()}}}function Op(t){let n;return{c(){n=h("div"),n.textContent="👤",m(n,"class","user-avatar-placeholder svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Pp(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||m(t,"src",n),m(t,"alt","User avatar"),m(t,"class","user-avatar svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&m(t,"src",n)},d(e){e&&d(t)}}}function Bp(e){let t,n,o;function i(){return e[88](e[173])}function s(...t){return e[89](e[173],...t)}return{c(){t=h("span"),t.textContent="✕",m(t,"class","tab-close-icon svelte-d3wb0j"),m(t,"role","button"),m(t,"tabindex","0")},m(e,r){u(e,t,r),n||(o=[w(t,"click",v(i)),w(t,"keydown",s)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r(o)}}}function Np(e){let t,n,r,o,i,s,a,l,f,g,v=e[173].icon+"",b=e[173].label+"",x=e[173].isSearchTab&&Bp(e);function k(){return e[90](e[173])}return{c(){t=h("button"),n=h("span"),r=p(v),o=y(),i=h("span"),s=p(b),a=y(),x&&x.c(),l=y(),m(n,"class","tab-icon svelte-d3wb0j"),m(i,"class","tab-label svelte-d3wb0j"),m(t,"class","tab svelte-d3wb0j"),S(t,"active",e[5]===e[173].id)},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,o),c(t,i),c(i,s),c(t,a),x&&x.m(t,null),c(t,l),f||(g=w(t,"click",k),f=!0)},p(n,o){e=n,2048&o[0]&&v!==(v=e[173].icon+"")&&E(r,v),2048&o[0]&&b!==(b=e[173].label+"")&&E(s,b),e[173].isSearchTab?x?x.p(e,o):(x=Bp(e),x.c(),x.m(t,l)):x&&(x.d(1),x=null),2080&o[0]&&S(t,"active",e[5]===e[173].id)},d(e){e&&d(t),x&&x.d(),f=!1,g()}}}function Lp(t){let n;function r(e,t){return e[1]?Vp:Wp}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),m(n,"class","welcome-message svelte-d3wb0j")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Up(t){let n,r=t[6],o=[];for(let e=0;e<r.length;e+=1)o[e]=ny(bp(t,r,e));return{c(){for(let e=0;e<o.length;e+=1)o[e].c();n=g()},m(e,t){for(let n=0;n<o.length;n+=1)o[n]&&o[n].m(e,t);u(e,n,t)},p(e,t){if(262260&t[0]|1440&t[1]|96&t[2]){let i;for(r=e[6],i=0;i<r.length;i+=1){const s=bp(e,r,i);o[i]?o[i].p(s,t):(o[i]=ny(s),o[i].c(),o[i].m(n.parentNode,n))}for(;i<o.length;i+=1)o[i].d(1);o.length=r.length}},i:e,o:e,d(e){f(o,e),e&&d(n)}}}function Fp(t){let n,o,i,s,a,l,p,g,v,E,S,C,A,j,T,_,$,I,R=null!==t[29]&&void 0!==t[29]&&t[29]>=0||""!==t[30]&&parseInt(t[30])>=0,O=t[37],P=[];for(let e=0;e<O.length;e+=1)P[e]=ry(kp(t,O,e));let B=R&&oy(t);return{c(){n=h("div"),o=h("div"),o.innerHTML='<h3 class="svelte-d3wb0j">Event Recovery</h3> \n <p class="svelte-d3wb0j">Search and recover old versions of replaceable events</p>',i=y(),s=h("div"),a=h("div"),l=h("div"),p=h("label"),p.textContent="Select Event Kind:",g=y(),v=h("select"),E=h("option"),E.textContent="Choose a replaceable kind...";for(let e=0;e<P.length;e+=1)P[e].c();S=y(),C=h("div"),A=h("label"),A.textContent="Or enter custom kind number:",j=y(),T=h("input"),_=y(),B&&B.c(),m(p,"for","recovery-kind"),m(p,"class","svelte-d3wb0j"),E.__value=null,E.value=E.__value,m(v,"id","recovery-kind"),m(v,"class","svelte-d3wb0j"),void 0===t[29]&&N(()=>t[103].call(v)),m(l,"class","kind-selector svelte-d3wb0j"),m(A,"for","custom-kind"),m(A,"class","svelte-d3wb0j"),m(T,"id","custom-kind"),m(T,"type","number"),m(T,"placeholder","e.g., 10001"),m(T,"min","0"),m(T,"class","svelte-d3wb0j"),m(C,"class","custom-kind-input svelte-d3wb0j"),m(a,"class","recovery-controls svelte-d3wb0j"),m(s,"class","recovery-controls-card svelte-d3wb0j"),m(n,"class","recovery-tab svelte-d3wb0j")},m(e,r){u(e,n,r),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(l,p),c(l,g),c(l,v),c(v,E);for(let e=0;e<P.length;e+=1)P[e]&&P[e].m(v,null);k(v,t[29],!0),c(a,S),c(a,C),c(C,A),c(C,j),c(C,T),x(T,t[30]),c(n,_),B&&B.m(n,null),$||(I=[w(v,"change",t[103]),w(v,"change",t[44]),w(T,"input",t[104]),w(T,"input",t[45])],$=!0)},p(e,t){if(64&t[1]){let n;for(O=e[37],n=0;n<O.length;n+=1){const r=kp(e,O,n);P[n]?P[n].p(r,t):(P[n]=ry(r),P[n].c(),P[n].m(v,null))}for(;n<P.length;n+=1)P[n].d(1);P.length=O.length}536870912&t[0]|64&t[1]&&k(v,e[29]),1073741824&t[0]&&b(T.value)!==e[30]&&x(T,e[30]),1610612736&t[0]&&(R=null!==e[29]&&void 0!==e[29]&&e[29]>=0||""!==e[30]&&parseInt(e[30])>=0),R?B?B.p(e,t):(B=oy(e),B.c(),B.m(n,null)):B&&(B.d(1),B=null)},i:e,o:e,d(e){e&&d(n),f(P,e),B&&B.d(),$=!1,r(I)}}}function Mp(t){let n,r,o;function i(e,t){return e[1]&&"owner"===e[4]?py:e[1]?hy:fy}let s=i(t),a=s(t);return{c(){n=h("div"),r=h("h2"),r.textContent="Sprocket Script Management",o=y(),a.c(),m(n,"class","sprocket-view svelte-d3wb0j")},m(e,t){u(e,n,t),c(n,r),c(n,o),a.m(n,null)},p(e,t){s===(s=i(e))&&a?a.p(e,t):(a.d(1),a=s(e),a&&(a.c(),a.m(n,null)))},i:e,o:e,d(e){e&&d(n),a.d()}}}function Dp(e){let t,n,r,o;const i=[xy,Ey,by],s=[];function a(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),r=s[n]=i[n](e),{c(){t=h("div"),r.c(),m(t,"class","managed-acl-view svelte-d3wb0j")},m(e,r){u(e,t,r),s[n].m(t,null),o=!0},p(e,o){let l=n;n=a(e),n===l?s[n].p(e,o):(q(),W(s[l],1,1,()=>{s[l]=null}),z(),r=s[n],r?r.p(e,o):(r=s[n]=i[n](e),r.c()),K(r,1),r.m(t,null))},i(e){o||(K(r),o=!0)},o(e){W(r),o=!1},d(e){e&&d(t),s[n].d()}}}function Hp(t){let n,o,i,s,a,l,f,p,g,v,b,E;return{c(){n=h("div"),o=h("div"),i=h("button"),i.textContent="Reformat",s=y(),a=h("button"),a.textContent="Sign",l=y(),f=h("button"),f.textContent="Publish",p=y(),g=h("div"),v=h("textarea"),m(i,"class","compose-btn reformat-btn svelte-d3wb0j"),m(a,"class","compose-btn sign-btn svelte-d3wb0j"),m(f,"class","compose-btn publish-btn svelte-d3wb0j"),m(o,"class","compose-header svelte-d3wb0j"),m(v,"class","compose-textarea svelte-d3wb0j"),m(v,"placeholder","Enter your Nostr event JSON here..."),m(v,"spellcheck","false"),m(g,"class","compose-editor svelte-d3wb0j"),m(n,"class","compose-view svelte-d3wb0j")},m(e,r){u(e,n,r),c(n,o),c(o,i),c(o,s),c(o,a),c(o,l),c(o,f),c(n,p),c(n,g),c(g,v),x(v,t[28]),b||(E=[w(i,"click",t[76]),w(a,"click",t[77]),w(f,"click",t[78]),w(v,"input",t[99])],b=!0)},p(e,t){268435456&t[0]&&x(v,e[28])},i:e,o:e,d(e){e&&d(n),b=!1,r(E)}}}function qp(t){let n,r;function o(e,t){return!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?ky:Sy}let i=o(t),s=i(t),a=t[1]&&("write"===t[4]||"admin"===t[4]||"owner"===t[4])&&Ny(t);return{c(){n=h("div"),s.c(),r=y(),a&&a.c(),m(n,"class","events-view-container svelte-d3wb0j")},m(e,t){u(e,n,t),s.m(n,null),c(n,r),a&&a.m(n,null)},p(e,t){i===(i=o(e))&&s?s.p(e,t):(s.d(1),s=i(e),s&&(s.c(),s.m(n,r))),!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?a&&(a.d(1),a=null):a?a.p(e,t):(a=Ny(e),a.c(),a.m(n,null))},i:e,o:e,d(e){e&&d(n),s.d(),a&&a.d()}}}function zp(t){let n;function r(e,t){return!e[1]||"admin"!==e[10]&&"owner"!==e[10]?e[1]?My:Fy:Dy}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),m(n,"class","import-section svelte-d3wb0j")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Kp(t){let n;function r(e,t){return e[1]?qy:Hy}let o=r(t),i=o(t);return{c(){i.c(),n=g()},m(e,t){i.m(e,t),u(e,n,t)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n.parentNode,n)))},i:e,o:e,d(e){i.d(e),e&&d(n)}}}function Wp(t){let n;return{c(){n=h("p"),n.textContent="Log in to access your user dashboard",m(n,"class","svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Vp(e){let t,n,r,o=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=h("p"),n=p("Welcome "),r=p(o),m(t,"class","svelte-d3wb0j")},m(e,o){u(e,t,o),c(t,n),c(t,r)},p(e,t){12&t[0]&&o!==(o=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(r,o)},d(e){e&&d(t)}}}function Jp(e){let t,n,o,i,s,a,l,f,g,v,b,x,k,S,C,A,j,T,_,$=e[168].query+"",I=e[36].get(e[168].id)?.isLoading,R=!e[36].get(e[168].id)?.hasMore&&e[36].get(e[168].id)?.events?.length>0;function O(){return e[107](e[168])}function P(e,t){return 64&t[0]&&(k=null),64&t[0]&&(S=null),null==k&&(k=!!(e[36].get(e[168].id)?.events?.length>0)),k?Zp:(null==S&&(S=!e[36].get(e[168].id)?.isLoading),S?Gp:void 0)}let B=P(e,[-1,-1,-1,-1,-1,-1]),N=B&&B(e),L=I&&ey(),U=R&&ty();function F(...t){return e[112](e[168],...t)}return{c(){t=h("div"),n=h("div"),o=h("h2"),i=p('🔍 Search Results: "'),s=p($),a=p('"'),l=y(),f=h("button"),g=p("🔄 Refresh"),b=y(),x=h("div"),N&&N.c(),C=y(),L&&L.c(),A=y(),U&&U.c(),j=y(),m(o,"class","svelte-d3wb0j"),m(f,"class","refresh-btn svelte-d3wb0j"),f.disabled=v=e[36].get(e[168].id)?.isLoading,m(n,"class","search-results-header svelte-d3wb0j"),m(x,"class","search-results-content svelte-d3wb0j"),m(t,"class","search-results-view svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),c(f,g),c(t,b),c(t,x),N&&N.m(x,null),c(x,C),L&&L.m(x,null),c(x,A),U&&U.m(x,null),c(t,j),T||(_=[w(f,"click",O),w(x,"scroll",F)],T=!0)},p(t,n){e=t,64&n[0]&&$!==($=e[168].query+"")&&E(s,$),64&n[0]&&v!==(v=e[36].get(e[168].id)?.isLoading)&&(f.disabled=v),B===(B=P(e,n))&&N?N.p(e,n):(N&&N.d(1),N=B&&B(e),N&&(N.c(),N.m(x,C))),64&n[0]&&(I=e[36].get(e[168].id)?.isLoading),I?L||(L=ey(),L.c(),L.m(x,A)):L&&(L.d(1),L=null),64&n[0]&&(R=!e[36].get(e[168].id)?.hasMore&&e[36].get(e[168].id)?.events?.length>0),R?U||(U=ty(),U.c(),U.m(x,null)):U&&(U.d(1),U=null)},d(e){e&&d(t),N&&N.d(),L&&L.d(),U&&U.d(),T=!1,r(_)}}}function Gp(e){let t,n,r,o,i,s=e[168].query+"";return{c(){t=h("div"),n=h("p"),r=p('No search results found for "'),o=p(s),i=p('".'),m(n,"class","svelte-d3wb0j"),m(t,"class","no-search-results svelte-d3wb0j")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(n,o),c(n,i)},p(e,t){64&t[0]&&s!==(s=e[168].query+"")&&E(o,s)},d(e){e&&d(t)}}}function Zp(e){let t,n=e[36].get(e[168].id).events,r=[];for(let t=0;t<n.length;t+=1)r[t]=Xp(Ep(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(262228&o[0]|1440&o[1]){let i;for(n=e[36].get(e[168].id).events,i=0;i<n.length;i+=1){const s=Ep(e,n,i);r[i]?r[i].p(s,o):(r[i]=Xp(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function Yp(e){let t,n,r;function o(){return e[108](e[153])}return{c(){t=h("button"),t.textContent="🗑️",m(t,"class","delete-btn svelte-d3wb0j")},m(e,i){u(e,t,i),n||(r=w(t,"click",v(o)),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r()}}}function Qp(e){let t,n,r,o,i,s,a,l,f=JSON.stringify(e[153],null,2)+"";function g(...t){return e[111](e[153],...t)}return{c(){t=h("div"),n=h("div"),r=h("pre"),o=p(f),i=y(),s=h("button"),s.textContent="📋",m(r,"class","event-json svelte-d3wb0j"),m(s,"class","copy-json-btn svelte-d3wb0j"),m(s,"title","Copy minified JSON to clipboard"),m(n,"class","json-container svelte-d3wb0j"),m(t,"class","search-result-details svelte-d3wb0j")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,o),c(n,i),c(n,s),a||(l=w(s,"click",v(g)),a=!0)},p(t,n){e=t,64&n[0]&&f!==(f=JSON.stringify(e[153],null,2)+"")&&E(o,f)},d(e){e&&d(t),a=!1,l()}}}function Xp(e){let t,n,o,i,s,a,l,f,g,v,b,x,k,C,A,j,T,_,$,I,R,O,P,B,N,L,U=ng(e[153].pubkey)+"",F=e[153].kind+"",M=e[38](e[153].kind)+"",D=og(e[153].created_at)+"",H=rg(e[153].content)+"",q=e[18].has(e[153].id),z=5!==e[153].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[153].pubkey&&e[153].pubkey===e[2])&&Yp(e);function K(){return e[109](e[153])}function W(...t){return e[110](e[153],...t)}let V=q&&Qp(e);return{c(){t=h("div"),n=h("div"),o=h("div"),o.innerHTML='<div class="avatar-placeholder svelte-d3wb0j">👤</div>',i=y(),s=h("div"),a=h("div"),l=p(U),f=y(),g=h("div"),v=h("span"),b=p(F),x=y(),k=h("span"),C=p(M),A=y(),j=h("div"),T=h("div"),_=p(D),$=y(),I=h("div"),R=p(H),O=y(),z&&z.c(),P=y(),V&&V.c(),B=y(),m(o,"class","search-result-avatar svelte-d3wb0j"),m(a,"class","search-result-author svelte-d3wb0j"),m(v,"class","kind-number svelte-d3wb0j"),m(k,"class","kind-name svelte-d3wb0j"),m(g,"class","search-result-kind svelte-d3wb0j"),m(s,"class","search-result-info svelte-d3wb0j"),m(T,"class","event-timestamp svelte-d3wb0j"),m(I,"class","event-content-single-line svelte-d3wb0j"),m(j,"class","search-result-content svelte-d3wb0j"),m(n,"class","search-result-row svelte-d3wb0j"),m(n,"role","button"),m(n,"tabindex","0"),m(t,"class","search-result-item svelte-d3wb0j"),S(t,"expanded",e[18].has(e[153].id))},m(e,r){u(e,t,r),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,f),c(s,g),c(g,v),c(v,b),c(g,x),c(g,k),c(k,C),c(n,A),c(n,j),c(j,T),c(T,_),c(j,$),c(j,I),c(I,R),c(n,O),z&&z.m(n,null),c(t,P),V&&V.m(t,null),c(t,B),N||(L=[w(n,"click",K),w(n,"keydown",W)],N=!0)},p(r,o){e=r,64&o[0]&&U!==(U=ng(e[153].pubkey)+"")&&E(l,U),64&o[0]&&F!==(F=e[153].kind+"")&&E(b,F),64&o[0]&&M!==(M=e[38](e[153].kind)+"")&&E(C,M),64&o[0]&&D!==(D=og(e[153].created_at)+"")&&E(_,D),64&o[0]&&H!==(H=rg(e[153].content)+"")&&E(R,H),5!==e[153].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[153].pubkey&&e[153].pubkey===e[2])?z?z.p(e,o):(z=Yp(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),262208&o[0]&&(q=e[18].has(e[153].id)),q?V?V.p(e,o):(V=Qp(e),V.c(),V.m(t,B)):V&&(V.d(1),V=null),262208&o[0]|32&o[1]&&S(t,"expanded",e[18].has(e[153].id))},d(e){e&&d(t),z&&z.d(),V&&V.d(),N=!1,r(L)}}}function ey(e){let t;return{c(){t=h("div"),t.innerHTML='<div class="loading-spinner svelte-d3wb0j"></div> \n <p class="svelte-d3wb0j">Searching...</p>',m(t,"class","loading-search-results svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function ty(e){let t;return{c(){t=h("div"),t.innerHTML='<p class="svelte-d3wb0j">No more search results to load.</p>',m(t,"class","end-of-search-results svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function ny(e){let t,n=e[168].id===e[5]&&Jp(e);return{c(){n&&n.c(),t=g()},m(e,r){n&&n.m(e,r),u(e,t,r)},p(e,r){e[168].id===e[5]?n?n.p(e,r):(n=Jp(e),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(e){n&&n.d(e),e&&d(t)}}}function ry(t){let n,r,o=t[165].label+"";return{c(){n=h("option"),r=p(o),n.__value=t[165].value,n.value=n.__value},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}function oy(e){let t;function n(e,t){return e[32]?ay:0===e[31].length?sy:iy}let r=n(e),o=r(e);return{c(){t=h("div"),o.c(),m(t,"class","recovery-results svelte-d3wb0j")},m(e,n){u(e,t,n),o.m(t,null)},p(e,i){r===(r=n(e))&&o?o.p(e,i):(o.d(1),o=r(e),o&&(o.c(),o.m(t,null)))},d(e){e&&d(t),o.d()}}}function iy(e){let t,n,r,o=e[31],i=[];for(let t=0;t<o.length;t+=1)i[t]=uy(xp(e,o,t));let s=e[33]&&dy(e);return{c(){t=h("div");for(let e=0;e<i.length;e+=1)i[e].c();n=y(),s&&s.c(),r=g(),m(t,"class","events-list svelte-d3wb0j")},m(e,o){u(e,t,o);for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(t,null);u(e,n,o),s&&s.m(e,o),u(e,r,o)},p(e,n){if(36865&n[1]){let r;for(o=e[31],r=0;r<o.length;r+=1){const s=xp(e,o,r);i[r]?i[r].p(s,n):(i[r]=uy(s),i[r].c(),i[r].m(t,null))}for(;r<i.length;r+=1)i[r].d(1);i.length=o.length}e[33]?s?s.p(e,n):(s=dy(e),s.c(),s.m(r.parentNode,r)):s&&(s.d(1),s=null)},d(e){e&&d(t),f(i,e),e&&d(n),s&&s.d(e),e&&d(r)}}}function sy(t){let n;return{c(){n=h("div"),n.textContent="No events found for this kind",m(n,"class","no-events svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function ay(t){let n;return{c(){n=h("div"),n.textContent="Loading events...",m(n,"class","loading svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function ly(e){let t;return{c(){t=p("Current Version")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function cy(e){let t,n,r;function o(){return e[105](e[153])}return{c(){t=h("button"),t.textContent="🔄 Repost",m(t,"class","repost-button svelte-d3wb0j")},m(e,i){u(e,t,i),n||(r=w(t,"click",o),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r()}}}function uy(e){let t,n,r,o,i,s,a,l,f,g,b,x,k,C,A,j,T,_,$=new Date(1e3*e[153].created_at).toLocaleString()+"",I=JSON.stringify(e[153],null,2)+"",R=e[162]&&ly(),O=!e[162]&&cy(e);function P(...t){return e[106](e[153],...t)}return{c(){t=h("div"),n=h("div"),r=h("div"),o=h("span"),R&&R.c(),i=y(),s=h("span"),a=p($),l=y(),f=h("div"),O&&O.c(),g=y(),b=h("button"),b.textContent="📋 Copy JSON",x=y(),k=h("div"),C=h("pre"),A=p(I),j=y(),m(o,"class","event-kind svelte-d3wb0j"),m(s,"class","event-timestamp svelte-d3wb0j"),m(r,"class","event-header-left svelte-d3wb0j"),m(b,"class","copy-json-btn svelte-d3wb0j"),m(f,"class","event-header-actions svelte-d3wb0j"),m(n,"class","event-header svelte-d3wb0j"),m(C,"class","event-json svelte-d3wb0j"),m(k,"class","event-content svelte-d3wb0j"),m(t,"class","event-item svelte-d3wb0j"),S(t,"old-version",!e[162])},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,o),R&&R.m(o,null),c(r,i),c(r,s),c(s,a),c(n,l),c(n,f),O&&O.m(f,null),c(f,g),c(f,b),c(t,x),c(t,k),c(k,C),c(C,A),c(t,j),T||(_=w(b,"click",v(P)),T=!0)},p(n,r){(e=n)[162]?R||(R=ly(),R.c(),R.m(o,null)):R&&(R.d(1),R=null),1&r[1]&&$!==($=new Date(1e3*e[153].created_at).toLocaleString()+"")&&E(a,$),e[162]?O&&(O.d(1),O=null):O?O.p(e,r):(O=cy(e),O.c(),O.m(f,g)),1&r[1]&&I!==(I=JSON.stringify(e[153],null,2)+"")&&E(A,I),32769&r[1]&&S(t,"old-version",!e[162])},d(e){e&&d(t),R&&R.d(),O&&O.d(),T=!1,_()}}}function dy(e){let t,n,r,o;return{c(){t=h("button"),n=p("Load More Events"),m(t,"class","load-more svelte-d3wb0j"),t.disabled=e[32]},m(i,s){u(i,t,s),c(t,n),r||(o=w(t,"click",e[42]),r=!0)},p(e,n){2&n[1]&&(t.disabled=e[32])},d(e){e&&d(t),r=!1,o()}}}function fy(t){let n,r,o,i,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access sprocket management.",o=y(),i=h("button"),i.textContent="Log In",m(r,"class","svelte-d3wb0j"),m(i,"class","login-btn svelte-d3wb0j"),m(n,"class","login-prompt svelte-d3wb0j")},m(e,l){u(e,n,l),c(n,r),c(n,o),c(n,i),s||(a=w(i,"click",t[58]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function hy(e){let t,n,r,o,i,s,a,l,f,g=(e[4]||"none")+"";return{c(){t=h("div"),n=h("p"),n.textContent="❌ Owner permission required for sprocket\n management.",r=y(),o=h("p"),o.innerHTML="To enable sprocket functionality, set the <code>ORLY_OWNERS</code> environment variable with your npub when starting the\n relay.",i=y(),s=h("p"),a=p("Current user role: "),l=h("strong"),f=p(g),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","svelte-d3wb0j"),m(t,"class","permission-denied svelte-d3wb0j")},m(e,d){u(e,t,d),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),c(s,a),c(s,l),c(l,f)},p(e,t){16&t[0]&&g!==(g=(e[4]||"none")+"")&&E(f,g)},d(e){e&&d(t)}}}function py(e){let t,n,o,i,s,a,l,g,v,b,k,C,A,j,T,_,$,I,R,O,P,B,N,L,U,F,M,D,H,q,z,K,W,V,J,G,Z,Y,Q,X,ee,te,ne,re,oe,ie,se,ae,le,ce,ue,de,fe,he,pe,ye,ge=e[22]?.is_running?"🟢 Running":"🔴 Stopped",we=e[22]?.script_exists?"✅ Exists":"❌ Not found",ve=e[22]?.pid&&yy(e),me=e[25]&&gy(e),be=e[23],Ee=[];for(let t=0;t<be.length;t+=1)Ee[t]=my(Sp(e,be,t));return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Script Editor",i=y(),s=h("div"),a=h("button"),l=p("🔄 Restart"),g=y(),v=h("button"),b=p("🗑️ Delete Script"),C=y(),A=h("div"),j=h("h4"),j.textContent="Upload Script",T=y(),_=h("div"),$=h("input"),I=y(),R=h("button"),O=p("📤 Upload & Update"),B=y(),N=h("div"),L=h("div"),U=h("span"),U.textContent="Status:",F=y(),M=h("span"),D=p(ge),H=y(),ve&&ve.c(),q=y(),z=h("div"),K=h("span"),K.textContent="Script:",W=y(),V=h("span"),J=p(we),G=y(),Z=h("div"),Y=h("textarea"),Q=y(),X=h("div"),ee=h("button"),te=p("💾 Save & Update"),ne=y(),re=h("button"),oe=p("📥 Load Current"),ie=y(),me&&me.c(),se=y(),ae=h("div"),le=h("h3"),le.textContent="Script Versions",ce=y(),ue=h("div");for(let e=0;e<Ee.length;e+=1)Ee[e].c();de=y(),fe=h("button"),he=p("🔄 Refresh Versions"),m(a,"class","sprocket-btn restart-btn svelte-d3wb0j"),a.disabled=e[24],m(v,"class","sprocket-btn delete-btn svelte-d3wb0j"),v.disabled=k=e[24]||!e[22]?.script_exists,m(s,"class","sprocket-controls svelte-d3wb0j"),m(n,"class","sprocket-header svelte-d3wb0j"),m(j,"class","svelte-d3wb0j"),m($,"type","file"),m($,"id","sprocket-upload-file"),m($,"accept",".sh,.bash"),$.disabled=e[24],m($,"class","svelte-d3wb0j"),m(R,"class","sprocket-btn upload-btn svelte-d3wb0j"),R.disabled=P=e[24]||!e[27],m(_,"class","upload-controls svelte-d3wb0j"),m(A,"class","sprocket-upload-section svelte-d3wb0j"),m(U,"class","status-label svelte-d3wb0j"),m(M,"class","status-value svelte-d3wb0j"),S(M,"running",e[22]?.is_running),m(L,"class","status-item svelte-d3wb0j"),m(K,"class","status-label svelte-d3wb0j"),m(V,"class","status-value svelte-d3wb0j"),m(z,"class","status-item svelte-d3wb0j"),m(N,"class","sprocket-status svelte-d3wb0j"),m(Y,"class","script-editor svelte-d3wb0j"),m(Y,"placeholder","#!/bin/bash # Enter your sprocket script here..."),Y.disabled=e[24],m(Z,"class","script-editor-container svelte-d3wb0j"),m(ee,"class","sprocket-btn save-btn svelte-d3wb0j"),ee.disabled=e[24],m(re,"class","sprocket-btn load-btn svelte-d3wb0j"),re.disabled=e[24],m(X,"class","script-actions svelte-d3wb0j"),m(t,"class","sprocket-section svelte-d3wb0j"),m(ue,"class","versions-list svelte-d3wb0j"),m(fe,"class","sprocket-btn refresh-btn svelte-d3wb0j"),fe.disabled=e[24],m(ae,"class","sprocket-section svelte-d3wb0j")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,g),c(s,v),c(v,b),c(t,C),c(t,A),c(A,j),c(A,T),c(A,_),c(_,$),c(_,I),c(_,R),c(R,O),c(t,B),c(t,N),c(N,L),c(L,U),c(L,F),c(L,M),c(M,D),c(N,H),ve&&ve.m(N,null),c(N,q),c(N,z),c(z,K),c(z,W),c(z,V),c(V,J),c(t,G),c(t,Z),c(Z,Y),x(Y,e[21]),c(t,Q),c(t,X),c(X,ee),c(ee,te),c(X,ne),c(X,re),c(re,oe),c(t,ie),me&&me.m(t,null),u(r,se,d),u(r,ae,d),c(ae,le),c(ae,ce),c(ae,ue);for(let e=0;e<Ee.length;e+=1)Ee[e]&&Ee[e].m(ue,null);c(ae,de),c(ae,fe),c(fe,he),pe||(ye=[w(a,"click",e[49]),w(v,"click",e[50]),w($,"change",e[54]),w(R,"click",e[55]),w(Y,"input",e[100]),w(ee,"click",e[48]),w(re,"click",e[47]),w(fe,"click",e[51])],pe=!0)},p(e,n){if(16777216&n[0]&&(a.disabled=e[24]),20971520&n[0]&&k!==(k=e[24]||!e[22]?.script_exists)&&(v.disabled=k),16777216&n[0]&&($.disabled=e[24]),150994944&n[0]&&P!==(P=e[24]||!e[27])&&(R.disabled=P),4194304&n[0]&&ge!==(ge=e[22]?.is_running?"🟢 Running":"🔴 Stopped")&&E(D,ge),4194304&n[0]&&S(M,"running",e[22]?.is_running),e[22]?.pid?ve?ve.p(e,n):(ve=yy(e),ve.c(),ve.m(N,q)):ve&&(ve.d(1),ve=null),4194304&n[0]&&we!==(we=e[22]?.script_exists?"✅ Exists":"❌ Not found")&&E(J,we),16777216&n[0]&&(Y.disabled=e[24]),2097152&n[0]&&x(Y,e[21]),16777216&n[0]&&(ee.disabled=e[24]),16777216&n[0]&&(re.disabled=e[24]),e[25]?me?me.p(e,n):(me=gy(e),me.c(),me.m(t,null)):me&&(me.d(1),me=null),25165824&n[0]|6291456&n[1]){let t;for(be=e[23],t=0;t<be.length;t+=1){const r=Sp(e,be,t);Ee[t]?Ee[t].p(r,n):(Ee[t]=my(r),Ee[t].c(),Ee[t].m(ue,null))}for(;t<Ee.length;t+=1)Ee[t].d(1);Ee.length=be.length}16777216&n[0]&&(fe.disabled=e[24])},d(e){e&&d(t),ve&&ve.d(),me&&me.d(),e&&d(se),e&&d(ae),f(Ee,e),pe=!1,r(ye)}}}function yy(e){let t,n,r,o,i,s=e[22].pid+"";return{c(){t=h("div"),n=h("span"),n.textContent="PID:",r=y(),o=h("span"),i=p(s),m(n,"class","status-label svelte-d3wb0j"),m(o,"class","status-value svelte-d3wb0j"),m(t,"class","status-item svelte-d3wb0j")},m(e,s){u(e,t,s),c(t,n),c(t,r),c(t,o),c(o,i)},p(e,t){4194304&t[0]&&s!==(s=e[22].pid+"")&&E(i,s)},d(e){e&&d(t)}}}function gy(e){let t,n;return{c(){t=h("div"),n=p(e[25]),m(t,"class","sprocket-message svelte-d3wb0j"),S(t,"error","error"===e[26])},m(e,r){u(e,t,r),c(t,n)},p(e,r){33554432&r[0]&&E(n,e[25]),67108864&r[0]&&S(t,"error","error"===e[26])},d(e){e&&d(t)}}}function wy(e){let t;return{c(){t=h("span"),t.textContent="Current",m(t,"class","current-badge svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function vy(e){let t,n,r,o;function i(){return e[102](e[159])}return{c(){t=h("button"),n=p("🗑️ Delete"),m(t,"class","version-btn delete-btn svelte-d3wb0j"),t.disabled=e[24]},m(e,s){u(e,t,s),c(t,n),r||(o=w(t,"click",i),r=!0)},p(n,r){e=n,16777216&r[0]&&(t.disabled=e[24])},d(e){e&&d(t),r=!1,o()}}}function my(e){let t,n,r,o,i,s,a,l,f,g,v,b,x,k,C,A,j=e[159].name+"",T=new Date(e[159].modified).toLocaleString()+"",_=e[159].is_current&&wy();function $(){return e[101](e[159])}let I=!e[159].is_current&&vy(e);return{c(){t=h("div"),n=h("div"),r=h("div"),o=p(j),i=y(),s=h("div"),a=p(T),l=y(),_&&_.c(),f=y(),g=h("div"),v=h("button"),b=p("📥 Load"),x=y(),I&&I.c(),k=y(),m(r,"class","version-name svelte-d3wb0j"),m(s,"class","version-date svelte-d3wb0j"),m(n,"class","version-info svelte-d3wb0j"),m(v,"class","version-btn load-btn svelte-d3wb0j"),v.disabled=e[24],m(g,"class","version-actions svelte-d3wb0j"),m(t,"class","version-item svelte-d3wb0j"),S(t,"current",e[159].is_current)},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,o),c(n,i),c(n,s),c(s,a),c(s,l),_&&_.m(s,null),c(t,f),c(t,g),c(g,v),c(v,b),c(g,x),I&&I.m(g,null),c(t,k),C||(A=w(v,"click",$),C=!0)},p(n,r){e=n,8388608&r[0]&&j!==(j=e[159].name+"")&&E(o,j),8388608&r[0]&&T!==(T=new Date(e[159].modified).toLocaleString()+"")&&E(a,T),e[159].is_current?_||(_=wy(),_.c(),_.m(s,null)):_&&(_.d(1),_=null),16777216&r[0]&&(v.disabled=e[24]),e[159].is_current?I&&(I.d(1),I=null):I?I.p(e,r):(I=vy(e),I.c(),I.m(g,null)),8388608&r[0]&&S(t,"current",e[159].is_current)},d(e){e&&d(t),_&&_.d(),I&&I.d(),C=!1,A()}}}function by(t){let n,r,o,i,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in with owner permissions to access\n managed ACL configuration.",o=y(),i=h("button"),i.textContent="Log In",m(i,"class","login-btn svelte-d3wb0j"),m(n,"class","access-denied")},m(e,l){u(e,n,l),c(n,r),c(n,o),c(n,i),s||(a=w(i,"click",t[58]),s=!0)},p:e,i:e,o:e,d(e){e&&d(n),s=!1,a()}}}function Ey(e){let t,n;return t=new gp({props:{userSigner:e[13],userPubkey:e[2]}}),{c(){V(t.$$.fragment)},m(e,r){J(t,e,r),n=!0},p(e,n){const r={};8192&n[0]&&(r.userSigner=e[13]),4&n[0]&&(r.userPubkey=e[2]),t.$set(r)},i(e){n||(K(t.$$.fragment,e),n=!0)},o(e){W(t.$$.fragment,e),n=!1},d(e){G(t,e)}}}function xy(t){let n,r,o,i,s,a,l,f,g,w,v,b=(t[9]||"unknown")+"";return{c(){n=h("div"),r=h("h3"),r.textContent="⚠️ Managed ACL Mode Not Active",o=y(),i=h("p"),i.textContent='To use the Managed ACL interface, you need to set\n the ACL mode to "managed" in your relay\n configuration.',s=y(),a=h("p"),l=p("Current ACL mode: "),f=h("strong"),g=p(b),w=y(),v=h("p"),v.innerHTML='Please set <code class="svelte-d3wb0j">ORLY_ACL_MODE=managed</code> in your\n environment variables and restart the relay.',m(r,"class","svelte-d3wb0j"),m(i,"class","svelte-d3wb0j"),m(a,"class","svelte-d3wb0j"),m(v,"class","svelte-d3wb0j"),m(n,"class","acl-mode-warning svelte-d3wb0j")},m(e,t){u(e,n,t),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),c(a,l),c(a,f),c(f,g),c(n,w),c(n,v)},p(e,t){512&t[0]&&b!==(b=(e[9]||"unknown")+"")&&E(g,b)},i:e,o:e,d(e){e&&d(n)}}}function ky(t){let n;return{c(){n=h("div"),n.innerHTML='<p class="svelte-d3wb0j">❌ Write, admin, or owner permission required to\n view all events.</p>',m(n,"class","permission-denied svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Sy(e){let t,n,r,o,i;function s(e,t){return e[35].length>0?Ay:e[19]?void 0:Cy}let a=s(e),l=a&&a(e),f=e[19]&&Py(),p=!e[20]&&e[7].length>0&&By();return{c(){t=h("div"),l&&l.c(),n=y(),f&&f.c(),r=y(),p&&p.c(),m(t,"class","events-view-content svelte-d3wb0j")},m(s,a){u(s,t,a),l&&l.m(t,null),c(t,n),f&&f.m(t,null),c(t,r),p&&p.m(t,null),o||(i=w(t,"scroll",e[75]),o=!0)},p(e,o){a===(a=s(e))&&l?l.p(e,o):(l&&l.d(1),l=a&&a(e),l&&(l.c(),l.m(t,n))),e[19]?f||(f=Py(),f.c(),f.m(t,r)):f&&(f.d(1),f=null),!e[20]&&e[7].length>0?p||(p=By(),p.c(),p.m(t,null)):p&&(p.d(1),p=null)},d(e){e&&d(t),l&&l.d(),f&&f.d(),p&&p.d(),o=!1,i()}}}function Cy(t){let n;return{c(){n=h("div"),n.innerHTML='<p class="svelte-d3wb0j">No events found.</p>',m(n,"class","no-events svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ay(e){let t,n=e[35],r=[];for(let t=0;t<n.length;t+=1)r[t]=Oy(Cp(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=g()},m(e,n){for(let t=0;t<r.length;t+=1)r[t]&&r[t].m(e,n);u(e,t,n)},p(e,o){if(262164&o[0]|1424&o[1]){let i;for(n=e[35],i=0;i<n.length;i+=1){const s=Cp(e,n,i);r[i]?r[i].p(s,o):(r[i]=Oy(s),r[i].c(),r[i].m(t.parentNode,t))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function jy(e){let t,n,r=rg(e[153].content)+"";return{c(){t=h("div"),n=p(r),m(t,"class","event-content-single-line svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n)},p(e,t){16&t[1]&&r!==(r=rg(e[153].content)+"")&&E(n,r)},d(e){e&&d(t)}}}function Ty(e){let t,n,r,o=e[153].tags&&e[153].tags.length>0&&_y(e);return{c(){t=h("div"),n=h("span"),n.textContent="🗑️ Delete Event",r=y(),o&&o.c(),m(n,"class","delete-event-label svelte-d3wb0j"),m(t,"class","delete-event-info svelte-d3wb0j")},m(e,i){u(e,t,i),c(t,n),c(t,r),o&&o.m(t,null)},p(e,n){e[153].tags&&e[153].tags.length>0?o?o.p(e,n):(o=_y(e),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function _y(e){let t,n=e[153].tags.filter(sg),r=[];for(let t=0;t<n.length;t+=1)r[t]=$y(Ap(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();m(t,"class","delete-targets svelte-d3wb0j")},m(e,n){u(e,t,n);for(let e=0;e<r.length;e+=1)r[e]&&r[e].m(t,null)},p(e,o){if(16&o[1]){let i;for(n=e[153].tags.filter(sg),i=0;i<n.length;i+=1){const s=Ap(e,n,i);r[i]?r[i].p(s,o):(r[i]=$y(s),r[i].c(),r[i].m(t,null))}for(;i<r.length;i+=1)r[i].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function $y(e){let t,n,r,o,i,s=e[156][1].slice(0,8)+"",a=e[156][1].slice(-8)+"";return{c(){t=h("span"),n=p("Target: "),r=p(s),o=p("..."),i=p(a),m(t,"class","delete-target svelte-d3wb0j")},m(e,s){u(e,t,s),c(t,n),c(t,r),c(t,o),c(t,i)},p(e,t){16&t[1]&&s!==(s=e[156][1].slice(0,8)+"")&&E(r,s),16&t[1]&&a!==(a=e[156][1].slice(-8)+"")&&E(i,a)},d(e){e&&d(t)}}}function Iy(e){let t,n,r;function o(){return e[91](e[153])}return{c(){t=h("button"),t.textContent="🗑️",m(t,"class","delete-btn svelte-d3wb0j")},m(e,i){u(e,t,i),n||(r=w(t,"click",v(o)),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r()}}}function Ry(e){let t,n,r,o,i,s,a,l,f=JSON.stringify(e[153],null,2)+"";function g(...t){return e[94](e[153],...t)}return{c(){t=h("div"),n=h("div"),r=h("pre"),o=p(f),i=y(),s=h("button"),s.textContent="📋",m(r,"class","event-json svelte-d3wb0j"),m(s,"class","copy-json-btn svelte-d3wb0j"),m(s,"title","Copy minified JSON to clipboard"),m(n,"class","json-container svelte-d3wb0j"),m(t,"class","events-view-details svelte-d3wb0j")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,o),c(n,i),c(n,s),a||(l=w(s,"click",v(g)),a=!0)},p(t,n){e=t,16&n[1]&&f!==(f=JSON.stringify(e[153],null,2)+"")&&E(o,f)},d(e){e&&d(t),a=!1,l()}}}function Oy(e){let t,n,o,i,s,a,l,f,g,v,b,x,k,C,A,j,T,_,$,I,R,O,P,B,N=ng(e[153].pubkey)+"",L=e[153].kind+"",U=e[38](e[153].kind)+"",F=og(e[153].created_at)+"",M=e[18].has(e[153].id);function D(e,t){return 5===e[153].kind?Ty:jy}let H=D(e),q=H(e),z=5!==e[153].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[153].pubkey&&e[153].pubkey===e[2])&&Iy(e);function K(){return e[92](e[153])}function W(...t){return e[93](e[153],...t)}let V=M&&Ry(e);return{c(){t=h("div"),n=h("div"),o=h("div"),o.innerHTML='<div class="avatar-placeholder svelte-d3wb0j">👤</div>',i=y(),s=h("div"),a=h("div"),l=p(N),f=y(),g=h("div"),v=h("span"),b=p(L),x=y(),k=h("span"),C=p(U),A=y(),j=h("div"),T=h("div"),_=p(F),$=y(),q.c(),I=y(),z&&z.c(),R=y(),V&&V.c(),O=y(),m(o,"class","events-view-avatar svelte-d3wb0j"),m(a,"class","events-view-author svelte-d3wb0j"),m(v,"class","kind-number svelte-d3wb0j"),S(v,"delete-event",5===e[153].kind),m(k,"class","kind-name svelte-d3wb0j"),m(g,"class","events-view-kind svelte-d3wb0j"),m(s,"class","events-view-info svelte-d3wb0j"),m(T,"class","event-timestamp svelte-d3wb0j"),m(j,"class","events-view-content svelte-d3wb0j"),m(n,"class","events-view-row svelte-d3wb0j"),m(n,"role","button"),m(n,"tabindex","0"),m(t,"class","events-view-item svelte-d3wb0j"),S(t,"expanded",e[18].has(e[153].id))},m(e,r){u(e,t,r),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,f),c(s,g),c(g,v),c(v,b),c(g,x),c(g,k),c(k,C),c(n,A),c(n,j),c(j,T),c(T,_),c(j,$),q.m(j,null),c(n,I),z&&z.m(n,null),c(t,R),V&&V.m(t,null),c(t,O),P||(B=[w(n,"click",K),w(n,"keydown",W)],P=!0)},p(r,o){e=r,16&o[1]&&N!==(N=ng(e[153].pubkey)+"")&&E(l,N),16&o[1]&&L!==(L=e[153].kind+"")&&E(b,L),16&o[1]&&S(v,"delete-event",5===e[153].kind),16&o[1]&&U!==(U=e[38](e[153].kind)+"")&&E(C,U),16&o[1]&&F!==(F=og(e[153].created_at)+"")&&E(_,F),H===(H=D(e))&&q?q.p(e,o):(q.d(1),q=H(e),q&&(q.c(),q.m(j,null))),5!==e[153].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[153].pubkey&&e[153].pubkey===e[2])?z?z.p(e,o):(z=Iy(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),262144&o[0]|16&o[1]&&(M=e[18].has(e[153].id)),M?V?V.p(e,o):(V=Ry(e),V.c(),V.m(t,O)):V&&(V.d(1),V=null),262144&o[0]|16&o[1]&&S(t,"expanded",e[18].has(e[153].id))},d(e){e&&d(t),q.d(),z&&z.d(),V&&V.d(),P=!1,r(B)}}}function Py(e){let t;return{c(){t=h("div"),t.innerHTML='<div class="loading-spinner svelte-d3wb0j"></div> \n <p class="svelte-d3wb0j">Loading events...</p>',m(t,"class","loading-events svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function By(e){let t;return{c(){t=h("div"),t.innerHTML='<p class="svelte-d3wb0j">No more events to load.</p>',m(t,"class","end-of-events svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ny(e){let t,n,o,i,s,a,l,f,g,v,b,E,x,k,S,C;function A(e,t){return e[19]?Uy:Ly}let j=A(e),T=j(e);return{c(){t=h("div"),n=h("div"),o=h("label"),i=h("input"),s=y(),a=h("span"),l=y(),f=h("span"),f.textContent="Only show my events",g=y(),v=h("div"),b=h("button"),E=p("🔄 Load More"),x=y(),k=h("button"),T.c(),m(i,"type","checkbox"),m(i,"class","svelte-d3wb0j"),m(a,"class","toggle-slider svelte-d3wb0j"),m(f,"class","toggle-label svelte-d3wb0j"),m(o,"class","toggle-container svelte-d3wb0j"),m(n,"class","events-view-toggle svelte-d3wb0j"),m(b,"class","refresh-btn svelte-d3wb0j"),b.disabled=e[19],m(k,"class","reload-btn svelte-d3wb0j"),k.disabled=e[19],m(v,"class","events-view-buttons svelte-d3wb0j"),m(t,"class","events-view-header svelte-d3wb0j")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),i.checked=e[8],c(o,s),c(o,a),c(o,l),c(o,f),c(t,g),c(t,v),c(v,b),c(b,E),c(v,x),c(v,k),T.m(k,null),S||(C=[w(i,"change",e[95]),w(i,"change",e[96]),w(b,"click",e[97]),w(k,"click",e[98])],S=!0)},p(e,t){256&t[0]&&(i.checked=e[8]),524288&t[0]&&(b.disabled=e[19]),j!==(j=A(e))&&(T.d(1),T=j(e),T&&(T.c(),T.m(k,null))),524288&t[0]&&(k.disabled=e[19])},d(e){e&&d(t),T.d(),S=!1,r(C)}}}function Ly(e){let t;return{c(){t=p("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Uy(e){let t;return{c(){t=h("div"),m(t,"class","spinner svelte-d3wb0j")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Fy(t){let n,r,o,i,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Import Events",o=y(),i=h("p"),i.textContent="Please log in to access import functionality.",s=y(),a=h("button"),a.textContent="Log In",m(r,"class","recovery-header svelte-d3wb0j"),m(i,"class","recovery-description svelte-d3wb0j"),m(a,"class","login-btn svelte-d3wb0j"),m(n,"class","login-prompt svelte-d3wb0j")},m(e,d){u(e,n,d),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),l||(f=w(a,"click",t[58]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function My(t){let n;return{c(){n=h("div"),n.innerHTML='<h3 class="recovery-header svelte-d3wb0j">Import Events</h3> \n <p class="recovery-description svelte-d3wb0j">❌ Admin or owner permission required for import\n functionality.</p>',m(n,"class","permission-denied svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Dy(e){let t,n,o,i,s,a,l,f,g,v,b,E;return{c(){t=h("h3"),t.textContent="Import Events",n=y(),o=h("p"),o.textContent="Upload a JSONL file to import events into the database.",i=y(),s=h("div"),a=h("input"),l=y(),f=h("button"),g=p("Import Events"),m(t,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(a,"type","file"),m(a,"id","import-file"),m(a,"accept",".jsonl,.txt"),m(a,"class","svelte-d3wb0j"),m(f,"class","import-btn svelte-d3wb0j"),f.disabled=v=!e[17],m(s,"class","recovery-controls-card svelte-d3wb0j")},m(r,d){u(r,t,d),u(r,n,d),u(r,o,d),u(r,i,d),u(r,s,d),c(s,a),c(s,l),c(s,f),c(f,g),b||(E=[w(a,"change",e[72]),w(f,"click",e[73])],b=!0)},p(e,t){131072&t[0]&&v!==(v=!e[17])&&(f.disabled=v)},d(e){e&&d(t),e&&d(n),e&&d(o),e&&d(i),e&&d(s),b=!1,r(E)}}}function Hy(t){let n,r,o,i,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access export functionality.",o=y(),i=h("button"),i.textContent="Log In",m(r,"class","svelte-d3wb0j"),m(i,"class","login-btn svelte-d3wb0j"),m(n,"class","login-prompt svelte-d3wb0j")},m(e,l){u(e,n,l),c(n,r),c(n,o),c(n,i),s||(a=w(i,"click",t[58]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function qy(e){let t,n,r,o,i,s,a,l,f,p,v=("admin"===e[10]||"owner"===e[10])&&zy(e);return{c(){t=h("div"),n=h("h3"),n.textContent="Export My Events",r=y(),o=h("p"),o.textContent="Download your personal events as a JSONL file.",i=y(),s=h("button"),s.textContent="📤 Export My Events",a=y(),v&&v.c(),l=g(),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","export-btn svelte-d3wb0j"),m(t,"class","export-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),u(d,a,h),v&&v.m(d,h),u(d,l,h),f||(p=w(s,"click",e[71]),f=!0)},p(e,t){"admin"===e[10]||"owner"===e[10]?v?v.p(e,t):(v=zy(e),v.c(),v.m(l.parentNode,l)):v&&(v.d(1),v=null)},d(e){e&&d(t),e&&d(a),v&&v.d(e),e&&d(l),f=!1,p()}}}function zy(t){let n,r,o,i,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export All Events",o=y(),i=h("p"),i.textContent="Download the complete database as a JSONL file. This\n includes all events from all users.",s=y(),a=h("button"),a.textContent="📤 Export All Events",m(r,"class","svelte-d3wb0j"),m(i,"class","svelte-d3wb0j"),m(a,"class","export-btn svelte-d3wb0j"),m(n,"class","export-section svelte-d3wb0j")},m(e,d){u(e,n,d),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),l||(f=w(a,"click",t[70]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function Ky(e){let t,n,o,i,s,a,l,f,p,g;function b(e,t){return e[3]?Vy:e[1]&&e[2]?Wy:void 0}let E=b(e),x=E&&E(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Settings",s=y(),a=h("button"),a.textContent="✕",l=y(),f=h("div"),x&&x.c(),m(i,"class","svelte-d3wb0j"),m(a,"class","close-btn svelte-d3wb0j"),m(o,"class","drawer-header svelte-d3wb0j"),m(f,"class","drawer-content"),m(n,"class","settings-drawer svelte-d3wb0j"),S(n,"dark-theme",e[0]),m(t,"class","drawer-overlay svelte-d3wb0j"),m(t,"role","button"),m(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),x&&x.m(f,null),p||(g=[w(a,"click",e[63]),w(n,"click",v(e[84])),w(n,"keydown",v(e[85])),w(t,"click",e[63]),w(t,"keydown",e[114])],p=!0)},p(e,t){E===(E=b(e))&&x?x.p(e,t):(x&&x.d(1),x=E&&E(e),x&&(x.c(),x.m(f,null))),1&t[0]&&S(n,"dark-theme",e[0])},d(e){e&&d(t),x&&x.d(),p=!1,r(g)}}}function Wy(e){let t,n,r,o,i,s,a,l,f,g,v,b,x,k,S,C=e[2].slice(0,16)+"",A=e[2].slice(-8)+"";return{c(){t=h("div"),n=h("h3"),n.textContent="Profile Loading",r=y(),o=h("p"),o.textContent="Your profile metadata is being loaded...",i=y(),s=h("button"),s.textContent="Retry Loading Profile",a=y(),l=h("div"),f=h("strong"),f.textContent="Public Key:",g=y(),v=p(C),b=p("..."),x=p(A),m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","retry-profile-btn svelte-d3wb0j"),m(l,"class","user-pubkey-display svelte-d3wb0j"),m(t,"class","profile-loading-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),c(t,a),c(t,l),c(l,f),c(l,g),c(l,v),c(l,b),c(l,x),k||(S=w(s,"click",e[69]),k=!0)},p(e,t){4&t[0]&&C!==(C=e[2].slice(0,16)+"")&&E(v,C),4&t[0]&&A!==(A=e[2].slice(-8)+"")&&E(x,A)},d(e){e&&d(t),k=!1,S()}}}function Vy(e){let t,n,r,o,i,s,a,l,f,v,b,x,k,S,C,A=(e[3].name||"Unknown User")+"",j=e[3].banner&&Jy(e);function T(e,t){return e[3].picture?Zy:Gy}let _=T(e),$=_(e),I=e[3].nip05&&Yy(e),R=e[3].about&&Qy(e),O=e[4]&&"read"!==e[4]&&Xy(e);return{c(){t=h("div"),n=h("div"),j&&j.c(),r=y(),o=h("button"),o.textContent="Log out",i=y(),$.c(),s=y(),a=h("div"),l=h("h3"),f=p(A),v=y(),I&&I.c(),b=y(),R&&R.c(),x=y(),O&&O.c(),k=g(),m(o,"class","logout-btn floating svelte-d3wb0j"),m(l,"class","profile-username svelte-d3wb0j"),m(a,"class","name-row svelte-d3wb0j"),m(n,"class","profile-hero svelte-d3wb0j"),m(t,"class","profile-section svelte-d3wb0j")},m(d,h){u(d,t,h),c(t,n),j&&j.m(n,null),c(n,r),c(n,o),c(n,i),$.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,v),I&&I.m(a,null),c(t,b),R&&R.m(t,null),u(d,x,h),O&&O.m(d,h),u(d,k,h),S||(C=w(o,"click",e[60]),S=!0)},p(e,o){e[3].banner?j?j.p(e,o):(j=Jy(e),j.c(),j.m(n,r)):j&&(j.d(1),j=null),_===(_=T(e))&&$?$.p(e,o):($.d(1),$=_(e),$&&($.c(),$.m(n,s))),8&o[0]&&A!==(A=(e[3].name||"Unknown User")+"")&&E(f,A),e[3].nip05?I?I.p(e,o):(I=Yy(e),I.c(),I.m(a,null)):I&&(I.d(1),I=null),e[3].about?R?R.p(e,o):(R=Qy(e),R.c(),R.m(t,null)):R&&(R.d(1),R=null),e[4]&&"read"!==e[4]?O?O.p(e,o):(O=Xy(e),O.c(),O.m(k.parentNode,k)):O&&(O.d(1),O=null)},d(e){e&&d(t),j&&j.d(),$.d(),I&&I.d(),R&&R.d(),e&&d(x),O&&O.d(e),e&&d(k),S=!1,C()}}}function Jy(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].banner)||m(t,"src",n),m(t,"alt","Profile banner"),m(t,"class","profile-banner svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].banner)&&m(t,"src",n)},d(e){e&&d(t)}}}function Gy(t){let n;return{c(){n=h("div"),n.textContent="👤",m(n,"class","profile-avatar-placeholder overlap svelte-d3wb0j")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Zy(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||m(t,"src",n),m(t,"alt","User avatar"),m(t,"class","profile-avatar overlap svelte-d3wb0j")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&m(t,"src",n)},d(e){e&&d(t)}}}function Yy(e){let t,n,r=e[3].nip05+"";return{c(){t=h("span"),n=p(r),m(t,"class","profile-nip05-inline svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&E(n,r)},d(e){e&&d(t)}}}function Qy(e){let t,n;return{c(){t=h("div"),n=h("p"),m(n,"class","profile-about svelte-d3wb0j"),m(t,"class","about-card svelte-d3wb0j")},m(r,o){u(r,t,o),c(t,n),n.innerHTML=e[34]},p(e,t){8&t[1]&&(n.innerHTML=e[34])},d(e){e&&d(t)}}}function Xy(e){let t,n,r,o,i,s,a=e[80](),l=[];for(let t=0;t<a.length;t+=1)l[t]=eg(mp(e,a,t));return{c(){t=h("div"),n=h("h3"),n.textContent="View as Role",r=y(),o=h("p"),o.textContent="See the interface as it appears for different\n permission levels:",i=y(),s=h("div");for(let e=0;e<l.length;e+=1)l[e].c();m(n,"class","svelte-d3wb0j"),m(o,"class","svelte-d3wb0j"),m(s,"class","radio-group svelte-d3wb0j"),m(t,"class","view-as-section svelte-d3wb0j")},m(e,a){u(e,t,a),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s);for(let e=0;e<l.length;e+=1)l[e]&&l[e].m(s,null)},p(e,t){if(1040&t[0]|393216&t[2]){let n;for(a=e[80](),n=0;n<a.length;n+=1){const r=mp(e,a,n);l[n]?l[n].p(r,t):(l[n]=eg(r),l[n].c(),l[n].m(s,null))}for(;n<l.length;n+=1)l[n].d(1);l.length=a.length}},d(e){e&&d(t),f(l,e)}}}function eg(e){let t,n,r,o,i,s,a,l,f,g=e[150].charAt(0).toUpperCase()+e[150].slice(1)+"",v=e[150]===e[4]?" (Default)":"";function b(){return e[113](e[150])}return{c(){t=h("label"),n=h("input"),o=y(),i=p(g),s=p(v),a=y(),m(n,"type","radio"),m(n,"name","viewAsRole"),n.value=e[150],n.checked=r=e[10]===e[150],m(n,"class","svelte-d3wb0j"),m(t,"class","radio-label svelte-d3wb0j")},m(e,r){u(e,t,r),c(t,n),c(t,o),c(t,i),c(t,s),c(t,a),l||(f=w(n,"change",b),l=!0)},p(t,o){e=t,1024&o[0]&&r!==(r=e[10]===e[150])&&(n.checked=r),16&o[0]&&v!==(v=e[150]===e[4]?" (Default)":"")&&E(s,v)},d(e){e&&d(t),l=!1,f()}}}function tg(e){let t,n,o,i,s,l,g,v,b,x,k,C,A,j,T,_,$,R,P,B,N,L,U,F,M,D,H,Z,Y=e[0]?"☀️":"🌙";function Q(e,t){return e[15]?_p:Tp}let X=Q(e),ee=X(e);function te(e,t){return e[1]?Rp:Ip}let ne=te(e),re=ne(e),oe=e[11],ie=[];for(let t=0;t<oe.length;t+=1)ie[t]=Np(jp(e,oe,t));const se=[Kp,zp,qp,Hp,Dp,Mp,Fp,Up,Lp],ae=[];function le(e,t){return 96&t[0]&&(P=null),"export"===e[5]?0:"import"===e[5]?1:"events"===e[5]?2:"compose"===e[5]?3:"managed-acl"===e[5]?4:"sprocket"===e[5]?5:"recovery"===e[5]?6:(null==P&&(P=!!e[6].some(e[86])),P?7:8)}B=le(e,[-1,-1,-1,-1,-1,-1]),N=ae[B]=se[B](e);let ce=e[14]&&Ky(e);function ue(t){e[115](t)}let de={isDarkTheme:e[0]};return void 0!==e[12]&&(de.showModal=e[12]),F=new Ch({props:de}),I.push(()=>function(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}(F,"showModal",ue)),F.$on("login",e[59]),F.$on("close",e[61]),{c(){t=h("header"),n=h("div"),o=h("img"),s=y(),ee.c(),l=y(),g=h("button"),g.textContent="🔍",v=y(),b=h("button"),x=p(Y),k=y(),re.c(),C=y(),A=h("div"),j=h("aside"),T=h("div"),_=h("div");for(let e=0;e<ie.length;e+=1)ie[e].c();$=y(),R=h("main"),N.c(),L=y(),ce&&ce.c(),U=y(),V(F.$$.fragment),a(o.src,i="/orly.png")||m(o,"src","/orly.png"),m(o,"alt","ORLY Logo"),m(o,"class","logo svelte-d3wb0j"),m(g,"class","search-btn svelte-d3wb0j"),m(b,"class","theme-toggle-btn svelte-d3wb0j"),m(n,"class","header-content svelte-d3wb0j"),m(t,"class","main-header svelte-d3wb0j"),S(t,"dark-theme",e[0]),m(_,"class","tabs svelte-d3wb0j"),m(T,"class","sidebar-content svelte-d3wb0j"),m(j,"class","sidebar svelte-d3wb0j"),S(j,"dark-theme",e[0]),m(R,"class","main-content svelte-d3wb0j"),m(A,"class","app-container svelte-d3wb0j"),S(A,"dark-theme",e[0])},m(r,i){u(r,t,i),c(t,n),c(n,o),c(n,s),ee.m(n,null),c(n,l),c(n,g),c(n,v),c(n,b),c(b,x),c(n,k),re.m(n,null),u(r,C,i),u(r,A,i),c(A,j),c(j,T),c(T,_);for(let e=0;e<ie.length;e+=1)ie[e]&&ie[e].m(_,null);c(A,$),c(A,R),ae[B].m(R,null),u(r,L,i),ce&&ce.m(r,i),u(r,U,i),J(F,r,i),D=!0,H||(Z=[w(g,"click",e[64]),w(b,"click",e[57])],H=!0)},p(e,r){if(X===(X=Q(e))&&ee?ee.p(e,r):(ee.d(1),ee=X(e),ee&&(ee.c(),ee.m(n,l))),(!D||1&r[0])&&Y!==(Y=e[0]?"☀️":"🌙")&&E(x,Y),ne===(ne=te(e))&&re?re.p(e,r):(re.d(1),re=ne(e),re&&(re.c(),re.m(n,null))),(!D||1&r[0])&&S(t,"dark-theme",e[0]),2080&r[0]|33554432&r[1]|16&r[2]){let t;for(oe=e[11],t=0;t<oe.length;t+=1){const n=jp(e,oe,t);ie[t]?ie[t].p(n,r):(ie[t]=Np(n),ie[t].c(),ie[t].m(_,null))}for(;t<ie.length;t+=1)ie[t].d(1);ie.length=oe.length}(!D||1&r[0])&&S(j,"dark-theme",e[0]);let o=B;B=le(e,r),B===o?ae[B].p(e,r):(q(),W(ae[o],1,1,()=>{ae[o]=null}),z(),N=ae[B],N?N.p(e,r):(N=ae[B]=se[B](e),N.c()),K(N,1),N.m(R,null)),(!D||1&r[0])&&S(A,"dark-theme",e[0]),e[14]?ce?ce.p(e,r):(ce=Ky(e),ce.c(),ce.m(U.parentNode,U)):ce&&(ce.d(1),ce=null);const i={};var s;1&r[0]&&(i.isDarkTheme=e[0]),!M&&4096&r[0]&&(M=!0,i.showModal=e[12],s=()=>M=!1,O.push(s)),F.$set(i)},i(e){D||(K(N),K(F.$$.fragment,e),D=!0)},o(e){W(N),W(F.$$.fragment,e),D=!1},d(e){e&&d(t),ee.d(),re.d(),e&&d(C),e&&d(A),f(ie,e),ae[B].d(),e&&d(L),ce&&ce.d(e),e&&d(U),G(F,e),H=!1,r(Z)}}}function ng(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function rg(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function og(e){return e?new Date(1e3*e).toLocaleString():""}async function ig(e,t){try{const n=JSON.stringify(e);await navigator.clipboard.writeText(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(n){console.error("Failed to copy to clipboard:",n);try{const n=document.createElement("textarea");n.value=JSON.stringify(e),document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(e){console.error("Fallback copy also failed:",e),alert("Failed to copy to clipboard. Please copy manually.")}}}const sg=e=>"e"===e[0];function ag(e,t,n){let r,o,i,s,a;"undefined"!=typeof window&&(window.debugIndexedDB=gh);let l=!1,c=!1,u=!1,d="",f="",h=null,p="",y=null,g=!1,w=localStorage.getItem("selectedTab")||"export",v=!1,m="",E=[],x=[],k=null,S=new Set,C=!1,A=!0,j=null,T="",$=new Map,I=[],R=0;const O=3e5;let P=!1,B=[],N=!0,L=null,U="",F=null,M=[],D=!1,H="",q="info",z=!1,K=null,W="",V="",J=null,G="",Z=[],Y=!1,Q=!0,X=null;const ee=[{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)"}],te={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"};function ne(e){S.has(e)?S.delete(e):S.add(e),n(18,S)}async function re(){console.log("Toggle changed, showOnlyMyEvents:",P);const e=P&&u&&d?[d]:null;await Se(!0,e)}async function oe(e){if(!u)return void alert("Please log in first");const t=x.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===p||"owner"===p||"write"===p&&t.pubkey&&t.pubkey===d){if(confirm("Are you sure you want to delete this event?"))try{if(!y)throw new Error("Signer not available for signing");const r={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",r),console.log("User pubkey:",d),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const o=await y.signEvent(r);console.log("Signed delete event:",o),console.log("Signed delete event pubkey:",o.pubkey),console.log("Delete event tags:",o.tags);const i=`wss://${window.location.host}`;try{const e=await vp(i,o,y,d);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 s=t.pubkey&&t.pubkey===d;if(s){const t=await nh.publish(o);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 hh(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 ph(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===d);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(7,x=x.filter(t=>t.id!==e)),B=B.filter(t=>t.id!==e),I=I.filter(t=>t.id!==e);for(const[t,n]of $)n.events&&(n.events=n.events.filter(t=>t.id!==e),$.set(t,n));ae(),console.log("Reloading events to show delete event...");const r=P&&u&&d?[d]:null;await Se(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`wss://${window.location.host}/`,r=new th;await r.connectToRelay(t);const i=await r.publish(o);if(console.log("Delete event published to local relay only:",i),!(i.success&&i.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await hh(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${i.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 ph(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===d);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(7,x=x.filter(t=>t.id!==e)),B=B.filter(t=>t.id!==e),I=I.filter(t=>t.id!==e);for(const[t,n]of $)n.events&&(n.events=n.events.filter(t=>t.id!==e),$.set(t,n));ae(),console.log("Reloading events to show delete event...");const t=P&&u&&d?[d]:null;await Se(!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 ie(){const e=G?parseInt(G):J;if(null==e||isNaN(e))console.log("No valid kind to load, kindToUse:",e);else if(u){console.log("Loading recovery events for kind:",e,"user:",d),n(32,Y=!0);try{const t=[{kinds:[e],authors:[d],limit:100}];X&&(t[0].until=X),console.log("Recovery filters:",t);const r=await async function(e,t={}){const{timeout:n=3e4,cacheFirst:r=!0,cacheOnly:o=!1}=t;let i=[];if(r||o)try{if(i=await ch(e),console.log(`Found ${i.length} events in cache`),o||i.length>0)return i}catch(e){console.warn("Failed to query cache",e)}if(!o){const t=await fh(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return i}(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",r.length),console.log("Recovery events kinds:",r.map(e=>e.kind)),n(31,Z=X?[...Z,...r]:r),r.length>0?(X=Math.min(...r.map(e=>e.created_at)),n(33,Q=100===r.length)):n(33,Q=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(32,Y=!1)}}else console.log("Not logged in, cannot load recovery events")}async function se(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`wss://${window.location.host}/`;console.log("Reposting event to local relay:",t,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(y){const e=await y.sign(r);console.log("Signed event for repost:",e);const o=await nh.publish(e,[t]);console.log("Repost publish result:",o),o.success&&o.okCount>0?(alert("Event reposted successfully!"),n(33,Q=!1),await ie()):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)}}if("undefined"!=typeof localStorage){const e=localStorage.getItem("isDarkTheme");null!==e&&(l=JSON.parse(e));const t=localStorage.getItem("nostr_auth_method"),r=localStorage.getItem("nostr_pubkey");t&&r&&(u=!0,d=r,f=t,"extension"===t&&window.nostr&&(y=window.nostr),Ee(),xe()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&pe.some(e=>e.id===r.selectedTab)&&n(5,w=r.selectedTab),r.expandedEvents&&n(18,S=new Set(r.expandedEvents)),r.globalEventsCache&&(I=r.globalEventsCache),r.globalCacheTimestamp&&(R=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&n(20,A=r.hasMoreEvents),r.oldestEventTimestamp&&(j=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(N=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(L=r.oldestMyEventTimestamp),I.length>0&&((e=R)&&Date.now()-e<O)&&n(7,x=I)}}catch(e){console.error("Failed to load persistent state:",e)}var e}(),async function(){try{const e=await fetch("/api/sprocket/config",{method:"GET",headers:{"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(82,z=t.enabled)}}catch(e){console.error("Error loading sprocket config:",e)}}()}function ae(){if("undefined"==typeof localStorage)return;const e={selectedTab:w,expandedEvents:Array.from(S),globalEventsCache:I,globalCacheTimestamp:R,hasMoreEvents:A,oldestEventTimestamp:j};localStorage.setItem("app_state",JSON.stringify(e))}function le(e){I=e.sort((e,t)=>t.created_at-e.created_at),R=Date.now(),ae()}async function ce(){if(u&&"owner"===p&&z)try{n(24,D=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(22,F=await e.json()):he("Failed to load sprocket status","error")}catch(e){he(`Error loading sprocket status: ${e.message}`,"error")}finally{n(24,D=!1)}}async function ue(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(23,M=await e.json()):he("Failed to load versions","error")}catch(e){he(`Error loading versions: ${e.message}`,"error")}finally{n(24,D=!1)}}async function de(e){u&&"owner"===p&&(n(21,U=e.content),he(`Loaded version: ${e.name}`,"success"))}async function fe(e){if(u&&"owner"===p&&confirm(`Are you sure you want to delete version ${e}?`))try{n(24,D=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)he(`Version ${e} deleted successfully`,"success"),await ue();else{he(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){he(`Error deleting version: ${e.message}`,"error")}finally{n(24,D=!1)}}function he(e,t="info"){n(25,H=e),n(26,q=t),setTimeout(()=>{n(25,H="")},5e3)}const pe=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0}];function ye(e){n(5,w=e),"sprocket"===e&&u&&"owner"===p&&z&&(ce(),ue()),ae()}function ge(){n(14,g=!1)}function we(e){n(6,E=E.filter(t=>t.id!==e)),$.delete(e),w===e&&n(5,w="export")}async function ve(e,t,n=!0){const r=$.get(e);if(r&&!r.isLoading){r.isLoading=!0,$.set(e,r);try{const o={limit:n?100:200,until:n?Math.floor(Date.now()/1e3):r.oldestTimestamp};console.log("Loading search results for query:",t,"with options:",o);const i=await async function(e,t={}){const{limit:n=100,since:r=null,until:o=null,kinds:i=null}=t,s=[{search:e}];return r&&(s[0].since=r),o&&(s[0].until=o),i&&(s[0].kinds=i),n&&(s[0].limit=n),await fh(s,{timeout:3e4})}(t,o);if(console.log("Received search results:",i.length,"events"),r.events=n?i.sort((e,t)=>t.created_at-e.created_at):[...r.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!r.oldestTimestamp||e<r.oldestTimestamp)&&(r.oldestTimestamp=e)}r.hasMore=i.length===(n?100:200),r.isLoading=!1,$.set(e,r)}catch(t){console.error("Failed to load search results:",t),r.isLoading=!1,$.set(e,r),alert("Failed to load search results: "+t.message)}}}function me(e,t){const{scrollTop:n,scrollHeight:r,clientHeight:o}=e.target;if(r-n-o<100){const e=$.get(t);e&&!e.isLoading&&e.hasMore&&async function(e){const t=E.find(t=>t.id===e);t&&await ve(e,t.query,!1)}(t)}}async function be(){if(u&&d&&!h)try{console.log("Auto-fetching profile for:",d),await yh(),n(3,h=await dh(d)),console.log("Profile auto-loaded:",h)}catch(e){console.error("Failed to auto-load profile:",e)}}async function Ee(){if(u&&d)try{const e=await fetch(`/api/permissions/${d}`);if(e.ok){const t=await e.json();n(4,p=t.permission||""),console.log("User role loaded:",p),console.log("Is owner?","owner"===p)}else console.error("Failed to fetch user role:",e.status),n(4,p="")}catch(e){console.error("Error fetching user role:",e),n(4,p="")}else n(4,p="")}async function xe(){try{const e=await fetch("/api/acl-mode");if(e.ok){const t=await e.json();n(9,W=t.acl_mode||""),console.log("ACL mode loaded:",W)}else console.error("Failed to fetch ACL mode:",e.status),n(9,W="")}catch(e){console.error("Error fetching ACL mode:",e),n(9,W="")}}async function ke(e=[]){if(u)if(0!==e.length||"admin"===a||"owner"===a)try{const t=await Ae("/api/export","POST"),n=await fetch("/api/export",{method:"POST",headers:{Authorization:t,"Content-Type":"application/json"},body:JSON.stringify({pubkeys:e})});if(!n.ok)throw new Error(`Export failed: ${n.status} ${n.statusText}`);const r=await n.blob(),o=window.URL.createObjectURL(r),i=document.createElement("a");i.href=o;const s=n.headers.get("Content-Disposition");let a="events.jsonl";if(s){const e=s.match(/filename="([^"]+)"/);e&&(a=e[1])}i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(o)}catch(e){console.error("Export failed:",e),alert("Export failed: "+e.message)}else alert("Admin or owner permission required to export all events");else alert("Please log in first")}async function Se(e=!1,t=null){if(!u||"write"!==p&&"admin"!==p&&"owner"!==p)alert("Write, admin, or owner permission required");else if(!C){n(19,C=!0),e&&(j=null);try{console.log("Loading events with authors filter:",t,"including delete events");const r=await async function(e={}){const{limit:t=100,since:n=null,until:r=null,authors:o=null,kinds:i=null,...s}=e,a=[{...s}];return n&&(a[0].since=n),r&&(a[0].until=r),o&&(a[0].authors=o),i&&(a[0].kinds=i),t&&(a[0].limit=t),await fh(a,{timeout:3e4})}({limit:e?100:200,until:e?Math.floor(Date.now()/1e3):j,authors:t});if(console.log("Received events:",r.length,"events"),t&&r.length>0){const e=r.filter(e=>e.pubkey&&e.pubkey!==d);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",r.length)}if(e?(n(7,x=r.sort((e,t)=>t.created_at-e.created_at)),le(r)):(n(7,x=[...x,...r].sort((e,t)=>t.created_at-e.created_at)),le(x)),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!j||e<j)&&(j=e)}n(20,A=r.length===(e?1e3:200)),e&&A&&setTimeout(()=>{if("events"===w){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Ce()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(19,C=!1)}}}async function Ce(){await Se(!1)}async function Ae(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+e],["method",t.toUpperCase()]],content:"",pubkey:d};let r;if(y&&"extension"===f)try{r=await y.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return`Nostr ${btoa(o)}`}async function je(e,t){if(!u||!d)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",window.location.origin+t],["method",e.toUpperCase()]],content:"",pubkey:d};let r;if(y&&"extension"===f)try{r=await y.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==f)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return btoa(o)}function Te(e){n(81,T=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",a)}T=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(390&e.$$.dirty[0]&&n(35,r=(P&&u&&d?x.filter(e=>e.pubkey&&e.pubkey===d):x).sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(34,o=h?.about?(t=h.about,String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")).replace(/\n{2,}/g,"<br>"):""),16&e.$$.dirty[0]|524288&e.$$.dirty[2]&&n(10,a=T&&""!==T?T:p),1554&e.$$.dirty[0]|1572864&e.$$.dirty[2]&&n(83,i=pe.filter(e=>{const t=a;return!(e.requiresAdmin&&(!u||"admin"!==t&&"owner"!==t))&&(!(e.requiresOwner&&(!u||"owner"!==t))&&(!(e.requiresWrite&&(!u||"read"===t))&&(!("sprocket"===e.id&&!z)&&(("managed-acl"!==e.id||"managed"===W)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:u,userRole:p,viewAsRole:T,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0)))))})),64&e.$$.dirty[0]|2097152&e.$$.dirty[2]&&n(11,s=[...i,...E]),2578&e.$$.dirty[0]|2097152&e.$$.dirty[2]&&console.log("Tabs debug:",{isLoggedIn:u,userRole:p,aclMode:W,filteredBaseTabs:i.map(e=>e.id),allTabs:s.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(l?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&u&&d&&!h&&be(),438&e.$$.dirty[0]&&"events"===w&&u&&("write"===p||"admin"===p||"owner"===p)&&0===x.length){Se(!0,P&&d?[d]:null)}32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",w)},[l,u,d,h,p,w,E,x,P,W,a,s,c,y,g,v,m,k,S,C,A,U,F,M,D,H,q,K,V,J,G,Z,Y,Q,o,r,$,ee,function(e){return te[e]||`Kind ${e}`},ne,re,oe,ie,se,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",J),null!=J?(n(30,G=""),n(31,Z=[]),X=null,n(33,Q=!0),ie()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",G);const e=parseInt(G);""!==G&&!isNaN(e)&&e>=0&&(n(29,J=null),n(31,Z=[]),X=null,n(33,Q=!0),ie())},function(e){const t=Z.filter(t=>t.kind===e.kind&&t.pubkey===e.pubkey),n=Math.max(...t.map(e=>e.created_at));return e.created_at===n},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await je("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(21,U=t.script_content||""),n(22,F=t),he("Script loaded successfully","success")}else he("Failed to load script","error")}catch(e){he(`Error loading script: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:U});if(e.ok)he("Script saved and updated successfully","success"),await ce(),await ue();else{he(`Failed to save script: ${await e.text()}`,"error")}}catch(e){he(`Error saving script: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p)try{n(24,D=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)he("Sprocket restarted successfully","success"),await ce();else{he(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){he(`Error restarting sprocket: ${e.message}`,"error")}finally{n(24,D=!1)}},async function(){if(u&&"owner"===p&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(24,D=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(21,U=""),he("Sprocket script deleted successfully","success"),await ce(),await ue();else{he(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){he(`Error deleting script: ${e.message}`,"error")}finally{n(24,D=!1)}},ue,de,fe,function(e){n(27,K=e.target.files[0])},async function(){if(u&&"owner"===p&&K)try{n(24,D=!0);const e=await K.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await je("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(21,U=e),he("Script uploaded and updated successfully","success"),await ce(),await ue();else{he(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){he(`Error uploading script: ${e.message}`,"error")}finally{n(24,D=!1),n(27,K=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},ye,function(){n(0,l=!l),"undefined"!=typeof localStorage&&localStorage.setItem("isDarkTheme",JSON.stringify(l))},function(){u||n(12,c=!0)},async function(e){const{method:t,pubkey:r,privateKey:o,signer:i}=e.detail;n(1,u=!0),n(2,d=r),f=t,n(13,y=i),n(12,c=!1);try{if(await yh(),"extension"===t&&i)nh.setSigner(i);else if("nsec"===t&&o){const e=new Dd(o);nh.setSigner(e)}n(3,h=await dh(r)),console.log("Profile loaded:",h)}catch(e){console.error("Failed to load profile:",e)}await Ee(),await xe()},function(){n(1,u=!1),n(2,d=""),f="",n(3,h=null),n(4,p=""),n(13,y=null),n(14,g=!1),B=[],n(7,x=[]),I=[],R=0,ae(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(12,c=!1)},function(){n(14,g=!0)},ge,function(){n(15,v=!v),v||n(16,m="")},function(e){"Enter"===e.key&&m.trim()?(!function(e){const t=`search-${Date.now()}`,r={id:t,icon:"🔍",label:e,isSearchTab:!0,query:e};n(6,E=[...E,r]),n(5,w=t),$.set(t,{events:[],isLoading:!1,hasMore:!0,oldestTimestamp:null}),ve(t,e)}(m.trim()),n(16,m=""),n(15,v=!1)):"Escape"===e.key&&(n(15,v=!1),n(16,m=""))},we,ve,me,be,async function(){await ke([])},async function(){await ke([d])},function(e){n(17,k=e.target.files[0])},async function(){if(!u||"admin"!==p&&"owner"!==p)alert("Admin or owner permission required");else if(k)try{const e=await Ae("/api/import","POST"),t=new FormData;t.append("file",k);const r=await fetch("/api/import",{method:"POST",headers:{Authorization:e},body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();alert("Import started successfully"),n(17,k=null),document.getElementById("import-file").value=""}catch(e){console.error("Import failed:",e),alert("Import failed: "+e.message)}else alert("Please select a file")},Se,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&Ce()},function(){try{if(!V.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(V);n(28,V=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!V.trim())return void alert("Please enter an event to sign");if(!u||!d)return void alert("Please log in to sign events");if(!y)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(V);e.pubkey=d,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await y.signEvent(e);n(28,V=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(){try{if(!V.trim())return void alert("Please enter an event to publish");if(!u)return void alert("Please log in to publish events");if(!y)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(V);if(!e.id||!e.sig)return void alert('Event must be signed before publishing. Please click "Sign" first.');const t=`wss://${window.location.host}`,n=await vp(t,e,y,d);n.success?alert("Event published successfully to ORLY relay!"):alert(`Event publishing failed: ${n.reason||"Unknown error"}`)}catch(e){console.error("Error publishing event:",e),alert("Error publishing event: "+e.message)}},Te,function(){const e=["owner","admin","write","read"],t=e.indexOf(p);return-1===t?["read"]:e.slice(t)},T,z,i,function(t){_.call(this,e,t)},function(t){_.call(this,e,t)},e=>e.id===w,function(){m=this.value,n(16,m)},e=>we(e.id),(e,t)=>"Enter"===t.key&&we(e.id),e=>ye(e.id),e=>oe(e.id),e=>ne(e.id),(e,t)=>"Enter"===t.key&&ne(e.id),(e,t)=>ig(e,t),function(){P=this.checked,n(8,P)},()=>re(),()=>{Se(!1,P&&d?[d]:null)},()=>{Se(!0,P&&d?[d]:null)},function(){V=this.value,n(28,V)},function(){U=this.value,n(21,U)},e=>de(e),e=>fe(e.name),function(){J=function(e){const t=e.querySelector(":checked");return t&&t.__value}(this),n(29,J),n(37,ee)},function(){G=b(this.value),n(30,G)},e=>se(e),(e,t)=>ig(e,t),e=>ve(e.id,e.query,!0),e=>oe(e.id),e=>ne(e.id),(e,t)=>"Enter"===t.key&&ne(e.id),(e,t)=>ig(e,t),(e,t)=>me(t,e.id),e=>Te(e===p?"":e),e=>"Escape"===e.key&&ge(),function(e){c=e,n(12,c)}]}return new class extends Q{constructor(e){super(),Y(this,e,ag,tg,i,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); |