diff --git a/POLICY_BUG_FIX_SUMMARY.md b/POLICY_BUG_FIX_SUMMARY.md new file mode 100644 index 0000000..85ba0cf --- /dev/null +++ b/POLICY_BUG_FIX_SUMMARY.md @@ -0,0 +1,234 @@ +# Policy System Bug Fix Summary + +## Bug Report +**Issue:** Kind 1 events were being accepted even though the policy whitelist only contained kind 4678. + +## Root Cause Analysis + +The relay had **TWO critical bugs** in the policy system that worked together to create a security vulnerability: + +### Bug #1: Hardcoded `return true` in `checkKindsPolicy()` +**Location:** [`pkg/policy/policy.go:1010`](pkg/policy/policy.go#L1010) + +```go +// BEFORE (BUG): +// No specific rules (maybe global rule exists) - allow all kinds +return true + +// AFTER (FIXED): +// No specific rules (maybe global rule exists) - fall back to default policy +return p.getDefaultPolicyAction() +``` + +**Problem:** When no whitelist, blacklist, or rules were present, the function returned `true` unconditionally, ignoring the `default_policy` configuration. + +**Impact:** Empty policy configurations would allow ALL event kinds. + +--- + +### Bug #2: Silent Failure on Config Load Error +**Location:** [`pkg/policy/policy.go:363-378`](pkg/policy/policy.go#L363-L378) + +```go +// BEFORE (BUG): +if err := policy.LoadFromFile(configPath); err != nil { + log.W.F("failed to load policy configuration from %s: %v", configPath, err) + log.I.F("using default policy configuration") +} + +// AFTER (FIXED): +if err := policy.LoadFromFile(configPath); err != nil { + log.E.F("FATAL: Policy system is ENABLED (ORLY_POLICY_ENABLED=true) but configuration failed to load from %s: %v", configPath, err) + log.E.F("The relay cannot start with an invalid policy configuration.") + log.E.F("Fix: Either disable the policy system (ORLY_POLICY_ENABLED=false) or ensure %s exists and contains valid JSON", configPath) + panic(fmt.Sprintf("fatal policy configuration error: %v", err)) +} +``` + +**Problem:** When policy was enabled but `policy.json` failed to load: +- Only logged a WARNING (not fatal) +- Continued with empty policy object (no whitelist, no rules) +- Empty policy + Bug #1 = allowed ALL events +- Relay appeared to be "protected" but was actually wide open + +**Impact:** **Critical security vulnerability** - misconfigured policy files would silently allow all events. + +--- + +## Combined Effect + +When a relay operator: +1. Enabled policy system (`ORLY_POLICY_ENABLED=true`) +2. Had a missing, malformed, or inaccessible `policy.json` file + +The relay would: +- ❌ Log "policy allowed event" (appearing to work) +- ❌ Have empty whitelist/rules (silent failure) +- ❌ Fall through to hardcoded `return true` (Bug #1) +- ✅ **Allow ALL event kinds** (complete bypass) + +--- + +## Fixes Applied + +### Fix #1: Respect `default_policy` Setting +Changed `checkKindsPolicy()` to return `p.getDefaultPolicyAction()` instead of hardcoded `true`. + +**Result:** When no whitelist/rules exist, the policy respects the `default_policy` configuration (either "allow" or "deny"). + +### Fix #2: Fail-Fast on Config Error +Changed `NewWithManager()` to **panic immediately** if policy is enabled but config fails to load. + +**Result:** Relay refuses to start with invalid configuration, forcing operator to fix it. + +--- + +## Test Coverage + +### New Tests Added + +1. **`TestBugFix_FailSafeWhenConfigMissing`** - Verifies panic on missing config +2. **`TestBugFix_EmptyWhitelistRespectsDefaultPolicy`** - Tests both deny and allow defaults +3. **`TestBugReproduction_*`** - Reproduces the exact scenario from the bug report + +### Existing Tests Updated + +- **`TestNewWithManager`** - Now handles both enabled and disabled policy scenarios +- All existing whitelist tests continue to pass ✅ + +--- + +## Behavior Changes + +### Before Fix +``` +Policy System: ENABLED ✅ +Config File: MISSING ❌ +Logs: "failed to load policy configuration" (warning) +Result: Allow ALL events 🚨 + +Policy System: ENABLED ✅ +Config File: { "whitelist": [4678] } ✅ +Logs: "policy allowed event" for kind 1 +Result: Allow kind 1 event 🚨 +``` + +### After Fix +``` +Policy System: ENABLED ✅ +Config File: MISSING ❌ +Result: PANIC - relay refuses to start 🛑 + +Policy System: ENABLED ✅ +Config File: { "whitelist": [4678] } ✅ +Logs: "policy rejected event" for kind 1 +Result: Reject kind 1 event ✅ +``` + +--- + +## Migration Guide for Operators + +### If Your Relay Panics After Upgrade + +**Error Message:** +``` +FATAL: Policy system is ENABLED (ORLY_POLICY_ENABLED=true) but configuration failed to load +panic: fatal policy configuration error: policy configuration file does not exist +``` + +**Resolution Options:** + +1. **Create valid `policy.json`:** + ```bash + mkdir -p ~/.config/ORLY + cat > ~/.config/ORLY/policy.json << 'EOF' + { + "default_policy": "allow", + "kind": { + "whitelist": [1, 3, 4, 5, 6, 7] + }, + "rules": {} + } + EOF + ``` + +2. **Disable policy system (temporary):** + ```bash + # In your systemd service file: + Environment="ORLY_POLICY_ENABLED=false" + + sudo systemctl daemon-reload + sudo systemctl restart orly + ``` + +--- + +## Security Impact + +**Severity:** 🔴 **CRITICAL** + +**CVE-Like Description:** +> When `ORLY_POLICY_ENABLED=true` is set but the policy configuration file fails to load (missing file, permission error, or malformed JSON), the relay silently bypasses all policy checks and allows events of any kind, defeating the intended access control mechanism. + +**Affected Versions:** All versions prior to this fix + +**Fixed Versions:** Current HEAD after commit [TBD] + +**CVSS-like:** Configuration-dependent vulnerability requiring operator misconfiguration + +--- + +## Verification + +To verify the fix is working: + +1. **Test with valid config:** + ```bash + # Should start normally + ORLY_POLICY_ENABLED=true ./orly + # Logs: "loaded policy configuration from ~/.config/ORLY/policy.json" + ``` + +2. **Test with missing config:** + ```bash + # Should panic immediately + mv ~/.config/ORLY/policy.json ~/.config/ORLY/policy.json.bak + ORLY_POLICY_ENABLED=true ./orly + # Expected: FATAL error and panic + ``` + +3. **Test whitelist enforcement:** + ```bash + # Create whitelist with only kind 4678 + echo '{"kind":{"whitelist":[4678]},"rules":{}}' > ~/.config/ORLY/policy.json + + # Try to send kind 1 event + # Expected: "policy rejected event" or "event blocked by policy" + ``` + +--- + +## Files Modified + +- [`pkg/policy/policy.go`](pkg/policy/policy.go) - Core fixes +- [`pkg/policy/bug_reproduction_test.go`](pkg/policy/bug_reproduction_test.go) - New test file +- [`pkg/policy/policy_test.go`](pkg/policy/policy_test.go) - Updated existing tests + +--- + +## Related Documentation + +- [Policy Usage Guide](docs/POLICY_USAGE_GUIDE.md) +- [Policy Troubleshooting](docs/POLICY_TROUBLESHOOTING.md) +- [CLAUDE.md](CLAUDE.md) - Build and configuration instructions + +--- + +## Credits + +**Bug Reported By:** User via client relay (relay1.zenotp.app) + +**Root Cause Analysis:** Deep investigation of policy evaluation flow + +**Fix Verified:** All tests passing, including reproduction of original bug scenario diff --git a/app/config/config.go b/app/config/config.go index eeeaf00..1033e51 100644 --- a/app/config/config.go +++ b/app/config/config.go @@ -88,6 +88,11 @@ type C struct { // Branding/white-label settings BrandingDir string `env:"ORLY_BRANDING_DIR" usage:"directory containing branding assets and configuration (default: ~/.config/ORLY/branding)"` BrandingEnabled bool `env:"ORLY_BRANDING_ENABLED" default:"true" usage:"enable custom branding if branding directory exists"` + Theme string `env:"ORLY_THEME" default:"auto" usage:"UI color theme: auto (follow system), light, dark"` + + // CORS settings (for standalone dashboard mode) + CORSEnabled bool `env:"ORLY_CORS_ENABLED" default:"false" usage:"enable CORS headers for API endpoints (required for standalone dashboard)"` + CORSOrigins []string `env:"ORLY_CORS_ORIGINS" usage:"allowed CORS origins (comma-separated, or * for all origins)"` // Sprocket settings SprocketEnabled bool `env:"ORLY_SPROCKET_ENABLED" default:"false" usage:"enable sprocket event processing plugin system"` diff --git a/app/handle-relayinfo.go b/app/handle-relayinfo.go index 84b99ce..2e7abc7 100644 --- a/app/handle-relayinfo.go +++ b/app/handle-relayinfo.go @@ -29,6 +29,7 @@ type ExtendedRelayInfo struct { *relayinfo.T Addresses []string `json:"addresses,omitempty"` GraphQuery *GraphQueryConfig `json:"graph_query,omitempty"` + Theme string `json:"theme,omitempty"` } // HandleRelayInfo generates and returns a relay information document in JSON @@ -203,12 +204,17 @@ func (s *Server) HandleRelayInfo(w http.ResponseWriter, r *http.Request) { } } - // Return extended info if we have addresses or graph query support, otherwise standard info - if len(addresses) > 0 || graphConfig != nil { + // Return extended info if we have addresses, graph query support, or custom theme + theme := s.Config.Theme + if theme != "auto" && theme != "light" && theme != "dark" { + theme = "auto" + } + if len(addresses) > 0 || graphConfig != nil || theme != "auto" { extInfo := &ExtendedRelayInfo{ T: info, Addresses: addresses, GraphQuery: graphConfig, + Theme: theme, } if err := json.NewEncoder(w).Encode(extInfo); chk.E(err) { } diff --git a/app/server.go b/app/server.go index def6f67..35795a8 100644 --- a/app/server.go +++ b/app/server.go @@ -141,6 +141,32 @@ func (s *Server) isIPBlacklisted(remote string) bool { return false } +// isAllowedCORSOrigin checks if the given origin is allowed for CORS requests. +// Returns true if: +// - CORSOrigins contains "*" (allow all) +// - CORSOrigins is empty (allow all when CORS is enabled) +// - The origin matches one of the configured origins +func (s *Server) isAllowedCORSOrigin(origin string) bool { + if origin == "" { + return false + } + + // If no specific origins configured, allow all + if len(s.Config.CORSOrigins) == 0 { + return true + } + + for _, allowed := range s.Config.CORSOrigins { + if allowed == "*" { + return true + } + if allowed == origin { + return true + } + } + return false +} + func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Check if this is a blossom-related path (needs CORS headers) path := r.URL.Path @@ -163,8 +189,31 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) return } - } else if r.Method == "OPTIONS" { - // Handle OPTIONS for non-blossom paths + } + + // Set CORS headers for API endpoints when enabled (for standalone dashboard mode) + // Also allow root path for NIP-11 relay info requests + isAPIPath := strings.HasPrefix(path, "/api/") + isRelayInfoRequest := path == "/" && r.Header.Get("Accept") == "application/nostr+json" + if s.Config != nil && s.Config.CORSEnabled && (isAPIPath || isRelayInfoRequest) { + origin := r.Header.Get("Origin") + if s.isAllowedCORSOrigin(origin) { + w.Header().Set("Access-Control-Allow-Origin", origin) + w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") + w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Type, Accept") + w.Header().Set("Access-Control-Allow-Credentials", "true") + w.Header().Set("Access-Control-Max-Age", "86400") + } + + // Handle preflight OPTIONS requests for API paths + if r.Method == "OPTIONS" { + w.WriteHeader(http.StatusOK) + return + } + } + + if r.Method == "OPTIONS" && !isBlossomPath && !isAPIPath { + // Handle OPTIONS for other paths if s.mux != nil { s.mux.ServeHTTP(w, r) return diff --git a/app/web/bun.lock b/app/web/bun.lock index 3b55731..46f2a2d 100644 --- a/app/web/bun.lock +++ b/app/web/bun.lock @@ -17,6 +17,7 @@ "devDependencies": { "@rollup/plugin-commonjs": "^24.0.0", "@rollup/plugin-node-resolve": "^15.0.0", + "@rollup/plugin-replace": "^5.0.0", "@rollup/plugin-terser": "^0.4.0", "rollup": "^3.15.0", "rollup-plugin-copy": "^3.5.0", @@ -58,6 +59,8 @@ "@rollup/plugin-node-resolve": ["@rollup/plugin-node-resolve@15.3.1", "", { "dependencies": { "@rollup/pluginutils": "^5.0.1", "@types/resolve": "1.20.2", "deepmerge": "^4.2.2", "is-module": "^1.0.0", "resolve": "^1.22.1" }, "peerDependencies": { "rollup": "^2.78.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-tgg6b91pAybXHJQMAAwW9VuWBO6Thi+q7BCNARLwSqlmsHz0XYURtGvh/AuwSADXSI4h/2uHbs7s4FzlZDGSGA=="], + "@rollup/plugin-replace": ["@rollup/plugin-replace@5.0.7", "", { "dependencies": { "@rollup/pluginutils": "^5.0.1", "magic-string": "^0.30.3" }, "peerDependencies": { "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-PqxSfuorkHz/SPpyngLyg5GCEkOcee9M1bkxiVDr41Pd61mqP1PLOoDPbpl44SB2mQGKwV/In74gqQmGITOhEQ=="], + "@rollup/plugin-terser": ["@rollup/plugin-terser@0.4.4", "", { "dependencies": { "serialize-javascript": "^6.0.1", "smob": "^1.0.0", "terser": "^5.17.4" }, "peerDependencies": { "rollup": "^2.0.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A=="], "@rollup/pluginutils": ["@rollup/pluginutils@5.3.0", "", { "dependencies": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", "picomatch": "^4.0.2" }, "peerDependencies": { "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q=="], @@ -346,6 +349,8 @@ "yargs-parser": ["yargs-parser@18.1.3", "", { "dependencies": { "camelcase": "^5.0.0", "decamelize": "^1.2.0" } }, "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ=="], + "@rollup/plugin-replace/magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="], + "@scure/bip32/@noble/curves": ["@noble/curves@1.1.0", "", { "dependencies": { "@noble/hashes": "1.3.1" } }, "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA=="], "@scure/bip32/@noble/hashes": ["@noble/hashes@1.3.2", "", {}, "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ=="], diff --git a/app/web/dist/bundle.css b/app/web/dist/bundle.css index 0f431f5..4448fd2 100644 --- a/app/web/dist/bundle.css +++ b/app/web/dist/bundle.css @@ -1,13 +1,13 @@ .modal-overlay.svelte-4xpfbi.svelte-4xpfbi{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;z-index:1000}.modal.svelte-4xpfbi.svelte-4xpfbi{background:var(--bg-color);border-radius:8px;box-shadow:0 4px 20px rgba(0, 0, 0, 0.3);width:90%;max-width:500px;max-height:90vh;overflow-y:auto;border:1px solid var(--border-color)}.modal-header.svelte-4xpfbi.svelte-4xpfbi{display:flex;justify-content:space-between;align-items:center;padding:20px;border-bottom:1px solid var(--border-color)}.modal-header.svelte-4xpfbi h2.svelte-4xpfbi{margin:0;color:var(--text-color);font-size:1.5rem}.close-btn.svelte-4xpfbi.svelte-4xpfbi{background:none;border:none;font-size:1.5rem;cursor:pointer;color:var(--text-color);padding:0;width:30px;height:30px;display:flex;align-items:center;justify-content:center;border-radius:50%;transition:background-color 0.2s}.close-btn.svelte-4xpfbi.svelte-4xpfbi:hover{background-color:var(--tab-hover-bg)}.tab-container.svelte-4xpfbi.svelte-4xpfbi{padding:20px}.tabs.svelte-4xpfbi.svelte-4xpfbi{display:flex;border-bottom:1px solid var(--border-color);margin-bottom:20px}.tab-btn.svelte-4xpfbi.svelte-4xpfbi{flex:1;padding:12px 16px;background:none;border:none;cursor:pointer;color:var(--text-color);font-size:1rem;transition:all 0.2s;border-bottom:2px solid transparent}.tab-btn.svelte-4xpfbi.svelte-4xpfbi:hover{background-color:var(--tab-hover-bg)}.tab-btn.active.svelte-4xpfbi.svelte-4xpfbi{border-bottom-color:var(--primary);color:var(--primary)}.tab-content.svelte-4xpfbi.svelte-4xpfbi{min-height:200px}.extension-login.svelte-4xpfbi.svelte-4xpfbi,.nsec-login.svelte-4xpfbi.svelte-4xpfbi{display:flex;flex-direction:column;gap:16px}.extension-login.svelte-4xpfbi p.svelte-4xpfbi,.nsec-login.svelte-4xpfbi p.svelte-4xpfbi{margin:0;color:var(--text-color);line-height:1.5}.login-extension-btn.svelte-4xpfbi.svelte-4xpfbi,.login-nsec-btn.svelte-4xpfbi.svelte-4xpfbi{padding:12px 24px;background:var(--primary);color:var(--text-color);border:none;border-radius:6px;cursor:pointer;font-size:1rem;transition:background-color 0.2s}.login-extension-btn.svelte-4xpfbi.svelte-4xpfbi:hover:not(:disabled),.login-nsec-btn.svelte-4xpfbi.svelte-4xpfbi:hover:not(:disabled){background:#00acc1}.login-extension-btn.svelte-4xpfbi.svelte-4xpfbi:disabled,.login-nsec-btn.svelte-4xpfbi.svelte-4xpfbi:disabled{background:#ccc;cursor:not-allowed}.nsec-input.svelte-4xpfbi.svelte-4xpfbi{padding:12px;border:1px solid var(--input-border);border-radius:6px;font-size:1rem;background:var(--bg-color);color:var(--text-color)}.nsec-input.svelte-4xpfbi.svelte-4xpfbi:focus{outline:none;border-color:var(--primary)}.generate-btn.svelte-4xpfbi.svelte-4xpfbi{padding:10px 20px;background:var(--success, #4caf50);color:white;border:none;border-radius:6px;cursor:pointer;font-size:0.95rem;transition:background-color 0.2s}.generate-btn.svelte-4xpfbi.svelte-4xpfbi:hover:not(:disabled){background:#45a049}.generate-btn.svelte-4xpfbi.svelte-4xpfbi:disabled{background:#ccc;cursor:not-allowed}.generated-info.svelte-4xpfbi.svelte-4xpfbi{background:var(--card-bg, #f5f5f5);padding:12px;border-radius:6px;border:1px solid var(--border-color)}.generated-info.svelte-4xpfbi label.svelte-4xpfbi{display:block;font-size:0.85rem;color:var(--muted-foreground, #666);margin-bottom:6px}.npub-display.svelte-4xpfbi.svelte-4xpfbi{display:block;word-break:break-all;font-size:0.85rem;background:var(--bg-color);padding:8px;border-radius:4px;color:var(--text-color)}.password-section.svelte-4xpfbi.svelte-4xpfbi{display:flex;flex-direction:column;gap:8px}.password-section.svelte-4xpfbi label.svelte-4xpfbi{font-size:0.9rem;color:var(--text-color);font-weight:500}.password-input.svelte-4xpfbi.svelte-4xpfbi{padding:10px 12px;border:1px solid var(--input-border);border-radius:6px;font-size:0.95rem;background:var(--bg-color);color:var(--text-color)}.password-input.svelte-4xpfbi.svelte-4xpfbi:focus{outline:none;border-color:var(--primary)}.password-hint.svelte-4xpfbi.svelte-4xpfbi{font-size:0.8rem;color:var(--muted-foreground, #888);font-style:italic}.stored-info.svelte-4xpfbi.svelte-4xpfbi{background:var(--card-bg, #f5f5f5);padding:12px;border-radius:6px;border:1px solid var(--border-color)}.stored-info.svelte-4xpfbi label.svelte-4xpfbi{display:block;font-size:0.85rem;color:var(--muted-foreground, #666);margin-bottom:6px}.clear-btn.svelte-4xpfbi.svelte-4xpfbi{padding:10px 20px;background:transparent;color:var(--error, #dc3545);border:1px solid var(--error, #dc3545);border-radius:6px;cursor:pointer;font-size:0.9rem;transition:all 0.2s}.clear-btn.svelte-4xpfbi.svelte-4xpfbi:hover:not(:disabled){background:var(--error, #dc3545);color:white}.clear-btn.svelte-4xpfbi.svelte-4xpfbi:disabled{opacity:0.5;cursor:not-allowed}.message.svelte-4xpfbi.svelte-4xpfbi{padding:10px;border-radius:4px;margin-top:16px;text-align:center}.error-message.svelte-4xpfbi.svelte-4xpfbi{background:#ffebee;color:#c62828;border:1px solid #ffcdd2}.success-message.svelte-4xpfbi.svelte-4xpfbi{background:#e8f5e8;color:#2e7d32;border:1px solid #c8e6c9}.modal.dark-theme.svelte-4xpfbi .error-message.svelte-4xpfbi{background:#4a2c2a;color:#ffcdd2;border:1px solid #6d4c41}.modal.dark-theme.svelte-4xpfbi .success-message.svelte-4xpfbi{background:#2e4a2e;color:#a5d6a7;border:1px solid #4caf50}.deriving-overlay.svelte-4xpfbi.svelte-4xpfbi{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.7);display:flex;justify-content:center;align-items:center;z-index:2000}.deriving-modal.svelte-4xpfbi.svelte-4xpfbi{background:var(--bg-color, #fff);border-radius:12px;padding:2rem;text-align:center;box-shadow:0 8px 32px rgba(0, 0, 0, 0.3);min-width:280px}.deriving-modal.svelte-4xpfbi h3.svelte-4xpfbi{margin:1rem 0 0.5rem;color:var(--text-color, #333);font-size:1.2rem}.deriving-timer.svelte-4xpfbi.svelte-4xpfbi{font-size:2.5rem;font-weight:bold;color:var(--primary, #00bcd4);font-family:monospace;margin:0.5rem 0}.deriving-note.svelte-4xpfbi.svelte-4xpfbi{margin:0.5rem 0 0;color:var(--muted-foreground, #666);font-size:0.9rem}.deriving-spinner.svelte-4xpfbi.svelte-4xpfbi{width:48px;height:48px;border:4px solid var(--border-color, #e0e0e0);border-top-color:var(--primary, #00bcd4);border-radius:50%;margin:0 auto;animation:svelte-4xpfbi-spin 1s linear infinite}@keyframes svelte-4xpfbi-spin{to{transform:rotate(360deg)}}.deriving-modal.dark-theme.svelte-4xpfbi.svelte-4xpfbi{background:#1a1a1a}.deriving-modal.dark-theme.svelte-4xpfbi h3.svelte-4xpfbi{color:#fff}.deriving-modal.dark-theme.svelte-4xpfbi .deriving-note.svelte-4xpfbi{color:#aaa} .header.svelte-1y8wjwc.svelte-1y8wjwc{margin-bottom:30px}.header.svelte-1y8wjwc h2.svelte-1y8wjwc{margin:0 0 10px 0;color:var(--text-color)}.header.svelte-1y8wjwc p.svelte-1y8wjwc{margin:0;color:var(--text-color);opacity:0.8}.owner-only-notice.svelte-1y8wjwc.svelte-1y8wjwc{margin-top:10px;padding:8px 12px;background-color:var(--warning-bg);border:1px solid var(--warning);border-radius:4px;color:var(--text-color);font-size:0.9em}.message.svelte-1y8wjwc.svelte-1y8wjwc{padding:10px 15px;border-radius:4px;margin-bottom:20px}.message.success.svelte-1y8wjwc.svelte-1y8wjwc{background-color:var(--success-bg);color:var(--success-text);border:1px solid var(--success)}.message.error.svelte-1y8wjwc.svelte-1y8wjwc{background-color:var(--error-bg);color:var(--error-text);border:1px solid var(--danger)}.message.info.svelte-1y8wjwc.svelte-1y8wjwc{background-color:var(--primary-bg);color:var(--text-color);border:1px solid var(--info)}.tabs.svelte-1y8wjwc.svelte-1y8wjwc{display:flex;border-bottom:1px solid var(--border-color);margin-bottom:20px}.tab.svelte-1y8wjwc.svelte-1y8wjwc{padding:10px 20px;border:none;background:none;cursor:pointer;border-bottom:2px solid transparent;transition:all 0.2s;color:var(--text-color)}.tab.svelte-1y8wjwc.svelte-1y8wjwc:hover{background-color:var(--button-hover-bg)}.tab.active.svelte-1y8wjwc.svelte-1y8wjwc{border-bottom-color:var(--accent-color);color:var(--accent-color)}.tab-content.svelte-1y8wjwc.svelte-1y8wjwc{min-height:400px}.section.svelte-1y8wjwc.svelte-1y8wjwc{margin-bottom:30px}.section.svelte-1y8wjwc h3.svelte-1y8wjwc{margin:0 0 15px 0;color:var(--text-color)}.add-form.svelte-1y8wjwc.svelte-1y8wjwc{display:flex;gap:10px;margin-bottom:20px;flex-wrap:wrap}.add-form.svelte-1y8wjwc input.svelte-1y8wjwc{padding:8px 12px;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color);flex:1;min-width:200px}.add-form.svelte-1y8wjwc button.svelte-1y8wjwc{padding:8px 16px;background-color:var(--accent-color);color:var(--text-color);border:none;border-radius:4px;cursor:pointer}.add-form.svelte-1y8wjwc button.svelte-1y8wjwc:disabled{background-color:var(--secondary);cursor:not-allowed}.list.svelte-1y8wjwc.svelte-1y8wjwc{border:1px solid var(--border-color);border-radius:4px;max-height:300px;overflow-y:auto;background:var(--bg-color)}.list-item.svelte-1y8wjwc.svelte-1y8wjwc{padding:10px 15px;border-bottom:1px solid var(--border-color);display:flex;align-items:center;gap:15px;color:var(--text-color)}.list-item.svelte-1y8wjwc.svelte-1y8wjwc:last-child{border-bottom:none}.pubkey.svelte-1y8wjwc.svelte-1y8wjwc,.event-id.svelte-1y8wjwc.svelte-1y8wjwc,.ip.svelte-1y8wjwc.svelte-1y8wjwc,.kind.svelte-1y8wjwc.svelte-1y8wjwc{font-family:monospace;font-size:0.9em;color:var(--text-color)}.reason.svelte-1y8wjwc.svelte-1y8wjwc{color:var(--text-color);opacity:0.7;font-style:italic}.remove-btn.svelte-1y8wjwc.svelte-1y8wjwc{padding:4px 8px;background-color:var(--danger);color:var(--text-color);border:none;border-radius:3px;cursor:pointer;font-size:0.8em}.actions.svelte-1y8wjwc.svelte-1y8wjwc{display:flex;gap:5px;margin-left:auto}.actions.svelte-1y8wjwc button.svelte-1y8wjwc{padding:4px 8px;border:none;border-radius:3px;cursor:pointer;font-size:0.8em}.actions.svelte-1y8wjwc button.svelte-1y8wjwc:first-child{background-color:var(--success);color:var(--text-color)}.actions.svelte-1y8wjwc button.svelte-1y8wjwc:last-child{background-color:var(--danger);color:var(--text-color)}.config-form.svelte-1y8wjwc.svelte-1y8wjwc{display:flex;flex-direction:column;gap:20px}.form-group.svelte-1y8wjwc.svelte-1y8wjwc{display:flex;flex-direction:column;gap:10px}.form-group.svelte-1y8wjwc label.svelte-1y8wjwc{font-weight:bold;color:var(--text-color)}.form-group.svelte-1y8wjwc input.svelte-1y8wjwc,.form-group.svelte-1y8wjwc textarea.svelte-1y8wjwc{padding:8px 12px;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color)}.form-group.svelte-1y8wjwc textarea.svelte-1y8wjwc{min-height:80px;resize:vertical}.config-actions.svelte-1y8wjwc.svelte-1y8wjwc{margin-bottom:20px;padding:10px;background-color:var(--button-bg);border-radius:4px}.refresh-btn.svelte-1y8wjwc.svelte-1y8wjwc{padding:8px 16px;background-color:var(--success);color:var(--text-color);border:none;border-radius:4px;cursor:pointer;font-size:0.9em}.refresh-btn.svelte-1y8wjwc.svelte-1y8wjwc:hover:not(:disabled){background-color:var(--success);filter:brightness(0.9)}.refresh-btn.svelte-1y8wjwc.svelte-1y8wjwc:disabled{background-color:var(--secondary);cursor:not-allowed}.config-update-section.svelte-1y8wjwc.svelte-1y8wjwc{margin-top:20px;padding:15px;background-color:var(--button-bg);border-radius:6px;text-align:center}.update-all-btn.svelte-1y8wjwc.svelte-1y8wjwc{padding:12px 24px;background-color:var(--success);color:var(--text-color);border:none;border-radius:6px;cursor:pointer;font-size:1em;font-weight:600;min-width:200px}.update-all-btn.svelte-1y8wjwc.svelte-1y8wjwc:hover:not(:disabled){background-color:var(--success);filter:brightness(0.9);transform:translateY(-1px);box-shadow:0 2px 4px rgba(0, 0, 0, 0.1)}.update-all-btn.svelte-1y8wjwc.svelte-1y8wjwc:disabled{background-color:var(--secondary);cursor:not-allowed;transform:none;box-shadow:none}.no-items.svelte-1y8wjwc.svelte-1y8wjwc{padding:20px;text-align:center;color:var(--text-color);opacity:0.7;font-style:italic} -.main-header.svelte-1qkhxam{color:var(--text-color);position:fixed;top:0;left:0;right:0;height:3em;background:var(--header-bg);border:0;z-index:1000;display:flex;align-items:stretch;padding:0 0.25em}.header-content.svelte-1qkhxam{display:flex;align-items:stretch;width:100%;padding:0;margin:0}.logo.svelte-1qkhxam{height:2.5em;width:auto;flex-shrink:0;align-self:center}.header-title.svelte-1qkhxam{flex:1;display:flex;align-items:center;align-self:center}.app-title.svelte-1qkhxam{font-size:1.2em;font-weight:600;color:var(--text-color);display:flex;align-items:center;gap:0.5em}.permission-badge.svelte-1qkhxam{background:var(--primary);color:var(--text-color);padding:0.2em 0.5em;border-radius:0.5em;font-size:0.7em;font-weight:500;text-transform:uppercase;letter-spacing:0.5px}.header-buttons.svelte-1qkhxam{display:flex;align-items:stretch;align-self:stretch;margin-left:auto}.login-btn.svelte-1qkhxam,.user-profile-btn.svelte-1qkhxam{background:transparent;color:var(--button-text);border:0;cursor:pointer;font-size:1em;transition:background-color 0.2s;flex-shrink:0;padding:0.5em;margin:0;display:flex !important;align-items:center !important;justify-content:center}.login-btn.svelte-1qkhxam:hover,.user-profile-btn.svelte-1qkhxam:hover{background:var(--card-bg)}.user-profile-btn.svelte-1qkhxam{gap:0.5em;justify-content:flex-start;padding:0 0.5em}.user-avatar.svelte-1qkhxam{height:2.5em;width:2.5em;border-radius:50%;object-fit:cover;flex-shrink:0;align-self:center;vertical-align:middle}.user-avatar-placeholder.svelte-1qkhxam{height:2.5em;width:2.5em;border-radius:50%;background:var(--bg-color);display:flex;align-items:center;justify-content:center;font-size:1.2em;flex-shrink:0;align-self:center}.user-name.svelte-1qkhxam{font-weight:500;white-space:nowrap;line-height:1;align-self:center;max-width:none !important;overflow:visible !important;text-overflow:unset !important;width:auto !important} -.sidebar.svelte-wfmuj{position:fixed;left:0;top:3em;width:200px;bottom:0;background:var(--sidebar-bg);overflow-y:auto;z-index:100}.sidebar-content.svelte-wfmuj{padding:0;background:var(--sidebar-bg)}.tabs.svelte-wfmuj{display:flex;flex-direction:column;padding:0}.tab.svelte-wfmuj{display:flex;align-items:center;padding:0.75em;padding-left:1em;background:transparent;color:var(--text-color);border:none;cursor:pointer;transition:background-color 0.2s;gap:0.75rem;text-align:left;width:100%}.tab.svelte-wfmuj:hover{background-color:var(--bg-color)}.tab.active.svelte-wfmuj{background-color:var(--bg-color)}.tab-icon.svelte-wfmuj{font-size:1.2em;flex-shrink:0;width:1.5em;text-align:center}.tab-label.svelte-wfmuj{font-size:0.9em;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}.tab-close-icon.svelte-wfmuj{cursor:pointer;transition:opacity 0.2s;font-size:0.8em;margin-left:auto;padding:0.25rem;flex-shrink:0}.tab-close-icon.svelte-wfmuj:hover{opacity:0.7;background-color:var(--warning);color:var(--text-color)}@media(max-width: 1280px){.sidebar.svelte-wfmuj{width:60px}.tab-label.svelte-wfmuj{display:none}.tab-close-icon.svelte-wfmuj{display:none}.tab.svelte-wfmuj{justify-content:flex-start}}@media(max-width: 640px){.sidebar.svelte-wfmuj{width:160px}.tab-label.svelte-wfmuj{display:block}.tab.svelte-wfmuj{justify-content:flex-start}}.version-link.svelte-wfmuj{position:absolute;bottom:0;left:0;right:0;display:flex;align-items:center;gap:0.5rem;padding:0.75em 1em;color:var(--text-color);text-decoration:none;font-size:0.8em;transition:background-color 0.2s, color 0.2s;background:transparent}.version-link.svelte-wfmuj:hover{background-color:var(--bg-color)}.version-icon.svelte-wfmuj{width:1.2em;height:1.2em;flex-shrink:0;color:#4a9c5d}.version-text.svelte-wfmuj{white-space:nowrap}@media(max-width: 1280px){.version-text.svelte-wfmuj{display:none}.version-link.svelte-wfmuj{justify-content:flex-start;padding-left:1.25em}}@media(max-width: 640px){.version-text.svelte-wfmuj{display:inline}} +.main-header.svelte-e0nvq8.svelte-e0nvq8{color:var(--text-color);position:fixed;top:0;left:0;right:0;height:3em;background:var(--header-bg);border:0;z-index:1000;display:flex;align-items:stretch;padding:0 0.25em}.header-content.svelte-e0nvq8.svelte-e0nvq8{display:flex;align-items:stretch;width:100%;padding:0;margin:0}.mobile-menu-btn.svelte-e0nvq8.svelte-e0nvq8{display:none;align-items:center;justify-content:center;background:transparent;border:none;color:var(--text-color);cursor:pointer;padding:0.5em;margin-right:0.25em}.mobile-menu-btn.svelte-e0nvq8 svg.svelte-e0nvq8{width:1.5em;height:1.5em}.mobile-menu-btn.svelte-e0nvq8.svelte-e0nvq8:hover{background:var(--card-bg);border-radius:4px}@media(max-width: 640px){.mobile-menu-btn.svelte-e0nvq8.svelte-e0nvq8{display:flex}}.logo.svelte-e0nvq8.svelte-e0nvq8{height:2.5em;width:auto;flex-shrink:0;align-self:center}.header-title.svelte-e0nvq8.svelte-e0nvq8{flex:1;display:flex;align-items:center;align-self:center}.app-title.svelte-e0nvq8.svelte-e0nvq8{font-size:1.2em;font-weight:600;color:var(--text-color);display:flex;align-items:center;gap:0.5em}.permission-badge.svelte-e0nvq8.svelte-e0nvq8{background:var(--primary);color:var(--text-color);padding:0.2em 0.5em;border-radius:0.5em;font-size:0.7em;font-weight:500;text-transform:uppercase;letter-spacing:0.5px}.header-buttons.svelte-e0nvq8.svelte-e0nvq8{display:flex;align-items:stretch;align-self:stretch;margin-left:auto}.login-btn.svelte-e0nvq8.svelte-e0nvq8,.user-profile-btn.svelte-e0nvq8.svelte-e0nvq8{background:transparent;color:var(--button-text);border:0;cursor:pointer;font-size:1em;transition:background-color 0.2s;flex-shrink:0;padding:0.5em;margin:0;display:flex !important;align-items:center !important;justify-content:center}.login-btn.svelte-e0nvq8.svelte-e0nvq8:hover,.user-profile-btn.svelte-e0nvq8.svelte-e0nvq8:hover{background:var(--card-bg)}.user-profile-btn.svelte-e0nvq8.svelte-e0nvq8{gap:0.5em;justify-content:flex-start;padding:0 0.5em}.user-avatar.svelte-e0nvq8.svelte-e0nvq8{height:2.5em;width:2.5em;border-radius:50%;object-fit:cover;flex-shrink:0;align-self:center;vertical-align:middle}.user-avatar-placeholder.svelte-e0nvq8.svelte-e0nvq8{height:2.5em;width:2.5em;border-radius:50%;background:var(--bg-color);display:flex;align-items:center;justify-content:center;font-size:1.2em;flex-shrink:0;align-self:center}.user-name.svelte-e0nvq8.svelte-e0nvq8{font-weight:500;white-space:nowrap;line-height:1;align-self:center;max-width:none !important;overflow:visible !important;text-overflow:unset !important;width:auto !important;color:var(--text-color)}.relay-dropdown-container.svelte-e0nvq8.svelte-e0nvq8{position:relative;align-self:center}.relay-indicator.svelte-e0nvq8.svelte-e0nvq8{display:flex;align-items:center;gap:6px;padding:4px 10px;margin:0 8px;background:var(--muted);border:1px solid var(--border-color);border-radius:4px;cursor:pointer;font-size:0.85em;color:var(--text-color);transition:background-color 0.2s, border-color 0.2s}.relay-indicator.svelte-e0nvq8.svelte-e0nvq8:hover:not(.static){background:var(--card-bg);border-color:var(--primary)}.relay-indicator.static.svelte-e0nvq8.svelte-e0nvq8{cursor:default}.relay-status.svelte-e0nvq8.svelte-e0nvq8{width:8px;height:8px;border-radius:50%;background:var(--warning);flex-shrink:0}.relay-status.connected.svelte-e0nvq8.svelte-e0nvq8{background:var(--success)}.relay-status.error.svelte-e0nvq8.svelte-e0nvq8{background:var(--danger)}.relay-name.svelte-e0nvq8.svelte-e0nvq8{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:200px}.dropdown-arrow.svelte-e0nvq8.svelte-e0nvq8{font-size:0.7em;transition:transform 0.2s;margin-left:2px}.dropdown-arrow.open.svelte-e0nvq8.svelte-e0nvq8{transform:rotate(180deg)}.relay-dropdown.svelte-e0nvq8.svelte-e0nvq8{position:absolute;top:calc(100% + 4px);left:0;min-width:250px;background:var(--bg-color);border:1px solid var(--border-color);border-radius:6px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);z-index:1001;overflow:hidden}.dropdown-section.svelte-e0nvq8.svelte-e0nvq8{padding:4px 0}.dropdown-label.svelte-e0nvq8.svelte-e0nvq8{padding:6px 12px;font-size:0.75em;color:var(--muted-foreground);text-transform:uppercase;letter-spacing:0.5px;font-weight:500}.dropdown-item.svelte-e0nvq8.svelte-e0nvq8{display:flex;align-items:center;gap:8px;width:100%;padding:8px 12px;background:transparent;border:none;cursor:pointer;text-align:left;color:var(--text-color);font-size:0.9em;transition:background-color 0.15s}.dropdown-item.svelte-e0nvq8.svelte-e0nvq8:hover:not(:disabled){background:var(--tab-hover-bg)}.dropdown-item.svelte-e0nvq8.svelte-e0nvq8:disabled{opacity:0.6;cursor:not-allowed}.dropdown-item.current.svelte-e0nvq8.svelte-e0nvq8{background:rgba(16, 185, 129, 0.1)}.dropdown-item.connecting.svelte-e0nvq8.svelte-e0nvq8{background:rgba(234, 179, 8, 0.1)}.item-status.svelte-e0nvq8.svelte-e0nvq8{width:6px;height:6px;border-radius:50%;background:var(--muted-foreground);flex-shrink:0}.item-status.connected.svelte-e0nvq8.svelte-e0nvq8{background:var(--success)}.item-url-label.svelte-e0nvq8.svelte-e0nvq8{flex:1;font-family:monospace;font-size:0.85em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.connecting-indicator.svelte-e0nvq8.svelte-e0nvq8{color:var(--warning);font-weight:bold}.dropdown-divider.svelte-e0nvq8.svelte-e0nvq8{height:1px;background:var(--border-color);margin:4px 0}.manage-btn.svelte-e0nvq8.svelte-e0nvq8{color:var(--primary);font-weight:500} +.sidebar.svelte-1uja393.svelte-1uja393{position:fixed;left:0;top:3em;width:200px;bottom:0;background:var(--sidebar-bg);overflow-y:auto;z-index:100}.sidebar-content.svelte-1uja393.svelte-1uja393{padding:0;background:var(--sidebar-bg)}.tabs.svelte-1uja393.svelte-1uja393{display:flex;flex-direction:column;padding:0}.tab.svelte-1uja393.svelte-1uja393{display:flex;align-items:center;padding:0.75em;padding-left:1em;background:transparent;color:var(--text-color);border:none;cursor:pointer;transition:background-color 0.2s;gap:0.75rem;text-align:left;width:100%}.tab.svelte-1uja393.svelte-1uja393:hover{background-color:var(--bg-color)}.tab.active.svelte-1uja393.svelte-1uja393{background-color:var(--bg-color)}.tab-icon.svelte-1uja393.svelte-1uja393{font-size:1.2em;flex-shrink:0;width:1.5em;text-align:center}.tab-label.svelte-1uja393.svelte-1uja393{font-size:0.9em;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}.tab-close-icon.svelte-1uja393.svelte-1uja393{cursor:pointer;transition:opacity 0.2s;font-size:0.8em;margin-left:auto;padding:0.25rem;flex-shrink:0}.tab-close-icon.svelte-1uja393.svelte-1uja393:hover{opacity:0.7;background-color:var(--warning);color:var(--text-color)}@media(max-width: 1280px){.sidebar.svelte-1uja393.svelte-1uja393{width:60px}.tab-label.svelte-1uja393.svelte-1uja393{display:none}.tab-close-icon.svelte-1uja393.svelte-1uja393{display:none}.tab.svelte-1uja393.svelte-1uja393{justify-content:flex-start}}.version-link.svelte-1uja393.svelte-1uja393{position:absolute;bottom:0;left:0;right:0;display:flex;align-items:center;gap:0.5rem;padding:0.75em 1em;color:var(--text-color);text-decoration:none;font-size:0.8em;transition:background-color 0.2s, color 0.2s;background:transparent}.version-link.svelte-1uja393.svelte-1uja393:hover{background-color:var(--bg-color)}.version-icon.svelte-1uja393.svelte-1uja393{width:1.2em;height:1.2em;flex-shrink:0;color:#4a9c5d}.version-text.svelte-1uja393.svelte-1uja393{white-space:nowrap}@media(max-width: 1280px){.version-text.svelte-1uja393.svelte-1uja393{display:none}.version-link.svelte-1uja393.svelte-1uja393{justify-content:flex-start;padding-left:1.25em}}.mobile-overlay.svelte-1uja393.svelte-1uja393{display:none}@media(max-width: 640px){.mobile-overlay.svelte-1uja393.svelte-1uja393{display:block;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.5);z-index:199}.sidebar.svelte-1uja393.svelte-1uja393{transform:translateX(-100%);transition:transform 0.3s ease;z-index:200;width:200px}.sidebar.mobile-open.svelte-1uja393.svelte-1uja393{transform:translateX(0)}.sidebar.mobile-open.svelte-1uja393 .tab-label.svelte-1uja393{display:block}.sidebar.mobile-open.svelte-1uja393 .tab-close-icon.svelte-1uja393{display:block}.sidebar.mobile-open.svelte-1uja393 .version-text.svelte-1uja393{display:inline}.sidebar.mobile-open.svelte-1uja393 .version-link.svelte-1uja393{padding-left:1em}} .export-section.svelte-jzrdtj.svelte-jzrdtj{border-radius:8px;padding:1em;margin:1em;width:100%;max-width:32em;box-sizing:border-box;background-color:var(--card-bg)}.export-section.svelte-jzrdtj h3.svelte-jzrdtj{margin:0 0 1rem 0;color:var(--text-color);font-size:1.2rem;font-weight:600}.export-section.svelte-jzrdtj p.svelte-jzrdtj{margin:0 0 1.5rem 0;color:var(--text-color);opacity:0.8;line-height:1.4}.export-btn.svelte-jzrdtj.svelte-jzrdtj{background-color:var(--primary);color:var(--text-color);border:none;padding:0.75em 1.5em;border-radius:0.5em;cursor:pointer;font-weight:bold;font-size:0.9em;transition:background-color 0.2s}.export-btn.svelte-jzrdtj.svelte-jzrdtj:hover{background-color:var(--accent-hover-color)}.login-prompt.svelte-jzrdtj.svelte-jzrdtj{text-align:center;padding:2em;background-color:var(--card-bg);border-radius:8px;border:1px solid var(--border-color);width:100%;max-width:32em;box-sizing:border-box}.login-prompt.svelte-jzrdtj p.svelte-jzrdtj{margin:0 0 1.5rem 0;color:var(--text-color);font-size:1.1rem}.login-btn.svelte-jzrdtj.svelte-jzrdtj{background-color:var(--primary);color:var(--text-color);border:none;padding:0.75em 1.5em;border-radius:4px;cursor:pointer;font-weight:bold;font-size:0.9em;transition:background-color 0.2s}.login-btn.svelte-jzrdtj.svelte-jzrdtj:hover{background-color:var(--accent-hover-color)} .import-section.svelte-nonyqh.svelte-nonyqh{background:transparent;padding:1em;border-radius:8px;margin-bottom:1.5rem;width:100%;max-width:32em;box-sizing:border-box}.import-section.svelte-nonyqh h3.svelte-nonyqh{margin:0 0 1rem 0;color:var(--text-color);font-size:1.2rem;font-weight:600}.import-section.svelte-nonyqh p.svelte-nonyqh{margin:0 0 1.5rem 0;color:var(--text-color);opacity:0.8;line-height:1.4}.recovery-controls-card.svelte-nonyqh.svelte-nonyqh{background-color:var(--card-bg);padding:1em;border:0;display:flex;flex-direction:column;border-radius:0.5em;gap:1em}#import-file.svelte-nonyqh.svelte-nonyqh{padding:0.5em;border:0;background:var(--input-bg);color:var(--input-text-color)}.import-btn.svelte-nonyqh.svelte-nonyqh{background-color:var(--primary);color:var(--text-color);border-radius:0.5em;padding:0.75em 1.5em;border:0;cursor:pointer;font-weight:bold;font-size:0.9em;transition:background-color 0.2s;align-self:flex-start}.import-btn.svelte-nonyqh.svelte-nonyqh:hover:not(:disabled){background-color:var(--accent-hover-color)}.import-btn.svelte-nonyqh.svelte-nonyqh:disabled{background-color:var(--secondary);cursor:not-allowed}.import-row.svelte-nonyqh.svelte-nonyqh{display:flex;align-items:center;gap:1em}.import-message.svelte-nonyqh.svelte-nonyqh{font-size:0.9em;padding:0.25em 0.5em;border-radius:0.25em}.import-message.uploading.svelte-nonyqh.svelte-nonyqh{color:var(--primary)}.import-message.success.svelte-nonyqh.svelte-nonyqh{color:#4caf50}.import-message.error.svelte-nonyqh.svelte-nonyqh{color:#f44336}.permission-denied.svelte-nonyqh.svelte-nonyqh,.login-prompt.svelte-nonyqh.svelte-nonyqh{text-align:center;padding:2em;background-color:var(--card-bg);border:0}.recovery-header.svelte-nonyqh.svelte-nonyqh{margin:0 0 1rem 0;color:var(--text-color);font-size:1.2rem;font-weight:600}.recovery-description.svelte-nonyqh.svelte-nonyqh{margin:0 0 1.5rem 0;color:var(--text-color);line-height:1.4}.login-btn.svelte-nonyqh.svelte-nonyqh{background-color:var(--primary);color:var(--text-color);border:none;padding:0.75em 1.5em;border:0;cursor:pointer;font-weight:bold;font-size:0.9em;transition:background-color 0.2s}.login-btn.svelte-nonyqh.svelte-nonyqh:hover{background-color:var(--accent-hover-color)} .filter-builder.svelte-1a1v6k0.svelte-1a1v6k0{padding:1em;background:var(--bg-color);border-bottom:1px solid var(--border-color);display:flex;gap:1em}.filter-content.svelte-1a1v6k0.svelte-1a1v6k0{flex:1;min-width:0}.clear-column.svelte-1a1v6k0.svelte-1a1v6k0{display:flex;flex-direction:column;gap:0.5em;flex-shrink:0;width:2.5em}.clear-column.svelte-1a1v6k0 .spacer.svelte-1a1v6k0{flex:1}.clear-all-btn.svelte-1a1v6k0.svelte-1a1v6k0,.json-toggle-btn.svelte-1a1v6k0.svelte-1a1v6k0{background:var(--secondary);color:var(--text-color);border:none;padding:0;border-radius:4px;cursor:pointer;font-size:1em;transition:filter 0.2s, background-color 0.2s;width:100%;aspect-ratio:1;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.clear-all-btn.svelte-1a1v6k0.svelte-1a1v6k0{background:var(--danger)}.clear-all-btn.svelte-1a1v6k0.svelte-1a1v6k0:hover{filter:brightness(1.2)}.json-toggle-btn.svelte-1a1v6k0.svelte-1a1v6k0{font-family:monospace;font-weight:600;background:var(--primary)}.json-toggle-btn.svelte-1a1v6k0.svelte-1a1v6k0:hover{background:var(--accent-hover-color)}.json-toggle-btn.active.svelte-1a1v6k0.svelte-1a1v6k0{background:var(--accent-hover-color)}.filter-grid.svelte-1a1v6k0.svelte-1a1v6k0{display:grid;grid-template-columns:auto 1fr;gap:0.5em 1em;align-items:start}.filter-grid.svelte-1a1v6k0>label.svelte-1a1v6k0{font-weight:600;color:var(--text-color);font-size:0.9em;padding-top:0.6em;white-space:nowrap}.field-content.svelte-1a1v6k0.svelte-1a1v6k0{min-width:0}.filter-input.svelte-1a1v6k0.svelte-1a1v6k0{width:100%;padding:0.6em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color);font-size:0.9em;box-sizing:border-box}.filter-input.svelte-1a1v6k0.svelte-1a1v6k0:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 2px rgba(0, 123, 255, 0.15)}.picker-toggle-btn.svelte-1a1v6k0.svelte-1a1v6k0{width:100%;padding:0.6em;background:var(--secondary);color:var(--text-color);border:1px solid var(--border-color);border-radius:4px;cursor:pointer;font-size:0.9em;text-align:left;transition:background-color 0.2s}.picker-toggle-btn.svelte-1a1v6k0.svelte-1a1v6k0:hover{background:var(--accent-hover-color)}.kinds-picker.svelte-1a1v6k0.svelte-1a1v6k0{margin-top:0.5em;border:1px solid var(--border-color);border-radius:4px;padding:0.5em;background:var(--card-bg)}.kind-search.svelte-1a1v6k0.svelte-1a1v6k0{margin-bottom:0.5em}.kinds-list.svelte-1a1v6k0.svelte-1a1v6k0{max-height:300px;overflow-y:auto}.kind-checkbox.svelte-1a1v6k0.svelte-1a1v6k0{display:flex;align-items:center;padding:0.4em;cursor:pointer;border-radius:4px;transition:background-color 0.2s}.kind-checkbox.svelte-1a1v6k0.svelte-1a1v6k0:hover{background:var(--bg-color)}.kind-checkbox.svelte-1a1v6k0 input[type="checkbox"].svelte-1a1v6k0{margin-right:0.5em;cursor:pointer}.kind-number.svelte-1a1v6k0.svelte-1a1v6k0{background:var(--primary);color:var(--text-color);padding:0.1em 0.4em;border-radius:3px;font-size:0.8em;font-weight:600;font-family:monospace;margin-right:0.5em;min-width:40px;text-align:center;display:inline-block}.kind-name.svelte-1a1v6k0.svelte-1a1v6k0{font-size:0.85em;color:var(--text-color)}.chips-container.svelte-1a1v6k0.svelte-1a1v6k0{display:flex;flex-wrap:wrap;gap:0.5em;margin-top:0.5em}.chip.svelte-1a1v6k0.svelte-1a1v6k0{display:inline-flex;align-items:center;background:var(--primary);color:var(--text-color);padding:0.2em 0.5em;border-radius:0.5em;font-size:0.7em;font-weight:500;text-transform:uppercase;letter-spacing:0.5px;gap:0.4em}.chip-text.svelte-1a1v6k0.svelte-1a1v6k0{line-height:1}.chip-remove.svelte-1a1v6k0.svelte-1a1v6k0{background:transparent;border:none;color:var(--text-color);cursor:pointer;padding:0;font-size:1em;line-height:1;opacity:0.8;transition:opacity 0.2s}.chip-remove.svelte-1a1v6k0.svelte-1a1v6k0:hover{opacity:1}.input-group.svelte-1a1v6k0.svelte-1a1v6k0{display:flex;gap:0.5em}.input-group.svelte-1a1v6k0 .filter-input.svelte-1a1v6k0{flex:1}.add-btn.svelte-1a1v6k0.svelte-1a1v6k0{background:var(--primary);color:var(--text-color);border:none;padding:0.6em 1.2em;border-radius:4px;cursor:pointer;font-size:0.9em;font-weight:600;transition:background-color 0.2s;white-space:nowrap}.add-btn.svelte-1a1v6k0.svelte-1a1v6k0:hover{background:var(--accent-hover-color)}.error-message.svelte-1a1v6k0.svelte-1a1v6k0{color:var(--danger);font-size:0.85em;margin-top:0.25em}.list-items.svelte-1a1v6k0.svelte-1a1v6k0{margin-top:0.5em;display:flex;flex-direction:column;gap:0.5em}.list-item.svelte-1a1v6k0.svelte-1a1v6k0{display:flex;align-items:center;padding:0.5em;background:var(--card-bg);border:1px solid var(--border-color);border-radius:4px;gap:0.5em}.list-item-text.svelte-1a1v6k0.svelte-1a1v6k0{flex:1;font-family:monospace;font-size:0.85em;color:var(--text-color);word-break:break-all}.list-item-remove.svelte-1a1v6k0.svelte-1a1v6k0{background:var(--danger);color:var(--text-color);border:none;padding:0.25em 0.5em;border-radius:3px;cursor:pointer;font-size:1.2em;line-height:1;transition:background-color 0.2s}.list-item-remove.svelte-1a1v6k0.svelte-1a1v6k0:hover{filter:brightness(0.9)}.tag-input-group.svelte-1a1v6k0.svelte-1a1v6k0{display:flex;gap:0.5em;align-items:center}.hash-prefix.svelte-1a1v6k0.svelte-1a1v6k0{font-weight:700;font-size:1.2em;color:var(--text-color)}.tag-name-input.svelte-1a1v6k0.svelte-1a1v6k0{width:50px}.tag-value-input.svelte-1a1v6k0.svelte-1a1v6k0{flex:1}.timestamp-field.svelte-1a1v6k0.svelte-1a1v6k0{position:relative;display:flex;align-items:center;gap:0.5em}.timestamp-field.svelte-1a1v6k0 .filter-input.svelte-1a1v6k0{flex:1}.clear-timestamp-btn.svelte-1a1v6k0.svelte-1a1v6k0{background:var(--danger);color:var(--text-color);border:none;padding:0.25em 0.5em;border-radius:3px;cursor:pointer;font-size:1em;line-height:1;transition:background-color 0.2s;flex-shrink:0}.clear-timestamp-btn.svelte-1a1v6k0.svelte-1a1v6k0:hover{filter:brightness(0.9)}.json-editor-section.svelte-1a1v6k0.svelte-1a1v6k0{grid-column:1 / -1;margin-top:0.5em;padding-top:1em;border-top:1px solid var(--border-color)}.json-editor-section.svelte-1a1v6k0 label.svelte-1a1v6k0{display:block;font-weight:600;color:var(--text-color);font-size:0.9em;margin-bottom:0.5em}.json-editor.svelte-1a1v6k0.svelte-1a1v6k0{width:100%;padding:0.6em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color);font-family:monospace;font-size:0.85em;resize:vertical;box-sizing:border-box}.json-editor.svelte-1a1v6k0.svelte-1a1v6k0:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 2px rgba(0, 123, 255, 0.15)}.json-error.svelte-1a1v6k0.svelte-1a1v6k0{color:var(--danger);font-size:0.85em;margin-top:0.25em}.apply-json-btn.svelte-1a1v6k0.svelte-1a1v6k0{margin-top:0.5em;background:var(--primary);color:var(--text-color);border:none;padding:0.5em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;font-weight:600;transition:background-color 0.2s}.apply-json-btn.svelte-1a1v6k0.svelte-1a1v6k0:hover{background:var(--accent-hover-color)}@media(max-width: 768px){.filter-grid.svelte-1a1v6k0.svelte-1a1v6k0{grid-template-columns:1fr}.filter-grid.svelte-1a1v6k0>label.svelte-1a1v6k0{padding-top:0;padding-bottom:0.25em}} -.events-view-container.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{width:100%;height:100%;display:flex;flex-direction:column;box-sizing:border-box}.events-view-content.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{flex:1;overflow-y:auto;padding:0}.events-view-content.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar{width:16px;background:var(--bg-color)}.events-view-content.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar-track{background:var(--bg-color)}.events-view-content.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar-thumb{background:var(--text-color);border-radius:9999px;border:4px solid var(--bg-color)}.events-view-content.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar-thumb:hover{background:var(--text-color);filter:brightness(1.2)}.events-view-content.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar-button{background:var(--text-color);height:8px;border:4px solid var(--bg-color);border-radius:9999px;background-clip:padding-box}.events-view-item.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{border:0;margin:0;transition:all 0.2s ease}.events-view-item.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:hover{padding:0}.events-view-row.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{display:flex;align-items:center;padding:0.5em;cursor:pointer;gap:1em}.events-view-avatar.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{flex-shrink:0}.avatar-placeholder.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{width:40px;height:40px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1.2em;border:0}.events-view-info.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{flex-shrink:0;min-width:120px}.events-view-author.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{font-weight:600;color:var(--text-color);font-size:0.9em;font-family:monospace}.events-view-kind.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{display:flex;align-items:center;gap:0.5em;margin-top:0.25em}.kind-number.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--primary);color:#ffffff;padding:0.1em 0.4em;border:0;font-size:0.7em;font-weight:600;font-family:monospace}.kind-number.delete-event.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--danger)}.kind-name.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{font-size:0.8em;color:var(--text-color);opacity:0.8}.event-timestamp.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{font-size:0.8em;color:var(--text-color);opacity:0.6;margin-bottom:0.5em}.delete-event-info.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--danger-bg);padding:0.5em;border-radius:4px;border:1px solid var(--danger)}.delete-event-label.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{font-weight:600;color:var(--danger);display:block;margin-bottom:0.25em}.delete-targets.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{display:flex;flex-wrap:wrap;gap:0.25em}.delete-target.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--danger);color:#ffffff;padding:0.1em 0.3em;border-radius:0.2rem;font-size:0.7em;font-family:monospace}.event-content-single-line.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{color:var(--text-color);line-height:1.4;word-wrap:break-word}.delete-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--danger);color:var(--text-color);border:none;padding:0.5em;border-radius:4px;cursor:pointer;font-size:0.9em;flex-shrink:0;transition:background-color 0.2s}.delete-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:hover{background:var(--danger);filter:brightness(0.9)}.events-view-details.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{padding:0;background:var(--bg-color)}.json-container.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{position:relative}.event-json.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--code-bg);padding:1em;border:0;font-size:0.8em;line-height:1.4;overflow-x:auto;margin:0;color:var(--code-text)}.copy-json-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{position:absolute;top:1em;right:1em;background:var(--primary);color:var(--text-color);border:none;padding:1em;cursor:pointer;font-size:0.8em;opacity:0.8;transition:opacity 0.2s}.copy-json-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:hover{opacity:1}.no-events.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{text-align:center;padding:2em;color:var(--text-color);opacity:0.7}.loading-events.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{text-align:center;padding:2em;color:var(--text-color)}.spinner.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{width:20px;height:20px;border:0;border-radius:50%;animation:svelte-kw5eww-spin 1s linear infinite;margin:0 auto 1em}@keyframes svelte-kw5eww-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.permission-denied.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{text-align:center;padding:2em;background-color:var(--card-bg);border-radius:8px;border:1px solid var(--border-color);color:var(--text-color)}.events-view-footer.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{position:relative;flex-shrink:0}.events-view-header.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{display:flex;justify-content:space-between;align-items:center;padding:0.5em;border:0;background:var(--header-bg)}.events-view-toggle.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{display:flex;align-items:center}.toggle-container.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{display:flex;align-items:center;gap:0.5em;cursor:pointer}.toggle-container.svelte-kw5eww input[type="checkbox"].svelte-kw5eww.svelte-kw5eww{display:none}.toggle-slider.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{width:40px;height:20px;background:var(--border-color);border-radius:10px;position:relative;transition:background 0.2s}.toggle-slider.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::before{content:"";position:absolute;width:16px;height:16px;background:var(--text-color);border-radius:50%;top:2px;left:2px;transition:transform 0.2s}.toggle-container.svelte-kw5eww input.svelte-kw5eww:checked+.toggle-slider.svelte-kw5eww{background:var(--primary)}.toggle-container.svelte-kw5eww input.svelte-kw5eww:checked+.toggle-slider.svelte-kw5eww::before{transform:translateX(20px)}.toggle-label.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{font-size:0.9em;color:var(--text-color)}.events-view-buttons.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{display:flex;gap:0.5em}.refresh-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww,.reload-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--primary);color:var(--text-color);border:none;padding:0.4em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background-color 0.2s;display:flex;align-items:center;justify-content:center;gap:0.25em;box-sizing:border-box;line-height:1}.reload-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{width:2.5em;padding:0.4em}.refresh-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:hover:not(:disabled),.reload-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:hover:not(:disabled){background:var(--accent-hover-color)}.refresh-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:disabled,.reload-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:disabled{background:var(--secondary);cursor:not-allowed;padding:0.4em 1em}.reload-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:disabled{padding:0.4em}.reload-btn.svelte-kw5eww .spinner.svelte-kw5eww.svelte-kw5eww{width:0.8em;height:0.8em;border:1.5px solid var(--text-color);border-top-color:transparent;border-radius:50%;animation:svelte-kw5eww-spin 1s linear infinite;margin:0;box-sizing:border-box}.events-view-left.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{display:flex;align-items:center;gap:0.75em}.filter-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--primary);color:var(--text-color);border:none;padding:0.4em;border-radius:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color 0.2s;width:2.2em;height:2.2em;box-sizing:border-box}.filter-btn.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww:hover{background:var(--accent-hover-color)}.filter-btn.active.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{background:var(--accent-hover-color)}.filter-btn.svelte-kw5eww svg.svelte-kw5eww.svelte-kw5eww{width:1em;height:1em}.filter-panel.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{position:absolute;bottom:100%;left:0;right:0;background:var(--bg-color);border-top:1px solid var(--border-color);max-height:0;overflow:hidden;transition:max-height 0.3s ease-out;z-index:100;padding-right:16px;box-sizing:border-box;display:flex;flex-direction:column-reverse}.filter-panel.open.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww{max-height:60vh;overflow-y:auto}.filter-panel.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar{width:16px;background:var(--bg-color)}.filter-panel.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar-track{background:var(--bg-color)}.filter-panel.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar-thumb{background:var(--text-color);border-radius:9999px;border:4px solid var(--bg-color)}.filter-panel.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar-thumb:hover{background:var(--text-color);filter:brightness(1.2)}.filter-panel.svelte-kw5eww.svelte-kw5eww.svelte-kw5eww::-webkit-scrollbar-button{background:var(--text-color);height:8px;border:4px solid var(--bg-color);border-radius:9999px;background-clip:padding-box} +.events-view-container.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{width:100%;height:100%;display:flex;flex-direction:column;box-sizing:border-box}.events-view-content.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{flex:1;overflow-y:auto;padding:0}.events-view-content.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar{width:16px;background:var(--bg-color)}.events-view-content.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar-track{background:var(--bg-color)}.events-view-content.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar-thumb{background:var(--text-color);border-radius:9999px;border:4px solid var(--bg-color)}.events-view-content.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar-thumb:hover{background:var(--text-color);filter:brightness(1.2)}.events-view-content.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar-button{background:var(--text-color);height:8px;border:4px solid var(--bg-color);border-radius:9999px;background-clip:padding-box}.events-view-item.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{border:0;margin:0;transition:all 0.2s ease}.events-view-item.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:hover{padding:0}.events-view-row.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{display:flex;align-items:center;padding:0.5em;cursor:pointer;gap:1em}.events-view-avatar.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{flex-shrink:0}.avatar-placeholder.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{width:40px;height:40px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:1.2em;border:0}.events-view-info.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{flex-shrink:0;min-width:120px}.events-view-author.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{font-weight:600;color:var(--text-color);font-size:0.9em;font-family:monospace}.events-view-kind.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{display:flex;align-items:center;gap:0.5em;margin-top:0.25em}.kind-number.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--card-bg);color:var(--text-color);padding:0.1em 0.4em;border:1px solid var(--border-color);font-size:0.7em;font-weight:600;font-family:monospace}.kind-number.delete-event.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--danger)}.kind-name.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{font-size:0.8em;color:var(--text-color);opacity:0.8}.event-timestamp.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{font-size:0.8em;color:var(--text-color);opacity:0.6;margin-bottom:0.5em}.delete-event-info.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--danger-bg);padding:0.5em;border-radius:4px;border:1px solid var(--danger)}.delete-event-label.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{font-weight:600;color:var(--danger);display:block;margin-bottom:0.25em}.delete-targets.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{display:flex;flex-wrap:wrap;gap:0.25em}.delete-target.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--danger);color:#ffffff;padding:0.1em 0.3em;border-radius:0.2rem;font-size:0.7em;font-family:monospace}.event-content-single-line.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{color:var(--text-color);line-height:1.4;word-wrap:break-word}.delete-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--danger);color:var(--text-color);border:none;padding:0.5em;border-radius:4px;cursor:pointer;font-size:0.9em;flex-shrink:0;transition:background-color 0.2s}.delete-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:hover{background:var(--danger);filter:brightness(0.9)}.events-view-details.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{padding:0;background:var(--bg-color)}.json-container.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{position:relative}.event-json.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--code-bg);padding:1em;border:0;font-size:0.8em;line-height:1.4;overflow-x:auto;margin:0;color:var(--code-text)}.copy-json-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{position:absolute;top:1em;right:1em;background:var(--primary);color:var(--text-color);border:none;padding:1em;cursor:pointer;font-size:0.8em;opacity:0.8;transition:opacity 0.2s}.copy-json-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:hover{opacity:1}.no-events.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{text-align:center;padding:2em;color:var(--text-color);opacity:0.7}.loading-events.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{text-align:center;padding:2em;color:var(--text-color)}.spinner.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{width:20px;height:20px;border:0;border-radius:50%;animation:svelte-16xix3y-spin 1s linear infinite;margin:0 auto 1em}@keyframes svelte-16xix3y-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.permission-denied.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{text-align:center;padding:2em;background-color:var(--card-bg);border-radius:8px;border:1px solid var(--border-color);color:var(--text-color)}.events-view-footer.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{position:relative;flex-shrink:0}.events-view-header.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{display:flex;justify-content:space-between;align-items:center;padding:0.5em;border:0;background:var(--header-bg)}.events-view-toggle.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{display:flex;align-items:center}.toggle-container.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{display:flex;align-items:center;gap:0.5em;cursor:pointer}.toggle-container.svelte-16xix3y input[type="checkbox"].svelte-16xix3y.svelte-16xix3y{display:none}.toggle-slider.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{width:40px;height:20px;background:var(--border-color);border-radius:10px;position:relative;transition:background 0.2s}.toggle-slider.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::before{content:"";position:absolute;width:16px;height:16px;background:var(--text-color);border-radius:50%;top:2px;left:2px;transition:transform 0.2s}.toggle-container.svelte-16xix3y input.svelte-16xix3y:checked+.toggle-slider.svelte-16xix3y{background:var(--primary)}.toggle-container.svelte-16xix3y input.svelte-16xix3y:checked+.toggle-slider.svelte-16xix3y::before{transform:translateX(20px)}.toggle-label.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{font-size:0.9em;color:var(--text-color)}.events-view-buttons.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{display:flex;gap:0.5em}.refresh-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y,.reload-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--primary);color:var(--text-color);border:none;padding:0.4em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background-color 0.2s;display:flex;align-items:center;justify-content:center;gap:0.25em;box-sizing:border-box;line-height:1}.reload-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{width:2.5em;padding:0.4em}.refresh-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:hover:not(:disabled),.reload-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:hover:not(:disabled){background:var(--accent-hover-color)}.refresh-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:disabled,.reload-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:disabled{background:var(--secondary);cursor:not-allowed;padding:0.4em 1em}.reload-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:disabled{padding:0.4em}.reload-btn.svelte-16xix3y .spinner.svelte-16xix3y.svelte-16xix3y{width:0.8em;height:0.8em;border:1.5px solid var(--text-color);border-top-color:transparent;border-radius:50%;animation:svelte-16xix3y-spin 1s linear infinite;margin:0;box-sizing:border-box}.events-view-left.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{display:flex;align-items:center;gap:0.75em}.filter-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--primary);color:var(--text-color);border:none;padding:0.4em;border-radius:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color 0.2s;width:2.2em;height:2.2em;box-sizing:border-box}.filter-btn.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y:hover{background:var(--accent-hover-color)}.filter-btn.active.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{background:var(--accent-hover-color)}.filter-btn.svelte-16xix3y svg.svelte-16xix3y.svelte-16xix3y{width:1em;height:1em}.filter-panel.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{position:absolute;bottom:100%;left:0;right:0;background:var(--bg-color);border-top:1px solid var(--border-color);max-height:0;overflow:hidden;transition:max-height 0.3s ease-out;z-index:100;padding-right:16px;box-sizing:border-box;display:flex;flex-direction:column-reverse}.filter-panel.open.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y{max-height:60vh;overflow-y:auto}.filter-panel.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar{width:16px;background:var(--bg-color)}.filter-panel.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar-track{background:var(--bg-color)}.filter-panel.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar-thumb{background:var(--text-color);border-radius:9999px;border:4px solid var(--bg-color)}.filter-panel.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar-thumb:hover{background:var(--text-color);filter:brightness(1.2)}.filter-panel.svelte-16xix3y.svelte-16xix3y.svelte-16xix3y::-webkit-scrollbar-button{background:var(--text-color);height:8px;border:4px solid var(--bg-color);border-radius:9999px;background-clip:padding-box} .modal-backdrop.svelte-v55ls1.svelte-v55ls1{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.7);display:flex;align-items:center;justify-content:center;z-index:1000}.modal-content.svelte-v55ls1.svelte-v55ls1{background:var(--card-bg);border-radius:0.5rem;width:90%;max-width:800px;max-height:85vh;display:flex;flex-direction:column;box-shadow:0 4px 20px rgba(0, 0, 0, 0.3);border:1px solid var(--border-color)}.modal-header.svelte-v55ls1.svelte-v55ls1{display:flex;justify-content:space-between;align-items:center;padding:1rem 1.5rem;border-bottom:1px solid var(--border-color)}.modal-header.svelte-v55ls1 h2.svelte-v55ls1{margin:0;font-size:1.25rem;color:var(--text-color)}.close-btn.svelte-v55ls1.svelte-v55ls1{background:none;border:none;font-size:1.5rem;cursor:pointer;color:var(--text-color);padding:0;width:2rem;height:2rem;display:flex;align-items:center;justify-content:center;border-radius:0.25rem}.close-btn.svelte-v55ls1.svelte-v55ls1:hover{background:var(--button-hover-bg)}.modal-filters.svelte-v55ls1.svelte-v55ls1{padding:1rem 1.5rem;border-bottom:1px solid var(--border-color)}.search-box.svelte-v55ls1.svelte-v55ls1{margin-bottom:0.75rem}.search-input.svelte-v55ls1.svelte-v55ls1{width:100%;padding:0.75rem;border:1px solid var(--border-color);border-radius:0.25rem;background:var(--input-bg);color:var(--input-text-color);font-size:0.9rem}.search-input.svelte-v55ls1.svelte-v55ls1:focus{outline:none;border-color:var(--accent-color)}.category-tabs.svelte-v55ls1.svelte-v55ls1{display:flex;flex-wrap:wrap;gap:0.5rem}.category-tab.svelte-v55ls1.svelte-v55ls1{padding:0.4rem 0.75rem;border:1px solid var(--border-color);border-radius:1rem;background:transparent;color:var(--text-color);font-size:0.75rem;cursor:pointer;transition:all 0.2s}.category-tab.svelte-v55ls1.svelte-v55ls1:hover{background:var(--button-hover-bg)}.category-tab.active.svelte-v55ls1.svelte-v55ls1{background:var(--accent-color);border-color:var(--accent-color);color:white}.modal-body.svelte-v55ls1.svelte-v55ls1{flex:1;overflow-y:auto;padding:1rem 1.5rem}.kinds-list.svelte-v55ls1.svelte-v55ls1{display:flex;flex-direction:column;gap:0.5rem}.kind-item.svelte-v55ls1.svelte-v55ls1{display:block;width:100%;text-align:left;padding:0.75rem 1rem;border:1px solid var(--border-color);border-radius:0.375rem;background:var(--bg-color);cursor:pointer;transition:all 0.2s}.kind-item.svelte-v55ls1.svelte-v55ls1:hover{border-color:var(--accent-color);background:var(--button-hover-bg)}.kind-header.svelte-v55ls1.svelte-v55ls1{display:flex;align-items:center;gap:0.5rem;margin-bottom:0.25rem}.kind-number.svelte-v55ls1.svelte-v55ls1{font-family:monospace;font-size:0.8rem;color:var(--accent-color);font-weight:bold}.kind-badge.svelte-v55ls1.svelte-v55ls1{font-size:0.65rem;padding:0.15rem 0.4rem;border-radius:0.25rem;font-weight:500}.badge-regular.svelte-v55ls1.svelte-v55ls1{background:#6c757d;color:white}.badge-replaceable.svelte-v55ls1.svelte-v55ls1{background:#17a2b8;color:white}.badge-ephemeral.svelte-v55ls1.svelte-v55ls1{background:#ffc107;color:black}.badge-addressable.svelte-v55ls1.svelte-v55ls1{background:#28a745;color:white}.nip-badge.svelte-v55ls1.svelte-v55ls1{font-size:0.65rem;padding:0.15rem 0.4rem;border-radius:0.25rem;background:var(--primary);color:var(--text-color)}.kind-name.svelte-v55ls1.svelte-v55ls1{font-weight:600;color:var(--text-color);margin-bottom:0.25rem}.kind-description.svelte-v55ls1.svelte-v55ls1{font-size:0.85rem;color:var(--text-color);opacity:0.7}.no-results.svelte-v55ls1.svelte-v55ls1{text-align:center;padding:2rem;color:var(--text-color);opacity:0.6}.modal-footer.svelte-v55ls1.svelte-v55ls1{display:flex;justify-content:space-between;align-items:center;padding:1rem 1.5rem;border-top:1px solid var(--border-color)}.result-count.svelte-v55ls1.svelte-v55ls1{font-size:0.85rem;color:var(--text-color);opacity:0.7}.cancel-btn.svelte-v55ls1.svelte-v55ls1{padding:0.5rem 1rem;border:1px solid var(--border-color);border-radius:0.25rem;background:var(--button-bg);color:var(--button-text);cursor:pointer;font-size:0.9rem}.cancel-btn.svelte-v55ls1.svelte-v55ls1:hover{background:var(--button-hover-bg)}@media(max-width: 640px){.modal-content.svelte-v55ls1.svelte-v55ls1{width:95%;max-height:90vh}.category-tabs.svelte-v55ls1.svelte-v55ls1{overflow-x:auto;flex-wrap:nowrap;padding-bottom:0.5rem}.category-tab.svelte-v55ls1.svelte-v55ls1{white-space:nowrap}} -.compose-view.svelte-46pmgb{position:fixed;top:3em;left:200px;right:0;bottom:0;display:flex;flex-direction:column;background:transparent}.compose-header.svelte-46pmgb{display:flex;gap:0.5em;padding:0.5em;background:transparent}.compose-btn.svelte-46pmgb{padding:0.5em 1em;border:1px solid var(--border-color);border-radius:0.25rem;background:var(--button-bg);color:var(--button-text);cursor:pointer;font-size:0.9rem;transition:background-color 0.2s}.compose-btn.svelte-46pmgb:hover{background:var(--button-hover-bg)}.template-btn.svelte-46pmgb{background:var(--primary);color:var(--text-color)}.template-btn.svelte-46pmgb:hover{background:var(--primary);filter:brightness(0.9)}.reformat-btn.svelte-46pmgb{background:var(--info);color:var(--text-color)}.reformat-btn.svelte-46pmgb:hover{background:var(--info);filter:brightness(0.9)}.sign-btn.svelte-46pmgb{background:var(--warning);color:var(--text-color)}.sign-btn.svelte-46pmgb:hover{background:var(--warning);filter:brightness(0.9)}.publish-btn.svelte-46pmgb{background:var(--success);color:var(--text-color)}.publish-btn.svelte-46pmgb:hover{background:var(--success);filter:brightness(0.9)}.error-banner.svelte-46pmgb{display:flex;align-items:center;justify-content:space-between;padding:0.75em 1em;margin:0 0.5em;background:#f8d7da;border:1px solid #f5c6cb;border-radius:0.25rem;color:#721c24}.dark-theme .error-banner.svelte-46pmgb{background:#4a1c24;border-color:#6a2c34;color:#f8d7da}.error-content.svelte-46pmgb{display:flex;align-items:center;gap:0.5em}.error-icon.svelte-46pmgb{font-size:1.2em}.error-message.svelte-46pmgb{font-size:0.9rem;line-height:1.4}.error-dismiss.svelte-46pmgb{background:none;border:none;font-size:1.25rem;cursor:pointer;color:inherit;padding:0 0.25em;opacity:0.7}.error-dismiss.svelte-46pmgb:hover{opacity:1}.compose-editor.svelte-46pmgb{flex:1;display:flex;flex-direction:column;padding:0}.compose-textarea.svelte-46pmgb{flex:1;width:100%;padding:1em;border-radius:0.5em;background:var(--input-bg);color:var(--input-text-color);font-family:monospace;font-size:0.9em;line-height:1.4;resize:vertical;outline:none}.compose-textarea.svelte-46pmgb:focus{border-color:var(--accent-color);box-shadow:0 0 0 2px rgba(0, 123, 255, 0.25)}@media(max-width: 1280px){.compose-view.svelte-46pmgb{left:60px}}@media(max-width: 640px){.compose-view.svelte-46pmgb{left:160px}.compose-header.svelte-46pmgb{flex-wrap:wrap}.compose-btn.svelte-46pmgb{flex:1;min-width:calc(50% - 0.5em)}} +.compose-view.svelte-1gh9ysu{position:fixed;top:3em;left:200px;right:0;bottom:0;display:flex;flex-direction:column;background:transparent}.compose-header.svelte-1gh9ysu{display:flex;gap:0.5em;padding:0.5em;background:transparent}.compose-btn.svelte-1gh9ysu{padding:0.5em 1em;border:1px solid var(--border-color);border-radius:0.25rem;background:var(--button-bg);color:var(--button-text);cursor:pointer;font-size:0.9rem;transition:background-color 0.2s}.compose-btn.svelte-1gh9ysu:hover{background:var(--button-hover-bg)}.template-btn.svelte-1gh9ysu{background:var(--primary);color:var(--text-color)}.template-btn.svelte-1gh9ysu:hover{background:var(--primary);filter:brightness(0.9)}.reformat-btn.svelte-1gh9ysu{background:var(--info);color:var(--text-color)}.reformat-btn.svelte-1gh9ysu:hover{background:var(--info);filter:brightness(0.9)}.sign-btn.svelte-1gh9ysu{background:var(--warning);color:var(--text-color)}.sign-btn.svelte-1gh9ysu:hover{background:var(--warning);filter:brightness(0.9)}.publish-btn.svelte-1gh9ysu{background:var(--success);color:var(--text-color)}.publish-btn.svelte-1gh9ysu:hover{background:var(--success);filter:brightness(0.9)}.error-banner.svelte-1gh9ysu{display:flex;align-items:center;justify-content:space-between;padding:0.75em 1em;margin:0 0.5em;background:#f8d7da;border:1px solid #f5c6cb;border-radius:0.25rem;color:#721c24}.dark-theme .error-banner.svelte-1gh9ysu{background:#4a1c24;border-color:#6a2c34;color:#f8d7da}.error-content.svelte-1gh9ysu{display:flex;align-items:center;gap:0.5em}.error-icon.svelte-1gh9ysu{font-size:1.2em}.error-message.svelte-1gh9ysu{font-size:0.9rem;line-height:1.4}.error-dismiss.svelte-1gh9ysu{background:none;border:none;font-size:1.25rem;cursor:pointer;color:inherit;padding:0 0.25em;opacity:0.7}.error-dismiss.svelte-1gh9ysu:hover{opacity:1}.compose-editor.svelte-1gh9ysu{flex:1;display:flex;flex-direction:column;padding:0}.compose-textarea.svelte-1gh9ysu{flex:1;width:100%;padding:1em;border-radius:0.5em;background:var(--input-bg);color:var(--input-text-color);font-family:monospace;font-size:0.9em;line-height:1.4;resize:vertical;outline:none}.compose-textarea.svelte-1gh9ysu:focus{border-color:var(--accent-color);box-shadow:0 0 0 2px rgba(0, 123, 255, 0.25)}@media(max-width: 1280px){.compose-view.svelte-1gh9ysu{left:60px}}@media(max-width: 640px){.compose-view.svelte-1gh9ysu{left:0}.compose-header.svelte-1gh9ysu{flex-wrap:wrap}.compose-btn.svelte-1gh9ysu{flex:1;min-width:calc(50% - 0.5em)}} .recovery-tab.svelte-1e1mff9.svelte-1e1mff9{width:100%;max-width:1200px;margin:0;padding:20px;background:var(--header-bg);color:var(--text-color);border-radius:8px;box-sizing:border-box}.recovery-tab.svelte-1e1mff9 h3.svelte-1e1mff9{margin:0 0 0.5rem 0;color:var(--text-color);font-size:1.5rem;font-weight:600}.recovery-tab.svelte-1e1mff9 p.svelte-1e1mff9{margin:0 0 1.5rem 0;color:var(--text-color);opacity:0.8;line-height:1.4}.recovery-controls-card.svelte-1e1mff9.svelte-1e1mff9{background-color:var(--card-bg);border-radius:0.5em;padding:1em;margin-bottom:1.5rem}.recovery-controls.svelte-1e1mff9.svelte-1e1mff9{display:flex;flex-direction:column;gap:1em}.kind-selector.svelte-1e1mff9.svelte-1e1mff9,.custom-kind-input.svelte-1e1mff9.svelte-1e1mff9{display:flex;flex-direction:column;gap:0.5em}.kind-selector.svelte-1e1mff9 label.svelte-1e1mff9,.custom-kind-input.svelte-1e1mff9 label.svelte-1e1mff9{font-weight:600;color:var(--text-color)}.kind-selector.svelte-1e1mff9 select.svelte-1e1mff9,.custom-kind-input.svelte-1e1mff9 input.svelte-1e1mff9{padding:0.5em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color);font-size:0.9em}.recovery-results.svelte-1e1mff9.svelte-1e1mff9{margin-top:1.5rem}.loading.svelte-1e1mff9.svelte-1e1mff9,.no-events.svelte-1e1mff9.svelte-1e1mff9{text-align:center;padding:2em;color:var(--text-color);opacity:0.7}.events-list.svelte-1e1mff9.svelte-1e1mff9{display:flex;flex-direction:column;gap:1em}.event-item.svelte-1e1mff9.svelte-1e1mff9{background:var(--card-bg);border:1px solid var(--border-color);border-radius:8px;padding:1em}.event-item.old-version.svelte-1e1mff9.svelte-1e1mff9{border-color:var(--warning);background:var(--warning-bg)}.event-header.svelte-1e1mff9.svelte-1e1mff9{display:flex;justify-content:space-between;align-items:center;margin-bottom:1em;flex-wrap:wrap;gap:1em}.event-header-left.svelte-1e1mff9.svelte-1e1mff9{display:flex;flex-direction:column;gap:0.25em}.event-kind.svelte-1e1mff9.svelte-1e1mff9{font-weight:600;color:var(--primary)}.event-timestamp.svelte-1e1mff9.svelte-1e1mff9{font-size:0.9em;color:var(--text-color);opacity:0.7}.event-header-actions.svelte-1e1mff9.svelte-1e1mff9{display:flex;gap:0.5em;flex-wrap:wrap}.repost-all-button.svelte-1e1mff9.svelte-1e1mff9,.repost-button.svelte-1e1mff9.svelte-1e1mff9,.copy-json-btn.svelte-1e1mff9.svelte-1e1mff9{background:var(--accent-color);color:var(--accent-hover-color);border:none;padding:0.5em;border-radius:0.5em;cursor:pointer;font-size:0.8em;transition:background-color 0.2s}.repost-all-button.svelte-1e1mff9.svelte-1e1mff9:hover,.repost-button.svelte-1e1mff9.svelte-1e1mff9:hover,.copy-json-btn.svelte-1e1mff9.svelte-1e1mff9:hover{background:var(--accent-hover-color)}.event-content.svelte-1e1mff9.svelte-1e1mff9{margin-top:1em}.event-json.svelte-1e1mff9.svelte-1e1mff9{background:var(--code-bg);padding:1em;border:0;font-size:0.8em;line-height:1.4;overflow-x:auto;margin:0;color:var(--code-text)}.load-more.svelte-1e1mff9.svelte-1e1mff9{width:100%;padding:12px;background:var(--primary);color:var(--text-color);border:none;border-radius:4px;cursor:pointer;font-size:1em;margin-top:20px;transition:background 0.2s ease}.load-more.svelte-1e1mff9.svelte-1e1mff9:hover:not(:disabled){background:var(--accent-hover-color)}.load-more.svelte-1e1mff9.svelte-1e1mff9:disabled{opacity:0.6;cursor:not-allowed} .sprocket-view.svelte-fiaj1r.svelte-fiaj1r{width:100%;max-width:1200px;margin:0;padding:20px;background:var(--header-bg);color:var(--text-color);border-radius:8px}.sprocket-view.svelte-fiaj1r h2.svelte-fiaj1r{margin:0 0 1.5rem 0;color:var(--text-color);font-size:1.8rem;font-weight:600}.sprocket-section.svelte-fiaj1r.svelte-fiaj1r{background-color:var(--card-bg);border-radius:8px;padding:1em;margin-bottom:1.5rem;border:1px solid var(--border-color);width:32em}.sprocket-header.svelte-fiaj1r.svelte-fiaj1r{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}.sprocket-header.svelte-fiaj1r h3.svelte-fiaj1r{margin:0;color:var(--text-color);font-size:1.2rem;font-weight:600}.sprocket-controls.svelte-fiaj1r.svelte-fiaj1r{display:flex;gap:0.5rem}.sprocket-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--primary);color:var(--text-color);border:none;padding:0.5em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background-color 0.2s;display:flex;align-items:center;gap:0.25em}.sprocket-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--accent-hover-color)}.sprocket-btn.svelte-fiaj1r.svelte-fiaj1r:disabled{background:var(--secondary);cursor:not-allowed}.restart-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--warning)}.restart-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--warning);filter:brightness(0.9)}.delete-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--danger)}.delete-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--danger);filter:brightness(0.9)}.sprocket-upload-section.svelte-fiaj1r.svelte-fiaj1r{margin-bottom:1.5rem}.sprocket-upload-section.svelte-fiaj1r h4.svelte-fiaj1r{margin:0 0 0.5rem 0;color:var(--text-color);font-size:1rem;font-weight:600}.upload-controls.svelte-fiaj1r.svelte-fiaj1r{display:flex;flex-direction:column;gap:0.5rem}#sprocket-upload-file.svelte-fiaj1r.svelte-fiaj1r{padding:0.5em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color)}.upload-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--success);align-self:flex-start}.upload-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--success);filter:brightness(0.9)}.sprocket-status.svelte-fiaj1r.svelte-fiaj1r{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1.5rem;padding:1rem;background:var(--bg-color);border-radius:4px;border:1px solid var(--border-color)}.status-item.svelte-fiaj1r.svelte-fiaj1r{display:flex;justify-content:space-between;align-items:center}.status-label.svelte-fiaj1r.svelte-fiaj1r{font-weight:600;color:var(--text-color)}.status-value.svelte-fiaj1r.svelte-fiaj1r{color:var(--text-color)}.status-value.running.svelte-fiaj1r.svelte-fiaj1r{color:var(--success)}.script-editor-container.svelte-fiaj1r.svelte-fiaj1r{margin-bottom:1.5rem}.script-editor.svelte-fiaj1r.svelte-fiaj1r{width:100%;height:300px;padding:1em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color);font-family:monospace;font-size:0.9em;line-height:1.4;resize:vertical}.script-editor.svelte-fiaj1r.svelte-fiaj1r:disabled{opacity:0.6;cursor:not-allowed}.script-actions.svelte-fiaj1r.svelte-fiaj1r{display:flex;gap:0.5rem;margin-bottom:1rem}.save-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--success)}.save-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--success);filter:brightness(0.9)}.load-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--info)}.load-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--info);filter:brightness(0.9)}.sprocket-message.svelte-fiaj1r.svelte-fiaj1r{padding:1rem;border-radius:4px;margin-top:1rem;background:var(--success-bg);color:var(--success-text);border:1px solid var(--success)}.sprocket-message.error.svelte-fiaj1r.svelte-fiaj1r{background:var(--danger-bg);color:var(--danger-text);border:1px solid var(--danger)}.versions-list.svelte-fiaj1r.svelte-fiaj1r{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}.version-item.svelte-fiaj1r.svelte-fiaj1r{display:flex;justify-content:space-between;align-items:center;padding:0.75rem;background:var(--bg-color);border:1px solid var(--border-color);border-radius:4px}.version-item.current.svelte-fiaj1r.svelte-fiaj1r{border-color:var(--primary);background:var(--primary-bg)}.version-info.svelte-fiaj1r.svelte-fiaj1r{flex:1}.version-name.svelte-fiaj1r.svelte-fiaj1r{font-weight:600;color:var(--text-color);margin-bottom:0.25rem}.version-date.svelte-fiaj1r.svelte-fiaj1r{font-size:0.8em;color:var(--text-color);opacity:0.7;display:flex;align-items:center;gap:0.5rem}.current-badge.svelte-fiaj1r.svelte-fiaj1r{background:var(--primary);color:var(--text-color);padding:0.1em 0.4em;border-radius:0.25rem;font-size:0.7em;font-weight:600}.version-actions.svelte-fiaj1r.svelte-fiaj1r{display:flex;gap:0.25rem}.version-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--primary);color:var(--text-color);border:none;padding:0.25em 0.5em;border-radius:0.25rem;cursor:pointer;font-size:0.8em;transition:background-color 0.2s}.version-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--accent-hover-color)}.version-btn.svelte-fiaj1r.svelte-fiaj1r:disabled{background:var(--secondary);cursor:not-allowed}.version-btn.delete-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--danger)}.version-btn.delete-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--danger);filter:brightness(0.9)}.refresh-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--info)}.refresh-btn.svelte-fiaj1r.svelte-fiaj1r:hover:not(:disabled){background:var(--info);filter:brightness(0.9)}.permission-denied.svelte-fiaj1r.svelte-fiaj1r,.login-prompt.svelte-fiaj1r.svelte-fiaj1r{text-align:center;padding:2em;background-color:var(--card-bg);border-radius:8px;border:1px solid var(--border-color);color:var(--text-color)}.permission-denied.svelte-fiaj1r p.svelte-fiaj1r,.login-prompt.svelte-fiaj1r p.svelte-fiaj1r{margin:0 0 1rem 0;line-height:1.4}.permission-denied.svelte-fiaj1r code.svelte-fiaj1r{background:var(--code-bg);padding:0.2em 0.4em;border-radius:0.25rem;font-family:monospace;font-size:0.9em}.login-btn.svelte-fiaj1r.svelte-fiaj1r{background:var(--primary);color:var(--text-color);border:none;padding:0.75em 1.5em;border-radius:4px;cursor:pointer;font-weight:bold;font-size:0.9em;transition:background-color 0.2s}.login-btn.svelte-fiaj1r.svelte-fiaj1r:hover{background:var(--accent-hover-color)} .policy-view.svelte-gkxvxc.svelte-gkxvxc{width:100%;max-width:1200px;margin:0;padding:20px;background:var(--header-bg);color:var(--text-color);border-radius:8px;box-sizing:border-box}.policy-view.svelte-gkxvxc h2.svelte-gkxvxc{margin:0 0 1.5rem 0;color:var(--text-color);font-size:1.8rem;font-weight:600}.policy-section.svelte-gkxvxc.svelte-gkxvxc{background-color:var(--card-bg);border-radius:8px;padding:1.5em;margin-bottom:1.5rem;border:1px solid var(--border-color)}.policy-header.svelte-gkxvxc.svelte-gkxvxc{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}.policy-header.svelte-gkxvxc h3.svelte-gkxvxc{margin:0;color:var(--text-color);font-size:1.2rem;font-weight:600}.policy-status.svelte-gkxvxc.svelte-gkxvxc{display:flex;gap:0.5rem}.status-badge.svelte-gkxvxc.svelte-gkxvxc{padding:0.25em 0.75em;border-radius:1rem;font-size:0.8em;font-weight:600;background:var(--danger);color:white}.status-badge.enabled.svelte-gkxvxc.svelte-gkxvxc{background:var(--success)}.admin-badge.svelte-gkxvxc.svelte-gkxvxc{padding:0.25em 0.75em;border-radius:1rem;font-size:0.8em;font-weight:600;background:var(--primary);color:white}.policy-info.svelte-gkxvxc.svelte-gkxvxc{margin-bottom:1rem;padding:1rem;background:var(--bg-color);border-radius:4px;border:1px solid var(--border-color)}.policy-info.svelte-gkxvxc p.svelte-gkxvxc{margin:0 0 0.5rem 0;line-height:1.5}.policy-info.svelte-gkxvxc p.svelte-gkxvxc:last-child{margin-bottom:0}.info-note.svelte-gkxvxc.svelte-gkxvxc{font-size:0.9em;opacity:0.8}.editor-container.svelte-gkxvxc.svelte-gkxvxc{margin-bottom:1rem}.policy-editor.svelte-gkxvxc.svelte-gkxvxc{width:100%;height:400px;padding:1em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color);font-family:'Monaco', 'Menlo', 'Ubuntu Mono', monospace;font-size:0.85em;line-height:1.5;resize:vertical;tab-size:2}.policy-editor.svelte-gkxvxc.svelte-gkxvxc:disabled{opacity:0.6;cursor:not-allowed}.validation-errors.svelte-gkxvxc.svelte-gkxvxc{margin-bottom:1rem;padding:1rem;background:var(--danger-bg, rgba(220, 53, 69, 0.1));border:1px solid var(--danger);border-radius:4px}.validation-errors.svelte-gkxvxc h4.svelte-gkxvxc{margin:0 0 0.5rem 0;color:var(--danger);font-size:1rem}.validation-errors.svelte-gkxvxc ul.svelte-gkxvxc{margin:0;padding-left:1.5rem}.validation-errors.svelte-gkxvxc li.svelte-gkxvxc{color:var(--danger);margin-bottom:0.25rem}.policy-actions.svelte-gkxvxc.svelte-gkxvxc{display:flex;gap:0.5rem;flex-wrap:wrap}.policy-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--primary);color:white;border:none;padding:0.5em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background-color 0.2s, filter 0.2s;display:flex;align-items:center;gap:0.25em}.policy-btn.svelte-gkxvxc.svelte-gkxvxc:hover:not(:disabled){filter:brightness(1.1)}.policy-btn.svelte-gkxvxc.svelte-gkxvxc:disabled{background:var(--secondary);cursor:not-allowed}.load-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--info)}.format-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--secondary)}.validate-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--warning)}.save-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--success)}.policy-message.svelte-gkxvxc.svelte-gkxvxc{padding:1rem;border-radius:4px;margin-top:1rem;background:var(--info-bg, rgba(23, 162, 184, 0.1));color:var(--info-text, var(--text-color));border:1px solid var(--info)}.policy-message.error.svelte-gkxvxc.svelte-gkxvxc{background:var(--danger-bg, rgba(220, 53, 69, 0.1));color:var(--danger-text, var(--danger));border:1px solid var(--danger)}.policy-message.success.svelte-gkxvxc.svelte-gkxvxc{background:var(--success-bg, rgba(40, 167, 69, 0.1));color:var(--success-text, var(--success));border:1px solid var(--success)}.reference-content.svelte-gkxvxc h4.svelte-gkxvxc{margin:1rem 0 0.5rem 0;color:var(--text-color);font-size:1rem}.reference-content.svelte-gkxvxc h4.svelte-gkxvxc:first-child{margin-top:0}.field-list.svelte-gkxvxc.svelte-gkxvxc{margin:0 0 1rem 0;padding-left:1.5rem}.field-list.svelte-gkxvxc li.svelte-gkxvxc{margin-bottom:0.25rem;line-height:1.5}.field-list.svelte-gkxvxc code.svelte-gkxvxc{background:var(--code-bg, rgba(0, 0, 0, 0.1));padding:0.1em 0.4em;border-radius:3px;font-family:'Monaco', 'Menlo', 'Ubuntu Mono', monospace;font-size:0.9em}.example-json.svelte-gkxvxc.svelte-gkxvxc{background:var(--input-bg);color:var(--input-text-color);padding:1rem;border-radius:4px;border:1px solid var(--border-color);font-family:'Monaco', 'Menlo', 'Ubuntu Mono', monospace;font-size:0.8em;line-height:1.4;overflow-x:auto;white-space:pre;margin:0}.permission-denied.svelte-gkxvxc.svelte-gkxvxc,.login-prompt.svelte-gkxvxc.svelte-gkxvxc{text-align:center;padding:2em;background-color:var(--card-bg);border-radius:8px;border:1px solid var(--border-color);color:var(--text-color)}.permission-denied.svelte-gkxvxc p.svelte-gkxvxc,.login-prompt.svelte-gkxvxc p.svelte-gkxvxc{margin:0 0 1rem 0;line-height:1.4}.permission-denied.svelte-gkxvxc code.svelte-gkxvxc{background:var(--code-bg, rgba(0, 0, 0, 0.1));padding:0.2em 0.4em;border-radius:0.25rem;font-family:monospace;font-size:0.9em}.login-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--primary);color:white;border:none;padding:0.75em 1.5em;border-radius:4px;cursor:pointer;font-weight:bold;font-size:0.9em;transition:background-color 0.2s}.login-btn.svelte-gkxvxc.svelte-gkxvxc:hover{filter:brightness(1.1)}.admin-list.svelte-gkxvxc.svelte-gkxvxc{margin-bottom:1rem}.admin-item.svelte-gkxvxc.svelte-gkxvxc{display:flex;justify-content:space-between;align-items:center;padding:0.5em 0.75em;background:var(--bg-color);border:1px solid var(--border-color);border-radius:4px;margin-bottom:0.5rem}.admin-pubkey.svelte-gkxvxc.svelte-gkxvxc{font-family:'Monaco', 'Menlo', 'Ubuntu Mono', monospace;font-size:0.85em;color:var(--text-color)}.remove-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--danger);color:white;border:none;width:24px;height:24px;border-radius:50%;cursor:pointer;font-size:0.8em;display:flex;align-items:center;justify-content:center;transition:filter 0.2s}.remove-btn.svelte-gkxvxc.svelte-gkxvxc:hover:not(:disabled){filter:brightness(0.9)}.remove-btn.svelte-gkxvxc.svelte-gkxvxc:disabled{opacity:0.5;cursor:not-allowed}.add-admin.svelte-gkxvxc.svelte-gkxvxc{display:flex;gap:0.5rem}.add-admin.svelte-gkxvxc input.svelte-gkxvxc{flex:1;padding:0.5em 0.75em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color);font-family:'Monaco', 'Menlo', 'Ubuntu Mono', monospace;font-size:0.85em}.add-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--success);white-space:nowrap}.no-items.svelte-gkxvxc.svelte-gkxvxc{color:var(--text-color);opacity:0.6;font-style:italic;padding:1rem;text-align:center}.follows-header.svelte-gkxvxc.svelte-gkxvxc{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}.follows-count.svelte-gkxvxc.svelte-gkxvxc{font-weight:600;color:var(--text-color)}.refresh-btn.svelte-gkxvxc.svelte-gkxvxc{background:var(--info)}.follows-list.svelte-gkxvxc.svelte-gkxvxc{max-height:300px;overflow-y:auto;border:1px solid var(--border-color);border-radius:4px;background:var(--bg-color)}.follows-grid.svelte-gkxvxc.svelte-gkxvxc{display:grid;grid-template-columns:repeat(auto-fill, minmax(200px, 1fr));gap:0.5rem;padding:0.75rem}.follow-item.svelte-gkxvxc.svelte-gkxvxc{padding:0.4em 0.6em;background:var(--card-bg);border:1px solid var(--border-color);border-radius:4px;font-family:'Monaco', 'Menlo', 'Ubuntu Mono', monospace;font-size:0.75em;color:var(--text-color);text-overflow:ellipsis;overflow:hidden;white-space:nowrap} @@ -17,7 +17,8 @@ .relay-connect-view.svelte-gwb5vv.svelte-gwb5vv{width:100%;max-width:800px;margin:0;padding:20px;background:var(--header-bg);color:var(--text-color);border-radius:8px}.relay-connect-view.svelte-gwb5vv h2.svelte-gwb5vv{margin:0 0 0.5rem 0;color:var(--text-color);font-size:1.8rem;font-weight:600}.description.svelte-gwb5vv.svelte-gwb5vv{color:var(--muted-foreground);margin-bottom:1.5rem;line-height:1.5}.section.svelte-gwb5vv.svelte-gwb5vv{background-color:var(--card-bg);border-radius:8px;padding:1em;margin-bottom:1.5rem;border:1px solid var(--border-color)}.section.svelte-gwb5vv h3.svelte-gwb5vv{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem;font-weight:600}.config-status.svelte-gwb5vv.svelte-gwb5vv{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1.5rem;padding:1rem;background:var(--card-bg);border-radius:8px;border:1px solid var(--border-color)}.status-item.svelte-gwb5vv.svelte-gwb5vv{display:flex;justify-content:space-between;align-items:center}.status-label.svelte-gwb5vv.svelte-gwb5vv{font-weight:600;color:var(--text-color)}.status-value.svelte-gwb5vv.svelte-gwb5vv{color:var(--muted-foreground);font-family:monospace;font-size:0.9em}.status-value.enabled.svelte-gwb5vv.svelte-gwb5vv{color:var(--success)}.create-form.svelte-gwb5vv.svelte-gwb5vv{display:flex;flex-direction:column;gap:1rem}.form-group.svelte-gwb5vv.svelte-gwb5vv{display:flex;flex-direction:column;gap:0.5rem}.form-group.svelte-gwb5vv label.svelte-gwb5vv{font-weight:500;color:var(--text-color)}.form-group.svelte-gwb5vv input[type="text"].svelte-gwb5vv{padding:0.75em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color);font-size:1em}.checkbox-group.svelte-gwb5vv.svelte-gwb5vv{flex-direction:row;align-items:center}.checkbox-group.svelte-gwb5vv label.svelte-gwb5vv{display:flex;align-items:center;gap:0.5rem;cursor:pointer}.checkbox-group.svelte-gwb5vv input[type="checkbox"].svelte-gwb5vv{width:1.2em;height:1.2em}.hint.svelte-gwb5vv.svelte-gwb5vv{color:var(--muted-foreground);font-size:0.85em}.create-btn.svelte-gwb5vv.svelte-gwb5vv{background:var(--primary);color:var(--text-color);border:none;padding:0.75em 1.5em;border-radius:4px;cursor:pointer;font-size:1em;font-weight:500;align-self:flex-start;transition:background-color 0.2s}.create-btn.svelte-gwb5vv.svelte-gwb5vv:hover:not(:disabled){background:var(--accent-hover-color)}.create-btn.svelte-gwb5vv.svelte-gwb5vv:disabled{background:var(--secondary);cursor:not-allowed}.connections-list.svelte-gwb5vv.svelte-gwb5vv{display:flex;flex-direction:column;gap:0.75rem;margin-bottom:1rem}.connection-item.svelte-gwb5vv.svelte-gwb5vv{display:flex;justify-content:space-between;align-items:center;padding:1rem;background:var(--bg-color);border:1px solid var(--border-color);border-radius:4px}.connection-info.svelte-gwb5vv.svelte-gwb5vv{flex:1}.connection-label.svelte-gwb5vv.svelte-gwb5vv{font-weight:600;color:var(--text-color);margin-bottom:0.25rem}.connection-details.svelte-gwb5vv.svelte-gwb5vv{display:flex;flex-wrap:wrap;gap:0.75rem;font-size:0.85em;color:var(--muted-foreground)}.badge.svelte-gwb5vv.svelte-gwb5vv{background:var(--primary);color:var(--text-color);padding:0.1em 0.4em;border-radius:0.25rem;font-size:0.75em;font-weight:600}.badge.cashu.svelte-gwb5vv.svelte-gwb5vv{background:var(--warning)}.connection-actions.svelte-gwb5vv.svelte-gwb5vv{display:flex;gap:0.5rem}.action-btn.svelte-gwb5vv.svelte-gwb5vv{background:var(--primary);color:var(--text-color);border:none;padding:0.5em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background-color 0.2s}.action-btn.svelte-gwb5vv.svelte-gwb5vv:hover:not(:disabled){background:var(--accent-hover-color)}.action-btn.svelte-gwb5vv.svelte-gwb5vv:disabled{background:var(--secondary);cursor:not-allowed}.show-uri-btn.svelte-gwb5vv.svelte-gwb5vv{background:var(--info)}.show-uri-btn.svelte-gwb5vv.svelte-gwb5vv:hover:not(:disabled){filter:brightness(0.9)}.delete-btn.svelte-gwb5vv.svelte-gwb5vv{background:var(--danger)}.delete-btn.svelte-gwb5vv.svelte-gwb5vv:hover:not(:disabled){filter:brightness(0.9)}.refresh-btn.svelte-gwb5vv.svelte-gwb5vv{background:var(--secondary);color:var(--text-color);border:none;padding:0.5em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background-color 0.2s}.refresh-btn.svelte-gwb5vv.svelte-gwb5vv:hover:not(:disabled){filter:brightness(0.9)}.refresh-btn.svelte-gwb5vv.svelte-gwb5vv:disabled{cursor:not-allowed;opacity:0.6}.no-connections.svelte-gwb5vv.svelte-gwb5vv{color:var(--muted-foreground);text-align:center;padding:2rem}.message.svelte-gwb5vv.svelte-gwb5vv{padding:1rem;border-radius:4px;margin-top:1rem;background:var(--info-bg, #e7f3ff);color:var(--info-text, #0066cc);border:1px solid var(--info, #0066cc)}.message.error.svelte-gwb5vv.svelte-gwb5vv{background:var(--danger-bg);color:var(--danger-text);border-color:var(--danger)}.message.success.svelte-gwb5vv.svelte-gwb5vv{background:var(--success-bg);color:var(--success-text);border-color:var(--success)}.modal-overlay.svelte-gwb5vv.svelte-gwb5vv{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0, 0, 0, 0.6);display:flex;align-items:center;justify-content:center;z-index:1000}.modal.svelte-gwb5vv.svelte-gwb5vv{background:var(--card-bg);border-radius:8px;padding:1.5rem;max-width:600px;width:90%;max-height:80vh;overflow:auto;border:1px solid var(--border-color)}.modal.svelte-gwb5vv h3.svelte-gwb5vv{margin:0 0 0.5rem 0;color:var(--text-color)}.modal-description.svelte-gwb5vv.svelte-gwb5vv{color:var(--muted-foreground);margin-bottom:1rem;font-size:0.9em;line-height:1.5}.uri-display.svelte-gwb5vv textarea.svelte-gwb5vv{width:100%;height:120px;padding:0.75em;border:1px solid var(--border-color);border-radius:4px;background:var(--input-bg);color:var(--input-text-color);font-family:monospace;font-size:0.85em;resize:none;word-break:break-all}.modal-actions.svelte-gwb5vv.svelte-gwb5vv{display:flex;gap:0.5rem;margin-top:1rem;justify-content:flex-end}.copy-btn.svelte-gwb5vv.svelte-gwb5vv{background:var(--primary);color:var(--text-color);border:none;padding:0.75em 1.5em;border-radius:4px;cursor:pointer;font-weight:500;transition:background-color 0.2s}.copy-btn.svelte-gwb5vv.svelte-gwb5vv:hover{background:var(--accent-hover-color)}.close-btn.svelte-gwb5vv.svelte-gwb5vv{background:var(--secondary);color:var(--text-color);border:none;padding:0.75em 1.5em;border-radius:4px;cursor:pointer;font-weight:500;transition:background-color 0.2s}.close-btn.svelte-gwb5vv.svelte-gwb5vv:hover{filter:brightness(0.9)}.not-enabled.svelte-gwb5vv.svelte-gwb5vv,.permission-denied.svelte-gwb5vv.svelte-gwb5vv,.login-prompt.svelte-gwb5vv.svelte-gwb5vv{text-align:center;padding:2em;background-color:var(--card-bg);border-radius:8px;border:1px solid var(--border-color);color:var(--text-color)}.not-enabled.svelte-gwb5vv p.svelte-gwb5vv,.permission-denied.svelte-gwb5vv p.svelte-gwb5vv,.login-prompt.svelte-gwb5vv p.svelte-gwb5vv{margin:0 0 1rem 0;line-height:1.4}.not-enabled.svelte-gwb5vv code.svelte-gwb5vv{background:var(--code-bg);padding:0.2em 0.4em;border-radius:0.25rem;font-family:monospace;font-size:0.9em}.login-btn.svelte-gwb5vv.svelte-gwb5vv{background:var(--primary);color:var(--text-color);border:none;padding:0.75em 1.5em;border-radius:4px;cursor:pointer;font-weight:bold;font-size:0.9em;transition:background-color 0.2s}.login-btn.svelte-gwb5vv.svelte-gwb5vv:hover{background:var(--accent-hover-color)} .search-results-view.svelte-porghq.svelte-porghq{width:100%;height:100%;display:flex;flex-direction:column}.search-results-header.svelte-porghq.svelte-porghq{display:flex;justify-content:space-between;align-items:center;padding:1em;border-bottom:1px solid var(--border-color);background:var(--header-bg)}.search-results-header.svelte-porghq h2.svelte-porghq{margin:0;color:var(--text-color);font-size:1.2rem;font-weight:600}.refresh-btn.svelte-porghq.svelte-porghq{background:var(--primary);color:var(--text-color);border:none;padding:0.5em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background-color 0.2s}.refresh-btn.svelte-porghq.svelte-porghq:hover:not(:disabled){background:var(--accent-hover-color)}.refresh-btn.svelte-porghq.svelte-porghq:disabled{background:var(--secondary);cursor:not-allowed}.search-results-content.svelte-porghq.svelte-porghq{flex:1;overflow-y:auto;padding:1em}.search-result-item.svelte-porghq.svelte-porghq{border:1px solid var(--border-color);border-radius:8px;margin-bottom:0.5em;background:var(--card-bg);transition:all 0.2s ease}.search-result-item.svelte-porghq.svelte-porghq:hover{border-color:var(--primary);box-shadow:0 2px 8px rgba(0, 0, 0, 0.1)}.search-result-item.expanded.svelte-porghq.svelte-porghq{border-color:var(--primary);box-shadow:0 4px 12px rgba(0, 0, 0, 0.15)}.search-result-row.svelte-porghq.svelte-porghq{display:flex;align-items:center;padding:1em;cursor:pointer;gap:1em}.search-result-avatar.svelte-porghq.svelte-porghq{flex-shrink:0}.avatar-placeholder.svelte-porghq.svelte-porghq{width:40px;height:40px;border-radius:50%;background:var(--bg-color);display:flex;align-items:center;justify-content:center;font-size:1.2em;border:1px solid var(--border-color)}.search-result-info.svelte-porghq.svelte-porghq{flex-shrink:0;min-width:120px}.search-result-author.svelte-porghq.svelte-porghq{font-weight:600;color:var(--text-color);font-size:0.9em;font-family:monospace}.search-result-kind.svelte-porghq.svelte-porghq{display:flex;align-items:center;gap:0.5em;margin-top:0.25em}.kind-number.svelte-porghq.svelte-porghq{background:var(--primary);color:var(--text-color);padding:0.1em 0.4em;border-radius:0.25rem;font-size:0.7em;font-weight:600;font-family:monospace}.kind-name.svelte-porghq.svelte-porghq{font-size:0.8em;color:var(--text-color);opacity:0.8}.search-result-content.svelte-porghq.svelte-porghq{flex:1;min-width:0}.event-timestamp.svelte-porghq.svelte-porghq{font-size:0.8em;color:var(--text-color);opacity:0.6;margin-bottom:0.5em}.event-content-single-line.svelte-porghq.svelte-porghq{color:var(--text-color);line-height:1.4;word-wrap:break-word}.delete-btn.svelte-porghq.svelte-porghq{background:var(--danger);color:var(--text-color);border:none;padding:0.5em;border-radius:4px;cursor:pointer;font-size:0.9em;flex-shrink:0;transition:background-color 0.2s}.delete-btn.svelte-porghq.svelte-porghq:hover{background:var(--danger);filter:brightness(0.9)}.search-result-details.svelte-porghq.svelte-porghq{border-top:1px solid var(--border-color);padding:1em;background:var(--bg-color)}.json-container.svelte-porghq.svelte-porghq{position:relative}.event-json.svelte-porghq.svelte-porghq{background:var(--code-bg);padding:1em;border:0;font-size:0.8em;line-height:1.4;overflow-x:auto;margin:0;color:var(--code-text)}.copy-json-btn.svelte-porghq.svelte-porghq{position:absolute;top:0.5em;right:0.5em;background:var(--primary);color:var(--text-color);border:none;padding:0.25em 0.5em;border-radius:0.25rem;cursor:pointer;font-size:0.8em;opacity:0.8;transition:opacity 0.2s}.copy-json-btn.svelte-porghq.svelte-porghq:hover{opacity:1}.no-results.svelte-porghq.svelte-porghq{text-align:center;padding:2em;color:var(--text-color);opacity:0.7}.loading-search.svelte-porghq.svelte-porghq{text-align:center;padding:2em;color:var(--text-color)}.spinner.svelte-porghq.svelte-porghq{width:20px;height:20px;border:2px solid var(--border-color);border-top:2px solid var(--primary);border-radius:50%;animation:svelte-porghq-spin 1s linear infinite;margin:0 auto 1em}@keyframes svelte-porghq-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}} .filter-display.svelte-1tyqaa5.svelte-1tyqaa5{background:var(--card-bg);border:1px solid var(--border-color);border-radius:8px;margin:1em;overflow:hidden}.filter-display-header.svelte-1tyqaa5.svelte-1tyqaa5{display:flex;justify-content:space-between;align-items:center;padding:0.75em 1em;background:var(--bg-color);border-bottom:1px solid var(--border-color)}.filter-display-header.svelte-1tyqaa5 h3.svelte-1tyqaa5{margin:0;font-size:1em;font-weight:600;color:var(--text-color)}.sweep-btn.svelte-1tyqaa5.svelte-1tyqaa5{background:var(--danger);color:var(--text-color);border:none;padding:0.5em 1em;border-radius:4px;cursor:pointer;font-size:0.9em;font-weight:600;transition:all 0.2s}.sweep-btn.svelte-1tyqaa5.svelte-1tyqaa5:hover{filter:brightness(0.9);transform:translateY(-1px);box-shadow:0 2px 8px rgba(255, 0, 0, 0.3)}.filter-json-container.svelte-1tyqaa5.svelte-1tyqaa5{padding:1em;max-height:200px;overflow:auto}.filter-json.svelte-1tyqaa5.svelte-1tyqaa5{background:var(--code-bg);padding:1em;border-radius:4px;font-family:'Courier New', Courier, monospace;font-size:0.85em;line-height:1.5;color:var(--code-text);margin:0;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;overflow-wrap:anywhere}.filter-json-container.svelte-1tyqaa5.svelte-1tyqaa5::-webkit-scrollbar{width:8px;height:8px}.filter-json-container.svelte-1tyqaa5.svelte-1tyqaa5::-webkit-scrollbar-track{background:var(--bg-color)}.filter-json-container.svelte-1tyqaa5.svelte-1tyqaa5::-webkit-scrollbar-thumb{background:var(--border-color);border-radius:4px}.filter-json-container.svelte-1tyqaa5.svelte-1tyqaa5::-webkit-scrollbar-thumb:hover{background:var(--primary)} -html,body{margin:0;padding:0;overflow:hidden;height:100%;--bg-color:#ddd;--header-bg:#eee;--sidebar-bg:#eee;--card-bg:#f8f9fa;--panel-bg:#f8f9fa;--border-color:#dee2e6;--text-color:#444444;--text-muted:#6c757d;--input-border:#ccc;--input-bg:#ffffff;--input-text-color:#495057;--button-bg:#ddd;--button-hover-bg:#eee;--button-text:#444444;--button-hover-border:#adb5bd;--primary:#00bcd4;--primary-bg:rgba(0, 188, 212, 0.1);--secondary:#6c757d;--success:#28a745;--success-bg:#d4edda;--success-text:#155724;--info:#17a2b8;--warning:#ff3e00;--warning-bg:#fff3cd;--danger:#dc3545;--danger-bg:#f8d7da;--danger-text:#721c24;--error-bg:#f8d7da;--error-text:#721c24;--code-bg:#f8f9fa;--code-text:#495057;--tab-inactive-bg:#bbb;--accent-color:#007bff;--accent-hover-color:#0056b3}body.dark-theme{--bg-color:#263238;--header-bg:#1e272c;--sidebar-bg:#1e272c;--card-bg:#37474f;--panel-bg:#37474f;--border-color:#404040;--text-color:#ffffff;--text-muted:#adb5bd;--input-border:#555;--input-bg:#37474f;--input-text-color:#ffffff;--button-bg:#263238;--button-hover-bg:#1e272c;--button-text:#ffffff;--button-hover-border:#6c757d;--primary:#00bcd4;--primary-bg:rgba(0, 188, 212, 0.2);--secondary:#6c757d;--success:#28a745;--success-bg:#1e4620;--success-text:#d4edda;--info:#17a2b8;--warning:#ff3e00;--warning-bg:#4d1f00;--danger:#dc3545;--danger-bg:#4d1319;--danger-text:#f8d7da;--error-bg:#4d1319;--error-text:#f8d7da;--code-bg:#1e272c;--code-text:#ffffff;--tab-inactive-bg:#1a1a1a;--accent-color:#007bff;--accent-hover-color:#0056b3}.login-btn.svelte-u3u5mw.svelte-u3u5mw{padding:0.5em 1em;border:none;border-radius:6px;background-color:#4caf50;color:var(--text-color);cursor:pointer;font-size:1rem;font-weight:500;transition:background-color 0.2s;display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;margin:0 auto;padding:0.5em 1em}.login-btn.svelte-u3u5mw.svelte-u3u5mw:hover{background-color:#45a049}.acl-mode-warning.svelte-u3u5mw.svelte-u3u5mw{padding:1em;background-color:#fff3cd;border:1px solid #ffeaa7;border-radius:8px;color:#856404;margin:20px 0}.acl-mode-warning.svelte-u3u5mw h3.svelte-u3u5mw{margin:0 0 15px 0;color:#856404}.acl-mode-warning.svelte-u3u5mw p.svelte-u3u5mw{margin:10px 0;line-height:1.5}.acl-mode-warning.svelte-u3u5mw code.svelte-u3u5mw{background-color:#f8f9fa;padding:2px 6px;border-radius:4px;font-family:monospace;color:#495057}.app-container.svelte-u3u5mw.svelte-u3u5mw{display:flex;margin-top:3em;height:calc(100vh - 3em)}.main-content.svelte-u3u5mw.svelte-u3u5mw{position:fixed;left:200px;top:3em;right:0;bottom:0;padding:0;overflow-y:auto;background-color:var(--bg-color);color:var(--text-color);display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:column;display:flex}.welcome-message.svelte-u3u5mw.svelte-u3u5mw{text-align:center}.welcome-message.svelte-u3u5mw p.svelte-u3u5mw{font-size:1.2rem}@media(max-width: 640px){.main-content.svelte-u3u5mw.svelte-u3u5mw{left:160px;padding:1rem}}.logout-btn.svelte-u3u5mw.svelte-u3u5mw{padding:0.5rem 1rem;border:none;border-radius:6px;background-color:var(--warning);color:var(--text-color);cursor:pointer;font-size:1rem;font-weight:500;transition:background-color 0.2s;display:flex;align-items:center;justify-content:center;gap:0.5rem}.logout-btn.svelte-u3u5mw.svelte-u3u5mw:hover{background-color:#e53935}.logout-btn.floating.svelte-u3u5mw.svelte-u3u5mw{position:absolute;top:0.5em;right:0.5em;z-index:10;box-shadow:0 2px 8px rgba(0, 0, 0, 0.3)}.drawer-overlay.svelte-u3u5mw.svelte-u3u5mw{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.5);z-index:1000;display:flex;justify-content:flex-end}.settings-drawer.svelte-u3u5mw.svelte-u3u5mw{width:640px;height:100%;background:var(--bg-color);overflow-y:auto;animation:svelte-u3u5mw-slideIn 0.3s ease}@keyframes svelte-u3u5mw-slideIn{from{transform:translateX(100%)}to{transform:translateX(0)}}.drawer-header.svelte-u3u5mw.svelte-u3u5mw{display:flex;align-items:center;justify-content:space-between;background:var(--header-bg)}.drawer-header.svelte-u3u5mw h2.svelte-u3u5mw{margin:0;color:var(--text-color);font-size:1em;padding:1rem}.close-btn.svelte-u3u5mw.svelte-u3u5mw{background:none;border:none;font-size:1em;cursor:pointer;color:var(--text-color);padding:0.5em;transition:background-color 0.2s;align-items:center}.close-btn.svelte-u3u5mw.svelte-u3u5mw:hover{background:var(--button-hover-bg)}.profile-section.svelte-u3u5mw.svelte-u3u5mw{margin-bottom:2rem}.profile-hero.svelte-u3u5mw.svelte-u3u5mw{position:relative}.profile-banner.svelte-u3u5mw.svelte-u3u5mw{width:100%;height:160px;object-fit:cover;border-radius:0;display:block}.profile-avatar.svelte-u3u5mw.svelte-u3u5mw,.profile-avatar-placeholder.svelte-u3u5mw.svelte-u3u5mw{width:72px;height:72px;border-radius:50%;object-fit:cover;flex-shrink:0;box-shadow:0 2px 8px rgba(0, 0, 0, 0.25);border:2px solid var(--bg-color)}.overlap.svelte-u3u5mw.svelte-u3u5mw{position:absolute;left:12px;bottom:-36px;z-index:2;background:var(--button-hover-bg);display:flex;align-items:center;justify-content:center;font-size:1.5rem}.name-row.svelte-u3u5mw.svelte-u3u5mw{position:absolute;left:calc(12px + 72px + 12px);bottom:8px;right:12px;display:flex;align-items:baseline;gap:8px;z-index:1;background:var(--bg-color);padding:0.2em 0.5em;border-radius:0.5em;width:fit-content}.profile-username.svelte-u3u5mw.svelte-u3u5mw{margin:0;font-size:1.1rem;color:var(--text-color)}.profile-nip05-inline.svelte-u3u5mw.svelte-u3u5mw{font-size:0.85rem;color:var(--text-color);font-family:monospace;opacity:0.95}.about-card.svelte-u3u5mw.svelte-u3u5mw{background:var(--header-bg);padding:12px 12px 12px 96px;position:relative;word-break:auto-phrase}.profile-about.svelte-u3u5mw.svelte-u3u5mw{margin:0;color:var(--text-color);font-size:0.9rem;line-height:1.4}.profile-loading-section.svelte-u3u5mw.svelte-u3u5mw{padding:1rem;text-align:center;position:relative}.profile-loading-section.svelte-u3u5mw h3.svelte-u3u5mw{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem}.profile-loading-section.svelte-u3u5mw p.svelte-u3u5mw{margin:0 0 1rem 0;color:var(--text-color);opacity:0.8}.retry-profile-btn.svelte-u3u5mw.svelte-u3u5mw{padding:0.5rem 1rem;background:var(--primary);color:var(--text-color);border:none;border-radius:4px;cursor:pointer;font-size:0.9rem;margin-bottom:1rem;transition:background-color 0.2s}.retry-profile-btn.svelte-u3u5mw.svelte-u3u5mw:hover{background:#00acc1}.user-pubkey-display.svelte-u3u5mw.svelte-u3u5mw{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.7;background:var(--button-bg);padding:0.5rem;border-radius:4px;word-break:break-all}.managed-acl-view.svelte-u3u5mw.svelte-u3u5mw{padding:20px;max-width:1200px;margin:0;background:var(--header-bg);color:var(--text-color);border-radius:8px}.refresh-btn.svelte-u3u5mw.svelte-u3u5mw{padding:0.5rem 1rem;background:var(--primary);color:var(--text-color);border:none;border-radius:4px;cursor:pointer;font-size:0.875rem;font-weight:500;transition:background-color 0.2s;display:inline-flex;align-items:center;gap:0.25rem;height:2em;margin:1em}.refresh-btn.svelte-u3u5mw.svelte-u3u5mw:hover{background:#00acc1}@keyframes svelte-u3u5mw-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.view-as-section.svelte-u3u5mw.svelte-u3u5mw{color:var(--text-color);padding:1rem;border-radius:0.5em;margin-bottom:1rem}.view-as-section.svelte-u3u5mw h3.svelte-u3u5mw{margin-top:0;margin-bottom:0.5rem;font-size:1rem;color:var(--primary)}.view-as-section.svelte-u3u5mw p.svelte-u3u5mw{margin:0.5rem 0;font-size:0.9rem;opacity:0.8}.radio-group.svelte-u3u5mw.svelte-u3u5mw{display:flex;flex-direction:column;gap:0.5rem}.radio-label.svelte-u3u5mw.svelte-u3u5mw{display:flex;align-items:center;gap:0.5rem;cursor:pointer;padding:0.25rem;border-radius:0.5em;transition:background 0.2s}.radio-label.svelte-u3u5mw.svelte-u3u5mw:hover{background:rgba(255, 255, 255, 0.1)}.radio-label.svelte-u3u5mw input.svelte-u3u5mw{margin:0}.avatar-placeholder.svelte-u3u5mw.svelte-u3u5mw{width:1.5rem;height:1.5rem;border-radius:50%;background:var(--button-bg);display:flex;align-items:center;justify-content:center;font-size:0.7rem}.kind-number.svelte-u3u5mw.svelte-u3u5mw{background:var(--primary);color:var(--text-color);padding:0.125rem 0.375rem;border-radius:0.5em;font-size:0.7rem;font-weight:500;font-family:monospace}.kind-name.svelte-u3u5mw.svelte-u3u5mw{font-size:0.75rem;color:var(--text-color);opacity:0.7;font-weight:500}.event-timestamp.svelte-u3u5mw.svelte-u3u5mw{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.event-content-single-line.svelte-u3u5mw.svelte-u3u5mw{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.delete-btn.svelte-u3u5mw.svelte-u3u5mw{flex-shrink:0;background:none;border:none;cursor:pointer;padding:0.2rem;border-radius:0.5em;transition:background-color 0.2s;font-size:1.6rem;display:flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem}.delete-btn.svelte-u3u5mw.svelte-u3u5mw:hover{background:var(--warning);color:var(--text-color)}.json-container.svelte-u3u5mw.svelte-u3u5mw{position:relative}.copy-json-btn.svelte-u3u5mw.svelte-u3u5mw{color:var(--text-color);background:var(--accent-color);border:0;border-radius:0.5rem;padding:0.5rem;font-size:1rem;cursor:pointer;width:auto;height:auto;display:flex;align-items:center;justify-content:center}.copy-json-btn.svelte-u3u5mw.svelte-u3u5mw:hover{background:var(--accent-hover-color)}.event-json.svelte-u3u5mw.svelte-u3u5mw{background:var(--bg-color);padding:1rem;margin:0;font-family:"Courier New", monospace;font-size:0.8rem;line-height:1.4;color:var(--text-color);white-space:pre-wrap;word-break:break-word;overflow-x:auto}.no-events.svelte-u3u5mw.svelte-u3u5mw{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-spinner.svelte-u3u5mw.svelte-u3u5mw{width:2rem;height:2rem;border:3px solid var(--border-color);border-top:3px solid var(--primary);border-radius:50%;animation:svelte-u3u5mw-spin 1s linear infinite;margin:0 auto 1rem auto}@keyframes svelte-u3u5mw-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.search-results-view.svelte-u3u5mw.svelte-u3u5mw{position:fixed;top:3em;left:200px;right:0;bottom:0;background:var(--bg-color);color:var(--text-color);display:flex;flex-direction:column;overflow:hidden}.search-results-header.svelte-u3u5mw.svelte-u3u5mw{padding:0.5rem 1rem;background:var(--header-bg);border-bottom:1px solid var(--border-color);flex-shrink:0;display:flex;justify-content:space-between;align-items:center;height:2.5em}.search-results-header.svelte-u3u5mw h2.svelte-u3u5mw{margin:0;font-size:1rem;font-weight:600;color:var(--text-color)}.search-results-content.svelte-u3u5mw.svelte-u3u5mw{flex:1;overflow-y:auto;padding:0}.search-result-item.svelte-u3u5mw.svelte-u3u5mw{border-bottom:1px solid var(--border-color);transition:background-color 0.2s}.search-result-item.svelte-u3u5mw.svelte-u3u5mw:hover{background:var(--button-hover-bg)}.search-result-item.expanded.svelte-u3u5mw.svelte-u3u5mw{background:var(--button-hover-bg)}.search-result-row.svelte-u3u5mw.svelte-u3u5mw{display:flex;align-items:center;padding:0.75rem 1rem;cursor:pointer;gap:0.75rem;min-height:3rem}.search-result-avatar.svelte-u3u5mw.svelte-u3u5mw{flex-shrink:0;width:2rem;height:2rem;display:flex;align-items:center;justify-content:center}.search-result-info.svelte-u3u5mw.svelte-u3u5mw{flex-shrink:0;width:12rem;display:flex;flex-direction:column;gap:0.25rem}.search-result-author.svelte-u3u5mw.svelte-u3u5mw{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.8}.search-result-kind.svelte-u3u5mw.svelte-u3u5mw{display:flex;align-items:center;gap:0.5rem}.search-result-content.svelte-u3u5mw.svelte-u3u5mw{flex:1;color:var(--text-color);font-size:0.9rem;line-height:1.3;word-break:break-word}.search-result-content.svelte-u3u5mw .event-timestamp.svelte-u3u5mw{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.search-result-content.svelte-u3u5mw .event-content-single-line.svelte-u3u5mw{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.search-result-details.svelte-u3u5mw.svelte-u3u5mw{border-top:1px solid var(--border-color);background:var(--header-bg);padding:1rem}.no-search-results.svelte-u3u5mw.svelte-u3u5mw{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.no-search-results.svelte-u3u5mw p.svelte-u3u5mw{margin:0;font-size:1rem}.loading-search-results.svelte-u3u5mw.svelte-u3u5mw{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-search-results.svelte-u3u5mw p.svelte-u3u5mw{margin:0;font-size:0.9rem}.end-of-search-results.svelte-u3u5mw.svelte-u3u5mw{padding:1rem;text-align:center;color:var(--text-color);opacity:0.5;font-size:0.8rem;border-top:1px solid var(--border-color)}.end-of-search-results.svelte-u3u5mw p.svelte-u3u5mw{margin:0}@media(max-width: 1280px){.main-content.svelte-u3u5mw.svelte-u3u5mw{left:60px}.search-results-view.svelte-u3u5mw.svelte-u3u5mw{left:60px}}@media(max-width: 640px){.settings-drawer.svelte-u3u5mw.svelte-u3u5mw{width:100%}.name-row.svelte-u3u5mw.svelte-u3u5mw{left:calc(8px + 56px + 8px);bottom:6px;right:8px;gap:6px;background:var(--bg-color);padding:0.2em 0.5em;border-radius:0.5em;width:fit-content}.profile-username.svelte-u3u5mw.svelte-u3u5mw{font-size:1rem;color:var(--text-color)}.profile-nip05-inline.svelte-u3u5mw.svelte-u3u5mw{font-size:0.8rem;color:var(--text-color)}.managed-acl-view.svelte-u3u5mw.svelte-u3u5mw{padding:1rem}.kind-name.svelte-u3u5mw.svelte-u3u5mw{font-size:0.7rem}.search-results-view.svelte-u3u5mw.svelte-u3u5mw{left:160px}.search-result-info.svelte-u3u5mw.svelte-u3u5mw{width:8rem}.search-result-author.svelte-u3u5mw.svelte-u3u5mw{font-size:0.7rem}.search-result-content.svelte-u3u5mw.svelte-u3u5mw{font-size:0.8rem}}.recovery-tab.svelte-u3u5mw.svelte-u3u5mw{padding:20px;width:100%;max-width:1200px;margin:0;box-sizing:border-box}.recovery-tab.svelte-u3u5mw h3.svelte-u3u5mw{margin:0 0 10px 0;color:var(--text-color)}.recovery-tab.svelte-u3u5mw p.svelte-u3u5mw{margin:0;color:var(--text-color);opacity:0.7;padding:0.5em}.recovery-controls-card.svelte-u3u5mw.svelte-u3u5mw{background-color:transparent;border:none;border-radius:0.5em;padding:0}.recovery-controls.svelte-u3u5mw.svelte-u3u5mw{display:flex;gap:20px;align-items:center;flex-wrap:wrap}.kind-selector.svelte-u3u5mw.svelte-u3u5mw{display:flex;flex-direction:column;gap:5px}.kind-selector.svelte-u3u5mw label.svelte-u3u5mw{font-weight:500;color:var(--text-color)}.kind-selector.svelte-u3u5mw select.svelte-u3u5mw{padding:8px 12px;border:1px solid var(--border-color);border-radius:0.5em;background:var(--bg-color);color:var(--text-color);min-width:300px}.custom-kind-input.svelte-u3u5mw.svelte-u3u5mw{display:flex;flex-direction:column;gap:5px}.custom-kind-input.svelte-u3u5mw label.svelte-u3u5mw{font-weight:500;color:var(--text-color)}.custom-kind-input.svelte-u3u5mw input.svelte-u3u5mw{padding:8px 12px;border:1px solid var(--border-color);border-radius:0.5em;background:var(--bg-color);color:var(--text-color);min-width:200px}.custom-kind-input.svelte-u3u5mw input.svelte-u3u5mw::placeholder{color:var(--text-color);opacity:0.6}.recovery-results.svelte-u3u5mw.svelte-u3u5mw{margin-top:20px}.loading.svelte-u3u5mw.svelte-u3u5mw,.no-events.svelte-u3u5mw.svelte-u3u5mw{text-align:left;padding:40px 20px;color:var(--text-color);opacity:0.7}.events-list.svelte-u3u5mw.svelte-u3u5mw{display:flex;flex-direction:column;gap:15px}.event-item.svelte-u3u5mw.svelte-u3u5mw{background:var(--surface-bg);border:2px solid var(--primary);border-radius:0.5em;padding:20px;transition:all 0.2s ease;background:var(--header-bg)}.event-item.old-version.svelte-u3u5mw.svelte-u3u5mw{opacity:0.85;border:none;background:var(--header-bg)}.event-header.svelte-u3u5mw.svelte-u3u5mw{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px;flex-wrap:wrap;gap:10px}.event-header-left.svelte-u3u5mw.svelte-u3u5mw{display:flex;align-items:center;gap:15px;flex-wrap:wrap}.event-header-actions.svelte-u3u5mw.svelte-u3u5mw{display:flex;align-items:center;gap:8px}.event-kind.svelte-u3u5mw.svelte-u3u5mw{font-weight:600;color:var(--primary)}.event-timestamp.svelte-u3u5mw.svelte-u3u5mw{color:var(--text-color);font-size:0.9em;opacity:0.7}.repost-all-button.svelte-u3u5mw.svelte-u3u5mw{background:#059669;color:var(--text-color);border:none;padding:6px 12px;border-radius:0.5em;cursor:pointer;font-size:0.9em;transition:background 0.2s ease;margin-right:8px}.repost-all-button.svelte-u3u5mw.svelte-u3u5mw:hover{background:#047857}.repost-button.svelte-u3u5mw.svelte-u3u5mw{background:var(--primary);color:var(--text-color);border:none;padding:6px 12px;border-radius:0.5em;cursor:pointer;font-size:0.9em;transition:background 0.2s ease}.repost-button.svelte-u3u5mw.svelte-u3u5mw:hover{background:#00acc1}.event-content.svelte-u3u5mw.svelte-u3u5mw{margin-bottom:15px}.load-more.svelte-u3u5mw.svelte-u3u5mw{width:100%;padding:12px;background:var(--primary);color:var(--text-color);border:none;border-radius:0.5em;cursor:pointer;font-size:1em;margin-top:20px;transition:background 0.2s ease}.load-more.svelte-u3u5mw.svelte-u3u5mw:hover:not(:disabled){background:#00acc1}.load-more.svelte-u3u5mw.svelte-u3u5mw:disabled{opacity:0.6;cursor:not-allowed}body.dark-theme .event-item.old-version.svelte-u3u5mw.svelte-u3u5mw{background:var(--header-bg);border:none} +.modal-overlay.svelte-6a0diz.svelte-6a0diz{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;z-index:1000}.modal.svelte-6a0diz.svelte-6a0diz{background:var(--bg-color);border-radius:8px;box-shadow:0 4px 20px rgba(0, 0, 0, 0.3);width:90%;max-width:550px;max-height:90vh;overflow-y:auto;border:1px solid var(--border-color)}.modal-header.svelte-6a0diz.svelte-6a0diz{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--border-color)}.modal-header.svelte-6a0diz h2.svelte-6a0diz{margin:0;color:var(--text-color);font-size:1.25rem}.close-btn.svelte-6a0diz.svelte-6a0diz{background:none;border:none;font-size:1.5rem;cursor:pointer;color:var(--text-color);padding:0;width:30px;height:30px;display:flex;align-items:center;justify-content:center;border-radius:50%;transition:background-color 0.2s}.close-btn.svelte-6a0diz.svelte-6a0diz:hover{background-color:var(--tab-hover-bg)}.modal-content.svelte-6a0diz.svelte-6a0diz{padding:16px 20px;display:flex;flex-direction:column;gap:16px}.section-header.svelte-6a0diz.svelte-6a0diz{font-size:0.85rem;color:var(--muted-foreground);font-weight:600;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:8px}.add-relay-section.svelte-6a0diz.svelte-6a0diz{padding-bottom:16px;border-bottom:1px solid var(--border-color)}.input-row.svelte-6a0diz.svelte-6a0diz{display:flex;gap:8px}.url-input.svelte-6a0diz.svelte-6a0diz{flex:1;padding:10px 12px;border:1px solid var(--input-border);border-radius:6px;font-size:0.95rem;font-family:monospace;background:var(--bg-color);color:var(--text-color)}.url-input.svelte-6a0diz.svelte-6a0diz:focus{outline:none;border-color:var(--primary)}.url-input.svelte-6a0diz.svelte-6a0diz:disabled{opacity:0.6;cursor:not-allowed}.add-btn.svelte-6a0diz.svelte-6a0diz{padding:10px 20px;background:var(--primary);color:white;border:none;border-radius:6px;cursor:pointer;font-size:0.95rem;font-weight:500;white-space:nowrap;transition:background-color 0.2s}.add-btn.svelte-6a0diz.svelte-6a0diz:hover:not(:disabled){background:#00acc1}.add-btn.svelte-6a0diz.svelte-6a0diz:disabled{background:#ccc;cursor:not-allowed}.error-message.svelte-6a0diz.svelte-6a0diz{padding:10px 12px;background:#fee2e2;color:#dc2626;border-radius:6px;font-size:0.9rem}.dark.svelte-6a0diz .error-message.svelte-6a0diz{background:#450a0a;color:#fca5a5}.saved-relays-section.svelte-6a0diz.svelte-6a0diz{flex:1}.saved-relays-list.svelte-6a0diz.svelte-6a0diz{display:flex;flex-direction:column;gap:6px}.relay-item.svelte-6a0diz.svelte-6a0diz{display:flex;align-items:center;gap:8px;padding:4px;border-radius:6px;background:var(--muted);transition:background-color 0.2s}.relay-item.current.svelte-6a0diz.svelte-6a0diz{background:rgba(16, 185, 129, 0.15)}.relay-item.connecting.svelte-6a0diz.svelte-6a0diz{background:rgba(234, 179, 8, 0.15)}.relay-connect-btn.svelte-6a0diz.svelte-6a0diz{flex:1;display:flex;align-items:center;gap:10px;padding:10px 12px;background:transparent;border:none;cursor:pointer;text-align:left;border-radius:4px;transition:background-color 0.15s}.relay-connect-btn.svelte-6a0diz.svelte-6a0diz:hover:not(:disabled){background:var(--tab-hover-bg)}.relay-connect-btn.svelte-6a0diz.svelte-6a0diz:disabled{cursor:not-allowed;opacity:0.7}.relay-status-dot.svelte-6a0diz.svelte-6a0diz{width:8px;height:8px;border-radius:50%;background:var(--muted-foreground);flex-shrink:0}.relay-status-dot.connected.svelte-6a0diz.svelte-6a0diz{background:var(--success)}.relay-url-label.svelte-6a0diz.svelte-6a0diz{flex:1;color:var(--text-color);font-family:monospace;font-size:0.9rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.current-badge.svelte-6a0diz.svelte-6a0diz{font-size:0.7rem;padding:2px 8px;background:var(--success);color:white;border-radius:4px;font-weight:500;flex-shrink:0}.connecting-badge.svelte-6a0diz.svelte-6a0diz{font-size:0.7rem;padding:2px 8px;background:var(--warning);color:white;border-radius:4px;font-weight:500;flex-shrink:0}.relay-remove-btn.svelte-6a0diz.svelte-6a0diz{padding:6px 12px;background:transparent;border:1px solid var(--border-color);border-radius:4px;color:var(--muted-foreground);cursor:pointer;font-size:0.8rem;transition:background-color 0.2s, color 0.2s, border-color 0.2s;flex-shrink:0}.relay-remove-btn.svelte-6a0diz.svelte-6a0diz:hover:not(:disabled){background:var(--danger);border-color:var(--danger);color:white}.relay-remove-btn.svelte-6a0diz.svelte-6a0diz:disabled{cursor:not-allowed;opacity:0.5}.empty-state.svelte-6a0diz.svelte-6a0diz{padding:20px;text-align:center;color:var(--muted-foreground);font-size:0.9rem}.button-group.svelte-6a0diz.svelte-6a0diz{display:flex;justify-content:flex-end;margin-top:8px;padding-top:16px;border-top:1px solid var(--border-color)}.done-btn.svelte-6a0diz.svelte-6a0diz{padding:10px 24px;background:var(--primary);color:white;border:none;border-radius:6px;cursor:pointer;font-size:0.95rem;font-weight:500;transition:background-color 0.2s}.done-btn.svelte-6a0diz.svelte-6a0diz:hover{background:#00acc1} +html,body{margin:0;padding:0;overflow:hidden;height:100%;--bg-color:#ddd;--header-bg:#eee;--sidebar-bg:#eee;--card-bg:#f8f9fa;--panel-bg:#f8f9fa;--border-color:#dee2e6;--text-color:#444444;--text-muted:#6c757d;--input-border:#ccc;--input-bg:#ffffff;--input-text-color:#495057;--button-bg:#ddd;--button-hover-bg:#eee;--button-text:#444444;--button-hover-border:#adb5bd;--primary:#00bcd4;--primary-bg:rgba(0, 188, 212, 0.1);--secondary:#6c757d;--success:#28a745;--success-bg:#d4edda;--success-text:#155724;--info:#17a2b8;--warning:#ff3e00;--warning-bg:#fff3cd;--danger:#dc3545;--danger-bg:#f8d7da;--danger-text:#721c24;--error-bg:#f8d7da;--error-text:#721c24;--code-bg:#f8f9fa;--code-text:#495057;--tab-inactive-bg:#bbb;--accent-color:#007bff;--accent-hover-color:#0056b3}body.dark-theme{--bg-color:#263238;--header-bg:#1e272c;--sidebar-bg:#1e272c;--card-bg:#37474f;--panel-bg:#37474f;--border-color:#404040;--text-color:#ffffff;--text-muted:#adb5bd;--input-border:#555;--input-bg:#37474f;--input-text-color:#ffffff;--button-bg:#263238;--button-hover-bg:#1e272c;--button-text:#ffffff;--button-hover-border:#6c757d;--primary:#00bcd4;--primary-bg:rgba(0, 188, 212, 0.2);--secondary:#6c757d;--success:#28a745;--success-bg:#1e4620;--success-text:#d4edda;--info:#17a2b8;--warning:#ff3e00;--warning-bg:#4d1f00;--danger:#dc3545;--danger-bg:#4d1319;--danger-text:#f8d7da;--error-bg:#4d1319;--error-text:#f8d7da;--code-bg:#1e272c;--code-text:#ffffff;--tab-inactive-bg:#1a1a1a;--accent-color:#007bff;--accent-hover-color:#0056b3}.login-btn.svelte-1qbmv87.svelte-1qbmv87{padding:0.5em 1em;border:none;border-radius:6px;background-color:#4caf50;color:var(--text-color);cursor:pointer;font-size:1rem;font-weight:500;transition:background-color 0.2s;display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;margin:0 auto;padding:0.5em 1em}.login-btn.svelte-1qbmv87.svelte-1qbmv87:hover{background-color:#45a049}.acl-mode-warning.svelte-1qbmv87.svelte-1qbmv87{padding:1em;background-color:#fff3cd;border:1px solid #ffeaa7;border-radius:8px;color:#856404;margin:20px 0}.acl-mode-warning.svelte-1qbmv87 h3.svelte-1qbmv87{margin:0 0 15px 0;color:#856404}.acl-mode-warning.svelte-1qbmv87 p.svelte-1qbmv87{margin:10px 0;line-height:1.5}.acl-mode-warning.svelte-1qbmv87 code.svelte-1qbmv87{background-color:#f8f9fa;padding:2px 6px;border-radius:4px;font-family:monospace;color:#495057}.app-container.svelte-1qbmv87.svelte-1qbmv87{display:flex;margin-top:3em;height:calc(100vh - 3em)}.main-content.svelte-1qbmv87.svelte-1qbmv87{position:fixed;left:200px;top:3em;right:0;bottom:0;padding:0;overflow-y:auto;background-color:var(--bg-color);color:var(--text-color);display:flex;align-items:flex-start;justify-content:flex-start;flex-direction:column;display:flex}.welcome-message.svelte-1qbmv87.svelte-1qbmv87{text-align:center}.welcome-message.svelte-1qbmv87 p.svelte-1qbmv87{font-size:1.2rem}.logout-btn.svelte-1qbmv87.svelte-1qbmv87{padding:0.5rem 1rem;border:none;border-radius:6px;background-color:var(--warning);color:var(--text-color);cursor:pointer;font-size:1rem;font-weight:500;transition:background-color 0.2s;display:flex;align-items:center;justify-content:center;gap:0.5rem}.logout-btn.svelte-1qbmv87.svelte-1qbmv87:hover{background-color:#e53935}.logout-btn.floating.svelte-1qbmv87.svelte-1qbmv87{position:absolute;top:0.5em;right:0.5em;z-index:10;box-shadow:0 2px 8px rgba(0, 0, 0, 0.3)}.drawer-overlay.svelte-1qbmv87.svelte-1qbmv87{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.5);z-index:1000;display:flex;justify-content:flex-end}.settings-drawer.svelte-1qbmv87.svelte-1qbmv87{width:640px;height:100%;background:var(--bg-color);overflow-y:auto;animation:svelte-1qbmv87-slideIn 0.3s ease}@keyframes svelte-1qbmv87-slideIn{from{transform:translateX(100%)}to{transform:translateX(0)}}.drawer-header.svelte-1qbmv87.svelte-1qbmv87{display:flex;align-items:center;justify-content:space-between;background:var(--header-bg)}.drawer-header.svelte-1qbmv87 h2.svelte-1qbmv87{margin:0;color:var(--text-color);font-size:1em;padding:1rem}.close-btn.svelte-1qbmv87.svelte-1qbmv87{background:none;border:none;font-size:1em;cursor:pointer;color:var(--text-color);padding:0.5em;transition:background-color 0.2s;align-items:center}.close-btn.svelte-1qbmv87.svelte-1qbmv87:hover{background:var(--button-hover-bg)}.profile-section.svelte-1qbmv87.svelte-1qbmv87{margin-bottom:2rem}.profile-hero.svelte-1qbmv87.svelte-1qbmv87{position:relative}.profile-banner.svelte-1qbmv87.svelte-1qbmv87{width:100%;height:160px;object-fit:cover;border-radius:0;display:block}.profile-avatar.svelte-1qbmv87.svelte-1qbmv87,.profile-avatar-placeholder.svelte-1qbmv87.svelte-1qbmv87{width:72px;height:72px;border-radius:50%;object-fit:cover;flex-shrink:0;box-shadow:0 2px 8px rgba(0, 0, 0, 0.25);border:2px solid var(--bg-color)}.overlap.svelte-1qbmv87.svelte-1qbmv87{position:absolute;left:12px;bottom:-36px;z-index:2;background:var(--button-hover-bg);display:flex;align-items:center;justify-content:center;font-size:1.5rem}.name-row.svelte-1qbmv87.svelte-1qbmv87{position:absolute;left:calc(12px + 72px + 12px);bottom:8px;right:12px;display:flex;align-items:baseline;gap:8px;z-index:1;background:var(--bg-color);padding:0.2em 0.5em;border-radius:0.5em;width:fit-content}.profile-username.svelte-1qbmv87.svelte-1qbmv87{margin:0;font-size:1.1rem;color:var(--text-color)}.profile-nip05-inline.svelte-1qbmv87.svelte-1qbmv87{font-size:0.85rem;color:var(--text-color);font-family:monospace;opacity:0.95}.about-card.svelte-1qbmv87.svelte-1qbmv87{background:var(--header-bg);padding:12px 12px 12px 96px;position:relative;word-break:auto-phrase}.profile-about.svelte-1qbmv87.svelte-1qbmv87{margin:0;color:var(--text-color);font-size:0.9rem;line-height:1.4}.profile-loading-section.svelte-1qbmv87.svelte-1qbmv87{padding:1rem;text-align:center;position:relative}.profile-loading-section.svelte-1qbmv87 h3.svelte-1qbmv87{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem}.profile-loading-section.svelte-1qbmv87 p.svelte-1qbmv87{margin:0 0 1rem 0;color:var(--text-color);opacity:0.8}.retry-profile-btn.svelte-1qbmv87.svelte-1qbmv87{padding:0.5rem 1rem;background:var(--primary);color:var(--text-color);border:none;border-radius:4px;cursor:pointer;font-size:0.9rem;margin-bottom:1rem;transition:background-color 0.2s}.retry-profile-btn.svelte-1qbmv87.svelte-1qbmv87:hover{background:#00acc1}.user-pubkey-display.svelte-1qbmv87.svelte-1qbmv87{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.7;background:var(--button-bg);padding:0.5rem;border-radius:4px;word-break:break-all}.managed-acl-view.svelte-1qbmv87.svelte-1qbmv87{padding:20px;max-width:1200px;margin:0;background:var(--header-bg);color:var(--text-color);border-radius:8px}.refresh-btn.svelte-1qbmv87.svelte-1qbmv87{padding:0.5rem 1rem;background:var(--primary);color:var(--text-color);border:none;border-radius:4px;cursor:pointer;font-size:0.875rem;font-weight:500;transition:background-color 0.2s;display:inline-flex;align-items:center;gap:0.25rem;height:2em;margin:1em}.refresh-btn.svelte-1qbmv87.svelte-1qbmv87:hover{background:#00acc1}@keyframes svelte-1qbmv87-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.view-as-section.svelte-1qbmv87.svelte-1qbmv87{color:var(--text-color);padding:1rem;border-radius:0.5em;margin-bottom:1rem}.view-as-section.svelte-1qbmv87 h3.svelte-1qbmv87{margin-top:0;margin-bottom:0.5rem;font-size:1rem;color:var(--primary)}.view-as-section.svelte-1qbmv87 p.svelte-1qbmv87{margin:0.5rem 0;font-size:0.9rem;opacity:0.8}.radio-group.svelte-1qbmv87.svelte-1qbmv87{display:flex;flex-direction:column;gap:0.5rem}.radio-label.svelte-1qbmv87.svelte-1qbmv87{display:flex;align-items:center;gap:0.5rem;cursor:pointer;padding:0.25rem;border-radius:0.5em;transition:background 0.2s}.radio-label.svelte-1qbmv87.svelte-1qbmv87:hover{background:rgba(255, 255, 255, 0.1)}.radio-label.svelte-1qbmv87 input.svelte-1qbmv87{margin:0}.avatar-placeholder.svelte-1qbmv87.svelte-1qbmv87{width:1.5rem;height:1.5rem;border-radius:50%;background:var(--button-bg);display:flex;align-items:center;justify-content:center;font-size:0.7rem}.kind-number.svelte-1qbmv87.svelte-1qbmv87{background:var(--primary);color:var(--text-color);padding:0.125rem 0.375rem;border-radius:0.5em;font-size:0.7rem;font-weight:500;font-family:monospace}.kind-name.svelte-1qbmv87.svelte-1qbmv87{font-size:0.75rem;color:var(--text-color);opacity:0.7;font-weight:500}.event-timestamp.svelte-1qbmv87.svelte-1qbmv87{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.event-content-single-line.svelte-1qbmv87.svelte-1qbmv87{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.delete-btn.svelte-1qbmv87.svelte-1qbmv87{flex-shrink:0;background:none;border:none;cursor:pointer;padding:0.2rem;border-radius:0.5em;transition:background-color 0.2s;font-size:1.6rem;display:flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem}.delete-btn.svelte-1qbmv87.svelte-1qbmv87:hover{background:var(--warning);color:var(--text-color)}.json-container.svelte-1qbmv87.svelte-1qbmv87{position:relative}.copy-json-btn.svelte-1qbmv87.svelte-1qbmv87{color:var(--text-color);background:var(--accent-color);border:0;border-radius:0.5rem;padding:0.5rem;font-size:1rem;cursor:pointer;width:auto;height:auto;display:flex;align-items:center;justify-content:center}.copy-json-btn.svelte-1qbmv87.svelte-1qbmv87:hover{background:var(--accent-hover-color)}.event-json.svelte-1qbmv87.svelte-1qbmv87{background:var(--bg-color);padding:1rem;margin:0;font-family:"Courier New", monospace;font-size:0.8rem;line-height:1.4;color:var(--text-color);white-space:pre-wrap;word-break:break-word;overflow-x:auto}.no-events.svelte-1qbmv87.svelte-1qbmv87{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-spinner.svelte-1qbmv87.svelte-1qbmv87{width:2rem;height:2rem;border:3px solid var(--border-color);border-top:3px solid var(--primary);border-radius:50%;animation:svelte-1qbmv87-spin 1s linear infinite;margin:0 auto 1rem auto}@keyframes svelte-1qbmv87-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.search-results-view.svelte-1qbmv87.svelte-1qbmv87{position:fixed;top:3em;left:200px;right:0;bottom:0;background:var(--bg-color);color:var(--text-color);display:flex;flex-direction:column;overflow:hidden}.search-results-header.svelte-1qbmv87.svelte-1qbmv87{padding:0.5rem 1rem;background:var(--header-bg);border-bottom:1px solid var(--border-color);flex-shrink:0;display:flex;justify-content:space-between;align-items:center;height:2.5em}.search-results-header.svelte-1qbmv87 h2.svelte-1qbmv87{margin:0;font-size:1rem;font-weight:600;color:var(--text-color)}.search-results-content.svelte-1qbmv87.svelte-1qbmv87{flex:1;overflow-y:auto;padding:0}.search-result-item.svelte-1qbmv87.svelte-1qbmv87{border-bottom:1px solid var(--border-color);transition:background-color 0.2s}.search-result-item.svelte-1qbmv87.svelte-1qbmv87:hover{background:var(--button-hover-bg)}.search-result-item.expanded.svelte-1qbmv87.svelte-1qbmv87{background:var(--button-hover-bg)}.search-result-row.svelte-1qbmv87.svelte-1qbmv87{display:flex;align-items:center;padding:0.75rem 1rem;cursor:pointer;gap:0.75rem;min-height:3rem}.search-result-avatar.svelte-1qbmv87.svelte-1qbmv87{flex-shrink:0;width:2rem;height:2rem;display:flex;align-items:center;justify-content:center}.search-result-info.svelte-1qbmv87.svelte-1qbmv87{flex-shrink:0;width:12rem;display:flex;flex-direction:column;gap:0.25rem}.search-result-author.svelte-1qbmv87.svelte-1qbmv87{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.8}.search-result-kind.svelte-1qbmv87.svelte-1qbmv87{display:flex;align-items:center;gap:0.5rem}.search-result-content.svelte-1qbmv87.svelte-1qbmv87{flex:1;color:var(--text-color);font-size:0.9rem;line-height:1.3;word-break:break-word}.search-result-content.svelte-1qbmv87 .event-timestamp.svelte-1qbmv87{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.search-result-content.svelte-1qbmv87 .event-content-single-line.svelte-1qbmv87{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.search-result-details.svelte-1qbmv87.svelte-1qbmv87{border-top:1px solid var(--border-color);background:var(--header-bg);padding:1rem}.no-search-results.svelte-1qbmv87.svelte-1qbmv87{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.no-search-results.svelte-1qbmv87 p.svelte-1qbmv87{margin:0;font-size:1rem}.loading-search-results.svelte-1qbmv87.svelte-1qbmv87{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-search-results.svelte-1qbmv87 p.svelte-1qbmv87{margin:0;font-size:0.9rem}.end-of-search-results.svelte-1qbmv87.svelte-1qbmv87{padding:1rem;text-align:center;color:var(--text-color);opacity:0.5;font-size:0.8rem;border-top:1px solid var(--border-color)}.end-of-search-results.svelte-1qbmv87 p.svelte-1qbmv87{margin:0}@media(max-width: 1280px){.main-content.svelte-1qbmv87.svelte-1qbmv87{left:60px}.search-results-view.svelte-1qbmv87.svelte-1qbmv87{left:60px}}@media(max-width: 640px){.main-content.svelte-1qbmv87.svelte-1qbmv87{left:0}.search-results-view.svelte-1qbmv87.svelte-1qbmv87{left:0}.settings-drawer.svelte-1qbmv87.svelte-1qbmv87{width:100%}.name-row.svelte-1qbmv87.svelte-1qbmv87{left:calc(8px + 56px + 8px);bottom:6px;right:8px;gap:6px;background:var(--bg-color);padding:0.2em 0.5em;border-radius:0.5em;width:fit-content}.profile-username.svelte-1qbmv87.svelte-1qbmv87{font-size:1rem;color:var(--text-color)}.profile-nip05-inline.svelte-1qbmv87.svelte-1qbmv87{font-size:0.8rem;color:var(--text-color)}.managed-acl-view.svelte-1qbmv87.svelte-1qbmv87{padding:1rem}.kind-name.svelte-1qbmv87.svelte-1qbmv87{font-size:0.7rem}.search-results-view.svelte-1qbmv87.svelte-1qbmv87{left:160px}.search-result-info.svelte-1qbmv87.svelte-1qbmv87{width:8rem}.search-result-author.svelte-1qbmv87.svelte-1qbmv87{font-size:0.7rem}.search-result-content.svelte-1qbmv87.svelte-1qbmv87{font-size:0.8rem}}.recovery-tab.svelte-1qbmv87.svelte-1qbmv87{padding:20px;width:100%;max-width:1200px;margin:0;box-sizing:border-box}.recovery-tab.svelte-1qbmv87 h3.svelte-1qbmv87{margin:0 0 10px 0;color:var(--text-color)}.recovery-tab.svelte-1qbmv87 p.svelte-1qbmv87{margin:0;color:var(--text-color);opacity:0.7;padding:0.5em}.recovery-controls-card.svelte-1qbmv87.svelte-1qbmv87{background-color:transparent;border:none;border-radius:0.5em;padding:0}.recovery-controls.svelte-1qbmv87.svelte-1qbmv87{display:flex;gap:20px;align-items:center;flex-wrap:wrap}.kind-selector.svelte-1qbmv87.svelte-1qbmv87{display:flex;flex-direction:column;gap:5px}.kind-selector.svelte-1qbmv87 label.svelte-1qbmv87{font-weight:500;color:var(--text-color)}.kind-selector.svelte-1qbmv87 select.svelte-1qbmv87{padding:8px 12px;border:1px solid var(--border-color);border-radius:0.5em;background:var(--bg-color);color:var(--text-color);min-width:300px}.custom-kind-input.svelte-1qbmv87.svelte-1qbmv87{display:flex;flex-direction:column;gap:5px}.custom-kind-input.svelte-1qbmv87 label.svelte-1qbmv87{font-weight:500;color:var(--text-color)}.custom-kind-input.svelte-1qbmv87 input.svelte-1qbmv87{padding:8px 12px;border:1px solid var(--border-color);border-radius:0.5em;background:var(--bg-color);color:var(--text-color);min-width:200px}.custom-kind-input.svelte-1qbmv87 input.svelte-1qbmv87::placeholder{color:var(--text-color);opacity:0.6}.recovery-results.svelte-1qbmv87.svelte-1qbmv87{margin-top:20px}.loading.svelte-1qbmv87.svelte-1qbmv87,.no-events.svelte-1qbmv87.svelte-1qbmv87{text-align:left;padding:40px 20px;color:var(--text-color);opacity:0.7}.events-list.svelte-1qbmv87.svelte-1qbmv87{display:flex;flex-direction:column;gap:15px}.event-item.svelte-1qbmv87.svelte-1qbmv87{background:var(--surface-bg);border:2px solid var(--primary);border-radius:0.5em;padding:20px;transition:all 0.2s ease;background:var(--header-bg)}.event-item.old-version.svelte-1qbmv87.svelte-1qbmv87{opacity:0.85;border:none;background:var(--header-bg)}.event-header.svelte-1qbmv87.svelte-1qbmv87{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px;flex-wrap:wrap;gap:10px}.event-header-left.svelte-1qbmv87.svelte-1qbmv87{display:flex;align-items:center;gap:15px;flex-wrap:wrap}.event-header-actions.svelte-1qbmv87.svelte-1qbmv87{display:flex;align-items:center;gap:8px}.event-kind.svelte-1qbmv87.svelte-1qbmv87{font-weight:600;color:var(--primary)}.event-timestamp.svelte-1qbmv87.svelte-1qbmv87{color:var(--text-color);font-size:0.9em;opacity:0.7}.repost-all-button.svelte-1qbmv87.svelte-1qbmv87{background:#059669;color:var(--text-color);border:none;padding:6px 12px;border-radius:0.5em;cursor:pointer;font-size:0.9em;transition:background 0.2s ease;margin-right:8px}.repost-all-button.svelte-1qbmv87.svelte-1qbmv87:hover{background:#047857}.repost-button.svelte-1qbmv87.svelte-1qbmv87{background:var(--primary);color:var(--text-color);border:none;padding:6px 12px;border-radius:0.5em;cursor:pointer;font-size:0.9em;transition:background 0.2s ease}.repost-button.svelte-1qbmv87.svelte-1qbmv87:hover{background:#00acc1}.event-content.svelte-1qbmv87.svelte-1qbmv87{margin-bottom:15px}.load-more.svelte-1qbmv87.svelte-1qbmv87{width:100%;padding:12px;background:var(--primary);color:var(--text-color);border:none;border-radius:0.5em;cursor:pointer;font-size:1em;margin-top:20px;transition:background 0.2s ease}.load-more.svelte-1qbmv87.svelte-1qbmv87:hover:not(:disabled){background:#00acc1}.load-more.svelte-1qbmv87.svelte-1qbmv87:disabled{opacity:0.6;cursor:not-allowed}body.dark-theme .event-item.old-version.svelte-1qbmv87.svelte-1qbmv87{background:var(--header-bg);border:none}.relay-section.svelte-1qbmv87.svelte-1qbmv87{margin-top:20px;padding-top:20px;border-top:1px solid var(--border-color)}.relay-section.svelte-1qbmv87 h3.svelte-1qbmv87{margin:0 0 12px 0;color:var(--text-color);font-size:1.1rem}.relay-info-card.svelte-1qbmv87.svelte-1qbmv87{background:var(--muted);padding:12px;border-radius:8px;margin-bottom:12px}.relay-name.svelte-1qbmv87.svelte-1qbmv87{font-weight:600;color:var(--text-color);margin-bottom:4px}.relay-description.svelte-1qbmv87.svelte-1qbmv87{font-size:0.9rem;color:var(--muted-foreground);margin-bottom:8px}.relay-url.svelte-1qbmv87.svelte-1qbmv87{font-family:monospace;font-size:0.85rem;color:var(--primary);word-break:break-all}.relay-disconnected.svelte-1qbmv87.svelte-1qbmv87{display:flex;align-items:center;gap:8px;color:var(--muted-foreground);margin-bottom:12px}.status-dot.svelte-1qbmv87.svelte-1qbmv87{width:8px;height:8px;border-radius:50%}.status-dot.disconnected.svelte-1qbmv87.svelte-1qbmv87{background:var(--danger)}.change-relay-btn.svelte-1qbmv87.svelte-1qbmv87{width:100%;padding:10px 16px;background:var(--primary);color:white;border:none;border-radius:6px;cursor:pointer;font-size:0.95rem;transition:background-color 0.2s}.change-relay-btn.svelte-1qbmv87.svelte-1qbmv87:hover{background:#00acc1} html, body { position: relative; diff --git a/app/web/dist/bundle.js b/app/web/dist/bundle.js index 359addc..7b93a98 100644 --- a/app/web/dist/bundle.js +++ b/app/web/dist/bundle.js @@ -1,25 +1,25 @@ -var app=function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function i(e){e.forEach(t)}function r(e){return"function"==typeof e}function s(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let o;function l(e,t){return o||(o=document.createElement("a")),o.href=t,e===o.href}const a="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function c(e,t){e.appendChild(t)}function u(e,t,n){e.insertBefore(t,n||null)}function d(e){e.parentNode&&e.parentNode.removeChild(e)}function f(e,t){for(let n=0;ne.removeEventListener(t,n,i)}function w(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function A(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function b(e){return""===e?null:+e}function k(e,t){t=""+t,e.data!==t&&(e.data=t)}function I(e,t){e.value=null==t?"":t}function C(e,t,n,i){null==n?e.style.removeProperty(t):e.style.setProperty(t,n,i?"important":"")}function E(e,t,n){for(let n=0;n{const r=e.$$.callbacks[t];if(r){const s=function(e,t,{bubbles:n=!1,cancelable:i=!1}={}){const r=document.createEvent("CustomEvent");return r.initCustomEvent(e,n,i,t),r}(t,n,{cancelable:i});return r.slice().forEach(t=>{t.call(e,s)}),!s.defaultPrevented}return!0}}function R(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const T=[],U=[];let _=[];const N=[],L=Promise.resolve();let O=!1;function M(e){_.push(e)}function j(e){N.push(e)}const H=new Set;let G=0;function J(){if(0!==G)return;const e=B;do{try{for(;G{V.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}else i&&i()}function X(e,t,n){const i=e.$$.props[t];void 0!==i&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function ee(e){e&&e.c()}function te(e,n,s,o){const{fragment:l,after_update:a}=e.$$;l&&l.m(n,s),o||M(()=>{const n=e.$$.on_mount.map(t).filter(r);e.$$.on_destroy?e.$$.on_destroy.push(...n):i(n),e.$$.on_mount=[]}),a.forEach(M)}function ne(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];_.forEach(i=>-1===e.indexOf(i)?t.push(i):n.push(i)),n.forEach(e=>e()),_=t}(n.after_update),i(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function ie(e,t){-1===e.$$.dirty[0]&&(T.push(e),O||(O=!0,L.then(J)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const r=i.length?i[0]:n;return p.ctx&&l(p.ctx[e],p.ctx[e]=r)&&(!p.skip_bound&&p.bound[e]&&p.bound[e](r),h&&ie(t,e)),n}):[],p.update(),h=!0,i(p.before_update),p.fragment=!!o&&o(p.ctx),r.target){if(r.hydrate){const e=function(e){return Array.from(e.childNodes)}(r.target);p.fragment&&p.fragment.l(e),e.forEach(d)}else p.fragment&&p.fragment.c();r.intro&&z(t.$$.fragment),te(t,r.target,r.anchor,r.customElement),J()}Q(f)}class se{$destroy(){ne(this,1),this.$destroy=e}$on(t,n){if(!r(n))return e;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const e=i.indexOf(n);-1!==e&&i.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function oe(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function le(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function ae(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const ce="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,ue=e=>e instanceof Uint8Array,de=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),fe=(e,t)=>e<<32-t|e>>>t; -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function pe(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!ue(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let he=class{clone(){return this._cloneInto()}};function ge(e){const t=t=>e().update(pe(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function me(e=32){if(ce&&"function"==typeof ce.getRandomValues)return ce.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let ve=class extends he{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=de(this.buffer)}update(e){ae(this);const{view:t,buffer:n,blockLen:i}=this,r=(e=pe(e)).length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let e=s;e>r&s),l=Number(n&s),a=i?4:0,c=i?0:4;e.setUint32(t+a,o,i),e.setUint32(t+c,l,i)}(n,i-8,BigInt(8*this.length),r),this.process(n,0);const o=de(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=l/4,c=this.get();if(a>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,we=(e,t,n)=>e&t^e&n^t&n,Ae=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),be=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ke=new Uint32Array(64);let Ie=class extends ve{constructor(){super(64,32,8,!1),this.A=0|be[0],this.B=0|be[1],this.C=0|be[2],this.D=0|be[3],this.E=0|be[4],this.F=0|be[5],this.G=0|be[6],this.H=0|be[7]}get(){const{A:e,B:t,C:n,D:i,E:r,F:s,G:o,H:l}=this;return[e,t,n,i,r,s,o,l]}set(e,t,n,i,r,s,o,l){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|r,this.F=0|s,this.G=0|o,this.H=0|l}process(e,t){for(let n=0;n<16;n++,t+=4)ke[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ke[e-15],n=ke[e-2],i=fe(t,7)^fe(t,18)^t>>>3,r=fe(n,17)^fe(n,19)^n>>>10;ke[e]=r+ke[e-7]+i+ke[e-16]|0}let{A:n,B:i,C:r,D:s,E:o,F:l,G:a,H:c}=this;for(let e=0;e<64;e++){const t=c+(fe(o,6)^fe(o,11)^fe(o,25))+ye(o,l,a)+Ae[e]+ke[e]|0,u=(fe(n,2)^fe(n,13)^fe(n,22))+we(n,i,r)|0;c=a,a=l,l=o,o=s+t|0,s=r,r=i,i=n,n=t+u|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,s=s+this.D|0,o=o+this.E|0,l=l+this.F|0,a=a+this.G|0,c=c+this.H|0,this.set(n,i,r,s,o,l,a,c)}roundClean(){ke.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Ce=ge(()=>new Ie),Ee=BigInt(0),xe=BigInt(1),Se=BigInt(2),Be=e=>e instanceof Uint8Array,Qe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")); -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Fe(e){if(!Be(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!Be(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const Oe=e=>(Se<new Uint8Array(e),je=e=>Uint8Array.from(e);function He(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let i=Me(e),r=Me(e),s=0;const o=()=>{i.fill(1),r.fill(0),s=0},l=(...e)=>n(r,i,...e),a=(e=Me())=>{r=l(je([0]),e),i=l(),0!==e.length&&(r=l(je([1]),e),i=l())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(o(),a(e);!(n=t(c()));)a();return o(),n}}const Ge={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function Je(e,t,n={}){const i=(t,n,i)=>{const r=Ge[n];if("function"!=typeof r)throw new Error(`Invalid validator "${n}", expected function`);const s=e[t];if(!(i&&void 0===s||r(s,e)))throw new Error(`Invalid param ${String(t)}=${s} (${typeof s}), expected ${n}`)};for(const[e,n]of Object.entries(t))i(e,n,!1);for(const[e,t]of Object.entries(n))i(e,t,!0);return e}var Ke=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&xe},bitLen:function(e){let t;for(t=0;e>Ee;e>>=xe,t+=1);return t},bitMask:Oe,bitSet:(e,t,n)=>e|(n?xe:Ee)<=Ve?n:t+n}function tt(e,t,n){if(n<=Ve||t 0");if(n===qe)return Ve;let i=qe;for(;t>Ve;)t&qe&&(i=i*e%n),e=e*e%n,t>>=qe;return i}function nt(e,t,n){let i=e;for(;t-- >Ve;)i*=i,i%=n;return i}function it(e,t){if(e===Ve||t<=Ve)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=et(e,t),i=t,r=Ve,s=qe;for(;n!==Ve;){const e=i%n,t=r-s*(i/n);i=n,n=e,r=s,s=t}if(i!==qe)throw new Error("invert: does not exist");return et(r,t)}function rt(e){if(e%ze===We){const t=(e+qe)/ze;return function(e,n){const i=e.pow(n,t);if(!e.eql(e.sqr(i),n))throw new Error("Cannot find square root");return i}}if(e%Xe===Ze){const t=(e-Ze)/Xe;return function(e,n){const i=e.mul(n,Ye),r=e.pow(i,t),s=e.mul(n,r),o=e.mul(e.mul(s,Ye),r),l=e.mul(s,e.sub(o,e.ONE));if(!e.eql(e.sqr(l),n))throw new Error("Cannot find square root");return l}}return function(e){const t=(e-qe)/Ye;let n,i,r;for(n=e-qe,i=0;n%Ye===Ve;n/=Ye,i++);for(r=Ye;ri.unsubscribe():i}function c(e){let t;return a(e,e=>t=e)(),t}function u(e,t,n){e.$$.on_destroy.push(a(t,n))}const d="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function f(e,t){e.appendChild(t)}function p(e,t,n){e.insertBefore(t,n||null)}function h(e){e.parentNode&&e.parentNode.removeChild(e)}function g(e,t){for(let n=0;ne.removeEventListener(t,n,i)}function k(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function I(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function C(e){return""===e?null:+e}function E(e,t){t=""+t,e.data!==t&&(e.data=t)}function x(e,t){e.value=null==t?"":t}function S(e,t,n,i){null==n?e.style.removeProperty(t):e.style.setProperty(t,n,i?"important":"")}function B(e,t,n){for(let n=0;n{const r=e.$$.callbacks[t];if(r){const s=function(e,t,{bubbles:n=!1,cancelable:i=!1}={}){const r=document.createEvent("CustomEvent");return r.initCustomEvent(e,n,i,t),r}(t,n,{cancelable:i});return r.slice().forEach(t=>{t.call(e,s)}),!s.defaultPrevented}return!0}}function N(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const _=[],L=[];let M=[];const O=[],j=Promise.resolve();let H=!1;function G(e){M.push(e)}function q(e){O.push(e)}const J=new Set;let K=0;function V(){if(0!==K)return;const e=$;do{try{for(;K<_.length;){const e=_[K];K++,D(e),Y(e.$$)}}catch(e){throw _.length=0,K=0,e}for(D(null),_.length=0,K=0;L.length;)L.pop()();for(let e=0;e{z.delete(e),i&&(n&&e.d(1),i())}),e.o(t)}else i&&i()}function ne(e,t,n){const i=e.$$.props[t];void 0!==i&&(e.$$.bound[i]=n,n(e.$$.ctx[i]))}function ie(e){e&&e.c()}function re(e,n,s,o){const{fragment:l,after_update:a}=e.$$;l&&l.m(n,s),o||G(()=>{const n=e.$$.on_mount.map(t).filter(r);e.$$.on_destroy?e.$$.on_destroy.push(...n):i(n),e.$$.on_mount=[]}),a.forEach(G)}function se(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];M.forEach(i=>-1===e.indexOf(i)?t.push(i):n.push(i)),n.forEach(e=>e()),M=t}(n.after_update),i(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function oe(e,t){-1===e.$$.dirty[0]&&(_.push(e),H||(H=!0,j.then(V)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const r=i.length?i[0]:n;return f.ctx&&l(f.ctx[e],f.ctx[e]=r)&&(!f.skip_bound&&f.bound[e]&&f.bound[e](r),p&&oe(t,e)),n}):[],f.update(),p=!0,i(f.before_update),f.fragment=!!o&&o(f.ctx),r.target){if(r.hydrate){const e=function(e){return Array.from(e.childNodes)}(r.target);f.fragment&&f.fragment.l(e),e.forEach(h)}else f.fragment&&f.fragment.c();r.intro&&ee(t.$$.fragment),re(t,r.target,r.anchor,r.customElement),V()}D(d)}class ae{$destroy(){se(this,1),this.$destroy=e}$on(t,n){if(!r(n))return e;const i=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return i.push(n),()=>{const e=i.indexOf(n);-1!==e&&i.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function ce(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ue(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function de(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const fe="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,pe=e=>e instanceof Uint8Array,he=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),ge=(e,t)=>e<<32-t|e>>>t; +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function me(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),!pe(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let ve=class{clone(){return this._cloneInto()}};function ye(e){const t=t=>e().update(me(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function we(e=32){if(fe&&"function"==typeof fe.getRandomValues)return fe.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let be=class extends ve{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=he(this.buffer)}update(e){de(this);const{view:t,buffer:n,blockLen:i}=this,r=(e=me(e)).length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let e=s;e>r&s),l=Number(n&s),a=i?4:0,c=i?0:4;e.setUint32(t+a,o,i),e.setUint32(t+c,l,i)}(n,i-8,BigInt(8*this.length),r),this.process(n,0);const o=he(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=l/4,c=this.get();if(a>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,ke=(e,t,n)=>e&t^e&n^t&n,Ie=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ce=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ee=new Uint32Array(64);let xe=class extends be{constructor(){super(64,32,8,!1),this.A=0|Ce[0],this.B=0|Ce[1],this.C=0|Ce[2],this.D=0|Ce[3],this.E=0|Ce[4],this.F=0|Ce[5],this.G=0|Ce[6],this.H=0|Ce[7]}get(){const{A:e,B:t,C:n,D:i,E:r,F:s,G:o,H:l}=this;return[e,t,n,i,r,s,o,l]}set(e,t,n,i,r,s,o,l){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|r,this.F=0|s,this.G=0|o,this.H=0|l}process(e,t){for(let n=0;n<16;n++,t+=4)Ee[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Ee[e-15],n=Ee[e-2],i=ge(t,7)^ge(t,18)^t>>>3,r=ge(n,17)^ge(n,19)^n>>>10;Ee[e]=r+Ee[e-7]+i+Ee[e-16]|0}let{A:n,B:i,C:r,D:s,E:o,F:l,G:a,H:c}=this;for(let e=0;e<64;e++){const t=c+(ge(o,6)^ge(o,11)^ge(o,25))+Ae(o,l,a)+Ie[e]+Ee[e]|0,u=(ge(n,2)^ge(n,13)^ge(n,22))+ke(n,i,r)|0;c=a,a=l,l=o,o=s+t|0,s=r,r=i,i=n,n=t+u|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,s=s+this.D|0,o=o+this.E|0,l=l+this.F|0,a=a+this.G|0,c=c+this.H|0,this.set(n,i,r,s,o,l,a,c)}roundClean(){Ee.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Se=ye(()=>new xe),Be=BigInt(0),Qe=BigInt(1),Fe=BigInt(2),$e=e=>e instanceof Uint8Array,De=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Re(e){if(!$e(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!$e(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const He=e=>(Fe<new Uint8Array(e),qe=e=>Uint8Array.from(e);function Je(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let i=Ge(e),r=Ge(e),s=0;const o=()=>{i.fill(1),r.fill(0),s=0},l=(...e)=>n(r,i,...e),a=(e=Ge())=>{r=l(qe([0]),e),i=l(),0!==e.length&&(r=l(qe([1]),e),i=l())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(o(),a(e);!(n=t(c()));)a();return o(),n}}const Ke={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function Ve(e,t,n={}){const i=(t,n,i)=>{const r=Ke[n];if("function"!=typeof r)throw new Error(`Invalid validator "${n}", expected function`);const s=e[t];if(!(i&&void 0===s||r(s,e)))throw new Error(`Invalid param ${String(t)}=${s} (${typeof s}), expected ${n}`)};for(const[e,n]of Object.entries(t))i(e,n,!1);for(const[e,t]of Object.entries(n))i(e,t,!0);return e}var Ye=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&Qe},bitLen:function(e){let t;for(t=0;e>Be;e>>=Qe,t+=1);return t},bitMask:He,bitSet:(e,t,n)=>e|(n?Qe:Be)<=ze?n:t+n}function rt(e,t,n){if(n<=ze||t 0");if(n===We)return ze;let i=We;for(;t>ze;)t&We&&(i=i*e%n),e=e*e%n,t>>=We;return i}function st(e,t,n){let i=e;for(;t-- >ze;)i*=i,i%=n;return i}function ot(e,t){if(e===ze||t<=ze)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=it(e,t),i=t,r=ze,s=We;for(;n!==ze;){const e=i%n,t=r-s*(i/n);i=n,n=e,r=s,s=t}if(i!==We)throw new Error("invert: does not exist");return it(r,t)}function lt(e){if(e%et===Xe){const t=(e+We)/et;return function(e,n){const i=e.pow(n,t);if(!e.eql(e.sqr(i),n))throw new Error("Cannot find square root");return i}}if(e%nt===tt){const t=(e-tt)/nt;return function(e,n){const i=e.mul(n,Ze),r=e.pow(i,t),s=e.mul(n,r),o=e.mul(e.mul(s,Ze),r),l=e.mul(s,e.sub(o,e.ONE));if(!e.eql(e.sqr(l),n))throw new Error("Cannot find square root");return l}}return function(e){const t=(e-We)/Ze;let n,i,r;for(n=e-We,i=0;n%Ze===ze;n/=Ze,i++);for(r=Ze;r(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});Je(e,t)}(e.Fp),Je(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ot(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:ft,hexToBytes:pt}=Ke,ht={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=ht;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],i=e.subarray(2,n+2);if(!n||i.length!==n)throw new t("Invalid signature integer: wrong length");if(128&i[0])throw new t("Invalid signature integer: negative");if(0===i[0]&&!(128&i[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:ft(i),l:e.subarray(n+2)}},toSig(e){const{Err:t}=ht,n="string"==typeof e?pt(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let i=n.length;if(i<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==i-2)throw new t("Invalid signature: incorrect length");const{d:r,l:s}=ht._parseInt(n.subarray(2)),{d:o,l:l}=ht._parseInt(s);if(l.length)throw new t("Invalid signature: left bytes after parsing");return{r:r,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},i=t(n(e.s)),r=t(n(e.r)),s=i.length/2,o=r.length/2,l=n(s),a=n(o);return`30${n(o+s+4)}02${a}${r}02${l}${i}`}},gt=BigInt(0),mt=BigInt(1);BigInt(2);const vt=BigInt(3);function yt(e){const t=function(e){const t=dt(e);Je(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:i,a:r}=t;if(n){if(!i.eql(r,i.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,i=t.toBytes||((e,t,i)=>{const r=t.toAffine();return Le(Uint8Array.from([4]),n.toBytes(r.x),n.toBytes(r.y))}),r=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function s(e){const{a:i,b:r}=t,s=n.sqr(e),o=n.mul(s,e);return n.add(n.add(o,n.mul(e,i)),r)}if(!n.eql(n.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"==typeof e&>n.eql(e,n.ZERO);return r(t)&&r(i)?d.ZERO:new d(t,i,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(r(Ne("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(a(e))}_setWindowSize(e){this._WINDOW_SIZE=e,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:i}=this.toAffine();if(!n.isValid(e)||!n.isValid(i))throw new Error("bad point: x or y not FE");const r=n.sqr(i),o=s(e);if(!n.eql(r,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:i,pz:r}=this,{px:s,py:o,pz:l}=e,a=n.eql(n.mul(t,l),n.mul(s,r)),c=n.eql(n.mul(i,l),n.mul(o,r));return a&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:i}=t,r=n.mul(i,vt),{px:s,py:o,pz:l}=this;let a=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(s,s),p=n.mul(o,o),h=n.mul(l,l),g=n.mul(s,o);return g=n.add(g,g),u=n.mul(s,l),u=n.add(u,u),a=n.mul(e,u),c=n.mul(r,h),c=n.add(a,c),a=n.sub(p,c),c=n.add(p,c),c=n.mul(a,c),a=n.mul(g,a),u=n.mul(r,u),h=n.mul(e,h),g=n.sub(f,h),g=n.mul(e,g),g=n.add(g,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,h),f=n.mul(f,g),c=n.add(c,f),h=n.mul(o,l),h=n.add(h,h),f=n.mul(h,g),a=n.sub(a,f),u=n.mul(h,p),u=n.add(u,u),u=n.add(u,u),new d(a,c,u)}add(e){u(e);const{px:i,py:r,pz:s}=this,{px:o,py:l,pz:a}=e;let c=n.ZERO,f=n.ZERO,p=n.ZERO;const h=t.a,g=n.mul(t.b,vt);let m=n.mul(i,o),v=n.mul(r,l),y=n.mul(s,a),w=n.add(i,r),A=n.add(o,l);w=n.mul(w,A),A=n.add(m,v),w=n.sub(w,A),A=n.add(i,s);let b=n.add(o,a);return A=n.mul(A,b),b=n.add(m,y),A=n.sub(A,b),b=n.add(r,s),c=n.add(l,a),b=n.mul(b,c),c=n.add(v,y),b=n.sub(b,c),p=n.mul(h,A),c=n.mul(g,y),p=n.add(c,p),c=n.sub(v,p),p=n.add(v,p),f=n.mul(c,p),v=n.add(m,m),v=n.add(v,m),y=n.mul(h,y),A=n.mul(g,A),v=n.add(v,y),y=n.sub(m,y),y=n.mul(h,y),A=n.add(A,y),m=n.mul(v,A),f=n.add(f,m),m=n.mul(b,A),c=n.mul(w,c),c=n.sub(c,m),m=n.mul(w,v),p=n.mul(b,p),p=n.add(p,m),new d(c,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,c,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const i=d.ZERO;if(e===gt)return i;if(l(e),e===mt)return this;const{endo:r}=t;if(!r)return p.unsafeLadder(this,e);let{k1neg:s,k1:o,k2neg:a,k2:c}=r.splitScalar(e),u=i,f=i,h=this;for(;o>gt||c>gt;)o&mt&&(u=u.add(h)),c&mt&&(f=f.add(h)),h=h.double(),o>>=mt,c>>=mt;return s&&(u=u.negate()),a&&(f=f.negate()),f=new d(n.mul(f.px,r.beta),f.py,f.pz),u.add(f)}multiply(e){l(e);let i,r,s=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:l,k2:a}=o.splitScalar(s);let{p:c,f:u}=this.wNAF(t),{p:f,f:h}=this.wNAF(a);c=p.constTimeNegate(e,c),f=p.constTimeNegate(l,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=c.add(f),r=u.add(h)}else{const{p:e,f:t}=this.wNAF(s);i=e,r=t}return d.normalizeZ([i,r])[0]}multiplyAndAddUnsafe(e,t,n){const i=d.BASE,r=(e,t)=>t!==gt&&t!==mt&&e.equals(i)?e.multiply(t):e.multiplyUnsafe(t),s=r(this,t).add(r(e,n));return s.is0()?void 0:s}toAffine(e){const{px:t,py:i,pz:r}=this,s=this.is0();null==e&&(e=s?n.ONE:n.inv(r));const o=n.mul(t,e),l=n.mul(i,e),a=n.mul(r,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(a,n.ONE))throw new Error("invZ was invalid");return{x:o,y:l}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===mt)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===mt?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),i(d,this,e)}toHex(e=!0){return Fe(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=t.nBitLength,p=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},i=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let i=e.ZERO,r=t;for(;n>ct;)n&ut&&(i=i.add(r)),r=r.double(),n>>=ut;return i},precomputeWindow(e,t){const{windows:n,windowSize:r}=i(t),s=[];let o=e,l=o;for(let e=0;e>=f,i>l&&(i-=d,s+=ut);const o=t,p=t+Math.abs(i)-1,h=e%2!=0,g=i<0;0===i?c=c.add(n(h,r[o])):a=a.add(n(g,r[p]))}return{p:a,f:c}},wNAFCached(e,t,n,i){const r=e._WINDOW_SIZE||1;let s=t.get(e);return s||(s=this.precomputeWindow(e,r),1!==r&&t.set(e,i(s))),this.wNAF(r,s,n)}}}(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:o}}function wt(e){const t=function(e){const t=dt(e);return Je(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:i}=t,r=n.BYTES+1,s=2*n.BYTES+1;function o(e){return et(e,i)}function l(e){return it(e,i)}const{ProjectivePoint:a,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=yt({...t,toBytes(e,t,i){const r=t.toAffine(),s=n.toBytes(r.x),o=Le;return i?o(Uint8Array.from([t.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(r.y))},fromBytes(e){const t=e.length,i=e[0],o=e.subarray(1);if(t!==r||2!==i&&3!==i){if(t===s&&4===i){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${r} compressed bytes or ${s} uncompressed bytes`)}{const e=Re(o);if(!(gt<(l=e)&&lFe(Ue(e,t.nByteLength));function p(e){return e>i>>mt}const h=(e,t,n)=>Re(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=Ne("compactSignature",e,2*n),new g(h(e,0,n),h(e,n,2*n))}static fromDER(e){const{r:t,s:n}=ht.toSig(Ne("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:i,s:r,recovery:s}=this,c=w(Ne("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?i+t.n:i;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&s?"03":"02",p=a.fromHex(d+f(u)),h=l(u),g=o(-c*h),m=o(r*h),v=a.BASE.multiplyAndAddUnsafe(p,g,m);if(!v)throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Pe(this.toDERHex())}toDERHex(){return ht.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Pe(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const m={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=at(t.n);return function(e,t,n=!1){const i=e.length,r=lt(t),s=at(t);if(i<16||i1024)throw new Error(`expected ${s}-1024 bytes of input, got ${i}`);const o=et(n?Re(e):Te(e),t-qe)+qe;return n?_e(o,r):Ue(o,r)}(t.randomBytes(e),t.n)},precompute:(e=8,t=a.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function v(e){const t=e instanceof Uint8Array,n="string"==typeof e,i=(t||n)&&e.length;return t?i===r||i===s:n?i===2*r||i===2*s:e instanceof a}const y=t.bits2int||function(e){const n=Re(e),i=8*e.length-t.nBitLength;return i>0?n>>BigInt(i):n},w=t.bits2int_modN||function(e){return o(y(e))},A=Oe(t.nBitLength);function b(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(gt<=e&&ee in r))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=t;let{lowS:f,prehash:h,extraEntropy:m}=r;null==f&&(f=!0),e=Ne("msgHash",e),h&&(e=Ne("prehashed msgHash",s(e)));const v=w(e),A=c(i),k=[b(A),b(v)];if(null!=m){const e=!0===m?u(n.BYTES):m;k.push(Ne("extraEntropy",e))}const C=Le(...k),E=v;return{seed:C,k2sig:function(e){const t=y(e);if(!d(t))return;const n=l(t),i=a.BASE.multiply(t).toAffine(),r=o(i.x);if(r===gt)return;const s=o(n*o(E+r*A));if(s===gt)return;let c=(i.x===r?0:2)|Number(i.y&mt),u=s;return f&&p(s)&&(u=function(e){return p(e)?o(-e):e}(s),c^=1),new g(r,u,c)}}}const I={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};return a.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return a.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(v(e))throw new Error("first arg must be private key");if(!v(t))throw new Error("second arg must be public key");return a.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,i=I){const{seed:r,k2sig:s}=k(e,n,i),o=t;return He(o.hash.outputLen,o.nByteLength,o.hmac)(r,s)},verify:function(e,n,i,r=C){const s=e;if(n=Ne("msgHash",n),i=Ne("publicKey",i),"strict"in r)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=r;let d,f;try{if("string"==typeof s||s instanceof Uint8Array)try{d=g.fromDER(s)}catch(e){if(!(e instanceof ht.Err))throw e;d=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:e,s:t}=s;d=new g(e,t)}}f=a.fromHex(i)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:p,s:h}=d,m=w(n),v=l(h),y=o(m*v),A=o(p*v),b=a.BASE.multiplyAndAddUnsafe(f,y,A)?.toAffine();return!!b&&o(b.x)===p},ProjectivePoint:a,Signature:g,utils:m}}BigInt(4);let At=class extends he{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");oe(e.outputLen),oe(e.blockLen)}(e);const n=pe(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,r=new Uint8Array(i);r.set(n.length>i?e.create().update(n).digest():n);for(let e=0;enew At(e,t).update(n).digest(); +const ft=BigInt(0),pt=BigInt(1);function ht(e){return function(e){const t=at.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});Ve(e,t)}(e.Fp),Ve(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ct(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:gt,hexToBytes:mt}=Ye,vt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=vt;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],i=e.subarray(2,n+2);if(!n||i.length!==n)throw new t("Invalid signature integer: wrong length");if(128&i[0])throw new t("Invalid signature integer: negative");if(0===i[0]&&!(128&i[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:gt(i),l:e.subarray(n+2)}},toSig(e){const{Err:t}=vt,n="string"==typeof e?mt(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let i=n.length;if(i<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==i-2)throw new t("Invalid signature: incorrect length");const{d:r,l:s}=vt._parseInt(n.subarray(2)),{d:o,l:l}=vt._parseInt(s);if(l.length)throw new t("Invalid signature: left bytes after parsing");return{r:r,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},i=t(n(e.s)),r=t(n(e.r)),s=i.length/2,o=r.length/2,l=n(s),a=n(o);return`30${n(o+s+4)}02${a}${r}02${l}${i}`}},yt=BigInt(0),wt=BigInt(1);BigInt(2);const bt=BigInt(3);function At(e){const t=function(e){const t=ht(e);Ve(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:i,a:r}=t;if(n){if(!i.eql(r,i.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,i=t.toBytes||((e,t,i)=>{const r=t.toAffine();return je(Uint8Array.from([4]),n.toBytes(r.x),n.toBytes(r.y))}),r=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function s(e){const{a:i,b:r}=t,s=n.sqr(e),o=n.mul(s,e);return n.add(n.add(o,n.mul(e,i)),r)}if(!n.eql(n.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"==typeof e&&ytn.eql(e,n.ZERO);return r(t)&&r(i)?d.ZERO:new d(t,i,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(r(Oe("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(a(e))}_setWindowSize(e){this._WINDOW_SIZE=e,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:i}=this.toAffine();if(!n.isValid(e)||!n.isValid(i))throw new Error("bad point: x or y not FE");const r=n.sqr(i),o=s(e);if(!n.eql(r,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:i,pz:r}=this,{px:s,py:o,pz:l}=e,a=n.eql(n.mul(t,l),n.mul(s,r)),c=n.eql(n.mul(i,l),n.mul(o,r));return a&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:i}=t,r=n.mul(i,bt),{px:s,py:o,pz:l}=this;let a=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(s,s),p=n.mul(o,o),h=n.mul(l,l),g=n.mul(s,o);return g=n.add(g,g),u=n.mul(s,l),u=n.add(u,u),a=n.mul(e,u),c=n.mul(r,h),c=n.add(a,c),a=n.sub(p,c),c=n.add(p,c),c=n.mul(a,c),a=n.mul(g,a),u=n.mul(r,u),h=n.mul(e,h),g=n.sub(f,h),g=n.mul(e,g),g=n.add(g,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,h),f=n.mul(f,g),c=n.add(c,f),h=n.mul(o,l),h=n.add(h,h),f=n.mul(h,g),a=n.sub(a,f),u=n.mul(h,p),u=n.add(u,u),u=n.add(u,u),new d(a,c,u)}add(e){u(e);const{px:i,py:r,pz:s}=this,{px:o,py:l,pz:a}=e;let c=n.ZERO,f=n.ZERO,p=n.ZERO;const h=t.a,g=n.mul(t.b,bt);let m=n.mul(i,o),v=n.mul(r,l),y=n.mul(s,a),w=n.add(i,r),b=n.add(o,l);w=n.mul(w,b),b=n.add(m,v),w=n.sub(w,b),b=n.add(i,s);let A=n.add(o,a);return b=n.mul(b,A),A=n.add(m,y),b=n.sub(b,A),A=n.add(r,s),c=n.add(l,a),A=n.mul(A,c),c=n.add(v,y),A=n.sub(A,c),p=n.mul(h,b),c=n.mul(g,y),p=n.add(c,p),c=n.sub(v,p),p=n.add(v,p),f=n.mul(c,p),v=n.add(m,m),v=n.add(v,m),y=n.mul(h,y),b=n.mul(g,b),v=n.add(v,y),y=n.sub(m,y),y=n.mul(h,y),b=n.add(b,y),m=n.mul(v,b),f=n.add(f,m),m=n.mul(A,b),c=n.mul(w,c),c=n.sub(c,m),m=n.mul(w,v),p=n.mul(A,p),p=n.add(p,m),new d(c,f,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return p.wNAFCached(this,c,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const i=d.ZERO;if(e===yt)return i;if(l(e),e===wt)return this;const{endo:r}=t;if(!r)return p.unsafeLadder(this,e);let{k1neg:s,k1:o,k2neg:a,k2:c}=r.splitScalar(e),u=i,f=i,h=this;for(;o>yt||c>yt;)o&wt&&(u=u.add(h)),c&wt&&(f=f.add(h)),h=h.double(),o>>=wt,c>>=wt;return s&&(u=u.negate()),a&&(f=f.negate()),f=new d(n.mul(f.px,r.beta),f.py,f.pz),u.add(f)}multiply(e){l(e);let i,r,s=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:l,k2:a}=o.splitScalar(s);let{p:c,f:u}=this.wNAF(t),{p:f,f:h}=this.wNAF(a);c=p.constTimeNegate(e,c),f=p.constTimeNegate(l,f),f=new d(n.mul(f.px,o.beta),f.py,f.pz),i=c.add(f),r=u.add(h)}else{const{p:e,f:t}=this.wNAF(s);i=e,r=t}return d.normalizeZ([i,r])[0]}multiplyAndAddUnsafe(e,t,n){const i=d.BASE,r=(e,t)=>t!==yt&&t!==wt&&e.equals(i)?e.multiply(t):e.multiplyUnsafe(t),s=r(this,t).add(r(e,n));return s.is0()?void 0:s}toAffine(e){const{px:t,py:i,pz:r}=this,s=this.is0();null==e&&(e=s?n.ONE:n.inv(r));const o=n.mul(t,e),l=n.mul(i,e),a=n.mul(r,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(a,n.ONE))throw new Error("invZ was invalid");return{x:o,y:l}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===wt)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===wt?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),i(d,this,e)}toHex(e=!0){return Re(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=t.nBitLength,p=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},i=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let i=e.ZERO,r=t;for(;n>ft;)n&pt&&(i=i.add(r)),r=r.double(),n>>=pt;return i},precomputeWindow(e,t){const{windows:n,windowSize:r}=i(t),s=[];let o=e,l=o;for(let e=0;e>=f,i>l&&(i-=d,s+=pt);const o=t,p=t+Math.abs(i)-1,h=e%2!=0,g=i<0;0===i?c=c.add(n(h,r[o])):a=a.add(n(g,r[p]))}return{p:a,f:c}},wNAFCached(e,t,n,i){const r=e._WINDOW_SIZE||1;let s=t.get(e);return s||(s=this.precomputeWindow(e,r),1!==r&&t.set(e,i(s))),this.wNAF(r,s,n)}}}(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:o}}function kt(e){const t=function(e){const t=ht(e);return Ve(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:i}=t,r=n.BYTES+1,s=2*n.BYTES+1;function o(e){return it(e,i)}function l(e){return ot(e,i)}const{ProjectivePoint:a,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=At({...t,toBytes(e,t,i){const r=t.toAffine(),s=n.toBytes(r.x),o=je;return i?o(Uint8Array.from([t.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(r.y))},fromBytes(e){const t=e.length,i=e[0],o=e.subarray(1);if(t!==r||2!==i&&3!==i){if(t===s&&4===i){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${r} compressed bytes or ${s} uncompressed bytes`)}{const e=Ne(o);if(!(yt<(l=e)&&lRe(Le(e,t.nByteLength));function p(e){return e>i>>wt}const h=(e,t,n)=>Ne(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=Oe("compactSignature",e,2*n),new g(h(e,0,n),h(e,n,2*n))}static fromDER(e){const{r:t,s:n}=vt.toSig(Oe("DER",e));return new g(t,n)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:i,s:r,recovery:s}=this,c=w(Oe("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?i+t.n:i;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&s?"03":"02",p=a.fromHex(d+f(u)),h=l(u),g=o(-c*h),m=o(r*h),v=a.BASE.multiplyAndAddUnsafe(p,g,m);if(!v)throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ue(this.toDERHex())}toDERHex(){return vt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ue(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const m={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=dt(t.n);return function(e,t,n=!1){const i=e.length,r=ut(t),s=dt(t);if(i<16||i1024)throw new Error(`expected ${s}-1024 bytes of input, got ${i}`);const o=it(n?Ne(e):_e(e),t-We)+We;return n?Me(o,r):Le(o,r)}(t.randomBytes(e),t.n)},precompute:(e=8,t=a.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function v(e){const t=e instanceof Uint8Array,n="string"==typeof e,i=(t||n)&&e.length;return t?i===r||i===s:n?i===2*r||i===2*s:e instanceof a}const y=t.bits2int||function(e){const n=Ne(e),i=8*e.length-t.nBitLength;return i>0?n>>BigInt(i):n},w=t.bits2int_modN||function(e){return o(y(e))},b=He(t.nBitLength);function A(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(yt<=e&&ee in r))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=t;let{lowS:f,prehash:h,extraEntropy:m}=r;null==f&&(f=!0),e=Oe("msgHash",e),h&&(e=Oe("prehashed msgHash",s(e)));const v=w(e),b=c(i),k=[A(b),A(v)];if(null!=m){const e=!0===m?u(n.BYTES):m;k.push(Oe("extraEntropy",e))}const C=je(...k),E=v;return{seed:C,k2sig:function(e){const t=y(e);if(!d(t))return;const n=l(t),i=a.BASE.multiply(t).toAffine(),r=o(i.x);if(r===yt)return;const s=o(n*o(E+r*b));if(s===yt)return;let c=(i.x===r?0:2)|Number(i.y&wt),u=s;return f&&p(s)&&(u=function(e){return p(e)?o(-e):e}(s),c^=1),new g(r,u,c)}}}const I={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};return a.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return a.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(v(e))throw new Error("first arg must be private key");if(!v(t))throw new Error("second arg must be public key");return a.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,i=I){const{seed:r,k2sig:s}=k(e,n,i),o=t;return Je(o.hash.outputLen,o.nByteLength,o.hmac)(r,s)},verify:function(e,n,i,r=C){const s=e;if(n=Oe("msgHash",n),i=Oe("publicKey",i),"strict"in r)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=r;let d,f;try{if("string"==typeof s||s instanceof Uint8Array)try{d=g.fromDER(s)}catch(e){if(!(e instanceof vt.Err))throw e;d=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:e,s:t}=s;d=new g(e,t)}}f=a.fromHex(i)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:p,s:h}=d,m=w(n),v=l(h),y=o(m*v),b=o(p*v),A=a.BASE.multiplyAndAddUnsafe(f,y,b)?.toAffine();return!!A&&o(A.x)===p},ProjectivePoint:a,Signature:g,utils:m}}BigInt(4);let It=class extends ve{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");ce(e.outputLen),ce(e.blockLen)}(e);const n=me(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,r=new Uint8Array(i);r.set(n.length>i?e.create().update(n).digest():n);for(let e=0;enew It(e,t).update(n).digest(); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -function kt(e){return{hash:e,hmac:(t,...n)=>bt(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!ue(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:me}}bt.create=(e,t)=>new At(e,t); +function Et(e){return{hash:e,hmac:(t,...n)=>Ct(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!pe(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:we}}Ct.create=(e,t)=>new It(e,t); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const It=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ct=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Et=BigInt(1),xt=BigInt(2),St=(e,t)=>(e+t/xt)/t;function Bt(e){const t=It,n=BigInt(3),i=BigInt(6),r=BigInt(11),s=BigInt(22),o=BigInt(23),l=BigInt(44),a=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=nt(u,n,t)*u%t,f=nt(d,n,t)*u%t,p=nt(f,xt,t)*c%t,h=nt(p,r,t)*p%t,g=nt(h,s,t)*h%t,m=nt(g,l,t)*g%t,v=nt(m,a,t)*m%t,y=nt(v,l,t)*g%t,w=nt(y,n,t)*u%t,A=nt(w,o,t)*h%t,b=nt(A,i,t)*c%t,k=nt(b,xt,t);if(!Qt.eql(Qt.sqr(k),e))throw new Error("Cannot find square root");return k}const Qt=function(e,t,n=!1,i={}){if(e<=Ve)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:r,nByteLength:s}=ot(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=rt(e),l=Object.freeze({ORDER:e,BITS:r,BYTES:s,MASK:Oe(r),ZERO:Ve,ONE:qe,create:t=>et(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Ve<=t&&te===Ve,isOdd:e=>(e&qe)===qe,neg:t=>et(-t,e),eql:(e,t)=>e===t,sqr:t=>et(t*t,e),add:(t,n)=>et(t+n,e),sub:(t,n)=>et(t-n,e),mul:(t,n)=>et(t*n,e),pow:(e,t)=>function(e,t,n){if(n 0");if(n===Ve)return e.ONE;if(n===qe)return t;let i=e.ONE,r=t;for(;n>Ve;)n&qe&&(i=e.mul(i,r)),r=e.sqr(r),n>>=qe;return i}(l,e,t),div:(t,n)=>et(t*it(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>it(t,e),sqrt:i.sqrt||(e=>o(l,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),i=t.reduce((t,i,r)=>e.is0(i)?t:(n[r]=t,e.mul(t,i)),e.ONE),r=e.inv(i);return t.reduceRight((t,i,r)=>e.is0(i)?t:(n[r]=e.mul(t,n[r]),e.mul(t,i)),r),n}(l,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?_e(e,s):Ue(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return n?Te(e):Re(e)}});return Object.freeze(l)}(It,void 0,void 0,{sqrt:Bt}),Ft=function(e,t){const n=t=>wt({...e,...kt(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Qt,n:Ct,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ct,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Et*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),l=St(s*e,t),a=St(-i*e,t);let c=et(e-l*n-a*r,t),u=et(-l*i-a*s,t);const d=c>o,f=u>o;if(d&&(c=t-c),f&&(u=t-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}}},Ce),Dt=BigInt(0),$t=e=>"bigint"==typeof e&&Dte.charCodeAt(0)));n=Le(t,t),Pt[e]=n}return Ce(Le(n,...t))}const Tt=e=>e.toRawBytes(!0).slice(1),Ut=e=>Ue(e,32),_t=e=>et(e,It),Nt=e=>et(e,Ct),Lt=Ft.ProjectivePoint;function Ot(e){let t=Ft.utils.normPrivateKeyToScalar(e),n=Lt.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Nt(-t),bytes:Tt(n)}}function Mt(e){if(!$t(e))throw new Error("bad x: need 0 < x < p");const t=_t(e*e);let n=Bt(_t(t*e+BigInt(7)));n%xt!==Dt&&(n=_t(-n));const i=new Lt(e,n,Et);return i.assertValidity(),i}function jt(...e){return Nt(Re(Rt("BIP0340/challenge",...e)))}function Ht(e){return Ot(e).bytes}function Gt(e,t,n=me(32)){const i=Ne("message",e),{bytes:r,scalar:s}=Ot(t),o=Ne("auxRand",n,32),l=Ut(s^Re(Rt("BIP0340/aux",o))),a=Rt("BIP0340/nonce",l,r,i),c=Nt(Re(a));if(c===Dt)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Ot(c),f=jt(u,r,i),p=new Uint8Array(64);if(p.set(u,0),p.set(Ut(Nt(d+f*s)),32),!Jt(p,i,r))throw new Error("sign: Invalid signature produced");return p}function Jt(e,t,n){const i=Ne("signature",e,64),r=Ne("message",t),s=Ne("publicKey",n,32);try{const e=Mt(Re(s)),t=Re(i.subarray(0,32));if(!$t(t))return!1;const n=Re(i.subarray(32,64));if(!("bigint"==typeof(c=n)&&Dt({getPublicKey:Ht,sign:Gt,verify:Jt,utils:{randomPrivateKey:Ft.utils.randomPrivateKey,lift_x:Mt,pointToBytes:Tt,numberToBytesBE:Ue,bytesToNumberBE:Re,taggedHash:Rt,mod:et}}))(),Vt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,qt=e=>e instanceof Uint8Array,Yt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Wt=(e,t)=>e<<32-t|e>>>t;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const zt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Zt(e){if(!qt(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!qt(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}class nn{clone(){return this._cloneInto()}}function rn(e){const t=t=>e().update(en(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function sn(e=32){if(Vt&&"function"==typeof Vt.getRandomValues)return Vt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function on(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ln(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}const an={number:on,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:ln,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");on(e.outputLen),on(e.blockLen)},exists:function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},output:function(e,t){ln(e);const n=t.outputLen;if(e.lengthi-s&&(this.process(n,0),s=0);for(let e=s;e>r&s),l=Number(n&s),a=i?4:0,c=i?0:4;e.setUint32(t+a,o,i),e.setUint32(t+c,l,i)}(n,i-8,BigInt(8*this.length),r),this.process(n,0);const o=Yt(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=l/4,c=this.get();if(a>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,dn=(e,t,n)=>e&t^e&n^t&n,fn=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),pn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),hn=new Uint32Array(64);class gn extends cn{constructor(){super(64,32,8,!1),this.A=0|pn[0],this.B=0|pn[1],this.C=0|pn[2],this.D=0|pn[3],this.E=0|pn[4],this.F=0|pn[5],this.G=0|pn[6],this.H=0|pn[7]}get(){const{A:e,B:t,C:n,D:i,E:r,F:s,G:o,H:l}=this;return[e,t,n,i,r,s,o,l]}set(e,t,n,i,r,s,o,l){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|r,this.F=0|s,this.G=0|o,this.H=0|l}process(e,t){for(let n=0;n<16;n++,t+=4)hn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=hn[e-15],n=hn[e-2],i=Wt(t,7)^Wt(t,18)^t>>>3,r=Wt(n,17)^Wt(n,19)^n>>>10;hn[e]=r+hn[e-7]+i+hn[e-16]|0}let{A:n,B:i,C:r,D:s,E:o,F:l,G:a,H:c}=this;for(let e=0;e<64;e++){const t=c+(Wt(o,6)^Wt(o,11)^Wt(o,25))+un(o,l,a)+fn[e]+hn[e]|0,u=(Wt(n,2)^Wt(n,13)^Wt(n,22))+dn(n,i,r)|0;c=a,a=l,l=o,o=s+t|0,s=r,r=i,i=n,n=t+u|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,s=s+this.D|0,o=o+this.E|0,l=l+this.F|0,a=a+this.G|0,c=c+this.H|0,this.set(n,i,r,s,o,l,a,c)}roundClean(){hn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class mn extends gn{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const vn=rn(()=>new gn);rn(()=>new mn);var yn=Symbol("verified");function wn(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;te===n.slice(1)&&-1!==i.indexOf(t)))return!1}return!(e.since&&t.created_ate.until)}async function Bn(){return new Promise(e=>{const t=new MessageChannel,n=()=>{t.port1.removeEventListener("message",n),e()};t.port1.addEventListener("message",n),t.port2.postMessage(0),t.port1.start()})}var Qn,Fn=e=>(e[yn]=!0,!0),Dn=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},$n=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);baseEoseTimeout=4400;connectionTimeout=4400;publishTimeout=4400;pingFrequency=2e4;pingTimeout=2e4;openSubs=new Map;enablePing;connectionTimeoutHandle;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new In;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=bn(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing}static async connect(e,t){const n=new $n(e,t);return await n.connect(),n}closeAllSubscriptions(e){for(let[t,n]of this.openSubs)n.close(e);this.openSubs.clear();for(let[t,n]of this.openEventPublishes)n.reject(new Error(e));this.openEventPublishes.clear();for(let[t,n]of this.openCountRequests)n.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise||(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((e,t)=>{this.connectionTimeoutHandle=setTimeout(()=>{t("connection timed out"),this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(e){return clearTimeout(this.connectionTimeoutHandle),void t(e)}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,this.enablePing&&this.pingpong(),e()},this.ws.onerror=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket error"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection errored")},this.ws.onclose=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket closed"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)})),this.connectionPromise}async waitForPingPong(){return new Promise((e,t)=>{this.ws&&this.ws.on&&this.ws.on("pong",()=>e(!0))||t("ws can't listen for pong"),this.ws&&this.ws.ping&&this.ws.ping()})}async waitForDummyReq(){return new Promise((e,t)=>{const n=this.subscribe([{ids:["a".repeat(64)]}],{oneose:()=>{n.close(),e(!0)},eoseTimeout:this.pingTimeout+1e3})})}async pingpong(){if(1===this.ws?.readyState){await Promise.any([this.ws&&this.ws.ping&&this.ws.on?this.waitForPingPong():this.waitForDummyReq(),new Promise(e=>setTimeout(()=>e(!1),this.pingTimeout))])?setTimeout(()=>this.pingpong(),this.pingFrequency):(this.closeAllSubscriptions("pingpong timed out"),this._connected=!1,this.onclose?.(),this.ws?.close())}}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await Bn();this.queueRunning=!1}handleNext(){const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=function(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let i=t+7+1+n,r=e.slice(i+1,80).indexOf('"');if(-1===r)return null;let s=i+1+r;return e.slice(i+1,s)}(e);if(t){const n=this.openSubs.get(t);if(!n)return;const i=function(e,t){let n=t.length+3,i=e.indexOf(`"${t}":`)+n,r=e.slice(i).indexOf('"')+i+1;return e.slice(r,r+64)}(e,"id"),r=n.alreadyHaveEvent?.(i);if(n.receivedEvent?.(this,i),r)return}try{let t=JSON.parse(e);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return void(this.verifyEvent(n)&&function(e,t){for(let n=0;n{this.ws?.send(e)})}async auth(e){const t=this.challenge;if(!t)throw new Error("can't perform auth, no challenge was received");return this.authPromise||(this.authPromise=new Promise(async(n,i)=>{try{let r=await e(function(e,t){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}(this.url,t)),s=setTimeout(()=>{let e=this.openEventPublishes.get(r.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(r.id))},this.publishTimeout);this.openEventPublishes.set(r.id,{resolve:n,reject:i,timeout:s}),this.send('["AUTH",'+JSON.stringify(r)+"]")}catch(e){console.warn("subscribe auth function failed:",e)}})),this.authPromise}async publish(e){const t=new Promise((t,n)=>{const i=setTimeout(()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:i})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;const n=t?.id||"count:"+this.serial,i=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),i}subscribe(e,t){const n=this.prepareSubscription(e,t);return n.fire(),n}prepareSubscription(e,t){this.serial++;const n=t.id||(t.label?t.label+":":"sub:")+this.serial,i=new Pn(this,n,e,t);return this.openSubs.set(n,i),i}close(){this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.onclose?.(),this.ws?.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Pn=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,i){this.relay=e,this.filters=n,this.id=t,this.alreadyHaveEvent=i.alreadyHaveEvent,this.receivedEvent=i.receivedEvent,this.eoseTimeout=i.eoseTimeout||e.baseEoseTimeout,this.oneose=i.oneose,this.onclose=i.onclose,this.onevent=i.onevent||(e=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,e)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,this.oneose?.())}close(e="closed by caller"){if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(e){if(!(e instanceof Dn))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}},Rn=class{relays=new Map;seenOn=new Map;trackRelays=!1;verifyEvent;enablePing;trustedRelayURLs=new Set;_WebSocket;constructor(e){this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing}async ensureRelay(e,t){e=bn(e);let n=this.relays.get(e);return n||(n=new $n(e,{verifyEvent:this.trustedRelayURLs.has(e)?Fn:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing}),n.onclose=()=>{this.relays.delete(e)},t?.connectionTimeout&&(n.connectionTimeout=t.connectionTimeout),this.relays.set(e,n)),await n.connect(),n}close(e){e.map(bn).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){n.onauth=n.onauth||n.doauth;const i=[];for(let n=0;ne.url===r)||i.push({url:r,filter:t})}return this.subscribeMap(i,n)}subscribeMany(e,t,n){n.onauth=n.onauth||n.doauth;const i=[],r=[];for(let n=0;n({url:e,filters:t}));this.trackRelays&&(t.receivedEvent=(e,t)=>{let n=this.seenOn.get(t);n||(n=new Set,this.seenOn.set(t,n)),n.add(e)});const r=new Set,s=[],o=[];let l=n=>{o[n]||(o[n]=!0,o.filter(e=>e).length===e.length&&(t.oneose?.(),l=()=>{}))};const a=[];let c=(n,i)=>{a[n]||(l(n),a[n]=i,a.filter(e=>e).length===e.length&&(t.onclose?.(a),c=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=r.has(e);return r.add(e),n},d=Promise.all(i.map(async({url:e,filters:n},i)=>{let r;try{r=await this.ensureRelay(e,{connectionTimeout:t.maxWait?Math.max(.8*t.maxWait,t.maxWait-1e3):void 0})}catch(e){return void c(i,e?.message||String(e))}let o=r.subscribe(n,{...t,oneose:()=>l(i),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?r.auth(t.onauth).then(()=>{r.subscribe(n,{...t,oneose:()=>l(i),onclose:e=>{c(i,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait})}).catch(e=>{c(i,`auth was required and attempted, but failed with: ${e}`)}):c(i,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait});s.push(o)}));return{async close(e){await d,s.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){n.onauth=n.onauth||n.doauth;const i=this.subscribe(e,t,{...n,oneose(){i.close("closed automatically on eose")}});return i}subscribeManyEose(e,t,n){n.onauth=n.onauth||n.doauth;const i=this.subscribeMany(e,t,{...n,oneose(){i.close("closed automatically on eose")}});return i}async querySync(e,t,n){return new Promise(async i=>{const r=[];this.subscribeEose(e,t,{...n,onevent(e){r.push(e)},onclose(e){i(r)}})})}async get(e,t,n){t.limit=1;const i=await this.querySync(e,t,n);return i.sort((e,t)=>t.created_at-e.created_at),i[0]||null}publish(e,t,n){return e.map(bn).map(async(e,i,r)=>{if(r.indexOf(e)!==i)return Promise.reject("duplicate url");let s=await this.ensureRelay(e);return s.publish(t).catch(async e=>{if(e instanceof Error&&e.message.startsWith("auth-required: ")&&n?.onauth)return await s.auth(n.onauth),s.publish(t);throw e}).then(e=>{if(this.trackRelays){let e=this.seenOn.get(t.id);e||(e=new Set,this.seenOn.set(t.id,e)),e.add(s)}return e})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((t,n)=>e.set(n,t.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}};try{Qn=WebSocket}catch{}var Tn=class extends Rn{constructor(e){super({verifyEvent:xn,websocketImplementation:Qn,...e})}}; -/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Un(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function _n(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),i=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:i}}function Nn(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(Un(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function Ln(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function On(e,t="="){if(Un(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let i=n.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,i)}}}function Mn(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function jn(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const r=[],s=Array.from(e);for(s.forEach(e=>{if(Un(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let r=i;rt?Hn(t,e%t):e,Gn=(e,t)=>e+(t-Hn(e,t));function Jn(e,t,n,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Gn(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Gn(t,n)}`);let r=0,s=0;const o=2**n-1,l=[];for(const i of e){if(Un(i),i>=2**t)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(r=r<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)l.push((r>>s-n&o)>>>0);r&=2**s-1}if(r=r<=t)throw new Error("Excess padding");if(!i&&r)throw new Error(`Non-zero padding: ${r}`);return i&&s>0&&l.push(r>>>0),l}function Kn(e,t=!1){if(Un(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Gn(8,e)>32||Gn(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Jn(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Jn(n,e,8,t))}}}function Vn(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const qn=_n(Kn(4),Nn("0123456789ABCDEF"),Ln("")),Yn=_n(Kn(5),Nn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),On(5),Ln(""));_n(Kn(5),Nn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),On(5),Ln("")),_n(Kn(5),Nn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Ln(""),Mn(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const Wn=_n(Kn(6),Nn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),On(6),Ln("")),zn=_n(Kn(6),Nn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),On(6),Ln("")),Zn=e=>{return _n((Un(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return jn(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(jn(e,t,256))}}),Nn(e),Ln(""));var t},Xn=Zn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Zn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Zn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const ei=[0,2,3,5,6,7,9,10,11],ti={encode(e){let t="";for(let n=0;n>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=ii[e]);return n}function si(e,t,n=1){const i=e.length;let r=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);r=ri(r)^n>>5}r=ri(r);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=i).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,r),o=e.slice(r+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const l=ni.decode(o).slice(0,-6),a=si(s,l,t);if(!o.endsWith(a))throw new Error(`Invalid checksum in ${e}: expected "${a}"`);return{prefix:s,words:l}}return{encode:function(e,n,i=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const r=e.length+7+n.length;if(!1!==i&&r>i)throw new TypeError(`Length ${r} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${ni.encode(n)}${si(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:i(n)}},decodeUnsafe:Vn(o),fromWords:i,fromWordsUnsafe:s,toWords:r}}const li=oi("bech32");oi("bech32m");const ai={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:_n(Kn(4),Nn("0123456789abcdef"),Ln(""),Mn(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),base16:qn,base32:Yn,base64:Wn,base64url:zn,base58:Xn,base58xmr:ti};function ci(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function ui(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function di(e,...t){if(!((n=e)instanceof Uint8Array||null!=n&&"object"==typeof n&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)} -/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Object.keys(ai).join(", ");const fi=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const pi=16;function hi(e){return e<<1^283&-(e>>7)}function gi(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=hi(e);return n}const mi=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=hi(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let i=e[255-n];i|=i<<8,t[e[n]]=255&(i^i>>4^i>>5^i>>6^i>>7^99)}return t})(),vi=mi.map((e,t)=>mi.indexOf(t)),yi=e=>e<<24|e>>>8,wi=e=>e<<8|e>>>24;function Ai(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,i)=>t(e[i])),i=n.map(wi),r=i.map(wi),s=r.map(wi),o=new Uint32Array(65536),l=new Uint32Array(65536),a=new Uint16Array(65536);for(let t=0;t<256;t++)for(let c=0;c<256;c++){const u=256*t+c;o[u]=n[t]^i[c],l[u]=r[t]^s[c],a[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:a,T0:n,T1:i,T2:r,T3:s,T01:o,T23:l}}const bi=Ai(mi,e=>gi(e,3)<<24|e<<16|e<<8|gi(e,2)),ki=Ai(vi,e=>gi(e,11)<<24|gi(e,13)<<16|gi(e,9)<<8|gi(e,14)),Ii=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=hi(n))e[t]=n;return e})();function Ci(e){di(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=bi,i=fi(e),r=i.length,s=e=>xi(n,e,e,e,e),o=new Uint32Array(t+28);o.set(i);for(let e=r;e6&&e%r===4&&(t=s(t)),o[e]=o[e-r]^t}return o}function Ei(e,t,n,i,r,s){return e[n<<8&65280|i>>>8&255]^t[r>>>8&65280|s>>>24&255]}function xi(e,t,n,i,r){return e[255&t|65280&n]|e[i>>>16&255|r>>>16&65280]<<16}function Si(e,t,n,i,r){const{sbox2:s,T01:o,T23:l}=bi;let a=0;t^=e[a++],n^=e[a++],i^=e[a++],r^=e[a++];const c=e.length/4-2;for(let s=0;s{const s=Ci(e),{b:o,o:l,out:a}=function(e,t,n){let i=e.length;const r=i%pi;if(!t&&0!==r)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const s=fi(e);if(t){let e=pi-r;e||(e=pi),i+=e}const o=Qi(i,n);return{b:s,o:fi(o),out:o}}(n,i,r),c=fi(t);let u=c[0],d=c[1],f=c[2],p=c[3],h=0;for(;h+4<=o.length;)u^=o[h+0],d^=o[h+1],f^=o[h+2],p^=o[h+3],({s0:u,s1:d,s2:f,s3:p}=Si(s,u,d,f,p)),l[h++]=u,l[h++]=d,l[h++]=f,l[h++]=p;if(i){const e=function(e){const t=new Uint8Array(16),n=fi(t);t.set(e);const i=pi-e.length;for(let e=pi-i;e{!function(e){if(di(e),e.length%pi!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const s=function(e){const t=Ci(e),n=t.slice(),i=t.length,{sbox2:r}=bi,{T0:s,T1:o,T2:l,T3:a}=ki;for(let e=0;e>>8&255]^l[i>>>16&255]^a[i>>>24]}return n}(e),o=fi(t),l=Qi(n.length,r),a=fi(n),c=fi(l);let u=o[0],d=o[1],f=o[2],p=o[3];for(let e=0;e+4<=a.length;){const t=u,n=d,i=f,r=p;u=a[e+0],d=a[e+1],f=a[e+2],p=a[e+3];const{s0:o,s1:l,s2:h,s3:g}=Bi(s,u,d,f,p);c[e++]=o^t,c[e++]=l^n,c[e++]=h^i,c[e++]=g^r}return s.fill(0),function(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const i=e[n-1];if(i<=0||i>16)throw new Error(`aes/pcks5: wrong padding byte: ${i}`);const r=e.subarray(0,-i);for(let t=0;tUint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Ri=Pi("expand 16-byte k"),Ti=Pi("expand 32-byte k"),Ui=fi(Ri),_i=fi(Ti);function Ni(e,t){return e<>>32-t}function Li(e){return e.byteOffset%4==0}_i.slice();const Oi=2**32-1,Mi=new Uint32Array;function ji(e,t){const{allowShortKeys:n,extendNonceFn:i,counterLength:r,counterRight:s,rounds:o}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return ci(r),ci(o),ui(s),ui(n),(t,l,a,c,u=0)=>{di(t),di(l),di(a);const d=a.length;if(c||(c=new Uint8Array(d)),di(c),ci(u),u<0||u>=Oi)throw new Error("arx: counter overflow");if(c.length=Oi)throw new Error("arx: counter overflow");const g=Math.min(64,a-h);if(d&&64===g){const e=h/4;if(h%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,p[t]=f[t]^u[n];h+=64;continue}for(let e,t=0;t0;)f.pop().fill(0);return c}}function Hi(e,t,n,i,r,s=20){let o=e[0],l=e[1],a=e[2],c=e[3],u=t[0],d=t[1],f=t[2],p=t[3],h=t[4],g=t[5],m=t[6],v=t[7],y=r,w=n[0],A=n[1],b=n[2],k=o,I=l,C=a,E=c,x=u,S=d,B=f,Q=p,F=h,D=g,$=m,P=v,R=y,T=w,U=A,_=b;for(let e=0;ei?e.create().update(n).digest():n);for(let e=0;enew Ji(e,t).update(n).digest();Ki.create=(e,t)=>new Ji(e,t);const Vi=new Uint8Array([0]),qi=new Uint8Array;var Yi=Object.defineProperty,Wi=(e,t)=>{for(var n in t)Yi(e,n,{get:t[n],enumerable:!0})},zi=Symbol("verified");function Zi(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;tor,QueueNode:()=>sr,binarySearch:()=>rr,bytesToHex:()=>Zt,hexToBytes:()=>Xt,insertEventIntoAscendingList:()=>ir,insertEventIntoDescendingList:()=>nr,normalizeURL:()=>tr,utf8Decoder:()=>Xi,utf8Encoder:()=>er});var Xi=new TextDecoder("utf-8"),er=new TextEncoder;function tr(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function nr(e,t){const[n,i]=rr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return i||e.splice(n,0,t),e}function ir(e,t){const[n,i]=rr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return i||e.splice(n,0,t),e}function rr(e,t){let n=0,i=e.length-1;for(;n<=i;){const r=Math.floor((n+i)/2),s=t(e[r]);if(0===s)return[r,!0];s<0?i=r-1:n=r+1}return[n,!1]}var sr=class{value;next=null;prev=null;constructor(e){this.value=e}},or=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new sr(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}};function lr(e){return Zt(vn(er.encode(function(e){if(!Zi(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}(e))))}var ar=new class{generateSecretKey(){return Kt.utils.randomPrivateKey()}getPublicKey(e){return Zt(Kt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Zt(Kt.getPublicKey(t)),n.id=lr(n),n.sig=Zt(Kt.sign(lr(n),t)),n[zi]=!0,n}verifyEvent(e){if("boolean"==typeof e[zi])return e[zi];const t=lr(e);if(t!==e.id)return e[zi]=!1,!1;try{const n=Kt.verify(e.sig,t,e.pubkey);return e[zi]=n,n}catch(t){return e[zi]=!1,!1}}},cr=ar.generateSecretKey,ur=ar.getPublicKey,dr=ar.finalizeEvent,fr=ar.verifyEvent,pr={};function hr(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function gr(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function mr(e){return 2e4<=e&&e<3e4}function vr(e){return 3e4<=e&&e<4e4}function yr(e){return hr(e)?"regular":gr(e)?"replaceable":mr(e)?"ephemeral":vr(e)?"parameterized":"unknown"}function wr(e,t){const n=t instanceof Array?t:[t];return Zi(e)&&n.includes(e.kind)||!1}Wi(pr,{Application:()=>Ds,BadgeAward:()=>Br,BadgeDefinition:()=>Cs,BlockedRelaysList:()=>ss,BookmarkList:()=>ns,Bookmarksets:()=>bs,Calendar:()=>Ns,CalendarEventRSVP:()=>Ls,ChannelCreation:()=>$r,ChannelHideMessage:()=>Tr,ChannelMessage:()=>Rr,ChannelMetadata:()=>Pr,ChannelMuteUser:()=>Ur,ClassifiedListing:()=>Rs,ClientAuth:()=>ps,CommunitiesList:()=>is,CommunityDefinition:()=>js,CommunityPostApproval:()=>Jr,Contacts:()=>Ir,CreateOrUpdateProduct:()=>Ss,CreateOrUpdateStall:()=>xs,Curationsets:()=>ks,Date:()=>Us,DirectMessageRelaysList:()=>cs,DraftClassifiedListing:()=>Ts,DraftLong:()=>Qs,Emojisets:()=>Fs,EncryptedDirectMessage:()=>Cr,EventDeletion:()=>Er,FileMetadata:()=>Lr,FileServerPreference:()=>us,Followsets:()=>ys,GenericRepost:()=>Dr,Genericlists:()=>ws,GiftWrap:()=>Nr,HTTPAuth:()=>vs,Handlerinformation:()=>Ms,Handlerrecommendation:()=>Os,Highlights:()=>Zr,InterestsList:()=>ls,Interestsets:()=>Es,JobFeedback:()=>qr,JobRequest:()=>Kr,JobResult:()=>Vr,Label:()=>Gr,LightningPubRPC:()=>fs,LiveChatMessage:()=>Or,LiveEvent:()=>$s,LongFormArticle:()=>Bs,Metadata:()=>Ar,Mutelist:()=>Xr,NWCWalletInfo:()=>ds,NWCWalletRequest:()=>hs,NWCWalletResponse:()=>gs,NostrConnect:()=>ms,OpenTimestamps:()=>_r,Pinlist:()=>es,PrivateDirectMessage:()=>Fr,ProblemTracker:()=>Mr,ProfileBadges:()=>Is,PublicChatsList:()=>rs,Reaction:()=>Sr,RecommendRelay:()=>kr,RelayList:()=>ts,Relaysets:()=>As,Report:()=>jr,Reporting:()=>Hr,Repost:()=>xr,Seal:()=>Qr,SearchRelaysList:()=>os,ShortTextNote:()=>br,Time:()=>_s,UserEmojiList:()=>as,UserStatuses:()=>Ps,Zap:()=>zr,ZapGoal:()=>Yr,ZapRequest:()=>Wr,classifyKind:()=>yr,isAddressableKind:()=>vr,isEphemeralKind:()=>mr,isKind:()=>wr,isRegularKind:()=>hr,isReplaceableKind:()=>gr});var Ar=0,br=1,kr=2,Ir=3,Cr=4,Er=5,xr=6,Sr=7,Br=8,Qr=13,Fr=14,Dr=16,$r=40,Pr=41,Rr=42,Tr=43,Ur=44,_r=1040,Nr=1059,Lr=1063,Or=1311,Mr=1971,jr=1984,Hr=1984,Gr=1985,Jr=4550,Kr=5999,Vr=6999,qr=7e3,Yr=9041,Wr=9734,zr=9735,Zr=9802,Xr=1e4,es=10001,ts=10002,ns=10003,is=10004,rs=10005,ss=10006,os=10007,ls=10015,as=10030,cs=10050,us=10096,ds=13194,fs=21e3,ps=22242,hs=23194,gs=23195,ms=24133,vs=27235,ys=3e4,ws=30001,As=30002,bs=30003,ks=30004,Is=30008,Cs=30009,Es=30015,xs=30017,Ss=30018,Bs=30023,Qs=30024,Fs=30030,Ds=30078,$s=30311,Ps=30315,Rs=30402,Ts=30403,Us=31922,_s=31923,Ns=31924,Ls=31925,Os=31989,Ms=31990,js=34550;function Hs(e,t){let n=t.length+3,i=e.indexOf(`"${t}":`)+n,r=e.slice(i).indexOf('"')+i+1;return e.slice(r,r+64)}function Gs(e,t){let n=t.length,i=e.indexOf(`"${t}":`)+n+3,r=e.slice(i),s=Math.min(r.indexOf(","),r.indexOf("}"));return parseInt(r.slice(0,s),10)}function Js(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let i=t+7+1+n,r=e.slice(i+1,80).indexOf('"');if(-1===r)return null;let s=i+1+r;return e.slice(i+1,s)}function Ks(e,t){return t===Hs(e,"id")}function Vs(e,t){return t===Hs(e,"pubkey")}function qs(e,t){return t===Gs(e,"kind")}Wi({},{getHex64:()=>Hs,getInt:()=>Gs,getSubscriptionId:()=>Js,matchEventId:()=>Ks,matchEventKind:()=>qs,matchEventPubkey:()=>Vs});function Ys(e,t){return{kind:ps,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}Wi({},{makeAuthEvent:()=>Ys});try{WebSocket}catch{}try{WebSocket}catch{}var Ws={};Wi(Ws,{BECH32_REGEX:()=>Xs,Bech32MaxSize:()=>Zs,NostrTypeGuard:()=>zs,decode:()=>to,decodeNostrURI:()=>eo,encodeBytes:()=>lo,naddrEncode:()=>uo,neventEncode:()=>co,noteEncode:()=>so,nprofileEncode:()=>ao,npubEncode:()=>ro,nsecEncode:()=>io});var zs={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},Zs=5e3,Xs=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function eo(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),to(e)}catch(e){return{type:"invalid",data:null}}}function to(e){let{prefix:t,words:n}=li.decode(e,Zs),i=new Uint8Array(li.fromWords(n));switch(t){case"nprofile":{let e=no(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Zt(e[0][0]),relays:e[1]?e[1].map(e=>Xi.decode(e)):[]}}}case"nevent":{let e=no(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Zt(e[0][0]),relays:e[1]?e[1].map(e=>Xi.decode(e)):[],author:e[2]?.[0]?Zt(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(Zt(e[3][0]),16):void 0}}}case"naddr":{let e=no(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Xi.decode(e[0][0]),pubkey:Zt(e[2][0]),kind:parseInt(Zt(e[3][0]),16),relays:e[1]?e[1].map(e=>Xi.decode(e)):[]}}}case"nsec":return{type:t,data:i};case"npub":case"note":return{type:t,data:Zt(i)};default:throw new Error(`unknown prefix ${t}`)}}function no(e){let t={},n=e;for(;n.length>0;){let e=n[0],i=n[1],r=n.slice(2,2+i);if(n=n.slice(2+i),r.lengther.encode(e))}))}function co(e){let t;return void 0!==e.kind&&(t=function(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}(e.kind)),oo("nevent",fo({0:[Xt(e.id)],1:(e.relays||[]).map(e=>er.encode(e)),2:e.author?[Xt(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function uo(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),oo("naddr",fo({0:[er.encode(e.identifier)],1:(e.relays||[]).map(e=>er.encode(e)),2:[Xt(e.pubkey)],3:[new Uint8Array(t)]}))}function fo(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let i=new Uint8Array(n.length+2);i.set([parseInt(e)],0),i.set([n.length],1),i.set(n,2),t.push(i)})}),tn(...t)}var po={};function ho(e,t,n){const i=e instanceof Uint8Array?Zt(e):e,r=mo(Ft.getSharedSecret(i,"02"+t));let s=Uint8Array.from(sn(16)),o=er.encode(n),l=Fi(r,s).encrypt(o);return`${Wn.encode(new Uint8Array(l))}?iv=${Wn.encode(new Uint8Array(s.buffer))}`}function go(e,t,n){const i=e instanceof Uint8Array?Zt(e):e;let[r,s]=n.split("?iv="),o=mo(Ft.getSharedSecret(i,"02"+t)),l=Wn.decode(s),a=Wn.decode(r),c=Fi(o,l).decrypt(a);return Xi.decode(c)}function mo(e){return e.slice(1,33)}Wi(po,{decrypt:()=>go,encrypt:()=>ho});Wi({},{NIP05_REGEX:()=>yo,isNip05:()=>wo,isValid:()=>Io,queryProfile:()=>ko,searchDomain:()=>bo,useFetchImplementation:()=>Ao});var vo,yo=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,wo=e=>yo.test(e||"");try{vo=fetch}catch(e){}function Ao(e){vo=e}async function bo(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,i=await vo(n,{redirect:"manual"});if(200!==i.status)throw Error("Wrong response code");return(await i.json()).names}catch(e){return{}}}async function ko(e){const t=e.match(yo);if(!t)return null;const[,n="_",i]=t;try{const e=`https://${i}/.well-known/nostr.json?name=${n}`,t=await vo(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const r=await t.json(),s=r.names[n];return s?{pubkey:s,relays:r.relays?.[s]}:null}catch(e){return null}}async function Io(e,t){const n=await ko(t);return!!n&&n.pubkey===e}function Co(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,i;for(let r=e.tags.length-1;r>=0;r--){const s=e.tags[r];if("e"===s[0]&&s[1]){const[e,r,o,l,a]=s,c={id:r,relays:o?[o]:[],author:a};if("root"===l){t.root=c;continue}if("reply"===l){t.reply=c;continue}if("mention"===l){t.mentions.push(c);continue}n?i=c:n=c,t.mentions.push(c);continue}if("q"===s[0]&&s[1]){const[e,n,i]=s;t.quotes.push({id:n,relays:i?[i]:[]})}"p"===s[0]&&s[1]&&t.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]})}return t.root||(t.root=i||n||t.reply),t.reply||(t.reply=n||t.root),[t.reply,t.root].forEach(e=>{if(!e)return;let n=t.mentions.indexOf(e);if(-1!==n&&t.mentions.splice(n,1),e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays?.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t.mentions.forEach(e=>{if(e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t}Wi({},{parse:()=>Co});Wi({},{fetchRelayInformation:()=>xo,useFetchImplementation:()=>Eo});try{fetch}catch{}function Eo(e){0}async function xo(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function So(e){let t=0;for(let n=0;n<64;n+=8){const i=parseInt(e.substring(n,n+8),16);if(0!==i){t+=Math.clz32(i);break}t+=32}return t}function Bo(e,t){let n=0;const i=e,r=["nonce",n.toString(),t.toString()];for(i.tags.push(r);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==i.created_at&&(n=0,i.created_at=e),r[1]=(++n).toString(),i.id=Qo(i),So(i.id)>=t)break}return i}function Qo(e){return Zt(vn(er.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}Wi({},{fastEventHash:()=>Qo,getPow:()=>So,minePow:()=>Bo});Wi({},{unwrapEvent:()=>tl,unwrapManyEvents:()=>nl,wrapEvent:()=>Xo,wrapManyEvents:()=>el});Wi({},{createRumor:()=>Ko,createSeal:()=>Vo,createWrap:()=>qo,unwrapEvent:()=>zo,unwrapManyEvents:()=>Zo,wrapEvent:()=>Yo,wrapManyEvents:()=>Wo});var Fo={};Wi(Fo,{decrypt:()=>Lo,encrypt:()=>No,getConversationKey:()=>Po,v2:()=>Oo});var Do=1,$o=65535;function Po(e,t){const n=Ft.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return an.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Ki(e,en(n),en(t))}(vn,n,"nip44-v2")}function Ro(e,t){const n=function(e,t,n,i=32){if(an.hash(e),an.number(i),i>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/e.outputLen);void 0===n&&(n=qi);const s=new Uint8Array(r*e.outputLen),o=Ki.create(e,t),l=o._cloneInto(),a=new Uint8Array(o.outputLen);for(let t=0;t$o)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t}(n),t,new Uint8Array(To(n)-n))}function _o(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const i=tn(n,t);return Ki(vn,e,i)}function No(e,t,n=sn(32)){const{chacha_key:i,chacha_nonce:r,hmac_key:s}=Ro(t,n),o=Uo(e),l=Gi(i,r,o),a=_o(s,l,n);return Wn.encode(tn(new Uint8Array([2]),n,l,a))}function Lo(e,t){const{nonce:n,ciphertext:i,mac:r}=function(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=Wn.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const i=n.length;if(i<99||i>65603)throw new Error("invalid data length: "+i);const r=n[0];if(2!==r)throw new Error("unknown encryption version "+r);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:s,chacha_nonce:o,hmac_key:l}=Ro(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let i=0;i$o||n.length!==t||e.length!==2+To(t))throw new Error("invalid padding");return Xi.decode(n)}(Gi(s,o,i))}var Oo={utils:{getConversationKey:Po,calcPaddedLen:To},encrypt:No,decrypt:Lo},Mo=()=>Math.round(Date.now()/1e3),jo=()=>Math.round(Mo()-172800*Math.random()),Ho=(e,t)=>Po(e,t),Go=(e,t,n)=>No(JSON.stringify(e),Ho(t,n)),Jo=(e,t)=>JSON.parse(Lo(e.content,Ho(t,e.pubkey)));function Ko(e,t){const n={created_at:Mo(),content:"",tags:[],...e,pubkey:ur(t)};return n.id=lr(n),n}function Vo(e,t,n){return dr({kind:Qr,content:Go(e,t,n),created_at:jo(),tags:[]},t)}function qo(e,t){const n=cr();return dr({kind:Nr,content:Go(e,n,t),created_at:jo(),tags:[["p",t]]},n)}function Yo(e,t,n){return qo(Vo(Ko(e,t),t,n),n)}function Wo(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const i=ur(t),r=[Yo(e,t,i)];return n.forEach(n=>{r.push(Yo(e,t,n))}),r}function zo(e,t){const n=Jo(e,t);return Jo(n,t)}function Zo(e,t){let n=[];return e.forEach(e=>{n.push(zo(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function Xo(e,t,n,i,r){const s=function(e,t,n,i){const r={created_at:Math.ceil(Date.now()/1e3),kind:Fr,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{r.tags.push(t?["p",e,t]:["p",e])}),i&&r.tags.push(["e",i.eventId,i.relayUrl||"","reply"]),n&&r.tags.push(["subject",n]),r}(t,n,i,r);return Yo(s,e,t.publicKey)}function el(e,t,n,i,r){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:ur(e)},...t].map(t=>Xo(e,t,n,i,r))}var tl=zo,nl=Zo;function il(e,t,n,i){let r;const s=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===br?r=xr:(r=Dr,s.push(["k",String(t.kind)])),dr({kind:r,tags:s,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},i)}function rl(e){if(![xr,Dr].includes(e.kind))return;let t,n;for(let i=e.tags.length-1;i>=0&&(void 0===t||void 0===n);i--){const r=e.tags[i];r.length>=2&&("e"===r[0]&&void 0===t?t=r:"p"===r[0]&&void 0===n&&(n=r))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function sl(e,{skipVerification:t}={}){const n=rl(e);if(void 0===n||""===e.content)return;let i;try{i=JSON.parse(e.content)}catch(e){return}return i.id===n.id&&(t||fr(i))?i:void 0}Wi({},{finishRepostEvent:()=>il,getRepostedEvent:()=>sl,getRepostedEventPointer:()=>rl});Wi({},{NOSTR_URI_REGEX:()=>ol,parse:()=>al,test:()=>ll});var ol=new RegExp(`nostr:(${Xs.source})`);function ll(e){return"string"==typeof e&&new RegExp(`^${ol.source}$`).test(e)}function al(e){const t=e.match(new RegExp(`^${ol.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:to(t[1])}}function cl(e,t,n){const i=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return dr({...e,kind:Sr,tags:[...e.tags??[],...i,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function ul(e){if(e.kind!==Sr)return;let t,n;for(let i=e.tags.length-1;i>=0&&(void 0===t||void 0===n);i--){const r=e.tags[i];r.length>=2&&("e"===r[0]&&void 0===t?t=r:"p"===r[0]&&void 0===n&&(n=r))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}Wi({},{finishReactionEvent:()=>cl,getReactedEventPointer:()=>ul});Wi({},{parse:()=>pl});var dl=/\W/m,fl=/\W |\W$|$|,| /m;function*pl(e){const t=e.length;let n=0,i=0;for(;ihl,channelHideMessageEvent:()=>vl,channelMessageEvent:()=>ml,channelMetadataEvent:()=>gl,channelMuteUserEvent:()=>yl});var hl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return dr({kind:$r,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},gl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return dr({kind:Pr,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},ml=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),dr({kind:Rr,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},vl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return dr({kind:Tr,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},yl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return dr({kind:Ur,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};Wi({},{EMOJI_SHORTCODE_REGEX:()=>wl,matchAll:()=>bl,regex:()=>Al,replaceAll:()=>kl});var wl=/:(\w+):/,Al=()=>new RegExp(`\\B${wl.source}\\B`,"g");function*bl(e){const t=e.matchAll(Al());for(const e of t)try{const[t,n]=e;yield{shortcode:t,name:n,start:e.index,end:e.index+t.length}}catch(e){}}function kl(e,t){return e.replaceAll(Al(),(e,n)=>t({shortcode:e,name:n}))}var Il;Wi({},{useFetchImplementation:()=>Cl,validateGithub:()=>El});try{Il=fetch}catch{}function Cl(e){Il=e}async function El(e,t,n){try{return await(await Il(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function xl(e){const{host:t,pathname:n,searchParams:i}=new URL(e),r=n||t,s=i.get("relay"),o=i.get("secret");if(!r||!s||!o)throw new Error("invalid connection string");return{pubkey:r,relay:s,secret:o}}async function Sl(e,t,n){const i={method:"pay_invoice",params:{invoice:n}},r=ho(t,e,JSON.stringify(i)),s={kind:hs,created_at:Math.round(Date.now()/1e3),content:r,tags:[["p",e]]};return dr(s,t)}Wi({},{makeNwcRequestEvent:()=>Sl,parseConnectionString:()=>xl});function Bl(e){return e=(e=e.trim().toLowerCase()).normalize("NFKC"),Array.from(e).map(e=>/\p{Letter}/u.test(e)||/\p{Number}/u.test(e)?e:"-").join("")}Wi({},{normalizeIdentifier:()=>Bl});var Ql;Wi({},{getSatoshisAmountFromBolt11:()=>Tl,getZapEndpoint:()=>Dl,makeZapReceipt:()=>Rl,makeZapRequest:()=>$l,useFetchImplementation:()=>Fl,validateZapRequest:()=>Pl});try{Ql=fetch}catch{}function Fl(e){Ql=e}async function Dl(e){try{let t="",{lud06:n,lud16:i}=JSON.parse(e.content);if(n){let{words:e}=li.decode(n,1e3),i=li.fromWords(e);t=Xi.decode(i)}else{if(!i)return null;{let[e,n]=i.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let r=await Ql(t),s=await r.json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch(e){}return null}function $l(e){let t={kind:9734,created_at:Math.round(Date.now()/1e3),content:e.comment||"",tags:[["p","pubkey"in e?e.pubkey:e.event.pubkey],["amount",e.amount.toString()],["relays",...e.relays]]};if("event"in e){if(t.tags.push(["e",e.event.id]),gr(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(vr(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const i=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(i)}t.tags.push(["k",e.event.kind.toString()])}return t}function Pl(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!Zi(t))return"Zap request is not a valid Nostr event.";if(!fr(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let i=t.tags.find(([e,t])=>"e"===e&&t);return i&&!i[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function Rl({zapRequest:e,preimage:t,bolt11:n,paidAt:i}){let r=JSON.parse(e),s=r.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),o={kind:9735,created_at:Math.round(i.getTime()/1e3),content:"",tags:[...s,["P",r.pubkey],["bolt11",n],["description",e]]};return t&&o.tags.push(["preimage",t]),o}function Tl(e){if(e.length<50)return 0;const t=(e=e.substring(0,50)).lastIndexOf("1");if(-1===t)return 0;const n=e.substring(0,t);if(!n.startsWith("lnbc"))return 0;const i=n.substring(4);if(i.length<1)return 0;const r=i[i.length-1],s=r.charCodeAt(0)-"0".charCodeAt(0),o=s>=0&&s<=9;let l=i.length-1;if(o&&l++,l<1)return 0;const a=parseInt(i.substring(0,l));switch(r){case"m":return 1e5*a;case"u":return 100*a;case"n":return a/10;case"p":return a/1e4;default:return 1e8*a}}Wi({},{getToken:()=>_l,hashPayload:()=>Gl,unpackEventFromToken:()=>Ll,validateEvent:()=>Kl,validateEventKind:()=>Ml,validateEventMethodTag:()=>Hl,validateEventPayloadTag:()=>Jl,validateEventTimestamp:()=>Ol,validateEventUrlTag:()=>jl,validateToken:()=>Nl});var Ul="Nostr ";async function _l(e,t,n,i=!1,r){const s={kind:vs,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};r&&s.tags.push(["payload",Gl(r)]);const o=await n(s);return(i?Ul:"")+Wn.encode(er.encode(JSON.stringify(o)))}async function Nl(e,t,n){const i=await Ll(e).catch(e=>{throw e});return await Kl(i,t,n).catch(e=>{throw e})}async function Ll(e){if(!e)throw new Error("Missing token");e=e.replace(Ul,"");const t=Xi.decode(Wn.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Ol(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function Ml(e){return e.kind===vs}function jl(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function Hl(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function Gl(e){return Zt(vn(er.encode(JSON.stringify(e))))}function Jl(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const i=Gl(t);return n.length>0&&n[1]===i}async function Kl(e,t,n,i){if(!fr(e))throw new Error("Invalid nostr event, signature invalid");if(!Ml(e))throw new Error("Invalid nostr event, kind invalid");if(!Ol(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!jl(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!Hl(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(i)&&"object"==typeof i&&Object.keys(i).length>0&&!Jl(e,i))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function Vl(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function ql(e){return 3e4<=e&&e<4e4}var Yl=function(e,t){return Yl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Yl(e,t)};function Wl(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Yl(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function zl(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function l(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,l)}a((i=i.apply(e,t||[])).next())})}function Zl(e,t){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=l(0),o.throw=l(1),o.return=l(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(l){return function(a){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&l[0]?i.return:l[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;switch(i=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,i=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){s=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ea(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function ta(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r1||l(e,t)})},t&&(i[e]=t(i[e])))}function l(e,t){try{(n=r[e](t)).value instanceof na?Promise.resolve(n.value.v).then(a,c):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function a(e){l("next",e)}function c(e){l("throw",e)}function u(e,t){e(t),s.shift(),s.length&&l(s[0][0],s[0][1])}}function ra(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Xl(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise(function(i,r){(function(e,t,n,i){Promise.resolve(i).then(function(t){e({value:t,done:n})},t)})(i,r,(t=e[n](t)).done,t.value)})}}}function sa(e){return"function"==typeof e}function oa(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var la=oa(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function aa(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var ca=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,i,r;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var o=Xl(s),l=o.next();!l.done;l=o.next()){l.value.remove(this)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else s.remove(this);var a=this.initialTeardown;if(sa(a))try{a()}catch(e){r=e instanceof la?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=Xl(c),d=u.next();!d.done;d=u.next()){var f=d.value;try{fa(f)}catch(e){r=null!=r?r:[],e instanceof la?r=ta(ta([],ea(r)),ea(e.errors)):r.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}if(r)throw new la(r)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)fa(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&aa(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&aa(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),ua=ca.EMPTY;function da(e){return e instanceof ca||e&&"closed"in e&&sa(e.remove)&&sa(e.add)&&sa(e.unsubscribe)}function fa(e){sa(e)?e():e.unsubscribe()}var pa={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ha={setTimeout:function(e,t){for(var n=[],i=2;i0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,i=n.hasError,r=n.isStopped,s=n.observers;return i||r?ua:(this.currentObservers=null,s.push(e),new ca(function(){t.currentObservers=null,aa(s,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,i=t.thrownError,r=t.isStopped;n?e.error(i):r&&e.complete()},t.prototype.asObservable=function(){var e=new Sa;return e.source=this,e},t.create=function(e,t){return new Ra(e,t)},t}(Sa),Ra=function(e){function t(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return Wl(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:ua},t}(Pa),Ta={now:function(){return(Ta.delegate||Date).now()},delegate:void 0},Ua=function(e){function t(t,n,i){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===i&&(i=Ta);var r=e.call(this)||this;return r._bufferSize=t,r._windowTime=n,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=n===1/0,r._bufferSize=Math.max(1,t),r._windowTime=Math.max(1,n),r}return Wl(t,e),t.prototype.next=function(t){var n=this,i=n.isStopped,r=n._buffer,s=n._infiniteTimeWindow,o=n._timestampProvider,l=n._windowTime;i||(r.push(t),!s&&r.push(o.now()+l)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,i=this._buffer.slice(),r=0;r=2,!0))}function _c(e,t){for(var n=[],i=2;it.reduce((e,t)=>{const n=[];for(const i of e)try{const e=t(i);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);var Vc=Symbol("verified");function qc(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;tt.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return i||e.splice(n,0,t),e}function nu(e,t){let n=0,i=e.length-1;for(;n<=i;){const r=Math.floor((n+i)/2),s=t(e[r]);if(0===s)return[r,!0];s<0?i=r-1:n=r+1}return[n,!1]}zc.finalizeEvent,zc.verifyEvent,new TextDecoder("utf-8"),new TextEncoder;const iu=Symbol.for("event-store"),ru=Symbol.for("event-uid"),su=Symbol.for("replaceable-address"),ou=Symbol.for("from-cache"),lu=Symbol.for("replaceable-identifier");function au(e){return Vl(e)||ql(e)}function cu(e){let t=Reflect.get(e,ru);return t||(t=ql(e.kind)||Vl(e.kind)?uu(e):e.id,Reflect.set(e,ru,t)),t}function uu(e){if(!ql(e.kind)&&!Vl(e.kind))throw new Error("Event is not replaceable or addressable");return eu(e,su,()=>du(e.kind,e.pubkey,fu(e)))}function du(e,t,n){return e+":"+t+":"+(n??"")}function fu(e){return eu(e,lu,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function pu(){return Math.round(Date.now()/1e3)}const hu=Symbol("expiration-timestamp");function gu(e){return eu(e,hu,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}var mu=new TextDecoder("utf-8");new TextEncoder;function vu(e){let{prefix:t,words:n}=li.decode(e,5e3),i=new Uint8Array(li.fromWords(n));switch(t){case"nprofile":{let e=yu(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Zt(e[0][0]),relays:e[1]?e[1].map(e=>mu.decode(e)):[]}}}case"nevent":{let e=yu(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Zt(e[0][0]),relays:e[1]?e[1].map(e=>mu.decode(e)):[],author:e[2]?.[0]?Zt(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(Zt(e[3][0]),16):void 0}}}case"naddr":{let e=yu(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:mu.decode(e[0][0]),pubkey:Zt(e[2][0]),kind:parseInt(Zt(e[3][0]),16),relays:e[1]?e[1].map(e=>mu.decode(e)):[]}}}case"nsec":return{type:t,data:i};case"npub":case"note":return{type:t,data:Zt(i)};default:throw new Error(`unknown prefix ${t}`)}}function yu(e){let t={},n=e;for(;n.length>0;){let e=n[0],i=n[1],r=n.slice(2,2+i);if(n=n.slice(2+i),r.length=8&&Cu.test(e)}function xu(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)}const Su="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0; -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Bu(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}const Qu=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Fu=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Du(e){if(Bu(e),Qu)return e.toHex();let t="";for(let n=0;n=$u&&e<=Pu?e-$u:e>=Ru&&e<=Tu?e-(Ru-10):e>=Uu&&e<=_u?e-(Uu-10):void 0}function Lu(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Qu)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,r=0;tArray.isArray(e)).map(e=>e.map(e=>String(e)));return Reflect.set(e,Xu,i),i}const rd="abcdefghijklmnopqrstuvwxyz",sd=new Set((rd+rd.toUpperCase()).split("")),od=Symbol.for("indexable-tags");function ld(e){let t=Reflect.get(e,od);if(!t){const n=new Set;for(const t of e.tags)t.length>=2&&1===t[0].length&&sd.has(t[0])&&n.add(t[0]+":"+t[1]);t=n,Reflect.set(e,od,n)}return t}class ad{first=null;items=Object.create(null);last=null;max;resetTtl;size;ttl;constructor(e=0,t=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map(e=>[e,this.get(e)])}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0===--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const n=this.items[e];this.ttl>0&&n.expiry<=Date.now()?this.delete(e):(t=n.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,n=!1,i=this.resetTtl){let r;if(n||this.has(e)){if(r=this.items[e],r.value=t,!1===n&&i&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==r){const e=this.last,t=r.next,n=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,e.next=r,null!==n&&(n.next=t),null!==t&&(t.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1===++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(e=this.keys()){return e.map(e=>this.get(e))}}function cd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ud,dd,fd={exports:{}};function pd(){if(dd)return ud;dd=1;var e=1e3,t=60*e,n=60*t,i=24*n,r=7*i,s=365.25*i;function o(e,t,n,i){var r=t>=1.5*n;return Math.round(e/n)+" "+i+(r?"s":"")}return ud=function(l,a){a=a||{};var c=typeof l;if("string"===c&&l.length>0)return function(o){if((o=String(o)).length>100)return;var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(!l)return;var a=parseFloat(l[1]);switch((l[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"weeks":case"week":case"w":return a*r;case"days":case"day":case"d":return a*i;case"hours":case"hour":case"hrs":case"hr":case"h":return a*n;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(l);if("number"===c&&isFinite(l))return a.long?function(r){var s=Math.abs(r);if(s>=i)return o(r,s,i,"day");if(s>=n)return o(r,s,n,"hour");if(s>=t)return o(r,s,t,"minute");if(s>=e)return o(r,s,e,"second");return r+" ms"}(l):function(r){var s=Math.abs(r);if(s>=i)return Math.round(r/i)+"d";if(s>=n)return Math.round(r/n)+"h";if(s>=t)return Math.round(r/t)+"m";if(s>=e)return Math.round(r/e)+"s";return r+"ms"}(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))}}var hd=function(e){function t(e){let i,r,s,o=null;function l(...e){if(!l.enabled)return;const n=l,r=Number(new Date),s=r-(i||r);n.diff=s,n.prev=i,n.curr=r,i=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(i,r)=>{if("%%"===i)return"%";o++;const s=t.formatters[r];if("function"==typeof s){const t=e[o];i=s.call(n,t),e.splice(o,1),o--}return i}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return l.namespace=e,l.useColors=t.useColors(),l.color=t.selectColor(e),l.extend=n,l.destroy=t.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(r!==t.namespaces&&(r=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(l),l}function n(e,n){const i=t(this.namespace+(void 0===n?":":n)+e);return i.log=this.log,i}function i(e,t){let n=0,i=0,r=-1,s=0;for(;n"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(i(e,n))return!1;for(const n of t.names)if(i(e,n))return!0;return!1},t.humanize=pd(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"%%"!==e&&(i++,"%c"===e&&(r=i))}),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=hd(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(fd,fd.exports);const gd=cd(fd.exports)("applesauce");class md{log=gd.extend("EventMemory");kinds=new Map;authors=new Map;tags=new ad;created_at=[];kindAuthor=new Map;events=new ad;replaceable=new Map;get size(){return this.events.size}hasEvent(e){return this.events.has(e)}getEvent(e){return this.events.get(e)}hasReplaceable(e,t,n){const i=this.replaceable.get(du(e,t,n));return!!i&&i.length>0}getReplaceable(e,t,n){const i=du(e,t,n),r=this.replaceable.get(i);return r?.[0]}getReplaceableHistory(e,t,n){const i=du(e,t,n);return this.replaceable.get(i)}getByFilters(e){return Array.from(this.getEventsForFilters(Array.isArray(e)?e:[e]))}getTimeline(e){const t=[],n=this.getByFilters(e);for(const e of n)tu(t,e);return t}add(e){const t=e.id,n=this.events.get(t);if(n)return n;this.events.set(t,e),this.getKindIndex(e.kind).add(e),this.getAuthorsIndex(e.pubkey).add(e),this.getKindAuthorIndex(e.kind,e.pubkey).add(e);for(const t of ld(e))this.tags.has(t)&&this.getTagIndex(t).add(e);if(tu(this.created_at,e),au(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=du(e.kind,e.pubkey,t);let i=this.replaceable.get(n);this.replaceable.has(n)||(i=[],this.replaceable.set(n,i)),tu(i,e)}return e}remove(e){let t="string"==typeof e?this.events.get(e):e;if(!t)return!1;const n=t.id;if(!this.events.has(n))return!1;this.getAuthorsIndex(t.pubkey).delete(t),this.getKindIndex(t.kind).delete(t);const i=`${t.kind}:${t.pubkey}`;this.kindAuthor.has(i)&&this.kindAuthor.get(i).delete(t);for(const e of ld(t))this.tags.has(e)&&this.getTagIndex(e).delete(t);if(this.removeFromSortedArray(this.created_at,t),this.events.delete(n),au(t.kind)){const e=t.tags.find(e=>"d"===e[0])?.[1],n=du(t.kind,t.pubkey,e),i=this.replaceable.get(n);i&&this.removeFromSortedArray(i,t)}return this.claims.delete(t),!0}removeByFilters(e){const t=this.getByFilters(e);let n=0;for(const e of t)this.remove(e)&&n++;return n}update(e){}claims=new WeakMap;touch(e){this.events.has(e.id)&&this.events.set(e.id,e)}claim(e){const t=this.claims.get(e)||0;this.claims.set(e,t+1),this.touch(e)}isClaimed(e){const t=this.claims.get(e);return void 0!==t&&t>0}removeClaim(e){const t=this.claims.get(e);if(void 0!==t&&t>0){const n=t-1;0===n?this.claims.delete(e):this.claims.set(e,n)}}clearClaim(e){this.claims.delete(e)}*unclaimed(){let e=this.events.first;for(;e;){const t=e.value;this.isClaimed(t)||(yield t),e=e.next}return 0}prune(e){let t=0;const n=this.unclaimed();for(const i of n)if(this.remove(i),t++,e&&t>=e)break;return t}getKindIndex(e){return this.kinds.has(e)||this.kinds.set(e,new Set),this.kinds.get(e)}getAuthorsIndex(e){return this.authors.has(e)||this.authors.set(e,new Set),this.authors.get(e)}getKindAuthorIndex(e,t){const n=`${e}:${t}`;return this.kindAuthor.has(n)||this.kindAuthor.set(n,new Set),this.kindAuthor.get(n)}getTagIndex(e){if(!this.tags.has(e)){const t=new Set,n=Date.now();for(const n of this.events.values())ld(n).has(e)&&t.add(n);const i=Date.now()-n;i>100&&this.log(`Built index ${e} took ${i}ms`),this.tags.set(e,t)}return this.tags.get(e)}removeFromSortedArray(e,t){if(0===e.length)return;const n=nu(e,e=>e.created_at-t.created_at);if(n){let i=n[0],r=!1;if(e[i]===t)return void e.splice(i,1);for(let n=i-1;n>=0&&e[n].created_at===t.created_at;n--)if(e[n]===t){e.splice(n,1),r=!0;break}if(r)return;for(let n=i+1;ne.created_at-t):void 0;r&&(n=r[0]);const s=e?nu(this.created_at,t=>t.created_at-e):void 0;s&&(i=s[0]);for(let r=n;r<=i;r++){const n=this.created_at[r];if(!(void 0!==t&&n.created_at>t)){if(void 0!==e&&n.created_at{const i=e instanceof Set?e:new Set(e);if(t)n=i,t=!1;else for(const e of n)i.has(e)||n.delete(e);return n};e.ids&&i(this.iterateIds(e.ids));let r=null;void 0!==e.since&&(r=Array.from(this.iterateTime(e.since,e.until)),i(r));for(const t of sd){const n=e[`&${t}`];if(n?.length)for(const e of n)i(this.iterateTag(t,[e]))}for(const t of sd){const n=e[`#${t}`];if(n?.length){const r=e[`&${t}`],s=r?n.filter(e=>!r.includes(e)):n;s.length>0&&i(this.iterateTag(t,s))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<=20){const t=new Set;for(const n of e.kinds)for(const i of e.authors){const e=`${n}:${i}`,r=this.kindAuthor.get(e);if(r)for(const e of r)t.add(e)}i(t)}else e.authors&&i(this.iterateAuthors(e.authors)),e.kinds&&i(this.iterateKinds(e.kinds));if(void 0===e.since&&void 0!==e.until&&(r=Array.from(this.iterateTime(e.since,e.until)),i(r)),t)return new Set(this.events.values());if(e.limit&&r){const t=new Set;for(const i of r){if(t.size>=e.limit)break;n.has(i)&&t.add(i)}return t}return n}getEventsForFilters(e){if(0===e.length)return new Set;let t=new Set;for(const n of e){const e=this.getEventsForFilter(n);for(const n of e)t.add(n)}return t}reset(){this.events.clear(),this.kinds.clear(),this.authors.clear(),this.kindAuthor.clear(),this.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}}function vd(e,t){var n,i;if(0===t.length)return e;for(n=0,i=t.length;ne.until)return!1;for(let n in e)if("&"===n[0]){let i=n.slice(1),r=e[n];if(r&&r.length>0){const e=ld(t);for(const t of r)if(!e.has(i+":"+t))return!1}}for(let n in e)if("#"===n[0]){let i=n.slice(1),r=e[n];if(r){const n=e[`&${i}`],s=n?r.filter(e=>!n.includes(e)):r;if(0===s.length)continue;const o=ld(t);if(!1===s.some(e=>o.has(i+":"+e)))return!1}}return!0}function kd(e,t){for(let n=0;nt.replaceable({kind:10063,pubkey:e.pubkey,relays:e.relays}).pipe(fc(e=>e?function(e){const t=Array.isArray(e)?e:e.tags;return Kc(t,e=>Oc(e,"server")&&URL.canParse(e[1])?new URL("/",e[1]):void 0)}(e):[]))}const Cd=Symbol.for("profile-content");function Ed(e){return eu(e,Cd,()=>{const t=function(e){try{return JSON.parse(e)}catch(e){return}}(e.content);if(t)return t.nip05&&"string"!=typeof t.nip05&&(t.nip05=String(t.nip05)),t.website&&t.website?.length>0&&!1===t.website?.startsWith("http")&&(t.website="https://"+t.website),t})}function xd(e){return!!e&&((e.kind===pr.Metadata||e.kind===pr.Handlerinformation)&&!!Ed(e))}!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),i=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:i}}function i(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map(n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function r(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let i=t.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&t[i-1]===n;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,i)}}}function o(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function l(e,n,i){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(i<2)throw new Error(`convertRadix: wrong to=${i}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],o=Array.from(e);for(o.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let s=r;s(e+t/Qt)/t;function $t(e){const t=xt,n=BigInt(3),i=BigInt(6),r=BigInt(11),s=BigInt(22),o=BigInt(23),l=BigInt(44),a=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=st(u,n,t)*u%t,f=st(d,n,t)*u%t,p=st(f,Qt,t)*c%t,h=st(p,r,t)*p%t,g=st(h,s,t)*h%t,m=st(g,l,t)*g%t,v=st(m,a,t)*m%t,y=st(v,l,t)*g%t,w=st(y,n,t)*u%t,b=st(w,o,t)*h%t,A=st(b,i,t)*c%t,k=st(A,Qt,t);if(!Dt.eql(Dt.sqr(k),e))throw new Error("Cannot find square root");return k}const Dt=function(e,t,n=!1,i={}){if(e<=ze)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:r,nByteLength:s}=ct(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=lt(e),l=Object.freeze({ORDER:e,BITS:r,BYTES:s,MASK:He(r),ZERO:ze,ONE:We,create:t=>it(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return ze<=t&&te===ze,isOdd:e=>(e&We)===We,neg:t=>it(-t,e),eql:(e,t)=>e===t,sqr:t=>it(t*t,e),add:(t,n)=>it(t+n,e),sub:(t,n)=>it(t-n,e),mul:(t,n)=>it(t*n,e),pow:(e,t)=>function(e,t,n){if(n 0");if(n===ze)return e.ONE;if(n===We)return t;let i=e.ONE,r=t;for(;n>ze;)n&We&&(i=e.mul(i,r)),r=e.sqr(r),n>>=We;return i}(l,e,t),div:(t,n)=>it(t*ot(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ot(t,e),sqrt:i.sqrt||(e=>o(l,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),i=t.reduce((t,i,r)=>e.is0(i)?t:(n[r]=t,e.mul(t,i)),e.ONE),r=e.inv(i);return t.reduceRight((t,i,r)=>e.is0(i)?t:(n[r]=e.mul(t,n[r]),e.mul(t,i)),r),n}(l,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Me(e,s):Le(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return n?_e(e):Ne(e)}});return Object.freeze(l)}(xt,void 0,void 0,{sqrt:$t}),Rt=function(e,t){const n=t=>kt({...e,...Et(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Dt,n:St,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=St,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-Bt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),l=Ft(s*e,t),a=Ft(-i*e,t);let c=it(e-l*n-a*r,t),u=it(-l*i-a*s,t);const d=c>o,f=u>o;if(d&&(c=t-c),f&&(u=t-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}}},Se),Pt=BigInt(0),Tt=e=>"bigint"==typeof e&&Pte.charCodeAt(0)));n=je(t,t),Ut[e]=n}return Se(je(n,...t))}const _t=e=>e.toRawBytes(!0).slice(1),Lt=e=>Le(e,32),Mt=e=>it(e,xt),Ot=e=>it(e,St),jt=Rt.ProjectivePoint;function Ht(e){let t=Rt.utils.normPrivateKeyToScalar(e),n=jt.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Ot(-t),bytes:_t(n)}}function Gt(e){if(!Tt(e))throw new Error("bad x: need 0 < x < p");const t=Mt(e*e);let n=$t(Mt(t*e+BigInt(7)));n%Qt!==Pt&&(n=Mt(-n));const i=new jt(e,n,Bt);return i.assertValidity(),i}function qt(...e){return Ot(Ne(Nt("BIP0340/challenge",...e)))}function Jt(e){return Ht(e).bytes}function Kt(e,t,n=we(32)){const i=Oe("message",e),{bytes:r,scalar:s}=Ht(t),o=Oe("auxRand",n,32),l=Lt(s^Ne(Nt("BIP0340/aux",o))),a=Nt("BIP0340/nonce",l,r,i),c=Ot(Ne(a));if(c===Pt)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Ht(c),f=qt(u,r,i),p=new Uint8Array(64);if(p.set(u,0),p.set(Lt(Ot(d+f*s)),32),!Vt(p,i,r))throw new Error("sign: Invalid signature produced");return p}function Vt(e,t,n){const i=Oe("signature",e,64),r=Oe("message",t),s=Oe("publicKey",n,32);try{const e=Gt(Ne(s)),t=Ne(i.subarray(0,32));if(!Tt(t))return!1;const n=Ne(i.subarray(32,64));if(!("bigint"==typeof(c=n)&&Pt({getPublicKey:Jt,sign:Kt,verify:Vt,utils:{randomPrivateKey:Rt.utils.randomPrivateKey,lift_x:Gt,pointToBytes:_t,numberToBytesBE:Le,bytesToNumberBE:Ne,taggedHash:Nt,mod:it}}))(),zt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Wt=e=>e instanceof Uint8Array,Zt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Xt=(e,t)=>e<<32-t|e>>>t;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const en=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function tn(e){if(!Wt(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!Wt(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}class on{clone(){return this._cloneInto()}}function ln(e){const t=t=>e().update(rn(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function an(e=32){if(zt&&"function"==typeof zt.getRandomValues)return zt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function cn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function un(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}const dn={number:cn,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:un,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");cn(e.outputLen),cn(e.blockLen)},exists:function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},output:function(e,t){un(e);const n=t.outputLen;if(e.lengthi-s&&(this.process(n,0),s=0);for(let e=s;e>r&s),l=Number(n&s),a=i?4:0,c=i?0:4;e.setUint32(t+a,o,i),e.setUint32(t+c,l,i)}(n,i-8,BigInt(8*this.length),r),this.process(n,0);const o=Zt(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=l/4,c=this.get();if(a>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,hn=(e,t,n)=>e&t^e&n^t&n,gn=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),mn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),vn=new Uint32Array(64);class yn extends fn{constructor(){super(64,32,8,!1),this.A=0|mn[0],this.B=0|mn[1],this.C=0|mn[2],this.D=0|mn[3],this.E=0|mn[4],this.F=0|mn[5],this.G=0|mn[6],this.H=0|mn[7]}get(){const{A:e,B:t,C:n,D:i,E:r,F:s,G:o,H:l}=this;return[e,t,n,i,r,s,o,l]}set(e,t,n,i,r,s,o,l){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|r,this.F=0|s,this.G=0|o,this.H=0|l}process(e,t){for(let n=0;n<16;n++,t+=4)vn[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=vn[e-15],n=vn[e-2],i=Xt(t,7)^Xt(t,18)^t>>>3,r=Xt(n,17)^Xt(n,19)^n>>>10;vn[e]=r+vn[e-7]+i+vn[e-16]|0}let{A:n,B:i,C:r,D:s,E:o,F:l,G:a,H:c}=this;for(let e=0;e<64;e++){const t=c+(Xt(o,6)^Xt(o,11)^Xt(o,25))+pn(o,l,a)+gn[e]+vn[e]|0,u=(Xt(n,2)^Xt(n,13)^Xt(n,22))+hn(n,i,r)|0;c=a,a=l,l=o,o=s+t|0,s=r,r=i,i=n,n=t+u|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,s=s+this.D|0,o=o+this.E|0,l=l+this.F|0,a=a+this.G|0,c=c+this.H|0,this.set(n,i,r,s,o,l,a,c)}roundClean(){vn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class wn extends yn{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const bn=ln(()=>new yn);ln(()=>new wn);var An=Symbol("verified");function kn(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;te===n.slice(1)&&-1!==i.indexOf(t)))return!1}return!(e.since&&t.created_ate.until)}async function $n(){return new Promise(e=>{const t=new MessageChannel,n=()=>{t.port1.removeEventListener("message",n),e()};t.port1.addEventListener("message",n),t.port2.postMessage(0),t.port1.start()})}var Dn,Rn=e=>(e[An]=!0,!0),Pn=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},Tn=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);baseEoseTimeout=4400;connectionTimeout=4400;publishTimeout=4400;pingFrequency=2e4;pingTimeout=2e4;openSubs=new Map;enablePing;connectionTimeoutHandle;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new xn;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=Cn(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing}static async connect(e,t){const n=new Tn(e,t);return await n.connect(),n}closeAllSubscriptions(e){for(let[t,n]of this.openSubs)n.close(e);this.openSubs.clear();for(let[t,n]of this.openEventPublishes)n.reject(new Error(e));this.openEventPublishes.clear();for(let[t,n]of this.openCountRequests)n.reject(new Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise||(this.challenge=void 0,this.authPromise=void 0,this.connectionPromise=new Promise((e,t)=>{this.connectionTimeoutHandle=setTimeout(()=>{t("connection timed out"),this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(e){return clearTimeout(this.connectionTimeoutHandle),void t(e)}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,this.enablePing&&this.pingpong(),e()},this.ws.onerror=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket error"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection errored")},this.ws.onclose=e=>{clearTimeout(this.connectionTimeoutHandle),t(e.message||"websocket closed"),this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection closed")},this.ws.onmessage=this._onmessage.bind(this)})),this.connectionPromise}async waitForPingPong(){return new Promise((e,t)=>{this.ws&&this.ws.on&&this.ws.on("pong",()=>e(!0))||t("ws can't listen for pong"),this.ws&&this.ws.ping&&this.ws.ping()})}async waitForDummyReq(){return new Promise((e,t)=>{const n=this.subscribe([{ids:["a".repeat(64)]}],{oneose:()=>{n.close(),e(!0)},eoseTimeout:this.pingTimeout+1e3})})}async pingpong(){if(1===this.ws?.readyState){await Promise.any([this.ws&&this.ws.ping&&this.ws.on?this.waitForPingPong():this.waitForDummyReq(),new Promise(e=>setTimeout(()=>e(!1),this.pingTimeout))])?setTimeout(()=>this.pingpong(),this.pingFrequency):(this.closeAllSubscriptions("pingpong timed out"),this._connected=!1,this.onclose?.(),this.ws?.close())}}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await $n();this.queueRunning=!1}handleNext(){const e=this.incomingMessageQueue.dequeue();if(!e)return!1;const t=function(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let i=t+7+1+n,r=e.slice(i+1,80).indexOf('"');if(-1===r)return null;let s=i+1+r;return e.slice(i+1,s)}(e);if(t){const n=this.openSubs.get(t);if(!n)return;const i=function(e,t){let n=t.length+3,i=e.indexOf(`"${t}":`)+n,r=e.slice(i).indexOf('"')+i+1;return e.slice(r,r+64)}(e,"id"),r=n.alreadyHaveEvent?.(i);if(n.receivedEvent?.(this,i),r)return}try{let t=JSON.parse(e);switch(t[0]){case"EVENT":{const e=this.openSubs.get(t[1]),n=t[2];return void(this.verifyEvent(n)&&function(e,t){for(let n=0;n{this.ws?.send(e)})}async auth(e){const t=this.challenge;if(!t)throw new Error("can't perform auth, no challenge was received");return this.authPromise||(this.authPromise=new Promise(async(n,i)=>{try{let r=await e(function(e,t){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}(this.url,t)),s=setTimeout(()=>{let e=this.openEventPublishes.get(r.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(r.id))},this.publishTimeout);this.openEventPublishes.set(r.id,{resolve:n,reject:i,timeout:s}),this.send('["AUTH",'+JSON.stringify(r)+"]")}catch(e){console.warn("subscribe auth function failed:",e)}})),this.authPromise}async publish(e){const t=new Promise((t,n)=>{const i=setTimeout(()=>{const t=this.openEventPublishes.get(e.id);t&&(t.reject(new Error("publish timed out")),this.openEventPublishes.delete(e.id))},this.publishTimeout);this.openEventPublishes.set(e.id,{resolve:t,reject:n,timeout:i})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;const n=t?.id||"count:"+this.serial,i=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),i}subscribe(e,t){const n=this.prepareSubscription(e,t);return n.fire(),n}prepareSubscription(e,t){this.serial++;const n=t.id||(t.label?t.label+":":"sub:")+this.serial,i=new Un(this,n,e,t);return this.openSubs.set(n,i),i}close(){this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.onclose?.(),this.ws?.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},Un=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,i){this.relay=e,this.filters=n,this.id=t,this.alreadyHaveEvent=i.alreadyHaveEvent,this.receivedEvent=i.receivedEvent,this.eoseTimeout=i.eoseTimeout||e.baseEoseTimeout,this.oneose=i.oneose,this.onclose=i.onclose,this.onevent=i.onevent||(e=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,e)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,this.oneose?.())}close(e="closed by caller"){if(!this.closed&&this.relay.connected){try{this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]")}catch(e){if(!(e instanceof Pn))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}},Nn=class{relays=new Map;seenOn=new Map;trackRelays=!1;verifyEvent;enablePing;trustedRelayURLs=new Set;_WebSocket;constructor(e){this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation,this.enablePing=e.enablePing}async ensureRelay(e,t){e=Cn(e);let n=this.relays.get(e);return n||(n=new Tn(e,{verifyEvent:this.trustedRelayURLs.has(e)?Rn:this.verifyEvent,websocketImplementation:this._WebSocket,enablePing:this.enablePing}),n.onclose=()=>{this.relays.delete(e)},t?.connectionTimeout&&(n.connectionTimeout=t.connectionTimeout),this.relays.set(e,n)),await n.connect(),n}close(e){e.map(Cn).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){n.onauth=n.onauth||n.doauth;const i=[];for(let n=0;ne.url===r)||i.push({url:r,filter:t})}return this.subscribeMap(i,n)}subscribeMany(e,t,n){n.onauth=n.onauth||n.doauth;const i=[],r=[];for(let n=0;n({url:e,filters:t}));this.trackRelays&&(t.receivedEvent=(e,t)=>{let n=this.seenOn.get(t);n||(n=new Set,this.seenOn.set(t,n)),n.add(e)});const r=new Set,s=[],o=[];let l=n=>{o[n]||(o[n]=!0,o.filter(e=>e).length===e.length&&(t.oneose?.(),l=()=>{}))};const a=[];let c=(n,i)=>{a[n]||(l(n),a[n]=i,a.filter(e=>e).length===e.length&&(t.onclose?.(a),c=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=r.has(e);return r.add(e),n},d=Promise.all(i.map(async({url:e,filters:n},i)=>{let r;try{r=await this.ensureRelay(e,{connectionTimeout:t.maxWait?Math.max(.8*t.maxWait,t.maxWait-1e3):void 0})}catch(e){return void c(i,e?.message||String(e))}let o=r.subscribe(n,{...t,oneose:()=>l(i),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?r.auth(t.onauth).then(()=>{r.subscribe(n,{...t,oneose:()=>l(i),onclose:e=>{c(i,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait})}).catch(e=>{c(i,`auth was required and attempted, but failed with: ${e}`)}):c(i,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait});s.push(o)}));return{async close(e){await d,s.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){n.onauth=n.onauth||n.doauth;const i=this.subscribe(e,t,{...n,oneose(){i.close("closed automatically on eose")}});return i}subscribeManyEose(e,t,n){n.onauth=n.onauth||n.doauth;const i=this.subscribeMany(e,t,{...n,oneose(){i.close("closed automatically on eose")}});return i}async querySync(e,t,n){return new Promise(async i=>{const r=[];this.subscribeEose(e,t,{...n,onevent(e){r.push(e)},onclose(e){i(r)}})})}async get(e,t,n){t.limit=1;const i=await this.querySync(e,t,n);return i.sort((e,t)=>t.created_at-e.created_at),i[0]||null}publish(e,t,n){return e.map(Cn).map(async(e,i,r)=>{if(r.indexOf(e)!==i)return Promise.reject("duplicate url");let s=await this.ensureRelay(e);return s.publish(t).catch(async e=>{if(e instanceof Error&&e.message.startsWith("auth-required: ")&&n?.onauth)return await s.auth(n.onauth),s.publish(t);throw e}).then(e=>{if(this.trackRelays){let e=this.seenOn.get(t.id);e||(e=new Set,this.seenOn.set(t.id,e)),e.add(s)}return e})})}listConnectionStatus(){const e=new Map;return this.relays.forEach((t,n)=>e.set(n,t.connected)),e}destroy(){this.relays.forEach(e=>e.close()),this.relays=new Map}};try{Dn=WebSocket}catch{}var _n=class extends Nn{constructor(e){super({verifyEvent:Qn,websocketImplementation:Dn,...e})}}; +/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ln(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function Mn(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),i=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:i}}function On(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(Ln(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function jn(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function Hn(e,t="="){if(Ln(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let e of n)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let i=n.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,i)}}}function Gn(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function qn(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const r=[],s=Array.from(e);for(s.forEach(e=>{if(Ln(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,o=!0;for(let r=i;rt?Jn(t,e%t):e,Kn=(e,t)=>e+(t-Jn(e,t));function Vn(e,t,n,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Kn(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Kn(t,n)}`);let r=0,s=0;const o=2**n-1,l=[];for(const i of e){if(Ln(i),i>=2**t)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(r=r<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)l.push((r>>s-n&o)>>>0);r&=2**s-1}if(r=r<=t)throw new Error("Excess padding");if(!i&&r)throw new Error(`Non-zero padding: ${r}`);return i&&s>0&&l.push(r>>>0),l}function Yn(e,t=!1){if(Ln(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Kn(8,e)>32||Kn(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Vn(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Vn(n,e,8,t))}}}function zn(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}const Wn=Mn(Yn(4),On("0123456789ABCDEF"),jn("")),Zn=Mn(Yn(5),On("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Hn(5),jn(""));Mn(Yn(5),On("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Hn(5),jn("")),Mn(Yn(5),On("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),jn(""),Gn(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const Xn=Mn(Yn(6),On("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Hn(6),jn("")),ei=Mn(Yn(6),On("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Hn(6),jn("")),ti=e=>{return Mn((Ln(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return qn(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(qn(e,t,256))}}),On(e),jn(""));var t},ni=ti("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");ti("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),ti("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const ii=[0,2,3,5,6,7,9,10,11],ri={encode(e){let t="";for(let n=0;n>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=oi[e]);return n}function ai(e,t,n=1){const i=e.length;let r=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);r=li(r)^n>>5}r=li(r);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=i).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,r),o=e.slice(r+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const l=si.decode(o).slice(0,-6),a=ai(s,l,t);if(!o.endsWith(a))throw new Error(`Invalid checksum in ${e}: expected "${a}"`);return{prefix:s,words:l}}return{encode:function(e,n,i=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const r=e.length+7+n.length;if(!1!==i&&r>i)throw new TypeError(`Length ${r} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${si.encode(n)}${ai(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:i(n)}},decodeUnsafe:zn(o),fromWords:i,fromWordsUnsafe:s,toWords:r}}const ui=ci("bech32");ci("bech32m");const di={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:Mn(Yn(4),On("0123456789abcdef"),jn(""),Gn(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),base16:Wn,base32:Zn,base64:Xn,base64url:ei,base58:ni,base58xmr:ri};function fi(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function pi(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function hi(e,...t){if(!((n=e)instanceof Uint8Array||null!=n&&"object"==typeof n&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)} +/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */Object.keys(di).join(", ");const gi=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const mi=16;function vi(e){return e<<1^283&-(e>>7)}function yi(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=vi(e);return n}const wi=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=vi(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let i=e[255-n];i|=i<<8,t[e[n]]=255&(i^i>>4^i>>5^i>>6^i>>7^99)}return t})(),bi=wi.map((e,t)=>wi.indexOf(t)),Ai=e=>e<<24|e>>>8,ki=e=>e<<8|e>>>24;function Ii(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,i)=>t(e[i])),i=n.map(ki),r=i.map(ki),s=r.map(ki),o=new Uint32Array(65536),l=new Uint32Array(65536),a=new Uint16Array(65536);for(let t=0;t<256;t++)for(let c=0;c<256;c++){const u=256*t+c;o[u]=n[t]^i[c],l[u]=r[t]^s[c],a[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:a,T0:n,T1:i,T2:r,T3:s,T01:o,T23:l}}const Ci=Ii(wi,e=>yi(e,3)<<24|e<<16|e<<8|yi(e,2)),Ei=Ii(bi,e=>yi(e,11)<<24|yi(e,13)<<16|yi(e,9)<<8|yi(e,14)),xi=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=vi(n))e[t]=n;return e})();function Si(e){hi(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=Ci,i=gi(e),r=i.length,s=e=>Qi(n,e,e,e,e),o=new Uint32Array(t+28);o.set(i);for(let e=r;e6&&e%r===4&&(t=s(t)),o[e]=o[e-r]^t}return o}function Bi(e,t,n,i,r,s){return e[n<<8&65280|i>>>8&255]^t[r>>>8&65280|s>>>24&255]}function Qi(e,t,n,i,r){return e[255&t|65280&n]|e[i>>>16&255|r>>>16&65280]<<16}function Fi(e,t,n,i,r){const{sbox2:s,T01:o,T23:l}=Ci;let a=0;t^=e[a++],n^=e[a++],i^=e[a++],r^=e[a++];const c=e.length/4-2;for(let s=0;s{const s=Si(e),{b:o,o:l,out:a}=function(e,t,n){let i=e.length;const r=i%mi;if(!t&&0!==r)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const s=gi(e);if(t){let e=mi-r;e||(e=mi),i+=e}const o=Di(i,n);return{b:s,o:gi(o),out:o}}(n,i,r),c=gi(t);let u=c[0],d=c[1],f=c[2],p=c[3],h=0;for(;h+4<=o.length;)u^=o[h+0],d^=o[h+1],f^=o[h+2],p^=o[h+3],({s0:u,s1:d,s2:f,s3:p}=Fi(s,u,d,f,p)),l[h++]=u,l[h++]=d,l[h++]=f,l[h++]=p;if(i){const e=function(e){const t=new Uint8Array(16),n=gi(t);t.set(e);const i=mi-e.length;for(let e=mi-i;e{!function(e){if(hi(e),e.length%mi!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const s=function(e){const t=Si(e),n=t.slice(),i=t.length,{sbox2:r}=Ci,{T0:s,T1:o,T2:l,T3:a}=Ei;for(let e=0;e>>8&255]^l[i>>>16&255]^a[i>>>24]}return n}(e),o=gi(t),l=Di(n.length,r),a=gi(n),c=gi(l);let u=o[0],d=o[1],f=o[2],p=o[3];for(let e=0;e+4<=a.length;){const t=u,n=d,i=f,r=p;u=a[e+0],d=a[e+1],f=a[e+2],p=a[e+3];const{s0:o,s1:l,s2:h,s3:g}=$i(s,u,d,f,p);c[e++]=o^t,c[e++]=l^n,c[e++]=h^i,c[e++]=g^r}return s.fill(0),function(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const i=e[n-1];if(i<=0||i>16)throw new Error(`aes/pcks5: wrong padding byte: ${i}`);const r=e.subarray(0,-i);for(let t=0;tUint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Ni=Ui("expand 16-byte k"),_i=Ui("expand 32-byte k"),Li=gi(Ni),Mi=gi(_i);function Oi(e,t){return e<>>32-t}function ji(e){return e.byteOffset%4==0}Mi.slice();const Hi=2**32-1,Gi=new Uint32Array;function qi(e,t){const{allowShortKeys:n,extendNonceFn:i,counterLength:r,counterRight:s,rounds:o}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return fi(r),fi(o),pi(s),pi(n),(t,l,a,c,u=0)=>{hi(t),hi(l),hi(a);const d=a.length;if(c||(c=new Uint8Array(d)),hi(c),fi(u),u<0||u>=Hi)throw new Error("arx: counter overflow");if(c.length=Hi)throw new Error("arx: counter overflow");const g=Math.min(64,a-h);if(d&&64===g){const e=h/4;if(h%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,p[t]=f[t]^u[n];h+=64;continue}for(let e,t=0;t0;)f.pop().fill(0);return c}}function Ji(e,t,n,i,r,s=20){let o=e[0],l=e[1],a=e[2],c=e[3],u=t[0],d=t[1],f=t[2],p=t[3],h=t[4],g=t[5],m=t[6],v=t[7],y=r,w=n[0],b=n[1],A=n[2],k=o,I=l,C=a,E=c,x=u,S=d,B=f,Q=p,F=h,$=g,D=m,R=v,P=y,T=w,U=b,N=A;for(let e=0;ei?e.create().update(n).digest():n);for(let e=0;enew Vi(e,t).update(n).digest();Yi.create=(e,t)=>new Vi(e,t);const zi=new Uint8Array([0]),Wi=new Uint8Array;var Zi=Object.defineProperty,Xi=(e,t)=>{for(var n in t)Zi(e,n,{get:t[n],enumerable:!0})},er=Symbol("verified");function tr(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;tcr,QueueNode:()=>ar,binarySearch:()=>lr,bytesToHex:()=>tn,hexToBytes:()=>nn,insertEventIntoAscendingList:()=>or,insertEventIntoDescendingList:()=>sr,normalizeURL:()=>rr,utf8Decoder:()=>nr,utf8Encoder:()=>ir});var nr=new TextDecoder("utf-8"),ir=new TextEncoder;function rr(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function sr(e,t){const[n,i]=lr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return i||e.splice(n,0,t),e}function or(e,t){const[n,i]=lr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return i||e.splice(n,0,t),e}function lr(e,t){let n=0,i=e.length-1;for(;n<=i;){const r=Math.floor((n+i)/2),s=t(e[r]);if(0===s)return[r,!0];s<0?i=r-1:n=r+1}return[n,!1]}var ar=class{value;next=null;prev=null;constructor(e){this.value=e}},cr=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new ar(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}};function ur(e){return tn(bn(ir.encode(function(e){if(!tr(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}(e))))}var dr=new class{generateSecretKey(){return Yt.utils.randomPrivateKey()}getPublicKey(e){return tn(Yt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=tn(Yt.getPublicKey(t)),n.id=ur(n),n.sig=tn(Yt.sign(ur(n),t)),n[er]=!0,n}verifyEvent(e){if("boolean"==typeof e[er])return e[er];const t=ur(e);if(t!==e.id)return e[er]=!1,!1;try{const n=Yt.verify(e.sig,t,e.pubkey);return e[er]=n,n}catch(t){return e[er]=!1,!1}}},fr=dr.generateSecretKey,pr=dr.getPublicKey,hr=dr.finalizeEvent,gr=dr.verifyEvent,mr={};function vr(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function yr(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function wr(e){return 2e4<=e&&e<3e4}function br(e){return 3e4<=e&&e<4e4}function Ar(e){return vr(e)?"regular":yr(e)?"replaceable":wr(e)?"ephemeral":br(e)?"parameterized":"unknown"}function kr(e,t){const n=t instanceof Array?t:[t];return tr(e)&&n.includes(e.kind)||!1}Xi(mr,{Application:()=>Ps,BadgeAward:()=>$r,BadgeDefinition:()=>Ss,BlockedRelaysList:()=>as,BookmarkList:()=>ss,Bookmarksets:()=>Cs,Calendar:()=>Os,CalendarEventRSVP:()=>js,ChannelCreation:()=>Tr,ChannelHideMessage:()=>_r,ChannelMessage:()=>Nr,ChannelMetadata:()=>Ur,ChannelMuteUser:()=>Lr,ClassifiedListing:()=>Ns,ClientAuth:()=>ms,CommunitiesList:()=>os,CommunityDefinition:()=>qs,CommunityPostApproval:()=>Vr,Contacts:()=>xr,CreateOrUpdateProduct:()=>Fs,CreateOrUpdateStall:()=>Qs,Curationsets:()=>Es,Date:()=>Ls,DirectMessageRelaysList:()=>fs,DraftClassifiedListing:()=>_s,DraftLong:()=>Ds,Emojisets:()=>Rs,EncryptedDirectMessage:()=>Sr,EventDeletion:()=>Br,FileMetadata:()=>jr,FileServerPreference:()=>ps,Followsets:()=>As,GenericRepost:()=>Pr,Genericlists:()=>ks,GiftWrap:()=>Or,HTTPAuth:()=>bs,Handlerinformation:()=>Gs,Handlerrecommendation:()=>Hs,Highlights:()=>ts,InterestsList:()=>us,Interestsets:()=>Bs,JobFeedback:()=>Wr,JobRequest:()=>Yr,JobResult:()=>zr,Label:()=>Kr,LightningPubRPC:()=>gs,LiveChatMessage:()=>Hr,LiveEvent:()=>Ts,LongFormArticle:()=>$s,Metadata:()=>Ir,Mutelist:()=>ns,NWCWalletInfo:()=>hs,NWCWalletRequest:()=>vs,NWCWalletResponse:()=>ys,NostrConnect:()=>ws,OpenTimestamps:()=>Mr,Pinlist:()=>is,PrivateDirectMessage:()=>Rr,ProblemTracker:()=>Gr,ProfileBadges:()=>xs,PublicChatsList:()=>ls,Reaction:()=>Fr,RecommendRelay:()=>Er,RelayList:()=>rs,Relaysets:()=>Is,Report:()=>qr,Reporting:()=>Jr,Repost:()=>Qr,Seal:()=>Dr,SearchRelaysList:()=>cs,ShortTextNote:()=>Cr,Time:()=>Ms,UserEmojiList:()=>ds,UserStatuses:()=>Us,Zap:()=>es,ZapGoal:()=>Zr,ZapRequest:()=>Xr,classifyKind:()=>Ar,isAddressableKind:()=>br,isEphemeralKind:()=>wr,isKind:()=>kr,isRegularKind:()=>vr,isReplaceableKind:()=>yr});var Ir=0,Cr=1,Er=2,xr=3,Sr=4,Br=5,Qr=6,Fr=7,$r=8,Dr=13,Rr=14,Pr=16,Tr=40,Ur=41,Nr=42,_r=43,Lr=44,Mr=1040,Or=1059,jr=1063,Hr=1311,Gr=1971,qr=1984,Jr=1984,Kr=1985,Vr=4550,Yr=5999,zr=6999,Wr=7e3,Zr=9041,Xr=9734,es=9735,ts=9802,ns=1e4,is=10001,rs=10002,ss=10003,os=10004,ls=10005,as=10006,cs=10007,us=10015,ds=10030,fs=10050,ps=10096,hs=13194,gs=21e3,ms=22242,vs=23194,ys=23195,ws=24133,bs=27235,As=3e4,ks=30001,Is=30002,Cs=30003,Es=30004,xs=30008,Ss=30009,Bs=30015,Qs=30017,Fs=30018,$s=30023,Ds=30024,Rs=30030,Ps=30078,Ts=30311,Us=30315,Ns=30402,_s=30403,Ls=31922,Ms=31923,Os=31924,js=31925,Hs=31989,Gs=31990,qs=34550;function Js(e,t){let n=t.length+3,i=e.indexOf(`"${t}":`)+n,r=e.slice(i).indexOf('"')+i+1;return e.slice(r,r+64)}function Ks(e,t){let n=t.length,i=e.indexOf(`"${t}":`)+n+3,r=e.slice(i),s=Math.min(r.indexOf(","),r.indexOf("}"));return parseInt(r.slice(0,s),10)}function Vs(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let i=t+7+1+n,r=e.slice(i+1,80).indexOf('"');if(-1===r)return null;let s=i+1+r;return e.slice(i+1,s)}function Ys(e,t){return t===Js(e,"id")}function zs(e,t){return t===Js(e,"pubkey")}function Ws(e,t){return t===Ks(e,"kind")}Xi({},{getHex64:()=>Js,getInt:()=>Ks,getSubscriptionId:()=>Vs,matchEventId:()=>Ys,matchEventKind:()=>Ws,matchEventPubkey:()=>zs});function Zs(e,t){return{kind:ms,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}Xi({},{makeAuthEvent:()=>Zs});try{WebSocket}catch{}try{WebSocket}catch{}var Xs={};Xi(Xs,{BECH32_REGEX:()=>no,Bech32MaxSize:()=>to,NostrTypeGuard:()=>eo,decode:()=>ro,decodeNostrURI:()=>io,encodeBytes:()=>uo,naddrEncode:()=>ho,neventEncode:()=>po,noteEncode:()=>ao,nprofileEncode:()=>fo,npubEncode:()=>lo,nsecEncode:()=>oo});var eo={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},to=5e3,no=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function io(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),ro(e)}catch(e){return{type:"invalid",data:null}}}function ro(e){let{prefix:t,words:n}=ui.decode(e,to),i=new Uint8Array(ui.fromWords(n));switch(t){case"nprofile":{let e=so(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:tn(e[0][0]),relays:e[1]?e[1].map(e=>nr.decode(e)):[]}}}case"nevent":{let e=so(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:tn(e[0][0]),relays:e[1]?e[1].map(e=>nr.decode(e)):[],author:e[2]?.[0]?tn(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(tn(e[3][0]),16):void 0}}}case"naddr":{let e=so(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:nr.decode(e[0][0]),pubkey:tn(e[2][0]),kind:parseInt(tn(e[3][0]),16),relays:e[1]?e[1].map(e=>nr.decode(e)):[]}}}case"nsec":return{type:t,data:i};case"npub":case"note":return{type:t,data:tn(i)};default:throw new Error(`unknown prefix ${t}`)}}function so(e){let t={},n=e;for(;n.length>0;){let e=n[0],i=n[1],r=n.slice(2,2+i);if(n=n.slice(2+i),r.lengthir.encode(e))}))}function po(e){let t;return void 0!==e.kind&&(t=function(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}(e.kind)),co("nevent",go({0:[nn(e.id)],1:(e.relays||[]).map(e=>ir.encode(e)),2:e.author?[nn(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function ho(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),co("naddr",go({0:[ir.encode(e.identifier)],1:(e.relays||[]).map(e=>ir.encode(e)),2:[nn(e.pubkey)],3:[new Uint8Array(t)]}))}function go(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let i=new Uint8Array(n.length+2);i.set([parseInt(e)],0),i.set([n.length],1),i.set(n,2),t.push(i)})}),sn(...t)}var mo={};function vo(e,t,n){const i=e instanceof Uint8Array?tn(e):e,r=wo(Rt.getSharedSecret(i,"02"+t));let s=Uint8Array.from(an(16)),o=ir.encode(n),l=Ri(r,s).encrypt(o);return`${Xn.encode(new Uint8Array(l))}?iv=${Xn.encode(new Uint8Array(s.buffer))}`}function yo(e,t,n){const i=e instanceof Uint8Array?tn(e):e;let[r,s]=n.split("?iv="),o=wo(Rt.getSharedSecret(i,"02"+t)),l=Xn.decode(s),a=Xn.decode(r),c=Ri(o,l).decrypt(a);return nr.decode(c)}function wo(e){return e.slice(1,33)}Xi(mo,{decrypt:()=>yo,encrypt:()=>vo});Xi({},{NIP05_REGEX:()=>Ao,isNip05:()=>ko,isValid:()=>xo,queryProfile:()=>Eo,searchDomain:()=>Co,useFetchImplementation:()=>Io});var bo,Ao=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,ko=e=>Ao.test(e||"");try{bo=fetch}catch(e){}function Io(e){bo=e}async function Co(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,i=await bo(n,{redirect:"manual"});if(200!==i.status)throw Error("Wrong response code");return(await i.json()).names}catch(e){return{}}}async function Eo(e){const t=e.match(Ao);if(!t)return null;const[,n="_",i]=t;try{const e=`https://${i}/.well-known/nostr.json?name=${n}`,t=await bo(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const r=await t.json(),s=r.names[n];return s?{pubkey:s,relays:r.relays?.[s]}:null}catch(e){return null}}async function xo(e,t){const n=await Eo(t);return!!n&&n.pubkey===e}function So(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,i;for(let r=e.tags.length-1;r>=0;r--){const s=e.tags[r];if("e"===s[0]&&s[1]){const[e,r,o,l,a]=s,c={id:r,relays:o?[o]:[],author:a};if("root"===l){t.root=c;continue}if("reply"===l){t.reply=c;continue}if("mention"===l){t.mentions.push(c);continue}n?i=c:n=c,t.mentions.push(c);continue}if("q"===s[0]&&s[1]){const[e,n,i]=s;t.quotes.push({id:n,relays:i?[i]:[]})}"p"===s[0]&&s[1]&&t.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]})}return t.root||(t.root=i||n||t.reply),t.reply||(t.reply=n||t.root),[t.reply,t.root].forEach(e=>{if(!e)return;let n=t.mentions.indexOf(e);if(-1!==n&&t.mentions.splice(n,1),e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays?.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t.mentions.forEach(e=>{if(e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t}Xi({},{parse:()=>So});Xi({},{fetchRelayInformation:()=>Qo,useFetchImplementation:()=>Bo});try{fetch}catch{}function Bo(e){0}async function Qo(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function Fo(e){let t=0;for(let n=0;n<64;n+=8){const i=parseInt(e.substring(n,n+8),16);if(0!==i){t+=Math.clz32(i);break}t+=32}return t}function $o(e,t){let n=0;const i=e,r=["nonce",n.toString(),t.toString()];for(i.tags.push(r);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==i.created_at&&(n=0,i.created_at=e),r[1]=(++n).toString(),i.id=Do(i),Fo(i.id)>=t)break}return i}function Do(e){return tn(bn(ir.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}Xi({},{fastEventHash:()=>Do,getPow:()=>Fo,minePow:()=>$o});Xi({},{unwrapEvent:()=>rl,unwrapManyEvents:()=>sl,wrapEvent:()=>nl,wrapManyEvents:()=>il});Xi({},{createRumor:()=>Yo,createSeal:()=>zo,createWrap:()=>Wo,unwrapEvent:()=>el,unwrapManyEvents:()=>tl,wrapEvent:()=>Zo,wrapManyEvents:()=>Xo});var Ro={};Xi(Ro,{decrypt:()=>jo,encrypt:()=>Oo,getConversationKey:()=>Uo,v2:()=>Ho});var Po=1,To=65535;function Uo(e,t){const n=Rt.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return dn.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Yi(e,rn(n),rn(t))}(bn,n,"nip44-v2")}function No(e,t){const n=function(e,t,n,i=32){if(dn.hash(e),dn.number(i),i>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/e.outputLen);void 0===n&&(n=Wi);const s=new Uint8Array(r*e.outputLen),o=Yi.create(e,t),l=o._cloneInto(),a=new Uint8Array(o.outputLen);for(let t=0;tTo)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t}(n),t,new Uint8Array(_o(n)-n))}function Mo(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const i=sn(n,t);return Yi(bn,e,i)}function Oo(e,t,n=an(32)){const{chacha_key:i,chacha_nonce:r,hmac_key:s}=No(t,n),o=Lo(e),l=Ki(i,r,o),a=Mo(s,l,n);return Xn.encode(sn(new Uint8Array([2]),n,l,a))}function jo(e,t){const{nonce:n,ciphertext:i,mac:r}=function(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=Xn.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const i=n.length;if(i<99||i>65603)throw new Error("invalid data length: "+i);const r=n[0];if(2!==r)throw new Error("unknown encryption version "+r);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:s,chacha_nonce:o,hmac_key:l}=No(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let i=0;iTo||n.length!==t||e.length!==2+_o(t))throw new Error("invalid padding");return nr.decode(n)}(Ki(s,o,i))}var Ho={utils:{getConversationKey:Uo,calcPaddedLen:_o},encrypt:Oo,decrypt:jo},Go=()=>Math.round(Date.now()/1e3),qo=()=>Math.round(Go()-172800*Math.random()),Jo=(e,t)=>Uo(e,t),Ko=(e,t,n)=>Oo(JSON.stringify(e),Jo(t,n)),Vo=(e,t)=>JSON.parse(jo(e.content,Jo(t,e.pubkey)));function Yo(e,t){const n={created_at:Go(),content:"",tags:[],...e,pubkey:pr(t)};return n.id=ur(n),n}function zo(e,t,n){return hr({kind:Dr,content:Ko(e,t,n),created_at:qo(),tags:[]},t)}function Wo(e,t){const n=fr();return hr({kind:Or,content:Ko(e,n,t),created_at:qo(),tags:[["p",t]]},n)}function Zo(e,t,n){return Wo(zo(Yo(e,t),t,n),n)}function Xo(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const i=pr(t),r=[Zo(e,t,i)];return n.forEach(n=>{r.push(Zo(e,t,n))}),r}function el(e,t){const n=Vo(e,t);return Vo(n,t)}function tl(e,t){let n=[];return e.forEach(e=>{n.push(el(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function nl(e,t,n,i,r){const s=function(e,t,n,i){const r={created_at:Math.ceil(Date.now()/1e3),kind:Rr,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{r.tags.push(t?["p",e,t]:["p",e])}),i&&r.tags.push(["e",i.eventId,i.relayUrl||"","reply"]),n&&r.tags.push(["subject",n]),r}(t,n,i,r);return Zo(s,e,t.publicKey)}function il(e,t,n,i,r){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:pr(e)},...t].map(t=>nl(e,t,n,i,r))}var rl=el,sl=tl;function ol(e,t,n,i){let r;const s=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===Cr?r=Qr:(r=Pr,s.push(["k",String(t.kind)])),hr({kind:r,tags:s,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},i)}function ll(e){if(![Qr,Pr].includes(e.kind))return;let t,n;for(let i=e.tags.length-1;i>=0&&(void 0===t||void 0===n);i--){const r=e.tags[i];r.length>=2&&("e"===r[0]&&void 0===t?t=r:"p"===r[0]&&void 0===n&&(n=r))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function al(e,{skipVerification:t}={}){const n=ll(e);if(void 0===n||""===e.content)return;let i;try{i=JSON.parse(e.content)}catch(e){return}return i.id===n.id&&(t||gr(i))?i:void 0}Xi({},{finishRepostEvent:()=>ol,getRepostedEvent:()=>al,getRepostedEventPointer:()=>ll});Xi({},{NOSTR_URI_REGEX:()=>cl,parse:()=>dl,test:()=>ul});var cl=new RegExp(`nostr:(${no.source})`);function ul(e){return"string"==typeof e&&new RegExp(`^${cl.source}$`).test(e)}function dl(e){const t=e.match(new RegExp(`^${cl.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:ro(t[1])}}function fl(e,t,n){const i=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return hr({...e,kind:Fr,tags:[...e.tags??[],...i,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function pl(e){if(e.kind!==Fr)return;let t,n;for(let i=e.tags.length-1;i>=0&&(void 0===t||void 0===n);i--){const r=e.tags[i];r.length>=2&&("e"===r[0]&&void 0===t?t=r:"p"===r[0]&&void 0===n&&(n=r))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}Xi({},{finishReactionEvent:()=>fl,getReactedEventPointer:()=>pl});Xi({},{parse:()=>ml});var hl=/\W/m,gl=/\W |\W$|$|,| /m;function*ml(e){const t=e.length;let n=0,i=0;for(;ivl,channelHideMessageEvent:()=>bl,channelMessageEvent:()=>wl,channelMetadataEvent:()=>yl,channelMuteUserEvent:()=>Al});var vl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return hr({kind:Tr,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},yl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return hr({kind:Ur,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},wl=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),hr({kind:Nr,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},bl=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return hr({kind:_r,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},Al=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return hr({kind:Lr,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};Xi({},{EMOJI_SHORTCODE_REGEX:()=>kl,matchAll:()=>Cl,regex:()=>Il,replaceAll:()=>El});var kl=/:(\w+):/,Il=()=>new RegExp(`\\B${kl.source}\\B`,"g");function*Cl(e){const t=e.matchAll(Il());for(const e of t)try{const[t,n]=e;yield{shortcode:t,name:n,start:e.index,end:e.index+t.length}}catch(e){}}function El(e,t){return e.replaceAll(Il(),(e,n)=>t({shortcode:e,name:n}))}var xl;Xi({},{useFetchImplementation:()=>Sl,validateGithub:()=>Bl});try{xl=fetch}catch{}function Sl(e){xl=e}async function Bl(e,t,n){try{return await(await xl(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function Ql(e){const{host:t,pathname:n,searchParams:i}=new URL(e),r=n||t,s=i.get("relay"),o=i.get("secret");if(!r||!s||!o)throw new Error("invalid connection string");return{pubkey:r,relay:s,secret:o}}async function Fl(e,t,n){const i={method:"pay_invoice",params:{invoice:n}},r=vo(t,e,JSON.stringify(i)),s={kind:vs,created_at:Math.round(Date.now()/1e3),content:r,tags:[["p",e]]};return hr(s,t)}Xi({},{makeNwcRequestEvent:()=>Fl,parseConnectionString:()=>Ql});function $l(e){return e=(e=e.trim().toLowerCase()).normalize("NFKC"),Array.from(e).map(e=>/\p{Letter}/u.test(e)||/\p{Number}/u.test(e)?e:"-").join("")}Xi({},{normalizeIdentifier:()=>$l});var Dl;Xi({},{getSatoshisAmountFromBolt11:()=>_l,getZapEndpoint:()=>Pl,makeZapReceipt:()=>Nl,makeZapRequest:()=>Tl,useFetchImplementation:()=>Rl,validateZapRequest:()=>Ul});try{Dl=fetch}catch{}function Rl(e){Dl=e}async function Pl(e){try{let t="",{lud06:n,lud16:i}=JSON.parse(e.content);if(n){let{words:e}=ui.decode(n,1e3),i=ui.fromWords(e);t=nr.decode(i)}else{if(!i)return null;{let[e,n]=i.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let r=await Dl(t),s=await r.json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch(e){}return null}function Tl(e){let t={kind:9734,created_at:Math.round(Date.now()/1e3),content:e.comment||"",tags:[["p","pubkey"in e?e.pubkey:e.event.pubkey],["amount",e.amount.toString()],["relays",...e.relays]]};if("event"in e){if(t.tags.push(["e",e.event.id]),yr(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(br(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const i=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(i)}t.tags.push(["k",e.event.kind.toString()])}return t}function Ul(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!tr(t))return"Zap request is not a valid Nostr event.";if(!gr(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let i=t.tags.find(([e,t])=>"e"===e&&t);return i&&!i[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function Nl({zapRequest:e,preimage:t,bolt11:n,paidAt:i}){let r=JSON.parse(e),s=r.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),o={kind:9735,created_at:Math.round(i.getTime()/1e3),content:"",tags:[...s,["P",r.pubkey],["bolt11",n],["description",e]]};return t&&o.tags.push(["preimage",t]),o}function _l(e){if(e.length<50)return 0;const t=(e=e.substring(0,50)).lastIndexOf("1");if(-1===t)return 0;const n=e.substring(0,t);if(!n.startsWith("lnbc"))return 0;const i=n.substring(4);if(i.length<1)return 0;const r=i[i.length-1],s=r.charCodeAt(0)-"0".charCodeAt(0),o=s>=0&&s<=9;let l=i.length-1;if(o&&l++,l<1)return 0;const a=parseInt(i.substring(0,l));switch(r){case"m":return 1e5*a;case"u":return 100*a;case"n":return a/10;case"p":return a/1e4;default:return 1e8*a}}Xi({},{getToken:()=>Ml,hashPayload:()=>Kl,unpackEventFromToken:()=>jl,validateEvent:()=>Yl,validateEventKind:()=>Gl,validateEventMethodTag:()=>Jl,validateEventPayloadTag:()=>Vl,validateEventTimestamp:()=>Hl,validateEventUrlTag:()=>ql,validateToken:()=>Ol});var Ll="Nostr ";async function Ml(e,t,n,i=!1,r){const s={kind:bs,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};r&&s.tags.push(["payload",Kl(r)]);const o=await n(s);return(i?Ll:"")+Xn.encode(ir.encode(JSON.stringify(o)))}async function Ol(e,t,n){const i=await jl(e).catch(e=>{throw e});return await Yl(i,t,n).catch(e=>{throw e})}async function jl(e){if(!e)throw new Error("Missing token");e=e.replace(Ll,"");const t=nr.decode(Xn.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Hl(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function Gl(e){return e.kind===bs}function ql(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function Jl(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function Kl(e){return tn(bn(ir.encode(JSON.stringify(e))))}function Vl(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const i=Kl(t);return n.length>0&&n[1]===i}async function Yl(e,t,n,i){if(!gr(e))throw new Error("Invalid nostr event, signature invalid");if(!Gl(e))throw new Error("Invalid nostr event, kind invalid");if(!Hl(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!ql(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!Jl(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(i)&&"object"==typeof i&&Object.keys(i).length>0&&!Vl(e,i))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function zl(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function Wl(e){return 3e4<=e&&e<4e4}var Zl=function(e,t){return Zl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Zl(e,t)};function Xl(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Zl(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function ea(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function l(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,l)}a((i=i.apply(e,t||[])).next())})}function ta(e,t){var n,i,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=l(0),o.throw=l(1),o.return=l(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(l){return function(a){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&l[0]?i.return:l[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;switch(i=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,i=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){s=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ia(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function ra(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r1||l(e,t)})},t&&(i[e]=t(i[e])))}function l(e,t){try{(n=r[e](t)).value instanceof sa?Promise.resolve(n.value.v).then(a,c):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function a(e){l("next",e)}function c(e){l("throw",e)}function u(e,t){e(t),s.shift(),s.length&&l(s[0][0],s[0][1])}}function la(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=na(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise(function(i,r){(function(e,t,n,i){Promise.resolve(i).then(function(t){e({value:t,done:n})},t)})(i,r,(t=e[n](t)).done,t.value)})}}}function aa(e){return"function"==typeof e}function ca(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var ua=ca(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function da(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var fa=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,i,r;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var o=na(s),l=o.next();!l.done;l=o.next()){l.value.remove(this)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else s.remove(this);var a=this.initialTeardown;if(aa(a))try{a()}catch(e){r=e instanceof ua?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=na(c),d=u.next();!d.done;d=u.next()){var f=d.value;try{ga(f)}catch(e){r=null!=r?r:[],e instanceof ua?r=ra(ra([],ia(r)),ia(e.errors)):r.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}if(r)throw new ua(r)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ga(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&da(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&da(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),pa=fa.EMPTY;function ha(e){return e instanceof fa||e&&"closed"in e&&aa(e.remove)&&aa(e.add)&&aa(e.unsubscribe)}function ga(e){aa(e)?e():e.unsubscribe()}var ma={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},va={setTimeout:function(e,t){for(var n=[],i=2;i0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,i=n.hasError,r=n.isStopped,s=n.observers;return i||r?pa:(this.currentObservers=null,s.push(e),new fa(function(){t.currentObservers=null,da(s,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,i=t.thrownError,r=t.isStopped;n?e.error(i):r&&e.complete()},t.prototype.asObservable=function(){var e=new Fa;return e.source=this,e},t.create=function(e,t){return new Na(e,t)},t}(Fa),Na=function(e){function t(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return Xl(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:pa},t}(Ua),_a={now:function(){return(_a.delegate||Date).now()},delegate:void 0},La=function(e){function t(t,n,i){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===i&&(i=_a);var r=e.call(this)||this;return r._bufferSize=t,r._windowTime=n,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=n===1/0,r._bufferSize=Math.max(1,t),r._windowTime=Math.max(1,n),r}return Xl(t,e),t.prototype.next=function(t){var n=this,i=n.isStopped,r=n._buffer,s=n._infiniteTimeWindow,o=n._timestampProvider,l=n._windowTime;i||(r.push(t),!s&&r.push(o.now()+l)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,i=this._buffer.slice(),r=0;r=2,!0))}function Mc(e,t){for(var n=[],i=2;it.reduce((e,t)=>{const n=[];for(const i of e)try{const e=t(i);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);var zc=Symbol("verified");function Wc(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;tt.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return i||e.splice(n,0,t),e}function su(e,t){let n=0,i=e.length-1;for(;n<=i;){const r=Math.floor((n+i)/2),s=t(e[r]);if(0===s)return[r,!0];s<0?i=r-1:n=r+1}return[n,!1]}eu.finalizeEvent,eu.verifyEvent,new TextDecoder("utf-8"),new TextEncoder;const ou=Symbol.for("event-store"),lu=Symbol.for("event-uid"),au=Symbol.for("replaceable-address"),cu=Symbol.for("from-cache"),uu=Symbol.for("replaceable-identifier");function du(e){return zl(e)||Wl(e)}function fu(e){let t=Reflect.get(e,lu);return t||(t=Wl(e.kind)||zl(e.kind)?pu(e):e.id,Reflect.set(e,lu,t)),t}function pu(e){if(!Wl(e.kind)&&!zl(e.kind))throw new Error("Event is not replaceable or addressable");return iu(e,au,()=>hu(e.kind,e.pubkey,gu(e)))}function hu(e,t,n){return e+":"+t+":"+(n??"")}function gu(e){return iu(e,uu,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function mu(){return Math.round(Date.now()/1e3)}const vu=Symbol("expiration-timestamp");function yu(e){return iu(e,vu,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}var wu=new TextDecoder("utf-8");new TextEncoder;function bu(e){let{prefix:t,words:n}=ui.decode(e,5e3),i=new Uint8Array(ui.fromWords(n));switch(t){case"nprofile":{let e=Au(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:tn(e[0][0]),relays:e[1]?e[1].map(e=>wu.decode(e)):[]}}}case"nevent":{let e=Au(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:tn(e[0][0]),relays:e[1]?e[1].map(e=>wu.decode(e)):[],author:e[2]?.[0]?tn(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(tn(e[3][0]),16):void 0}}}case"naddr":{let e=Au(i);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:wu.decode(e[0][0]),pubkey:tn(e[2][0]),kind:parseInt(tn(e[3][0]),16),relays:e[1]?e[1].map(e=>wu.decode(e)):[]}}}case"nsec":return{type:t,data:i};case"npub":case"note":return{type:t,data:tn(i)};default:throw new Error(`unknown prefix ${t}`)}}function Au(e){let t={},n=e;for(;n.length>0;){let e=n[0],i=n[1],r=n.slice(2,2+i);if(n=n.slice(2+i),r.length=8&&Su.test(e)}function Qu(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)}const Fu="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0; +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $u(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}const Du=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Ru=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pu(e){if($u(e),Du)return e.toHex();let t="";for(let n=0;n=Tu&&e<=Uu?e-Tu:e>=Nu&&e<=_u?e-(Nu-10):e>=Lu&&e<=Mu?e-(Lu-10):void 0}function ju(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Du)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,r=0;tArray.isArray(e)).map(e=>e.map(e=>String(e)));return Reflect.set(e,nd,i),i}const ld="abcdefghijklmnopqrstuvwxyz",ad=new Set((ld+ld.toUpperCase()).split("")),cd=Symbol.for("indexable-tags");function ud(e){let t=Reflect.get(e,cd);if(!t){const n=new Set;for(const t of e.tags)t.length>=2&&1===t[0].length&&ad.has(t[0])&&n.add(t[0]+":"+t[1]);t=n,Reflect.set(e,cd,n)}return t}class dd{first=null;items=Object.create(null);last=null;max;resetTtl;size;ttl;constructor(e=0,t=0,n=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map(e=>[e,this.get(e)])}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0===--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const n=this.items[e];this.ttl>0&&n.expiry<=Date.now()?this.delete(e):(t=n.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,n=!1,i=this.resetTtl){let r;if(n||this.has(e)){if(r=this.items[e],r.value=t,!1===n&&i&&(r.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==r){const e=this.last,t=r.next,n=r.prev;this.first===r&&(this.first=r.next),r.next=null,r.prev=this.last,e.next=r,null!==n&&(n.next=t),null!==t&&(t.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),r=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1===++this.size?this.first=r:this.last.next=r;return this.last=r,this}values(e=this.keys()){return e.map(e=>this.get(e))}}function fd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pd,hd,gd={exports:{}};function md(){if(hd)return pd;hd=1;var e=1e3,t=60*e,n=60*t,i=24*n,r=7*i,s=365.25*i;function o(e,t,n,i){var r=t>=1.5*n;return Math.round(e/n)+" "+i+(r?"s":"")}return pd=function(l,a){a=a||{};var c=typeof l;if("string"===c&&l.length>0)return function(o){if((o=String(o)).length>100)return;var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(!l)return;var a=parseFloat(l[1]);switch((l[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"weeks":case"week":case"w":return a*r;case"days":case"day":case"d":return a*i;case"hours":case"hour":case"hrs":case"hr":case"h":return a*n;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(l);if("number"===c&&isFinite(l))return a.long?function(r){var s=Math.abs(r);if(s>=i)return o(r,s,i,"day");if(s>=n)return o(r,s,n,"hour");if(s>=t)return o(r,s,t,"minute");if(s>=e)return o(r,s,e,"second");return r+" ms"}(l):function(r){var s=Math.abs(r);if(s>=i)return Math.round(r/i)+"d";if(s>=n)return Math.round(r/n)+"h";if(s>=t)return Math.round(r/t)+"m";if(s>=e)return Math.round(r/e)+"s";return r+"ms"}(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))}}var vd=function(e){function t(e){let i,r,s,o=null;function l(...e){if(!l.enabled)return;const n=l,r=Number(new Date),s=r-(i||r);n.diff=s,n.prev=i,n.curr=r,i=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(i,r)=>{if("%%"===i)return"%";o++;const s=t.formatters[r];if("function"==typeof s){const t=e[o];i=s.call(n,t),e.splice(o,1),o--}return i}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return l.namespace=e,l.useColors=t.useColors(),l.color=t.selectColor(e),l.extend=n,l.destroy=t.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(r!==t.namespaces&&(r=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(l),l}function n(e,n){const i=t(this.namespace+(void 0===n?":":n)+e);return i.log=this.log,i}function i(e,t){let n=0,i=0,r=-1,s=0;for(;n"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(i(e,n))return!1;for(const n of t.names)if(i(e,n))return!0;return!1},t.humanize=md(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"%%"!==e&&(i++,"%c"===e&&(r=i))}),t.splice(r,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=vd(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(gd,gd.exports);const yd=fd(gd.exports)("applesauce");class wd{log=yd.extend("EventMemory");kinds=new Map;authors=new Map;tags=new dd;created_at=[];kindAuthor=new Map;events=new dd;replaceable=new Map;get size(){return this.events.size}hasEvent(e){return this.events.has(e)}getEvent(e){return this.events.get(e)}hasReplaceable(e,t,n){const i=this.replaceable.get(hu(e,t,n));return!!i&&i.length>0}getReplaceable(e,t,n){const i=hu(e,t,n),r=this.replaceable.get(i);return r?.[0]}getReplaceableHistory(e,t,n){const i=hu(e,t,n);return this.replaceable.get(i)}getByFilters(e){return Array.from(this.getEventsForFilters(Array.isArray(e)?e:[e]))}getTimeline(e){const t=[],n=this.getByFilters(e);for(const e of n)ru(t,e);return t}add(e){const t=e.id,n=this.events.get(t);if(n)return n;this.events.set(t,e),this.getKindIndex(e.kind).add(e),this.getAuthorsIndex(e.pubkey).add(e),this.getKindAuthorIndex(e.kind,e.pubkey).add(e);for(const t of ud(e))this.tags.has(t)&&this.getTagIndex(t).add(e);if(ru(this.created_at,e),du(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=hu(e.kind,e.pubkey,t);let i=this.replaceable.get(n);this.replaceable.has(n)||(i=[],this.replaceable.set(n,i)),ru(i,e)}return e}remove(e){let t="string"==typeof e?this.events.get(e):e;if(!t)return!1;const n=t.id;if(!this.events.has(n))return!1;this.getAuthorsIndex(t.pubkey).delete(t),this.getKindIndex(t.kind).delete(t);const i=`${t.kind}:${t.pubkey}`;this.kindAuthor.has(i)&&this.kindAuthor.get(i).delete(t);for(const e of ud(t))this.tags.has(e)&&this.getTagIndex(e).delete(t);if(this.removeFromSortedArray(this.created_at,t),this.events.delete(n),du(t.kind)){const e=t.tags.find(e=>"d"===e[0])?.[1],n=hu(t.kind,t.pubkey,e),i=this.replaceable.get(n);i&&this.removeFromSortedArray(i,t)}return this.claims.delete(t),!0}removeByFilters(e){const t=this.getByFilters(e);let n=0;for(const e of t)this.remove(e)&&n++;return n}update(e){}claims=new WeakMap;touch(e){this.events.has(e.id)&&this.events.set(e.id,e)}claim(e){const t=this.claims.get(e)||0;this.claims.set(e,t+1),this.touch(e)}isClaimed(e){const t=this.claims.get(e);return void 0!==t&&t>0}removeClaim(e){const t=this.claims.get(e);if(void 0!==t&&t>0){const n=t-1;0===n?this.claims.delete(e):this.claims.set(e,n)}}clearClaim(e){this.claims.delete(e)}*unclaimed(){let e=this.events.first;for(;e;){const t=e.value;this.isClaimed(t)||(yield t),e=e.next}return 0}prune(e){let t=0;const n=this.unclaimed();for(const i of n)if(this.remove(i),t++,e&&t>=e)break;return t}getKindIndex(e){return this.kinds.has(e)||this.kinds.set(e,new Set),this.kinds.get(e)}getAuthorsIndex(e){return this.authors.has(e)||this.authors.set(e,new Set),this.authors.get(e)}getKindAuthorIndex(e,t){const n=`${e}:${t}`;return this.kindAuthor.has(n)||this.kindAuthor.set(n,new Set),this.kindAuthor.get(n)}getTagIndex(e){if(!this.tags.has(e)){const t=new Set,n=Date.now();for(const n of this.events.values())ud(n).has(e)&&t.add(n);const i=Date.now()-n;i>100&&this.log(`Built index ${e} took ${i}ms`),this.tags.set(e,t)}return this.tags.get(e)}removeFromSortedArray(e,t){if(0===e.length)return;const n=su(e,e=>e.created_at-t.created_at);if(n){let i=n[0],r=!1;if(e[i]===t)return void e.splice(i,1);for(let n=i-1;n>=0&&e[n].created_at===t.created_at;n--)if(e[n]===t){e.splice(n,1),r=!0;break}if(r)return;for(let n=i+1;ne.created_at-t):void 0;r&&(n=r[0]);const s=e?su(this.created_at,t=>t.created_at-e):void 0;s&&(i=s[0]);for(let r=n;r<=i;r++){const n=this.created_at[r];if(!(void 0!==t&&n.created_at>t)){if(void 0!==e&&n.created_at{const i=e instanceof Set?e:new Set(e);if(t)n=i,t=!1;else for(const e of n)i.has(e)||n.delete(e);return n};e.ids&&i(this.iterateIds(e.ids));let r=null;void 0!==e.since&&(r=Array.from(this.iterateTime(e.since,e.until)),i(r));for(const t of ad){const n=e[`&${t}`];if(n?.length)for(const e of n)i(this.iterateTag(t,[e]))}for(const t of ad){const n=e[`#${t}`];if(n?.length){const r=e[`&${t}`],s=r?n.filter(e=>!r.includes(e)):n;s.length>0&&i(this.iterateTag(t,s))}}if(e.authors&&e.kinds&&e.authors.length*e.kinds.length<=20){const t=new Set;for(const n of e.kinds)for(const i of e.authors){const e=`${n}:${i}`,r=this.kindAuthor.get(e);if(r)for(const e of r)t.add(e)}i(t)}else e.authors&&i(this.iterateAuthors(e.authors)),e.kinds&&i(this.iterateKinds(e.kinds));if(void 0===e.since&&void 0!==e.until&&(r=Array.from(this.iterateTime(e.since,e.until)),i(r)),t)return new Set(this.events.values());if(e.limit&&r){const t=new Set;for(const i of r){if(t.size>=e.limit)break;n.has(i)&&t.add(i)}return t}return n}getEventsForFilters(e){if(0===e.length)return new Set;let t=new Set;for(const n of e){const e=this.getEventsForFilter(n);for(const n of e)t.add(n)}return t}reset(){this.events.clear(),this.kinds.clear(),this.authors.clear(),this.kindAuthor.clear(),this.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}}function bd(e,t){var n,i;if(0===t.length)return e;for(n=0,i=t.length;ne.until)return!1;for(let n in e)if("&"===n[0]){let i=n.slice(1),r=e[n];if(r&&r.length>0){const e=ud(t);for(const t of r)if(!e.has(i+":"+t))return!1}}for(let n in e)if("#"===n[0]){let i=n.slice(1),r=e[n];if(r){const n=e[`&${i}`],s=n?r.filter(e=>!n.includes(e)):r;if(0===s.length)continue;const o=ud(t);if(!1===s.some(e=>o.has(i+":"+e)))return!1}}return!0}function Ed(e,t){for(let n=0;nt.replaceable({kind:10063,pubkey:e.pubkey,relays:e.relays}).pipe(gc(e=>e?function(e){const t=Array.isArray(e)?e:e.tags;return Yc(t,e=>Hc(e,"server")&&URL.canParse(e[1])?new URL("/",e[1]):void 0)}(e):[]))}const Sd=Symbol.for("profile-content");function Bd(e){return iu(e,Sd,()=>{const t=function(e){try{return JSON.parse(e)}catch(e){return}}(e.content);if(t)return t.nip05&&"string"!=typeof t.nip05&&(t.nip05=String(t.nip05)),t.website&&t.website?.length>0&&!1===t.website?.startsWith("http")&&(t.website="https://"+t.website),t})}function Qd(e){return!!e&&((e.kind===mr.Metadata||e.kind===mr.Handlerinformation)&&!!Bd(e))}!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function n(...e){const t=(e,t)=>n=>e(t(n)),n=Array.from(e).reverse().reduce((e,n)=>e?t(e,n.encode):n.encode,void 0),i=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:i}}function i(e){return{encode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("alphabet.encode input should be an array of numbers");return n.map(n=>{if(t(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n})}}}function r(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,n="="){if(t(e),"string"!=typeof n)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(n);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let i=t.length;if(i*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;i>0&&t[i-1]===n;i--)if(!((i-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,i)}}}function o(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function l(e,n,i){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(i<2)throw new Error(`convertRadix: wrong to=${i}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const s=[],o=Array.from(e);for(o.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let s=r;st?a(t,e%t):e,c=(e,t)=>e+(t-a(e,t));function u(e,n,i,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(i<=0||i>32)throw new Error(`convertRadix2: wrong to=${i}`);if(c(n,i)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${i} carryBits=${c(n,i)}`);let s=0,o=0;const l=2**i-1,a=[];for(const r of e){if(t(r),r>=2**n)throw new Error(`convertRadix2: invalid data word=${r} from=${n}`);if(s=s<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${n}`);for(o+=n;o>=i;o-=i)a.push((s>>o-i&l)>>>0);s&=2**o-1}if(s=s<=n)throw new Error("Excess padding");if(!r&&s)throw new Error(`Non-zero padding: ${s}`);return r&&o>0&&a.push(s>>>0),a}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return l(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(l(t,e,256))}}}function f(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(c(8,e)>32||c(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(t,e,8,n))}}}function p(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function h(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const i=n(t).slice(0,e),r=new Uint8Array(t.length+e);return r.set(t),r.set(i,t.length),r},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const i=t.slice(0,-e),r=n(i).slice(0,e),s=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),r("")),e.base64url=n(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),r(""));const g=e=>n(d(58),i(e),r(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const m=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let i=0;in(h(4,e=>t(t(e))),e.base58);const v=n(i("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),r("")),y=[996825010,642813549,513874426,1027748829,705979059];function w(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=y[e]);return n}function A(e,t,n=1){const i=e.length;let r=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);r=w(r)^n>>5}r=w(r);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=i).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,r),o=e.slice(r+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const l=v.decode(o).slice(0,-6),a=A(s,l,t);if(!o.endsWith(a))throw new Error(`Invalid checksum in ${e}: expected "${a}"`);return{prefix:s,words:l}}return{encode:function(e,n,i=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const r=e.length+7+n.length;if(!1!==i&&r>i)throw new TypeError(`Length ${r} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${v.encode(n)}${A(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:i(n)}},decodeUnsafe:p(o),fromWords:i,fromWordsUnsafe:s,toWords:r}}e.bech32=b("bech32"),e.bech32m=b("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),i("0123456789abcdef"),r(""),o(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));const k={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},I=`Invalid encoding type. Available types: ${Object.keys(k).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!k.hasOwnProperty(e))throw new TypeError(I);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return k[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!k.hasOwnProperty(e))throw new TypeError(I);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return k[e].decode(t)},e.bytes=e.stringToBytes}({}),BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const Sd={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(Sd);eKc(e.tags,e=>jc(e)?e:void 0,ju))}(e),function(e){if(function(e){return nd(e)&&Reflect.has(e,Qd)}(e))return e[Qd];const t=id(e);if(!t)return;const n=Kc(t,e=>jc(e)?e:void 0,ju);return Reflect.set(e,Qd,n),n}(e))}gd.extend("EncryptedContentCache"),gd.extend("event-cache"),new TextDecoder;const Dd=Symbol.for("mailboxes-inboxes"),$d=Symbol.for("mailboxes-outboxes");function Pd(e){return eu(e,Dd,()=>{const t=[];for(const n of e.tags)if(Hc(n))try{const[,e,i]=n;!e||!Eu(e)||t.includes(e)||"read"!==i&&void 0!==i||t.push(bu(e))}catch{}return t})}function Rd(e){return eu(e,$d,()=>{const t=[];for(const n of e.tags)if(Hc(n))try{const[e,i,r]=n;"r"!==e||!Eu(i)||t.includes(i)||"write"!==r&&void 0!==r||t.push(bu(i))}catch{}return t})}const Td=Symbol.for("mute-public"),Ud=Symbol.for("mute-hidden");function _d(e){return{pubkeys:new Set(e.filter(jc).map(e=>e[1])),threads:new Set(e.filter(Mc).map(e=>e[1])),hashtags:new Set(e.filter(Jc).map(e=>e[1].toLocaleLowerCase())),words:new Set(e.filter(e=>"word"===e[0]&&e[1]).map(e=>e[1].toLocaleLowerCase()))}}function Nd(e){const t=function(e){if(function(e){return nd(e)&&Reflect.has(e,Ud)}(e))return e[Ud];const t=id(e);if(!t)return;const n=_d(t);return Reflect.set(e,Ud,n),n}(e),n=function(e){return eu(e,Td,()=>_d(e.tags))}(e);return t?function(...e){const t={pubkeys:new Set,threads:new Set,hashtags:new Set,words:new Set};for(const n of e){for(const e of n.pubkeys)t.pubkeys.add(e);for(const e of n.threads)t.threads.add(e);for(const e of n.hashtags)t.hashtags.add(e);for(const e of n.words)t.words.add(e)}return t}(t,n):n}var Ld;!function(e){e.nudity="nudity",e.malware="malware",e.profanity="profanity",e.illegal="illegal",e.spam="spam",e.impersonation="impersonation",e.other="other"}(Ld||(Ld={}));const Od=Symbol.for("nip10-thread-refs");function Md(e){if(!e[1])throw new Error("Missing event id in tag");let t={id:e[1]};return e[2]&&Eu(e[2])&&(t.relays=[e[2]]),"e"!==e[0]||"root"!==e[3]&&"reply"!==e[3]&&"mention"!==e[3]||!e[4]||64!==e[4].length||(t.author=e[4]),t}function jd(e){return t=>{const n=new Set;return t.pipe(Lc(t=>{if(void 0!==t)if(Array.isArray(t))for(const i of t)n.has(i)||(n.add(i),e.claim(i));else n.has(t)||(n.add(t),e.claim(t))}),Pc(()=>{for(const t of n)e.removeClaim(t)}))}}function Hd(e){return t=>{let n;return t.pipe(Lc(t=>{n!==t&&(n&&e.removeClaim(n),t&&e.claim(t),n=t)}),Pc(()=>{n&&e.removeClaim(n)}))}}function Gd(){return e=>e.pipe(Bc(e=>null!=e))}function Jd(e){return t=>new Sa(n=>{let i=!1;const r=t.subscribe({next:e=>{i=!0,n.next(e)},error:e=>n.error(e),complete:()=>n.complete()});return i||n.next(e),r})}function Kd(e){return"string"==typeof e&&(e={id:e}),t=>Sc(Ec(()=>function(e,t){const n=e.getEvent(t.id);return n instanceof Promise?uc(n):dc(n)}(t,e)).pipe(function(e,t){return Nc(n=>n?dc(n):e.eventLoader?uc(e.eventLoader(t)):Ha)}(t,e),Gd()),t.insert$.pipe(Bc(t=>t.id===e.id)),t.remove$.pipe(Bc(t=>t.id===e.id),Qc(1),Qa(function(e,t){e.subscribe(Fa(t,ma))}),$c(void 0))).pipe(Hd(t),Fc((e,t)=>e?.id===t?.id),Jd(void 0))}function Vd(e){return t=>{let n;return Sc(Ec(()=>function(e,t){const n=e.getReplaceable(t.kind,t.pubkey,t.identifier);return n instanceof Promise?uc(n):dc(n)}(t,e)).pipe(function(e,t){return Nc(n=>n?dc(n):void 0!==t.identifier?e.addressableLoader?uc(e.addressableLoader(t)).pipe(Bc(e=>!!e)):Ha:e.replaceableLoader?uc(e.replaceableLoader(t)).pipe(Bc(e=>!!e)):Ha)}(t,e),Gd()),t.insert$.pipe(Bc(t=>t.pubkey==e.pubkey&&t.kind===e.kind&&(void 0===e.identifier||fu(t)===e.identifier)))).pipe(Fc((e,t)=>e.created_at>=t.created_at),Lc(e=>n=e),(i=t.remove$.pipe(Bc(e=>e.id===n?.id)),Qa(function(e,t){ic(i).subscribe(Fa(t,function(){return t.complete()},ma)),!t.closed&&e.subscribe(t)})),$c(void 0),function(e){var t,n,i=1/0;return null!=e&&("object"==typeof e?(t=e.count,i=void 0===t?1/0:t,n=e.delay):i=e),i<=0?function(){return Ha}:Qa(function(e,t){var r,s=0,o=function(){if(null==r||r.unsubscribe(),r=null,null!=n){var e="number"==typeof n?xc(n):ic(n(s)),i=Fa(t,function(){i.unsubscribe(),l()});e.subscribe(i)}else l()},l=function(){var n=!1;r=e.subscribe(Fa(t,void 0,function(){++s{const i=new Map;return Ec(()=>{const t=n.getTimeline(e);return t instanceof Promise?uc(t):dc(t)}).pipe(jd(n),Tc(n.insert$.pipe(Bc(t=>kd(e,t)),jd(n))),Tc(n.remove$.pipe(Bc(t=>kd(e,t)),fc(e=>e.id))),Uc((e,n)=>{if("string"==typeof n)return e.filter(e=>e.id!==n);if(Array.isArray(n)){if(!t)for(const e of n)au(e.kind)&&i.set(cu(e),e);return n}let r=[...e];if(!t&&au(n.kind)){const t=cu(n),s=i.get(t);if(s&&n.created_ati.clear()))}}function Yd(e){return t=>Ac(Object.fromEntries(e.map(e=>[e,t.model(Kd,{id:e})])))}function Wd(e){return t=>Ac(Object.fromEntries(e.map(e=>[du(e.kind,e.pubkey,e.identifier),t.model(Vd,e)])))}function zd(e){return t=>{let n;return Sc(t.pipe(Lc(e=>n=e)),e.update$.pipe(Bc(e=>e.id===n?.id)))}}function Zd(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:pr.Contacts,pubkey:e.pubkey,relays:e.relays}).pipe(zd(t),fc(e=>e?Fd(e):[]))}function Xd(e){return t=>{const n=[{kinds:[1111],"#e":[e.id]}];return ql(e.kind)&&n.push({kinds:[1111],"#a":[uu(e)]}),t.timeline(n)}}function ef(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:pr.RelayList,pubkey:e.pubkey,relays:e.relays}).pipe(fc(e=>e&&{inboxes:Pd(e),outboxes:Rd(e)}))}function tf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:pr.Mutelist,pubkey:e.pubkey,relays:e.relays}).pipe(zd(t),fc(e=>e&&Nd(e)))}function nf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:pr.Metadata,pubkey:e.pubkey,relays:e.relays}).pipe(Bc(xd),fc(e=>e&&Ed(e)),Jd(void 0))}function rf(e){return t=>t.timeline(au(e.kind)?[{kinds:[pr.Reaction],"#e":[e.id]},{kinds:[pr.Reaction],"#a":[cu(e)]}]:[{kinds:[pr.Reaction],"#e":[e.id]}])}const sf={kinds:[pr.ShortTextNote]};function of(e,t){const n=new Map,i=new Map,{kinds:r}={...sf,...t};let s="";const o={},l={kinds:r};var a;return"string"!=typeof(a=e)&&Reflect.has(a,"identifier")&&Reflect.has(a,"pubkey")&&Reflect.has(a,"kind")?(s=Hu(e),o.kinds=[e.kind],o.authors=[e.pubkey],o["#d"]=[e.identifier],l["#a"]=[s]):"string"==typeof e?(s=e,o.ids=[e],l["#e"]=[e]):(s=e.id,o.ids=[e.id],l["#e"]=[e.id]),e=>e.filters([o,l]).pipe(fc(e=>{if(!i.has(cu(e))){const t=function(e){return eu(e,Od,()=>{const t=function(e){const t=e.filter(e=>"e"===e[0]&&e[1]),n=e.filter(e=>"a"===e[0]&&e[1]);let i=t.find(e=>"root"===e[3]),r=t.find(e=>"reply"===e[3]),s=n.find(e=>"root"===e[3]),o=n.find(e=>"reply"===e[3]);if(i&&r||(i=r=i||r),s&&o||(s=o=s||o),!i&&!r){const e=t.filter(e=>!e[3]);e.length>=1&&(i=e[0],r=e[e.length-1]??i)}return{root:i||s?{e:i,a:s}:void 0,reply:r||o?{e:r,a:o}:void 0}}(e.tags);let n,i;if(t.root)try{n={e:t.root.e&&Md(t.root.e),a:t.root.a&&Mu(t.root.a)}}catch(e){}if(t.reply)try{i={e:t.reply.e&&Md(t.reply.e),a:t.reply.a&&Mu(t.reply.a)}}catch(e){}return{root:n,reply:i}})}(e),r=n.get(cu(e))||new Set,s={event:e,refs:t,replies:r};for(const e of r)e.parent=s;if(t.reply?.e||t.reply?.a){let e=t.reply.e?t.reply.e.id:Hu(t.reply.a);if(s.parent=i.get(e),s.parent)s.parent.replies.add(s);else{let t=n.get(e);t||(t=new Set,n.set(e,t)),t.add(s)}}i.set(cu(e),s)}return{root:i.get(s),all:i}}))}function lf(e){return class extends e{models=new Map;modelKeepWarm=6e4;model(e,...t){let n=this.models.get(e);n||(n=new Map,this.models.set(e,n));const i=e.getKey?e.getKey(...t):Ad(t);let r=n.get(i);if(!r){const s=()=>{n.get(i)===r&&n.delete(i)};r=e(...t)(this).pipe(Pc(s),function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new Pa}:t,i=e.resetOnError,r=void 0===i||i,s=e.resetOnComplete,o=void 0===s||s,l=e.resetOnRefCountZero,a=void 0===l||l;return function(e){var t,i,s,l=0,c=!1,u=!1,d=function(){null==i||i.unsubscribe(),i=void 0},f=function(){d(),t=s=void 0,c=u=!1},p=function(){var e=t;f(),null==e||e.unsubscribe()};return Qa(function(e,h){l++,u||c||d();var g=s=null!=s?s:n();h.add(function(){0!==--l||u||c||(i=_c(p,a))}),g.subscribe(h),!t&&l>0&&(t=new ka({next:function(e){return g.next(e)},error:function(e){u=!0,d(),i=_c(f,r,e),g.error(e)},complete:function(){c=!0,d(),i=_c(f,o),g.complete()}}),ic(e).subscribe(t))})(e)}}({connector:()=>new Ua(1),resetOnComplete:()=>xc(this.modelKeepWarm),resetOnRefCountZero:()=>xc(this.modelKeepWarm)})),n.set(i,r)}return r}filters(e,t=!1){e=Array.isArray(e)?e:[e];const n=this.getByFilters(e);return Sc(t?Ha:n&&"function"==typeof n.then?uc(n).pipe(kc(e=>uc(Array.from(e)))):uc(Array.from(n)),this.insert$.pipe(Bc(t=>kd(e,t))))}event(e){return"string"==typeof e&&(e={id:e}),this.model(Kd,e)}replaceable(...e){let t;if(1===e.length)t=e[0];else if(3===e.length||2===e.length){let[n,i,r]=e;t={kind:n,pubkey:i,identifier:r}}if(!t)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(Vd,t)}addressable(e){return this.model(Vd,e)}timeline(e,t=!1){return this.model(qd,e,t)}profile(e){return this.model(nf,e)}contacts(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Zd,e)}mutes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(tf,e)}mailboxes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(ef,e)}blossomServers(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Id,e)}reactions(e){return this.model(rf,e)}thread(e){return this.model(of,e)}comments(e){return this.model(Xd,e)}events(e){return this.model(Yd,e)}replaceableSet(e){return this.model(Wd,e)}}}class af extends(lf(class{})){database;memory;keepOldVersions=!1;keepExpired=!1;verifyEvent;insert$=new Pa;update$=new Pa;remove$=new Pa;eventLoader;replaceableLoader;addressableLoader;constructor(e=new md){super(),e?(this.database=e,this.memory=new md):this.database=this.memory=new md,this.insert$.subscribe(e=>{Reflect.set(e,iu,this)}),this.remove$.subscribe(e=>{Reflect.deleteProperty(e,iu)})}mapToMemory(e){if(void 0!==e)return this.memory?this.memory.add(e):e}deletedIds=new Set;deletedCoords=new Map;checkDeleted(e){if("string"==typeof e)return this.deletedIds.has(e);if(this.deletedIds.has(e.id))return!0;if(ql(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=this.deletedCoords.get(du(e.kind,e.pubkey,t));if(n)return n>e.created_at}return!1}expirations=new Map;addExpiration(e){const t=gu(e);t&&Number.isFinite(t)&&this.expirations.set(e.id,t)}expirationTimeout=null;nextExpirationCheck=null;handleExpiringEvent(e){const t=gu(e);if(!t)return;if(this.expirations.set(e.id,t),this.expirationTimeout&&this.nextExpirationCheck&&this.nextExpirationChecke[1])}(e);for(const e of t)this.deletedIds.add(e),this.remove(e);const n=function(e){return e.tags.filter(Gc).map(e=>e[1])}(e);for(const t of n){this.deletedCoords.set(t,Math.max(this.deletedCoords.get(t)??0,e.created_at));const n=Ou(t);if(!n)continue;const i=this.database.getReplaceableHistory(n.kind,n.pubkey,n.identifier)??[];for(const t of i)t.created_at"d"===e[0])?.[1]:void 0;if(!this.keepOldVersions&&au(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(t&&t.length>0&&t[0].created_at>=e.created_at)return af.mergeDuplicateEvent(e,t[0]),t[0]}if(this.verifyEvent&&!1===this.verifyEvent(e))return null;const r=this.memory?.add(e);if(r&&r!==e)return af.mergeDuplicateEvent(e,r),t&&Iu(r,t),r;const s=this.mapToMemory(this.database.add(e));if(e!==s&&af.mergeDuplicateEvent(e,s),t&&Iu(s,t),s===e&&this.insert$.next(s),!this.keepOldVersions&&au(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(t&&t.length>0){const n=Array.from(t).filter(t=>t.created_atthis.mapToMemory(e)??e)}getByFilters(e){const t=this.database.getByFilters(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}getTimeline(e){const t=this.database.getTimeline(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}touch(e){return this.memory?.touch(e)}claim(e){return this.memory?.claim(e)}isClaimed(e){return this.memory?.isClaimed(e)??!1}removeClaim(e){return this.memory?.removeClaim(e)}clearClaim(e){return this.memory?.clearClaim(e)}unclaimed(){return this.memory?.unclaimed()||function*(){}()}prune(e){return this.memory?.prune(e)??0}removed(e){return this.checkDeleted(e)?Ha:this.remove$.pipe(Bc(t=>t.id===e),Qc(1),kc(()=>Ha))}updated(e){return this.update$.pipe(Bc(t=>t.id===e||t===e))}}function cf(){let e,t;const n=new Promise((n,i)=>{e=n,t=i});return n.resolve=e,n.reject=t,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var uf,df;Yu(pr.NostrConnect,"nip44"),function(e){e.GetPublicKey="get_pubic_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(uf||(uf={})),function(e){e.Connect="connect",e.CreateAccount="create_account",e.GetPublicKey="get_public_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(df||(df={}));class ff{key;constructor(e){this.key=e||cr()}async getPublicKey(){return ur(this.key)}async signEvent(e){return dr(e,this.key)}nip04={encrypt:async(e,t)=>po.encrypt(this.key,e,t),decrypt:async(e,t)=>po.decrypt(this.key,e,t)};nip44={encrypt:async(e,t)=>Fo.v2.encrypt(t,Fo.v2.utils.getConversationKey(this.key,e)),decrypt:async(e,t)=>Fo.v2.decrypt(t,Fo.v2.utils.getConversationKey(this.key,e))};static fromKey(e){return new ff(function(e){if(e instanceof Uint8Array)return e;if(xu(e))return Lu(e);{const t=Ws.decode(e);if("nsec"!==t.type)throw new Error(`Cant get secret key from ${t.type}`);return t.data}}(e))}} -/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const pf=BigInt(0),hf=BigInt(1),gf=BigInt(2),mf=BigInt(3),vf=BigInt(8),yf=Object.freeze({a:pf,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:hf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),wf=(e,t)=>(e+t/gf)/t,Af={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=yf,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-hf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),l=wf(s*e,t),a=wf(-i*e,t);let c=Jf(e-l*n-a*r,t),u=Jf(-l*i-a*s,t);const d=c>o,f=u>o;if(d&&(c=t-c),f&&(u=t-u),c>o||u>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}},bf=32;function kf(e){const{a:t,b:n}=yf,i=Jf(e*e),r=Jf(i*e);return Jf(r+t*e+n)}const If=yf.a===pf;function Cf(e){if(!(e instanceof Ef))throw new TypeError("JacobianPoint expected")}class Ef{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof Bf))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Bf.ZERO)?Ef.ZERO:new Ef(e.x,e.y,hf)}static toAffineBatch(e){const t=function(e,t=yf.P){const n=new Array(e.length),i=e.reduce((e,i,r)=>i===pf?e:(n[r]=e,Jf(e*i,t)),hf),r=Vf(i,t);return e.reduceRight((e,i,r)=>i===pf?e:(n[r]=Jf(e*n[r],t),Jf(e*i,t)),r),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return Ef.toAffineBatch(e).map(Ef.fromAffine)}equals(e){Cf(e);const{x:t,y:n,z:i}=this,{x:r,y:s,z:o}=e,l=Jf(i*i),a=Jf(o*o),c=Jf(t*a),u=Jf(r*l),d=Jf(Jf(n*o)*a),f=Jf(Jf(s*i)*l);return c===u&&d===f}negate(){return new Ef(this.x,Jf(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,i=Jf(e*e),r=Jf(t*t),s=Jf(r*r),o=e+r,l=Jf(gf*(Jf(o*o)-i-s)),a=Jf(mf*i),c=Jf(a*a),u=Jf(c-gf*l),d=Jf(a*(l-u)-vf*s),f=Jf(gf*t*n);return new Ef(u,d,f)}add(e){Cf(e);const{x:t,y:n,z:i}=this,{x:r,y:s,z:o}=e;if(r===pf||s===pf)return this;if(t===pf||n===pf)return e;const l=Jf(i*i),a=Jf(o*o),c=Jf(t*a),u=Jf(r*l),d=Jf(Jf(n*o)*a),f=Jf(Jf(s*i)*l),p=Jf(u-c),h=Jf(f-d);if(p===pf)return h===pf?this.double():Ef.ZERO;const g=Jf(p*p),m=Jf(p*g),v=Jf(c*g),y=Jf(h*h-m-gf*v),w=Jf(h*(v-y)-d*m),A=Jf(i*o*p);return new Ef(y,w,A)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Ef.ZERO;if("bigint"==typeof e&&e===pf)return t;let n=Gf(e);if(n===hf)return this;if(!If){let e=t,i=this;for(;n>pf;)n&hf&&(e=e.add(i)),i=i.double(),n>>=hf;return e}let{k1neg:i,k1:r,k2neg:s,k2:o}=Af.splitScalar(n),l=t,a=t,c=this;for(;r>pf||o>pf;)r&hf&&(l=l.add(c)),o&hf&&(a=a.add(c)),c=c.double(),r>>=hf,o>>=hf;return i&&(l=l.negate()),s&&(a=a.negate()),a=new Ef(Jf(a.x*Af.beta),a.y,a.z),l.add(a)}precomputeWindow(e){const t=If?128/e+1:256/e+1,n=[];let i=this,r=i;for(let s=0;s>=u,o>l&&(o-=c,e+=hf);const d=n,f=n+Math.abs(o)-1,p=t%2!=0,h=o<0;0===o?s=s.add(xf(p,i[d])):r=r.add(xf(h,i[f]))}return{p:r,f:s}}multiply(e,t){let n,i,r=Gf(e);if(If){const{k1neg:e,k1:s,k2neg:o,k2:l}=Af.splitScalar(r);let{p:a,f:c}=this.wNAF(s,t),{p:u,f:d}=this.wNAF(l,t);a=xf(e,a),u=xf(o,u),u=new Ef(Jf(u.x*Af.beta),u.y,u.z),n=a.add(u),i=c.add(d)}else{const{p:e,f:s}=this.wNAF(r,t);n=e,i=s}return Ef.normalizeZ([n,i])[0]}toAffine(e){const{x:t,y:n,z:i}=this,r=this.equals(Ef.ZERO);null==e&&(e=r?vf:Vf(i));const s=e,o=Jf(s*s),l=Jf(o*s),a=Jf(t*o),c=Jf(n*l),u=Jf(i*s);if(r)return Bf.ZERO;if(u!==hf)throw new Error("invZ was invalid");return new Bf(a,c)}}function xf(e,t){const n=t.negate();return e?n:t}Ef.BASE=new Ef(yf.Gx,yf.Gy,hf),Ef.ZERO=new Ef(pf,hf,pf);const Sf=new WeakMap;class Bf{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,Sf.delete(this)}hasEvenY(){return this.y%gf===pf}static fromCompressedHex(e){const t=32===e.length,n=jf(t?e:e.subarray(1));if(!Yf(n))throw new Error("Point is not on curve");let i=function(e){const{P:t}=yf,n=BigInt(6),i=BigInt(11),r=BigInt(22),s=BigInt(23),o=BigInt(44),l=BigInt(88),a=e*e*e%t,c=a*a*e%t,u=Kf(c,mf)*c%t,d=Kf(u,mf)*c%t,f=Kf(d,gf)*a%t,p=Kf(f,i)*f%t,h=Kf(p,r)*p%t,g=Kf(h,o)*h%t,m=Kf(g,l)*g%t,v=Kf(m,o)*h%t,y=Kf(v,mf)*c%t,w=Kf(y,s)*p%t,A=Kf(w,n)*a%t,b=Kf(A,gf);if(b*b%t!==e)throw new Error("Cannot find square root");return b}(kf(n));const r=(i&hf)===hf;if(t)r&&(i=Jf(-i));else{!(1&~e[0])!==r&&(i=Jf(-i))}const s=new Bf(n,i);return s.assertValidity(),s}static fromUncompressedHex(e){const t=jf(e.subarray(1,33)),n=jf(e.subarray(33,65)),i=new Bf(t,n);return i.assertValidity(),i}static fromHex(e){const t=Hf(e),n=t.length,i=t[0];if(n===bf)return this.fromCompressedHex(t);if(33===n&&(2===i||3===i))return this.fromCompressedHex(t);if(65===n&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(e){return Bf.BASE.multiply(function(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=Mf(e)}else{if(!$f(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=jf(e)}if(!qf(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:i,s:r}=function(e){if(e instanceof Df)return e.assertValidity(),e;try{return Df.fromDER(e)}catch(t){return Df.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const s=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=jf(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:i}=yf;return n>=i?n-i:n}(Hf(e)),{n:o}=yf,l=2===n||3===n?i+o:i,a=Vf(l,o),c=Jf(-s*a,o),u=Jf(r*a,o),d=1&n?"03":"02",f=Bf.fromHex(d+Lf(l)),p=Bf.BASE.multiplyAndAddUnsafe(f,c,u);if(!p)throw new Error("Cannot recover signature: point at infinify");return p.assertValidity(),p}toRawBytes(e=!1){return _f(this.toHex(e))}toHex(e=!1){const t=Lf(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${Lf(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:n}=this;if(!Yf(t)||!Yf(n))throw new Error(e);const i=Jf(n*n);if(Jf(i-kf(t))!==pf)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Bf(this.x,Jf(-this.y))}double(){return Ef.fromAffine(this).double().toAffine()}add(e){return Ef.fromAffine(this).add(Ef.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Ef.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const i=Ef.fromAffine(this),r=t===pf||t===hf||this!==Bf.BASE?i.multiplyUnsafe(t):i.multiply(t),s=Ef.fromAffine(e).multiplyUnsafe(n),o=r.add(s);return o.equals(Ef.ZERO)?void 0:o.toAffine()}}function Qf(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function Ff(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${Rf(e)}`);const t=e[1],n=e.subarray(2,t+2);if(!t||n.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:jf(n),left:e.subarray(t+2)}}Bf.BASE=new Bf(yf.Gx,yf.Gy),Bf.ZERO=new Bf(pf,pf);class Df{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=$f(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const i=t?Rf(e):e;if(128!==i.length)throw new Error(`${n}: Expected 64-byte hex`);return new Df(Mf(i.slice(0,64)),Mf(i.slice(64,128)))}static fromDER(e){const t=$f(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:i}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${Rf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=Ff(e.subarray(2)),{data:i,left:r}=Ff(n);if(r.length)throw new Error(`Invalid signature: left bytes after parsing: ${Rf(r)}`);return{r:t,s:i}}(t?e:_f(e));return new Df(n,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!qf(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!qf(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=yf.n>>hf;return this.s>e}normalizeS(){return this.hasHighS()?new Df(this.r,Jf(-this.s,yf.n)):this}toDERRawBytes(){return _f(this.toDERHex())}toDERHex(){const e=Qf(Of(this.s)),t=Qf(Of(this.r)),n=e.length/2,i=t.length/2,r=Of(n),s=Of(i);return`30${Of(i+n+4)}02${s}${t}02${r}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return _f(this.toCompactHex())}toCompactHex(){return Lf(this.r)+Lf(this.s)}}function $f(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const Pf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Rf(e){!function(e){if(!$f(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n=Tf._0&&e<=Tf._9?e-Tf._0:e>=Tf.A&&e<=Tf.F?e-(Tf.A-10):e>=Tf.a&&e<=Tf.f?e-(Tf.a-10):void 0}function _f(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,r=0;t0)return BigInt(e);if("bigint"==typeof e&&qf(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Jf(e,t=yf.P){const n=e%t;return n>=pf?n:t+n}function Kf(e,t){const{P:n}=yf;let i=e;for(;t-- >pf;)i*=i,i%=n;return i}function Vf(e,t=yf.P){if(e===pf||t<=pf)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Jf(e,t),i=t,r=pf,s=hf;for(;n!==pf;){const e=i%n,t=r-s*(i/n);i=n,n=e,r=s,s=t}if(i!==hf)throw new Error("invert: does not exist");return Jf(r,t)}function qf(e){return pft?a(t,e%t):e,c=(e,t)=>e+(t-a(e,t));function u(e,n,i,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(n<=0||n>32)throw new Error(`convertRadix2: wrong from=${n}`);if(i<=0||i>32)throw new Error(`convertRadix2: wrong to=${i}`);if(c(n,i)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${i} carryBits=${c(n,i)}`);let s=0,o=0;const l=2**i-1,a=[];for(const r of e){if(t(r),r>=2**n)throw new Error(`convertRadix2: invalid data word=${r} from=${n}`);if(s=s<32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${n}`);for(o+=n;o>=i;o-=i)a.push((s>>o-i&l)>>>0);s&=2**o-1}if(s=s<=n)throw new Error("Excess padding");if(!r&&s)throw new Error(`Non-zero padding: ${s}`);return r&&o>0&&a.push(s>>>0),a}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return l(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(l(t,e,256))}}}function f(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(c(8,e)>32||c(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(t,e,8,n))}}}function p(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function h(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const i=n(t).slice(0,e),r=new Uint8Array(t.length+e);return r.set(t),r.set(i,t.length),r},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const i=t.slice(0,-e),r=n(i).slice(0,e),s=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),r("")),e.base64url=n(f(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),r(""));const g=e=>n(d(58),i(e),r(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const m=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let i=0;in(h(4,e=>t(t(e))),e.base58);const v=n(i("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),r("")),y=[996825010,642813549,513874426,1027748829,705979059];function w(e){const t=e>>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=y[e]);return n}function b(e,t,n=1){const i=e.length;let r=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);r=w(r)^n>>5}r=w(r);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const i=e.toLowerCase();if(e!==i&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const r=(e=i).lastIndexOf("1");if(0===r||-1===r)throw new Error('Letter "1" must be present between prefix and data only');const s=e.slice(0,r),o=e.slice(r+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const l=v.decode(o).slice(0,-6),a=b(s,l,t);if(!o.endsWith(a))throw new Error(`Invalid checksum in ${e}: expected "${a}"`);return{prefix:s,words:l}}return{encode:function(e,n,i=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const r=e.length+7+n.length;if(!1!==i&&r>i)throw new TypeError(`Length ${r} exceeds limit ${i}`);return`${e=e.toLowerCase()}1${v.encode(n)}${b(e,n,t)}`},decode:o,decodeToBytes:function(e){const{prefix:t,words:n}=o(e,!1);return{prefix:t,words:n,bytes:i(n)}},decodeUnsafe:p(o),fromWords:i,fromWordsUnsafe:s,toWords:r}}e.bech32=A("bech32"),e.bech32m=A("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),i("0123456789abcdef"),r(""),o(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));const k={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},I=`Invalid encoding type. Available types: ${Object.keys(k).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!k.hasOwnProperty(e))throw new TypeError(I);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return k[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!k.hasOwnProperty(e))throw new TypeError(I);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return k[e].decode(t)},e.bytes=e.stringToBytes}({}),BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const Fd={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(Fd);eYc(e.tags,e=>qc(e)?e:void 0,qu))}(e),function(e){if(function(e){return sd(e)&&Reflect.has(e,Dd)}(e))return e[Dd];const t=od(e);if(!t)return;const n=Yc(t,e=>qc(e)?e:void 0,qu);return Reflect.set(e,Dd,n),n}(e))}yd.extend("EncryptedContentCache"),yd.extend("event-cache"),new TextDecoder;const Pd=Symbol.for("mailboxes-inboxes"),Td=Symbol.for("mailboxes-outboxes");function Ud(e){return iu(e,Pd,()=>{const t=[];for(const n of e.tags)if(Jc(n))try{const[,e,i]=n;!e||!Bu(e)||t.includes(e)||"read"!==i&&void 0!==i||t.push(Cu(e))}catch{}return t})}function Nd(e){return iu(e,Td,()=>{const t=[];for(const n of e.tags)if(Jc(n))try{const[e,i,r]=n;"r"!==e||!Bu(i)||t.includes(i)||"write"!==r&&void 0!==r||t.push(Cu(i))}catch{}return t})}const _d=Symbol.for("mute-public"),Ld=Symbol.for("mute-hidden");function Md(e){return{pubkeys:new Set(e.filter(qc).map(e=>e[1])),threads:new Set(e.filter(Gc).map(e=>e[1])),hashtags:new Set(e.filter(Vc).map(e=>e[1].toLocaleLowerCase())),words:new Set(e.filter(e=>"word"===e[0]&&e[1]).map(e=>e[1].toLocaleLowerCase()))}}function Od(e){const t=function(e){if(function(e){return sd(e)&&Reflect.has(e,Ld)}(e))return e[Ld];const t=od(e);if(!t)return;const n=Md(t);return Reflect.set(e,Ld,n),n}(e),n=function(e){return iu(e,_d,()=>Md(e.tags))}(e);return t?function(...e){const t={pubkeys:new Set,threads:new Set,hashtags:new Set,words:new Set};for(const n of e){for(const e of n.pubkeys)t.pubkeys.add(e);for(const e of n.threads)t.threads.add(e);for(const e of n.hashtags)t.hashtags.add(e);for(const e of n.words)t.words.add(e)}return t}(t,n):n}var jd;!function(e){e.nudity="nudity",e.malware="malware",e.profanity="profanity",e.illegal="illegal",e.spam="spam",e.impersonation="impersonation",e.other="other"}(jd||(jd={}));const Hd=Symbol.for("nip10-thread-refs");function Gd(e){if(!e[1])throw new Error("Missing event id in tag");let t={id:e[1]};return e[2]&&Bu(e[2])&&(t.relays=[e[2]]),"e"!==e[0]||"root"!==e[3]&&"reply"!==e[3]&&"mention"!==e[3]||!e[4]||64!==e[4].length||(t.author=e[4]),t}function qd(e){return t=>{const n=new Set;return t.pipe(jc(t=>{if(void 0!==t)if(Array.isArray(t))for(const i of t)n.has(i)||(n.add(i),e.claim(i));else n.has(t)||(n.add(t),e.claim(t))}),Uc(()=>{for(const t of n)e.removeClaim(t)}))}}function Jd(e){return t=>{let n;return t.pipe(jc(t=>{n!==t&&(n&&e.removeClaim(n),t&&e.claim(t),n=t)}),Uc(()=>{n&&e.removeClaim(n)}))}}function Kd(){return e=>e.pipe($c(e=>null!=e))}function Vd(e){return t=>new Fa(n=>{let i=!1;const r=t.subscribe({next:e=>{i=!0,n.next(e)},error:e=>n.error(e),complete:()=>n.complete()});return i||n.next(e),r})}function Yd(e){return"string"==typeof e&&(e={id:e}),t=>Fc(Bc(()=>function(e,t){const n=e.getEvent(t.id);return n instanceof Promise?pc(n):hc(n)}(t,e)).pipe(function(e,t){return Oc(n=>n?hc(n):e.eventLoader?pc(e.eventLoader(t)):Ja)}(t,e),Kd()),t.insert$.pipe($c(t=>t.id===e.id)),t.remove$.pipe($c(t=>t.id===e.id),Dc(1),Da(function(e,t){e.subscribe(Ra(t,wa))}),Tc(void 0))).pipe(Jd(t),Rc((e,t)=>e?.id===t?.id),Vd(void 0))}function zd(e){return t=>{let n;return Fc(Bc(()=>function(e,t){const n=e.getReplaceable(t.kind,t.pubkey,t.identifier);return n instanceof Promise?pc(n):hc(n)}(t,e)).pipe(function(e,t){return Oc(n=>n?hc(n):void 0!==t.identifier?e.addressableLoader?pc(e.addressableLoader(t)).pipe($c(e=>!!e)):Ja:e.replaceableLoader?pc(e.replaceableLoader(t)).pipe($c(e=>!!e)):Ja)}(t,e),Kd()),t.insert$.pipe($c(t=>t.pubkey==e.pubkey&&t.kind===e.kind&&(void 0===e.identifier||gu(t)===e.identifier)))).pipe(Rc((e,t)=>e.created_at>=t.created_at),jc(e=>n=e),(i=t.remove$.pipe($c(e=>e.id===n?.id)),Da(function(e,t){oc(i).subscribe(Ra(t,function(){return t.complete()},wa)),!t.closed&&e.subscribe(t)})),Tc(void 0),function(e){var t,n,i=1/0;return null!=e&&("object"==typeof e?(t=e.count,i=void 0===t?1/0:t,n=e.delay):i=e),i<=0?function(){return Ja}:Da(function(e,t){var r,s=0,o=function(){if(null==r||r.unsubscribe(),r=null,null!=n){var e="number"==typeof n?Qc(n):oc(n(s)),i=Ra(t,function(){i.unsubscribe(),l()});e.subscribe(i)}else l()},l=function(){var n=!1;r=e.subscribe(Ra(t,void 0,function(){++s{const i=new Map;return Bc(()=>{const t=n.getTimeline(e);return t instanceof Promise?pc(t):hc(t)}).pipe(qd(n),_c(n.insert$.pipe($c(t=>Ed(e,t)),qd(n))),_c(n.remove$.pipe($c(t=>Ed(e,t)),gc(e=>e.id))),Lc((e,n)=>{if("string"==typeof n)return e.filter(e=>e.id!==n);if(Array.isArray(n)){if(!t)for(const e of n)du(e.kind)&&i.set(fu(e),e);return n}let r=[...e];if(!t&&du(n.kind)){const t=fu(n),s=i.get(t);if(s&&n.created_ati.clear()))}}function Zd(e){return t=>Ic(Object.fromEntries(e.map(e=>[e,t.model(Yd,{id:e})])))}function Xd(e){return t=>Ic(Object.fromEntries(e.map(e=>[hu(e.kind,e.pubkey,e.identifier),t.model(zd,e)])))}function ef(e){return t=>{let n;return Fc(t.pipe(jc(e=>n=e)),e.update$.pipe($c(e=>e.id===n?.id)))}}function tf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:mr.Contacts,pubkey:e.pubkey,relays:e.relays}).pipe(ef(t),gc(e=>e?Rd(e):[]))}function nf(e){return t=>{const n=[{kinds:[1111],"#e":[e.id]}];return Wl(e.kind)&&n.push({kinds:[1111],"#a":[pu(e)]}),t.timeline(n)}}function rf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:mr.RelayList,pubkey:e.pubkey,relays:e.relays}).pipe(gc(e=>e&&{inboxes:Ud(e),outboxes:Nd(e)}))}function sf(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:mr.Mutelist,pubkey:e.pubkey,relays:e.relays}).pipe(ef(t),gc(e=>e&&Od(e)))}function of(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:mr.Metadata,pubkey:e.pubkey,relays:e.relays}).pipe($c(Qd),gc(e=>e&&Bd(e)),Vd(void 0))}function lf(e){return t=>t.timeline(du(e.kind)?[{kinds:[mr.Reaction],"#e":[e.id]},{kinds:[mr.Reaction],"#a":[fu(e)]}]:[{kinds:[mr.Reaction],"#e":[e.id]}])}const af={kinds:[mr.ShortTextNote]};function cf(e,t){const n=new Map,i=new Map,{kinds:r}={...af,...t};let s="";const o={},l={kinds:r};var a;return"string"!=typeof(a=e)&&Reflect.has(a,"identifier")&&Reflect.has(a,"pubkey")&&Reflect.has(a,"kind")?(s=Ju(e),o.kinds=[e.kind],o.authors=[e.pubkey],o["#d"]=[e.identifier],l["#a"]=[s]):"string"==typeof e?(s=e,o.ids=[e],l["#e"]=[e]):(s=e.id,o.ids=[e.id],l["#e"]=[e.id]),e=>e.filters([o,l]).pipe(gc(e=>{if(!i.has(fu(e))){const t=function(e){return iu(e,Hd,()=>{const t=function(e){const t=e.filter(e=>"e"===e[0]&&e[1]),n=e.filter(e=>"a"===e[0]&&e[1]);let i=t.find(e=>"root"===e[3]),r=t.find(e=>"reply"===e[3]),s=n.find(e=>"root"===e[3]),o=n.find(e=>"reply"===e[3]);if(i&&r||(i=r=i||r),s&&o||(s=o=s||o),!i&&!r){const e=t.filter(e=>!e[3]);e.length>=1&&(i=e[0],r=e[e.length-1]??i)}return{root:i||s?{e:i,a:s}:void 0,reply:r||o?{e:r,a:o}:void 0}}(e.tags);let n,i;if(t.root)try{n={e:t.root.e&&Gd(t.root.e),a:t.root.a&&Gu(t.root.a)}}catch(e){}if(t.reply)try{i={e:t.reply.e&&Gd(t.reply.e),a:t.reply.a&&Gu(t.reply.a)}}catch(e){}return{root:n,reply:i}})}(e),r=n.get(fu(e))||new Set,s={event:e,refs:t,replies:r};for(const e of r)e.parent=s;if(t.reply?.e||t.reply?.a){let e=t.reply.e?t.reply.e.id:Ju(t.reply.a);if(s.parent=i.get(e),s.parent)s.parent.replies.add(s);else{let t=n.get(e);t||(t=new Set,n.set(e,t)),t.add(s)}}i.set(fu(e),s)}return{root:i.get(s),all:i}}))}function uf(e){return class extends e{models=new Map;modelKeepWarm=6e4;model(e,...t){let n=this.models.get(e);n||(n=new Map,this.models.set(e,n));const i=e.getKey?e.getKey(...t):Id(t);let r=n.get(i);if(!r){const s=()=>{n.get(i)===r&&n.delete(i)};r=e(...t)(this).pipe(Uc(s),function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new Ua}:t,i=e.resetOnError,r=void 0===i||i,s=e.resetOnComplete,o=void 0===s||s,l=e.resetOnRefCountZero,a=void 0===l||l;return function(e){var t,i,s,l=0,c=!1,u=!1,d=function(){null==i||i.unsubscribe(),i=void 0},f=function(){d(),t=s=void 0,c=u=!1},p=function(){var e=t;f(),null==e||e.unsubscribe()};return Da(function(e,h){l++,u||c||d();var g=s=null!=s?s:n();h.add(function(){0!==--l||u||c||(i=Mc(p,a))}),g.subscribe(h),!t&&l>0&&(t=new Ea({next:function(e){return g.next(e)},error:function(e){u=!0,d(),i=Mc(f,r,e),g.error(e)},complete:function(){c=!0,d(),i=Mc(f,o),g.complete()}}),oc(e).subscribe(t))})(e)}}({connector:()=>new La(1),resetOnComplete:()=>Qc(this.modelKeepWarm),resetOnRefCountZero:()=>Qc(this.modelKeepWarm)})),n.set(i,r)}return r}filters(e,t=!1){e=Array.isArray(e)?e:[e];const n=this.getByFilters(e);return Fc(t?Ja:n&&"function"==typeof n.then?pc(n).pipe(Ec(e=>pc(Array.from(e)))):pc(Array.from(n)),this.insert$.pipe($c(t=>Ed(e,t))))}event(e){return"string"==typeof e&&(e={id:e}),this.model(Yd,e)}replaceable(...e){let t;if(1===e.length)t=e[0];else if(3===e.length||2===e.length){let[n,i,r]=e;t={kind:n,pubkey:i,identifier:r}}if(!t)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(zd,t)}addressable(e){return this.model(zd,e)}timeline(e,t=!1){return this.model(Wd,e,t)}profile(e){return this.model(of,e)}contacts(e){return"string"==typeof e&&(e={pubkey:e}),this.model(tf,e)}mutes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(sf,e)}mailboxes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(rf,e)}blossomServers(e){return"string"==typeof e&&(e={pubkey:e}),this.model(xd,e)}reactions(e){return this.model(lf,e)}thread(e){return this.model(cf,e)}comments(e){return this.model(nf,e)}events(e){return this.model(Zd,e)}replaceableSet(e){return this.model(Xd,e)}}}class df extends(uf(class{})){database;memory;keepOldVersions=!1;keepExpired=!1;verifyEvent;insert$=new Ua;update$=new Ua;remove$=new Ua;eventLoader;replaceableLoader;addressableLoader;constructor(e=new wd){super(),e?(this.database=e,this.memory=new wd):this.database=this.memory=new wd,this.insert$.subscribe(e=>{Reflect.set(e,ou,this)}),this.remove$.subscribe(e=>{Reflect.deleteProperty(e,ou)})}mapToMemory(e){if(void 0!==e)return this.memory?this.memory.add(e):e}deletedIds=new Set;deletedCoords=new Map;checkDeleted(e){if("string"==typeof e)return this.deletedIds.has(e);if(this.deletedIds.has(e.id))return!0;if(Wl(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=this.deletedCoords.get(hu(e.kind,e.pubkey,t));if(n)return n>e.created_at}return!1}expirations=new Map;addExpiration(e){const t=yu(e);t&&Number.isFinite(t)&&this.expirations.set(e.id,t)}expirationTimeout=null;nextExpirationCheck=null;handleExpiringEvent(e){const t=yu(e);if(!t)return;if(this.expirations.set(e.id,t),this.expirationTimeout&&this.nextExpirationCheck&&this.nextExpirationChecke[1])}(e);for(const e of t)this.deletedIds.add(e),this.remove(e);const n=function(e){return e.tags.filter(Kc).map(e=>e[1])}(e);for(const t of n){this.deletedCoords.set(t,Math.max(this.deletedCoords.get(t)??0,e.created_at));const n=Hu(t);if(!n)continue;const i=this.database.getReplaceableHistory(n.kind,n.pubkey,n.identifier)??[];for(const t of i)t.created_at"d"===e[0])?.[1]:void 0;if(!this.keepOldVersions&&du(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(t&&t.length>0&&t[0].created_at>=e.created_at)return df.mergeDuplicateEvent(e,t[0]),t[0]}if(this.verifyEvent&&!1===this.verifyEvent(e))return null;const r=this.memory?.add(e);if(r&&r!==e)return df.mergeDuplicateEvent(e,r),t&&xu(r,t),r;const s=this.mapToMemory(this.database.add(e));if(e!==s&&df.mergeDuplicateEvent(e,s),t&&xu(s,t),s===e&&this.insert$.next(s),!this.keepOldVersions&&du(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(t&&t.length>0){const n=Array.from(t).filter(t=>t.created_atthis.mapToMemory(e)??e)}getByFilters(e){const t=this.database.getByFilters(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}getTimeline(e){const t=this.database.getTimeline(e);return this.memory?t.map(e=>this.mapToMemory(e)):t}touch(e){return this.memory?.touch(e)}claim(e){return this.memory?.claim(e)}isClaimed(e){return this.memory?.isClaimed(e)??!1}removeClaim(e){return this.memory?.removeClaim(e)}clearClaim(e){return this.memory?.clearClaim(e)}unclaimed(){return this.memory?.unclaimed()||function*(){}()}prune(e){return this.memory?.prune(e)??0}removed(e){return this.checkDeleted(e)?Ja:this.remove$.pipe($c(t=>t.id===e),Dc(1),Ec(()=>Ja))}updated(e){return this.update$.pipe($c(t=>t.id===e||t===e))}}function ff(){let e,t;const n=new Promise((n,i)=>{e=n,t=i});return n.resolve=e,n.reject=t,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var pf,hf;Zu(mr.NostrConnect,"nip44"),function(e){e.GetPublicKey="get_pubic_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(pf||(pf={})),function(e){e.Connect="connect",e.CreateAccount="create_account",e.GetPublicKey="get_public_key",e.SignEvent="sign_event",e.Nip04Encrypt="nip04_encrypt",e.Nip04Decrypt="nip04_decrypt",e.Nip44Encrypt="nip44_encrypt",e.Nip44Decrypt="nip44_decrypt"}(hf||(hf={}));class gf{key;constructor(e){this.key=e||fr()}async getPublicKey(){return pr(this.key)}async signEvent(e){return hr(e,this.key)}nip04={encrypt:async(e,t)=>mo.encrypt(this.key,e,t),decrypt:async(e,t)=>mo.decrypt(this.key,e,t)};nip44={encrypt:async(e,t)=>Ro.v2.encrypt(t,Ro.v2.utils.getConversationKey(this.key,e)),decrypt:async(e,t)=>Ro.v2.decrypt(t,Ro.v2.utils.getConversationKey(this.key,e))};static fromKey(e){return new gf(function(e){if(e instanceof Uint8Array)return e;if(Qu(e))return ju(e);{const t=Xs.decode(e);if("nsec"!==t.type)throw new Error(`Cant get secret key from ${t.type}`);return t.data}}(e))}} +/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const mf=BigInt(0),vf=BigInt(1),yf=BigInt(2),wf=BigInt(3),bf=BigInt(8),Af=Object.freeze({a:mf,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:vf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),kf=(e,t)=>(e+t/yf)/t,If={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=Af,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-vf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),r=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),l=kf(s*e,t),a=kf(-i*e,t);let c=Vf(e-l*n-a*r,t),u=Vf(-l*i-a*s,t);const d=c>o,f=u>o;if(d&&(c=t-c),f&&(u=t-u),c>o||u>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}},Cf=32;function Ef(e){const{a:t,b:n}=Af,i=Vf(e*e),r=Vf(i*e);return Vf(r+t*e+n)}const xf=Af.a===mf;function Sf(e){if(!(e instanceof Bf))throw new TypeError("JacobianPoint expected")}class Bf{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof $f))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals($f.ZERO)?Bf.ZERO:new Bf(e.x,e.y,vf)}static toAffineBatch(e){const t=function(e,t=Af.P){const n=new Array(e.length),i=e.reduce((e,i,r)=>i===mf?e:(n[r]=e,Vf(e*i,t)),vf),r=zf(i,t);return e.reduceRight((e,i,r)=>i===mf?e:(n[r]=Vf(e*n[r],t),Vf(e*i,t)),r),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return Bf.toAffineBatch(e).map(Bf.fromAffine)}equals(e){Sf(e);const{x:t,y:n,z:i}=this,{x:r,y:s,z:o}=e,l=Vf(i*i),a=Vf(o*o),c=Vf(t*a),u=Vf(r*l),d=Vf(Vf(n*o)*a),f=Vf(Vf(s*i)*l);return c===u&&d===f}negate(){return new Bf(this.x,Vf(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,i=Vf(e*e),r=Vf(t*t),s=Vf(r*r),o=e+r,l=Vf(yf*(Vf(o*o)-i-s)),a=Vf(wf*i),c=Vf(a*a),u=Vf(c-yf*l),d=Vf(a*(l-u)-bf*s),f=Vf(yf*t*n);return new Bf(u,d,f)}add(e){Sf(e);const{x:t,y:n,z:i}=this,{x:r,y:s,z:o}=e;if(r===mf||s===mf)return this;if(t===mf||n===mf)return e;const l=Vf(i*i),a=Vf(o*o),c=Vf(t*a),u=Vf(r*l),d=Vf(Vf(n*o)*a),f=Vf(Vf(s*i)*l),p=Vf(u-c),h=Vf(f-d);if(p===mf)return h===mf?this.double():Bf.ZERO;const g=Vf(p*p),m=Vf(p*g),v=Vf(c*g),y=Vf(h*h-m-yf*v),w=Vf(h*(v-y)-d*m),b=Vf(i*o*p);return new Bf(y,w,b)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Bf.ZERO;if("bigint"==typeof e&&e===mf)return t;let n=Kf(e);if(n===vf)return this;if(!xf){let e=t,i=this;for(;n>mf;)n&vf&&(e=e.add(i)),i=i.double(),n>>=vf;return e}let{k1neg:i,k1:r,k2neg:s,k2:o}=If.splitScalar(n),l=t,a=t,c=this;for(;r>mf||o>mf;)r&vf&&(l=l.add(c)),o&vf&&(a=a.add(c)),c=c.double(),r>>=vf,o>>=vf;return i&&(l=l.negate()),s&&(a=a.negate()),a=new Bf(Vf(a.x*If.beta),a.y,a.z),l.add(a)}precomputeWindow(e){const t=xf?128/e+1:256/e+1,n=[];let i=this,r=i;for(let s=0;s>=u,o>l&&(o-=c,e+=vf);const d=n,f=n+Math.abs(o)-1,p=t%2!=0,h=o<0;0===o?s=s.add(Qf(p,i[d])):r=r.add(Qf(h,i[f]))}return{p:r,f:s}}multiply(e,t){let n,i,r=Kf(e);if(xf){const{k1neg:e,k1:s,k2neg:o,k2:l}=If.splitScalar(r);let{p:a,f:c}=this.wNAF(s,t),{p:u,f:d}=this.wNAF(l,t);a=Qf(e,a),u=Qf(o,u),u=new Bf(Vf(u.x*If.beta),u.y,u.z),n=a.add(u),i=c.add(d)}else{const{p:e,f:s}=this.wNAF(r,t);n=e,i=s}return Bf.normalizeZ([n,i])[0]}toAffine(e){const{x:t,y:n,z:i}=this,r=this.equals(Bf.ZERO);null==e&&(e=r?bf:zf(i));const s=e,o=Vf(s*s),l=Vf(o*s),a=Vf(t*o),c=Vf(n*l),u=Vf(i*s);if(r)return $f.ZERO;if(u!==vf)throw new Error("invZ was invalid");return new $f(a,c)}}function Qf(e,t){const n=t.negate();return e?n:t}Bf.BASE=new Bf(Af.Gx,Af.Gy,vf),Bf.ZERO=new Bf(mf,vf,mf);const Ff=new WeakMap;class $f{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,Ff.delete(this)}hasEvenY(){return this.y%yf===mf}static fromCompressedHex(e){const t=32===e.length,n=qf(t?e:e.subarray(1));if(!Zf(n))throw new Error("Point is not on curve");let i=function(e){const{P:t}=Af,n=BigInt(6),i=BigInt(11),r=BigInt(22),s=BigInt(23),o=BigInt(44),l=BigInt(88),a=e*e*e%t,c=a*a*e%t,u=Yf(c,wf)*c%t,d=Yf(u,wf)*c%t,f=Yf(d,yf)*a%t,p=Yf(f,i)*f%t,h=Yf(p,r)*p%t,g=Yf(h,o)*h%t,m=Yf(g,l)*g%t,v=Yf(m,o)*h%t,y=Yf(v,wf)*c%t,w=Yf(y,s)*p%t,b=Yf(w,n)*a%t,A=Yf(b,yf);if(A*A%t!==e)throw new Error("Cannot find square root");return A}(Ef(n));const r=(i&vf)===vf;if(t)r&&(i=Vf(-i));else{!(1&~e[0])!==r&&(i=Vf(-i))}const s=new $f(n,i);return s.assertValidity(),s}static fromUncompressedHex(e){const t=qf(e.subarray(1,33)),n=qf(e.subarray(33,65)),i=new $f(t,n);return i.assertValidity(),i}static fromHex(e){const t=Jf(e),n=t.length,i=t[0];if(n===Cf)return this.fromCompressedHex(t);if(33===n&&(2===i||3===i))return this.fromCompressedHex(t);if(65===n&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(e){return $f.BASE.multiply(function(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=Gf(e)}else{if(!Tf(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=qf(e)}if(!Wf(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:i,s:r}=function(e){if(e instanceof Pf)return e.assertValidity(),e;try{return Pf.fromDER(e)}catch(t){return Pf.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const s=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=qf(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:i}=Af;return n>=i?n-i:n}(Jf(e)),{n:o}=Af,l=2===n||3===n?i+o:i,a=zf(l,o),c=Vf(-s*a,o),u=Vf(r*a,o),d=1&n?"03":"02",f=$f.fromHex(d+jf(l)),p=$f.BASE.multiplyAndAddUnsafe(f,c,u);if(!p)throw new Error("Cannot recover signature: point at infinify");return p.assertValidity(),p}toRawBytes(e=!1){return Mf(this.toHex(e))}toHex(e=!1){const t=jf(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${jf(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:n}=this;if(!Zf(t)||!Zf(n))throw new Error(e);const i=Vf(n*n);if(Vf(i-Ef(t))!==mf)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new $f(this.x,Vf(-this.y))}double(){return Bf.fromAffine(this).double().toAffine()}add(e){return Bf.fromAffine(this).add(Bf.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Bf.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const i=Bf.fromAffine(this),r=t===mf||t===vf||this!==$f.BASE?i.multiplyUnsafe(t):i.multiply(t),s=Bf.fromAffine(e).multiplyUnsafe(n),o=r.add(s);return o.equals(Bf.ZERO)?void 0:o.toAffine()}}function Df(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function Rf(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${Nf(e)}`);const t=e[1],n=e.subarray(2,t+2);if(!t||n.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:qf(n),left:e.subarray(t+2)}}$f.BASE=new $f(Af.Gx,Af.Gy),$f.ZERO=new $f(mf,mf);class Pf{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=Tf(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const i=t?Nf(e):e;if(128!==i.length)throw new Error(`${n}: Expected 64-byte hex`);return new Pf(Gf(i.slice(0,64)),Gf(i.slice(64,128)))}static fromDER(e){const t=Tf(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:i}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${Nf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=Rf(e.subarray(2)),{data:i,left:r}=Rf(n);if(r.length)throw new Error(`Invalid signature: left bytes after parsing: ${Nf(r)}`);return{r:t,s:i}}(t?e:Mf(e));return new Pf(n,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Wf(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Wf(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=Af.n>>vf;return this.s>e}normalizeS(){return this.hasHighS()?new Pf(this.r,Vf(-this.s,Af.n)):this}toDERRawBytes(){return Mf(this.toDERHex())}toDERHex(){const e=Df(Hf(this.s)),t=Df(Hf(this.r)),n=e.length/2,i=t.length/2,r=Hf(n),s=Hf(i);return`30${Hf(i+n+4)}02${s}${t}02${r}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Mf(this.toCompactHex())}toCompactHex(){return jf(this.r)+jf(this.s)}}function Tf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const Uf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Nf(e){!function(e){if(!Tf(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n=_f._0&&e<=_f._9?e-_f._0:e>=_f.A&&e<=_f.F?e-(_f.A-10):e>=_f.a&&e<=_f.f?e-(_f.a-10):void 0}function Mf(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let t=0,r=0;t0)return BigInt(e);if("bigint"==typeof e&&Wf(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Vf(e,t=Af.P){const n=e%t;return n>=mf?n:t+n}function Yf(e,t){const{P:n}=Af;let i=e;for(;t-- >mf;)i*=i,i%=n;return i}function zf(e,t=Af.P){if(e===mf||t<=mf)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Vf(e,t),i=t,r=mf,s=vf;for(;n!==mf;){const e=i%n,t=r-s*(i/n);i=n,n=e,r=s,s=t}if(i!==vf)throw new Error("invert: does not exist");return Vf(r,t)}function Wf(e){return mf"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function Zf(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function Xf(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ep(e){if(!Array.isArray(e))throw new Error("array expected")}function tp(e,t){if(!zf(!0,t))throw new Error(`${e}: array of strings expected`)}Bf.BASE._setWindowSize(8);const np=(e,t)=>0===t?e:np(t,e%t),ip=(e,t)=>e+(t-np(e,t)),rp=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function sp(e,t,n,i){if(ep(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(ip(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${ip(t,n)}`);let r=0,s=0;const o=rp[t],l=rp[n]-1,a=[];for(const i of e){if(Xf(i),i>=o)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(r=r<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((r>>s-n&l)>>>0);const e=rp[s];if(void 0===e)throw new Error("invalid carry");r&=e-1}if(r=r<=t)throw new Error("Excess padding");if(!i&&r>0)throw new Error(`Non-zero padding: ${r}`);return i&&s>0&&a.push(r>>>0),a}const op=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Wf(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}(e),e.toBase64()),decode:e=>((e,t)=>{Zf("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,i=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:i,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(Xf(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(ip(8,e)>32||ip(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Wf(n))throw new Error("radix2.encode input should be Uint8Array");return sp(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!zf(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(sp(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;tp("alphabet",t);const i=new Map(t.map((e,t)=>[e,t]));return{encode:i=>(ep(i),i.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:t=>(ep(t),t.map(t=>{Zf("alphabet.decode",t);const n=i.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return Xf(e),Zf("padding",t),{encode(n){for(tp("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){tp("padding.decode",n);let i=n.length;if(i*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--){if((i-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,i)}}}(6),function(e=""){return Zf("join",e),{encode:t=>(tp("join.decode",t),t.join(e)),decode:t=>(Zf("join.decode",t),t.split(e))}}(""));function lp(e){return Bf.fromHex(e).toHex().substring(2)}const ap=new TextDecoder("utf-8"),cp=new TextEncoder;class up{log=gd.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=fr;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!up.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const i=cf();return this.lastCommand=i,this.sendCommand(e,t),setTimeout(()=>{i.reject(new Error("Device timeout")),this.lastCommand===i&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:i}){let r,s=await window.navigator.serial.requestPort();await s.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;s&&s.readable;){const e=new window.TextDecoderStream;s.readable.pipeTo(e.writable),r=e.readable.getReader();const t=this.readFromSerialPort(r);try{for(;;){const{value:e,done:n}=await t("\n");if(e){const{method:t,data:n}=this.parseResponse(e);if("/ping"===t&&this.log("Pong"),-1===up.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(i&&i())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const o=new window.TextEncoderStream;o.readable.pipeTo(s.writable),this.writer=o.writable.getWriter(),await this.sendCommand(up.METHOD_PING),await this.sendCommand(up.METHOD_PING,[window.location.host]),e&&e(),s.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(i="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const r=[];for(t&&(r.push(t),t=void 0);;){const{value:s,done:o}=await e.read();if(s){const e=s.split(i);if(e.length>1)return r.push(e.shift()),t=e.pop(),n=e,{value:r.join("").trim(),done:!1};r.push(s)}if(o)return{value:r.join("").trim(),done:!0}}}}parseResponse(e){const t=e.split(" ")[0];return{method:t,data:e.substring(t.length).trim()}}async nip04Encrypt(e,t){const n=Lu(await this.callMethodOnDevice(up.METHOD_SHARED_SECRET,[lp(e)]));let i=Uint8Array.from(function(e=32){if(Su&&"function"==typeof Su.getRandomValues)return Su.getRandomValues(new Uint8Array(e));if(Su&&"function"==typeof Su.randomBytes)return Uint8Array.from(Su.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),r=cp.encode(t),s=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),o=await crypto.subtle.encrypt({name:"AES-CBC",iv:i},s,r);return`${op.encode(new Uint8Array(o))}?iv=${op.encode(new Uint8Array(i.buffer))}`}async nip04Decrypt(e,t){let[n,i]=t.split("?iv=");const r=Lu(await this.callMethodOnDevice(up.METHOD_SHARED_SECRET,[lp(e)]));let s=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["decrypt"]),o=op.decode(n),l=op.decode(i),a=await crypto.subtle.decrypt({name:"AES-CBC",iv:l},s,o);return ap.decode(a)}async getPublicKey(){const e=await this.callMethodOnDevice(up.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(up.METHOD_RESTORE,[Du(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:lr({...e,pubkey:t})},i=await this.callMethodOnDevice(up.METHOD_SIGN_MESSAGE,[n.id]),r={...n,sig:i,pubkey:t};if(!this.verifyEvent(r))throw new Error("Invalid signature");return r}ping(){this.sendCommand(up.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[up.METHOD_PUBLIC_KEY,up.METHOD_SIGN_MESSAGE,up.METHOD_SHARED_SECRET,up.METHOD_RESTORE]}const dp=[`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`],fp=["wss://relay.damus.io","wss://nos.lol","wss://relay.nostr.band","wss://purplepag.es"],pp=[{value:0,label:"User Metadata (0)"},{value:3,label:"Follows (3)"},{value:1e4,label:"Mute list (10000)"},{value:10001,label:"Pin list (10001)"},{value:10002,label:"Relay List Metadata (10002)"},{value:10003,label:"Bookmark list (10003)"},{value:10004,label:"Communities list (10004)"},{value:10005,label:"Public chats list (10005)"},{value:10006,label:"Blocked relays list (10006)"},{value:10007,label:"Search relays list (10007)"},{value:10009,label:"User groups (10009)"},{value:10012,label:"Favorite relays list (10012)"},{value:10013,label:"Private event relay list (10013)"},{value:10015,label:"Interests list (10015)"},{value:10019,label:"Nutzap Mint Recommendation (10019)"},{value:10020,label:"Media follows (10020)"},{value:10030,label:"User emoji list (10030)"},{value:10050,label:"Relay list to receive DMs (10050)"},{value:10051,label:"KeyPackage Relays List (10051)"},{value:10063,label:"User server list (10063)"},{value:10096,label:"File storage server list (10096)"},{value:10166,label:"Relay Monitor Announcement (10166)"},{value:10312,label:"Room Presence (10312)"},{value:10377,label:"Proxy Announcement (10377)"},{value:11111,label:"Transport Method Announcement (11111)"},{value:13194,label:"Wallet Info (13194)"},{value:17375,label:"Cashu Wallet Event (17375)"},{value:3e4,label:"Follow sets (30000)"},{value:30001,label:"Generic lists (30001)"},{value:30002,label:"Relay sets (30002)"},{value:30003,label:"Bookmark sets (30003)"},{value:30004,label:"Curation sets (30004)"},{value:30005,label:"Video sets (30005)"},{value:30007,label:"Kind mute sets (30007)"},{value:30008,label:"Profile Badges (30008)"},{value:30009,label:"Badge Definition (30009)"},{value:30015,label:"Interest sets (30015)"},{value:30017,label:"Create or update a stall (30017)"},{value:30018,label:"Create or update a product (30018)"},{value:30019,label:"Marketplace UI/UX (30019)"},{value:30020,label:"Product sold as an auction (30020)"},{value:30023,label:"Long-form Content (30023)"},{value:30024,label:"Draft Long-form Content (30024)"},{value:30030,label:"Emoji sets (30030)"},{value:30040,label:"Curated Publication Index (30040)"},{value:30041,label:"Curated Publication Content (30041)"},{value:30063,label:"Release artifact sets (30063)"},{value:30078,label:"Application-specific Data (30078)"},{value:30166,label:"Relay Discovery (30166)"},{value:30267,label:"App curation sets (30267)"},{value:30311,label:"Live Event (30311)"},{value:30312,label:"Interactive Room (30312)"},{value:30313,label:"Conference Event (30313)"},{value:30315,label:"User Statuses (30315)"},{value:30388,label:"Slide Set (30388)"},{value:30402,label:"Classified Listing (30402)"},{value:30403,label:"Draft Classified Listing (30403)"},{value:30617,label:"Repository announcements (30617)"},{value:30618,label:"Repository state announcements (30618)"},{value:30818,label:"Wiki article (30818)"},{value:30819,label:"Redirects (30819)"},{value:31234,label:"Draft Event (31234)"},{value:31388,label:"Link Set (31388)"},{value:31890,label:"Feed (31890)"},{value:31922,label:"Date-Based Calendar Event (31922)"},{value:31923,label:"Time-Based Calendar Event (31923)"},{value:31924,label:"Calendar (31924)"},{value:31925,label:"Calendar Event RSVP (31925)"},{value:31989,label:"Handler recommendation (31989)"},{value:31990,label:"Handler information (31990)"},{value:32267,label:"Software Application (32267)"},{value:34550,label:"Community Definition (34550)"},{value:37516,label:"Geocache listing (37516)"},{value:38172,label:"Cashu Mint Announcement (38172)"},{value:38173,label:"Fedimint Announcement (38173)"},{value:38383,label:"Peer-to-peer Order events (38383)"},{value:39089,label:"Starter packs (39089)"},{value:39092,label:"Media starter packs (39092)"},{value:39701,label:"Web bookmarks (39701)"}],hp={0:"User Metadata",1:"Short Text Note",2:"Recommend Relay",3:"Follows",4:"Encrypted Direct Messages",5:"Event Deletion Request",6:"Repost",7:"Reaction",8:"Badge Award",9:"Chat Message",10:"Group Chat Threaded Reply",11:"Thread",12:"Group Thread Reply",13:"Seal",14:"Direct Message",15:"File Message",16:"Generic Repost",17:"Reaction to a website",20:"Picture",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1021:"Bid",1022:"Bid Confirmation",1040:"OpenTimestamps",1063:"File Metadata",1311:"Live Chat Message",1971:"Problem Tracker",1984:"Reporting",1985:"Label",4550:"Community Post Approval",5e3:"Job Request",5999:"Job Request",6e3:"Job Result",6999:"Job Result",7e3:"Job Feedback",9041:"Zap Goal",9734:"Zap Request",9735:"Zap",9882:"Highlights",1e4:"Mute list",10001:"Pin list",10002:"Relay List Metadata",10003:"Bookmarks list",10004:"Communities list",10005:"Public Chats list",10006:"Blocked Relays list",10007:"Search Relays list",10015:"Interests",10030:"User Emoji list",10050:"DM relays",10096:"File Storage Server List",13194:"Wallet Service Info",21e3:"Lightning pub RPC",22242:"Client Authentication",23194:"Wallet Request",23195:"Wallet Response",23196:"Wallet Notification",23197:"Wallet Notification",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Follow sets",30001:"Generic lists",30002:"Relay sets",30003:"Bookmark sets",30004:"Curation sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest sets",30017:"Stall Definition",30018:"Product Definition",30019:"Marketplace UI/UX",30020:"Product sold as an auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34235:"Video Event Horizontal",34236:"Video Event Vertical",34550:"Community Definition"},gp=3e5;class mp{constructor(){this.pool=new Tn,this.eventStore=new af,this.isConnected=!1,this.signer=null,this.relays=[...dp]}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());try{const n=t||this.relays,i=this.pool.publish(n,e);return await Promise.allSettled(i),console.log("✓ Event published successfully"),await Cp([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const vp=new mp;function yp(e,t){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of t){const t=n.get(e.id);(!t||e.created_at>=t.created_at)&&n.set(e.id,e)}return Array.from(n.values()).sort((e,t)=>t.created_at-e.created_at)}const wp="nostrCache",Ap=2,bp="events";function kp(){return new Promise((e,t)=>{try{const n=indexedDB.open(wp,Ap);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let i;i=t.objectStoreNames.contains(bp)?n.transaction.objectStore(bp):t.createObjectStore(bp,{keyPath:"id"}),i.indexNames.contains("byKindAuthor")||i.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),i.indexNames.contains("byKindAuthorCreated")||i.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),i.indexNames.contains("byKind")||i.createIndex("byKind","kind",{unique:!1}),i.indexNames.contains("byAuthor")||i.createIndex("byAuthor","pubkey",{unique:!1}),i.indexNames.contains("byCreatedAt")||i.createIndex("byCreatedAt","created_at",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){console.error("Failed to open IndexedDB",e),t(e)}})}async function Ip(e){try{const t=await kp();await new Promise((n,i)=>{const r=t.transaction(bp,"readwrite");r.oncomplete=()=>n(),r.onerror=()=>i(r.error),r.objectStore(bp).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function Cp(e){if(e&&0!==e.length)try{const t=await kp();await new Promise((n,i)=>{const r=t.transaction(bp,"readwrite");r.oncomplete=()=>n(),r.onerror=()=>i(r.error);const s=r.objectStore(bp);for(const t of e)s.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function Ep(e){try{const t=await kp(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const i of e){console.log("QueryEventsFromDB: Processing filter:",i);const e=await new Promise((e,n)=>{const r=t.transaction(bp,"readonly").objectStore(bp),s=[];let o;if(i.kinds&&i.kinds.length>0&&i.authors&&i.authors.length>0){const e=i.kinds[0],t=i.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=r.index("byKindAuthorCreated"),s=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);o=n.openCursor(s,"prev")}else if(i.kinds&&i.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${i.kinds[0]}`);const e=r.index("byKind");o=e.openCursor(IDBKeyRange.only(i.kinds[0]))}else if(i.authors&&i.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${i.authors[0].substring(0,8)}...`);const e=r.index("byAuthor");o=e.openCursor(IDBKeyRange.only(i.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),o=r.openCursor();o.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let r=!0;if(i.kinds&&i.kinds.length>0&&!i.kinds.includes(t.kind)&&(r=!1),i.authors&&i.authors.length>0&&!i.authors.includes(t.pubkey)&&(r=!1),i.since&&t.created_ati.until&&(r=!1),i.ids&&i.ids.length>0&&!i.ids.includes(t.id)&&(r=!1),r&&s.push(t),i.limit&&s.length>=i.limit)return console.log(`QueryEventsFromDB: Reached limit of ${i.limit}, found ${s.length} matching events`),void e(s);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${s.length} matching events`),e(s)},o.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",o.error),n(o.error)}});console.log(`QueryEventsFromDB: Found ${e.length} events for this filter`),n.push(...e)}return n.sort((e,t)=>t.created_at-e.created_at),console.log(`QueryEventsFromDB: Returning ${n.length} total events`),n}catch(e){return console.error("QueryEventsFromDB failed:",e),[]}}function xp(e){try{const t=JSON.parse(e.content||"{}");return{name:t.name||t.display_name||"",picture:t.picture||"",banner:t.banner||"",about:t.about||"",nip05:t.nip05||"",lud16:t.lud16||t.lud06||""}}catch(e){return{name:"",picture:"",banner:"",about:"",nip05:"",lud16:""}}}async function Sp(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await kp();return await new Promise((n,i)=>{const r=t.transaction(bp,"readonly").objectStore(bp).index("byKindAuthorCreated"),s=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),o=r.openCursor(s,"prev");o.onsuccess=()=>{const e=o.result;n(e?e.value:null)},o.onerror=()=>i(o.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return xp(t)}}catch(e){console.warn("Failed to load cached profile",e)}const t=[{kinds:[0],authors:[e],limit:1}];try{const n=await Qp(t,{timeout:1e4});if(n.length>0){const t=n[0];return console.log("Profile fetched from local relay:",t),Bp(t,e)}}catch(e){console.warn("Failed to fetch profile from local relay:",e)}console.log("Profile not found on local relay, trying fallback relays:",fp);try{const n=await async function(e,t){return new Promise(e=>{const n=[],i=setTimeout(()=>{r.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),e(n[0])):e(null)},5e3),r=vp.pool.subscribeMany(fp,t,{onevent(e){console.log("Profile event received from fallback relay:",e.id?.substring(0,8)),n.push(e)},oneose(){clearTimeout(i),r.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),e(n[0])):e(null)}})})}(0,t);if(n)return Bp(n,e)}catch(e){console.warn("Failed to fetch profile from fallback relays:",e)}return console.log("No profile found for pubkey:",e),null}async function Bp(e,t){await Ip(e);try{console.log("Publishing profile event to local relay:",e.id),await vp.publish(e),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const n=xp(e);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:t,profile:n,event:e}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return n}async function Qp(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",vp.relays),vp.isConnected&&0!==vp.relays.length||(console.warn("Client not connected, initializing..."),await $p());const{timeout:n=3e4,useCache:i=!0}=t;let r=[];if(i)try{r=await Ep(e),r.length>0&&console.log(`Found ${r.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,i)=>{const s=[],o=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${s.length} relay events`),sub.close(),s.length>0&&Cp(s).catch(e=>console.warn("Failed to cache events",e));const e=yp(r,s);t(e)},n);try{const n=Math.random().toString(36).substring(7);console.log(`📤 REQ [${n}]:`,JSON.stringify(["REQ",n,...e],null,2));const i=vp.pool.subscribeMany(vp.relays,e,{onevent(e){console.log(`📥 EVENT received for REQ [${n}]:`,{id:e.id?.substring(0,8)+"...",kind:e.kind,pubkey:e.pubkey?.substring(0,8)+"...",created_at:e.created_at,content_preview:e.content?.substring(0,50)}),s.push(e),Ip(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${s.length} relay events`),clearTimeout(o),i.close(),s.length>0&&Cp(s).catch(e=>console.warn("Failed to cache events",e));const e=yp(r,s);console.log(`Merged ${r.length} cached + ${s.length} relay = ${e.length} total events`),t(e)}})}catch(e){clearTimeout(o),console.error("Failed to fetch events:",e),i(e)}})}async function Fp(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const i=await Qp(t,{timeout:n});return console.log(`Fetched ${i.length} events`),i.length>0?i[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function Dp(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const i=await Qp(t,{timeout:n});return console.log(`Fetched ${i.length} delete events`),i}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function $p(){await vp.connect()}async function Pp(e,t={}){const{timeout:n=3e4,cacheFirst:i=!0,cacheOnly:r=!1}=t;let s=[];if(i||r)try{if(s=await Ep(e),console.log(`Found ${s.length} events in cache`),r||s.length>0)return s}catch(e){console.warn("Failed to query cache",e)}if(!r){const t=await Qp(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return s}async function Rp(){try{const e=await kp(),t=e.transaction(bp,"readonly").objectStore(bp),n=await new Promise((e,n)=>{const i=t.getAll();i.onsuccess=()=>e(i.result),i.onerror=()=>n(i.error)}),i=n.reduce((e,t)=>(e[t.kind]=(e[t.kind]||0)+1,e),{});return console.log("===== IndexedDB Contents ====="),console.log(`Total events: ${n.length}`),console.log("Events by kind:",i),console.log("Kind 0 events:",n.filter(e=>0===e.kind)),console.log("All event IDs:",n.map(e=>({id:e.id.substring(0,8),kind:e.kind,pubkey:e.pubkey.substring(0,8)}))),console.log("=============================="),{total:n.length,byKind:i,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}} +function Xf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ep(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function tp(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function np(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function ip(e){if(!Array.isArray(e))throw new Error("array expected")}function rp(e,t){if(!ep(!0,t))throw new Error(`${e}: array of strings expected`)}$f.BASE._setWindowSize(8);const sp=(e,t)=>0===t?e:sp(t,e%t),op=(e,t)=>e+(t-sp(e,t)),lp=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function ap(e,t,n,i){if(ip(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(op(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${op(t,n)}`);let r=0,s=0;const o=lp[t],l=lp[n]-1,a=[];for(const i of e){if(np(i),i>=o)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(r=r<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((r>>s-n&l)>>>0);const e=lp[s];if(void 0===e)throw new Error("invalid carry");r&=e-1}if(r=r<=t)throw new Error("Excess padding");if(!i&&r>0)throw new Error(`Non-zero padding: ${r}`);return i&&s>0&&a.push(r>>>0),a}const cp=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Xf(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}(e),e.toBase64()),decode:e=>((e,t)=>{tp("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,i=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:i,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(np(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(op(8,e)>32||op(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Xf(n))throw new Error("radix2.encode input should be Uint8Array");return ap(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!ep(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(ap(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;rp("alphabet",t);const i=new Map(t.map((e,t)=>[e,t]));return{encode:i=>(ip(i),i.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:t=>(ip(t),t.map(t=>{tp("alphabet.decode",t);const n=i.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return np(e),tp("padding",t),{encode(n){for(rp("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){rp("padding.decode",n);let i=n.length;if(i*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;i>0&&n[i-1]===t;i--){if((i-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,i)}}}(6),function(e=""){return tp("join",e),{encode:t=>(rp("join.decode",t),t.join(e)),decode:t=>(tp("join.decode",t),t.split(e))}}(""));function up(e){return $f.fromHex(e).toHex().substring(2)}const dp=new TextDecoder("utf-8"),fp=new TextEncoder;class pp{log=yd.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=gr;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!pp.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const i=ff();return this.lastCommand=i,this.sendCommand(e,t),setTimeout(()=>{i.reject(new Error("Device timeout")),this.lastCommand===i&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:i}){let r,s=await window.navigator.serial.requestPort();await s.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;s&&s.readable;){const e=new window.TextDecoderStream;s.readable.pipeTo(e.writable),r=e.readable.getReader();const t=this.readFromSerialPort(r);try{for(;;){const{value:e,done:n}=await t("\n");if(e){const{method:t,data:n}=this.parseResponse(e);if("/ping"===t&&this.log("Pong"),-1===pp.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(i&&i())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const o=new window.TextEncoderStream;o.readable.pipeTo(s.writable),this.writer=o.writable.getWriter(),await this.sendCommand(pp.METHOD_PING),await this.sendCommand(pp.METHOD_PING,[window.location.host]),e&&e(),s.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(i="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const r=[];for(t&&(r.push(t),t=void 0);;){const{value:s,done:o}=await e.read();if(s){const e=s.split(i);if(e.length>1)return r.push(e.shift()),t=e.pop(),n=e,{value:r.join("").trim(),done:!1};r.push(s)}if(o)return{value:r.join("").trim(),done:!0}}}}parseResponse(e){const t=e.split(" ")[0];return{method:t,data:e.substring(t.length).trim()}}async nip04Encrypt(e,t){const n=ju(await this.callMethodOnDevice(pp.METHOD_SHARED_SECRET,[up(e)]));let i=Uint8Array.from(function(e=32){if(Fu&&"function"==typeof Fu.getRandomValues)return Fu.getRandomValues(new Uint8Array(e));if(Fu&&"function"==typeof Fu.randomBytes)return Uint8Array.from(Fu.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),r=fp.encode(t),s=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),o=await crypto.subtle.encrypt({name:"AES-CBC",iv:i},s,r);return`${cp.encode(new Uint8Array(o))}?iv=${cp.encode(new Uint8Array(i.buffer))}`}async nip04Decrypt(e,t){let[n,i]=t.split("?iv=");const r=ju(await this.callMethodOnDevice(pp.METHOD_SHARED_SECRET,[up(e)]));let s=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["decrypt"]),o=cp.decode(n),l=cp.decode(i),a=await crypto.subtle.decrypt({name:"AES-CBC",iv:l},s,o);return dp.decode(a)}async getPublicKey(){const e=await this.callMethodOnDevice(pp.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(pp.METHOD_RESTORE,[Pu(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:ur({...e,pubkey:t})},i=await this.callMethodOnDevice(pp.METHOD_SIGN_MESSAGE,[n.id]),r={...n,sig:i,pubkey:t};if(!this.verifyEvent(r))throw new Error("Invalid signature");return r}ping(){this.sendCommand(pp.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[pp.METHOD_PUBLIC_KEY,pp.METHOD_SIGN_MESSAGE,pp.METHOD_SHARED_SECRET,pp.METHOD_RESTORE]}const hp=[];function gp(t,n=e){let i;const r=new Set;function o(e){if(s(t,e)&&(t=e,i)){const e=!hp.length;for(const e of r)e[1](),hp.push(e,t);if(e){for(let e=0;e{r.delete(a),0===r.size&&i&&(i(),i=null)}}}}const mp=gp(localStorage.getItem("relayUrl")||""),vp=gp(!1),yp=gp(null),wp=gp("disconnected"),bp=gp(!0),Ap=localStorage.getItem("savedRelays"),kp=gp(Ap?JSON.parse(Ap):[]);mp.subscribe(e=>{e?localStorage.setItem("relayUrl",e):localStorage.removeItem("relayUrl")}),kp.subscribe(e=>{localStorage.setItem("savedRelays",JSON.stringify(e))});function Ip(e,t){kp.update(n=>{const i=n.findIndex(t=>t.url===e),r={url:e,name:t,lastConnected:Date.now()};return i>=0?n[i]=r:n.unshift(r),n})}!function(t,n,s){const o=!Array.isArray(t),l=o?[t]:t,c=n.length<2;return u=t=>{let s=!1;const u=[];let d=0,f=e;const p=()=>{if(d)return;f();const i=n(o?u[0]:u,t);c?t(i):f=r(i)?i:e},h=l.map((e,t)=>a(e,e=>{u[t]=e,d&=~(1<{d|=1<t||e),gp(localStorage.getItem("selectedTab")||"export");const Cp="undefined"!=typeof process&&process.env&&!1,Ep=("undefined"!=typeof process&&process.env,"");function xp(){const e=c(mp);return e?$p(e):window.location.origin}function Sp(){const e=c(mp);if(e)return Dp(e);return`${"https:"===window.location.protocol?"wss:":"ws:"}//${window.location.host}/`}function Bp(e){const t=e?$p(e):"";mp.set(t),t&&vp.set(!0)}async function Qp(e){const t=e?$p(e):xp();try{wp.set("connecting");const e=await fetch(t,{headers:{Accept:"application/nostr+json"}});if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);const n=await e.json();if(!n.name&&!n.supported_nips)throw new Error("Invalid relay info response");return yp.set(n),wp.set("connected"),n}catch(e){return console.error("[config] Failed to fetch relay info:",e),wp.set("error"),yp.set(null),null}}async function Fp(e){if(console.log("[config] connectToRelay called with:",e),!e)return{success:!1,error:"URL is required"};const t=$p(e);console.log("[config] Normalized HTTP URL:",t);const n=await Qp(t);if(console.log("[config] fetchRelayInfoFromUrl returned:",n?"success":"null"),n)return Bp(t),{success:!0,info:n};console.log("[config] NIP-11 failed, trying WebSocket connection test");const i=Dp(e);console.log("[config] Normalized WS URL:",i);const r=await async function(e){return console.log("[config] Testing WebSocket connection to:",e),new Promise(t=>{let n=!1,i=null;const r=e=>{n||(n=!0,console.log("[config] WebSocket test result:",e),t(e))},s=setTimeout(()=>{console.log("[config] WebSocket connection timed out"),i&&i.close(),r({success:!1,error:"Connection timed out"})},5e3);try{i=new WebSocket(e),i.onopen=()=>{console.log("[config] WebSocket connected successfully"),clearTimeout(s),i.close(),r({success:!0})},i.onerror=e=>{console.log("[config] WebSocket error:",e),clearTimeout(s),r({success:!1,error:"WebSocket connection failed"})},i.onclose=e=>{console.log("[config] WebSocket closed:",e.code,e.reason),clearTimeout(s),1e3===e.code||n||r({success:!1,error:`Connection closed: ${e.reason||"code "+e.code}`})}}catch(e){console.error("[config] WebSocket creation error:",e),clearTimeout(s),r({success:!1,error:e.message||"Failed to create WebSocket"})}})}(i);if(console.log("[config] WebSocket test complete:",r),r.success){Bp(t),wp.set("connected");const e={name:i};return yp.set(e),{success:!0,info:e}}return{success:!1,error:r.error||"Could not connect to relay"}}function $p(e){let t=e.trim();return t.startsWith("wss://")?t="https://"+t.slice(6):t.startsWith("ws://")&&(t="http://"+t.slice(5)),t.startsWith("http://")||t.startsWith("https://")||(t="https://"+t),t.replace(/\/$/,"")}function Dp(e){let t=e.trim();return t.startsWith("https://")?t="wss://"+t.slice(8):t.startsWith("http://")&&(t="ws://"+t.slice(7)),t.startsWith("ws://")||t.startsWith("wss://")||(t="wss://"+t),t.endsWith("/")||(t+="/"),t}function Rp(){return[Sp()]}window.location.protocol.startsWith("https");const Pp=["wss://relay.damus.io","wss://nos.lol","wss://relay.nostr.band","wss://purplepag.es"],Tp=[{value:0,label:"User Metadata (0)"},{value:3,label:"Follows (3)"},{value:1e4,label:"Mute list (10000)"},{value:10001,label:"Pin list (10001)"},{value:10002,label:"Relay List Metadata (10002)"},{value:10003,label:"Bookmark list (10003)"},{value:10004,label:"Communities list (10004)"},{value:10005,label:"Public chats list (10005)"},{value:10006,label:"Blocked relays list (10006)"},{value:10007,label:"Search relays list (10007)"},{value:10009,label:"User groups (10009)"},{value:10012,label:"Favorite relays list (10012)"},{value:10013,label:"Private event relay list (10013)"},{value:10015,label:"Interests list (10015)"},{value:10019,label:"Nutzap Mint Recommendation (10019)"},{value:10020,label:"Media follows (10020)"},{value:10030,label:"User emoji list (10030)"},{value:10050,label:"Relay list to receive DMs (10050)"},{value:10051,label:"KeyPackage Relays List (10051)"},{value:10063,label:"User server list (10063)"},{value:10096,label:"File storage server list (10096)"},{value:10166,label:"Relay Monitor Announcement (10166)"},{value:10312,label:"Room Presence (10312)"},{value:10377,label:"Proxy Announcement (10377)"},{value:11111,label:"Transport Method Announcement (11111)"},{value:13194,label:"Wallet Info (13194)"},{value:17375,label:"Cashu Wallet Event (17375)"},{value:3e4,label:"Follow sets (30000)"},{value:30001,label:"Generic lists (30001)"},{value:30002,label:"Relay sets (30002)"},{value:30003,label:"Bookmark sets (30003)"},{value:30004,label:"Curation sets (30004)"},{value:30005,label:"Video sets (30005)"},{value:30007,label:"Kind mute sets (30007)"},{value:30008,label:"Profile Badges (30008)"},{value:30009,label:"Badge Definition (30009)"},{value:30015,label:"Interest sets (30015)"},{value:30017,label:"Create or update a stall (30017)"},{value:30018,label:"Create or update a product (30018)"},{value:30019,label:"Marketplace UI/UX (30019)"},{value:30020,label:"Product sold as an auction (30020)"},{value:30023,label:"Long-form Content (30023)"},{value:30024,label:"Draft Long-form Content (30024)"},{value:30030,label:"Emoji sets (30030)"},{value:30040,label:"Curated Publication Index (30040)"},{value:30041,label:"Curated Publication Content (30041)"},{value:30063,label:"Release artifact sets (30063)"},{value:30078,label:"Application-specific Data (30078)"},{value:30166,label:"Relay Discovery (30166)"},{value:30267,label:"App curation sets (30267)"},{value:30311,label:"Live Event (30311)"},{value:30312,label:"Interactive Room (30312)"},{value:30313,label:"Conference Event (30313)"},{value:30315,label:"User Statuses (30315)"},{value:30388,label:"Slide Set (30388)"},{value:30402,label:"Classified Listing (30402)"},{value:30403,label:"Draft Classified Listing (30403)"},{value:30617,label:"Repository announcements (30617)"},{value:30618,label:"Repository state announcements (30618)"},{value:30818,label:"Wiki article (30818)"},{value:30819,label:"Redirects (30819)"},{value:31234,label:"Draft Event (31234)"},{value:31388,label:"Link Set (31388)"},{value:31890,label:"Feed (31890)"},{value:31922,label:"Date-Based Calendar Event (31922)"},{value:31923,label:"Time-Based Calendar Event (31923)"},{value:31924,label:"Calendar (31924)"},{value:31925,label:"Calendar Event RSVP (31925)"},{value:31989,label:"Handler recommendation (31989)"},{value:31990,label:"Handler information (31990)"},{value:32267,label:"Software Application (32267)"},{value:34550,label:"Community Definition (34550)"},{value:37516,label:"Geocache listing (37516)"},{value:38172,label:"Cashu Mint Announcement (38172)"},{value:38173,label:"Fedimint Announcement (38173)"},{value:38383,label:"Peer-to-peer Order events (38383)"},{value:39089,label:"Starter packs (39089)"},{value:39092,label:"Media starter packs (39092)"},{value:39701,label:"Web bookmarks (39701)"}],Up={0:"User Metadata",1:"Short Text Note",2:"Recommend Relay",3:"Follows",4:"Encrypted Direct Messages",5:"Event Deletion Request",6:"Repost",7:"Reaction",8:"Badge Award",9:"Chat Message",10:"Group Chat Threaded Reply",11:"Thread",12:"Group Thread Reply",13:"Seal",14:"Direct Message",15:"File Message",16:"Generic Repost",17:"Reaction to a website",20:"Picture",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1021:"Bid",1022:"Bid Confirmation",1040:"OpenTimestamps",1063:"File Metadata",1311:"Live Chat Message",1971:"Problem Tracker",1984:"Reporting",1985:"Label",4550:"Community Post Approval",5e3:"Job Request",5999:"Job Request",6e3:"Job Result",6999:"Job Result",7e3:"Job Feedback",9041:"Zap Goal",9734:"Zap Request",9735:"Zap",9882:"Highlights",1e4:"Mute list",10001:"Pin list",10002:"Relay List Metadata",10003:"Bookmarks list",10004:"Communities list",10005:"Public Chats list",10006:"Blocked Relays list",10007:"Search Relays list",10015:"Interests",10030:"User Emoji list",10050:"DM relays",10096:"File Storage Server List",13194:"Wallet Service Info",21e3:"Lightning pub RPC",22242:"Client Authentication",23194:"Wallet Request",23195:"Wallet Response",23196:"Wallet Notification",23197:"Wallet Notification",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Follow sets",30001:"Generic lists",30002:"Relay sets",30003:"Bookmark sets",30004:"Curation sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest sets",30017:"Stall Definition",30018:"Product Definition",30019:"Marketplace UI/UX",30020:"Product sold as an auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34235:"Video Event Horizontal",34236:"Video Event Vertical",34550:"Community Definition"},Np=3e5;let _p=null;function Lp(){return _p||(_p=new _n),_p}class Mp{constructor(){this.pool=new _n,this.eventStore=new df,this.isConnected=!1,this.signer=null,this.relays=[...Rp()]}refreshRelays(){const e=Rp();JSON.stringify(this.relays)!==JSON.stringify(e)&&(console.log("Relay list updated:",e),this.relays=[...e])}reset(){if(console.log("[NostrClient] Resetting for new relay..."),this.pool){try{this.pool.close(this.relays)}catch(e){console.warn("[NostrClient] Error closing old relay connections:",e)}this.pool=null}this.pool=new _n,this.isConnected=!1,this.relays=[...Rp()],console.log("[NostrClient] Reset complete, new relays:",this.relays)}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());try{const n=t||this.relays,i=this.pool.publish(n,e);return await Promise.allSettled(i),console.log("✓ Event published successfully"),await Vp([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const Op=new Mp;function jp(e,t){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of t){const t=n.get(e.id);(!t||e.created_at>=t.created_at)&&n.set(e.id,e)}return Array.from(n.values()).sort((e,t)=>t.created_at-e.created_at)}const Hp="nostrCache",Gp=2,qp="events";function Jp(){return new Promise((e,t)=>{try{const n=indexedDB.open(Hp,Gp);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let i;i=t.objectStoreNames.contains(qp)?n.transaction.objectStore(qp):t.createObjectStore(qp,{keyPath:"id"}),i.indexNames.contains("byKindAuthor")||i.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),i.indexNames.contains("byKindAuthorCreated")||i.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),i.indexNames.contains("byKind")||i.createIndex("byKind","kind",{unique:!1}),i.indexNames.contains("byAuthor")||i.createIndex("byAuthor","pubkey",{unique:!1}),i.indexNames.contains("byCreatedAt")||i.createIndex("byCreatedAt","created_at",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){console.error("Failed to open IndexedDB",e),t(e)}})}async function Kp(e){try{const t=await Jp();await new Promise((n,i)=>{const r=t.transaction(qp,"readwrite");r.oncomplete=()=>n(),r.onerror=()=>i(r.error),r.objectStore(qp).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function Vp(e){if(e&&0!==e.length)try{const t=await Jp();await new Promise((n,i)=>{const r=t.transaction(qp,"readwrite");r.oncomplete=()=>n(),r.onerror=()=>i(r.error);const s=r.objectStore(qp);for(const t of e)s.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function Yp(e){try{const t=await Jp(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const i of e){console.log("QueryEventsFromDB: Processing filter:",i);const e=await new Promise((e,n)=>{const r=t.transaction(qp,"readonly").objectStore(qp),s=[];let o;if(i.kinds&&i.kinds.length>0&&i.authors&&i.authors.length>0){const e=i.kinds[0],t=i.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=r.index("byKindAuthorCreated"),s=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);o=n.openCursor(s,"prev")}else if(i.kinds&&i.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${i.kinds[0]}`);const e=r.index("byKind");o=e.openCursor(IDBKeyRange.only(i.kinds[0]))}else if(i.authors&&i.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${i.authors[0].substring(0,8)}...`);const e=r.index("byAuthor");o=e.openCursor(IDBKeyRange.only(i.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),o=r.openCursor();o.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let r=!0;if(i.kinds&&i.kinds.length>0&&!i.kinds.includes(t.kind)&&(r=!1),i.authors&&i.authors.length>0&&!i.authors.includes(t.pubkey)&&(r=!1),i.since&&t.created_ati.until&&(r=!1),i.ids&&i.ids.length>0&&!i.ids.includes(t.id)&&(r=!1),r&&s.push(t),i.limit&&s.length>=i.limit)return console.log(`QueryEventsFromDB: Reached limit of ${i.limit}, found ${s.length} matching events`),void e(s);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${s.length} matching events`),e(s)},o.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",o.error),n(o.error)}});console.log(`QueryEventsFromDB: Found ${e.length} events for this filter`),n.push(...e)}return n.sort((e,t)=>t.created_at-e.created_at),console.log(`QueryEventsFromDB: Returning ${n.length} total events`),n}catch(e){return console.error("QueryEventsFromDB failed:",e),[]}}function zp(e){try{const t=JSON.parse(e.content||"{}");return{name:t.name||t.display_name||"",picture:t.picture||"",banner:t.banner||"",about:t.about||"",nip05:t.nip05||"",lud16:t.lud16||t.lud06||""}}catch(e){return{name:"",picture:"",banner:"",about:"",nip05:"",lud16:""}}}async function Wp(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await Jp();return await new Promise((n,i)=>{const r=t.transaction(qp,"readonly").objectStore(qp).index("byKindAuthorCreated"),s=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),o=r.openCursor(s,"prev");o.onsuccess=()=>{const e=o.result;n(e?e.value:null)},o.onerror=()=>i(o.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return zp(t)}}catch(e){console.warn("Failed to load cached profile",e)}const t=[{kinds:[0],authors:[e],limit:1}];try{const n=await nh(t,{timeout:1e4});if(n.length>0){const t=n[0];return console.log("Profile fetched from local relay:",t),Zp(t,e)}}catch(e){console.warn("Failed to fetch profile from local relay:",e)}console.log("Profile not found on local relay, trying fallback relays:",Pp);try{const n=await async function(e,t){return new Promise(e=>{const n=[],i=Lp();let r;const s=setTimeout(()=>{r&&r.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),e(n[0])):e(null)},5e3);r=i.subscribeMany(Pp,t,{onevent(e){console.log("Profile event received from fallback relay:",e.id?.substring(0,8)),n.push(e)},oneose(){clearTimeout(s),r&&r.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),e(n[0])):e(null)}})})}(0,t);if(n)return Zp(n,e)}catch(e){console.warn("Failed to fetch profile from fallback relays:",e)}return console.log("No profile found for pubkey:",e),null}async function Zp(e,t){await Kp(e);try{console.log("Publishing profile event to local relay:",e.id),await Op.publish(e),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const n=zp(e);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:t,profile:n,event:e}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return n}function Xp(e){if(!e||10002!==e.kind)return null;const t={read:[],write:[],all:[]};for(const n of e.tags)if("r"===n[0]&&n[1]){const e=n[1],i=n[2];"read"===i?t.read.push(e):("write"===i||t.read.push(e),t.write.push(e)),t.all.push({url:e,read:"write"!==i,write:"read"!==i})}return console.log(`[nostr] Parsed relay list: ${t.all.length} relays`),t}async function eh(e){return new Promise(t=>{const n=[],i=Lp();let r;const s=setTimeout(()=>{r&&r.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),t(n[0])):t(null)},5e3);r=i.subscribeMany(Pp,e,{onevent(e){n.push(e)},oneose(){clearTimeout(s),r&&r.close(),n.length>0?(n.sort((e,t)=>t.created_at-e.created_at),t(n[0])):t(null)}})})}function th(e){if(!e||3!==e.kind)return null;const t=[],n={};for(const i of e.tags)if("p"===i[0]&&i[1]){const e=i[1],r=i[2]||null,s=i[3]||null;t.push({pubkey:e,relayUrl:r,petname:s}),r&&(n[r]||(n[r]=[]),n[r].push(e))}let i={};try{e.content&&(i=JSON.parse(e.content))}catch(e){}return console.log(`[nostr] Parsed contact list: ${t.length} follows, ${Object.keys(n).length} relay hints`),{follows:t,relayHints:n,legacyRelays:i,event:e}}async function nh(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",Op.relays),Op.isConnected&&0!==Op.relays.length||(console.warn("Client not connected, initializing..."),await sh());const{timeout:n=3e4,useCache:i=!0}=t;let r=[];if(i)try{r=await Yp(e),r.length>0&&console.log(`Found ${r.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,i)=>{const s=[];let o=null;const l=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${s.length} relay events`),o&&o.close(),s.length>0&&Vp(s).catch(e=>console.warn("Failed to cache events",e));const e=jp(r,s);t(e)},n);try{const n=Math.random().toString(36).substring(7);if(!Array.isArray(e)||0===e.length)return console.error("❌ Invalid filters: not an array or empty",e),void t(r);const i=e.filter(e=>e&&"object"==typeof e&&!Array.isArray(e));if(i.length!==e.length&&console.warn(`⚠️ Some filters were invalid, filtered ${e.length} -> ${i.length}`,e),0===i.length)return console.error("❌ No valid filters remaining"),void t(r);console.log(`📤 REQ [${n}] to ${Op.relays.join(", ")}:`,JSON.stringify(["REQ",n,...i],null,2)),o=Op.pool.subscribeMany(Op.relays,i,{onevent(e){console.log(`📥 EVENT received for REQ [${n}]:`,{id:e.id?.substring(0,8)+"...",kind:e.kind,pubkey:e.pubkey?.substring(0,8)+"...",created_at:e.created_at,content_preview:e.content?.substring(0,50)}),s.push(e),Kp(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${s.length} relay events`),clearTimeout(l),o&&o.close(),s.length>0&&Vp(s).catch(e=>console.warn("Failed to cache events",e));const e=jp(r,s);console.log(`Merged ${r.length} cached + ${s.length} relay = ${e.length} total events`),t(e)}})}catch(e){clearTimeout(l),console.error("Failed to fetch events:",e),i(e)}})}async function ih(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const i=await nh(t,{timeout:n});return console.log(`Fetched ${i.length} events`),i.length>0?i[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function rh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const i=await nh(t,{timeout:n});return console.log(`Fetched ${i.length} delete events`),i}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function sh(){await Op.connect()}async function oh(e,t={}){const{timeout:n=3e4,cacheFirst:i=!0,cacheOnly:r=!1}=t;let s=[];if(i||r)try{if(s=await Yp(e),console.log(`Found ${s.length} events in cache`),r||s.length>0)return s}catch(e){console.warn("Failed to query cache",e)}if(!r){const t=await nh(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return s}async function lh(){try{const e=await Jp(),t=e.transaction(qp,"readonly").objectStore(qp),n=await new Promise((e,n)=>{const i=t.getAll();i.onsuccess=()=>e(i.result),i.onerror=()=>n(i.error)}),i=n.reduce((e,t)=>(e[t.kind]=(e[t.kind]||0)+1,e),{});return console.log("===== IndexedDB Contents ====="),console.log(`Total events: ${n.length}`),console.log("Events by kind:",i),console.log("Kind 0 events:",n.filter(e=>0===e.kind)),console.log("All event IDs:",n.map(e=>({id:e.id.substring(0,8),kind:e.kind,pubkey:e.pubkey.substring(0,8)}))),console.log("=============================="),{total:n.length,byKind:i,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}} /*! * hash-wasm (https://www.npmjs.com/package/hash-wasm) * (c) Dani Biro * @license MIT - */function Tp(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function l(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,l)}a((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class Up{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 Tp(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}var _p;const Np="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Lp=null!==(_p=Np.Buffer)&&void 0!==_p?_p:null,Op=Np.TextEncoder?new Np.TextEncoder:null;function Mp(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function jp(e,t){const n=t.length>>1;for(let i=0;i>>4;e[i++]=n>9?n+Hp:n+Gp,n=15&t[r],e[i++]=n>9?n+Hp:n+Gp}return String.fromCharCode.apply(null,e)}const Kp=null!==Lp?e=>{if("string"==typeof e){const t=Lp.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(Lp.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 Op.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},Vp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qp=new Uint8Array(256);for(let e=0;e<64;e++)qp[Vp.charCodeAt(e)]=e;function Yp(e,t=!0){const n=e.length,i=n%3,r=[],s=n-i;for(let t=0;t>18&63)+Vp.charAt(n>>12&63)+Vp.charAt(n>>6&63)+Vp.charAt(63&n);r.push(i)}if(1===i){const i=e[n-1],s=Vp.charAt(i>>2),o=Vp.charAt(i<<4&63);r.push(`${s}${o}`),t&&r.push("==")}else if(2===i){const i=(e[n-2]<<8)+e[n-1],s=Vp.charAt(i>>10),o=Vp.charAt(i>>4&63),l=Vp.charAt(i<<2&63);r.push(`${s}${o}${l}`),t&&r.push("=")}return r.join("")}function Wp(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,i=new Uint8Array(t);let r=0;for(let t=0;t>4,r+=1,i[r]=(15&s)<<4|o>>2,r+=1,i[r]=(3&o)<<6|63&l,r+=1}return i}const zp=16384,Zp=new Up,Xp=new Map;function eh(e,t){return Tp(this,void 0,void 0,function*(){let n=null,i=null,r=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const s=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),o=Zp.dispatch(()=>Tp(this,void 0,void 0,function*(){if(!Xp.has(e.name)){const t=Wp(e.data),n=WebAssembly.compile(t);Xp.set(e.name,n)}const t=yield Xp.get(e.name);n=yield WebAssembly.instantiate(t,{})})),l=(e=null)=>{r=!0,n.exports.Hash_Init(e)},a=e=>{if(!r)throw new Error("update() called before init()");(e=>{let t=0;for(;t{if(!r)throw new Error("digest() called before init()");return r=!1,n.exports.Hash_Final(s),"binary"===e?i.slice(0,t):Jp(c,i,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength!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(()=>Tp(this,void 0,void 0,function*(){n||(yield o);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;i=new Uint8Array(t,e,zp)}))(),{getMemory:()=>i,writeMemory:(e,t=0)=>{i.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),r=n.exports.memory.buffer;i=new Uint8Array(r,t,e)},init:l,update:a,digest:u,save:()=>{if(!r)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),i=s(),o=n.exports.memory.buffer,l=new Uint8Array(o,t,i),a=new Uint8Array(4+i);return jp(a,e.hash),a.set(l,4),a},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const i=n.exports.Hash_GetState(),o=s(),l=4+o,a=n.exports.memory.buffer;if(t.length!==l)throw new Error(`Bad state length (expected ${l} bytes, got ${t.length})`);if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n{if(!f(e,r))return l(r),a(e),u("hex",s);const o=Kp(e);return i.set(o),n.exports.Hash_Calculate(o.length,r,s),Jp(c,i,t)},hashLength:t}})}new Up;var th={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"},nh={name:"blake2b",data:"AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX8AYAAAAwoJAAECAwECAgABBQQBAQICBg4CfwFBsIsFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACkhhc2hfRmluYWwAAwlIYXNoX0luaXQABQtIYXNoX1VwZGF0ZQAGDUhhc2hfR2V0U3RhdGUABw5IYXNoX0NhbGN1bGF0ZQAIClNUQVRFX1NJWkUDAQrTOAkFAEGACQvrAgIFfwF+AkAgAUEBSA0AAkACQAJAIAFBgAFBACgC4IoBIgJrIgNKDQAgASEEDAELQQBBADYC4IoBAkAgAkH/AEoNACACQeCJAWohBSAAIQRBACEGA0AgBSAELQAAOgAAIARBAWohBCAFQQFqIQUgAyAGQQFqIgZB/wFxSg0ACwtBAEEAKQPAiQEiB0KAAXw3A8CJAUEAQQApA8iJASAHQv9+Vq18NwPIiQFB4IkBEAIgACADaiEAAkAgASADayIEQYEBSA0AIAIgAWohBQNAQQBBACkDwIkBIgdCgAF8NwPAiQFBAEEAKQPIiQEgB0L/flatfDcDyIkBIAAQAiAAQYABaiEAIAVBgH9qIgVBgAJLDQALIAVBgH9qIQQMAQsgBEEATA0BC0EAIQUDQCAFQQAoAuCKAWpB4IkBaiAAIAVqLQAAOgAAIAQgBUEBaiIFQf8BcUoNAAsLQQBBACgC4IoBIARqNgLgigELC78uASR+QQBBACkD0IkBQQApA7CJASIBQQApA5CJAXwgACkDICICfCIDhULr+obav7X2wR+FQiCJIgRCq/DT9K/uvLc8fCIFIAGFQiiJIgYgA3wgACkDKCIBfCIHIASFQjCJIgggBXwiCSAGhUIBiSIKQQApA8iJAUEAKQOoiQEiBEEAKQOIiQF8IAApAxAiA3wiBYVCn9j52cKR2oKbf4VCIIkiC0K7zqqm2NDrs7t/fCIMIASFQiiJIg0gBXwgACkDGCIEfCIOfCAAKQNQIgV8Ig9BACkDwIkBQQApA6CJASIQQQApA4CJASIRfCAAKQMAIgZ8IhKFQtGFmu/6z5SH0QCFQiCJIhNCiJLznf/M+YTqAHwiFCAQhUIoiSIVIBJ8IAApAwgiEHwiFiAThUIwiSIXhUIgiSIYQQApA9iJAUEAKQO4iQEiE0EAKQOYiQF8IAApAzAiEnwiGYVC+cL4m5Gjs/DbAIVCIIkiGkLx7fT4paf9p6V/fCIbIBOFQiiJIhwgGXwgACkDOCITfCIZIBqFQjCJIhogG3wiG3wiHSAKhUIoiSIeIA98IAApA1giCnwiDyAYhUIwiSIYIB18Ih0gDiALhUIwiSIOIAx8Ih8gDYVCAYkiDCAWfCAAKQNAIgt8Ig0gGoVCIIkiFiAJfCIaIAyFQiiJIiAgDXwgACkDSCIJfCIhIBaFQjCJIhYgGyAchUIBiSIMIAd8IAApA2AiB3wiDSAOhUIgiSIOIBcgFHwiFHwiFyAMhUIoiSIbIA18IAApA2giDHwiHCAOhUIwiSIOIBd8IhcgG4VCAYkiGyAZIBQgFYVCAYkiFHwgACkDcCINfCIVIAiFQiCJIhkgH3wiHyAUhUIoiSIUIBV8IAApA3giCHwiFXwgDHwiIoVCIIkiI3wiJCAbhUIoiSIbICJ8IBJ8IiIgFyAYIBUgGYVCMIkiFSAffCIZIBSFQgGJIhQgIXwgDXwiH4VCIIkiGHwiFyAUhUIoiSIUIB98IAV8Ih8gGIVCMIkiGCAXfCIXIBSFQgGJIhR8IAF8IiEgFiAafCIWIBUgHSAehUIBiSIaIBx8IAl8IhyFQiCJIhV8Ih0gGoVCKIkiGiAcfCAIfCIcIBWFQjCJIhWFQiCJIh4gGSAOIBYgIIVCAYkiFiAPfCACfCIPhUIgiSIOfCIZIBaFQiiJIhYgD3wgC3wiDyAOhUIwiSIOIBl8Ihl8IiAgFIVCKIkiFCAhfCAEfCIhIB6FQjCJIh4gIHwiICAiICOFQjCJIiIgJHwiIyAbhUIBiSIbIBx8IAp8IhwgDoVCIIkiDiAXfCIXIBuFQiiJIhsgHHwgE3wiHCAOhUIwiSIOIBkgFoVCAYkiFiAffCAQfCIZICKFQiCJIh8gFSAdfCIVfCIdIBaFQiiJIhYgGXwgB3wiGSAfhUIwiSIfIB18Ih0gFoVCAYkiFiAVIBqFQgGJIhUgD3wgBnwiDyAYhUIgiSIYICN8IhogFYVCKIkiFSAPfCADfCIPfCAHfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBnwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAOIBd8Ig4gDyAYhUIwiSIPICAgFIVCAYkiFCAZfCAKfCIXhUIgiSIYfCIZIBSFQiiJIhQgF3wgC3wiF3wgBXwiICAPIBp8Ig8gHyAOIBuFQgGJIg4gIXwgCHwiGoVCIIkiG3wiHyAOhUIoiSIOIBp8IAx8IhogG4VCMIkiG4VCIIkiISAdIB4gDyAVhUIBiSIPIBx8IAF8IhWFQiCJIhx8Ih0gD4VCKIkiDyAVfCADfCIVIByFQjCJIhwgHXwiHXwiHiAWhUIoiSIWICB8IA18IiAgIYVCMIkiISAefCIeIBogFyAYhUIwiSIXIBl8IhggFIVCAYkiFHwgCXwiGSAchUIgiSIaICR8IhwgFIVCKIkiFCAZfCACfCIZIBqFQjCJIhogHSAPhUIBiSIPICJ8IAR8Ih0gF4VCIIkiFyAbIB98Iht8Ih8gD4VCKIkiDyAdfCASfCIdIBeFQjCJIhcgH3wiHyAPhUIBiSIPIBsgDoVCAYkiDiAVfCATfCIVICOFQiCJIhsgGHwiGCAOhUIoiSIOIBV8IBB8IhV8IAx8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAHfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBogHHwiGiAVIBuFQjCJIhUgHiAWhUIBiSIWIB18IAR8IhuFQiCJIhx8Ih0gFoVCKIkiFiAbfCAQfCIbfCABfCIeIBUgGHwiFSAXIBogFIVCAYkiFCAgfCATfCIYhUIgiSIXfCIaIBSFQiiJIhQgGHwgCXwiGCAXhUIwiSIXhUIgiSIgIB8gISAVIA6FQgGJIg4gGXwgCnwiFYVCIIkiGXwiHyAOhUIoiSIOIBV8IA18IhUgGYVCMIkiGSAffCIffCIhIA+FQiiJIg8gHnwgBXwiHiAghUIwiSIgICF8IiEgGyAchUIwiSIbIB18IhwgFoVCAYkiFiAYfCADfCIYIBmFQiCJIhkgJHwiHSAWhUIoiSIWIBh8IBJ8IhggGYVCMIkiGSAfIA6FQgGJIg4gInwgAnwiHyAbhUIgiSIbIBcgGnwiF3wiGiAOhUIoiSIOIB98IAZ8Ih8gG4VCMIkiGyAafCIaIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAh8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgC3wiFXwgBXwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAh8IiIgGiAgIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGHwgCXwiGIVCIIkiHHwiGiAUhUIoiSIUIBh8IAZ8IhggHIVCMIkiHCAafCIaIBSFQgGJIhR8IAR8IiAgGSAdfCIZIBUgISAPhUIBiSIPIB98IAN8Ih2FQiCJIhV8Ih8gD4VCKIkiDyAdfCACfCIdIBWFQjCJIhWFQiCJIiEgFyAbIBkgFoVCAYkiFiAefCABfCIZhUIgiSIbfCIXIBaFQiiJIhYgGXwgE3wiGSAbhUIwiSIbIBd8Ihd8Ih4gFIVCKIkiFCAgfCAMfCIgICGFQjCJIiEgHnwiHiAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IBJ8Ih0gG4VCIIkiGyAafCIaIA6FQiiJIg4gHXwgC3wiHSAbhUIwiSIbIBcgFoVCAYkiFiAYfCANfCIXICKFQiCJIhggFSAffCIVfCIfIBaFQiiJIhYgF3wgEHwiFyAYhUIwiSIYIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGXwgCnwiFSAchUIgiSIZICN8IhwgD4VCKIkiDyAVfCAHfCIVfCASfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAbIBp8IhogFSAZhUIwiSIVIB4gFIVCAYkiFCAXfCADfCIXhUIgiSIZfCIbIBSFQiiJIhQgF3wgB3wiF3wgAnwiHiAVIBx8IhUgGCAaIA6FQgGJIg4gIHwgC3wiGoVCIIkiGHwiHCAOhUIoiSIOIBp8IAR8IhogGIVCMIkiGIVCIIkiICAfICEgFSAPhUIBiSIPIB18IAZ8IhWFQiCJIh18Ih8gD4VCKIkiDyAVfCAKfCIVIB2FQjCJIh0gH3wiH3wiISAWhUIoiSIWIB58IAx8Ih4gIIVCMIkiICAhfCIhIBogFyAZhUIwiSIXIBt8IhkgFIVCAYkiFHwgEHwiGiAdhUIgiSIbICR8Ih0gFIVCKIkiFCAafCAJfCIaIBuFQjCJIhsgHyAPhUIBiSIPICJ8IBN8Ih8gF4VCIIkiFyAYIBx8Ihh8IhwgD4VCKIkiDyAffCABfCIfIBeFQjCJIhcgHHwiHCAPhUIBiSIPIBggDoVCAYkiDiAVfCAIfCIVICOFQiCJIhggGXwiGSAOhUIoiSIOIBV8IA18IhV8IA18IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAMfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHXwiGyAVIBiFQjCJIhUgISAWhUIBiSIWIB98IBB8IhiFQiCJIh18Ih8gFoVCKIkiFiAYfCAIfCIYfCASfCIhIBUgGXwiFSAXIBsgFIVCAYkiFCAefCAHfCIZhUIgiSIXfCIbIBSFQiiJIhQgGXwgAXwiGSAXhUIwiSIXhUIgiSIeIBwgICAVIA6FQgGJIg4gGnwgAnwiFYVCIIkiGnwiHCAOhUIoiSIOIBV8IAV8IhUgGoVCMIkiGiAcfCIcfCIgIA+FQiiJIg8gIXwgBHwiISAehUIwiSIeICB8IiAgGCAdhUIwiSIYIB98Ih0gFoVCAYkiFiAZfCAGfCIZIBqFQiCJIhogJHwiHyAWhUIoiSIWIBl8IBN8IhkgGoVCMIkiGiAcIA6FQgGJIg4gInwgCXwiHCAYhUIgiSIYIBcgG3wiF3wiGyAOhUIoiSIOIBx8IAN8IhwgGIVCMIkiGCAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAt8IhUgI4VCIIkiFyAdfCIdIBSFQiiJIhQgFXwgCnwiFXwgBHwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAl8IiIgGyAeIBUgF4VCMIkiFSAdfCIXIBSFQgGJIhQgGXwgDHwiGYVCIIkiHXwiGyAUhUIoiSIUIBl8IAp8IhkgHYVCMIkiHSAbfCIbIBSFQgGJIhR8IAN8Ih4gGiAffCIaIBUgICAPhUIBiSIPIBx8IAd8IhyFQiCJIhV8Ih8gD4VCKIkiDyAcfCAQfCIcIBWFQjCJIhWFQiCJIiAgFyAYIBogFoVCAYkiFiAhfCATfCIahUIgiSIYfCIXIBaFQiiJIhYgGnwgDXwiGiAYhUIwiSIYIBd8Ihd8IiEgFIVCKIkiFCAefCAFfCIeICCFQjCJIiAgIXwiISAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIBx8IAt8IhwgGIVCIIkiGCAbfCIbIA6FQiiJIg4gHHwgEnwiHCAYhUIwiSIYIBcgFoVCAYkiFiAZfCABfCIXICKFQiCJIhkgFSAffCIVfCIfIBaFQiiJIhYgF3wgBnwiFyAZhUIwiSIZIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGnwgCHwiFSAdhUIgiSIaICN8Ih0gD4VCKIkiDyAVfCACfCIVfCANfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgCXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAYIBt8IhggFSAahUIwiSIVICEgFIVCAYkiFCAXfCASfCIXhUIgiSIafCIbIBSFQiiJIhQgF3wgCHwiF3wgB3wiISAVIB18IhUgGSAYIA6FQgGJIg4gHnwgBnwiGIVCIIkiGXwiHSAOhUIoiSIOIBh8IAt8IhggGYVCMIkiGYVCIIkiHiAfICAgFSAPhUIBiSIPIBx8IAp8IhWFQiCJIhx8Ih8gD4VCKIkiDyAVfCAEfCIVIByFQjCJIhwgH3wiH3wiICAWhUIoiSIWICF8IAN8IiEgHoVCMIkiHiAgfCIgIBggFyAahUIwiSIXIBt8IhogFIVCAYkiFHwgBXwiGCAchUIgiSIbICR8IhwgFIVCKIkiFCAYfCABfCIYIBuFQjCJIhsgHyAPhUIBiSIPICJ8IAx8Ih8gF4VCIIkiFyAZIB18Ihl8Ih0gD4VCKIkiDyAffCATfCIfIBeFQjCJIhcgHXwiHSAPhUIBiSIPIBkgDoVCAYkiDiAVfCAQfCIVICOFQiCJIhkgGnwiGiAOhUIoiSIOIBV8IAJ8IhV8IBN8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCASfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHHwiGyAVIBmFQjCJIhUgICAWhUIBiSIWIB98IAt8IhmFQiCJIhx8Ih8gFoVCKIkiFiAZfCACfCIZfCAJfCIgIBUgGnwiFSAXIBsgFIVCAYkiFCAhfCAFfCIahUIgiSIXfCIbIBSFQiiJIhQgGnwgA3wiGiAXhUIwiSIXhUIgiSIhIB0gHiAVIA6FQgGJIg4gGHwgEHwiFYVCIIkiGHwiHSAOhUIoiSIOIBV8IAF8IhUgGIVCMIkiGCAdfCIdfCIeIA+FQiiJIg8gIHwgDXwiICAhhUIwiSIhIB58Ih4gGSAchUIwiSIZIB98IhwgFoVCAYkiFiAafCAIfCIaIBiFQiCJIhggJHwiHyAWhUIoiSIWIBp8IAp8IhogGIVCMIkiGCAdIA6FQgGJIg4gInwgBHwiHSAZhUIgiSIZIBcgG3wiF3wiGyAOhUIoiSIOIB18IAd8Ih0gGYVCMIkiGSAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAx8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgBnwiFXwgEnwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IBN8IiIgGyAhIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGnwgBnwiGoVCIIkiHHwiGyAUhUIoiSIUIBp8IBB8IhogHIVCMIkiHCAbfCIbIBSFQgGJIhR8IA18IiEgGCAffCIYIBUgHiAPhUIBiSIPIB18IAJ8Ih2FQiCJIhV8Ih4gD4VCKIkiDyAdfCABfCIdIBWFQjCJIhWFQiCJIh8gFyAZIBggFoVCAYkiFiAgfCADfCIYhUIgiSIZfCIXIBaFQiiJIhYgGHwgBHwiGCAZhUIwiSIZIBd8Ihd8IiAgFIVCKIkiFCAhfCAIfCIhIB+FQjCJIh8gIHwiICAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IAd8Ih0gGYVCIIkiGSAbfCIbIA6FQiiJIg4gHXwgDHwiHSAZhUIwiSIZIBcgFoVCAYkiFiAafCALfCIXICKFQiCJIhogFSAefCIVfCIeIBaFQiiJIhYgF3wgCXwiFyAahUIwiSIaIB58Ih4gFoVCAYkiFiAVIA+FQgGJIg8gGHwgBXwiFSAchUIgiSIYICN8IhwgD4VCKIkiDyAVfCAKfCIVfCACfCIChUIgiSIifCIjIBaFQiiJIhYgAnwgC3wiAiAihUIwiSILICN8IiIgFoVCAYkiFiAZIBt8IhkgFSAYhUIwiSIVICAgFIVCAYkiFCAXfCANfCINhUIgiSIXfCIYIBSFQiiJIhQgDXwgBXwiBXwgEHwiECAVIBx8Ig0gGiAZIA6FQgGJIg4gIXwgDHwiDIVCIIkiFXwiGSAOhUIoiSIOIAx8IBJ8IhIgFYVCMIkiDIVCIIkiFSAeIB8gDSAPhUIBiSINIB18IAl8IgmFQiCJIg98IhogDYVCKIkiDSAJfCAIfCIJIA+FQjCJIgggGnwiD3wiGiAWhUIoiSIWIBB8IAd8IhAgEYUgDCAZfCIHIA6FQgGJIgwgCXwgCnwiCiALhUIgiSILIAUgF4VCMIkiBSAYfCIJfCIOIAyFQiiJIgwgCnwgE3wiEyALhUIwiSIKIA58IguFNwOAiQFBACADIAYgDyANhUIBiSINIAJ8fCICIAWFQiCJIgUgB3wiBiANhUIoiSIHIAJ8fCICQQApA4iJAYUgBCABIBIgCSAUhUIBiSIDfHwiASAIhUIgiSISICJ8IgkgA4VCKIkiAyABfHwiASAShUIwiSIEIAl8IhKFNwOIiQFBACATQQApA5CJAYUgECAVhUIwiSIQIBp8IhOFNwOQiQFBACABQQApA5iJAYUgAiAFhUIwiSICIAZ8IgGFNwOYiQFBACASIAOFQgGJQQApA6CJAYUgAoU3A6CJAUEAIBMgFoVCAYlBACkDqIkBhSAKhTcDqIkBQQAgASAHhUIBiUEAKQOwiQGFIASFNwOwiQFBACALIAyFQgGJQQApA7iJAYUgEIU3A7iJAQvdAgUBfwF+AX8BfgJ/IwBBwABrIgAkAAJAQQApA9CJAUIAUg0AQQBBACkDwIkBIgFBACgC4IoBIgKsfCIDNwPAiQFBAEEAKQPIiQEgAyABVK18NwPIiQECQEEALQDoigFFDQBBAEJ/NwPYiQELQQBCfzcD0IkBAkAgAkH/AEoNAEEAIQQDQCACIARqQeCJAWpBADoAACAEQQFqIgRBgAFBACgC4IoBIgJrSA0ACwtB4IkBEAIgAEEAKQOAiQE3AwAgAEEAKQOIiQE3AwggAEEAKQOQiQE3AxAgAEEAKQOYiQE3AxggAEEAKQOgiQE3AyAgAEEAKQOoiQE3AyggAEEAKQOwiQE3AzAgAEEAKQO4iQE3AzhBACgC5IoBIgVBAUgNAEEAIQRBACECA0AgBEGACWogACAEai0AADoAACAEQQFqIQQgBSACQQFqIgJB/wFxSg0ACwsgAEHAAGokAAv9AwMBfwF+AX8jAEGAAWsiAiQAQQBBgQI7AfKKAUEAIAE6APGKAUEAIAA6APCKAUGQfiEAA0AgAEGAiwFqQgA3AAAgAEH4igFqQgA3AAAgAEHwigFqQgA3AAAgAEEYaiIADQALQQAhAEEAQQApA/CKASIDQoiS853/zPmE6gCFNwOAiQFBAEEAKQP4igFCu86qptjQ67O7f4U3A4iJAUEAQQApA4CLAUKr8NP0r+68tzyFNwOQiQFBAEEAKQOIiwFC8e30+KWn/aelf4U3A5iJAUEAQQApA5CLAULRhZrv+s+Uh9EAhTcDoIkBQQBBACkDmIsBQp/Y+dnCkdqCm3+FNwOoiQFBAEEAKQOgiwFC6/qG2r+19sEfhTcDsIkBQQBBACkDqIsBQvnC+JuRo7Pw2wCFNwO4iQFBACADp0H/AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=",hash:"c6f286e6"};function ih(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function rh(e=512,t=null){if(ih(e))return Promise.reject(ih(e));let n=null,i=e;if(null!==t){if(n=Kp(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));r=e,s=n.length,i=r|s<<16}var r,s;const o=e/8;return eh(nh,o).then(e=>{i>512&&e.writeMemory(n),e.init(i);const t={init:i>512?()=>(e.writeMemory(n),e.init(i),t):()=>(e.init(i),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:o};return t})}new Up;const sh=new DataView(new ArrayBuffer(4));function oh(e){return sh.setInt32(0,e,!0),new Uint8Array(sh.buffer)}function lh(e,t,n){return Tp(this,void 0,void 0,function*(){if(n<=64){const e=yield rh(8*n);return e.update(oh(n)),e.update(t),e.digest("binary")}const i=Math.ceil(n/32)-2,r=new Uint8Array(n);e.init(),e.update(oh(n)),e.update(t);let s=e.digest("binary");r.set(s.subarray(0,32),0);for(let t=1;t{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=Kp(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=Kp(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=Kp(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),ah(Object.assign(Object.assign({},e),{hashType:"id"}))})}new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up,new Up;const uh={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let dh=null,fh=0;const ph=new Map;async function hh(e,t){try{const n=function(){if(dh)return dh;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 dh=new Worker(URL.createObjectURL(e)),dh.onmessage=function(e){const{id:t,success:n,result:i,error:r}=e.data,s=ph.get(t);s&&(ph.delete(t),n?s.resolve(new Uint8Array(i)):s.reject(new Error(r)))},dh.onerror=function(e){console.error("Argon2 worker error:",e)},dh}(),i=++fh;return new Promise((r,s)=>{ph.set(i,{resolve:r,reject:s}),n.postMessage({id:i,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await ch({password:e,salt:t,...uh})}}const{window:gh}=a;function mh(e){let t,n,r,s,o,l,a,f,h,g,v,b,k,I,C,E,x,B;function Q(e,t){return"extension"===e[2]?yh:vh}let F=Q(e),D=F(e),$=e[10]&&Fh(e),P=e[11]&&Dh(e);return{c(){t=p("div"),n=p("div"),r=p("div"),s=p("h2"),s.textContent="Login to Nostr",o=m(),l=p("button"),l.textContent="×",a=m(),f=p("div"),h=p("div"),g=p("button"),g.textContent="Extension",v=m(),b=p("button"),b.textContent="Nsec",k=m(),I=p("div"),D.c(),C=m(),$&&$.c(),E=m(),P&&P.c(),A(s,"class","svelte-4xpfbi"),A(l,"class","close-btn svelte-4xpfbi"),A(r,"class","modal-header svelte-4xpfbi"),A(g,"class","tab-btn svelte-4xpfbi"),S(g,"active","extension"===e[2]),A(b,"class","tab-btn svelte-4xpfbi"),S(b,"active","nsec"===e[2]),A(h,"class","tabs svelte-4xpfbi"),A(I,"class","tab-content svelte-4xpfbi"),A(f,"class","tab-container svelte-4xpfbi"),A(n,"class","modal svelte-4xpfbi"),S(n,"dark-theme",e[1]),A(t,"class","modal-overlay svelte-4xpfbi"),A(t,"role","button"),A(t,"tabindex","0")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(r,o),c(r,l),c(n,a),c(n,f),c(f,h),c(h,g),c(h,v),c(h,b),c(f,k),c(f,I),D.m(I,null),c(I,C),$&&$.m(I,null),c(I,E),P&&P.m(I,null),x||(B=[y(l,"click",e[17]),y(g,"click",e[26]),y(b,"click",e[27]),y(n,"click",w(e[24])),y(n,"keydown",w(e[25])),y(t,"click",e[17]),y(t,"keydown",e[32])],x=!0)},p(e,t){4&t[0]&&S(g,"active","extension"===e[2]),4&t[0]&&S(b,"active","nsec"===e[2]),F===(F=Q(e))&&D?D.p(e,t):(D.d(1),D=F(e),D&&(D.c(),D.m(I,C))),e[10]?$?$.p(e,t):($=Fh(e),$.c(),$.m(I,E)):$&&($.d(1),$=null),e[11]?P?P.p(e,t):(P=Dh(e),P.c(),P.m(I,null)):P&&(P.d(1),P=null),2&t[0]&&S(n,"dark-theme",e[1])},d(e){e&&d(t),D.d(),$&&$.d(),P&&P.d(),x=!1,i(B)}}}function vh(e){let t;function n(e,t){return e[14]?Ah:wh}let i=n(e),r=i(e);return{c(){t=p("div"),r.c(),A(t,"class","nsec-login svelte-4xpfbi")},m(e,n){u(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&d(t),r.d()}}}function yh(e){let t,n,i,r,s,o,l,a=e[7]?"Connecting...":"Log in using extension";return{c(){t=p("div"),n=p("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",i=m(),r=p("button"),s=g(a),A(n,"class","svelte-4xpfbi"),A(r,"class","login-extension-btn svelte-4xpfbi"),r.disabled=e[7],A(t,"class","extension-login svelte-4xpfbi")},m(a,d){u(a,t,d),c(t,n),c(t,i),c(t,r),c(r,s),o||(l=y(r,"click",e[21]),o=!0)},p(e,t){128&t[0]&&a!==(a=e[7]?"Connecting...":"Log in using extension")&&k(s,a),128&t[0]&&(r.disabled=e[7])},d(e){e&&d(t),o=!1,l()}}}function wh(e){let t,n,r,s,o,l,a,f,h,v,w,b,C,E,x,S,B,Q,F,D,$,P,R,T=e[8]?"Generating...":"Generate New Key",U=e[12]&&bh(e),_=e[4]&&kh(e);function N(e,t){return e[9]?Eh:e[7]?Ch:Ih}let L=N(e),O=L(e);return{c(){t=p("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n set a password to encrypt it securely.",n=m(),r=p("button"),s=g(T),l=m(),U&&U.c(),a=m(),f=p("input"),v=m(),w=p("div"),b=p("label"),b.textContent="Encryption Password (optional but recommended):",C=m(),E=p("input"),S=m(),_&&_.c(),B=m(),Q=p("small"),Q.textContent="Password uses Argon2id with ~3 second derivation time for security.",F=m(),D=p("button"),O.c(),A(t,"class","svelte-4xpfbi"),A(r,"class","generate-btn svelte-4xpfbi"),r.disabled=o=e[7]||e[8],A(f,"type","password"),A(f,"placeholder","nsec1..."),f.disabled=h=e[7]||e[9],A(f,"class","nsec-input svelte-4xpfbi"),A(b,"class","svelte-4xpfbi"),A(E,"type","password"),A(E,"placeholder","Enter password (min 8 chars)"),E.disabled=x=e[7]||e[9],A(E,"class","password-input svelte-4xpfbi"),A(Q,"class","password-hint svelte-4xpfbi"),A(w,"class","password-section svelte-4xpfbi"),A(D,"class","login-nsec-btn svelte-4xpfbi"),D.disabled=$=e[7]||e[9]||!e[3].trim()},m(i,o){u(i,t,o),u(i,n,o),u(i,r,o),c(r,s),u(i,l,o),U&&U.m(i,o),u(i,a,o),u(i,f,o),I(f,e[3]),u(i,v,o),u(i,w,o),c(w,b),c(w,C),c(w,E),I(E,e[4]),c(w,S),_&&_.m(w,null),c(w,B),c(w,Q),u(i,F,o),u(i,D,o),O.m(D,null),P||(R=[y(r,"click",e[20]),y(f,"input",e[29]),y(E,"input",e[30]),y(D,"click",e[22])],P=!0)},p(e,t){256&t[0]&&T!==(T=e[8]?"Generating...":"Generate New Key")&&k(s,T),384&t[0]&&o!==(o=e[7]||e[8])&&(r.disabled=o),e[12]?U?U.p(e,t):(U=bh(e),U.c(),U.m(a.parentNode,a)):U&&(U.d(1),U=null),640&t[0]&&h!==(h=e[7]||e[9])&&(f.disabled=h),8&t[0]&&f.value!==e[3]&&I(f,e[3]),640&t[0]&&x!==(x=e[7]||e[9])&&(E.disabled=x),16&t[0]&&E.value!==e[4]&&I(E,e[4]),e[4]?_?_.p(e,t):(_=kh(e),_.c(),_.m(w,B)):_&&(_.d(1),_=null),L!==(L=N(e))&&(O.d(1),O=L(e),O&&(O.c(),O.m(D,null))),648&t[0]&&$!==($=e[7]||e[9]||!e[3].trim())&&(D.disabled=$)},d(e){e&&d(t),e&&d(n),e&&d(r),e&&d(l),U&&U.d(e),e&&d(a),e&&d(f),e&&d(v),e&&d(w),_&&_.d(),e&&d(F),e&&d(D),O.d(),P=!1,i(R)}}}function Ah(e){let t,n,r,s,o,l,a,f,h,v,w,b,k,C,E=e[15]&&xh(e);function x(e,t){return e[9]?Qh:e[7]?Bh:Sh}let S=x(e),B=S(e);return{c(){t=p("p"),t.textContent="You have a stored encrypted key. Enter your\n password to unlock it.",n=m(),E&&E.c(),r=m(),s=p("input"),l=m(),a=p("button"),B.c(),h=m(),v=p("button"),w=g("Clear stored key & start fresh"),A(t,"class","svelte-4xpfbi"),A(s,"type","password"),A(s,"placeholder","Enter your password"),s.disabled=o=e[7]||e[9],A(s,"class","password-input svelte-4xpfbi"),A(a,"class","login-nsec-btn svelte-4xpfbi"),a.disabled=f=e[7]||e[9]||!e[6],A(v,"class","clear-btn svelte-4xpfbi"),v.disabled=b=e[7]||e[9]},m(i,o){u(i,t,o),u(i,n,o),E&&E.m(i,o),u(i,r,o),u(i,s,o),I(s,e[6]),u(i,l,o),u(i,a,o),B.m(a,null),u(i,h,o),u(i,v,o),c(v,w),k||(C=[y(s,"input",e[28]),y(a,"click",e[18]),y(v,"click",e[16])],k=!0)},p(e,t){e[15]?E?E.p(e,t):(E=xh(e),E.c(),E.m(r.parentNode,r)):E&&(E.d(1),E=null),640&t[0]&&o!==(o=e[7]||e[9])&&(s.disabled=o),64&t[0]&&s.value!==e[6]&&I(s,e[6]),S!==(S=x(e))&&(B.d(1),B=S(e),B&&(B.c(),B.m(a,null))),704&t[0]&&f!==(f=e[7]||e[9]||!e[6])&&(a.disabled=f),640&t[0]&&b!==(b=e[7]||e[9])&&(v.disabled=b)},d(e){e&&d(t),e&&d(n),E&&E.d(e),e&&d(r),e&&d(s),e&&d(l),e&&d(a),B.d(),e&&d(h),e&&d(v),k=!1,i(C)}}}function bh(e){let t,n,i,r,s;return{c(){t=p("div"),n=p("label"),n.textContent="Your new public key (npub):",i=m(),r=p("code"),s=g(e[12]),A(n,"class","svelte-4xpfbi"),A(r,"class","npub-display svelte-4xpfbi"),A(t,"class","generated-info svelte-4xpfbi")},m(e,o){u(e,t,o),c(t,n),c(t,i),c(t,r),c(r,s)},p(e,t){4096&t[0]&&k(s,e[12])},d(e){e&&d(t)}}}function kh(e){let t,n,i,r;return{c(){t=p("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,s){u(n,t,s),I(t,e[5]),i||(r=y(t,"input",e[31]),i=!0)},p(e,i){640&i[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&i[0]&&t.value!==e[5]&&I(t,e[5])},d(e){e&&d(t),i=!1,r()}}}function Ih(e){let t;return{c(){t=g("Log in with nsec")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ch(e){let t;return{c(){t=g("Logging in...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Eh(e){let t;return{c(){t=g("Deriving key...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function xh(e){let t,n,i,r,s,o,l,a=e[15].slice(0,16)+"",f=e[15].slice(-8)+"";return{c(){t=p("div"),n=p("label"),n.textContent="Stored public key:",i=m(),r=p("code"),s=g(a),o=g("..."),l=g(f),A(n,"class","svelte-4xpfbi"),A(r,"class","npub-display svelte-4xpfbi"),A(t,"class","stored-info svelte-4xpfbi")},m(e,a){u(e,t,a),c(t,n),c(t,i),c(t,r),c(r,s),c(r,o),c(r,l)},p(e,t){32768&t[0]&&a!==(a=e[15].slice(0,16)+"")&&k(s,a),32768&t[0]&&f!==(f=e[15].slice(-8)+"")&&k(l,f)},d(e){e&&d(t)}}}function Sh(e){let t;return{c(){t=g("Unlock")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Bh(e){let t;return{c(){t=g("Unlocking...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Qh(e){let t;return{c(){t=g("Deriving key...")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Fh(e){let t,n;return{c(){t=p("div"),n=g(e[10]),A(t,"class","message error-message svelte-4xpfbi")},m(e,i){u(e,t,i),c(t,n)},p(e,t){1024&t[0]&&k(n,e[10])},d(e){e&&d(t)}}}function Dh(e){let t,n;return{c(){t=p("div"),n=g(e[11]),A(t,"class","message success-message svelte-4xpfbi")},m(e,i){u(e,t,i),c(t,n)},p(e,t){2048&t[0]&&k(n,e[11])},d(e){e&&d(t)}}}function $h(e){let t,n,i,r,s,o,l,a,f,h,v,y=e[13].toFixed(1)+"";return{c(){t=p("div"),n=p("div"),i=p("div"),r=m(),s=p("h3"),s.textContent="Deriving encryption key",o=m(),l=p("div"),a=g(y),f=g("s"),h=m(),v=p("p"),v.textContent="This may take 3-6 seconds for security",A(i,"class","deriving-spinner svelte-4xpfbi"),A(s,"class","svelte-4xpfbi"),A(l,"class","deriving-timer svelte-4xpfbi"),A(v,"class","deriving-note svelte-4xpfbi"),A(n,"class","deriving-modal svelte-4xpfbi"),S(n,"dark-theme",e[1]),A(t,"class","deriving-overlay svelte-4xpfbi")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(n,r),c(n,s),c(n,o),c(n,l),c(l,a),c(l,f),c(n,h),c(n,v)},p(e,t){8192&t[0]&&y!==(y=e[13].toFixed(1)+"")&&k(a,y),2&t[0]&&S(n,"dark-theme",e[1])},d(e){e&&d(t)}}}function Ph(t){let n,i,r,s,o=t[0]&&mh(t),l=t[9]&&$h(t);return{c(){o&&o.c(),n=m(),l&&l.c(),i=v()},m(e,a){o&&o.m(e,a),u(e,n,a),l&&l.m(e,a),u(e,i,a),r||(s=y(gh,"keydown",t[23]),r=!0)},p(e,t){e[0]?o?o.p(e,t):(o=mh(e),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null),e[9]?l?l.p(e,t):(l=$h(e),l.c(),l.m(i.parentNode,i)):l&&(l.d(1),l=null)},i:e,o:e,d(e){o&&o.d(e),e&&d(n),l&&l.d(e),e&&d(i),r=!1,s()}}}function Rh(e,t,n){const i=P();let{showModal:r=!1}=t,{isDarkTheme:s=!1}=t,o="extension",l="",a="",c="",u="",d=!1,f=!1,p=!1,h="",g="",m="",v="",y=0,w=null,A=null;function b(){n(13,y=0),w=performance.now(),k()}function k(){null!==w&&(n(13,y=(performance.now()-w)/1e3),A=requestAnimationFrame(k))}function I(){w=null,A&&(cancelAnimationFrame(A),A=null)}$(()=>{I()});let C=!1,E="";function x(){n(14,C=!!localStorage.getItem("nostr_privkey_encrypted")),n(15,E=localStorage.getItem("nostr_pubkey")||"")}function S(){n(0,r=!1),n(3,l=""),n(4,a=""),n(5,c=""),n(6,u=""),n(10,h=""),n(11,g=""),m="",n(12,v=""),i("close")}function B(e){n(2,o=e),n(10,h=""),n(11,g=""),m="",n(12,v="")}async function Q(){n(7,d=!0),n(10,h=""),n(11,g="");try{if(!l.trim())throw new Error("Please enter your nsec");if(!function(e){if(!e||!e.startsWith("nsec1"))return!1;try{return"nsec"===vu(e).type}catch{return!1}}(l.trim()))throw new Error("Invalid nsec format or checksum");if(a){if(a.length<8)throw new Error("Password must be at least 8 characters");if(a!==c)throw new Error("Passwords do not match")}const e=ff.fromKey(l.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),a){n(9,p=!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)),i=crypto.getRandomValues(new Uint8Array(12)),r=await hh(t,n),s=await crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),o=new TextEncoder,l=await crypto.subtle.encrypt({name:"AES-GCM",iv:i},s,o.encode(e)),a=new Uint8Array(n.length+i.length+l.byteLength);return a.set(n,0),a.set(i,n.length),a.set(new Uint8Array(l),n.length+i.length),btoa(String.fromCharCode(...a))}(l.trim(),a);I(),n(9,p=!1),localStorage.setItem("nostr_privkey_encrypted",e),localStorage.removeItem("nostr_privkey")}else localStorage.setItem("nostr_privkey",l.trim()),localStorage.removeItem("nostr_privkey_encrypted"),n(11,g="Successfully logged in with nsec!");i("login",{method:"nsec",pubkey:t,privateKey:l.trim(),signer:e}),setTimeout(()=>{S()},1500)}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}}D(()=>{x()});return e.$$set=e=>{"showModal"in e&&n(0,r=e.showModal),"isDarkTheme"in e&&n(1,s=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&r&&x()},[r,s,o,l,a,c,u,d,f,p,h,g,v,y,C,E,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(14,C=!1),n(15,E=""),n(6,u=""),n(10,h=""),n(11,g="")},S,async function(){n(7,d=!0),n(9,p=!0),b(),n(10,h=""),n(11,g="");try{if(!u)throw new Error("Please enter your password");const e=localStorage.getItem("nostr_privkey_encrypted");if(!e)throw new Error("No encrypted key found");const t=await async function(e,t){const n=new Uint8Array(atob(e).split("").map(e=>e.charCodeAt(0)));if(n.length<60)throw new Error("Invalid encrypted data - too short");const i=n.slice(0,32),r=n.slice(32,44),s=n.slice(44),o=await hh(t,i),l=await crypto.subtle.importKey("raw",o,{name:"AES-GCM"},!1,["decrypt"]);let a;try{a=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},l,s)}catch(e){throw new Error("Decryption failed - invalid password or corrupted data")}const c=(new TextDecoder).decode(a);if(!c.startsWith("nsec1"))throw new Error("Decryption produced invalid data - not an nsec");try{if("nsec"!==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,p=!1);const r=ff.fromKey(t),s=await r.getPublicKey();i("login",{method:"nsec",pubkey:s,privateKey:t,signer:r}),S()}catch(e){I(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,h="Invalid password"):n(10,h=e.message)}finally{n(7,d=!1),n(9,p=!1),I()}},B,async function(){n(8,f=!0),n(10,h=""),n(11,g="");try{const e=Zc(),t=Au("nsec",e),i=wu(Xc(e));m=t,n(12,v=i),n(3,l=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,h="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,h=""),n(11,g="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(11,g="Successfully logged in with extension!"),i("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{S()},1500))}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}},Q,function(e){"Escape"===e.key&&S(),"Enter"===e.key&&"nsec"===o&&Q()},function(t){R.call(this,e,t)},function(t){R.call(this,e,t)},()=>B("extension"),()=>B("nsec"),function(){u=this.value,n(6,u)},function(){l=this.value,n(3,l)},function(){a=this.value,n(4,a)},function(){c=this.value,n(5,c)},e=>"Escape"===e.key&&S()]}class Th extends se{constructor(e){super(),re(this,e,Rh,Ph,s,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function Uh(e,t,n){const i=e.slice();return i[72]=t[n],i}function _h(e,t,n){const i=e.slice();return i[75]=t[n],i}function Nh(e,t,n){const i=e.slice();return i[72]=t[n],i}function Lh(e,t,n){const i=e.slice();return i[72]=t[n],i}function Oh(e,t,n){const i=e.slice();return i[72]=t[n],i}function Mh(e,t,n){const i=e.slice();return i[72]=t[n],i}function jh(e,t,n){const i=e.slice();return i[72]=t[n],i}function Hh(e){let t,n,i;return{c(){t=p("div"),n=g(e[3]),A(t,"class",i="message "+e[4]+" svelte-1y8wjwc")},m(e,i){u(e,t,i),c(t,n)},p(e,r){8&r[0]&&k(n,e[3]),16&r[0]&&i!==(i="message "+e[4]+" svelte-1y8wjwc")&&A(t,"class",i)},d(e){e&&d(t)}}}function Gh(e){let t,n,r,s,o,l,a,f,h,v,w,b,k,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N;function L(e,t){return e[5]&&e[5].length>0?Kh:Jh}let O=L(e),M=O(e);function j(e,t){return e[8]&&e[8].length>0?Wh:Yh}let H=j(e),G=H(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Banned Pubkeys",s=m(),o=p("div"),l=p("input"),a=m(),f=p("input"),h=m(),v=p("button"),w=g("Ban Pubkey"),b=m(),k=p("div"),M.c(),C=m(),E=p("div"),x=p("h3"),x.textContent="Allowed Pubkeys",S=m(),B=p("div"),Q=p("input"),F=m(),D=p("input"),$=m(),P=p("button"),R=g("Allow Pubkey"),T=m(),U=p("div"),G.c(),A(r,"class","svelte-1y8wjwc"),A(l,"type","text"),A(l,"placeholder","Pubkey (64 hex chars)"),A(l,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),v.disabled=e[2],A(v,"class","svelte-1y8wjwc"),A(o,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(x,"class","svelte-1y8wjwc"),A(Q,"type","text"),A(Q,"placeholder","Pubkey (64 hex chars)"),A(Q,"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(B,"class","add-form svelte-1y8wjwc"),A(U,"class","list svelte-1y8wjwc"),A(E,"class","section svelte-1y8wjwc"),A(t,"class","pubkeys-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,l),I(l,e[6]),c(o,a),c(o,f),I(f,e[7]),c(o,h),c(o,v),c(v,w),c(n,b),c(n,k),M.m(k,null),c(t,C),c(t,E),c(E,x),c(E,S),c(E,B),c(B,Q),I(Q,e[9]),c(B,F),c(B,D),I(D,e[10]),c(B,$),c(B,P),c(P,R),c(E,T),c(E,U),G.m(U,null),_||(N=[y(l,"input",e[43]),y(f,"input",e[44]),y(v,"click",e[25]),y(Q,"input",e[45]),y(D,"input",e[46]),y(P,"click",e[26])],_=!0)},p(e,t){64&t[0]&&l.value!==e[6]&&I(l,e[6]),128&t[0]&&f.value!==e[7]&&I(f,e[7]),4&t[0]&&(v.disabled=e[2]),O===(O=L(e))&&M?M.p(e,t):(M.d(1),M=O(e),M&&(M.c(),M.m(k,null))),512&t[0]&&Q.value!==e[9]&&I(Q,e[9]),1024&t[0]&&D.value!==e[10]&&I(D,e[10]),4&t[0]&&(P.disabled=e[2]),H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(U,null)))},d(e){e&&d(t),M.d(),G.d(),_=!1,i(N)}}}function Jh(t){let n;return{c(){n=p("div"),n.innerHTML="

No banned pubkeys configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Kh(e){let t,n=e[5],i=[];for(let t=0;tNo allowed pubkeys configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Wh(e){let t,n=e[8],i=[];for(let t=0;t0?tg:eg}let O=L(e),M=O(e);let j=function(e){return e[22]&&e[22].length>0?sg:rg}(e),H=j(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Banned Events",s=m(),o=p("div"),l=p("input"),a=m(),f=p("input"),h=m(),v=p("button"),w=g("Ban Event"),b=m(),k=p("div"),M.c(),C=m(),E=p("div"),x=p("h3"),x.textContent="Allowed Events",S=m(),B=p("div"),Q=p("input"),F=m(),D=p("input"),$=m(),P=p("button"),R=g("Allow Event"),T=m(),U=p("div"),H.c(),A(r,"class","svelte-1y8wjwc"),A(l,"type","text"),A(l,"placeholder","Event ID (64 hex chars)"),A(l,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),v.disabled=e[2],A(v,"class","svelte-1y8wjwc"),A(o,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(x,"class","svelte-1y8wjwc"),A(Q,"type","text"),A(Q,"placeholder","Event ID (64 hex chars)"),A(Q,"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(B,"class","add-form svelte-1y8wjwc"),A(U,"class","list svelte-1y8wjwc"),A(E,"class","section svelte-1y8wjwc"),A(t,"class","events-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,l),I(l,e[12]),c(o,a),c(o,f),I(f,e[13]),c(o,h),c(o,v),c(v,w),c(n,b),c(n,k),M.m(k,null),c(t,C),c(t,E),c(E,x),c(E,S),c(E,B),c(B,Q),I(Q,e[14]),c(B,F),c(B,D),I(D,e[15]),c(B,$),c(B,P),c(P,R),c(E,T),c(E,U),H.m(U,null),_||(N=[y(l,"input",e[47]),y(f,"input",e[48]),y(v,"click",e[27]),y(Q,"input",e[49]),y(D,"input",e[50]),y(P,"click",e[28])],_=!0)},p(e,t){4096&t[0]&&l.value!==e[12]&&I(l,e[12]),8192&t[0]&&f.value!==e[13]&&I(f,e[13]),4&t[0]&&(v.disabled=e[2]),O===(O=L(e))&&M?M.p(e,t):(M.d(1),M=O(e),M&&(M.c(),M.m(k,null))),16384&t[0]&&Q.value!==e[14]&&I(Q,e[14]),32768&t[0]&&D.value!==e[15]&&I(D,e[15]),4&t[0]&&(P.disabled=e[2]),H.p(e,t)},d(e){e&&d(t),M.d(),H.d(),_=!1,i(N)}}}function eg(t){let n;return{c(){n=p("div"),n.innerHTML="

No banned events configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function tg(e){let t,n=e[11],i=[];for(let t=0;tNo allowed events configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function sg(e){let t,n=e[22],i=[];for(let t=0;t0?cg:ag}let S=x(e),B=S(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Blocked IPs",s=m(),o=p("div"),l=p("input"),a=m(),f=p("input"),h=m(),v=p("button"),w=g("Block IP"),b=m(),k=p("div"),B.c(),A(r,"class","svelte-1y8wjwc"),A(l,"type","text"),A(l,"placeholder","IP Address"),A(l,"class","svelte-1y8wjwc"),A(f,"type","text"),A(f,"placeholder","Reason (optional)"),A(f,"class","svelte-1y8wjwc"),v.disabled=e[2],A(v,"class","svelte-1y8wjwc"),A(o,"class","add-form svelte-1y8wjwc"),A(k,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","ips-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,l),I(l,e[17]),c(o,a),c(o,f),I(f,e[18]),c(o,h),c(o,v),c(v,w),c(n,b),c(n,k),B.m(k,null),C||(E=[y(l,"input",e[51]),y(f,"input",e[52]),y(v,"click",e[29])],C=!0)},p(e,t){131072&t[0]&&l.value!==e[17]&&I(l,e[17]),262144&t[0]&&f.value!==e[18]&&I(f,e[18]),4&t[0]&&(v.disabled=e[2]),S===(S=x(e))&&B?B.p(e,t):(B.d(1),B=S(e),B&&(B.c(),B.m(k,null)))},d(e){e&&d(t),B.d(),C=!1,i(E)}}}function ag(t){let n;return{c(){n=p("div"),n.innerHTML="

No blocked IPs configured.

",A(n,"class","no-items svelte-1y8wjwc")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function cg(e){let t,n=e[16],i=[];for(let t=0;t0?hg:pg}let x=E(e),S=x(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Allowed Event Kinds",s=m(),o=p("div"),l=p("input"),a=m(),f=p("button"),h=g("Allow Kind"),v=m(),w=p("div"),S.c(),A(r,"class","svelte-1y8wjwc"),A(l,"type","number"),A(l,"placeholder","Kind number"),A(l,"class","svelte-1y8wjwc"),f.disabled=e[2],A(f,"class","svelte-1y8wjwc"),A(o,"class","add-form svelte-1y8wjwc"),A(w,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","kinds-section")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,l),I(l,e[20]),c(o,a),c(o,f),c(f,h),c(n,v),c(n,w),S.m(w,null),k||(C=[y(l,"input",e[53]),y(f,"click",e[30])],k=!0)},p(e,t){1048576&t[0]&&b(l.value)!==e[20]&&I(l,e[20]),4&t[0]&&(f.disabled=e[2]),x===(x=E(e))&&S?S.p(e,t):(S.d(1),S=x(e),S&&(S.c(),S.m(w,null)))},d(e){e&&d(t),S.d(),k=!1,i(C)}}}function pg(t){let n;return{c(){n=p("div"),n.innerHTML="

No allowed kinds configured. All kinds are\n allowed by default.

",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[19],i=[];for(let t=0;t0?yg:vg}let w=v(e),b=w(e);return{c(){t=p("div"),n=p("div"),i=p("h3"),i.textContent="Events Needing Moderation",r=m(),s=p("button"),o=g("Refresh"),l=m(),a=p("div"),b.c(),A(i,"class","svelte-1y8wjwc"),s.disabled=e[2],A(a,"class","list svelte-1y8wjwc"),A(n,"class","section svelte-1y8wjwc"),A(t,"class","moderation-section")},m(d,p){u(d,t,p),c(t,n),c(n,i),c(n,r),c(n,s),c(s,o),c(n,l),c(n,a),b.m(a,null),f||(h=y(s,"click",e[24]),f=!0)},p(e,t){4&t[0]&&(s.disabled=e[2]),w===(w=v(e))&&b?b.p(e,t):(b.d(1),b=w(e),b&&(b.c(),b.m(a,null)))},d(e){e&&d(t),b.d(),f=!1,h()}}}function vg(t){let n;return{c(){n=p("div"),n.innerHTML="

No events need moderation at this time.

",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[21],i=[];for(let t=0;tManaged ACL Configuration \n

Configure access control using NIP-86 management API

\n
Owner Only: This interface is restricted to relay owners\n only.
',s=m(),q&&q.c(),o=m(),l=p("div"),a=p("button"),f=g("Pubkeys"),v=m(),w=p("button"),b=g("Events"),I=m(),C=p("button"),E=g("IPs"),S=m(),B=p("button"),Q=g("Kinds"),D=m(),$=p("button"),P=g("Moderation"),T=m(),U=p("button"),_=g("Relay Config"),L=m(),O=p("div"),Y&&Y.c(),M=m(),W&&W.c(),j=m(),z&&z.c(),H=m(),Z&&Z.c(),G=m(),X&&X.c(),J=m(),ee&&ee.c(),A(r,"class","header svelte-1y8wjwc"),A(a,"class",h="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),A(w,"class",k="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),A(C,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),A(B,"class",F="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),A($,"class",R="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),A(U,"class",N="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),A(l,"class","tabs svelte-1y8wjwc"),A(O,"class","tab-content svelte-1y8wjwc")},m(e,i){u(e,n,i),c(n,r),c(n,s),q&&q.m(n,null),c(n,o),c(n,l),c(l,a),c(a,f),c(l,v),c(l,w),c(w,b),c(l,I),c(l,C),c(C,E),c(l,S),c(l,B),c(B,Q),c(l,D),c(l,$),c($,P),c(l,T),c(l,U),c(U,_),c(n,L),c(n,O),Y&&Y.m(O,null),c(O,M),W&&W.m(O,null),c(O,j),z&&z.m(O,null),c(O,H),Z&&Z.m(O,null),c(O,G),X&&X.m(O,null),c(O,J),ee&&ee.m(O,null),K||(V=[y(a,"click",t[37]),y(w,"click",t[38]),y(C,"click",t[39]),y(B,"click",t[40]),y($,"click",t[41]),y(U,"click",t[42])],K=!0)},p(e,t){e[3]?q?q.p(e,t):(q=Hh(e),q.c(),q.m(n,o)):q&&(q.d(1),q=null),2&t[0]&&h!==(h="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(a,"class",h),2&t[0]&&k!==(k="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(w,"class",k),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(C,"class",x),2&t[0]&&F!==(F="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(B,"class",F),2&t[0]&&R!==(R="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&A($,"class",R),2&t[0]&&N!==(N="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&A(U,"class",N),"pubkeys"===e[1]?Y?Y.p(e,t):(Y=Gh(e),Y.c(),Y.m(O,M)):Y&&(Y.d(1),Y=null),"events"===e[1]?W?W.p(e,t):(W=Xh(e),W.c(),W.m(O,j)):W&&(W.d(1),W=null),"ips"===e[1]?z?z.p(e,t):(z=lg(e),z.c(),z.m(O,H)):z&&(z.d(1),z=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=fg(e),Z.c(),Z.m(O,G)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=mg(e),X.c(),X.m(O,J)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=bg(e),ee.c(),ee.m(O,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),q&&q.d(),Y&&Y.d(),W&&W.d(),z&&z.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),K=!1,i(V)}}}function Eg(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="pubkeys",o=!1,l="",a="info",c=[],u="",d="",f=[],p="",h="",g=[],m="",v="",y="",w="",A=[],k="",I="",C=[],E="",x=[],S={relay_name:"",relay_description:"",relay_icon:""};async function B(){try{n(2,o=!0),console.log("Fetching relay info from /");const e=await fetch(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,S={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",S),console.log("Loaded relay info:",t),n(3,l="Relay configuration loaded successfully"),n(4,a="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,l=`Failed to fetch relay info: ${e.status}`),n(4,a="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,l=`Failed to fetch relay info: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}}async function Q(e,t=[]){try{n(2,o=!0),n(3,l="");const s={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s),l=JSON.stringify(o);return`Nostr ${btoa(l)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(s)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,l=e.message),n(4,a="error"),e}finally{n(2,o=!1)}}async function F(){try{n(5,c=await Q("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function $(){try{n(8,f=await Q("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function P(){try{n(11,g=await Q("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function R(){try{n(16,A=await Q("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function T(){try{n(19,C=await Q("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function U(){try{n(2,o=!0),n(21,x=await Q("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",x)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,l=`Failed to load moderation events: ${e.message}`),n(4,a="error"),n(21,x=[])}finally{n(2,o=!1)}}async function _(e){try{await Q("disallowkind",[e]),n(3,l="Kind disallowed successfully"),n(4,a="success"),await T()}catch(e){console.error("Failed to disallow kind:",e)}}async function N(e){try{await Q("allowevent",[e,"Approved from moderation queue"]),n(3,l="Event allowed successfully"),n(4,a="success"),await U()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function L(e){try{await Q("banevent",[e,"Banned from moderation queue"]),n(3,l="Event banned successfully"),n(4,a="success"),await U()}catch(e){console.error("Failed to ban event from moderation:",e)}}D(()=>{setTimeout(()=>{B()},100)}),async function(){await Promise.all([F(),$(),P(),R(),T()])}();return e.$$set=e=>{"userSigner"in e&&n(35,i=e.userSigner),"userPubkey"in e&&n(36,r=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",S)},[S,s,o,l,a,c,u,d,f,p,h,g,m,v,y,w,A,k,I,C,E,x,[],B,U,async function(){if(u)try{await Q("banpubkey",[u,d]),n(3,l="Pubkey banned successfully"),n(4,a="success"),n(6,u=""),n(7,d=""),await F()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(p)try{await Q("allowpubkey",[p,h]),n(3,l="Pubkey allowed successfully"),n(4,a="success"),n(9,p=""),n(10,h=""),await $()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await Q("banevent",[m,v]),n(3,l="Event banned successfully"),n(4,a="success"),n(12,m=""),n(13,v=""),await P()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(y)try{await Q("allowevent",[y,w]),n(3,l="Event allowed successfully"),n(4,a="success"),n(14,y=""),n(15,w="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(k)try{await Q("blockip",[k,I]),n(3,l="IP blocked successfully"),n(4,a="success"),n(17,k=""),n(18,I=""),await R()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!E)return;const e=parseInt(E);if(isNaN(e))return n(3,l="Invalid kind number"),void n(4,a="error");try{await Q("allowkind",[e]),n(3,l="Kind allowed successfully"),n(4,a="success"),n(20,E=""),await T()}catch(e){console.error("Failed to allow kind:",e)}},_,async function(){try{n(2,o=!0),n(3,l="");const e=[];if(S.relay_name&&e.push(Q("changerelayname",[S.relay_name])),S.relay_description&&e.push(Q("changerelaydescription",[S.relay_description])),S.relay_icon&&e.push(Q("changerelayicon",[S.relay_icon])),0===e.length)return n(3,l="No changes to update"),void n(4,a="info");await Promise.all(e),n(3,l="Relay configuration updated successfully"),n(4,a="success"),await B()}catch(e){console.error("Failed to update relay configuration:",e),n(3,l=`Failed to update relay configuration: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}},N,L,i,r,()=>n(1,s="pubkeys"),()=>n(1,s="events"),()=>n(1,s="ips"),()=>n(1,s="kinds"),()=>{n(1,s="moderation"),x&&0!==x.length||U()},()=>n(1,s="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){p=this.value,n(9,p)},function(){h=this.value,n(10,h)},function(){m=this.value,n(12,m)},function(){v=this.value,n(13,v)},function(){y=this.value,n(14,y)},function(){w=this.value,n(15,w)},function(){k=this.value,n(17,k)},function(){I=this.value,n(18,I)},function(){E=b(this.value),n(20,E)},e=>_(e),e=>N(e.id),e=>L(e.id),function(){S.relay_name=this.value,n(0,S)},function(){S.relay_description=this.value,n(0,S)},function(){S.relay_icon=this.value,n(0,S)}]}class xg extends se{constructor(e){super(),re(this,e,Eg,Cg,s,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}function Sg(e){let t,n;return{c(){t=p("span"),n=g(e[3]),A(t,"class","permission-badge svelte-1qkhxam")},m(e,i){u(e,t,i),c(t,n)},p(e,t){8&t&&k(n,e[3])},d(e){e&&d(t)}}}function Bg(t){let n,i,r;return{c(){n=p("button"),n.textContent="Log in",A(n,"class","login-btn svelte-1qkhxam")},m(e,s){u(e,n,s),i||(r=y(n,"click",t[7]),i=!0)},p:e,d(e){e&&d(n),i=!1,r()}}}function Qg(e){let t,n,i,r,s,o,l=(e[4]?.name||e[5])+"";function a(e,t){return e[4]?.picture?Dg:Fg}let f=a(e),h=f(e);return{c(){t=p("button"),h.c(),n=m(),i=p("span"),r=g(l),A(i,"class","user-name svelte-1qkhxam"),A(t,"class","user-profile-btn svelte-1qkhxam")},m(l,a){u(l,t,a),h.m(t,null),c(t,n),c(t,i),c(i,r),s||(o=y(t,"click",e[6]),s=!0)},p(e,i){f===(f=a(e))&&h?h.p(e,i):(h.d(1),h=f(e),h&&(h.c(),h.m(t,n))),48&i&&l!==(l=(e[4]?.name||e[5])+"")&&k(r,l)},d(e){e&&d(t),h.d(),s=!1,o()}}}function Fg(t){let n;return{c(){n=p("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 Dg(e){let t,n;return{c(){t=p("img"),l(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,i){16&i&&!l(t.src,n=e[4].picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function $g(t){let n,i,r,s,o,a,f,h,v,y,w=t[1]&&t[2]&&Sg(t);function b(e,t){return e[1]?Qg:Bg}let k=b(t),I=k(t);return{c(){n=p("header"),i=p("div"),r=p("img"),o=m(),a=p("div"),f=p("span"),h=g("ORLY? dashboard\n "),w&&w.c(),v=m(),y=p("div"),I.c(),l(r.src,s="/orly.png")||A(r,"src","/orly.png"),A(r,"alt","ORLY Logo"),A(r,"class","logo svelte-1qkhxam"),A(f,"class","app-title svelte-1qkhxam"),A(a,"class","header-title svelte-1qkhxam"),A(y,"class","header-buttons svelte-1qkhxam"),A(i,"class","header-content svelte-1qkhxam"),A(n,"class","main-header svelte-1qkhxam"),S(n,"dark-theme",t[0])},m(e,t){u(e,n,t),c(n,i),c(i,r),c(i,o),c(i,a),c(a,f),c(f,h),w&&w.m(f,null),c(i,v),c(i,y),I.m(y,null)},p(e,[t]){e[1]&&e[2]?w?w.p(e,t):(w=Sg(e),w.c(),w.m(f,null)):w&&(w.d(1),w=null),k===(k=b(e))&&I?I.p(e,t):(I.d(1),I=k(e),I&&(I.c(),I.m(y,null))),1&t&&S(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&d(n),w&&w.d(),I.d()}}}function Pg(e,t,n){let{isDarkTheme:i=!1}=t,{isLoggedIn:r=!1}=t,{userRole:s=""}=t,{currentEffectiveRole:o=""}=t,{userProfile:l=null}=t,{userPubkey:a=""}=t;const c=P();return e.$$set=e=>{"isDarkTheme"in e&&n(0,i=e.isDarkTheme),"isLoggedIn"in e&&n(1,r=e.isLoggedIn),"userRole"in e&&n(2,s=e.userRole),"currentEffectiveRole"in e&&n(3,o=e.currentEffectiveRole),"userProfile"in e&&n(4,l=e.userProfile),"userPubkey"in e&&n(5,a=e.userPubkey)},[i,r,s,o,l,a,function(){c("openSettingsDrawer")},function(){c("openLoginModal")}]}class Rg extends se{constructor(e){super(),re(this,e,Pg,$g,s,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3,userProfile:4,userPubkey:5})}}function Tg(e,t,n){const i=e.slice();return i[10]=t[n],i}function Ug(e){let t,n,r;function s(){return e[6](e[10])}function o(...t){return e[7](e[10],...t)}return{c(){t=p("span"),t.textContent="✕",A(t,"class","tab-close-icon svelte-wfmuj"),A(t,"role","button"),A(t,"tabindex","0")},m(e,i){u(e,t,i),n||(r=[y(t,"click",w(s)),y(t,"keydown",o)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,i(r)}}}function _g(e){let t,n,i,r,s,o,l,a,f,h,v=e[10].icon+"",w=e[10].label+"",b=e[10].isSearchTab&&Ug(e);function I(){return e[8](e[10])}return{c(){t=p("button"),n=p("span"),i=g(v),r=m(),s=p("span"),o=g(w),l=m(),b&&b.c(),a=m(),A(n,"class","tab-icon svelte-wfmuj"),A(s,"class","tab-label svelte-wfmuj"),A(t,"class","tab svelte-wfmuj"),S(t,"active",e[2]===e[10].id)},m(e,d){u(e,t,d),c(t,n),c(n,i),c(t,r),c(t,s),c(s,o),c(t,l),b&&b.m(t,null),c(t,a),f||(h=y(t,"click",I),f=!0)},p(n,r){e=n,2&r&&v!==(v=e[10].icon+"")&&k(i,v),2&r&&w!==(w=e[10].label+"")&&k(o,w),e[10].isSearchTab?b?b.p(e,r):(b=Ug(e),b.c(),b.m(t,a)):b&&(b.d(1),b=null),6&r&&S(t,"active",e[2]===e[10].id)},d(e){e&&d(t),b&&b.d(),f=!1,h()}}}function Ng(e){let t,n,i,r,s,o,l,a;return{c(){t=p("a"),n=h("svg"),i=h("path"),r=h("path"),s=m(),o=p("span"),l=g("v"),a=g(e[3]),A(i,"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(r,"d","M9 9c1.5 0 3 .5 3 2.5S10.5 14 9 14c0-1.5.5-3.5 2-4.5"),A(r,"stroke","currentColor"),A(r,"stroke-width","1"),A(r,"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(o,"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,i),c(n,r),c(t,s),c(t,o),c(o,l),c(o,a)},p(e,t){8&t&&k(a,e[3])},d(e){e&&d(t)}}}function Lg(t){let n,i,r,s,o=t[1],l=[];for(let e=0;e{"isDarkTheme"in e&&n(0,i=e.isDarkTheme),"tabs"in e&&n(1,r=e.tabs),"selectedTab"in e&&n(2,s=e.selectedTab),"version"in e&&n(3,o=e.version)},[i,r,s,o,a,c,e=>c(e.id),(e,t)=>"Enter"===t.key&&c(e.id),e=>a(e.id)]}class Mg extends se{constructor(e){super(),re(this,e,Og,Lg,s,{isDarkTheme:0,tabs:1,selectedTab:2,version:3})}}function jg(t){let n,i,r,s,o,l;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to access export functionality.",r=m(),s=p("button"),s.textContent="Log In",A(i,"class","svelte-jzrdtj"),A(s,"class","login-btn svelte-jzrdtj"),A(n,"class","login-prompt svelte-jzrdtj")},m(e,a){u(e,n,a),c(n,i),c(n,r),c(n,s),o||(l=y(s,"click",t[5]),o=!0)},p:e,d(e){e&&d(n),o=!1,l()}}}function Hg(e){let t,n,i=e[0]&&Gg(e),r=e[1]&&Jg(e);return{c(){i&&i.c(),t=m(),r&&r.c(),n=v()},m(e,s){i&&i.m(e,s),u(e,t,s),r&&r.m(e,s),u(e,n,s)},p(e,s){e[0]?i?i.p(e,s):(i=Gg(e),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null),e[1]?r?r.p(e,s):(r=Jg(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},d(e){i&&i.d(e),e&&d(t),r&&r.d(e),e&&d(n)}}}function Gg(t){let n,i,r,s,o,l,a,f;return{c(){n=p("div"),i=p("h3"),i.textContent="Export My Events",r=m(),s=p("p"),s.textContent="Download your personal events as a JSONL file.",o=m(),l=p("button"),l.textContent="📤 Export My Events",A(i,"class","svelte-jzrdtj"),A(s,"class","svelte-jzrdtj"),A(l,"class","export-btn svelte-jzrdtj"),A(n,"class","export-section svelte-jzrdtj")},m(e,d){u(e,n,d),c(n,i),c(n,r),c(n,s),c(n,o),c(n,l),a||(f=y(l,"click",t[3]),a=!0)},p:e,d(e){e&&d(n),a=!1,f()}}}function Jg(t){let n,i,r,s,o,l,a,f;return{c(){n=p("div"),i=p("h3"),i.textContent="Export All Events",r=m(),s=p("p"),s.textContent="Download the complete database as a JSONL file. This includes\n all events from all users.",o=m(),l=p("button"),l.textContent="📤 Export All Events",A(i,"class","svelte-jzrdtj"),A(s,"class","svelte-jzrdtj"),A(l,"class","export-btn svelte-jzrdtj"),A(n,"class","export-section svelte-jzrdtj")},m(e,d){u(e,n,d),c(n,i),c(n,r),c(n,s),c(n,o),c(n,l),a||(f=y(l,"click",t[4]),a=!0)},p:e,d(e){e&&d(n),a=!1,f()}}}function Kg(t){let n;function i(e,t){return e[2]?Hg:jg}let r=i(t),s=r(t);return{c(){s.c(),n=v()},m(e,t){s.m(e,t),u(e,n,t)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&d(n)}}}function Vg(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{currentEffectiveRole:o=""}=t,{aclMode:l=""}=t;const a=P();return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"currentEffectiveRole"in e&&n(6,o=e.currentEffectiveRole),"aclMode"in e&&n(7,l=e.aclMode)},e.$$.update=()=>{129&e.$$.dirty&&n(2,i="none"===l||s),192&e.$$.dirty&&n(1,r="none"===l||"admin"===o||"owner"===o)},[s,r,i,function(){a("exportMyEvents")},function(){a("exportAllEvents")},function(){a("openLoginModal")},o,l]}class qg extends se{constructor(e){super(),re(this,e,Vg,Kg,s,{isLoggedIn:0,currentEffectiveRole:6,aclMode:7})}}function Yg(t){let n,i,r,s,o,l,a,f;return{c(){n=p("div"),i=p("h3"),i.textContent="Import Events",r=m(),s=p("p"),s.textContent="Please log in to access import functionality.",o=m(),l=p("button"),l.textContent="Log In",A(i,"class","recovery-header svelte-nonyqh"),A(s,"class","recovery-description svelte-nonyqh"),A(l,"class","login-btn svelte-nonyqh"),A(n,"class","login-prompt svelte-nonyqh")},m(e,d){u(e,n,d),c(n,i),c(n,r),c(n,s),c(n,o),c(n,l),a||(f=y(l,"click",t[6]),a=!0)},p:e,d(e){e&&d(n),a=!1,f()}}}function Wg(t){let n;return{c(){n=p("div"),n.innerHTML='

Import Events

\n

Admin or owner permission required for import functionality.

',A(n,"class","permission-denied svelte-nonyqh")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function zg(e){let t,n,r,s,o,l,a,f,h,v,w,b,k,I,C=e[2]&&Zg(e);return{c(){t=p("h3"),t.textContent="Import Events",n=m(),r=p("p"),r.textContent="Upload a JSONL file to import events into the database.",s=m(),o=p("div"),l=p("input"),a=m(),f=p("div"),h=p("button"),v=g("Import Events"),b=m(),C&&C.c(),A(t,"class","svelte-nonyqh"),A(r,"class","svelte-nonyqh"),A(l,"type","file"),A(l,"id","import-file"),A(l,"accept",".jsonl,.txt"),A(l,"class","svelte-nonyqh"),A(h,"class","import-btn svelte-nonyqh"),h.disabled=w=!e[1]||"Uploading..."===e[2],A(f,"class","import-row svelte-nonyqh"),A(o,"class","recovery-controls-card svelte-nonyqh")},m(i,d){u(i,t,d),u(i,n,d),u(i,r,d),u(i,s,d),u(i,o,d),c(o,l),c(o,a),c(o,f),c(f,h),c(h,v),c(f,b),C&&C.m(f,null),k||(I=[y(l,"change",e[4]),y(h,"click",e[5])],k=!0)},p(e,t){6&t&&w!==(w=!e[1]||"Uploading..."===e[2])&&(h.disabled=w),e[2]?C?C.p(e,t):(C=Zg(e),C.c(),C.m(f,null)):C&&(C.d(1),C=null)},d(e){e&&d(t),e&&d(n),e&&d(r),e&&d(s),e&&d(o),C&&C.d(),k=!1,i(I)}}}function Zg(e){let t,n;return{c(){t=p("span"),n=g(e[2]),A(t,"class","import-message svelte-nonyqh"),S(t,"uploading","Uploading..."===e[2]),S(t,"success","Upload complete"===e[2]),S(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,i){u(e,t,i),c(t,n)},p(e,i){4&i&&k(n,e[2]),4&i&&S(t,"uploading","Uploading..."===e[2]),4&i&&S(t,"success","Upload complete"===e[2]),4&i&&S(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&d(t)}}}function Xg(t){let n;function i(e,t){return e[3]?zg:e[0]?Wg:Yg}let r=i(t),s=r(t);return{c(){n=p("div"),s.c(),A(n,"class","import-section svelte-nonyqh")},m(e,t){u(e,n,t),s.m(n,null)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&d(n),s.d()}}}function em(e,t,n){let i,{isLoggedIn:r=!1}=t,{currentEffectiveRole:s=""}=t,{selectedFile:o=null}=t,{aclMode:l=""}=t,{importMessage:a=""}=t;const c=P();return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,s=e.currentEffectiveRole),"selectedFile"in e&&n(1,o=e.selectedFile),"aclMode"in e&&n(8,l=e.aclMode),"importMessage"in e&&n(2,a=e.importMessage)},e.$$.update=()=>{385&e.$$.dirty&&n(3,i="none"===l||r&&("admin"===s||"owner"===s))},[r,o,a,i,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},s,l]}class tm extends se{constructor(e){super(),re(this,e,em,Xg,s,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const nm={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 im(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function rm(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 sm(e){return Math.floor(new Date(e).getTime()/1e3)}function om(e,t,n){const i=e.slice();return i[62]=t[n],i[64]=n,i}function lm(e,t,n){const i=e.slice();return i[65]=t[n],i}function am(e,t,n){const i=e.slice();return i[68]=t[n],i}function cm(e,t,n){const i=e.slice();return i[71]=t[n],i}function um(e,t,n){const i=e.slice();return i[71]=t[n].kind,i[74]=t[n].name,i}function dm(e){let t,n,i,r,s,o,l=e[20],a=[];for(let t=0;t0&&pm(t),Ge=t[17]&&gm(t),Je=t[2].length>0&&mm(t),Ke=t[18]&&ym(t),Ve=t[3].length>0&&wm(t),qe=t[19]&&bm(t),Ye=t[4].length>0&&km(t),We=t[5]&&Cm(t),ze=t[6]&&Em(t),Ze=t[8]&&xm(t);return{c(){n=p("div"),r=p("div"),s=p("div"),o=p("label"),o.textContent="Search Text (NIP-50)",l=m(),a=p("div"),f=p("input"),h=m(),v=p("label"),v.textContent="Event Kinds",w=m(),C=p("div"),E=p("button"),x=g(Oe),B=g(" Select Kinds ("),Q=g(Me),F=g(" selected)"),D=m(),je&&je.c(),$=m(),He&&He.c(),P=m(),R=p("label"),R.textContent="Authors (Pubkeys)",T=m(),U=p("div"),_=p("div"),N=p("input"),L=m(),O=p("button"),O.textContent="Add",M=m(),Ge&&Ge.c(),j=m(),Je&&Je.c(),H=m(),G=p("label"),G.textContent="Event IDs",J=m(),K=p("div"),V=p("div"),q=p("input"),Y=m(),W=p("button"),W.textContent="Add",z=m(),Ke&&Ke.c(),Z=m(),Ve&&Ve.c(),X=m(),ee=p("label"),ee.textContent="Tags (#e, #p, #a)",te=m(),ne=p("div"),ie=p("div"),re=p("span"),re.textContent="#",se=m(),oe=p("input"),le=m(),ae=p("input"),ce=m(),ue=p("button"),ue.textContent="Add",de=m(),qe&&qe.c(),fe=m(),Ye&&Ye.c(),pe=m(),he=p("label"),he.textContent="Since",ge=m(),me=p("div"),ve=p("input"),ye=m(),We&&We.c(),we=m(),Ae=p("label"),Ae.textContent="Until",be=m(),ke=p("div"),Ie=p("input"),Ce=m(),ze&&ze.c(),Ee=m(),xe=p("label"),xe.textContent="Limit",Se=m(),Be=p("div"),Qe=p("input"),Fe=m(),Ze&&Ze.c(),De=m(),$e=p("div"),Pe=p("button"),Pe.textContent="🧹",Re=m(),Te=p("div"),Ue=m(),_e=p("button"),_e.textContent="",A(o,"for","search-text"),A(o,"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(a,"class","field-content svelte-1a1v6k0"),A(v,"class","svelte-1a1v6k0"),A(E,"class","picker-toggle-btn svelte-1a1v6k0"),A(C,"class","field-content svelte-1a1v6k0"),A(R,"class","svelte-1a1v6k0"),A(N,"type","text"),A(N,"placeholder","64 character hex pubkey..."),A(N,"class","filter-input svelte-1a1v6k0"),A(N,"maxlength","64"),A(O,"class","add-btn svelte-1a1v6k0"),A(_,"class","input-group svelte-1a1v6k0"),A(U,"class","field-content svelte-1a1v6k0"),A(G,"class","svelte-1a1v6k0"),A(q,"type","text"),A(q,"placeholder","64 character hex event ID..."),A(q,"class","filter-input svelte-1a1v6k0"),A(q,"maxlength","64"),A(W,"class","add-btn svelte-1a1v6k0"),A(V,"class","input-group svelte-1a1v6k0"),A(K,"class","field-content svelte-1a1v6k0"),A(ee,"class","svelte-1a1v6k0"),A(re,"class","hash-prefix svelte-1a1v6k0"),A(oe,"type","text"),A(oe,"placeholder","Tag"),A(oe,"class","filter-input tag-name-input svelte-1a1v6k0"),A(oe,"maxlength","1"),A(ae,"type","text"),A(ae,"placeholder","Value..."),A(ae,"class","filter-input tag-value-input svelte-1a1v6k0"),A(ue,"class","add-btn svelte-1a1v6k0"),A(ie,"class","tag-input-group svelte-1a1v6k0"),A(ne,"class","field-content svelte-1a1v6k0"),A(he,"for","since-timestamp"),A(he,"class","svelte-1a1v6k0"),A(ve,"id","since-timestamp"),A(ve,"type","datetime-local"),ve.value=t[32](),A(ve,"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(Qe,"id","limit"),A(Qe,"type","number"),A(Qe,"placeholder","Max events to return"),A(Qe,"class","filter-input svelte-1a1v6k0"),A(Qe,"min","1"),A(Be,"class","field-content svelte-1a1v6k0"),A(s,"class","filter-grid svelte-1a1v6k0"),A(r,"class","filter-content svelte-1a1v6k0"),A(Pe,"class","clear-all-btn svelte-1a1v6k0"),A(Pe,"title","Clear all filters"),A(Te,"class","spacer svelte-1a1v6k0"),A(_e,"class","json-toggle-btn svelte-1a1v6k0"),A(_e,"title","Edit filter JSON"),S(_e,"active",t[8]),A($e,"class","clear-column svelte-1a1v6k0"),A(n,"class","filter-builder svelte-1a1v6k0")},m(e,i){u(e,n,i),c(n,r),c(r,s),c(s,o),c(s,l),c(s,a),c(a,f),I(f,t[0]),c(s,h),c(s,v),c(s,w),c(s,C),c(C,E),c(E,x),c(E,B),c(E,Q),c(E,F),c(C,D),je&&je.m(C,null),c(C,$),He&&He.m(C,null),c(s,P),c(s,R),c(s,T),c(s,U),c(U,_),c(_,N),I(N,t[13]),c(_,L),c(_,O),c(U,M),Ge&&Ge.m(U,null),c(U,j),Je&&Je.m(U,null),c(s,H),c(s,G),c(s,J),c(s,K),c(K,V),c(V,q),I(q,t[14]),c(V,Y),c(V,W),c(K,z),Ke&&Ke.m(K,null),c(K,Z),Ve&&Ve.m(K,null),c(s,X),c(s,ee),c(s,te),c(s,ne),c(ne,ie),c(ie,re),c(ie,se),c(ie,oe),I(oe,t[15]),c(ie,le),c(ie,ae),I(ae,t[16]),c(ie,ce),c(ie,ue),c(ne,de),qe&&qe.m(ne,null),c(ne,fe),Ye&&Ye.m(ne,null),c(s,pe),c(s,he),c(s,ge),c(s,me),c(me,ve),c(me,ye),We&&We.m(me,null),c(s,we),c(s,Ae),c(s,be),c(s,ke),c(ke,Ie),c(ke,Ce),ze&&ze.m(ke,null),c(s,Ee),c(s,xe),c(s,Se),c(s,Be),c(Be,Qe),I(Qe,t[7]),c(s,Fe),Ze&&Ze.m(s,null),c(n,De),c(n,$e),c($e,Pe),c($e,Re),c($e,Te),c($e,Ue),c($e,_e),Ne||(Le=[y(f,"input",t[38]),y(E,"click",t[39]),y(N,"input",t[43]),y(N,"keydown",t[44]),y(O,"click",t[25]),y(q,"input",t[46]),y(q,"keydown",t[47]),y(W,"click",t[27]),y(oe,"input",t[49]),y(ae,"input",t[50]),y(ae,"keydown",t[51]),y(ue,"click",t[29]),y(ve,"change",t[34]),y(Ie,"change",t[35]),y(Qe,"input",t[55]),y(Pe,"click",t[31]),y(_e,"click",t[57])],Ne=!0)},p(e,t){1&t[0]&&f.value!==e[0]&&I(f,e[0]),4096&t[0]&&Oe!==(Oe=e[12]?"▼":"▶")&&k(x,Oe),2&t[0]&&Me!==(Me=e[1].length+"")&&k(Q,Me),e[12]?je?je.p(e,t):(je=dm(e),je.c(),je.m(C,$)):je&&(je.d(1),je=null),e[1].length>0?He?He.p(e,t):(He=pm(e),He.c(),He.m(C,null)):He&&(He.d(1),He=null),8192&t[0]&&N.value!==e[13]&&I(N,e[13]),e[17]?Ge?Ge.p(e,t):(Ge=gm(e),Ge.c(),Ge.m(U,j)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?Je?Je.p(e,t):(Je=mm(e),Je.c(),Je.m(U,null)):Je&&(Je.d(1),Je=null),16384&t[0]&&q.value!==e[14]&&I(q,e[14]),e[18]?Ke?Ke.p(e,t):(Ke=ym(e),Ke.c(),Ke.m(K,Z)):Ke&&(Ke.d(1),Ke=null),e[3].length>0?Ve?Ve.p(e,t):(Ve=wm(e),Ve.c(),Ve.m(K,null)):Ve&&(Ve.d(1),Ve=null),32768&t[0]&&oe.value!==e[15]&&I(oe,e[15]),65536&t[0]&&ae.value!==e[16]&&I(ae,e[16]),e[19]?qe?qe.p(e,t):(qe=bm(e),qe.c(),qe.m(ne,fe)):qe&&(qe.d(1),qe=null),e[4].length>0?Ye?Ye.p(e,t):(Ye=km(e),Ye.c(),Ye.m(ne,null)):Ye&&(Ye.d(1),Ye=null),e[5]?We?We.p(e,t):(We=Cm(e),We.c(),We.m(me,null)):We&&(We.d(1),We=null),e[6]?ze?ze.p(e,t):(ze=Em(e),ze.c(),ze.m(ke,null)):ze&&(ze.d(1),ze=null),128&t[0]&&b(Qe.value)!==e[7]&&I(Qe,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=xm(e),Ze.c(),Ze.m(s,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&S(_e,"active",e[8])},i:e,o:e,d(e){e&&d(n),je&&je.d(),He&&He.d(),Ge&&Ge.d(),Je&&Je.d(),Ke&&Ke.d(),Ve&&Ve.d(),qe&&qe.d(),Ye&&Ye.d(),We&&We.d(),ze&&ze.d(),Ze&&Ze.d(),Ne=!1,i(Le)}}}function Qm(e,t,n){let i,r;const s=P();let{searchText:o=""}=t,{selectedKinds:l=[]}=t,{pubkeys:a=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:p=null}=t,{showJsonEditor:h=!1}=t,g="",m="",v=!1,y="",w="",A="",k="",I="",C="",E="",x="",S=null,B=!1;function Q(e){l.includes(e)?n(1,l=l.filter(t=>t!==e)):n(1,l=[...l,e].sort((e,t)=>e-t))}function F(e){n(1,l=l.filter(t=>t!==e))}function D(){const e=w.trim();e&&(im(e,64)?a.includes(e)?n(17,C="Pubkey already added"):(n(2,a=[...a,e]),n(13,w=""),n(17,C="")):n(17,C="Invalid pubkey: must be 64 character hex string"))}function R(e){n(2,a=a.filter(t=>t!==e))}function T(){const e=A.trim();e&&(im(e,64)?c.includes(e)?n(18,E="Event ID already added"):(n(3,c=[...c,e]),n(14,A=""),n(18,E="")):n(18,E="Invalid event ID: must be 64 character hex string"))}function U(e){n(3,c=c.filter(t=>t!==e))}function _(){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 N(e){n(4,u=u.filter((t,n)=>n!==e))}function L(){s("apply",{searchText:o,selectedKinds:l,pubkeys:a,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:p})}$(()=>{S&&clearTimeout(S)});return e.$$set=e=>{"searchText"in e&&n(0,o=e.searchText),"selectedKinds"in e&&n(1,l=e.selectedKinds),"pubkeys"in e&&n(2,a=e.pubkeys),"eventIds"in e&&n(3,c=e.eventIds),"tags"in e&&n(4,u=e.tags),"sinceTimestamp"in e&&n(5,d=e.sinceTimestamp),"untilTimestamp"in e&&n(6,f=e.untilTimestamp),"limit"in e&&n(7,p=e.limit),"showJsonEditor"in e&&n(8,h=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&h){const e=function(){const e={};return l.length>0&&(e.kinds=l),a.length>0&&(e.authors=a),c.length>0&&(e.ids=c),d&&(e.since=d),f&&(e.until=f),p&&(e.limit=p),o&&(e.search=o),u.forEach(t=>{const n=`#${t.name}`;e[n]||(e[n]=[]),e[n].push(t.value)}),e}();n(10,g=JSON.stringify(e,null,2))}255&e.$$.dirty[0]|32&e.$$.dirty[1]&&(B?(S&&clearTimeout(S),S=setTimeout(()=>{L()},1e3)):n(36,B=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,r=i.filter(e=>e.kind.toString().includes(y)||e.name.toLowerCase().includes(y.toLowerCase())))},n(37,i=Object.entries(nm).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[o,l,a,c,u,d,f,p,h,y,g,m,v,w,A,k,I,C,E,x,r,s,function(){try{const e=JSON.parse(g);n(11,m=""),n(1,l=e.kinds||[]),n(2,a=e.authors||[]),n(3,c=e.ids||[]),n(5,d=e.since||null),n(6,f=e.until||null),n(7,p=e.limit||null),n(0,o=e.search||""),n(4,u=[]),Object.keys(e).forEach(t=>{if(t.startsWith("#")&&2===t.length){const n=t.slice(1);(Array.isArray(e[t])?e[t]:[e[t]]).forEach(e=>{u.push({name:n,value:String(e)})})}}),n(4,u),S&&clearTimeout(S),L()}catch(e){n(11,m="Invalid JSON: "+e.message)}},Q,F,D,R,T,U,_,N,function(){n(0,o=""),n(1,l=[]),n(2,a=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,p=null),s("clear")},function(){return d?rm(d):""},function(){return f?rm(f):""},function(e){const t=e.target.value;n(5,d=t?sm(t):null)},function(e){const t=e.target.value;n(6,f=t?sm(t):null)},B,i,function(){o=this.value,n(0,o)},()=>n(12,v=!v),function(){y=this.value,n(9,y)},e=>Q(e),e=>F(e),function(){w=this.value,n(13,w)},e=>"Enter"===e.key&&D(),e=>R(e),function(){A=this.value,n(14,A)},e=>"Enter"===e.key&&T(),e=>U(e),function(){k=this.value,n(15,k)},function(){I=this.value,n(16,I)},e=>"Enter"===e.key&&_(),e=>N(e),()=>n(5,d=null),()=>n(6,f=null),function(){p=b(this.value),n(7,p)},function(){g=this.value,n(10,g),n(8,h)},()=>s("toggleJson")]}class Fm extends se{constructor(e){super(),re(this,e,Qm,Bm,s,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function Dm(e,t,n){const i=e.slice();return i[28]=t[n],i}function $m(e,t,n){const i=e.slice();return i[31]=t[n],i}function Pm(t){let n;return{c(){n=p("div"),n.innerHTML="

❌ Read, write, admin, or owner permission required to view all\n events.

",A(n,"class","permission-denied svelte-kw5eww")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Rm(e){let t,n,i,r;function s(e,t){return e[4].length>0?Um:e[6]?void 0:Tm}let o=s(e),l=o&&o(e),a=e[6]&&Gm();return{c(){t=p("div"),l&&l.c(),n=m(),a&&a.c(),A(t,"class","events-view-content svelte-kw5eww")},m(s,o){u(s,t,o),l&&l.m(t,null),c(t,n),a&&a.m(t,null),i||(r=y(t,"scroll",e[9]),i=!0)},p(e,i){o===(o=s(e))&&l?l.p(e,i):(l&&l.d(1),l=o&&o(e),l&&(l.c(),l.m(t,n))),e[6]?a||(a=Gm(),a.c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&d(t),l&&l.d(),a&&a.d(),i=!1,r()}}}function Tm(t){let n;return{c(){n=p("div"),n.innerHTML="

No events found.

",A(n,"class","no-events svelte-kw5eww")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Um(e){let t,n=e[4],i=[];for(let t=0;t0&&Lm(e);return{c(){t=p("div"),n=p("span"),n.textContent="🗑️ Delete Event",i=m(),r&&r.c(),A(n,"class","delete-event-label svelte-kw5eww"),A(t,"class","delete-event-info svelte-kw5eww")},m(e,s){u(e,t,s),c(t,n),c(t,i),r&&r.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?r?r.p(e,n):(r=Lm(e),r.c(),r.m(t,null)):r&&(r.d(1),r=null)},d(e){e&&d(t),r&&r.d()}}}function Lm(e){let t,n=e[28].tags.filter(Xm),i=[];for(let t=0;t👤',s=m(),o=p("div"),l=p("div"),a=g(U),f=m(),h=p("div"),v=p("span"),w=g(_),b=m(),I=p("span"),C=g(N),E=m(),x=p("div"),B=p("div"),Q=g(L),F=m(),H.c(),D=m(),G&&G.c(),$=m(),V&&V.c(),P=m(),A(r,"class","events-view-avatar svelte-kw5eww"),A(l,"class","events-view-author svelte-kw5eww"),A(v,"class","kind-number svelte-kw5eww"),S(v,"delete-event",5===e[28].kind),A(I,"class","kind-name svelte-kw5eww"),A(h,"class","events-view-kind svelte-kw5eww"),A(o,"class","events-view-info svelte-kw5eww"),A(B,"class","event-timestamp svelte-kw5eww"),A(x,"class","events-view-content svelte-kw5eww"),A(n,"class","events-view-row svelte-kw5eww"),A(n,"role","button"),A(n,"tabindex","0"),A(t,"class","events-view-item svelte-kw5eww"),S(t,"expanded",e[5].has(e[28].id))},m(e,i){u(e,t,i),c(t,n),c(n,r),c(n,s),c(n,o),c(o,l),c(l,a),c(o,f),c(o,h),c(h,v),c(v,w),c(h,b),c(h,I),c(I,C),c(n,E),c(n,x),c(x,B),c(B,Q),c(x,F),H.m(x,null),c(n,D),G&&G.m(n,null),c(t,$),V&&V.m(t,null),c(t,P),R||(T=[y(n,"click",J),y(n,"keydown",K)],R=!0)},p(i,r){e=i,16&r[0]&&U!==(U=Ym(e[28].pubkey)+"")&&k(a,U),16&r[0]&&_!==(_=e[28].kind+"")&&k(w,_),16&r[0]&&S(v,"delete-event",5===e[28].kind),16&r[0]&&N!==(N=Wm(e[28].kind)+"")&&k(C,N),16&r[0]&&L!==(L=zm(e[28].created_at)+"")&&k(Q,L),j===(j=M(e))&&H?H.p(e,r):(H.d(1),H=j(e),H&&(H.c(),H.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,r):(G=Mm(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),48&r[0]&&(O=e[5].has(e[28].id)),O?V?V.p(e,r):(V=jm(e),V.c(),V.m(t,P)):V&&(V.d(1),V=null),48&r[0]&&S(t,"expanded",e[5].has(e[28].id))},d(e){e&&d(t),H.d(),G&&G.d(),V&&V.d(),R=!1,i(T)}}}function Gm(e){let t;return{c(){t=p("div"),t.innerHTML='
\n

Loading events...

',A(t,"class","loading-events svelte-kw5eww")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Jm(e){let t,n,r,s,o,l,a,f,h,v,w,b,k,I,C,E,x,B,Q,F,D,$,P,R;function T(e,t){return e[6]?Vm:Km}r=new Fm({props:{showJsonEditor:e[8]}}),r.$on("apply",e[17]),r.$on("clear",e[18]),r.$on("toggleJson",e[16]);let U=T(e),_=U(e);return{c(){t=p("div"),n=p("div"),ee(r.$$.fragment),s=m(),o=p("div"),l=p("div"),a=p("button"),a.innerHTML='',f=m(),h=p("div"),v=p("label"),w=p("input"),b=m(),k=p("span"),I=m(),C=p("span"),C.textContent="Only show my events",E=m(),x=p("div"),B=p("button"),Q=g("🔄 Load More"),F=m(),D=p("button"),_.c(),A(n,"class","filter-panel svelte-kw5eww"),S(n,"open",e[7]),A(a,"class","filter-btn svelte-kw5eww"),A(a,"title","Filter events"),S(a,"active",e[7]),A(w,"type","checkbox"),A(w,"class","svelte-kw5eww"),A(k,"class","toggle-slider svelte-kw5eww"),A(C,"class","toggle-label svelte-kw5eww"),A(v,"class","toggle-container svelte-kw5eww"),A(h,"class","events-view-toggle svelte-kw5eww"),A(l,"class","events-view-left svelte-kw5eww"),A(B,"class","refresh-btn svelte-kw5eww"),B.disabled=e[6],A(D,"class","reload-btn svelte-kw5eww"),D.disabled=e[6],A(x,"class","events-view-buttons svelte-kw5eww"),A(o,"class","events-view-header svelte-kw5eww"),A(t,"class","events-view-footer svelte-kw5eww")},m(i,d){u(i,t,d),c(t,n),te(r,n,null),c(t,s),c(t,o),c(o,l),c(l,a),c(l,f),c(l,h),c(h,v),c(v,w),w.checked=e[0],c(v,b),c(v,k),c(v,I),c(v,C),c(o,E),c(o,x),c(x,B),c(B,Q),c(x,F),c(x,D),_.m(D,null),$=!0,P||(R=[y(a,"click",e[15]),y(w,"change",e[23]),y(w,"change",e[24]),y(B,"click",e[25]),y(D,"click",e[26])],P=!0)},p(e,t){const i={};256&t[0]&&(i.showJsonEditor=e[8]),r.$set(i),(!$||128&t[0])&&S(n,"open",e[7]),(!$||128&t[0])&&S(a,"active",e[7]),1&t[0]&&(w.checked=e[0]),(!$||64&t[0])&&(B.disabled=e[6]),U!==(U=T(e))&&(_.d(1),_=U(e),_&&(_.c(),_.m(D,null))),(!$||64&t[0])&&(D.disabled=e[6])},i(e){$||(z(r.$$.fragment,e),$=!0)},o(e){Z(r.$$.fragment,e),$=!1},d(e){e&&d(t),ne(r),_.d(),P=!1,i(R)}}}function Km(e){let t;return{c(){t=g("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Vm(e){let t;return{c(){t=p("div"),A(t,"class","spinner svelte-kw5eww")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function qm(e){let t,n,i;function r(e,t){return!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?Pm:Rm}let s=r(e),o=s(e),l=e[1]&&("read"===e[2]||"write"===e[2]||"admin"===e[2]||"owner"===e[2])&&Jm(e);return{c(){t=p("div"),o.c(),n=m(),l&&l.c(),A(t,"class","events-view-container svelte-kw5eww")},m(e,r){u(e,t,r),o.m(t,null),c(t,n),l&&l.m(t,null),i=!0},p(e,i){s===(s=r(e))&&o?o.p(e,i):(o.d(1),o=s(e),o&&(o.c(),o.m(t,n))),!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?l&&(Y(),Z(l,1,1,()=>{l=null}),W()):l?(l.p(e,i),6&i[0]&&z(l,1)):(l=Jm(e),l.c(),z(l,1),l.m(t,null))},i(e){i||(z(l),i=!0)},o(e){Z(l),i=!1},d(e){e&&d(t),o.d(),l&&l.d()}}}function Ym(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function Wm(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 zm(e){return new Date(1e3*e).toLocaleString()}function Zm(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const Xm=e=>"e"===e[0];function ev(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{userPubkey:s=""}=t,{filteredEvents:o=[]}=t,{expandedEvents:l=new Set}=t,{isLoadingEvents:a=!1}=t,{showOnlyMyEvents:c=!1}=t,{showFilterBuilder:u=!1}=t;const d=P();let f=!1;function p(e){d("toggleEventExpansion",e)}function h(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function v(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"userPubkey"in e&&n(3,s=e.userPubkey),"filteredEvents"in e&&n(4,o=e.filteredEvents),"expandedEvents"in e&&n(5,l=e.expandedEvents),"isLoadingEvents"in e&&n(6,a=e.isLoadingEvents),"showOnlyMyEvents"in e&&n(0,c=e.showOnlyMyEvents),"showFilterBuilder"in e&&n(7,u=e.showFilterBuilder)},[c,i,r,s,o,l,a,u,f,function(e){d("scroll",e)},p,h,g,m,v,function(){d("toggleFilterBuilder")},function(){n(8,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},e=>h(e.id),e=>p(e.id),(e,t)=>"Enter"===t.key&&p(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{v(!1,c&&s?[s]:null)},()=>{v(!0,c&&s?[s]:null)}]}class tv extends se{constructor(e){super(),re(this,e,ev,qm,s,{isLoggedIn:1,userRole:2,userPubkey:3,filteredEvents:4,expandedEvents:5,isLoadingEvents:6,showOnlyMyEvents:0,showFilterBuilder:7},null,[-1,-1])}}const nv=[{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 iv(e,t=null){const n=function(e){return nv.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||""}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||""}}const rv=[{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 sv(e,t,n){const i=e.slice();return i[13]=t[n],i}function ov(e,t,n){const i=e.slice();return i[16]=t[n],i}function lv(e){let t,n,r,s,o,l,a,h,v,w,b,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N=e[3].length+"",L=1!==e[3].length?"s":"",O=rv,M=[];for(let t=0;t=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function gv(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function mv(e,t,n){let{isOpen:i=!1}=t,{userPubkey:r=""}=t;const s=P();let o="",l="all",a=nv;function c(e){const t=iv(e.kind,r);s("select",{kind:e,template:t}),u()}function u(){n(0,i=!1),n(1,o=""),n(2,l="all"),s("close")}return e.$$set=e=>{"isOpen"in e&&n(0,i=e.isOpen),"userPubkey"in e&&n(8,r=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=nv;const t=rv.find(e=>e.id===l);if(t&&(e=e.filter(t.filter)),o.trim()){const t=o.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.kind.toString().includes(t)||e.nip&&e.nip.includes(t))}n(3,a=e)}},[i,o,l,a,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},r,function(){o=this.value,n(1,o)},e=>n(2,l=e.id),e=>c(e)]}class vv extends se{constructor(e){super(),re(this,e,mv,pv,s,{isOpen:0,userPubkey:8})}}function yv(e){let t,n,i,r,s,o,l,a,f,h;return{c(){t=p("div"),n=p("div"),i=p("span"),i.textContent="⚠",r=m(),s=p("span"),o=g(e[1]),l=m(),a=p("button"),a.textContent="×",A(i,"class","error-icon svelte-46pmgb"),A(s,"class","error-message svelte-46pmgb"),A(n,"class","error-content svelte-46pmgb"),A(a,"class","error-dismiss svelte-46pmgb"),A(t,"class","error-banner svelte-46pmgb")},m(d,p){u(d,t,p),c(t,n),c(n,i),c(n,r),c(n,s),c(s,o),c(t,l),c(t,a),f||(h=y(a,"click",e[10]),f=!0)},p(e,t){2&t&&k(o,e[1])},d(e){e&&d(t),f=!1,h()}}}function wv(e){let t,n,r,s,o,l,a,f,h,g,v,w,b,k,C,E,x,S,B,Q=e[1]&&yv(e);function F(t){e[14](t)}let D={userPubkey:e[2]};return void 0!==e[3]&&(D.isOpen=e[3]),C=new vv({props:D}),U.push(()=>X(C,"isOpen",F)),C.$on("select",e[8]),C.$on("close",e[9]),{c(){t=p("div"),n=p("div"),r=p("button"),r.textContent="Generate Template",s=m(),o=p("button"),o.textContent="Reformat",l=m(),a=p("button"),a.textContent="Sign",f=m(),h=p("button"),h.textContent="Publish",g=m(),Q&&Q.c(),v=m(),w=p("div"),b=p("textarea"),k=m(),ee(C.$$.fragment),A(r,"class","compose-btn template-btn svelte-46pmgb"),A(o,"class","compose-btn reformat-btn svelte-46pmgb"),A(a,"class","compose-btn sign-btn svelte-46pmgb"),A(h,"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(w,"class","compose-editor svelte-46pmgb"),A(t,"class","compose-view svelte-46pmgb")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(n,l),c(n,a),c(n,f),c(n,h),c(t,g),Q&&Q.m(t,null),c(t,v),c(t,w),c(w,b),I(b,e[0]),u(i,k,d),te(C,i,d),x=!0,S||(B=[y(r,"click",e[7]),y(o,"click",e[4]),y(a,"click",e[5]),y(h,"click",e[6]),y(b,"input",e[13])],S=!0)},p(e,[n]){e[1]?Q?Q.p(e,n):(Q=yv(e),Q.c(),Q.m(t,v)):Q&&(Q.d(1),Q=null),1&n&&I(b,e[0]);const i={};4&n&&(i.userPubkey=e[2]),!E&&8&n&&(E=!0,i.isOpen=e[3],j(()=>E=!1)),C.$set(i)},i(e){x||(z(C.$$.fragment,e),x=!0)},o(e){Z(C.$$.fragment,e),x=!1},d(e){e&&d(t),Q&&Q.d(),e&&d(k),ne(C,e),S=!1,i(B)}}}function Av(e,t,n){let{composeEventJson:i=""}=t,{userPubkey:r=""}=t,{userRole:s=""}=t,{policyEnabled:o=!1}=t,{publishError:l=""}=t;const a=P();let c=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,i=e.composeEventJson),"userPubkey"in e&&n(2,r=e.userPubkey),"userRole"in e&&n(11,s=e.userRole),"policyEnabled"in e&&n(12,o=e.policyEnabled),"publishError"in e&&n(1,l=e.publishError)},[i,l,r,c,function(){a("reformatJson")},function(){a("signEvent")},function(){a("publishEvent")},function(){n(3,c=!0)},function(e){const{kind:t,template:r}=e.detail;n(0,i=JSON.stringify(r,null,2)),a("templateSelected",{kind:t,template:r})},function(){n(3,c=!1)},function(){n(1,l=""),a("clearError")},s,o,function(){i=this.value,n(0,i)},function(e){c=e,n(3,c)}]}class bv extends se{constructor(e){super(),re(this,e,Av,wv,s,{composeEventJson:0,userPubkey:2,userRole:11,policyEnabled:12,publishError:1})}}function kv(e,t,n){const i=e.slice();return i[23]=t[n],i}function Iv(t){let n,i,r,s,o,l;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to access sprocket management.",r=m(),s=p("button"),s.textContent="Log In",A(i,"class","svelte-fiaj1r"),A(s,"class","login-btn svelte-fiaj1r"),A(n,"class","login-prompt svelte-fiaj1r")},m(e,a){u(e,n,a),c(n,i),c(n,r),c(n,s),o||(l=y(s,"click",t[18]),o=!0)},p:e,d(e){e&&d(n),o=!1,l()}}}function Cv(e){let t,n,i,r,s,o,l,a,f,h=(e[2]||"none")+"";return{c(){t=p("div"),n=p("p"),n.textContent="❌ Owner permission required for sprocket management.",i=m(),r=p("p"),r.innerHTML='To enable sprocket functionality, set the ORLY_OWNERS environment variable with your npub when starting the relay.',s=m(),o=p("p"),l=g("Current user role: "),a=p("strong"),f=g(h),A(n,"class","svelte-fiaj1r"),A(r,"class","svelte-fiaj1r"),A(o,"class","svelte-fiaj1r"),A(t,"class","permission-denied svelte-fiaj1r")},m(e,d){u(e,t,d),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o),c(o,l),c(o,a),c(a,f)},p(e,t){4&t&&h!==(h=(e[2]||"none")+"")&&k(f,h)},d(e){e&&d(t)}}}function Ev(e){let t,n,r,s,o,l,a,h,v,w,b,C,E,x,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te,ne,ie,re,se,oe,le,ae,ce,ue,de,fe,pe,he,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ve=e[3]?.script_exists?"✅ Exists":"❌ Not found",ye=e[3]?.pid&&xv(e),we=e[6]&&Sv(e),Ae=e[8],be=[];for(let t=0;t{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"sprocketStatus"in e&&n(3,s=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,o=e.isLoadingSprocket),"sprocketUploadFile"in e&&n(5,l=e.sprocketUploadFile),"sprocketScript"in e&&n(0,a=e.sprocketScript),"sprocketMessage"in e&&n(6,c=e.sprocketMessage),"sprocketMessageType"in e&&n(7,u=e.sprocketMessageType),"sprocketVersions"in e&&n(8,d=e.sprocketVersions)},[a,i,r,s,o,l,c,u,d,function(){f("restartSprocket")},function(){f("deleteSprocket")},function(e){f("sprocketFileSelect",e)},function(){f("uploadSprocketScript")},function(){f("saveSprocket")},function(){f("loadSprocket")},function(){f("loadVersions")},p,h,function(){f("openLoginModal")},function(){a=this.value,n(0,a)},e=>p(e),e=>h(e.name)]}class Pv extends se{constructor(e){super(),re(this,e,$v,Dv,s,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function Rv(e,t,n){const i=e.slice();return i[26]=t[n],i}function Tv(e,t,n){const i=e.slice();return i[29]=t[n],i}function Uv(e,t,n){const i=e.slice();return i[32]=t[n],i}function _v(t){let n,i,r,s,o,l;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to access policy configuration.",r=m(),s=p("button"),s.textContent="Log In",A(i,"class","svelte-gkxvxc"),A(s,"class","login-btn svelte-gkxvxc"),A(n,"class","login-prompt svelte-gkxvxc")},m(e,a){u(e,n,a),c(n,i),c(n,r),c(n,s),o||(l=y(s,"click",t[16]),o=!0)},p:e,d(e){e&&d(n),o=!1,l()}}}function Nv(e){let t,n,i,r,s,o,l,a,f,h=(e[3]||"none")+"";return{c(){t=p("div"),n=p("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",i=m(),r=p("p"),r.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n to the policy_admins list.',s=m(),o=p("p"),l=g("Current user role: "),a=p("strong"),f=g(h),A(n,"class","svelte-gkxvxc"),A(r,"class","svelte-gkxvxc"),A(o,"class","svelte-gkxvxc"),A(t,"class","permission-denied svelte-gkxvxc")},m(e,d){u(e,t,d),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o),c(o,l),c(o,a),c(a,f)},p(e,t){8&t[0]&&h!==(h=(e[3]||"none")+"")&&k(f,h)},d(e){e&&d(t)}}}function Lv(e){let t,n,r,s,o,l,a,f,h,v,w,b,C,E,x,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te,ne,ie,re,se,oe,le,ae,ce,ue,de,fe,pe,he,ge,me,ve,ye,we,Ae,be,ke,Ie,Ce,Ee,xe,Se,Be,Qe,Fe,De,$e,Pe,Re=e[5]?"Policy Enabled":"Policy Disabled",Te=e[10].length+"",Ue=e[4]&&Ov(),_e=e[9].length>0&&Mv(e),Ne=e[7]&&Hv(e);function Le(e,t){return 0===e[1].length?Jv:Gv}let Oe=Le(e),Me=Oe(e);function je(e,t){return 0===e[10].length?qv:Vv}let He=je(e),Ge=He(e);return{c(){t=p("div"),n=p("div"),r=p("h3"),r.textContent="Policy Editor",s=m(),o=p("div"),l=p("span"),a=g(Re),f=m(),Ue&&Ue.c(),h=m(),v=p("div"),v.innerHTML='

Edit the policy JSON below and click "Save & Publish" to update the relay's policy configuration.\n Changes are applied immediately after validation.

\n

Policy updates are published as kind 12345 events and require policy admin permissions.

',w=m(),b=p("div"),C=p("textarea"),E=m(),_e&&_e.c(),x=m(),B=p("div"),Q=p("button"),F=g("Load Current"),D=m(),$=p("button"),P=g("Format JSON"),R=m(),T=p("button"),U=g("Validate"),_=m(),N=p("button"),L=g("Save & Publish"),O=m(),Ne&&Ne.c(),M=m(),j=p("div"),H=p("h3"),H.textContent="Policy Administrators",G=m(),J=p("div"),J.innerHTML='

Policy admins can update the relay's policy configuration via kind 12345 events.\n Their follows get whitelisted if policy_follow_whitelist_enabled is true in the policy.

\n

Note: Policy admins are separate from relay admins (ORLY_ADMINS).\n Changes here update the JSON editor - click "Save & Publish" to apply.

',K=m(),V=p("div"),Me.c(),q=m(),Y=p("div"),W=p("input"),z=m(),Z=p("button"),X=g("+ Add Admin"),te=m(),ne=p("div"),ie=p("h3"),ie.textContent="Policy Follow Whitelist",re=m(),se=p("div"),se.innerHTML='

Pubkeys followed by policy admins (kind 3 events).\n These get automatic read+write access when rules have write_allow_follows: true.

',oe=m(),le=p("div"),ae=p("span"),ce=g(Te),ue=g(" pubkey(s) in whitelist"),de=m(),fe=p("button"),pe=g("🔄 Refresh Follows"),he=m(),ge=p("div"),Ge.c(),me=m(),ve=p("div"),ye=p("h3"),ye.textContent="Policy Reference",we=m(),Ae=p("div"),be=p("h4"),be.textContent="Structure Overview",ke=m(),Ie=p("ul"),Ie.innerHTML='
  • kind.whitelist - Only allow these event kinds (takes precedence)
  • \n
  • kind.blacklist - Deny these event kinds (if no whitelist)
  • \n
  • global - Rules applied to all events
  • \n
  • rules - Per-kind rules (keyed by kind number as string)
  • \n
  • default_policy - "allow" or "deny" when no rules match
  • \n
  • policy_admins - Hex pubkeys that can update policy
  • \n
  • policy_follow_whitelist_enabled - Enable follow-based access
  • ',Ce=m(),Ee=p("h4"),Ee.textContent="Rule Fields",xe=m(),Se=p("ul"),Se.innerHTML='
  • description - Human-readable rule description
  • \n
  • write_allow / write_deny - Pubkey lists for write access
  • \n
  • read_allow / read_deny - Pubkey lists for read access
  • \n
  • write_allow_follows - Grant access to policy admin follows
  • \n
  • size_limit - Max total event size in bytes
  • \n
  • content_limit - Max content field size in bytes
  • \n
  • max_expiry - Max expiry offset in seconds
  • \n
  • max_age_of_event - Max age of created_at in seconds
  • \n
  • max_age_event_in_future - Max future offset in seconds
  • \n
  • must_have_tags - Required tag letters (e.g., ["d", "t"])
  • \n
  • tag_validation - Regex patterns for tag values
  • \n
  • script - Path to external validation script
  • ',Be=m(),Qe=p("h4"),Qe.textContent="Example Policy",Fe=m(),De=p("pre"),De.textContent=`${e[20]}`,A(r,"class","svelte-gkxvxc"),A(l,"class","status-badge svelte-gkxvxc"),S(l,"enabled",e[5]),A(o,"class","policy-status svelte-gkxvxc"),A(n,"class","policy-header svelte-gkxvxc"),A(v,"class","policy-info svelte-gkxvxc"),A(C,"class","policy-editor svelte-gkxvxc"),A(C,"placeholder","Loading policy configuration..."),C.disabled=e[6],A(C,"spellcheck","false"),A(b,"class","editor-container svelte-gkxvxc"),A(Q,"class","policy-btn load-btn svelte-gkxvxc"),Q.disabled=e[6],A($,"class","policy-btn format-btn svelte-gkxvxc"),$.disabled=e[6],A(T,"class","policy-btn validate-btn svelte-gkxvxc"),T.disabled=e[6],A(N,"class","policy-btn save-btn svelte-gkxvxc"),N.disabled=e[6],A(B,"class","policy-actions svelte-gkxvxc"),A(t,"class","policy-section svelte-gkxvxc"),A(J,"class","policy-info svelte-gkxvxc"),A(V,"class","admin-list svelte-gkxvxc"),A(W,"type","text"),A(W,"placeholder","npub or hex pubkey"),W.disabled=e[6],A(W,"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(j,"class","policy-section svelte-gkxvxc"),A(se,"class","policy-info svelte-gkxvxc"),A(ae,"class","follows-count svelte-gkxvxc"),A(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],A(le,"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(Ee,"class","svelte-gkxvxc"),A(Se,"class","field-list svelte-gkxvxc"),A(Qe,"class","svelte-gkxvxc"),A(De,"class","example-json svelte-gkxvxc"),A(Ae,"class","reference-content svelte-gkxvxc"),A(ve,"class","policy-section svelte-gkxvxc")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,l),c(l,a),c(o,f),Ue&&Ue.m(o,null),c(t,h),c(t,v),c(t,w),c(t,b),c(b,C),I(C,e[0]),c(t,E),_e&&_e.m(t,null),c(t,x),c(t,B),c(B,Q),c(Q,F),c(B,D),c(B,$),c($,P),c(B,R),c(B,T),c(T,U),c(B,_),c(B,N),c(N,L),c(t,O),Ne&&Ne.m(t,null),u(i,M,d),u(i,j,d),c(j,H),c(j,G),c(j,J),c(j,K),c(j,V),Me.m(V,null),c(j,q),c(j,Y),c(Y,W),I(W,e[11]),c(Y,z),c(Y,Z),c(Z,X),u(i,te,d),u(i,ne,d),c(ne,ie),c(ne,re),c(ne,se),c(ne,oe),c(ne,le),c(le,ae),c(ae,ce),c(ae,ue),c(le,de),c(le,fe),c(fe,pe),c(ne,he),c(ne,ge),Ge.m(ge,null),u(i,me,d),u(i,ve,d),c(ve,ye),c(ve,we),c(ve,Ae),c(Ae,be),c(Ae,ke),c(Ae,Ie),c(Ae,Ce),c(Ae,Ee),c(Ae,xe),c(Ae,Se),c(Ae,Be),c(Ae,Qe),c(Ae,Fe),c(Ae,De),$e||(Pe=[y(C,"input",e[21]),y(Q,"click",e[12]),y($,"click",e[15]),y(T,"click",e[13]),y(N,"click",e[14]),y(W,"input",e[23]),y(W,"keydown",e[24]),y(Z,"click",e[18]),y(fe,"click",e[17])],$e=!0)},p(e,n){32&n[0]&&Re!==(Re=e[5]?"Policy Enabled":"Policy Disabled")&&k(a,Re),32&n[0]&&S(l,"enabled",e[5]),e[4]?Ue||(Ue=Ov(),Ue.c(),Ue.m(o,null)):Ue&&(Ue.d(1),Ue=null),64&n[0]&&(C.disabled=e[6]),1&n[0]&&I(C,e[0]),e[9].length>0?_e?_e.p(e,n):(_e=Mv(e),_e.c(),_e.m(t,x)):_e&&(_e.d(1),_e=null),64&n[0]&&(Q.disabled=e[6]),64&n[0]&&($.disabled=e[6]),64&n[0]&&(T.disabled=e[6]),64&n[0]&&(N.disabled=e[6]),e[7]?Ne?Ne.p(e,n):(Ne=Hv(e),Ne.c(),Ne.m(t,null)):Ne&&(Ne.d(1),Ne=null),Oe===(Oe=Le(e))&&Me?Me.p(e,n):(Me.d(1),Me=Oe(e),Me&&(Me.c(),Me.m(V,null))),64&n[0]&&(W.disabled=e[6]),2048&n[0]&&W.value!==e[11]&&I(W,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Te!==(Te=e[10].length+"")&&k(ce,Te),64&n[0]&&(fe.disabled=e[6]),He===(He=je(e))&&Ge?Ge.p(e,n):(Ge.d(1),Ge=He(e),Ge&&(Ge.c(),Ge.m(ge,null)))},d(e){e&&d(t),Ue&&Ue.d(),_e&&_e.d(),Ne&&Ne.d(),e&&d(M),e&&d(j),Me.d(),e&&d(te),e&&d(ne),Ge.d(),e&&d(me),e&&d(ve),$e=!1,i(Pe)}}}function Ov(e){let t;return{c(){t=p("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 Mv(e){let t,n,i,r,s=e[9],o=[];for(let t=0;t{"isLoggedIn"in e&&n(2,i=e.isLoggedIn),"userRole"in e&&n(3,r=e.userRole),"isPolicyAdmin"in e&&n(4,s=e.isPolicyAdmin),"policyEnabled"in e&&n(5,o=e.policyEnabled),"policyJson"in e&&n(0,l=e.policyJson),"isLoadingPolicy"in e&&n(6,a=e.isLoadingPolicy),"policyMessage"in e&&n(7,c=e.policyMessage),"policyMessageType"in e&&n(8,u=e.policyMessageType),"validationErrors"in e&&n(9,d=e.validationErrors),"policyAdmins"in e&&n(1,f=e.policyAdmins),"policyFollows"in e&&n(10,p=e.policyFollows)},e.$$.update=()=>{if(1&e.$$.dirty[0])try{if(l){const e=JSON.parse(l);n(1,f=e.policy_admins||[])}}catch(e){}},[l,f,i,r,s,o,a,c,u,d,p,g,function(){h("loadPolicy")},function(){h("validatePolicy")},function(){h("savePolicy")},function(){h("formatJson")},function(){h("openLoginModal")},function(){h("refreshFollows")},m,v,'{\n "kind": {\n "whitelist": [0, 1, 3, 6, 7, 10002],\n "blacklist": []\n },\n "global": {\n "description": "Global rules applied to all events",\n "size_limit": 65536,\n "max_age_of_event": 86400,\n "max_age_event_in_future": 300\n },\n "rules": {\n "1": {\n "description": "Kind 1 (short text notes)",\n "content_limit": 8192,\n "write_allow_follows": true\n },\n "30023": {\n "description": "Long-form articles",\n "content_limit": 100000,\n "tag_validation": {\n "d": "^[a-z0-9-]{1,64}$",\n "t": "^[a-z0-9-]{1,32}$"\n }\n }\n },\n "default_policy": "allow",\n "policy_admins": [""],\n "policy_follow_whitelist_enabled": true\n}',function(){l=this.value,n(0,l)},e=>v(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class Zv extends se{constructor(e){super(),re(this,e,zv,Wv,s,{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 Xv=[{id:"social",name:"Social/Notes",description:"User profiles, notes, follows, reposts, reactions, and relay lists",kinds:[0,1,3,6,7,10002]},{id:"dm",name:"Direct Messages",description:"Encrypted direct messages (legacy and NIP-17 gift-wrapped)",kinds:[4,14,1059]},{id:"longform",name:"Long-form Content",description:"Blog posts and article drafts",kinds:[30023,30024]},{id:"media",name:"Media",description:"File metadata and media attachments",kinds:[1063,20,21,22]},{id:"marketplace_nip15",name:"Marketplace (NIP-15)",description:"Legacy NIP-15 stalls and products",kinds:[30017,30018,30019,30020]},{id:"marketplace_nip99",name:"Marketplace (NIP-99/Gamma)",description:"NIP-99 classified listings, collections, shipping, reviews (Plebeian Market)",kinds:[30402,30403,30405,30406,31555]},{id:"order_communication",name:"Order Communication",description:"Gamma Markets order messages and payment receipts (kinds 16, 17)",kinds:[16,17]},{id:"groups_nip29",name:"Group Messaging (NIP-29)",description:"Simple relay-based group chat messages",kinds:[9,10,11,12]},{id:"groups_nip72",name:"Communities (NIP-72)",description:"Community definitions and threaded discussions",kinds:[34550,1111,4550]},{id:"lists",name:"Lists/Bookmarks",description:"Mute lists, pin lists, and parameterized list events",kinds:[1e4,10001,3e4,30001]}];function ey(e,t,n){const i=e.slice();return i[90]=t[n],i}function ty(e,t,n){const i=e.slice();return i[98]=t[n],i}function ny(e,t,n){const i=e.slice();return i[93]=t[n],i}function iy(e,t,n){const i=e.slice();return i[103]=t[n],i}function ry(e,t,n){const i=e.slice();return i[106]=t[n],i}function sy(e,t,n){const i=e.slice();return i[106]=t[n],i}function oy(e,t,n){const i=e.slice();return i[93]=t[n],i}function ly(e,t,n){const i=e.slice();return i[90]=t[n],i}function ay(e){let t,n,i;return{c(){t=p("div"),n=g(e[2]),A(t,"class",i="message "+e[3]+" svelte-1i0huu3")},m(e,i){u(e,t,i),c(t,n)},p(e,r){4&r[0]&&k(n,e[2]),8&r[0]&&i!==(i="message "+e[3]+" svelte-1i0huu3")&&A(t,"class",i)},d(e){e&&d(t)}}}function cy(e){let t;function n(e,t){return e[5]?fy:dy}let i=n(e),r=i(e);return{c(){r.c(),t=v()},m(e,n){r.m(e,n),u(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&d(t)}}}function uy(e){let t,n,r,s,o,l,a,h,g,v,w,k,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X=Xv,ee=[];for(let t=0;tInitial Configuration \n

    Configure curating mode before the relay will accept events. Select which event kinds to allow and set rate limiting parameters.

    ',r=m(),s=p("div"),o=p("h4"),o.textContent="Allowed Event Kinds",l=m(),a=p("p"),a.textContent="Select categories of events to allow. At least one must be selected.",h=m(),g=p("div");for(let e=0;e0?gy:hy}let B=S(e),Q=B(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Trusted Publishers",r=m(),s=p("p"),s.textContent="Trusted users can publish unlimited events without rate limiting.",o=m(),l=p("div"),a=p("input"),f=m(),h=p("input"),v=m(),w=p("button"),b=g("Trust"),k=m(),C=p("div"),Q.c(),A(n,"class","svelte-1i0huu3"),A(s,"class","help-text svelte-1i0huu3"),A(a,"type","text"),A(a,"placeholder","Pubkey (64 hex chars)"),A(a,"class","svelte-1i0huu3"),A(h,"type","text"),A(h,"placeholder","Note (optional)"),A(h,"class","svelte-1i0huu3"),w.disabled=e[1],A(w,"class","svelte-1i0huu3"),A(l,"class","add-form svelte-1i0huu3"),A(C,"class","list svelte-1i0huu3"),A(t,"class","section svelte-1i0huu3")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,l),c(l,a),I(a,e[13]),c(l,f),c(l,h),I(h,e[14]),c(l,v),c(l,w),c(w,b),c(t,k),c(t,C),Q.m(C,null),E||(x=[y(a,"input",e[58]),y(h,"input",e[59]),y(w,"click",e[60])],E=!0)},p(e,t){8192&t[0]&&a.value!==e[13]&&I(a,e[13]),16384&t[0]&&h.value!==e[14]&&I(h,e[14]),2&t[0]&&(w.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(C,null)))},d(e){e&&d(t),Q.d(),E=!1,i(x)}}}function hy(t){let n;return{c(){n=p("div"),n.textContent="No trusted pubkeys yet.",A(n,"class","empty svelte-1i0huu3")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function gy(e){let t,n=e[12],i=[];for(let t=0;t0?Ay:wy}let B=S(e),Q=B(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Blacklisted Publishers",r=m(),s=p("p"),s.textContent="Blacklisted users cannot publish any events.",o=m(),l=p("div"),a=p("input"),f=m(),h=p("input"),v=m(),w=p("button"),b=g("Blacklist"),k=m(),C=p("div"),Q.c(),A(n,"class","svelte-1i0huu3"),A(s,"class","help-text svelte-1i0huu3"),A(a,"type","text"),A(a,"placeholder","Pubkey (64 hex chars)"),A(a,"class","svelte-1i0huu3"),A(h,"type","text"),A(h,"placeholder","Reason (optional)"),A(h,"class","svelte-1i0huu3"),w.disabled=e[1],A(w,"class","svelte-1i0huu3"),A(l,"class","add-form svelte-1i0huu3"),A(C,"class","list svelte-1i0huu3"),A(t,"class","section svelte-1i0huu3")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,l),c(l,a),I(a,e[16]),c(l,f),c(l,h),I(h,e[17]),c(l,v),c(l,w),c(w,b),c(t,k),c(t,C),Q.m(C,null),E||(x=[y(a,"input",e[63]),y(h,"input",e[64]),y(w,"click",e[65])],E=!0)},p(e,t){65536&t[0]&&a.value!==e[16]&&I(a,e[16]),131072&t[0]&&h.value!==e[17]&&I(h,e[17]),2&t[0]&&(w.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(C,null)))},d(e){e&&d(t),Q.d(),E=!1,i(x)}}}function wy(t){let n;return{c(){n=p("div"),n.textContent="No blacklisted pubkeys.",A(n,"class","empty svelte-1i0huu3")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ay(e){let t,n=e[15],i=[];for(let t=0;t0?Ey:Cy}let x=E(e),S=x(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Unclassified Users",r=m(),s=p("p"),s.textContent="Users who have posted events but haven't been classified. Sorted by event count.",o=m(),l=p("div"),a=p("button"),f=g("Refresh"),h=m(),v=p("button"),w=g("Scan Database"),b=m(),k=p("div"),S.c(),A(n,"class","svelte-1i0huu3"),A(s,"class","help-text svelte-1i0huu3"),A(a,"class","refresh-btn svelte-1i0huu3"),a.disabled=e[1],A(v,"class","scan-btn svelte-1i0huu3"),v.disabled=e[1],A(l,"class","button-row svelte-1i0huu3"),A(k,"class","list svelte-1i0huu3"),A(t,"class","section svelte-1i0huu3")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,l),c(l,a),c(a,f),c(l,h),c(l,v),c(v,w),c(t,b),c(t,k),S.m(k,null),I||(C=[y(a,"click",e[21]),y(v,"click",e[22])],I=!0)},p(e,t){2&t[0]&&(a.disabled=e[1]),2&t[0]&&(v.disabled=e[1]),x===(x=E(e))&&S?S.p(e,t):(S.d(1),S=x(e),S&&(S.c(),S.m(k,null)))},d(e){e&&d(t),S.d(),I=!1,i(C)}}}function Cy(t){let n;return{c(){n=p("div"),n.textContent="No unclassified users.",A(n,"class","empty svelte-1i0huu3")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ey(e){let t,n=e[18],i=[];for(let t=0;t0?Qy:By}let b=w(e),k=b(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Spam Events",i=m(),r=p("p"),r.textContent="Events flagged as spam are hidden from query results but remain in the database.",s=m(),o=p("button"),l=g("Refresh"),a=m(),f=p("div"),k.c(),A(n,"class","svelte-1i0huu3"),A(r,"class","help-text svelte-1i0huu3"),A(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],A(f,"class","list svelte-1i0huu3"),A(t,"class","section svelte-1i0huu3")},m(d,p){u(d,t,p),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o),c(o,l),c(t,a),c(t,f),k.m(f,null),h||(v=y(o,"click",e[23]),h=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),b===(b=w(e))&&k?k.p(e,t):(k.d(1),k=b(e),k&&(k.c(),k.m(f,null)))},d(e){e&&d(t),k.d(),h=!1,v()}}}function By(t){let n;return{c(){n=p("div"),n.textContent="No spam events flagged.",A(n,"class","empty svelte-1i0huu3")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Qy(e){let t,n=e[19],i=[];for(let t=0;t0?Ry:Py}let b=w(e),k=b(e);return{c(){t=p("div"),n=p("h3"),n.textContent="Blocked IP Addresses",i=m(),r=p("p"),r.textContent="IP addresses blocked due to rate limit violations.",s=m(),o=p("button"),l=g("Refresh"),a=m(),f=p("div"),k.c(),A(n,"class","svelte-1i0huu3"),A(r,"class","help-text svelte-1i0huu3"),A(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],A(f,"class","list svelte-1i0huu3"),A(t,"class","section svelte-1i0huu3")},m(d,p){u(d,t,p),c(t,n),c(t,i),c(t,r),c(t,s),c(t,o),c(o,l),c(t,a),c(t,f),k.m(f,null),h||(v=y(o,"click",e[24]),h=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),b===(b=w(e))&&k?k.p(e,t):(k.d(1),k=b(e),k&&(k.c(),k.m(f,null)))},d(e){e&&d(t),k.d(),h=!1,v()}}}function Py(t){let n;return{c(){n=p("div"),n.textContent="No blocked IPs.",A(n,"class","empty svelte-1i0huu3")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ry(e){let t,n=e[20],i=[];for(let t=0;t100*t&&(i=i.substring(0,100*t)),i}function ow(e,t=6){if(!e)return!1;return e.split("\n").length>t||e.length>100*t}function lw(e){return{0:"Metadata",1:"Text Note",3:"Follow List",4:"Encrypted DM",6:"Repost",7:"Reaction",14:"Chat Message",16:"Order Message",17:"Payment Receipt",1063:"File Metadata",10002:"Relay List",30017:"Stall",30018:"Product (NIP-15)",30023:"Long-form",30078:"App Data",30402:"Product (NIP-99)",30405:"Collection",30406:"Shipping",31555:"Review"}[e]||`Kind ${e}`}function aw(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="trusted",o=!1,l="",a="info",c=!1,u=null,d=null,f=[],p=0,h=0,g=!1,m={},v={daily_limit:50,first_ban_hours:1,second_ban_hours:168,categories:[],custom_kinds:"",kind_ranges:[]},y=[],w="",A="",k=[],I="",C="",E=[],x=[],S=[];async function B(e,t=[]){try{n(1,o=!0),n(2,l="");const s={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available.");const n=window.location.origin+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s);return`Nostr ${btoa(JSON.stringify(o))}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(s)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(2,l=e.message),n(3,a="error"),e}finally{n(1,o=!1)}}async function Q(){await Promise.all([F(),$(),P(),R(),T()])}async function F(){try{n(12,y=await B("listtrustedpubkeys"))}catch(e){console.error("Failed to load trusted pubkeys:",e),n(12,y=[])}}async function $(){try{n(15,k=await B("listblacklistedpubkeys"))}catch(e){console.error("Failed to load blacklisted pubkeys:",e),n(15,k=[])}}async function P(){try{n(18,E=await B("listunclassifiedusers"))}catch(e){console.error("Failed to load unclassified users:",e),n(18,E=[])}}async function R(){try{n(19,x=await B("listspamevents"))}catch(e){console.error("Failed to load spam events:",e),n(19,x=[])}}async function T(){try{n(20,S=await B("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e),n(20,S=[])}}async function U(e=null,t=""){const i=e||w,r=e?t:A;if(i)try{await B("trustpubkey",[i,r]),n(2,l="Pubkey trusted successfully"),n(3,a="success"),n(13,w=""),n(14,A=""),await F(),await P()}catch(e){console.error("Failed to trust pubkey:",e)}}async function _(e){try{await B("untrustpubkey",[e]),n(2,l="Pubkey untrusted"),n(3,a="success"),await F()}catch(e){console.error("Failed to untrust pubkey:",e)}}async function N(e=null,t=""){const i=e||I,r=e?t:C;if(i)try{await B("blacklistpubkey",[i,r]),n(2,l="Pubkey blacklisted"),n(3,a="success"),n(16,I=""),n(17,C=""),await $(),await P()}catch(e){console.error("Failed to blacklist pubkey:",e)}}async function L(e){try{await B("unblacklistpubkey",[e]),n(2,l="Pubkey removed from blacklist"),n(3,a="success"),await $()}catch(e){console.error("Failed to remove from blacklist:",e)}}async function O(e){try{await B("unmarkspam",[e]),n(2,l="Spam mark removed"),n(3,a="success"),await R()}catch(e){console.error("Failed to unmark spam:",e)}}async function M(e){if(confirm("Permanently delete this event?"))try{await B("deleteevent",[e]),n(2,l="Event deleted"),n(3,a="success"),await R()}catch(e){console.error("Failed to delete event:",e)}}async function j(e){try{await B("unblockip",[e]),n(2,l="IP unblocked"),n(3,a="success"),await T()}catch(e){console.error("Failed to unblock IP:",e)}}function H(e){v.categories.includes(e)?n(11,v.categories=v.categories.filter(t=>t!==e),v):n(11,v.categories=[...v.categories,e],v)}async function G(){if(!i||!r)return n(2,l="Please log in with a Nostr extension to publish configuration"),void n(3,a="error");if(0===v.categories.length&&!v.custom_kinds.trim())return n(2,l="Please select at least one kind category or enter custom kinds"),void n(3,a="error");try{n(1,o=!0),n(2,l="");const e=[["d","curating-config"],["daily_limit",String(v.daily_limit)],["first_ban_hours",String(v.first_ban_hours)],["second_ban_hours",String(v.second_ban_hours)]];for(const t of v.categories)e.push(["kind_category",t]);const t=function(e){if(!e||!e.trim())return[];const t=new Set,n=e.split(",").map(e=>e.trim());for(const e of n)if(e)if(e.includes("-")){const[n,i]=e.split("-").map(e=>parseInt(e.trim(),10));if(!isNaN(n)&&!isNaN(i)&&n<=i&&i-n<=1e3)for(let e=n;e<=i;e++)t.add(e)}else{const n=parseInt(e,10);isNaN(n)||t.add(n)}return Array.from(t).sort((e,t)=>e-t)}(v.custom_kinds);for(const n of t)e.push(["kind",String(n)]);const s={kind:30078,created_at:Math.floor(Date.now()/1e3),tags:e,content:"Curating relay configuration",pubkey:r},u=await i.signEvent(s),d=new WebSocket(window.location.origin.replace(/^http/,"ws"));await new Promise((e,t)=>{d.onopen=()=>{d.send(JSON.stringify(["EVENT",u]))},d.onmessage=n=>{const i=JSON.parse(n.data);"OK"===i[0]&&(!0===i[2]?e():t(new Error(i[3]||"Event rejected")))},d.onerror=e=>t(new Error("WebSocket error")),setTimeout(()=>t(new Error("Timeout")),1e4)}),d.close(),n(2,l="Configuration published successfully"),n(3,a="success"),n(4,c=!0),await Q()}catch(e){console.error("Failed to publish configuration:",e),n(2,l=`Failed to publish: ${e.message}`),n(3,a="error")}finally{n(1,o=!1)}}function J(e,t="info"){n(2,l=e),n(3,a=t)}async function K(e,t){console.log("openUserDetail called:",e,t),n(5,u=e),n(6,d=t),n(7,f=[]),n(8,p=0),h=0,n(10,m={}),console.log("selectedUser set to:",u),await q()}function V(){n(5,u=null),n(6,d=null),n(7,f=[]),n(8,p=0),h=0,n(10,m={})}async function q(){if(console.log("loadUserEvents called, selectedUser:",u,"loadingEvents:",g),u&&!g)try{n(9,g=!0),console.log("Calling geteventsforpubkey API...");const e=await B("geteventsforpubkey",[u,100,h]);console.log("API result:",e),e&&(n(7,f=0===h?e.events||[]:[...f,...e.events||[]]),n(8,p=e.total||0))}catch(e){console.error("Failed to load user events:",e),J("Failed to load events: "+e.message,"error")}finally{n(9,g=!1)}}function Y(e){n(10,m={...m,[e]:!m[e]})}D(async()=>{await async function(){try{const e=await B("isconfigured");n(4,c=!0===e),c&&(await async function(){try{const e=await B("getcuratingconfig");e&&n(11,v={daily_limit:e.daily_limit||50,first_ban_hours:e.first_ban_hours||1,second_ban_hours:e.second_ban_hours||168,categories:e.categories||[],custom_kinds:e.custom_kinds?e.custom_kinds.join(", "):"",kind_ranges:e.kind_ranges||[]})}catch(e){console.error("Failed to load config:",e)}}(),await Q())}catch(e){console.error("Failed to check configuration:",e),n(4,c=!1)}}()});return e.$$set=e=>{"userSigner"in e&&n(44,i=e.userSigner),"userPubkey"in e&&n(45,r=e.userPubkey)},[s,o,l,a,c,u,d,f,p,g,m,v,y,w,A,k,I,C,E,x,S,P,async function(){try{const e=await B("scanpubkeys");J(`Database scanned: ${e.total_pubkeys} pubkeys, ${e.total_events} events (${e.skipped} skipped)`,"success"),await P()}catch(e){console.error("Failed to scan database:",e),J("Failed to scan database: "+e.message,"error")}},R,T,U,_,N,L,O,M,j,H,G,async function(){await G()},K,V,async function(){h=f.length,await q()},Y,async function(){await U(u,""),await Q(),V()},async function(){await N(u,""),await Q(),V()},async function(){await _(u),await Q(),V()},async function(){await L(u),await Q(),V()},async function(){if(confirm(`Delete ALL ${p} events from this user? This cannot be undone.`))try{n(1,o=!0);J(`Deleted ${(await B("deleteeventsforpubkey",[u])).deleted} events`,"success"),n(7,f=[]),n(8,p=0),h=0,await q()}catch(e){console.error("Failed to delete events:",e),J("Failed to delete events: "+e.message,"error")}finally{n(1,o=!1)}},i,r,e=>H(e.id),function(){v.custom_kinds=this.value,n(11,v)},function(){v.daily_limit=b(this.value),n(11,v)},function(){v.first_ban_hours=b(this.value),n(11,v)},function(){v.second_ban_hours=b(this.value),n(11,v)},e=>Y(e.id),()=>n(0,s="trusted"),()=>n(0,s="blacklist"),()=>n(0,s="unclassified"),()=>n(0,s="spam"),()=>n(0,s="ips"),()=>n(0,s="settings"),function(){w=this.value,n(13,w)},function(){A=this.value,n(14,A)},()=>U(),e=>_(e.pubkey),e=>K(e.pubkey,"trusted"),function(){I=this.value,n(16,I)},function(){C=this.value,n(17,C)},()=>N(),e=>L(e.pubkey),e=>K(e.pubkey,"blacklisted"),e=>U(e.pubkey,""),e=>N(e.pubkey,""),e=>K(e.pubkey,"unclassified"),e=>O(e.event_id),e=>M(e.event_id),e=>j(e.ip),e=>H(e.id),function(){v.custom_kinds=this.value,n(11,v)},function(){v.daily_limit=b(this.value),n(11,v)},function(){v.first_ban_hours=b(this.value),n(11,v)},function(){v.second_ban_hours=b(this.value),n(11,v)}]}class cw extends se{constructor(e){super(),re(this,e,aw,nw,s,{userSigner:44,userPubkey:45},null,[-1,-1,-1,-1])}}const{window:uw}=a;function dw(e,t,n){const i=e.slice();return i[57]=t[n],i}function fw(e,t,n){const i=e.slice();return i[54]=t[n],i}function pw(t){let n,i,r,s,o,l;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to view your Blossom storage.",r=m(),s=p("button"),s.textContent="Log In",A(i,"class","svelte-on0yal"),A(s,"class","login-btn svelte-on0yal"),A(n,"class","login-prompt svelte-on0yal")},m(e,a){u(e,n,a),c(n,i),c(n,r),c(n,s),o||(l=y(s,"click",t[20]),o=!0)},p:e,d(e){e&&d(n),o=!1,l()}}}function hw(e){let t,n,i,r,s,o,l,a,f,h,v,w,b,I,C=e[0]||e[12]?"Loading...":"Refresh";function E(e,t){return e[13]?vw:e[10]?mw:gw}let x=E(e),S=x(e),B=e[14]&&!e[10]&&!e[13]&&ww(e),Q=!e[10]&&!e[13]&&Aw(e),F=e[2]&&kw(e);function D(e,t){return e[10]&&!e[13]?Cw:Iw}let $=D(e),P=$(e);return{c(){t=p("div"),n=p("div"),S.c(),i=m(),r=p("div"),B&&B.c(),s=m(),o=p("button"),l=g("🔄 "),a=g(C),h=m(),Q&&Q.c(),v=m(),F&&F.c(),w=m(),P.c(),A(o,"class","refresh-btn svelte-on0yal"),o.disabled=f=e[0]||e[12],A(r,"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),S.m(n,null),c(n,i),c(n,r),B&&B.m(r,null),c(r,s),c(r,o),c(o,l),c(o,a),c(t,h),Q&&Q.m(t,null),c(t,v),F&&F.m(t,null),c(t,w),P.m(t,null),b||(I=y(o,"click",e[30]),b=!0)},p(e,l){x===(x=E(e))&&S?S.p(e,l):(S.d(1),S=x(e),S&&(S.c(),S.m(n,i))),!e[14]||e[10]||e[13]?B&&(B.d(1),B=null):B?B.p(e,l):(B=ww(e),B.c(),B.m(r,s)),4097&l[0]&&C!==(C=e[0]||e[12]?"Loading...":"Refresh")&&k(a,C),4097&l[0]&&f!==(f=e[0]||e[12])&&(o.disabled=f),e[10]||e[13]?Q&&(Q.d(1),Q=null):Q?Q.p(e,l):(Q=Aw(e),Q.c(),Q.m(t,v)),e[2]?F?F.p(e,l):(F=kw(e),F.c(),F.m(t,w)):F&&(F.d(1),F=null),$===($=D(e))&&P?P.p(e,l):(P.d(1),P=$(e),P&&(P.c(),P.m(t,null)))},d(e){e&&d(t),S.d(),B&&B.d(),Q&&Q.d(),F&&F.d(),P.d(),b=!1,I()}}}function gw(t){let n;return{c(){n=p("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 mw(t){let n,i,r,s,o;return{c(){n=p("button"),n.textContent="← Back",i=m(),r=p("h3"),r.textContent="All Users Storage",A(n,"class","back-btn svelte-on0yal"),A(r,"class","svelte-on0yal")},m(e,l){u(e,n,l),u(e,i,l),u(e,r,l),s||(o=y(n,"click",t[27]),s=!0)},p:e,d(e){e&&d(n),e&&d(i),e&&d(r),s=!1,o()}}}function vw(e){let t,n,i,r,s,o,l,a=(e[13].profile?.name||eA(e[25](e[13].pubkey)))+"",f=e[13].profile?.picture&&yw(e);return{c(){t=p("button"),t.textContent="← Back",n=m(),i=p("h3"),f&&f.c(),r=m(),s=g(a),A(t,"class","back-btn svelte-on0yal"),A(i,"class","user-header svelte-on0yal")},m(a,d){u(a,t,d),u(a,n,d),u(a,i,d),f&&f.m(i,null),c(i,r),c(i,s),o||(l=y(t,"click",e[29]),o=!0)},p(e,t){e[13].profile?.picture?f?f.p(e,t):(f=yw(e),f.c(),f.m(i,r)):f&&(f.d(1),f=null),8192&t[0]&&a!==(a=(e[13].profile?.name||eA(e[25](e[13].pubkey)))+"")&&k(s,a)},d(e){e&&d(t),e&&d(n),e&&d(i),f&&f.d(),o=!1,l()}}}function yw(e){let t,n;return{c(){t=p("img"),l(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,i){8192&i[0]&&!l(t.src,n=e[13].profile.picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function ww(e){let t,n,i,r;return{c(){t=p("button"),n=g("Admin"),A(t,"class","admin-btn svelte-on0yal"),t.disabled=e[0]},m(s,o){u(s,t,o),c(t,n),i||(r=y(t,"click",e[26]),i=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&d(t),i=!1,r()}}}function Aw(e){let t,n,r,s,o,l,a,f,h,v,w=e[3].length>0&&bw(e);return{c(){t=p("div"),n=p("span"),n.textContent="Upload new files",r=m(),s=p("input"),o=m(),w&&w.c(),l=m(),a=p("button"),f=g("Select Files"),A(n,"class","upload-label svelte-on0yal"),A(s,"type","file"),s.multiple=!0,A(s,"class","file-input-hidden svelte-on0yal"),A(a,"class","select-btn svelte-on0yal"),a.disabled=e[4],A(t,"class","upload-section svelte-on0yal")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),e[39](s),c(t,o),w&&w.m(t,null),c(t,l),c(t,a),c(a,f),h||(v=[y(s,"change",e[22]),y(a,"click",e[23])],h=!0)},p(e,n){e[3].length>0?w?w.p(e,n):(w=bw(e),w.c(),w.m(t,l)):w&&(w.d(1),w=null),16&n[0]&&(a.disabled=e[4])},d(n){n&&d(t),e[39](null),w&&w.d(),h=!1,i(v)}}}function bw(e){let t,n,i,r,s,o,l,a,f=e[3].length+"",h=(e[4]?e[5]:"Upload")+"";return{c(){t=p("span"),n=g(f),i=g(" file(s) selected"),r=m(),s=p("button"),o=g(h),A(t,"class","selected-count svelte-on0yal"),A(s,"class","upload-btn svelte-on0yal"),s.disabled=e[4]},m(d,f){u(d,t,f),c(t,n),c(t,i),u(d,r,f),u(d,s,f),c(s,o),l||(a=y(s,"click",e[24]),l=!0)},p(e,t){8&t[0]&&f!==(f=e[3].length+"")&&k(n,f),48&t[0]&&h!==(h=(e[4]?e[5]:"Upload")+"")&&k(o,h),16&t[0]&&(s.disabled=e[4])},d(e){e&&d(t),e&&d(r),e&&d(s),l=!1,a()}}}function kw(e){let t,n;return{c(){t=p("div"),n=g(e[2]),A(t,"class","error-message svelte-on0yal")},m(e,i){u(e,t,i),c(t,n)},p(e,t){4&t[0]&&k(n,e[2])},d(e){e&&d(t)}}}function Iw(e){let t,n,i;function r(e,i){return 1&i[0]&&(t=null),null==t&&(t=!(!e[0]||0!==e[31]().length)),t?Sw:(null==n&&(n=!(0!==e[31]().length)),n?xw:Ew)}let s=r(e,[-1,-1]),o=s(e);return{c(){o.c(),i=v()},m(e,t){o.m(e,t),u(e,i,t)},p(e,t){s===(s=r(e,t))&&o?o.p(e,t):(o.d(1),o=s(e),o&&(o.c(),o.m(i.parentNode,i)))},d(e){o.d(e),e&&d(i)}}}function Cw(e){let t;function n(e,t){return e[12]?Rw:0===e[11].length?Pw:$w}let i=n(e),r=i(e);return{c(){r.c(),t=v()},m(e,n){r.m(e,n),u(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&d(t)}}}function Ew(e){let t,n=e[31](),i=[];for(let t=0;tNo users have uploaded files yet.

    ",A(n,"class","empty-state svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Rw(t){let n;return{c(){n=p("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=p("div"),A(n,"class","user-avatar-placeholder svelte-on0yal")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Uw(e){let t,n;return{c(){t=p("img"),l(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,i){2048&i[0]&&!l(t.src,n=e[54].profile.picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function _w(e){let t,n,r,s,o,l,a,f,h,v,w,b,I,C,E,x,S,B,Q,F,D,$,P,R,T,U=(e[54].profile?.name||eA(e[25](e[54].pubkey)))+"",_=e[25](e[54].pubkey)+"",N=eA(e[25](e[54].pubkey))+"",L=e[54].blob_count+"",O=qw(e[54].total_size_bytes)+"";function M(e,t){return e[54].profile?.picture?Uw:Tw}let j=M(e),H=j(e);function G(){return e[40](e[54])}function J(...t){return e[41](e[54],...t)}return{c(){t=p("div"),n=p("div"),H.c(),r=m(),s=p("div"),o=p("div"),l=g(U),a=m(),f=p("div"),h=p("span"),v=g(_),w=m(),b=p("span"),I=g(N),E=m(),x=p("div"),S=p("span"),B=g(L),Q=g(" files"),F=m(),D=p("span"),$=g(O),P=m(),A(n,"class","user-avatar-container svelte-on0yal"),A(o,"class","user-name svelte-on0yal"),A(h,"class","npub-full svelte-on0yal"),A(b,"class","npub-truncated svelte-on0yal"),A(f,"class","user-npub svelte-on0yal"),A(f,"title",C=e[54].pubkey),A(s,"class","user-info svelte-on0yal"),A(S,"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,i){u(e,t,i),c(t,n),H.m(n,null),c(t,r),c(t,s),c(s,o),c(o,l),c(s,a),c(s,f),c(f,h),c(h,v),c(f,w),c(f,b),c(b,I),c(t,E),c(t,x),c(x,S),c(S,B),c(S,Q),c(x,F),c(x,D),c(D,$),c(t,P),R||(T=[y(t,"click",G),y(t,"keypress",J)],R=!0)},p(t,i){j===(j=M(e=t))&&H?H.p(e,i):(H.d(1),H=j(e),H&&(H.c(),H.m(n,null))),2048&i[0]&&U!==(U=(e[54].profile?.name||eA(e[25](e[54].pubkey)))+"")&&k(l,U),2048&i[0]&&_!==(_=e[25](e[54].pubkey)+"")&&k(v,_),2048&i[0]&&N!==(N=eA(e[25](e[54].pubkey))+"")&&k(I,N),2048&i[0]&&C!==(C=e[54].pubkey)&&A(f,"title",C),2048&i[0]&&L!==(L=e[54].blob_count+"")&&k(B,L),2048&i[0]&&O!==(O=qw(e[54].total_size_bytes)+"")&&k($,O)},d(e){e&&d(t),H.d(),R=!1,i(T)}}}function Nw(e){let t,n,r,s,o,l,a,f,h,v,b,I,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te=Ww(e[8].sha256)+"",ne=(e[8].type||"unknown")+"",ie="image"===zw(e[8].type),re=qw(e[8].size)+"",se=Yw(e[8].uploaded)+"",oe=ie&&Lw(e);function le(e,t){return 256&t[0]&&(S=null),256&t[0]&&(B=null),256&t[0]&&(Q=null),null==S&&(S=!("image"!==zw(e[8].type))),S?Hw:(null==B&&(B=!("video"!==zw(e[8].type))),B?jw:(null==Q&&(Q=!("audio"!==zw(e[8].type))),Q?Mw:Ow))}let ae=le(e,[-1,-1]),ce=ae(e);return{c(){t=p("div"),n=p("div"),r=p("div"),s=p("div"),o=p("span"),l=g(te),a=m(),f=p("span"),h=g(ne),v=m(),b=p("div"),oe&&oe.c(),I=m(),C=p("button"),C.textContent="X",E=m(),x=p("div"),ce.c(),F=m(),D=p("div"),$=p("div"),P=p("span"),R=g("Size: "),T=g(re),U=m(),_=p("span"),N=g("Uploaded: "),L=g(se),O=m(),M=p("div"),j=p("input"),G=m(),J=p("button"),J.textContent="Copy",K=m(),V=p("div"),q=p("a"),Y=g("Open in New Tab"),z=m(),Z=p("button"),Z.textContent="Delete",A(o,"class","modal-hash svelte-on0yal"),A(f,"class","modal-type svelte-on0yal"),A(s,"class","modal-title svelte-on0yal"),A(C,"class","close-btn svelte-on0yal"),A(b,"class","modal-controls svelte-on0yal"),A(r,"class","modal-header svelte-on0yal"),A(x,"class","modal-body svelte-on0yal"),A($,"class","blob-details svelte-on0yal"),A(j,"type","text"),j.readOnly=!0,j.value=H=Xw(e[8]),A(j,"class","blob-url-input svelte-on0yal"),A(J,"class","copy-btn svelte-on0yal"),A(M,"class","blob-url-section svelte-on0yal"),A(q,"href",W=Xw(e[8])),A(q,"target","_blank"),A(q,"rel","noopener noreferrer"),A(q,"class","action-btn svelte-on0yal"),A(Z,"class","action-btn danger svelte-on0yal"),A(V,"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(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(s,o),c(o,l),c(s,a),c(s,f),c(f,h),c(r,v),c(r,b),oe&&oe.m(b,null),c(b,I),c(b,C),c(n,E),c(n,x),ce.m(x,null),c(n,F),c(n,D),c(D,$),c($,P),c(P,R),c(P,T),c($,U),c($,_),c(_,N),c(_,L),c(D,O),c(D,M),c(M,j),c(M,G),c(M,J),c(D,K),c(D,V),c(V,q),c(q,Y),c(V,z),c(V,Z),X||(ee=[y(C,"click",e[16]),y(j,"click",tA),y(J,"click",e[45]),y(Z,"click",e[46]),y(n,"click",w(e[37])),y(n,"keypress",w(e[38])),y(t,"click",e[16]),y(t,"keypress",e[47])],X=!0)},p(e,t){256&t[0]&&te!==(te=Ww(e[8].sha256)+"")&&k(l,te),256&t[0]&&ne!==(ne=(e[8].type||"unknown")+"")&&k(h,ne),256&t[0]&&(ie="image"===zw(e[8].type)),ie?oe?oe.p(e,t):(oe=Lw(e),oe.c(),oe.m(b,I)):oe&&(oe.d(1),oe=null),ae===(ae=le(e,t))&&ce?ce.p(e,t):(ce.d(1),ce=ae(e),ce&&(ce.c(),ce.m(x,null))),256&t[0]&&re!==(re=qw(e[8].size)+"")&&k(T,re),256&t[0]&&se!==(se=Yw(e[8].uploaded)+"")&&k(L,se),256&t[0]&&H!==(H=Xw(e[8]))&&j.value!==H&&(j.value=H),256&t[0]&&W!==(W=Xw(e[8]))&&A(q,"href",W)},d(e){e&&d(t),oe&&oe.d(),ce.d(),X=!1,i(ee)}}}function Lw(e){let t,n,r,s,o,l,a,f,h,v,w,b,I,C=Math.round(100*e[9])+"";return{c(){t=p("button"),n=g("-"),s=m(),o=p("span"),l=g(C),a=g("%"),f=m(),h=p("button"),v=g("+"),A(t,"class","zoom-btn svelte-on0yal"),t.disabled=r=e[9]<=Jw,A(o,"class","zoom-level svelte-on0yal"),A(h,"class","zoom-btn svelte-on0yal"),h.disabled=w=e[9]>=Kw},m(i,r){u(i,t,r),c(t,n),u(i,s,r),u(i,o,r),c(o,l),c(o,a),u(i,f,r),u(i,h,r),c(h,v),b||(I=[y(t,"click",e[18]),y(h,"click",e[17])],b=!0)},p(e,n){512&n[0]&&r!==(r=e[9]<=Jw)&&(t.disabled=r),512&n[0]&&C!==(C=Math.round(100*e[9])+"")&&k(l,C),512&n[0]&&w!==(w=e[9]>=Kw)&&(h.disabled=w)},d(e){e&&d(t),e&&d(s),e&&d(o),e&&d(f),e&&d(h),b=!1,i(I)}}}function Ow(e){let t,n,i,r,s,o,l,a,f,h=Zw(e[8].type)+"";return{c(){t=p("div"),n=p("div"),i=g(h),r=m(),s=p("p"),s.textContent="Preview not available for this file type.",o=m(),l=p("a"),a=g("Download File"),A(n,"class","file-icon svelte-on0yal"),A(l,"href",f=Xw(e[8])),A(l,"target","_blank"),A(l,"rel","noopener noreferrer"),A(l,"class","download-link svelte-on0yal"),A(t,"class","file-preview svelte-on0yal")},m(e,d){u(e,t,d),c(t,n),c(n,i),c(t,r),c(t,s),c(t,o),c(t,l),c(l,a)},p(e,t){256&t[0]&&h!==(h=Zw(e[8].type)+"")&&k(i,h),256&t[0]&&f!==(f=Xw(e[8]))&&A(l,"href",f)},d(e){e&&d(t)}}}function Mw(e){let t,n,i;return{c(){t=p("div"),n=p("audio"),n.controls=!0,l(n.src,i=Xw(e[8]))||A(n,"src",i),A(n,"class","svelte-on0yal"),A(t,"class","media-container audio svelte-on0yal")},m(e,i){u(e,t,i),c(t,n)},p(e,t){256&t[0]&&!l(n.src,i=Xw(e[8]))&&A(n,"src",i)},d(e){e&&d(t)}}}function jw(e){let t,n,i,r;return{c(){t=p("div"),n=p("video"),i=p("track"),A(i,"kind","captions"),n.controls=!0,l(n.src,r=Xw(e[8]))||A(n,"src",r),A(n,"class","svelte-on0yal"),A(t,"class","media-container svelte-on0yal")},m(e,r){u(e,t,r),c(t,n),c(n,i)},p(e,t){256&t[0]&&!l(n.src,r=Xw(e[8]))&&A(n,"src",r)},d(e){e&&d(t)}}}function Hw(e){let t,n,i;return{c(){t=p("div"),n=p("img"),l(n.src,i=Xw(e[8]))||A(n,"src",i),A(n,"alt","Blob content"),A(n,"class","svelte-on0yal"),A(t,"class","media-container svelte-on0yal"),C(t,"transform","scale("+e[9]+")")},m(e,i){u(e,t,i),c(t,n)},p(e,r){256&r[0]&&!l(n.src,i=Xw(e[8]))&&A(n,"src",i),512&r[0]&&C(t,"transform","scale("+e[9]+")")},d(e){e&&d(t)}}}function Gw(t){let n,i,r,s;function o(e,t){return e[1]?hw:pw}let l=o(t),a=l(t),c=t[7]&&t[8]&&Nw(t);return{c(){a.c(),n=m(),c&&c.c(),i=v()},m(e,o){a.m(e,o),u(e,n,o),c&&c.m(e,o),u(e,i,o),r||(s=y(uw,"keydown",t[19]),r=!0)},p(e,t){l===(l=o(e))&&a?a.p(e,t):(a.d(1),a=l(e),a&&(a.c(),a.m(n.parentNode,n))),e[7]&&e[8]?c?c.p(e,t):(c=Nw(e),c.c(),c.m(i.parentNode,i)):c&&(c.d(1),c=null)},i:e,o:e,d(e){a.d(e),e&&d(n),c&&c.d(e),e&&d(i),r=!1,s()}}}const Jw=.25,Kw=4;async function Vw(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const i=Math.floor(Date.now()/1e3),r=[["t",t],["expiration",(i+60).toString()]];n&&r.push(["x",n]);const s={kind:24242,created_at:i,tags:r,content:`Blossom ${t} operation`},o=await e.signEvent(s);return btoa(JSON.stringify(o)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating Blossom auth:",e),null}}function qw(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,i=e;for(;i>=1024&&ne.target.select();function nA(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{userPubkey:o=""}=t,{userSigner:l=null}=t,{currentEffectiveRole:a=""}=t;const c=P();let u,d=[],f=!1,p="",h=[],g=!1,m="",v=!1,y=null,w=1,A=!1,b=[],k=!1,I=null,C=[],E=!1;async function x(){if(o){n(0,f=!0),n(2,p="");try{const e=`${window.location.origin}/blossom/list/${o}`,t=await Vw(l,"list"),n=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!n.ok)throw new Error(`Failed to load blobs: ${n.statusText}`);const i=await n.json();d=Array.isArray(i)?i:[],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,p=e.message||"Failed to load blobs")}finally{n(0,f=!1)}}}function S(e){n(8,y=e),n(9,w=1),n(7,v=!0)}function B(){n(7,v=!1),n(8,y=null),n(9,w=1)}function Q(){wJw&&n(9,w=Math.max(Jw,w-.25))}async function $(e){if(confirm(`Delete blob ${Ww(e.sha256)}?`))try{const t=`${window.location.origin}/blossom/${e.sha256}`,n=await Vw(l,"delete",e.sha256),i=await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to delete: ${i.statusText}`);d=d.filter(t=>t.sha256!==e.sha256),y?.sha256===e.sha256&&B()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function T(){n(12,k=!0),n(2,p="");try{const e=`${window.location.origin}/blossom/admin/users`,t=await Vw(l,"admin"),i=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!i.ok)throw new Error(`Failed to load user stats: ${i.statusText}`);n(11,b=await i.json());for(const e of b)Sp(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,p=e.message||"Failed to load user stats")}finally{n(12,k=!1)}}async function _(e){n(0,f=!0),n(2,p="");try{const t=`${window.location.origin}/blossom/list/${e}`,n=await Vw(l,"list"),i=await fetch(t,{headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to load user blobs: ${i.statusText}`);C=await i.json(),C.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))}catch(e){console.error("Error loading user blobs:",e),n(2,p=e.message||"Failed to load user blobs")}finally{n(0,f=!1)}}async function N(e){n(13,I={pubkey:e.pubkey,profile:e.profile}),await _(e.pubkey)}D(()=>{i&&!E&&(n(36,E=!0),x())});return e.$$set=e=>{"isLoggedIn"in e&&n(32,s=e.isLoggedIn),"userPubkey"in e&&n(33,o=e.userPubkey),"userSigner"in e&&n(34,l=e.userSigner),"currentEffectiveRole"in e&&n(35,a=e.currentEffectiveRole)},e.$$.update=()=>{6&e.$$.dirty[1]&&n(1,i=s&&o),16&e.$$.dirty[1]&&n(14,r="admin"===a||"owner"===a),3&e.$$.dirty[0]|32&e.$$.dirty[1]&&(!i||E||f||(n(36,E=!0),x()))},[f,i,p,h,g,m,u,v,y,w,A,b,k,I,r,S,B,Q,F,function(e){v&&("Escape"===e.key?B():"+"===e.key||"="===e.key?Q():"-"===e.key&&F())},function(){c("openLoginModal")},$,function(e){n(3,h=Array.from(e.target.files))},function(){u?.click()},async function(){if(0===h.length)return;n(4,g=!0),n(2,p="");const e=[],t=[];for(let i=0;i0&&await x(),t.length>0&&n(2,p=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return wu(e)}catch(t){return Ww(e)}},function(){n(10,A=!0),T()},function(){n(10,A=!1),n(11,b=[]),n(13,I=null),C=[]},N,function(){n(13,I=null),C=[]},function(){I?_(I.pubkey):A?T():x()},function(){return I?C:d},s,o,l,a,E,function(t){R.call(this,e,t)},function(t){R.call(this,e,t)},function(e){U[e?"unshift":"push"](()=>{u=e,n(6,u)})},e=>N(e),(e,t)=>"Enter"===t.key&&N(e),e=>$(e),e=>S(e),(e,t)=>"Enter"===t.key&&S(e),()=>{navigator.clipboard.writeText(Xw(y))},()=>$(y),e=>"Enter"===e.key&&B()]}class iA extends se{constructor(e){super(),re(this,e,nA,Gw,s,{isLoggedIn:32,userPubkey:33,userSigner:34,currentEffectiveRole:35},null,[-1,-1])}}function rA(e,t,n){const i=e.slice();return i[29]=t[n],i}function sA(e,t,n){const i=e.slice();return i[32]=t[n],i}function oA(e){let t,n,i;function r(e,t){return e[0]?aA:cA}let s=r(e),o=s(e);return{c(){t=p("div"),n=p("p"),n.textContent="Log viewer is only available to relay owners.",i=m(),o.c(),A(n,"class","svelte-w6h7aj"),A(t,"class","login-prompt svelte-w6h7aj")},m(e,r){u(e,t,r),c(t,n),c(t,i),o.m(t,null)},p(e,n){s===(s=r(e))&&o?o.p(e,n):(o.d(1),o=s(e),o&&(o.c(),o.m(t,null)))},d(e){e&&d(t),o.d()}}}function lA(e){let t,n,r,s,o,l,a,h,v,w,b,I,C,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,j,H,G,J=e[3]?"Loading...":"Refresh",K=e[2].length+"",V=e[12],q=[];for(let t=0;te[18].call(v)),A(l,"class","level-selector svelte-w6h7aj"),A(b,"class","clear-btn svelte-w6h7aj"),b.disabled=C=e[3]||0===e[2].length,A(S,"class","refresh-btn svelte-w6h7aj"),S.disabled=e[3],A(o,"class","header-controls svelte-w6h7aj"),A(n,"class","header-section svelte-w6h7aj"),A($,"class","log-info svelte-w6h7aj"),A(j,"class","log-list svelte-w6h7aj"),A(t,"class","log-view svelte-w6h7aj")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(n,s),c(n,o),c(o,l),c(l,a),c(l,h),c(l,v);for(let e=0;eNo logs available.

    ",A(n,"class","empty-state svelte-w6h7aj")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function hA(e){let t,n,i,r,s=e[29].file+"",o=e[29].line+"";return{c(){t=p("span"),n=g(s),i=g(":"),r=g(o),A(t,"class","log-location svelte-w6h7aj")},m(e,s){u(e,t,s),c(t,n),c(t,i),c(t,r)},p(e,t){4&t[0]&&s!==(s=e[29].file+"")&&k(n,s),4&t[0]&&o!==(o=e[29].line+"")&&k(r,o)},d(e){e&&d(t)}}}function gA(e){let t,n,i,r,s,o,l,a,f,h,v,y=AA(e[29].timestamp)+"",w=e[29].level+"",b=e[29].message+"",I=e[29].file&&hA(e);return{c(){t=p("div"),n=p("span"),i=g(y),r=m(),s=p("span"),o=g(w),a=m(),I&&I.c(),f=m(),h=p("span"),v=g(b),A(n,"class","log-timestamp svelte-w6h7aj"),A(s,"class",l="log-level "+bA(e[29].level)+" svelte-w6h7aj"),A(h,"class","log-message svelte-w6h7aj"),A(t,"class","log-entry svelte-w6h7aj")},m(e,l){u(e,t,l),c(t,n),c(n,i),c(t,r),c(t,s),c(s,o),c(t,a),I&&I.m(t,null),c(t,f),c(t,h),c(h,v)},p(e,n){4&n[0]&&y!==(y=AA(e[29].timestamp)+"")&&k(i,y),4&n[0]&&w!==(w=e[29].level+"")&&k(o,w),4&n[0]&&l!==(l="log-level "+bA(e[29].level)+" svelte-w6h7aj")&&A(s,"class",l),e[29].file?I?I.p(e,n):(I=hA(e),I.c(),I.m(t,f)):I&&(I.d(1),I=null),4&n[0]&&b!==(b=e[29].message+"")&&k(v,b)},d(e){e&&d(t),I&&I.d()}}}function mA(e){let t;return{c(){t=p("span"),t.textContent="End of logs"},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function vA(e){let t;return{c(){t=p("span"),t.textContent="Scroll for more"},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function yA(e){let t;return{c(){t=p("span"),t.textContent="Loading more..."},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function wA(t){let n;function i(e,t){return e[4]?lA:oA}let r=i(t),s=r(t);return{c(){s.c(),n=v()},m(e,t){s.m(e,t),u(e,n,t)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&d(n)}}}function AA(e){if(!e)return"";return new Date(e).toLocaleString()}function bA(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 kA(e,t,n){let i,{isLoggedIn:r=!1}=t,{userRole:s=""}=t,{userSigner:o=null}=t;const l=P();let a=[],c=!1,u=!0,d=0,f=0,p="",h="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let v,y,w;async function A(e="GET",t="/api/logs"){if(!o)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${window.location.origin}${t}`],["method",e]],content:""},i=await o.signEvent(n);return btoa(JSON.stringify(i)).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,p=""),e&&(d=0,n(2,a=[]));try{const t=`/api/logs?offset=${d}&limit=100`,i=await A("GET",t),r=`${window.location.origin}${t}`,s=await fetch(r,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!s.ok)throw new Error(`Failed to load logs: ${s.statusText}`);const o=await s.json();n(2,a=e?o.logs||[]:[...a,...o.logs||[]]),n(6,f=o.total||0),n(5,u=o.has_more||!1),d=a.length}catch(e){console.error("Error loading logs:",e),n(7,p=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,h=t.level||"info"),n(9,g=h)}}catch(e){console.error("Error loading log level:",e)}}D(()=>{i&&(b(!0),k(),function(){if(!y)return;w=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&b(!1)},{threshold:.1}),w.observe(y)}())}),$(()=>{w&&w.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"userRole"in e&&n(1,s=e.userRole),"userSigner"in e&&n(17,o=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,i=r&&"owner"===s),28&e.$$.dirty[0]&&i&&0===a.length&&!c&&(b(!0),k())},[r,s,a,c,i,u,f,p,h,g,v,y,m,b,async function(){if(g!==h)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 i=await t.json();n(8,h=i.level),n(9,g=h)}catch(e){console.error("Error setting log level:",e),n(7,p=e.message||"Failed to set log level"),n(9,g=h)}},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,a=[]),d=0,n(5,u=!1),n(6,f=0)}catch(e){console.error("Error clearing logs:",e),n(7,p=e.message||"Failed to clear logs")}},function(){l("openLoginModal")},o,function(){g=x(this),n(9,g),n(12,m)},()=>b(!0),function(e){U[e?"unshift":"push"](()=>{y=e,n(11,y)})},function(e){U[e?"unshift":"push"](()=>{v=e,n(10,v)})}]}class IA extends se{constructor(e){super(),re(this,e,kA,wA,s,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}async function CA(e,t,n,i){if(!e||!t)return console.log("createNIP98Auth: No signer or pubkey available",{hasSigner:!!e,hasPubkey:!!t}),null;try{const t={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",i],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,i);const r=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:r.id,pubkey:r.pubkey,kind:r.kind,created_at:r.created_at,tags:r.tags,hasSig:!!r.sig});const s=JSON.stringify(r);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("createNIP98Auth: Error:",e),null}}async function EA(){try{const e=await fetch(`${window.location.origin}/api/nrc/config`);if(e.ok)return await e.json()}catch(e){console.error("Error fetching NRC config:",e)}return{enabled:!1,badger_required:!0}}function xA(e){return hp[e]||`Kind ${e}`}function SA(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function BA(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function QA(e){return e?new Date(1e3*e).toLocaleString():""}async function FA(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){console.error("Failed to copy to clipboard:",t);try{const t=document.createElement("textarea");return t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch(e){return console.error("Fallback copy also failed:",e),!1}}}function DA(e,t=!0){if(!e)return;const n=e.textContent,i=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=i},2e3)}function $A(e,t,n){const i=e.slice();return i[31]=t[n],i}function PA(e){let t,n,r,s,o,l,a,f,h,w,b,C,E,x,S,B,Q,F,D,$,P,R,T,U,_,N,L,O,M,j,H,G,J,K,V,q,Y,W,z,Z,X,ee,te=(e[5].rendezvous_url||"Not configured")+"",ne=e[4].length+"",ie=e[5].mint_url&&_A(e),re=!e[5].mint_url&&NA();function se(e,t){return 0===e[4].length?OA:LA}let oe=se(e),le=oe(e),ae=e[7]&&GA(e);return{c(){t=p("div"),n=p("div"),n.innerHTML='Status: \n Enabled',r=m(),s=p("div"),o=p("span"),o.textContent="Rendezvous:",l=m(),a=p("span"),f=g(te),h=m(),ie&&ie.c(),w=m(),b=p("div"),C=p("h3"),C.textContent="Create New Connection",E=m(),x=p("div"),S=p("div"),B=p("label"),B.textContent="Device Label",Q=m(),F=p("input"),D=m(),$=p("div"),P=p("label"),R=p("input"),U=g("\n Include CAT (Cashu Access Token)\n "),re&&re.c(),_=m(),N=p("button"),L=g("+ Create Connection"),M=m(),j=p("div"),H=p("h3"),G=g("Connections ("),J=g(ne),K=g(")"),V=m(),le.c(),q=m(),Y=p("button"),W=g("Refresh"),z=m(),ae&&ae.c(),Z=v(),A(n,"class","status-item svelte-gwb5vv"),A(o,"class","status-label svelte-gwb5vv"),A(a,"class","status-value svelte-gwb5vv"),A(s,"class","status-item svelte-gwb5vv"),A(t,"class","config-status svelte-gwb5vv"),A(C,"class","svelte-gwb5vv"),A(B,"for","new-label"),A(B,"class","svelte-gwb5vv"),A(F,"type","text"),A(F,"id","new-label"),A(F,"placeholder","e.g., Phone, Laptop, Tablet"),F.disabled=e[6],A(F,"class","svelte-gwb5vv"),A(S,"class","form-group svelte-gwb5vv"),A(R,"type","checkbox"),R.disabled=T=e[6]||!e[5].mint_url,A(R,"class","svelte-gwb5vv"),A(P,"class","svelte-gwb5vv"),A($,"class","form-group checkbox-group svelte-gwb5vv"),A(N,"class","create-btn svelte-gwb5vv"),N.disabled=O=e[6]||!e[9].trim(),A(x,"class","create-form svelte-gwb5vv"),A(b,"class","section svelte-gwb5vv"),A(H,"class","svelte-gwb5vv"),A(Y,"class","refresh-btn svelte-gwb5vv"),Y.disabled=e[6],A(j,"class","section svelte-gwb5vv")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(s,o),c(s,l),c(s,a),c(a,f),c(t,h),ie&&ie.m(t,null),u(i,w,d),u(i,b,d),c(b,C),c(b,E),c(b,x),c(x,S),c(S,B),c(S,Q),c(S,F),I(F,e[9]),c(x,D),c(x,$),c($,P),c(P,R),R.checked=e[10],c(P,U),re&&re.m(P,null),c(x,_),c(x,N),c(N,L),u(i,M,d),u(i,j,d),c(j,H),c(H,G),c(H,J),c(H,K),c(j,V),le.m(j,null),c(j,q),c(j,Y),c(Y,W),u(i,z,d),ae&&ae.m(i,d),u(i,Z,d),X||(ee=[y(F,"input",e[24]),y(R,"change",e[25]),y(N,"click",e[15]),y(Y,"click",e[14])],X=!0)},p(e,n){32&n[0]&&te!==(te=(e[5].rendezvous_url||"Not configured")+"")&&k(f,te),e[5].mint_url?ie?ie.p(e,n):(ie=_A(e),ie.c(),ie.m(t,null)):ie&&(ie.d(1),ie=null),64&n[0]&&(F.disabled=e[6]),512&n[0]&&F.value!==e[9]&&I(F,e[9]),96&n[0]&&T!==(T=e[6]||!e[5].mint_url)&&(R.disabled=T),1024&n[0]&&(R.checked=e[10]),e[5].mint_url?re&&(re.d(1),re=null):re||(re=NA(),re.c(),re.m(P,null)),576&n[0]&&O!==(O=e[6]||!e[9].trim())&&(N.disabled=O),16&n[0]&&ne!==(ne=e[4].length+"")&&k(J,ne),oe===(oe=se(e))&&le?le.p(e,n):(le.d(1),le=oe(e),le&&(le.c(),le.m(j,q))),64&n[0]&&(Y.disabled=e[6]),e[7]?ae?ae.p(e,n):(ae=GA(e),ae.c(),ae.m(Z.parentNode,Z)):ae&&(ae.d(1),ae=null)},d(e){e&&d(t),ie&&ie.d(),e&&d(w),e&&d(b),re&&re.d(),e&&d(M),e&&d(j),le.d(),e&&d(z),ae&&ae.d(e),e&&d(Z),X=!1,i(ee)}}}function RA(e){let t,n,i,r,s,o,l,a=(e[1]||"none")+"";return{c(){t=p("div"),n=p("p"),n.textContent="Owner permission required for relay connection management.",i=m(),r=p("p"),s=g("Current role: "),o=p("strong"),l=g(a),A(n,"class","svelte-gwb5vv"),A(r,"class","svelte-gwb5vv"),A(t,"class","permission-denied svelte-gwb5vv")},m(e,a){u(e,t,a),c(t,n),c(t,i),c(t,r),c(r,s),c(r,o),c(o,l)},p(e,t){2&t[0]&&a!==(a=(e[1]||"none")+"")&&k(l,a)},d(e){e&&d(t)}}}function TA(t){let n,i,r,s,o,l;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in to manage relay connections.",r=m(),s=p("button"),s.textContent="Log In",A(i,"class","svelte-gwb5vv"),A(s,"class","login-btn svelte-gwb5vv"),A(n,"class","login-prompt svelte-gwb5vv")},m(e,a){u(e,n,a),c(n,i),c(n,r),c(n,s),o||(l=y(s,"click",t[20]),o=!0)},p:e,d(e){e&&d(n),o=!1,l()}}}function UA(e){let t;function n(e,t){return e[3]?KA:JA}let i=n(e),r=i(e);return{c(){t=p("div"),r.c(),A(t,"class","not-enabled svelte-gwb5vv")},m(e,n){u(e,t,n),r.m(t,null)},p(e,s){i!==(i=n(e))&&(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&d(t),r.d()}}}function _A(e){let t,n,i,r,s,o=e[5].mint_url+"";return{c(){t=p("div"),n=p("span"),n.textContent="Cashu Mint:",i=m(),r=p("span"),s=g(o),A(n,"class","status-label svelte-gwb5vv"),A(r,"class","status-value svelte-gwb5vv"),A(t,"class","status-item svelte-gwb5vv")},m(e,o){u(e,t,o),c(t,n),c(t,i),c(t,r),c(r,s)},p(e,t){32&t[0]&&o!==(o=e[5].mint_url+"")&&k(s,o)},d(e){e&&d(t)}}}function NA(e){let t;return{c(){t=p("span"),t.textContent="(requires Cashu mint)",A(t,"class","hint svelte-gwb5vv")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function LA(e){let t,n=e[4],i=[];for(let t=0;tORLY_NRC_ENABLED=true and configure ORLY_NRC_RENDEZVOUS_URL to enable.',A(t,"class","svelte-gwb5vv"),A(i,"class","svelte-gwb5vv")},m(e,r){u(e,t,r),u(e,n,r),u(e,i,r)},d(e){e&&d(t),e&&d(n),e&&d(i)}}}function KA(e){let t,n,i;return{c(){t=p("p"),t.textContent="NRC requires the Badger database backend.",n=m(),i=p("p"),i.innerHTML='Set ORLY_DB_TYPE=badger to enable NRC functionality.',A(t,"class","svelte-gwb5vv"),A(i,"class","svelte-gwb5vv")},m(e,r){u(e,t,r),u(e,n,r),u(e,i,r)},d(e){e&&d(t),e&&d(n),e&&d(i)}}}function VA(e){let t,n,r,s,o,l,a,f,h,v,b,I,C,E,x,S,B,Q;return{c(){t=p("div"),n=p("div"),r=p("h3"),s=g('Connection URI for "'),o=g(e[13]),l=g('"'),a=m(),f=p("p"),f.textContent="Copy this URI to your Nostr client to connect to this relay remotely.\n Keep it secret - anyone with this URI can access your relay.",h=m(),v=p("div"),b=p("textarea"),I=m(),C=p("div"),E=p("button"),E.textContent="Copy to Clipboard",x=m(),S=p("button"),S.textContent="Close",A(r,"class","svelte-gwb5vv"),A(f,"class","modal-description svelte-gwb5vv"),b.readOnly=!0,b.value=e[12],A(b,"class","svelte-gwb5vv"),A(v,"class","uri-display svelte-gwb5vv"),A(E,"class","copy-btn svelte-gwb5vv"),A(S,"class","close-btn svelte-gwb5vv"),A(C,"class","modal-actions svelte-gwb5vv"),A(n,"class","modal svelte-gwb5vv"),A(t,"class","modal-overlay svelte-gwb5vv")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(r,o),c(r,l),c(n,a),c(n,f),c(n,h),c(n,v),c(v,b),c(n,I),c(n,C),c(C,E),c(C,x),c(C,S),B||(Q=[y(E,"click",e[18]),y(S,"click",e[19]),y(n,"click",w(e[23])),y(t,"click",e[19])],B=!0)},p(e,t){8192&t[0]&&k(o,e[13]),4096&t[0]&&(b.value=e[12])},d(e){e&&d(t),B=!1,i(Q)}}}function qA(t){let n,i,r,s,o,l,a;function f(e,t){return e[2]?e[0]?"owner"!==e[1]?RA:PA:TA:UA}let h=f(t),g=h(t),y=t[11]&&VA(t);return{c(){n=p("div"),i=p("h2"),i.textContent="Relay Connect",r=m(),s=p("p"),s.textContent="Nostr Relay Connect (NRC) allows remote access to this relay through a public relay tunnel.\n Create connection strings for your devices to sync securely.",o=m(),g.c(),l=m(),y&&y.c(),a=v(),A(i,"class","svelte-gwb5vv"),A(s,"class","description svelte-gwb5vv"),A(n,"class","relay-connect-view svelte-gwb5vv")},m(e,t){u(e,n,t),c(n,i),c(n,r),c(n,s),c(n,o),g.m(n,null),u(e,l,t),y&&y.m(e,t),u(e,a,t)},p(e,t){h===(h=f(e))&&g?g.p(e,t):(g.d(1),g=h(e),g&&(g.c(),g.m(n,null))),e[11]?y?y.p(e,t):(y=VA(e),y.c(),y.m(a.parentNode,a)):y&&(y.d(1),y=null)},i:e,o:e,d(e){e&&d(n),g.d(),e&&d(l),y&&y.d(e),e&&d(a)}}}function YA(e){return e?new Date(1e3*e).toLocaleString():"Never"}function WA(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{userSigner:s=null}=t,{userPubkey:o=""}=t;const l=P();let a=!1,c=!1,u=[],d={},f=!1,p="",h="info",g="",m=!1,v=!1,y="",w="";async function A(){if(i&&s&&o){n(6,f=!0);try{const e=await async function(e,t){const n=`${window.location.origin}/api/nrc/connections`,i=await CA(e,t,"GET",n),r=await fetch(n,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!r.ok){const e=await r.text();throw new Error(e||`Failed to get NRC connections: ${r.statusText}`)}return await r.json()}(s,o);n(4,u=e.connections||[]),n(5,d=e.config||{})}catch(e){I(`Failed to load connections: ${e.message}`,"error")}finally{n(6,f=!1)}}}async function b(e,t){if(confirm(`Are you sure you want to delete the connection "${t}"? This will revoke access for any device using this connection.`)){n(6,f=!0);try{await async function(e,t,n){const i=`${window.location.origin}/api/nrc/connections/${n}`,r=await CA(e,t,"DELETE",i),s=await fetch(i,{method:"DELETE",headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to delete NRC connection: ${s.statusText}`)}return await s.json()}(s,o,e),await A(),I(`Connection "${t}" deleted`,"success")}catch(e){I(`Failed to delete connection: ${e.message}`,"error")}finally{n(6,f=!1)}}}async function k(e,t){n(6,f=!0);try{const i=await async function(e,t,n){const i=`${window.location.origin}/api/nrc/connections/${n}/uri`,r=await CA(e,t,"GET",i),s=await fetch(i,{headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to get NRC URI: ${s.statusText}`)}return await s.json()}(s,o,e);n(12,y=i.uri),n(13,w=t),n(11,v=!0)}catch(e){I(`Failed to get URI: ${e.message}`,"error")}finally{n(6,f=!1)}}function I(e,t="info"){n(7,p=e),n(8,h=t),setTimeout(()=>{p===e&&n(7,p="")},5e3)}D(async()=>{await async function(){try{const e=await EA();n(2,a=e.enabled),n(3,c=e.badger_required),a&&i&&"owner"===r&&await A()}catch(e){console.error("Failed to load NRC config:",e)}}()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,i=e.isLoggedIn),"userRole"in e&&n(1,r=e.userRole),"userSigner"in e&&n(21,s=e.userSigner),"userPubkey"in e&&n(22,o=e.userPubkey)},e.$$.update=()=>{7&e.$$.dirty[0]&&i&&"owner"===r&&a&&A()},[i,r,a,c,u,d,f,p,h,g,m,v,y,w,A,async function(){if(g.trim()){n(6,f=!0);try{const e=await async function(e,t,n,i=!1){const r=`${window.location.origin}/api/nrc/connections`,s=await CA(e,t,"POST",r),o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...s?{Authorization:`Nostr ${s}`}:{}},body:JSON.stringify({label:n,use_cashu:i})});if(!o.ok){const e=await o.text();throw new Error(e||`Failed to create NRC connection: ${o.statusText}`)}return await o.json()}(s,o,g.trim(),m);n(12,y=e.uri),n(13,w=e.label),n(11,v=!0),n(9,g=""),n(10,m=!1),await A(),I(`Connection "${e.label}" created successfully`,"success")}catch(e){I(`Failed to create connection: ${e.message}`,"error")}finally{n(6,f=!1)}}else I("Please enter a label for the connection","error")},b,k,async function(e){const t=await FA(y);DA(e.target.closest("button"),t),t||I("Failed to copy to clipboard","error")},function(){n(11,v=!1),n(12,y=""),n(13,w="")},function(){l("openLoginModal")},s,o,function(t){R.call(this,e,t)},function(){g=this.value,n(9,g)},function(){m=this.checked,n(10,m)},e=>k(e.id,e.label),e=>b(e.id,e.label)]}class zA extends se{constructor(e){super(),re(this,e,WA,qA,s,{isLoggedIn:0,userRole:1,userSigner:21,userPubkey:22},null,[-1,-1])}}function ZA(e){let t,n,i,r,s,o,l,a,f,h,v;return{c(){t=p("div"),n=p("div"),i=p("h3"),i.textContent="Active Filter",r=m(),s=p("button"),s.textContent="🧹 Sweep",o=m(),l=p("div"),a=p("pre"),f=g(e[2]),A(i,"class","svelte-1tyqaa5"),A(s,"class","sweep-btn svelte-1tyqaa5"),A(s,"title","Clear filter"),A(n,"class","filter-display-header svelte-1tyqaa5"),A(a,"class","filter-json svelte-1tyqaa5"),A(l,"class","filter-json-container svelte-1tyqaa5"),A(t,"class","filter-display svelte-1tyqaa5")},m(d,p){u(d,t,p),c(t,n),c(n,i),c(n,r),c(n,s),c(t,o),c(t,l),c(l,a),c(a,f),h||(v=y(s,"click",e[3]),h=!0)},p(e,t){4&t&&k(f,e[2])},d(e){e&&d(t),h=!1,v()}}}function XA(t){let n,i=t[0]&&t[1]&&ZA(t);return{c(){i&&i.c(),n=v()},m(e,t){i&&i.m(e,t),u(e,n,t)},p(e,[t]){e[0]&&e[1]?i?i.p(e,t):(i=ZA(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&d(n)}}}function eb(e,t,n){let i,r;const s=P();let{filter:o={}}=t,{showFilter:l=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,o=e.filter),"showFilter"in e&&n(0,l=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,i=function(e){return JSON.stringify(e,null,2)}(o)),16&e.$$.dirty&&n(1,r=Object.keys(o).length>0)},[l,r,i,function(){s("sweep")},o]}class tb extends se{constructor(e){super(),re(this,e,eb,XA,s,{filter:4,showFilter:0})}}class nb{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,i,r]=n;e&&i?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!i&&(console.error("Authentication failed:",r),this.authPromise&&(this.authPromise.reject(new Error(r||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const i=["EVENT",e];this.ws.send(JSON.stringify(i));const r=this.ws.onmessage,s=setTimeout(()=>{this.ws.onmessage=r,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async i=>{try{const o=JSON.parse(i.data),[l,a,c,u]=o;if("OK"===l&&a===e.id)if(c)clearTimeout(s),this.ws.onmessage=r,console.log("Event published successfully:",a),t({success:!0,eventId:a,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required"))return void console.log("Authentication required, waiting for AUTH challenge...");clearTimeout(s),this.ws.onmessage=r,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===l){this.challenge=o[1],console.log("Received AUTH challenge during publish:",this.challenge);try{await this.authenticate(),console.log("Authentication successful, retrying event publish...");const t=["EVENT",e];this.ws.send(JSON.stringify(t))}catch(e){clearTimeout(s),this.ws.onmessage=r,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(o)}catch(e){clearTimeout(s),this.ws.onmessage=r,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function ib(e,t,n,i){const r=new nb(e,n,i);try{await r.connect();return await r.publishEvent(t)}finally{r.close()}}function rb(e,t,n){const i=e.slice();return i[171]=t[n],i}function sb(e,t,n){const i=e.slice();return i[181]=t[n],i}function ob(e,t,n){const i=e.slice();return i[174]=t[n],i}function lb(e,t,n){const i=e.slice();i[174]=t[n];const r=i[52](i[174]);return i[175]=r,i}function ab(e,t,n){const i=e.slice();return i[178]=t[n],i}function cb(t){let n;function i(e,t){return e[1]?Cb:Ib}let r=i(t),s=r(t);return{c(){n=p("div"),s.c(),A(n,"class","welcome-message svelte-u3u5mw")},m(e,t){u(e,n,t),s.m(n,null)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&d(n),s.d()}}}function ub(e){let t,n,i=e[6],r=[];for(let t=0;tZ(r[e],1,1,()=>{r[e]=null});return{c(){for(let e=0;e=0||""!==t[36]&&parseInt(t[36])>=0,P=pp,R=[];for(let e=0;eEvent Recovery \n

    Search and recover old versions of replaceable events

    ',s=m(),o=p("div"),l=p("div"),a=p("div"),h=p("label"),h.textContent="Select Event Kind:",g=m(),v=p("select"),w=p("option"),w.textContent="Choose a replaceable kind...";for(let e=0;et[116].call(v)),A(a,"class","kind-selector svelte-u3u5mw"),A(x,"for","custom-kind"),A(x,"class","svelte-u3u5mw"),A(B,"id","custom-kind"),A(B,"type","number"),A(B,"placeholder","e.g., 10001"),A(B,"min","0"),A(B,"class","svelte-u3u5mw"),A(C,"class","custom-kind-input svelte-u3u5mw"),A(l,"class","recovery-controls svelte-u3u5mw"),A(o,"class","recovery-controls-card svelte-u3u5mw"),A(n,"class","recovery-tab svelte-u3u5mw")},m(e,i){u(e,n,i),c(n,r),c(n,s),c(n,o),c(o,l),c(l,a),c(a,h),c(a,g),c(a,v),c(v,w);for(let e=0;e=0||""!==e[36]&&parseInt(e[36])>=0),$?T?T.p(e,t):(T=Tb(e),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},i:e,o:e,d(e){e&&d(n),f(R,e),T&&T.d(),F=!1,i(D)}}}function fb(e){let t,n;return t=new IA({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[13]}}),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),8192&n[0]&&(i.userSigner=e[13]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function pb(e){let t,n;return t=new zA({props:{isLoggedIn:e[1],userRole:e[4],userSigner:e[13],userPubkey:e[2]}}),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),8192&n[0]&&(i.userSigner=e[13]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function hb(e){let t,n,i;function r(t){e[115](t)}let s={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:ak,policyEnabled:e[8],isLoadingPolicy:e[27],policyMessage:e[28],policyMessageType:e[29],validationErrors:e[30],policyFollows:e[31]};return void 0!==e[26]&&(s.policyJson=e[26]),t=new Zv({props:s}),U.push(()=>X(t,"policyJson",r)),t.$on("loadPolicy",e[60]),t.$on("validatePolicy",e[61]),t.$on("savePolicy",e[62]),t.$on("formatJson",e[63]),t.$on("addPolicyAdmin",e[64]),t.$on("removePolicyAdmin",e[65]),t.$on("refreshFollows",e[66]),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,n){te(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),134217728&i[0]&&(r.isLoadingPolicy=e[27]),268435456&i[0]&&(r.policyMessage=e[28]),536870912&i[0]&&(r.policyMessageType=e[29]),1073741824&i[0]&&(r.validationErrors=e[30]),1&i[1]&&(r.policyFollows=e[31]),!n&&67108864&i[0]&&(n=!0,r.policyJson=e[26],j(()=>n=!1)),t.$set(r)},i(e){i||(z(t.$$.fragment,e),i=!0)},o(e){Z(t.$$.fragment,e),i=!1},d(e){ne(t,e)}}}function gb(e){let t,n,i;function r(t){e[112](t)}let s={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[20],isLoadingSprocket:e[22],sprocketUploadFile:e[25],sprocketMessage:e[23],sprocketMessageType:e[24],sprocketVersions:e[21]};return void 0!==e[19]&&(s.sprocketScript=e[19]),t=new Pv({props:s}),U.push(()=>X(t,"sprocketScript",r)),t.$on("restartSprocket",e[55]),t.$on("deleteSprocket",e[56]),t.$on("sprocketFileSelect",e[67]),t.$on("uploadSprocketScript",e[68]),t.$on("saveSprocket",e[54]),t.$on("loadSprocket",e[53]),t.$on("loadVersions",e[57]),t.$on("loadVersion",e[113]),t.$on("deleteVersion",e[114]),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,n){te(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),1048576&i[0]&&(r.sprocketStatus=e[20]),4194304&i[0]&&(r.isLoadingSprocket=e[22]),33554432&i[0]&&(r.sprocketUploadFile=e[25]),8388608&i[0]&&(r.sprocketMessage=e[23]),16777216&i[0]&&(r.sprocketMessageType=e[24]),2097152&i[0]&&(r.sprocketVersions=e[21]),!n&&524288&i[0]&&(n=!0,r.sprocketScript=e[19],j(()=>n=!1)),t.$set(r)},i(e){i||(z(t.$$.fragment,e),i=!0)},o(e){Z(t.$$.fragment,e),i=!1},d(e){ne(t,e)}}}function mb(e){let t,n,i,r;const s=[Kb,Jb,Gb],o=[];function l(e,t){return"curating"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=s[n](e),{c(){t=p("div"),i.c(),A(t,"class","curation-view-container")},m(e,i){u(e,t,i),o[n].m(t,null),r=!0},p(e,r){let a=n;n=l(e),n===a?o[n].p(e,r):(Y(),Z(o[a],1,1,()=>{o[a]=null}),W(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),z(i,1),i.m(t,null))},i(e){r||(z(i),r=!0)},o(e){Z(i),r=!1},d(e){e&&d(t),o[n].d()}}}function vb(e){let t,n,i,r;const s=[Yb,qb,Vb],o=[];function l(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=s[n](e),{c(){t=p("div"),i.c(),A(t,"class","managed-acl-view svelte-u3u5mw")},m(e,i){u(e,t,i),o[n].m(t,null),r=!0},p(e,r){let a=n;n=l(e),n===a?o[n].p(e,r):(Y(),Z(o[a],1,1,()=>{o[a]=null}),W(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),z(i,1),i.m(t,null))},i(e){r||(z(i),r=!0)},o(e){Z(i),r=!1},d(e){e&&d(t),o[n].d()}}}function yb(e){let t,n,i;function r(t){e[111](t)}let s={userPubkey:e[2],userRole:e[4],policyEnabled:e[8],publishError:e[34]};return void 0!==e[33]&&(s.composeEventJson=e[33]),t=new bv({props:s}),U.push(()=>X(t,"composeEventJson",r)),t.$on("reformatJson",e[90]),t.$on("signEvent",e[91]),t.$on("publishEvent",e[92]),t.$on("clearError",e[93]),{c(){ee(t.$$.fragment)},m(e,n){te(t,e,n),i=!0},p(e,i){const r={};4&i[0]&&(r.userPubkey=e[2]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),8&i[1]&&(r.publishError=e[34]),!n&&4&i[1]&&(n=!0,r.composeEventJson=e[33],j(()=>n=!1)),t.$set(r)},i(e){i||(z(t.$$.fragment,e),i=!0)},o(e){Z(t.$$.fragment,e),i=!1},d(e){ne(t,e)}}}function wb(e){let t,n;return t=new iA({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[13],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),8192&n[0]&&(i.userSigner=e[13]),1024&n[0]&&(i.currentEffectiveRole=e[10]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function Ab(e){let t,n;return t=new tv({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[41],expandedEvents:e[18],isLoadingEvents:e[7],showOnlyMyEvents:lk,showFilterBuilder:e[15]}}),t.$on("scroll",e[89]),t.$on("toggleEventExpansion",e[107]),t.$on("deleteEvent",e[108]),t.$on("copyEventToClipboard",e[109]),t.$on("toggleChange",e[45]),t.$on("loadAllEvents",e[110]),t.$on("toggleFilterBuilder",e[76]),t.$on("filterApply",e[77]),t.$on("filterClear",e[78]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),4&n[0]&&(i.userPubkey=e[2]),1024&n[1]&&(i.filteredEvents=e[41]),262144&n[0]&&(i.expandedEvents=e[18]),128&n[0]&&(i.isLoadingEvents=e[7]),32768&n[0]&&(i.showFilterBuilder=e[15]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function bb(e){let t,n;return t=new tm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],selectedFile:e[16],aclMode:e[9],importMessage:e[17]}}),t.$on("fileSelect",e[86]),t.$on("importEvents",e[87]),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),65536&n[0]&&(i.selectedFile=e[16]),512&n[0]&&(i.aclMode=e[9]),131072&n[0]&&(i.importMessage=e[17]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function kb(e){let t,n;return t=new qg({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],aclMode:e[9]}}),t.$on("exportMyEvents",e[85]),t.$on("exportAllEvents",e[84]),t.$on("openLoginModal",e[70]),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),512&n[0]&&(i.aclMode=e[9]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function Ib(t){let n;return{c(){n=p("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 Cb(e){let t,n,i,r=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=p("p"),n=g("Welcome "),i=g(r),A(t,"class","svelte-u3u5mw")},m(e,r){u(e,t,r),c(t,n),c(t,i)},p(e,t){12&t[0]&&r!==(r=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&k(i,r)},d(e){e&&d(t)}}}function Eb(e){let t,n,r,s,o,l,a,f,h,v,w,b,I,C,E,x,S,B,Q,F,D,$=e[181].label+"",P=e[42].get(e[181].id)?.isLoading,R=!e[42].get(e[181].id)?.hasMore&&e[42].get(e[181].id)?.events?.length>0;function T(){return e[121](e[181])}function U(e,t){return 64&t[0]&&(C=null),64&t[0]&&(E=null),null==C&&(C=!!(e[42].get(e[181].id)?.events?.length>0)),C?Sb:(null==E&&(E=!e[42].get(e[181].id)?.isLoading),E?xb:void 0)}w=new tb({props:{filter:e[42].get(e[181].id)?.filter||{}}}),w.$on("sweep",function(){return e[122](e[181])});let _=U(e,[-1,-1,-1,-1,-1,-1]),N=_&&_(e),L=P&&Db(),O=R&&$b();function M(...t){return e[127](e[181],...t)}return{c(){t=p("div"),n=p("div"),r=p("h2"),s=g("🔍 "),o=g($),l=m(),a=p("button"),f=g("🔄 Refresh"),v=m(),ee(w.$$.fragment),b=m(),I=p("div"),N&&N.c(),x=m(),L&&L.c(),S=m(),O&&O.c(),B=m(),A(r,"class","svelte-u3u5mw"),A(a,"class","refresh-btn svelte-u3u5mw"),a.disabled=h=e[42].get(e[181].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,i){u(e,t,i),c(t,n),c(n,r),c(r,s),c(r,o),c(n,l),c(n,a),c(a,f),c(t,v),te(w,t,null),c(t,b),c(t,I),N&&N.m(I,null),c(I,x),L&&L.m(I,null),c(I,S),O&&O.m(I,null),c(t,B),Q=!0,F||(D=[y(a,"click",T),y(I,"scroll",M)],F=!0)},p(t,n){e=t,(!Q||64&n[0])&&$!==($=e[181].label+"")&&k(o,$),(!Q||64&n[0]&&h!==(h=e[42].get(e[181].id)?.isLoading))&&(a.disabled=h);const i={};64&n[0]&&(i.filter=e[42].get(e[181].id)?.filter||{}),w.$set(i),_===(_=U(e,n))&&N?N.p(e,n):(N&&N.d(1),N=_&&_(e),N&&(N.c(),N.m(I,x))),64&n[0]&&(P=e[42].get(e[181].id)?.isLoading),P?L||(L=Db(),L.c(),L.m(I,S)):L&&(L.d(1),L=null),64&n[0]&&(R=!e[42].get(e[181].id)?.hasMore&&e[42].get(e[181].id)?.events?.length>0),R?O||(O=$b(),O.c(),O.m(I,null)):O&&(O.d(1),O=null)},i(e){Q||(z(w.$$.fragment,e),Q=!0)},o(e){Z(w.$$.fragment,e),Q=!1},d(e){e&&d(t),ne(w),N&&N.d(),L&&L.d(),O&&O.d(),F=!1,i(D)}}}function xb(t){let n;return{c(){n=p("div"),n.innerHTML='

    No search results found.

    ',A(n,"class","no-search-results svelte-u3u5mw")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Sb(e){let t,n=e[42].get(e[181].id).events,i=[];for(let t=0;t👤',s=m(),o=p("div"),l=p("div"),a=g(N),f=m(),h=p("div"),v=p("span"),w=g(L),b=m(),I=p("span"),C=g(O),E=m(),x=p("div"),B=p("div"),Q=g(M),F=m(),D=p("div"),$=g(j),P=m(),G&&G.c(),R=m(),V&&V.c(),T=m(),A(r,"class","search-result-avatar svelte-u3u5mw"),A(l,"class","search-result-author svelte-u3u5mw"),A(v,"class","kind-number svelte-u3u5mw"),A(I,"class","kind-name svelte-u3u5mw"),A(h,"class","search-result-kind svelte-u3u5mw"),A(o,"class","search-result-info svelte-u3u5mw"),A(B,"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"),S(t,"expanded",e[18].has(e[174].id))},m(e,i){u(e,t,i),c(t,n),c(n,r),c(n,s),c(n,o),c(o,l),c(l,a),c(o,f),c(o,h),c(h,v),c(v,w),c(h,b),c(h,I),c(I,C),c(n,E),c(n,x),c(x,B),c(B,Q),c(x,F),c(x,D),c(D,$),c(n,P),G&&G.m(n,null),c(t,R),V&&V.m(t,null),c(t,T),U||(_=[y(n,"click",J),y(n,"keydown",K)],U=!0)},p(i,r){e=i,64&r[0]&&N!==(N=SA(e[174].pubkey)+"")&&k(a,N),64&r[0]&&L!==(L=e[174].kind+"")&&k(w,L),64&r[0]&&O!==(O=xA(e[174].kind)+"")&&k(C,O),64&r[0]&&M!==(M=QA(e[174].created_at)+"")&&k(Q,M),64&r[0]&&j!==(j=BA(e[174].content)+"")&&k($,j),5!==e[174].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[174].pubkey&&e[174].pubkey===e[2])?G?G.p(e,r):(G=Bb(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),262208&r[0]&&(H=e[18].has(e[174].id)),H?V?V.p(e,r):(V=Qb(e),V.c(),V.m(t,T)):V&&(V.d(1),V=null),262208&r[0]|2048&r[1]&&S(t,"expanded",e[18].has(e[174].id))},d(e){e&&d(t),G&&G.d(),V&&V.d(),U=!1,i(_)}}}function Db(e){let t;return{c(){t=p("div"),t.innerHTML='
    \n

    Searching...

    ',A(t,"class","loading-search-results svelte-u3u5mw")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function $b(e){let t;return{c(){t=p("div"),t.innerHTML='

    No more search results to load.

    ',A(t,"class","end-of-search-results svelte-u3u5mw")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Pb(e){let t,n,i=e[181].id===e[5]&&Eb(e);return{c(){i&&i.c(),t=v()},m(e,r){i&&i.m(e,r),u(e,t,r),n=!0},p(e,n){e[181].id===e[5]?i?(i.p(e,n),96&n[0]&&z(i,1)):(i=Eb(e),i.c(),z(i,1),i.m(t.parentNode,t)):i&&(Y(),Z(i,1,1,()=>{i=null}),W())},i(e){n||(z(i),n=!0)},o(e){Z(i),n=!1},d(e){i&&i.d(e),e&&d(t)}}}function Rb(t){let n,i,r=t[178].label+"";return{c(){n=p("option"),i=g(r),n.__value=t[178].value,n.value=n.__value},m(e,t){u(e,n,t),c(n,i)},p:e,d(e){e&&d(n)}}}function Tb(e){let t;function n(e,t){return e[38]?Nb:0===e[37].length?_b:Ub}let i=n(e),r=i(e);return{c(){t=p("div"),r.c(),A(t,"class","recovery-results svelte-u3u5mw")},m(e,n){u(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&d(t),r.d()}}}function Ub(e){let t,n,i,r=e[37],s=[];for(let t=0;tORLY_ACL_MODE=curating in your\n environment variables and restart the relay.',A(i,"class","svelte-u3u5mw"),A(s,"class","svelte-u3u5mw"),A(l,"class","svelte-u3u5mw"),A(y,"class","svelte-u3u5mw"),A(n,"class","acl-mode-warning svelte-u3u5mw")},m(e,t){u(e,n,t),c(n,i),c(n,r),c(n,s),c(n,o),c(n,l),c(l,a),c(l,f),c(f,h),c(n,v),c(n,y)},p(e,t){512&t[0]&&w!==(w=(e[9]||"unknown")+"")&&k(h,w)},i:e,o:e,d(e){e&&d(n)}}}function Vb(t){let n,i,r,s,o,l;return{c(){n=p("div"),i=p("p"),i.textContent="Please log in with owner permissions to access\n managed ACL configuration.",r=m(),s=p("button"),s.textContent="Log In",A(s,"class","login-btn svelte-u3u5mw"),A(n,"class","access-denied")},m(e,a){u(e,n,a),c(n,i),c(n,r),c(n,s),o||(l=y(s,"click",t[70]),o=!0)},p:e,i:e,o:e,d(e){e&&d(n),o=!1,l()}}}function qb(e){let t,n;return t=new xg({props:{userSigner:e[13],userPubkey:e[2]}}),{c(){ee(t.$$.fragment)},m(e,i){te(t,e,i),n=!0},p(e,n){const i={};8192&n[0]&&(i.userSigner=e[13]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(z(t.$$.fragment,e),n=!0)},o(e){Z(t.$$.fragment,e),n=!1},d(e){ne(t,e)}}}function Yb(t){let n,i,r,s,o,l,a,f,h,v,y,w=(t[9]||"unknown")+"";return{c(){n=p("div"),i=p("h3"),i.textContent="⚠️ Managed ACL Mode Not Active",r=m(),s=p("p"),s.textContent='To use the Managed ACL interface, you need to set\n the ACL mode to "managed" in your relay\n configuration.',o=m(),l=p("p"),a=g("Current ACL mode: "),f=p("strong"),h=g(w),v=m(),y=p("p"),y.innerHTML='Please set ORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',A(i,"class","svelte-u3u5mw"),A(s,"class","svelte-u3u5mw"),A(l,"class","svelte-u3u5mw"),A(y,"class","svelte-u3u5mw"),A(n,"class","acl-mode-warning svelte-u3u5mw")},m(e,t){u(e,n,t),c(n,i),c(n,r),c(n,s),c(n,o),c(n,l),c(l,a),c(l,f),c(f,h),c(n,v),c(n,y)},p(e,t){512&t[0]&&w!==(w=(e[9]||"unknown")+"")&&k(h,w)},i:e,o:e,d(e){e&&d(n)}}}function Wb(e){let t,n,r,s,o,l,a,f,h,g;function v(e,t){return e[3]?Zb:e[1]&&e[2]?zb:void 0}let b=v(e),k=b&&b(e);return{c(){t=p("div"),n=p("div"),r=p("div"),s=p("h2"),s.textContent="Settings",o=m(),l=p("button"),l.textContent="✕",a=m(),f=p("div"),k&&k.c(),A(s,"class","svelte-u3u5mw"),A(l,"class","close-btn svelte-u3u5mw"),A(r,"class","drawer-header svelte-u3u5mw"),A(f,"class","drawer-content"),A(n,"class","settings-drawer svelte-u3u5mw"),S(n,"dark-theme",e[0]),A(t,"class","drawer-overlay svelte-u3u5mw"),A(t,"role","button"),A(t,"tabindex","0")},m(i,d){u(i,t,d),c(t,n),c(n,r),c(r,s),c(r,o),c(r,l),c(n,a),c(n,f),k&&k.m(f,null),h||(g=[y(l,"click",e[75]),y(n,"click",w(e[102])),y(n,"keydown",w(e[103])),y(t,"click",e[75]),y(t,"keydown",e[129])],h=!0)},p(e,t){b===(b=v(e))&&k?k.p(e,t):(k&&k.d(1),k=b&&b(e),k&&(k.c(),k.m(f,null))),1&t[0]&&S(n,"dark-theme",e[0])},d(e){e&&d(t),k&&k.d(),h=!1,i(g)}}}function zb(e){let t,n,r,s,o,l,a,f,h,v,w,b,I,C,E,x,S,B=e[2].slice(0,16)+"",Q=e[2].slice(-8)+"";return{c(){t=p("div"),n=p("button"),n.textContent="Log out",r=m(),s=p("h3"),s.textContent="Profile Loading",o=m(),l=p("p"),l.textContent="Your profile metadata is being loaded...",a=m(),f=p("button"),f.textContent="Retry Loading Profile",h=m(),v=p("div"),w=p("strong"),w.textContent="Public Key:",b=m(),I=g(B),C=g("..."),E=g(Q),A(n,"class","logout-btn floating svelte-u3u5mw"),A(s,"class","svelte-u3u5mw"),A(l,"class","svelte-u3u5mw"),A(f,"class","retry-profile-btn svelte-u3u5mw"),A(v,"class","user-pubkey-display svelte-u3u5mw"),A(t,"class","profile-loading-section svelte-u3u5mw")},m(i,d){u(i,t,d),c(t,n),c(t,r),c(t,s),c(t,o),c(t,l),c(t,a),c(t,f),c(t,h),c(t,v),c(v,w),c(v,b),c(v,I),c(v,C),c(v,E),x||(S=[y(n,"click",e[72]),y(f,"click",e[83])],x=!0)},p(e,t){4&t[0]&&B!==(B=e[2].slice(0,16)+"")&&k(I,B),4&t[0]&&Q!==(Q=e[2].slice(-8)+"")&&k(E,Q)},d(e){e&&d(t),x=!1,i(S)}}}function Zb(e){let t,n,i,r,s,o,l,a,f,h,w,b,I,C,E,x=(e[3].name||"Unknown User")+"",S=e[3].banner&&Xb(e);function B(e,t){return e[3].picture?tk:ek}let Q=B(e),F=Q(e),D=e[3].nip05&&nk(e),$=e[3].about&&ik(e),P=e[4]&&"read"!==e[4]&&rk(e);return{c(){t=p("div"),n=p("div"),S&&S.c(),i=m(),r=p("button"),r.textContent="Log out",s=m(),F.c(),o=m(),l=p("div"),a=p("h3"),f=g(x),h=m(),D&&D.c(),w=m(),$&&$.c(),b=m(),P&&P.c(),I=v(),A(r,"class","logout-btn floating svelte-u3u5mw"),A(a,"class","profile-username svelte-u3u5mw"),A(l,"class","name-row svelte-u3u5mw"),A(n,"class","profile-hero svelte-u3u5mw"),A(t,"class","profile-section svelte-u3u5mw")},m(d,p){u(d,t,p),c(t,n),S&&S.m(n,null),c(n,i),c(n,r),c(n,s),F.m(n,null),c(n,o),c(n,l),c(l,a),c(a,f),c(l,h),D&&D.m(l,null),c(t,w),$&&$.m(t,null),u(d,b,p),P&&P.m(d,p),u(d,I,p),C||(E=y(r,"click",e[72]),C=!0)},p(e,r){e[3].banner?S?S.p(e,r):(S=Xb(e),S.c(),S.m(n,i)):S&&(S.d(1),S=null),Q===(Q=B(e))&&F?F.p(e,r):(F.d(1),F=Q(e),F&&(F.c(),F.m(n,o))),8&r[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&k(f,x),e[3].nip05?D?D.p(e,r):(D=nk(e),D.c(),D.m(l,null)):D&&(D.d(1),D=null),e[3].about?$?$.p(e,r):($=ik(e),$.c(),$.m(t,null)):$&&($.d(1),$=null),e[4]&&"read"!==e[4]?P?P.p(e,r):(P=rk(e),P.c(),P.m(I.parentNode,I)):P&&(P.d(1),P=null)},d(e){e&&d(t),S&&S.d(),F.d(),D&&D.d(),$&&$.d(),e&&d(b),P&&P.d(e),e&&d(I),C=!1,E()}}}function Xb(e){let t,n;return{c(){t=p("img"),l(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,i){8&i[0]&&!l(t.src,n=e[3].banner)&&A(t,"src",n)},d(e){e&&d(t)}}}function ek(t){let n;return{c(){n=p("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 tk(e){let t,n;return{c(){t=p("img"),l(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,i){8&i[0]&&!l(t.src,n=e[3].picture)&&A(t,"src",n)},d(e){e&&d(t)}}}function nk(e){let t,n,i=e[3].nip05+"";return{c(){t=p("span"),n=g(i),A(t,"class","profile-nip05-inline svelte-u3u5mw")},m(e,i){u(e,t,i),c(t,n)},p(e,t){8&t[0]&&i!==(i=e[3].nip05+"")&&k(n,i)},d(e){e&&d(t)}}}function ik(e){let t,n;return{c(){t=p("div"),n=p("p"),A(n,"class","profile-about svelte-u3u5mw"),A(t,"class","about-card svelte-u3u5mw")},m(i,r){u(i,t,r),c(t,n),n.innerHTML=e[40]},p(e,t){512&t[1]&&(n.innerHTML=e[40])},d(e){e&&d(t)}}}function rk(e){let t,n,i,r,s,o,l=e[95](),a=[];for(let t=0;tX(v,"showModal",E)),v.$on("login",e[71]),v.$on("close",e[73]),{c(){ee(t.$$.fragment),n=m(),i=p("div"),ee(r.$$.fragment),s=m(),o=p("main"),f.c(),h=m(),C&&C.c(),g=m(),ee(v.$$.fragment),A(o,"class","main-content svelte-u3u5mw"),A(i,"class","app-container svelte-u3u5mw"),S(i,"dark-theme",e[0])},m(e,l){te(t,e,l),u(e,n,l),u(e,i,l),te(r,i,null),c(i,s),c(i,o),k[a].m(o,null),u(e,h,l),C&&C.m(e,l),u(e,g,l),te(v,e,l),w=!0},p(e,n){const s={};1&n[0]&&(s.isDarkTheme=e[0]),2&n[0]&&(s.isLoggedIn=e[1]),16&n[0]&&(s.userRole=e[4]),1024&n[0]&&(s.currentEffectiveRole=e[10]),8&n[0]&&(s.userProfile=e[3]),4&n[0]&&(s.userPubkey=e[2]),t.$set(s);const l={};1&n[0]&&(l.isDarkTheme=e[0]),2048&n[0]&&(l.tabs=e[11]),32&n[0]&&(l.selectedTab=e[5]),2&n[1]&&(l.version=e[32]),r.$set(l);let c=a;a=I(e,n),a===c?k[a].p(e,n):(Y(),Z(k[c],1,1,()=>{k[c]=null}),W(),f=k[a],f?f.p(e,n):(f=k[a]=b[a](e),f.c()),z(f,1),f.m(o,null)),(!w||1&n[0])&&S(i,"dark-theme",e[0]),e[14]?C?C.p(e,n):(C=Wb(e),C.c(),C.m(g.parentNode,g)):C&&(C.d(1),C=null);const u={};1&n[0]&&(u.isDarkTheme=e[0]),!y&&4096&n[0]&&(y=!0,u.showModal=e[12],j(()=>y=!1)),v.$set(u)},i(e){w||(z(t.$$.fragment,e),z(r.$$.fragment,e),z(f),z(v.$$.fragment,e),w=!0)},o(e){Z(t.$$.fragment,e),Z(r.$$.fragment,e),Z(f),Z(v.$$.fragment,e),w=!1},d(e){ne(t,e),e&&d(n),e&&d(i),ne(r),k[a].d(),e&&d(h),C&&C.d(e),e&&d(g),ne(v,e)}}}let lk=!1,ak=!1;function ck(e,t,n){let i,r,s,o,l;"undefined"!=typeof window&&(window.debugIndexedDB=Rp);let a=!1,c=!1,u=!1,d="",f="",p=null,h="",g=null,m=!1,v=localStorage.getItem("selectedTab")||"export",y=!1,w={},A=[],k=[],I=null,C="",E=new Set,S=!1,B=!0,Q=null,F="",D=new Map,$=[],P=0,T=[],U=!0,_=null,N="",L=null,O=[],M=!1,j="",H="info",G=!1,J=null,K="",V=!1,q=!1,Y="",W="info",z=[],Z=[],X=!1,ee="",te="",ne="",ie="",re=null,se="",oe=[],le=!1,ae=!0,ce=null;function ue(e){E.has(e)?E.delete(e):E.add(e),n(18,E)}async function de(e,t){const n=JSON.stringify(e),i=await FA(n);DA(t.target.closest(".copy-json-btn"),i),i||alert("Failed to copy to clipboard. Please copy manually.")}async function fe(e){if(!u)return void alert("Please log in first");const t=k.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===h||"owner"===h||"write"===h&&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 i={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",i),console.log("User pubkey:",d),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const r=await g.signEvent(i);console.log("Signed delete event:",r),console.log("Signed delete event pubkey:",r.pubkey),console.log("Delete event tags:",r.tags);const s=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await ib(s,r,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 o=t.pubkey&&t.pubkey===d;if(o){const t=await vp.publish(r);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 Fp(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 Dp(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(96,k=k.filter(t=>t.id!==e)),T=T.filter(t=>t.id!==e),$=$.filter(t=>t.id!==e);for(const[t,n]of D)n.events&&(n.events=n.events.filter(t=>t.id!==e),D.set(t,n));me(),console.log("Reloading events to show delete event...");const i=lk&&u&&d?[d]:null;await Ue(!0,i),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=new mp;await i.connectToRelay(t);const s=await i.publish(r);if(console.log("Delete event published to local relay only:",s),!(s.success&&s.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await Fp(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${s.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 Dp(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(96,k=k.filter(t=>t.id!==e)),T=T.filter(t=>t.id!==e),$=$.filter(t=>t.id!==e);for(const[t,n]of D)n.events&&(n.events=n.events.filter(t=>t.id!==e),D.set(t,n));me(),console.log("Reloading events to show delete event...");const t=lk&&u&&d?[d]:null;await Ue(!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 pe(){const e=se?parseInt(se):re;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(38,le=!0);try{const t=[{kinds:[e],authors:[d],limit:100}];ce&&(t[0].until=ce),console.log("Recovery filters:",t);const i=await Pp(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",i.length),console.log("Recovery events kinds:",i.map(e=>e.kind)),n(37,oe=ce?[...oe,...i]:i),i.length>0?(ce=Math.min(...i.map(e=>e.created_at)),n(39,ae=100===i.length)):n(39,ae=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(38,le=!1)}}else console.log("Not logged in, cannot load recovery events")}async function he(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const i={...e};if(i.created_at=Math.floor(Date.now()/1e3),i.id="",i.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(i.tags=i.tags.filter(e=>"d"!==e[0]),i.tags.push(t))}if(g){const e=await g.signEvent(i);console.log("Signed event for repost:",e);const r=await vp.publish(e,[t]);console.log("Repost publish result:",r),r.success&&r.okCount>0?(alert("Event reposted successfully!"),n(39,ae=!1),await pe()):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 Ep([{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],i=e.length>=3?e[2]:null;i&&"write"!==i||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),i=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=[i,...t.filter(e=>e!==i)];1===r.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",r,e);const s={...e};if(s.created_at=Math.floor(Date.now()/1e3),s.id="",s.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(s.tags=s.tags.filter(e=>"d"!==e[0]),s.tags.push(t))}if(g){const e=await g.signEvent(s);console.log("Signed event for repost to all:",e);const t=await vp.publish(e,r);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${r.length} relays!`),n(39,ae=!1),await pe()):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)");a=e.matches,e.addEventListener("change",e=>{n(0,a=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(),Re()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const i=JSON.parse(t);i.selectedTab&&Ee.some(e=>e.id===i.selectedTab)&&n(5,v=i.selectedTab),i.expandedEvents&&n(18,E=new Set(i.expandedEvents)),i.globalEventsCache&&($=i.globalEventsCache),i.globalCacheTimestamp&&(P=i.globalCacheTimestamp),void 0!==i.hasMoreEvents&&(B=i.hasMoreEvents),i.oldestEventTimestamp&&(Q=i.oldestEventTimestamp),void 0!==i.hasMoreMyEvents&&(U=i.hasMoreMyEvents),i.oldestMyEventTimestamp&&(_=i.oldestMyEventTimestamp),$.length>0&&((e=P)&&Date.now()-et.created_at-e.created_at),P=Date.now(),me()}async function ye(){if(u&&"owner"===h&&G)try{n(22,M=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Oe("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(20,L=await e.json()):ke("Failed to load sprocket status","error")}catch(e){ke(`Error loading sprocket status: ${e.message}`,"error")}finally{n(22,M=!1)}}async function we(){if(u&&"owner"===h)try{n(22,M=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await Oe("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(21,O=await e.json()):ke("Failed to load versions","error")}catch(e){ke(`Error loading versions: ${e.message}`,"error")}finally{n(22,M=!1)}}async function Ae(e){u&&"owner"===h&&(n(19,N=e.content),ke(`Loaded version: ${e.name}`,"success"))}async function be(e){if(u&&"owner"===h&&confirm(`Are you sure you want to delete version ${e}?`))try{n(22,M=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)ke(`Version ${e} deleted successfully`,"success"),await we();else{ke(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){ke(`Error deleting version: ${e.message}`,"error")}finally{n(22,M=!1)}}function ke(e,t="info"){n(23,j=e),n(24,H=t),setTimeout(()=>{n(23,j="")},5e3)}function Ie(e,t="info"){n(28,Y=e),n(29,W=t),"error"!==t&&setTimeout(()=>{n(28,Y="")},5e3)}async function Ce(){if(n(30,z=[]),!K.trim())return n(30,z=["Policy JSON is empty"]),Ie("Validation failed","error"),!1;try{const e=JSON.parse(K);if("object"!=typeof e||null===e)return n(30,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(30,z=[`JSON parse error: ${e.message}`]),Ie("Invalid JSON syntax","error"),!1}}const Ee=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"curation",icon:"📋",label:"Curation",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"relay-connect",icon:"🔗",label:"Relay Connect",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];function xe(e){n(5,v=e),"sprocket"===e&&u&&"owner"===h&&G&&(ye(),we()),me()}function Se(){n(14,m=!1)}function Be(e){Qe(e)}function Qe(e){n(6,A=A.filter(t=>t.id!==e)),D.delete(e),v===e&&n(5,v="export")}async function Fe(e,t=!0){const n=D.get(e);if(n&&!n.isLoading){n.isLoading=!0,D.set(e,n);try{const i={...n.filter};!t&&n.oldestTimestamp&&(i.until=n.oldestTimestamp),t||(i.limit=200),console.log("Loading search results with filter:",i);const r=await Qp([i],{timeout:3e4});if(console.log("Received search results:",r.length,"events"),n.events=t?r.sort((e,t)=>t.created_at-e.created_at):[...n.events,...r].sort((e,t)=>t.created_at-e.created_at),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!n.oldestTimestamp||e0){const e=s.filter(e=>e.pubkey&&e.pubkey!==d);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",s.length)}if(e?(n(96,k=s.sort((e,t)=>t.created_at-e.created_at)),ve(s)):(n(96,k=[...k,...s].sort((e,t)=>t.created_at-e.created_at)),ve(k)),s.length>0){const e=Math.min(...s.map(e=>e.created_at));(!Q||e{if("events"===v){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&_e()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,S=!1)}}}async function _e(){await Ue(!1)}let Ne=!1;async function Le(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 i;if(g&&"extension"===f)try{i=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(),i=n}const r=JSON.stringify(i);return`Nostr ${btoa(r)}`}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+t],["method",e.toUpperCase()]],content:"",pubkey:d};let i;if(g&&"extension"===f)try{i=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(),i=n}const r=JSON.stringify(i);return btoa(r)}function Me(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: ${h||"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 je(e){n(97,F=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",l)}F=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(6&e.$$.dirty[0]|8&e.$$.dirty[3]&&n(41,i=k.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(40,r=p?.about?(t=p.about,t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):"").replace(/\n{2,}/g,"
    "):""),16&e.$$.dirty[0]|16&e.$$.dirty[3]&&n(10,l=F&&""!==F?F:h),1810&e.$$.dirty[0]|112&e.$$.dirty[3]&&n(101,s=Ee.filter(e=>{const t=l;return!(e.requiresAdmin&&(!u||"admin"!==t&&"owner"!==t))&&(!(e.requiresOwner&&(!u||"owner"!==t))&&(!(e.requiresWrite&&(!u||"read"===t))&&(!("sprocket"===e.id&&!G)&&(!("policy"===e.id&&!V)&&(!("relay-connect"===e.id&&!X)&&(("managed-acl"!==e.id||"managed"===ee)&&(("curation"!==e.id||"curating"===ee)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:u,userRole:h,viewAsRole:F,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0))))))))})),64&e.$$.dirty[0]|256&e.$$.dirty[3]&&n(11,o=[...s,...A]),2578&e.$$.dirty[0]|256&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:u,userRole:h,aclMode:ee,filteredBaseTabs:s.map(e=>e.id),allTabs:o.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(a?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&u&&d&&!p&&$e(),182&e.$$.dirty[0]|136&e.$$.dirty[3]&&"events"===v&&u&&("read"===h||"write"===h||"admin"===h||"owner"===h)&&0===k.length&&!Ne&&!S){n(100,Ne=!0);Ue(!0,null)}32&e.$$.dirty[0]|8&e.$$.dirty[3]&&("events"!==v||"events"===v&&k.length>0)&&n(100,Ne=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",v)},[a,u,d,p,h,v,A,S,V,ee,l,o,c,g,m,y,I,C,E,N,L,O,M,j,H,J,K,q,Y,W,z,Z,te,ne,ie,re,se,oe,le,ae,r,i,D,ue,de,async function(){console.log("Toggle changed, showOnlyMyEvents:",lk),n(100,Ne=!1),await Ue(!0,null)},fe,pe,he,ge,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",re),null!=re?(n(36,se=""),n(37,oe=[]),ce=null,n(39,ae=!0),pe()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",se);const e=parseInt(se);""!==se&&!isNaN(e)&&e>=0&&(n(35,re=null),n(37,oe=[]),ce=null,n(39,ae=!0),pe())},function(e){const t=oe.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"===h)try{n(22,M=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Oe("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(19,N=t.script_content||""),n(20,L=t),ke("Script loaded successfully","success")}else ke("Failed to load script","error")}catch(e){ke(`Error loading script: ${e.message}`,"error")}finally{n(22,M=!1)}},async function(){if(u&&"owner"===h)try{n(22,M=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:N});if(e.ok)ke("Script saved and updated successfully","success"),await ye(),await we();else{ke(`Failed to save script: ${await e.text()}`,"error")}}catch(e){ke(`Error saving script: ${e.message}`,"error")}finally{n(22,M=!1)}},async function(){if(u&&"owner"===h)try{n(22,M=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)ke("Sprocket restarted successfully","success"),await ye();else{ke(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){ke(`Error restarting sprocket: ${e.message}`,"error")}finally{n(22,M=!1)}},async function(){if(u&&"owner"===h&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(22,M=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(19,N=""),ke("Sprocket script deleted successfully","success"),await ye(),await we();else{ke(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){ke(`Error deleting script: ${e.message}`,"error")}finally{n(22,M=!1)}},we,Ae,be,async function(){if(u&&("owner"===h||ak))try{n(27,q=!0),n(30,z=[]);const e={kinds:[12345],limit:1},t=await Pp(e);if(t&&t.length>0){n(26,K=t[0].content);try{n(26,K=JSON.stringify(JSON.parse(K),null,2))}catch(e){}Ie("Policy loaded successfully","success")}else{const e=await fetch("/api/policy",{method:"GET",headers:{Authorization:`Nostr ${await Oe("GET","/api/policy")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(26,K=JSON.stringify(t,null,2)),Ie("Policy loaded from file","success")}else Ie("No policy configuration found","info"),n(26,K="")}}catch(e){Ie(`Error loading policy: ${e.message}`,"error")}finally{n(27,q=!1)}},Ce,async function(){if(!u||"owner"!==h&&!ak)return;if(await Ce())try{n(27,q=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:K},t=await ib(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(27,q=!1)}},function(){try{const e=JSON.parse(K);n(26,K=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 i=function(e){if(!e)return null;if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(e.startsWith("npub1"))try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(5);let i=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");i.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}i=i.slice(0,-30);const r=[];for(let e=0;e+8<=i.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|i[e+n];r.push(t)}return r.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(i&&64===i.length)try{const e=JSON.parse(K||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(i))return void Ie("Admin already in list","warning");e.policy_admins.push(i),n(26,K=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(K||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(26,K=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"===h||ak))try{n(27,q=!0),n(31,Z=[]);let e=[];try{e=JSON.parse(K||"{}").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},i=await Pp(t),r=new Set;for(const e of i)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&r.add(t[1]);n(31,Z=Array.from(r)),Ie(`Loaded ${Z.length} follows from ${i.length} admin(s)`,"success")}catch(e){Ie(`Error loading follows: ${e.message}`,"error")}finally{n(27,q=!1)}},function(e){n(25,J=e.target.files[0])},async function(){if(u&&"owner"===h&&J)try{n(22,M=!0);const e=await J.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Oe("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(19,N=e),ke("Script uploaded and updated successfully","success"),await ye(),await we();else{ke(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){ke(`Error uploading script: ${e.message}`,"error")}finally{n(22,M=!1),n(25,J=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:i,privateKey:r,signer:s}=e.detail;n(1,u=!0),n(2,d=i),f=t,n(13,g=s),n(12,c=!1);try{if(await $p(),"extension"===t&&s)vp.setSigner(s);else if("nsec"===t&&r){const e=new ff(r);vp.setSigner(e)}n(3,p=await Sp(i)),console.log("Profile loaded:",p)}catch(e){console.error("Failed to load profile:",e)}await Pe(),await Re()},function(){n(1,u=!1),n(2,d=""),f="",n(3,p=null),n(4,h=""),n(13,g=null),userPrivkey=null,n(14,m=!1),T=[],n(96,k=[]),$=[],P=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(14,m=!0)},Se,function(){n(15,y=!y)},function(e){const{searchText:t,selectedKinds:n,pubkeys:i,eventIds:r,tags:s,sinceTimestamp:o,untilTimestamp:l,limit:a}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:i=[],tags:r=[],since:s=null,until:o=null,limit:l=null}){const a={};return e&&e.trim()&&(a.search=e.trim()),t&&t.length>0&&(a.kinds=t),n&&n.length>0&&(a.authors=n),i&&i.length>0&&(a.ids=i),r&&r.length>0&&r.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;a[t]||(a[t]=[]),a[t].push(e.value)}}),s&&(a.since=s),o&&(a.until=o),l&&l>0&&(a.limit=l),a}({searchText:t,kinds:n,authors:i,ids:r,tags:s,since:o,until:l,limit:a||100});w=c,Ue(!0,null)},function(){w={},Ue(!0,null)},Be,Qe,Fe,De,$e,async function(){await Te([])},async function(){await Te([d])},function(e){n(16,I=e.detail.target.files[0])},async function(){if("none"!==ee&&(!u||"admin"!==h&&"owner"!==h))return n(17,C="Admin or owner permission required"),void setTimeout(()=>{n(17,C="")},5e3);if(!I)return n(17,C="Please select a file"),void setTimeout(()=>{n(17,C="")},5e3);try{n(17,C="Uploading...");const e={};"none"!==ee&&u&&(e.Authorization=await Le("/api/import","POST"));const t=new FormData;t.append("file",I);const i=await fetch("/api/import",{method:"POST",headers:e,body:t});if(!i.ok)throw new Error(`Import failed: ${i.status} ${i.statusText}`);await i.json();n(17,C="Upload complete"),n(16,I=null),document.getElementById("import-file").value="",setTimeout(()=>{n(17,C="")},5e3)}catch(e){console.error("Import failed:",e),n(17,C="Import failed: "+e.message),setTimeout(()=>{n(17,C="")},5e3)}},Ue,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:i}=e.target;n-t-i<100&&_e()},function(){try{if(!ne.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(ne);n(33,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(33,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(34,ie="");try{if(!ne.trim())return void n(34,ie="Please enter an event to publish");if(!u)return void n(34,ie="Please log in to publish events");if(!g)return void n(34,ie="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(ne)}catch(e){return void n(34,ie=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(34,ie='Event must be signed before publishing. Please click "Sign" first.');if("read"===h)return void n(34,ie=`Permission denied: Your current role is "${h}" which does not allow publishing events. Contact a relay administrator to upgrade your permissions.`);const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=await ib(t,e,g,d);if(i.success)n(34,ie=""),alert("Event published successfully to ORLY relay!");else{const t=i.reason||"Unknown error";n(34,ie=Me(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(34,ie=Me(t,null))}},function(){n(34,ie="")},je,function(){const e=["owner","admin","write","read"],t=e.indexOf(h);return-1===t?["read"]:e.slice(t)},k,F,G,X,Ne,s,function(t){R.call(this,e,t)},function(t){R.call(this,e,t)},e=>e.id===v,e=>xe(e.detail),e=>Qe(e.detail),e=>ue(e.detail),e=>fe(e.detail),e=>de(e.detail.event,e.detail.e),e=>Ue(e.detail.refresh,e.detail.authors),function(e){ne=e,n(33,ne)},function(e){N=e,n(19,N)},e=>Ae(e.detail),e=>be(e.detail),function(e){K=e,n(26,K)},function(){re=x(this),n(35,re)},function(){se=b(this.value),n(36,se)},e=>ge(e),e=>he(e),(e,t)=>de(e,t),e=>Fe(e.id,!0),e=>Be(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=>je(e===h?"":e),e=>"Escape"===e.key&&Se(),function(e){c=e,n(12,c)}]}return new class extends se{constructor(e){super(),re(this,e,ck,ok,s,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); + */function ah(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function l(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,l)}a((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class ch{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 ah(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}var uh;const dh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,fh=null!==(uh=dh.Buffer)&&void 0!==uh?uh:null,ph=dh.TextEncoder?new dh.TextEncoder:null;function hh(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function gh(e,t){const n=t.length>>1;for(let i=0;i>>4;e[i++]=n>9?n+mh:n+vh,n=15&t[r],e[i++]=n>9?n+mh:n+vh}return String.fromCharCode.apply(null,e)}const wh=null!==fh?e=>{if("string"==typeof e){const t=fh.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(fh.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 ph.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},bh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ah=new Uint8Array(256);for(let e=0;e<64;e++)Ah[bh.charCodeAt(e)]=e;function kh(e,t=!0){const n=e.length,i=n%3,r=[],s=n-i;for(let t=0;t>18&63)+bh.charAt(n>>12&63)+bh.charAt(n>>6&63)+bh.charAt(63&n);r.push(i)}if(1===i){const i=e[n-1],s=bh.charAt(i>>2),o=bh.charAt(i<<4&63);r.push(`${s}${o}`),t&&r.push("==")}else if(2===i){const i=(e[n-2]<<8)+e[n-1],s=bh.charAt(i>>10),o=bh.charAt(i>>4&63),l=bh.charAt(i<<2&63);r.push(`${s}${o}${l}`),t&&r.push("=")}return r.join("")}function Ih(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,i=new Uint8Array(t);let r=0;for(let t=0;t>4,r+=1,i[r]=(15&s)<<4|o>>2,r+=1,i[r]=(3&o)<<6|63&l,r+=1}return i}const Ch=16384,Eh=new ch,xh=new Map;function Sh(e,t){return ah(this,void 0,void 0,function*(){let n=null,i=null,r=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const s=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),o=Eh.dispatch(()=>ah(this,void 0,void 0,function*(){if(!xh.has(e.name)){const t=Ih(e.data),n=WebAssembly.compile(t);xh.set(e.name,n)}const t=yield xh.get(e.name);n=yield WebAssembly.instantiate(t,{})})),l=(e=null)=>{r=!0,n.exports.Hash_Init(e)},a=e=>{if(!r)throw new Error("update() called before init()");(e=>{let t=0;for(;t{if(!r)throw new Error("digest() called before init()");return r=!1,n.exports.Hash_Final(s),"binary"===e?i.slice(0,t):yh(c,i,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength!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(()=>ah(this,void 0,void 0,function*(){n||(yield o);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;i=new Uint8Array(t,e,Ch)}))(),{getMemory:()=>i,writeMemory:(e,t=0)=>{i.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),r=n.exports.memory.buffer;i=new Uint8Array(r,t,e)},init:l,update:a,digest:u,save:()=>{if(!r)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),i=s(),o=n.exports.memory.buffer,l=new Uint8Array(o,t,i),a=new Uint8Array(4+i);return gh(a,e.hash),a.set(l,4),a},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const i=n.exports.Hash_GetState(),o=s(),l=4+o,a=n.exports.memory.buffer;if(t.length!==l)throw new Error(`Bad state length (expected ${l} bytes, got ${t.length})`);if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n{if(!f(e,r))return l(r),a(e),u("hex",s);const o=wh(e);return i.set(o),n.exports.Hash_Calculate(o.length,r,s),yh(c,i,t)},hashLength:t}})}new ch;var Bh={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"},Qh={name:"blake2b",data:"AGFzbQEAAAABEQRgAAF/YAJ/fwBgAX8AYAAAAwoJAAECAwECAgABBQQBAQICBg4CfwFBsIsFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACkhhc2hfRmluYWwAAwlIYXNoX0luaXQABQtIYXNoX1VwZGF0ZQAGDUhhc2hfR2V0U3RhdGUABw5IYXNoX0NhbGN1bGF0ZQAIClNUQVRFX1NJWkUDAQrTOAkFAEGACQvrAgIFfwF+AkAgAUEBSA0AAkACQAJAIAFBgAFBACgC4IoBIgJrIgNKDQAgASEEDAELQQBBADYC4IoBAkAgAkH/AEoNACACQeCJAWohBSAAIQRBACEGA0AgBSAELQAAOgAAIARBAWohBCAFQQFqIQUgAyAGQQFqIgZB/wFxSg0ACwtBAEEAKQPAiQEiB0KAAXw3A8CJAUEAQQApA8iJASAHQv9+Vq18NwPIiQFB4IkBEAIgACADaiEAAkAgASADayIEQYEBSA0AIAIgAWohBQNAQQBBACkDwIkBIgdCgAF8NwPAiQFBAEEAKQPIiQEgB0L/flatfDcDyIkBIAAQAiAAQYABaiEAIAVBgH9qIgVBgAJLDQALIAVBgH9qIQQMAQsgBEEATA0BC0EAIQUDQCAFQQAoAuCKAWpB4IkBaiAAIAVqLQAAOgAAIAQgBUEBaiIFQf8BcUoNAAsLQQBBACgC4IoBIARqNgLgigELC78uASR+QQBBACkD0IkBQQApA7CJASIBQQApA5CJAXwgACkDICICfCIDhULr+obav7X2wR+FQiCJIgRCq/DT9K/uvLc8fCIFIAGFQiiJIgYgA3wgACkDKCIBfCIHIASFQjCJIgggBXwiCSAGhUIBiSIKQQApA8iJAUEAKQOoiQEiBEEAKQOIiQF8IAApAxAiA3wiBYVCn9j52cKR2oKbf4VCIIkiC0K7zqqm2NDrs7t/fCIMIASFQiiJIg0gBXwgACkDGCIEfCIOfCAAKQNQIgV8Ig9BACkDwIkBQQApA6CJASIQQQApA4CJASIRfCAAKQMAIgZ8IhKFQtGFmu/6z5SH0QCFQiCJIhNCiJLznf/M+YTqAHwiFCAQhUIoiSIVIBJ8IAApAwgiEHwiFiAThUIwiSIXhUIgiSIYQQApA9iJAUEAKQO4iQEiE0EAKQOYiQF8IAApAzAiEnwiGYVC+cL4m5Gjs/DbAIVCIIkiGkLx7fT4paf9p6V/fCIbIBOFQiiJIhwgGXwgACkDOCITfCIZIBqFQjCJIhogG3wiG3wiHSAKhUIoiSIeIA98IAApA1giCnwiDyAYhUIwiSIYIB18Ih0gDiALhUIwiSIOIAx8Ih8gDYVCAYkiDCAWfCAAKQNAIgt8Ig0gGoVCIIkiFiAJfCIaIAyFQiiJIiAgDXwgACkDSCIJfCIhIBaFQjCJIhYgGyAchUIBiSIMIAd8IAApA2AiB3wiDSAOhUIgiSIOIBcgFHwiFHwiFyAMhUIoiSIbIA18IAApA2giDHwiHCAOhUIwiSIOIBd8IhcgG4VCAYkiGyAZIBQgFYVCAYkiFHwgACkDcCINfCIVIAiFQiCJIhkgH3wiHyAUhUIoiSIUIBV8IAApA3giCHwiFXwgDHwiIoVCIIkiI3wiJCAbhUIoiSIbICJ8IBJ8IiIgFyAYIBUgGYVCMIkiFSAffCIZIBSFQgGJIhQgIXwgDXwiH4VCIIkiGHwiFyAUhUIoiSIUIB98IAV8Ih8gGIVCMIkiGCAXfCIXIBSFQgGJIhR8IAF8IiEgFiAafCIWIBUgHSAehUIBiSIaIBx8IAl8IhyFQiCJIhV8Ih0gGoVCKIkiGiAcfCAIfCIcIBWFQjCJIhWFQiCJIh4gGSAOIBYgIIVCAYkiFiAPfCACfCIPhUIgiSIOfCIZIBaFQiiJIhYgD3wgC3wiDyAOhUIwiSIOIBl8Ihl8IiAgFIVCKIkiFCAhfCAEfCIhIB6FQjCJIh4gIHwiICAiICOFQjCJIiIgJHwiIyAbhUIBiSIbIBx8IAp8IhwgDoVCIIkiDiAXfCIXIBuFQiiJIhsgHHwgE3wiHCAOhUIwiSIOIBkgFoVCAYkiFiAffCAQfCIZICKFQiCJIh8gFSAdfCIVfCIdIBaFQiiJIhYgGXwgB3wiGSAfhUIwiSIfIB18Ih0gFoVCAYkiFiAVIBqFQgGJIhUgD3wgBnwiDyAYhUIgiSIYICN8IhogFYVCKIkiFSAPfCADfCIPfCAHfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBnwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAOIBd8Ig4gDyAYhUIwiSIPICAgFIVCAYkiFCAZfCAKfCIXhUIgiSIYfCIZIBSFQiiJIhQgF3wgC3wiF3wgBXwiICAPIBp8Ig8gHyAOIBuFQgGJIg4gIXwgCHwiGoVCIIkiG3wiHyAOhUIoiSIOIBp8IAx8IhogG4VCMIkiG4VCIIkiISAdIB4gDyAVhUIBiSIPIBx8IAF8IhWFQiCJIhx8Ih0gD4VCKIkiDyAVfCADfCIVIByFQjCJIhwgHXwiHXwiHiAWhUIoiSIWICB8IA18IiAgIYVCMIkiISAefCIeIBogFyAYhUIwiSIXIBl8IhggFIVCAYkiFHwgCXwiGSAchUIgiSIaICR8IhwgFIVCKIkiFCAZfCACfCIZIBqFQjCJIhogHSAPhUIBiSIPICJ8IAR8Ih0gF4VCIIkiFyAbIB98Iht8Ih8gD4VCKIkiDyAdfCASfCIdIBeFQjCJIhcgH3wiHyAPhUIBiSIPIBsgDoVCAYkiDiAVfCATfCIVICOFQiCJIhsgGHwiGCAOhUIoiSIOIBV8IBB8IhV8IAx8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAHfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBogHHwiGiAVIBuFQjCJIhUgHiAWhUIBiSIWIB18IAR8IhuFQiCJIhx8Ih0gFoVCKIkiFiAbfCAQfCIbfCABfCIeIBUgGHwiFSAXIBogFIVCAYkiFCAgfCATfCIYhUIgiSIXfCIaIBSFQiiJIhQgGHwgCXwiGCAXhUIwiSIXhUIgiSIgIB8gISAVIA6FQgGJIg4gGXwgCnwiFYVCIIkiGXwiHyAOhUIoiSIOIBV8IA18IhUgGYVCMIkiGSAffCIffCIhIA+FQiiJIg8gHnwgBXwiHiAghUIwiSIgICF8IiEgGyAchUIwiSIbIB18IhwgFoVCAYkiFiAYfCADfCIYIBmFQiCJIhkgJHwiHSAWhUIoiSIWIBh8IBJ8IhggGYVCMIkiGSAfIA6FQgGJIg4gInwgAnwiHyAbhUIgiSIbIBcgGnwiF3wiGiAOhUIoiSIOIB98IAZ8Ih8gG4VCMIkiGyAafCIaIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAh8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgC3wiFXwgBXwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAh8IiIgGiAgIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGHwgCXwiGIVCIIkiHHwiGiAUhUIoiSIUIBh8IAZ8IhggHIVCMIkiHCAafCIaIBSFQgGJIhR8IAR8IiAgGSAdfCIZIBUgISAPhUIBiSIPIB98IAN8Ih2FQiCJIhV8Ih8gD4VCKIkiDyAdfCACfCIdIBWFQjCJIhWFQiCJIiEgFyAbIBkgFoVCAYkiFiAefCABfCIZhUIgiSIbfCIXIBaFQiiJIhYgGXwgE3wiGSAbhUIwiSIbIBd8Ihd8Ih4gFIVCKIkiFCAgfCAMfCIgICGFQjCJIiEgHnwiHiAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IBJ8Ih0gG4VCIIkiGyAafCIaIA6FQiiJIg4gHXwgC3wiHSAbhUIwiSIbIBcgFoVCAYkiFiAYfCANfCIXICKFQiCJIhggFSAffCIVfCIfIBaFQiiJIhYgF3wgEHwiFyAYhUIwiSIYIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGXwgCnwiFSAchUIgiSIZICN8IhwgD4VCKIkiDyAVfCAHfCIVfCASfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgBXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAbIBp8IhogFSAZhUIwiSIVIB4gFIVCAYkiFCAXfCADfCIXhUIgiSIZfCIbIBSFQiiJIhQgF3wgB3wiF3wgAnwiHiAVIBx8IhUgGCAaIA6FQgGJIg4gIHwgC3wiGoVCIIkiGHwiHCAOhUIoiSIOIBp8IAR8IhogGIVCMIkiGIVCIIkiICAfICEgFSAPhUIBiSIPIB18IAZ8IhWFQiCJIh18Ih8gD4VCKIkiDyAVfCAKfCIVIB2FQjCJIh0gH3wiH3wiISAWhUIoiSIWIB58IAx8Ih4gIIVCMIkiICAhfCIhIBogFyAZhUIwiSIXIBt8IhkgFIVCAYkiFHwgEHwiGiAdhUIgiSIbICR8Ih0gFIVCKIkiFCAafCAJfCIaIBuFQjCJIhsgHyAPhUIBiSIPICJ8IBN8Ih8gF4VCIIkiFyAYIBx8Ihh8IhwgD4VCKIkiDyAffCABfCIfIBeFQjCJIhcgHHwiHCAPhUIBiSIPIBggDoVCAYkiDiAVfCAIfCIVICOFQiCJIhggGXwiGSAOhUIoiSIOIBV8IA18IhV8IA18IiKFQiCJIiN8IiQgD4VCKIkiDyAifCAMfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHXwiGyAVIBiFQjCJIhUgISAWhUIBiSIWIB98IBB8IhiFQiCJIh18Ih8gFoVCKIkiFiAYfCAIfCIYfCASfCIhIBUgGXwiFSAXIBsgFIVCAYkiFCAefCAHfCIZhUIgiSIXfCIbIBSFQiiJIhQgGXwgAXwiGSAXhUIwiSIXhUIgiSIeIBwgICAVIA6FQgGJIg4gGnwgAnwiFYVCIIkiGnwiHCAOhUIoiSIOIBV8IAV8IhUgGoVCMIkiGiAcfCIcfCIgIA+FQiiJIg8gIXwgBHwiISAehUIwiSIeICB8IiAgGCAdhUIwiSIYIB98Ih0gFoVCAYkiFiAZfCAGfCIZIBqFQiCJIhogJHwiHyAWhUIoiSIWIBl8IBN8IhkgGoVCMIkiGiAcIA6FQgGJIg4gInwgCXwiHCAYhUIgiSIYIBcgG3wiF3wiGyAOhUIoiSIOIBx8IAN8IhwgGIVCMIkiGCAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAt8IhUgI4VCIIkiFyAdfCIdIBSFQiiJIhQgFXwgCnwiFXwgBHwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IAl8IiIgGyAeIBUgF4VCMIkiFSAdfCIXIBSFQgGJIhQgGXwgDHwiGYVCIIkiHXwiGyAUhUIoiSIUIBl8IAp8IhkgHYVCMIkiHSAbfCIbIBSFQgGJIhR8IAN8Ih4gGiAffCIaIBUgICAPhUIBiSIPIBx8IAd8IhyFQiCJIhV8Ih8gD4VCKIkiDyAcfCAQfCIcIBWFQjCJIhWFQiCJIiAgFyAYIBogFoVCAYkiFiAhfCATfCIahUIgiSIYfCIXIBaFQiiJIhYgGnwgDXwiGiAYhUIwiSIYIBd8Ihd8IiEgFIVCKIkiFCAefCAFfCIeICCFQjCJIiAgIXwiISAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIBx8IAt8IhwgGIVCIIkiGCAbfCIbIA6FQiiJIg4gHHwgEnwiHCAYhUIwiSIYIBcgFoVCAYkiFiAZfCABfCIXICKFQiCJIhkgFSAffCIVfCIfIBaFQiiJIhYgF3wgBnwiFyAZhUIwiSIZIB98Ih8gFoVCAYkiFiAVIA+FQgGJIg8gGnwgCHwiFSAdhUIgiSIaICN8Ih0gD4VCKIkiDyAVfCACfCIVfCANfCIihUIgiSIjfCIkIBaFQiiJIhYgInwgCXwiIiAjhUIwiSIjICR8IiQgFoVCAYkiFiAYIBt8IhggFSAahUIwiSIVICEgFIVCAYkiFCAXfCASfCIXhUIgiSIafCIbIBSFQiiJIhQgF3wgCHwiF3wgB3wiISAVIB18IhUgGSAYIA6FQgGJIg4gHnwgBnwiGIVCIIkiGXwiHSAOhUIoiSIOIBh8IAt8IhggGYVCMIkiGYVCIIkiHiAfICAgFSAPhUIBiSIPIBx8IAp8IhWFQiCJIhx8Ih8gD4VCKIkiDyAVfCAEfCIVIByFQjCJIhwgH3wiH3wiICAWhUIoiSIWICF8IAN8IiEgHoVCMIkiHiAgfCIgIBggFyAahUIwiSIXIBt8IhogFIVCAYkiFHwgBXwiGCAchUIgiSIbICR8IhwgFIVCKIkiFCAYfCABfCIYIBuFQjCJIhsgHyAPhUIBiSIPICJ8IAx8Ih8gF4VCIIkiFyAZIB18Ihl8Ih0gD4VCKIkiDyAffCATfCIfIBeFQjCJIhcgHXwiHSAPhUIBiSIPIBkgDoVCAYkiDiAVfCAQfCIVICOFQiCJIhkgGnwiGiAOhUIoiSIOIBV8IAJ8IhV8IBN8IiKFQiCJIiN8IiQgD4VCKIkiDyAifCASfCIiICOFQjCJIiMgJHwiJCAPhUIBiSIPIBsgHHwiGyAVIBmFQjCJIhUgICAWhUIBiSIWIB98IAt8IhmFQiCJIhx8Ih8gFoVCKIkiFiAZfCACfCIZfCAJfCIgIBUgGnwiFSAXIBsgFIVCAYkiFCAhfCAFfCIahUIgiSIXfCIbIBSFQiiJIhQgGnwgA3wiGiAXhUIwiSIXhUIgiSIhIB0gHiAVIA6FQgGJIg4gGHwgEHwiFYVCIIkiGHwiHSAOhUIoiSIOIBV8IAF8IhUgGIVCMIkiGCAdfCIdfCIeIA+FQiiJIg8gIHwgDXwiICAhhUIwiSIhIB58Ih4gGSAchUIwiSIZIB98IhwgFoVCAYkiFiAafCAIfCIaIBiFQiCJIhggJHwiHyAWhUIoiSIWIBp8IAp8IhogGIVCMIkiGCAdIA6FQgGJIg4gInwgBHwiHSAZhUIgiSIZIBcgG3wiF3wiGyAOhUIoiSIOIB18IAd8Ih0gGYVCMIkiGSAbfCIbIA6FQgGJIg4gFSAXIBSFQgGJIhR8IAx8IhUgI4VCIIkiFyAcfCIcIBSFQiiJIhQgFXwgBnwiFXwgEnwiIoVCIIkiI3wiJCAOhUIoiSIOICJ8IBN8IiIgGyAhIBUgF4VCMIkiFSAcfCIXIBSFQgGJIhQgGnwgBnwiGoVCIIkiHHwiGyAUhUIoiSIUIBp8IBB8IhogHIVCMIkiHCAbfCIbIBSFQgGJIhR8IA18IiEgGCAffCIYIBUgHiAPhUIBiSIPIB18IAJ8Ih2FQiCJIhV8Ih4gD4VCKIkiDyAdfCABfCIdIBWFQjCJIhWFQiCJIh8gFyAZIBggFoVCAYkiFiAgfCADfCIYhUIgiSIZfCIXIBaFQiiJIhYgGHwgBHwiGCAZhUIwiSIZIBd8Ihd8IiAgFIVCKIkiFCAhfCAIfCIhIB+FQjCJIh8gIHwiICAiICOFQjCJIiIgJHwiIyAOhUIBiSIOIB18IAd8Ih0gGYVCIIkiGSAbfCIbIA6FQiiJIg4gHXwgDHwiHSAZhUIwiSIZIBcgFoVCAYkiFiAafCALfCIXICKFQiCJIhogFSAefCIVfCIeIBaFQiiJIhYgF3wgCXwiFyAahUIwiSIaIB58Ih4gFoVCAYkiFiAVIA+FQgGJIg8gGHwgBXwiFSAchUIgiSIYICN8IhwgD4VCKIkiDyAVfCAKfCIVfCACfCIChUIgiSIifCIjIBaFQiiJIhYgAnwgC3wiAiAihUIwiSILICN8IiIgFoVCAYkiFiAZIBt8IhkgFSAYhUIwiSIVICAgFIVCAYkiFCAXfCANfCINhUIgiSIXfCIYIBSFQiiJIhQgDXwgBXwiBXwgEHwiECAVIBx8Ig0gGiAZIA6FQgGJIg4gIXwgDHwiDIVCIIkiFXwiGSAOhUIoiSIOIAx8IBJ8IhIgFYVCMIkiDIVCIIkiFSAeIB8gDSAPhUIBiSINIB18IAl8IgmFQiCJIg98IhogDYVCKIkiDSAJfCAIfCIJIA+FQjCJIgggGnwiD3wiGiAWhUIoiSIWIBB8IAd8IhAgEYUgDCAZfCIHIA6FQgGJIgwgCXwgCnwiCiALhUIgiSILIAUgF4VCMIkiBSAYfCIJfCIOIAyFQiiJIgwgCnwgE3wiEyALhUIwiSIKIA58IguFNwOAiQFBACADIAYgDyANhUIBiSINIAJ8fCICIAWFQiCJIgUgB3wiBiANhUIoiSIHIAJ8fCICQQApA4iJAYUgBCABIBIgCSAUhUIBiSIDfHwiASAIhUIgiSISICJ8IgkgA4VCKIkiAyABfHwiASAShUIwiSIEIAl8IhKFNwOIiQFBACATQQApA5CJAYUgECAVhUIwiSIQIBp8IhOFNwOQiQFBACABQQApA5iJAYUgAiAFhUIwiSICIAZ8IgGFNwOYiQFBACASIAOFQgGJQQApA6CJAYUgAoU3A6CJAUEAIBMgFoVCAYlBACkDqIkBhSAKhTcDqIkBQQAgASAHhUIBiUEAKQOwiQGFIASFNwOwiQFBACALIAyFQgGJQQApA7iJAYUgEIU3A7iJAQvdAgUBfwF+AX8BfgJ/IwBBwABrIgAkAAJAQQApA9CJAUIAUg0AQQBBACkDwIkBIgFBACgC4IoBIgKsfCIDNwPAiQFBAEEAKQPIiQEgAyABVK18NwPIiQECQEEALQDoigFFDQBBAEJ/NwPYiQELQQBCfzcD0IkBAkAgAkH/AEoNAEEAIQQDQCACIARqQeCJAWpBADoAACAEQQFqIgRBgAFBACgC4IoBIgJrSA0ACwtB4IkBEAIgAEEAKQOAiQE3AwAgAEEAKQOIiQE3AwggAEEAKQOQiQE3AxAgAEEAKQOYiQE3AxggAEEAKQOgiQE3AyAgAEEAKQOoiQE3AyggAEEAKQOwiQE3AzAgAEEAKQO4iQE3AzhBACgC5IoBIgVBAUgNAEEAIQRBACECA0AgBEGACWogACAEai0AADoAACAEQQFqIQQgBSACQQFqIgJB/wFxSg0ACwsgAEHAAGokAAv9AwMBfwF+AX8jAEGAAWsiAiQAQQBBgQI7AfKKAUEAIAE6APGKAUEAIAA6APCKAUGQfiEAA0AgAEGAiwFqQgA3AAAgAEH4igFqQgA3AAAgAEHwigFqQgA3AAAgAEEYaiIADQALQQAhAEEAQQApA/CKASIDQoiS853/zPmE6gCFNwOAiQFBAEEAKQP4igFCu86qptjQ67O7f4U3A4iJAUEAQQApA4CLAUKr8NP0r+68tzyFNwOQiQFBAEEAKQOIiwFC8e30+KWn/aelf4U3A5iJAUEAQQApA5CLAULRhZrv+s+Uh9EAhTcDoIkBQQBBACkDmIsBQp/Y+dnCkdqCm3+FNwOoiQFBAEEAKQOgiwFC6/qG2r+19sEfhTcDsIkBQQBBACkDqIsBQvnC+JuRo7Pw2wCFNwO4iQFBACADp0H/AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=",hash:"c6f286e6"};function Fh(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function $h(e=512,t=null){if(Fh(e))return Promise.reject(Fh(e));let n=null,i=e;if(null!==t){if(n=wh(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));r=e,s=n.length,i=r|s<<16}var r,s;const o=e/8;return Sh(Qh,o).then(e=>{i>512&&e.writeMemory(n),e.init(i);const t={init:i>512?()=>(e.writeMemory(n),e.init(i),t):()=>(e.init(i),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:o};return t})}new ch;const Dh=new DataView(new ArrayBuffer(4));function Rh(e){return Dh.setInt32(0,e,!0),new Uint8Array(Dh.buffer)}function Ph(e,t,n){return ah(this,void 0,void 0,function*(){if(n<=64){const e=yield $h(8*n);return e.update(Rh(n)),e.update(t),e.digest("binary")}const i=Math.ceil(n/32)-2,r=new Uint8Array(n);e.init(),e.update(Rh(n)),e.update(t);let s=e.digest("binary");r.set(s.subarray(0,32),0);for(let t=1;t{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=wh(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=wh(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=wh(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),Th(Object.assign(Object.assign({},e),{hashType:"id"}))})}new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch;const Nh={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let _h=null,Lh=0;const Mh=new Map;async function Oh(e,t){try{const n=function(){if(_h)return _h;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 _h=new Worker(URL.createObjectURL(e)),_h.onmessage=function(e){const{id:t,success:n,result:i,error:r}=e.data,s=Mh.get(t);s&&(Mh.delete(t),n?s.resolve(new Uint8Array(i)):s.reject(new Error(r)))},_h.onerror=function(e){console.error("Argon2 worker error:",e)},_h}(),i=++Lh;return new Promise((r,s)=>{Mh.set(i,{resolve:r,reject:s}),n.postMessage({id:i,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await Uh({password:e,salt:t,...Nh})}}const{window:jh}=d;function Hh(e){let t,n,r,s,o,l,a,c,u,d,g,v,y,b,C,E,x,S;function B(e,t){return"extension"===e[2]?qh:Gh}let Q=B(e),$=Q(e),D=e[10]&&ig(e),R=e[11]&&rg(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Login to Nostr",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("button"),d.textContent="Extension",g=w(),v=m("button"),v.textContent="Nsec",y=w(),b=m("div"),$.c(),C=w(),D&&D.c(),E=w(),R&&R.c(),I(s,"class","svelte-4xpfbi"),I(l,"class","close-btn svelte-4xpfbi"),I(r,"class","modal-header svelte-4xpfbi"),I(d,"class","tab-btn svelte-4xpfbi"),F(d,"active","extension"===e[2]),I(v,"class","tab-btn svelte-4xpfbi"),F(v,"active","nsec"===e[2]),I(u,"class","tabs svelte-4xpfbi"),I(b,"class","tab-content svelte-4xpfbi"),I(c,"class","tab-container svelte-4xpfbi"),I(n,"class","modal svelte-4xpfbi"),F(n,"dark-theme",e[1]),I(t,"class","modal-overlay svelte-4xpfbi"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(u,v),f(c,y),f(c,b),$.m(b,null),f(b,C),D&&D.m(b,null),f(b,E),R&&R.m(b,null),x||(S=[A(l,"click",e[17]),A(d,"click",e[26]),A(v,"click",e[27]),A(n,"click",k(e[24])),A(n,"keydown",k(e[25])),A(t,"click",e[17]),A(t,"keydown",e[32])],x=!0)},p(e,t){4&t[0]&&F(d,"active","extension"===e[2]),4&t[0]&&F(v,"active","nsec"===e[2]),Q===(Q=B(e))&&$?$.p(e,t):($.d(1),$=Q(e),$&&($.c(),$.m(b,C))),e[10]?D?D.p(e,t):(D=ig(e),D.c(),D.m(b,E)):D&&(D.d(1),D=null),e[11]?R?R.p(e,t):(R=rg(e),R.c(),R.m(b,null)):R&&(R.d(1),R=null),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&h(t),$.d(),D&&D.d(),R&&R.d(),x=!1,i(S)}}}function Gh(e){let t;function n(e,t){return e[14]?Kh:Jh}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","nsec-login svelte-4xpfbi")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function qh(e){let t,n,i,r,s,o,l,a=e[7]?"Connecting...":"Log in using extension";return{c(){t=m("div"),n=m("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",i=w(),r=m("button"),s=y(a),I(n,"class","svelte-4xpfbi"),I(r,"class","login-extension-btn svelte-4xpfbi"),r.disabled=e[7],I(t,"class","extension-login svelte-4xpfbi")},m(a,c){p(a,t,c),f(t,n),f(t,i),f(t,r),f(r,s),o||(l=A(r,"click",e[21]),o=!0)},p(e,t){128&t[0]&&a!==(a=e[7]?"Connecting...":"Log in using extension")&&E(s,a),128&t[0]&&(r.disabled=e[7])},d(e){e&&h(t),o=!1,l()}}}function Jh(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C,S,B,Q,F,$,D,R,P,T=e[8]?"Generating...":"Generate New Key",U=e[12]&&Vh(e),N=e[4]&&Yh(e);function _(e,t){return e[9]?Zh:e[7]?Wh:zh}let L=_(e),M=L(e);return{c(){t=m("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n set a password to encrypt it securely.",n=w(),r=m("button"),s=y(T),l=w(),U&&U.c(),a=w(),c=m("input"),d=w(),g=m("div"),v=m("label"),v.textContent="Encryption Password (optional but recommended):",b=w(),k=m("input"),S=w(),N&&N.c(),B=w(),Q=m("small"),Q.textContent="Password uses Argon2id with ~3 second derivation time for security.",F=w(),$=m("button"),M.c(),I(t,"class","svelte-4xpfbi"),I(r,"class","generate-btn svelte-4xpfbi"),r.disabled=o=e[7]||e[8],I(c,"type","password"),I(c,"placeholder","nsec1..."),c.disabled=u=e[7]||e[9],I(c,"class","nsec-input svelte-4xpfbi"),I(v,"class","svelte-4xpfbi"),I(k,"type","password"),I(k,"placeholder","Enter password (min 8 chars)"),k.disabled=C=e[7]||e[9],I(k,"class","password-input svelte-4xpfbi"),I(Q,"class","password-hint svelte-4xpfbi"),I(g,"class","password-section svelte-4xpfbi"),I($,"class","login-nsec-btn svelte-4xpfbi"),$.disabled=D=e[7]||e[9]||!e[3].trim()},m(i,o){p(i,t,o),p(i,n,o),p(i,r,o),f(r,s),p(i,l,o),U&&U.m(i,o),p(i,a,o),p(i,c,o),x(c,e[3]),p(i,d,o),p(i,g,o),f(g,v),f(g,b),f(g,k),x(k,e[4]),f(g,S),N&&N.m(g,null),f(g,B),f(g,Q),p(i,F,o),p(i,$,o),M.m($,null),R||(P=[A(r,"click",e[20]),A(c,"input",e[29]),A(k,"input",e[30]),A($,"click",e[22])],R=!0)},p(e,t){256&t[0]&&T!==(T=e[8]?"Generating...":"Generate New Key")&&E(s,T),384&t[0]&&o!==(o=e[7]||e[8])&&(r.disabled=o),e[12]?U?U.p(e,t):(U=Vh(e),U.c(),U.m(a.parentNode,a)):U&&(U.d(1),U=null),640&t[0]&&u!==(u=e[7]||e[9])&&(c.disabled=u),8&t[0]&&c.value!==e[3]&&x(c,e[3]),640&t[0]&&C!==(C=e[7]||e[9])&&(k.disabled=C),16&t[0]&&k.value!==e[4]&&x(k,e[4]),e[4]?N?N.p(e,t):(N=Yh(e),N.c(),N.m(g,B)):N&&(N.d(1),N=null),L!==(L=_(e))&&(M.d(1),M=L(e),M&&(M.c(),M.m($,null))),648&t[0]&&D!==(D=e[7]||e[9]||!e[3].trim())&&($.disabled=D)},d(e){e&&h(t),e&&h(n),e&&h(r),e&&h(l),U&&U.d(e),e&&h(a),e&&h(c),e&&h(d),e&&h(g),N&&N.d(),e&&h(F),e&&h($),M.d(),R=!1,i(P)}}}function Kh(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C=e[15]&&Xh(e);function E(e,t){return e[9]?ng:e[7]?tg:eg}let S=E(e),B=S(e);return{c(){t=m("p"),t.textContent="You have a stored encrypted key. Enter your\n password to unlock it.",n=w(),C&&C.c(),r=w(),s=m("input"),l=w(),a=m("button"),B.c(),u=w(),d=m("button"),g=y("Clear stored key & start fresh"),I(t,"class","svelte-4xpfbi"),I(s,"type","password"),I(s,"placeholder","Enter your password"),s.disabled=o=e[7]||e[9],I(s,"class","password-input svelte-4xpfbi"),I(a,"class","login-nsec-btn svelte-4xpfbi"),a.disabled=c=e[7]||e[9]||!e[6],I(d,"class","clear-btn svelte-4xpfbi"),d.disabled=v=e[7]||e[9]},m(i,o){p(i,t,o),p(i,n,o),C&&C.m(i,o),p(i,r,o),p(i,s,o),x(s,e[6]),p(i,l,o),p(i,a,o),B.m(a,null),p(i,u,o),p(i,d,o),f(d,g),b||(k=[A(s,"input",e[28]),A(a,"click",e[18]),A(d,"click",e[16])],b=!0)},p(e,t){e[15]?C?C.p(e,t):(C=Xh(e),C.c(),C.m(r.parentNode,r)):C&&(C.d(1),C=null),640&t[0]&&o!==(o=e[7]||e[9])&&(s.disabled=o),64&t[0]&&s.value!==e[6]&&x(s,e[6]),S!==(S=E(e))&&(B.d(1),B=S(e),B&&(B.c(),B.m(a,null))),704&t[0]&&c!==(c=e[7]||e[9]||!e[6])&&(a.disabled=c),640&t[0]&&v!==(v=e[7]||e[9])&&(d.disabled=v)},d(e){e&&h(t),e&&h(n),C&&C.d(e),e&&h(r),e&&h(s),e&&h(l),e&&h(a),B.d(),e&&h(u),e&&h(d),b=!1,i(k)}}}function Vh(e){let t,n,i,r,s;return{c(){t=m("div"),n=m("label"),n.textContent="Your new public key (npub):",i=w(),r=m("code"),s=y(e[12]),I(n,"class","svelte-4xpfbi"),I(r,"class","npub-display svelte-4xpfbi"),I(t,"class","generated-info svelte-4xpfbi")},m(e,o){p(e,t,o),f(t,n),f(t,i),f(t,r),f(r,s)},p(e,t){4096&t[0]&&E(s,e[12])},d(e){e&&h(t)}}}function Yh(e){let t,n,i,r;return{c(){t=m("input"),I(t,"type","password"),I(t,"placeholder","Confirm password"),t.disabled=n=e[7]||e[9],I(t,"class","password-input svelte-4xpfbi")},m(n,s){p(n,t,s),x(t,e[5]),i||(r=A(t,"input",e[31]),i=!0)},p(e,i){640&i[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&i[0]&&t.value!==e[5]&&x(t,e[5])},d(e){e&&h(t),i=!1,r()}}}function zh(e){let t;return{c(){t=y("Log in with nsec")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Wh(e){let t;return{c(){t=y("Logging in...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Zh(e){let t;return{c(){t=y("Deriving key...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Xh(e){let t,n,i,r,s,o,l,a=e[15].slice(0,16)+"",c=e[15].slice(-8)+"";return{c(){t=m("div"),n=m("label"),n.textContent="Stored public key:",i=w(),r=m("code"),s=y(a),o=y("..."),l=y(c),I(n,"class","svelte-4xpfbi"),I(r,"class","npub-display svelte-4xpfbi"),I(t,"class","stored-info svelte-4xpfbi")},m(e,a){p(e,t,a),f(t,n),f(t,i),f(t,r),f(r,s),f(r,o),f(r,l)},p(e,t){32768&t[0]&&a!==(a=e[15].slice(0,16)+"")&&E(s,a),32768&t[0]&&c!==(c=e[15].slice(-8)+"")&&E(l,c)},d(e){e&&h(t)}}}function eg(e){let t;return{c(){t=y("Unlock")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function tg(e){let t;return{c(){t=y("Unlocking...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function ng(e){let t;return{c(){t=y("Deriving key...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function ig(e){let t,n;return{c(){t=m("div"),n=y(e[10]),I(t,"class","message error-message svelte-4xpfbi")},m(e,i){p(e,t,i),f(t,n)},p(e,t){1024&t[0]&&E(n,e[10])},d(e){e&&h(t)}}}function rg(e){let t,n;return{c(){t=m("div"),n=y(e[11]),I(t,"class","message success-message svelte-4xpfbi")},m(e,i){p(e,t,i),f(t,n)},p(e,t){2048&t[0]&&E(n,e[11])},d(e){e&&h(t)}}}function sg(e){let t,n,i,r,s,o,l,a,c,u,d,g=e[13].toFixed(1)+"";return{c(){t=m("div"),n=m("div"),i=m("div"),r=w(),s=m("h3"),s.textContent="Deriving encryption key",o=w(),l=m("div"),a=y(g),c=y("s"),u=w(),d=m("p"),d.textContent="This may take 3-6 seconds for security",I(i,"class","deriving-spinner svelte-4xpfbi"),I(s,"class","svelte-4xpfbi"),I(l,"class","deriving-timer svelte-4xpfbi"),I(d,"class","deriving-note svelte-4xpfbi"),I(n,"class","deriving-modal svelte-4xpfbi"),F(n,"dark-theme",e[1]),I(t,"class","deriving-overlay svelte-4xpfbi")},m(e,h){p(e,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(n,u),f(n,d)},p(e,t){8192&t[0]&&g!==(g=e[13].toFixed(1)+"")&&E(a,g),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&h(t)}}}function og(t){let n,i,r,s,o=t[0]&&Hh(t),l=t[9]&&sg(t);return{c(){o&&o.c(),n=w(),l&&l.c(),i=b()},m(e,a){o&&o.m(e,a),p(e,n,a),l&&l.m(e,a),p(e,i,a),r||(s=A(jh,"keydown",t[23]),r=!0)},p(e,t){e[0]?o?o.p(e,t):(o=Hh(e),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null),e[9]?l?l.p(e,t):(l=sg(e),l.c(),l.m(i.parentNode,i)):l&&(l.d(1),l=null)},i:e,o:e,d(e){o&&o.d(e),e&&h(n),l&&l.d(e),e&&h(i),r=!1,s()}}}function lg(e,t,n){const i=U();let{showModal:r=!1}=t,{isDarkTheme:s=!1}=t,o="extension",l="",a="",c="",u="",d=!1,f=!1,p=!1,h="",g="",m="",v="",y=0,w=null,b=null;function A(){n(13,y=0),w=performance.now(),k()}function k(){null!==w&&(n(13,y=(performance.now()-w)/1e3),b=requestAnimationFrame(k))}function I(){w=null,b&&(cancelAnimationFrame(b),b=null)}T(()=>{I()});let C=!1,E="";function x(){n(14,C=!!localStorage.getItem("nostr_privkey_encrypted")),n(15,E=localStorage.getItem("nostr_pubkey")||"")}function S(){n(0,r=!1),n(3,l=""),n(4,a=""),n(5,c=""),n(6,u=""),n(10,h=""),n(11,g=""),m="",n(12,v=""),i("close")}function B(e){n(2,o=e),n(10,h=""),n(11,g=""),m="",n(12,v="")}async function Q(){n(7,d=!0),n(10,h=""),n(11,g="");try{if(!l.trim())throw new Error("Please enter your nsec");if(!function(e){if(!e||!e.startsWith("nsec1"))return!1;try{return"nsec"===bu(e).type}catch{return!1}}(l.trim()))throw new Error("Invalid nsec format or checksum");if(a){if(a.length<8)throw new Error("Password must be at least 8 characters");if(a!==c)throw new Error("Passwords do not match")}const e=gf.fromKey(l.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),a){n(9,p=!0),A();const e=await async function(e,t){if(!e.startsWith("nsec1"))throw new Error("Invalid nsec format - must start with nsec1");try{if("nsec"!==bu(e).type)throw new Error("Invalid nsec - wrong type")}catch(e){throw new Error("Invalid nsec - bech32 checksum failed")}const n=crypto.getRandomValues(new Uint8Array(32)),i=crypto.getRandomValues(new Uint8Array(12)),r=await Oh(t,n),s=await crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),o=new TextEncoder,l=await crypto.subtle.encrypt({name:"AES-GCM",iv:i},s,o.encode(e)),a=new Uint8Array(n.length+i.length+l.byteLength);return a.set(n,0),a.set(i,n.length),a.set(new Uint8Array(l),n.length+i.length),btoa(String.fromCharCode(...a))}(l.trim(),a);I(),n(9,p=!1),localStorage.setItem("nostr_privkey_encrypted",e),localStorage.removeItem("nostr_privkey")}else localStorage.setItem("nostr_privkey",l.trim()),localStorage.removeItem("nostr_privkey_encrypted"),n(11,g="Successfully logged in with nsec!");i("login",{method:"nsec",pubkey:t,privateKey:l.trim(),signer:e}),setTimeout(()=>{S()},1500)}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}}P(()=>{x()});return e.$$set=e=>{"showModal"in e&&n(0,r=e.showModal),"isDarkTheme"in e&&n(1,s=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&r&&x()},[r,s,o,l,a,c,u,d,f,p,h,g,v,y,C,E,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(14,C=!1),n(15,E=""),n(6,u=""),n(10,h=""),n(11,g="")},S,async function(){n(7,d=!0),n(9,p=!0),A(),n(10,h=""),n(11,g="");try{if(!u)throw new Error("Please enter your password");const e=localStorage.getItem("nostr_privkey_encrypted");if(!e)throw new Error("No encrypted key found");const t=await async function(e,t){const n=new Uint8Array(atob(e).split("").map(e=>e.charCodeAt(0)));if(n.length<60)throw new Error("Invalid encrypted data - too short");const i=n.slice(0,32),r=n.slice(32,44),s=n.slice(44),o=await Oh(t,i),l=await crypto.subtle.importKey("raw",o,{name:"AES-GCM"},!1,["decrypt"]);let a;try{a=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},l,s)}catch(e){throw new Error("Decryption failed - invalid password or corrupted data")}const c=(new TextDecoder).decode(a);if(!c.startsWith("nsec1"))throw new Error("Decryption produced invalid data - not an nsec");try{if("nsec"!==bu(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,p=!1);const r=gf.fromKey(t),s=await r.getPublicKey();i("login",{method:"nsec",pubkey:s,privateKey:t,signer:r}),S()}catch(e){I(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,h="Invalid password"):n(10,h=e.message)}finally{n(7,d=!1),n(9,p=!1),I()}},B,async function(){n(8,f=!0),n(10,h=""),n(11,g="");try{const e=tu(),t=Iu("nsec",e),i=ku(nu(e));m=t,n(12,v=i),n(3,l=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,h="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,h=""),n(11,g="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(11,g="Successfully logged in with extension!"),i("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{S()},1500))}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}},Q,function(e){"Escape"===e.key&&S(),"Enter"===e.key&&"nsec"===o&&Q()},function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},()=>B("extension"),()=>B("nsec"),function(){u=this.value,n(6,u)},function(){l=this.value,n(3,l)},function(){a=this.value,n(4,a)},function(){c=this.value,n(5,c)},e=>"Escape"===e.key&&S()]}class ag extends ae{constructor(e){super(),le(this,e,lg,og,s,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function cg(e,t,n){const i=e.slice();return i[72]=t[n],i}function ug(e,t,n){const i=e.slice();return i[75]=t[n],i}function dg(e,t,n){const i=e.slice();return i[72]=t[n],i}function fg(e,t,n){const i=e.slice();return i[72]=t[n],i}function pg(e,t,n){const i=e.slice();return i[72]=t[n],i}function hg(e,t,n){const i=e.slice();return i[72]=t[n],i}function gg(e,t,n){const i=e.slice();return i[72]=t[n],i}function mg(e){let t,n,i;return{c(){t=m("div"),n=y(e[3]),I(t,"class",i="message "+e[4]+" svelte-1y8wjwc")},m(e,i){p(e,t,i),f(t,n)},p(e,r){8&r[0]&&E(n,e[3]),16&r[0]&&i!==(i="message "+e[4]+" svelte-1y8wjwc")&&I(t,"class",i)},d(e){e&&h(t)}}}function vg(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C,E,S,B,Q,F,$,D,R,P,T,U,N,_;function L(e,t){return e[5]&&e[5].length>0?wg:yg}let M=L(e),O=M(e);function j(e,t){return e[8]&&e[8].length>0?Ig:kg}let H=j(e),G=H(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Banned Pubkeys",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=y("Ban Pubkey"),v=w(),b=m("div"),O.c(),k=w(),C=m("div"),E=m("h3"),E.textContent="Allowed Pubkeys",S=w(),B=m("div"),Q=m("input"),F=w(),$=m("input"),D=w(),R=m("button"),P=y("Allow Pubkey"),T=w(),U=m("div"),G.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","Pubkey (64 hex chars)"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(E,"class","svelte-1y8wjwc"),I(Q,"type","text"),I(Q,"placeholder","Pubkey (64 hex chars)"),I(Q,"class","svelte-1y8wjwc"),I($,"type","text"),I($,"placeholder","Reason (optional)"),I($,"class","svelte-1y8wjwc"),R.disabled=e[2],I(R,"class","svelte-1y8wjwc"),I(B,"class","add-form svelte-1y8wjwc"),I(U,"class","list svelte-1y8wjwc"),I(C,"class","section svelte-1y8wjwc"),I(t,"class","pubkeys-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[6]),f(o,a),f(o,c),x(c,e[7]),f(o,u),f(o,d),f(d,g),f(n,v),f(n,b),O.m(b,null),f(t,k),f(t,C),f(C,E),f(C,S),f(C,B),f(B,Q),x(Q,e[9]),f(B,F),f(B,$),x($,e[10]),f(B,D),f(B,R),f(R,P),f(C,T),f(C,U),G.m(U,null),N||(_=[A(l,"input",e[43]),A(c,"input",e[44]),A(d,"click",e[25]),A(Q,"input",e[45]),A($,"input",e[46]),A(R,"click",e[26])],N=!0)},p(e,t){64&t[0]&&l.value!==e[6]&&x(l,e[6]),128&t[0]&&c.value!==e[7]&&x(c,e[7]),4&t[0]&&(d.disabled=e[2]),M===(M=L(e))&&O?O.p(e,t):(O.d(1),O=M(e),O&&(O.c(),O.m(b,null))),512&t[0]&&Q.value!==e[9]&&x(Q,e[9]),1024&t[0]&&$.value!==e[10]&&x($,e[10]),4&t[0]&&(R.disabled=e[2]),H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(U,null)))},d(e){e&&h(t),O.d(),G.d(),N=!1,i(_)}}}function yg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No banned pubkeys configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function wg(e){let t,n=e[5],i=[];for(let t=0;tNo allowed pubkeys configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Ig(e){let t,n=e[8],i=[];for(let t=0;t0?Bg:Sg}let M=L(e),O=M(e);let j=function(e){return e[22]&&e[22].length>0?Dg:$g}(e),H=j(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Banned Events",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=y("Ban Event"),v=w(),b=m("div"),O.c(),k=w(),C=m("div"),E=m("h3"),E.textContent="Allowed Events",S=w(),B=m("div"),Q=m("input"),F=w(),$=m("input"),D=w(),R=m("button"),P=y("Allow Event"),T=w(),U=m("div"),H.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","Event ID (64 hex chars)"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(E,"class","svelte-1y8wjwc"),I(Q,"type","text"),I(Q,"placeholder","Event ID (64 hex chars)"),I(Q,"class","svelte-1y8wjwc"),I($,"type","text"),I($,"placeholder","Reason (optional)"),I($,"class","svelte-1y8wjwc"),R.disabled=e[2],I(R,"class","svelte-1y8wjwc"),I(B,"class","add-form svelte-1y8wjwc"),I(U,"class","list svelte-1y8wjwc"),I(C,"class","section svelte-1y8wjwc"),I(t,"class","events-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[12]),f(o,a),f(o,c),x(c,e[13]),f(o,u),f(o,d),f(d,g),f(n,v),f(n,b),O.m(b,null),f(t,k),f(t,C),f(C,E),f(C,S),f(C,B),f(B,Q),x(Q,e[14]),f(B,F),f(B,$),x($,e[15]),f(B,D),f(B,R),f(R,P),f(C,T),f(C,U),H.m(U,null),N||(_=[A(l,"input",e[47]),A(c,"input",e[48]),A(d,"click",e[27]),A(Q,"input",e[49]),A($,"input",e[50]),A(R,"click",e[28])],N=!0)},p(e,t){4096&t[0]&&l.value!==e[12]&&x(l,e[12]),8192&t[0]&&c.value!==e[13]&&x(c,e[13]),4&t[0]&&(d.disabled=e[2]),M===(M=L(e))&&O?O.p(e,t):(O.d(1),O=M(e),O&&(O.c(),O.m(b,null))),16384&t[0]&&Q.value!==e[14]&&x(Q,e[14]),32768&t[0]&&$.value!==e[15]&&x($,e[15]),4&t[0]&&(R.disabled=e[2]),H.p(e,t)},d(e){e&&h(t),O.d(),H.d(),N=!1,i(_)}}}function Sg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No banned events configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Bg(e){let t,n=e[11],i=[];for(let t=0;tNo allowed events configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Dg(e){let t,n=e[22],i=[];for(let t=0;t0?Ug:Tg}let S=E(e),B=S(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Blocked IPs",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=y("Block IP"),v=w(),b=m("div"),B.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","IP Address"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","ips-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[17]),f(o,a),f(o,c),x(c,e[18]),f(o,u),f(o,d),f(d,g),f(n,v),f(n,b),B.m(b,null),k||(C=[A(l,"input",e[51]),A(c,"input",e[52]),A(d,"click",e[29])],k=!0)},p(e,t){131072&t[0]&&l.value!==e[17]&&x(l,e[17]),262144&t[0]&&c.value!==e[18]&&x(c,e[18]),4&t[0]&&(d.disabled=e[2]),S===(S=E(e))&&B?B.p(e,t):(B.d(1),B=S(e),B&&(B.c(),B.m(b,null)))},d(e){e&&h(t),B.d(),k=!1,i(C)}}}function Tg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No blocked IPs configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Ug(e){let t,n=e[16],i=[];for(let t=0;t0?Og:Mg}let E=k(e),S=E(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Allowed Event Kinds",s=w(),o=m("div"),l=m("input"),a=w(),c=m("button"),u=y("Allow Kind"),d=w(),g=m("div"),S.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","number"),I(l,"placeholder","Kind number"),I(l,"class","svelte-1y8wjwc"),c.disabled=e[2],I(c,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(g,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","kinds-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[20]),f(o,a),f(o,c),f(c,u),f(n,d),f(n,g),S.m(g,null),v||(b=[A(l,"input",e[53]),A(c,"click",e[30])],v=!0)},p(e,t){1048576&t[0]&&C(l.value)!==e[20]&&x(l,e[20]),4&t[0]&&(c.disabled=e[2]),E===(E=k(e))&&S?S.p(e,t):(S.d(1),S=E(e),S&&(S.c(),S.m(g,null)))},d(e){e&&h(t),S.d(),v=!1,i(b)}}}function Mg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No allowed kinds configured. All kinds are\n allowed by default.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Og(e){let t,n=e[19],i=[];for(let t=0;t0?qg:Gg}let g=d(e),v=g(e);return{c(){t=m("div"),n=m("div"),i=m("h3"),i.textContent="Events Needing Moderation",r=w(),s=m("button"),o=y("Refresh"),l=w(),a=m("div"),v.c(),I(i,"class","svelte-1y8wjwc"),s.disabled=e[2],I(a,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","moderation-section")},m(d,h){p(d,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(s,o),f(n,l),f(n,a),v.m(a,null),c||(u=A(s,"click",e[24]),c=!0)},p(e,t){4&t[0]&&(s.disabled=e[2]),g===(g=d(e))&&v?v.p(e,t):(v.d(1),v=g(e),v&&(v.c(),v.m(a,null)))},d(e){e&&h(t),v.d(),c=!1,u()}}}function Gg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No events need moderation at this time.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function qg(e){let t,n=e[21],i=[];for(let t=0;tManaged ACL Configuration \n

    Configure access control using NIP-86 management API

    \n
    Owner Only: This interface is restricted to relay owners\n only.
    ',s=w(),V&&V.c(),o=w(),l=m("div"),a=m("button"),c=y("Pubkeys"),d=w(),g=m("button"),v=y("Events"),k=w(),C=m("button"),E=y("IPs"),S=w(),B=m("button"),Q=y("Kinds"),$=w(),D=m("button"),R=y("Moderation"),T=w(),U=m("button"),N=y("Relay Config"),L=w(),M=m("div"),Y&&Y.c(),O=w(),z&&z.c(),j=w(),W&&W.c(),H=w(),Z&&Z.c(),G=w(),X&&X.c(),q=w(),ee&&ee.c(),I(r,"class","header svelte-1y8wjwc"),I(a,"class",u="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),I(g,"class",b="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),I(C,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),I(B,"class",F="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),I(D,"class",P="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),I(U,"class",_="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),I(l,"class","tabs svelte-1y8wjwc"),I(M,"class","tab-content svelte-1y8wjwc")},m(e,i){p(e,n,i),f(n,r),f(n,s),V&&V.m(n,null),f(n,o),f(n,l),f(l,a),f(a,c),f(l,d),f(l,g),f(g,v),f(l,k),f(l,C),f(C,E),f(l,S),f(l,B),f(B,Q),f(l,$),f(l,D),f(D,R),f(l,T),f(l,U),f(U,N),f(n,L),f(n,M),Y&&Y.m(M,null),f(M,O),z&&z.m(M,null),f(M,j),W&&W.m(M,null),f(M,H),Z&&Z.m(M,null),f(M,G),X&&X.m(M,null),f(M,q),ee&&ee.m(M,null),J||(K=[A(a,"click",t[37]),A(g,"click",t[38]),A(C,"click",t[39]),A(B,"click",t[40]),A(D,"click",t[41]),A(U,"click",t[42])],J=!0)},p(e,t){e[3]?V?V.p(e,t):(V=mg(e),V.c(),V.m(n,o)):V&&(V.d(1),V=null),2&t[0]&&u!==(u="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(a,"class",u),2&t[0]&&b!==(b="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(g,"class",b),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(C,"class",x),2&t[0]&&F!==(F="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(B,"class",F),2&t[0]&&P!==(P="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(D,"class",P),2&t[0]&&_!==(_="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(U,"class",_),"pubkeys"===e[1]?Y?Y.p(e,t):(Y=vg(e),Y.c(),Y.m(M,O)):Y&&(Y.d(1),Y=null),"events"===e[1]?z?z.p(e,t):(z=xg(e),z.c(),z.m(M,j)):z&&(z.d(1),z=null),"ips"===e[1]?W?W.p(e,t):(W=Pg(e),W.c(),W.m(M,H)):W&&(W.d(1),W=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=Lg(e),Z.c(),Z.m(M,G)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=Hg(e),X.c(),X.m(M,q)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=Vg(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&h(n),V&&V.d(),Y&&Y.d(),z&&z.d(),W&&W.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),J=!1,i(K)}}}function Zg(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="pubkeys",o=!1,l="",a="info",c=[],u="",d="",f=[],p="",h="",g=[],m="",v="",y="",w="",b=[],A="",k="",I=[],E="",x=[],S={relay_name:"",relay_description:"",relay_icon:""};async function B(){try{n(2,o=!0),console.log("Fetching relay info from /");const e=await fetch(xp()+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,S={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",S),console.log("Loaded relay info:",t),n(3,l="Relay configuration loaded successfully"),n(4,a="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,l=`Failed to fetch relay info: ${e.status}`),n(4,a="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,l=`Failed to fetch relay info: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}}async function Q(e,t=[]){try{n(2,o=!0),n(3,l="");const s={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available for authentication.");const n=xp()+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s),l=JSON.stringify(o);return`Nostr ${btoa(l)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(s)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,l=e.message),n(4,a="error"),e}finally{n(2,o=!1)}}async function F(){try{n(5,c=await Q("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function $(){try{n(8,f=await Q("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function D(){try{n(11,g=await Q("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function R(){try{n(16,b=await Q("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function T(){try{n(19,I=await Q("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function U(){try{n(2,o=!0),n(21,x=await Q("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",x)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,l=`Failed to load moderation events: ${e.message}`),n(4,a="error"),n(21,x=[])}finally{n(2,o=!1)}}async function N(e){try{await Q("disallowkind",[e]),n(3,l="Kind disallowed successfully"),n(4,a="success"),await T()}catch(e){console.error("Failed to disallow kind:",e)}}async function _(e){try{await Q("allowevent",[e,"Approved from moderation queue"]),n(3,l="Event allowed successfully"),n(4,a="success"),await U()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function L(e){try{await Q("banevent",[e,"Banned from moderation queue"]),n(3,l="Event banned successfully"),n(4,a="success"),await U()}catch(e){console.error("Failed to ban event from moderation:",e)}}P(()=>{setTimeout(()=>{B()},100)}),async function(){await Promise.all([F(),$(),D(),R(),T()])}();return e.$$set=e=>{"userSigner"in e&&n(35,i=e.userSigner),"userPubkey"in e&&n(36,r=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",S)},[S,s,o,l,a,c,u,d,f,p,h,g,m,v,y,w,b,A,k,I,E,x,[],B,U,async function(){if(u)try{await Q("banpubkey",[u,d]),n(3,l="Pubkey banned successfully"),n(4,a="success"),n(6,u=""),n(7,d=""),await F()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(p)try{await Q("allowpubkey",[p,h]),n(3,l="Pubkey allowed successfully"),n(4,a="success"),n(9,p=""),n(10,h=""),await $()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await Q("banevent",[m,v]),n(3,l="Event banned successfully"),n(4,a="success"),n(12,m=""),n(13,v=""),await D()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(y)try{await Q("allowevent",[y,w]),n(3,l="Event allowed successfully"),n(4,a="success"),n(14,y=""),n(15,w="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(A)try{await Q("blockip",[A,k]),n(3,l="IP blocked successfully"),n(4,a="success"),n(17,A=""),n(18,k=""),await R()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!E)return;const e=parseInt(E);if(isNaN(e))return n(3,l="Invalid kind number"),void n(4,a="error");try{await Q("allowkind",[e]),n(3,l="Kind allowed successfully"),n(4,a="success"),n(20,E=""),await T()}catch(e){console.error("Failed to allow kind:",e)}},N,async function(){try{n(2,o=!0),n(3,l="");const e=[];if(S.relay_name&&e.push(Q("changerelayname",[S.relay_name])),S.relay_description&&e.push(Q("changerelaydescription",[S.relay_description])),S.relay_icon&&e.push(Q("changerelayicon",[S.relay_icon])),0===e.length)return n(3,l="No changes to update"),void n(4,a="info");await Promise.all(e),n(3,l="Relay configuration updated successfully"),n(4,a="success"),await B()}catch(e){console.error("Failed to update relay configuration:",e),n(3,l=`Failed to update relay configuration: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}},_,L,i,r,()=>n(1,s="pubkeys"),()=>n(1,s="events"),()=>n(1,s="ips"),()=>n(1,s="kinds"),()=>{n(1,s="moderation"),x&&0!==x.length||U()},()=>n(1,s="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){p=this.value,n(9,p)},function(){h=this.value,n(10,h)},function(){m=this.value,n(12,m)},function(){v=this.value,n(13,v)},function(){y=this.value,n(14,y)},function(){w=this.value,n(15,w)},function(){A=this.value,n(17,A)},function(){k=this.value,n(18,k)},function(){E=C(this.value),n(20,E)},e=>N(e),e=>_(e.id),e=>L(e.id),function(){S.relay_name=this.value,n(0,S)},function(){S.relay_description=this.value,n(0,S)},function(){S.relay_icon=this.value,n(0,S)}]}class Xg extends ae{constructor(e){super(),le(this,e,Zg,Wg,s,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}function em(e,t,n){const i=e.slice();return i[28]=t[n],i}function tm(e){let t,n;return{c(){t=m("span"),n=y(e[3]),I(t,"class","permission-badge svelte-e0nvq8")},m(e,i){p(e,t,i),f(t,n)},p(e,t){8&t&&E(n,e[3])},d(e){e&&h(t)}}}function nm(e){let t,n,i,r,s,o;return{c(){t=m("div"),n=m("span"),i=w(),r=m("span"),s=y(e[9]),I(n,"class","relay-status svelte-e0nvq8"),F(n,"connected","connected"===e[10]),F(n,"error","error"===e[10]),I(r,"class","relay-name svelte-e0nvq8"),I(t,"class","relay-indicator static svelte-e0nvq8"),I(t,"title",o="Connected to "+e[9])},m(e,o){p(e,t,o),f(t,n),f(t,i),f(t,r),f(r,s)},p(e,i){1024&i&&F(n,"connected","connected"===e[10]),1024&i&&F(n,"error","error"===e[10]),512&i&&E(s,e[9]),512&i&&o!==(o="Connected to "+e[9])&&I(t,"title",o)},d(e){e&&h(t)}}}function im(e){let t,n,i,r,s,o,l,a,c,u,d,g=e[6]&&rm(e);return{c(){t=m("button"),n=m("span"),i=w(),r=m("span"),s=y(e[9]),o=w(),l=m("span"),l.textContent="▾",a=w(),g&&g.c(),c=b(),I(n,"class","relay-status svelte-e0nvq8"),F(n,"connected","connected"===e[10]),F(n,"error","error"===e[10]),I(r,"class","relay-name svelte-e0nvq8"),I(l,"class","dropdown-arrow svelte-e0nvq8"),F(l,"open",e[6]),I(t,"class","relay-indicator svelte-e0nvq8"),I(t,"title","Click to switch relays")},m(h,m){p(h,t,m),f(t,n),f(t,i),f(t,r),f(r,s),f(t,o),f(t,l),p(h,a,m),g&&g.m(h,m),p(h,c,m),u||(d=A(t,"click",e[16]),u=!0)},p(e,t){1024&t&&F(n,"connected","connected"===e[10]),1024&t&&F(n,"error","error"===e[10]),512&t&&E(s,e[9]),64&t&&F(l,"open",e[6]),e[6]?g?g.p(e,t):(g=rm(e),g.c(),g.m(c.parentNode,c)):g&&(g.d(1),g=null)},d(e){e&&h(t),e&&h(a),g&&g.d(e),e&&h(c),u=!1,d()}}}function rm(e){let t,n,r,s,o,l=e[12].length>0&&sm(e);return{c(){t=m("div"),l&&l.c(),n=w(),r=m("button"),r.textContent="Manage Relays...",I(r,"class","dropdown-item manage-btn svelte-e0nvq8"),I(t,"class","relay-dropdown svelte-e0nvq8")},m(i,a){p(i,t,a),l&&l.m(t,null),f(t,n),f(t,r),s||(o=[A(r,"click",e[18]),A(t,"click",k(e[22]))],s=!0)},p(e,i){e[12].length>0?l?l.p(e,i):(l=sm(e),l.c(),l.m(t,n)):l&&(l.d(1),l=null)},d(e){e&&h(t),l&&l.d(),s=!1,i(o)}}}function sm(e){let t,n,i,r,s,o=e[12],l=[];for(let t=0;t',o=w(),a=m("img"),u=w(),d=m("div"),g=m("span"),v=y("ORLY? dashboard\n "),B&&B.c(),b=w(),k=m("div"),D.c(),C=w(),E=m("div"),T.c(),I(s,"class","mobile-menu-btn svelte-e0nvq8"),I(s,"aria-label","Toggle menu"),l(a.src,c="/orly.png")||I(a,"src","/orly.png"),I(a,"alt","ORLY Logo"),I(a,"class","logo svelte-e0nvq8"),I(g,"class","app-title svelte-e0nvq8"),I(d,"class","header-title svelte-e0nvq8"),I(k,"class","relay-dropdown-container svelte-e0nvq8"),I(E,"class","header-buttons svelte-e0nvq8"),I(r,"class","header-content svelte-e0nvq8"),I(n,"class","main-header svelte-e0nvq8"),F(n,"dark-theme",t[0])},m(e,i){p(e,n,i),f(n,r),f(r,s),f(r,o),f(r,a),f(r,u),f(r,d),f(d,g),f(g,v),B&&B.m(g,null),f(r,b),f(r,k),D.m(k,null),f(r,C),f(r,E),T.m(E,null),x||(S=[A(window,"click",t[19]),A(s,"click",t[14])],x=!0)},p(e,[t]){e[1]&&e[2]?B?B.p(e,t):(B=tm(e),B.c(),B.m(g,null)):B&&(B.d(1),B=null),$===($=Q(e))&&D?D.p(e,t):(D.d(1),D=$(e),D&&(D.c(),D.m(k,null))),P===(P=R(e))&&T?T.p(e,t):(T.d(1),T=P(e),T&&(T.c(),T.m(E,null))),1&t&&F(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&h(n),B&&B.d(),D.d(),T.d(),x=!1,i(S)}}}function pm(e,t,n){let i,r,s,o,l;u(e,wp,e=>n(10,r=e)),u(e,mp,e=>n(21,s=e)),u(e,vp,e=>n(11,o=e)),u(e,kp,e=>n(12,l=e));let{isDarkTheme:a=!1}=t,{isLoggedIn:c=!1}=t,{userRole:d=""}=t,{currentEffectiveRole:f=""}=t,{userProfile:p=null}=t,{userPubkey:h=""}=t;const g=U();let m=!1,v=!1,y="";function w(){n(6,m=!1)}async function b(e){if(console.log("[Header] switchToRelay called with:",e),v||e===s)console.log("[Header] Skipping - already connecting or same relay");else{n(7,v=!0),n(8,y=e);try{console.log("[Header] Calling connectToRelay...");const t=await Fp(e);if(console.log("[Header] connectToRelay result:",t),t.success){Ip(e,Dp(e)),g("relayChanged",{info:t.info}),w()}else console.log("[Header] Connection failed:",t.error)}catch(e){console.error("[Header] Failed to switch relay:",e)}finally{n(7,v=!1),n(8,y="")}}}return e.$$set=e=>{"isDarkTheme"in e&&n(0,a=e.isDarkTheme),"isLoggedIn"in e&&n(1,c=e.isLoggedIn),"userRole"in e&&n(2,d=e.userRole),"currentEffectiveRole"in e&&n(3,f=e.currentEffectiveRole),"userProfile"in e&&n(4,p=e.userProfile),"userPubkey"in e&&n(5,h=e.userPubkey)},e.$$.update=()=>{2097152&e.$$.dirty&&n(9,i=function(e){try{const t=e||xp();return console.log("[Header] getRelayHost - storeUrl:",e,"resolved url:",t),new URL(t).host}catch{return e||"local"}}(s))},[a,c,d,f,p,h,m,v,y,i,r,o,l,function(){g("openSettingsDrawer")},function(){g("toggleMobileMenu")},function(){g("openLoginModal")},function(e){e.stopPropagation(),n(6,m=!m)},b,function(e){e.stopPropagation(),w(),g("openRelayModal")},function(e){m&&w()},function(e){return s===e&&"connected"===r},s,function(t){N.call(this,e,t)},e=>b(e.url)]}class hm extends ae{constructor(e){super(),le(this,e,pm,fm,s,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3,userProfile:4,userPubkey:5})}}function gm(e,t,n){const i=e.slice();return i[12]=t[n],i}function mm(t){let n,i,r;return{c(){n=m("div"),I(n,"class","mobile-overlay svelte-1uja393")},m(e,s){p(e,n,s),i||(r=A(n,"click",t[7]),i=!0)},p:e,d(e){e&&h(n),i=!1,r()}}}function vm(e){let t,n,r;function s(){return e[8](e[12])}function o(...t){return e[9](e[12],...t)}return{c(){t=m("span"),t.textContent="✕",I(t,"class","tab-close-icon svelte-1uja393"),I(t,"role","button"),I(t,"tabindex","0")},m(e,i){p(e,t,i),n||(r=[A(t,"click",k(s)),A(t,"keydown",o)],n=!0)},p(t,n){e=t},d(e){e&&h(t),n=!1,i(r)}}}function ym(e){let t,n,i,r,s,o,l,a,c,u,d=e[12].icon+"",g=e[12].label+"",v=e[12].isSearchTab&&vm(e);function b(){return e[10](e[12])}return{c(){t=m("button"),n=m("span"),i=y(d),r=w(),s=m("span"),o=y(g),l=w(),v&&v.c(),a=w(),I(n,"class","tab-icon svelte-1uja393"),I(s,"class","tab-label svelte-1uja393"),I(t,"class","tab svelte-1uja393"),F(t,"active",e[2]===e[12].id)},m(e,d){p(e,t,d),f(t,n),f(n,i),f(t,r),f(t,s),f(s,o),f(t,l),v&&v.m(t,null),f(t,a),c||(u=A(t,"click",b),c=!0)},p(n,r){e=n,2&r&&d!==(d=e[12].icon+"")&&E(i,d),2&r&&g!==(g=e[12].label+"")&&E(o,g),e[12].isSearchTab?v?v.p(e,r):(v=vm(e),v.c(),v.m(t,a)):v&&(v.d(1),v=null),6&r&&F(t,"active",e[2]===e[12].id)},d(e){e&&h(t),v&&v.d(),c=!1,u()}}}function wm(e){let t,n,i,r,s,o,l,a;return{c(){t=m("a"),n=v("svg"),i=v("path"),r=v("path"),s=w(),o=m("span"),l=y("v"),a=y(e[3]),I(i,"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"),I(r,"d","M9 9c1.5 0 3 .5 3 2.5S10.5 14 9 14c0-1.5.5-3.5 2-4.5"),I(r,"stroke","currentColor"),I(r,"stroke-width","1"),I(r,"fill","none"),I(n,"class","version-icon svelte-1uja393"),I(n,"viewBox","0 0 24 24"),I(n,"fill","currentColor"),I(n,"xmlns","http://www.w3.org/2000/svg"),I(o,"class","version-text svelte-1uja393"),I(t,"href","https://next.orly.dev"),I(t,"target","_blank"),I(t,"rel","noopener noreferrer"),I(t,"class","version-link svelte-1uja393")},m(e,c){p(e,t,c),f(t,n),f(n,i),f(n,r),f(t,s),f(t,o),f(o,l),f(o,a)},p(e,t){8&t&&E(a,e[3])},d(e){e&&h(t)}}}function bm(t){let n,i,r,s,o,l=t[4]&&mm(t),a=t[1],c=[];for(let e=0;e{"isDarkTheme"in e&&n(0,i=e.isDarkTheme),"tabs"in e&&n(1,r=e.tabs),"selectedTab"in e&&n(2,s=e.selectedTab),"version"in e&&n(3,o=e.version),"mobileOpen"in e&&n(4,l=e.mobileOpen)},[i,r,s,o,l,c,u,function(){a("closeMobileMenu")},e=>u(e.id),(e,t)=>"Enter"===t.key&&u(e.id),e=>c(e.id)]}class km extends ae{constructor(e){super(),le(this,e,Am,bm,s,{isDarkTheme:0,tabs:1,selectedTab:2,version:3,mobileOpen:4})}}function Im(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access export functionality.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-jzrdtj"),I(s,"class","login-btn svelte-jzrdtj"),I(n,"class","login-prompt svelte-jzrdtj")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[5]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function Cm(e){let t,n,i=e[0]&&Em(e),r=e[1]&&xm(e);return{c(){i&&i.c(),t=w(),r&&r.c(),n=b()},m(e,s){i&&i.m(e,s),p(e,t,s),r&&r.m(e,s),p(e,n,s)},p(e,s){e[0]?i?i.p(e,s):(i=Em(e),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null),e[1]?r?r.p(e,s):(r=xm(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},d(e){i&&i.d(e),e&&h(t),r&&r.d(e),e&&h(n)}}}function Em(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Export My Events",r=w(),s=m("p"),s.textContent="Download your personal events as a JSONL file.",o=w(),l=m("button"),l.textContent="📤 Export My Events",I(i,"class","svelte-jzrdtj"),I(s,"class","svelte-jzrdtj"),I(l,"class","export-btn svelte-jzrdtj"),I(n,"class","export-section svelte-jzrdtj")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[3]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function xm(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Export All Events",r=w(),s=m("p"),s.textContent="Download the complete database as a JSONL file. This includes\n all events from all users.",o=w(),l=m("button"),l.textContent="📤 Export All Events",I(i,"class","svelte-jzrdtj"),I(s,"class","svelte-jzrdtj"),I(l,"class","export-btn svelte-jzrdtj"),I(n,"class","export-section svelte-jzrdtj")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[4]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function Sm(t){let n;function i(e,t){return e[2]?Cm:Im}let r=i(t),s=r(t);return{c(){s.c(),n=b()},m(e,t){s.m(e,t),p(e,n,t)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&h(n)}}}function Bm(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{currentEffectiveRole:o=""}=t,{aclMode:l=""}=t;const a=U();return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"currentEffectiveRole"in e&&n(6,o=e.currentEffectiveRole),"aclMode"in e&&n(7,l=e.aclMode)},e.$$.update=()=>{129&e.$$.dirty&&n(2,i="none"===l||s),192&e.$$.dirty&&n(1,r="none"===l||"admin"===o||"owner"===o)},[s,r,i,function(){a("exportMyEvents")},function(){a("exportAllEvents")},function(){a("openLoginModal")},o,l]}class Qm extends ae{constructor(e){super(),le(this,e,Bm,Sm,s,{isLoggedIn:0,currentEffectiveRole:6,aclMode:7})}}function Fm(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Import Events",r=w(),s=m("p"),s.textContent="Please log in to access import functionality.",o=w(),l=m("button"),l.textContent="Log In",I(i,"class","recovery-header svelte-nonyqh"),I(s,"class","recovery-description svelte-nonyqh"),I(l,"class","login-btn svelte-nonyqh"),I(n,"class","login-prompt svelte-nonyqh")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[6]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function $m(t){let n;return{c(){n=m("div"),n.innerHTML='

    Import Events

    \n

    Admin or owner permission required for import functionality.

    ',I(n,"class","permission-denied svelte-nonyqh")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Dm(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C=e[2]&&Rm(e);return{c(){t=m("h3"),t.textContent="Import Events",n=w(),r=m("p"),r.textContent="Upload a JSONL file to import events into the database.",s=w(),o=m("div"),l=m("input"),a=w(),c=m("div"),u=m("button"),d=y("Import Events"),v=w(),C&&C.c(),I(t,"class","svelte-nonyqh"),I(r,"class","svelte-nonyqh"),I(l,"type","file"),I(l,"id","import-file"),I(l,"accept",".jsonl,.txt"),I(l,"class","svelte-nonyqh"),I(u,"class","import-btn svelte-nonyqh"),u.disabled=g=!e[1]||"Uploading..."===e[2],I(c,"class","import-row svelte-nonyqh"),I(o,"class","recovery-controls-card svelte-nonyqh")},m(i,h){p(i,t,h),p(i,n,h),p(i,r,h),p(i,s,h),p(i,o,h),f(o,l),f(o,a),f(o,c),f(c,u),f(u,d),f(c,v),C&&C.m(c,null),b||(k=[A(l,"change",e[4]),A(u,"click",e[5])],b=!0)},p(e,t){6&t&&g!==(g=!e[1]||"Uploading..."===e[2])&&(u.disabled=g),e[2]?C?C.p(e,t):(C=Rm(e),C.c(),C.m(c,null)):C&&(C.d(1),C=null)},d(e){e&&h(t),e&&h(n),e&&h(r),e&&h(s),e&&h(o),C&&C.d(),b=!1,i(k)}}}function Rm(e){let t,n;return{c(){t=m("span"),n=y(e[2]),I(t,"class","import-message svelte-nonyqh"),F(t,"uploading","Uploading..."===e[2]),F(t,"success","Upload complete"===e[2]),F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,i){p(e,t,i),f(t,n)},p(e,i){4&i&&E(n,e[2]),4&i&&F(t,"uploading","Uploading..."===e[2]),4&i&&F(t,"success","Upload complete"===e[2]),4&i&&F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&h(t)}}}function Pm(t){let n;function i(e,t){return e[3]?Dm:e[0]?$m:Fm}let r=i(t),s=r(t);return{c(){n=m("div"),s.c(),I(n,"class","import-section svelte-nonyqh")},m(e,t){p(e,n,t),s.m(n,null)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&h(n),s.d()}}}function Tm(e,t,n){let i,{isLoggedIn:r=!1}=t,{currentEffectiveRole:s=""}=t,{selectedFile:o=null}=t,{aclMode:l=""}=t,{importMessage:a=""}=t;const c=U();return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,s=e.currentEffectiveRole),"selectedFile"in e&&n(1,o=e.selectedFile),"aclMode"in e&&n(8,l=e.aclMode),"importMessage"in e&&n(2,a=e.importMessage)},e.$$.update=()=>{385&e.$$.dirty&&n(3,i="none"===l||r&&("admin"===s||"owner"===s))},[r,o,a,i,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},s,l]}class Um extends ae{constructor(e){super(),le(this,e,Tm,Pm,s,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const Nm={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 _m(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function Lm(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 Mm(e){return Math.floor(new Date(e).getTime()/1e3)}function Om(e,t,n){const i=e.slice();return i[62]=t[n],i[64]=n,i}function jm(e,t,n){const i=e.slice();return i[65]=t[n],i}function Hm(e,t,n){const i=e.slice();return i[68]=t[n],i}function Gm(e,t,n){const i=e.slice();return i[71]=t[n],i}function qm(e,t,n){const i=e.slice();return i[71]=t[n].kind,i[74]=t[n].name,i}function Jm(e){let t,n,i,r,s,o,l=e[20],a=[];for(let t=0;t0&&Vm(t),Ge=t[17]&&zm(t),qe=t[2].length>0&&Wm(t),Je=t[18]&&Xm(t),Ke=t[3].length>0&&ev(t),Ve=t[19]&&nv(t),Ye=t[4].length>0&&iv(t),ze=t[5]&&sv(t),We=t[6]&&ov(t),Ze=t[8]&&lv(t);return{c(){n=m("div"),r=m("div"),s=m("div"),o=m("label"),o.textContent="Search Text (NIP-50)",l=w(),a=m("div"),c=m("input"),u=w(),d=m("label"),d.textContent="Event Kinds",g=w(),v=m("div"),b=m("button"),k=y(Me),S=y(" Select Kinds ("),B=y(Oe),Q=y(" selected)"),$=w(),je&&je.c(),D=w(),He&&He.c(),R=w(),P=m("label"),P.textContent="Authors (Pubkeys)",T=w(),U=m("div"),N=m("div"),_=m("input"),L=w(),M=m("button"),M.textContent="Add",O=w(),Ge&&Ge.c(),j=w(),qe&&qe.c(),H=w(),G=m("label"),G.textContent="Event IDs",q=w(),J=m("div"),K=m("div"),V=m("input"),Y=w(),z=m("button"),z.textContent="Add",W=w(),Je&&Je.c(),Z=w(),Ke&&Ke.c(),X=w(),ee=m("label"),ee.textContent="Tags (#e, #p, #a)",te=w(),ne=m("div"),ie=m("div"),re=m("span"),re.textContent="#",se=w(),oe=m("input"),le=w(),ae=m("input"),ce=w(),ue=m("button"),ue.textContent="Add",de=w(),Ve&&Ve.c(),fe=w(),Ye&&Ye.c(),pe=w(),he=m("label"),he.textContent="Since",ge=w(),me=m("div"),ve=m("input"),ye=w(),ze&&ze.c(),we=w(),be=m("label"),be.textContent="Until",Ae=w(),ke=m("div"),Ie=m("input"),Ce=w(),We&&We.c(),Ee=w(),xe=m("label"),xe.textContent="Limit",Se=w(),Be=m("div"),Qe=m("input"),Fe=w(),Ze&&Ze.c(),$e=w(),De=m("div"),Re=m("button"),Re.textContent="🧹",Pe=w(),Te=m("div"),Ue=w(),Ne=m("button"),Ne.textContent="",I(o,"for","search-text"),I(o,"class","svelte-1a1v6k0"),I(c,"id","search-text"),I(c,"type","text"),I(c,"placeholder","Search events..."),I(c,"class","filter-input svelte-1a1v6k0"),I(a,"class","field-content svelte-1a1v6k0"),I(d,"class","svelte-1a1v6k0"),I(b,"class","picker-toggle-btn svelte-1a1v6k0"),I(v,"class","field-content svelte-1a1v6k0"),I(P,"class","svelte-1a1v6k0"),I(_,"type","text"),I(_,"placeholder","64 character hex pubkey..."),I(_,"class","filter-input svelte-1a1v6k0"),I(_,"maxlength","64"),I(M,"class","add-btn svelte-1a1v6k0"),I(N,"class","input-group svelte-1a1v6k0"),I(U,"class","field-content svelte-1a1v6k0"),I(G,"class","svelte-1a1v6k0"),I(V,"type","text"),I(V,"placeholder","64 character hex event ID..."),I(V,"class","filter-input svelte-1a1v6k0"),I(V,"maxlength","64"),I(z,"class","add-btn svelte-1a1v6k0"),I(K,"class","input-group svelte-1a1v6k0"),I(J,"class","field-content svelte-1a1v6k0"),I(ee,"class","svelte-1a1v6k0"),I(re,"class","hash-prefix svelte-1a1v6k0"),I(oe,"type","text"),I(oe,"placeholder","Tag"),I(oe,"class","filter-input tag-name-input svelte-1a1v6k0"),I(oe,"maxlength","1"),I(ae,"type","text"),I(ae,"placeholder","Value..."),I(ae,"class","filter-input tag-value-input svelte-1a1v6k0"),I(ue,"class","add-btn svelte-1a1v6k0"),I(ie,"class","tag-input-group svelte-1a1v6k0"),I(ne,"class","field-content svelte-1a1v6k0"),I(he,"for","since-timestamp"),I(he,"class","svelte-1a1v6k0"),I(ve,"id","since-timestamp"),I(ve,"type","datetime-local"),ve.value=t[32](),I(ve,"class","filter-input svelte-1a1v6k0"),I(me,"class","field-content timestamp-field svelte-1a1v6k0"),I(be,"for","until-timestamp"),I(be,"class","svelte-1a1v6k0"),I(Ie,"id","until-timestamp"),I(Ie,"type","datetime-local"),Ie.value=t[33](),I(Ie,"class","filter-input svelte-1a1v6k0"),I(ke,"class","field-content timestamp-field svelte-1a1v6k0"),I(xe,"for","limit"),I(xe,"class","svelte-1a1v6k0"),I(Qe,"id","limit"),I(Qe,"type","number"),I(Qe,"placeholder","Max events to return"),I(Qe,"class","filter-input svelte-1a1v6k0"),I(Qe,"min","1"),I(Be,"class","field-content svelte-1a1v6k0"),I(s,"class","filter-grid svelte-1a1v6k0"),I(r,"class","filter-content svelte-1a1v6k0"),I(Re,"class","clear-all-btn svelte-1a1v6k0"),I(Re,"title","Clear all filters"),I(Te,"class","spacer svelte-1a1v6k0"),I(Ne,"class","json-toggle-btn svelte-1a1v6k0"),I(Ne,"title","Edit filter JSON"),F(Ne,"active",t[8]),I(De,"class","clear-column svelte-1a1v6k0"),I(n,"class","filter-builder svelte-1a1v6k0")},m(e,i){p(e,n,i),f(n,r),f(r,s),f(s,o),f(s,l),f(s,a),f(a,c),x(c,t[0]),f(s,u),f(s,d),f(s,g),f(s,v),f(v,b),f(b,k),f(b,S),f(b,B),f(b,Q),f(v,$),je&&je.m(v,null),f(v,D),He&&He.m(v,null),f(s,R),f(s,P),f(s,T),f(s,U),f(U,N),f(N,_),x(_,t[13]),f(N,L),f(N,M),f(U,O),Ge&&Ge.m(U,null),f(U,j),qe&&qe.m(U,null),f(s,H),f(s,G),f(s,q),f(s,J),f(J,K),f(K,V),x(V,t[14]),f(K,Y),f(K,z),f(J,W),Je&&Je.m(J,null),f(J,Z),Ke&&Ke.m(J,null),f(s,X),f(s,ee),f(s,te),f(s,ne),f(ne,ie),f(ie,re),f(ie,se),f(ie,oe),x(oe,t[15]),f(ie,le),f(ie,ae),x(ae,t[16]),f(ie,ce),f(ie,ue),f(ne,de),Ve&&Ve.m(ne,null),f(ne,fe),Ye&&Ye.m(ne,null),f(s,pe),f(s,he),f(s,ge),f(s,me),f(me,ve),f(me,ye),ze&&ze.m(me,null),f(s,we),f(s,be),f(s,Ae),f(s,ke),f(ke,Ie),f(ke,Ce),We&&We.m(ke,null),f(s,Ee),f(s,xe),f(s,Se),f(s,Be),f(Be,Qe),x(Qe,t[7]),f(s,Fe),Ze&&Ze.m(s,null),f(n,$e),f(n,De),f(De,Re),f(De,Pe),f(De,Te),f(De,Ue),f(De,Ne),_e||(Le=[A(c,"input",t[38]),A(b,"click",t[39]),A(_,"input",t[43]),A(_,"keydown",t[44]),A(M,"click",t[25]),A(V,"input",t[46]),A(V,"keydown",t[47]),A(z,"click",t[27]),A(oe,"input",t[49]),A(ae,"input",t[50]),A(ae,"keydown",t[51]),A(ue,"click",t[29]),A(ve,"change",t[34]),A(Ie,"change",t[35]),A(Qe,"input",t[55]),A(Re,"click",t[31]),A(Ne,"click",t[57])],_e=!0)},p(e,t){1&t[0]&&c.value!==e[0]&&x(c,e[0]),4096&t[0]&&Me!==(Me=e[12]?"▼":"▶")&&E(k,Me),2&t[0]&&Oe!==(Oe=e[1].length+"")&&E(B,Oe),e[12]?je?je.p(e,t):(je=Jm(e),je.c(),je.m(v,D)):je&&(je.d(1),je=null),e[1].length>0?He?He.p(e,t):(He=Vm(e),He.c(),He.m(v,null)):He&&(He.d(1),He=null),8192&t[0]&&_.value!==e[13]&&x(_,e[13]),e[17]?Ge?Ge.p(e,t):(Ge=zm(e),Ge.c(),Ge.m(U,j)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?qe?qe.p(e,t):(qe=Wm(e),qe.c(),qe.m(U,null)):qe&&(qe.d(1),qe=null),16384&t[0]&&V.value!==e[14]&&x(V,e[14]),e[18]?Je?Je.p(e,t):(Je=Xm(e),Je.c(),Je.m(J,Z)):Je&&(Je.d(1),Je=null),e[3].length>0?Ke?Ke.p(e,t):(Ke=ev(e),Ke.c(),Ke.m(J,null)):Ke&&(Ke.d(1),Ke=null),32768&t[0]&&oe.value!==e[15]&&x(oe,e[15]),65536&t[0]&&ae.value!==e[16]&&x(ae,e[16]),e[19]?Ve?Ve.p(e,t):(Ve=nv(e),Ve.c(),Ve.m(ne,fe)):Ve&&(Ve.d(1),Ve=null),e[4].length>0?Ye?Ye.p(e,t):(Ye=iv(e),Ye.c(),Ye.m(ne,null)):Ye&&(Ye.d(1),Ye=null),e[5]?ze?ze.p(e,t):(ze=sv(e),ze.c(),ze.m(me,null)):ze&&(ze.d(1),ze=null),e[6]?We?We.p(e,t):(We=ov(e),We.c(),We.m(ke,null)):We&&(We.d(1),We=null),128&t[0]&&C(Qe.value)!==e[7]&&x(Qe,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=lv(e),Ze.c(),Ze.m(s,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&F(Ne,"active",e[8])},i:e,o:e,d(e){e&&h(n),je&&je.d(),He&&He.d(),Ge&&Ge.d(),qe&&qe.d(),Je&&Je.d(),Ke&&Ke.d(),Ve&&Ve.d(),Ye&&Ye.d(),ze&&ze.d(),We&&We.d(),Ze&&Ze.d(),_e=!1,i(Le)}}}function uv(e,t,n){let i,r;const s=U();let{searchText:o=""}=t,{selectedKinds:l=[]}=t,{pubkeys:a=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:p=null}=t,{showJsonEditor:h=!1}=t,g="",m="",v=!1,y="",w="",b="",A="",k="",I="",E="",x="",S=null,B=!1;function Q(e){l.includes(e)?n(1,l=l.filter(t=>t!==e)):n(1,l=[...l,e].sort((e,t)=>e-t))}function F(e){n(1,l=l.filter(t=>t!==e))}function $(){const e=w.trim();e&&(_m(e,64)?a.includes(e)?n(17,I="Pubkey already added"):(n(2,a=[...a,e]),n(13,w=""),n(17,I="")):n(17,I="Invalid pubkey: must be 64 character hex string"))}function D(e){n(2,a=a.filter(t=>t!==e))}function R(){const e=b.trim();e&&(_m(e,64)?c.includes(e)?n(18,E="Event ID already added"):(n(3,c=[...c,e]),n(14,b=""),n(18,E="")):n(18,E="Invalid event ID: must be 64 character hex string"))}function P(e){n(3,c=c.filter(t=>t!==e))}function N(){const e=A.trim(),t=k.trim();e&&t&&(/^[a-zA-Z]$/.test(e)?u.some(n=>n.name===e&&n.value===t)?n(19,x="Tag already added"):(n(4,u=[...u,{name:e,value:t}]),n(15,A=""),n(16,k=""),n(19,x="")):n(19,x="Invalid tag name: must be single letter a-z or A-Z"))}function _(e){n(4,u=u.filter((t,n)=>n!==e))}function L(){s("apply",{searchText:o,selectedKinds:l,pubkeys:a,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:p})}T(()=>{S&&clearTimeout(S)});return e.$$set=e=>{"searchText"in e&&n(0,o=e.searchText),"selectedKinds"in e&&n(1,l=e.selectedKinds),"pubkeys"in e&&n(2,a=e.pubkeys),"eventIds"in e&&n(3,c=e.eventIds),"tags"in e&&n(4,u=e.tags),"sinceTimestamp"in e&&n(5,d=e.sinceTimestamp),"untilTimestamp"in e&&n(6,f=e.untilTimestamp),"limit"in e&&n(7,p=e.limit),"showJsonEditor"in e&&n(8,h=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&h){const e=function(){const e={};return l.length>0&&(e.kinds=l),a.length>0&&(e.authors=a),c.length>0&&(e.ids=c),d&&(e.since=d),f&&(e.until=f),p&&(e.limit=p),o&&(e.search=o),u.forEach(t=>{const n=`#${t.name}`;e[n]||(e[n]=[]),e[n].push(t.value)}),e}();n(10,g=JSON.stringify(e,null,2))}255&e.$$.dirty[0]|32&e.$$.dirty[1]&&(B?(S&&clearTimeout(S),S=setTimeout(()=>{L()},1e3)):n(36,B=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,r=i.filter(e=>e.kind.toString().includes(y)||e.name.toLowerCase().includes(y.toLowerCase())))},n(37,i=Object.entries(Nm).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[o,l,a,c,u,d,f,p,h,y,g,m,v,w,b,A,k,I,E,x,r,s,function(){try{const e=JSON.parse(g);n(11,m=""),n(1,l=e.kinds||[]),n(2,a=e.authors||[]),n(3,c=e.ids||[]),n(5,d=e.since||null),n(6,f=e.until||null),n(7,p=e.limit||null),n(0,o=e.search||""),n(4,u=[]),Object.keys(e).forEach(t=>{if(t.startsWith("#")&&2===t.length){const n=t.slice(1);(Array.isArray(e[t])?e[t]:[e[t]]).forEach(e=>{u.push({name:n,value:String(e)})})}}),n(4,u),S&&clearTimeout(S),L()}catch(e){n(11,m="Invalid JSON: "+e.message)}},Q,F,$,D,R,P,N,_,function(){n(0,o=""),n(1,l=[]),n(2,a=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,p=null),s("clear")},function(){return d?Lm(d):""},function(){return f?Lm(f):""},function(e){const t=e.target.value;n(5,d=t?Mm(t):null)},function(e){const t=e.target.value;n(6,f=t?Mm(t):null)},B,i,function(){o=this.value,n(0,o)},()=>n(12,v=!v),function(){y=this.value,n(9,y)},e=>Q(e),e=>F(e),function(){w=this.value,n(13,w)},e=>"Enter"===e.key&&$(),e=>D(e),function(){b=this.value,n(14,b)},e=>"Enter"===e.key&&R(),e=>P(e),function(){A=this.value,n(15,A)},function(){k=this.value,n(16,k)},e=>"Enter"===e.key&&N(),e=>_(e),()=>n(5,d=null),()=>n(6,f=null),function(){p=C(this.value),n(7,p)},function(){g=this.value,n(10,g),n(8,h)},()=>s("toggleJson")]}class dv extends ae{constructor(e){super(),le(this,e,uv,cv,s,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function fv(e,t,n){const i=e.slice();return i[28]=t[n],i}function pv(e,t,n){const i=e.slice();return i[31]=t[n],i}function hv(t){let n;return{c(){n=m("div"),n.innerHTML="

    ❌ Read, write, admin, or owner permission required to view all\n events.

    ",I(n,"class","permission-denied svelte-16xix3y")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gv(e){let t,n,i,r;function s(e,t){return e[4].length>0?vv:e[6]?void 0:mv}let o=s(e),l=o&&o(e),a=e[6]&&Ev();return{c(){t=m("div"),l&&l.c(),n=w(),a&&a.c(),I(t,"class","events-view-content svelte-16xix3y")},m(s,o){p(s,t,o),l&&l.m(t,null),f(t,n),a&&a.m(t,null),i||(r=A(t,"scroll",e[9]),i=!0)},p(e,i){o===(o=s(e))&&l?l.p(e,i):(l&&l.d(1),l=o&&o(e),l&&(l.c(),l.m(t,n))),e[6]?a||(a=Ev(),a.c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&h(t),l&&l.d(),a&&a.d(),i=!1,r()}}}function mv(t){let n;return{c(){n=m("div"),n.innerHTML="

    No events found.

    ",I(n,"class","no-events svelte-16xix3y")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function vv(e){let t,n=e[4],i=[];for(let t=0;t0&&bv(e);return{c(){t=m("div"),n=m("span"),n.textContent="🗑️ Delete Event",i=w(),r&&r.c(),I(n,"class","delete-event-label svelte-16xix3y"),I(t,"class","delete-event-info svelte-16xix3y")},m(e,s){p(e,t,s),f(t,n),f(t,i),r&&r.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?r?r.p(e,n):(r=bv(e),r.c(),r.m(t,null)):r&&(r.d(1),r=null)},d(e){e&&h(t),r&&r.d()}}}function bv(e){let t,n=e[28].tags.filter(Pv),i=[];for(let t=0;t👤',s=w(),o=m("div"),l=m("div"),a=y(U),c=w(),u=m("div"),d=m("span"),g=y(N),v=w(),b=m("span"),k=y(_),C=w(),x=m("div"),S=m("div"),B=y(L),Q=w(),H.c(),$=w(),G&&G.c(),D=w(),K&&K.c(),R=w(),I(r,"class","events-view-avatar svelte-16xix3y"),I(l,"class","events-view-author svelte-16xix3y"),I(d,"class","kind-number svelte-16xix3y"),F(d,"delete-event",5===e[28].kind),I(b,"class","kind-name svelte-16xix3y"),I(u,"class","events-view-kind svelte-16xix3y"),I(o,"class","events-view-info svelte-16xix3y"),I(S,"class","event-timestamp svelte-16xix3y"),I(x,"class","events-view-content svelte-16xix3y"),I(n,"class","events-view-row svelte-16xix3y"),I(n,"role","button"),I(n,"tabindex","0"),I(t,"class","events-view-item svelte-16xix3y"),F(t,"expanded",e[5].has(e[28].id))},m(e,i){p(e,t,i),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(d,g),f(u,v),f(u,b),f(b,k),f(n,C),f(n,x),f(x,S),f(S,B),f(x,Q),H.m(x,null),f(n,$),G&&G.m(n,null),f(t,D),K&&K.m(t,null),f(t,R),P||(T=[A(n,"click",q),A(n,"keydown",J)],P=!0)},p(i,r){e=i,16&r[0]&&U!==(U=Fv(e[28].pubkey)+"")&&E(a,U),16&r[0]&&N!==(N=e[28].kind+"")&&E(g,N),16&r[0]&&F(d,"delete-event",5===e[28].kind),16&r[0]&&_!==(_=$v(e[28].kind)+"")&&E(k,_),16&r[0]&&L!==(L=Dv(e[28].created_at)+"")&&E(B,L),j===(j=O(e))&&H?H.p(e,r):(H.d(1),H=j(e),H&&(H.c(),H.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,r):(G=kv(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),48&r[0]&&(M=e[5].has(e[28].id)),M?K?K.p(e,r):(K=Iv(e),K.c(),K.m(t,R)):K&&(K.d(1),K=null),48&r[0]&&F(t,"expanded",e[5].has(e[28].id))},d(e){e&&h(t),H.d(),G&&G.d(),K&&K.d(),P=!1,i(T)}}}function Ev(e){let t;return{c(){t=m("div"),t.innerHTML='
    \n

    Loading events...

    ',I(t,"class","loading-events svelte-16xix3y")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function xv(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C,E,x,S,B,Q,$,D,R,P;function T(e,t){return e[6]?Bv:Sv}r=new dv({props:{showJsonEditor:e[8]}}),r.$on("apply",e[17]),r.$on("clear",e[18]),r.$on("toggleJson",e[16]);let U=T(e),N=U(e);return{c(){t=m("div"),n=m("div"),ie(r.$$.fragment),s=w(),o=m("div"),l=m("div"),a=m("button"),a.innerHTML='',c=w(),u=m("div"),d=m("label"),g=m("input"),v=w(),b=m("span"),k=w(),C=m("span"),C.textContent="Only show my events",E=w(),x=m("div"),S=m("button"),B=y("🔄 Load More"),Q=w(),$=m("button"),N.c(),I(n,"class","filter-panel svelte-16xix3y"),F(n,"open",e[7]),I(a,"class","filter-btn svelte-16xix3y"),I(a,"title","Filter events"),F(a,"active",e[7]),I(g,"type","checkbox"),I(g,"class","svelte-16xix3y"),I(b,"class","toggle-slider svelte-16xix3y"),I(C,"class","toggle-label svelte-16xix3y"),I(d,"class","toggle-container svelte-16xix3y"),I(u,"class","events-view-toggle svelte-16xix3y"),I(l,"class","events-view-left svelte-16xix3y"),I(S,"class","refresh-btn svelte-16xix3y"),S.disabled=e[6],I($,"class","reload-btn svelte-16xix3y"),$.disabled=e[6],I(x,"class","events-view-buttons svelte-16xix3y"),I(o,"class","events-view-header svelte-16xix3y"),I(t,"class","events-view-footer svelte-16xix3y")},m(i,h){p(i,t,h),f(t,n),re(r,n,null),f(t,s),f(t,o),f(o,l),f(l,a),f(l,c),f(l,u),f(u,d),f(d,g),g.checked=e[0],f(d,v),f(d,b),f(d,k),f(d,C),f(o,E),f(o,x),f(x,S),f(S,B),f(x,Q),f(x,$),N.m($,null),D=!0,R||(P=[A(a,"click",e[15]),A(g,"change",e[23]),A(g,"change",e[24]),A(S,"click",e[25]),A($,"click",e[26])],R=!0)},p(e,t){const i={};256&t[0]&&(i.showJsonEditor=e[8]),r.$set(i),(!D||128&t[0])&&F(n,"open",e[7]),(!D||128&t[0])&&F(a,"active",e[7]),1&t[0]&&(g.checked=e[0]),(!D||64&t[0])&&(S.disabled=e[6]),U!==(U=T(e))&&(N.d(1),N=U(e),N&&(N.c(),N.m($,null))),(!D||64&t[0])&&($.disabled=e[6])},i(e){D||(ee(r.$$.fragment,e),D=!0)},o(e){te(r.$$.fragment,e),D=!1},d(e){e&&h(t),se(r),N.d(),R=!1,i(P)}}}function Sv(e){let t;return{c(){t=y("🔄")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Bv(e){let t;return{c(){t=m("div"),I(t,"class","spinner svelte-16xix3y")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Qv(e){let t,n,i;function r(e,t){return!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?hv:gv}let s=r(e),o=s(e),l=e[1]&&("read"===e[2]||"write"===e[2]||"admin"===e[2]||"owner"===e[2])&&xv(e);return{c(){t=m("div"),o.c(),n=w(),l&&l.c(),I(t,"class","events-view-container svelte-16xix3y")},m(e,r){p(e,t,r),o.m(t,null),f(t,n),l&&l.m(t,null),i=!0},p(e,i){s===(s=r(e))&&o?o.p(e,i):(o.d(1),o=s(e),o&&(o.c(),o.m(t,n))),!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?l&&(Z(),te(l,1,1,()=>{l=null}),X()):l?(l.p(e,i),6&i[0]&&ee(l,1)):(l=xv(e),l.c(),ee(l,1),l.m(t,null))},i(e){i||(ee(l),i=!0)},o(e){te(l),i=!1},d(e){e&&h(t),o.d(),l&&l.d()}}}function Fv(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function $v(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 Dv(e){return new Date(1e3*e).toLocaleString()}function Rv(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const Pv=e=>"e"===e[0];function Tv(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{userPubkey:s=""}=t,{filteredEvents:o=[]}=t,{expandedEvents:l=new Set}=t,{isLoadingEvents:a=!1}=t,{showOnlyMyEvents:c=!1}=t,{showFilterBuilder:u=!1}=t;const d=U();let f=!1;function p(e){d("toggleEventExpansion",e)}function h(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function v(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"userPubkey"in e&&n(3,s=e.userPubkey),"filteredEvents"in e&&n(4,o=e.filteredEvents),"expandedEvents"in e&&n(5,l=e.expandedEvents),"isLoadingEvents"in e&&n(6,a=e.isLoadingEvents),"showOnlyMyEvents"in e&&n(0,c=e.showOnlyMyEvents),"showFilterBuilder"in e&&n(7,u=e.showFilterBuilder)},[c,i,r,s,o,l,a,u,f,function(e){d("scroll",e)},p,h,g,m,v,function(){d("toggleFilterBuilder")},function(){n(8,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},e=>h(e.id),e=>p(e.id),(e,t)=>"Enter"===t.key&&p(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{v(!1,c&&s?[s]:null)},()=>{v(!0,c&&s?[s]:null)}]}class Uv extends ae{constructor(e){super(),le(this,e,Tv,Qv,s,{isLoggedIn:1,userRole:2,userPubkey:3,filteredEvents:4,expandedEvents:5,isLoadingEvents:6,showOnlyMyEvents:0,showFilterBuilder:7},null,[-1,-1])}}const Nv=[{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 _v(e,t=null){const n=function(e){return Nv.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||""}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||""}}const Lv=[{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 Mv(e,t,n){const i=e.slice();return i[13]=t[n],i}function Ov(e,t,n){const i=e.slice();return i[16]=t[n],i}function jv(e){let t,n,r,s,o,l,a,c,u,d,v,b,k,C,S,B,Q,F,$,D,R,P,T,U,N,_=e[3].length+"",L=1!==e[3].length?"s":"",M=Lv,O=[];for(let t=0;t=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function zv(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function Wv(e,t,n){let{isOpen:i=!1}=t,{userPubkey:r=""}=t;const s=U();let o="",l="all",a=Nv;function c(e){const t=_v(e.kind,r);s("select",{kind:e,template:t}),u()}function u(){n(0,i=!1),n(1,o=""),n(2,l="all"),s("close")}return e.$$set=e=>{"isOpen"in e&&n(0,i=e.isOpen),"userPubkey"in e&&n(8,r=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=Nv;const t=Lv.find(e=>e.id===l);if(t&&(e=e.filter(t.filter)),o.trim()){const t=o.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.kind.toString().includes(t)||e.nip&&e.nip.includes(t))}n(3,a=e)}},[i,o,l,a,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},r,function(){o=this.value,n(1,o)},e=>n(2,l=e.id),e=>c(e)]}class Zv extends ae{constructor(e){super(),le(this,e,Wv,Vv,s,{isOpen:0,userPubkey:8})}}function Xv(e){let t,n,i,r,s,o,l,a,c,u;return{c(){t=m("div"),n=m("div"),i=m("span"),i.textContent="⚠",r=w(),s=m("span"),o=y(e[1]),l=w(),a=m("button"),a.textContent="×",I(i,"class","error-icon svelte-1gh9ysu"),I(s,"class","error-message svelte-1gh9ysu"),I(n,"class","error-content svelte-1gh9ysu"),I(a,"class","error-dismiss svelte-1gh9ysu"),I(t,"class","error-banner svelte-1gh9ysu")},m(d,h){p(d,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(s,o),f(t,l),f(t,a),c||(u=A(a,"click",e[10]),c=!0)},p(e,t){2&t&&E(o,e[1])},d(e){e&&h(t),c=!1,u()}}}function ey(e){let t,n,r,s,o,l,a,c,u,d,g,v,y,b,k,C,E,S,B,Q=e[1]&&Xv(e);function F(t){e[14](t)}let $={userPubkey:e[2]};return void 0!==e[3]&&($.isOpen=e[3]),k=new Zv({props:$}),L.push(()=>ne(k,"isOpen",F)),k.$on("select",e[8]),k.$on("close",e[9]),{c(){t=m("div"),n=m("div"),r=m("button"),r.textContent="Generate Template",s=w(),o=m("button"),o.textContent="Reformat",l=w(),a=m("button"),a.textContent="Sign",c=w(),u=m("button"),u.textContent="Publish",d=w(),Q&&Q.c(),g=w(),v=m("div"),y=m("textarea"),b=w(),ie(k.$$.fragment),I(r,"class","compose-btn template-btn svelte-1gh9ysu"),I(o,"class","compose-btn reformat-btn svelte-1gh9ysu"),I(a,"class","compose-btn sign-btn svelte-1gh9ysu"),I(u,"class","compose-btn publish-btn svelte-1gh9ysu"),I(n,"class","compose-header svelte-1gh9ysu"),I(y,"class","compose-textarea svelte-1gh9ysu"),I(y,"placeholder","Enter your Nostr event JSON here, or click 'Generate Template' to start with a template..."),I(y,"spellcheck","false"),I(v,"class","compose-editor svelte-1gh9ysu"),I(t,"class","compose-view svelte-1gh9ysu")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(n,l),f(n,a),f(n,c),f(n,u),f(t,d),Q&&Q.m(t,null),f(t,g),f(t,v),f(v,y),x(y,e[0]),p(i,b,h),re(k,i,h),E=!0,S||(B=[A(r,"click",e[7]),A(o,"click",e[4]),A(a,"click",e[5]),A(u,"click",e[6]),A(y,"input",e[13])],S=!0)},p(e,[n]){e[1]?Q?Q.p(e,n):(Q=Xv(e),Q.c(),Q.m(t,g)):Q&&(Q.d(1),Q=null),1&n&&x(y,e[0]);const i={};4&n&&(i.userPubkey=e[2]),!C&&8&n&&(C=!0,i.isOpen=e[3],q(()=>C=!1)),k.$set(i)},i(e){E||(ee(k.$$.fragment,e),E=!0)},o(e){te(k.$$.fragment,e),E=!1},d(e){e&&h(t),Q&&Q.d(),e&&h(b),se(k,e),S=!1,i(B)}}}function ty(e,t,n){let{composeEventJson:i=""}=t,{userPubkey:r=""}=t,{userRole:s=""}=t,{policyEnabled:o=!1}=t,{publishError:l=""}=t;const a=U();let c=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,i=e.composeEventJson),"userPubkey"in e&&n(2,r=e.userPubkey),"userRole"in e&&n(11,s=e.userRole),"policyEnabled"in e&&n(12,o=e.policyEnabled),"publishError"in e&&n(1,l=e.publishError)},[i,l,r,c,function(){a("reformatJson")},function(){a("signEvent")},function(){a("publishEvent")},function(){n(3,c=!0)},function(e){const{kind:t,template:r}=e.detail;n(0,i=JSON.stringify(r,null,2)),a("templateSelected",{kind:t,template:r})},function(){n(3,c=!1)},function(){n(1,l=""),a("clearError")},s,o,function(){i=this.value,n(0,i)},function(e){c=e,n(3,c)}]}class ny extends ae{constructor(e){super(),le(this,e,ty,ey,s,{composeEventJson:0,userPubkey:2,userRole:11,policyEnabled:12,publishError:1})}}function iy(e,t,n){const i=e.slice();return i[23]=t[n],i}function ry(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access sprocket management.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-fiaj1r"),I(s,"class","login-btn svelte-fiaj1r"),I(n,"class","login-prompt svelte-fiaj1r")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[18]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function sy(e){let t,n,i,r,s,o,l,a,c,u=(e[2]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="❌ Owner permission required for sprocket management.",i=w(),r=m("p"),r.innerHTML='To enable sprocket functionality, set the ORLY_OWNERS environment variable with your npub when starting the relay.',s=w(),o=m("p"),l=y("Current user role: "),a=m("strong"),c=y(u),I(n,"class","svelte-fiaj1r"),I(r,"class","svelte-fiaj1r"),I(o,"class","svelte-fiaj1r"),I(t,"class","permission-denied svelte-fiaj1r")},m(e,u){p(e,t,u),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(o,a),f(a,c)},p(e,t){4&t&&u!==(u=(e[2]||"none")+"")&&E(c,u)},d(e){e&&h(t)}}}function oy(e){let t,n,r,s,o,l,a,c,u,d,v,b,k,C,S,B,Q,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te,ne,ie,re,se,oe,le,ae,ce,ue,de,fe,pe,he,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ve=e[3]?.script_exists?"✅ Exists":"❌ Not found",ye=e[3]?.pid&&ly(e),we=e[6]&&ay(e),be=e[8],Ae=[];for(let t=0;t{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"sprocketStatus"in e&&n(3,s=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,o=e.isLoadingSprocket),"sprocketUploadFile"in e&&n(5,l=e.sprocketUploadFile),"sprocketScript"in e&&n(0,a=e.sprocketScript),"sprocketMessage"in e&&n(6,c=e.sprocketMessage),"sprocketMessageType"in e&&n(7,u=e.sprocketMessageType),"sprocketVersions"in e&&n(8,d=e.sprocketVersions)},[a,i,r,s,o,l,c,u,d,function(){f("restartSprocket")},function(){f("deleteSprocket")},function(e){f("sprocketFileSelect",e)},function(){f("uploadSprocketScript")},function(){f("saveSprocket")},function(){f("loadSprocket")},function(){f("loadVersions")},p,h,function(){f("openLoginModal")},function(){a=this.value,n(0,a)},e=>p(e),e=>h(e.name)]}class hy extends ae{constructor(e){super(),le(this,e,py,fy,s,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function gy(e,t,n){const i=e.slice();return i[26]=t[n],i}function my(e,t,n){const i=e.slice();return i[29]=t[n],i}function vy(e,t,n){const i=e.slice();return i[32]=t[n],i}function yy(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access policy configuration.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-gkxvxc"),I(s,"class","login-btn svelte-gkxvxc"),I(n,"class","login-prompt svelte-gkxvxc")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[16]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function wy(e){let t,n,i,r,s,o,l,a,c,u=(e[3]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",i=w(),r=m("p"),r.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n to the policy_admins list.',s=w(),o=m("p"),l=y("Current user role: "),a=m("strong"),c=y(u),I(n,"class","svelte-gkxvxc"),I(r,"class","svelte-gkxvxc"),I(o,"class","svelte-gkxvxc"),I(t,"class","permission-denied svelte-gkxvxc")},m(e,u){p(e,t,u),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(o,a),f(a,c)},p(e,t){8&t[0]&&u!==(u=(e[3]||"none")+"")&&E(c,u)},d(e){e&&h(t)}}}function by(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C,S,B,Q,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te,ne,ie,re,se,oe,le,ae,ce,ue,de,fe,pe,he,ge,me,ve,ye,we,be,Ae,ke,Ie,Ce,Ee,xe,Se,Be,Qe,Fe,$e,De,Re,Pe=e[5]?"Policy Enabled":"Policy Disabled",Te=e[10].length+"",Ue=e[4]&&Ay(),Ne=e[9].length>0&&ky(e),_e=e[7]&&Cy(e);function Le(e,t){return 0===e[1].length?xy:Ey}let Me=Le(e),Oe=Me(e);function je(e,t){return 0===e[10].length?Qy:By}let He=je(e),Ge=He(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Policy Editor",s=w(),o=m("div"),l=m("span"),a=y(Pe),c=w(),Ue&&Ue.c(),u=w(),d=m("div"),d.innerHTML='

    Edit the policy JSON below and click "Save & Publish" to update the relay's policy configuration.\n Changes are applied immediately after validation.

    \n

    Policy updates are published as kind 12345 events and require policy admin permissions.

    ',g=w(),v=m("div"),b=m("textarea"),k=w(),Ne&&Ne.c(),C=w(),S=m("div"),B=m("button"),Q=y("Load Current"),$=w(),D=m("button"),R=y("Format JSON"),P=w(),T=m("button"),U=y("Validate"),N=w(),_=m("button"),L=y("Save & Publish"),M=w(),_e&&_e.c(),O=w(),j=m("div"),H=m("h3"),H.textContent="Policy Administrators",G=w(),q=m("div"),q.innerHTML='

    Policy admins can update the relay's policy configuration via kind 12345 events.\n Their follows get whitelisted if policy_follow_whitelist_enabled is true in the policy.

    \n

    Note: Policy admins are separate from relay admins (ORLY_ADMINS).\n Changes here update the JSON editor - click "Save & Publish" to apply.

    ',J=w(),K=m("div"),Oe.c(),V=w(),Y=m("div"),z=m("input"),W=w(),Z=m("button"),X=y("+ Add Admin"),te=w(),ne=m("div"),ie=m("h3"),ie.textContent="Policy Follow Whitelist",re=w(),se=m("div"),se.innerHTML='

    Pubkeys followed by policy admins (kind 3 events).\n These get automatic read+write access when rules have write_allow_follows: true.

    ',oe=w(),le=m("div"),ae=m("span"),ce=y(Te),ue=y(" pubkey(s) in whitelist"),de=w(),fe=m("button"),pe=y("🔄 Refresh Follows"),he=w(),ge=m("div"),Ge.c(),me=w(),ve=m("div"),ye=m("h3"),ye.textContent="Policy Reference",we=w(),be=m("div"),Ae=m("h4"),Ae.textContent="Structure Overview",ke=w(),Ie=m("ul"),Ie.innerHTML='
  • kind.whitelist - Only allow these event kinds (takes precedence)
  • \n
  • kind.blacklist - Deny these event kinds (if no whitelist)
  • \n
  • global - Rules applied to all events
  • \n
  • rules - Per-kind rules (keyed by kind number as string)
  • \n
  • default_policy - "allow" or "deny" when no rules match
  • \n
  • policy_admins - Hex pubkeys that can update policy
  • \n
  • policy_follow_whitelist_enabled - Enable follow-based access
  • ',Ce=w(),Ee=m("h4"),Ee.textContent="Rule Fields",xe=w(),Se=m("ul"),Se.innerHTML='
  • description - Human-readable rule description
  • \n
  • write_allow / write_deny - Pubkey lists for write access
  • \n
  • read_allow / read_deny - Pubkey lists for read access
  • \n
  • write_allow_follows - Grant access to policy admin follows
  • \n
  • size_limit - Max total event size in bytes
  • \n
  • content_limit - Max content field size in bytes
  • \n
  • max_expiry - Max expiry offset in seconds
  • \n
  • max_age_of_event - Max age of created_at in seconds
  • \n
  • max_age_event_in_future - Max future offset in seconds
  • \n
  • must_have_tags - Required tag letters (e.g., ["d", "t"])
  • \n
  • tag_validation - Regex patterns for tag values
  • \n
  • script - Path to external validation script
  • ',Be=w(),Qe=m("h4"),Qe.textContent="Example Policy",Fe=w(),$e=m("pre"),$e.textContent=`${e[20]}`,I(r,"class","svelte-gkxvxc"),I(l,"class","status-badge svelte-gkxvxc"),F(l,"enabled",e[5]),I(o,"class","policy-status svelte-gkxvxc"),I(n,"class","policy-header svelte-gkxvxc"),I(d,"class","policy-info svelte-gkxvxc"),I(b,"class","policy-editor svelte-gkxvxc"),I(b,"placeholder","Loading policy configuration..."),b.disabled=e[6],I(b,"spellcheck","false"),I(v,"class","editor-container svelte-gkxvxc"),I(B,"class","policy-btn load-btn svelte-gkxvxc"),B.disabled=e[6],I(D,"class","policy-btn format-btn svelte-gkxvxc"),D.disabled=e[6],I(T,"class","policy-btn validate-btn svelte-gkxvxc"),T.disabled=e[6],I(_,"class","policy-btn save-btn svelte-gkxvxc"),_.disabled=e[6],I(S,"class","policy-actions svelte-gkxvxc"),I(t,"class","policy-section svelte-gkxvxc"),I(q,"class","policy-info svelte-gkxvxc"),I(K,"class","admin-list svelte-gkxvxc"),I(z,"type","text"),I(z,"placeholder","npub or hex pubkey"),z.disabled=e[6],I(z,"class","svelte-gkxvxc"),I(Z,"class","policy-btn add-btn svelte-gkxvxc"),Z.disabled=ee=e[6]||!e[11].trim(),I(Y,"class","add-admin svelte-gkxvxc"),I(j,"class","policy-section svelte-gkxvxc"),I(se,"class","policy-info svelte-gkxvxc"),I(ae,"class","follows-count svelte-gkxvxc"),I(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],I(le,"class","follows-header svelte-gkxvxc"),I(ge,"class","follows-list svelte-gkxvxc"),I(ne,"class","policy-section svelte-gkxvxc"),I(Ae,"class","svelte-gkxvxc"),I(Ie,"class","field-list svelte-gkxvxc"),I(Ee,"class","svelte-gkxvxc"),I(Se,"class","field-list svelte-gkxvxc"),I(Qe,"class","svelte-gkxvxc"),I($e,"class","example-json svelte-gkxvxc"),I(be,"class","reference-content svelte-gkxvxc"),I(ve,"class","policy-section svelte-gkxvxc")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),Ue&&Ue.m(o,null),f(t,u),f(t,d),f(t,g),f(t,v),f(v,b),x(b,e[0]),f(t,k),Ne&&Ne.m(t,null),f(t,C),f(t,S),f(S,B),f(B,Q),f(S,$),f(S,D),f(D,R),f(S,P),f(S,T),f(T,U),f(S,N),f(S,_),f(_,L),f(t,M),_e&&_e.m(t,null),p(i,O,h),p(i,j,h),f(j,H),f(j,G),f(j,q),f(j,J),f(j,K),Oe.m(K,null),f(j,V),f(j,Y),f(Y,z),x(z,e[11]),f(Y,W),f(Y,Z),f(Z,X),p(i,te,h),p(i,ne,h),f(ne,ie),f(ne,re),f(ne,se),f(ne,oe),f(ne,le),f(le,ae),f(ae,ce),f(ae,ue),f(le,de),f(le,fe),f(fe,pe),f(ne,he),f(ne,ge),Ge.m(ge,null),p(i,me,h),p(i,ve,h),f(ve,ye),f(ve,we),f(ve,be),f(be,Ae),f(be,ke),f(be,Ie),f(be,Ce),f(be,Ee),f(be,xe),f(be,Se),f(be,Be),f(be,Qe),f(be,Fe),f(be,$e),De||(Re=[A(b,"input",e[21]),A(B,"click",e[12]),A(D,"click",e[15]),A(T,"click",e[13]),A(_,"click",e[14]),A(z,"input",e[23]),A(z,"keydown",e[24]),A(Z,"click",e[18]),A(fe,"click",e[17])],De=!0)},p(e,n){32&n[0]&&Pe!==(Pe=e[5]?"Policy Enabled":"Policy Disabled")&&E(a,Pe),32&n[0]&&F(l,"enabled",e[5]),e[4]?Ue||(Ue=Ay(),Ue.c(),Ue.m(o,null)):Ue&&(Ue.d(1),Ue=null),64&n[0]&&(b.disabled=e[6]),1&n[0]&&x(b,e[0]),e[9].length>0?Ne?Ne.p(e,n):(Ne=ky(e),Ne.c(),Ne.m(t,C)):Ne&&(Ne.d(1),Ne=null),64&n[0]&&(B.disabled=e[6]),64&n[0]&&(D.disabled=e[6]),64&n[0]&&(T.disabled=e[6]),64&n[0]&&(_.disabled=e[6]),e[7]?_e?_e.p(e,n):(_e=Cy(e),_e.c(),_e.m(t,null)):_e&&(_e.d(1),_e=null),Me===(Me=Le(e))&&Oe?Oe.p(e,n):(Oe.d(1),Oe=Me(e),Oe&&(Oe.c(),Oe.m(K,null))),64&n[0]&&(z.disabled=e[6]),2048&n[0]&&z.value!==e[11]&&x(z,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Te!==(Te=e[10].length+"")&&E(ce,Te),64&n[0]&&(fe.disabled=e[6]),He===(He=je(e))&&Ge?Ge.p(e,n):(Ge.d(1),Ge=He(e),Ge&&(Ge.c(),Ge.m(ge,null)))},d(e){e&&h(t),Ue&&Ue.d(),Ne&&Ne.d(),_e&&_e.d(),e&&h(O),e&&h(j),Oe.d(),e&&h(te),e&&h(ne),Ge.d(),e&&h(me),e&&h(ve),De=!1,i(Re)}}}function Ay(e){let t;return{c(){t=m("span"),t.textContent="Policy Admin",I(t,"class","admin-badge svelte-gkxvxc")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function ky(e){let t,n,i,r,s=e[9],o=[];for(let t=0;t{"isLoggedIn"in e&&n(2,i=e.isLoggedIn),"userRole"in e&&n(3,r=e.userRole),"isPolicyAdmin"in e&&n(4,s=e.isPolicyAdmin),"policyEnabled"in e&&n(5,o=e.policyEnabled),"policyJson"in e&&n(0,l=e.policyJson),"isLoadingPolicy"in e&&n(6,a=e.isLoadingPolicy),"policyMessage"in e&&n(7,c=e.policyMessage),"policyMessageType"in e&&n(8,u=e.policyMessageType),"validationErrors"in e&&n(9,d=e.validationErrors),"policyAdmins"in e&&n(1,f=e.policyAdmins),"policyFollows"in e&&n(10,p=e.policyFollows)},e.$$.update=()=>{if(1&e.$$.dirty[0])try{if(l){const e=JSON.parse(l);n(1,f=e.policy_admins||[])}}catch(e){}},[l,f,i,r,s,o,a,c,u,d,p,g,function(){h("loadPolicy")},function(){h("validatePolicy")},function(){h("savePolicy")},function(){h("formatJson")},function(){h("openLoginModal")},function(){h("refreshFollows")},m,v,'{\n "kind": {\n "whitelist": [0, 1, 3, 6, 7, 10002],\n "blacklist": []\n },\n "global": {\n "description": "Global rules applied to all events",\n "size_limit": 65536,\n "max_age_of_event": 86400,\n "max_age_event_in_future": 300\n },\n "rules": {\n "1": {\n "description": "Kind 1 (short text notes)",\n "content_limit": 8192,\n "write_allow_follows": true\n },\n "30023": {\n "description": "Long-form articles",\n "content_limit": 100000,\n "tag_validation": {\n "d": "^[a-z0-9-]{1,64}$",\n "t": "^[a-z0-9-]{1,32}$"\n }\n }\n },\n "default_policy": "allow",\n "policy_admins": [""],\n "policy_follow_whitelist_enabled": true\n}',function(){l=this.value,n(0,l)},e=>v(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class Ry extends ae{constructor(e){super(),le(this,e,Dy,$y,s,{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 Py=[{id:"social",name:"Social/Notes",description:"User profiles, notes, follows, reposts, reactions, and relay lists",kinds:[0,1,3,6,7,10002]},{id:"dm",name:"Direct Messages",description:"Encrypted direct messages (legacy and NIP-17 gift-wrapped)",kinds:[4,14,1059]},{id:"longform",name:"Long-form Content",description:"Blog posts and article drafts",kinds:[30023,30024]},{id:"media",name:"Media",description:"File metadata and media attachments",kinds:[1063,20,21,22]},{id:"marketplace_nip15",name:"Marketplace (NIP-15)",description:"Legacy NIP-15 stalls and products",kinds:[30017,30018,30019,30020]},{id:"marketplace_nip99",name:"Marketplace (NIP-99/Gamma)",description:"NIP-99 classified listings, collections, shipping, reviews (Plebeian Market)",kinds:[30402,30403,30405,30406,31555]},{id:"order_communication",name:"Order Communication",description:"Gamma Markets order messages and payment receipts (kinds 16, 17)",kinds:[16,17]},{id:"groups_nip29",name:"Group Messaging (NIP-29)",description:"Simple relay-based group chat messages",kinds:[9,10,11,12]},{id:"groups_nip72",name:"Communities (NIP-72)",description:"Community definitions and threaded discussions",kinds:[34550,1111,4550]},{id:"lists",name:"Lists/Bookmarks",description:"Mute lists, pin lists, and parameterized list events",kinds:[1e4,10001,3e4,30001]}];function Ty(e,t,n){const i=e.slice();return i[90]=t[n],i}function Uy(e,t,n){const i=e.slice();return i[98]=t[n],i}function Ny(e,t,n){const i=e.slice();return i[93]=t[n],i}function _y(e,t,n){const i=e.slice();return i[103]=t[n],i}function Ly(e,t,n){const i=e.slice();return i[106]=t[n],i}function My(e,t,n){const i=e.slice();return i[106]=t[n],i}function Oy(e,t,n){const i=e.slice();return i[93]=t[n],i}function jy(e,t,n){const i=e.slice();return i[90]=t[n],i}function Hy(e){let t,n,i;return{c(){t=m("div"),n=y(e[2]),I(t,"class",i="message "+e[3]+" svelte-1i0huu3")},m(e,i){p(e,t,i),f(t,n)},p(e,r){4&r[0]&&E(n,e[2]),8&r[0]&&i!==(i="message "+e[3]+" svelte-1i0huu3")&&I(t,"class",i)},d(e){e&&h(t)}}}function Gy(e){let t;function n(e,t){return e[5]?Ky:Jy}let i=n(e),r=i(e);return{c(){r.c(),t=b()},m(e,n){r.m(e,n),p(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&h(t)}}}function qy(e){let t,n,r,s,o,l,a,c,u,d,v,y,b,k,E,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X=Py,ee=[];for(let t=0;tInitial Configuration \n

    Configure curating mode before the relay will accept events. Select which event kinds to allow and set rate limiting parameters.

    ',r=w(),s=m("div"),o=m("h4"),o.textContent="Allowed Event Kinds",l=w(),a=m("p"),a.textContent="Select categories of events to allow. At least one must be selected.",c=w(),u=m("div");for(let e=0;e0?zy:Yy}let B=S(e),Q=B(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Trusted Publishers",r=w(),s=m("p"),s.textContent="Trusted users can publish unlimited events without rate limiting.",o=w(),l=m("div"),a=m("input"),c=w(),u=m("input"),d=w(),g=m("button"),v=y("Trust"),b=w(),k=m("div"),Q.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"type","text"),I(a,"placeholder","Pubkey (64 hex chars)"),I(a,"class","svelte-1i0huu3"),I(u,"type","text"),I(u,"placeholder","Note (optional)"),I(u,"class","svelte-1i0huu3"),g.disabled=e[1],I(g,"class","svelte-1i0huu3"),I(l,"class","add-form svelte-1i0huu3"),I(k,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),x(a,e[13]),f(l,c),f(l,u),x(u,e[14]),f(l,d),f(l,g),f(g,v),f(t,b),f(t,k),Q.m(k,null),C||(E=[A(a,"input",e[58]),A(u,"input",e[59]),A(g,"click",e[60])],C=!0)},p(e,t){8192&t[0]&&a.value!==e[13]&&x(a,e[13]),16384&t[0]&&u.value!==e[14]&&x(u,e[14]),2&t[0]&&(g.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(k,null)))},d(e){e&&h(t),Q.d(),C=!1,i(E)}}}function Yy(t){let n;return{c(){n=m("div"),n.textContent="No trusted pubkeys yet.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function zy(e){let t,n=e[12],i=[];for(let t=0;t0?tw:ew}let B=S(e),Q=B(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Blacklisted Publishers",r=w(),s=m("p"),s.textContent="Blacklisted users cannot publish any events.",o=w(),l=m("div"),a=m("input"),c=w(),u=m("input"),d=w(),g=m("button"),v=y("Blacklist"),b=w(),k=m("div"),Q.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"type","text"),I(a,"placeholder","Pubkey (64 hex chars)"),I(a,"class","svelte-1i0huu3"),I(u,"type","text"),I(u,"placeholder","Reason (optional)"),I(u,"class","svelte-1i0huu3"),g.disabled=e[1],I(g,"class","svelte-1i0huu3"),I(l,"class","add-form svelte-1i0huu3"),I(k,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),x(a,e[16]),f(l,c),f(l,u),x(u,e[17]),f(l,d),f(l,g),f(g,v),f(t,b),f(t,k),Q.m(k,null),C||(E=[A(a,"input",e[63]),A(u,"input",e[64]),A(g,"click",e[65])],C=!0)},p(e,t){65536&t[0]&&a.value!==e[16]&&x(a,e[16]),131072&t[0]&&u.value!==e[17]&&x(u,e[17]),2&t[0]&&(g.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(k,null)))},d(e){e&&h(t),Q.d(),C=!1,i(E)}}}function ew(t){let n;return{c(){n=m("div"),n.textContent="No blacklisted pubkeys.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function tw(e){let t,n=e[15],i=[];for(let t=0;t0?ow:sw}let x=E(e),S=x(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Unclassified Users",r=w(),s=m("p"),s.textContent="Users who have posted events but haven't been classified. Sorted by event count.",o=w(),l=m("div"),a=m("button"),c=y("Refresh"),u=w(),d=m("button"),g=y("Scan Database"),v=w(),b=m("div"),S.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"class","refresh-btn svelte-1i0huu3"),a.disabled=e[1],I(d,"class","scan-btn svelte-1i0huu3"),d.disabled=e[1],I(l,"class","button-row svelte-1i0huu3"),I(b,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),f(a,c),f(l,u),f(l,d),f(d,g),f(t,v),f(t,b),S.m(b,null),k||(C=[A(a,"click",e[21]),A(d,"click",e[22])],k=!0)},p(e,t){2&t[0]&&(a.disabled=e[1]),2&t[0]&&(d.disabled=e[1]),x===(x=E(e))&&S?S.p(e,t):(S.d(1),S=x(e),S&&(S.c(),S.m(b,null)))},d(e){e&&h(t),S.d(),k=!1,i(C)}}}function sw(t){let n;return{c(){n=m("div"),n.textContent="No unclassified users.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function ow(e){let t,n=e[18],i=[];for(let t=0;t0?uw:cw}let v=g(e),b=v(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Spam Events",i=w(),r=m("p"),r.textContent="Events flagged as spam are hidden from query results but remain in the database.",s=w(),o=m("button"),l=y("Refresh"),a=w(),c=m("div"),b.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],I(c,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(h,g){p(h,t,g),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(t,a),f(t,c),b.m(c,null),u||(d=A(o,"click",e[23]),u=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),v===(v=g(e))&&b?b.p(e,t):(b.d(1),b=v(e),b&&(b.c(),b.m(c,null)))},d(e){e&&h(t),b.d(),u=!1,d()}}}function cw(t){let n;return{c(){n=m("div"),n.textContent="No spam events flagged.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function uw(e){let t,n=e[19],i=[];for(let t=0;t0?gw:hw}let v=g(e),b=v(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Blocked IP Addresses",i=w(),r=m("p"),r.textContent="IP addresses blocked due to rate limit violations.",s=w(),o=m("button"),l=y("Refresh"),a=w(),c=m("div"),b.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],I(c,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(h,g){p(h,t,g),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(t,a),f(t,c),b.m(c,null),u||(d=A(o,"click",e[24]),u=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),v===(v=g(e))&&b?b.p(e,t):(b.d(1),b=v(e),b&&(b.c(),b.m(c,null)))},d(e){e&&h(t),b.d(),u=!1,d()}}}function hw(t){let n;return{c(){n=m("div"),n.textContent="No blocked IPs.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gw(e){let t,n=e[20],i=[];for(let t=0;t100*t&&(i=i.substring(0,100*t)),i}function Ow(e,t=6){if(!e)return!1;return e.split("\n").length>t||e.length>100*t}function jw(e){return{0:"Metadata",1:"Text Note",3:"Follow List",4:"Encrypted DM",6:"Repost",7:"Reaction",14:"Chat Message",16:"Order Message",17:"Payment Receipt",1063:"File Metadata",10002:"Relay List",30017:"Stall",30018:"Product (NIP-15)",30023:"Long-form",30078:"App Data",30402:"Product (NIP-99)",30405:"Collection",30406:"Shipping",31555:"Review"}[e]||`Kind ${e}`}function Hw(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="trusted",o=!1,l="",a="info",c=!1,u=null,d=null,f=[],p=0,h=0,g=!1,m={},v={daily_limit:50,first_ban_hours:1,second_ban_hours:168,categories:[],custom_kinds:"",kind_ranges:[]},y=[],w="",b="",A=[],k="",I="",E=[],x=[],S=[];async function B(e,t=[]){try{n(1,o=!0),n(2,l="");const s={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available.");const n=xp()+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s);return`Nostr ${btoa(JSON.stringify(o))}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(s)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(2,l=e.message),n(3,a="error"),e}finally{n(1,o=!1)}}async function Q(){await Promise.all([F(),$(),D(),R(),T()])}async function F(){try{n(12,y=await B("listtrustedpubkeys"))}catch(e){console.error("Failed to load trusted pubkeys:",e),n(12,y=[])}}async function $(){try{n(15,A=await B("listblacklistedpubkeys"))}catch(e){console.error("Failed to load blacklisted pubkeys:",e),n(15,A=[])}}async function D(){try{n(18,E=await B("listunclassifiedusers"))}catch(e){console.error("Failed to load unclassified users:",e),n(18,E=[])}}async function R(){try{n(19,x=await B("listspamevents"))}catch(e){console.error("Failed to load spam events:",e),n(19,x=[])}}async function T(){try{n(20,S=await B("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e),n(20,S=[])}}async function U(e=null,t=""){const i=e||w,r=e?t:b;if(i)try{await B("trustpubkey",[i,r]),n(2,l="Pubkey trusted successfully"),n(3,a="success"),n(13,w=""),n(14,b=""),await F(),await D()}catch(e){console.error("Failed to trust pubkey:",e)}}async function N(e){try{await B("untrustpubkey",[e]),n(2,l="Pubkey untrusted"),n(3,a="success"),await F()}catch(e){console.error("Failed to untrust pubkey:",e)}}async function _(e=null,t=""){const i=e||k,r=e?t:I;if(i)try{await B("blacklistpubkey",[i,r]),n(2,l="Pubkey blacklisted"),n(3,a="success"),n(16,k=""),n(17,I=""),await $(),await D()}catch(e){console.error("Failed to blacklist pubkey:",e)}}async function L(e){try{await B("unblacklistpubkey",[e]),n(2,l="Pubkey removed from blacklist"),n(3,a="success"),await $()}catch(e){console.error("Failed to remove from blacklist:",e)}}async function M(e){try{await B("unmarkspam",[e]),n(2,l="Spam mark removed"),n(3,a="success"),await R()}catch(e){console.error("Failed to unmark spam:",e)}}async function O(e){if(confirm("Permanently delete this event?"))try{await B("deleteevent",[e]),n(2,l="Event deleted"),n(3,a="success"),await R()}catch(e){console.error("Failed to delete event:",e)}}async function j(e){try{await B("unblockip",[e]),n(2,l="IP unblocked"),n(3,a="success"),await T()}catch(e){console.error("Failed to unblock IP:",e)}}function H(e){v.categories.includes(e)?n(11,v.categories=v.categories.filter(t=>t!==e),v):n(11,v.categories=[...v.categories,e],v)}async function G(){if(!i||!r)return n(2,l="Please log in with a Nostr extension to publish configuration"),void n(3,a="error");if(0===v.categories.length&&!v.custom_kinds.trim())return n(2,l="Please select at least one kind category or enter custom kinds"),void n(3,a="error");try{n(1,o=!0),n(2,l="");const e=[["d","curating-config"],["daily_limit",String(v.daily_limit)],["first_ban_hours",String(v.first_ban_hours)],["second_ban_hours",String(v.second_ban_hours)]];for(const t of v.categories)e.push(["kind_category",t]);const t=function(e){if(!e||!e.trim())return[];const t=new Set,n=e.split(",").map(e=>e.trim());for(const e of n)if(e)if(e.includes("-")){const[n,i]=e.split("-").map(e=>parseInt(e.trim(),10));if(!isNaN(n)&&!isNaN(i)&&n<=i&&i-n<=1e3)for(let e=n;e<=i;e++)t.add(e)}else{const n=parseInt(e,10);isNaN(n)||t.add(n)}return Array.from(t).sort((e,t)=>e-t)}(v.custom_kinds);for(const n of t)e.push(["kind",String(n)]);const s={kind:30078,created_at:Math.floor(Date.now()/1e3),tags:e,content:"Curating relay configuration",pubkey:r},u=await i.signEvent(s),d=new WebSocket(Sp());await new Promise((e,t)=>{d.onopen=()=>{d.send(JSON.stringify(["EVENT",u]))},d.onmessage=n=>{const i=JSON.parse(n.data);"OK"===i[0]&&(!0===i[2]?e():t(new Error(i[3]||"Event rejected")))},d.onerror=e=>t(new Error("WebSocket error")),setTimeout(()=>t(new Error("Timeout")),1e4)}),d.close(),n(2,l="Configuration published successfully"),n(3,a="success"),n(4,c=!0),await Q()}catch(e){console.error("Failed to publish configuration:",e),n(2,l=`Failed to publish: ${e.message}`),n(3,a="error")}finally{n(1,o=!1)}}function q(e,t="info"){n(2,l=e),n(3,a=t)}async function J(e,t){console.log("openUserDetail called:",e,t),n(5,u=e),n(6,d=t),n(7,f=[]),n(8,p=0),h=0,n(10,m={}),console.log("selectedUser set to:",u),await V()}function K(){n(5,u=null),n(6,d=null),n(7,f=[]),n(8,p=0),h=0,n(10,m={})}async function V(){if(console.log("loadUserEvents called, selectedUser:",u,"loadingEvents:",g),u&&!g)try{n(9,g=!0),console.log("Calling geteventsforpubkey API...");const e=await B("geteventsforpubkey",[u,100,h]);console.log("API result:",e),e&&(n(7,f=0===h?e.events||[]:[...f,...e.events||[]]),n(8,p=e.total||0))}catch(e){console.error("Failed to load user events:",e),q("Failed to load events: "+e.message,"error")}finally{n(9,g=!1)}}function Y(e){n(10,m={...m,[e]:!m[e]})}P(async()=>{await async function(){try{const e=await B("isconfigured");n(4,c=!0===e),c&&(await async function(){try{const e=await B("getcuratingconfig");e&&n(11,v={daily_limit:e.daily_limit||50,first_ban_hours:e.first_ban_hours||1,second_ban_hours:e.second_ban_hours||168,categories:e.categories||[],custom_kinds:e.custom_kinds?e.custom_kinds.join(", "):"",kind_ranges:e.kind_ranges||[]})}catch(e){console.error("Failed to load config:",e)}}(),await Q())}catch(e){console.error("Failed to check configuration:",e),n(4,c=!1)}}()});return e.$$set=e=>{"userSigner"in e&&n(44,i=e.userSigner),"userPubkey"in e&&n(45,r=e.userPubkey)},[s,o,l,a,c,u,d,f,p,g,m,v,y,w,b,A,k,I,E,x,S,D,async function(){try{const e=await B("scanpubkeys");q(`Database scanned: ${e.total_pubkeys} pubkeys, ${e.total_events} events (${e.skipped} skipped)`,"success"),await D()}catch(e){console.error("Failed to scan database:",e),q("Failed to scan database: "+e.message,"error")}},R,T,U,N,_,L,M,O,j,H,G,async function(){await G()},J,K,async function(){h=f.length,await V()},Y,async function(){await U(u,""),await Q(),K()},async function(){await _(u,""),await Q(),K()},async function(){await N(u),await Q(),K()},async function(){await L(u),await Q(),K()},async function(){if(confirm(`Delete ALL ${p} events from this user? This cannot be undone.`))try{n(1,o=!0);q(`Deleted ${(await B("deleteeventsforpubkey",[u])).deleted} events`,"success"),n(7,f=[]),n(8,p=0),h=0,await V()}catch(e){console.error("Failed to delete events:",e),q("Failed to delete events: "+e.message,"error")}finally{n(1,o=!1)}},i,r,e=>H(e.id),function(){v.custom_kinds=this.value,n(11,v)},function(){v.daily_limit=C(this.value),n(11,v)},function(){v.first_ban_hours=C(this.value),n(11,v)},function(){v.second_ban_hours=C(this.value),n(11,v)},e=>Y(e.id),()=>n(0,s="trusted"),()=>n(0,s="blacklist"),()=>n(0,s="unclassified"),()=>n(0,s="spam"),()=>n(0,s="ips"),()=>n(0,s="settings"),function(){w=this.value,n(13,w)},function(){b=this.value,n(14,b)},()=>U(),e=>N(e.pubkey),e=>J(e.pubkey,"trusted"),function(){k=this.value,n(16,k)},function(){I=this.value,n(17,I)},()=>_(),e=>L(e.pubkey),e=>J(e.pubkey,"blacklisted"),e=>U(e.pubkey,""),e=>_(e.pubkey,""),e=>J(e.pubkey,"unclassified"),e=>M(e.event_id),e=>O(e.event_id),e=>j(e.ip),e=>H(e.id),function(){v.custom_kinds=this.value,n(11,v)},function(){v.daily_limit=C(this.value),n(11,v)},function(){v.first_ban_hours=C(this.value),n(11,v)},function(){v.second_ban_hours=C(this.value),n(11,v)}]}class Gw extends ae{constructor(e){super(),le(this,e,Hw,Nw,s,{userSigner:44,userPubkey:45},null,[-1,-1,-1,-1])}}function qw(e,t,n){const i=e.slice();return i[58]=t[n],i}function Jw(e,t,n){const i=e.slice();return i[55]=t[n],i}function Kw(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to view your Blossom storage.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-on0yal"),I(s,"class","login-btn svelte-on0yal"),I(n,"class","login-prompt svelte-on0yal")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[21]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function Vw(e){let t,n,i,r,s,o,l,a,c,u,d,g,v,b,k=e[0]||e[12]?"Loading...":"Refresh";function C(e,t){return e[13]?Ww:e[10]?zw:Yw}let x=C(e),S=x(e),B=e[14]&&!e[10]&&!e[13]&&Xw(e),Q=!e[10]&&!e[13]&&eb(e),F=e[2]&&nb(e);function $(e,t){return e[10]&&!e[13]?rb:ib}let D=$(e),R=D(e);return{c(){t=m("div"),n=m("div"),S.c(),i=w(),r=m("div"),B&&B.c(),s=w(),o=m("button"),l=y("🔄 "),a=y(k),u=w(),Q&&Q.c(),d=w(),F&&F.c(),g=w(),R.c(),I(o,"class","refresh-btn svelte-on0yal"),o.disabled=c=e[0]||e[12],I(r,"class","header-buttons svelte-on0yal"),I(n,"class","header-section svelte-on0yal"),I(t,"class","blossom-view svelte-on0yal")},m(c,h){p(c,t,h),f(t,n),S.m(n,null),f(n,i),f(n,r),B&&B.m(r,null),f(r,s),f(r,o),f(o,l),f(o,a),f(t,u),Q&&Q.m(t,null),f(t,d),F&&F.m(t,null),f(t,g),R.m(t,null),v||(b=A(o,"click",e[31]),v=!0)},p(e,l){x===(x=C(e))&&S?S.p(e,l):(S.d(1),S=x(e),S&&(S.c(),S.m(n,i))),!e[14]||e[10]||e[13]?B&&(B.d(1),B=null):B?B.p(e,l):(B=Xw(e),B.c(),B.m(r,s)),4097&l[0]&&k!==(k=e[0]||e[12]?"Loading...":"Refresh")&&E(a,k),4097&l[0]&&c!==(c=e[0]||e[12])&&(o.disabled=c),e[10]||e[13]?Q&&(Q.d(1),Q=null):Q?Q.p(e,l):(Q=eb(e),Q.c(),Q.m(t,d)),e[2]?F?F.p(e,l):(F=nb(e),F.c(),F.m(t,g)):F&&(F.d(1),F=null),D===(D=$(e))&&R?R.p(e,l):(R.d(1),R=D(e),R&&(R.c(),R.m(t,null)))},d(e){e&&h(t),S.d(),B&&B.d(),Q&&Q.d(),F&&F.d(),R.d(),v=!1,b()}}}function Yw(t){let n;return{c(){n=m("h3"),n.textContent="Blossom Media Storage",I(n,"class","svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function zw(t){let n,i,r,s,o;return{c(){n=m("button"),n.textContent="← Back",i=w(),r=m("h3"),r.textContent="All Users Storage",I(n,"class","back-btn svelte-on0yal"),I(r,"class","svelte-on0yal")},m(e,l){p(e,n,l),p(e,i,l),p(e,r,l),s||(o=A(n,"click",t[28]),s=!0)},p:e,d(e){e&&h(n),e&&h(i),e&&h(r),s=!1,o()}}}function Ww(e){let t,n,i,r,s,o,l,a=(e[13].profile?.name||Rb(e[26](e[13].pubkey)))+"",c=e[13].profile?.picture&&Zw(e);return{c(){t=m("button"),t.textContent="← Back",n=w(),i=m("h3"),c&&c.c(),r=w(),s=y(a),I(t,"class","back-btn svelte-on0yal"),I(i,"class","user-header svelte-on0yal")},m(a,u){p(a,t,u),p(a,n,u),p(a,i,u),c&&c.m(i,null),f(i,r),f(i,s),o||(l=A(t,"click",e[30]),o=!0)},p(e,t){e[13].profile?.picture?c?c.p(e,t):(c=Zw(e),c.c(),c.m(i,r)):c&&(c.d(1),c=null),8192&t[0]&&a!==(a=(e[13].profile?.name||Rb(e[26](e[13].pubkey)))+"")&&E(s,a)},d(e){e&&h(t),e&&h(n),e&&h(i),c&&c.d(),o=!1,l()}}}function Zw(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[13].profile.picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","header-avatar svelte-on0yal")},m(e,n){p(e,t,n)},p(e,i){8192&i[0]&&!l(t.src,n=e[13].profile.picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function Xw(e){let t,n,i,r;return{c(){t=m("button"),n=y("Admin"),I(t,"class","admin-btn svelte-on0yal"),t.disabled=e[0]},m(s,o){p(s,t,o),f(t,n),i||(r=A(t,"click",e[27]),i=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&h(t),i=!1,r()}}}function eb(e){let t,n,r,s,o,l,a,c,u,d,g=e[3].length>0&&tb(e);return{c(){t=m("div"),n=m("span"),n.textContent="Upload new files",r=w(),s=m("input"),o=w(),g&&g.c(),l=w(),a=m("button"),c=y("Select Files"),I(n,"class","upload-label svelte-on0yal"),I(s,"type","file"),s.multiple=!0,I(s,"class","file-input-hidden svelte-on0yal"),I(a,"class","select-btn svelte-on0yal"),a.disabled=e[4],I(t,"class","upload-section svelte-on0yal")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),e[40](s),f(t,o),g&&g.m(t,null),f(t,l),f(t,a),f(a,c),u||(d=[A(s,"change",e[23]),A(a,"click",e[24])],u=!0)},p(e,n){e[3].length>0?g?g.p(e,n):(g=tb(e),g.c(),g.m(t,l)):g&&(g.d(1),g=null),16&n[0]&&(a.disabled=e[4])},d(n){n&&h(t),e[40](null),g&&g.d(),u=!1,i(d)}}}function tb(e){let t,n,i,r,s,o,l,a,c=e[3].length+"",u=(e[4]?e[5]:"Upload")+"";return{c(){t=m("span"),n=y(c),i=y(" file(s) selected"),r=w(),s=m("button"),o=y(u),I(t,"class","selected-count svelte-on0yal"),I(s,"class","upload-btn svelte-on0yal"),s.disabled=e[4]},m(c,u){p(c,t,u),f(t,n),f(t,i),p(c,r,u),p(c,s,u),f(s,o),l||(a=A(s,"click",e[25]),l=!0)},p(e,t){8&t[0]&&c!==(c=e[3].length+"")&&E(n,c),48&t[0]&&u!==(u=(e[4]?e[5]:"Upload")+"")&&E(o,u),16&t[0]&&(s.disabled=e[4])},d(e){e&&h(t),e&&h(r),e&&h(s),l=!1,a()}}}function nb(e){let t,n;return{c(){t=m("div"),n=y(e[2]),I(t,"class","error-message svelte-on0yal")},m(e,i){p(e,t,i),f(t,n)},p(e,t){4&t[0]&&E(n,e[2])},d(e){e&&h(t)}}}function ib(e){let t,n,i;function r(e,i){return 1&i[0]&&(t=null),null==t&&(t=!(!e[0]||0!==e[32]().length)),t?lb:(null==n&&(n=!(0!==e[32]().length)),n?ob:sb)}let s=r(e,[-1,-1]),o=s(e);return{c(){o.c(),i=b()},m(e,t){o.m(e,t),p(e,i,t)},p(e,t){s===(s=r(e,t))&&o?o.p(e,t):(o.d(1),o=s(e),o&&(o.c(),o.m(i.parentNode,i)))},d(e){o.d(e),e&&h(i)}}}function rb(e){let t;function n(e,t){return e[12]?hb:0===e[11].length?pb:fb}let i=n(e),r=i(e);return{c(){r.c(),t=b()},m(e,n){r.m(e,n),p(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&h(t)}}}function sb(e){let t,n=e[32](),i=[];for(let t=0;tNo users have uploaded files yet.

    ",I(n,"class","empty-state svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function hb(t){let n;return{c(){n=m("div"),n.textContent="Loading user statistics...",I(n,"class","loading svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gb(t){let n;return{c(){n=m("div"),I(n,"class","user-avatar-placeholder svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function mb(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[55].profile.picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","user-avatar svelte-on0yal")},m(e,n){p(e,t,n)},p(e,i){2048&i[0]&&!l(t.src,n=e[55].profile.picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function vb(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C,x,S,B,Q,F,$,D,R,P,T,U=(e[55].profile?.name||Rb(e[26](e[55].pubkey)))+"",N=e[26](e[55].pubkey)+"",_=Rb(e[26](e[55].pubkey))+"",L=e[55].blob_count+"",M=Bb(e[55].total_size_bytes)+"";function O(e,t){return e[55].profile?.picture?mb:gb}let j=O(e),H=j(e);function G(){return e[41](e[55])}function q(...t){return e[42](e[55],...t)}return{c(){t=m("div"),n=m("div"),H.c(),r=w(),s=m("div"),o=m("div"),l=y(U),a=w(),c=m("div"),u=m("span"),d=y(N),g=w(),v=m("span"),b=y(_),C=w(),x=m("div"),S=m("span"),B=y(L),Q=y(" files"),F=w(),$=m("span"),D=y(M),R=w(),I(n,"class","user-avatar-container svelte-on0yal"),I(o,"class","user-name svelte-on0yal"),I(u,"class","npub-full svelte-on0yal"),I(v,"class","npub-truncated svelte-on0yal"),I(c,"class","user-npub svelte-on0yal"),I(c,"title",k=e[55].pubkey),I(s,"class","user-info svelte-on0yal"),I(S,"class","blob-count svelte-on0yal"),I($,"class","total-size svelte-on0yal"),I(x,"class","user-stats svelte-on0yal"),I(t,"class","user-stat-item svelte-on0yal"),I(t,"role","button"),I(t,"tabindex","0")},m(e,i){p(e,t,i),f(t,n),H.m(n,null),f(t,r),f(t,s),f(s,o),f(o,l),f(s,a),f(s,c),f(c,u),f(u,d),f(c,g),f(c,v),f(v,b),f(t,C),f(t,x),f(x,S),f(S,B),f(S,Q),f(x,F),f(x,$),f($,D),f(t,R),P||(T=[A(t,"click",G),A(t,"keypress",q)],P=!0)},p(t,i){j===(j=O(e=t))&&H?H.p(e,i):(H.d(1),H=j(e),H&&(H.c(),H.m(n,null))),2048&i[0]&&U!==(U=(e[55].profile?.name||Rb(e[26](e[55].pubkey)))+"")&&E(l,U),2048&i[0]&&N!==(N=e[26](e[55].pubkey)+"")&&E(d,N),2048&i[0]&&_!==(_=Rb(e[26](e[55].pubkey))+"")&&E(b,_),2048&i[0]&&k!==(k=e[55].pubkey)&&I(c,"title",k),2048&i[0]&&L!==(L=e[55].blob_count+"")&&E(B,L),2048&i[0]&&M!==(M=Bb(e[55].total_size_bytes)+"")&&E(D,M)},d(e){e&&h(t),H.d(),P=!1,i(T)}}}function yb(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,C,x,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te=Fb(e[8].sha256)+"",ne=(e[8].type||"unknown")+"",ie="image"===$b(e[8].type),re=Bb(e[8].size)+"",se=Qb(e[8].uploaded)+"",oe=ie&&wb(e);function le(e,t){return 256&t[0]&&(S=null),256&t[0]&&(B=null),256&t[0]&&(Q=null),null==S&&(S=!("image"!==$b(e[8].type))),S?Ib:(null==B&&(B=!("video"!==$b(e[8].type))),B?kb:(null==Q&&(Q=!("audio"!==$b(e[8].type))),Q?Ab:bb))}let ae=le(e,[-1,-1]),ce=ae(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("div"),o=m("span"),l=y(te),a=w(),c=m("span"),u=y(ne),d=w(),g=m("div"),oe&&oe.c(),v=w(),b=m("button"),b.textContent="X",C=w(),x=m("div"),ce.c(),F=w(),$=m("div"),D=m("div"),R=m("span"),P=y("Size: "),T=y(re),U=w(),N=m("span"),_=y("Uploaded: "),L=y(se),M=w(),O=m("div"),j=m("input"),G=w(),q=m("button"),q.textContent="Copy",J=w(),K=m("div"),V=m("a"),Y=y("Open in New Tab"),W=w(),Z=m("button"),Z.textContent="Delete",I(o,"class","modal-hash svelte-on0yal"),I(c,"class","modal-type svelte-on0yal"),I(s,"class","modal-title svelte-on0yal"),I(b,"class","close-btn svelte-on0yal"),I(g,"class","modal-controls svelte-on0yal"),I(r,"class","modal-header svelte-on0yal"),I(x,"class","modal-body svelte-on0yal"),I(D,"class","blob-details svelte-on0yal"),I(j,"type","text"),j.readOnly=!0,j.value=H=e[20](e[8]),I(j,"class","blob-url-input svelte-on0yal"),I(q,"class","copy-btn svelte-on0yal"),I(O,"class","blob-url-section svelte-on0yal"),I(V,"href",z=e[20](e[8])),I(V,"target","_blank"),I(V,"rel","noopener noreferrer"),I(V,"class","action-btn svelte-on0yal"),I(Z,"class","action-btn danger svelte-on0yal"),I(K,"class","modal-actions svelte-on0yal"),I($,"class","modal-footer svelte-on0yal"),I(n,"class","modal-content svelte-on0yal"),I(n,"role","dialog"),I(t,"class","modal-overlay svelte-on0yal"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(s,o),f(o,l),f(s,a),f(s,c),f(c,u),f(r,d),f(r,g),oe&&oe.m(g,null),f(g,v),f(g,b),f(n,C),f(n,x),ce.m(x,null),f(n,F),f(n,$),f($,D),f(D,R),f(R,P),f(R,T),f(D,U),f(D,N),f(N,_),f(N,L),f($,M),f($,O),f(O,j),f(O,G),f(O,q),f($,J),f($,K),f(K,V),f(V,Y),f(K,W),f(K,Z),X||(ee=[A(b,"click",e[16]),A(j,"click",Pb),A(q,"click",e[46]),A(Z,"click",e[47]),A(n,"click",k(e[38])),A(n,"keypress",k(e[39])),A(t,"click",e[16]),A(t,"keypress",e[48])],X=!0)},p(e,t){256&t[0]&&te!==(te=Fb(e[8].sha256)+"")&&E(l,te),256&t[0]&&ne!==(ne=(e[8].type||"unknown")+"")&&E(u,ne),256&t[0]&&(ie="image"===$b(e[8].type)),ie?oe?oe.p(e,t):(oe=wb(e),oe.c(),oe.m(g,v)):oe&&(oe.d(1),oe=null),ae===(ae=le(e,t))&&ce?ce.p(e,t):(ce.d(1),ce=ae(e),ce&&(ce.c(),ce.m(x,null))),256&t[0]&&re!==(re=Bb(e[8].size)+"")&&E(T,re),256&t[0]&&se!==(se=Qb(e[8].uploaded)+"")&&E(L,se),256&t[0]&&H!==(H=e[20](e[8]))&&j.value!==H&&(j.value=H),256&t[0]&&z!==(z=e[20](e[8]))&&I(V,"href",z)},d(e){e&&h(t),oe&&oe.d(),ce.d(),X=!1,i(ee)}}}function wb(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k=Math.round(100*e[9])+"";return{c(){t=m("button"),n=y("-"),s=w(),o=m("span"),l=y(k),a=y("%"),c=w(),u=m("button"),d=y("+"),I(t,"class","zoom-btn svelte-on0yal"),t.disabled=r=e[9]<=Eb,I(o,"class","zoom-level svelte-on0yal"),I(u,"class","zoom-btn svelte-on0yal"),u.disabled=g=e[9]>=xb},m(i,r){p(i,t,r),f(t,n),p(i,s,r),p(i,o,r),f(o,l),f(o,a),p(i,c,r),p(i,u,r),f(u,d),v||(b=[A(t,"click",e[18]),A(u,"click",e[17])],v=!0)},p(e,n){512&n[0]&&r!==(r=e[9]<=Eb)&&(t.disabled=r),512&n[0]&&k!==(k=Math.round(100*e[9])+"")&&E(l,k),512&n[0]&&g!==(g=e[9]>=xb)&&(u.disabled=g)},d(e){e&&h(t),e&&h(s),e&&h(o),e&&h(c),e&&h(u),v=!1,i(b)}}}function bb(e){let t,n,i,r,s,o,l,a,c,u=Db(e[8].type)+"";return{c(){t=m("div"),n=m("div"),i=y(u),r=w(),s=m("p"),s.textContent="Preview not available for this file type.",o=w(),l=m("a"),a=y("Download File"),I(n,"class","file-icon svelte-on0yal"),I(l,"href",c=e[20](e[8])),I(l,"target","_blank"),I(l,"rel","noopener noreferrer"),I(l,"class","download-link svelte-on0yal"),I(t,"class","file-preview svelte-on0yal")},m(e,c){p(e,t,c),f(t,n),f(n,i),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a)},p(e,t){256&t[0]&&u!==(u=Db(e[8].type)+"")&&E(i,u),256&t[0]&&c!==(c=e[20](e[8]))&&I(l,"href",c)},d(e){e&&h(t)}}}function Ab(e){let t,n,i;return{c(){t=m("div"),n=m("audio"),n.controls=!0,l(n.src,i=e[20](e[8]))||I(n,"src",i),I(n,"class","svelte-on0yal"),I(t,"class","media-container audio svelte-on0yal")},m(e,i){p(e,t,i),f(t,n)},p(e,t){256&t[0]&&!l(n.src,i=e[20](e[8]))&&I(n,"src",i)},d(e){e&&h(t)}}}function kb(e){let t,n,i,r;return{c(){t=m("div"),n=m("video"),i=m("track"),I(i,"kind","captions"),n.controls=!0,l(n.src,r=e[20](e[8]))||I(n,"src",r),I(n,"class","svelte-on0yal"),I(t,"class","media-container svelte-on0yal")},m(e,r){p(e,t,r),f(t,n),f(n,i)},p(e,t){256&t[0]&&!l(n.src,r=e[20](e[8]))&&I(n,"src",r)},d(e){e&&h(t)}}}function Ib(e){let t,n,i;return{c(){t=m("div"),n=m("img"),l(n.src,i=e[20](e[8]))||I(n,"src",i),I(n,"alt","Blob content"),I(n,"class","svelte-on0yal"),I(t,"class","media-container svelte-on0yal"),S(t,"transform","scale("+e[9]+")")},m(e,i){p(e,t,i),f(t,n)},p(e,r){256&r[0]&&!l(n.src,i=e[20](e[8]))&&I(n,"src",i),512&r[0]&&S(t,"transform","scale("+e[9]+")")},d(e){e&&h(t)}}}function Cb(t){let n,i,r,s;function o(e,t){return e[1]?Vw:Kw}let l=o(t),a=l(t),c=t[7]&&t[8]&&yb(t);return{c(){a.c(),n=w(),c&&c.c(),i=b()},m(e,o){a.m(e,o),p(e,n,o),c&&c.m(e,o),p(e,i,o),r||(s=A(window,"keydown",t[19]),r=!0)},p(e,t){l===(l=o(e))&&a?a.p(e,t):(a.d(1),a=l(e),a&&(a.c(),a.m(n.parentNode,n))),e[7]&&e[8]?c?c.p(e,t):(c=yb(e),c.c(),c.m(i.parentNode,i)):c&&(c.d(1),c=null)},i:e,o:e,d(e){a.d(e),e&&h(n),c&&c.d(e),e&&h(i),r=!1,s()}}}const Eb=.25,xb=4;async function Sb(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const i=Math.floor(Date.now()/1e3),r=[["t",t],["expiration",(i+60).toString()]];n&&r.push(["x",n]);const s={kind:24242,created_at:i,tags:r,content:`Blossom ${t} operation`},o=await e.signEvent(s);return btoa(JSON.stringify(o)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating Blossom auth:",e),null}}function Bb(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,i=e;for(;i>=1024&&ne.target.select();function Tb(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{userPubkey:o=""}=t,{userSigner:l=null}=t,{currentEffectiveRole:a=""}=t;const c=U();let u,d=[],f=!1,p="",h=[],g=!1,m="",v=!1,y=null,w=1,b=!1,A=[],k=!1,I=null,C=[],E=!1;async function x(){if(o){n(0,f=!0),n(2,p="");try{const e=`${xp()}/blossom/list/${o}`,t=await Sb(l,"list"),n=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!n.ok)throw new Error(`Failed to load blobs: ${n.statusText}`);const i=await n.json();d=Array.isArray(i)?i:[],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,p=e.message||"Failed to load blobs")}finally{n(0,f=!1)}}}function S(e){n(8,y=e),n(9,w=1),n(7,v=!0)}function B(){n(7,v=!1),n(8,y=null),n(9,w=1)}function Q(){wEb&&n(9,w=Math.max(Eb,w-.25))}function $(e){return e.url?e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:e.url.startsWith("/")?`${xp()}${e.url}`:`http://${e.url}`:`${xp()}/blossom/${e.sha256}`}async function D(e){if(confirm(`Delete blob ${Fb(e.sha256)}?`))try{const t=`${xp()}/blossom/${e.sha256}`,n=await Sb(l,"delete",e.sha256),i=await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to delete: ${i.statusText}`);d=d.filter(t=>t.sha256!==e.sha256),y?.sha256===e.sha256&&B()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function R(){n(12,k=!0),n(2,p="");try{const e=`${xp()}/blossom/admin/users`,t=await Sb(l,"admin"),i=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!i.ok)throw new Error(`Failed to load user stats: ${i.statusText}`);n(11,A=await i.json());for(const e of A)Wp(e.pubkey).then(t=>{e.profile=t||{name:"",picture:""},n(11,A)}).catch(()=>{e.profile={name:"",picture:""}})}catch(e){console.error("Error fetching admin user stats:",e),n(2,p=e.message||"Failed to load user stats")}finally{n(12,k=!1)}}async function T(e){n(0,f=!0),n(2,p="");try{const t=`${xp()}/blossom/list/${e}`,n=await Sb(l,"list"),i=await fetch(t,{headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to load user blobs: ${i.statusText}`);C=await i.json(),C.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))}catch(e){console.error("Error loading user blobs:",e),n(2,p=e.message||"Failed to load user blobs")}finally{n(0,f=!1)}}async function _(e){n(13,I={pubkey:e.pubkey,profile:e.profile}),await T(e.pubkey)}P(()=>{i&&!E&&(n(37,E=!0),x())});return e.$$set=e=>{"isLoggedIn"in e&&n(33,s=e.isLoggedIn),"userPubkey"in e&&n(34,o=e.userPubkey),"userSigner"in e&&n(35,l=e.userSigner),"currentEffectiveRole"in e&&n(36,a=e.currentEffectiveRole)},e.$$.update=()=>{12&e.$$.dirty[1]&&n(1,i=s&&o),32&e.$$.dirty[1]&&n(14,r="admin"===a||"owner"===a),3&e.$$.dirty[0]|64&e.$$.dirty[1]&&(!i||E||f||(n(37,E=!0),x()))},[f,i,p,h,g,m,u,v,y,w,b,A,k,I,r,S,B,Q,F,function(e){v&&("Escape"===e.key?B():"+"===e.key||"="===e.key?Q():"-"===e.key&&F())},$,function(){c("openLoginModal")},D,function(e){n(3,h=Array.from(e.target.files))},function(){u?.click()},async function(){if(0===h.length)return;n(4,g=!0),n(2,p="");const e=[],t=[];for(let i=0;i0&&await x(),t.length>0&&n(2,p=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return ku(e)}catch(t){return Fb(e)}},function(){n(10,b=!0),R()},function(){n(10,b=!1),n(11,A=[]),n(13,I=null),C=[]},_,function(){n(13,I=null),C=[]},function(){I?T(I.pubkey):b?R():x()},function(){return I?C:d},s,o,l,a,E,function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},function(e){L[e?"unshift":"push"](()=>{u=e,n(6,u)})},e=>_(e),(e,t)=>"Enter"===t.key&&_(e),e=>D(e),e=>S(e),(e,t)=>"Enter"===t.key&&S(e),()=>{navigator.clipboard.writeText($(y))},()=>D(y),e=>"Enter"===e.key&&B()]}class Ub extends ae{constructor(e){super(),le(this,e,Tb,Cb,s,{isLoggedIn:33,userPubkey:34,userSigner:35,currentEffectiveRole:36},null,[-1,-1])}}function Nb(e,t,n){const i=e.slice();return i[29]=t[n],i}function _b(e,t,n){const i=e.slice();return i[32]=t[n],i}function Lb(e){let t,n,i;function r(e,t){return e[0]?Ob:jb}let s=r(e),o=s(e);return{c(){t=m("div"),n=m("p"),n.textContent="Log viewer is only available to relay owners.",i=w(),o.c(),I(n,"class","svelte-w6h7aj"),I(t,"class","login-prompt svelte-w6h7aj")},m(e,r){p(e,t,r),f(t,n),f(t,i),o.m(t,null)},p(e,n){s===(s=r(e))&&o?o.p(e,n):(o.d(1),o=s(e),o&&(o.c(),o.m(t,null)))},d(e){e&&h(t),o.d()}}}function Mb(e){let t,n,r,s,o,l,a,c,u,d,v,b,k,C,x,S,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,q=e[3]?"Loading...":"Refresh",J=e[2].length+"",K=e[12],V=[];for(let t=0;te[18].call(u)),I(l,"class","level-selector svelte-w6h7aj"),I(v,"class","clear-btn svelte-w6h7aj"),v.disabled=k=e[3]||0===e[2].length,I(x,"class","refresh-btn svelte-w6h7aj"),x.disabled=e[3],I(o,"class","header-controls svelte-w6h7aj"),I(n,"class","header-section svelte-w6h7aj"),I(D,"class","log-info svelte-w6h7aj"),I(O,"class","log-list svelte-w6h7aj"),I(t,"class","log-view svelte-w6h7aj")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(l,c),f(l,u);for(let e=0;eNo logs available.

    ",I(n,"class","empty-state svelte-w6h7aj")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Kb(e){let t,n,i,r,s=e[29].file+"",o=e[29].line+"";return{c(){t=m("span"),n=y(s),i=y(":"),r=y(o),I(t,"class","log-location svelte-w6h7aj")},m(e,s){p(e,t,s),f(t,n),f(t,i),f(t,r)},p(e,t){4&t[0]&&s!==(s=e[29].file+"")&&E(n,s),4&t[0]&&o!==(o=e[29].line+"")&&E(r,o)},d(e){e&&h(t)}}}function Vb(e){let t,n,i,r,s,o,l,a,c,u,d,g=Xb(e[29].timestamp)+"",v=e[29].level+"",b=e[29].message+"",A=e[29].file&&Kb(e);return{c(){t=m("div"),n=m("span"),i=y(g),r=w(),s=m("span"),o=y(v),a=w(),A&&A.c(),c=w(),u=m("span"),d=y(b),I(n,"class","log-timestamp svelte-w6h7aj"),I(s,"class",l="log-level "+eA(e[29].level)+" svelte-w6h7aj"),I(u,"class","log-message svelte-w6h7aj"),I(t,"class","log-entry svelte-w6h7aj")},m(e,l){p(e,t,l),f(t,n),f(n,i),f(t,r),f(t,s),f(s,o),f(t,a),A&&A.m(t,null),f(t,c),f(t,u),f(u,d)},p(e,n){4&n[0]&&g!==(g=Xb(e[29].timestamp)+"")&&E(i,g),4&n[0]&&v!==(v=e[29].level+"")&&E(o,v),4&n[0]&&l!==(l="log-level "+eA(e[29].level)+" svelte-w6h7aj")&&I(s,"class",l),e[29].file?A?A.p(e,n):(A=Kb(e),A.c(),A.m(t,c)):A&&(A.d(1),A=null),4&n[0]&&b!==(b=e[29].message+"")&&E(d,b)},d(e){e&&h(t),A&&A.d()}}}function Yb(e){let t;return{c(){t=m("span"),t.textContent="End of logs"},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function zb(e){let t;return{c(){t=m("span"),t.textContent="Scroll for more"},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Wb(e){let t;return{c(){t=m("span"),t.textContent="Loading more..."},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Zb(t){let n;function i(e,t){return e[4]?Mb:Lb}let r=i(t),s=r(t);return{c(){s.c(),n=b()},m(e,t){s.m(e,t),p(e,n,t)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&h(n)}}}function Xb(e){if(!e)return"";return new Date(e).toLocaleString()}function eA(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 tA(e,t,n){let i,{isLoggedIn:r=!1}=t,{userRole:s=""}=t,{userSigner:o=null}=t;const l=U();let a=[],c=!1,u=!0,d=0,f=0,p="",h="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let v,y,w;async function b(e="GET",t="/api/logs"){if(!o)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${xp()}${t}`],["method",e]],content:""},i=await o.signEvent(n);return btoa(JSON.stringify(i)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating auth header:",e),null}}async function A(e=!1){if(!c){n(3,c=!0),n(7,p=""),e&&(d=0,n(2,a=[]));try{const t=`/api/logs?offset=${d}&limit=100`,i=await b("GET",t),r=`${xp()}${t}`,s=await fetch(r,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!s.ok)throw new Error(`Failed to load logs: ${s.statusText}`);const o=await s.json();n(2,a=e?o.logs||[]:[...a,...o.logs||[]]),n(6,f=o.total||0),n(5,u=o.has_more||!1),d=a.length}catch(e){console.error("Error loading logs:",e),n(7,p=e.message||"Failed to load logs")}finally{n(3,c=!1)}}}async function k(){try{const e=await fetch(`${xp()}/api/logs/level`);if(e.ok){const t=await e.json();n(8,h=t.level||"info"),n(9,g=h)}}catch(e){console.error("Error loading log level:",e)}}P(()=>{i&&(A(!0),k(),function(){if(!y)return;w=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&A(!1)},{threshold:.1}),w.observe(y)}())}),T(()=>{w&&w.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"userRole"in e&&n(1,s=e.userRole),"userSigner"in e&&n(17,o=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,i=r&&"owner"===s),28&e.$$.dirty[0]&&i&&0===a.length&&!c&&(A(!0),k())},[r,s,a,c,i,u,f,p,h,g,v,y,m,A,async function(){if(g!==h)try{const e=await b("POST","/api/logs/level"),t=await fetch(`${xp()}/api/logs/level`,{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Nostr ${e}`}:{}},body:JSON.stringify({level:g})});if(!t.ok)throw new Error(`Failed to set log level: ${t.statusText}`);const i=await t.json();n(8,h=i.level),n(9,g=h)}catch(e){console.error("Error setting log level:",e),n(7,p=e.message||"Failed to set log level"),n(9,g=h)}},async function(){if(confirm("Are you sure you want to clear all logs?"))try{const e=await b("POST","/api/logs/clear"),t=await fetch(`${xp()}/api/logs/clear`,{method:"POST",headers:e?{Authorization:`Nostr ${e}`}:{}});if(!t.ok)throw new Error(`Failed to clear logs: ${t.statusText}`);n(2,a=[]),d=0,n(5,u=!1),n(6,f=0)}catch(e){console.error("Error clearing logs:",e),n(7,p=e.message||"Failed to clear logs")}},function(){l("openLoginModal")},o,function(){g=Q(this),n(9,g),n(12,m)},()=>A(!0),function(e){L[e?"unshift":"push"](()=>{y=e,n(11,y)})},function(e){L[e?"unshift":"push"](()=>{v=e,n(10,v)})}]}class nA extends ae{constructor(e){super(),le(this,e,tA,Zb,s,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}async function iA(e,t,n,i){if(!e||!t)return console.log("createNIP98Auth: No signer or pubkey available",{hasSigner:!!e,hasPubkey:!!t}),null;try{const t={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",i],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,i);const r=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:r.id,pubkey:r.pubkey,kind:r.kind,created_at:r.created_at,tags:r.tags,hasSig:!!r.sig});const s=JSON.stringify(r);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("createNIP98Auth: Error:",e),null}}async function rA(){try{const e=await fetch(xp(),{headers:{Accept:"application/nostr+json"}});if(e.ok)return await e.json()}catch(e){console.error("Error fetching relay info:",e)}return null}async function sA(){const e=xp();console.log("[api] fetchNRCConfig using base URL:",e);try{const t=await fetch(`${e}/api/nrc/config`);if(t.ok)return await t.json()}catch(e){console.error("Error fetching NRC config:",e)}return{enabled:!1,badger_required:!0}}function oA(e){return Up[e]||`Kind ${e}`}function lA(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function aA(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function cA(e){return e?new Date(1e3*e).toLocaleString():""}async function uA(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){console.error("Failed to copy to clipboard:",t);try{const t=document.createElement("textarea");return t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch(e){return console.error("Fallback copy also failed:",e),!1}}}function dA(e,t=!0){if(!e)return;const n=e.textContent,i=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=i},2e3)}function fA(e,t,n){const i=e.slice();return i[36]=t[n],i}function pA(e){let t,n,r,s,o,l,a,c,u,d,g,v,k,C,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te=(e[5].rendezvous_url||"Not configured")+"",ne=e[4].length+"",ie=e[5].mint_url&&vA(e),re=!e[5].mint_url&&yA();function se(e,t){return 0===e[4].length?bA:wA}let oe=se(e),le=oe(e),ae=e[7]&&CA(e);return{c(){t=m("div"),n=m("div"),n.innerHTML='Status: \n Enabled',r=w(),s=m("div"),o=m("span"),o.textContent="Rendezvous:",l=w(),a=m("span"),c=y(te),u=w(),ie&&ie.c(),d=w(),g=m("div"),v=m("h3"),v.textContent="Create New Connection",k=w(),C=m("div"),S=m("div"),B=m("label"),B.textContent="Device Label",Q=w(),F=m("input"),$=w(),D=m("div"),R=m("label"),P=m("input"),U=y("\n Include CAT (Cashu Access Token)\n "),re&&re.c(),N=w(),_=m("button"),L=y("+ Create Connection"),O=w(),j=m("div"),H=m("h3"),G=y("Connections ("),q=y(ne),J=y(")"),K=w(),le.c(),V=w(),Y=m("button"),z=y("Refresh"),W=w(),ae&&ae.c(),Z=b(),I(n,"class","status-item svelte-gwb5vv"),I(o,"class","status-label svelte-gwb5vv"),I(a,"class","status-value svelte-gwb5vv"),I(s,"class","status-item svelte-gwb5vv"),I(t,"class","config-status svelte-gwb5vv"),I(v,"class","svelte-gwb5vv"),I(B,"for","new-label"),I(B,"class","svelte-gwb5vv"),I(F,"type","text"),I(F,"id","new-label"),I(F,"placeholder","e.g., Phone, Laptop, Tablet"),F.disabled=e[6],I(F,"class","svelte-gwb5vv"),I(S,"class","form-group svelte-gwb5vv"),I(P,"type","checkbox"),P.disabled=T=e[6]||!e[5].mint_url,I(P,"class","svelte-gwb5vv"),I(R,"class","svelte-gwb5vv"),I(D,"class","form-group checkbox-group svelte-gwb5vv"),I(_,"class","create-btn svelte-gwb5vv"),_.disabled=M=e[6]||!e[9].trim(),I(C,"class","create-form svelte-gwb5vv"),I(g,"class","section svelte-gwb5vv"),I(H,"class","svelte-gwb5vv"),I(Y,"class","refresh-btn svelte-gwb5vv"),Y.disabled=e[6],I(j,"class","section svelte-gwb5vv")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(s,o),f(s,l),f(s,a),f(a,c),f(t,u),ie&&ie.m(t,null),p(i,d,h),p(i,g,h),f(g,v),f(g,k),f(g,C),f(C,S),f(S,B),f(S,Q),f(S,F),x(F,e[9]),f(C,$),f(C,D),f(D,R),f(R,P),P.checked=e[10],f(R,U),re&&re.m(R,null),f(C,N),f(C,_),f(_,L),p(i,O,h),p(i,j,h),f(j,H),f(H,G),f(H,q),f(H,J),f(j,K),le.m(j,null),f(j,V),f(j,Y),f(Y,z),p(i,W,h),ae&&ae.m(i,h),p(i,Z,h),X||(ee=[A(F,"input",e[28]),A(P,"change",e[29]),A(_,"click",e[15]),A(Y,"click",e[14])],X=!0)},p(e,n){32&n[0]&&te!==(te=(e[5].rendezvous_url||"Not configured")+"")&&E(c,te),e[5].mint_url?ie?ie.p(e,n):(ie=vA(e),ie.c(),ie.m(t,null)):ie&&(ie.d(1),ie=null),64&n[0]&&(F.disabled=e[6]),512&n[0]&&F.value!==e[9]&&x(F,e[9]),96&n[0]&&T!==(T=e[6]||!e[5].mint_url)&&(P.disabled=T),1024&n[0]&&(P.checked=e[10]),e[5].mint_url?re&&(re.d(1),re=null):re||(re=yA(),re.c(),re.m(R,null)),576&n[0]&&M!==(M=e[6]||!e[9].trim())&&(_.disabled=M),16&n[0]&&ne!==(ne=e[4].length+"")&&E(q,ne),oe===(oe=se(e))&&le?le.p(e,n):(le.d(1),le=oe(e),le&&(le.c(),le.m(j,V))),64&n[0]&&(Y.disabled=e[6]),e[7]?ae?ae.p(e,n):(ae=CA(e),ae.c(),ae.m(Z.parentNode,Z)):ae&&(ae.d(1),ae=null)},d(e){e&&h(t),ie&&ie.d(),e&&h(d),e&&h(g),re&&re.d(),e&&h(O),e&&h(j),le.d(),e&&h(W),ae&&ae.d(e),e&&h(Z),X=!1,i(ee)}}}function hA(e){let t,n,i,r,s,o,l,a=(e[1]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="Owner permission required for relay connection management.",i=w(),r=m("p"),s=y("Current role: "),o=m("strong"),l=y(a),I(n,"class","svelte-gwb5vv"),I(r,"class","svelte-gwb5vv"),I(t,"class","permission-denied svelte-gwb5vv")},m(e,a){p(e,t,a),f(t,n),f(t,i),f(t,r),f(r,s),f(r,o),f(o,l)},p(e,t){2&t[0]&&a!==(a=(e[1]||"none")+"")&&E(l,a)},d(e){e&&h(t)}}}function gA(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to manage relay connections.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-gwb5vv"),I(s,"class","login-btn svelte-gwb5vv"),I(n,"class","login-prompt svelte-gwb5vv")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[20]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function mA(e){let t;function n(e,t){return e[3]?xA:EA}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","not-enabled svelte-gwb5vv")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i!==(i=n(e))&&(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function vA(e){let t,n,i,r,s,o=e[5].mint_url+"";return{c(){t=m("div"),n=m("span"),n.textContent="Cashu Mint:",i=w(),r=m("span"),s=y(o),I(n,"class","status-label svelte-gwb5vv"),I(r,"class","status-value svelte-gwb5vv"),I(t,"class","status-item svelte-gwb5vv")},m(e,o){p(e,t,o),f(t,n),f(t,i),f(t,r),f(r,s)},p(e,t){32&t[0]&&o!==(o=e[5].mint_url+"")&&E(s,o)},d(e){e&&h(t)}}}function yA(e){let t;return{c(){t=m("span"),t.textContent="(requires Cashu mint)",I(t,"class","hint svelte-gwb5vv")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function wA(e){let t,n=e[4],i=[];for(let t=0;tORLY_NRC_ENABLED=true and configure ORLY_NRC_RENDEZVOUS_URL to enable.',I(t,"class","svelte-gwb5vv"),I(i,"class","svelte-gwb5vv")},m(e,r){p(e,t,r),p(e,n,r),p(e,i,r)},d(e){e&&h(t),e&&h(n),e&&h(i)}}}function xA(e){let t,n,i;return{c(){t=m("p"),t.textContent="NRC requires the Badger database backend.",n=w(),i=m("p"),i.innerHTML='Set ORLY_DB_TYPE=badger to enable NRC functionality.',I(t,"class","svelte-gwb5vv"),I(i,"class","svelte-gwb5vv")},m(e,r){p(e,t,r),p(e,n,r),p(e,i,r)},d(e){e&&h(t),e&&h(n),e&&h(i)}}}function SA(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,C,x,S,B,Q;return{c(){t=m("div"),n=m("div"),r=m("h3"),s=y('Connection URI for "'),o=y(e[13]),l=y('"'),a=w(),c=m("p"),c.textContent="Copy this URI to your Nostr client to connect to this relay remotely.\n Keep it secret - anyone with this URI can access your relay.",u=w(),d=m("div"),g=m("textarea"),v=w(),b=m("div"),C=m("button"),C.textContent="Copy to Clipboard",x=w(),S=m("button"),S.textContent="Close",I(r,"class","svelte-gwb5vv"),I(c,"class","modal-description svelte-gwb5vv"),g.readOnly=!0,g.value=e[12],I(g,"class","svelte-gwb5vv"),I(d,"class","uri-display svelte-gwb5vv"),I(C,"class","copy-btn svelte-gwb5vv"),I(S,"class","close-btn svelte-gwb5vv"),I(b,"class","modal-actions svelte-gwb5vv"),I(n,"class","modal svelte-gwb5vv"),I(t,"class","modal-overlay svelte-gwb5vv")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(n,u),f(n,d),f(d,g),f(n,v),f(n,b),f(b,C),f(b,x),f(b,S),B||(Q=[A(C,"click",e[18]),A(S,"click",e[19]),A(n,"click",k(e[27])),A(t,"click",e[19])],B=!0)},p(e,t){8192&t[0]&&E(o,e[13]),4096&t[0]&&(g.value=e[12])},d(e){e&&h(t),B=!1,i(Q)}}}function BA(t){let n,i,r,s,o,l,a;function c(e,t){return e[2]?e[0]?"owner"!==e[1]?hA:pA:gA:mA}let u=c(t),d=u(t),g=t[11]&&SA(t);return{c(){n=m("div"),i=m("h2"),i.textContent="Relay Connect",r=w(),s=m("p"),s.textContent="Nostr Relay Connect (NRC) allows remote access to this relay through a public relay tunnel.\n Create connection strings for your devices to sync securely.",o=w(),d.c(),l=w(),g&&g.c(),a=b(),I(i,"class","svelte-gwb5vv"),I(s,"class","description svelte-gwb5vv"),I(n,"class","relay-connect-view svelte-gwb5vv")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),d.m(n,null),p(e,l,t),g&&g.m(e,t),p(e,a,t)},p(e,t){u===(u=c(e))&&d?d.p(e,t):(d.d(1),d=u(e),d&&(d.c(),d.m(n,null))),e[11]?g?g.p(e,t):(g=SA(e),g.c(),g.m(a.parentNode,a)):g&&(g.d(1),g=null)},i:e,o:e,d(e){e&&h(n),d.d(),e&&h(l),g&&g.d(e),e&&h(a)}}}function QA(e){return e?new Date(1e3*e).toLocaleString():"Never"}function FA(e,t,n){let i,r;u(e,mp,e=>n(26,r=e));let{isLoggedIn:s=!1}=t,{userRole:o=""}=t,{userSigner:l=null}=t,{userPubkey:a=""}=t;const c=U();let d=!1,f=!1,p=[],h={},g=!1,m="",v="info",y="",w=!1,b=!1,A="",k="",I=!1,C="";async function E(){console.log("[RelayConnectView] loadNRCConfig called, current relayUrl:",r);try{const e=await sA();console.log("[RelayConnectView] NRC config result:",e),n(2,d=e.enabled),n(3,f=e.badger_required),d&&s&&"owner"===o&&await x()}catch(e){console.error("Failed to load NRC config:",e)}}async function x(){if(s&&l&&a){n(6,g=!0);try{const e=await async function(e,t){const n=`${xp()}/api/nrc/connections`,i=await iA(e,t,"GET",n),r=await fetch(n,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!r.ok){const e=await r.text();throw new Error(e||`Failed to get NRC connections: ${r.statusText}`)}return await r.json()}(l,a);n(4,p=e.connections||[]),n(5,h=e.config||{})}catch(e){Q(`Failed to load connections: ${e.message}`,"error")}finally{n(6,g=!1)}}}async function S(e,t){if(confirm(`Are you sure you want to delete the connection "${t}"? This will revoke access for any device using this connection.`)){n(6,g=!0);try{await async function(e,t,n){const i=`${xp()}/api/nrc/connections/${n}`,r=await iA(e,t,"DELETE",i),s=await fetch(i,{method:"DELETE",headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to delete NRC connection: ${s.statusText}`)}return await s.json()}(l,a,e),await x(),Q(`Connection "${t}" deleted`,"success")}catch(e){Q(`Failed to delete connection: ${e.message}`,"error")}finally{n(6,g=!1)}}}async function B(e,t){n(6,g=!0);try{const i=await async function(e,t,n){const i=`${xp()}/api/nrc/connections/${n}/uri`,r=await iA(e,t,"GET",i),s=await fetch(i,{headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to get NRC URI: ${s.statusText}`)}return await s.json()}(l,a,e);n(12,A=i.uri),n(13,k=t),n(11,b=!0)}catch(e){Q(`Failed to get URI: ${e.message}`,"error")}finally{n(6,g=!1)}}function Q(e,t="info"){n(7,m=e),n(8,v=t),setTimeout(()=>{m===e&&n(7,m="")},5e3)}P(async()=>{n(24,C=r||""),await E(),n(23,I=!0)});return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"userRole"in e&&n(1,o=e.userRole),"userSigner"in e&&n(21,l=e.userSigner),"userPubkey"in e&&n(22,a=e.userPubkey)},e.$$.update=()=>{67108864&e.$$.dirty[0]&&n(25,i=r),58720256&e.$$.dirty[0]&&I&&i!==C&&(n(24,C=i),console.log("[RelayConnectView] Relay changed, reloading..."),n(4,p=[]),n(5,h={}),n(2,d=!1),E()),7&e.$$.dirty[0]&&s&&"owner"===o&&d&&x()},[s,o,d,f,p,h,g,m,v,y,w,b,A,k,x,async function(){if(y.trim()){n(6,g=!0);try{const e=await async function(e,t,n,i=!1){const r=`${xp()}/api/nrc/connections`,s=await iA(e,t,"POST",r),o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...s?{Authorization:`Nostr ${s}`}:{}},body:JSON.stringify({label:n,use_cashu:i})});if(!o.ok){const e=await o.text();throw new Error(e||`Failed to create NRC connection: ${o.statusText}`)}return await o.json()}(l,a,y.trim(),w);n(12,A=e.uri),n(13,k=e.label),n(11,b=!0),n(9,y=""),n(10,w=!1),await x(),Q(`Connection "${e.label}" created successfully`,"success")}catch(e){Q(`Failed to create connection: ${e.message}`,"error")}finally{n(6,g=!1)}}else Q("Please enter a label for the connection","error")},S,B,async function(e){const t=await uA(A);dA(e.target.closest("button"),t),t||Q("Failed to copy to clipboard","error")},function(){n(11,b=!1),n(12,A=""),n(13,k="")},function(){c("openLoginModal")},l,a,I,C,i,r,function(t){N.call(this,e,t)},function(){y=this.value,n(9,y)},function(){w=this.checked,n(10,w)},e=>B(e.id,e.label),e=>S(e.id,e.label)]}class $A extends ae{constructor(e){super(),le(this,e,FA,BA,s,{isLoggedIn:0,userRole:1,userSigner:21,userPubkey:22},null,[-1,-1])}}function DA(e){let t,n,i,r,s,o,l,a,c,u,d;return{c(){t=m("div"),n=m("div"),i=m("h3"),i.textContent="Active Filter",r=w(),s=m("button"),s.textContent="🧹 Sweep",o=w(),l=m("div"),a=m("pre"),c=y(e[2]),I(i,"class","svelte-1tyqaa5"),I(s,"class","sweep-btn svelte-1tyqaa5"),I(s,"title","Clear filter"),I(n,"class","filter-display-header svelte-1tyqaa5"),I(a,"class","filter-json svelte-1tyqaa5"),I(l,"class","filter-json-container svelte-1tyqaa5"),I(t,"class","filter-display svelte-1tyqaa5")},m(h,g){p(h,t,g),f(t,n),f(n,i),f(n,r),f(n,s),f(t,o),f(t,l),f(l,a),f(a,c),u||(d=A(s,"click",e[3]),u=!0)},p(e,t){4&t&&E(c,e[2])},d(e){e&&h(t),u=!1,d()}}}function RA(t){let n,i=t[0]&&t[1]&&DA(t);return{c(){i&&i.c(),n=b()},m(e,t){i&&i.m(e,t),p(e,n,t)},p(e,[t]){e[0]&&e[1]?i?i.p(e,t):(i=DA(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&h(n)}}}function PA(e,t,n){let i,r;const s=U();let{filter:o={}}=t,{showFilter:l=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,o=e.filter),"showFilter"in e&&n(0,l=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,i=function(e){return JSON.stringify(e,null,2)}(o)),16&e.$$.dirty&&n(1,r=Object.keys(o).length>0)},[l,r,i,function(){s("sweep")},o]}class TA extends ae{constructor(e){super(),le(this,e,PA,RA,s,{filter:4,showFilter:0})}}function UA(e,t,n){const i=e.slice();return i[20]=t[n],i}function NA(e){let t,n,r,s,o,l,a,c,u,d,g,v,y,b,C,E,S,B,Q,$,D,R,P,T,U,N;function _(e,t){return e[3]&&!e[5]?LA:_A}let L=_(e),M=L(e),O=e[4]&&MA(e);function j(e,t){return e[6].length>0?jA:OA}let H=j(e),G=H(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Relay Manager",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("div"),d.textContent="Add Relay",g=w(),v=m("div"),y=m("input"),b=w(),C=m("button"),M.c(),S=w(),O&&O.c(),B=w(),Q=m("div"),$=m("div"),$.textContent="Saved Relays",D=w(),G.c(),R=w(),P=m("div"),T=m("button"),T.textContent="Done",I(s,"class","svelte-6a0diz"),I(l,"class","close-btn svelte-6a0diz"),I(r,"class","modal-header svelte-6a0diz"),I(d,"class","section-header svelte-6a0diz"),I(y,"type","text"),I(y,"placeholder","wss://relay.example.com"),y.disabled=e[3],I(y,"class","url-input svelte-6a0diz"),I(C,"class","add-btn svelte-6a0diz"),C.disabled=E=e[3]||!e[2].trim(),I(v,"class","input-row svelte-6a0diz"),I(u,"class","add-relay-section svelte-6a0diz"),I($,"class","section-header svelte-6a0diz"),I(Q,"class","saved-relays-section svelte-6a0diz"),I(T,"class","done-btn svelte-6a0diz"),I(P,"class","button-group svelte-6a0diz"),I(c,"class","modal-content svelte-6a0diz"),I(n,"class","modal svelte-6a0diz"),F(n,"dark",e[1]),I(t,"class","modal-overlay svelte-6a0diz")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(u,v),f(v,y),x(y,e[2]),f(v,b),f(v,C),M.m(C,null),f(c,S),O&&O.m(c,null),f(c,B),f(c,Q),f(Q,$),f(Q,D),G.m(Q,null),f(c,R),f(c,P),f(P,T),U||(N=[A(l,"click",e[7]),A(y,"input",e[14]),A(y,"keydown",e[11]),A(C,"click",e[9]),A(T,"click",e[7]),A(n,"click",k(e[13])),A(t,"click",e[7])],U=!0)},p(e,t){8&t&&(y.disabled=e[3]),4&t&&y.value!==e[2]&&x(y,e[2]),L!==(L=_(e))&&(M.d(1),M=L(e),M&&(M.c(),M.m(C,null))),12&t&&E!==(E=e[3]||!e[2].trim())&&(C.disabled=E),e[4]?O?O.p(e,t):(O=MA(e),O.c(),O.m(c,B)):O&&(O.d(1),O=null),H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(Q,null))),2&t&&F(n,"dark",e[1])},d(e){e&&h(t),M.d(),O&&O.d(),G.d(),U=!1,i(N)}}}function _A(e){let t;return{c(){t=y("Add")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function LA(e){let t;return{c(){t=y("Adding...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function MA(e){let t,n;return{c(){t=m("div"),n=y(e[4]),I(t,"class","error-message svelte-6a0diz")},m(e,i){p(e,t,i),f(t,n)},p(e,t){16&t&&E(n,e[4])},d(e){e&&h(t)}}}function OA(t){let n;return{c(){n=m("div"),n.textContent="No saved relays. Add one above to get started.",I(n,"class","empty-state svelte-6a0diz")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function jA(e){let t,n=e[6],i=[];for(let t=0;tn(17,i=e)),u(e,mp,e=>n(18,r=e)),u(e,kp,e=>n(6,s=e));const o=U();let{showModal:l=!1}=t,{isDarkTheme:a=!1}=t,c="",d=!1,f="",p="";function h(){n(0,l=!1),n(4,f=""),o("close")}async function g(e=null){const t=e||c.trim();if(t){n(3,d=!0),n(5,p=t),n(4,f="");try{const e=await Fp(t);if(e.success){Ip(t,Dp(t)),n(2,c=""),o("connected",{info:e.info}),h()}else n(4,f=e.error||"Failed to connect")}catch(e){n(4,f=e.message||"Connection failed")}finally{n(3,d=!1),n(5,p="")}}else n(4,f="Please enter a relay URL")}async function m(){const e=c.trim();if(e){n(3,d=!0),n(4,f="");try{const t=await Fp(e);if(t.success){Ip(e,Dp(e)),n(2,c=""),o("connected",{info:t.info})}else n(4,f=t.error||"Failed to connect")}catch(e){n(4,f=e.message||"Connection failed")}finally{n(3,d=!1)}}else n(4,f="Please enter a relay URL")}function v(e,t){t.stopPropagation(),function(e){kp.update(t=>t.filter(t=>t.url!==e))}(e)}return e.$$set=e=>{"showModal"in e&&n(0,l=e.showModal),"isDarkTheme"in e&&n(1,a=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty&&l&&(n(2,c=""),n(4,f=""))},[l,a,c,d,f,p,s,h,g,m,v,function(e){"Enter"!==e.key||d?"Escape"===e.key&&h():m()},function(e){return r===e&&"connected"===i},function(t){N.call(this,e,t)},function(){c=this.value,n(2,c),n(0,l)},e=>g(e.url),(e,t)=>v(e.url,t)]}class VA extends ae{constructor(e){super(),le(this,e,KA,JA,s,{showModal:0,isDarkTheme:1})}}class YA{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,i,r]=n;e&&i?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!i&&(console.error("Authentication failed:",r),this.authPromise&&(this.authPromise.reject(new Error(r||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const i=["EVENT",e];this.ws.send(JSON.stringify(i));const r=this.ws.onmessage,s=setTimeout(()=>{this.ws.onmessage=r,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async i=>{try{const o=JSON.parse(i.data),[l,a,c,u]=o;if("OK"===l&&a===e.id)if(c)clearTimeout(s),this.ws.onmessage=r,console.log("Event published successfully:",a),t({success:!0,eventId:a,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required"))return void console.log("Authentication required, waiting for AUTH challenge...");clearTimeout(s),this.ws.onmessage=r,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===l){this.challenge=o[1],console.log("Received AUTH challenge during publish:",this.challenge);try{await this.authenticate(),console.log("Authentication successful, retrying event publish...");const t=["EVENT",e];this.ws.send(JSON.stringify(t))}catch(e){clearTimeout(s),this.ws.onmessage=r,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(o)}catch(e){clearTimeout(s),this.ws.onmessage=r,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function zA(e,t,n,i){const r=new YA(e,n,i);try{await r.connect();return await r.publishEvent(t)}finally{r.close()}}function WA(e,t,n){const i=e.slice();return i[191]=t[n],i}function ZA(e,t,n){const i=e.slice();return i[201]=t[n],i}function XA(e,t,n){const i=e.slice();return i[194]=t[n],i}function ek(e,t,n){const i=e.slice();i[194]=t[n];const r=i[57](i[194]);return i[195]=r,i}function tk(e,t,n){const i=e.slice();return i[198]=t[n],i}function nk(t){let n;function i(e,t){return e[1]?vk:mk}let r=i(t),s=r(t);return{c(){n=m("div"),s.c(),I(n,"class","welcome-message svelte-1qbmv87")},m(e,t){p(e,n,t),s.m(n,null)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&h(n),s.d()}}}function ik(e){let t,n,i=e[6],r=[];for(let t=0;tte(r[e],1,1,()=>{r[e]=null});return{c(){for(let e=0;e=0||""!==t[38]&&parseInt(t[38])>=0,R=Tp,P=[];for(let e=0;eEvent Recovery \n

    Search and recover old versions of replaceable events

    ',s=w(),o=m("div"),l=m("div"),a=m("div"),c=m("label"),c.textContent="Select Event Kind:",u=w(),d=m("select"),v=m("option"),v.textContent="Choose a replaceable kind...";for(let e=0;et[128].call(d)),I(a,"class","kind-selector svelte-1qbmv87"),I(k,"for","custom-kind"),I(k,"class","svelte-1qbmv87"),I(S,"id","custom-kind"),I(S,"type","number"),I(S,"placeholder","e.g., 10001"),I(S,"min","0"),I(S,"class","svelte-1qbmv87"),I(b,"class","custom-kind-input svelte-1qbmv87"),I(l,"class","recovery-controls svelte-1qbmv87"),I(o,"class","recovery-controls-card svelte-1qbmv87"),I(n,"class","recovery-tab svelte-1qbmv87")},m(e,i){p(e,n,i),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(a,c),f(a,u),f(a,d),f(d,v);for(let e=0;e=0||""!==e[38]&&parseInt(e[38])>=0),D?T?T.p(e,t):(T=Bk(e),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},i:e,o:e,d(e){e&&h(n),g(P,e),T&&T.d(),F=!1,i($)}}}function sk(t){let n,i,r=t[45],o=Nk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Nk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function ok(t){let n,i,r=t[45],o=_k(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=_k(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function lk(e){let t,n,i;function r(t){e[127](t)}let s={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:uI,policyEnabled:e[8],isLoadingPolicy:e[29],policyMessage:e[30],policyMessageType:e[31],validationErrors:e[32],policyFollows:e[33]};return void 0!==e[28]&&(s.policyJson=e[28]),t=new Ry({props:s}),L.push(()=>ne(t,"policyJson",r)),t.$on("loadPolicy",e[69]),t.$on("validatePolicy",e[70]),t.$on("savePolicy",e[71]),t.$on("formatJson",e[72]),t.$on("addPolicyAdmin",e[73]),t.$on("removePolicyAdmin",e[74]),t.$on("refreshFollows",e[75]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),536870912&i[0]&&(r.isLoadingPolicy=e[29]),1073741824&i[0]&&(r.policyMessage=e[30]),1&i[1]&&(r.policyMessageType=e[31]),2&i[1]&&(r.validationErrors=e[32]),4&i[1]&&(r.policyFollows=e[33]),!n&&268435456&i[0]&&(n=!0,r.policyJson=e[28],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function ak(e){let t,n,i;function r(t){e[124](t)}let s={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[22],isLoadingSprocket:e[24],sprocketUploadFile:e[27],sprocketMessage:e[25],sprocketMessageType:e[26],sprocketVersions:e[23]};return void 0!==e[21]&&(s.sprocketScript=e[21]),t=new hy({props:s}),L.push(()=>ne(t,"sprocketScript",r)),t.$on("restartSprocket",e[64]),t.$on("deleteSprocket",e[65]),t.$on("sprocketFileSelect",e[76]),t.$on("uploadSprocketScript",e[77]),t.$on("saveSprocket",e[63]),t.$on("loadSprocket",e[62]),t.$on("loadVersions",e[66]),t.$on("loadVersion",e[125]),t.$on("deleteVersion",e[126]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),4194304&i[0]&&(r.sprocketStatus=e[22]),16777216&i[0]&&(r.isLoadingSprocket=e[24]),134217728&i[0]&&(r.sprocketUploadFile=e[27]),33554432&i[0]&&(r.sprocketMessage=e[25]),67108864&i[0]&&(r.sprocketMessageType=e[26]),8388608&i[0]&&(r.sprocketVersions=e[23]),!n&&2097152&i[0]&&(n=!0,r.sprocketScript=e[21],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function ck(e){let t,n,i,r;const s=[Ok,Mk,Lk],o=[];function l(e,t){return"curating"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=s[n](e),{c(){t=m("div"),i.c(),I(t,"class","curation-view-container")},m(e,i){p(e,t,i),o[n].m(t,null),r=!0},p(e,r){let a=n;n=l(e),n===a?o[n].p(e,r):(Z(),te(o[a],1,1,()=>{o[a]=null}),X(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),ee(i,1),i.m(t,null))},i(e){r||(ee(i),r=!0)},o(e){te(i),r=!1},d(e){e&&h(t),o[n].d()}}}function uk(e){let t,n,i,r;const s=[qk,Gk,Hk],o=[];function l(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=s[n](e),{c(){t=m("div"),i.c(),I(t,"class","managed-acl-view svelte-1qbmv87")},m(e,i){p(e,t,i),o[n].m(t,null),r=!0},p(e,r){let a=n;n=l(e),n===a?o[n].p(e,r):(Z(),te(o[a],1,1,()=>{o[a]=null}),X(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),ee(i,1),i.m(t,null))},i(e){r||(ee(i),r=!0)},o(e){te(i),r=!1},d(e){e&&h(t),o[n].d()}}}function dk(e){let t,n,i;function r(t){e[123](t)}let s={userPubkey:e[2],userRole:e[4],policyEnabled:e[8],publishError:e[36]};return void 0!==e[35]&&(s.composeEventJson=e[35]),t=new ny({props:s}),L.push(()=>ne(t,"composeEventJson",r)),t.$on("reformatJson",e[101]),t.$on("signEvent",e[102]),t.$on("publishEvent",e[103]),t.$on("clearError",e[104]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};4&i[0]&&(r.userPubkey=e[2]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),32&i[1]&&(r.publishError=e[36]),!n&&16&i[1]&&(n=!0,r.composeEventJson=e[35],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function fk(t){let n,i,r=t[45],o=Kk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Kk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function pk(e){let t,n;return t=new Uv({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[43],expandedEvents:e[20],isLoadingEvents:e[7],showOnlyMyEvents:cI,showFilterBuilder:e[17]}}),t.$on("scroll",e[100]),t.$on("toggleEventExpansion",e[119]),t.$on("deleteEvent",e[120]),t.$on("copyEventToClipboard",e[121]),t.$on("toggleChange",e[50]),t.$on("loadAllEvents",e[122]),t.$on("toggleFilterBuilder",e[87]),t.$on("filterApply",e[88]),t.$on("filterClear",e[89]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),4&n[0]&&(i.userPubkey=e[2]),4096&n[1]&&(i.filteredEvents=e[43]),1048576&n[0]&&(i.expandedEvents=e[20]),128&n[0]&&(i.isLoadingEvents=e[7]),131072&n[0]&&(i.showFilterBuilder=e[17]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function hk(e){let t,n;return t=new Um({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],selectedFile:e[18],aclMode:e[9],importMessage:e[19]}}),t.$on("fileSelect",e[97]),t.$on("importEvents",e[98]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),262144&n[0]&&(i.selectedFile=e[18]),512&n[0]&&(i.aclMode=e[9]),524288&n[0]&&(i.importMessage=e[19]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function gk(e){let t,n;return t=new Qm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],aclMode:e[9]}}),t.$on("exportMyEvents",e[96]),t.$on("exportAllEvents",e[95]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),512&n[0]&&(i.aclMode=e[9]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function mk(t){let n;return{c(){n=m("p"),n.textContent="Log in to access your user dashboard",I(n,"class","svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function vk(e){let t,n,i,r=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=m("p"),n=y("Welcome "),i=y(r),I(t,"class","svelte-1qbmv87")},m(e,r){p(e,t,r),f(t,n),f(t,i)},p(e,t){12&t[0]&&r!==(r=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(i,r)},d(e){e&&h(t)}}}function yk(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C,x,S,B,Q,F,$,D=e[201].label+"",R=e[47].get(e[201].id)?.isLoading,P=!e[47].get(e[201].id)?.hasMore&&e[47].get(e[201].id)?.events?.length>0;function T(){return e[133](e[201])}function U(e,t){return 64&t[0]&&(k=null),64&t[0]&&(C=null),null==k&&(k=!!(e[47].get(e[201].id)?.events?.length>0)),k?bk:(null==C&&(C=!e[47].get(e[201].id)?.isLoading),C?wk:void 0)}g=new TA({props:{filter:e[47].get(e[201].id)?.filter||{}}}),g.$on("sweep",function(){return e[134](e[201])});let N=U(e,[-1,-1,-1,-1,-1,-1,-1]),_=N&&N(e),L=R&&Ck(),M=P&&Ek();function O(...t){return e[139](e[201],...t)}return{c(){t=m("div"),n=m("div"),r=m("h2"),s=y("🔍 "),o=y(D),l=w(),a=m("button"),c=y("🔄 Refresh"),d=w(),ie(g.$$.fragment),v=w(),b=m("div"),_&&_.c(),x=w(),L&&L.c(),S=w(),M&&M.c(),B=w(),I(r,"class","svelte-1qbmv87"),I(a,"class","refresh-btn svelte-1qbmv87"),a.disabled=u=e[47].get(e[201].id)?.isLoading,I(n,"class","search-results-header svelte-1qbmv87"),I(b,"class","search-results-content svelte-1qbmv87"),I(t,"class","search-results-view svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n),f(n,r),f(r,s),f(r,o),f(n,l),f(n,a),f(a,c),f(t,d),re(g,t,null),f(t,v),f(t,b),_&&_.m(b,null),f(b,x),L&&L.m(b,null),f(b,S),M&&M.m(b,null),f(t,B),Q=!0,F||($=[A(a,"click",T),A(b,"scroll",O)],F=!0)},p(t,n){e=t,(!Q||64&n[0])&&D!==(D=e[201].label+"")&&E(o,D),(!Q||64&n[0]&&u!==(u=e[47].get(e[201].id)?.isLoading))&&(a.disabled=u);const i={};64&n[0]&&(i.filter=e[47].get(e[201].id)?.filter||{}),g.$set(i),N===(N=U(e,n))&&_?_.p(e,n):(_&&_.d(1),_=N&&N(e),_&&(_.c(),_.m(b,x))),64&n[0]&&(R=e[47].get(e[201].id)?.isLoading),R?L||(L=Ck(),L.c(),L.m(b,S)):L&&(L.d(1),L=null),64&n[0]&&(P=!e[47].get(e[201].id)?.hasMore&&e[47].get(e[201].id)?.events?.length>0),P?M||(M=Ek(),M.c(),M.m(b,null)):M&&(M.d(1),M=null)},i(e){Q||(ee(g.$$.fragment,e),Q=!0)},o(e){te(g.$$.fragment,e),Q=!1},d(e){e&&h(t),se(g),_&&_.d(),L&&L.d(),M&&M.d(),F=!1,i($)}}}function wk(t){let n;return{c(){n=m("div"),n.innerHTML='

    No search results found.

    ',I(n,"class","no-search-results svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function bk(e){let t,n=e[47].get(e[201].id).events,i=[];for(let t=0;t👤',s=w(),o=m("div"),l=m("div"),a=y(_),c=w(),u=m("div"),d=m("span"),g=y(L),v=w(),b=m("span"),k=y(M),C=w(),x=m("div"),S=m("div"),B=y(O),Q=w(),$=m("div"),D=y(j),R=w(),G&&G.c(),P=w(),K&&K.c(),T=w(),I(r,"class","search-result-avatar svelte-1qbmv87"),I(l,"class","search-result-author svelte-1qbmv87"),I(d,"class","kind-number svelte-1qbmv87"),I(b,"class","kind-name svelte-1qbmv87"),I(u,"class","search-result-kind svelte-1qbmv87"),I(o,"class","search-result-info svelte-1qbmv87"),I(S,"class","event-timestamp svelte-1qbmv87"),I($,"class","event-content-single-line svelte-1qbmv87"),I(x,"class","search-result-content svelte-1qbmv87"),I(n,"class","search-result-row svelte-1qbmv87"),I(n,"role","button"),I(n,"tabindex","0"),I(t,"class","search-result-item svelte-1qbmv87"),F(t,"expanded",e[20].has(e[194].id))},m(e,i){p(e,t,i),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(d,g),f(u,v),f(u,b),f(b,k),f(n,C),f(n,x),f(x,S),f(S,B),f(x,Q),f(x,$),f($,D),f(n,R),G&&G.m(n,null),f(t,P),K&&K.m(t,null),f(t,T),U||(N=[A(n,"click",q),A(n,"keydown",J)],U=!0)},p(i,r){e=i,64&r[0]&&_!==(_=lA(e[194].pubkey)+"")&&E(a,_),64&r[0]&&L!==(L=e[194].kind+"")&&E(g,L),64&r[0]&&M!==(M=oA(e[194].kind)+"")&&E(k,M),64&r[0]&&O!==(O=cA(e[194].created_at)+"")&&E(B,O),64&r[0]&&j!==(j=aA(e[194].content)+"")&&E(D,j),5!==e[194].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[194].pubkey&&e[194].pubkey===e[2])?G?G.p(e,r):(G=Ak(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),1048640&r[0]&&(H=e[20].has(e[194].id)),H?K?K.p(e,r):(K=kk(e),K.c(),K.m(t,T)):K&&(K.d(1),K=null),1048640&r[0]|65536&r[1]&&F(t,"expanded",e[20].has(e[194].id))},d(e){e&&h(t),G&&G.d(),K&&K.d(),U=!1,i(N)}}}function Ck(e){let t;return{c(){t=m("div"),t.innerHTML='
    \n

    Searching...

    ',I(t,"class","loading-search-results svelte-1qbmv87")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Ek(e){let t;return{c(){t=m("div"),t.innerHTML='

    No more search results to load.

    ',I(t,"class","end-of-search-results svelte-1qbmv87")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function xk(e){let t,n,i=e[201].id===e[5]&&yk(e);return{c(){i&&i.c(),t=b()},m(e,r){i&&i.m(e,r),p(e,t,r),n=!0},p(e,n){e[201].id===e[5]?i?(i.p(e,n),96&n[0]&&ee(i,1)):(i=yk(e),i.c(),ee(i,1),i.m(t.parentNode,t)):i&&(Z(),te(i,1,1,()=>{i=null}),X())},i(e){n||(ee(i),n=!0)},o(e){te(i),n=!1},d(e){i&&i.d(e),e&&h(t)}}}function Sk(t){let n,i,r=t[198].label+"";return{c(){n=m("option"),i=y(r),n.__value=t[198].value,n.value=n.__value},m(e,t){p(e,n,t),f(n,i)},p:e,d(e){e&&h(n)}}}function Bk(e){let t;function n(e,t){return e[40]?$k:0===e[39].length?Fk:Qk}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","recovery-results svelte-1qbmv87")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function Qk(e){let t,n,i,r=e[39],s=[];for(let t=0;tORLY_ACL_MODE=curating in your\n environment variables and restart the relay.',I(i,"class","svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(g,"class","svelte-1qbmv87"),I(n,"class","acl-mode-warning svelte-1qbmv87")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(c,u),f(n,d),f(n,g)},p(e,t){512&t[0]&&v!==(v=(e[9]||"unknown")+"")&&E(u,v)},i:e,o:e,d(e){e&&h(n)}}}function jk(e){let t,n;return t=new Gw({props:{userSigner:e[14],userPubkey:e[2]}}),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};16384&n[0]&&(i.userSigner=e[14]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function Hk(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in with owner permissions to access\n managed ACL configuration.",r=w(),s=m("button"),s.textContent="Log In",I(s,"class","login-btn svelte-1qbmv87"),I(n,"class","access-denied")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[79]),o=!0)},p:e,i:e,o:e,d(e){e&&h(n),o=!1,l()}}}function Gk(t){let n,i,r=t[45],o=Jk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Jk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function qk(t){let n,i,r,s,o,l,a,c,u,d,g,v=(t[9]||"unknown")+"";return{c(){n=m("div"),i=m("h3"),i.textContent="⚠️ Managed ACL Mode Not Active",r=w(),s=m("p"),s.textContent='To use the Managed ACL interface, you need to set\n the ACL mode to "managed" in your relay\n configuration.',o=w(),l=m("p"),a=y("Current ACL mode: "),c=m("strong"),u=y(v),d=w(),g=m("p"),g.innerHTML='Please set ORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',I(i,"class","svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(g,"class","svelte-1qbmv87"),I(n,"class","acl-mode-warning svelte-1qbmv87")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(c,u),f(n,d),f(n,g)},p(e,t){512&t[0]&&v!==(v=(e[9]||"unknown")+"")&&E(u,v)},i:e,o:e,d(e){e&&h(n)}}}function Jk(e){let t,n;return t=new Xg({props:{userSigner:e[14],userPubkey:e[2]}}),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};16384&n[0]&&(i.userSigner=e[14]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function Kk(e){let t,n;return t=new Ub({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[14],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),16384&n[0]&&(i.userSigner=e[14]),1024&n[0]&&(i.currentEffectiveRole=e[10]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function Vk(e){let t,n,r,s,o,l,a,c,u,d,g;function v(e,t){return e[3]?zk:e[1]&&e[2]?Yk:void 0}let y=v(e),b=y&&y(e),C=e[46]&&rI(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Settings",o=w(),l=m("button"),l.textContent="✕",a=w(),c=m("div"),b&&b.c(),u=w(),C&&C.c(),I(s,"class","svelte-1qbmv87"),I(l,"class","close-btn svelte-1qbmv87"),I(r,"class","drawer-header svelte-1qbmv87"),I(c,"class","drawer-content"),I(n,"class","settings-drawer svelte-1qbmv87"),F(n,"dark-theme",e[0]),I(t,"class","drawer-overlay svelte-1qbmv87"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),b&&b.m(c,null),f(c,u),C&&C.m(c,null),d||(g=[A(l,"click",e[84]),A(n,"click",k(e[114])),A(n,"keydown",k(e[115])),A(t,"click",e[84]),A(t,"keydown",e[142])],d=!0)},p(e,t){y===(y=v(e))&&b?b.p(e,t):(b&&b.d(1),b=y&&y(e),b&&(b.c(),b.m(c,u))),e[46]?C?C.p(e,t):(C=rI(e),C.c(),C.m(c,null)):C&&(C.d(1),C=null),1&t[0]&&F(n,"dark-theme",e[0])},d(e){e&&h(t),b&&b.d(),C&&C.d(),d=!1,i(g)}}}function Yk(e){let t,n,r,s,o,l,a,c,u,d,g,v,b,k,C,x,S,B=e[2].slice(0,16)+"",Q=e[2].slice(-8)+"";return{c(){t=m("div"),n=m("button"),n.textContent="Log out",r=w(),s=m("h3"),s.textContent="Profile Loading",o=w(),l=m("p"),l.textContent="Your profile metadata is being loaded...",a=w(),c=m("button"),c.textContent="Retry Loading Profile",u=w(),d=m("div"),g=m("strong"),g.textContent="Public Key:",v=w(),b=y(B),k=y("..."),C=y(Q),I(n,"class","logout-btn floating svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(c,"class","retry-profile-btn svelte-1qbmv87"),I(d,"class","user-pubkey-display svelte-1qbmv87"),I(t,"class","profile-loading-section svelte-1qbmv87")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(t,a),f(t,c),f(t,u),f(t,d),f(d,g),f(d,v),f(d,b),f(d,k),f(d,C),x||(S=[A(n,"click",e[81]),A(c,"click",e[94])],x=!0)},p(e,t){4&t[0]&&B!==(B=e[2].slice(0,16)+"")&&E(b,B),4&t[0]&&Q!==(Q=e[2].slice(-8)+"")&&E(C,Q)},d(e){e&&h(t),x=!1,i(S)}}}function zk(e){let t,n,i,r,s,o,l,a,c,u,d,g,v,k,C,x=(e[3].name||"Unknown User")+"",S=e[3].banner&&Wk(e);function B(e,t){return e[3].picture?Xk:Zk}let Q=B(e),F=Q(e),$=e[3].nip05&&eI(e),D=e[3].about&&tI(e),R=e[4]&&"read"!==e[4]&&nI(e);return{c(){t=m("div"),n=m("div"),S&&S.c(),i=w(),r=m("button"),r.textContent="Log out",s=w(),F.c(),o=w(),l=m("div"),a=m("h3"),c=y(x),u=w(),$&&$.c(),d=w(),D&&D.c(),g=w(),R&&R.c(),v=b(),I(r,"class","logout-btn floating svelte-1qbmv87"),I(a,"class","profile-username svelte-1qbmv87"),I(l,"class","name-row svelte-1qbmv87"),I(n,"class","profile-hero svelte-1qbmv87"),I(t,"class","profile-section svelte-1qbmv87")},m(h,m){p(h,t,m),f(t,n),S&&S.m(n,null),f(n,i),f(n,r),f(n,s),F.m(n,null),f(n,o),f(n,l),f(l,a),f(a,c),f(l,u),$&&$.m(l,null),f(t,d),D&&D.m(t,null),p(h,g,m),R&&R.m(h,m),p(h,v,m),k||(C=A(r,"click",e[81]),k=!0)},p(e,r){e[3].banner?S?S.p(e,r):(S=Wk(e),S.c(),S.m(n,i)):S&&(S.d(1),S=null),Q===(Q=B(e))&&F?F.p(e,r):(F.d(1),F=Q(e),F&&(F.c(),F.m(n,o))),8&r[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&E(c,x),e[3].nip05?$?$.p(e,r):($=eI(e),$.c(),$.m(l,null)):$&&($.d(1),$=null),e[3].about?D?D.p(e,r):(D=tI(e),D.c(),D.m(t,null)):D&&(D.d(1),D=null),e[4]&&"read"!==e[4]?R?R.p(e,r):(R=nI(e),R.c(),R.m(v.parentNode,v)):R&&(R.d(1),R=null)},d(e){e&&h(t),S&&S.d(),F.d(),$&&$.d(),D&&D.d(),e&&h(g),R&&R.d(e),e&&h(v),k=!1,C()}}}function Wk(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[3].banner)||I(t,"src",n),I(t,"alt","Profile banner"),I(t,"class","profile-banner svelte-1qbmv87")},m(e,n){p(e,t,n)},p(e,i){8&i[0]&&!l(t.src,n=e[3].banner)&&I(t,"src",n)},d(e){e&&h(t)}}}function Zk(t){let n;return{c(){n=m("div"),n.textContent="👤",I(n,"class","profile-avatar-placeholder overlap svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Xk(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[3].picture)||I(t,"src",n),I(t,"alt","User avatar"),I(t,"class","profile-avatar overlap svelte-1qbmv87")},m(e,n){p(e,t,n)},p(e,i){8&i[0]&&!l(t.src,n=e[3].picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function eI(e){let t,n,i=e[3].nip05+"";return{c(){t=m("span"),n=y(i),I(t,"class","profile-nip05-inline svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n)},p(e,t){8&t[0]&&i!==(i=e[3].nip05+"")&&E(n,i)},d(e){e&&h(t)}}}function tI(e){let t,n;return{c(){t=m("div"),n=m("p"),I(n,"class","profile-about svelte-1qbmv87"),I(t,"class","about-card svelte-1qbmv87")},m(i,r){p(i,t,r),f(t,n),n.innerHTML=e[42]},p(e,t){2048&t[1]&&(n.innerHTML=e[42])},d(e){e&&h(t)}}}function nI(e){let t,n,i,r,s,o,l=e[106](),a=[];for(let t=0;t\n Not connected',I(n,"class","relay-disconnected svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function oI(e){let t,n,i,r,s,o,l,a=(e[44].name||"Unknown relay")+"",c=e[44].description&&lI(e);return{c(){t=m("div"),n=m("div"),i=y(a),r=w(),c&&c.c(),s=w(),o=m("div"),l=y(e[45]),I(n,"class","relay-name svelte-1qbmv87"),I(o,"class","relay-url svelte-1qbmv87"),I(t,"class","relay-info-card svelte-1qbmv87")},m(e,a){p(e,t,a),f(t,n),f(n,i),f(t,r),c&&c.m(t,null),f(t,s),f(t,o),f(o,l)},p(e,n){8192&n[1]&&a!==(a=(e[44].name||"Unknown relay")+"")&&E(i,a),e[44].description?c?c.p(e,n):(c=lI(e),c.c(),c.m(t,s)):c&&(c.d(1),c=null),16384&n[1]&&E(l,e[45])},d(e){e&&h(t),c&&c.d()}}}function lI(e){let t,n,i=e[44].description+"";return{c(){t=m("div"),n=y(i),I(t,"class","relay-description svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n)},p(e,t){8192&t[1]&&i!==(i=e[44].description+"")&&E(n,i)},d(e){e&&h(t)}}}function aI(e){let t,n,i,r,s,o,l,a,c,u,d,g,v,y,b,A,k;t=new hm({props:{isDarkTheme:e[0],isLoggedIn:e[1],userRole:e[4],currentEffectiveRole:e[10],userProfile:e[3],userPubkey:e[2]}}),t.$on("openSettingsDrawer",e[83]),t.$on("openLoginModal",e[79]),t.$on("openRelayModal",e[59]),t.$on("relayChanged",e[58]),t.$on("toggleMobileMenu",e[85]),r=new km({props:{isDarkTheme:e[0],tabs:e[11],selectedTab:e[5],version:e[34],mobileOpen:e[16]}}),r.$on("selectTab",e[117]),r.$on("closeSearchTab",e[118]),r.$on("closeMobileMenu",e[86]);const C=[gk,hk,pk,fk,dk,uk,ck,ak,lk,ok,sk,rk,ik,nk],E=[];function x(e,t){return 96&t[0]&&(l=null),"export"===e[5]?0:"import"===e[5]?1:"events"===e[5]?2:"blossom"===e[5]?3:"compose"===e[5]?4:"managed-acl"===e[5]?5:"curation"===e[5]?6:"sprocket"===e[5]?7:"policy"===e[5]?8:"relay-connect"===e[5]?9:"logs"===e[5]?10:"recovery"===e[5]?11:(null==l&&(l=!!e[6].some(e[116])),l?12:13)}a=x(e,[-1,-1,-1,-1,-1,-1,-1]),c=E[a]=C[a](e);let S=e[15]&&Vk(e);function B(t){e[143](t)}let Q={isDarkTheme:e[0]};function $(t){e[144](t)}void 0!==e[12]&&(Q.showModal=e[12]),g=new ag({props:Q}),L.push(()=>ne(g,"showModal",B)),g.$on("login",e[80]),g.$on("close",e[82]);let D={isDarkTheme:e[0]};return void 0!==e[13]&&(D.showModal=e[13]),b=new VA({props:D}),L.push(()=>ne(b,"showModal",$)),b.$on("connected",e[61]),b.$on("close",e[60]),{c(){ie(t.$$.fragment),n=w(),i=m("div"),ie(r.$$.fragment),s=w(),o=m("main"),c.c(),u=w(),S&&S.c(),d=w(),ie(g.$$.fragment),y=w(),ie(b.$$.fragment),I(o,"class","main-content svelte-1qbmv87"),I(i,"class","app-container svelte-1qbmv87"),F(i,"dark-theme",e[0])},m(e,l){re(t,e,l),p(e,n,l),p(e,i,l),re(r,i,null),f(i,s),f(i,o),E[a].m(o,null),p(e,u,l),S&&S.m(e,l),p(e,d,l),re(g,e,l),p(e,y,l),re(b,e,l),k=!0},p(e,n){const s={};1&n[0]&&(s.isDarkTheme=e[0]),2&n[0]&&(s.isLoggedIn=e[1]),16&n[0]&&(s.userRole=e[4]),1024&n[0]&&(s.currentEffectiveRole=e[10]),8&n[0]&&(s.userProfile=e[3]),4&n[0]&&(s.userPubkey=e[2]),t.$set(s);const l={};1&n[0]&&(l.isDarkTheme=e[0]),2048&n[0]&&(l.tabs=e[11]),32&n[0]&&(l.selectedTab=e[5]),8&n[1]&&(l.version=e[34]),65536&n[0]&&(l.mobileOpen=e[16]),r.$set(l);let u=a;a=x(e,n),a===u?E[a].p(e,n):(Z(),te(E[u],1,1,()=>{E[u]=null}),X(),c=E[a],c?c.p(e,n):(c=E[a]=C[a](e),c.c()),ee(c,1),c.m(o,null)),(!k||1&n[0])&&F(i,"dark-theme",e[0]),e[15]?S?S.p(e,n):(S=Vk(e),S.c(),S.m(d.parentNode,d)):S&&(S.d(1),S=null);const f={};1&n[0]&&(f.isDarkTheme=e[0]),!v&&4096&n[0]&&(v=!0,f.showModal=e[12],q(()=>v=!1)),g.$set(f);const p={};1&n[0]&&(p.isDarkTheme=e[0]),!A&&8192&n[0]&&(A=!0,p.showModal=e[13],q(()=>A=!1)),b.$set(p)},i(e){k||(ee(t.$$.fragment,e),ee(r.$$.fragment,e),ee(c),ee(g.$$.fragment,e),ee(b.$$.fragment,e),k=!0)},o(e){te(t.$$.fragment,e),te(r.$$.fragment,e),te(c),te(g.$$.fragment,e),te(b.$$.fragment,e),k=!1},d(e){se(t,e),e&&h(n),e&&h(i),se(r),E[a].d(),e&&h(u),S&&S.d(e),e&&h(d),se(g,e),e&&h(y),se(b,e)}}}let cI=!1,uI=!1;function dI(e,t,n){let i,r,s,o,l,a,d,f,p;u(e,yp,e=>n(44,a=e)),u(e,bp,e=>n(113,d=e)),u(e,mp,e=>n(45,f=e)),u(e,vp,e=>n(46,p=e)),"undefined"!=typeof window&&(window.debugIndexedDB=lh);let h=!1,g=!1,m=!1,v=!1,y="",w="",b=null,A=null,k=null,I="",E=null,x=!1,S=!1,B=localStorage.getItem("selectedTab")||"export",F=!1,$={},D=[],R=[],P=null,T="",U=new Set,_=!1,L=!0,M=null,O="",j=new Map,H=[],G=0,q=[],J=!1,K=!0,V=null,Y="",z=null,W=[],Z=!1,X="",ee="info",te=!1,ne=null,ie="",re=!1,se=!1,oe="",le="info",ae=[],ce=[],ue=!1,de="",fe="",pe="",he="",ge=null,me="",ve=[],ye=!1,we=!0,be=null;function Ae(e){U.has(e)?U.delete(e):U.add(e),n(20,U)}async function ke(e,t){const n=JSON.stringify(e),i=await uA(n);dA(t.target.closest(".copy-json-btn"),i),i||alert("Failed to copy to clipboard. Please copy manually.")}async function Ie(e){if(!v)return void alert("Please log in first");const t=R.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===I||"owner"===I||"write"===I&&t.pubkey&&t.pubkey===y){if(confirm("Are you sure you want to delete this event?"))try{if(!E)throw new Error("Signer not available for signing");const i={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",i),console.log("User pubkey:",y),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const r=await E.signEvent(i);console.log("Signed delete event:",r),console.log("Signed delete event pubkey:",r.pubkey),console.log("Delete event tags:",r.tags);const s=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await zA(s,r,E,y);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const o=t.pubkey&&t.pubkey===y;if(o){const t=await Op.publish(r);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 ih(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 rh(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===y);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(107,R=R.filter(t=>t.id!==e)),q=q.filter(t=>t.id!==e),H=H.filter(t=>t.id!==e);for(const[t,n]of j)n.events&&(n.events=n.events.filter(t=>t.id!==e),j.set(t,n));Fe(),console.log("Reloading events to show delete event...");const i=cI&&v&&y?[y]:null;await Ze(!0,i),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=new Mp;await i.connectToRelay(t);const s=await i.publish(r);if(console.log("Delete event published to local relay only:",s),!(s.success&&s.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await ih(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${s.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 rh(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===y);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(107,R=R.filter(t=>t.id!==e)),q=q.filter(t=>t.id!==e),H=H.filter(t=>t.id!==e);for(const[t,n]of j)n.events&&(n.events=n.events.filter(t=>t.id!==e),j.set(t,n));Fe(),console.log("Reloading events to show delete event...");const t=cI&&v&&y?[y]:null;await Ze(!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 Ce(){const e=me?parseInt(me):ge;if(null==e||isNaN(e))console.log("No valid kind to load, kindToUse:",e);else if(v){console.log("Loading recovery events for kind:",e,"user:",y),n(40,ye=!0);try{const t=[{kinds:[e],authors:[y],limit:100}];be&&(t[0].until=be),console.log("Recovery filters:",t);const i=await oh(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",i.length),console.log("Recovery events kinds:",i.map(e=>e.kind)),n(39,ve=be?[...ve,...i]:i),i.length>0?(be=Math.min(...i.map(e=>e.created_at)),n(41,we=100===i.length)):n(41,we=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(40,ye=!1)}}else console.log("Not logged in, cannot load recovery events")}async function Ee(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const i={...e};if(i.created_at=Math.floor(Date.now()/1e3),i.id="",i.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(i.tags=i.tags.filter(e=>"d"!==e[0]),i.tags.push(t))}if(E){const e=await E.signEvent(i);console.log("Signed event for repost:",e);const r=await Op.publish(e,[t]);console.log("Repost publish result:",r),r.success&&r.okCount>0?(alert("Event reposted successfully!"),n(41,we=!1),await Ce()):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 xe(e){if(confirm("Are you sure you want to repost this event to all your write relays?"))try{const t=await async function(){if(!y)return[];try{const e=await Yp([{kinds:[10002],authors:[y],limit:1}]);if(0===e.length)return console.log("No relay list event found for user"),[];const t=e[0];console.log("Found relay list event:",t);const n=[];for(const e of t.tags)if("r"===e[0]&&e.length>=2){const t=e[1],i=e.length>=3?e[2]:null;i&&"write"!==i||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),i=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=[i,...t.filter(e=>e!==i)];1===r.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",r,e);const s={...e};if(s.created_at=Math.floor(Date.now()/1e3),s.id="",s.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(s.tags=s.tags.filter(e=>"d"!==e[0]),s.tags.push(t))}if(E){const e=await E.signEvent(s);console.log("Signed event for repost to all:",e);const t=await Op.publish(e,r);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${r.length} relays!`),n(41,we=!1),await Ce()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event to all:",e),alert("Error reposting event to all: "+e.message)}}let Se="auto";if("undefined"!=typeof window&&window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");h=e.matches,e.addEventListener("change",e=>{"auto"===Se&&n(0,h=e.matches)}),(async()=>{try{const e=await rA();e?.theme&&"auto"!==e.theme&&(Se=e.theme,n(0,h="dark"===e.theme))}catch(e){console.log("Could not fetch relay theme config:",e)}})()}if("undefined"!=typeof localStorage){const e=localStorage.getItem("nostr_auth_method"),t=localStorage.getItem("nostr_pubkey");e&&t&&(v=!0,y=t,w=e,"extension"===e&&window.nostr&&(E=window.nostr)),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const i=JSON.parse(t);i.selectedTab&&Le.some(e=>e.id===i.selectedTab)&&n(5,B=i.selectedTab),i.expandedEvents&&n(20,U=new Set(i.expandedEvents)),i.globalEventsCache&&(H=i.globalEventsCache),i.globalCacheTimestamp&&(G=i.globalCacheTimestamp),void 0!==i.hasMoreEvents&&(L=i.hasMoreEvents),i.oldestEventTimestamp&&(M=i.oldestEventTimestamp),void 0!==i.hasMoreMyEvents&&(K=i.hasMoreMyEvents),i.oldestMyEventTimestamp&&(V=i.oldestMyEventTimestamp),H.length>0&&((e=G)&&Date.now()-et.created_at-e.created_at),G=Date.now(),Fe()}async function De(){if(v&&"owner"===I&&te)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/status`,{method:"GET",headers:{Authorization:`Nostr ${await nt("GET",`${xp()}/api/sprocket/status`)}`,"Content-Type":"application/json"}});e.ok?n(22,z=await e.json()):Ue("Failed to load sprocket status","error")}catch(e){Ue(`Error loading sprocket status: ${e.message}`,"error")}finally{n(24,Z=!1)}}async function Re(){if(v&&"owner"===I)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/versions`,{method:"GET",headers:{Authorization:`Nostr ${await nt("GET",`${xp()}/api/sprocket/versions`)}`,"Content-Type":"application/json"}});e.ok?n(23,W=await e.json()):Ue("Failed to load versions","error")}catch(e){Ue(`Error loading versions: ${e.message}`,"error")}finally{n(24,Z=!1)}}async function Pe(e){v&&"owner"===I&&(n(21,Y=e.content),Ue(`Loaded version: ${e.name}`,"success"))}async function Te(e){if(v&&"owner"===I&&confirm(`Are you sure you want to delete version ${e}?`))try{n(24,Z=!0);const t=await fetch(`${xp()}/api/sprocket/delete-version`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/delete-version`)}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)Ue(`Version ${e} deleted successfully`,"success"),await Re();else{Ue(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){Ue(`Error deleting version: ${e.message}`,"error")}finally{n(24,Z=!1)}}function Ue(e,t="info"){n(25,X=e),n(26,ee=t),setTimeout(()=>{n(25,X="")},5e3)}function Ne(e,t="info"){n(30,oe=e),n(31,le=t),"error"!==t&&setTimeout(()=>{n(30,oe="")},5e3)}async function _e(){if(n(32,ae=[]),!ie.trim())return n(32,ae=["Policy JSON is empty"]),Ne("Validation failed","error"),!1;try{const e=JSON.parse(ie);if("object"!=typeof e||null===e)return n(32,ae=["Policy must be a JSON object"]),Ne("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)||ae.push(`Invalid policy_admin pubkey: ${t}`);else ae.push("policy_admins must be an array");if(e.rules)if("object"!=typeof e.rules)ae.push("rules must be an object");else for(const[t,n]of Object.entries(e.rules))if(/^\d+$/.test(t)||ae.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){ae.push(`Invalid regex for tag '${e}': ${t}`)}return e.default_policy&&!["allow","deny"].includes(e.default_policy)&&ae.push("default_policy must be 'allow' or 'deny'"),ae.length>0?(Ne("Validation failed - see errors below","error"),!1):(Ne("Validation passed","success"),!0)}catch(e){return n(32,ae=[`JSON parse error: ${e.message}`]),Ne("Invalid JSON syntax","error"),!1}}const Le=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"curation",icon:"📋",label:"Curation",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"relay-connect",icon:"🔗",label:"Relay Connect",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];function Me(e){n(5,B=e),"sprocket"===e&&v&&"owner"===I&&te&&(De(),Re()),Fe()}function Oe(){n(15,x=!1)}function je(e){He(e)}function He(e){n(6,D=D.filter(t=>t.id!==e)),j.delete(e),B===e&&n(5,B="export")}async function Ge(e,t=!0){const n=j.get(e);if(n&&!n.isLoading){n.isLoading=!0,j.set(e,n);try{const i={...n.filter};!t&&n.oldestTimestamp&&(i.until=n.oldestTimestamp),t||(i.limit=200),console.log("Loading search results with filter:",i);const r=await nh([i],{timeout:3e4});if(console.log("Received search results:",r.length,"events"),n.events=t?r.sort((e,t)=>t.created_at-e.created_at):[...n.events,...r].sort((e,t)=>t.created_at-e.created_at),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!n.oldestTimestamp||et.created_at-e.created_at):[...q,...t].sort((e,t)=>t.created_at-e.created_at),t.length>0){const e=Math.min(...t.map(e=>e.created_at));(!V||e{if("myevents"===B){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&async function(){!J&&K&&await We(!1)}()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{J=!1}}}else alert("Please log in first")}async function Ze(e=!1,t=null){if(!v||"read"!==I&&"write"!==I&&"admin"!==I&&"owner"!==I)alert("Read, write, admin, or owner permission required");else if(!_){n(7,_=!0),e&&(M=null);try{console.log("Loading events with authors filter:",t,"including delete events");const i=e?Math.floor(Date.now()/1e3):M,r=$.authors||t,s=await async function(e={}){const{limit:t=100,since:n=null,until:i=null,authors:r=null,kinds:s=null,...o}=e,l=Math.floor(Date.now()/1e3),a=l-15552e3,c=n||l-2592e3,u=[{...o}];u[0].since=c,i&&(u[0].until=i),r&&(u[0].authors=r),s&&(u[0].kinds=s),t&&(u[0].limit=t);let d=await nh(u,{timeout:3e4});const f=Math.min(20,t/2);return d.lengtha&&!n&&(console.log(`[fetchAllEvents] Only got ${d.length} events, retrying with 6-month window...`),u[0].since=a,d=await nh(u,{timeout:3e4}),console.log(`[fetchAllEvents] 6-month window returned ${d.length} events`)),d}({...$,limit:e?100:200,until:$.until||i,authors:r});if(console.log("Received events:",s.length,"events"),t&&s.length>0){const e=s.filter(e=>e.pubkey&&e.pubkey!==y);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",s.length)}if(e?(n(107,R=s.sort((e,t)=>t.created_at-e.created_at)),$e(s)):(n(107,R=[...R,...s].sort((e,t)=>t.created_at-e.created_at)),$e(R)),s.length>0){const e=Math.min(...s.map(e=>e.created_at));(!M||e{if("events"===B){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Xe()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,_=!1)}}}async function Xe(){await Ze(!1)}let et=!1;async function tt(e,t){if(!v||!y)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",e],["method",t.toUpperCase()]],content:"",pubkey:y};let i;if(E&&"extension"===w)try{i=await E.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==w)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),i=n}const r=JSON.stringify(i);return`Nostr ${btoa(r)}`}async function nt(e,t){if(!v||!y)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",t],["method",e.toUpperCase()]],content:"",pubkey:y};let i;if(E&&"extension"===w)try{i=await E.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==w)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),i=n}const r=JSON.stringify(i);return btoa(r)}function it(e,t){const n=e.toLowerCase();if(n.includes("policy")||n.includes("blocked")||n.includes("denied")){let n=`Policy Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} may be restricted by the relay's policy configuration.`),re&&(n+="\n\nThe relay has policy enforcement enabled. Contact a relay administrator to allow this event kind or adjust your permissions."),n}if(n.includes("auth")||n.includes("permission")||n.includes("unauthorized"))return`Permission Error: ${e}\n\nYour current permissions may not allow publishing this type of event. Current role: ${I||"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 rt(e){n(108,O=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",l)}O=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(6&e.$$.dirty[0]|16384&e.$$.dirty[3]&&n(43,i=R.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(42,r=b?.about?(t=b.about,t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):"").replace(/\n{2,}/g,"
    "):""),16&e.$$.dirty[0]|32768&e.$$.dirty[3]&&n(10,l=O&&""!==O?O:I),1810&e.$$.dirty[0]|1277952&e.$$.dirty[3]&&n(112,s=Le.filter(e=>{const t=l;if(e.requiresAdmin&&(!v||"admin"!==t&&"owner"!==t))return!1;if(e.requiresOwner&&(!v||"owner"!==t))return!1;if(e.requiresWrite&&(!v||"read"===t))return!1;return!(["sprocket","policy","managed-acl","curation","logs","relay-connect"].includes(e.id)&&!d)&&(!("sprocket"===e.id&&!te)&&(!("policy"===e.id&&!re)&&(!("relay-connect"===e.id&&!ue)&&(("managed-acl"!==e.id||"managed"===de)&&(("curation"!==e.id||"curating"===de)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:v,userRole:I,viewAsRole:O,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0))))))})),64&e.$$.dirty[0]|524288&e.$$.dirty[3]&&n(11,o=[...s,...D]),2578&e.$$.dirty[0]|524288&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:v,userRole:I,aclMode:de,filteredBaseTabs:s.map(e=>e.id),allTabs:o.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(h?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&v&&y&&!b&&Je(),182&e.$$.dirty[0]|278528&e.$$.dirty[3]&&"events"===B&&v&&("read"===I||"write"===I||"admin"===I||"owner"===I)&&0===R.length&&!et&&!_){n(111,et=!0);Ze(!0,null)}32&e.$$.dirty[0]|16384&e.$$.dirty[3]&&("events"!==B||"events"===B&&R.length>0)&&n(111,et=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",B)},[h,v,y,b,I,B,D,_,re,de,l,o,g,m,E,x,S,F,P,T,U,Y,z,W,Z,X,ee,ne,ie,se,oe,le,ae,ce,fe,pe,he,ge,me,ve,ye,we,r,i,a,f,p,j,Ae,ke,async function(){console.log("Toggle changed, showOnlyMyEvents:",cI),n(111,et=!1),await Ze(!0,null)},Ie,Ce,Ee,xe,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",ge),null!=ge?(n(38,me=""),n(39,ve=[]),be=null,n(41,we=!0),Ce()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",me);const e=parseInt(me);""!==me&&!isNaN(e)&&e>=0&&(n(37,ge=null),n(39,ve=[]),be=null,n(41,we=!0),Ce())},function(e){const t=ve.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(e){console.log("Relay changed:",e.detail?.info?.name),Op.reset(),await async function(){console.log("[nostr] Clearing IndexedDB cache...");try{const e=(await Jp()).transaction(qp,"readwrite").objectStore(qp);await new Promise((t,n)=>{const i=e.clear();i.onsuccess=()=>t(),i.onerror=()=>n(i.error)}),console.log("[nostr] IndexedDB cache cleared")}catch(e){console.warn("[nostr] Failed to clear IndexedDB cache",e)}}(),H=[],G=0,n(111,et=!1),n(107,R=[]),q=[],L=!0,K=!0,M=null,j.clear(),n(6,D=[]),Be(),"events"===B&&v?Ze(!0):"myevents"===B&&v&&We(!0)},Qe,function(){n(13,m=!1)},async function(e){console.log("Connected to relay:",e.detail?.info?.name),Op&&Op.refreshRelays(),await Be()},async function(){if(v&&"owner"===I)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/status`,{method:"GET",headers:{Authorization:`Nostr ${await nt("GET",`${xp()}/api/sprocket/status`)}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(21,Y=t.script_content||""),n(22,z=t),Ue("Script loaded successfully","success")}else Ue("Failed to load script","error")}catch(e){Ue(`Error loading script: ${e.message}`,"error")}finally{n(24,Z=!1)}},async function(){if(v&&"owner"===I)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:Y});if(e.ok)Ue("Script saved and updated successfully","success"),await De(),await Re();else{Ue(`Failed to save script: ${await e.text()}`,"error")}}catch(e){Ue(`Error saving script: ${e.message}`,"error")}finally{n(24,Z=!1)}},async function(){if(v&&"owner"===I)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/restart`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/restart`)}`,"Content-Type":"application/json"}});if(e.ok)Ue("Sprocket restarted successfully","success"),await De();else{Ue(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){Ue(`Error restarting sprocket: ${e.message}`,"error")}finally{n(24,Z=!1)}},async function(){if(v&&"owner"===I&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(21,Y=""),Ue("Sprocket script deleted successfully","success"),await De(),await Re();else{Ue(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){Ue(`Error deleting script: ${e.message}`,"error")}finally{n(24,Z=!1)}},Re,Pe,Te,async function(){if(v&&("owner"===I||uI))try{n(29,se=!0),n(32,ae=[]);const e={kinds:[12345],limit:1},t=await oh(e);if(t&&t.length>0){n(28,ie=t[0].content);try{n(28,ie=JSON.stringify(JSON.parse(ie),null,2))}catch(e){}Ne("Policy loaded successfully","success")}else{const e=await fetch(`${xp()}/api/policy`,{method:"GET",headers:{Authorization:`Nostr ${await nt("GET",`${xp()}/api/policy`)}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(28,ie=JSON.stringify(t,null,2)),Ne("Policy loaded from file","success")}else Ne("No policy configuration found","info"),n(28,ie="")}}catch(e){Ne(`Error loading policy: ${e.message}`,"error")}finally{n(29,se=!1)}},_e,async function(){if(!v||"owner"!==I&&!uI)return;if(await _e())try{n(29,se=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:ie},t=await zA(e,E);t.success?Ne("Policy updated successfully","success"):Ne(`Failed to publish policy: ${t.error||"Unknown error"}`,"error")}catch(e){Ne(`Error saving policy: ${e.message}`,"error")}finally{n(29,se=!1)}},function(){try{const e=JSON.parse(ie);n(28,ie=JSON.stringify(e,null,2)),Ne("JSON formatted","success")}catch(e){Ne(`Cannot format: ${e.message}`,"error")}},function(e){const t=e.detail;if(!t)return void Ne("Please enter a pubkey","error");const i=function(e){if(!e)return null;if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(e.startsWith("npub1"))try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(5);let i=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");i.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}i=i.slice(0,-30);const r=[];for(let e=0;e+8<=i.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|i[e+n];r.push(t)}return r.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(i&&64===i.length)try{const e=JSON.parse(ie||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(i))return void Ne("Admin already in list","warning");e.policy_admins.push(i),n(28,ie=JSON.stringify(e,null,2)),Ne("Admin added - click 'Save & Publish' to apply","info")}catch(e){Ne(`Error adding admin: ${e.message}`,"error")}else Ne("Invalid pubkey format. Use hex (64 chars) or npub","error")},function(e){const t=e.detail;try{const e=JSON.parse(ie||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(28,ie=JSON.stringify(e,null,2)),Ne("Admin removed - click 'Save & Publish' to apply","info"))}catch(e){Ne(`Error removing admin: ${e.message}`,"error")}},async function(){if(v&&("owner"===I||uI))try{n(29,se=!0),n(33,ce=[]);let e=[];try{e=JSON.parse(ie||"{}").policy_admins||[]}catch(e){return void Ne("Cannot parse policy JSON to get admins","error")}if(0===e.length)return void Ne("No policy admins configured","warning");const t={kinds:[3],authors:e,limit:e.length},i=await oh(t),r=new Set;for(const e of i)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&r.add(t[1]);n(33,ce=Array.from(r)),Ne(`Loaded ${ce.length} follows from ${i.length} admin(s)`,"success")}catch(e){Ne(`Error loading follows: ${e.message}`,"error")}finally{n(29,se=!1)}},function(e){n(27,ne=e.target.files[0])},async function(){if(v&&"owner"===I&&ne)try{n(24,Z=!0);const e=await ne.text(),t=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(21,Y=e),Ue("Script uploaded and updated successfully","success"),await De(),await Re();else{Ue(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){Ue(`Error uploading script: ${e.message}`,"error")}finally{n(24,Z=!1),n(27,ne=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},Me,function(){v||n(12,g=!0)},async function(e){const{method:t,pubkey:i,privateKey:r,signer:s}=e.detail;n(1,v=!0),n(2,y=i),w=t,n(14,E=s),n(12,g=!1);try{if(await sh(),"extension"===t&&s)Op.setSigner(s);else if("nsec"===t&&r){const e=new gf(r);Op.setSigner(e)}n(3,b=await Wp(i)),console.log("Profile loaded:",b),A=await async function(e){console.log(`[nostr] Fetching relay list for pubkey: ${e?.substring(0,8)}...`);const t=[{kinds:[10002],authors:[e],limit:1}];try{const e=await nh(t,{timeout:1e4,useCache:!0});if(e.length>0){const t=e.sort((e,t)=>t.created_at-e.created_at)[0];return console.log("[nostr] Relay list found on local relay"),Xp(t)}}catch(e){console.warn("[nostr] Failed to fetch relay list from local relay:",e)}console.log("[nostr] Relay list not found locally, trying fallback relays...");try{const e=await eh(t);if(e){await Kp(e);try{await Op.publish(e)}catch(e){console.warn("[nostr] Failed to publish relay list to local relay:",e)}return Xp(e)}}catch(e){console.warn("[nostr] Failed to fetch relay list from fallback relays:",e)}return console.log("[nostr] No relay list found for pubkey"),null}(i),A&&console.log("User relay list loaded:",A.all.length,"relays"),k=await async function(e){console.log(`[nostr] Fetching contact list for pubkey: ${e?.substring(0,8)}...`);const t=[{kinds:[3],authors:[e],limit:1}];try{const e=await nh(t,{timeout:1e4,useCache:!0});if(e.length>0){const t=e.sort((e,t)=>t.created_at-e.created_at)[0];return console.log("[nostr] Contact list found on local relay"),th(t)}}catch(e){console.warn("[nostr] Failed to fetch contact list from local relay:",e)}console.log("[nostr] Contact list not found locally, trying fallback relays...");try{const e=await eh(t);if(e){await Kp(e);try{await Op.publish(e)}catch(e){console.warn("[nostr] Failed to publish contact list to local relay:",e)}return th(e)}}catch(e){console.warn("[nostr] Failed to fetch contact list from fallback relays:",e)}return console.log("[nostr] No contact list found for pubkey"),null}(i),k&&console.log("User contact list loaded:",k.follows.length,"follows")}catch(e){console.error("Failed to load profile:",e)}await Ke(),await Ye()},function(){n(1,v=!1),n(2,y=""),w="",n(3,b=null),A=null,k=null,n(4,I=""),n(14,E=null),userPrivkey=null,n(15,x=!1),q=[],n(107,R=[]),H=[],G=0,Fe(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(12,g=!1)},function(){n(15,x=!0)},Oe,function(){n(16,S=!S)},function(){n(16,S=!1)},function(){n(17,F=!F)},function(e){const{searchText:t,selectedKinds:n,pubkeys:i,eventIds:r,tags:s,sinceTimestamp:o,untilTimestamp:l,limit:a}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:i=[],tags:r=[],since:s=null,until:o=null,limit:l=null}){const a={};return e&&e.trim()&&(a.search=e.trim()),t&&t.length>0&&(a.kinds=t),n&&n.length>0&&(a.authors=n),i&&i.length>0&&(a.ids=i),r&&r.length>0&&r.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;a[t]||(a[t]=[]),a[t].push(e.value)}}),s&&(a.since=s),o&&(a.until=o),l&&l>0&&(a.limit=l),a}({searchText:t,kinds:n,authors:i,ids:r,tags:s,since:o,until:l,limit:a||100});$=c,Ze(!0,null)},function(){$={},Ze(!0,null)},je,He,Ge,qe,Je,async function(){await ze([])},async function(){await ze([y])},function(e){n(18,P=e.detail.target.files[0])},async function(){if("none"!==de&&(!v||"admin"!==I&&"owner"!==I))return n(19,T="Admin or owner permission required"),void setTimeout(()=>{n(19,T="")},5e3);if(!P)return n(19,T="Please select a file"),void setTimeout(()=>{n(19,T="")},5e3);try{n(19,T="Uploading...");const e={};"none"!==de&&v&&(e.Authorization=await tt(`${xp()}/api/import`,"POST"));const t=new FormData;t.append("file",P);const i=await fetch(`${xp()}/api/import`,{method:"POST",headers:e,body:t});if(!i.ok)throw new Error(`Import failed: ${i.status} ${i.statusText}`);await i.json();n(19,T="Upload complete"),n(18,P=null),document.getElementById("import-file").value="",setTimeout(()=>{n(19,T="")},5e3)}catch(e){console.error("Import failed:",e),n(19,T="Import failed: "+e.message),setTimeout(()=>{n(19,T="")},5e3)}},Ze,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:i}=e.target;n-t-i<100&&Xe()},function(){try{if(!pe.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(pe);n(35,pe=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!pe.trim())return void alert("Please enter an event to sign");if(!v||!y)return void alert("Please log in to sign events");if(!E)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(pe);e.pubkey=y,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await E.signEvent(e);n(35,pe=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(36,he="");try{if(!pe.trim())return void n(36,he="Please enter an event to publish");if(!v)return void n(36,he="Please log in to publish events");if(!E)return void n(36,he="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(pe)}catch(e){return void n(36,he=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(36,he='Event must be signed before publishing. Please click "Sign" first.');if("read"===I)return void n(36,he=`Permission denied: Your current role is "${I}" which does not allow publishing events. Contact a relay administrator to upgrade your permissions.`);const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=await zA(t,e,E,y);if(i.success)n(36,he=""),alert("Event published successfully to ORLY relay!");else{const t=i.reason||"Unknown error";n(36,he=it(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(36,he=it(t,null))}},function(){n(36,he="")},rt,function(){const e=["owner","admin","write","read"],t=e.indexOf(I);return-1===t?["read"]:e.slice(t)},R,O,te,ue,et,s,d,function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},e=>e.id===B,e=>Me(e.detail),e=>He(e.detail),e=>Ae(e.detail),e=>Ie(e.detail),e=>ke(e.detail.event,e.detail.e),e=>Ze(e.detail.refresh,e.detail.authors),function(e){pe=e,n(35,pe)},function(e){Y=e,n(21,Y)},e=>Pe(e.detail),e=>Te(e.detail),function(e){ie=e,n(28,ie)},function(){ge=Q(this),n(37,ge)},function(){me=C(this.value),n(38,me)},e=>xe(e),e=>Ee(e),(e,t)=>ke(e,t),e=>Ge(e.id,!0),e=>je(e.id),e=>Ie(e.id),e=>Ae(e.id),(e,t)=>"Enter"===t.key&&Ae(e.id),(e,t)=>ke(e,t),(e,t)=>qe(t,e.id),e=>rt(e===I?"":e),()=>{Oe(),Qe()},e=>"Escape"===e.key&&Oe(),function(e){g=e,n(12,g)},function(e){m=e,n(13,m)}]}!function(){const e=!!localStorage.getItem("relayUrl"),t="file:"===window.location.protocol,n=!["3334","443","80",""].includes(window.location.port),i=Cp||e||t||n;vp.set(i),Ep&&!c(mp)&&mp.set(Ep),console.log("[config] Initialized:",{standaloneMode:i,buildStandalone:Cp,hasStoredRelay:e,isNonRelayPort:n,port:window.location.port,relayUrl:c(mp)||"(same origin)"})}();return new class extends ae{constructor(e){super(),le(this,e,dI,aI,s,{},null,[-1,-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); //# sourceMappingURL=bundle.js.map diff --git a/app/web/dist/bundle.js.map b/app/web/dist/bundle.js.map index d2c09bd..4761507 100644 --- a/app/web/dist/bundle.js.map +++ b/app/web/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"file":"bundle.js","sources":["../node_modules/svelte/internal/index.mjs","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/crypto.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/utils.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/_assert.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/sha256.js","../node_modules/nostr-tools/lib/esm/pool.js","../node_modules/nostr-tools/node_modules/@scure/base/lib/esm/index.js","../node_modules/@noble/ciphers/esm/_assert.js","../node_modules/@noble/ciphers/esm/utils.js","../node_modules/@noble/ciphers/esm/aes.js","../node_modules/@noble/ciphers/esm/_arx.js","../node_modules/@noble/ciphers/esm/chacha.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/hmac.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/hkdf.js","../node_modules/nostr-tools/lib/esm/index.js","../node_modules/nostr-tools/lib/esm/kinds.js","../node_modules/tslib/tslib.es6.mjs","../node_modules/rxjs/dist/esm5/internal/util/isFunction.js","../node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js","../node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js","../node_modules/rxjs/dist/esm5/internal/util/arrRemove.js","../node_modules/rxjs/dist/esm5/internal/Subscription.js","../node_modules/rxjs/dist/esm5/internal/config.js","../node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js","../node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js","../node_modules/rxjs/dist/esm5/internal/util/noop.js","../node_modules/rxjs/dist/esm5/internal/util/errorContext.js","../node_modules/rxjs/dist/esm5/internal/Subscriber.js","../node_modules/rxjs/dist/esm5/internal/symbol/observable.js","../node_modules/rxjs/dist/esm5/internal/util/identity.js","../node_modules/rxjs/dist/esm5/internal/Observable.js","../node_modules/rxjs/dist/esm5/internal/util/pipe.js","../node_modules/rxjs/dist/esm5/internal/util/lift.js","../node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js","../node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js","../node_modules/rxjs/dist/esm5/internal/Subject.js","../node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js","../node_modules/rxjs/dist/esm5/internal/ReplaySubject.js","../node_modules/rxjs/dist/esm5/internal/scheduler/Action.js","../node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js","../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js","../node_modules/rxjs/dist/esm5/internal/Scheduler.js","../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js","../node_modules/rxjs/dist/esm5/internal/scheduler/async.js","../node_modules/rxjs/dist/esm5/internal/observable/empty.js","../node_modules/rxjs/dist/esm5/internal/util/isScheduler.js","../node_modules/rxjs/dist/esm5/internal/util/args.js","../node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js","../node_modules/rxjs/dist/esm5/internal/util/isPromise.js","../node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js","../node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js","../node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js","../node_modules/rxjs/dist/esm5/internal/symbol/iterator.js","../node_modules/rxjs/dist/esm5/internal/util/isIterable.js","../node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js","../node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js","../node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js","../node_modules/rxjs/dist/esm5/internal/operators/observeOn.js","../node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js","../node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js","../node_modules/rxjs/dist/esm5/internal/observable/from.js","../node_modules/rxjs/dist/esm5/internal/observable/of.js","../node_modules/rxjs/dist/esm5/internal/operators/map.js","../node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js","../node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js","../node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js","../node_modules/rxjs/dist/esm5/internal/util/createObject.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js","../node_modules/rxjs/dist/esm5/internal/observable/concat.js","../node_modules/rxjs/dist/esm5/internal/operators/concatAll.js","../node_modules/rxjs/dist/esm5/internal/observable/defer.js","../node_modules/rxjs/dist/esm5/internal/observable/timer.js","../node_modules/rxjs/dist/esm5/internal/util/isDate.js","../node_modules/rxjs/dist/esm5/internal/observable/merge.js","../node_modules/rxjs/dist/esm5/internal/operators/filter.js","../node_modules/rxjs/dist/esm5/internal/operators/take.js","../node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js","../node_modules/rxjs/dist/esm5/internal/operators/endWith.js","../node_modules/rxjs/dist/esm5/internal/operators/finalize.js","../node_modules/rxjs/dist/esm5/internal/operators/merge.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeWith.js","../node_modules/rxjs/dist/esm5/internal/operators/scan.js","../node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js","../node_modules/rxjs/dist/esm5/internal/operators/share.js","../node_modules/rxjs/dist/esm5/internal/operators/switchMap.js","../node_modules/rxjs/dist/esm5/internal/operators/tap.js","../node_modules/applesauce-core/dist/helpers/tags.js","../node_modules/nostr-tools/lib/esm/pure.js","../node_modules/applesauce-core/dist/helpers/cache.js","../node_modules/nostr-tools/lib/esm/utils.js","../node_modules/applesauce-core/dist/helpers/event.js","../node_modules/applesauce-core/dist/helpers/time.js","../node_modules/applesauce-core/dist/helpers/expiration.js","../node_modules/nostr-tools/lib/esm/nip19.js","../node_modules/applesauce-core/dist/helpers/url.js","../node_modules/applesauce-core/dist/helpers/relays.js","../node_modules/applesauce-core/dist/helpers/string.js","../node_modules/@noble/hashes/esm/crypto.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/applesauce-core/dist/helpers/pointers.js","../node_modules/applesauce-core/dist/helpers/groups.js","../node_modules/applesauce-core/dist/helpers/encrypted-content.js","../node_modules/applesauce-core/dist/helpers/hidden-content.js","../node_modules/applesauce-core/dist/helpers/hidden-tags.js","../node_modules/applesauce-core/dist/helpers/event-tags.js","../node_modules/applesauce-core/dist/helpers/lru.js","../node_modules/ms/index.js","../node_modules/debug/src/common.js","../node_modules/debug/src/browser.js","../node_modules/applesauce-core/dist/logger.js","../node_modules/applesauce-core/dist/event-store/event-memory.js","../node_modules/hash-sum/hash-sum.js","../node_modules/applesauce-core/dist/helpers/filter.js","../node_modules/applesauce-core/dist/models/blossom.js","../node_modules/applesauce-core/dist/helpers/blossom.js","../node_modules/applesauce-core/dist/helpers/profile.js","../node_modules/applesauce-core/dist/helpers/json.js","../node_modules/light-bolt11-decoder/node_modules/@scure/base/lib/index.js","../node_modules/light-bolt11-decoder/bolt11.js","../node_modules/applesauce-core/dist/helpers/comment.js","../node_modules/applesauce-core/dist/helpers/contacts.js","../node_modules/applesauce-core/dist/helpers/encrypted-content-cache.js","../node_modules/applesauce-core/dist/helpers/event-cache.js","../node_modules/applesauce-core/dist/helpers/lnurl.js","../node_modules/applesauce-core/dist/helpers/mailboxes.js","../node_modules/applesauce-core/dist/helpers/mutes.js","../node_modules/applesauce-core/dist/helpers/reports.js","../node_modules/applesauce-core/dist/helpers/threading.js","../node_modules/applesauce-core/dist/observable/claim-events.js","../node_modules/applesauce-core/dist/observable/claim-latest.js","../node_modules/applesauce-core/dist/observable/defined.js","../node_modules/applesauce-core/dist/observable/with-immediate-value.js","../node_modules/applesauce-core/dist/models/common.js","../node_modules/rxjs/dist/esm5/internal/operators/ignoreElements.js","../node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js","../node_modules/rxjs/dist/esm5/internal/operators/repeat.js","../node_modules/applesauce-core/dist/observable/watch-event-updates.js","../node_modules/applesauce-core/dist/models/contacts.js","../node_modules/applesauce-core/dist/models/comments.js","../node_modules/applesauce-core/dist/models/mailboxes.js","../node_modules/applesauce-core/dist/models/mutes.js","../node_modules/applesauce-core/dist/models/profile.js","../node_modules/applesauce-core/dist/models/reactions.js","../node_modules/applesauce-core/dist/models/thread.js","../node_modules/applesauce-core/dist/event-store/model-mixin.js","../node_modules/applesauce-core/dist/event-store/event-store.js","../node_modules/applesauce-core/dist/helpers/delete.js","../node_modules/applesauce-core/dist/promise/deferred.js","../node_modules/applesauce-signers/dist/signers/amber-clipboard-signer.js","../node_modules/applesauce-signers/dist/helpers/nostr-connect.js","../node_modules/applesauce-signers/dist/signers/private-key-signer.js","../node_modules/applesauce-signers/node_modules/@noble/secp256k1/lib/esm/index.js","../node_modules/applesauce-signers/node_modules/@scure/base/lib/esm/index.js","../node_modules/applesauce-signers/dist/signers/serial-port-signer.js","../src/constants.js","../src/nostr.js","../node_modules/hash-wasm/dist/index.esm.js","../src/nsec-crypto.js","../src/LoginModal.svelte","../src/ManagedACL.svelte","../src/Header.svelte","../src/Sidebar.svelte","../src/ExportView.svelte","../src/ImportView.svelte","../src/helpers.tsx","../src/FilterBuilder.svelte","../src/EventsView.svelte","../src/eventKinds.js","../src/EventTemplateSelector.svelte","../src/ComposeView.svelte","../src/SprocketView.svelte","../src/PolicyView.svelte","../src/kindCategories.js","../src/CurationView.svelte","../src/BlossomView.svelte","../src/LogView.svelte","../src/api.js","../src/utils.js","../src/RelayConnectView.svelte","../src/FilterDisplay.svelte","../src/websocket-auth.js","../src/App.svelte","../src/main.js"],"sourcesContent":["function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\nfunction is_promise(value) {\n return !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nlet src_url_equal_anchor;\nfunction src_url_equal(element_src, url) {\n if (!src_url_equal_anchor) {\n src_url_equal_anchor = document.createElement('a');\n }\n src_url_equal_anchor.href = url;\n return element_src === src_url_equal_anchor.href;\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction is_empty(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction validate_store(store, name) {\n if (store != null && typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, $$scope, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n return definition[1] && fn\n ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))\n : $$scope.ctx;\n}\nfunction get_slot_changes(definition, $$scope, dirty, fn) {\n if (definition[2] && fn) {\n const lets = definition[2](fn(dirty));\n if ($$scope.dirty === undefined) {\n return lets;\n }\n if (typeof lets === 'object') {\n const merged = [];\n const len = Math.max($$scope.dirty.length, lets.length);\n for (let i = 0; i < len; i += 1) {\n merged[i] = $$scope.dirty[i] | lets[i];\n }\n return merged;\n }\n return $$scope.dirty | lets;\n }\n return $$scope.dirty;\n}\nfunction update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {\n if (slot_changes) {\n const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n slot.p(slot_context, slot_changes);\n }\n}\nfunction update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {\n const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\nfunction get_all_dirty_from_scope($$scope) {\n if ($$scope.ctx.length > 32) {\n const dirty = [];\n const length = $$scope.ctx.length / 32;\n for (let i = 0; i < length; i++) {\n dirty[i] = -1;\n }\n return dirty;\n }\n return -1;\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction compute_rest_props(props, keys) {\n const rest = {};\n keys = new Set(keys);\n for (const k in props)\n if (!keys.has(k) && k[0] !== '$')\n rest[k] = props[k];\n return rest;\n}\nfunction compute_slots(slots) {\n const result = {};\n for (const key in slots) {\n result[key] = true;\n }\n return result;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value) {\n store.set(value);\n return ret;\n}\nconst has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\nfunction action_destroyer(action_result) {\n return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\nfunction split_css_unit(value) {\n const split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];\n}\nconst contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nfunction run_tasks(now) {\n tasks.forEach(task => {\n if (!task.c(now)) {\n tasks.delete(task);\n task.f();\n }\n });\n if (tasks.size !== 0)\n raf(run_tasks);\n}\n/**\n * For testing purposes only!\n */\nfunction clear_loops() {\n tasks.clear();\n}\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n */\nfunction loop(callback) {\n let task;\n if (tasks.size === 0)\n raf(run_tasks);\n return {\n promise: new Promise(fulfill => {\n tasks.add(task = { c: callback, f: fulfill });\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nconst globals = (typeof window !== 'undefined'\n ? window\n : typeof globalThis !== 'undefined'\n ? globalThis\n : global);\n\n/**\n * Resize observer singleton.\n * One listener per element only!\n * https://groups.google.com/a/chromium.org/g/blink-dev/c/z6ienONUb5A/m/F5-VcUZtBAAJ\n */\nclass ResizeObserverSingleton {\n constructor(options) {\n this.options = options;\n this._listeners = 'WeakMap' in globals ? new WeakMap() : undefined;\n }\n observe(element, listener) {\n this._listeners.set(element, listener);\n this._getObserver().observe(element, this.options);\n return () => {\n this._listeners.delete(element);\n this._observer.unobserve(element); // this line can probably be removed\n };\n }\n _getObserver() {\n var _a;\n return (_a = this._observer) !== null && _a !== void 0 ? _a : (this._observer = new ResizeObserver((entries) => {\n var _a;\n for (const entry of entries) {\n ResizeObserverSingleton.entries.set(entry.target, entry);\n (_a = this._listeners.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry);\n }\n }));\n }\n}\n// Needs to be written like this to pass the tree-shake-test\nResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined;\n\n// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM\n// at the end of hydration without touching the remaining nodes.\nlet is_hydrating = false;\nfunction start_hydrating() {\n is_hydrating = true;\n}\nfunction end_hydrating() {\n is_hydrating = false;\n}\nfunction upper_bound(low, high, key, value) {\n // Return first index of value larger than input value in the range [low, high)\n while (low < high) {\n const mid = low + ((high - low) >> 1);\n if (key(mid) <= value) {\n low = mid + 1;\n }\n else {\n high = mid;\n }\n }\n return low;\n}\nfunction init_hydrate(target) {\n if (target.hydrate_init)\n return;\n target.hydrate_init = true;\n // We know that all children have claim_order values since the unclaimed have been detached if target is not \n let children = target.childNodes;\n // If target is , there may be children without claim_order\n if (target.nodeName === 'HEAD') {\n const myChildren = [];\n for (let i = 0; i < children.length; i++) {\n const node = children[i];\n if (node.claim_order !== undefined) {\n myChildren.push(node);\n }\n }\n children = myChildren;\n }\n /*\n * Reorder claimed children optimally.\n * We can reorder claimed children optimally by finding the longest subsequence of\n * nodes that are already claimed in order and only moving the rest. The longest\n * subsequence of nodes that are claimed in order can be found by\n * computing the longest increasing subsequence of .claim_order values.\n *\n * This algorithm is optimal in generating the least amount of reorder operations\n * possible.\n *\n * Proof:\n * We know that, given a set of reordering operations, the nodes that do not move\n * always form an increasing subsequence, since they do not move among each other\n * meaning that they must be already ordered among each other. Thus, the maximal\n * set of nodes that do not move form a longest increasing subsequence.\n */\n // Compute longest increasing subsequence\n // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n const m = new Int32Array(children.length + 1);\n // Predecessor indices + 1\n const p = new Int32Array(children.length);\n m[0] = -1;\n let longest = 0;\n for (let i = 0; i < children.length; i++) {\n const current = children[i].claim_order;\n // Find the largest subsequence length such that it ends in a value less than our current value\n // upper_bound returns first greater value, so we subtract one\n // with fast path for when we are on the current longest subsequence\n const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;\n p[i] = m[seqLen] + 1;\n const newLen = seqLen + 1;\n // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n m[newLen] = i;\n longest = Math.max(newLen, longest);\n }\n // The longest increasing subsequence of nodes (initially reversed)\n const lis = [];\n // The rest of the nodes, nodes that will be moved\n const toMove = [];\n let last = children.length - 1;\n for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n lis.push(children[cur - 1]);\n for (; last >= cur; last--) {\n toMove.push(children[last]);\n }\n last--;\n }\n for (; last >= 0; last--) {\n toMove.push(children[last]);\n }\n lis.reverse();\n // We sort the nodes being moved to guarantee that their insertion order matches the claim order\n toMove.sort((a, b) => a.claim_order - b.claim_order);\n // Finally, we move the nodes\n for (let i = 0, j = 0; i < toMove.length; i++) {\n while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {\n j++;\n }\n const anchor = j < lis.length ? lis[j] : null;\n target.insertBefore(toMove[i], anchor);\n }\n}\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction append_styles(target, style_sheet_id, styles) {\n const append_styles_to = get_root_for_style(target);\n if (!append_styles_to.getElementById(style_sheet_id)) {\n const style = element('style');\n style.id = style_sheet_id;\n style.textContent = styles;\n append_stylesheet(append_styles_to, style);\n }\n}\nfunction get_root_for_style(node) {\n if (!node)\n return document;\n const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n if (root && root.host) {\n return root;\n }\n return node.ownerDocument;\n}\nfunction append_empty_stylesheet(node) {\n const style_element = element('style');\n append_stylesheet(get_root_for_style(node), style_element);\n return style_element.sheet;\n}\nfunction append_stylesheet(node, style) {\n append(node.head || node, style);\n return style.sheet;\n}\nfunction append_hydration(target, node) {\n if (is_hydrating) {\n init_hydrate(target);\n if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentNode !== target))) {\n target.actual_end_child = target.firstChild;\n }\n // Skip nodes of undefined ordering\n while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {\n target.actual_end_child = target.actual_end_child.nextSibling;\n }\n if (node !== target.actual_end_child) {\n // We only insert if the ordering of this node should be modified or the parent node is not target\n if (node.claim_order !== undefined || node.parentNode !== target) {\n target.insertBefore(node, target.actual_end_child);\n }\n }\n else {\n target.actual_end_child = node.nextSibling;\n }\n }\n else if (node.parentNode !== target || node.nextSibling !== null) {\n target.appendChild(node);\n }\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction insert_hydration(target, node, anchor) {\n if (is_hydrating && !anchor) {\n append_hydration(target, node);\n }\n else if (node.parentNode !== target || node.nextSibling != anchor) {\n target.insertBefore(node, anchor || null);\n }\n}\nfunction detach(node) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunction element_is(name, is) {\n return document.createElement(name, { is });\n}\nfunction object_without_properties(obj, exclude) {\n const target = {};\n for (const k in obj) {\n if (has_prop(obj, k)\n // @ts-ignore\n && exclude.indexOf(k) === -1) {\n // @ts-ignore\n target[k] = obj[k];\n }\n }\n return target;\n}\nfunction svg_element(name) {\n return document.createElementNS('http://www.w3.org/2000/svg', name);\n}\nfunction text(data) {\n return document.createTextNode(data);\n}\nfunction space() {\n return text(' ');\n}\nfunction empty() {\n return text('');\n}\nfunction comment(content) {\n return document.createComment(content);\n}\nfunction listen(node, event, handler, options) {\n node.addEventListener(event, handler, options);\n return () => node.removeEventListener(event, handler, options);\n}\nfunction prevent_default(fn) {\n return function (event) {\n event.preventDefault();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_propagation(fn) {\n return function (event) {\n event.stopPropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_immediate_propagation(fn) {\n return function (event) {\n event.stopImmediatePropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction self(fn) {\n return function (event) {\n // @ts-ignore\n if (event.target === this)\n fn.call(this, event);\n };\n}\nfunction trusted(fn) {\n return function (event) {\n // @ts-ignore\n if (event.isTrusted)\n fn.call(this, event);\n };\n}\nfunction attr(node, attribute, value) {\n if (value == null)\n node.removeAttribute(attribute);\n else if (node.getAttribute(attribute) !== value)\n node.setAttribute(attribute, value);\n}\n/**\n * List of attributes that should always be set through the attr method,\n * because updating them through the property setter doesn't work reliably.\n * In the example of `width`/`height`, the problem is that the setter only\n * accepts numeric values, but the attribute can also be set to a string like `50%`.\n * If this list becomes too big, rethink this approach.\n */\nconst always_set_through_set_attribute = ['width', 'height'];\nfunction set_attributes(node, attributes) {\n // @ts-ignore\n const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n for (const key in attributes) {\n if (attributes[key] == null) {\n node.removeAttribute(key);\n }\n else if (key === 'style') {\n node.style.cssText = attributes[key];\n }\n else if (key === '__value') {\n node.value = node[key] = attributes[key];\n }\n else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {\n node[key] = attributes[key];\n }\n else {\n attr(node, key, attributes[key]);\n }\n }\n}\nfunction set_svg_attributes(node, attributes) {\n for (const key in attributes) {\n attr(node, key, attributes[key]);\n }\n}\nfunction set_custom_element_data_map(node, data_map) {\n Object.keys(data_map).forEach((key) => {\n set_custom_element_data(node, key, data_map[key]);\n });\n}\nfunction set_custom_element_data(node, prop, value) {\n if (prop in node) {\n node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n }\n else {\n attr(node, prop, value);\n }\n}\nfunction set_dynamic_element_data(tag) {\n return (/-/.test(tag)) ? set_custom_element_data_map : set_attributes;\n}\nfunction xlink_attr(node, attribute, value) {\n node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\nfunction get_binding_group_value(group, __value, checked) {\n const value = new Set();\n for (let i = 0; i < group.length; i += 1) {\n if (group[i].checked)\n value.add(group[i].__value);\n }\n if (!checked) {\n value.delete(__value);\n }\n return Array.from(value);\n}\nfunction init_binding_group(group) {\n let _inputs;\n return {\n /* push */ p(...inputs) {\n _inputs = inputs;\n _inputs.forEach(input => group.push(input));\n },\n /* remove */ r() {\n _inputs.forEach(input => group.splice(group.indexOf(input), 1));\n }\n };\n}\nfunction init_binding_group_dynamic(group, indexes) {\n let _group = get_binding_group(group);\n let _inputs;\n function get_binding_group(group) {\n for (let i = 0; i < indexes.length; i++) {\n group = group[indexes[i]] = group[indexes[i]] || [];\n }\n return group;\n }\n function push() {\n _inputs.forEach(input => _group.push(input));\n }\n function remove() {\n _inputs.forEach(input => _group.splice(_group.indexOf(input), 1));\n }\n return {\n /* update */ u(new_indexes) {\n indexes = new_indexes;\n const new_group = get_binding_group(group);\n if (new_group !== _group) {\n remove();\n _group = new_group;\n push();\n }\n },\n /* push */ p(...inputs) {\n _inputs = inputs;\n push();\n },\n /* remove */ r: remove\n };\n}\nfunction to_number(value) {\n return value === '' ? null : +value;\n}\nfunction time_ranges_to_array(ranges) {\n const array = [];\n for (let i = 0; i < ranges.length; i += 1) {\n array.push({ start: ranges.start(i), end: ranges.end(i) });\n }\n return array;\n}\nfunction children(element) {\n return Array.from(element.childNodes);\n}\nfunction init_claim_info(nodes) {\n if (nodes.claim_info === undefined) {\n nodes.claim_info = { last_index: 0, total_claimed: 0 };\n }\n}\nfunction claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {\n // Try to find nodes in an order such that we lengthen the longest increasing subsequence\n init_claim_info(nodes);\n const resultNode = (() => {\n // We first try to find an element after the previous one\n for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n return node;\n }\n }\n // Otherwise, we try to find one before\n // We iterate in reverse so that we don't go too far back\n for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n else if (replacement === undefined) {\n // Since we spliced before the last_index, we decrease it\n nodes.claim_info.last_index--;\n }\n return node;\n }\n }\n // If we can't find any matching node, we create a new one\n return createNode();\n })();\n resultNode.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n return resultNode;\n}\nfunction claim_element_base(nodes, name, attributes, create_element) {\n return claim_node(nodes, (node) => node.nodeName === name, (node) => {\n const remove = [];\n for (let j = 0; j < node.attributes.length; j++) {\n const attribute = node.attributes[j];\n if (!attributes[attribute.name]) {\n remove.push(attribute.name);\n }\n }\n remove.forEach(v => node.removeAttribute(v));\n return undefined;\n }, () => create_element(name));\n}\nfunction claim_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, element);\n}\nfunction claim_svg_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, svg_element);\n}\nfunction claim_text(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 3, (node) => {\n const dataStr = '' + data;\n if (node.data.startsWith(dataStr)) {\n if (node.data.length !== dataStr.length) {\n return node.splitText(dataStr.length);\n }\n }\n else {\n node.data = dataStr;\n }\n }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n );\n}\nfunction claim_space(nodes) {\n return claim_text(nodes, ' ');\n}\nfunction claim_comment(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 8, (node) => {\n node.data = '' + data;\n return undefined;\n }, () => comment(data), true);\n}\nfunction find_comment(nodes, text, start) {\n for (let i = start; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n return i;\n }\n }\n return nodes.length;\n}\nfunction claim_html_tag(nodes, is_svg) {\n // find html opening tag\n const start_index = find_comment(nodes, 'HTML_TAG_START', 0);\n const end_index = find_comment(nodes, 'HTML_TAG_END', start_index);\n if (start_index === end_index) {\n return new HtmlTagHydration(undefined, is_svg);\n }\n init_claim_info(nodes);\n const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n detach(html_tag_nodes[0]);\n detach(html_tag_nodes[html_tag_nodes.length - 1]);\n const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n for (const n of claimed_nodes) {\n n.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n }\n return new HtmlTagHydration(claimed_nodes, is_svg);\n}\nfunction set_data(text, data) {\n data = '' + data;\n if (text.data === data)\n return;\n text.data = data;\n}\nfunction set_data_contenteditable(text, data) {\n data = '' + data;\n if (text.wholeText === data)\n return;\n text.data = data;\n}\nfunction set_data_maybe_contenteditable(text, data, attr_value) {\n if (~contenteditable_truthy_values.indexOf(attr_value)) {\n set_data_contenteditable(text, data);\n }\n else {\n set_data(text, data);\n }\n}\nfunction set_input_value(input, value) {\n input.value = value == null ? '' : value;\n}\nfunction set_input_type(input, type) {\n try {\n input.type = type;\n }\n catch (e) {\n // do nothing\n }\n}\nfunction set_style(node, key, value, important) {\n if (value == null) {\n node.style.removeProperty(key);\n }\n else {\n node.style.setProperty(key, value, important ? 'important' : '');\n }\n}\nfunction select_option(select, value, mounting) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n if (option.__value === value) {\n option.selected = true;\n return;\n }\n }\n if (!mounting || value !== undefined) {\n select.selectedIndex = -1; // no option should be selected\n }\n}\nfunction select_options(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n option.selected = ~value.indexOf(option.__value);\n }\n}\nfunction select_value(select) {\n const selected_option = select.querySelector(':checked');\n return selected_option && selected_option.__value;\n}\nfunction select_multiple_value(select) {\n return [].map.call(select.querySelectorAll(':checked'), option => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\nlet crossorigin;\nfunction is_crossorigin() {\n if (crossorigin === undefined) {\n crossorigin = false;\n try {\n if (typeof window !== 'undefined' && window.parent) {\n void window.parent.document;\n }\n }\n catch (error) {\n crossorigin = true;\n }\n }\n return crossorigin;\n}\nfunction add_iframe_resize_listener(node, fn) {\n const computed_style = getComputedStyle(node);\n if (computed_style.position === 'static') {\n node.style.position = 'relative';\n }\n const iframe = element('iframe');\n iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n 'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');\n iframe.setAttribute('aria-hidden', 'true');\n iframe.tabIndex = -1;\n const crossorigin = is_crossorigin();\n let unsubscribe;\n if (crossorigin) {\n iframe.src = \"data:text/html,\";\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n // make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n // see https://github.com/sveltejs/svelte/issues/4233\n fn();\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nconst resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'content-box' });\nconst resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'border-box' });\nconst resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'device-pixel-content-box' });\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, bubbles, cancelable, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nfunction head_selector(nodeId, head) {\n const result = [];\n let started = 0;\n for (const node of head.childNodes) {\n if (node.nodeType === 8 /* comment node */) {\n const comment = node.textContent.trim();\n if (comment === `HEAD_${nodeId}_END`) {\n started -= 1;\n result.push(node);\n }\n else if (comment === `HEAD_${nodeId}_START`) {\n started += 1;\n result.push(node);\n }\n }\n else if (started > 0) {\n result.push(node);\n }\n }\n return result;\n}\nclass HtmlTag {\n constructor(is_svg = false) {\n this.is_svg = false;\n this.is_svg = is_svg;\n this.e = this.n = null;\n }\n c(html) {\n this.h(html);\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n if (this.is_svg)\n this.e = svg_element(target.nodeName);\n /** #7364 target for