|
|
*/function Jh(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(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"==typeof SuppressedError&&SuppressedError;class Vh{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then(()=>new Promise(e)),new Promise(t=>{e=t})}dispatch(e){return Jh(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}var Yh;const zh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Wh=null!==(Yh=zh.Buffer)&&void 0!==Yh?Yh:null,Zh=zh.TextEncoder?new zh.TextEncoder:null;function Xh(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function ep(e,t){const n=t.length>>1;for(let r=0;r<n;r++){const n=r<<1;e[r]=Xh(t.charCodeAt(n),t.charCodeAt(n+1))}}const tp="a".charCodeAt(0)-10,np="0".charCodeAt(0);function rp(e,t,n){let r=0;for(let i=0;i<n;i++){let n=t[i]>>>4;e[r++]=n>9?n+tp:n+np,n=15&t[i],e[r++]=n>9?n+tp:n+np}return String.fromCharCode.apply(null,e)}const ip=null!==Wh?e=>{if("string"==typeof e){const t=Wh.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(Wh.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return Zh.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},op="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",sp=new Uint8Array(256);for(let e=0;e<64;e++)sp[op.charCodeAt(e)]=e;function ap(e,t=!0){const n=e.length,r=n%3,i=[],o=n-r;for(let t=0;t<o;t+=3){const n=(e[t]<<16&16711680)+(e[t+1]<<8&65280)+(255&e[t+2]),r=op.charAt(n>>18&63)+op.charAt(n>>12&63)+op.charAt(n>>6&63)+op.charAt(63&n);i.push(r)}if(1===r){const r=e[n-1],o=op.charAt(r>>2),s=op.charAt(r<<4&63);i.push(`${o}${s}`),t&&i.push("==")}else if(2===r){const r=(e[n-2]<<8)+e[n-1],o=op.charAt(r>>10),s=op.charAt(r>>4&63),a=op.charAt(r<<2&63);i.push(`${o}${s}${a}`),t&&i.push("=")}return i.join("")}function lp(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,r=new Uint8Array(t);let i=0;for(let t=0;t<n;t+=4){const n=sp[e.charCodeAt(t)],o=sp[e.charCodeAt(t+1)],s=sp[e.charCodeAt(t+2)],a=sp[e.charCodeAt(t+3)];r[i]=n<<2|o>>4,i+=1,r[i]=(15&o)<<4|s>>2,i+=1,r[i]=(3&s)<<6|63&a,i+=1}return r}const cp=16384,up=new Vh,dp=new Map;function fp(e,t){return Jh(this,void 0,void 0,function*(){let n=null,r=null,i=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const o=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),s=up.dispatch(()=>Jh(this,void 0,void 0,function*(){if(!dp.has(e.name)){const t=lp(e.data),n=WebAssembly.compile(t);dp.set(e.name,n)}const t=yield dp.get(e.name);n=yield WebAssembly.instantiate(t,{})})),a=(e=null)=>{i=!0,n.exports.Hash_Init(e)},l=e=>{if(!i)throw new Error("update() called before init()");(e=>{let t=0;for(;t<e.length;){const i=e.subarray(t,t+cp);t+=i.length,r.set(i),n.exports.Hash_Update(i.length)}})(ip(e))},c=new Uint8Array(2*t),u=(e,o=null)=>{if(!i)throw new Error("digest() called before init()");return i=!1,n.exports.Hash_Final(o),"binary"===e?r.slice(0,t):rp(c,r,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength<cp;let f=d;switch(e.name){case"argon2":case"scrypt":f=()=>!0;break;case"blake2b":case"blake2s":f=(e,t)=>t<=512&&d(e);break;case"blake3":f=(e,t)=>0===t&&d(e);break;case"xxhash64":case"xxhash3":case"xxhash128":case"crc64":f=()=>!1}return yield(()=>Jh(this,void 0,void 0,function*(){n||(yield s);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;r=new Uint8Array(t,e,cp)}))(),{getMemory:()=>r,writeMemory:(e,t=0)=>{r.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),i=n.exports.memory.buffer;r=new Uint8Array(i,t,e)},init:a,update:l,digest:u,save:()=>{if(!i)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),r=o(),s=n.exports.memory.buffer,a=new Uint8Array(s,t,r),l=new Uint8Array(4+r);return ep(l,e.hash),l.set(a,4),l},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const r=n.exports.Hash_GetState(),s=o(),a=4+s,l=n.exports.memory.buffer;if(t.length!==a)throw new Error(`Bad state length (expected ${a} bytes, got ${t.length})`);if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n<t.length;n++){const r=n<<1;if(t[n]!==Xh(e.charCodeAt(r),e.charCodeAt(r+1)))return!1}return!0}(e.hash,t.subarray(0,4)))throw new Error("This state was written by an incompatible hash implementation");const c=t.subarray(4);new Uint8Array(l,r,s).set(c),i=!0},calculate:(e,i=null,o=null)=>{if(!f(e,i))return a(i),l(e),u("hex",o);const s=ip(e);return r.set(s),n.exports.Hash_Calculate(s.length,i,o),rp(c,r,t)},hashLength:t}})}new Vh;var hp={name:"argon2",data:"AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGFNwOQCUEAIAIpA4gBIAEpA4gBhTcDmAlBACACKQOQASABKQOQAYU3A6AJQQAgAikDmAEgASkDmAGFNwOoCUEAIAIpA6ABIAEpA6ABhTcDsAlBACACKQOoASABKQOoAYU3A7gJQQAgAikDsAEgASkDsAGFNwPACUEAIAIpA7gBIAEpA7gBhTcDyAlBACACKQPAASABKQPAAYU3A9AJQQAgAikDyAEgASkDyAGFNwPYCUEAIAIpA9ABIAEpA9ABhTcD4AlBACACKQPYASABKQPYAYU3A+gJQQAgAikD4AEgASkD4AGFNwPwCUEAIAIpA+gBIAEpA+gBhTcD+AlBACACKQPwASABKQPwAYU3A4AKQQAgAikD+AEgASkD+AGFNwOICkEAIAIpA4ACIAEpA4AChTcDkApBACACKQOIAiABKQOIAoU3A5gKQQAgAikDkAIgASkDkAKFNwOgCkEAIAIpA5gCIAEpA5gChTcDqApBACACKQOgAiABKQOgAoU3A7AKQQAgAikDqAIgASkDqAKFNwO4CkEAIAIpA7ACIAEpA7AChTcDwApBACACKQO4AiABKQO4AoU3A8gKQQAgAikDwAIgASkDwAKFNwPQCkEAIAIpA8gCIAEpA8gChTcD2ApBACACKQPQAiABKQPQAoU3A+AKQQAgAikD2AIgASkD2AKFNwPoCkEAIAIpA+ACIAEpA+AChTcD8ApBACACKQPoAiABKQPoAoU3A/gKQQAgAikD8AIgASkD8AKFNwOAC0EAIAIpA/gCIAEpA/gChTcDiAtBACACKQOAAyABKQOAA4U3A5ALQQAgAikDiAMgASkDiAOFNwOYC0EAIAIpA5ADIAEpA5ADhTcDoAtBACACKQOYAyABKQOYA4U3A6gLQQAgAikDoAMgASkDoAOFNwOwC0EAIAIpA6gDIAEpA6gDhTcDuAtBACACKQOwAyABKQOwA4U3A8ALQQAgAikDuAMgASkDuAOFNwPIC0EAIAIpA8ADIAEpA8ADhTcD0AtBACACKQPIAyABKQPIA4U3A9gLQQAgAikD0AMgASkD0AOFNwPgC0EAIAIpA9gDIAEpA9gDhTcD6AtBACACKQPgAyABKQPgA4U3A/ALQQAgAikD6AMgASkD6AOFNwP4C0EAIAIpA/ADIAEpA/ADhTcDgAxBACACKQP4AyABKQP4A4U3A4gMQQAgAikDgAQgASkDgASFNwOQDEEAIAIpA4gEIAEpA4gEhTcDmAxBACACKQOQBCABKQOQBIU3A6AMQQAgAikDmAQgASkDmASFNwOoDEEAIAIpA6AEIAEpA6AEhTcDsAxBACACKQOoBCABKQOoBIU3A7gMQQAgAikDsAQgASkDsASFNwPADEEAIAIpA7gEIAEpA7gEhTcDyAxBACACKQPABCABKQPABIU3A9AMQQAgAikDyAQgASkDyASFNwPYDEEAIAIpA9AEIAEpA9AEhTcD4AxBACACKQPYBCABKQPYBIU3A+gMQQAgAikD4AQgASkD4ASFNwPwDEEAIAIpA+gEIAEpA+gEhTcD+AxBACACKQPwBCABKQPwBIU3A4ANQQAgAikD+AQgASkD+ASFNwOIDUEAIAIpA4AFIAEpA4AFhTcDkA1BACACKQOIBSABKQOIBYU3A5gNQQAgAikDkAUgASkDkAWFNwOgDUEAIAIpA5gFIAEpA5gFhTcDqA1BACACKQOgBSABKQOgBYU3A7ANQQAgAikDqAUgASkDqAWFNwO4DUEAIAIpA7AFIAEpA7AFhTcDwA1BACACKQO4BSABKQO4BYU3A8gNQQAgAikDwAUgASkDwAWFNwPQDUEAIAIpA8gFIAEpA8gFhTcD2A1BACACKQPQBSABKQPQBYU3A+ANQQAgAikD2AUgASkD2AWFNwPoDUEAIAIpA+AFIAEpA+AFhTcD8A1BACACKQPoBSABKQPoBYU3A/gNQQAgAikD8AUgASkD8AWFNwOADkEAIAIpA/gFIAEpA/gFhTcDiA5BACACKQOABiABKQOABoU3A5AOQQAgAikDiAYgASkDiAaFNwOYDkEAIAIpA5AGIAEpA5AGhTcDoA5BACACKQOYBiABKQOYBoU3A6gOQQAgAikDoAYgASkDoAaFNwOwDkEAIAIpA6gGIAEpA6gGhTcDuA5BACACKQOwBiABKQOwBoU3A8AOQQAgAikDuAYgASkDuAaFNwPIDkEAIAIpA8AGIAEpA8AGhTcD0A5BACACKQPIBiABKQPIBoU3A9gOQQAgAikD0AYgASkD0AaFNwPgDkEAIAIpA9gGIAEpA9gGhTcD6A5BACACKQPgBiABKQPgBoU3A/AOQQAgAikD6AYgASkD6AaFNwP4DkEAIAIpA/AGIAEpA/AGhTcDgA9BACACKQP4BiABKQP4BoU3A4gPQQAgAikDgAcgASkDgAeFNwOQD0EAIAIpA4gHIAEpA4gHhTcDmA9BACACKQOQByABKQOQB4U3A6APQQAgAikDmAcgASkDmAeFNwOoD0EAIAIpA6AHIAEpA6AHhTcDsA9BACACKQOoByABKQOoB4U3A7gPQQAgAikDsAcgASkDsAeFNwPAD0EAIAIpA7gHIAEpA7gHhTcDyA9BACACKQPAByABKQPAB4U3A9APQQAgAikDyAcgASkDyAeFNwPYD0EAIAIpA9AHIAEpA9AHhTcD4A9BACACKQPYByABKQPYB4U3A+gPQQAgAikD4AcgASkD4AeFNwPwD0EAIAIpA+gHIAEpA+gHhTcD+A9BACACKQPwByABKQPwB4U3A4AQQQAgAikD+AcgASkD+AeFNwOIEEGQCEGYCEGgCEGoCEGwCEG4CEHACEHICEHQCEHYCEHgCEHoCEHwCEH4CEGACUGICRACQZAJQZgJQaAJQagJQbAJQbgJQcAJQcgJQdAJQdgJQeAJQegJQfAJQfgJQYAKQYgKEAJBkApBmApBoApBqApBsApBuApBwApByApB0ApB2ApB4ApB6ApB8ApB+ApBgAtBiAsQAkGQC0GYC0GgC0GoC0GwC0G4C0HAC0HIC0HQC0HYC0HgC0HoC0HwC0H4C0GADEGIDBACQZAMQZgMQaAMQagMQbAMQbgMQcAMQcgMQdAMQdgMQeAMQegMQfAMQfgMQYANQYgNEAJBkA1BmA1BoA1BqA1BsA1BuA1BwA1ByA1B0A1B2A1B4A1B6A1B8A1B+A1BgA5BiA4QAkGQDkGYDkGgDkGoDkGwDkG4DkHADkHIDkHQDkHYDkHgDkHoDkHwDkH4DkGAD0GIDxACQZAPQZgPQaAPQagPQbAPQbgPQcAPQcgPQdAPQdgPQeAPQegPQfAPQfgPQYAQQYgQEAJBkAhBmAhBkAlBmAlBkApBmApBkAtBmAtBkAxBmAxBkA1BmA1BkA5BmA5BkA9BmA8QAkGgCEGoCEGgCUGoCUGgCkGoCkGgC0GoC0GgDEGoDEGgDUGoDUGgDkGoDkGgD0GoDxACQbAIQbgIQbAJQbgJQbAKQbgKQbALQbgLQbAMQbgMQbANQbgNQbAOQbgOQbAPQbgPEAJBwAhByAhBwAlByAlBwApByApBwAtByAtBwAxByAxBwA1ByA1BwA5ByA5BwA9ByA8QAkHQCEHYCEHQCUHYCUHQCkHYCkHQC0HYC0HQDEHYDEHQDUHYDUHQDkHYDkHQD0HYDxACQeAIQegIQeAJQegJQeAKQegKQeALQegLQeAMQegMQeANQegNQeAOQegOQeAPQegPEAJB8AhB+AhB8AlB+AlB8ApB+ApB8AtB+AtB8AxB+AxB8A1B+A1B8A5B+A5B8A9B+A8QAkGACUGICUGACkGICkGAC0GIC0GADEGIDEGADUGIDUGADkGIDkGAD0GID0GAEEGIEBACAkACQCADRQ0AA0AgACAEaiIDIAIgBGoiBSkDACABIARqIgYpAwCFIARBkAhqKQMAhSADKQMAhTcDACADQQhqIgMgBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIUgAykDAIU3AwAgBEEQaiIEQYAIRw0ADAILC0EAIQQDQCAAIARqIgMgAiAEaiIFKQMAIAEgBGoiBikDAIUgBEGQCGopAwCFNwMAIANBCGogBUEIaikDACAGQQhqKQMAhSAEQZgIaikDAIU3AwAgBEEQaiIEQYAIRw0ACwsL5QcMBX8BfgR/An4BfwF+AX8Bfgd/AX4DfwF+AkBBACgCgAgiAiABQQp0aiIDKAIIIAFHDQAgAygCDCEEIAMoAgAhBUEAIAMoAhQiBq03A7gQQQAgBK0iBzcDsBBBACAFIAEgBUECdG4iCGwiCUECdK03A6gQAkACQAJAAkAgBEUNAEF/IQogBUUNASAIQQNsIQsgCEECdCIErSEMIAWtIQ0gBkF/akECSSEOQgAhDwNAQQAgDzcDkBAgD6chEEIAIRFBACEBA0BBACARNwOgECAPIBGEUCIDIA5xIRIgBkEBRiAPUCITIAZBAkYgEUICVHFxciEUQX8gAUEBakEDcSAIbEF/aiATGyEVIAEgEHIhFiABIAhsIRcgA0EBdCEYQgAhGQNAQQBCADcDwBBBACAZNwOYECAYIQECQCASRQ0AQQBCATcDwBBBkBhBkBBBkCBBABADQZAYQZAYQZAgQQAQA0ECIQELAkAgASAITw0AIAQgGaciGmwgF2ogAWohAwNAIANBACAEIAEbQQAgEVAiGxtqQX9qIRwCQAJAIBQNAEEAKAKACCICIBxBCnQiHGohCgwBCwJAIAFB/wBxIgINAEEAQQApA8AQQgF8NwPAEEGQGEGQEEGQIEEAEANBkBhBkBhBkCBBABADCyAcQQp0IRwgAkEDdEGQGGohCkEAKAKACCECCyACIANBCnRqIAIgHGogAiAKKQMAIh1CIIinIAVwIBogFhsiHCAEbCABIAFBACAZIBytUSIcGyIKIBsbIBdqIAogC2ogExsgAUUgHHJrIhsgFWqtIB1C/////w+DIh0gHX5CIIggG61+QiCIfSAMgqdqQQp0akEBEAMgA0EBaiEDIAggAUEBaiIBRw0ACwsgGUIBfCIZIA1SDQALIBFCAXwiEachASARQgRSDQALIA9CAXwiDyAHUg0AC0EAKAKACCECCyAJQQx0QYB4aiEXIAVBf2oiCkUNAgwBC0EAQgM3A6AQQQAgBEF/aq03A5AQQYB4IRcLIAIgF2ohGyAIQQx0IQhBACEcA0AgCCAcQQFqIhxsQYB4aiEEQQAhAQNAIBsgAWoiAyADKQMAIAIgBCABamopAwCFNwMAIANBCGoiAyADKQMAIAIgBCABQQhyamopAwCFNwMAIAFBCGohAyABQRBqIQEgA0H4B0kNAAsgHCAKRw0ACwsgAiAXaiEbQXghAQNAIAIgAWoiA0EIaiAbIAFqIgRBCGopAwA3AwAgA0EQaiAEQRBqKQMANwMAIANBGGogBEEYaikDADcDACADQSBqIARBIGopAwA3AwAgAUEgaiIBQfgHSQ0ACwsL",hash:"e4cdc523"},pp={name:"blake2b",data:"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",hash:"c6f286e6"};function gp(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function mp(e=512,t=null){if(gp(e))return Promise.reject(gp(e));let n=null,r=e;if(null!==t){if(n=ip(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));i=e,o=n.length,r=i|o<<16}var i,o;const s=e/8;return fp(pp,s).then(e=>{r>512&&e.writeMemory(n),e.init(r);const t={init:r>512?()=>(e.writeMemory(n),e.init(r),t):()=>(e.init(r),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:s};return t})}new Vh;const yp=new DataView(new ArrayBuffer(4));function wp(e){return yp.setInt32(0,e,!0),new Uint8Array(yp.buffer)}function vp(e,t,n){return Jh(this,void 0,void 0,function*(){if(n<=64){const e=yield mp(8*n);return e.update(wp(n)),e.update(t),e.digest("binary")}const r=Math.ceil(n/32)-2,i=new Uint8Array(n);e.init(),e.update(wp(n)),e.update(t);let o=e.digest("binary");i.set(o.subarray(0,32),0);for(let t=1;t<r;t++)e.init(),e.update(o),o=e.digest("binary"),i.set(o.subarray(0,32),32*t);const s=n-32*r;let a;return 64===s?(a=e,a.init()):a=yield mp(8*s),a.update(o),o=a.digest("binary"),i.set(o.subarray(0,s),32*r),i})}function Ap(e){return Jh(this,void 0,void 0,function*(){var t;const{parallelism:n,iterations:r,hashLength:i}=e,o=ip(e.password),s=ip(e.salt),a=function(e){switch(e){case"d":return 0;case"i":return 1;default:return 2}}(e.hashType),{memorySize:l}=e,c=ip(null!==(t=e.secret)&&void 0!==t?t:""),[u,d]=yield Promise.all([fp(hp,1024),mp(512)]);u.setMemorySize(1024*l+1024);const f=new Uint8Array(24),h=new DataView(f.buffer);h.setInt32(0,n,!0),h.setInt32(4,i,!0),h.setInt32(8,l,!0),h.setInt32(12,r,!0),h.setInt32(16,19,!0),h.setInt32(20,a,!0),u.writeMemory(f,1024*l),d.init(),d.update(f),d.update(wp(o.length)),d.update(o),d.update(wp(s.length)),d.update(s),d.update(wp(c.length)),d.update(c),d.update(wp(0));const p=4*Math.floor(l/(4*n)),g=new Uint8Array(72),m=d.digest("binary");g.set(m);for(let e=0;e<n;e++){g.set(wp(0),64),g.set(wp(e),68);let t=e*p,n=yield vp(d,g,1024);u.writeMemory(n,1024*t),t+=1,g.set(wp(1),64),n=yield vp(d,g,1024),u.writeMemory(n,1024*t)}const y=new Uint8Array(1024);ep(y,u.calculate(new Uint8Array([]),l));const w=yield vp(d,y,i);if("hex"===e.outputType){return rp(new Uint8Array(2*i),w,i)}return"encoded"===e.outputType?function(e,t,n){const r=[`m=${t.memorySize}`,`t=${t.iterations}`,`p=${t.parallelism}`].join(",");return`$argon2${t.hashType}$v=19$${r}$${ap(e,!1)}$${ap(n,!1)}`}(s,e,w):w})}function bp(e){return Jh(this,void 0,void 0,function*(){return(e=>{var t;if(!e||"object"!=typeof e)throw new Error("Invalid options parameter. It requires an object.");if(!e.password)throw new Error("Password must be specified");if(e.password=ip(e.password),e.password.length<1)throw new Error("Password must be specified");if(!e.salt)throw new Error("Salt must be specified");if(e.salt=ip(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=ip(null!==(t=e.secret)&&void 0!==t?t:""),!Number.isInteger(e.iterations)||e.iterations<1)throw new Error("Iterations should be a positive number");if(!Number.isInteger(e.parallelism)||e.parallelism<1)throw new Error("Parallelism should be a positive number");if(!Number.isInteger(e.hashLength)||e.hashLength<4)throw new Error("Hash length should be at least 4 bytes.");if(!Number.isInteger(e.memorySize))throw new Error("Memory size should be specified.");if(e.memorySize<8*e.parallelism)throw new Error("Memory size should be at least 8 * parallelism.");if(void 0===e.outputType&&(e.outputType="hex"),!["hex","binary","encoded"].includes(e.outputType))throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary', 'encoded']`)})(e),Ap(Object.assign(Object.assign({},e),{hashType:"id"}))})}new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh,new Vh;const kp={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let Ip=null,Ep=0;const Cp=new Map;async function xp(e,t){try{const n=function(){if(Ip)return Ip;const e=new Blob(["\n importScripts('https://cdn.jsdelivr.net/npm/hash-wasm@4.11.0/dist/argon2.umd.min.js');\n\n const ARGON2_CONFIG = {\n parallelism: 4,\n iterations: 8,\n memorySize: 262144,\n hashLength: 32,\n outputType: \"binary\"\n };\n\n self.onmessage = async function(e) {\n const { password, salt, id } = e.data;\n\n try {\n const result = await hashwasm.argon2id({\n password: password,\n salt: new Uint8Array(salt),\n ...ARGON2_CONFIG\n });\n\n self.postMessage({\n id,\n success: true,\n result: Array.from(result)\n });\n } catch (error) {\n self.postMessage({\n id,\n success: false,\n error: error.message\n });\n }\n };\n "],{type:"application/javascript"});return Ip=new Worker(URL.createObjectURL(e)),Ip.onmessage=function(e){const{id:t,success:n,result:r,error:i}=e.data,o=Cp.get(t);o&&(Cp.delete(t),n?o.resolve(new Uint8Array(r)):o.reject(new Error(i)))},Ip.onerror=function(e){console.error("Argon2 worker error:",e)},Ip}(),r=++Ep;return new Promise((i,o)=>{Cp.set(r,{resolve:i,reject:o}),n.postMessage({id:r,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await bp({password:e,salt:t,...kp})}}const{window:Bp}=l;function Sp(e){let t,n,i,o,s,a,l,f,p,g,y,b,k,I,E,C,x,S;function F(e,t){return"extension"===e[2]?Qp:Fp}let Q=F(e),D=Q(e),R=e[10]&&Hp(e),P=e[11]&&jp(e);return{c(){t=h("div"),n=h("div"),i=h("div"),o=h("h2"),o.textContent="Login to Nostr",s=m(),a=h("button"),a.textContent="×",l=m(),f=h("div"),p=h("div"),g=h("button"),g.textContent="Extension",y=m(),b=h("button"),b.textContent="Nsec",k=m(),I=h("div"),D.c(),E=m(),R&&R.c(),C=m(),P&&P.c(),A(o,"class","svelte-4xpfbi"),A(a,"class","close-btn svelte-4xpfbi"),A(i,"class","modal-header svelte-4xpfbi"),A(g,"class","tab-btn svelte-4xpfbi"),B(g,"active","extension"===e[2]),A(b,"class","tab-btn svelte-4xpfbi"),B(b,"active","nsec"===e[2]),A(p,"class","tabs svelte-4xpfbi"),A(I,"class","tab-content svelte-4xpfbi"),A(f,"class","tab-container svelte-4xpfbi"),A(n,"class","modal svelte-4xpfbi"),B(n,"dark-theme",e[1]),A(t,"class","modal-overlay svelte-4xpfbi"),A(t,"role","button"),A(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(i,o),c(i,s),c(i,a),c(n,l),c(n,f),c(f,p),c(p,g),c(p,y),c(p,b),c(f,k),c(f,I),D.m(I,null),c(I,E),R&&R.m(I,null),c(I,C),P&&P.m(I,null),x||(S=[w(a,"click",e[17]),w(g,"click",e[26]),w(b,"click",e[27]),w(n,"click",v(e[24])),w(n,"keydown",v(e[25])),w(t,"click",e[17]),w(t,"keydown",e[32])],x=!0)},p(e,t){4&t[0]&&B(g,"active","extension"===e[2]),4&t[0]&&B(b,"active","nsec"===e[2]),Q===(Q=F(e))&&D?D.p(e,t):(D.d(1),D=Q(e),D&&(D.c(),D.m(I,E))),e[10]?R?R.p(e,t):(R=Hp(e),R.c(),R.m(I,C)):R&&(R.d(1),R=null),e[11]?P?P.p(e,t):(P=jp(e),P.c(),P.m(I,null)):P&&(P.d(1),P=null),2&t[0]&&B(n,"dark-theme",e[1])},d(e){e&&d(t),D.d(),R&&R.d(),P&&P.d(),x=!1,r(S)}}}function Fp(e){let t;function n(e,t){return e[14]?Rp:Dp}let r=n(e),i=r(e);return{c(){t=h("div"),i.c(),A(t,"class","nsec-login svelte-4xpfbi")},m(e,n){u(e,t,n),i.m(t,null)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t,null)))},d(e){e&&d(t),i.d()}}}function Qp(e){let t,n,r,i,o,s,a,l=e[7]?"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=m(),i=h("button"),o=g(l),A(n,"class","svelte-4xpfbi"),A(i,"class","login-extension-btn svelte-4xpfbi"),i.disabled=e[7],A(t,"class","extension-login svelte-4xpfbi")},m(l,d){u(l,t,d),c(t,n),c(t,r),c(t,i),c(i,o),s||(a=w(i,"click",e[21]),s=!0)},p(e,t){128&t[0]&&l!==(l=e[7]?"Connecting...":"Log in using extension")&&k(o,l),128&t[0]&&(i.disabled=e[7])},d(e){e&&d(t),s=!1,a()}}}function Dp(e){let t,n,i,o,s,a,l,f,p,y,v,b,E,C,x,B,S,F,Q,D,R,P,$,U=e[8]?"Generating...":"Generate New Key",T=e[12]&&Pp(e),N=e[4]&&$p(e);function L(e,t){return e[9]?Np:e[7]?Tp:Up}let O=L(e),M=O(e);return{c(){t=h("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n set a password to encrypt it securely.",n=m(),i=h("button"),o=g(U),a=m(),T&&T.c(),l=m(),f=h("input"),y=m(),v=h("div"),b=h("label"),b.textContent="Encryption Password (optional but recommended):",E=m(),C=h("input"),B=m(),N&&N.c(),S=m(),F=h("small"),F.textContent="Password uses Argon2id with ~3 second derivation time for security.",Q=m(),D=h("button"),M.c(),A(t,"class","svelte-4xpfbi"),A(i,"class","generate-btn svelte-4xpfbi"),i.disabled=s=e[7]||e[8],A(f,"type","password"),A(f,"placeholder","nsec1..."),f.disabled=p=e[7]||e[9],A(f,"class","nsec-input svelte-4xpfbi"),A(b,"class","svelte-4xpfbi"),A(C,"type","password"),A(C,"placeholder","Enter password (min 8 chars)"),C.disabled=x=e[7]||e[9],A(C,"class","password-input svelte-4xpfbi"),A(F,"class","password-hint svelte-4xpfbi"),A(v,"class","password-section svelte-4xpfbi"),A(D,"class","login-nsec-btn svelte-4xpfbi"),D.disabled=R=e[7]||e[9]||!e[3].trim()},m(r,s){u(r,t,s),u(r,n,s),u(r,i,s),c(i,o),u(r,a,s),T&&T.m(r,s),u(r,l,s),u(r,f,s),I(f,e[3]),u(r,y,s),u(r,v,s),c(v,b),c(v,E),c(v,C),I(C,e[4]),c(v,B),N&&N.m(v,null),c(v,S),c(v,F),u(r,Q,s),u(r,D,s),M.m(D,null),P||($=[w(i,"click",e[20]),w(f,"input",e[29]),w(C,"input",e[30]),w(D,"click",e[22])],P=!0)},p(e,t){256&t[0]&&U!==(U=e[8]?"Generating...":"Generate New Key")&&k(o,U),384&t[0]&&s!==(s=e[7]||e[8])&&(i.disabled=s),e[12]?T?T.p(e,t):(T=Pp(e),T.c(),T.m(l.parentNode,l)):T&&(T.d(1),T=null),640&t[0]&&p!==(p=e[7]||e[9])&&(f.disabled=p),8&t[0]&&f.value!==e[3]&&I(f,e[3]),640&t[0]&&x!==(x=e[7]||e[9])&&(C.disabled=x),16&t[0]&&C.value!==e[4]&&I(C,e[4]),e[4]?N?N.p(e,t):(N=$p(e),N.c(),N.m(v,S)):N&&(N.d(1),N=null),O!==(O=L(e))&&(M.d(1),M=O(e),M&&(M.c(),M.m(D,null))),648&t[0]&&R!==(R=e[7]||e[9]||!e[3].trim())&&(D.disabled=R)},d(e){e&&d(t),e&&d(n),e&&d(i),e&&d(a),T&&T.d(e),e&&d(l),e&&d(f),e&&d(y),e&&d(v),N&&N.d(),e&&d(Q),e&&d(D),M.d(),P=!1,r($)}}}function Rp(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,E,C=e[15]&&Lp(e);function x(e,t){return e[9]?_p:e[7]?Mp:Op}let B=x(e),S=B(e);return{c(){t=h("p"),t.textContent="You have a stored encrypted key. Enter your\n password to unlock it.",n=m(),C&&C.c(),i=m(),o=h("input"),a=m(),l=h("button"),S.c(),p=m(),y=h("button"),v=g("Clear stored key & start fresh"),A(t,"class","svelte-4xpfbi"),A(o,"type","password"),A(o,"placeholder","Enter your password"),o.disabled=s=e[7]||e[9],A(o,"class","password-input svelte-4xpfbi"),A(l,"class","login-nsec-btn svelte-4xpfbi"),l.disabled=f=e[7]||e[9]||!e[6],A(y,"class","clear-btn svelte-4xpfbi"),y.disabled=b=e[7]||e[9]},m(r,s){u(r,t,s),u(r,n,s),C&&C.m(r,s),u(r,i,s),u(r,o,s),I(o,e[6]),u(r,a,s),u(r,l,s),S.m(l,null),u(r,p,s),u(r,y,s),c(y,v),k||(E=[w(o,"input",e[28]),w(l,"click",e[18]),w(y,"click",e[16])],k=!0)},p(e,t){e[15]?C?C.p(e,t):(C=Lp(e),C.c(),C.m(i.parentNode,i)):C&&(C.d(1),C=null),640&t[0]&&s!==(s=e[7]||e[9])&&(o.disabled=s),64&t[0]&&o.value!==e[6]&&I(o,e[6]),B!==(B=x(e))&&(S.d(1),S=B(e),S&&(S.c(),S.m(l,null))),704&t[0]&&f!==(f=e[7]||e[9]||!e[6])&&(l.disabled=f),640&t[0]&&b!==(b=e[7]||e[9])&&(y.disabled=b)},d(e){e&&d(t),e&&d(n),C&&C.d(e),e&&d(i),e&&d(o),e&&d(a),e&&d(l),S.d(),e&&d(p),e&&d(y),k=!1,r(E)}}}function Pp(e){let t,n,r,i,o;return{c(){t=h("div"),n=h("label"),n.textContent="Your new public key (npub):",r=m(),i=h("code"),o=g(e[12]),A(n,"class","svelte-4xpfbi"),A(i,"class","npub-display svelte-4xpfbi"),A(t,"class","generated-info svelte-4xpfbi")},m(e,s){u(e,t,s),c(t,n),c(t,r),c(t,i),c(i,o)},p(e,t){4096&t[0]&&k(o,e[12])},d(e){e&&d(t)}}}function $p(e){let t,n,r,i;return{c(){t=h("input"),A(t,"type","password"),A(t,"placeholder","Confirm password"),t.disabled=n=e[7]||e[9],A(t,"class","password-input svelte-4xpfbi")},m(n,o){u(n,t,o),I(t,e[5]),r||(i=w(t,"input",e[31]),r=!0)},p(e,r){640&r[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&r[0]&&t.value!==e[5]&&I(t,e[5])},d(e){e&&d(t),r=!1,i()}}}function Up(e){let t;return{c(){t=g("Log in with nsec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Tp(e){let t;return{c(){t=g("Logging in...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Np(e){let t;return{c(){t=g("Deriving key...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Lp(e){let t,n,r,i,o,s,a,l=e[15].slice(0,16)+"",f=e[15].slice(-8)+"";return{c(){t=h("div"),n=h("label"),n.textContent="Stored public key:",r=m(),i=h("code"),o=g(l),s=g("..."),a=g(f),A(n,"class","svelte-4xpfbi"),A(i,"class","npub-display svelte-4xpfbi"),A(t,"class","stored-info svelte-4xpfbi")},m(e,l){u(e,t,l),c(t,n),c(t,r),c(t,i),c(i,o),c(i,s),c(i,a)},p(e,t){32768&t[0]&&l!==(l=e[15].slice(0,16)+"")&&k(o,l),32768&t[0]&&f!==(f=e[15].slice(-8)+"")&&k(a,f)},d(e){e&&d(t)}}}function Op(e){let t;return{c(){t=g("Unlock")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Mp(e){let t;return{c(){t=g("Unlocking...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function _p(e){let t;return{c(){t=g("Deriving key...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Hp(e){let t,n;return{c(){t=h("div"),n=g(e[10]),A(t,"class","message error-message svelte-4xpfbi")},m(e,r){u(e,t,r),c(t,n)},p(e,t){1024&t[0]&&k(n,e[10])},d(e){e&&d(t)}}}function jp(e){let t,n;return{c(){t=h("div"),n=g(e[11]),A(t,"class","message success-message svelte-4xpfbi")},m(e,r){u(e,t,r),c(t,n)},p(e,t){2048&t[0]&&k(n,e[11])},d(e){e&&d(t)}}}function Gp(e){let t,n,r,i,o,s,a,l,f,p,y,w=e[13].toFixed(1)+"";return{c(){t=h("div"),n=h("div"),r=h("div"),i=m(),o=h("h3"),o.textContent="Deriving encryption key",s=m(),a=h("div"),l=g(w),f=g("s"),p=m(),y=h("p"),y.textContent="This may take 3-6 seconds for security",A(r,"class","deriving-spinner svelte-4xpfbi"),A(o,"class","svelte-4xpfbi"),A(a,"class","deriving-timer svelte-4xpfbi"),A(y,"class","deriving-note svelte-4xpfbi"),A(n,"class","deriving-modal svelte-4xpfbi"),B(n,"dark-theme",e[1]),A(t,"class","deriving-overlay svelte-4xpfbi")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),c(a,l),c(a,f),c(n,p),c(n,y)},p(e,t){8192&t[0]&&w!==(w=e[13].toFixed(1)+"")&&k(l,w),2&t[0]&&B(n,"dark-theme",e[1])},d(e){e&&d(t)}}}function qp(t){let n,r,i,o,s=t[0]&&Sp(t),a=t[9]&&Gp(t);return{c(){s&&s.c(),n=m(),a&&a.c(),r=y()},m(e,l){s&&s.m(e,l),u(e,n,l),a&&a.m(e,l),u(e,r,l),i||(o=w(Bp,"keydown",t[23]),i=!0)},p(e,t){e[0]?s?s.p(e,t):(s=Sp(e),s.c(),s.m(n.parentNode,n)):s&&(s.d(1),s=null),e[9]?a?a.p(e,t):(a=Gp(e),a.c(),a.m(r.parentNode,r)):a&&(a.d(1),a=null)},i:e,o:e,d(e){s&&s.d(e),e&&d(n),a&&a.d(e),e&&d(r),i=!1,o()}}}function Kp(e,t,n){const r=P();let{showModal:i=!1}=t,{isDarkTheme:o=!1}=t,s="extension",a="",l="",c="",u="",d=!1,f=!1,h=!1,p="",g="",m="",y="",w=0,v=null,A=null;function b(){n(13,w=0),v=performance.now(),k()}function k(){null!==v&&(n(13,w=(performance.now()-v)/1e3),A=requestAnimationFrame(k))}function I(){v=null,A&&(cancelAnimationFrame(A),A=null)}R(()=>{I()});let E=!1,C="";function x(){n(14,E=!!localStorage.getItem("nostr_privkey_encrypted")),n(15,C=localStorage.getItem("nostr_pubkey")||"")}function B(){n(0,i=!1),n(3,a=""),n(4,l=""),n(5,c=""),n(6,u=""),n(10,p=""),n(11,g=""),m="",n(12,y=""),r("close")}function S(e){n(2,s=e),n(10,p=""),n(11,g=""),m="",n(12,y="")}async function F(){n(7,d=!0),n(10,p=""),n(11,g="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!function(e){if(!e||!e.startsWith("nsec1"))return!1;try{return"nsec"===vu(e).type}catch{return!1}}(a.trim()))throw new Error("Invalid nsec format or checksum");if(l){if(l.length<8)throw new Error("Password must be at least 8 characters");if(l!==c)throw new Error("Passwords do not match")}const e=xf.fromKey(a.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),l){n(9,h=!0),b();const e=await async function(e,t){if(!e.startsWith("nsec1"))throw new Error("Invalid nsec format - must start with nsec1");try{if("nsec"!==vu(e).type)throw new Error("Invalid nsec - wrong type")}catch(e){throw new Error("Invalid nsec - bech32 checksum failed")}const n=crypto.getRandomValues(new Uint8Array(32)),r=crypto.getRandomValues(new Uint8Array(12)),i=await xp(t,n),o=await crypto.subtle.importKey("raw",i,{name:"AES-GCM"},!1,["encrypt"]),s=new TextEncoder,a=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},o,s.encode(e)),l=new Uint8Array(n.length+r.length+a.byteLength);return l.set(n,0),l.set(r,n.length),l.set(new Uint8Array(a),n.length+r.length),btoa(String.fromCharCode(...l))}(a.trim(),l);I(),n(9,h=!1),localStorage.setItem("nostr_privkey_encrypted",e),localStorage.removeItem("nostr_privkey")}else localStorage.setItem("nostr_privkey",a.trim()),localStorage.removeItem("nostr_privkey_encrypted"),n(11,g="Successfully logged in with nsec!");r("login",{method:"nsec",pubkey:t,privateKey:a.trim(),signer:e}),setTimeout(()=>{B()},1500)}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}}D(()=>{x()});return e.$$set=e=>{"showModal"in e&&n(0,i=e.showModal),"isDarkTheme"in e&&n(1,o=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&i&&x()},[i,o,s,a,l,c,u,d,f,h,p,g,y,w,E,C,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(14,E=!1),n(15,C=""),n(6,u=""),n(10,p=""),n(11,g="")},B,async function(){n(7,d=!0),n(9,h=!0),b(),n(10,p=""),n(11,g="");try{if(!u)throw new Error("Please enter your password");const e=localStorage.getItem("nostr_privkey_encrypted");if(!e)throw new Error("No encrypted key found");const t=await async function(e,t){const n=new Uint8Array(atob(e).split("").map(e=>e.charCodeAt(0)));if(n.length<60)throw new Error("Invalid encrypted data - too short");const r=n.slice(0,32),i=n.slice(32,44),o=n.slice(44),s=await xp(t,r),a=await crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["decrypt"]);let l;try{l=await crypto.subtle.decrypt({name:"AES-GCM",iv:i},a,o)}catch(e){throw new Error("Decryption failed - invalid password or corrupted data")}const c=(new TextDecoder).decode(l);if(!c.startsWith("nsec1"))throw new Error("Decryption produced invalid data - not an nsec");try{if("nsec"!==vu(c).type)throw new Error("Decryption produced invalid nsec type")}catch(e){throw new Error("Decryption produced invalid nsec - bech32 checksum failed")}return c}(e,u);I(),n(9,h=!1);const i=xf.fromKey(t),o=await i.getPublicKey();r("login",{method:"nsec",pubkey:o,privateKey:t,signer:i}),B()}catch(e){I(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,p="Invalid password"):n(10,p=e.message)}finally{n(7,d=!1),n(9,h=!1),I()}},S,async function(){n(8,f=!0),n(10,p=""),n(11,g="");try{const e=eu(),t=ku("nsec",e),r=bu(tu(e));m=t,n(12,y=r),n(3,a=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,p="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,p=""),n(11,g="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(11,g="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{B()},1500))}catch(e){n(10,p=e.message)}finally{n(7,d=!1)}},F,function(e){"Escape"===e.key&&B(),"Enter"===e.key&&"nsec"===s&&F()},function(t){$.call(this,e,t)},function(t){$.call(this,e,t)},()=>S("extension"),()=>S("nsec"),function(){u=this.value,n(6,u)},function(){a=this.value,n(3,a)},function(){l=this.value,n(4,l)},function(){c=this.value,n(5,c)},e=>"Escape"===e.key&&B()]}class Jp extends ae{constructor(e){super(),se(this,e,Kp,qp,o,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function Vp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Yp(e,t,n){const r=e.slice();return r[75]=t[n],r}function zp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Wp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Zp(e,t,n){const r=e.slice();return r[72]=t[n],r}function Xp(e,t,n){const r=e.slice();return r[72]=t[n],r}function eg(e,t,n){const r=e.slice();return r[72]=t[n],r}function tg(e){let t,n,r;return{c(){t=h("div"),n=g(e[3]),A(t,"class",r="message "+e[4]+" svelte-1y8wjwc")},m(e,r){u(e,t,r),c(t,n)},p(e,i){8&i[0]&&k(n,e[3]),16&i[0]&&r!==(r="message "+e[4]+" svelte-1y8wjwc")&&A(t,"class",r)},d(e){e&&d(t)}}}function ng(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L;function O(e,t){return e[5]&&e[5].length>0?ig:rg}let M=O(e),_=M(e);function H(e,t){return e[8]&&e[8].length>0?lg:ag}let j=H(e),G=j(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Banned Pubkeys",o=m(),s=h("div"),a=h("input"),l=m(),f=h("input"),p=m(),y=h("button"),v=g("Ban Pubkey"),b=m(),k=h("div"),_.c(),E=m(),C=h("div"),x=h("h3"),x.textContent="Allowed Pubkeys",B=m(),S=h("div"),F=h("input"),Q=m(),D=h("input"),R=m(),P=h("button"),$=g("Allow Pubkey"),U=m(),T=h("div"),G.c(),A(i,"class","svelte-1y8wjwc"),A(a,"type","text"),A(a,"placeholder","Pubkey (64 hex chars)"),A(a,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),y.disabled=e[2],A(y,"class","svelte-1y8wjwc"),A(s,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(x,"class","svelte-1y8wjwc"),A(F,"type","text"),A(F,"placeholder","Pubkey (64 hex chars)"),A(F,"class","svelte-1y8wjwc"),A(D,"type","text"),A(D,"placeholder","Reason (optional)"),A(D,"class","svelte-1y8wjwc"),P.disabled=e[2],A(P,"class","svelte-1y8wjwc"),A(S,"class","add-form svelte-1y8wjwc"),A(T,"class","list svelte-1y8wjwc"),A(C,"class","section svelte-1y8wjwc"),A(t,"class","pubkeys-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),I(a,e[6]),c(s,l),c(s,f),I(f,e[7]),c(s,p),c(s,y),c(y,v),c(n,b),c(n,k),_.m(k,null),c(t,E),c(t,C),c(C,x),c(C,B),c(C,S),c(S,F),I(F,e[9]),c(S,Q),c(S,D),I(D,e[10]),c(S,R),c(S,P),c(P,$),c(C,U),c(C,T),G.m(T,null),N||(L=[w(a,"input",e[43]),w(f,"input",e[44]),w(y,"click",e[25]),w(F,"input",e[45]),w(D,"input",e[46]),w(P,"click",e[26])],N=!0)},p(e,t){64&t[0]&&a.value!==e[6]&&I(a,e[6]),128&t[0]&&f.value!==e[7]&&I(f,e[7]),4&t[0]&&(y.disabled=e[2]),M===(M=O(e))&&_?_.p(e,t):(_.d(1),_=M(e),_&&(_.c(),_.m(k,null))),512&t[0]&&F.value!==e[9]&&I(F,e[9]),1024&t[0]&&D.value!==e[10]&&I(D,e[10]),4&t[0]&&(P.disabled=e[2]),j===(j=H(e))&&G?G.p(e,t):(G.d(1),G=j(e),G&&(G.c(),G.m(T,null)))},d(e){e&&d(t),_.d(),G.d(),N=!1,r(L)}}}function rg(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No banned pubkeys configured.</p>",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function ig(e){let t,n=e[5],r=[];for(let t=0;t<n.length;t+=1)r[t]=sg(eg(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(32&i[0]){let o;for(n=e[5],o=0;o<n.length;o+=1){const s=eg(e,n,o);r[o]?r[o].p(s,i):(r[o]=sg(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function og(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=g(r),A(t,"class","reason svelte-1y8wjwc")},m(e,r){u(e,t,r),c(t,n)},p(e,t){32&t[0]&&r!==(r=e[72].reason+"")&&k(n,r)},d(e){e&&d(t)}}}function sg(e){let t,n,r,i,o,s=e[72].pubkey+"",a=e[72].reason&&og(e);return{c(){t=h("div"),n=h("span"),r=g(s),i=m(),a&&a.c(),o=m(),A(n,"class","pubkey svelte-1y8wjwc"),A(t,"class","list-item svelte-1y8wjwc")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(t,i),a&&a.m(t,null),c(t,o)},p(e,n){32&n[0]&&s!==(s=e[72].pubkey+"")&&k(r,s),e[72].reason?a?a.p(e,n):(a=og(e),a.c(),a.m(t,o)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function ag(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No allowed pubkeys configured.</p>",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function lg(e){let t,n=e[8],r=[];for(let t=0;t<n.length;t+=1)r[t]=ug(Xp(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(256&i[0]){let o;for(n=e[8],o=0;o<n.length;o+=1){const s=Xp(e,n,o);r[o]?r[o].p(s,i):(r[o]=ug(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function cg(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=g(r),A(t,"class","reason svelte-1y8wjwc")},m(e,r){u(e,t,r),c(t,n)},p(e,t){256&t[0]&&r!==(r=e[72].reason+"")&&k(n,r)},d(e){e&&d(t)}}}function ug(e){let t,n,r,i,o,s=e[72].pubkey+"",a=e[72].reason&&cg(e);return{c(){t=h("div"),n=h("span"),r=g(s),i=m(),a&&a.c(),o=m(),A(n,"class","pubkey svelte-1y8wjwc"),A(t,"class","list-item svelte-1y8wjwc")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(t,i),a&&a.m(t,null),c(t,o)},p(e,n){256&n[0]&&s!==(s=e[72].pubkey+"")&&k(r,s),e[72].reason?a?a.p(e,n):(a=cg(e),a.c(),a.m(t,o)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function dg(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L;function O(e,t){return e[11]&&e[11].length>0?hg:fg}let M=O(e),_=M(e);let H=function(e){return e[22]&&e[22].length>0?yg:mg}(e),j=H(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Banned Events",o=m(),s=h("div"),a=h("input"),l=m(),f=h("input"),p=m(),y=h("button"),v=g("Ban Event"),b=m(),k=h("div"),_.c(),E=m(),C=h("div"),x=h("h3"),x.textContent="Allowed Events",B=m(),S=h("div"),F=h("input"),Q=m(),D=h("input"),R=m(),P=h("button"),$=g("Allow Event"),U=m(),T=h("div"),j.c(),A(i,"class","svelte-1y8wjwc"),A(a,"type","text"),A(a,"placeholder","Event ID (64 hex chars)"),A(a,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),y.disabled=e[2],A(y,"class","svelte-1y8wjwc"),A(s,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(x,"class","svelte-1y8wjwc"),A(F,"type","text"),A(F,"placeholder","Event ID (64 hex chars)"),A(F,"class","svelte-1y8wjwc"),A(D,"type","text"),A(D,"placeholder","Reason (optional)"),A(D,"class","svelte-1y8wjwc"),P.disabled=e[2],A(P,"class","svelte-1y8wjwc"),A(S,"class","add-form svelte-1y8wjwc"),A(T,"class","list svelte-1y8wjwc"),A(C,"class","section svelte-1y8wjwc"),A(t,"class","events-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),I(a,e[12]),c(s,l),c(s,f),I(f,e[13]),c(s,p),c(s,y),c(y,v),c(n,b),c(n,k),_.m(k,null),c(t,E),c(t,C),c(C,x),c(C,B),c(C,S),c(S,F),I(F,e[14]),c(S,Q),c(S,D),I(D,e[15]),c(S,R),c(S,P),c(P,$),c(C,U),c(C,T),j.m(T,null),N||(L=[w(a,"input",e[47]),w(f,"input",e[48]),w(y,"click",e[27]),w(F,"input",e[49]),w(D,"input",e[50]),w(P,"click",e[28])],N=!0)},p(e,t){4096&t[0]&&a.value!==e[12]&&I(a,e[12]),8192&t[0]&&f.value!==e[13]&&I(f,e[13]),4&t[0]&&(y.disabled=e[2]),M===(M=O(e))&&_?_.p(e,t):(_.d(1),_=M(e),_&&(_.c(),_.m(k,null))),16384&t[0]&&F.value!==e[14]&&I(F,e[14]),32768&t[0]&&D.value!==e[15]&&I(D,e[15]),4&t[0]&&(P.disabled=e[2]),j.p(e,t)},d(e){e&&d(t),_.d(),j.d(),N=!1,r(L)}}}function fg(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No banned events configured.</p>",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function hg(e){let t,n=e[11],r=[];for(let t=0;t<n.length;t+=1)r[t]=gg(Zp(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(2048&i[0]){let o;for(n=e[11],o=0;o<n.length;o+=1){const s=Zp(e,n,o);r[o]?r[o].p(s,i):(r[o]=gg(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function pg(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=g(r),A(t,"class","reason svelte-1y8wjwc")},m(e,r){u(e,t,r),c(t,n)},p(e,t){2048&t[0]&&r!==(r=e[72].reason+"")&&k(n,r)},d(e){e&&d(t)}}}function gg(e){let t,n,r,i,o,s=e[72].id+"",a=e[72].reason&&pg(e);return{c(){t=h("div"),n=h("span"),r=g(s),i=m(),a&&a.c(),o=m(),A(n,"class","event-id svelte-1y8wjwc"),A(t,"class","list-item svelte-1y8wjwc")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(t,i),a&&a.m(t,null),c(t,o)},p(e,n){2048&n[0]&&s!==(s=e[72].id+"")&&k(r,s),e[72].reason?a?a.p(e,n):(a=pg(e),a.c(),a.m(t,o)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function mg(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No allowed events configured.</p>",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function yg(e){let t,n=e[22],r=[];for(let t=0;t<n.length;t+=1)r[t]=wg(Wp(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(4194304&i[0]){let o;for(n=e[22],o=0;o<n.length;o+=1){const s=Wp(e,n,o);r[o]?r[o].p(s,i):(r[o]=wg(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function wg(t){let n,r,i,o,s,a=t[72].id+"",l=t[72].reason&&function(t){let n,r,i=t[72].reason+"";return{c(){n=h("span"),r=g(i),A(n,"class","reason svelte-1y8wjwc")},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"),i=g(a),o=m(),l&&l.c(),s=m(),A(r,"class","event-id svelte-1y8wjwc"),A(n,"class","list-item svelte-1y8wjwc")},m(e,t){u(e,n,t),c(n,r),c(r,i),c(n,o),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 vg(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,E,C;function x(e,t){return e[16]&&e[16].length>0?bg:Ag}let B=x(e),S=B(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Blocked IPs",o=m(),s=h("div"),a=h("input"),l=m(),f=h("input"),p=m(),y=h("button"),v=g("Block IP"),b=m(),k=h("div"),S.c(),A(i,"class","svelte-1y8wjwc"),A(a,"type","text"),A(a,"placeholder","IP Address"),A(a,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),y.disabled=e[2],A(y,"class","svelte-1y8wjwc"),A(s,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","ips-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),I(a,e[17]),c(s,l),c(s,f),I(f,e[18]),c(s,p),c(s,y),c(y,v),c(n,b),c(n,k),S.m(k,null),E||(C=[w(a,"input",e[51]),w(f,"input",e[52]),w(y,"click",e[29])],E=!0)},p(e,t){131072&t[0]&&a.value!==e[17]&&I(a,e[17]),262144&t[0]&&f.value!==e[18]&&I(f,e[18]),4&t[0]&&(y.disabled=e[2]),B===(B=x(e))&&S?S.p(e,t):(S.d(1),S=B(e),S&&(S.c(),S.m(k,null)))},d(e){e&&d(t),S.d(),E=!1,r(C)}}}function Ag(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No blocked IPs configured.</p>",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function bg(e){let t,n=e[16],r=[];for(let t=0;t<n.length;t+=1)r[t]=Ig(zp(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(65536&i[0]){let o;for(n=e[16],o=0;o<n.length;o+=1){const s=zp(e,n,o);r[o]?r[o].p(s,i):(r[o]=Ig(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function kg(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=g(r),A(t,"class","reason svelte-1y8wjwc")},m(e,r){u(e,t,r),c(t,n)},p(e,t){65536&t[0]&&r!==(r=e[72].reason+"")&&k(n,r)},d(e){e&&d(t)}}}function Ig(e){let t,n,r,i,o,s=e[72].ip+"",a=e[72].reason&&kg(e);return{c(){t=h("div"),n=h("span"),r=g(s),i=m(),a&&a.c(),o=m(),A(n,"class","ip svelte-1y8wjwc"),A(t,"class","list-item svelte-1y8wjwc")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(t,i),a&&a.m(t,null),c(t,o)},p(e,n){65536&n[0]&&s!==(s=e[72].ip+"")&&k(r,s),e[72].reason?a?a.p(e,n):(a=kg(e),a.c(),a.m(t,o)):a&&(a.d(1),a=null)},d(e){e&&d(t),a&&a.d()}}}function Eg(e){let t,n,i,o,s,a,l,f,p,y,v,k,E;function C(e,t){return e[19]&&e[19].length>0?xg:Cg}let x=C(e),B=x(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Allowed Event Kinds",o=m(),s=h("div"),a=h("input"),l=m(),f=h("button"),p=g("Allow Kind"),y=m(),v=h("div"),B.c(),A(i,"class","svelte-1y8wjwc"),A(a,"type","number"),A(a,"placeholder","Kind number"),A(a,"class","svelte-1y8wjwc"),f.disabled=e[2],A(f,"class","svelte-1y8wjwc"),A(s,"class","add-form svelte-1y8wjwc"),A(v,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","kinds-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),I(a,e[20]),c(s,l),c(s,f),c(f,p),c(n,y),c(n,v),B.m(v,null),k||(E=[w(a,"input",e[53]),w(f,"click",e[30])],k=!0)},p(e,t){1048576&t[0]&&b(a.value)!==e[20]&&I(a,e[20]),4&t[0]&&(f.disabled=e[2]),x===(x=C(e))&&B?B.p(e,t):(B.d(1),B=x(e),B&&(B.c(),B.m(v,null)))},d(e){e&&d(t),B.d(),k=!1,r(E)}}}function Cg(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No allowed kinds configured. All kinds are\n allowed by default.</p>",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function xg(e){let t,n=e[19],r=[];for(let t=0;t<n.length;t+=1)r[t]=Bg(Yp(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(524288&i[0]|1&i[1]){let o;for(n=e[19],o=0;o<n.length;o+=1){const s=Yp(e,n,o);r[o]?r[o].p(s,i):(r[o]=Bg(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function Bg(e){let t,n,r,i,o,s,a,l,f,p=e[75]+"";function y(){return e[54](e[75])}return{c(){t=h("div"),n=h("span"),r=g("Kind "),i=g(p),o=m(),s=h("button"),s.textContent="Remove",a=m(),A(n,"class","kind svelte-1y8wjwc"),A(s,"class","remove-btn svelte-1y8wjwc"),A(t,"class","list-item svelte-1y8wjwc")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(t,o),c(t,s),c(t,a),l||(f=w(s,"click",y),l=!0)},p(t,n){e=t,524288&n[0]&&p!==(p=e[75]+"")&&k(i,p)},d(e){e&&d(t),l=!1,f()}}}function Sg(e){let t,n,r,i,o,s,a,l,f,p;function y(e,t){return e[21]&&e[21].length>0?Qg:Fg}let v=y(e),b=v(e);return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Events Needing Moderation",i=m(),o=h("button"),s=g("Refresh"),a=m(),l=h("div"),b.c(),A(r,"class","svelte-1y8wjwc"),o.disabled=e[2],A(l,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","moderation-section")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,i),c(n,o),c(o,s),c(n,a),c(n,l),b.m(l,null),f||(p=w(o,"click",e[24]),f=!0)},p(e,t){4&t[0]&&(o.disabled=e[2]),v===(v=y(e))&&b?b.p(e,t):(b.d(1),b=v(e),b&&(b.c(),b.m(l,null)))},d(e){e&&d(t),b.d(),f=!1,p()}}}function Fg(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No events need moderation at this time.</p>",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Qg(e){let t,n=e[21],r=[];for(let t=0;t<n.length;t+=1)r[t]=Rg(Vp(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(2097152&i[0]|12&i[1]){let o;for(n=e[21],o=0;o<n.length;o+=1){const s=Vp(e,n,o);r[o]?r[o].p(s,i):(r[o]=Rg(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function Dg(e){let t,n,r=e[72].reason+"";return{c(){t=h("span"),n=g(r),A(t,"class","reason svelte-1y8wjwc")},m(e,r){u(e,t,r),c(t,n)},p(e,t){2097152&t[0]&&r!==(r=e[72].reason+"")&&k(n,r)},d(e){e&&d(t)}}}function Rg(e){let t,n,i,o,s,a,l,f,p,y,v,b,I=e[72].id+"",E=e[72].reason&&Dg(e);function C(){return e[55](e[72])}function x(){return e[56](e[72])}return{c(){t=h("div"),n=h("span"),i=g(I),o=m(),E&&E.c(),s=m(),a=h("div"),l=h("button"),l.textContent="Allow",f=m(),p=h("button"),p.textContent="Ban",y=m(),A(n,"class","event-id svelte-1y8wjwc"),A(l,"class","svelte-1y8wjwc"),A(p,"class","svelte-1y8wjwc"),A(a,"class","actions svelte-1y8wjwc"),A(t,"class","list-item svelte-1y8wjwc")},m(e,r){u(e,t,r),c(t,n),c(n,i),c(t,o),E&&E.m(t,null),c(t,s),c(t,a),c(a,l),c(a,f),c(a,p),c(t,y),v||(b=[w(l,"click",C),w(p,"click",x)],v=!0)},p(n,r){e=n,2097152&r[0]&&I!==(I=e[72].id+"")&&k(i,I),e[72].reason?E?E.p(e,r):(E=Dg(e),E.c(),E.m(t,s)):E&&(E.d(1),E=null)},d(e){e&&d(t),E&&E.d(),v=!1,r(b)}}}function Pg(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L;function O(e,t){return e[2]?Ug:$g}let M=O(e),_=M(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Relay Configuration",o=m(),s=h("div"),a=h("button"),l=g("🔄 Refresh from Relay Info"),f=m(),p=h("div"),y=h("div"),v=h("label"),v.textContent="Relay Name",b=m(),k=h("input"),E=m(),C=h("div"),x=h("label"),x.textContent="Relay Description",B=m(),S=h("textarea"),F=m(),Q=h("div"),D=h("label"),D.textContent="Relay Icon URL",R=m(),P=h("input"),$=m(),U=h("div"),T=h("button"),_.c(),A(i,"class","svelte-1y8wjwc"),a.disabled=e[2],A(a,"class","refresh-btn svelte-1y8wjwc"),A(s,"class","config-actions svelte-1y8wjwc"),A(v,"for","relay-name"),A(v,"class","svelte-1y8wjwc"),A(k,"id","relay-name"),A(k,"type","text"),A(k,"placeholder","Enter relay name"),A(k,"class","svelte-1y8wjwc"),A(y,"class","form-group svelte-1y8wjwc"),A(x,"for","relay-description"),A(x,"class","svelte-1y8wjwc"),A(S,"id","relay-description"),A(S,"placeholder","Enter relay description"),A(S,"class","svelte-1y8wjwc"),A(C,"class","form-group svelte-1y8wjwc"),A(D,"for","relay-icon"),A(D,"class","svelte-1y8wjwc"),A(P,"id","relay-icon"),A(P,"type","url"),A(P,"placeholder","Enter icon URL"),A(P,"class","svelte-1y8wjwc"),A(Q,"class","form-group svelte-1y8wjwc"),T.disabled=e[2],A(T,"class","update-all-btn svelte-1y8wjwc"),A(U,"class","config-update-section svelte-1y8wjwc"),A(p,"class","config-form svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","relay-section")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(n,f),c(n,p),c(p,y),c(y,v),c(y,b),c(y,k),I(k,e[0].relay_name),c(p,E),c(p,C),c(C,x),c(C,B),c(C,S),I(S,e[0].relay_description),c(p,F),c(p,Q),c(Q,D),c(Q,R),c(Q,P),I(P,e[0].relay_icon),c(p,$),c(p,U),c(U,T),_.m(T,null),N||(L=[w(a,"click",e[23]),w(k,"input",e[57]),w(S,"input",e[58]),w(P,"input",e[59]),w(T,"click",e[32])],N=!0)},p(e,t){4&t[0]&&(a.disabled=e[2]),1&t[0]&&k.value!==e[0].relay_name&&I(k,e[0].relay_name),1&t[0]&&I(S,e[0].relay_description),1&t[0]&&P.value!==e[0].relay_icon&&I(P,e[0].relay_icon),M!==(M=O(e))&&(_.d(1),_=M(e),_&&(_.c(),_.m(T,null))),4&t[0]&&(T.disabled=e[2])},d(e){e&&d(t),_.d(),N=!1,r(L)}}}function $g(e){let t;return{c(){t=g("💾 Update Configuration")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ug(e){let t;return{c(){t=g("⏳ Updating...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Tg(t){let n,i,o,s,a,l,f,p,y,v,b,k,I,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V=t[3]&&tg(t),Y="pubkeys"===t[1]&&ng(t),z="events"===t[1]&&dg(t),W="ips"===t[1]&&vg(t),Z="kinds"===t[1]&&Eg(t),X="moderation"===t[1]&&Sg(t),ee="relay"===t[1]&&Pg(t);return{c(){n=h("div"),i=h("div"),i.innerHTML='<h2 class="svelte-1y8wjwc">Managed ACL Configuration</h2> \n <p class="svelte-1y8wjwc">Configure access control using NIP-86 management API</p> \n <div class="owner-only-notice svelte-1y8wjwc"><strong>Owner Only:</strong> This interface is restricted to relay owners\n only.</div>',o=m(),V&&V.c(),s=m(),a=h("div"),l=h("button"),f=g("Pubkeys"),y=m(),v=h("button"),b=g("Events"),I=m(),E=h("button"),C=g("IPs"),B=m(),S=h("button"),F=g("Kinds"),D=m(),R=h("button"),P=g("Moderation"),U=m(),T=h("button"),N=g("Relay Config"),O=m(),M=h("div"),Y&&Y.c(),_=m(),z&&z.c(),H=m(),W&&W.c(),j=m(),Z&&Z.c(),G=m(),X&&X.c(),q=m(),ee&&ee.c(),A(i,"class","header svelte-1y8wjwc"),A(l,"class",p="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),A(v,"class",k="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),A(E,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),A(S,"class",Q="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),A(R,"class",$="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),A(T,"class",L="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),A(a,"class","tabs svelte-1y8wjwc"),A(M,"class","tab-content svelte-1y8wjwc")},m(e,r){u(e,n,r),c(n,i),c(n,o),V&&V.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,y),c(a,v),c(v,b),c(a,I),c(a,E),c(E,C),c(a,B),c(a,S),c(S,F),c(a,D),c(a,R),c(R,P),c(a,U),c(a,T),c(T,N),c(n,O),c(n,M),Y&&Y.m(M,null),c(M,_),z&&z.m(M,null),c(M,H),W&&W.m(M,null),c(M,j),Z&&Z.m(M,null),c(M,G),X&&X.m(M,null),c(M,q),ee&&ee.m(M,null),K||(J=[w(l,"click",t[37]),w(v,"click",t[38]),w(E,"click",t[39]),w(S,"click",t[40]),w(R,"click",t[41]),w(T,"click",t[42])],K=!0)},p(e,t){e[3]?V?V.p(e,t):(V=tg(e),V.c(),V.m(n,s)):V&&(V.d(1),V=null),2&t[0]&&p!==(p="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(l,"class",p),2&t[0]&&k!==(k="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(v,"class",k),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(E,"class",x),2&t[0]&&Q!==(Q="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(S,"class",Q),2&t[0]&&$!==($="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(R,"class",$),2&t[0]&&L!==(L="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(T,"class",L),"pubkeys"===e[1]?Y?Y.p(e,t):(Y=ng(e),Y.c(),Y.m(M,_)):Y&&(Y.d(1),Y=null),"events"===e[1]?z?z.p(e,t):(z=dg(e),z.c(),z.m(M,H)):z&&(z.d(1),z=null),"ips"===e[1]?W?W.p(e,t):(W=vg(e),W.c(),W.m(M,j)):W&&(W.d(1),W=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=Eg(e),Z.c(),Z.m(M,G)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=Sg(e),X.c(),X.m(M,q)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=Pg(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),V&&V.d(),Y&&Y.d(),z&&z.d(),W&&W.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),K=!1,r(J)}}}function Ng(e,t,n){let{userSigner:r}=t,{userPubkey:i}=t,o="pubkeys",s=!1,a="",l="info",c=[],u="",d="",f=[],h="",p="",g=[],m="",y="",w="",v="",A=[],k="",I="",E=[],C="",x=[],B={relay_name:"",relay_description:"",relay_icon:""};async function S(){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,B={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",B),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 F(e,t=[]){try{n(2,s=!0),n(3,a="");const o={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(!i)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,o={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:i},s=await r.signEvent(o),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(o)});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 Q(){try{n(5,c=await F("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function R(){try{n(8,f=await F("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function P(){try{n(11,g=await F("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function $(){try{n(16,A=await F("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function U(){try{n(19,E=await F("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function T(){try{n(2,s=!0),n(21,x=await F("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",x)}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,x=[])}finally{n(2,s=!1)}}async function N(e){try{await F("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,l="success"),await U()}catch(e){console.error("Failed to disallow kind:",e)}}async function L(e){try{await F("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,l="success"),await T()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function O(e){try{await F("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,l="success"),await T()}catch(e){console.error("Failed to ban event from moderation:",e)}}D(()=>{setTimeout(()=>{S()},100)}),async function(){await Promise.all([Q(),R(),P(),$(),U()])}();return e.$$set=e=>{"userSigner"in e&&n(35,r=e.userSigner),"userPubkey"in e&&n(36,i=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",B)},[B,o,s,a,l,c,u,d,f,h,p,g,m,y,w,v,A,k,I,E,C,x,[],S,T,async function(){if(u)try{await F("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,l="success"),n(6,u=""),n(7,d=""),await Q()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await F("allowpubkey",[h,p]),n(3,a="Pubkey allowed successfully"),n(4,l="success"),n(9,h=""),n(10,p=""),await R()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await F("banevent",[m,y]),n(3,a="Event banned successfully"),n(4,l="success"),n(12,m=""),n(13,y=""),await P()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(w)try{await F("allowevent",[w,v]),n(3,a="Event allowed successfully"),n(4,l="success"),n(14,w=""),n(15,v="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(k)try{await F("blockip",[k,I]),n(3,a="IP blocked successfully"),n(4,l="success"),n(17,k=""),n(18,I=""),await $()}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 F("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,l="success"),n(20,C=""),await U()}catch(e){console.error("Failed to allow kind:",e)}},N,async function(){try{n(2,s=!0),n(3,a="");const e=[];if(B.relay_name&&e.push(F("changerelayname",[B.relay_name])),B.relay_description&&e.push(F("changerelaydescription",[B.relay_description])),B.relay_icon&&e.push(F("changerelayicon",[B.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 S()}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)}},L,O,r,i,()=>n(1,o="pubkeys"),()=>n(1,o="events"),()=>n(1,o="ips"),()=>n(1,o="kinds"),()=>{n(1,o="moderation"),x&&0!==x.length||T()},()=>n(1,o="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){h=this.value,n(9,h)},function(){p=this.value,n(10,p)},function(){m=this.value,n(12,m)},function(){y=this.value,n(13,y)},function(){w=this.value,n(14,w)},function(){v=this.value,n(15,v)},function(){k=this.value,n(17,k)},function(){I=this.value,n(18,I)},function(){C=b(this.value),n(20,C)},e=>N(e),e=>L(e.id),e=>O(e.id),function(){B.relay_name=this.value,n(0,B)},function(){B.relay_description=this.value,n(0,B)},function(){B.relay_icon=this.value,n(0,B)}]}class Lg extends ae{constructor(e){super(),se(this,e,Ng,Tg,o,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}function Og(e){let t,n;return{c(){t=h("span"),n=g(e[3]),A(t,"class","permission-badge svelte-1qkhxam")},m(e,r){u(e,t,r),c(t,n)},p(e,t){8&t&&k(n,e[3])},d(e){e&&d(t)}}}function Mg(t){let n,r,i;return{c(){n=h("button"),n.textContent="Log in",A(n,"class","login-btn svelte-1qkhxam")},m(e,o){u(e,n,o),r||(i=w(n,"click",t[7]),r=!0)},p:e,d(e){e&&d(n),r=!1,i()}}}function _g(e){let t,n,r,i,o,s,a=(e[4]?.name||e[5])+"";function l(e,t){return e[4]?.picture?jg:Hg}let f=l(e),p=f(e);return{c(){t=h("button"),p.c(),n=m(),r=h("span"),i=g(a),A(r,"class","user-name svelte-1qkhxam"),A(t,"class","user-profile-btn svelte-1qkhxam")},m(a,l){u(a,t,l),p.m(t,null),c(t,n),c(t,r),c(r,i),o||(s=w(t,"click",e[6]),o=!0)},p(e,r){f===(f=l(e))&&p?p.p(e,r):(p.d(1),p=f(e),p&&(p.c(),p.m(t,n))),48&r&&a!==(a=(e[4]?.name||e[5])+"")&&k(i,a)},d(e){e&&d(t),p.d(),o=!1,s()}}}function Hg(t){let n;return{c(){n=h("div"),n.textContent="👤",A(n,"class","user-avatar-placeholder svelte-1qkhxam")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function jg(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[4].picture)||A(t,"src",n),A(t,"alt","User avatar"),A(t,"class","user-avatar svelte-1qkhxam")},m(e,n){u(e,t,n)},p(e,r){16&r&&!a(t.src,n=e[4].picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function Gg(t){let n,r,i,o,s,l,f,p,y,w,v=t[1]&&t[2]&&Og(t);function b(e,t){return e[1]?_g:Mg}let k=b(t),I=k(t);return{c(){n=h("header"),r=h("div"),i=h("img"),s=m(),l=h("div"),f=h("span"),p=g("ORLY? dashboard\n "),v&&v.c(),y=m(),w=h("div"),I.c(),a(i.src,o="/orly.png")||A(i,"src","/orly.png"),A(i,"alt","ORLY Logo"),A(i,"class","logo svelte-1qkhxam"),A(f,"class","app-title svelte-1qkhxam"),A(l,"class","header-title svelte-1qkhxam"),A(w,"class","header-buttons svelte-1qkhxam"),A(r,"class","header-content svelte-1qkhxam"),A(n,"class","main-header svelte-1qkhxam"),B(n,"dark-theme",t[0])},m(e,t){u(e,n,t),c(n,r),c(r,i),c(r,s),c(r,l),c(l,f),c(f,p),v&&v.m(f,null),c(r,y),c(r,w),I.m(w,null)},p(e,[t]){e[1]&&e[2]?v?v.p(e,t):(v=Og(e),v.c(),v.m(f,null)):v&&(v.d(1),v=null),k===(k=b(e))&&I?I.p(e,t):(I.d(1),I=k(e),I&&(I.c(),I.m(w,null))),1&t&&B(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&d(n),v&&v.d(),I.d()}}}function qg(e,t,n){let{isDarkTheme:r=!1}=t,{isLoggedIn:i=!1}=t,{userRole:o=""}=t,{currentEffectiveRole:s=""}=t,{userProfile:a=null}=t,{userPubkey:l=""}=t;const c=P();return e.$$set=e=>{"isDarkTheme"in e&&n(0,r=e.isDarkTheme),"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,o=e.userRole),"currentEffectiveRole"in e&&n(3,s=e.currentEffectiveRole),"userProfile"in e&&n(4,a=e.userProfile),"userPubkey"in e&&n(5,l=e.userPubkey)},[r,i,o,s,a,l,function(){c("openSettingsDrawer")},function(){c("openLoginModal")}]}class Kg extends ae{constructor(e){super(),se(this,e,qg,Gg,o,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3,userProfile:4,userPubkey:5})}}function Jg(e,t,n){const r=e.slice();return r[10]=t[n],r}function Vg(e){let t,n,i;function o(){return e[6](e[10])}function s(...t){return e[7](e[10],...t)}return{c(){t=h("span"),t.textContent="✕",A(t,"class","tab-close-icon svelte-wfmuj"),A(t,"role","button"),A(t,"tabindex","0")},m(e,r){u(e,t,r),n||(i=[w(t,"click",v(o)),w(t,"keydown",s)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r(i)}}}function Yg(e){let t,n,r,i,o,s,a,l,f,p,y=e[10].icon+"",v=e[10].label+"",b=e[10].isSearchTab&&Vg(e);function I(){return e[8](e[10])}return{c(){t=h("button"),n=h("span"),r=g(y),i=m(),o=h("span"),s=g(v),a=m(),b&&b.c(),l=m(),A(n,"class","tab-icon svelte-wfmuj"),A(o,"class","tab-label svelte-wfmuj"),A(t,"class","tab svelte-wfmuj"),B(t,"active",e[2]===e[10].id)},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,i),c(t,o),c(o,s),c(t,a),b&&b.m(t,null),c(t,l),f||(p=w(t,"click",I),f=!0)},p(n,i){e=n,2&i&&y!==(y=e[10].icon+"")&&k(r,y),2&i&&v!==(v=e[10].label+"")&&k(s,v),e[10].isSearchTab?b?b.p(e,i):(b=Vg(e),b.c(),b.m(t,l)):b&&(b.d(1),b=null),6&i&&B(t,"active",e[2]===e[10].id)},d(e){e&&d(t),b&&b.d(),f=!1,p()}}}function zg(e){let t,n,r,i,o,s,a,l;return{c(){t=h("a"),n=p("svg"),r=p("path"),i=p("path"),o=m(),s=h("span"),a=g("v"),l=g(e[3]),A(r,"d","M5 6h12v2h1.5c1.38 0 2.5 1.12 2.5 2.5v1c0 1.38-1.12 2.5-2.5 2.5H17v1c0 1.66-1.34 3-3 3H8c-1.66 0-3-1.34-3-3V6zm12 6h1.5c.28 0 .5-.22.5-.5v-1c0-.28-.22-.5-.5-.5H17v2z"),A(i,"d","M9 9c1.5 0 3 .5 3 2.5S10.5 14 9 14c0-1.5.5-3.5 2-4.5"),A(i,"stroke","currentColor"),A(i,"stroke-width","1"),A(i,"fill","none"),A(n,"class","version-icon svelte-wfmuj"),A(n,"viewBox","0 0 24 24"),A(n,"fill","currentColor"),A(n,"xmlns","http://www.w3.org/2000/svg"),A(s,"class","version-text svelte-wfmuj"),A(t,"href","https://next.orly.dev"),A(t,"target","_blank"),A(t,"rel","noopener noreferrer"),A(t,"class","version-link svelte-wfmuj")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(t,o),c(t,s),c(s,a),c(s,l)},p(e,t){8&t&&k(l,e[3])},d(e){e&&d(t)}}}function Wg(t){let n,r,i,o,s=t[1],a=[];for(let e=0;e<s.length;e+=1)a[e]=Yg(Jg(t,s,e));let l=t[3]&&zg(t);return{c(){n=h("aside"),r=h("div"),i=h("div");for(let e=0;e<a.length;e+=1)a[e].c();o=m(),l&&l.c(),A(i,"class","tabs svelte-wfmuj"),A(r,"class","sidebar-content svelte-wfmuj"),A(n,"class","sidebar svelte-wfmuj"),B(n,"dark-theme",t[0])},m(e,t){u(e,n,t),c(n,r),c(r,i);for(let e=0;e<a.length;e+=1)a[e]&&a[e].m(i,null);c(n,o),l&&l.m(n,null)},p(e,[t]){if(54&t){let n;for(s=e[1],n=0;n<s.length;n+=1){const r=Jg(e,s,n);a[n]?a[n].p(r,t):(a[n]=Yg(r),a[n].c(),a[n].m(i,null))}for(;n<a.length;n+=1)a[n].d(1);a.length=s.length}e[3]?l?l.p(e,t):(l=zg(e),l.c(),l.m(n,null)):l&&(l.d(1),l=null),1&t&&B(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&d(n),f(a,e),l&&l.d()}}}function Zg(e,t,n){let{isDarkTheme:r=!1}=t,{tabs:i=[]}=t,{selectedTab:o=""}=t,{version:s=""}=t;const a=P();function l(e){a("selectTab",e)}function c(e){a("closeSearchTab",e)}return e.$$set=e=>{"isDarkTheme"in e&&n(0,r=e.isDarkTheme),"tabs"in e&&n(1,i=e.tabs),"selectedTab"in e&&n(2,o=e.selectedTab),"version"in e&&n(3,s=e.version)},[r,i,o,s,l,c,e=>c(e.id),(e,t)=>"Enter"===t.key&&c(e.id),e=>l(e.id)]}class Xg extends ae{constructor(e){super(),se(this,e,Zg,Wg,o,{isDarkTheme:0,tabs:1,selectedTab:2,version:3})}}function em(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access export functionality.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-jzrdtj"),A(o,"class","login-btn svelte-jzrdtj"),A(n,"class","login-prompt svelte-jzrdtj")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[5]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function tm(e){let t,n,r=e[0]&&nm(e),i=e[1]&&rm(e);return{c(){r&&r.c(),t=m(),i&&i.c(),n=y()},m(e,o){r&&r.m(e,o),u(e,t,o),i&&i.m(e,o),u(e,n,o)},p(e,o){e[0]?r?r.p(e,o):(r=nm(e),r.c(),r.m(t.parentNode,t)):r&&(r.d(1),r=null),e[1]?i?i.p(e,o):(i=rm(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},d(e){r&&r.d(e),e&&d(t),i&&i.d(e),e&&d(n)}}}function nm(t){let n,r,i,o,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export My Events",i=m(),o=h("p"),o.textContent="Download your personal events as a JSONL file.",s=m(),a=h("button"),a.textContent="📤 Export My Events",A(r,"class","svelte-jzrdtj"),A(o,"class","svelte-jzrdtj"),A(a,"class","export-btn svelte-jzrdtj"),A(n,"class","export-section svelte-jzrdtj")},m(e,d){u(e,n,d),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),l||(f=w(a,"click",t[3]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function rm(t){let n,r,i,o,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export All Events",i=m(),o=h("p"),o.textContent="Download the complete database as a JSONL file. This includes\n all events from all users.",s=m(),a=h("button"),a.textContent="📤 Export All Events",A(r,"class","svelte-jzrdtj"),A(o,"class","svelte-jzrdtj"),A(a,"class","export-btn svelte-jzrdtj"),A(n,"class","export-section svelte-jzrdtj")},m(e,d){u(e,n,d),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),l||(f=w(a,"click",t[4]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function im(t){let n;function r(e,t){return e[2]?tm:em}let i=r(t),o=i(t);return{c(){o.c(),n=y()},m(e,t){o.m(e,t),u(e,n,t)},p(e,[t]){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&d(n)}}}function om(e,t,n){let r,i,{isLoggedIn:o=!1}=t,{currentEffectiveRole:s=""}=t,{aclMode:a=""}=t;const l=P();return e.$$set=e=>{"isLoggedIn"in e&&n(0,o=e.isLoggedIn),"currentEffectiveRole"in e&&n(6,s=e.currentEffectiveRole),"aclMode"in e&&n(7,a=e.aclMode)},e.$$.update=()=>{129&e.$$.dirty&&n(2,r="none"===a||o),192&e.$$.dirty&&n(1,i="none"===a||"admin"===s||"owner"===s)},[o,i,r,function(){l("exportMyEvents")},function(){l("exportAllEvents")},function(){l("openLoginModal")},s,a]}class sm extends ae{constructor(e){super(),se(this,e,om,im,o,{isLoggedIn:0,currentEffectiveRole:6,aclMode:7})}}function am(t){let n,r,i,o,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Import Events",i=m(),o=h("p"),o.textContent="Please log in to access import functionality.",s=m(),a=h("button"),a.textContent="Log In",A(r,"class","recovery-header svelte-nonyqh"),A(o,"class","recovery-description svelte-nonyqh"),A(a,"class","login-btn svelte-nonyqh"),A(n,"class","login-prompt svelte-nonyqh")},m(e,d){u(e,n,d),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),l||(f=w(a,"click",t[6]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function lm(t){let n;return{c(){n=h("div"),n.innerHTML='<h3 class="recovery-header svelte-nonyqh">Import Events</h3> \n <p class="recovery-description svelte-nonyqh">Admin or owner permission required for import functionality.</p>',A(n,"class","permission-denied svelte-nonyqh")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function cm(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,I,E=e[2]&&um(e);return{c(){t=h("h3"),t.textContent="Import Events",n=m(),i=h("p"),i.textContent="Upload a JSONL file to import events into the database.",o=m(),s=h("div"),a=h("input"),l=m(),f=h("div"),p=h("button"),y=g("Import Events"),b=m(),E&&E.c(),A(t,"class","svelte-nonyqh"),A(i,"class","svelte-nonyqh"),A(a,"type","file"),A(a,"id","import-file"),A(a,"accept",".jsonl,.txt"),A(a,"class","svelte-nonyqh"),A(p,"class","import-btn svelte-nonyqh"),p.disabled=v=!e[1]||"Uploading..."===e[2],A(f,"class","import-row svelte-nonyqh"),A(s,"class","recovery-controls-card svelte-nonyqh")},m(r,d){u(r,t,d),u(r,n,d),u(r,i,d),u(r,o,d),u(r,s,d),c(s,a),c(s,l),c(s,f),c(f,p),c(p,y),c(f,b),E&&E.m(f,null),k||(I=[w(a,"change",e[4]),w(p,"click",e[5])],k=!0)},p(e,t){6&t&&v!==(v=!e[1]||"Uploading..."===e[2])&&(p.disabled=v),e[2]?E?E.p(e,t):(E=um(e),E.c(),E.m(f,null)):E&&(E.d(1),E=null)},d(e){e&&d(t),e&&d(n),e&&d(i),e&&d(o),e&&d(s),E&&E.d(),k=!1,r(I)}}}function um(e){let t,n;return{c(){t=h("span"),n=g(e[2]),A(t,"class","import-message svelte-nonyqh"),B(t,"uploading","Uploading..."===e[2]),B(t,"success","Upload complete"===e[2]),B(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,r){u(e,t,r),c(t,n)},p(e,r){4&r&&k(n,e[2]),4&r&&B(t,"uploading","Uploading..."===e[2]),4&r&&B(t,"success","Upload complete"===e[2]),4&r&&B(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&d(t)}}}function dm(t){let n;function r(e,t){return e[3]?cm:e[0]?lm:am}let i=r(t),o=i(t);return{c(){n=h("div"),o.c(),A(n,"class","import-section svelte-nonyqh")},m(e,t){u(e,n,t),o.m(n,null)},p(e,[t]){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n,null)))},i:e,o:e,d(e){e&&d(n),o.d()}}}function fm(e,t,n){let r,{isLoggedIn:i=!1}=t,{currentEffectiveRole:o=""}=t,{selectedFile:s=null}=t,{aclMode:a=""}=t,{importMessage:l=""}=t;const c=P();return e.$$set=e=>{"isLoggedIn"in e&&n(0,i=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,o=e.currentEffectiveRole),"selectedFile"in e&&n(1,s=e.selectedFile),"aclMode"in e&&n(8,a=e.aclMode),"importMessage"in e&&n(2,l=e.importMessage)},e.$$.update=()=>{385&e.$$.dirty&&n(3,r="none"===a||i&&("admin"===o||"owner"===o))},[i,s,l,r,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},o,a]}class hm extends ae{constructor(e){super(),se(this,e,fm,dm,o,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const pm={0:"Profile Metadata",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete Request",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1063:"File Metadata",1311:"Live Chat Message",1984:"Reporting",1985:"Label",9734:"Zap Request",9735:"Zap Receipt",1e4:"Mute List",10001:"Pin List",10002:"Relay List Metadata",10003:"Bookmark List",10004:"Communities List",10005:"Public Chats List",10006:"Blocked Relays List",10007:"Search Relays List",10009:"User Groups",10015:"Interests List",10030:"User Emoji List",13194:"Wallet Info",22242:"Client Auth",23194:"Wallet Request",23195:"Wallet Response",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People List",30001:"Categorized Bookmarks",30002:"Categorized Relay List",30003:"Bookmark Sets",30004:"Curation Sets",30005:"Video Sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest Sets",30017:"Create/Update Stall",30018:"Create/Update Product",30019:"Marketplace UI/UX",30020:"Product Sold As Auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji Sets",30063:"Release Artifact Sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30388:"Slide Set",30402:"Classified Listing",30403:"Draft Classified Listing",30617:"Repository Announcement",30618:"Repository State Announcement",30818:"Wiki Article",30819:"Redirects",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler Recommendation",31990:"Handler Information",34550:"Community Definition",34551:"Community Post Approval"};function gm(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function mm(e){const t=new Date(1e3*e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function ym(e){return Math.floor(new Date(e).getTime()/1e3)}function wm(e,t,n){const r=e.slice();return r[62]=t[n],r[64]=n,r}function vm(e,t,n){const r=e.slice();return r[65]=t[n],r}function Am(e,t,n){const r=e.slice();return r[68]=t[n],r}function bm(e,t,n){const r=e.slice();return r[71]=t[n],r}function km(e,t,n){const r=e.slice();return r[71]=t[n].kind,r[74]=t[n].name,r}function Im(e){let t,n,r,i,o,s,a=e[20],l=[];for(let t=0;t<a.length;t+=1)l[t]=Em(km(e,a,t));return{c(){t=h("div"),n=h("input"),r=m(),i=h("div");for(let e=0;e<l.length;e+=1)l[e].c();A(n,"type","text"),A(n,"placeholder","Search kinds..."),A(n,"class","filter-input kind-search svelte-1a1v6k0"),A(i,"class","kinds-list svelte-1a1v6k0"),A(t,"class","kinds-picker svelte-1a1v6k0")},m(a,d){u(a,t,d),c(t,n),I(n,e[9]),c(t,r),c(t,i);for(let e=0;e<l.length;e+=1)l[e]&&l[e].m(i,null);o||(s=w(n,"input",e[40]),o=!0)},p(e,t){if(512&t[0]&&n.value!==e[9]&&I(n,e[9]),9437186&t[0]){let n;for(a=e[20],n=0;n<a.length;n+=1){const r=km(e,a,n);l[n]?l[n].p(r,t):(l[n]=Em(r),l[n].c(),l[n].m(i,null))}for(;n<l.length;n+=1)l[n].d(1);l.length=a.length}},d(e){e&&d(t),f(l,e),o=!1,s()}}}function Em(e){let t,n,r,i,o,s,a,l,f,p,y,v,b=e[71]+"",I=e[74]+"";function E(){return e[41](e[71])}return{c(){t=h("label"),n=h("input"),i=m(),o=h("span"),s=g(b),a=m(),l=h("span"),f=g(I),p=m(),A(n,"type","checkbox"),n.checked=r=e[1].includes(e[71]),A(n,"class","svelte-1a1v6k0"),A(o,"class","kind-number svelte-1a1v6k0"),A(l,"class","kind-name svelte-1a1v6k0"),A(t,"class","kind-checkbox svelte-1a1v6k0")},m(e,r){u(e,t,r),c(t,n),c(t,i),c(t,o),c(o,s),c(t,a),c(t,l),c(l,f),c(t,p),y||(v=w(n,"change",E),y=!0)},p(t,i){e=t,1048578&i[0]&&r!==(r=e[1].includes(e[71]))&&(n.checked=r),1048576&i[0]&&b!==(b=e[71]+"")&&k(s,b),1048576&i[0]&&I!==(I=e[74]+"")&&k(f,I)},d(e){e&&d(t),y=!1,v()}}}function Cm(e){let t,n=e[1],r=[];for(let t=0;t<n.length;t+=1)r[t]=xm(bm(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();A(t,"class","chips-container svelte-1a1v6k0")},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,i){if(16777218&i[0]){let o;for(n=e[1],o=0;o<n.length;o+=1){const s=bm(e,n,o);r[o]?r[o].p(s,i):(r[o]=xm(s),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function xm(e){let t,n,r,i,o,s,a,l,f,p,y=e[71]+"",v=(pm[e[71]]||`Kind ${e[71]}`)+"";function b(){return e[42](e[71])}return{c(){t=h("div"),n=h("span"),r=g(y),i=g(": "),o=g(v),s=m(),a=h("button"),a.textContent="×",l=m(),A(n,"class","chip-text svelte-1a1v6k0"),A(a,"class","chip-remove svelte-1a1v6k0"),A(t,"class","chip svelte-1a1v6k0")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(n,o),c(t,s),c(t,a),c(t,l),f||(p=w(a,"click",b),f=!0)},p(t,n){e=t,2&n[0]&&y!==(y=e[71]+"")&&k(r,y),2&n[0]&&v!==(v=(pm[e[71]]||`Kind ${e[71]}`)+"")&&k(o,v)},d(e){e&&d(t),f=!1,p()}}}function Bm(e){let t,n;return{c(){t=h("div"),n=g(e[17]),A(t,"class","error-message svelte-1a1v6k0")},m(e,r){u(e,t,r),c(t,n)},p(e,t){131072&t[0]&&k(n,e[17])},d(e){e&&d(t)}}}function Sm(e){let t,n=e[2],r=[];for(let t=0;t<n.length;t+=1)r[t]=Fm(Am(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();A(t,"class","list-items svelte-1a1v6k0")},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,i){if(67108868&i[0]){let o;for(n=e[2],o=0;o<n.length;o+=1){const s=Am(e,n,o);r[o]?r[o].p(s,i):(r[o]=Fm(s),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function Fm(e){let t,n,r,i,o,s,a,l,f=e[68]+"";function p(){return e[45](e[68])}return{c(){t=h("div"),n=h("span"),r=g(f),i=m(),o=h("button"),o.textContent="×",s=m(),A(n,"class","list-item-text svelte-1a1v6k0"),A(o,"class","list-item-remove svelte-1a1v6k0"),A(t,"class","list-item svelte-1a1v6k0")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,i),c(t,o),c(t,s),a||(l=w(o,"click",p),a=!0)},p(t,n){e=t,4&n[0]&&f!==(f=e[68]+"")&&k(r,f)},d(e){e&&d(t),a=!1,l()}}}function Qm(e){let t,n;return{c(){t=h("div"),n=g(e[18]),A(t,"class","error-message svelte-1a1v6k0")},m(e,r){u(e,t,r),c(t,n)},p(e,t){262144&t[0]&&k(n,e[18])},d(e){e&&d(t)}}}function Dm(e){let t,n=e[3],r=[];for(let t=0;t<n.length;t+=1)r[t]=Rm(vm(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();A(t,"class","list-items svelte-1a1v6k0")},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,i){if(268435464&i[0]){let o;for(n=e[3],o=0;o<n.length;o+=1){const s=vm(e,n,o);r[o]?r[o].p(s,i):(r[o]=Rm(s),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function Rm(e){let t,n,r,i,o,s,a,l,f=e[65]+"";function p(){return e[48](e[65])}return{c(){t=h("div"),n=h("span"),r=g(f),i=m(),o=h("button"),o.textContent="×",s=m(),A(n,"class","list-item-text svelte-1a1v6k0"),A(o,"class","list-item-remove svelte-1a1v6k0"),A(t,"class","list-item svelte-1a1v6k0")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,i),c(t,o),c(t,s),a||(l=w(o,"click",p),a=!0)},p(t,n){e=t,8&n[0]&&f!==(f=e[65]+"")&&k(r,f)},d(e){e&&d(t),a=!1,l()}}}function Pm(e){let t,n;return{c(){t=h("div"),n=g(e[19]),A(t,"class","error-message svelte-1a1v6k0")},m(e,r){u(e,t,r),c(t,n)},p(e,t){524288&t[0]&&k(n,e[19])},d(e){e&&d(t)}}}function $m(e){let t,n=e[4],r=[];for(let t=0;t<n.length;t+=1)r[t]=Um(wm(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();A(t,"class","list-items svelte-1a1v6k0")},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,i){if(1073741840&i[0]){let o;for(n=e[4],o=0;o<n.length;o+=1){const s=wm(e,n,o);r[o]?r[o].p(s,i):(r[o]=Um(s),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function Um(e){let t,n,r,i,o,s,a,l,f,p,y,v=e[62].name+"",b=e[62].value+"";function I(){return e[52](e[64])}return{c(){t=h("div"),n=h("span"),r=g("#"),i=g(v),o=g(": "),s=g(b),a=m(),l=h("button"),l.textContent="×",f=m(),A(n,"class","list-item-text svelte-1a1v6k0"),A(l,"class","list-item-remove svelte-1a1v6k0"),A(t,"class","list-item svelte-1a1v6k0")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(n,o),c(n,s),c(t,a),c(t,l),c(t,f),p||(y=w(l,"click",I),p=!0)},p(t,n){e=t,16&n[0]&&v!==(v=e[62].name+"")&&k(i,v),16&n[0]&&b!==(b=e[62].value+"")&&k(s,b)},d(e){e&&d(t),p=!1,y()}}}function Tm(t){let n,r,i;return{c(){n=h("button"),n.textContent="×",A(n,"class","clear-timestamp-btn svelte-1a1v6k0")},m(e,o){u(e,n,o),r||(i=w(n,"click",t[53]),r=!0)},p:e,d(e){e&&d(n),r=!1,i()}}}function Nm(t){let n,r,i;return{c(){n=h("button"),n.textContent="×",A(n,"class","clear-timestamp-btn svelte-1a1v6k0")},m(e,o){u(e,n,o),r||(i=w(n,"click",t[54]),r=!0)},p:e,d(e){e&&d(n),r=!1,i()}}}function Lm(e){let t,n,i,o,s,a,l,f,p,g=e[11]&&Om(e);return{c(){t=h("div"),n=h("label"),n.textContent="Filter JSON",i=m(),o=h("textarea"),s=m(),g&&g.c(),a=m(),l=h("button"),l.textContent="Apply JSON",A(n,"for","json-editor"),A(n,"class","svelte-1a1v6k0"),A(o,"id","json-editor"),A(o,"class","json-editor svelte-1a1v6k0"),A(o,"placeholder",'{"kinds": [1], "limit": 100}'),A(o,"rows","8"),A(l,"class","apply-json-btn svelte-1a1v6k0"),A(t,"class","json-editor-section svelte-1a1v6k0")},m(r,d){u(r,t,d),c(t,n),c(t,i),c(t,o),I(o,e[10]),c(t,s),g&&g.m(t,null),c(t,a),c(t,l),f||(p=[w(o,"input",e[56]),w(l,"click",e[22])],f=!0)},p(e,n){1024&n[0]&&I(o,e[10]),e[11]?g?g.p(e,n):(g=Om(e),g.c(),g.m(t,a)):g&&(g.d(1),g=null)},d(e){e&&d(t),g&&g.d(),f=!1,r(p)}}}function Om(e){let t,n;return{c(){t=h("div"),n=g(e[11]),A(t,"class","json-error svelte-1a1v6k0")},m(e,r){u(e,t,r),c(t,n)},p(e,t){2048&t[0]&&k(n,e[11])},d(e){e&&d(t)}}}function Mm(t){let n,i,o,s,a,l,f,p,y,v,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te,ne,re,ie,oe,se,ae,le,ce,ue,de,fe,he,pe,ge,me,ye,we,ve,Ae,be,ke,Ie,Ee,Ce,xe,Be,Se,Fe,Qe,De,Re,Pe,$e,Ue,Te,Ne,Le,Oe,Me=t[12]?"▼":"▶",_e=t[1].length+"",He=t[12]&&Im(t),je=t[1].length>0&&Cm(t),Ge=t[17]&&Bm(t),qe=t[2].length>0&&Sm(t),Ke=t[18]&&Qm(t),Je=t[3].length>0&&Dm(t),Ve=t[19]&&Pm(t),Ye=t[4].length>0&&$m(t),ze=t[5]&&Tm(t),We=t[6]&&Nm(t),Ze=t[8]&&Lm(t);return{c(){n=h("div"),i=h("div"),o=h("div"),s=h("label"),s.textContent="Search Text (NIP-50)",a=m(),l=h("div"),f=h("input"),p=m(),y=h("label"),y.textContent="Event Kinds",v=m(),E=h("div"),C=h("button"),x=g(Me),S=g(" Select Kinds ("),F=g(_e),Q=g(" selected)"),D=m(),He&&He.c(),R=m(),je&&je.c(),P=m(),$=h("label"),$.textContent="Authors (Pubkeys)",U=m(),T=h("div"),N=h("div"),L=h("input"),O=m(),M=h("button"),M.textContent="Add",_=m(),Ge&&Ge.c(),H=m(),qe&&qe.c(),j=m(),G=h("label"),G.textContent="Event IDs",q=m(),K=h("div"),J=h("div"),V=h("input"),Y=m(),z=h("button"),z.textContent="Add",W=m(),Ke&&Ke.c(),Z=m(),Je&&Je.c(),X=m(),ee=h("label"),ee.textContent="Tags (#e, #p, #a)",te=m(),ne=h("div"),re=h("div"),ie=h("span"),ie.textContent="#",oe=m(),se=h("input"),ae=m(),le=h("input"),ce=m(),ue=h("button"),ue.textContent="Add",de=m(),Ve&&Ve.c(),fe=m(),Ye&&Ye.c(),he=m(),pe=h("label"),pe.textContent="Since",ge=m(),me=h("div"),ye=h("input"),we=m(),ze&&ze.c(),ve=m(),Ae=h("label"),Ae.textContent="Until",be=m(),ke=h("div"),Ie=h("input"),Ee=m(),We&&We.c(),Ce=m(),xe=h("label"),xe.textContent="Limit",Be=m(),Se=h("div"),Fe=h("input"),Qe=m(),Ze&&Ze.c(),De=m(),Re=h("div"),Pe=h("button"),Pe.textContent="🧹",$e=m(),Ue=h("div"),Te=m(),Ne=h("button"),Ne.textContent="</>",A(s,"for","search-text"),A(s,"class","svelte-1a1v6k0"),A(f,"id","search-text"),A(f,"type","text"),A(f,"placeholder","Search events..."),A(f,"class","filter-input svelte-1a1v6k0"),A(l,"class","field-content svelte-1a1v6k0"),A(y,"class","svelte-1a1v6k0"),A(C,"class","picker-toggle-btn svelte-1a1v6k0"),A(E,"class","field-content svelte-1a1v6k0"),A($,"class","svelte-1a1v6k0"),A(L,"type","text"),A(L,"placeholder","64 character hex pubkey..."),A(L,"class","filter-input svelte-1a1v6k0"),A(L,"maxlength","64"),A(M,"class","add-btn svelte-1a1v6k0"),A(N,"class","input-group svelte-1a1v6k0"),A(T,"class","field-content svelte-1a1v6k0"),A(G,"class","svelte-1a1v6k0"),A(V,"type","text"),A(V,"placeholder","64 character hex event ID..."),A(V,"class","filter-input svelte-1a1v6k0"),A(V,"maxlength","64"),A(z,"class","add-btn svelte-1a1v6k0"),A(J,"class","input-group svelte-1a1v6k0"),A(K,"class","field-content svelte-1a1v6k0"),A(ee,"class","svelte-1a1v6k0"),A(ie,"class","hash-prefix svelte-1a1v6k0"),A(se,"type","text"),A(se,"placeholder","Tag"),A(se,"class","filter-input tag-name-input svelte-1a1v6k0"),A(se,"maxlength","1"),A(le,"type","text"),A(le,"placeholder","Value..."),A(le,"class","filter-input tag-value-input svelte-1a1v6k0"),A(ue,"class","add-btn svelte-1a1v6k0"),A(re,"class","tag-input-group svelte-1a1v6k0"),A(ne,"class","field-content svelte-1a1v6k0"),A(pe,"for","since-timestamp"),A(pe,"class","svelte-1a1v6k0"),A(ye,"id","since-timestamp"),A(ye,"type","datetime-local"),ye.value=t[32](),A(ye,"class","filter-input svelte-1a1v6k0"),A(me,"class","field-content timestamp-field svelte-1a1v6k0"),A(Ae,"for","until-timestamp"),A(Ae,"class","svelte-1a1v6k0"),A(Ie,"id","until-timestamp"),A(Ie,"type","datetime-local"),Ie.value=t[33](),A(Ie,"class","filter-input svelte-1a1v6k0"),A(ke,"class","field-content timestamp-field svelte-1a1v6k0"),A(xe,"for","limit"),A(xe,"class","svelte-1a1v6k0"),A(Fe,"id","limit"),A(Fe,"type","number"),A(Fe,"placeholder","Max events to return"),A(Fe,"class","filter-input svelte-1a1v6k0"),A(Fe,"min","1"),A(Se,"class","field-content svelte-1a1v6k0"),A(o,"class","filter-grid svelte-1a1v6k0"),A(i,"class","filter-content svelte-1a1v6k0"),A(Pe,"class","clear-all-btn svelte-1a1v6k0"),A(Pe,"title","Clear all filters"),A(Ue,"class","spacer svelte-1a1v6k0"),A(Ne,"class","json-toggle-btn svelte-1a1v6k0"),A(Ne,"title","Edit filter JSON"),B(Ne,"active",t[8]),A(Re,"class","clear-column svelte-1a1v6k0"),A(n,"class","filter-builder svelte-1a1v6k0")},m(e,r){u(e,n,r),c(n,i),c(i,o),c(o,s),c(o,a),c(o,l),c(l,f),I(f,t[0]),c(o,p),c(o,y),c(o,v),c(o,E),c(E,C),c(C,x),c(C,S),c(C,F),c(C,Q),c(E,D),He&&He.m(E,null),c(E,R),je&&je.m(E,null),c(o,P),c(o,$),c(o,U),c(o,T),c(T,N),c(N,L),I(L,t[13]),c(N,O),c(N,M),c(T,_),Ge&&Ge.m(T,null),c(T,H),qe&&qe.m(T,null),c(o,j),c(o,G),c(o,q),c(o,K),c(K,J),c(J,V),I(V,t[14]),c(J,Y),c(J,z),c(K,W),Ke&&Ke.m(K,null),c(K,Z),Je&&Je.m(K,null),c(o,X),c(o,ee),c(o,te),c(o,ne),c(ne,re),c(re,ie),c(re,oe),c(re,se),I(se,t[15]),c(re,ae),c(re,le),I(le,t[16]),c(re,ce),c(re,ue),c(ne,de),Ve&&Ve.m(ne,null),c(ne,fe),Ye&&Ye.m(ne,null),c(o,he),c(o,pe),c(o,ge),c(o,me),c(me,ye),c(me,we),ze&&ze.m(me,null),c(o,ve),c(o,Ae),c(o,be),c(o,ke),c(ke,Ie),c(ke,Ee),We&&We.m(ke,null),c(o,Ce),c(o,xe),c(o,Be),c(o,Se),c(Se,Fe),I(Fe,t[7]),c(o,Qe),Ze&&Ze.m(o,null),c(n,De),c(n,Re),c(Re,Pe),c(Re,$e),c(Re,Ue),c(Re,Te),c(Re,Ne),Le||(Oe=[w(f,"input",t[38]),w(C,"click",t[39]),w(L,"input",t[43]),w(L,"keydown",t[44]),w(M,"click",t[25]),w(V,"input",t[46]),w(V,"keydown",t[47]),w(z,"click",t[27]),w(se,"input",t[49]),w(le,"input",t[50]),w(le,"keydown",t[51]),w(ue,"click",t[29]),w(ye,"change",t[34]),w(Ie,"change",t[35]),w(Fe,"input",t[55]),w(Pe,"click",t[31]),w(Ne,"click",t[57])],Le=!0)},p(e,t){1&t[0]&&f.value!==e[0]&&I(f,e[0]),4096&t[0]&&Me!==(Me=e[12]?"▼":"▶")&&k(x,Me),2&t[0]&&_e!==(_e=e[1].length+"")&&k(F,_e),e[12]?He?He.p(e,t):(He=Im(e),He.c(),He.m(E,R)):He&&(He.d(1),He=null),e[1].length>0?je?je.p(e,t):(je=Cm(e),je.c(),je.m(E,null)):je&&(je.d(1),je=null),8192&t[0]&&L.value!==e[13]&&I(L,e[13]),e[17]?Ge?Ge.p(e,t):(Ge=Bm(e),Ge.c(),Ge.m(T,H)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?qe?qe.p(e,t):(qe=Sm(e),qe.c(),qe.m(T,null)):qe&&(qe.d(1),qe=null),16384&t[0]&&V.value!==e[14]&&I(V,e[14]),e[18]?Ke?Ke.p(e,t):(Ke=Qm(e),Ke.c(),Ke.m(K,Z)):Ke&&(Ke.d(1),Ke=null),e[3].length>0?Je?Je.p(e,t):(Je=Dm(e),Je.c(),Je.m(K,null)):Je&&(Je.d(1),Je=null),32768&t[0]&&se.value!==e[15]&&I(se,e[15]),65536&t[0]&&le.value!==e[16]&&I(le,e[16]),e[19]?Ve?Ve.p(e,t):(Ve=Pm(e),Ve.c(),Ve.m(ne,fe)):Ve&&(Ve.d(1),Ve=null),e[4].length>0?Ye?Ye.p(e,t):(Ye=$m(e),Ye.c(),Ye.m(ne,null)):Ye&&(Ye.d(1),Ye=null),e[5]?ze?ze.p(e,t):(ze=Tm(e),ze.c(),ze.m(me,null)):ze&&(ze.d(1),ze=null),e[6]?We?We.p(e,t):(We=Nm(e),We.c(),We.m(ke,null)):We&&(We.d(1),We=null),128&t[0]&&b(Fe.value)!==e[7]&&I(Fe,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=Lm(e),Ze.c(),Ze.m(o,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&B(Ne,"active",e[8])},i:e,o:e,d(e){e&&d(n),He&&He.d(),je&&je.d(),Ge&&Ge.d(),qe&&qe.d(),Ke&&Ke.d(),Je&&Je.d(),Ve&&Ve.d(),Ye&&Ye.d(),ze&&ze.d(),We&&We.d(),Ze&&Ze.d(),Le=!1,r(Oe)}}}function _m(e,t,n){let r,i;const o=P();let{searchText:s=""}=t,{selectedKinds:a=[]}=t,{pubkeys:l=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:h=null}=t,{showJsonEditor:p=!1}=t,g="",m="",y=!1,w="",v="",A="",k="",I="",E="",C="",x="",B=null,S=!1;function F(e){a.includes(e)?n(1,a=a.filter(t=>t!==e)):n(1,a=[...a,e].sort((e,t)=>e-t))}function Q(e){n(1,a=a.filter(t=>t!==e))}function D(){const e=v.trim();e&&(gm(e,64)?l.includes(e)?n(17,E="Pubkey already added"):(n(2,l=[...l,e]),n(13,v=""),n(17,E="")):n(17,E="Invalid pubkey: must be 64 character hex string"))}function $(e){n(2,l=l.filter(t=>t!==e))}function U(){const e=A.trim();e&&(gm(e,64)?c.includes(e)?n(18,C="Event ID already added"):(n(3,c=[...c,e]),n(14,A=""),n(18,C="")):n(18,C="Invalid event ID: must be 64 character hex string"))}function T(e){n(3,c=c.filter(t=>t!==e))}function N(){const e=k.trim(),t=I.trim();e&&t&&(/^[a-zA-Z]$/.test(e)?u.some(n=>n.name===e&&n.value===t)?n(19,x="Tag already added"):(n(4,u=[...u,{name:e,value:t}]),n(15,k=""),n(16,I=""),n(19,x="")):n(19,x="Invalid tag name: must be single letter a-z or A-Z"))}function L(e){n(4,u=u.filter((t,n)=>n!==e))}function O(){o("apply",{searchText:s,selectedKinds:a,pubkeys:l,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:h})}R(()=>{B&&clearTimeout(B)});return e.$$set=e=>{"searchText"in e&&n(0,s=e.searchText),"selectedKinds"in e&&n(1,a=e.selectedKinds),"pubkeys"in e&&n(2,l=e.pubkeys),"eventIds"in e&&n(3,c=e.eventIds),"tags"in e&&n(4,u=e.tags),"sinceTimestamp"in e&&n(5,d=e.sinceTimestamp),"untilTimestamp"in e&&n(6,f=e.untilTimestamp),"limit"in e&&n(7,h=e.limit),"showJsonEditor"in e&&n(8,p=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&p){const e=function(){const e={};return a.length>0&&(e.kinds=a),l.length>0&&(e.authors=l),c.length>0&&(e.ids=c),d&&(e.since=d),f&&(e.until=f),h&&(e.limit=h),s&&(e.search=s),u.forEach(t=>{const n=`#${t.name}`;e[n]||(e[n]=[]),e[n].push(t.value)}),e}();n(10,g=JSON.stringify(e,null,2))}255&e.$$.dirty[0]|32&e.$$.dirty[1]&&(S?(B&&clearTimeout(B),B=setTimeout(()=>{O()},1e3)):n(36,S=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,i=r.filter(e=>e.kind.toString().includes(w)||e.name.toLowerCase().includes(w.toLowerCase())))},n(37,r=Object.entries(pm).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[s,a,l,c,u,d,f,h,p,w,g,m,y,v,A,k,I,E,C,x,i,o,function(){try{const e=JSON.parse(g);n(11,m=""),n(1,a=e.kinds||[]),n(2,l=e.authors||[]),n(3,c=e.ids||[]),n(5,d=e.since||null),n(6,f=e.until||null),n(7,h=e.limit||null),n(0,s=e.search||""),n(4,u=[]),Object.keys(e).forEach(t=>{if(t.startsWith("#")&&2===t.length){const n=t.slice(1);(Array.isArray(e[t])?e[t]:[e[t]]).forEach(e=>{u.push({name:n,value:String(e)})})}}),n(4,u),B&&clearTimeout(B),O()}catch(e){n(11,m="Invalid JSON: "+e.message)}},F,Q,D,$,U,T,N,L,function(){n(0,s=""),n(1,a=[]),n(2,l=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,h=null),o("clear")},function(){return d?mm(d):""},function(){return f?mm(f):""},function(e){const t=e.target.value;n(5,d=t?ym(t):null)},function(e){const t=e.target.value;n(6,f=t?ym(t):null)},S,r,function(){s=this.value,n(0,s)},()=>n(12,y=!y),function(){w=this.value,n(9,w)},e=>F(e),e=>Q(e),function(){v=this.value,n(13,v)},e=>"Enter"===e.key&&D(),e=>$(e),function(){A=this.value,n(14,A)},e=>"Enter"===e.key&&U(),e=>T(e),function(){k=this.value,n(15,k)},function(){I=this.value,n(16,I)},e=>"Enter"===e.key&&N(),e=>L(e),()=>n(5,d=null),()=>n(6,f=null),function(){h=b(this.value),n(7,h)},function(){g=this.value,n(10,g),n(8,p)},()=>o("toggleJson")]}class Hm extends ae{constructor(e){super(),se(this,e,_m,Mm,o,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function jm(e,t,n){const r=e.slice();return r[28]=t[n],r}function Gm(e,t,n){const r=e.slice();return r[31]=t[n],r}function qm(t){let n;return{c(){n=h("div"),n.innerHTML="<p>❌ Read, write, admin, or owner permission required to view all\n events.</p>",A(n,"class","permission-denied svelte-5kb1ec")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Km(e){let t,n,r,i;function o(e,t){return e[4].length>0?Vm:e[6]?void 0:Jm}let s=o(e),a=s&&s(e),l=e[6]&&ny();return{c(){t=h("div"),a&&a.c(),n=m(),l&&l.c(),A(t,"class","events-view-content svelte-5kb1ec")},m(o,s){u(o,t,s),a&&a.m(t,null),c(t,n),l&&l.m(t,null),r||(i=w(t,"scroll",e[9]),r=!0)},p(e,r){s===(s=o(e))&&a?a.p(e,r):(a&&a.d(1),a=s&&s(e),a&&(a.c(),a.m(t,n))),e[6]?l||(l=ny(),l.c(),l.m(t,null)):l&&(l.d(1),l=null)},d(e){e&&d(t),a&&a.d(),l&&l.d(),r=!1,i()}}}function Jm(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No events found.</p>",A(n,"class","no-events svelte-5kb1ec")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Vm(e){let t,n=e[4],r=[];for(let t=0;t<n.length;t+=1)r[t]=ty(jm(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(7228&i[0]){let o;for(n=e[4],o=0;o<n.length;o+=1){const s=jm(e,n,o);r[o]?r[o].p(s,i):(r[o]=ty(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function Ym(e){let t,n,r=uy(e[28].content)+"";return{c(){t=h("div"),n=g(r),A(t,"class","event-content-single-line svelte-5kb1ec")},m(e,r){u(e,t,r),c(t,n)},p(e,t){16&t[0]&&r!==(r=uy(e[28].content)+"")&&k(n,r)},d(e){e&&d(t)}}}function zm(e){let t,n,r,i=e[28].tags&&e[28].tags.length>0&&Wm(e);return{c(){t=h("div"),n=h("span"),n.textContent="🗑️ Delete Event",r=m(),i&&i.c(),A(n,"class","delete-event-label svelte-5kb1ec"),A(t,"class","delete-event-info svelte-5kb1ec")},m(e,o){u(e,t,o),c(t,n),c(t,r),i&&i.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?i?i.p(e,n):(i=Wm(e),i.c(),i.m(t,null)):i&&(i.d(1),i=null)},d(e){e&&d(t),i&&i.d()}}}function Wm(e){let t,n=e[28].tags.filter(dy),r=[];for(let t=0;t<n.length;t+=1)r[t]=Zm(Gm(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();A(t,"class","delete-targets svelte-5kb1ec")},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,i){if(16&i[0]){let o;for(n=e[28].tags.filter(dy),o=0;o<n.length;o+=1){const s=Gm(e,n,o);r[o]?r[o].p(s,i):(r[o]=Zm(s),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function Zm(e){let t,n,r,i,o,s=e[31][1].slice(0,8)+"",a=e[31][1].slice(-8)+"";return{c(){t=h("span"),n=g("Target: "),r=g(s),i=g("..."),o=g(a),A(t,"class","delete-target svelte-5kb1ec")},m(e,s){u(e,t,s),c(t,n),c(t,r),c(t,i),c(t,o)},p(e,t){16&t[0]&&s!==(s=e[31][1].slice(0,8)+"")&&k(r,s),16&t[0]&&a!==(a=e[31][1].slice(-8)+"")&&k(o,a)},d(e){e&&d(t)}}}function Xm(e){let t,n,r;function i(){return e[19](e[28])}return{c(){t=h("button"),t.textContent="🗑️",A(t,"class","delete-btn svelte-5kb1ec")},m(e,o){u(e,t,o),n||(r=w(t,"click",v(i)),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r()}}}function ey(e){let t,n,r,i,o,s,a,l,f=JSON.stringify(e[28],null,2)+"";function p(...t){return e[22](e[28],...t)}return{c(){t=h("div"),n=h("div"),r=h("pre"),i=g(f),o=m(),s=h("button"),s.textContent="📋",A(r,"class","event-json svelte-5kb1ec"),A(s,"class","copy-json-btn svelte-5kb1ec"),A(s,"title","Copy minified JSON to clipboard"),A(n,"class","json-container svelte-5kb1ec"),A(t,"class","events-view-details svelte-5kb1ec")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,i),c(n,o),c(n,s),a||(l=w(s,"click",v(p)),a=!0)},p(t,n){e=t,16&n[0]&&f!==(f=JSON.stringify(e[28],null,2)+"")&&k(i,f)},d(e){e&&d(t),a=!1,l()}}}function ty(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,S,F,Q,D,R,P,$,U,T=ay(e[28].pubkey)+"",N=e[28].kind+"",L=ly(e[28].kind)+"",O=cy(e[28].created_at)+"",M=e[5].has(e[28].id);function _(e,t){return 5===e[28].kind?zm:Ym}let H=_(e),j=H(e),G=5!==e[28].kind&&("admin"===e[2]||"owner"===e[2]||"write"===e[2]&&e[28].pubkey&&e[28].pubkey===e[3])&&Xm(e);function q(){return e[20](e[28])}function K(...t){return e[21](e[28],...t)}let J=M&&ey(e);return{c(){t=h("div"),n=h("div"),i=h("div"),i.innerHTML='<div class="avatar-placeholder svelte-5kb1ec">👤</div>',o=m(),s=h("div"),a=h("div"),l=g(T),f=m(),p=h("div"),y=h("span"),v=g(N),b=m(),I=h("span"),E=g(L),C=m(),x=h("div"),S=h("div"),F=g(O),Q=m(),j.c(),D=m(),G&&G.c(),R=m(),J&&J.c(),P=m(),A(i,"class","events-view-avatar svelte-5kb1ec"),A(a,"class","events-view-author svelte-5kb1ec"),A(y,"class","kind-number svelte-5kb1ec"),B(y,"delete-event",5===e[28].kind),A(I,"class","kind-name svelte-5kb1ec"),A(p,"class","events-view-kind svelte-5kb1ec"),A(s,"class","events-view-info svelte-5kb1ec"),A(S,"class","event-timestamp svelte-5kb1ec"),A(x,"class","events-view-content svelte-5kb1ec"),A(n,"class","events-view-row svelte-5kb1ec"),A(n,"role","button"),A(n,"tabindex","0"),A(t,"class","events-view-item svelte-5kb1ec"),B(t,"expanded",e[5].has(e[28].id))},m(e,r){u(e,t,r),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(s,f),c(s,p),c(p,y),c(y,v),c(p,b),c(p,I),c(I,E),c(n,C),c(n,x),c(x,S),c(S,F),c(x,Q),j.m(x,null),c(n,D),G&&G.m(n,null),c(t,R),J&&J.m(t,null),c(t,P),$||(U=[w(n,"click",q),w(n,"keydown",K)],$=!0)},p(r,i){e=r,16&i[0]&&T!==(T=ay(e[28].pubkey)+"")&&k(l,T),16&i[0]&&N!==(N=e[28].kind+"")&&k(v,N),16&i[0]&&B(y,"delete-event",5===e[28].kind),16&i[0]&&L!==(L=ly(e[28].kind)+"")&&k(E,L),16&i[0]&&O!==(O=cy(e[28].created_at)+"")&&k(F,O),H===(H=_(e))&&j?j.p(e,i):(j.d(1),j=H(e),j&&(j.c(),j.m(x,null))),5!==e[28].kind&&("admin"===e[2]||"owner"===e[2]||"write"===e[2]&&e[28].pubkey&&e[28].pubkey===e[3])?G?G.p(e,i):(G=Xm(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),48&i[0]&&(M=e[5].has(e[28].id)),M?J?J.p(e,i):(J=ey(e),J.c(),J.m(t,P)):J&&(J.d(1),J=null),48&i[0]&&B(t,"expanded",e[5].has(e[28].id))},d(e){e&&d(t),j.d(),G&&G.d(),J&&J.d(),$=!1,r(U)}}}function ny(e){let t;return{c(){t=h("div"),t.innerHTML='<div class="spinner svelte-5kb1ec"></div> \n <p>Loading events...</p>',A(t,"class","loading-events svelte-5kb1ec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function ry(e){let t,n,i,o,s,a,l,f,p,y,v,b,k,I,E,C,x,S,F,Q,D,R,P,$;function U(e,t){return e[6]?oy:iy}i=new Hm({props:{showJsonEditor:e[8]}}),i.$on("apply",e[17]),i.$on("clear",e[18]),i.$on("toggleJson",e[16]);let T=U(e),N=T(e);return{c(){t=h("div"),n=h("div"),ne(i.$$.fragment),o=m(),s=h("div"),a=h("div"),l=h("button"),l.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-5kb1ec"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon></svg>',f=m(),p=h("div"),y=h("label"),v=h("input"),b=m(),k=h("span"),I=m(),E=h("span"),E.textContent="Only show my events",C=m(),x=h("div"),S=h("button"),F=g("🔄 Load More"),Q=m(),D=h("button"),N.c(),A(n,"class","filter-panel svelte-5kb1ec"),B(n,"open",e[7]),A(l,"class","filter-btn svelte-5kb1ec"),A(l,"title","Filter events"),B(l,"active",e[7]),A(v,"type","checkbox"),A(v,"class","svelte-5kb1ec"),A(k,"class","toggle-slider svelte-5kb1ec"),A(E,"class","toggle-label svelte-5kb1ec"),A(y,"class","toggle-container svelte-5kb1ec"),A(p,"class","events-view-toggle svelte-5kb1ec"),A(a,"class","events-view-left svelte-5kb1ec"),A(S,"class","refresh-btn svelte-5kb1ec"),S.disabled=e[6],A(D,"class","reload-btn svelte-5kb1ec"),D.disabled=e[6],A(x,"class","events-view-buttons svelte-5kb1ec"),A(s,"class","events-view-header svelte-5kb1ec"),A(t,"class","events-view-footer svelte-5kb1ec")},m(r,d){u(r,t,d),c(t,n),re(i,n,null),c(t,o),c(t,s),c(s,a),c(a,l),c(a,f),c(a,p),c(p,y),c(y,v),v.checked=e[0],c(y,b),c(y,k),c(y,I),c(y,E),c(s,C),c(s,x),c(x,S),c(S,F),c(x,Q),c(x,D),N.m(D,null),R=!0,P||($=[w(l,"click",e[15]),w(v,"change",e[23]),w(v,"change",e[24]),w(S,"click",e[25]),w(D,"click",e[26])],P=!0)},p(e,t){const r={};256&t[0]&&(r.showJsonEditor=e[8]),i.$set(r),(!R||128&t[0])&&B(n,"open",e[7]),(!R||128&t[0])&&B(l,"active",e[7]),1&t[0]&&(v.checked=e[0]),(!R||64&t[0])&&(S.disabled=e[6]),T!==(T=U(e))&&(N.d(1),N=T(e),N&&(N.c(),N.m(D,null))),(!R||64&t[0])&&(D.disabled=e[6])},i(e){R||(W(i.$$.fragment,e),R=!0)},o(e){Z(i.$$.fragment,e),R=!1},d(e){e&&d(t),ie(i),N.d(),P=!1,r($)}}}function iy(e){let t;return{c(){t=g("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function oy(e){let t;return{c(){t=h("div"),A(t,"class","spinner svelte-5kb1ec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function sy(e){let t,n,r;function i(e,t){return!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?qm:Km}let o=i(e),s=o(e),a=e[1]&&("read"===e[2]||"write"===e[2]||"admin"===e[2]||"owner"===e[2])&&ry(e);return{c(){t=h("div"),s.c(),n=m(),a&&a.c(),A(t,"class","events-view-container svelte-5kb1ec")},m(e,i){u(e,t,i),s.m(t,null),c(t,n),a&&a.m(t,null),r=!0},p(e,r){o===(o=i(e))&&s?s.p(e,r):(s.d(1),s=o(e),s&&(s.c(),s.m(t,n))),!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?a&&(Y(),Z(a,1,1,()=>{a=null}),z()):a?(a.p(e,r),6&r[0]&&W(a,1)):(a=ry(e),a.c(),W(a,1),a.m(t,null))},i(e){r||(W(a),r=!0)},o(e){Z(a),r=!1},d(e){e&&d(t),s.d(),a&&a.d()}}}function ay(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function ly(e){return{0:"Profile",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1984:"Reporting",9734:"Zap Request",9735:"Zap",1e4:"Mute List",10001:"Pin List",10002:"Relay List",22242:"Client Auth",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People",30001:"Categorized Bookmarks",30008:"Profile Badges",30009:"Badge Definition",30017:"Create or update a stall",30018:"Create or update a product",30023:"Long-form Content",30024:"Draft Long-form Content",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34550:"Community Definition"}[e]||`Kind ${e}`}function cy(e){return new Date(1e3*e).toLocaleString()}function uy(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const dy=e=>"e"===e[0];function fy(e,t,n){let{isLoggedIn:r=!1}=t,{userRole:i=""}=t,{userPubkey:o=""}=t,{filteredEvents:s=[]}=t,{expandedEvents:a=new Set}=t,{isLoadingEvents:l=!1}=t,{showOnlyMyEvents:c=!1}=t,{showFilterBuilder:u=!1}=t;const d=P();let f=!1;function h(e){d("toggleEventExpansion",e)}function p(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function y(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(1,r=e.isLoggedIn),"userRole"in e&&n(2,i=e.userRole),"userPubkey"in e&&n(3,o=e.userPubkey),"filteredEvents"in e&&n(4,s=e.filteredEvents),"expandedEvents"in e&&n(5,a=e.expandedEvents),"isLoadingEvents"in e&&n(6,l=e.isLoadingEvents),"showOnlyMyEvents"in e&&n(0,c=e.showOnlyMyEvents),"showFilterBuilder"in e&&n(7,u=e.showFilterBuilder)},[c,r,i,o,s,a,l,u,f,function(e){d("scroll",e)},h,p,g,m,y,function(){d("toggleFilterBuilder")},function(){n(8,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},e=>p(e.id),e=>h(e.id),(e,t)=>"Enter"===t.key&&h(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{y(!1,c&&o?[o]:null)},()=>{y(!0,c&&o?[o]:null)}]}class hy extends ae{constructor(e){super(),se(this,e,fy,sy,o,{isLoggedIn:1,userRole:2,userPubkey:3,filteredEvents:4,expandedEvents:5,isLoadingEvents:6,showOnlyMyEvents:0,showFilterBuilder:7},null,[-1,-1])}}const py=[{kind:0,name:"Metadata",description:"User profile information (name, about, picture, nip05, etc.)",nip:"01",isReplaceable:!0,template:{kind:0,content:"",tags:[]}},{kind:1,name:"Short Text Note",description:"Short-form text post (like a tweet)",nip:"01",template:{kind:1,content:"",tags:[]}},{kind:2,name:"Recommend Relay",description:"Relay recommendation",nip:"01",deprecated:!0,template:{kind:2,content:"",tags:[]}},{kind:3,name:"Follows",description:"Following list with optional relay hints",nip:"02",isReplaceable:!0,template:{kind:3,content:"",tags:[]}},{kind:4,name:"Encrypted Direct Message",description:"Private message using NIP-04 encryption",nip:"04",deprecated:!0,template:{kind:4,content:"",tags:[]}},{kind:5,name:"Event Deletion Request",description:"Request to delete events",nip:"09",template:{kind:5,content:"",tags:[]}},{kind:6,name:"Repost",description:"Share/repost another text note",nip:"18",template:{kind:6,content:"",tags:[]}},{kind:7,name:"Reaction",description:"Like, emoji reaction to an event",nip:"25",template:{kind:7,content:"",tags:[]}},{kind:8,name:"Badge Award",description:"Award a badge to someone",nip:"58",template:{kind:8,content:"",tags:[]}},{kind:9,name:"Chat Message",description:"Chat message",nip:"C7",template:{kind:9,content:"",tags:[]}},{kind:10,name:"Group Chat Threaded Reply",description:"Threaded reply in group chat",nip:"29",deprecated:!0,template:{kind:10,content:"",tags:[]}},{kind:11,name:"Thread",description:"Thread event",nip:"7D",template:{kind:11,content:"",tags:[]}},{kind:12,name:"Group Thread Reply",description:"Reply in group thread",nip:"29",deprecated:!0,template:{kind:12,content:"",tags:[]}},{kind:13,name:"Seal",description:"Sealed/encrypted event wrapper",nip:"59",template:{kind:13,content:"",tags:[]}},{kind:14,name:"Direct Message",description:"Private direct message using NIP-17",nip:"17",template:{kind:14,content:"",tags:[]}},{kind:15,name:"File Message",description:"File message in DMs",nip:"17",template:{kind:15,content:"",tags:[]}},{kind:16,name:"Generic Repost",description:"Repost any event kind",nip:"18",template:{kind:16,content:"",tags:[]}},{kind:17,name:"Reaction to Website",description:"Reaction to a website URL",nip:"25",template:{kind:17,content:"",tags:[]}},{kind:20,name:"Picture",description:"Picture-first feed post",nip:"68",template:{kind:20,content:"",tags:[]}},{kind:21,name:"Video Event",description:"Horizontal video event",nip:"71",template:{kind:21,content:"",tags:[]}},{kind:22,name:"Short-form Video",description:"Short-form portrait video (like TikTok)",nip:"71",template:{kind:22,content:"",tags:[]}},{kind:40,name:"Channel Creation",description:"Create a public chat channel",nip:"28",template:{kind:40,content:"",tags:[]}},{kind:41,name:"Channel Metadata",description:"Set channel name, about, picture",nip:"28",template:{kind:41,content:"",tags:[]}},{kind:42,name:"Channel Message",description:"Post message in channel",nip:"28",template:{kind:42,content:"",tags:[]}},{kind:43,name:"Channel Hide Message",description:"Hide a message in channel",nip:"28",template:{kind:43,content:"",tags:[]}},{kind:44,name:"Channel Mute User",description:"Mute a user in channel",nip:"28",template:{kind:44,content:"",tags:[]}},{kind:62,name:"Request to Vanish",description:"Request permanent deletion of all user data",nip:"62",template:{kind:62,content:"",tags:[]}},{kind:64,name:"Chess (PGN)",description:"Chess game in PGN format",nip:"64",template:{kind:64,content:"",tags:[]}},{kind:443,name:"KeyPackage",description:"Marmot protocol key package",nip:null,spec:"Marmot",template:{kind:443,content:"",tags:[]}},{kind:444,name:"Welcome Message",description:"Marmot protocol welcome message",nip:null,spec:"Marmot",template:{kind:444,content:"",tags:[]}},{kind:445,name:"Group Event",description:"Marmot protocol group event",nip:null,spec:"Marmot",template:{kind:445,content:"",tags:[]}},{kind:818,name:"Merge Requests",description:"Git merge request",nip:"54",template:{kind:818,content:"",tags:[]}},{kind:1018,name:"Poll Response",description:"Response to a poll",nip:"88",template:{kind:1018,content:"",tags:[]}},{kind:1021,name:"Bid",description:"Auction bid",nip:"15",template:{kind:1021,content:"",tags:[]}},{kind:1022,name:"Bid Confirmation",description:"Confirmation of auction bid",nip:"15",template:{kind:1022,content:"",tags:[]}},{kind:1040,name:"OpenTimestamps",description:"OpenTimestamps attestation",nip:"03",template:{kind:1040,content:"",tags:[]}},{kind:1059,name:"Gift Wrap",description:"Encrypted gift-wrapped event",nip:"59",template:{kind:1059,content:"",tags:[]}},{kind:1060,name:"Gift Wrap (Kind 4)",description:"Gift wrap variant for NIP-04 compatibility",nip:"59",template:{kind:1060,content:"",tags:[]}},{kind:1063,name:"File Metadata",description:"Metadata for shared files",nip:"94",template:{kind:1063,content:"",tags:[]}},{kind:1068,name:"Poll",description:"Create a poll",nip:"88",template:{kind:1068,content:"",tags:[]}},{kind:1111,name:"Comment",description:"Comment on events or external content",nip:"22",template:{kind:1111,content:"",tags:[]}},{kind:1222,name:"Voice Message",description:"Voice message",nip:"A0",template:{kind:1222,content:"",tags:[]}},{kind:1244,name:"Voice Message Comment",description:"Comment on voice message",nip:"A0",template:{kind:1244,content:"",tags:[]}},{kind:1311,name:"Live Chat Message",description:"Message in live stream chat",nip:"53",template:{kind:1311,content:"",tags:[]}},{kind:1337,name:"Code Snippet",description:"Code snippet post",nip:"C0",template:{kind:1337,content:"",tags:[]}},{kind:1517,name:"Bitcoin Block",description:"Bitcoin block data",nip:null,spec:"Nostrocket",template:{kind:1517,content:"",tags:[]}},{kind:1617,name:"Patches",description:"Git patches",nip:"34",template:{kind:1617,content:"",tags:[]}},{kind:1618,name:"Pull Requests",description:"Git pull request",nip:"34",template:{kind:1618,content:"",tags:[]}},{kind:1619,name:"Pull Request Updates",description:"Updates to git pull request",nip:"34",template:{kind:1619,content:"",tags:[]}},{kind:1621,name:"Issues",description:"Git issues",nip:"34",template:{kind:1621,content:"",tags:[]}},{kind:1622,name:"Git Replies",description:"Replies on git objects",nip:"34",deprecated:!0,template:{kind:1622,content:"",tags:[]}},{kind:1630,name:"Status",description:"Git status",nip:"34",template:{kind:1630,content:"",tags:[]}},{kind:1631,name:"Status",description:"Git status",nip:"34",template:{kind:1631,content:"",tags:[]}},{kind:1632,name:"Status",description:"Git status",nip:"34",template:{kind:1632,content:"",tags:[]}},{kind:1633,name:"Status",description:"Git status",nip:"34",template:{kind:1633,content:"",tags:[]}},{kind:1808,name:"Live Stream",description:"Live streaming event",nip:null,spec:"zap.stream",template:{kind:1808,content:"",tags:[]}},{kind:1971,name:"Problem Tracker",description:"Problem tracking",nip:null,spec:"Nostrocket",template:{kind:1971,content:"",tags:[]}},{kind:1984,name:"Reporting",description:"Report content or users",nip:"56",template:{kind:1984,content:"",tags:[]}},{kind:1985,name:"Label",description:"Label/tag content with namespace",nip:"32",template:{kind:1985,content:"",tags:[]}},{kind:1986,name:"Relay Reviews",description:"Reviews of relays",nip:null,template:{kind:1986,content:"",tags:[]}},{kind:1987,name:"AI Embeddings",description:"AI embeddings/vector lists",nip:null,spec:"NKBIP-02",template:{kind:1987,content:"",tags:[]}},{kind:2003,name:"Torrent",description:"Torrent magnet link",nip:"35",template:{kind:2003,content:"",tags:[]}},{kind:2004,name:"Torrent Comment",description:"Comment on torrent",nip:"35",template:{kind:2004,content:"",tags:[]}},{kind:2022,name:"Coinjoin Pool",description:"Coinjoin coordination",nip:null,spec:"joinstr",template:{kind:2022,content:"",tags:[]}},{kind:4550,name:"Community Post Approval",description:"Approve post in community",nip:"72",template:{kind:4550,content:"",tags:[]}},{kind:5e3,name:"Job Request",description:"Data vending machine job request (start of range)",nip:"90",template:{kind:5e3,content:"",tags:[]}},{kind:6e3,name:"Job Result",description:"Data vending machine job result (start of range)",nip:"90",template:{kind:6e3,content:"",tags:[]}},{kind:7e3,name:"Job Feedback",description:"Feedback on job request/result",nip:"90",template:{kind:7e3,content:"",tags:[]}},{kind:7374,name:"Reserved Cashu Wallet Tokens",description:"Reserved Cashu wallet tokens",nip:"60",template:{kind:7374,content:"",tags:[]}},{kind:7375,name:"Cashu Wallet Tokens",description:"Cashu wallet tokens",nip:"60",template:{kind:7375,content:"",tags:[]}},{kind:7376,name:"Cashu Wallet History",description:"Cashu wallet transaction history",nip:"60",template:{kind:7376,content:"",tags:[]}},{kind:7516,name:"Geocache Log",description:"Geocaching log entry",nip:null,spec:"geocaching",template:{kind:7516,content:"",tags:[]}},{kind:7517,name:"Geocache Proof of Find",description:"Proof of geocache find",nip:null,spec:"geocaching",template:{kind:7517,content:"",tags:[]}},{kind:8e3,name:"Add User",description:"Add user to group",nip:"43",template:{kind:8e3,content:"",tags:[]}},{kind:8001,name:"Remove User",description:"Remove user from group",nip:"43",template:{kind:8001,content:"",tags:[]}},{kind:9e3,name:"Group Control Events",description:"Group control events (start of range)",nip:"29",template:{kind:9e3,content:"",tags:[]}},{kind:9041,name:"Zap Goal",description:"Fundraising goal for zaps",nip:"75",template:{kind:9041,content:"",tags:[]}},{kind:9321,name:"Nutzap",description:"Cashu nutzap",nip:"61",template:{kind:9321,content:"",tags:[]}},{kind:9467,name:"Tidal Login",description:"Tidal streaming login",nip:null,spec:"Tidal-nostr",template:{kind:9467,content:"",tags:[]}},{kind:9734,name:"Zap Request",description:"Request Lightning payment",nip:"57",template:{kind:9734,content:"",tags:[]}},{kind:9735,name:"Zap",description:"Lightning payment receipt",nip:"57",template:{kind:9735,content:"",tags:[]}},{kind:9802,name:"Highlights",description:"Highlighted text selection",nip:"84",template:{kind:9802,content:"",tags:[]}},{kind:1e4,name:"Mute List",description:"List of muted users/content",nip:"51",isReplaceable:!0,template:{kind:1e4,content:"",tags:[]}},{kind:10001,name:"Pin List",description:"Pinned events",nip:"51",isReplaceable:!0,template:{kind:10001,content:"",tags:[]}},{kind:10002,name:"Relay List Metadata",description:"User's preferred relays for read/write",nip:"65",isReplaceable:!0,template:{kind:10002,content:"",tags:[]}},{kind:10003,name:"Bookmark List",description:"Bookmarked events",nip:"51",isReplaceable:!0,template:{kind:10003,content:"",tags:[]}},{kind:10004,name:"Communities List",description:"Communities user belongs to",nip:"51",isReplaceable:!0,template:{kind:10004,content:"",tags:[]}},{kind:10005,name:"Public Chats List",description:"Public chats user is in",nip:"51",isReplaceable:!0,template:{kind:10005,content:"",tags:[]}},{kind:10006,name:"Blocked Relays List",description:"Relays user has blocked",nip:"51",isReplaceable:!0,template:{kind:10006,content:"",tags:[]}},{kind:10007,name:"Search Relays List",description:"Preferred search relays",nip:"51",isReplaceable:!0,template:{kind:10007,content:"",tags:[]}},{kind:10008,name:"Relay Group Configuration",description:"Relay group configuration",nip:null,isReplaceable:!0,template:{kind:10008,content:"",tags:[]}},{kind:10009,name:"User Groups",description:"Groups user belongs to",nip:"29",isReplaceable:!0,template:{kind:10009,content:"",tags:[]}},{kind:10012,name:"Favorite Relays List",description:"User's favorite relays",nip:"51",isReplaceable:!0,template:{kind:10012,content:"",tags:[]}},{kind:10013,name:"Private Event Relay List",description:"Relays for private events",nip:"37",isReplaceable:!0,template:{kind:10013,content:"",tags:[]}},{kind:10015,name:"Interests List",description:"User interests/topics",nip:"51",isReplaceable:!0,template:{kind:10015,content:"",tags:[]}},{kind:10019,name:"Nutzap Mint Recommendation",description:"Recommended Cashu mints for nutzaps",nip:"61",isReplaceable:!0,template:{kind:10019,content:"",tags:[]}},{kind:10020,name:"Media Follows",description:"Followed media accounts",nip:"51",isReplaceable:!0,template:{kind:10020,content:"",tags:[]}},{kind:10030,name:"User Emoji List",description:"Custom emoji list",nip:"51",isReplaceable:!0,template:{kind:10030,content:"",tags:[]}},{kind:10050,name:"DM Relays List",description:"Relays to receive DMs on",nip:"17",isReplaceable:!0,template:{kind:10050,content:"",tags:[]}},{kind:10051,name:"KeyPackage Relays List",description:"Marmot key package relays",nip:null,isReplaceable:!0,spec:"Marmot",template:{kind:10051,content:"",tags:[]}},{kind:10063,name:"User Server List",description:"Blossom server list",nip:null,isReplaceable:!0,spec:"Blossom",template:{kind:10063,content:"",tags:[]}},{kind:10096,name:"File Storage Server List",description:"File storage servers",nip:"96",isReplaceable:!0,deprecated:!0,template:{kind:10096,content:"",tags:[]}},{kind:10166,name:"Relay Monitor Announcement",description:"Relay monitoring announcement",nip:"66",isReplaceable:!0,template:{kind:10166,content:"",tags:[]}},{kind:10312,name:"Room Presence",description:"Presence in live room",nip:"53",isReplaceable:!0,template:{kind:10312,content:"",tags:[]}},{kind:10377,name:"Proxy Announcement",description:"Nostr proxy announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:10377,content:"",tags:[]}},{kind:11111,name:"Transport Method Announcement",description:"Transport method announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:11111,content:"",tags:[]}},{kind:12345,name:"Relay Policy Configuration",description:"Relay-internal policy configuration (admin only)",nip:null,isReplaceable:!0,spec:"orly",template:{kind:12345,content:"",tags:[]}},{kind:13004,name:"JWT Binding",description:"Link between JWT certificate and pubkey",nip:null,isReplaceable:!0,template:{kind:13004,content:"",tags:[]}},{kind:13194,name:"Wallet Service Info",description:"NWC wallet service information",nip:"47",isReplaceable:!0,template:{kind:13194,content:"",tags:[]}},{kind:13534,name:"Membership Lists",description:"Group membership lists",nip:"43",isReplaceable:!0,template:{kind:13534,content:"",tags:[]}},{kind:14388,name:"User Sound Effect Lists",description:"Sound effect lists",nip:null,isReplaceable:!0,spec:"Corny Chat",template:{kind:14388,content:"",tags:[]}},{kind:17375,name:"Cashu Wallet Event",description:"Cashu wallet event",nip:"60",isReplaceable:!0,template:{kind:17375,content:"",tags:[]}},{kind:21e3,name:"Lightning Pub RPC",description:"Lightning.Pub RPC",nip:null,isEphemeral:!0,spec:"Lightning.Pub",template:{kind:21e3,content:"",tags:[]}},{kind:22242,name:"Client Authentication",description:"Authenticate to relay",nip:"42",isEphemeral:!0,template:{kind:22242,content:"",tags:[]}},{kind:23194,name:"Wallet Request",description:"NWC wallet request",nip:"47",isEphemeral:!0,template:{kind:23194,content:"",tags:[]}},{kind:23195,name:"Wallet Response",description:"NWC wallet response",nip:"47",isEphemeral:!0,template:{kind:23195,content:"",tags:[]}},{kind:23196,name:"Wallet Notification (NIP-04)",description:"NWC wallet notification (NIP-04 encrypted)",nip:"47",isEphemeral:!0,template:{kind:23196,content:"",tags:[]}},{kind:23197,name:"Wallet Notification",description:"NWC wallet notification",nip:"47",isEphemeral:!0,template:{kind:23197,content:"",tags:[]}},{kind:24133,name:"Nostr Connect",description:"Remote signer connection",nip:"46",isEphemeral:!0,template:{kind:24133,content:"",tags:[]}},{kind:24242,name:"Blobs Stored on Mediaservers",description:"Blossom blob storage",nip:null,isEphemeral:!0,spec:"Blossom",template:{kind:24242,content:"",tags:[]}},{kind:27235,name:"HTTP Auth",description:"Authenticate HTTP requests",nip:"98",isEphemeral:!0,template:{kind:27235,content:"",tags:[]}},{kind:28934,name:"Join Request",description:"Request to join group",nip:"43",isEphemeral:!0,template:{kind:28934,content:"",tags:[]}},{kind:28935,name:"Invite Request",description:"Invite to group",nip:"43",isEphemeral:!0,template:{kind:28935,content:"",tags:[]}},{kind:28936,name:"Leave Request",description:"Leave group request",nip:"43",isEphemeral:!0,template:{kind:28936,content:"",tags:[]}},{kind:3e4,name:"Follow Sets",description:"Categorized people lists",nip:"51",isAddressable:!0,template:{kind:3e4,content:"",tags:[["d","identifier"]]}},{kind:30001,name:"Generic Lists",description:"Generic categorized lists",nip:"51",isAddressable:!0,deprecated:!0,template:{kind:30001,content:"",tags:[["d","identifier"]]}},{kind:30002,name:"Relay Sets",description:"Categorized relay lists",nip:"51",isAddressable:!0,template:{kind:30002,content:"",tags:[["d","identifier"]]}},{kind:30003,name:"Bookmark Sets",description:"Categorized bookmark lists",nip:"51",isAddressable:!0,template:{kind:30003,content:"",tags:[["d","identifier"]]}},{kind:30004,name:"Curation Sets",description:"Curated content sets",nip:"51",isAddressable:!0,template:{kind:30004,content:"",tags:[["d","identifier"]]}},{kind:30005,name:"Video Sets",description:"Video playlists",nip:"51",isAddressable:!0,template:{kind:30005,content:"",tags:[["d","identifier"]]}},{kind:30007,name:"Kind Mute Sets",description:"Muted event kinds",nip:"51",isAddressable:!0,template:{kind:30007,content:"",tags:[["d","identifier"]]}},{kind:30008,name:"Profile Badges",description:"Badges displayed on profile",nip:"58",isAddressable:!0,template:{kind:30008,content:"",tags:[["d","identifier"]]}},{kind:30009,name:"Badge Definition",description:"Define a badge/achievement",nip:"58",isAddressable:!0,template:{kind:30009,content:"",tags:[["d","identifier"]]}},{kind:30015,name:"Interest Sets",description:"Interest/topic sets",nip:"51",isAddressable:!0,template:{kind:30015,content:"",tags:[["d","identifier"]]}},{kind:30017,name:"Stall",description:"Marketplace stall definition",nip:"15",isAddressable:!0,template:{kind:30017,content:"",tags:[["d","identifier"]]}},{kind:30018,name:"Product",description:"Marketplace product listing",nip:"15",isAddressable:!0,template:{kind:30018,content:"",tags:[["d","identifier"]]}},{kind:30019,name:"Marketplace UI/UX",description:"Marketplace interface settings",nip:"15",isAddressable:!0,template:{kind:30019,content:"",tags:[["d","identifier"]]}},{kind:30020,name:"Product Sold as Auction",description:"Auction product listing",nip:"15",isAddressable:!0,template:{kind:30020,content:"",tags:[["d","identifier"]]}},{kind:30023,name:"Long-form Content",description:"Blog post, article in markdown",nip:"23",isAddressable:!0,template:{kind:30023,content:"",tags:[["d","identifier"]]}},{kind:30024,name:"Draft Long-form Content",description:"Draft article",nip:"23",isAddressable:!0,template:{kind:30024,content:"",tags:[["d","identifier"]]}},{kind:30030,name:"Emoji Sets",description:"Custom emoji sets",nip:"51",isAddressable:!0,template:{kind:30030,content:"",tags:[["d","identifier"]]}},{kind:30040,name:"Curated Publication Index",description:"Publication index",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30040,content:"",tags:[["d","identifier"]]}},{kind:30041,name:"Curated Publication Content",description:"Publication content",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30041,content:"",tags:[["d","identifier"]]}},{kind:30063,name:"Release Artifact Sets",description:"Software release artifacts",nip:"51",isAddressable:!0,template:{kind:30063,content:"",tags:[["d","identifier"]]}},{kind:30078,name:"Application-specific Data",description:"App-specific key-value storage",nip:"78",isAddressable:!0,template:{kind:30078,content:"",tags:[["d","identifier"]]}},{kind:30166,name:"Relay Discovery",description:"Relay discovery/monitoring",nip:"66",isAddressable:!0,template:{kind:30166,content:"",tags:[["d","identifier"]]}},{kind:30267,name:"App Curation Sets",description:"Curated app sets",nip:"51",isAddressable:!0,template:{kind:30267,content:"",tags:[["d","identifier"]]}},{kind:30311,name:"Live Event",description:"Live streaming event",nip:"53",isAddressable:!0,template:{kind:30311,content:"",tags:[["d","identifier"]]}},{kind:30312,name:"Interactive Room",description:"Interactive live room",nip:"53",isAddressable:!0,template:{kind:30312,content:"",tags:[["d","identifier"]]}},{kind:30313,name:"Conference Event",description:"Conference/meetup event",nip:"53",isAddressable:!0,template:{kind:30313,content:"",tags:[["d","identifier"]]}},{kind:30315,name:"User Statuses",description:"User status updates",nip:"38",isAddressable:!0,template:{kind:30315,content:"",tags:[["d","identifier"]]}},{kind:30388,name:"Slide Set",description:"Presentation slides",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:30388,content:"",tags:[["d","identifier"]]}},{kind:30402,name:"Classified Listing",description:"Classified ad listing",nip:"99",isAddressable:!0,template:{kind:30402,content:"",tags:[["d","identifier"]]}},{kind:30403,name:"Draft Classified Listing",description:"Draft classified ad",nip:"99",isAddressable:!0,template:{kind:30403,content:"",tags:[["d","identifier"]]}},{kind:30617,name:"Repository Announcements",description:"Git repository announcement",nip:"34",isAddressable:!0,template:{kind:30617,content:"",tags:[["d","identifier"]]}},{kind:30618,name:"Repository State Announcements",description:"Git repository state",nip:"34",isAddressable:!0,template:{kind:30618,content:"",tags:[["d","identifier"]]}},{kind:30818,name:"Wiki Article",description:"Wiki article",nip:"54",isAddressable:!0,template:{kind:30818,content:"",tags:[["d","identifier"]]}},{kind:30819,name:"Redirects",description:"URL redirects",nip:"54",isAddressable:!0,template:{kind:30819,content:"",tags:[["d","identifier"]]}},{kind:31234,name:"Draft Event",description:"Draft of any event",nip:"37",isAddressable:!0,template:{kind:31234,content:"",tags:[["d","identifier"]]}},{kind:31388,name:"Link Set",description:"Link collection",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:31388,content:"",tags:[["d","identifier"]]}},{kind:31890,name:"Feed",description:"Custom feed definition",nip:null,isAddressable:!0,spec:"NUD: Custom Feeds",template:{kind:31890,content:"",tags:[["d","identifier"]]}},{kind:31922,name:"Date-Based Calendar Event",description:"All-day calendar event",nip:"52",isAddressable:!0,template:{kind:31922,content:"",tags:[["d","identifier"]]}},{kind:31923,name:"Time-Based Calendar Event",description:"Calendar event with time",nip:"52",isAddressable:!0,template:{kind:31923,content:"",tags:[["d","identifier"]]}},{kind:31924,name:"Calendar",description:"Calendar definition",nip:"52",isAddressable:!0,template:{kind:31924,content:"",tags:[["d","identifier"]]}},{kind:31925,name:"Calendar Event RSVP",description:"RSVP to calendar event",nip:"52",isAddressable:!0,template:{kind:31925,content:"",tags:[["d","identifier"]]}},{kind:31989,name:"Handler Recommendation",description:"Recommended app for event kind",nip:"89",isAddressable:!0,template:{kind:31989,content:"",tags:[["d","identifier"]]}},{kind:31990,name:"Handler Information",description:"App handler declaration",nip:"89",isAddressable:!0,template:{kind:31990,content:"",tags:[["d","identifier"]]}},{kind:32123,name:"WaveLake Track",description:"WaveLake music track",nip:null,isAddressable:!0,spec:"WaveLake",template:{kind:32123,content:"",tags:[["d","identifier"]]}},{kind:32267,name:"Software Application",description:"Software application listing",nip:null,isAddressable:!0,template:{kind:32267,content:"",tags:[["d","identifier"]]}},{kind:32388,name:"User Room Favorites",description:"Favorite rooms",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:32388,content:"",tags:[["d","identifier"]]}},{kind:33388,name:"High Scores",description:"Game high scores",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:33388,content:"",tags:[["d","identifier"]]}},{kind:34235,name:"Video Event Horizontal",description:"Horizontal video event",nip:"71",isAddressable:!0,template:{kind:34235,content:"",tags:[["d","identifier"]]}},{kind:34236,name:"Video Event Vertical",description:"Vertical video event",nip:"71",isAddressable:!0,template:{kind:34236,content:"",tags:[["d","identifier"]]}},{kind:34388,name:"Sound Effects",description:"Sound effect definitions",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:34388,content:"",tags:[["d","identifier"]]}},{kind:34550,name:"Community Definition",description:"Define a community",nip:"72",isAddressable:!0,template:{kind:34550,content:"",tags:[["d","identifier"]]}},{kind:37516,name:"Geocache Listing",description:"Geocache location listing",nip:null,isAddressable:!0,spec:"geocaching",template:{kind:37516,content:"",tags:[["d","identifier"]]}},{kind:38172,name:"Cashu Mint Announcement",description:"Cashu mint announcement",nip:"87",isAddressable:!0,template:{kind:38172,content:"",tags:[["d","identifier"]]}},{kind:38173,name:"Fedimint Announcement",description:"Fedimint announcement",nip:"87",isAddressable:!0,template:{kind:38173,content:"",tags:[["d","identifier"]]}},{kind:38383,name:"Peer-to-peer Order Events",description:"P2P trading orders",nip:"69",isAddressable:!0,template:{kind:38383,content:"",tags:[["d","identifier"]]}},{kind:39e3,name:"Group Metadata Events",description:"Group metadata (start of range)",nip:"29",isAddressable:!0,template:{kind:39e3,content:"",tags:[["d","identifier"]]}},{kind:39089,name:"Starter Packs",description:"Starter pack lists",nip:"51",isAddressable:!0,template:{kind:39089,content:"",tags:[["d","identifier"]]}},{kind:39092,name:"Media Starter Packs",description:"Media starter packs",nip:"51",isAddressable:!0,template:{kind:39092,content:"",tags:[["d","identifier"]]}},{kind:39701,name:"Web Bookmarks",description:"Web URL bookmarks",nip:"B0",isAddressable:!0,template:{kind:39701,content:"",tags:[["d","identifier"]]}},{kind:39998,name:"ACL Event",description:"Access control list event",nip:null,isAddressable:!0,template:{kind:39998,content:"",tags:[["d","identifier"]]}}];function gy(e,t=null){const n=function(e){return py.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||"<your_pubkey_here>"}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||"<your_pubkey_here>"}}const my=[{id:"all",name:"All Kinds",filter:()=>!0},{id:"regular",name:"Regular Events (0-9999)",filter:e=>e.kind<1e4&&!e.isReplaceable},{id:"replaceable",name:"Replaceable (10000-19999)",filter:e=>e.isReplaceable},{id:"ephemeral",name:"Ephemeral (20000-29999)",filter:e=>e.isEphemeral},{id:"addressable",name:"Addressable (30000-39999)",filter:e=>e.isAddressable},{id:"social",name:"Social",filter:e=>[0,1,3,6,7].includes(e.kind)},{id:"messaging",name:"Messaging",filter:e=>[4,9,10,11,12,14,15,40,41,42].includes(e.kind)},{id:"lists",name:"Lists",filter:e=>e.name.toLowerCase().includes("list")||e.name.toLowerCase().includes("set")},{id:"marketplace",name:"Marketplace",filter:e=>[30017,30018,30019,30020,1021,1022,30402,30403].includes(e.kind)},{id:"lightning",name:"Lightning/Zaps",filter:e=>[9734,9735,9041,9321,7374,7375,7376].includes(e.kind)},{id:"media",name:"Media",filter:e=>[20,21,22,1063,1222,1244].includes(e.kind)},{id:"git",name:"Git/Code",filter:e=>[818,1337,1617,1618,1619,1621,1622,30617,30618].includes(e.kind)},{id:"calendar",name:"Calendar",filter:e=>[31922,31923,31924,31925].includes(e.kind)},{id:"groups",name:"Groups",filter:e=>e.kind>=9e3&&e.kind<=9030||e.kind>=39e3&&e.kind<=39009}];function yy(e,t,n){const r=e.slice();return r[13]=t[n],r}function wy(e,t,n){const r=e.slice();return r[16]=t[n],r}function vy(e){let t,n,i,o,s,a,l,p,y,v,b,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L=e[3].length+"",O=1!==e[3].length?"s":"",M=my,_=[];for(let t=0;t<M.length;t+=1)_[t]=Ay(wy(e,M,t));function H(e,t){return 0===e[3].length?ky:by}let j=H(e),G=j(e);return{c(){t=h("div"),n=h("div"),i=h("div"),o=h("h2"),o.textContent="Generate Event Template",s=m(),a=h("button"),a.textContent="×",l=m(),p=h("div"),y=h("div"),v=h("input"),b=m(),E=h("div");for(let e=0;e<_.length;e+=1)_[e].c();C=m(),x=h("div"),B=h("div"),G.c(),S=m(),F=h("div"),Q=h("span"),D=g(L),R=g(" event type"),P=g(O),$=m(),U=h("button"),U.textContent="Cancel",A(o,"class","svelte-v55ls1"),A(a,"class","close-btn svelte-v55ls1"),A(i,"class","modal-header svelte-v55ls1"),A(v,"type","text"),A(v,"placeholder","Search by name, description, or kind number..."),A(v,"class","search-input svelte-v55ls1"),A(y,"class","search-box svelte-v55ls1"),A(E,"class","category-tabs svelte-v55ls1"),A(p,"class","modal-filters svelte-v55ls1"),A(B,"class","kinds-list svelte-v55ls1"),A(x,"class","modal-body svelte-v55ls1"),A(Q,"class","result-count svelte-v55ls1"),A(U,"class","cancel-btn svelte-v55ls1"),A(F,"class","modal-footer svelte-v55ls1"),A(n,"class","modal-content svelte-v55ls1"),A(t,"class","modal-backdrop svelte-v55ls1")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(i,o),c(i,s),c(i,a),c(n,l),c(n,p),c(p,y),c(y,v),I(v,e[1]),c(p,b),c(p,E);for(let e=0;e<_.length;e+=1)_[e]&&_[e].m(E,null);c(n,C),c(n,x),c(x,B),G.m(B,null),c(n,S),c(n,F),c(F,Q),c(Q,D),c(Q,R),c(Q,P),c(F,$),c(F,U),T||(N=[w(a,"click",e[5]),w(v,"input",e[9]),w(U,"click",e[5]),w(t,"click",e[7])],T=!0)},p(e,t){if(2&t&&v.value!==e[1]&&I(v,e[1]),4&t){let n;for(M=my,n=0;n<M.length;n+=1){const r=wy(e,M,n);_[n]?_[n].p(r,t):(_[n]=Ay(r),_[n].c(),_[n].m(E,null))}for(;n<_.length;n+=1)_[n].d(1);_.length=M.length}j===(j=H(e))&&G?G.p(e,t):(G.d(1),G=j(e),G&&(G.c(),G.m(B,null))),8&t&&L!==(L=e[3].length+"")&&k(D,L),8&t&&O!==(O=1!==e[3].length?"s":"")&&k(P,O)},d(e){e&&d(t),f(_,e),G.d(),T=!1,r(N)}}}function Ay(e){let t,n,r,i,o,s=e[16].name+"";function a(){return e[10](e[16])}return{c(){t=h("button"),n=g(s),r=m(),A(t,"class","category-tab svelte-v55ls1"),B(t,"active",e[2]===e[16].id)},m(e,s){u(e,t,s),c(t,n),c(t,r),i||(o=w(t,"click",a),i=!0)},p(n,r){e=n,4&r&&B(t,"active",e[2]===e[16].id)},d(e){e&&d(t),i=!1,o()}}}function by(e){let t,n=e[3],r=[];for(let t=0;t<n.length;t+=1)r[t]=Ey(yy(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(24&i){let o;for(n=e[3],o=0;o<n.length;o+=1){const s=yy(e,n,o);r[o]?r[o].p(s,i):(r[o]=Ey(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function ky(e){let t,n,r,i;return{c(){t=h("div"),n=g('No event kinds found matching "'),r=g(e[1]),i=g('"'),A(t,"class","no-results svelte-v55ls1")},m(e,o){u(e,t,o),c(t,n),c(t,r),c(t,i)},p(e,t){2&t&&k(r,e[1])},d(e){e&&d(t)}}}function Iy(e){let t,n,r,i=e[13].nip+"";return{c(){t=h("span"),n=g("NIP-"),r=g(i),A(t,"class","nip-badge svelte-v55ls1")},m(e,i){u(e,t,i),c(t,n),c(t,r)},p(e,t){8&t&&i!==(i=e[13].nip+"")&&k(r,i)},d(e){e&&d(t)}}}function Ey(e){let t,n,r,i,o,s,a,l,f,p,y,v,b,I,E,C,x,B,S,F=e[13].kind+"",Q=By(e[13])+"",D=e[13].name+"",R=e[13].description+"",P=e[13].nip&&"XX"!==e[13].nip&&Iy(e);function $(){return e[11](e[13])}return{c(){t=h("button"),n=h("div"),r=h("span"),i=g("Kind "),o=g(F),s=m(),a=h("span"),l=g(Q),p=m(),P&&P.c(),y=m(),v=h("div"),b=g(D),I=m(),E=h("div"),C=g(R),x=m(),A(r,"class","kind-number svelte-v55ls1"),A(a,"class",f="kind-badge "+xy(e[13])+" svelte-v55ls1"),A(n,"class","kind-header svelte-v55ls1"),A(v,"class","kind-name svelte-v55ls1"),A(E,"class","kind-description svelte-v55ls1"),A(t,"class","kind-item svelte-v55ls1")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,i),c(r,o),c(n,s),c(n,a),c(a,l),c(n,p),P&&P.m(n,null),c(t,y),c(t,v),c(v,b),c(t,I),c(t,E),c(E,C),c(t,x),B||(S=w(t,"click",$),B=!0)},p(t,r){e=t,8&r&&F!==(F=e[13].kind+"")&&k(o,F),8&r&&Q!==(Q=By(e[13])+"")&&k(l,Q),8&r&&f!==(f="kind-badge "+xy(e[13])+" svelte-v55ls1")&&A(a,"class",f),e[13].nip&&"XX"!==e[13].nip?P?P.p(e,r):(P=Iy(e),P.c(),P.m(n,null)):P&&(P.d(1),P=null),8&r&&D!==(D=e[13].name+"")&&k(b,D),8&r&&R!==(R=e[13].description+"")&&k(C,R)},d(e){e&&d(t),P&&P.d(),B=!1,S()}}}function Cy(t){let n,r,i,o=t[0]&&vy(t);return{c(){o&&o.c(),n=y()},m(e,s){o&&o.m(e,s),u(e,n,s),r||(i=w(window,"keydown",t[6]),r=!0)},p(e,[t]){e[0]?o?o.p(e,t):(o=vy(e),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:e,o:e,d(e){o&&o.d(e),e&&d(n),r=!1,i()}}}function xy(e){return e.isAddressable?"badge-addressable":e.isReplaceable?"badge-replaceable":e.kind>=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function By(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function Sy(e,t,n){let{isOpen:r=!1}=t,{userPubkey:i=""}=t;const o=P();let s="",a="all",l=py;function c(e){const t=gy(e.kind,i);o("select",{kind:e,template:t}),u()}function u(){n(0,r=!1),n(1,s=""),n(2,a="all"),o("close")}return e.$$set=e=>{"isOpen"in e&&n(0,r=e.isOpen),"userPubkey"in e&&n(8,i=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=py;const t=my.find(e=>e.id===a);if(t&&(e=e.filter(t.filter)),s.trim()){const t=s.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.kind.toString().includes(t)||e.nip&&e.nip.includes(t))}n(3,l=e)}},[r,s,a,l,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},i,function(){s=this.value,n(1,s)},e=>n(2,a=e.id),e=>c(e)]}class Fy extends ae{constructor(e){super(),se(this,e,Sy,Cy,o,{isOpen:0,userPubkey:8})}}function Qy(e){let t,n,r,i,o,s,a,l,f,p;return{c(){t=h("div"),n=h("div"),r=h("span"),r.textContent="⚠",i=m(),o=h("span"),s=g(e[1]),a=m(),l=h("button"),l.textContent="×",A(r,"class","error-icon svelte-46pmgb"),A(o,"class","error-message svelte-46pmgb"),A(n,"class","error-content svelte-46pmgb"),A(l,"class","error-dismiss svelte-46pmgb"),A(t,"class","error-banner svelte-46pmgb")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,i),c(n,o),c(o,s),c(t,a),c(t,l),f||(p=w(l,"click",e[10]),f=!0)},p(e,t){2&t&&k(s,e[1])},d(e){e&&d(t),f=!1,p()}}}function Dy(e){let t,n,i,o,s,a,l,f,p,g,y,v,b,k,E,C,x,B,S,F=e[1]&&Qy(e);function Q(t){e[14](t)}let D={userPubkey:e[2]};return void 0!==e[3]&&(D.isOpen=e[3]),E=new Fy({props:D}),T.push(()=>te(E,"isOpen",Q)),E.$on("select",e[8]),E.$on("close",e[9]),{c(){t=h("div"),n=h("div"),i=h("button"),i.textContent="Generate Template",o=m(),s=h("button"),s.textContent="Reformat",a=m(),l=h("button"),l.textContent="Sign",f=m(),p=h("button"),p.textContent="Publish",g=m(),F&&F.c(),y=m(),v=h("div"),b=h("textarea"),k=m(),ne(E.$$.fragment),A(i,"class","compose-btn template-btn svelte-46pmgb"),A(s,"class","compose-btn reformat-btn svelte-46pmgb"),A(l,"class","compose-btn sign-btn svelte-46pmgb"),A(p,"class","compose-btn publish-btn svelte-46pmgb"),A(n,"class","compose-header svelte-46pmgb"),A(b,"class","compose-textarea svelte-46pmgb"),A(b,"placeholder","Enter your Nostr event JSON here, or click 'Generate Template' to start with a template..."),A(b,"spellcheck","false"),A(v,"class","compose-editor svelte-46pmgb"),A(t,"class","compose-view svelte-46pmgb")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(n,a),c(n,l),c(n,f),c(n,p),c(t,g),F&&F.m(t,null),c(t,y),c(t,v),c(v,b),I(b,e[0]),u(r,k,d),re(E,r,d),x=!0,B||(S=[w(i,"click",e[7]),w(s,"click",e[4]),w(l,"click",e[5]),w(p,"click",e[6]),w(b,"input",e[13])],B=!0)},p(e,[n]){e[1]?F?F.p(e,n):(F=Qy(e),F.c(),F.m(t,y)):F&&(F.d(1),F=null),1&n&&I(b,e[0]);const r={};4&n&&(r.userPubkey=e[2]),!C&&8&n&&(C=!0,r.isOpen=e[3],H(()=>C=!1)),E.$set(r)},i(e){x||(W(E.$$.fragment,e),x=!0)},o(e){Z(E.$$.fragment,e),x=!1},d(e){e&&d(t),F&&F.d(),e&&d(k),ie(E,e),B=!1,r(S)}}}function Ry(e,t,n){let{composeEventJson:r=""}=t,{userPubkey:i=""}=t,{userRole:o=""}=t,{policyEnabled:s=!1}=t,{publishError:a=""}=t;const l=P();let c=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,r=e.composeEventJson),"userPubkey"in e&&n(2,i=e.userPubkey),"userRole"in e&&n(11,o=e.userRole),"policyEnabled"in e&&n(12,s=e.policyEnabled),"publishError"in e&&n(1,a=e.publishError)},[r,a,i,c,function(){l("reformatJson")},function(){l("signEvent")},function(){l("publishEvent")},function(){n(3,c=!0)},function(e){const{kind:t,template:i}=e.detail;n(0,r=JSON.stringify(i,null,2)),l("templateSelected",{kind:t,template:i})},function(){n(3,c=!1)},function(){n(1,a=""),l("clearError")},o,s,function(){r=this.value,n(0,r)},function(e){c=e,n(3,c)}]}class Py extends ae{constructor(e){super(),se(this,e,Ry,Dy,o,{composeEventJson:0,userPubkey:2,userRole:11,policyEnabled:12,publishError:1})}}function $y(e,t,n){const r=e.slice();return r[23]=t[n],r}function Uy(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access sprocket management.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-fiaj1r"),A(o,"class","login-btn svelte-fiaj1r"),A(n,"class","login-prompt svelte-fiaj1r")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[18]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function Ty(e){let t,n,r,i,o,s,a,l,f,p=(e[2]||"none")+"";return{c(){t=h("div"),n=h("p"),n.textContent="❌ Owner permission required for sprocket management.",r=m(),i=h("p"),i.innerHTML='To enable sprocket functionality, set the <code class="svelte-fiaj1r">ORLY_OWNERS</code> environment variable with your npub when starting the relay.',o=m(),s=h("p"),a=g("Current user role: "),l=h("strong"),f=g(p),A(n,"class","svelte-fiaj1r"),A(i,"class","svelte-fiaj1r"),A(s,"class","svelte-fiaj1r"),A(t,"class","permission-denied svelte-fiaj1r")},m(e,d){u(e,t,d),c(t,n),c(t,r),c(t,i),c(t,o),c(t,s),c(s,a),c(s,l),c(l,f)},p(e,t){4&t&&p!==(p=(e[2]||"none")+"")&&k(f,p)},d(e){e&&d(t)}}}function Ny(e){let t,n,i,o,s,a,l,p,y,v,b,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te,ne,re,ie,oe,se,ae,le,ce,ue,de,fe,he,pe,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ye=e[3]?.script_exists?"✅ Exists":"❌ Not found",we=e[3]?.pid&&Ly(e),ve=e[6]&&Oy(e),Ae=e[8],be=[];for(let t=0;t<Ae.length;t+=1)be[t]=Hy($y(e,Ae,t));return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Script Editor",o=m(),s=h("div"),a=h("button"),l=g("🔄 Restart"),p=m(),y=h("button"),v=g("🗑️ Delete Script"),E=m(),C=h("div"),x=h("h4"),x.textContent="Upload Script",S=m(),F=h("div"),Q=h("input"),D=m(),R=h("button"),P=g("📤 Upload & Update"),U=m(),T=h("div"),N=h("div"),L=h("span"),L.textContent="Status:",O=m(),M=h("span"),_=g(me),H=m(),we&&we.c(),j=m(),G=h("div"),q=h("span"),q.textContent="Script:",K=m(),J=h("span"),V=g(ye),Y=m(),z=h("div"),W=h("textarea"),Z=m(),X=h("div"),ee=h("button"),te=g("💾 Save & Update"),ne=m(),re=h("button"),ie=g("📥 Load Current"),oe=m(),ve&&ve.c(),se=m(),ae=h("div"),le=h("h3"),le.textContent="Script Versions",ce=m(),ue=h("div");for(let e=0;e<be.length;e+=1)be[e].c();de=m(),fe=h("button"),he=g("🔄 Refresh Versions"),A(i,"class","svelte-fiaj1r"),A(a,"class","sprocket-btn restart-btn svelte-fiaj1r"),a.disabled=e[4],A(y,"class","sprocket-btn delete-btn svelte-fiaj1r"),y.disabled=b=e[4]||!e[3]?.script_exists,A(s,"class","sprocket-controls svelte-fiaj1r"),A(n,"class","sprocket-header svelte-fiaj1r"),A(x,"class","svelte-fiaj1r"),A(Q,"type","file"),A(Q,"id","sprocket-upload-file"),A(Q,"accept",".sh,.bash"),Q.disabled=e[4],A(Q,"class","svelte-fiaj1r"),A(R,"class","sprocket-btn upload-btn svelte-fiaj1r"),R.disabled=$=e[4]||!e[5],A(F,"class","upload-controls svelte-fiaj1r"),A(C,"class","sprocket-upload-section svelte-fiaj1r"),A(L,"class","status-label svelte-fiaj1r"),A(M,"class","status-value svelte-fiaj1r"),B(M,"running",e[3]?.is_running),A(N,"class","status-item svelte-fiaj1r"),A(q,"class","status-label svelte-fiaj1r"),A(J,"class","status-value svelte-fiaj1r"),A(G,"class","status-item svelte-fiaj1r"),A(T,"class","sprocket-status svelte-fiaj1r"),A(W,"class","script-editor svelte-fiaj1r"),A(W,"placeholder","#!/bin/bash # Enter your sprocket script here..."),W.disabled=e[4],A(z,"class","script-editor-container svelte-fiaj1r"),A(ee,"class","sprocket-btn save-btn svelte-fiaj1r"),ee.disabled=e[4],A(re,"class","sprocket-btn load-btn svelte-fiaj1r"),re.disabled=e[4],A(X,"class","script-actions svelte-fiaj1r"),A(t,"class","sprocket-section svelte-fiaj1r"),A(ue,"class","versions-list svelte-fiaj1r"),A(fe,"class","sprocket-btn refresh-btn svelte-fiaj1r"),fe.disabled=e[4],A(ae,"class","sprocket-section svelte-fiaj1r")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(s,p),c(s,y),c(y,v),c(t,E),c(t,C),c(C,x),c(C,S),c(C,F),c(F,Q),c(F,D),c(F,R),c(R,P),c(t,U),c(t,T),c(T,N),c(N,L),c(N,O),c(N,M),c(M,_),c(T,H),we&&we.m(T,null),c(T,j),c(T,G),c(G,q),c(G,K),c(G,J),c(J,V),c(t,Y),c(t,z),c(z,W),I(W,e[0]),c(t,Z),c(t,X),c(X,ee),c(ee,te),c(X,ne),c(X,re),c(re,ie),c(t,oe),ve&&ve.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<be.length;e+=1)be[e]&&be[e].m(ue,null);c(ae,de),c(ae,fe),c(fe,he),pe||(ge=[w(a,"click",e[9]),w(y,"click",e[10]),w(Q,"change",e[11]),w(R,"click",e[12]),w(W,"input",e[19]),w(ee,"click",e[13]),w(re,"click",e[14]),w(fe,"click",e[15])],pe=!0)},p(e,n){if(16&n&&(a.disabled=e[4]),24&n&&b!==(b=e[4]||!e[3]?.script_exists)&&(y.disabled=b),16&n&&(Q.disabled=e[4]),48&n&&$!==($=e[4]||!e[5])&&(R.disabled=$),8&n&&me!==(me=e[3]?.is_running?"🟢 Running":"🔴 Stopped")&&k(_,me),8&n&&B(M,"running",e[3]?.is_running),e[3]?.pid?we?we.p(e,n):(we=Ly(e),we.c(),we.m(T,j)):we&&(we.d(1),we=null),8&n&&ye!==(ye=e[3]?.script_exists?"✅ Exists":"❌ Not found")&&k(V,ye),16&n&&(W.disabled=e[4]),1&n&&I(W,e[0]),16&n&&(ee.disabled=e[4]),16&n&&(re.disabled=e[4]),e[6]?ve?ve.p(e,n):(ve=Oy(e),ve.c(),ve.m(t,null)):ve&&(ve.d(1),ve=null),196880&n){let t;for(Ae=e[8],t=0;t<Ae.length;t+=1){const r=$y(e,Ae,t);be[t]?be[t].p(r,n):(be[t]=Hy(r),be[t].c(),be[t].m(ue,null))}for(;t<be.length;t+=1)be[t].d(1);be.length=Ae.length}16&n&&(fe.disabled=e[4])},d(e){e&&d(t),we&&we.d(),ve&&ve.d(),e&&d(se),e&&d(ae),f(be,e),pe=!1,r(ge)}}}function Ly(e){let t,n,r,i,o,s=e[3].pid+"";return{c(){t=h("div"),n=h("span"),n.textContent="PID:",r=m(),i=h("span"),o=g(s),A(n,"class","status-label svelte-fiaj1r"),A(i,"class","status-value svelte-fiaj1r"),A(t,"class","status-item svelte-fiaj1r")},m(e,s){u(e,t,s),c(t,n),c(t,r),c(t,i),c(i,o)},p(e,t){8&t&&s!==(s=e[3].pid+"")&&k(o,s)},d(e){e&&d(t)}}}function Oy(e){let t,n;return{c(){t=h("div"),n=g(e[6]),A(t,"class","sprocket-message svelte-fiaj1r"),B(t,"error","error"===e[7])},m(e,r){u(e,t,r),c(t,n)},p(e,r){64&r&&k(n,e[6]),128&r&&B(t,"error","error"===e[7])},d(e){e&&d(t)}}}function My(e){let t;return{c(){t=h("span"),t.textContent="Current",A(t,"class","current-badge svelte-fiaj1r")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function _y(e){let t,n,r,i;function o(){return e[21](e[23])}return{c(){t=h("button"),n=g("🗑️ Delete"),A(t,"class","version-btn delete-btn svelte-fiaj1r"),t.disabled=e[4]},m(e,s){u(e,t,s),c(t,n),r||(i=w(t,"click",o),r=!0)},p(n,r){e=n,16&r&&(t.disabled=e[4])},d(e){e&&d(t),r=!1,i()}}}function Hy(e){let t,n,r,i,o,s,a,l,f,p,y,v,b,I,E,C,x=e[23].name+"",S=new Date(e[23].modified).toLocaleString()+"",F=e[23].is_current&&My();function Q(){return e[20](e[23])}let D=!e[23].is_current&&_y(e);return{c(){t=h("div"),n=h("div"),r=h("div"),i=g(x),o=m(),s=h("div"),a=g(S),l=m(),F&&F.c(),f=m(),p=h("div"),y=h("button"),v=g("📥 Load"),b=m(),D&&D.c(),I=m(),A(r,"class","version-name svelte-fiaj1r"),A(s,"class","version-date svelte-fiaj1r"),A(n,"class","version-info svelte-fiaj1r"),A(y,"class","version-btn load-btn svelte-fiaj1r"),y.disabled=e[4],A(p,"class","version-actions svelte-fiaj1r"),A(t,"class","version-item svelte-fiaj1r"),B(t,"current",e[23].is_current)},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,i),c(n,o),c(n,s),c(s,a),c(s,l),F&&F.m(s,null),c(t,f),c(t,p),c(p,y),c(y,v),c(p,b),D&&D.m(p,null),c(t,I),E||(C=w(y,"click",Q),E=!0)},p(n,r){e=n,256&r&&x!==(x=e[23].name+"")&&k(i,x),256&r&&S!==(S=new Date(e[23].modified).toLocaleString()+"")&&k(a,S),e[23].is_current?F||(F=My(),F.c(),F.m(s,null)):F&&(F.d(1),F=null),16&r&&(y.disabled=e[4]),e[23].is_current?D&&(D.d(1),D=null):D?D.p(e,r):(D=_y(e),D.c(),D.m(p,null)),256&r&&B(t,"current",e[23].is_current)},d(e){e&&d(t),F&&F.d(),D&&D.d(),E=!1,C()}}}function jy(t){let n,r,i;function o(e,t){return e[1]&&"owner"===e[2]?Ny:e[1]?Ty:Uy}let s=o(t),a=s(t);return{c(){n=h("div"),r=h("h2"),r.textContent="Sprocket Script Management",i=m(),a.c(),A(r,"class","svelte-fiaj1r"),A(n,"class","sprocket-view svelte-fiaj1r")},m(e,t){u(e,n,t),c(n,r),c(n,i),a.m(n,null)},p(e,[t]){s===(s=o(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 Gy(e,t,n){let{isLoggedIn:r=!1}=t,{userRole:i=""}=t,{sprocketStatus:o=null}=t,{isLoadingSprocket:s=!1}=t,{sprocketUploadFile:a=null}=t,{sprocketScript:l=""}=t,{sprocketMessage:c=""}=t,{sprocketMessageType:u=""}=t,{sprocketVersions:d=[]}=t;const f=P();function h(e){f("loadVersion",e)}function p(e){f("deleteVersion",e)}return e.$$set=e=>{"isLoggedIn"in e&&n(1,r=e.isLoggedIn),"userRole"in e&&n(2,i=e.userRole),"sprocketStatus"in e&&n(3,o=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,s=e.isLoadingSprocket),"sprocketUploadFile"in e&&n(5,a=e.sprocketUploadFile),"sprocketScript"in e&&n(0,l=e.sprocketScript),"sprocketMessage"in e&&n(6,c=e.sprocketMessage),"sprocketMessageType"in e&&n(7,u=e.sprocketMessageType),"sprocketVersions"in e&&n(8,d=e.sprocketVersions)},[l,r,i,o,s,a,c,u,d,function(){f("restartSprocket")},function(){f("deleteSprocket")},function(e){f("sprocketFileSelect",e)},function(){f("uploadSprocketScript")},function(){f("saveSprocket")},function(){f("loadSprocket")},function(){f("loadVersions")},h,p,function(){f("openLoginModal")},function(){l=this.value,n(0,l)},e=>h(e),e=>p(e.name)]}class qy extends ae{constructor(e){super(),se(this,e,Gy,jy,o,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function Ky(e,t,n){const r=e.slice();return r[26]=t[n],r}function Jy(e,t,n){const r=e.slice();return r[29]=t[n],r}function Vy(e,t,n){const r=e.slice();return r[32]=t[n],r}function Yy(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access policy configuration.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-gkxvxc"),A(o,"class","login-btn svelte-gkxvxc"),A(n,"class","login-prompt svelte-gkxvxc")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[16]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function zy(e){let t,n,r,i,o,s,a,l,f,p=(e[3]||"none")+"";return{c(){t=h("div"),n=h("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",r=m(),i=h("p"),i.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n to the <code class="svelte-gkxvxc">policy_admins</code> list.',o=m(),s=h("p"),a=g("Current user role: "),l=h("strong"),f=g(p),A(n,"class","svelte-gkxvxc"),A(i,"class","svelte-gkxvxc"),A(s,"class","svelte-gkxvxc"),A(t,"class","permission-denied svelte-gkxvxc")},m(e,d){u(e,t,d),c(t,n),c(t,r),c(t,i),c(t,o),c(t,s),c(s,a),c(s,l),c(l,f)},p(e,t){8&t[0]&&p!==(p=(e[3]||"none")+"")&&k(f,p)},d(e){e&&d(t)}}}function Wy(e){let t,n,i,o,s,a,l,f,p,y,v,b,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te,ne,re,ie,oe,se,ae,le,ce,ue,de,fe,he,pe,ge,me,ye,we,ve,Ae,be,ke,Ie,Ee,Ce,xe,Be,Se,Fe,Qe,De,Re,Pe,$e=e[5]?"Policy Enabled":"Policy Disabled",Ue=e[10].length+"",Te=e[4]&&Zy(),Ne=e[9].length>0&&Xy(e),Le=e[7]&&tw(e);function Oe(e,t){return 0===e[1].length?rw:nw}let Me=Oe(e),_e=Me(e);function He(e,t){return 0===e[10].length?sw:ow}let je=He(e),Ge=je(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Policy Editor",o=m(),s=h("div"),a=h("span"),l=g($e),f=m(),Te&&Te.c(),p=m(),y=h("div"),y.innerHTML='<p class="svelte-gkxvxc">Edit the policy JSON below and click "Save & Publish" to update the relay's policy configuration.\n Changes are applied immediately after validation.</p> \n <p class="info-note svelte-gkxvxc">Policy updates are published as kind 12345 events and require policy admin permissions.</p>',v=m(),b=h("div"),E=h("textarea"),C=m(),Ne&&Ne.c(),x=m(),S=h("div"),F=h("button"),Q=g("Load Current"),D=m(),R=h("button"),P=g("Format JSON"),$=m(),U=h("button"),T=g("Validate"),N=m(),L=h("button"),O=g("Save & Publish"),M=m(),Le&&Le.c(),_=m(),H=h("div"),j=h("h3"),j.textContent="Policy Administrators",G=m(),q=h("div"),q.innerHTML='<p class="svelte-gkxvxc">Policy admins can update the relay's policy configuration via kind 12345 events.\n Their follows get whitelisted if <code>policy_follow_whitelist_enabled</code> is true in the policy.</p> \n <p class="info-note svelte-gkxvxc"><strong>Note:</strong> Policy admins are separate from relay admins (ORLY_ADMINS).\n Changes here update the JSON editor - click "Save & Publish" to apply.</p>',K=m(),J=h("div"),_e.c(),V=m(),Y=h("div"),z=h("input"),W=m(),Z=h("button"),X=g("+ Add Admin"),te=m(),ne=h("div"),re=h("h3"),re.textContent="Policy Follow Whitelist",ie=m(),oe=h("div"),oe.innerHTML='<p class="svelte-gkxvxc">Pubkeys followed by policy admins (kind 3 events).\n These get automatic read+write access when rules have <code>write_allow_follows: true</code>.</p>',se=m(),ae=h("div"),le=h("span"),ce=g(Ue),ue=g(" pubkey(s) in whitelist"),de=m(),fe=h("button"),he=g("🔄 Refresh Follows"),pe=m(),ge=h("div"),Ge.c(),me=m(),ye=h("div"),we=h("h3"),we.textContent="Policy Reference",ve=m(),Ae=h("div"),be=h("h4"),be.textContent="Structure Overview",ke=m(),Ie=h("ul"),Ie.innerHTML='<li class="svelte-gkxvxc"><code class="svelte-gkxvxc">kind.whitelist</code> - Only allow these event kinds (takes precedence)</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">kind.blacklist</code> - Deny these event kinds (if no whitelist)</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">global</code> - Rules applied to all events</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">rules</code> - Per-kind rules (keyed by kind number as string)</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">default_policy</code> - "allow" or "deny" when no rules match</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">policy_admins</code> - Hex pubkeys that can update policy</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">policy_follow_whitelist_enabled</code> - Enable follow-based access</li>',Ee=m(),Ce=h("h4"),Ce.textContent="Rule Fields",xe=m(),Be=h("ul"),Be.innerHTML='<li class="svelte-gkxvxc"><code class="svelte-gkxvxc">description</code> - Human-readable rule description</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">write_allow</code> / <code class="svelte-gkxvxc">write_deny</code> - Pubkey lists for write access</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">read_allow</code> / <code class="svelte-gkxvxc">read_deny</code> - Pubkey lists for read access</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">write_allow_follows</code> - Grant access to policy admin follows</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">size_limit</code> - Max total event size in bytes</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">content_limit</code> - Max content field size in bytes</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_expiry</code> - Max expiry offset in seconds</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_age_of_event</code> - Max age of created_at in seconds</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">max_age_event_in_future</code> - Max future offset in seconds</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">must_have_tags</code> - Required tag letters (e.g., ["d", "t"])</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">tag_validation</code> - Regex patterns for tag values</li> \n <li class="svelte-gkxvxc"><code class="svelte-gkxvxc">script</code> - Path to external validation script</li>',Se=m(),Fe=h("h4"),Fe.textContent="Example Policy",Qe=m(),De=h("pre"),De.textContent=`${e[20]}`,A(i,"class","svelte-gkxvxc"),A(a,"class","status-badge svelte-gkxvxc"),B(a,"enabled",e[5]),A(s,"class","policy-status svelte-gkxvxc"),A(n,"class","policy-header svelte-gkxvxc"),A(y,"class","policy-info svelte-gkxvxc"),A(E,"class","policy-editor svelte-gkxvxc"),A(E,"placeholder","Loading policy configuration..."),E.disabled=e[6],A(E,"spellcheck","false"),A(b,"class","editor-container svelte-gkxvxc"),A(F,"class","policy-btn load-btn svelte-gkxvxc"),F.disabled=e[6],A(R,"class","policy-btn format-btn svelte-gkxvxc"),R.disabled=e[6],A(U,"class","policy-btn validate-btn svelte-gkxvxc"),U.disabled=e[6],A(L,"class","policy-btn save-btn svelte-gkxvxc"),L.disabled=e[6],A(S,"class","policy-actions svelte-gkxvxc"),A(t,"class","policy-section svelte-gkxvxc"),A(q,"class","policy-info svelte-gkxvxc"),A(J,"class","admin-list svelte-gkxvxc"),A(z,"type","text"),A(z,"placeholder","npub or hex pubkey"),z.disabled=e[6],A(z,"class","svelte-gkxvxc"),A(Z,"class","policy-btn add-btn svelte-gkxvxc"),Z.disabled=ee=e[6]||!e[11].trim(),A(Y,"class","add-admin svelte-gkxvxc"),A(H,"class","policy-section svelte-gkxvxc"),A(oe,"class","policy-info svelte-gkxvxc"),A(le,"class","follows-count svelte-gkxvxc"),A(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],A(ae,"class","follows-header svelte-gkxvxc"),A(ge,"class","follows-list svelte-gkxvxc"),A(ne,"class","policy-section svelte-gkxvxc"),A(be,"class","svelte-gkxvxc"),A(Ie,"class","field-list svelte-gkxvxc"),A(Ce,"class","svelte-gkxvxc"),A(Be,"class","field-list svelte-gkxvxc"),A(Fe,"class","svelte-gkxvxc"),A(De,"class","example-json svelte-gkxvxc"),A(Ae,"class","reference-content svelte-gkxvxc"),A(ye,"class","policy-section svelte-gkxvxc")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(s,f),Te&&Te.m(s,null),c(t,p),c(t,y),c(t,v),c(t,b),c(b,E),I(E,e[0]),c(t,C),Ne&&Ne.m(t,null),c(t,x),c(t,S),c(S,F),c(F,Q),c(S,D),c(S,R),c(R,P),c(S,$),c(S,U),c(U,T),c(S,N),c(S,L),c(L,O),c(t,M),Le&&Le.m(t,null),u(r,_,d),u(r,H,d),c(H,j),c(H,G),c(H,q),c(H,K),c(H,J),_e.m(J,null),c(H,V),c(H,Y),c(Y,z),I(z,e[11]),c(Y,W),c(Y,Z),c(Z,X),u(r,te,d),u(r,ne,d),c(ne,re),c(ne,ie),c(ne,oe),c(ne,se),c(ne,ae),c(ae,le),c(le,ce),c(le,ue),c(ae,de),c(ae,fe),c(fe,he),c(ne,pe),c(ne,ge),Ge.m(ge,null),u(r,me,d),u(r,ye,d),c(ye,we),c(ye,ve),c(ye,Ae),c(Ae,be),c(Ae,ke),c(Ae,Ie),c(Ae,Ee),c(Ae,Ce),c(Ae,xe),c(Ae,Be),c(Ae,Se),c(Ae,Fe),c(Ae,Qe),c(Ae,De),Re||(Pe=[w(E,"input",e[21]),w(F,"click",e[12]),w(R,"click",e[15]),w(U,"click",e[13]),w(L,"click",e[14]),w(z,"input",e[23]),w(z,"keydown",e[24]),w(Z,"click",e[18]),w(fe,"click",e[17])],Re=!0)},p(e,n){32&n[0]&&$e!==($e=e[5]?"Policy Enabled":"Policy Disabled")&&k(l,$e),32&n[0]&&B(a,"enabled",e[5]),e[4]?Te||(Te=Zy(),Te.c(),Te.m(s,null)):Te&&(Te.d(1),Te=null),64&n[0]&&(E.disabled=e[6]),1&n[0]&&I(E,e[0]),e[9].length>0?Ne?Ne.p(e,n):(Ne=Xy(e),Ne.c(),Ne.m(t,x)):Ne&&(Ne.d(1),Ne=null),64&n[0]&&(F.disabled=e[6]),64&n[0]&&(R.disabled=e[6]),64&n[0]&&(U.disabled=e[6]),64&n[0]&&(L.disabled=e[6]),e[7]?Le?Le.p(e,n):(Le=tw(e),Le.c(),Le.m(t,null)):Le&&(Le.d(1),Le=null),Me===(Me=Oe(e))&&_e?_e.p(e,n):(_e.d(1),_e=Me(e),_e&&(_e.c(),_e.m(J,null))),64&n[0]&&(z.disabled=e[6]),2048&n[0]&&z.value!==e[11]&&I(z,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Ue!==(Ue=e[10].length+"")&&k(ce,Ue),64&n[0]&&(fe.disabled=e[6]),je===(je=He(e))&&Ge?Ge.p(e,n):(Ge.d(1),Ge=je(e),Ge&&(Ge.c(),Ge.m(ge,null)))},d(e){e&&d(t),Te&&Te.d(),Ne&&Ne.d(),Le&&Le.d(),e&&d(_),e&&d(H),_e.d(),e&&d(te),e&&d(ne),Ge.d(),e&&d(me),e&&d(ye),Re=!1,r(Pe)}}}function Zy(e){let t;return{c(){t=h("span"),t.textContent="Policy Admin",A(t,"class","admin-badge svelte-gkxvxc")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Xy(e){let t,n,r,i,o=e[9],s=[];for(let t=0;t<o.length;t+=1)s[t]=ew(Vy(e,o,t));return{c(){t=h("div"),n=h("h4"),n.textContent="Validation Errors:",r=m(),i=h("ul");for(let e=0;e<s.length;e+=1)s[e].c();A(n,"class","svelte-gkxvxc"),A(i,"class","svelte-gkxvxc"),A(t,"class","validation-errors svelte-gkxvxc")},m(e,o){u(e,t,o),c(t,n),c(t,r),c(t,i);for(let e=0;e<s.length;e+=1)s[e]&&s[e].m(i,null)},p(e,t){if(512&t[0]){let n;for(o=e[9],n=0;n<o.length;n+=1){const r=Vy(e,o,n);s[n]?s[n].p(r,t):(s[n]=ew(r),s[n].c(),s[n].m(i,null))}for(;n<s.length;n+=1)s[n].d(1);s.length=o.length}},d(e){e&&d(t),f(s,e)}}}function ew(e){let t,n,r=e[32]+"";return{c(){t=h("li"),n=g(r),A(t,"class","svelte-gkxvxc")},m(e,r){u(e,t,r),c(t,n)},p(e,t){512&t[0]&&r!==(r=e[32]+"")&&k(n,r)},d(e){e&&d(t)}}}function tw(e){let t,n;return{c(){t=h("div"),n=g(e[7]),A(t,"class","policy-message svelte-gkxvxc"),B(t,"error","error"===e[8]),B(t,"success","success"===e[8])},m(e,r){u(e,t,r),c(t,n)},p(e,r){128&r[0]&&k(n,e[7]),256&r[0]&&B(t,"error","error"===e[8]),256&r[0]&&B(t,"success","success"===e[8])},d(e){e&&d(t)}}}function nw(e){let t,n=e[1],r=[];for(let t=0;t<n.length;t+=1)r[t]=iw(Jy(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(524354&i[0]){let o;for(n=e[1],o=0;o<n.length;o+=1){const s=Jy(e,n,o);r[o]?r[o].p(s,i):(r[o]=iw(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function rw(t){let n;return{c(){n=h("p"),n.textContent="No policy admins configured",A(n,"class","no-items svelte-gkxvxc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function iw(e){let t,n,r,i,o,s,a,l,f,p,y,v,b=e[29].substring(0,16)+"",I=e[29].substring(e[29].length-8)+"";function E(){return e[22](e[29])}return{c(){t=h("div"),n=h("span"),r=g(b),i=g("..."),o=g(I),a=m(),l=h("button"),f=g("✕"),p=m(),A(n,"class","admin-pubkey svelte-gkxvxc"),A(n,"title",s=e[29]),A(l,"class","remove-btn svelte-gkxvxc"),l.disabled=e[6],A(l,"title","Remove admin"),A(t,"class","admin-item svelte-gkxvxc")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(n,i),c(n,o),c(t,a),c(t,l),c(l,f),c(t,p),y||(v=w(l,"click",E),y=!0)},p(t,i){e=t,2&i[0]&&b!==(b=e[29].substring(0,16)+"")&&k(r,b),2&i[0]&&I!==(I=e[29].substring(e[29].length-8)+"")&&k(o,I),2&i[0]&&s!==(s=e[29])&&A(n,"title",s),64&i[0]&&(l.disabled=e[6])},d(e){e&&d(t),y=!1,v()}}}function ow(e){let t,n=e[10],r=[];for(let t=0;t<n.length;t+=1)r[t]=aw(Ky(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();A(t,"class","follows-grid svelte-gkxvxc")},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,i){if(1024&i[0]){let o;for(n=e[10],o=0;o<n.length;o+=1){const s=Ky(e,n,o);r[o]?r[o].p(s,i):(r[o]=aw(s),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function sw(t){let n;return{c(){n=h("p"),n.textContent='No follows loaded. Click "Refresh Follows" to load from database.',A(n,"class","no-items svelte-gkxvxc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function aw(e){let t,n,r,i,o,s,a=e[26].substring(0,12)+"",l=e[26].substring(e[26].length-6)+"";return{c(){t=h("div"),n=g(a),r=g("..."),i=g(l),o=m(),A(t,"class","follow-item svelte-gkxvxc"),A(t,"title",s=e[26])},m(e,s){u(e,t,s),c(t,n),c(t,r),c(t,i),c(t,o)},p(e,r){1024&r[0]&&a!==(a=e[26].substring(0,12)+"")&&k(n,a),1024&r[0]&&l!==(l=e[26].substring(e[26].length-6)+"")&&k(i,l),1024&r[0]&&s!==(s=e[26])&&A(t,"title",s)},d(e){e&&d(t)}}}function lw(t){let n,r,i;function o(e,t){return e[2]&&("owner"===e[3]||e[4])?Wy:e[2]?zy:Yy}let s=o(t),a=s(t);return{c(){n=h("div"),r=h("h2"),r.textContent="Policy Configuration",i=m(),a.c(),A(r,"class","svelte-gkxvxc"),A(n,"class","policy-view svelte-gkxvxc")},m(e,t){u(e,n,t),c(n,r),c(n,i),a.m(n,null)},p(e,t){s===(s=o(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 cw(e,t,n){let{isLoggedIn:r=!1}=t,{userRole:i=""}=t,{isPolicyAdmin:o=!1}=t,{policyEnabled:s=!1}=t,{policyJson:a=""}=t,{isLoadingPolicy:l=!1}=t,{policyMessage:c=""}=t,{policyMessageType:u=""}=t,{validationErrors:d=[]}=t,{policyAdmins:f=[]}=t,{policyFollows:h=[]}=t;const p=P();let g="";function m(){g.trim()&&(p("addPolicyAdmin",g.trim()),n(11,g=""))}function y(e){p("removePolicyAdmin",e)}return e.$$set=e=>{"isLoggedIn"in e&&n(2,r=e.isLoggedIn),"userRole"in e&&n(3,i=e.userRole),"isPolicyAdmin"in e&&n(4,o=e.isPolicyAdmin),"policyEnabled"in e&&n(5,s=e.policyEnabled),"policyJson"in e&&n(0,a=e.policyJson),"isLoadingPolicy"in e&&n(6,l=e.isLoadingPolicy),"policyMessage"in e&&n(7,c=e.policyMessage),"policyMessageType"in e&&n(8,u=e.policyMessageType),"validationErrors"in e&&n(9,d=e.validationErrors),"policyAdmins"in e&&n(1,f=e.policyAdmins),"policyFollows"in e&&n(10,h=e.policyFollows)},e.$$.update=()=>{if(1&e.$$.dirty[0])try{if(a){const e=JSON.parse(a);n(1,f=e.policy_admins||[])}}catch(e){}},[a,f,r,i,o,s,l,c,u,d,h,g,function(){p("loadPolicy")},function(){p("validatePolicy")},function(){p("savePolicy")},function(){p("formatJson")},function(){p("openLoginModal")},function(){p("refreshFollows")},m,y,'{\n "kind": {\n "whitelist": [0, 1, 3, 6, 7, 10002],\n "blacklist": []\n },\n "global": {\n "description": "Global rules applied to all events",\n "size_limit": 65536,\n "max_age_of_event": 86400,\n "max_age_event_in_future": 300\n },\n "rules": {\n "1": {\n "description": "Kind 1 (short text notes)",\n "content_limit": 8192,\n "write_allow_follows": true\n },\n "30023": {\n "description": "Long-form articles",\n "content_limit": 100000,\n "tag_validation": {\n "d": "^[a-z0-9-]{1,64}$",\n "t": "^[a-z0-9-]{1,32}$"\n }\n }\n },\n "default_policy": "allow",\n "policy_admins": ["<your-hex-pubkey>"],\n "policy_follow_whitelist_enabled": true\n}',function(){a=this.value,n(0,a)},e=>y(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class uw extends ae{constructor(e){super(),se(this,e,cw,lw,o,{isLoggedIn:2,userRole:3,isPolicyAdmin:4,policyEnabled:5,policyJson:0,isLoadingPolicy:6,policyMessage:7,policyMessageType:8,validationErrors:9,policyAdmins:1,policyFollows:10},null,[-1,-1])}}const{window:dw}=l;function fw(e,t,n){const r=e.slice();return r[57]=t[n],r}function hw(e,t,n){const r=e.slice();return r[54]=t[n],r}function pw(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to view your Blossom storage.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-on0yal"),A(o,"class","login-btn svelte-on0yal"),A(n,"class","login-prompt svelte-on0yal")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[20]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function gw(e){let t,n,r,i,o,s,a,l,f,p,y,v,b,I,E=e[0]||e[12]?"Loading...":"Refresh";function C(e,t){return e[13]?ww:e[10]?yw:mw}let x=C(e),B=x(e),S=e[14]&&!e[10]&&!e[13]&&Aw(e),F=!e[10]&&!e[13]&&bw(e),Q=e[2]&&Iw(e);function D(e,t){return e[10]&&!e[13]?Cw:Ew}let R=D(e),P=R(e);return{c(){t=h("div"),n=h("div"),B.c(),r=m(),i=h("div"),S&&S.c(),o=m(),s=h("button"),a=g("🔄 "),l=g(E),p=m(),F&&F.c(),y=m(),Q&&Q.c(),v=m(),P.c(),A(s,"class","refresh-btn svelte-on0yal"),s.disabled=f=e[0]||e[12],A(i,"class","header-buttons svelte-on0yal"),A(n,"class","header-section svelte-on0yal"),A(t,"class","blossom-view svelte-on0yal")},m(d,f){u(d,t,f),c(t,n),B.m(n,null),c(n,r),c(n,i),S&&S.m(i,null),c(i,o),c(i,s),c(s,a),c(s,l),c(t,p),F&&F.m(t,null),c(t,y),Q&&Q.m(t,null),c(t,v),P.m(t,null),b||(I=w(s,"click",e[30]),b=!0)},p(e,a){x===(x=C(e))&&B?B.p(e,a):(B.d(1),B=x(e),B&&(B.c(),B.m(n,r))),!e[14]||e[10]||e[13]?S&&(S.d(1),S=null):S?S.p(e,a):(S=Aw(e),S.c(),S.m(i,o)),4097&a[0]&&E!==(E=e[0]||e[12]?"Loading...":"Refresh")&&k(l,E),4097&a[0]&&f!==(f=e[0]||e[12])&&(s.disabled=f),e[10]||e[13]?F&&(F.d(1),F=null):F?F.p(e,a):(F=bw(e),F.c(),F.m(t,y)),e[2]?Q?Q.p(e,a):(Q=Iw(e),Q.c(),Q.m(t,v)):Q&&(Q.d(1),Q=null),R===(R=D(e))&&P?P.p(e,a):(P.d(1),P=R(e),P&&(P.c(),P.m(t,null)))},d(e){e&&d(t),B.d(),S&&S.d(),F&&F.d(),Q&&Q.d(),P.d(),b=!1,I()}}}function mw(t){let n;return{c(){n=h("h3"),n.textContent="Blossom Media Storage",A(n,"class","svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function yw(t){let n,r,i,o,s;return{c(){n=h("button"),n.textContent="← Back",r=m(),i=h("h3"),i.textContent="All Users Storage",A(n,"class","back-btn svelte-on0yal"),A(i,"class","svelte-on0yal")},m(e,a){u(e,n,a),u(e,r,a),u(e,i,a),o||(s=w(n,"click",t[27]),o=!0)},p:e,d(e){e&&d(n),e&&d(r),e&&d(i),o=!1,s()}}}function ww(e){let t,n,r,i,o,s,a,l=(e[13].profile?.name||tv(e[25](e[13].pubkey)))+"",f=e[13].profile?.picture&&vw(e);return{c(){t=h("button"),t.textContent="← Back",n=m(),r=h("h3"),f&&f.c(),i=m(),o=g(l),A(t,"class","back-btn svelte-on0yal"),A(r,"class","user-header svelte-on0yal")},m(l,d){u(l,t,d),u(l,n,d),u(l,r,d),f&&f.m(r,null),c(r,i),c(r,o),s||(a=w(t,"click",e[29]),s=!0)},p(e,t){e[13].profile?.picture?f?f.p(e,t):(f=vw(e),f.c(),f.m(r,i)):f&&(f.d(1),f=null),8192&t[0]&&l!==(l=(e[13].profile?.name||tv(e[25](e[13].pubkey)))+"")&&k(o,l)},d(e){e&&d(t),e&&d(n),e&&d(r),f&&f.d(),s=!1,a()}}}function vw(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[13].profile.picture)||A(t,"src",n),A(t,"alt",""),A(t,"class","header-avatar svelte-on0yal")},m(e,n){u(e,t,n)},p(e,r){8192&r[0]&&!a(t.src,n=e[13].profile.picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function Aw(e){let t,n,r,i;return{c(){t=h("button"),n=g("Admin"),A(t,"class","admin-btn svelte-on0yal"),t.disabled=e[0]},m(o,s){u(o,t,s),c(t,n),r||(i=w(t,"click",e[26]),r=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&d(t),r=!1,i()}}}function bw(e){let t,n,i,o,s,a,l,f,p,y,v=e[3].length>0&&kw(e);return{c(){t=h("div"),n=h("span"),n.textContent="Upload new files",i=m(),o=h("input"),s=m(),v&&v.c(),a=m(),l=h("button"),f=g("Select Files"),A(n,"class","upload-label svelte-on0yal"),A(o,"type","file"),o.multiple=!0,A(o,"class","file-input-hidden svelte-on0yal"),A(l,"class","select-btn svelte-on0yal"),l.disabled=e[4],A(t,"class","upload-section svelte-on0yal")},m(r,d){u(r,t,d),c(t,n),c(t,i),c(t,o),e[39](o),c(t,s),v&&v.m(t,null),c(t,a),c(t,l),c(l,f),p||(y=[w(o,"change",e[22]),w(l,"click",e[23])],p=!0)},p(e,n){e[3].length>0?v?v.p(e,n):(v=kw(e),v.c(),v.m(t,a)):v&&(v.d(1),v=null),16&n[0]&&(l.disabled=e[4])},d(n){n&&d(t),e[39](null),v&&v.d(),p=!1,r(y)}}}function kw(e){let t,n,r,i,o,s,a,l,f=e[3].length+"",p=(e[4]?e[5]:"Upload")+"";return{c(){t=h("span"),n=g(f),r=g(" file(s) selected"),i=m(),o=h("button"),s=g(p),A(t,"class","selected-count svelte-on0yal"),A(o,"class","upload-btn svelte-on0yal"),o.disabled=e[4]},m(d,f){u(d,t,f),c(t,n),c(t,r),u(d,i,f),u(d,o,f),c(o,s),a||(l=w(o,"click",e[24]),a=!0)},p(e,t){8&t[0]&&f!==(f=e[3].length+"")&&k(n,f),48&t[0]&&p!==(p=(e[4]?e[5]:"Upload")+"")&&k(s,p),16&t[0]&&(o.disabled=e[4])},d(e){e&&d(t),e&&d(i),e&&d(o),a=!1,l()}}}function Iw(e){let t,n;return{c(){t=h("div"),n=g(e[2]),A(t,"class","error-message svelte-on0yal")},m(e,r){u(e,t,r),c(t,n)},p(e,t){4&t[0]&&k(n,e[2])},d(e){e&&d(t)}}}function Ew(e){let t,n,r;function i(e,r){return 1&r[0]&&(t=null),null==t&&(t=!(!e[0]||0!==e[31]().length)),t?Sw:(null==n&&(n=!(0!==e[31]().length)),n?Bw:xw)}let o=i(e,[-1,-1]),s=o(e);return{c(){s.c(),r=y()},m(e,t){s.m(e,t),u(e,r,t)},p(e,t){o===(o=i(e,t))&&s?s.p(e,t):(s.d(1),s=o(e),s&&(s.c(),s.m(r.parentNode,r)))},d(e){s.d(e),e&&d(r)}}}function Cw(e){let t;function n(e,t){return e[12]?Uw:0===e[11].length?$w:Pw}let r=n(e),i=r(e);return{c(){i.c(),t=y()},m(e,n){i.m(e,n),u(e,t,n)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t.parentNode,t)))},d(e){i.d(e),e&&d(t)}}}function xw(e){let t,n=e[31](),r=[];for(let t=0;t<n.length;t+=1)r[t]=Rw(fw(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();A(t,"class","blob-list svelte-on0yal")},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,i){if(2129920&i[0]|1&i[1]){let o;for(n=e[31](),o=0;o<n.length;o+=1){const s=fw(e,n,o);r[o]?r[o].p(s,i):(r[o]=Rw(s),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function Bw(e){let t,n,r,i=e[13]?"No files found for this user.":"No files found in your Blossom storage.";return{c(){t=h("div"),n=h("p"),r=g(i),A(t,"class","empty-state svelte-on0yal")},m(e,i){u(e,t,i),c(t,n),c(n,r)},p(e,t){8192&t[0]&&i!==(i=e[13]?"No files found for this user.":"No files found in your Blossom storage.")&&k(r,i)},d(e){e&&d(t)}}}function Sw(t){let n;return{c(){n=h("div"),n.textContent="Loading blobs...",A(n,"class","loading svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Fw(t){let n,r,i=Xw(t[57].type)+"";return{c(){n=h("span"),r=g(i),A(n,"class","thumbnail-icon svelte-on0yal")},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}function Qw(t){let n,r;return{c(){n=h("video"),a(n.src,r=ev(t[57]))||A(n,"src",r),A(n,"class","thumbnail-video svelte-on0yal"),n.muted=!0,A(n,"preload","metadata")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Dw(t){let n,r;return{c(){n=h("img"),a(n.src,r=ev(t[57]))||A(n,"src",r),A(n,"alt",""),A(n,"class","thumbnail-img svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Rw(e){let t,n,i,o,s,a,l,f,p,y,b,k,I,E,C,x,B,S,F,Q,D,R,P,$,U,T=e[57].sha256+"",N=Ww(e[57].sha256)+"",L=Yw(e[57].size)+"",O=(e[57].type||"unknown")+"",M=zw(e[57].uploaded)+"";let _=function(e){return"image"===Zw(e[57].type)?Dw:"video"===Zw(e[57].type)?Qw:Fw}(e),H=_(e);function j(){return e[42](e[57])}function G(){return e[43](e[57])}function q(...t){return e[44](e[57],...t)}return{c(){t=h("div"),n=h("div"),H.c(),i=m(),o=h("div"),s=h("div"),a=h("span"),l=g(T),f=m(),p=h("span"),y=g(N),b=m(),k=h("div"),I=h("span"),E=g(L),C=m(),x=h("span"),B=g(O),S=m(),F=h("div"),Q=g(M),D=m(),R=h("button"),R.textContent="X",P=m(),A(n,"class","blob-thumbnail svelte-on0yal"),A(a,"class","hash-full svelte-on0yal"),A(p,"class","hash-truncated svelte-on0yal"),A(s,"class","blob-hash svelte-on0yal"),A(s,"title",e[57].sha256),A(I,"class","blob-size"),A(x,"class","blob-type"),A(k,"class","blob-meta svelte-on0yal"),A(o,"class","blob-info svelte-on0yal"),A(F,"class","blob-date svelte-on0yal"),A(R,"class","delete-btn svelte-on0yal"),A(R,"title","Delete"),A(t,"class","blob-item svelte-on0yal"),A(t,"role","button"),A(t,"tabindex","0")},m(e,r){u(e,t,r),c(t,n),H.m(n,null),c(t,i),c(t,o),c(o,s),c(s,a),c(a,l),c(s,f),c(s,p),c(p,y),c(o,b),c(o,k),c(k,I),c(I,E),c(k,C),c(k,x),c(x,B),c(t,S),c(t,F),c(F,Q),c(t,D),c(t,R),c(t,P),$||(U=[w(R,"click",v(j)),w(t,"click",G),w(t,"keypress",q)],$=!0)},p(t,n){e=t,H.p(e,n)},d(e){e&&d(t),H.d(),$=!1,r(U)}}}function Pw(e){let t,n=e[11],r=[];for(let t=0;t<n.length;t+=1)r[t]=Lw(hw(e,n,t));return{c(){t=h("div");for(let e=0;e<r.length;e+=1)r[e].c();A(t,"class","admin-users-list svelte-on0yal")},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,i){if(301991936&i[0]){let o;for(n=e[11],o=0;o<n.length;o+=1){const s=hw(e,n,o);r[o]?r[o].p(s,i):(r[o]=Lw(s),r[o].c(),r[o].m(t,null))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){e&&d(t),f(r,e)}}}function $w(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No users have uploaded files yet.</p>",A(n,"class","empty-state svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Uw(t){let n;return{c(){n=h("div"),n.textContent="Loading user statistics...",A(n,"class","loading svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Tw(t){let n;return{c(){n=h("div"),A(n,"class","user-avatar-placeholder svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Nw(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[54].profile.picture)||A(t,"src",n),A(t,"alt",""),A(t,"class","user-avatar svelte-on0yal")},m(e,n){u(e,t,n)},p(e,r){2048&r[0]&&!a(t.src,n=e[54].profile.picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function Lw(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,B,S,F,Q,D,R,P,$,U,T=(e[54].profile?.name||tv(e[25](e[54].pubkey)))+"",N=e[25](e[54].pubkey)+"",L=tv(e[25](e[54].pubkey))+"",O=e[54].blob_count+"",M=Yw(e[54].total_size_bytes)+"";function _(e,t){return e[54].profile?.picture?Nw:Tw}let H=_(e),j=H(e);function G(){return e[40](e[54])}function q(...t){return e[41](e[54],...t)}return{c(){t=h("div"),n=h("div"),j.c(),i=m(),o=h("div"),s=h("div"),a=g(T),l=m(),f=h("div"),p=h("span"),y=g(N),v=m(),b=h("span"),I=g(L),C=m(),x=h("div"),B=h("span"),S=g(O),F=g(" files"),Q=m(),D=h("span"),R=g(M),P=m(),A(n,"class","user-avatar-container svelte-on0yal"),A(s,"class","user-name svelte-on0yal"),A(p,"class","npub-full svelte-on0yal"),A(b,"class","npub-truncated svelte-on0yal"),A(f,"class","user-npub svelte-on0yal"),A(f,"title",E=e[54].pubkey),A(o,"class","user-info svelte-on0yal"),A(B,"class","blob-count svelte-on0yal"),A(D,"class","total-size svelte-on0yal"),A(x,"class","user-stats svelte-on0yal"),A(t,"class","user-stat-item svelte-on0yal"),A(t,"role","button"),A(t,"tabindex","0")},m(e,r){u(e,t,r),c(t,n),j.m(n,null),c(t,i),c(t,o),c(o,s),c(s,a),c(o,l),c(o,f),c(f,p),c(p,y),c(f,v),c(f,b),c(b,I),c(t,C),c(t,x),c(x,B),c(B,S),c(B,F),c(x,Q),c(x,D),c(D,R),c(t,P),$||(U=[w(t,"click",G),w(t,"keypress",q)],$=!0)},p(t,r){H===(H=_(e=t))&&j?j.p(e,r):(j.d(1),j=H(e),j&&(j.c(),j.m(n,null))),2048&r[0]&&T!==(T=(e[54].profile?.name||tv(e[25](e[54].pubkey)))+"")&&k(a,T),2048&r[0]&&N!==(N=e[25](e[54].pubkey)+"")&&k(y,N),2048&r[0]&&L!==(L=tv(e[25](e[54].pubkey))+"")&&k(I,L),2048&r[0]&&E!==(E=e[54].pubkey)&&A(f,"title",E),2048&r[0]&&O!==(O=e[54].blob_count+"")&&k(S,O),2048&r[0]&&M!==(M=Yw(e[54].total_size_bytes)+"")&&k(R,M)},d(e){e&&d(t),j.d(),$=!1,r(U)}}}function Ow(e){let t,n,i,o,s,a,l,f,p,y,b,I,E,C,x,B,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z,X,ee,te=Ww(e[8].sha256)+"",ne=(e[8].type||"unknown")+"",re="image"===Zw(e[8].type),ie=Yw(e[8].size)+"",oe=zw(e[8].uploaded)+"",se=re&&Mw(e);function ae(e,t){return 256&t[0]&&(B=null),256&t[0]&&(S=null),256&t[0]&&(F=null),null==B&&(B=!("image"!==Zw(e[8].type))),B?Gw:(null==S&&(S=!("video"!==Zw(e[8].type))),S?jw:(null==F&&(F=!("audio"!==Zw(e[8].type))),F?Hw:_w))}let le=ae(e,[-1,-1]),ce=le(e);return{c(){t=h("div"),n=h("div"),i=h("div"),o=h("div"),s=h("span"),a=g(te),l=m(),f=h("span"),p=g(ne),y=m(),b=h("div"),se&&se.c(),I=m(),E=h("button"),E.textContent="X",C=m(),x=h("div"),ce.c(),Q=m(),D=h("div"),R=h("div"),P=h("span"),$=g("Size: "),U=g(ie),T=m(),N=h("span"),L=g("Uploaded: "),O=g(oe),M=m(),_=h("div"),H=h("input"),G=m(),q=h("button"),q.textContent="Copy",K=m(),J=h("div"),V=h("a"),Y=g("Open in New Tab"),W=m(),Z=h("button"),Z.textContent="Delete",A(s,"class","modal-hash svelte-on0yal"),A(f,"class","modal-type svelte-on0yal"),A(o,"class","modal-title svelte-on0yal"),A(E,"class","close-btn svelte-on0yal"),A(b,"class","modal-controls svelte-on0yal"),A(i,"class","modal-header svelte-on0yal"),A(x,"class","modal-body svelte-on0yal"),A(R,"class","blob-details svelte-on0yal"),A(H,"type","text"),H.readOnly=!0,H.value=j=ev(e[8]),A(H,"class","blob-url-input svelte-on0yal"),A(q,"class","copy-btn svelte-on0yal"),A(_,"class","blob-url-section svelte-on0yal"),A(V,"href",z=ev(e[8])),A(V,"target","_blank"),A(V,"rel","noopener noreferrer"),A(V,"class","action-btn svelte-on0yal"),A(Z,"class","action-btn danger svelte-on0yal"),A(J,"class","modal-actions svelte-on0yal"),A(D,"class","modal-footer svelte-on0yal"),A(n,"class","modal-content svelte-on0yal"),A(n,"role","dialog"),A(t,"class","modal-overlay svelte-on0yal"),A(t,"role","button"),A(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(i,o),c(o,s),c(s,a),c(o,l),c(o,f),c(f,p),c(i,y),c(i,b),se&&se.m(b,null),c(b,I),c(b,E),c(n,C),c(n,x),ce.m(x,null),c(n,Q),c(n,D),c(D,R),c(R,P),c(P,$),c(P,U),c(R,T),c(R,N),c(N,L),c(N,O),c(D,M),c(D,_),c(_,H),c(_,G),c(_,q),c(D,K),c(D,J),c(J,V),c(V,Y),c(J,W),c(J,Z),X||(ee=[w(E,"click",e[16]),w(H,"click",nv),w(q,"click",e[45]),w(Z,"click",e[46]),w(n,"click",v(e[37])),w(n,"keypress",v(e[38])),w(t,"click",e[16]),w(t,"keypress",e[47])],X=!0)},p(e,t){256&t[0]&&te!==(te=Ww(e[8].sha256)+"")&&k(a,te),256&t[0]&&ne!==(ne=(e[8].type||"unknown")+"")&&k(p,ne),256&t[0]&&(re="image"===Zw(e[8].type)),re?se?se.p(e,t):(se=Mw(e),se.c(),se.m(b,I)):se&&(se.d(1),se=null),le===(le=ae(e,t))&&ce?ce.p(e,t):(ce.d(1),ce=le(e),ce&&(ce.c(),ce.m(x,null))),256&t[0]&&ie!==(ie=Yw(e[8].size)+"")&&k(U,ie),256&t[0]&&oe!==(oe=zw(e[8].uploaded)+"")&&k(O,oe),256&t[0]&&j!==(j=ev(e[8]))&&H.value!==j&&(H.value=j),256&t[0]&&z!==(z=ev(e[8]))&&A(V,"href",z)},d(e){e&&d(t),se&&se.d(),ce.d(),X=!1,r(ee)}}}function Mw(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E=Math.round(100*e[9])+"";return{c(){t=h("button"),n=g("-"),o=m(),s=h("span"),a=g(E),l=g("%"),f=m(),p=h("button"),y=g("+"),A(t,"class","zoom-btn svelte-on0yal"),t.disabled=i=e[9]<=Kw,A(s,"class","zoom-level svelte-on0yal"),A(p,"class","zoom-btn svelte-on0yal"),p.disabled=v=e[9]>=Jw},m(r,i){u(r,t,i),c(t,n),u(r,o,i),u(r,s,i),c(s,a),c(s,l),u(r,f,i),u(r,p,i),c(p,y),b||(I=[w(t,"click",e[18]),w(p,"click",e[17])],b=!0)},p(e,n){512&n[0]&&i!==(i=e[9]<=Kw)&&(t.disabled=i),512&n[0]&&E!==(E=Math.round(100*e[9])+"")&&k(a,E),512&n[0]&&v!==(v=e[9]>=Jw)&&(p.disabled=v)},d(e){e&&d(t),e&&d(o),e&&d(s),e&&d(f),e&&d(p),b=!1,r(I)}}}function _w(e){let t,n,r,i,o,s,a,l,f,p=Xw(e[8].type)+"";return{c(){t=h("div"),n=h("div"),r=g(p),i=m(),o=h("p"),o.textContent="Preview not available for this file type.",s=m(),a=h("a"),l=g("Download File"),A(n,"class","file-icon svelte-on0yal"),A(a,"href",f=ev(e[8])),A(a,"target","_blank"),A(a,"rel","noopener noreferrer"),A(a,"class","download-link svelte-on0yal"),A(t,"class","file-preview svelte-on0yal")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,i),c(t,o),c(t,s),c(t,a),c(a,l)},p(e,t){256&t[0]&&p!==(p=Xw(e[8].type)+"")&&k(r,p),256&t[0]&&f!==(f=ev(e[8]))&&A(a,"href",f)},d(e){e&&d(t)}}}function Hw(e){let t,n,r;return{c(){t=h("div"),n=h("audio"),n.controls=!0,a(n.src,r=ev(e[8]))||A(n,"src",r),A(n,"class","svelte-on0yal"),A(t,"class","media-container audio svelte-on0yal")},m(e,r){u(e,t,r),c(t,n)},p(e,t){256&t[0]&&!a(n.src,r=ev(e[8]))&&A(n,"src",r)},d(e){e&&d(t)}}}function jw(e){let t,n,r,i;return{c(){t=h("div"),n=h("video"),r=h("track"),A(r,"kind","captions"),n.controls=!0,a(n.src,i=ev(e[8]))||A(n,"src",i),A(n,"class","svelte-on0yal"),A(t,"class","media-container svelte-on0yal")},m(e,i){u(e,t,i),c(t,n),c(n,r)},p(e,t){256&t[0]&&!a(n.src,i=ev(e[8]))&&A(n,"src",i)},d(e){e&&d(t)}}}function Gw(e){let t,n,r;return{c(){t=h("div"),n=h("img"),a(n.src,r=ev(e[8]))||A(n,"src",r),A(n,"alt","Blob content"),A(n,"class","svelte-on0yal"),A(t,"class","media-container svelte-on0yal"),E(t,"transform","scale("+e[9]+")")},m(e,r){u(e,t,r),c(t,n)},p(e,i){256&i[0]&&!a(n.src,r=ev(e[8]))&&A(n,"src",r),512&i[0]&&E(t,"transform","scale("+e[9]+")")},d(e){e&&d(t)}}}function qw(t){let n,r,i,o;function s(e,t){return e[1]?gw:pw}let a=s(t),l=a(t),c=t[7]&&t[8]&&Ow(t);return{c(){l.c(),n=m(),c&&c.c(),r=y()},m(e,s){l.m(e,s),u(e,n,s),c&&c.m(e,s),u(e,r,s),i||(o=w(dw,"keydown",t[19]),i=!0)},p(e,t){a===(a=s(e))&&l?l.p(e,t):(l.d(1),l=a(e),l&&(l.c(),l.m(n.parentNode,n))),e[7]&&e[8]?c?c.p(e,t):(c=Ow(e),c.c(),c.m(r.parentNode,r)):c&&(c.d(1),c=null)},i:e,o:e,d(e){l.d(e),e&&d(n),c&&c.d(e),e&&d(r),i=!1,o()}}}const Kw=.25,Jw=4;async function Vw(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const r=Math.floor(Date.now()/1e3),i=[["t",t],["expiration",(r+60).toString()]];n&&i.push(["x",n]);const o={kind:24242,created_at:r,tags:i,content:`Blossom ${t} operation`},s=await e.signEvent(o);return btoa(JSON.stringify(s)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating Blossom auth:",e),null}}function Yw(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(0===n?0:1)} ${t[n]}`}function zw(e){return e?new Date(1e3*e).toLocaleString():"Unknown"}function Ww(e){return e?`${e.slice(0,8)}...${e.slice(-8)}`:""}function Zw(e){return e?e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":"file":"unknown"}function Xw(e){switch(Zw(e)){case"image":return"🖼️";case"video":return"🎬";case"audio":return"🎵";default:return"📄"}}function ev(e){return e.url?e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:e.url.startsWith("/")?`${window.location.origin}${e.url}`:`http://${e.url}`:`${window.location.origin}/blossom/${e.sha256}`}function tv(e){return e?`${e.slice(0,12)}...${e.slice(-8)}`:""}const nv=e=>e.target.select();function rv(e,t,n){let r,i,{isLoggedIn:o=!1}=t,{userPubkey:s=""}=t,{userSigner:a=null}=t,{currentEffectiveRole:l=""}=t;const c=P();let u,d=[],f=!1,h="",p=[],g=!1,m="",y=!1,w=null,v=1,A=!1,b=[],k=!1,I=null,E=[],C=!1;async function x(){if(s){n(0,f=!0),n(2,h="");try{const e=`${window.location.origin}/blossom/list/${s}`,t=await Vw(a,"list"),n=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!n.ok)throw new Error(`Failed to load blobs: ${n.statusText}`);const r=await n.json();d=Array.isArray(r)?r:[],d.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0)),console.log("Loaded blobs:",d)}catch(e){console.error("Error loading blobs:",e),n(2,h=e.message||"Failed to load blobs")}finally{n(0,f=!1)}}}function B(e){n(8,w=e),n(9,v=1),n(7,y=!0)}function S(){n(7,y=!1),n(8,w=null),n(9,v=1)}function F(){v<Jw&&n(9,v=Math.min(Jw,v+.25))}function Q(){v>Kw&&n(9,v=Math.max(Kw,v-.25))}async function R(e){if(confirm(`Delete blob ${Ww(e.sha256)}?`))try{const t=`${window.location.origin}/blossom/${e.sha256}`,n=await Vw(a,"delete",e.sha256),r=await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}});if(!r.ok)throw new Error(`Failed to delete: ${r.statusText}`);d=d.filter(t=>t.sha256!==e.sha256),w?.sha256===e.sha256&&S()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function U(){n(12,k=!0),n(2,h="");try{const e=`${window.location.origin}/blossom/admin/users`,t=await Vw(a,"admin"),r=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!r.ok)throw new Error(`Failed to load user stats: ${r.statusText}`);n(11,b=await r.json());for(const e of b)Oh(e.pubkey).then(t=>{e.profile=t||{name:"",picture:""},n(11,b)}).catch(()=>{e.profile={name:"",picture:""}})}catch(e){console.error("Error fetching admin user stats:",e),n(2,h=e.message||"Failed to load user stats")}finally{n(12,k=!1)}}async function N(e){n(0,f=!0),n(2,h="");try{const t=`${window.location.origin}/blossom/list/${e}`,n=await Vw(a,"list"),r=await fetch(t,{headers:n?{Authorization:`Nostr ${n}`}:{}});if(!r.ok)throw new Error(`Failed to load user blobs: ${r.statusText}`);E=await r.json(),E.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))}catch(e){console.error("Error loading user blobs:",e),n(2,h=e.message||"Failed to load user blobs")}finally{n(0,f=!1)}}async function L(e){n(13,I={pubkey:e.pubkey,profile:e.profile}),await N(e.pubkey)}D(()=>{r&&!C&&(n(36,C=!0),x())});return e.$$set=e=>{"isLoggedIn"in e&&n(32,o=e.isLoggedIn),"userPubkey"in e&&n(33,s=e.userPubkey),"userSigner"in e&&n(34,a=e.userSigner),"currentEffectiveRole"in e&&n(35,l=e.currentEffectiveRole)},e.$$.update=()=>{6&e.$$.dirty[1]&&n(1,r=o&&s),16&e.$$.dirty[1]&&n(14,i="admin"===l||"owner"===l),3&e.$$.dirty[0]|32&e.$$.dirty[1]&&(!r||C||f||(n(36,C=!0),x()))},[f,r,h,p,g,m,u,y,w,v,A,b,k,I,i,B,S,F,Q,function(e){y&&("Escape"===e.key?S():"+"===e.key||"="===e.key?F():"-"===e.key&&Q())},function(){c("openLoginModal")},R,function(e){n(3,p=Array.from(e.target.files))},function(){u?.click()},async function(){if(0===p.length)return;n(4,g=!0),n(2,h="");const e=[],t=[];for(let r=0;r<p.length;r++){const i=p[r];n(5,m=`Uploading ${r+1}/${p.length}: ${i.name}`);try{const t=`${window.location.origin}/blossom/upload`,n=await Vw(a,"upload"),r=await fetch(t,{method:"PUT",headers:{"Content-Type":i.type||"application/octet-stream",...n?{Authorization:`Nostr ${n}`}:{}},body:i});if(!r.ok){const e=r.headers.get("X-Reason")||r.statusText;throw new Error(e)}const o=await r.json();console.log("Upload response:",o),e.push(o)}catch(e){console.error(`Error uploading ${i.name}:`,e),t.push({name:i.name,error:e.message})}}n(4,g=!1),n(5,m=""),n(3,p=[]),u&&n(6,u.value="",u),e.length>0&&await x(),t.length>0&&n(2,h=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return bu(e)}catch(t){return Ww(e)}},function(){n(10,A=!0),U()},function(){n(10,A=!1),n(11,b=[]),n(13,I=null),E=[]},L,function(){n(13,I=null),E=[]},function(){I?N(I.pubkey):A?U():x()},function(){return I?E:d},o,s,a,l,C,function(t){$.call(this,e,t)},function(t){$.call(this,e,t)},function(e){T[e?"unshift":"push"](()=>{u=e,n(6,u)})},e=>L(e),(e,t)=>"Enter"===t.key&&L(e),e=>R(e),e=>B(e),(e,t)=>"Enter"===t.key&&B(e),()=>{navigator.clipboard.writeText(ev(w))},()=>R(w),e=>"Enter"===e.key&&S()]}class iv extends ae{constructor(e){super(),se(this,e,rv,qw,o,{isLoggedIn:32,userPubkey:33,userSigner:34,currentEffectiveRole:35},null,[-1,-1])}}var ov={},sv={},av={};let lv;const cv=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];av.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},av.getSymbolTotalCodewords=function(e){return cv[e]},av.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},av.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');lv=e},av.isKanjiModeEnabled=function(){return void 0!==lv},av.toSJIS=function(e){return lv(e)};var uv,dv={};function fv(){this.buffer=[],this.length=0}(uv=dv).L={bit:1},uv.M={bit:0},uv.Q={bit:3},uv.H={bit:2},uv.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},uv.from=function(e,t){if(uv.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return uv.L;case"m":case"medium":return uv.M;case"q":case"quartile":return uv.Q;case"h":case"high":return uv.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(e){return t}},fv.prototype={get:function(e){const t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(let n=0;n<t;n++)this.putBit(1==(e>>>t-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var hv=fv;function pv(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}pv.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},pv.prototype.get=function(e,t){return this.data[e*this.size+t]},pv.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},pv.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var gv=pv,mv={};!function(e){const t=av.getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];const n=Math.floor(e/7)+2,r=t(e),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),o=[r-7];for(let e=1;e<n-1;e++)o[e]=o[e-1]-i;return o.push(6),o.reverse()},e.getPositions=function(t){const n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)0===e&&0===t||0===e&&t===i-1||e===i-1&&0===t||n.push([r[e],r[t]]);return n}}(mv);var yv={};const wv=av.getSymbolSize;yv.getPositions=function(e){const t=wv(e);return[[0,0],[t-7,0],[0,t-7]]};var vv={};!function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t=3,n=3,r=40,i=10;function o(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){const n=e.size;let r=0,i=0,o=0,s=null,a=null;for(let l=0;l<n;l++){i=o=0,s=a=null;for(let c=0;c<n;c++){let n=e.get(l,c);n===s?i++:(i>=5&&(r+=t+(i-5)),s=n,i=1),n=e.get(c,l),n===a?o++:(o>=5&&(r+=t+(o-5)),a=n,o=1)}i>=5&&(r+=t+(i-5)),o>=5&&(r+=t+(o-5))}return r},e.getPenaltyN2=function(e){const t=e.size;let r=0;for(let n=0;n<t-1;n++)for(let i=0;i<t-1;i++){const t=e.get(n,i)+e.get(n,i+1)+e.get(n+1,i)+e.get(n+1,i+1);4!==t&&0!==t||r++}return r*n},e.getPenaltyN3=function(e){const t=e.size;let n=0,i=0,o=0;for(let r=0;r<t;r++){i=o=0;for(let s=0;s<t;s++)i=i<<1&2047|e.get(r,s),s>=10&&(1488===i||93===i)&&n++,o=o<<1&2047|e.get(s,r),s>=10&&(1488===o||93===o)&&n++}return n*r},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return Math.abs(Math.ceil(100*t/n/5)-10)*i},e.applyMask=function(e,t){const n=t.size;for(let r=0;r<n;r++)for(let i=0;i<n;i++)t.isReserved(i,r)||t.xor(i,r,o(e,i,r))},e.getBestMask=function(t,n){const r=Object.keys(e.Patterns).length;let i=0,o=1/0;for(let s=0;s<r;s++){n(s),e.applyMask(s,t);const r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(s,t),r<o&&(o=r,i=s)}return i}}(vv);var Av={};const bv=dv,kv=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Iv=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Av.getBlocksCount=function(e,t){switch(t){case bv.L:return kv[4*(e-1)+0];case bv.M:return kv[4*(e-1)+1];case bv.Q:return kv[4*(e-1)+2];case bv.H:return kv[4*(e-1)+3];default:return}},Av.getTotalCodewordsCount=function(e,t){switch(t){case bv.L:return Iv[4*(e-1)+0];case bv.M:return Iv[4*(e-1)+1];case bv.Q:return Iv[4*(e-1)+2];case bv.H:return Iv[4*(e-1)+3];default:return}};var Ev={},Cv={};const xv=new Uint8Array(512),Bv=new Uint8Array(256);!function(){let e=1;for(let t=0;t<255;t++)xv[t]=e,Bv[e]=t,e<<=1,256&e&&(e^=285);for(let e=255;e<512;e++)xv[e]=xv[e-255]}(),Cv.log=function(e){if(e<1)throw new Error("log("+e+")");return Bv[e]},Cv.exp=function(e){return xv[e]},Cv.mul=function(e,t){return 0===e||0===t?0:xv[Bv[e]+Bv[t]]},function(e){const t=Cv;e.mul=function(e,n){const r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let o=0;o<n.length;o++)r[i+o]^=t.mul(e[i],n[o]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){const e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&0===r[i];)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}}(Ev);const Sv=Ev;function Fv(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Fv.prototype.initialize=function(e){this.degree=e,this.genPoly=Sv.generateECPolynomial(this.degree)},Fv.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const n=Sv.mod(t,this.genPoly),r=this.degree-n.length;if(r>0){const e=new Uint8Array(this.degree);return e.set(n,r),e}return n};var Qv=Fv,Dv={},Rv={},Pv={isValid:function(e){return!isNaN(e)&&e>=1&&e<=40}},$v={};const Uv="[0-9]+";let Tv="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Tv=Tv.replace(/u/g,"\\u");const Nv="(?:(?![A-Z0-9 $%*+\\-./:]|"+Tv+")(?:.|[\r\n]))+";$v.KANJI=new RegExp(Tv,"g"),$v.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),$v.BYTE=new RegExp(Nv,"g"),$v.NUMERIC=new RegExp(Uv,"g"),$v.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const Lv=new RegExp("^"+Tv+"$"),Ov=new RegExp("^"+Uv+"$"),Mv=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");$v.testKanji=function(e){return Lv.test(e)},$v.testNumeric=function(e){return Ov.test(e)},$v.testAlphanumeric=function(e){return Mv.test(e)},function(e){const t=Pv,n=$v;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,n){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return n}}}(Rv),function(e){const t=av,n=Av,r=dv,i=Rv,o=Pv,s=t.getBCHDigit(7973);function a(e,t){return i.getCharCountIndicator(e,t)+4}function l(e,t){let n=0;return e.forEach(function(e){const r=a(e.mode,t);n+=r+e.getBitsLength()}),n}e.from=function(e,t){return o.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,s){if(!o.isValid(e))throw new Error("Invalid QR Code version");void 0===s&&(s=i.BYTE);const l=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r));if(s===i.MIXED)return l;const c=l-a(s,e);switch(s){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(t,n){let o;const s=r.from(n,r.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let r=1;r<=40;r++)if(l(t,r)<=e.getCapacity(r,n,i.MIXED))return r}(t,s);if(0===t.length)return 1;o=t[0]}else o=t;return function(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}(o.mode,o.getLength(),s)},e.getEncodedBits=function(e){if(!o.isValid(e)||e<7)throw new Error("Invalid QR Code version");let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=7973<<t.getBCHDigit(n)-s;return e<<12|n}}(Dv);var _v={};const Hv=av,jv=Hv.getBCHDigit(1335);_v.getEncodedBits=function(e,t){const n=e.bit<<3|t;let r=n<<10;for(;Hv.getBCHDigit(r)-jv>=0;)r^=1335<<Hv.getBCHDigit(r)-jv;return 21522^(n<<10|r)};var Gv={};const qv=Rv;function Kv(e){this.mode=qv.NUMERIC,this.data=e.toString()}Kv.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},Kv.prototype.getLength=function(){return this.data.length},Kv.prototype.getBitsLength=function(){return Kv.getBitsLength(this.data.length)},Kv.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);const i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,3*i+1))};var Jv=Kv;const Vv=Rv,Yv=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function zv(e){this.mode=Vv.ALPHANUMERIC,this.data=e}zv.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},zv.prototype.getLength=function(){return this.data.length},zv.prototype.getBitsLength=function(){return zv.getBitsLength(this.data.length)},zv.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*Yv.indexOf(this.data[t]);n+=Yv.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(Yv.indexOf(this.data[t]),6)};var Wv=zv;const Zv=Rv;function Xv(e){this.mode=Zv.BYTE,this.data="string"==typeof e?(new TextEncoder).encode(e):new Uint8Array(e)}Xv.getBitsLength=function(e){return 8*e},Xv.prototype.getLength=function(){return this.data.length},Xv.prototype.getBitsLength=function(){return Xv.getBitsLength(this.data.length)},Xv.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var eA=Xv;const tA=Rv,nA=av;function rA(e){this.mode=tA.KANJI,this.data=e}rA.getBitsLength=function(e){return 13*e},rA.prototype.getLength=function(){return this.data.length},rA.prototype.getBitsLength=function(){return rA.getBitsLength(this.data.length)},rA.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=nA.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}};var iA=rA,oA={exports:{}};!function(e){var t={single_source_shortest_paths:function(e,n,r){var i={},o={};o[n]=0;var s,a,l,c,u,d,f,h=t.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(l in a=(s=h.pop()).value,c=s.cost,u=e[a]||{})u.hasOwnProperty(l)&&(d=c+u[l],f=o[l],(void 0===o[l]||f>d)&&(o[l]=d,h.push(l,d),i[l]=a));if(void 0!==r&&void 0===o[r]){var p=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(p)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,n,r){var i=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,i={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(i[n]=r[n]);return i.queue=[],i.sorter=e.sorter||r.default_sorter,i},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(oA);var sA=oA.exports;!function(e){const t=Rv,n=Jv,r=Wv,i=eA,o=iA,s=$v,a=av,l=sA;function c(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){const r=[];let i;for(;null!==(i=e.exec(n));)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){const n=u(s.NUMERIC,t.NUMERIC,e),r=u(s.ALPHANUMERIC,t.ALPHANUMERIC,e);let i,o;a.isKanjiModeEnabled()?(i=u(s.BYTE,t.BYTE,e),o=u(s.KANJI,t.KANJI,e)):(i=u(s.BYTE_KANJI,t.BYTE,e),o=[]);return n.concat(r,i,o).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,s){switch(s){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return o.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function h(e,s){let l;const c=t.getBestModeForData(e);if(l=t.from(s,c),l!==t.BYTE&&l.bit<c.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(l)+".\n Suggested mode is: "+t.toString(c));switch(l!==t.KANJI||a.isKanjiModeEnabled()||(l=t.BYTE),l){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new o(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(h(t,null)):t.data&&e.push(h(t.data,t.mode)),e},[])},e.fromString=function(n,r){const i=function(e){const n=[];for(let r=0;r<e.length;r++){const i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:c(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:c(i.data)}])}}return n}(d(n,a.isKanjiModeEnabled())),o=function(e,n){const r={},i={start:{}};let o=["start"];for(let s=0;s<e.length;s++){const a=e[s],l=[];for(let e=0;e<a.length;e++){const c=a[e],u=""+s+e;l.push(u),r[u]={node:c,lastCount:0},i[u]={};for(let e=0;e<o.length;e++){const s=o[e];r[s]&&r[s].node.mode===c.mode?(i[s][u]=f(r[s].lastCount+c.length,c.mode)-f(r[s].lastCount,c.mode),r[s].lastCount+=c.length):(r[s]&&(r[s].lastCount=c.length),i[s][u]=f(c.length,c.mode)+4+t.getCharCountIndicator(c.mode,n))}}o=l}for(let e=0;e<o.length;e++)i[o[e]].end=0;return{map:i,table:r}}(i,r),s=l.find_path(o.map,"start","end"),u=[];for(let e=1;e<s.length-1;e++)u.push(o.table[s[e]].node);return e.fromArray(function(e){return e.reduce(function(e,t){const n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(u))},e.rawSplit=function(t){return e.fromArray(d(t,a.isKanjiModeEnabled()))}}(Gv);const aA=av,lA=dv,cA=hv,uA=gv,dA=mv,fA=yv,hA=vv,pA=Av,gA=Qv,mA=Dv,yA=_v,wA=Rv,vA=Gv;function AA(e,t,n){const r=e.size,i=yA.getEncodedBits(t,n);let o,s;for(o=0;o<15;o++)s=1==(i>>o&1),o<6?e.set(o,8,s,!0):o<8?e.set(o+1,8,s,!0):e.set(r-15+o,8,s,!0),o<8?e.set(8,r-o-1,s,!0):o<9?e.set(8,15-o-1+1,s,!0):e.set(8,15-o-1,s,!0);e.set(r-8,8,1,!0)}function bA(e,t,n){const r=new cA;n.forEach(function(t){r.put(t.mode.bit,4),r.put(t.getLength(),wA.getCharCountIndicator(t.mode,e)),t.write(r)});const i=8*(aA.getSymbolTotalCodewords(e)-pA.getTotalCodewordsCount(e,t));for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const o=(i-r.getLengthInBits())/8;for(let e=0;e<o;e++)r.put(e%2?17:236,8);return function(e,t,n){const r=aA.getSymbolTotalCodewords(t),i=pA.getTotalCodewordsCount(t,n),o=r-i,s=pA.getBlocksCount(t,n),a=r%s,l=s-a,c=Math.floor(r/s),u=Math.floor(o/s),d=u+1,f=c-u,h=new gA(f);let p=0;const g=new Array(s),m=new Array(s);let y=0;const w=new Uint8Array(e.buffer);for(let e=0;e<s;e++){const t=e<l?u:d;g[e]=w.slice(p,p+t),m[e]=h.encode(g[e]),p+=t,y=Math.max(y,t)}const v=new Uint8Array(r);let A,b,k=0;for(A=0;A<y;A++)for(b=0;b<s;b++)A<g[b].length&&(v[k++]=g[b][A]);for(A=0;A<f;A++)for(b=0;b<s;b++)v[k++]=m[b][A];return v}(r,e,t)}function kA(e,t,n,r){let i;if(Array.isArray(e))i=vA.fromArray(e);else{if("string"!=typeof e)throw new Error("Invalid data");{let r=t;if(!r){const t=vA.rawSplit(e);r=mA.getBestVersionForData(t,n)}i=vA.fromString(e,r||40)}}const o=mA.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<o)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+o+".\n")}else t=o;const s=bA(t,n,i),a=aA.getSymbolSize(t),l=new uA(a);return function(e,t){const n=e.size,r=fA.getPositions(t);for(let t=0;t<r.length;t++){const i=r[t][0],o=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)o+r<=-1||n<=o+r||(t>=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,o+r,!0,!0):e.set(i+t,o+r,!1,!0))}}(l,t),function(e){const t=e.size;for(let n=8;n<t-8;n++){const t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}(l),function(e,t){const n=dA.getPositions(t);for(let t=0;t<n.length;t++){const r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)-2===t||2===t||-2===n||2===n||0===t&&0===n?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}(l,t),AA(l,n,0),t>=7&&function(e,t){const n=e.size,r=mA.getEncodedBits(t);let i,o,s;for(let t=0;t<18;t++)i=Math.floor(t/3),o=t%3+n-8-3,s=1==(r>>t&1),e.set(i,o,s,!0),e.set(o,i,s,!0)}(l,t),function(e,t){const n=e.size;let r=-1,i=n-1,o=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,a-n)){let r=!1;s<t.length&&(r=1==(t[s]>>>o&1)),e.set(i,a-n,r),o--,-1===o&&(s++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}(l,s),isNaN(r)&&(r=hA.getBestMask(l,AA.bind(null,l,n))),hA.applyMask(r,l),AA(l,n,r),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}sv.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,r,i=lA.M;return void 0!==t&&(i=lA.from(t.errorCorrectionLevel,lA.M),n=mA.from(t.version),r=hA.from(t.maskPattern),t.toSJISFunc&&aA.setToSJISFunction(t.toSJISFunc)),kA(e,n,i,r)};var IA={},EA={};!function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");const n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});const n=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,n){const r=e.getScale(t,n);return Math.floor((t+2*n.margin)*r)},e.qrToImageData=function(t,n,r){const i=n.modules.size,o=n.modules.data,s=e.getScale(i,r),a=Math.floor((i+2*r.margin)*s),l=r.margin*s,c=[r.color.light,r.color.dark];for(let e=0;e<a;e++)for(let n=0;n<a;n++){let u=4*(e*a+n),d=r.color.light;if(e>=l&&n>=l&&e<a-l&&n<a-l){d=c[o[Math.floor((e-l)/s)*i+Math.floor((n-l)/s)]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}}(EA),function(e){const t=EA;e.render=function(e,n,r){let i=r,o=n;void 0!==i||n&&n.getContext||(i=n,n=void 0),n||(o=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),i=t.getOptions(i);const s=t.getImageWidth(e.modules.size,i),a=o.getContext("2d"),l=a.createImageData(s,s);return t.qrToImageData(l.data,e,i),function(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+"px",t.style.width=n+"px"}(a,o,s),a.putImageData(l,0,0),o},e.renderToDataURL=function(t,n,r){let i=r;void 0!==i||n&&n.getContext||(i=n,n=void 0),i||(i={});const o=e.render(t,n,i),s=i.type||"image/png",a=i.rendererOpts||{};return o.toDataURL(s,a.quality)}}(IA);var CA={};const xA=EA;function BA(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function SA(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}CA.render=function(e,t,n){const r=xA.getOptions(t),i=e.modules.size,o=e.modules.data,s=i+2*r.margin,a=r.color.light.a?"<path "+BA(r.color.light,"fill")+' d="M0 0h'+s+"v"+s+'H0z"/>':"",l="<path "+BA(r.color.dark,"stroke")+' d="'+function(e,t,n){let r="",i=0,o=!1,s=0;for(let a=0;a<e.length;a++){const l=Math.floor(a%t),c=Math.floor(a/t);l||o||(o=!0),e[a]?(s++,a>0&&l>0&&e[a-1]||(r+=o?SA("M",l+n,.5+c+n):SA("m",i,0),i=0,o=!1),l+1<t&&e[a+1]||(r+=SA("h",s),s=0)):i++}return r}(o,i,r.margin)+'"/>',c='viewBox="0 0 '+s+" "+s+'"',u='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+c+' shape-rendering="crispEdges">'+a+l+"</svg>\n";return"function"==typeof n&&n(null,u),u};const FA=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},QA=sv,DA=IA,RA=CA;function PA(e,t,n,r,i){const o=[].slice.call(arguments,1),s=o.length,a="function"==typeof o[s-1];if(!a&&!FA())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=t,t=r=void 0):2!==s||t.getContext||(r=n,n=t,t=void 0),new Promise(function(i,o){try{const o=QA.create(n,r);i(e(o,t,r))}catch(e){o(e)}})}if(s<2)throw new Error("Too few arguments provided");2===s?(i=n,n=t,t=r=void 0):3===s&&(t.getContext&&void 0===i?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0));try{const o=QA.create(n,r);i(null,e(o,t,r))}catch(e){i(e)}}async function $A(e,t,n,r){if(!e||!t)return console.log("createNIP98Auth: No signer or pubkey available",{hasSigner:!!e,hasPubkey:!!t}),null;try{const t={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",r],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,r);const i=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:i.id,pubkey:i.pubkey,kind:i.kind,created_at:i.created_at,tags:i.tags,hasSig:!!i.sig});const o=JSON.stringify(i);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("createNIP98Auth: Error:",e),null}}function UA(e,t,n){return e&t^~e&n}function TA(e,t,n){return e&t^e&n^t&n}ov.create=QA.create,ov.toCanvas=PA.bind(null,DA.render),ov.toDataURL=PA.bind(null,DA.renderToDataURL),ov.toString=PA.bind(null,function(e,t,n){return RA.render(e,n)});class NA extends Wu{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Tu(this.buffer)}update(e){$u(this),Ru(e=Yu(e));const{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){const t=Tu(e);for(;r<=i-o;o+=r)this.process(t,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){$u(this),function(e,t){Ru(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,Uu(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Tu(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)s.setUint32(4*e,c[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=i,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const LA=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),OA=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),MA=new Uint32Array(64);class _A extends NA{constructor(e=32){super(64,e,8,!1),this.A=0|LA[0],this.B=0|LA[1],this.C=0|LA[2],this.D=0|LA[3],this.E=0|LA[4],this.F=0|LA[5],this.G=0|LA[6],this.H=0|LA[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)MA[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=MA[e-15],n=MA[e-2],r=Nu(t,7)^Nu(t,18)^t>>>3,i=Nu(n,17)^Nu(n,19)^n>>>10;MA[e]=i+MA[e-7]+r+MA[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(Nu(s,6)^Nu(s,11)^Nu(s,25))+UA(s,a,l)+OA[e]+MA[e]|0,u=(Nu(n,2)^Nu(n,13)^Nu(n,22))+TA(n,r,i)|0;c=l,l=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,l,c)}roundClean(){Uu(MA)}destroy(){this.set(0,0,0,0,0,0,0,0),Uu(this.buffer)}}const HA=Zu(()=>new _A);class jA extends Wu{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Pu(e);const n=Yu(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,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),Uu(i)}update(e){return $u(this),this.iHash.update(e),this}digestInto(e){$u(this),Ru(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:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const GA=(e,t,n)=>new jA(e,t).update(n).digest();GA.create=(e,t)=>new jA(e,t); |
|
|
const dk={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},fk={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},hk=BigInt(2);const pk=Qb(dk.p,{sqrt:function(e){const t=dk.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=vb(u,n,t)*u%t,f=vb(d,n,t)*u%t,h=vb(f,hk,t)*c%t,p=vb(h,i,t)*h%t,g=vb(p,o,t)*p%t,m=vb(g,a,t)*g%t,y=vb(m,l,t)*m%t,w=vb(y,a,t)*g%t,v=vb(w,n,t)*u%t,A=vb(v,s,t)*p%t,b=vb(A,r,t)*c%t,k=vb(b,hk,t);if(!pk.eql(pk.sqr(k),e))throw new Error("Cannot find square root");return k}}),gk=function(e,t){const n=t=>uk({...e,hash:t});return{...n(t),create:n}}({...dk,Fp:pk,lowS:!0,endo:fk},HA),mk=HA,yk="nip46";function wk(e){let t=0n;for(const n of e)t=t<<8n|BigInt(n);return t}function vk(e){const t=gk.utils.randomPrivateKey(),n=gk.ProjectivePoint.fromHex(function(e){const t=(new TextEncoder).encode("Secp256k1_HashToCurve_Cashu_"),n=mk(new Uint8Array([...t,...e]));for(let e=0;e<65536;e++){const t=new Uint8Array(4);new DataView(t.buffer).setUint32(0,e,!0);const r=new Uint8Array([...n,...t]),i=mk(r),o=new Uint8Array([2,...i]);try{if(!gk.ProjectivePoint.fromHex(o).equals(gk.ProjectivePoint.ZERO))return o}catch{}}throw new Error("Failed to hash to curve after 65536 attempts")}(e)),r=gk.ProjectivePoint.BASE.multiply(wk(t));return{B_:n.add(r).toRawBytes(!0),secret:e,r:t}}function Ak(e){const t={k:e.keysetId,s:Mu(e.secret),c:Mu(e.signature),p:Mu(e.pubkey),e:e.expiry,sc:e.scope,kinds:e.kinds,kind_ranges:e.kindRanges},n=JSON.stringify(t);return"cashuA"+btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function bk(e,t,n,r,i,o){const s=vk(crypto.getRandomValues(new Uint8Array(32))),a={blinded_message:Mu(s.B_),scope:t,kinds:i,kind_ranges:o},l=`${e}/cashu/mint`,c=await r(l,"POST"),u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c},body:JSON.stringify(a)});if(!u.ok){const e=await u.text();throw new Error(`Mint request failed: ${e}`)}const d=await u.json(),f=Vu(d.blinded_signature),h=Vu(d.mint_pubkey),p=function(e,t,n){const r=gk.ProjectivePoint.fromHex(e),i=gk.ProjectivePoint.fromHex(n).multiply(wk(t));return r.subtract(i).toRawBytes(!0)}(f,s.r,h);return{keysetId:d.keyset_id,secret:s.secret,signature:p,pubkey:n,expiry:d.expiry,scope:t,kinds:i,kindRanges:o}}async function kk(e){let t=e.replace("wss://","https://").replace("ws://","http://").replace(/\/$/,"");try{const e=await fetch(`${t}/cashu/info`);if(!e.ok)return null;const n=await e.json();return n.mintUrl=t,n}catch{return null}}const Ik="connect",Ek="get_public_key",Ck="sign_event",xk="nip04_encrypt",Bk="nip04_decrypt",Sk="ping";class Fk{constructor(e,t,n){this.relayUrl=e,this.userPubkey=t,this.userPrivkey=n,this.ws=null,this.connected=!1,this.allowedSecrets=new Set,this.connectedClients=new Map,this.requestLog=[],this.heartbeatInterval=null,this.subscriptionId=null,this.catToken=null,this.onClientConnected=null,this.onClientDisconnected=null,this.onRequest=null,this.onStatusChange=null}addAllowedSecret(e){this.allowedSecrets.add(e)}removeAllowedSecret(e){this.allowedSecrets.delete(e)}setCatToken(e){this.catToken=e}async connect(){return new Promise((e,t)=>{let n=this.relayUrl;if(n.startsWith("http://")?n="ws://"+n.slice(7):n.startsWith("https://")?n="wss://"+n.slice(8):n.startsWith("ws://")||n.startsWith("wss://")||(n="wss://"+n),this.catToken){const e=Ak(this.catToken),t=new URL(n);t.searchParams.set("token",e),n=t.toString()}console.log("[BunkerService] Connecting to:",n.split("?")[0]);const r=new WebSocket(n),i=setTimeout(()=>{r.close(),t(new Error("Connection timeout"))},1e4);r.onopen=()=>{clearTimeout(i),this.ws=r,this.connected=!0,console.log("[BunkerService] Connected to relay"),this.subscriptionId=function(e=16){const t=new Uint8Array(e);return crypto.getRandomValues(t),Mu(t)}(8);const t=JSON.stringify(["REQ",this.subscriptionId,{kinds:[24133],"#p":[this.userPubkey],since:Math.floor(Date.now()/1e3)-60}]);r.send(t),console.log("[BunkerService] Subscribed to NIP-46 events"),this.startHeartbeat(),this.onStatusChange&&this.onStatusChange("connected"),e()},r.onerror=e=>{clearTimeout(i),console.error("[BunkerService] WebSocket error:",e),t(new Error("WebSocket error"))},r.onclose=()=>{this.connected=!1,this.ws=null,this.stopHeartbeat(),console.log("[BunkerService] Disconnected from relay"),this.onStatusChange&&this.onStatusChange("disconnected")},r.onmessage=e=>{this.handleMessage(e.data)}})}startHeartbeat(e=3e4){this.stopHeartbeat(),this.heartbeatInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const e=JSON.stringify(["REQ",this.subscriptionId,{kinds:[24133],"#p":[this.userPubkey],since:Math.floor(Date.now()/1e3)-60}]);this.ws.send(e)}},e)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}disconnect(){this.stopHeartbeat(),this.ws&&(this.subscriptionId&&this.ws.send(JSON.stringify(["CLOSE",this.subscriptionId])),this.ws.close(),this.ws=null),this.connected=!1,this.connectedClients.clear()}async handleMessage(e){try{const t=JSON.parse(e);if(!Array.isArray(t))return;const[n,...r]=t;if("EVENT"===n){const[,e]=r;24133===e.kind&&await this.handleNIP46Request(e)}else"OK"===n?console.log("[BunkerService] Event published:",r[0]?.substring(0,8)):"NOTICE"===n&&console.warn("[BunkerService] Relay notice:",r[0])}catch(e){console.error("[BunkerService] Failed to parse message:",e)}}async handleNIP46Request(e){try{const t=Mu(this.userPrivkey),n=await gs.decrypt(t,e.pubkey,e.content),r=JSON.parse(n);console.log("[BunkerService] Received request:",r.method,"from:",e.pubkey.substring(0,8)),this.requestLog.push({id:r.id,method:r.method,from:e.pubkey,timestamp:Date.now()}),this.requestLog.length>100&&this.requestLog.shift(),this.onRequest&&this.onRequest(r,e.pubkey);let i=null,o=null;try{switch(r.method){case Ik:i=await this.handleConnect(r,e.pubkey);break;case Ek:i=await this.handleGetPublicKey(r,e.pubkey);break;case Ck:i=await this.handleSignEvent(r,e.pubkey);break;case xk:i=await this.handleNip04Encrypt(r,e.pubkey);break;case Bk:i=await this.handleNip04Decrypt(r,e.pubkey);break;case Sk:i="pong";break;default:o=`Unknown method: ${r.method}`}}catch(e){console.error("[BunkerService] Error handling request:",e),o=e.message}await this.sendResponse(r.id,i,o,e.pubkey)}catch(e){console.error("[BunkerService] Failed to handle NIP-46 request:",e)}}async handleConnect(e,t){const[n,r]=e.params;if(this.allowedSecrets.size>0&&(!r||!this.allowedSecrets.has(r)))throw new Error("Invalid or missing connection secret");return this.connectedClients.set(t,{clientPubkey:n||t,connectedAt:Date.now(),lastActivity:Date.now()}),console.log("[BunkerService] Client connected:",t.substring(0,8)),this.onClientConnected&&this.onClientConnected(t),"ack"}async handleGetPublicKey(e,t){return this.connectedClients.has(t)&&(this.connectedClients.get(t).lastActivity=Date.now()),this.userPubkey}async handleSignEvent(e,t){if(!this.connectedClients.has(t))throw new Error("Not connected");this.connectedClients.get(t).lastActivity=Date.now();const[n]=e.params,r=JSON.parse(n);if(r.pubkey&&r.pubkey!==this.userPubkey)throw new Error("Event pubkey does not match signer pubkey");r.pubkey=this.userPubkey;const i=JSON.stringify([0,r.pubkey,r.created_at,r.kind,r.tags,r.content]),o=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(i));r.id=Mu(new Uint8Array(o));const s=gk.sign(Vu(r.id),this.userPrivkey);return r.sig=s.toCompactHex(),console.log("[BunkerService] Signed event:",r.id.substring(0,8),"kind:",r.kind),JSON.stringify(r)}async handleNip04Encrypt(e,t){if(!this.connectedClients.has(t))throw new Error("Not connected");this.connectedClients.get(t).lastActivity=Date.now();const[n,r]=e.params,i=Mu(this.userPrivkey);return await gs.encrypt(i,n,r)}async handleNip04Decrypt(e,t){if(!this.connectedClients.has(t))throw new Error("Not connected");this.connectedClients.get(t).lastActivity=Date.now();const[n,r]=e.params,i=Mu(this.userPrivkey);return await gs.decrypt(i,n,r)}async sendResponse(e,t,n,r){if(!this.ws||!this.connected)return void console.error("[BunkerService] Cannot send response: not connected");const i={id:e,result:null!==t?t:void 0,error:null!==n?n:void 0},o=Mu(this.userPrivkey),s=await gs.encrypt(o,r,JSON.stringify(i)),a={kind:24133,pubkey:this.userPubkey,created_at:Math.floor(Date.now()/1e3),content:s,tags:[["p",r]]},l=JSON.stringify([0,a.pubkey,a.created_at,a.kind,a.tags,a.content]),c=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(l));a.id=Mu(new Uint8Array(c));const u=gk.sign(Vu(a.id),this.userPrivkey);a.sig=u.toCompactHex(),this.ws.send(JSON.stringify(["EVENT",a])),console.log("[BunkerService] Sent response for:",e)}isConnected(){return this.connected}getConnectedClients(){return Array.from(this.connectedClients.entries()).map(([e,t])=>({pubkey:e,...t}))}getRequestLog(){return[...this.requestLog]}}function Qk(e,t,n){const r=e.slice();return r[48]=t[n],r}function Dk(e,t,n){const r=e.slice();return r[52]=t[n],r}function Rk(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access remote signing.",i=m(),o=h("button"),o.textContent="Log In",A(r,"class","svelte-13nqrp7"),A(o,"class","login-btn svelte-13nqrp7"),A(n,"class","login-prompt svelte-13nqrp7")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[24]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function Pk(e){let t,n,r,i,o,s,a,l,f=(e[3]||"read-only")+"";return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Access Denied",i=m(),o=h("p"),s=g("You need write access to use remote signing. Your current access level: "),a=h("strong"),l=g(f),A(r,"class","svelte-13nqrp7"),A(o,"class","svelte-13nqrp7"),A(n,"class","access-denied svelte-13nqrp7"),A(t,"class","bunker-view svelte-13nqrp7")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(n,o),c(o,s),c(o,a),c(a,l)},p(e,t){8&t[0]&&f!==(f=(e[3]||"read-only")+"")&&k(l,f)},d(e){e&&d(t)}}}function $k(e){let t,n,r,i,o,s,a,l,f,p,y,v=e[7]?"Loading...":"Refresh",b=e[8]&&Tk(e),I=e[4]?.cashu_enabled&&"none"!==e[4]?.acl_mode&&Nk();function E(e,t){return e[7]&&!e[4]?Ok:e[4]?Lk:void 0}let C=E(e),x=C&&C(e);return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Remote Signing (NIP-46 Bunker)",i=m(),o=h("button"),s=g(v),a=m(),b&&b.c(),l=m(),I&&I.c(),f=m(),x&&x.c(),A(r,"class","svelte-13nqrp7"),A(o,"class","refresh-btn svelte-13nqrp7"),o.disabled=e[7],A(n,"class","header-section svelte-13nqrp7"),A(t,"class","bunker-view svelte-13nqrp7")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,i),c(n,o),c(o,s),c(t,a),b&&b.m(t,null),c(t,l),I&&I.m(t,null),c(t,f),x&&x.m(t,null),p||(y=w(o,"click",e[21]),p=!0)},p(e,n){128&n[0]&&v!==(v=e[7]?"Loading...":"Refresh")&&k(s,v),128&n[0]&&(o.disabled=e[7]),e[8]?b?b.p(e,n):(b=Tk(e),b.c(),b.m(t,l)):b&&(b.d(1),b=null),e[4]?.cashu_enabled&&"none"!==e[4]?.acl_mode?I||(I=Nk(),I.c(),I.m(t,f)):I&&(I.d(1),I=null),C===(C=E(e))&&x?x.p(e,n):(x&&x.d(1),x=C&&C(e),x&&(x.c(),x.m(t,null)))},d(e){e&&d(t),b&&b.d(),I&&I.d(),x&&x.d(),p=!1,y()}}}function Uk(t){let n;return{c(){n=h("div"),n.innerHTML='<div class="unavailable-message svelte-13nqrp7"><h3 class="svelte-13nqrp7">Remote Signing Not Available</h3> \n <p class="svelte-13nqrp7">This relay does not have bunker mode enabled, or ACL mode is set to "none".</p> \n <p class="hint svelte-13nqrp7">Remote signing requires the relay operator to enable ACL mode "follows" or "managed".</p></div>',A(n,"class","bunker-view svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Tk(e){let t,n;return{c(){t=h("div"),n=g(e[8]),A(t,"class","error-message svelte-13nqrp7")},m(e,r){u(e,t,r),c(t,n)},p(e,t){256&t[0]&&k(n,e[8])},d(e){e&&d(t)}}}function Nk(e){let t;return{c(){t=h("div"),t.innerHTML="<strong>CAT Required:</strong> This relay requires Cashu Access Tokens (CAT) for bunker connections.\n Your client must support CAT authentication or connections will be rejected.",A(t,"class","cat-warning svelte-13nqrp7")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Lk(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H,j,G,q,K,J,V,Y,z,W,Z=e[10]?"Active":"Inactive",X=e[4].relay_url+"",ee="relay"===e[9]?"Copied!":"Copy";function te(e,t){return e[2]?Mk:_k}let ne=te(e),re=ne(e),ie=e[10]&&e[6].length>0&&Kk(e);return{c(){t=h("div"),t.innerHTML='<p class="svelte-13nqrp7"><strong>How it works:</strong> Start the bunker service to allow remote apps (like Smesh) to request signatures from your ORLY account.\n Share the QR code or bunker URL with your client app.</p>',n=m(),i=h("div"),o=h("div"),s=h("h4"),s.textContent="Bunker Service",a=m(),l=h("div"),f=h("span"),p=m(),y=g(Z),v=m(),re.c(),b=m(),ie&&ie.c(),I=m(),E=h("div"),C=h("h4"),C.textContent="Connection Details",x=m(),S=h("div"),F=h("span"),F.textContent="Relay:",Q=m(),D=h("code"),R=g(X),P=m(),$=h("button"),U=g(ee),T=m(),N=h("div"),L=h("span"),L.textContent="Your npub:",O=m(),M=h("code"),_=g(e[1]),H=m(),j=h("div"),G=h("span"),G.textContent="Secret:",q=m(),K=h("code"),J=g(e[5]),V=m(),Y=h("button"),Y.textContent="Regenerate",A(t,"class","instructions svelte-13nqrp7"),A(s,"class","svelte-13nqrp7"),A(f,"class","status-dot svelte-13nqrp7"),A(l,"class","service-status svelte-13nqrp7"),B(l,"active",e[10]),A(o,"class","service-header svelte-13nqrp7"),A(i,"class","service-control svelte-13nqrp7"),A(C,"class","svelte-13nqrp7"),A(F,"class","label svelte-13nqrp7"),A(D,"class","svelte-13nqrp7"),A($,"class","copy-btn svelte-13nqrp7"),A(S,"class","info-row svelte-13nqrp7"),A(L,"class","label svelte-13nqrp7"),A(M,"class","npub svelte-13nqrp7"),A(N,"class","info-row svelte-13nqrp7"),A(G,"class","label svelte-13nqrp7"),A(K,"class","secret svelte-13nqrp7"),A(Y,"class","copy-btn svelte-13nqrp7"),A(j,"class","info-row svelte-13nqrp7"),A(E,"class","connection-info svelte-13nqrp7")},m(r,d){u(r,t,d),u(r,n,d),u(r,i,d),c(i,o),c(o,s),c(o,a),c(o,l),c(l,f),c(l,p),c(l,y),c(i,v),re.m(i,null),u(r,b,d),ie&&ie.m(r,d),u(r,I,d),u(r,E,d),c(E,C),c(E,x),c(E,S),c(S,F),c(S,Q),c(S,D),c(D,R),c(S,P),c(S,$),c($,U),c(E,T),c(E,N),c(N,L),c(N,O),c(N,M),c(M,_),c(E,H),c(E,j),c(j,G),c(j,q),c(j,K),c(K,J),c(j,V),c(j,Y),z||(W=[w($,"click",e[37]),w(Y,"click",e[22])],z=!0)},p(e,t){1024&t[0]&&Z!==(Z=e[10]?"Active":"Inactive")&&k(y,Z),1024&t[0]&&B(l,"active",e[10]),ne===(ne=te(e))&&re?re.p(e,t):(re.d(1),re=ne(e),re&&(re.c(),re.m(i,null))),e[10]&&e[6].length>0?ie?ie.p(e,t):(ie=Kk(e),ie.c(),ie.m(I.parentNode,I)):ie&&(ie.d(1),ie=null),16&t[0]&&X!==(X=e[4].relay_url+"")&&k(R,X),512&t[0]&&ee!==(ee="relay"===e[9]?"Copied!":"Copy")&&k(U,ee),2&t[0]&&k(_,e[1]),32&t[0]&&k(J,e[5])},d(e){e&&d(t),e&&d(n),e&&d(i),re.d(),e&&d(b),ie&&ie.d(e),e&&d(I),e&&d(E),z=!1,r(W)}}}function Ok(t){let n;return{c(){n=h("div"),n.textContent="Loading bunker information...",A(n,"class","loading svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Mk(e){let t,n,r;function i(e,t){return e[10]?jk:Hk}let o=i(e),s=o(e),a=e[10]&&e[12].length>0&&Gk(e);return{c(){t=h("div"),s.c(),n=m(),a&&a.c(),r=y(),A(t,"class","service-actions svelte-13nqrp7")},m(e,i){u(e,t,i),s.m(t,null),u(e,n,i),a&&a.m(e,i),u(e,r,i)},p(e,n){o===(o=i(e))&&s?s.p(e,n):(s.d(1),s=o(e),s&&(s.c(),s.m(t,null))),e[10]&&e[12].length>0?a?a.p(e,n):(a=Gk(e),a.c(),a.m(r.parentNode,r)):a&&(a.d(1),a=null)},d(e){e&&d(t),s.d(),e&&d(n),a&&a.d(e),e&&d(r)}}}function _k(t){let n;return{c(){n=h("div"),n.textContent="Bunker service requires nsec login. Please log in with your private key to enable remote signing.",A(n,"class","no-privkey-warning svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Hk(e){let t,n,r,i,o=e[11]?"Starting...":"Start Service";return{c(){t=h("button"),n=g(o),A(t,"class","start-btn svelte-13nqrp7"),t.disabled=e[11]},m(o,s){u(o,t,s),c(t,n),r||(i=w(t,"click",e[19]),r=!0)},p(e,r){2048&r[0]&&o!==(o=e[11]?"Starting...":"Start Service")&&k(n,o),2048&r[0]&&(t.disabled=e[11])},d(e){e&&d(t),r=!1,i()}}}function jk(t){let n,r,i;return{c(){n=h("button"),n.textContent="Stop Service",A(n,"class","stop-btn svelte-13nqrp7")},m(e,o){u(e,n,o),r||(i=w(n,"click",t[20]),r=!0)},p:e,d(e){e&&d(n),r=!1,i()}}}function Gk(e){let t,n,r,i,o,s,a=e[12].length+"",l=e[12],p=[];for(let t=0;t<l.length;t+=1)p[t]=qk(Dk(e,l,t));return{c(){t=h("div"),n=h("h5"),r=g("Connected Clients ("),i=g(a),o=g(")"),s=m();for(let e=0;e<p.length;e+=1)p[e].c();A(n,"class","svelte-13nqrp7"),A(t,"class","connected-clients svelte-13nqrp7")},m(e,a){u(e,t,a),c(t,n),c(n,r),c(n,i),c(n,o),c(t,s);for(let e=0;e<p.length;e+=1)p[e]&&p[e].m(t,null)},p(e,n){if(4096&n[0]&&a!==(a=e[12].length+"")&&k(i,a),4096&n[0]){let r;for(l=e[12],r=0;r<l.length;r+=1){const i=Dk(e,l,r);p[r]?p[r].p(i,n):(p[r]=qk(i),p[r].c(),p[r].m(t,null))}for(;r<p.length;r+=1)p[r].d(1);p.length=l.length}},d(e){e&&d(t),f(p,e)}}}function qk(e){let t,n,r,i,o,s,a,l,f,p=e[52].pubkey.substring(0,16)+"",y=new Date(e[52].connectedAt).toLocaleTimeString()+"";return{c(){t=h("div"),n=h("code"),r=g(p),i=g("..."),o=m(),s=h("span"),a=g("Connected "),l=g(y),f=m(),A(n,"class","svelte-13nqrp7"),A(s,"class","client-time svelte-13nqrp7"),A(t,"class","client-entry svelte-13nqrp7")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(n,i),c(t,o),c(t,s),c(s,a),c(s,l),c(t,f)},p(e,t){4096&t[0]&&p!==(p=e[52].pubkey.substring(0,16)+"")&&k(r,p),4096&t[0]&&y!==(y=new Date(e[52].connectedAt).toLocaleTimeString()+"")&&k(l,y)},d(e){e&&d(t)}}}function Kk(e){let t,n,i,o,s,a,l,f,p,g,y,v=[],b=new Map,k=e[6];const I=e=>e[48].id;for(let t=0;t<k.length;t+=1){let n=Qk(e,k,t),r=I(n);b.set(r,v[t]=Wk(r,n))}return{c(){t=h("div"),n=h("div"),i=h("h4"),i.textContent="Client Tokens",o=m(),s=h("button"),s.textContent="+ Add Token",a=m(),l=h("p"),l.textContent="Each device/app gets its own token. Tokens can be individually revoked.",f=m(),p=h("div");for(let e=0;e<v.length;e+=1)v[e].c();A(i,"class","svelte-13nqrp7"),A(s,"class","add-token-btn svelte-13nqrp7"),A(n,"class","tokens-header svelte-13nqrp7"),A(l,"class","tokens-desc svelte-13nqrp7"),A(p,"class","tokens-table svelte-13nqrp7"),A(t,"class","tokens-section svelte-13nqrp7")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(t,a),c(t,l),c(t,f),c(t,p);for(let e=0;e<v.length;e+=1)v[e]&&v[e].m(p,null);g||(y=w(s,"click",e[14]),g=!0)},p(e,t){8880754&t[0]&&(k=e[6],v=function(e,t,n,i,o,s,a,l,c,u,d,f){let h=e.length,p=s.length,g=h;const m={};for(;g--;)m[e[g].key]=g;const y=[],w=new Map,v=new Map,A=[];for(g=p;g--;){const e=f(o,s,g),r=n(e);let l=a.get(r);l?i&&A.push(()=>l.p(e,t)):(l=u(r,e),l.c()),w.set(r,y[g]=l),r in m&&v.set(r,Math.abs(g-m[r]))}const b=new Set,k=new Set;function I(e){W(e,1),e.m(l,d),a.set(e.key,e),d=e.first,p--}for(;h&&p;){const t=y[p-1],n=e[h-1],r=t.key,i=n.key;t===n?(d=t.first,h--,p--):w.has(i)?!a.has(r)||b.has(r)?I(t):k.has(i)?h--:v.get(r)>v.get(i)?(k.add(r),I(t)):(b.add(i),h--):(c(n,a),h--)}for(;h--;){const t=e[h];w.has(t.key)||c(t,a)}for(;p;)I(y[p-1]);return r(A),y}(v,t,I,1,e,k,b,p,ee,Wk,null,Qk))},d(e){e&&d(t);for(let e=0;e<v.length;e+=1)v[e].d();g=!1,y()}}}function Jk(e){let t,n,r={ctx:e,current:null,token:null,hasCatch:!0,pending:zk,then:Yk,catch:Vk,value:51};return X(n=e[18](e[48]),r),{c(){t=h("div"),r.block.c(),A(t,"class","token-details svelte-13nqrp7")},m(e,n){u(e,t,n),r.block.m(t,r.anchor=null),r.mount=()=>t,r.anchor=null},p(t,i){e=t,r.ctx=e,64&i[0]&&n!==(n=e[18](e[48]))&&X(n,r)||function(e,t,n){const r=t.slice(),{resolved:i}=e;e.current===e.then&&(r[e.value]=i),e.current===e.catch&&(r[e.error]=i),e.block.p(r,n)}(r,e,i)},d(e){e&&d(t),r.block.d(),r.token=null,r=null}}}function Vk(t){let n;return{c(){n=h("div"),n.textContent="Failed to generate QR",A(n,"class","error-message svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Yk(e){let t,n,i,o,s,l,f,p,y,v,b,I,E,C,x,S,F,Q,D,R,P,$,U,T,N,L,O,M,_,H=new Date(e[48].createdAt).toLocaleString()+"",j=new Date(1e3*e[48].token.expiry).toLocaleString()+"",G=`bunker://${e[1]}?relay=${encodeURIComponent(e[4].relay_url)}${e[5]?`&secret=${e[5]}`:""}&cat=${e[48].encoded}`;function q(){return e[35](e[48])}function K(...t){return e[36](e[48],...t)}return{c(){t=h("div"),n=h("div"),i=h("img"),s=m(),l=h("div"),l.textContent="Copied!",f=m(),p=h("div"),y=h("div"),v=h("span"),v.textContent="Created:",b=m(),I=h("span"),E=g(H),C=m(),x=h("div"),S=h("span"),S.textContent="Expires:",F=m(),Q=h("span"),D=g(j),R=m(),P=h("div"),$=h("span"),$.textContent="Bunker URL:",U=m(),T=h("code"),N=g(G),L=m(),O=h("div"),O.textContent="Click QR code to copy URL",a(i.src,o=e[51])||A(i,"src",o),A(i,"alt","Token QR Code"),A(i,"class","qr-code small svelte-13nqrp7"),A(l,"class","qr-overlay svelte-13nqrp7"),B(l,"visible",e[9]===e[48].id),A(n,"class","qr-container small clickable svelte-13nqrp7"),A(n,"role","button"),A(n,"tabindex","0"),A(n,"title","Click to copy bunker URL"),A(v,"class","label svelte-13nqrp7"),A(y,"class","info-item svelte-13nqrp7"),A(S,"class","label svelte-13nqrp7"),A(x,"class","info-item svelte-13nqrp7"),A($,"class","label svelte-13nqrp7"),A(T,"class","bunker-url small svelte-13nqrp7"),A(P,"class","info-item url-item svelte-13nqrp7"),A(O,"class","copy-hint svelte-13nqrp7"),A(p,"class","token-info svelte-13nqrp7"),A(t,"class","token-detail-content svelte-13nqrp7")},m(e,r){u(e,t,r),c(t,n),c(n,i),c(n,s),c(n,l),c(t,f),c(t,p),c(p,y),c(y,v),c(y,b),c(y,I),c(I,E),c(p,C),c(p,x),c(x,S),c(x,F),c(x,Q),c(Q,D),c(p,R),c(p,P),c(P,$),c(P,U),c(P,T),c(T,N),c(p,L),c(p,O),M||(_=[w(n,"click",q),w(n,"keypress",K)],M=!0)},p(t,n){e=t,64&n[0]&&!a(i.src,o=e[51])&&A(i,"src",o),576&n[0]&&B(l,"visible",e[9]===e[48].id),64&n[0]&&H!==(H=new Date(e[48].createdAt).toLocaleString()+"")&&k(E,H),64&n[0]&&j!==(j=new Date(1e3*e[48].token.expiry).toLocaleString()+"")&&k(D,j),114&n[0]&&G!==(G=`bunker://${e[1]}?relay=${encodeURIComponent(e[4].relay_url)}${e[5]?`&secret=${e[5]}`:""}&cat=${e[48].encoded}`)&&k(N,G)},d(e){e&&d(t),M=!1,r(_)}}}function zk(t){let n;return{c(){n=h("div"),n.textContent="Loading QR...",A(n,"class","qr-placeholder small svelte-13nqrp7")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Wk(e,t){let n,i,o,s,a,l,f,p,y,b,I,E,C,x,S,F,Q,D,R,P,$=t[48].isExpanded?"▼":"▶",U=new Date(t[48].createdAt).toLocaleDateString()+"",T=new Date(1e3*t[48].token.expiry).toLocaleDateString()+"";function N(...e){return t[31](t[48],...e)}function L(){return t[32](t[48])}function O(){return t[33](t[48])}function M(...e){return t[34](t[48],...e)}let _=t[48].isExpanded&&Jk(t);return{key:e,first:null,c(){n=h("div"),i=h("div"),o=h("span"),s=g($),a=m(),l=h("input"),p=m(),y=h("span"),b=g(U),I=m(),E=h("span"),C=g("Expires: "),x=g(T),S=m(),F=h("button"),F.textContent="Revoke",Q=m(),_&&_.c(),D=m(),A(o,"class","expand-icon svelte-13nqrp7"),A(l,"type","text"),A(l,"class","token-name-input svelte-13nqrp7"),l.value=f=t[48].name,A(l,"placeholder","Token name"),A(y,"class","token-created svelte-13nqrp7"),A(E,"class","token-expiry svelte-13nqrp7"),A(F,"class","revoke-btn svelte-13nqrp7"),A(F,"title","Revoke this token"),A(i,"class","token-main svelte-13nqrp7"),A(i,"role","button"),A(i,"tabindex","0"),A(n,"class","token-row svelte-13nqrp7"),B(n,"expanded",t[48].isExpanded),this.first=n},m(e,r){u(e,n,r),c(n,i),c(i,o),c(o,s),c(i,a),c(i,l),c(i,p),c(i,y),c(y,b),c(i,I),c(i,E),c(E,C),c(E,x),c(i,S),c(i,F),c(n,Q),_&&_.m(n,null),c(n,D),R||(P=[w(l,"input",N),w(l,"click",v(t[30])),w(F,"click",v(L)),w(i,"click",O),w(i,"keypress",M)],R=!0)},p(e,r){t=e,64&r[0]&&$!==($=t[48].isExpanded?"▼":"▶")&&k(s,$),64&r[0]&&f!==(f=t[48].name)&&l.value!==f&&(l.value=f),64&r[0]&&U!==(U=new Date(t[48].createdAt).toLocaleDateString()+"")&&k(b,U),64&r[0]&&T!==(T=new Date(1e3*t[48].token.expiry).toLocaleDateString()+"")&&k(x,T),t[48].isExpanded?_?_.p(t,r):(_=Jk(t),_.c(),_.m(n,D)):_&&(_.d(1),_=null),64&r[0]&&B(n,"expanded",t[48].isExpanded)},d(e){e&&d(n),_&&_.d(),R=!1,r(P)}}}function Zk(t){let n;function r(e,t){return e[4]?.available?e[13]?$k:e[0]?Pk:Rk:Uk}let i=r(t),o=i(t);return{c(){o.c(),n=y()},m(e,t){o.m(e,t),u(e,n,t)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&d(n)}}}function Xk(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}function eI(e,t,n){let r,i,o,s,{isLoggedIn:a=!1}=t,{userPubkey:l=""}=t,{userSigner:c=null}=t,{userPrivkey:u=null}=t,{currentEffectiveRole:d=""}=t;const f=P();let h=null,p=!1,g="",m="",y="",w=null,v=!1,A=!1,b=[],k=null,I=[],E=null;const C=["brave","calm","clever","cosmic","cozy","daring","eager","fancy","gentle","happy","jolly","keen","lively","merry","nimble","peppy","quick","rustic","shiny","swift","tender","vivid","witty","zesty"],x=["badger","bunny","coral","dolphin","falcon","gecko","heron","iguana","jaguar","koala","lemur","mango","narwhal","otter","panda","quail","rabbit","salmon","turtle","urchin","viper","walrus","yak","zebra"];async function B(e,t){const r=await bk(e.mintUrl,yk,Vu(l),t,[24133]),i=Ak(r),o=crypto.randomUUID().split("-")[0],s={id:o,name:`${C[Math.floor(Math.random()*C.length)]}-${x[Math.floor(Math.random()*x.length)]}`,token:r,encoded:i,createdAt:Date.now(),isExpanded:!1};return n(6,I=[...I,s]),E||n(26,E=o),console.log(`Client token "${s.name}" created, expires:`,new Date(1e3*r.expiry).toISOString()),s}function S(e){n(6,I=I.filter(t=>t.id!==e)),E===e&&n(26,E=I.length>0?I[0].id:null),T()}function F(e){n(6,I=I.map(t=>t.id===e?{...t,isExpanded:!t.isExpanded}:t))}function Q(e,t){n(6,I=I.map(n=>n.id===e?{...n,name:t}:n))}async function U(){n(7,p=!0),n(8,g="");try{n(4,h=await async function(){const e=`${window.location.origin}/api/bunker/info`,t=await fetch(e);if(!t.ok){const e=await t.text();throw new Error(e||`Failed to get bunker info: ${t.statusText}`)}return await t.json()}()),y||n(5,y=Xk()),await T()}catch(e){console.error("Error loading bunker info:",e),n(8,g=e.message||"Failed to load bunker information")}finally{n(7,p=!1)}}async function T(){o&&await ov.toDataURL(o,{width:280,margin:2,color:{dark:"#000000",light:"#ffffff"}}),s&&await ov.toDataURL(s,{width:280,margin:2,color:{dark:"#000000",light:"#ffffff"}})}function N(e,t){navigator.clipboard.writeText(e),n(9,m=t),setTimeout(()=>{n(9,m="")},2e3)}D(async()=>{await U()}),R(()=>{w&&(w.disconnect(),w=null,n(10,v=!1))});return e.$$set=e=>{"isLoggedIn"in e&&n(0,a=e.isLoggedIn),"userPubkey"in e&&n(1,l=e.userPubkey),"userSigner"in e&&n(25,c=e.userSigner),"userPrivkey"in e&&n(2,u=e.userPrivkey),"currentEffectiveRole"in e&&n(3,d=e.currentEffectiveRole)},e.$$.update=()=>{11&e.$$.dirty[0]&&n(13,r=a&&l&&("write"===d||"admin"===d||"owner"===d)),67108928&e.$$.dirty[0]&&n(29,i=I.find(e=>e.id===E)),536870962&e.$$.dirty[0]&&n(28,o=h&&l&&i?`bunker://${l}?relay=${encodeURIComponent(h.relay_url)}${y?`&secret=${y}`:""}&cat=${i.encoded}`:""),16&e.$$.dirty[0]&&n(27,s=h?`nostr+connect://${h.relay_url}`:""),402653184&e.$$.dirty[0]&&(o||s)&&T()},[a,l,u,d,h,y,I,p,g,m,v,A,b,r,async function(){if(h?.cashu_enabled)try{const e=await kk(h.relay_url);if(!e)return;const t=async(e,t)=>`Nostr ${await $A(c,l,t,e)}`;await B(e,t),await T()}catch(e){console.error("Failed to add token:",e),n(8,g=e.message||"Failed to add token")}},S,F,Q,async function(e){if(!h||!l)return null;const t=`bunker://${l}?relay=${encodeURIComponent(h.relay_url)}${y?`&secret=${y}`:""}&cat=${e.encoded}`;return await ov.toDataURL(t,{width:200,margin:2,color:{dark:"#000000",light:"#ffffff"}})},async function(){if(u&&l&&h){n(11,A=!0),n(8,g="");try{if(h.cashu_enabled){console.log("CAT required, minting tokens...");const e=await kk(h.relay_url);if(e){const t=async(e,t)=>`Nostr ${await $A(c,l,t,e)}`;k=await bk(e.mintUrl,yk,Vu(l),t,[24133]),console.log("Service CAT token acquired, expires:",new Date(1e3*k.expiry).toISOString()),await B(e,t)}}w=new Fk(h.relay_url,l,u),y&&w.addAllowedSecret(y),k&&w.setCatToken(k),w.onClientConnected=e=>{n(12,b=w.getConnectedClients())},w.onStatusChange=e=>{n(10,v="connected"===e),"disconnected"===e&&n(12,b=[])},await w.connect(),n(10,v=!0),await T(),console.log("Bunker service started successfully")}catch(e){console.error("Failed to start bunker service:",e),n(8,g=e.message||"Failed to start bunker service"),w=null,n(10,v=!1),catToken=null,catTokenEncoded=""}finally{n(11,A=!1)}}else n(8,g="Missing private key or bunker info")},function(){w&&(w.disconnect(),w=null),n(10,v=!1),n(12,b=[]),k=null,n(6,I=[]),n(26,E=null),T()},U,async function(){n(5,y=Xk()),await T()},N,function(){f("openLoginModal")},c,E,s,o,i,function(t){$.call(this,e,t)},(e,t)=>Q(e.id,t.target.value),e=>S(e.id),e=>F(e.id),(e,t)=>"Enter"===t.key&&F(e.id),e=>{N(`bunker://${l}?relay=${encodeURIComponent(h.relay_url)}${y?`&secret=${y}`:""}&cat=${e.encoded}`,e.id)},(e,t)=>{if("Enter"===t.key){N(`bunker://${l}?relay=${encodeURIComponent(h.relay_url)}${y?`&secret=${y}`:""}&cat=${e.encoded}`,e.id)}},()=>N(h.relay_url,"relay")]}class tI extends ae{constructor(e){super(),se(this,e,eI,Zk,o,{isLoggedIn:0,userPubkey:1,userSigner:25,userPrivkey:2,currentEffectiveRole:3},null,[-1,-1])}}function nI(e,t,n){const r=e.slice();return r[29]=t[n],r}function rI(e,t,n){const r=e.slice();return r[32]=t[n],r}function iI(e){let t,n,r;function i(e,t){return e[0]?sI:aI}let o=i(e),s=o(e);return{c(){t=h("div"),n=h("p"),n.textContent="Log viewer is only available to relay owners.",r=m(),s.c(),A(n,"class","svelte-w6h7aj"),A(t,"class","login-prompt svelte-w6h7aj")},m(e,i){u(e,t,i),c(t,n),c(t,r),s.m(t,null)},p(e,n){o===(o=i(e))&&s?s.p(e,n):(s.d(1),s=o(e),s&&(s.c(),s.m(t,null)))},d(e){e&&d(t),s.d()}}}function oI(e){let t,n,i,o,s,a,l,p,y,v,b,I,E,x,B,S,F,Q,D,R,P,$,U,T,N,L,O,M,H,j,G,q=e[3]?"Loading...":"Refresh",K=e[2].length+"",J=e[12],V=[];for(let t=0;t<J.length;t+=1)V[t]=lI(rI(e,J,t));let Y=e[7]&&cI(e);function z(e,t){return 0!==e[2].length||e[3]?uI:dI}let W=z(e),Z=W(e);return{c(){t=h("div"),n=h("div"),i=h("h3"),i.textContent="Logs",o=m(),s=h("div"),a=h("div"),l=h("label"),l.textContent="Level:",p=m(),y=h("select");for(let e=0;e<V.length;e+=1)V[e].c();v=m(),b=h("button"),I=g("Clear"),x=m(),B=h("button"),S=g("🔄 "),F=g(q),Q=m(),Y&&Y.c(),D=m(),R=h("div"),P=g("Showing "),$=g(K),U=g(" of "),T=g(e[6]),N=g(" logs (Level: "),L=g(e[8]),O=g(")"),M=m(),H=h("div"),Z.c(),A(i,"class","svelte-w6h7aj"),A(l,"for","log-level"),A(l,"class","svelte-w6h7aj"),A(y,"id","log-level"),A(y,"class","svelte-w6h7aj"),void 0===e[9]&&_(()=>e[18].call(y)),A(a,"class","level-selector svelte-w6h7aj"),A(b,"class","clear-btn svelte-w6h7aj"),b.disabled=E=e[3]||0===e[2].length,A(B,"class","refresh-btn svelte-w6h7aj"),B.disabled=e[3],A(s,"class","header-controls svelte-w6h7aj"),A(n,"class","header-section svelte-w6h7aj"),A(R,"class","log-info svelte-w6h7aj"),A(H,"class","log-list svelte-w6h7aj"),A(t,"class","log-view svelte-w6h7aj")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(a,p),c(a,y);for(let e=0;e<V.length;e+=1)V[e]&&V[e].m(y,null);C(y,e[9],!0),c(s,v),c(s,b),c(b,I),c(s,x),c(s,B),c(B,S),c(B,F),c(t,Q),Y&&Y.m(t,null),c(t,D),c(t,R),c(R,P),c(R,$),c(R,U),c(R,T),c(R,N),c(R,L),c(R,O),c(t,M),c(t,H),Z.m(H,null),e[21](H),j||(G=[w(y,"change",e[18]),w(y,"change",e[14]),w(b,"click",e[15]),w(B,"click",e[19])],j=!0)},p(e,n){if(4096&n[0]){let t;for(J=e[12],t=0;t<J.length;t+=1){const r=rI(e,J,t);V[t]?V[t].p(r,n):(V[t]=lI(r),V[t].c(),V[t].m(y,null))}for(;t<V.length;t+=1)V[t].d(1);V.length=J.length}4608&n[0]&&C(y,e[9]),12&n[0]&&E!==(E=e[3]||0===e[2].length)&&(b.disabled=E),8&n[0]&&q!==(q=e[3]?"Loading...":"Refresh")&&k(F,q),8&n[0]&&(B.disabled=e[3]),e[7]?Y?Y.p(e,n):(Y=cI(e),Y.c(),Y.m(t,D)):Y&&(Y.d(1),Y=null),4&n[0]&&K!==(K=e[2].length+"")&&k($,K),64&n[0]&&k(T,e[6]),256&n[0]&&k(L,e[8]),W===(W=z(e))&&Z?Z.p(e,n):(Z.d(1),Z=W(e),Z&&(Z.c(),Z.m(H,null)))},d(n){n&&d(t),f(V,n),Y&&Y.d(),Z.d(),e[21](null),j=!1,r(G)}}}function sI(e){let t,n,r,i;return{c(){t=h("p"),n=g("Your role ("),r=g(e[1]),i=g(") does not have access to this feature."),A(t,"class","access-denied svelte-w6h7aj")},m(e,o){u(e,t,o),c(t,n),c(t,r),c(t,i)},p(e,t){2&t[0]&&k(r,e[1])},d(e){e&&d(t)}}}function aI(t){let n,r,i;return{c(){n=h("button"),n.textContent="Log In",A(n,"class","login-btn svelte-w6h7aj")},m(e,o){u(e,n,o),r||(i=w(n,"click",t[16]),r=!0)},p:e,d(e){e&&d(n),r=!1,i()}}}function lI(t){let n,r,i=t[32]+"";return{c(){n=h("option"),r=g(i),n.__value=t[32],n.value=n.__value},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}function cI(e){let t,n;return{c(){t=h("div"),n=g(e[7]),A(t,"class","error-message svelte-w6h7aj")},m(e,r){u(e,t,r),c(t,n)},p(e,t){128&t[0]&&k(n,e[7])},d(e){e&&d(t)}}}function uI(e){let t,n,r=e[2],i=[];for(let t=0;t<r.length;t+=1)i[t]=hI(nI(e,r,t));function o(e,t){return e[3]?mI:e[5]?gI:pI}let s=o(e),a=s(e);return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=m(),n=h("div"),a.c(),A(n,"class","load-more-trigger svelte-w6h7aj")},m(r,o){for(let e=0;e<i.length;e+=1)i[e]&&i[e].m(r,o);u(r,t,o),u(r,n,o),a.m(n,null),e[20](n)},p(e,l){if(4&l[0]){let n;for(r=e[2],n=0;n<r.length;n+=1){const o=nI(e,r,n);i[n]?i[n].p(o,l):(i[n]=hI(o),i[n].c(),i[n].m(t.parentNode,t))}for(;n<i.length;n+=1)i[n].d(1);i.length=r.length}s!==(s=o(e))&&(a.d(1),a=s(e),a&&(a.c(),a.m(n,null)))},d(r){f(i,r),r&&d(t),r&&d(n),a.d(),e[20](null)}}}function dI(t){let n;return{c(){n=h("div"),n.innerHTML="<p>No logs available.</p>",A(n,"class","empty-state svelte-w6h7aj")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function fI(e){let t,n,r,i,o=e[29].file+"",s=e[29].line+"";return{c(){t=h("span"),n=g(o),r=g(":"),i=g(s),A(t,"class","log-location svelte-w6h7aj")},m(e,o){u(e,t,o),c(t,n),c(t,r),c(t,i)},p(e,t){4&t[0]&&o!==(o=e[29].file+"")&&k(n,o),4&t[0]&&s!==(s=e[29].line+"")&&k(i,s)},d(e){e&&d(t)}}}function hI(e){let t,n,r,i,o,s,a,l,f,p,y,w=wI(e[29].timestamp)+"",v=e[29].level+"",b=e[29].message+"",I=e[29].file&&fI(e);return{c(){t=h("div"),n=h("span"),r=g(w),i=m(),o=h("span"),s=g(v),l=m(),I&&I.c(),f=m(),p=h("span"),y=g(b),A(n,"class","log-timestamp svelte-w6h7aj"),A(o,"class",a="log-level "+vI(e[29].level)+" svelte-w6h7aj"),A(p,"class","log-message svelte-w6h7aj"),A(t,"class","log-entry svelte-w6h7aj")},m(e,a){u(e,t,a),c(t,n),c(n,r),c(t,i),c(t,o),c(o,s),c(t,l),I&&I.m(t,null),c(t,f),c(t,p),c(p,y)},p(e,n){4&n[0]&&w!==(w=wI(e[29].timestamp)+"")&&k(r,w),4&n[0]&&v!==(v=e[29].level+"")&&k(s,v),4&n[0]&&a!==(a="log-level "+vI(e[29].level)+" svelte-w6h7aj")&&A(o,"class",a),e[29].file?I?I.p(e,n):(I=fI(e),I.c(),I.m(t,f)):I&&(I.d(1),I=null),4&n[0]&&b!==(b=e[29].message+"")&&k(y,b)},d(e){e&&d(t),I&&I.d()}}}function pI(e){let t;return{c(){t=h("span"),t.textContent="End of logs"},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function gI(e){let t;return{c(){t=h("span"),t.textContent="Scroll for more"},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function mI(e){let t;return{c(){t=h("span"),t.textContent="Loading more..."},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function yI(t){let n;function r(e,t){return e[4]?oI:iI}let i=r(t),o=i(t);return{c(){o.c(),n=y()},m(e,t){o.m(e,t),u(e,n,t)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n.parentNode,n)))},i:e,o:e,d(e){o.d(e),e&&d(n)}}}function wI(e){if(!e)return"";return new Date(e).toLocaleString()}function vI(e){switch(e?.toUpperCase()){case"TRC":case"TRACE":return"level-trace";case"DBG":case"DEBUG":return"level-debug";case"INF":case"INFO":default:return"level-info";case"WRN":case"WARN":return"level-warn";case"ERR":case"ERROR":return"level-error";case"FTL":case"FATAL":return"level-fatal"}}function AI(e,t,n){let r,{isLoggedIn:i=!1}=t,{userRole:o=""}=t,{userSigner:s=null}=t;const a=P();let l=[],c=!1,u=!0,d=0,f=0,h="",p="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let y,w,v;async function A(e="GET",t="/api/logs"){if(!s)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${window.location.origin}${t}`],["method",e]],content:""},r=await s.signEvent(n);return btoa(JSON.stringify(r)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating auth header:",e),null}}async function b(e=!1){if(!c){n(3,c=!0),n(7,h=""),e&&(d=0,n(2,l=[]));try{const t=`/api/logs?offset=${d}&limit=100`,r=await A("GET",t),i=`${window.location.origin}${t}`,o=await fetch(i,{headers:r?{Authorization:`Nostr ${r}`}:{}});if(!o.ok)throw new Error(`Failed to load logs: ${o.statusText}`);const s=await o.json();n(2,l=e?s.logs||[]:[...l,...s.logs||[]]),n(6,f=s.total||0),n(5,u=s.has_more||!1),d=l.length}catch(e){console.error("Error loading logs:",e),n(7,h=e.message||"Failed to load logs")}finally{n(3,c=!1)}}}async function k(){try{const e=await fetch(`${window.location.origin}/api/logs/level`);if(e.ok){const t=await e.json();n(8,p=t.level||"info"),n(9,g=p)}}catch(e){console.error("Error loading log level:",e)}}D(()=>{r&&(b(!0),k(),function(){if(!w)return;v=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&b(!1)},{threshold:.1}),v.observe(w)}())}),R(()=>{v&&v.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,i=e.isLoggedIn),"userRole"in e&&n(1,o=e.userRole),"userSigner"in e&&n(17,s=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,r=i&&"owner"===o),28&e.$$.dirty[0]&&r&&0===l.length&&!c&&(b(!0),k())},[i,o,l,c,r,u,f,h,p,g,y,w,m,b,async function(){if(g!==p)try{const e=await A("POST","/api/logs/level"),t=await fetch(`${window.location.origin}/api/logs/level`,{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Nostr ${e}`}:{}},body:JSON.stringify({level:g})});if(!t.ok)throw new Error(`Failed to set log level: ${t.statusText}`);const r=await t.json();n(8,p=r.level),n(9,g=p)}catch(e){console.error("Error setting log level:",e),n(7,h=e.message||"Failed to set log level"),n(9,g=p)}},async function(){if(confirm("Are you sure you want to clear all logs?"))try{const e=await A("POST","/api/logs/clear"),t=await fetch(`${window.location.origin}/api/logs/clear`,{method:"POST",headers:e?{Authorization:`Nostr ${e}`}:{}});if(!t.ok)throw new Error(`Failed to clear logs: ${t.statusText}`);n(2,l=[]),d=0,n(5,u=!1),n(6,f=0)}catch(e){console.error("Error clearing logs:",e),n(7,h=e.message||"Failed to clear logs")}},function(){a("openLoginModal")},s,function(){g=x(this),n(9,g),n(12,m)},()=>b(!0),function(e){T[e?"unshift":"push"](()=>{w=e,n(11,w)})},function(e){T[e?"unshift":"push"](()=>{y=e,n(10,y)})}]}class bI extends ae{constructor(e){super(),se(this,e,AI,yI,o,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}function kI(e){let t,n,r,i,o,s,a,l,f,p,y;return{c(){t=h("div"),n=h("div"),r=h("h3"),r.textContent="Active Filter",i=m(),o=h("button"),o.textContent="🧹 Sweep",s=m(),a=h("div"),l=h("pre"),f=g(e[2]),A(r,"class","svelte-1tyqaa5"),A(o,"class","sweep-btn svelte-1tyqaa5"),A(o,"title","Clear filter"),A(n,"class","filter-display-header svelte-1tyqaa5"),A(l,"class","filter-json svelte-1tyqaa5"),A(a,"class","filter-json-container svelte-1tyqaa5"),A(t,"class","filter-display svelte-1tyqaa5")},m(d,h){u(d,t,h),c(t,n),c(n,r),c(n,i),c(n,o),c(t,s),c(t,a),c(a,l),c(l,f),p||(y=w(o,"click",e[3]),p=!0)},p(e,t){4&t&&k(f,e[2])},d(e){e&&d(t),p=!1,y()}}}function II(t){let n,r=t[0]&&t[1]&&kI(t);return{c(){r&&r.c(),n=y()},m(e,t){r&&r.m(e,t),u(e,n,t)},p(e,[t]){e[0]&&e[1]?r?r.p(e,t):(r=kI(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:e,o:e,d(e){r&&r.d(e),e&&d(n)}}}function EI(e,t,n){let r,i;const o=P();let{filter:s={}}=t,{showFilter:a=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,s=e.filter),"showFilter"in e&&n(0,a=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,r=function(e){return JSON.stringify(e,null,2)}(s)),16&e.$$.dirty&&n(1,i=Object.keys(s).length>0)},[a,i,r,function(){o("sweep")},s]}class CI extends ae{constructor(e){super(),se(this,e,EI,II,o,{filter:4,showFilter:0})}}function xI(e){return Bh[e]||`Kind ${e}`}function BI(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function SI(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function FI(e){return e?new Date(1e3*e).toLocaleString():""}class QI{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,i]=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:",i),this.authPromise&&(this.authPromise.reject(new Error(i||"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 i=this.ws.onmessage,o=setTimeout(()=>{this.ws.onmessage=i,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(c)clearTimeout(o),this.ws.onmessage=i,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"))return void console.log("Authentication required, waiting for AUTH challenge...");clearTimeout(o),this.ws.onmessage=i,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===a){this.challenge=s[1],console.log("Received AUTH challenge during publish:",this.challenge);try{await this.authenticate(),console.log("Authentication successful, retrying event publish...");const t=["EVENT",e];this.ws.send(JSON.stringify(t))}catch(e){clearTimeout(o),this.ws.onmessage=i,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(s)}catch(e){clearTimeout(o),this.ws.onmessage=i,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function DI(e,t,n,r){const i=new QI(e,n,r);try{await i.connect();return await i.publishEvent(t)}finally{i.close()}}function RI(e,t,n){const r=e.slice();return r[170]=t[n],r}function PI(e,t,n){const r=e.slice();return r[180]=t[n],r}function $I(e,t,n){const r=e.slice();return r[173]=t[n],r}function UI(e,t,n){const r=e.slice();r[173]=t[n];const i=r[53](r[173]);return r[174]=i,r}function TI(e,t,n){const r=e.slice();return r[177]=t[n],r}function NI(t){let n;function r(e,t){return e[1]?WI:zI}let i=r(t),o=i(t);return{c(){n=h("div"),o.c(),A(n,"class","welcome-message svelte-u3u5mw")},m(e,t){u(e,n,t),o.m(n,null)},p(e,t){i===(i=r(e))&&o?o.p(e,t):(o.d(1),o=i(e),o&&(o.c(),o.m(n,null)))},i:e,o:e,d(e){e&&d(n),o.d()}}}function LI(e){let t,n,r=e[6],i=[];for(let t=0;t<r.length;t+=1)i[t]=sE(PI(e,r,t));const o=e=>Z(i[e],1,1,()=>{i[e]=null});return{c(){for(let e=0;e<i.length;e+=1)i[e].c();t=y()},m(e,r){for(let t=0;t<i.length;t+=1)i[t]&&i[t].m(e,r);u(e,t,r),n=!0},p(e,n){if(524404&n[0]|94208&n[1]|3407872&n[2]){let s;for(r=e[6],s=0;s<r.length;s+=1){const o=PI(e,r,s);i[s]?(i[s].p(o,n),W(i[s],1)):(i[s]=sE(o),i[s].c(),W(i[s],1),i[s].m(t.parentNode,t))}for(Y(),s=r.length;s<i.length;s+=1)o(s);z()}},i(e){if(!n){for(let e=0;e<r.length;e+=1)W(i[e]);n=!0}},o(e){i=i.filter(Boolean);for(let e=0;e<i.length;e+=1)Z(i[e]);n=!1},d(e){f(i,e),e&&d(t)}}}function OI(t){let n,i,o,s,a,l,p,g,y,v,k,E,x,B,S,F,Q,D,R=null!==t[36]&&void 0!==t[36]&&t[36]>=0||""!==t[37]&&parseInt(t[37])>=0,P=xh,$=[];for(let e=0;e<P.length;e+=1)$[e]=aE(TI(t,P,e));let U=R&&lE(t);return{c(){n=h("div"),i=h("div"),i.innerHTML='<h3 class="svelte-u3u5mw">Event Recovery</h3> \n <p class="svelte-u3u5mw">Search and recover old versions of replaceable events</p>',o=m(),s=h("div"),a=h("div"),l=h("div"),p=h("label"),p.textContent="Select Event Kind:",g=m(),y=h("select"),v=h("option"),v.textContent="Choose a replaceable kind...";for(let e=0;e<$.length;e+=1)$[e].c();k=m(),E=h("div"),x=h("label"),x.textContent="Or enter custom kind number:",B=m(),S=h("input"),F=m(),U&&U.c(),A(p,"for","recovery-kind"),A(p,"class","svelte-u3u5mw"),v.__value=null,v.value=v.__value,A(y,"id","recovery-kind"),A(y,"class","svelte-u3u5mw"),void 0===t[36]&&_(()=>t[116].call(y)),A(l,"class","kind-selector svelte-u3u5mw"),A(x,"for","custom-kind"),A(x,"class","svelte-u3u5mw"),A(S,"id","custom-kind"),A(S,"type","number"),A(S,"placeholder","e.g., 10001"),A(S,"min","0"),A(S,"class","svelte-u3u5mw"),A(E,"class","custom-kind-input svelte-u3u5mw"),A(a,"class","recovery-controls svelte-u3u5mw"),A(s,"class","recovery-controls-card svelte-u3u5mw"),A(n,"class","recovery-tab svelte-u3u5mw")},m(e,r){u(e,n,r),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(l,p),c(l,g),c(l,y),c(y,v);for(let e=0;e<$.length;e+=1)$[e]&&$[e].m(y,null);C(y,t[36],!0),c(a,k),c(a,E),c(E,x),c(E,B),c(E,S),I(S,t[37]),c(n,F),U&&U.m(n,null),Q||(D=[w(y,"change",t[116]),w(y,"change",t[51]),w(S,"input",t[117]),w(S,"input",t[52])],Q=!0)},p(e,t){if(0&t){let n;for(P=xh,n=0;n<P.length;n+=1){const r=TI(e,P,n);$[n]?$[n].p(r,t):($[n]=aE(r),$[n].c(),$[n].m(y,null))}for(;n<$.length;n+=1)$[n].d(1);$.length=P.length}32&t[1]&&C(y,e[36]),64&t[1]&&b(S.value)!==e[37]&&I(S,e[37]),96&t[1]&&(R=null!==e[36]&&void 0!==e[36]&&e[36]>=0||""!==e[37]&&parseInt(e[37])>=0),R?U?U.p(e,t):(U=lE(e),U.c(),U.m(n,null)):U&&(U.d(1),U=null)},i:e,o:e,d(e){e&&d(n),f($,e),U&&U.d(),Q=!1,r(D)}}}function MI(e){let t,n;return t=new bI({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[13]}}),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),16&n[0]&&(r.userRole=e[4]),8192&n[0]&&(r.userSigner=e[13]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function _I(e){let t,n,r;function i(t){e[115](t)}let o={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:RE,policyEnabled:e[8],isLoadingPolicy:e[28],policyMessage:e[29],policyMessageType:e[30],validationErrors:e[31],policyFollows:e[32]};return void 0!==e[27]&&(o.policyJson=e[27]),t=new uw({props:o}),T.push(()=>te(t,"policyJson",i)),t.$on("loadPolicy",e[61]),t.$on("validatePolicy",e[62]),t.$on("savePolicy",e[63]),t.$on("formatJson",e[64]),t.$on("addPolicyAdmin",e[65]),t.$on("removePolicyAdmin",e[66]),t.$on("refreshFollows",e[67]),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,n){re(t,e,n),r=!0},p(e,r){const i={};2&r[0]&&(i.isLoggedIn=e[1]),16&r[0]&&(i.userRole=e[4]),256&r[0]&&(i.policyEnabled=e[8]),268435456&r[0]&&(i.isLoadingPolicy=e[28]),536870912&r[0]&&(i.policyMessage=e[29]),1073741824&r[0]&&(i.policyMessageType=e[30]),1&r[1]&&(i.validationErrors=e[31]),2&r[1]&&(i.policyFollows=e[32]),!n&&134217728&r[0]&&(n=!0,i.policyJson=e[27],H(()=>n=!1)),t.$set(i)},i(e){r||(W(t.$$.fragment,e),r=!0)},o(e){Z(t.$$.fragment,e),r=!1},d(e){ie(t,e)}}}function HI(e){let t,n,r;function i(t){e[112](t)}let o={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[21],isLoadingSprocket:e[23],sprocketUploadFile:e[26],sprocketMessage:e[24],sprocketMessageType:e[25],sprocketVersions:e[22]};return void 0!==e[20]&&(o.sprocketScript=e[20]),t=new qy({props:o}),T.push(()=>te(t,"sprocketScript",i)),t.$on("restartSprocket",e[56]),t.$on("deleteSprocket",e[57]),t.$on("sprocketFileSelect",e[68]),t.$on("uploadSprocketScript",e[69]),t.$on("saveSprocket",e[55]),t.$on("loadSprocket",e[54]),t.$on("loadVersions",e[58]),t.$on("loadVersion",e[113]),t.$on("deleteVersion",e[114]),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,n){re(t,e,n),r=!0},p(e,r){const i={};2&r[0]&&(i.isLoggedIn=e[1]),16&r[0]&&(i.userRole=e[4]),2097152&r[0]&&(i.sprocketStatus=e[21]),8388608&r[0]&&(i.isLoadingSprocket=e[23]),67108864&r[0]&&(i.sprocketUploadFile=e[26]),16777216&r[0]&&(i.sprocketMessage=e[24]),33554432&r[0]&&(i.sprocketMessageType=e[25]),4194304&r[0]&&(i.sprocketVersions=e[22]),!n&&1048576&r[0]&&(n=!0,i.sprocketScript=e[20],H(()=>n=!1)),t.$set(i)},i(e){r||(W(t.$$.fragment,e),r=!0)},o(e){Z(t.$$.fragment,e),r=!1},d(e){ie(t,e)}}}function jI(e){let t,n,r,i;const o=[vE,wE,yE],s=[];function a(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),r=s[n]=o[n](e),{c(){t=h("div"),r.c(),A(t,"class","managed-acl-view svelte-u3u5mw")},m(e,r){u(e,t,r),s[n].m(t,null),i=!0},p(e,i){let l=n;n=a(e),n===l?s[n].p(e,i):(Y(),Z(s[l],1,1,()=>{s[l]=null}),z(),r=s[n],r?r.p(e,i):(r=s[n]=o[n](e),r.c()),W(r,1),r.m(t,null))},i(e){i||(W(r),i=!0)},o(e){Z(r),i=!1},d(e){e&&d(t),s[n].d()}}}function GI(e){let t,n,r;function i(t){e[111](t)}let o={userPubkey:e[2],userRole:e[4],policyEnabled:e[8],publishError:e[35]};return void 0!==e[34]&&(o.composeEventJson=e[34]),t=new Py({props:o}),T.push(()=>te(t,"composeEventJson",i)),t.$on("reformatJson",e[91]),t.$on("signEvent",e[92]),t.$on("publishEvent",e[93]),t.$on("clearError",e[94]),{c(){ne(t.$$.fragment)},m(e,n){re(t,e,n),r=!0},p(e,r){const i={};4&r[0]&&(i.userPubkey=e[2]),16&r[0]&&(i.userRole=e[4]),256&r[0]&&(i.policyEnabled=e[8]),16&r[1]&&(i.publishError=e[35]),!n&&8&r[1]&&(n=!0,i.composeEventJson=e[34],H(()=>n=!1)),t.$set(i)},i(e){r||(W(t.$$.fragment,e),r=!0)},o(e){Z(t.$$.fragment,e),r=!1},d(e){ie(t,e)}}}function qI(e){let t,n;return t=new tI({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[13],userPrivkey:e[14],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),4&n[0]&&(r.userPubkey=e[2]),8192&n[0]&&(r.userSigner=e[13]),16384&n[0]&&(r.userPrivkey=e[14]),1024&n[0]&&(r.currentEffectiveRole=e[10]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function KI(e){let t,n;return t=new iv({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[13],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),4&n[0]&&(r.userPubkey=e[2]),8192&n[0]&&(r.userSigner=e[13]),1024&n[0]&&(r.currentEffectiveRole=e[10]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function JI(e){let t,n;return t=new hy({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[42],expandedEvents:e[19],isLoadingEvents:e[7],showOnlyMyEvents:DE,showFilterBuilder:e[16]}}),t.$on("scroll",e[90]),t.$on("toggleEventExpansion",e[107]),t.$on("deleteEvent",e[108]),t.$on("copyEventToClipboard",e[109]),t.$on("toggleChange",e[46]),t.$on("loadAllEvents",e[110]),t.$on("toggleFilterBuilder",e[77]),t.$on("filterApply",e[78]),t.$on("filterClear",e[79]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),16&n[0]&&(r.userRole=e[4]),4&n[0]&&(r.userPubkey=e[2]),2048&n[1]&&(r.filteredEvents=e[42]),524288&n[0]&&(r.expandedEvents=e[19]),128&n[0]&&(r.isLoadingEvents=e[7]),65536&n[0]&&(r.showFilterBuilder=e[16]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function VI(e){let t,n;return t=new hm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],selectedFile:e[17],aclMode:e[9],importMessage:e[18]}}),t.$on("fileSelect",e[87]),t.$on("importEvents",e[88]),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),1024&n[0]&&(r.currentEffectiveRole=e[10]),131072&n[0]&&(r.selectedFile=e[17]),512&n[0]&&(r.aclMode=e[9]),262144&n[0]&&(r.importMessage=e[18]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function YI(e){let t,n;return t=new sm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],aclMode:e[9]}}),t.$on("exportMyEvents",e[86]),t.$on("exportAllEvents",e[85]),t.$on("openLoginModal",e[71]),{c(){ne(t.$$.fragment)},m(e,r){re(t,e,r),n=!0},p(e,n){const r={};2&n[0]&&(r.isLoggedIn=e[1]),1024&n[0]&&(r.currentEffectiveRole=e[10]),512&n[0]&&(r.aclMode=e[9]),t.$set(r)},i(e){n||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function zI(t){let n;return{c(){n=h("p"),n.textContent="Log in to access your user dashboard",A(n,"class","svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function WI(e){let t,n,r,i=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=h("p"),n=g("Welcome "),r=g(i),A(t,"class","svelte-u3u5mw")},m(e,i){u(e,t,i),c(t,n),c(t,r)},p(e,t){12&t[0]&&i!==(i=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&k(r,i)},d(e){e&&d(t)}}}function ZI(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,B,S,F,Q,D,R=e[180].label+"",P=e[43].get(e[180].id)?.isLoading,$=!e[43].get(e[180].id)?.hasMore&&e[43].get(e[180].id)?.events?.length>0;function U(){return e[121](e[180])}function T(e,t){return 64&t[0]&&(E=null),64&t[0]&&(C=null),null==E&&(E=!!(e[43].get(e[180].id)?.events?.length>0)),E?eE:(null==C&&(C=!e[43].get(e[180].id)?.isLoading),C?XI:void 0)}v=new CI({props:{filter:e[43].get(e[180].id)?.filter||{}}}),v.$on("sweep",function(){return e[122](e[180])});let N=T(e,[-1,-1,-1,-1,-1,-1]),L=N&&N(e),O=P&&iE(),M=$&&oE();function _(...t){return e[127](e[180],...t)}return{c(){t=h("div"),n=h("div"),i=h("h2"),o=g("🔍 "),s=g(R),a=m(),l=h("button"),f=g("🔄 Refresh"),y=m(),ne(v.$$.fragment),b=m(),I=h("div"),L&&L.c(),x=m(),O&&O.c(),B=m(),M&&M.c(),S=m(),A(i,"class","svelte-u3u5mw"),A(l,"class","refresh-btn svelte-u3u5mw"),l.disabled=p=e[43].get(e[180].id)?.isLoading,A(n,"class","search-results-header svelte-u3u5mw"),A(I,"class","search-results-content svelte-u3u5mw"),A(t,"class","search-results-view svelte-u3u5mw")},m(e,r){u(e,t,r),c(t,n),c(n,i),c(i,o),c(i,s),c(n,a),c(n,l),c(l,f),c(t,y),re(v,t,null),c(t,b),c(t,I),L&&L.m(I,null),c(I,x),O&&O.m(I,null),c(I,B),M&&M.m(I,null),c(t,S),F=!0,Q||(D=[w(l,"click",U),w(I,"scroll",_)],Q=!0)},p(t,n){e=t,(!F||64&n[0])&&R!==(R=e[180].label+"")&&k(s,R),(!F||64&n[0]&&p!==(p=e[43].get(e[180].id)?.isLoading))&&(l.disabled=p);const r={};64&n[0]&&(r.filter=e[43].get(e[180].id)?.filter||{}),v.$set(r),N===(N=T(e,n))&&L?L.p(e,n):(L&&L.d(1),L=N&&N(e),L&&(L.c(),L.m(I,x))),64&n[0]&&(P=e[43].get(e[180].id)?.isLoading),P?O||(O=iE(),O.c(),O.m(I,B)):O&&(O.d(1),O=null),64&n[0]&&($=!e[43].get(e[180].id)?.hasMore&&e[43].get(e[180].id)?.events?.length>0),$?M||(M=oE(),M.c(),M.m(I,null)):M&&(M.d(1),M=null)},i(e){F||(W(v.$$.fragment,e),F=!0)},o(e){Z(v.$$.fragment,e),F=!1},d(e){e&&d(t),ie(v),L&&L.d(),O&&O.d(),M&&M.d(),Q=!1,r(D)}}}function XI(t){let n;return{c(){n=h("div"),n.innerHTML='<p class="svelte-u3u5mw">No search results found.</p>',A(n,"class","no-search-results svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function eE(e){let t,n=e[43].get(e[180].id).events,r=[];for(let t=0;t<n.length;t+=1)r[t]=rE($I(e,n,t));return{c(){for(let e=0;e<r.length;e+=1)r[e].c();t=y()},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,i){if(524372&i[0]|94208&i[1]){let o;for(n=e[43].get(e[180].id).events,o=0;o<n.length;o+=1){const s=$I(e,n,o);r[o]?r[o].p(s,i):(r[o]=rE(s),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},d(e){f(r,e),e&&d(t)}}}function tE(e){let t,n,r;function i(){return e[123](e[173])}return{c(){t=h("button"),t.textContent="🗑️",A(t,"class","delete-btn svelte-u3u5mw")},m(e,o){u(e,t,o),n||(r=w(t,"click",v(i)),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r()}}}function nE(e){let t,n,r,i,o,s,a,l,f=JSON.stringify(e[173],null,2)+"";function p(...t){return e[126](e[173],...t)}return{c(){t=h("div"),n=h("div"),r=h("pre"),i=g(f),o=m(),s=h("button"),s.textContent="📋",A(r,"class","event-json svelte-u3u5mw"),A(s,"class","copy-json-btn svelte-u3u5mw"),A(s,"title","Copy minified JSON to clipboard"),A(n,"class","json-container svelte-u3u5mw"),A(t,"class","search-result-details svelte-u3u5mw")},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,i),c(n,o),c(n,s),a||(l=w(s,"click",v(p)),a=!0)},p(t,n){e=t,64&n[0]&&f!==(f=JSON.stringify(e[173],null,2)+"")&&k(i,f)},d(e){e&&d(t),a=!1,l()}}}function rE(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,S,F,Q,D,R,P,$,U,T,N,L=BI(e[173].pubkey)+"",O=e[173].kind+"",M=xI(e[173].kind)+"",_=FI(e[173].created_at)+"",H=SI(e[173].content)+"",j=e[19].has(e[173].id),G=5!==e[173].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[173].pubkey&&e[173].pubkey===e[2])&&tE(e);function q(){return e[124](e[173])}function K(...t){return e[125](e[173],...t)}let J=j&&nE(e);return{c(){t=h("div"),n=h("div"),i=h("div"),i.innerHTML='<div class="avatar-placeholder svelte-u3u5mw">👤</div>',o=m(),s=h("div"),a=h("div"),l=g(L),f=m(),p=h("div"),y=h("span"),v=g(O),b=m(),I=h("span"),E=g(M),C=m(),x=h("div"),S=h("div"),F=g(_),Q=m(),D=h("div"),R=g(H),P=m(),G&&G.c(),$=m(),J&&J.c(),U=m(),A(i,"class","search-result-avatar svelte-u3u5mw"),A(a,"class","search-result-author svelte-u3u5mw"),A(y,"class","kind-number svelte-u3u5mw"),A(I,"class","kind-name svelte-u3u5mw"),A(p,"class","search-result-kind svelte-u3u5mw"),A(s,"class","search-result-info svelte-u3u5mw"),A(S,"class","event-timestamp svelte-u3u5mw"),A(D,"class","event-content-single-line svelte-u3u5mw"),A(x,"class","search-result-content svelte-u3u5mw"),A(n,"class","search-result-row svelte-u3u5mw"),A(n,"role","button"),A(n,"tabindex","0"),A(t,"class","search-result-item svelte-u3u5mw"),B(t,"expanded",e[19].has(e[173].id))},m(e,r){u(e,t,r),c(t,n),c(n,i),c(n,o),c(n,s),c(s,a),c(a,l),c(s,f),c(s,p),c(p,y),c(y,v),c(p,b),c(p,I),c(I,E),c(n,C),c(n,x),c(x,S),c(S,F),c(x,Q),c(x,D),c(D,R),c(n,P),G&&G.m(n,null),c(t,$),J&&J.m(t,null),c(t,U),T||(N=[w(n,"click",q),w(n,"keydown",K)],T=!0)},p(r,i){e=r,64&i[0]&&L!==(L=BI(e[173].pubkey)+"")&&k(l,L),64&i[0]&&O!==(O=e[173].kind+"")&&k(v,O),64&i[0]&&M!==(M=xI(e[173].kind)+"")&&k(E,M),64&i[0]&&_!==(_=FI(e[173].created_at)+"")&&k(F,_),64&i[0]&&H!==(H=SI(e[173].content)+"")&&k(R,H),5!==e[173].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[173].pubkey&&e[173].pubkey===e[2])?G?G.p(e,i):(G=tE(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),524352&i[0]&&(j=e[19].has(e[173].id)),j?J?J.p(e,i):(J=nE(e),J.c(),J.m(t,U)):J&&(J.d(1),J=null),524352&i[0]|4096&i[1]&&B(t,"expanded",e[19].has(e[173].id))},d(e){e&&d(t),G&&G.d(),J&&J.d(),T=!1,r(N)}}}function iE(e){let t;return{c(){t=h("div"),t.innerHTML='<div class="loading-spinner svelte-u3u5mw"></div> \n <p class="svelte-u3u5mw">Searching...</p>',A(t,"class","loading-search-results svelte-u3u5mw")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function oE(e){let t;return{c(){t=h("div"),t.innerHTML='<p class="svelte-u3u5mw">No more search results to load.</p>',A(t,"class","end-of-search-results svelte-u3u5mw")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function sE(e){let t,n,r=e[180].id===e[5]&&ZI(e);return{c(){r&&r.c(),t=y()},m(e,i){r&&r.m(e,i),u(e,t,i),n=!0},p(e,n){e[180].id===e[5]?r?(r.p(e,n),96&n[0]&&W(r,1)):(r=ZI(e),r.c(),W(r,1),r.m(t.parentNode,t)):r&&(Y(),Z(r,1,1,()=>{r=null}),z())},i(e){n||(W(r),n=!0)},o(e){Z(r),n=!1},d(e){r&&r.d(e),e&&d(t)}}}function aE(t){let n,r,i=t[177].label+"";return{c(){n=h("option"),r=g(i),n.__value=t[177].value,n.value=n.__value},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}function lE(e){let t;function n(e,t){return e[39]?dE:0===e[38].length?uE:cE}let r=n(e),i=r(e);return{c(){t=h("div"),i.c(),A(t,"class","recovery-results svelte-u3u5mw")},m(e,n){u(e,t,n),i.m(t,null)},p(e,o){r===(r=n(e))&&i?i.p(e,o):(i.d(1),i=r(e),i&&(i.c(),i.m(t,null)))},d(e){e&&d(t),i.d()}}}function cE(e){let t,n,r,i=e[38],o=[];for(let t=0;t<i.length;t+=1)o[t]=gE(UI(e,i,t));let s=e[40]&&mE(e);return{c(){t=h("div");for(let e=0;e<o.length;e+=1)o[e].c();n=m(),s&&s.c(),r=y(),A(t,"class","events-list svelte-u3u5mw")},m(e,i){u(e,t,i);for(let e=0;e<o.length;e+=1)o[e]&&o[e].m(t,null);u(e,n,i),s&&s.m(e,i),u(e,r,i)},p(e,n){if(1024&n[0]|4997248&n[1]){let r;for(i=e[38],r=0;r<i.length;r+=1){const s=UI(e,i,r);o[r]?o[r].p(s,n):(o[r]=gE(s),o[r].c(),o[r].m(t,null))}for(;r<o.length;r+=1)o[r].d(1);o.length=i.length}e[40]?s?s.p(e,n):(s=mE(e),s.c(),s.m(r.parentNode,r)):s&&(s.d(1),s=null)},d(e){e&&d(t),f(o,e),e&&d(n),s&&s.d(e),e&&d(r)}}}function uE(t){let n;return{c(){n=h("div"),n.textContent="No events found for this kind",A(n,"class","no-events svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function dE(t){let n;return{c(){n=h("div"),n.textContent="Loading events...",A(n,"class","loading svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function fE(e){let t;return{c(){t=g("Current Version")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function hE(e){let t,n,r,i,o;function s(){return e[118](e[173])}let a="read"!==e[10]&&pE(e);return{c(){t=h("button"),t.textContent="🌐 Repost to All",n=m(),a&&a.c(),r=y(),A(t,"class","repost-all-button svelte-u3u5mw")},m(e,l){u(e,t,l),u(e,n,l),a&&a.m(e,l),u(e,r,l),i||(o=w(t,"click",s),i=!0)},p(t,n){"read"!==(e=t)[10]?a?a.p(e,n):(a=pE(e),a.c(),a.m(r.parentNode,r)):a&&(a.d(1),a=null)},d(e){e&&d(t),e&&d(n),a&&a.d(e),e&&d(r),i=!1,o()}}}function pE(e){let t,n,r;function i(){return e[119](e[173])}return{c(){t=h("button"),t.textContent="🔄 Repost",A(t,"class","repost-button svelte-u3u5mw")},m(e,o){u(e,t,o),n||(r=w(t,"click",i),n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r()}}}function gE(e){let t,n,r,i,o,s,a,l,f,p,y,b,I,E,C,x,S,F,Q=new Date(1e3*e[173].created_at).toLocaleString()+"",D=JSON.stringify(e[173],null,2)+"",R=e[174]&&fE(),P=!e[174]&&hE(e);function $(...t){return e[120](e[173],...t)}return{c(){t=h("div"),n=h("div"),r=h("div"),i=h("span"),R&&R.c(),o=m(),s=h("span"),a=g(Q),l=m(),f=h("div"),P&&P.c(),p=m(),y=h("button"),y.textContent="📋 Copy JSON",b=m(),I=h("div"),E=h("pre"),C=g(D),x=m(),A(i,"class","event-kind svelte-u3u5mw"),A(s,"class","event-timestamp svelte-u3u5mw"),A(r,"class","event-header-left svelte-u3u5mw"),A(y,"class","copy-json-btn svelte-u3u5mw"),A(f,"class","event-header-actions svelte-u3u5mw"),A(n,"class","event-header svelte-u3u5mw"),A(E,"class","event-json svelte-u3u5mw"),A(I,"class","event-content svelte-u3u5mw"),A(t,"class","event-item svelte-u3u5mw"),B(t,"old-version",!e[174])},m(e,d){u(e,t,d),c(t,n),c(n,r),c(r,i),R&&R.m(i,null),c(r,o),c(r,s),c(s,a),c(n,l),c(n,f),P&&P.m(f,null),c(f,p),c(f,y),c(t,b),c(t,I),c(I,E),c(E,C),c(t,x),S||(F=w(y,"click",v($)),S=!0)},p(n,r){(e=n)[174]?R||(R=fE(),R.c(),R.m(i,null)):R&&(R.d(1),R=null),128&r[1]&&Q!==(Q=new Date(1e3*e[173].created_at).toLocaleString()+"")&&k(a,Q),e[174]?P&&(P.d(1),P=null):P?P.p(e,r):(P=hE(e),P.c(),P.m(f,p)),128&r[1]&&D!==(D=JSON.stringify(e[173],null,2)+"")&&k(C,D),4194432&r[1]&&B(t,"old-version",!e[174])},d(e){e&&d(t),R&&R.d(),P&&P.d(),S=!1,F()}}}function mE(e){let t,n,r,i;return{c(){t=h("button"),n=g("Load More Events"),A(t,"class","load-more svelte-u3u5mw"),t.disabled=e[39]},m(o,s){u(o,t,s),c(t,n),r||(i=w(t,"click",e[48]),r=!0)},p(e,n){256&n[1]&&(t.disabled=e[39])},d(e){e&&d(t),r=!1,i()}}}function yE(t){let n,r,i,o,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in with owner permissions to access\n managed ACL configuration.",i=m(),o=h("button"),o.textContent="Log In",A(o,"class","login-btn svelte-u3u5mw"),A(n,"class","access-denied")},m(e,l){u(e,n,l),c(n,r),c(n,i),c(n,o),s||(a=w(o,"click",t[71]),s=!0)},p:e,i:e,o:e,d(e){e&&d(n),s=!1,a()}}}function wE(e){let t,n;return t=new Lg({props:{userSigner:e[13],userPubkey:e[2]}}),{c(){ne(t.$$.fragment)},m(e,r){re(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||(W(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ie(t,e)}}}function vE(t){let n,r,i,o,s,a,l,f,p,y,w,v=(t[9]||"unknown")+"";return{c(){n=h("div"),r=h("h3"),r.textContent="⚠️ Managed ACL Mode Not Active",i=m(),o=h("p"),o.textContent='To use the Managed ACL interface, you need to set\n the ACL mode to "managed" in your relay\n configuration.',s=m(),a=h("p"),l=g("Current ACL mode: "),f=h("strong"),p=g(v),y=m(),w=h("p"),w.innerHTML='Please set <code class="svelte-u3u5mw">ORLY_ACL_MODE=managed</code> in your\n environment variables and restart the relay.',A(r,"class","svelte-u3u5mw"),A(o,"class","svelte-u3u5mw"),A(a,"class","svelte-u3u5mw"),A(w,"class","svelte-u3u5mw"),A(n,"class","acl-mode-warning svelte-u3u5mw")},m(e,t){u(e,n,t),c(n,r),c(n,i),c(n,o),c(n,s),c(n,a),c(a,l),c(a,f),c(f,p),c(n,y),c(n,w)},p(e,t){512&t[0]&&v!==(v=(e[9]||"unknown")+"")&&k(p,v)},i:e,o:e,d(e){e&&d(n)}}}function AE(e){let t,n,i,o,s,a,l,f,p,g;function y(e,t){return e[3]?kE:e[1]&&e[2]?bE:void 0}let b=y(e),k=b&&b(e);return{c(){t=h("div"),n=h("div"),i=h("div"),o=h("h2"),o.textContent="Settings",s=m(),a=h("button"),a.textContent="✕",l=m(),f=h("div"),k&&k.c(),A(o,"class","svelte-u3u5mw"),A(a,"class","close-btn svelte-u3u5mw"),A(i,"class","drawer-header svelte-u3u5mw"),A(f,"class","drawer-content"),A(n,"class","settings-drawer svelte-u3u5mw"),B(n,"dark-theme",e[0]),A(t,"class","drawer-overlay svelte-u3u5mw"),A(t,"role","button"),A(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,i),c(i,o),c(i,s),c(i,a),c(n,l),c(n,f),k&&k.m(f,null),p||(g=[w(a,"click",e[76]),w(n,"click",v(e[102])),w(n,"keydown",v(e[103])),w(t,"click",e[76]),w(t,"keydown",e[129])],p=!0)},p(e,t){b===(b=y(e))&&k?k.p(e,t):(k&&k.d(1),k=b&&b(e),k&&(k.c(),k.m(f,null))),1&t[0]&&B(n,"dark-theme",e[0])},d(e){e&&d(t),k&&k.d(),p=!1,r(g)}}}function bE(e){let t,n,i,o,s,a,l,f,p,y,v,b,I,E,C,x,B,S=e[2].slice(0,16)+"",F=e[2].slice(-8)+"";return{c(){t=h("div"),n=h("button"),n.textContent="Log out",i=m(),o=h("h3"),o.textContent="Profile Loading",s=m(),a=h("p"),a.textContent="Your profile metadata is being loaded...",l=m(),f=h("button"),f.textContent="Retry Loading Profile",p=m(),y=h("div"),v=h("strong"),v.textContent="Public Key:",b=m(),I=g(S),E=g("..."),C=g(F),A(n,"class","logout-btn floating svelte-u3u5mw"),A(o,"class","svelte-u3u5mw"),A(a,"class","svelte-u3u5mw"),A(f,"class","retry-profile-btn svelte-u3u5mw"),A(y,"class","user-pubkey-display svelte-u3u5mw"),A(t,"class","profile-loading-section svelte-u3u5mw")},m(r,d){u(r,t,d),c(t,n),c(t,i),c(t,o),c(t,s),c(t,a),c(t,l),c(t,f),c(t,p),c(t,y),c(y,v),c(y,b),c(y,I),c(y,E),c(y,C),x||(B=[w(n,"click",e[73]),w(f,"click",e[84])],x=!0)},p(e,t){4&t[0]&&S!==(S=e[2].slice(0,16)+"")&&k(I,S),4&t[0]&&F!==(F=e[2].slice(-8)+"")&&k(C,F)},d(e){e&&d(t),x=!1,r(B)}}}function kE(e){let t,n,r,i,o,s,a,l,f,p,v,b,I,E,C,x=(e[3].name||"Unknown User")+"",B=e[3].banner&&IE(e);function S(e,t){return e[3].picture?CE:EE}let F=S(e),Q=F(e),D=e[3].nip05&&xE(e),R=e[3].about&&BE(e),P=e[4]&&"read"!==e[4]&&SE(e);return{c(){t=h("div"),n=h("div"),B&&B.c(),r=m(),i=h("button"),i.textContent="Log out",o=m(),Q.c(),s=m(),a=h("div"),l=h("h3"),f=g(x),p=m(),D&&D.c(),v=m(),R&&R.c(),b=m(),P&&P.c(),I=y(),A(i,"class","logout-btn floating svelte-u3u5mw"),A(l,"class","profile-username svelte-u3u5mw"),A(a,"class","name-row svelte-u3u5mw"),A(n,"class","profile-hero svelte-u3u5mw"),A(t,"class","profile-section svelte-u3u5mw")},m(d,h){u(d,t,h),c(t,n),B&&B.m(n,null),c(n,r),c(n,i),c(n,o),Q.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,p),D&&D.m(a,null),c(t,v),R&&R.m(t,null),u(d,b,h),P&&P.m(d,h),u(d,I,h),E||(C=w(i,"click",e[73]),E=!0)},p(e,i){e[3].banner?B?B.p(e,i):(B=IE(e),B.c(),B.m(n,r)):B&&(B.d(1),B=null),F===(F=S(e))&&Q?Q.p(e,i):(Q.d(1),Q=F(e),Q&&(Q.c(),Q.m(n,s))),8&i[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&k(f,x),e[3].nip05?D?D.p(e,i):(D=xE(e),D.c(),D.m(a,null)):D&&(D.d(1),D=null),e[3].about?R?R.p(e,i):(R=BE(e),R.c(),R.m(t,null)):R&&(R.d(1),R=null),e[4]&&"read"!==e[4]?P?P.p(e,i):(P=SE(e),P.c(),P.m(I.parentNode,I)):P&&(P.d(1),P=null)},d(e){e&&d(t),B&&B.d(),Q.d(),D&&D.d(),R&&R.d(),e&&d(b),P&&P.d(e),e&&d(I),E=!1,C()}}}function IE(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].banner)||A(t,"src",n),A(t,"alt","Profile banner"),A(t,"class","profile-banner svelte-u3u5mw")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].banner)&&A(t,"src",n)},d(e){e&&d(t)}}}function EE(t){let n;return{c(){n=h("div"),n.textContent="👤",A(n,"class","profile-avatar-placeholder overlap svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function CE(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||A(t,"src",n),A(t,"alt","User avatar"),A(t,"class","profile-avatar overlap svelte-u3u5mw")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function xE(e){let t,n,r=e[3].nip05+"";return{c(){t=h("span"),n=g(r),A(t,"class","profile-nip05-inline svelte-u3u5mw")},m(e,r){u(e,t,r),c(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&k(n,r)},d(e){e&&d(t)}}}function BE(e){let t,n;return{c(){t=h("div"),n=h("p"),A(n,"class","profile-about svelte-u3u5mw"),A(t,"class","about-card svelte-u3u5mw")},m(r,i){u(r,t,i),c(t,n),n.innerHTML=e[41]},p(e,t){1024&t[1]&&(n.innerHTML=e[41])},d(e){e&&d(t)}}}function SE(e){let t,n,r,i,o,s,a=e[96](),l=[];for(let t=0;t<a.length;t+=1)l[t]=FE(RI(e,a,t));return{c(){t=h("div"),n=h("h3"),n.textContent="View as Role",r=m(),i=h("p"),i.textContent="See the interface as it appears for different\n permission levels:",o=m(),s=h("div");for(let e=0;e<l.length;e+=1)l[e].c();A(n,"class","svelte-u3u5mw"),A(i,"class","svelte-u3u5mw"),A(s,"class","radio-group svelte-u3u5mw"),A(t,"class","view-as-section svelte-u3u5mw")},m(e,a){u(e,t,a),c(t,n),c(t,r),c(t,i),c(t,o),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]|12&t[3]){let n;for(a=e[96](),n=0;n<a.length;n+=1){const r=RI(e,a,n);l[n]?l[n].p(r,t):(l[n]=FE(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 FE(e){let t,n,r,i,o,s,a,l,f,p=e[170].charAt(0).toUpperCase()+e[170].slice(1)+"",y=e[170]===e[4]?" (Default)":"";function v(){return e[128](e[170])}return{c(){t=h("label"),n=h("input"),i=m(),o=g(p),s=g(y),a=m(),A(n,"type","radio"),A(n,"name","viewAsRole"),n.value=e[170],n.checked=r=e[10]===e[170],A(n,"class","svelte-u3u5mw"),A(t,"class","radio-label svelte-u3u5mw")},m(e,r){u(e,t,r),c(t,n),c(t,i),c(t,o),c(t,s),c(t,a),l||(f=w(n,"change",v),l=!0)},p(t,i){e=t,1024&i[0]&&r!==(r=e[10]===e[170])&&(n.checked=r),16&i[0]&&y!==(y=e[170]===e[4]?" (Default)":"")&&k(s,y)},d(e){e&&d(t),l=!1,f()}}}function QE(e){let t,n,r,i,o,s,a,l,f,p,g,y,w,v;t=new Kg({props:{isDarkTheme:e[0],isLoggedIn:e[1],userRole:e[4],currentEffectiveRole:e[10],userProfile:e[3],userPubkey:e[2]}}),t.$on("openSettingsDrawer",e[75]),t.$on("openLoginModal",e[71]),i=new Xg({props:{isDarkTheme:e[0],tabs:e[11],selectedTab:e[5],version:e[33]}}),i.$on("selectTab",e[105]),i.$on("closeSearchTab",e[106]);const b=[YI,VI,JI,KI,qI,GI,jI,HI,_I,MI,OI,LI,NI],k=[];function I(e,t){return 96&t[0]&&(a=null),"export"===e[5]?0:"import"===e[5]?1:"events"===e[5]?2:"blossom"===e[5]?3:"bunker"===e[5]?4:"compose"===e[5]?5:"managed-acl"===e[5]?6:"sprocket"===e[5]?7:"policy"===e[5]?8:"logs"===e[5]?9:"recovery"===e[5]?10:(null==a&&(a=!!e[6].some(e[104])),a?11:12)}l=I(e,[-1,-1,-1,-1,-1,-1]),f=k[l]=b[l](e);let E=e[15]&&AE(e);function C(t){e[130](t)}let x={isDarkTheme:e[0]};return void 0!==e[12]&&(x.showModal=e[12]),y=new Jp({props:x}),T.push(()=>te(y,"showModal",C)),y.$on("login",e[72]),y.$on("close",e[74]),{c(){ne(t.$$.fragment),n=m(),r=h("div"),ne(i.$$.fragment),o=m(),s=h("main"),f.c(),p=m(),E&&E.c(),g=m(),ne(y.$$.fragment),A(s,"class","main-content svelte-u3u5mw"),A(r,"class","app-container svelte-u3u5mw"),B(r,"dark-theme",e[0])},m(e,a){re(t,e,a),u(e,n,a),u(e,r,a),re(i,r,null),c(r,o),c(r,s),k[l].m(s,null),u(e,p,a),E&&E.m(e,a),u(e,g,a),re(y,e,a),v=!0},p(e,n){const o={};1&n[0]&&(o.isDarkTheme=e[0]),2&n[0]&&(o.isLoggedIn=e[1]),16&n[0]&&(o.userRole=e[4]),1024&n[0]&&(o.currentEffectiveRole=e[10]),8&n[0]&&(o.userProfile=e[3]),4&n[0]&&(o.userPubkey=e[2]),t.$set(o);const a={};1&n[0]&&(a.isDarkTheme=e[0]),2048&n[0]&&(a.tabs=e[11]),32&n[0]&&(a.selectedTab=e[5]),4&n[1]&&(a.version=e[33]),i.$set(a);let c=l;l=I(e,n),l===c?k[l].p(e,n):(Y(),Z(k[c],1,1,()=>{k[c]=null}),z(),f=k[l],f?f.p(e,n):(f=k[l]=b[l](e),f.c()),W(f,1),f.m(s,null)),(!v||1&n[0])&&B(r,"dark-theme",e[0]),e[15]?E?E.p(e,n):(E=AE(e),E.c(),E.m(g.parentNode,g)):E&&(E.d(1),E=null);const u={};1&n[0]&&(u.isDarkTheme=e[0]),!w&&4096&n[0]&&(w=!0,u.showModal=e[12],H(()=>w=!1)),y.$set(u)},i(e){v||(W(t.$$.fragment,e),W(i.$$.fragment,e),W(f),W(y.$$.fragment,e),v=!0)},o(e){Z(t.$$.fragment,e),Z(i.$$.fragment,e),Z(f),Z(y.$$.fragment,e),v=!1},d(e){ie(t,e),e&&d(n),e&&d(r),ie(i),k[l].d(),e&&d(p),E&&E.d(e),e&&d(g),ie(y,e)}}}let DE=!1,RE=!1;function PE(e,t,n){let r,i,o,s,a;"undefined"!=typeof window&&(window.debugIndexedDB=Kh);let l=!1,c=!1,u=!1,d="",f="",h=null,p="",g=null,m=null,y=!1,w=localStorage.getItem("selectedTab")||"export",v=!1,A={},k=[],I=[],E=null,C="",B=new Set,S=!1,F=!0,Q=null,D="",R=new Map,P=[],U=0,T=[],N=!0,L=null,O="",M=null,_=[],H=!1,j="",G="info",q=!1,K=null,J="",V=!1,Y=!1,z="",W="info",Z=[],X=[],ee="",te="",ne="",re="",ie=null,oe="",se=[],ae=!1,le=!0,ce=null;function ue(e){B.has(e)?B.delete(e):B.add(e),n(19,B)}async function de(e,t){const n=JSON.stringify(e),r=await async function(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){console.error("Failed to copy to clipboard:",t);try{const t=document.createElement("textarea");return t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch(e){return console.error("Fallback copy also failed:",e),!1}}}(n);!function(e,t=!0){if(!e)return;const n=e.textContent,r=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=r},2e3)}(t.target.closest(".copy-json-btn"),r),r||alert("Failed to copy to clipboard. Please copy manually.")}async function fe(e){if(!u)return void alert("Please log in first");const t=I.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(!g)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 i=await g.signEvent(r);console.log("Signed delete event:",i),console.log("Signed delete event pubkey:",i.pubkey),console.log("Delete event tags:",i.tags);const o=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await DI(o,i,g,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 Qh.publish(i);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 jh(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(97,I=I.filter(t=>t.id!==e)),T=T.filter(t=>t.id!==e),P=P.filter(t=>t.id!==e);for(const[t,n]of R)n.events&&(n.events=n.events.filter(t=>t.id!==e),R.set(t,n));me(),console.log("Reloading events to show delete event...");const r=DE&&u&&d?[d]:null;await Te(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=new Fh;await r.connectToRelay(t);const o=await r.publish(i);if(console.log("Delete event published to local relay only:",o),!(o.success&&o.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 ${o.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 jh(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(97,I=I.filter(t=>t.id!==e)),T=T.filter(t=>t.id!==e),P=P.filter(t=>t.id!==e);for(const[t,n]of R)n.events&&(n.events=n.events.filter(t=>t.id!==e),R.set(t,n));me(),console.log("Reloading events to show delete event...");const t=DE&&u&&d?[d]:null;await Te(!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 he(){const e=oe?parseInt(oe):ie;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(39,ae=!0);try{const t=[{kinds:[e],authors:[d],limit:100}];ce&&(t[0].until=ce),console.log("Recovery filters:",t);const r=await qh(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",r.length),console.log("Recovery events kinds:",r.map(e=>e.kind)),n(38,se=ce?[...se,...r]:r),r.length>0?(ce=Math.min(...r.map(e=>e.created_at)),n(40,le=100===r.length)):n(40,le=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(39,ae=!1)}}else console.log("Not logged in, cannot load recovery events")}async function pe(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const 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(g){const e=await g.signEvent(r);console.log("Signed event for repost:",e);const i=await Qh.publish(e,[t]);console.log("Repost publish result:",i),i.success&&i.okCount>0?(alert("Event reposted successfully!"),n(40,le=!1),await he()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event:",e),alert("Error reposting event: "+e.message)}}async function ge(e){if(confirm("Are you sure you want to repost this event to all your write relays?"))try{const t=await async function(){if(!d)return[];try{const e=await Nh([{kinds:[10002],authors:[d],limit:1}]);if(0===e.length)return console.log("No relay list event found for user"),[];const t=e[0];console.log("Found relay list event:",t);const n=[];for(const e of t.tags)if("r"===e[0]&&e.length>=2){const t=e[1],r=e.length>=3?e[2]:null;r&&"write"!==r||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),r=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=[r,...t.filter(e=>e!==r)];1===i.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",i,e);const o={...e};if(o.created_at=Math.floor(Date.now()/1e3),o.id="",o.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(o.tags=o.tags.filter(e=>"d"!==e[0]),o.tags.push(t))}if(g){const e=await g.signEvent(o);console.log("Signed event for repost to all:",e);const t=await Qh.publish(e,i);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${i.length} relays!`),n(40,le=!1),await he()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event to all:",e),alert("Error reposting event to all: "+e.message)}}if("undefined"!=typeof window&&window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");l=e.matches,e.addEventListener("change",e=>{n(0,l=e.matches)})}if("undefined"!=typeof localStorage){const e=localStorage.getItem("nostr_auth_method"),t=localStorage.getItem("nostr_pubkey");e&&t&&(u=!0,d=t,f=e,"extension"===e&&window.nostr&&(g=window.nostr),Pe(),$e()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&Ce.some(e=>e.id===r.selectedTab)&&n(5,w=r.selectedTab),r.expandedEvents&&n(19,B=new Set(r.expandedEvents)),r.globalEventsCache&&(P=r.globalEventsCache),r.globalCacheTimestamp&&(U=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&(F=r.hasMoreEvents),r.oldestEventTimestamp&&(Q=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(N=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(L=r.oldestMyEventTimestamp),P.length>0&&((e=U)&&Date.now()-e<Sh)&&n(97,I=P)}}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(99,q=t.enabled)}}catch(e){console.error("Error loading sprocket config:",e)}}(),async function(){try{const e=await fetch("/api/policy/config",{method:"GET",headers:{"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(8,V=t.enabled||!1)}}catch(e){console.error("Error loading policy config:",e),n(8,V=!1)}}(),async function(){try{const e=await async function(){try{const e=await fetch(window.location.origin,{headers:{Accept:"application/nostr+json"}});if(e.ok)return await e.json()}catch(e){console.error("Error fetching relay info:",e)}return null}();e&&e.version&&n(33,te=e.version)}catch(e){console.error("Error fetching relay version:",e)}}()}function me(){if("undefined"==typeof localStorage)return;const e={selectedTab:w,expandedEvents:Array.from(B),globalEventsCache:P,globalCacheTimestamp:U,hasMoreEvents:F,oldestEventTimestamp:Q};localStorage.setItem("app_state",JSON.stringify(e))}function ye(e){P=e.sort((e,t)=>t.created_at-e.created_at),U=Date.now(),me()}async function we(){if(u&&"owner"===p&&q)try{n(23,H=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(21,M=await e.json()):ke("Failed to load sprocket status","error")}catch(e){ke(`Error loading sprocket status: ${e.message}`,"error")}finally{n(23,H=!1)}}async function ve(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(22,_=await e.json()):ke("Failed to load versions","error")}catch(e){ke(`Error loading versions: ${e.message}`,"error")}finally{n(23,H=!1)}}async function Ae(e){u&&"owner"===p&&(n(20,O=e.content),ke(`Loaded version: ${e.name}`,"success"))}async function be(e){if(u&&"owner"===p&&confirm(`Are you sure you want to delete version ${e}?`))try{n(23,H=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)ke(`Version ${e} deleted successfully`,"success"),await ve();else{ke(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){ke(`Error deleting version: ${e.message}`,"error")}finally{n(23,H=!1)}}function ke(e,t="info"){n(24,j=e),n(25,G=t),setTimeout(()=>{n(24,j="")},5e3)}function Ie(e,t="info"){n(29,z=e),n(30,W=t),"error"!==t&&setTimeout(()=>{n(29,z="")},5e3)}async function Ee(){if(n(31,Z=[]),!J.trim())return n(31,Z=["Policy JSON is empty"]),Ie("Validation failed","error"),!1;try{const e=JSON.parse(J);if("object"!=typeof e||null===e)return n(31,Z=["Policy must be a JSON object"]),Ie("Validation failed","error"),!1;if(e.policy_admins)if(Array.isArray(e.policy_admins))for(const t of e.policy_admins)"string"==typeof t&&/^[0-9a-fA-F]{64}$/.test(t)||Z.push(`Invalid policy_admin pubkey: ${t}`);else Z.push("policy_admins must be an array");if(e.rules)if("object"!=typeof e.rules)Z.push("rules must be an object");else for(const[t,n]of Object.entries(e.rules))if(/^\d+$/.test(t)||Z.push(`Invalid kind number: ${t}`),n.tag_validation&&"object"==typeof n.tag_validation)for(const[e,t]of Object.entries(n.tag_validation))try{new RegExp(t)}catch(n){Z.push(`Invalid regex for tag '${e}': ${t}`)}return e.default_policy&&!["allow","deny"].includes(e.default_policy)&&Z.push("default_policy must be 'allow' or 'deny'"),Z.length>0?(Ie("Validation failed - see errors below","error"),!1):(Ie("Validation passed","success"),!0)}catch(e){return n(31,Z=[`JSON parse error: ${e.message}`]),Ie("Invalid JSON syntax","error"),!1}}const Ce=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"bunker",icon:"🔐",label:"Bunker",requiresWrite:!0},{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},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];function xe(e){n(5,w=e),"sprocket"===e&&u&&"owner"===p&&q&&(we(),ve()),me()}function Be(){n(15,y=!1)}function Se(e){Fe(e)}function Fe(e){n(6,k=k.filter(t=>t.id!==e)),R.delete(e),w===e&&n(5,w="export")}async function Qe(e,t=!0){const n=R.get(e);if(n&&!n.isLoading){n.isLoading=!0,R.set(e,n);try{const r={...n.filter};!t&&n.oldestTimestamp&&(r.until=n.oldestTimestamp),t||(r.limit=200),console.log("Loading search results with filter:",r);const i=await _h([r],{timeout:3e4});if(console.log("Received search results:",i.length,"events"),n.events=t?i.sort((e,t)=>t.created_at-e.created_at):[...n.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!n.oldestTimestamp||e<n.oldestTimestamp)&&(n.oldestTimestamp=e)}n.hasMore=i.length===(t?r.limit||100:200),n.isLoading=!1,R.set(e,n)}catch(t){console.error("Failed to load search results:",t),n.isLoading=!1,R.set(e,n),alert("Failed to load search results: "+t.message)}}}function De(e,t){const{scrollTop:n,scrollHeight:r,clientHeight:i}=e.target;if(r-n-i<100){const e=R.get(t);e&&!e.isLoading&&e.hasMore&&async function(e){await Qe(e,!1)}(t)}}async function Re(){if(u&&d&&!h)try{console.log("Auto-fetching profile for:",d),await Gh(),n(3,h=await Oh(d)),console.log("Profile auto-loaded:",h)}catch(e){console.error("Failed to auto-load profile:",e)}}async function Pe(){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 $e(){try{const e=await fetch("/api/acl-mode");if(e.ok){const t=await e.json();n(9,ee=t.acl_mode||""),console.log("ACL mode loaded:",ee)}else console.error("Failed to fetch ACL mode:",e.status),n(9,ee="")}catch(e){console.error("Error fetching ACL mode:",e),n(9,ee="")}}async function Ue(e=[]){if("none"===ee||u)if("none"===ee||0!==e.length||"admin"===a||"owner"===a)try{const t={"Content-Type":"application/json"};"none"!==ee&&u&&(t.Authorization=await Oe("/api/export","POST"));const n=await fetch("/api/export",{method:"POST",headers:t,body:JSON.stringify({pubkeys:e})});if(!n.ok)throw new Error(`Export failed: ${n.status} ${n.statusText}`);const r=await n.blob(),i=window.URL.createObjectURL(r),o=document.createElement("a");o.href=i;const s=n.headers.get("Content-Disposition");let a="events.jsonl";if(s){const e=s.match(/filename="([^"]+)"/);e&&(a=e[1])}o.download=a,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(i)}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 Te(e=!1,t=null){if(!u||"read"!==p&&"write"!==p&&"admin"!==p&&"owner"!==p)alert("Read, write, admin, or owner permission required");else if(!S){n(7,S=!0),e&&(Q=null);try{console.log("Loading events with authors filter:",t,"including delete events");const r=e?Math.floor(Date.now()/1e3):Q,i=A.authors||t,o=await async function(e={}){const{limit:t=100,since:n=null,until:r=null,authors:i=null,kinds:o=null,...s}=e,a=[{...s}];return n&&(a[0].since=n),r&&(a[0].until=r),i&&(a[0].authors=i),o&&(a[0].kinds=o),t&&(a[0].limit=t),await _h(a,{timeout:3e4})}({...A,limit:e?100:200,until:A.until||r,authors:i});if(console.log("Received events:",o.length,"events"),t&&o.length>0){const e=o.filter(e=>e.pubkey&&e.pubkey!==d);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",o.length)}if(e?(n(97,I=o.sort((e,t)=>t.created_at-e.created_at)),ye(o)):(n(97,I=[...I,...o].sort((e,t)=>t.created_at-e.created_at)),ye(I)),o.length>0){const e=Math.min(...o.map(e=>e.created_at));(!Q||e<Q)&&(Q=e)}F=o.length===(e?1e3:200),e&&F&&setTimeout(()=>{if("events"===w){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Ne()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,S=!1)}}}async function Ne(){await Te(!1)}let Le=!1;async function Oe(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(g&&"extension"===f)try{r=await g.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 i=JSON.stringify(r);return`Nostr ${btoa(i)}`}async function Me(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(g&&"extension"===f)try{r=await g.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 i=JSON.stringify(r);return btoa(i)}function _e(e,t){const n=e.toLowerCase();if(n.includes("policy")||n.includes("blocked")||n.includes("denied")){let n=`Policy Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} may be restricted by the relay's policy configuration.`),V&&(n+="\n\nThe relay has policy enforcement enabled. Contact a relay administrator to allow this event kind or adjust your permissions."),n}if(n.includes("auth")||n.includes("permission")||n.includes("unauthorized"))return`Permission Error: ${e}\n\nYour current permissions may not allow publishing this type of event. Current role: ${p||"unknown"}. Contact a relay administrator to upgrade your permissions.`;if(n.includes("kind")||n.includes("not allowed")||n.includes("restricted")){let n=`Event Type Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} is not currently allowed on this relay.`),n+="\n\nThe relay administrator may need to update the policy configuration to allow this event kind.",n}return n.includes("rate")||n.includes("limit")||n.includes("too many")?`Rate Limit Error: ${e}\n\nPlease wait a moment before trying again.`:n.includes("size")||n.includes("too large")||n.includes("content")?`Size Limit Error: ${e}\n\nThe event may exceed the relay's size limits. Try reducing the content length.`:`Publishing failed: ${e}`}function He(e){n(98,D=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",a)}D=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(6&e.$$.dirty[0]|16&e.$$.dirty[3]&&n(42,r=I.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(41,i=h?.about?(t=h.about,t?t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):"").replace(/\n{2,}/g,"<br>"):""),16&e.$$.dirty[0]|32&e.$$.dirty[3]&&n(10,a=D&&""!==D?D:p),1810&e.$$.dirty[0]|96&e.$$.dirty[3]&&n(101,o=Ce.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&&!q)&&(!("policy"===e.id&&!V)&&(("managed-acl"!==e.id||"managed"===ee)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:u,userRole:p,viewAsRole:D,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0))))))})),64&e.$$.dirty[0]|256&e.$$.dirty[3]&&n(11,s=[...o,...k]),2578&e.$$.dirty[0]|256&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:u,userRole:p,aclMode:ee,filteredBaseTabs:o.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&&Re(),182&e.$$.dirty[0]|144&e.$$.dirty[3]&&"events"===w&&u&&("read"===p||"write"===p||"admin"===p||"owner"===p)&&0===I.length&&!Le&&!S){n(100,Le=!0);Te(!0,null)}32&e.$$.dirty[0]|16&e.$$.dirty[3]&&("events"!==w||"events"===w&&I.length>0)&&n(100,Le=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",w)},[l,u,d,h,p,w,k,S,V,ee,a,s,c,g,m,y,v,E,C,B,O,M,_,H,j,G,K,J,Y,z,W,Z,X,te,ne,re,ie,oe,se,ae,le,i,r,R,ue,de,async function(){console.log("Toggle changed, showOnlyMyEvents:",DE),n(100,Le=!1),await Te(!0,null)},fe,he,pe,ge,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",ie),null!=ie?(n(37,oe=""),n(38,se=[]),ce=null,n(40,le=!0),he()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",oe);const e=parseInt(oe);""!==oe&&!isNaN(e)&&e>=0&&(n(36,ie=null),n(38,se=[]),ce=null,n(40,le=!0),he())},function(e){const t=se.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(23,H=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(20,O=t.script_content||""),n(21,M=t),ke("Script loaded successfully","success")}else ke("Failed to load script","error")}catch(e){ke(`Error loading script: ${e.message}`,"error")}finally{n(23,H=!1)}},async function(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:O});if(e.ok)ke("Script saved and updated successfully","success"),await we(),await ve();else{ke(`Failed to save script: ${await e.text()}`,"error")}}catch(e){ke(`Error saving script: ${e.message}`,"error")}finally{n(23,H=!1)}},async function(){if(u&&"owner"===p)try{n(23,H=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)ke("Sprocket restarted successfully","success"),await we();else{ke(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){ke(`Error restarting sprocket: ${e.message}`,"error")}finally{n(23,H=!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(23,H=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(20,O=""),ke("Sprocket script deleted successfully","success"),await we(),await ve();else{ke(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){ke(`Error deleting script: ${e.message}`,"error")}finally{n(23,H=!1)}},ve,Ae,be,async function(){if(u&&("owner"===p||RE))try{n(28,Y=!0),n(31,Z=[]);const e={kinds:[12345],limit:1},t=await qh(e);if(t&&t.length>0){n(27,J=t[0].content);try{n(27,J=JSON.stringify(JSON.parse(J),null,2))}catch(e){}Ie("Policy loaded successfully","success")}else{const e=await fetch("/api/policy",{method:"GET",headers:{Authorization:`Nostr ${await Me("GET","/api/policy")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(27,J=JSON.stringify(t,null,2)),Ie("Policy loaded from file","success")}else Ie("No policy configuration found","info"),n(27,J="")}}catch(e){Ie(`Error loading policy: ${e.message}`,"error")}finally{n(28,Y=!1)}},Ee,async function(){if(!u||"owner"!==p&&!RE)return;if(await Ee())try{n(28,Y=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:J},t=await DI(e,g);t.success?Ie("Policy updated successfully","success"):Ie(`Failed to publish policy: ${t.error||"Unknown error"}`,"error")}catch(e){Ie(`Error saving policy: ${e.message}`,"error")}finally{n(28,Y=!1)}},function(){try{const e=JSON.parse(J);n(27,J=JSON.stringify(e,null,2)),Ie("JSON formatted","success")}catch(e){Ie(`Cannot format: ${e.message}`,"error")}},function(e){const t=e.detail;if(!t)return void Ie("Please enter a pubkey","error");const r=function(e){if(!e)return null;if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(e.startsWith("npub1"))try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(5);let r=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");r.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}r=r.slice(0,-30);const i=[];for(let e=0;e+8<=r.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|r[e+n];i.push(t)}return i.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(r&&64===r.length)try{const e=JSON.parse(J||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(r))return void Ie("Admin already in list","warning");e.policy_admins.push(r),n(27,J=JSON.stringify(e,null,2)),Ie("Admin added - click 'Save & Publish' to apply","info")}catch(e){Ie(`Error adding admin: ${e.message}`,"error")}else Ie("Invalid pubkey format. Use hex (64 chars) or npub","error")},function(e){const t=e.detail;try{const e=JSON.parse(J||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(27,J=JSON.stringify(e,null,2)),Ie("Admin removed - click 'Save & Publish' to apply","info"))}catch(e){Ie(`Error removing admin: ${e.message}`,"error")}},async function(){if(u&&("owner"===p||RE))try{n(28,Y=!0),n(32,X=[]);let e=[];try{e=JSON.parse(J||"{}").policy_admins||[]}catch(e){return void Ie("Cannot parse policy JSON to get admins","error")}if(0===e.length)return void Ie("No policy admins configured","warning");const t={kinds:[3],authors:e,limit:e.length},r=await qh(t),i=new Set;for(const e of r)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&i.add(t[1]);n(32,X=Array.from(i)),Ie(`Loaded ${X.length} follows from ${r.length} admin(s)`,"success")}catch(e){Ie(`Error loading follows: ${e.message}`,"error")}finally{n(28,Y=!1)}},function(e){n(26,K=e.target.files[0])},async function(){if(u&&"owner"===p&&K)try{n(23,H=!0);const e=await K.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Me("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(20,O=e),ke("Script uploaded and updated successfully","success"),await we(),await ve();else{ke(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){ke(`Error uploading script: ${e.message}`,"error")}finally{n(23,H=!1),n(26,K=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},xe,function(){u||n(12,c=!0)},async function(e){const{method:t,pubkey:r,privateKey:i,signer:o}=e.detail;n(1,u=!0),n(2,d=r),f=t,n(13,g=o),n(12,c=!1),n(14,m="nsec"===t&&i?i:null);try{if(await Gh(),"extension"===t&&o)Qh.setSigner(o);else if("nsec"===t&&i){const e=new xf(i);Qh.setSigner(e)}n(3,h=await Oh(r)),console.log("Profile loaded:",h)}catch(e){console.error("Failed to load profile:",e)}await Pe(),await $e()},function(){n(1,u=!1),n(2,d=""),f="",n(3,h=null),n(4,p=""),n(13,g=null),n(14,m=null),n(15,y=!1),T=[],n(97,I=[]),P=[],U=0,me(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(12,c=!1)},function(){n(15,y=!0)},Be,function(){n(16,v=!v)},function(e){const{searchText:t,selectedKinds:n,pubkeys:r,eventIds:i,tags:o,sinceTimestamp:s,untilTimestamp:a,limit:l}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:r=[],tags:i=[],since:o=null,until:s=null,limit:a=null}){const l={};return e&&e.trim()&&(l.search=e.trim()),t&&t.length>0&&(l.kinds=t),n&&n.length>0&&(l.authors=n),r&&r.length>0&&(l.ids=r),i&&i.length>0&&i.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;l[t]||(l[t]=[]),l[t].push(e.value)}}),o&&(l.since=o),s&&(l.until=s),a&&a>0&&(l.limit=a),l}({searchText:t,kinds:n,authors:r,ids:i,tags:o,since:s,until:a,limit:l||100});A=c,Te(!0,null)},function(){A={},Te(!0,null)},Se,Fe,Qe,De,Re,async function(){await Ue([])},async function(){await Ue([d])},function(e){n(17,E=e.detail.target.files[0])},async function(){if("none"!==ee&&(!u||"admin"!==p&&"owner"!==p))return n(18,C="Admin or owner permission required"),void setTimeout(()=>{n(18,C="")},5e3);if(!E)return n(18,C="Please select a file"),void setTimeout(()=>{n(18,C="")},5e3);try{n(18,C="Uploading...");const e={};"none"!==ee&&u&&(e.Authorization=await Oe("/api/import","POST"));const t=new FormData;t.append("file",E);const r=await fetch("/api/import",{method:"POST",headers:e,body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();n(18,C="Upload complete"),n(17,E=null),document.getElementById("import-file").value="",setTimeout(()=>{n(18,C="")},5e3)}catch(e){console.error("Import failed:",e),n(18,C="Import failed: "+e.message),setTimeout(()=>{n(18,C="")},5e3)}},Te,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&Ne()},function(){try{if(!ne.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(ne);n(34,ne=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!ne.trim())return void alert("Please enter an event to sign");if(!u||!d)return void alert("Please log in to sign events");if(!g)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(ne);e.pubkey=d,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await g.signEvent(e);n(34,ne=JSON.stringify(t,null,2)),alert("Event signed successfully!")}catch(e){console.error("Error signing event:",e),alert("Error signing event: "+e.message)}},async function(){n(35,re="");try{if(!ne.trim())return void n(35,re="Please enter an event to publish");if(!u)return void n(35,re="Please log in to publish events");if(!g)return void n(35,re="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(ne)}catch(e){return void n(35,re=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(35,re='Event must be signed before publishing. Please click "Sign" first.');if("read"===p)return void n(35,re=`Permission denied: Your current role is "${p}" which does not allow publishing events. Contact a relay administrator to upgrade your permissions.`);const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=await DI(t,e,g,d);if(r.success)n(35,re=""),alert("Event published successfully to ORLY relay!");else{const t=r.reason||"Unknown error";n(35,re=_e(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(35,re=_e(t,null))}},function(){n(35,re="")},He,function(){const e=["owner","admin","write","read"],t=e.indexOf(p);return-1===t?["read"]:e.slice(t)},I,D,q,Le,o,function(t){$.call(this,e,t)},function(t){$.call(this,e,t)},e=>e.id===w,e=>xe(e.detail),e=>Fe(e.detail),e=>ue(e.detail),e=>fe(e.detail),e=>de(e.detail.event,e.detail.e),e=>Te(e.detail.refresh,e.detail.authors),function(e){ne=e,n(34,ne)},function(e){O=e,n(20,O)},e=>Ae(e.detail),e=>be(e.detail),function(e){J=e,n(27,J)},function(){ie=x(this),n(36,ie)},function(){oe=b(this.value),n(37,oe)},e=>ge(e),e=>pe(e),(e,t)=>de(e,t),e=>Qe(e.id,!0),e=>Se(e.id),e=>fe(e.id),e=>ue(e.id),(e,t)=>"Enter"===t.key&&ue(e.id),(e,t)=>de(e,t),(e,t)=>De(t,e.id),e=>He(e===p?"":e),e=>"Escape"===e.key&&Be(),function(e){c=e,n(12,c)}]}return new class extends ae{constructor(e){super(),se(this,e,PE,QE,o,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); |