diff --git a/.gitignore b/.gitignore index 0e303ed..91c2309 100644 --- a/.gitignore +++ b/.gitignore @@ -99,6 +99,13 @@ cmd/benchmark/data !.github/** !.github/workflows/** !app/web/dist/** +!app/web/dist/*.js +!app/web/dist/*.js.map +!app/web/dist/*.css +!app/web/dist/*.html +!app/web/dist/*.ico +!app/web/dist/*.png +!app/web/dist/*.svg # ...even if they are in subdirectories !*/ /blocklist.json diff --git a/app/web/dist/bundle.css b/app/web/dist/bundle.css index 3fcaa80..efa9d37 100644 --- a/app/web/dist/bundle.css +++ b/app/web/dist/bundle.css @@ -1,8 +1,8 @@ .modal-overlay.svelte-1wl3v5c.svelte-1wl3v5c{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-1wl3v5c.svelte-1wl3v5c{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-1wl3v5c.svelte-1wl3v5c{display:flex;justify-content:space-between;align-items:center;padding:20px;border-bottom:1px solid var(--border-color)}.modal-header.svelte-1wl3v5c h2.svelte-1wl3v5c{margin:0;color:var(--text-color);font-size:1.5rem}.close-btn.svelte-1wl3v5c.svelte-1wl3v5c{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-1wl3v5c.svelte-1wl3v5c:hover{background-color:var(--tab-hover-bg)}.tab-container.svelte-1wl3v5c.svelte-1wl3v5c{padding:20px}.tabs.svelte-1wl3v5c.svelte-1wl3v5c{display:flex;border-bottom:1px solid var(--border-color);margin-bottom:20px}.tab-btn.svelte-1wl3v5c.svelte-1wl3v5c{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-1wl3v5c.svelte-1wl3v5c:hover{background-color:var(--tab-hover-bg)}.tab-btn.active.svelte-1wl3v5c.svelte-1wl3v5c{border-bottom-color:var(--primary);color:var(--primary)}.tab-content.svelte-1wl3v5c.svelte-1wl3v5c{min-height:200px}.extension-login.svelte-1wl3v5c.svelte-1wl3v5c,.nsec-login.svelte-1wl3v5c.svelte-1wl3v5c{display:flex;flex-direction:column;gap:16px}.extension-login.svelte-1wl3v5c p.svelte-1wl3v5c,.nsec-login.svelte-1wl3v5c p.svelte-1wl3v5c{margin:0;color:var(--text-color);line-height:1.5}.login-extension-btn.svelte-1wl3v5c.svelte-1wl3v5c,.login-nsec-btn.svelte-1wl3v5c.svelte-1wl3v5c{padding:12px 24px;background:var(--primary);color:white;border:none;border-radius:6px;cursor:pointer;font-size:1rem;transition:background-color 0.2s}.login-extension-btn.svelte-1wl3v5c.svelte-1wl3v5c:hover:not(:disabled),.login-nsec-btn.svelte-1wl3v5c.svelte-1wl3v5c:hover:not(:disabled){background:#00acc1}.login-extension-btn.svelte-1wl3v5c.svelte-1wl3v5c:disabled,.login-nsec-btn.svelte-1wl3v5c.svelte-1wl3v5c:disabled{background:#ccc;cursor:not-allowed}.nsec-input.svelte-1wl3v5c.svelte-1wl3v5c{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-1wl3v5c.svelte-1wl3v5c:focus{outline:none;border-color:var(--primary)}.message.svelte-1wl3v5c.svelte-1wl3v5c{padding:10px;border-radius:4px;margin-top:16px;text-align:center}.error-message.svelte-1wl3v5c.svelte-1wl3v5c{background:#ffebee;color:#c62828;border:1px solid #ffcdd2}.success-message.svelte-1wl3v5c.svelte-1wl3v5c{background:#e8f5e8;color:#2e7d32;border:1px solid #c8e6c9}.modal.dark-theme.svelte-1wl3v5c .error-message.svelte-1wl3v5c{background:#4a2c2a;color:#ffcdd2;border:1px solid #6d4c41}.modal.dark-theme.svelte-1wl3v5c .success-message.svelte-1wl3v5c{background:#2e4a2e;color:#a5d6a7;border:1px solid #4caf50} .header.svelte-1smaj3x.svelte-1smaj3x{margin-bottom:30px}.header.svelte-1smaj3x h2.svelte-1smaj3x{margin:0 0 10px 0;color:var(--text-color)}.header.svelte-1smaj3x p.svelte-1smaj3x{margin:0;color:var(--text-color);opacity:0.8}.owner-only-notice.svelte-1smaj3x.svelte-1smaj3x{margin-top:10px;padding:8px 12px;background-color:#fff3cd;border:1px solid #ffeaa7;border-radius:4px;color:#856404;font-size:0.9em}.message.svelte-1smaj3x.svelte-1smaj3x{padding:10px 15px;border-radius:4px;margin-bottom:20px}.message.success.svelte-1smaj3x.svelte-1smaj3x{background-color:#d4edda;color:#155724;border:1px solid #c3e6cb}.message.error.svelte-1smaj3x.svelte-1smaj3x{background-color:#f8d7da;color:#721c24;border:1px solid #f5c6cb}.message.info.svelte-1smaj3x.svelte-1smaj3x{background-color:#d1ecf1;color:#0c5460;border:1px solid #bee5eb}.tabs.svelte-1smaj3x.svelte-1smaj3x{display:flex;border-bottom:1px solid var(--border-color);margin-bottom:20px}.tab.svelte-1smaj3x.svelte-1smaj3x{padding:10px 20px;border:none;background:none;cursor:pointer;border-bottom:2px solid transparent;transition:all 0.2s;color:var(--text-color)}.tab.svelte-1smaj3x.svelte-1smaj3x:hover{background-color:var(--button-hover-bg)}.tab.active.svelte-1smaj3x.svelte-1smaj3x{border-bottom-color:#007bff;color:#007bff}.tab-content.svelte-1smaj3x.svelte-1smaj3x{min-height:400px}.section.svelte-1smaj3x.svelte-1smaj3x{margin-bottom:30px}.section.svelte-1smaj3x h3.svelte-1smaj3x{margin:0 0 15px 0;color:var(--text-color)}.add-form.svelte-1smaj3x.svelte-1smaj3x{display:flex;gap:10px;margin-bottom:20px;flex-wrap:wrap}.add-form.svelte-1smaj3x input.svelte-1smaj3x{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-1smaj3x button.svelte-1smaj3x{padding:8px 16px;background-color:#007bff;color:white;border:none;border-radius:4px;cursor:pointer}.add-form.svelte-1smaj3x button.svelte-1smaj3x:disabled{background-color:#6c757d;cursor:not-allowed}.list.svelte-1smaj3x.svelte-1smaj3x{border:1px solid var(--border-color);border-radius:4px;max-height:300px;overflow-y:auto;background:var(--bg-color)}.list-item.svelte-1smaj3x.svelte-1smaj3x{padding:10px 15px;border-bottom:1px solid var(--border-color);display:flex;align-items:center;gap:15px;color:var(--text-color)}.list-item.svelte-1smaj3x.svelte-1smaj3x:last-child{border-bottom:none}.pubkey.svelte-1smaj3x.svelte-1smaj3x,.event-id.svelte-1smaj3x.svelte-1smaj3x,.ip.svelte-1smaj3x.svelte-1smaj3x,.kind.svelte-1smaj3x.svelte-1smaj3x{font-family:monospace;font-size:0.9em;color:var(--text-color)}.reason.svelte-1smaj3x.svelte-1smaj3x{color:var(--text-color);opacity:0.7;font-style:italic}.remove-btn.svelte-1smaj3x.svelte-1smaj3x{padding:4px 8px;background-color:#dc3545;color:white;border:none;border-radius:3px;cursor:pointer;font-size:0.8em}.actions.svelte-1smaj3x.svelte-1smaj3x{display:flex;gap:5px;margin-left:auto}.actions.svelte-1smaj3x button.svelte-1smaj3x{padding:4px 8px;border:none;border-radius:3px;cursor:pointer;font-size:0.8em}.actions.svelte-1smaj3x button.svelte-1smaj3x:first-child{background-color:#28a745;color:white}.actions.svelte-1smaj3x button.svelte-1smaj3x:last-child{background-color:#dc3545;color:white}.config-form.svelte-1smaj3x.svelte-1smaj3x{display:flex;flex-direction:column;gap:20px}.form-group.svelte-1smaj3x.svelte-1smaj3x{display:flex;flex-direction:column;gap:10px}.form-group.svelte-1smaj3x label.svelte-1smaj3x{font-weight:bold;color:var(--text-color)}.form-group.svelte-1smaj3x input.svelte-1smaj3x,.form-group.svelte-1smaj3x textarea.svelte-1smaj3x{padding:8px 12px;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color)}.form-group.svelte-1smaj3x textarea.svelte-1smaj3x{min-height:80px;resize:vertical}.config-actions.svelte-1smaj3x.svelte-1smaj3x{margin-bottom:20px;padding:10px;background-color:var(--button-bg);border-radius:4px}.refresh-btn.svelte-1smaj3x.svelte-1smaj3x{padding:8px 16px;background-color:#28a745;color:white;border:none;border-radius:4px;cursor:pointer;font-size:0.9em}.refresh-btn.svelte-1smaj3x.svelte-1smaj3x:hover:not(:disabled){background-color:#218838}.refresh-btn.svelte-1smaj3x.svelte-1smaj3x:disabled{background-color:#6c757d;cursor:not-allowed}.config-update-section.svelte-1smaj3x.svelte-1smaj3x{margin-top:20px;padding:15px;background-color:var(--button-bg);border-radius:6px;text-align:center}.update-all-btn.svelte-1smaj3x.svelte-1smaj3x{padding:12px 24px;background-color:#28a745;color:white;border:none;border-radius:6px;cursor:pointer;font-size:1em;font-weight:600;min-width:200px}.update-all-btn.svelte-1smaj3x.svelte-1smaj3x:hover:not(:disabled){background-color:#218838;transform:translateY(-1px);box-shadow:0 2px 4px rgba(0, 0, 0, 0.1)}.update-all-btn.svelte-1smaj3x.svelte-1smaj3x:disabled{background-color:#6c757d;cursor:not-allowed;transform:none;box-shadow:none}.no-items.svelte-1smaj3x.svelte-1smaj3x{padding:20px;text-align:center;color:var(--text-color);opacity:0.7;font-style:italic} -body{margin:0;padding:0;--bg-color:#ddd;--header-bg:#eee;--border-color:#dee2e6;--text-color:#444444;--input-border:#ccc;--button-bg:#ddd;--button-hover-bg:#eee;--primary:#00bcd4;--warning:#ff3e00;--tab-inactive-bg:#bbb}body.dark-theme{--bg-color:#263238;--header-bg:#1e272c;--border-color:#404040;--text-color:#ffffff;--input-border:#555;--button-bg:#263238;--button-hover-bg:#1e272c;--primary:#00bcd4;--warning:#ff3e00;--tab-inactive-bg:#1a1a1a}.main-header.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{height:3em;background-color:var(--header-bg);position:fixed;top:0;left:0;right:0;z-index:1000;color:var(--text-color)}.header-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{height:100%;display:flex;align-items:center;padding:0;gap:0}.logo.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{height:2.5em;width:2.5em;object-fit:contain;flex-shrink:0;transition:opacity 0.2s ease}.logo.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{content:url("/favicon.png")}.header-title.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1;height:100%;display:flex;align-items:center;gap:0;padding:0 1rem}.app-title.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:1em;font-weight:600;color:var(--text-color);display:flex;align-items:center;gap:0.5rem}.permission-badge.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.7em;font-weight:500;padding:0.2em 0.5em;border-radius:0.3em;background-color:var(--primary);color:white;text-transform:uppercase;letter-spacing:0.05em}.search-input-container.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1;height:100%;display:flex;align-items:center;padding:0 1rem}.search-input.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:100%;height:2em;padding:0.5rem;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:1em;outline:none}.search-input.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:focus{border-color:var(--primary)}.search-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.search-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background-color:var(--button-bg)}.theme-toggle-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.theme-toggle-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background-color:var(--button-bg)}.login-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:0.5em 1em;border:none;border-radius:6px;background-color:#4caf50;color:white;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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background-color:#45a049}.acl-mode-warning.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:1em;background-color:#fff3cd;border:1px solid #ffeaa7;border-radius:8px;color:#856404;margin:20px 0}.acl-mode-warning.svelte-1a66x6i h3.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 15px 0;color:#856404}.acl-mode-warning.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:10px 0;line-height:1.5}.acl-mode-warning.svelte-1a66x6i code.svelte-1a66x6i.svelte-1a66x6i{background-color:#f8f9fa;padding:2px 6px;border-radius:4px;font-family:monospace;color:#495057}.app-container.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;margin-top:3em;height:calc(100vh - 3em)}.sidebar.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:fixed;left:0;top:3em;bottom:0;width:200px;background-color:var(--header-bg);color:var(--text-color);z-index:100}.sidebar-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{height:100%;display:flex;flex-direction:column;padding:0}.tabs.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-direction:column}.tab.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{height:3em;display:flex;align-items:center;padding:0 1rem;cursor:pointer;border:none;background:transparent;color:var(--text-color);transition:background-color 0.2s ease;gap:0.75rem;text-align:left;width:100%}.tab.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background-color:var(--bg-color)}.tab.active.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:var(--bg-color)}.tab-icon.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:1.2em;flex-shrink:0;width:1.5em;text-align:center}.tab-label.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.9em;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}.tab-close-icon.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{cursor:pointer;transition:opacity 0.2s;font-size:0.8em;margin-left:auto;padding:0.25rem;border-radius:0.25rem;flex-shrink:0}.tab-close-icon.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{opacity:0.7;background-color:var(--warning);color:white}.main-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:fixed;left:200px;top:3em;right:0;bottom:0;padding:1em;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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{text-align:center}.welcome-message.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{font-size:1.2rem}.sprocket-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:100%;max-width:1200px;margin:0;padding:20px;background:var(--header-bg);color:var(--text-color);border-radius:8px}.sprocket-section.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}.sprocket-controls.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;gap:0.5rem}.sprocket-upload-section.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin-bottom:1rem;padding:1rem;background-color:var(--bg-color);border-radius:6px;border:1px solid var(--border-color)}.sprocket-upload-section.svelte-1a66x6i h4.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 0.75rem 0;color:var(--text-color);font-size:1rem;font-weight:500}.upload-controls.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;gap:0.5rem;align-items:center}.upload-controls.svelte-1a66x6i input[type="file"].svelte-1a66x6i.svelte-1a66x6i{flex:1;padding:0.5rem;border:1px solid var(--border-color);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:0.9rem}.sprocket-btn.upload-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#8b5cf6;color:white}.sprocket-btn.upload-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background-color:#7c3aed}.sprocket-status.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;gap:1rem;margin-bottom:1rem;padding:0.75rem;background-color:var(--bg-color);border-radius:6px;border:1px solid var(--border-color)}.status-item.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-direction:column;gap:0.25rem}.status-label.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.8rem;color:var(--text-muted);font-weight:500}.status-value.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.9rem;font-weight:600}.status-value.running.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{color:#22c55e}.script-editor-container.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin-bottom:1rem}.script-editor.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:100%;height:300px;padding:1rem;border:1px solid var(--border-color);border-radius:6px;background-color:var(--bg-color);color:var(--text-color);font-family:"Monaco", "Menlo", "Ubuntu Mono", monospace;font-size:0.9rem;line-height:1.4;resize:vertical;outline:none}.script-editor.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:focus{border-color:var(--primary-color);box-shadow:0 0 0 2px rgba(59, 130, 246, 0.1)}.script-editor.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:disabled{opacity:0.6;cursor:not-allowed}.script-actions.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;gap:0.5rem;margin-bottom:1rem}.sprocket-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:0.5rem 1rem;border:none;border-radius:6px;font-size:0.9rem;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;gap:0.5rem}.sprocket-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:disabled{opacity:0.6;cursor:not-allowed}.sprocket-btn.save-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#22c55e;color:white}.sprocket-btn.save-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background-color:#16a34a}.sprocket-btn.load-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#3b82f6;color:white}.sprocket-btn.load-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background-color:#2563eb}.sprocket-btn.restart-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#f59e0b;color:white}.sprocket-btn.restart-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background-color:#d97706}.sprocket-btn.delete-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#ef4444;color:white}.sprocket-btn.delete-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background-color:#dc2626}.sprocket-btn.refresh-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#6b7280;color:white}.sprocket-btn.refresh-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background-color:#4b5563}.sprocket-message.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:0.75rem;border-radius:6px;font-size:0.9rem;font-weight:500;background-color:#dbeafe;color:#1e40af;border:1px solid #93c5fd}.sprocket-message.error.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#fee2e2;color:#dc2626;border-color:#fca5a5}.versions-list.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-direction:column;gap:0.75rem;margin-bottom:1rem}.version-item.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;justify-content:space-between;align-items:center;padding:1rem;background-color:var(--bg-color);border:1px solid var(--border-color);border-radius:6px;transition:all 0.2s ease}.version-item.current.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{border-color:var(--primary-color);background-color:rgba(59, 130, 246, 0.05)}.version-item.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{border-color:var(--primary-color)}.version-info.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1}.version-name.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-weight:600;font-size:0.9rem;margin-bottom:0.25rem}.version-date.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.8rem;color:var(--text-muted);display:flex;align-items:center;gap:0.5rem}.current-badge.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:var(--primary-color);color:white;padding:0.125rem 0.5rem;border-radius:12px;font-size:0.7rem;font-weight:500}.version-actions.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;gap:0.5rem}.version-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:0.375rem 0.75rem;border:none;border-radius:4px;font-size:0.8rem;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;gap:0.25rem}.version-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:disabled{opacity:0.6;cursor:not-allowed}.version-btn.load-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#3b82f6;color:white}.version-btn.load-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background-color:#2563eb}.version-btn.delete-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background-color:#ef4444;color:white}.version-btn.delete-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background-color:#dc2626}@media(max-width: 640px){.header-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:0}.sidebar.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:160px}.main-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:160px;padding:1rem}}.user-info.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;align-items:flex-start;padding:0;height:3em}.logout-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:0.5rem 1rem;border:none;border-radius:6px;background-color:var(--warning);color:white;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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background-color:#e53935}.logout-btn.floating.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:absolute;top:0.5em;right:0.5em;z-index:10;box-shadow:0 2px 8px rgba(0, 0, 0, 0.3)}.user-profile-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:0;margin:0}.user-profile-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background-color:var(--button-bg);padding:0}.user-avatar.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i,.user-avatar-placeholder.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:2.5em;height:2.5em;object-fit:cover}.user-avatar-placeholder.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;align-items:center;justify-content:center;font-size:0.5em;padding:0.5em}.user-name.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:1.2em;font-weight:500;max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0.5em}.drawer-overlay.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:640px;height:100%;background:var(--bg-color);overflow-y:auto;animation:svelte-1a66x6i-slideIn 0.3s ease}@keyframes svelte-1a66x6i-slideIn{from{transform:translateX(100%)}to{transform:translateX(0)}}.drawer-header.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;align-items:center;justify-content:space-between;background:var(--header-bg)}.drawer-header.svelte-1a66x6i h2.svelte-1a66x6i.svelte-1a66x6i{margin:0;color:var(--text-color);font-size:1em;padding:1rem}.close-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:var(--button-hover-bg)}.profile-section.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin-bottom:2rem}.profile-hero.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:relative}.profile-banner.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:100%;height:160px;object-fit:cover;border-radius:0;display:block}.profile-avatar.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i,.profile-avatar-placeholder.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:absolute;left:calc(12px + 72px + 12px);bottom:8px;right:12px;display:flex;align-items:baseline;gap:8px;z-index:1}.profile-username.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin:0;font-size:1.1rem;color:#000;text-shadow:0 3px 6px rgba(255, 255, 255, 1)}.profile-nip05-inline.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.85rem;color:#000;font-family:monospace;opacity:0.95;text-shadow:0 3px 6px rgba(255, 255, 255, 1)}.about-card.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--header-bg);padding:12px 12px 12px 96px;position:relative;word-break:auto-phrase}.profile-about.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin:0;color:var(--text-color);font-size:0.9rem;line-height:1.4}.profile-loading-section.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:1rem;text-align:center}.profile-loading-section.svelte-1a66x6i h3.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem}.profile-loading-section.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 1rem 0;color:var(--text-color);opacity:0.8}.retry-profile-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:0.5rem 1rem;background:var(--primary);color:white;border:none;border-radius:4px;cursor:pointer;font-size:0.9rem;margin-bottom:1rem;transition:background-color 0.2s}.retry-profile-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:#00acc1}.user-pubkey-display.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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}.import-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:1em;max-width:32em;margin:0;background:var(--header-bg);color:var(--text-color);border-radius:8px}.managed-acl-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:20px;max-width:1200px;margin:0;background:var(--header-bg);color:var(--text-color);border-radius:8px}.compose-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:fixed;top:3em;left:200px;right:0;bottom:0;display:flex;flex-direction:column;background:transparent}.compose-header.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;gap:0.5em;padding:0.5em;background:transparent;border-bottom:1px solid var(--border-color)}.compose-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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, - border-color 0.2s}.compose-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:var(--button-hover-bg);border-color:var(--button-hover-border)}.publish-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--accent-color, #007bff);color:white;border-color:var(--accent-color, #007bff)}.publish-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:var(--accent-hover-color, #0056b3);border-color:var(--accent-hover-color, #0056b3)}.compose-editor.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1;padding:0.5em}.compose-textarea.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:100%;height:100%;border:1px solid var(--border-color);border-radius:0.25rem;background:var(--bg-color);color:var(--text-color);font-family:"Courier New", monospace;font-size:0.9rem;padding:1rem;resize:none;outline:none}.compose-textarea.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:focus{border-color:var(--accent-color, #007bff);box-shadow:0 0 0 2px rgba(0, 123, 255, 0.25)}.import-view.svelte-1a66x6i h2.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 2rem 0;color:var(--text-color);font-size:1.5rem;font-weight:600}.export-section.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--header-bg);padding:1em;border-radius:8px;margin-bottom:1.5rem;width:32em}.export-section.svelte-1a66x6i h3.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 1rem 0;color:var(--text-color);font-size:1.2rem;font-weight:500}.export-section.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 1rem 0;color:var(--text-color);opacity:0.8;line-height:1.5}.events-view-buttons.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;gap:0.5rem;align-items:center}.export-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i,.import-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i,.refresh-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i,.reload-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:0.5rem 1rem;background:var(--primary);color:white;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}.export-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover,.import-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover,.refresh-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover,.reload-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:#00acc1}.reload-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{min-width:2em;justify-content:center}.spinner.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:1em;height:1em;border:2px solid transparent;border-top:2px solid currentColor;border-radius:50%;animation:svelte-1a66x6i-spin 1s linear infinite}@keyframes svelte-1a66x6i-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.export-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:disabled,.import-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:disabled{opacity:0.5;cursor:not-allowed}#import-file.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin:1rem 0;padding:0.5rem;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:1rem}.login-prompt.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{text-align:center;padding:1em;background:var(--header-bg);border-radius:8px}.login-prompt.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem}.permission-denied.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{text-align:center;padding:1em;background:var(--header-bg);border-radius:8px;border:2px solid var(--warning)}.permission-denied.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0;color:var(--warning);font-size:1.1rem;font-weight:500}.events-view-container.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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}.events-view-header.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:absolute;bottom:0;left:0;right:0;padding:0.5rem 1rem;background:var(--header-bg);border-top:1px solid var(--border-color);display:flex;justify-content:space-between;align-items:center;height:2.5em;z-index:10}.events-view-toggle.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1;display:flex;align-items:center;justify-content:center}.toggle-container.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;align-items:center;gap:0.5rem;cursor:pointer;font-size:0.875rem;color:var(--text-color)}.toggle-container.svelte-1a66x6i input[type="checkbox"].svelte-1a66x6i.svelte-1a66x6i{display:none}.toggle-slider.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:relative;width:2.5em;height:1.25em;background:var(--border-color);border-radius:1.25em;transition:background-color 0.3s}.toggle-slider.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i::before{content:"";position:absolute;top:0.125em;left:0.125em;width:1em;height:1em;background:white;border-radius:50%;transition:transform 0.3s}.toggle-container.svelte-1a66x6i input[type="checkbox"].svelte-1a66x6i:checked+.toggle-slider.svelte-1a66x6i{background:var(--primary)}.toggle-container.svelte-1a66x6i input[type="checkbox"].svelte-1a66x6i:checked+.toggle-slider.svelte-1a66x6i::before{transform:translateX(1.25em)}.toggle-label.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.875rem;font-weight:500;user-select:none}.events-view-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1;overflow-y:auto;padding:0}.events-view-item.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{border-bottom:1px solid var(--border-color);transition:background-color 0.2s}.events-view-item.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:var(--button-hover-bg)}.events-view-item.expanded.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--button-hover-bg)}.events-view-row.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;align-items:center;padding:0.4rem 1rem;cursor:pointer;gap:0.75rem;min-height:2rem}.events-view-avatar.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex-shrink:0;width:1.5rem;height:1.5rem;display:flex;align-items:center;justify-content:center}.avatar-placeholder.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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}.events-view-info.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex-shrink:0;width:12rem;display:flex;flex-direction:column;gap:0.1rem}.events-view-author.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.8}.events-view-kind.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;align-items:center;gap:0.5rem}.kind-number.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--primary);color:white;padding:0.125rem 0.375rem;border-radius:0.25rem;font-size:0.7rem;font-weight:500;font-family:monospace}.kind-name.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.75rem;color:var(--text-color);opacity:0.7;font-weight:500}.events-view-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1;color:var(--text-color);font-size:0.9rem;line-height:1.3;word-break:break-word}.event-timestamp.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.event-content-single-line.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.delete-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex-shrink:0;background:none;border:none;cursor:pointer;padding:0.2rem;border-radius:0.25rem;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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:var(--warning);color:white}.kind-number.delete-event.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--warning)}.delete-event-info.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-direction:column;gap:0.25rem}.delete-event-label.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-weight:500;color:var(--warning)}.delete-targets.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-direction:column;gap:0.125rem}.delete-target.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.75rem;font-family:monospace;color:var(--text-color);opacity:0.7}.events-view-details.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{border-top:1px solid var(--border-color);background:var(--header-bg);padding:1rem}.json-container.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:relative}.copy-json-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{position:absolute;top:0.5rem;right:0.5rem;background:var(--button-bg);color:var(--button-text);border:1px solid var(--border-color);border-radius:0.25rem;padding:0.5rem 1rem;font-size:1.6rem;cursor:pointer;transition:background-color 0.2s, - border-color 0.2s;z-index:10;opacity:0.8;width:auto;height:auto;display:flex;align-items:center;justify-content:center}.copy-json-btn.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:var(--button-hover-bg);border-color:var(--button-hover-border);opacity:1}.event-json.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--bg-color);border:1px solid var(--border-color);border-radius:0.25rem;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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.no-events.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0;font-size:1rem}.loading-events.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-spinner.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:2rem;height:2rem;border:3px solid var(--border-color);border-top:3px solid var(--primary);border-radius:50%;animation:svelte-1a66x6i-spin 1s linear infinite;margin:0 auto 1rem auto}@keyframes svelte-1a66x6i-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.loading-events.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0;font-size:0.9rem}.end-of-events.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-events.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0}.search-results-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-1a66x6i h2.svelte-1a66x6i.svelte-1a66x6i{margin:0;font-size:1rem;font-weight:600;color:var(--text-color)}.search-results-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1;overflow-y:auto;padding:0}.search-result-item.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{border-bottom:1px solid var(--border-color);transition:background-color 0.2s}.search-result-item.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:var(--button-hover-bg)}.search-result-item.expanded.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--button-hover-bg)}.search-result-row.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;align-items:center;padding:0.75rem 1rem;cursor:pointer;gap:0.75rem;min-height:3rem}.search-result-avatar.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex-shrink:0;width:2rem;height:2rem;display:flex;align-items:center;justify-content:center}.search-result-info.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex-shrink:0;width:12rem;display:flex;flex-direction:column;gap:0.25rem}.search-result-author.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.8}.search-result-kind.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;align-items:center;gap:0.5rem}.search-result-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{flex:1;color:var(--text-color);font-size:0.9rem;line-height:1.3;word-break:break-word}.search-result-content.svelte-1a66x6i .event-timestamp.svelte-1a66x6i.svelte-1a66x6i{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.search-result-content.svelte-1a66x6i .event-content-single-line.svelte-1a66x6i.svelte-1a66x6i{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.search-result-details.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{border-top:1px solid var(--border-color);background:var(--header-bg);padding:1rem}.no-search-results.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.no-search-results.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0;font-size:1rem}.loading-search-results.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-search-results.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0;font-size:0.9rem}.end-of-search-results.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{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-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0}@media(max-width: 1280px){.sidebar.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:60px}.main-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:60px}.events-view-container.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:60px}.compose-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:60px}.search-results-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:60px}.tab-label.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:none}.tab.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{justify-content:center;padding:0 0.5rem}.tab-icon.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:2em;height:2em;display:flex;align-items:center;justify-content:center;border-radius:0.25rem;background-color:var(--bg-color)}.tab.active.svelte-1a66x6i .tab-icon.svelte-1a66x6i.svelte-1a66x6i{background-color:var(--primary);color:white}}@media(max-width: 640px){.settings-drawer.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:100%}.name-row.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:calc(8px + 56px + 8px);bottom:6px;right:8px;gap:6px}.profile-username.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:1rem}.profile-nip05-inline.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.8rem}.import-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:1em}.managed-acl-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:1rem}.export-section.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:1em;width:32em}.events-view-container.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:160px}.compose-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:160px}.events-view-info.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:8rem}.events-view-author.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.7rem}.kind-name.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.7rem}.events-view-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.8rem}.search-results-view.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{left:160px}.search-result-info.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:8rem}.search-result-author.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.7rem}.search-result-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-size:0.8rem}}.recovery-tab.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{padding:20px;max-width:1200px;margin:0 auto}.recovery-header.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin-bottom:30px;text-align:center}.recovery-header.svelte-1a66x6i h2.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 10px 0;color:var(--text-color)}.recovery-header.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0;color:var(--text-color);opacity:0.7}.recovery-controls.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;gap:20px;align-items:center;margin-bottom:30px;padding:20px;background:var(--bg-color);border-radius:8px;flex-wrap:wrap}.kind-selector.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-direction:column;gap:5px}.kind-selector.svelte-1a66x6i label.svelte-1a66x6i.svelte-1a66x6i{font-weight:500;color:var(--text-color)}.kind-selector.svelte-1a66x6i select.svelte-1a66x6i.svelte-1a66x6i{padding:8px 12px;border:1px solid var(--border-color);border-radius:4px;background:var(--bg-color);color:var(--text-color);min-width:300px}.custom-kind-input.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-direction:column;gap:5px}.custom-kind-input.svelte-1a66x6i label.svelte-1a66x6i.svelte-1a66x6i{font-weight:500;color:var(--text-color)}.custom-kind-input.svelte-1a66x6i input.svelte-1a66x6i.svelte-1a66x6i{padding:8px 12px;border:1px solid var(--border-color);border-radius:4px;background:var(--bg-color);color:var(--text-color);min-width:200px}.custom-kind-input.svelte-1a66x6i input.svelte-1a66x6i.svelte-1a66x6i::placeholder{color:var(--text-color);opacity:0.6}.recovery-results.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin-top:20px}.loading.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i,.no-events.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{text-align:center;padding:40px;color:var(--text-color);opacity:0.7}.events-list.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-direction:column;gap:15px}.event-item.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--bg-color);border:1px solid var(--border-color);border-radius:8px;padding:20px;transition:all 0.2s ease}.event-item.old-version.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{opacity:0.7;border-color:#ffc107;background:rgba(255, 193, 7, 0.1)}.event-header.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px;flex-wrap:wrap;gap:10px}.event-kind.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{font-weight:600;color:var(--primary)}.event-timestamp.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{color:var(--text-color);font-size:0.9em;opacity:0.7}.repost-button.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--primary);color:white;border:none;padding:6px 12px;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background 0.2s ease}.repost-button.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover{background:#00acc1}.event-content.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{margin-bottom:15px}.profile-content.svelte-1a66x6i pre.svelte-1a66x6i.svelte-1a66x6i,.generic-content.svelte-1a66x6i pre.svelte-1a66x6i.svelte-1a66x6i{background:var(--bg-color);padding:15px;border-radius:4px;overflow-x:auto;font-size:0.9em;margin:0;border:1px solid var(--border-color)}.follow-list.svelte-1a66x6i p.svelte-1a66x6i.svelte-1a66x6i{margin:0 0 10px 0;font-weight:500;color:var(--text-color)}.follow-tags.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-wrap:wrap;gap:8px}.pubkey-tag.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--bg-color);padding:4px 8px;border-radius:4px;font-family:monospace;font-size:0.8em;border:1px solid var(--border-color);color:var(--text-color)}.event-tags.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{display:flex;flex-wrap:wrap;gap:8px}.tag.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:var(--bg-color);padding:4px 8px;border-radius:4px;font-size:0.8em;color:var(--text-color);opacity:0.7;border:1px solid var(--border-color)}.load-more.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{width:100%;padding:12px;background:var(--primary);color:white;border:none;border-radius:4px;cursor:pointer;font-size:1em;margin-top:20px;transition:background 0.2s ease}.load-more.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:hover:not(:disabled){background:#00acc1}.load-more.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i:disabled{opacity:0.6;cursor:not-allowed}body.dark-theme .event-item.old-version.svelte-1a66x6i.svelte-1a66x6i.svelte-1a66x6i{background:rgba(255, 193, 7, 0.1);border-color:#ffc107} +body{margin:0;padding:0;--bg-color:#ddd;--header-bg:#eee;--border-color:#dee2e6;--text-color:#444444;--input-border:#ccc;--button-bg:#ddd;--button-hover-bg:#eee;--primary:#00bcd4;--warning:#ff3e00;--tab-inactive-bg:#bbb}body.dark-theme{--bg-color:#263238;--header-bg:#1e272c;--border-color:#404040;--text-color:#ffffff;--input-border:#555;--button-bg:#263238;--button-hover-bg:#1e272c;--primary:#00bcd4;--warning:#ff3e00;--tab-inactive-bg:#1a1a1a}.main-header.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{height:3em;background-color:var(--header-bg);position:fixed;top:0;left:0;right:0;z-index:1000;color:var(--text-color)}.header-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{height:100%;display:flex;align-items:center;padding:0;gap:0}.logo.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{height:2.5em;width:2.5em;object-fit:contain;flex-shrink:0;transition:opacity 0.2s ease}.logo.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{content:url("/favicon.png")}.header-title.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1;height:100%;display:flex;align-items:center;gap:0;padding:0 1rem}.app-title.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:1em;font-weight:600;color:var(--text-color);display:flex;align-items:center;gap:0.5rem}.permission-badge.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.7em;font-weight:500;padding:0.2em 0.5em;border-radius:0.3em;background-color:var(--primary);color:white;text-transform:uppercase;letter-spacing:0.05em}.search-input-container.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1;height:100%;display:flex;align-items:center;padding:0 1rem}.search-input.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:100%;height:2em;padding:0.5rem;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:1em;outline:none}.search-input.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:focus{border-color:var(--primary)}.search-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.search-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background-color:var(--button-bg)}.theme-toggle-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:1em 1em 1em 1em;margin:0}.theme-toggle-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background-color:var(--button-bg)}.login-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:0.5em 1em;border:none;border-radius:6px;background-color:#4caf50;color:white;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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background-color:#45a049}.acl-mode-warning.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:1em;background-color:#fff3cd;border:1px solid #ffeaa7;border-radius:8px;color:#856404;margin:20px 0}.acl-mode-warning.svelte-1mgoo1i h3.svelte-1mgoo1i.svelte-1mgoo1i{margin:0 0 15px 0;color:#856404}.acl-mode-warning.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:10px 0;line-height:1.5}.acl-mode-warning.svelte-1mgoo1i code.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#f8f9fa;padding:2px 6px;border-radius:4px;font-family:monospace;color:#495057}.app-container.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;margin-top:3em;height:calc(100vh - 3em)}.sidebar.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:fixed;left:0;top:3em;bottom:0;width:200px;background-color:var(--header-bg);color:var(--text-color);z-index:100}.sidebar-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{height:100%;display:flex;flex-direction:column;padding:0}.tabs.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;flex-direction:column}.tab.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{height:3em;display:flex;align-items:center;padding:0 1rem;cursor:pointer;border:none;background:transparent;color:var(--text-color);transition:background-color 0.2s ease;gap:0.75rem;text-align:left;width:100%}.tab.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background-color:var(--bg-color)}.tab.active.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:var(--bg-color)}.tab-icon.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:1.2em;flex-shrink:0;width:1.5em;text-align:center}.tab-label.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.9em;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1}.tab-close-icon.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{cursor:pointer;transition:opacity 0.2s;font-size:0.8em;margin-left:auto;padding:0.25rem;border-radius:0.25rem;flex-shrink:0}.tab-close-icon.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{opacity:0.7;background-color:var(--warning);color:white}.main-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:fixed;left:200px;top:3em;right:0;bottom:0;padding:1em;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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{text-align:center}.welcome-message.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{font-size:1.2rem}.sprocket-view.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:100%;max-width:1200px;margin:0;padding:20px;background:var(--header-bg);color:var(--text-color);border-radius:8px}.sprocket-section.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem}.sprocket-controls.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;gap:0.5rem}.sprocket-upload-section.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin-bottom:1rem;padding:1rem;background-color:var(--bg-color);border-radius:6px;border:1px solid var(--border-color)}.sprocket-upload-section.svelte-1mgoo1i h4.svelte-1mgoo1i.svelte-1mgoo1i{margin:0 0 0.75rem 0;color:var(--text-color);font-size:1rem;font-weight:500}.upload-controls.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;gap:0.5rem;align-items:center}.upload-controls.svelte-1mgoo1i input[type="file"].svelte-1mgoo1i.svelte-1mgoo1i{flex:1;padding:0.5rem;border:1px solid var(--border-color);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:0.9rem}.sprocket-btn.upload-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#8b5cf6;color:white}.sprocket-btn.upload-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background-color:#7c3aed}.sprocket-status.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;gap:1rem;margin-bottom:1rem;padding:0.75rem;background-color:var(--bg-color);border-radius:6px;border:1px solid var(--border-color)}.status-item.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;flex-direction:column;gap:0.25rem}.status-label.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.8rem;color:var(--text-muted);font-weight:500}.status-value.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.9rem;font-weight:600}.status-value.running.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{color:#22c55e}.script-editor-container.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin-bottom:1rem}.script-editor.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:100%;height:300px;padding:1rem;border:1px solid var(--border-color);border-radius:6px;background-color:var(--bg-color);color:var(--text-color);font-family:"Monaco", "Menlo", "Ubuntu Mono", monospace;font-size:0.9rem;line-height:1.4;resize:vertical;outline:none}.script-editor.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:focus{border-color:var(--primary-color);box-shadow:0 0 0 2px rgba(59, 130, 246, 0.1)}.script-editor.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:disabled{opacity:0.6;cursor:not-allowed}.script-actions.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;gap:0.5rem;margin-bottom:1rem}.sprocket-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:0.5rem 1rem;border:none;border-radius:6px;font-size:0.9rem;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;gap:0.5rem}.sprocket-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:disabled{opacity:0.6;cursor:not-allowed}.sprocket-btn.save-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#22c55e;color:white}.sprocket-btn.save-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background-color:#16a34a}.sprocket-btn.load-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#3b82f6;color:white}.sprocket-btn.load-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background-color:#2563eb}.sprocket-btn.restart-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#f59e0b;color:white}.sprocket-btn.restart-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background-color:#d97706}.sprocket-btn.delete-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#ef4444;color:white}.sprocket-btn.delete-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background-color:#dc2626}.sprocket-btn.refresh-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#6b7280;color:white}.sprocket-btn.refresh-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background-color:#4b5563}.sprocket-message.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:0.75rem;border-radius:6px;font-size:0.9rem;font-weight:500;background-color:#dbeafe;color:#1e40af;border:1px solid #93c5fd}.sprocket-message.error.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#fee2e2;color:#dc2626;border-color:#fca5a5}.versions-list.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;flex-direction:column;gap:0.75rem;margin-bottom:1rem}.version-item.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;justify-content:space-between;align-items:center;padding:1rem;background-color:var(--bg-color);border:1px solid var(--border-color);border-radius:6px;transition:all 0.2s ease}.version-item.current.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{border-color:var(--primary-color);background-color:rgba(59, 130, 246, 0.05)}.version-item.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{border-color:var(--primary-color)}.version-info.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1}.version-name.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-weight:600;font-size:0.9rem;margin-bottom:0.25rem}.version-date.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.8rem;color:var(--text-muted);display:flex;align-items:center;gap:0.5rem}.current-badge.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:var(--primary-color);color:white;padding:0.125rem 0.5rem;border-radius:12px;font-size:0.7rem;font-weight:500}.version-actions.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;gap:0.5rem}.version-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:0.375rem 0.75rem;border:none;border-radius:4px;font-size:0.8rem;font-weight:500;cursor:pointer;transition:all 0.2s ease;display:flex;align-items:center;gap:0.25rem}.version-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:disabled{opacity:0.6;cursor:not-allowed}.version-btn.load-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#3b82f6;color:white}.version-btn.load-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background-color:#2563eb}.version-btn.delete-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:#ef4444;color:white}.version-btn.delete-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background-color:#dc2626}@media(max-width: 640px){.header-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:0}.sidebar.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:160px}.main-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:160px;padding:1rem}}.user-info.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:flex-start;padding:0;height:3em}.logout-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:0.5rem 1rem;border:none;border-radius:6px;background-color:var(--warning);color:white;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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background-color:#e53935}.logout-btn.floating.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:absolute;top:0.5em;right:0.5em;z-index:10;box-shadow:0 2px 8px rgba(0, 0, 0, 0.3)}.user-profile-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{border:0 none;border-radius:0;display:flex;align-items:center;background-color:var(--button-hover-bg);cursor:pointer;color:var(--text-color);height:3em;width:auto;min-width:3em;flex-shrink:0;line-height:1;transition:background-color 0.2s;justify-content:center;padding:0;margin:0}.user-profile-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background-color:var(--button-bg);padding:0}.user-avatar.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i,.user-avatar-placeholder.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:2.5em;height:2.5em;object-fit:cover;border-radius:50%}.user-avatar-placeholder.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;justify-content:center;font-size:0.5em;padding:0.5em}.user-name.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:1.2em;font-weight:500;max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0.5em}.drawer-overlay.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:640px;height:100%;background:var(--bg-color);overflow-y:auto;animation:svelte-1mgoo1i-slideIn 0.3s ease}@keyframes svelte-1mgoo1i-slideIn{from{transform:translateX(100%)}to{transform:translateX(0)}}.drawer-header.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;justify-content:space-between;background:var(--header-bg)}.drawer-header.svelte-1mgoo1i h2.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;color:var(--text-color);font-size:1em;padding:1rem}.close-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:var(--button-hover-bg)}.profile-section.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin-bottom:2rem}.profile-hero.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:relative}.profile-banner.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:100%;height:160px;object-fit:cover;border-radius:0;display:block}.profile-avatar.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i,.profile-avatar-placeholder.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:absolute;left:calc(12px + 72px + 12px);bottom:8px;right:12px;display:flex;align-items:baseline;gap:8px;z-index:1}.profile-username.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;font-size:1.1rem;color:#000;text-shadow:0 3px 6px rgba(255, 255, 255, 1)}.profile-nip05-inline.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.85rem;color:#000;font-family:monospace;opacity:0.95;text-shadow:0 3px 6px rgba(255, 255, 255, 1)}.about-card.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--header-bg);padding:12px 12px 12px 96px;position:relative;word-break:auto-phrase}.profile-about.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;color:var(--text-color);font-size:0.9rem;line-height:1.4}.profile-loading-section.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:1rem;text-align:center}.profile-loading-section.svelte-1mgoo1i h3.svelte-1mgoo1i.svelte-1mgoo1i{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem}.profile-loading-section.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0 0 1rem 0;color:var(--text-color);opacity:0.8}.retry-profile-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:0.5rem 1rem;background:var(--primary);color:white;border:none;border-radius:4px;cursor:pointer;font-size:0.9rem;margin-bottom:1rem;transition:background-color 0.2s}.retry-profile-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:#00acc1}.user-pubkey-display.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:20px;max-width:1200px;margin:0;background:var(--header-bg);color:var(--text-color);border-radius:8px}.compose-view.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:fixed;top:3em;left:200px;right:0;bottom:0;display:flex;flex-direction:column;background:transparent}.compose-header.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;gap:0.5em;padding:0.5em;background:transparent;border-bottom:1px solid var(--border-color)}.compose-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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, + border-color 0.2s}.compose-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:var(--button-hover-bg);border-color:var(--button-hover-border)}.publish-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--accent-color, #007bff);color:white;border-color:var(--accent-color, #007bff)}.publish-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:var(--accent-hover-color, #0056b3);border-color:var(--accent-hover-color, #0056b3)}.compose-editor.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1;padding:0.5em}.compose-textarea.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:100%;height:100%;border:1px solid var(--border-color);border-radius:0.25rem;background:var(--bg-color);color:var(--text-color);font-family:"Courier New", monospace;font-size:0.9rem;padding:1rem;resize:none;outline:none}.compose-textarea.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:focus{border-color:var(--accent-color, #007bff);box-shadow:0 0 0 2px rgba(0, 123, 255, 0.25)}.export-section.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i,.import-section.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:transparent;padding:1em;border-radius:8px;margin-bottom:1.5rem;width:32em}.export-section.svelte-1mgoo1i h3.svelte-1mgoo1i.svelte-1mgoo1i,.import-section.svelte-1mgoo1i h3.svelte-1mgoo1i.svelte-1mgoo1i{margin:0 0 10px 0;color:var(--text-color)}.export-section.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i,.import-section.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;color:var(--text-color);opacity:0.7;padding:0.5em}.events-view-buttons.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;gap:0.5rem;align-items:center}.export-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i,.import-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i,.refresh-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i,.reload-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:0.5rem 1rem;background:var(--primary);color:white;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}.export-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover,.import-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover,.refresh-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover,.reload-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:#00acc1}.reload-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{min-width:2em;justify-content:center}.spinner.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:1em;height:1em;border:2px solid transparent;border-top:2px solid currentColor;border-radius:50%;animation:svelte-1mgoo1i-spin 1s linear infinite}@keyframes svelte-1mgoo1i-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.export-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:disabled,.import-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:disabled{opacity:0.5;cursor:not-allowed}#import-file.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin:1rem 0;padding:0.5rem;border:1px solid var(--input-border);border-radius:4px;background:var(--bg-color);color:var(--text-color);font-size:1rem}.login-prompt.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{text-align:center;padding:1em;background:var(--header-bg);border-radius:8px}.login-prompt.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0 0 1rem 0;color:var(--text-color);font-size:1.1rem}.permission-denied.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{text-align:center;padding:1em;background:var(--header-bg);border-radius:8px;border:2px solid var(--warning)}.permission-denied.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;color:var(--warning);font-size:1.1rem;font-weight:500}.events-view-container.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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}.events-view-header.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:absolute;bottom:0;left:0;right:0;padding:0.5rem 1rem;background:var(--header-bg);border-top:1px solid var(--border-color);display:flex;justify-content:space-between;align-items:center;height:2.5em;z-index:10}.events-view-toggle.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1;display:flex;align-items:center;justify-content:center}.toggle-container.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;gap:0.5rem;cursor:pointer;font-size:0.875rem;color:var(--text-color)}.toggle-container.svelte-1mgoo1i input[type="checkbox"].svelte-1mgoo1i.svelte-1mgoo1i{display:none}.toggle-slider.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:relative;width:2.5em;height:1.25em;background:var(--border-color);border-radius:1.25em;transition:background-color 0.3s}.toggle-slider.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i::before{content:"";position:absolute;top:0.125em;left:0.125em;width:1em;height:1em;background:white;border-radius:50%;transition:transform 0.3s}.toggle-container.svelte-1mgoo1i input[type="checkbox"].svelte-1mgoo1i:checked+.toggle-slider.svelte-1mgoo1i{background:var(--primary)}.toggle-container.svelte-1mgoo1i input[type="checkbox"].svelte-1mgoo1i:checked+.toggle-slider.svelte-1mgoo1i::before{transform:translateX(1.25em)}.toggle-label.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.875rem;font-weight:500;user-select:none}.events-view-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1;overflow-y:auto;padding:0}.events-view-item.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{border-bottom:1px solid var(--border-color);transition:background-color 0.2s}.events-view-item.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:var(--button-hover-bg)}.events-view-item.expanded.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--button-hover-bg)}.events-view-row.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;padding:0.4rem 1rem;cursor:pointer;gap:0.75rem;min-height:2rem}.events-view-avatar.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex-shrink:0;width:1.5rem;height:1.5rem;display:flex;align-items:center;justify-content:center}.avatar-placeholder.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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}.events-view-info.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex-shrink:0;width:12rem;display:flex;flex-direction:column;gap:0.1rem}.events-view-author.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.8}.events-view-kind.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;gap:0.5rem}.kind-number.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--primary);color:white;padding:0.125rem 0.375rem;border-radius:0.25rem;font-size:0.7rem;font-weight:500;font-family:monospace}.kind-name.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.75rem;color:var(--text-color);opacity:0.7;font-weight:500}.events-view-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1;color:var(--text-color);font-size:0.9rem;line-height:1.3;word-break:break-word}.event-timestamp.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.event-content-single-line.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.delete-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex-shrink:0;background:none;border:none;cursor:pointer;padding:0.2rem;border-radius:0.25rem;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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:var(--warning);color:white}.kind-number.delete-event.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--warning)}.delete-event-info.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;flex-direction:column;gap:0.25rem}.delete-event-label.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-weight:500;color:var(--warning)}.delete-targets.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;flex-direction:column;gap:0.125rem}.delete-target.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.75rem;font-family:monospace;color:var(--text-color);opacity:0.7}.events-view-details.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{border-top:1px solid var(--border-color);background:var(--header-bg);padding:1rem}.json-container.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{position:relative}.copy-json-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--active-tab-bg);color:var(--button-text);border:1px solid var(--border-color);border-radius:0.25rem;padding:0.5rem 1rem;font-size:1rem;cursor:pointer;transition:background-color 0.2s, + border-color 0.2s;width:auto;height:auto;display:flex;align-items:center;justify-content:center}.copy-json-btn.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:var(--button-hover-bg);border-color:var(--button-hover-border)}.event-json.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.no-events.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;font-size:1rem}.loading-events.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-spinner.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:2rem;height:2rem;border:3px solid var(--border-color);border-top:3px solid var(--primary);border-radius:50%;animation:svelte-1mgoo1i-spin 1s linear infinite;margin:0 auto 1rem auto}@keyframes svelte-1mgoo1i-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.loading-events.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;font-size:0.9rem}.end-of-events.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-events.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0}.search-results-view.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i h2.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;font-size:1rem;font-weight:600;color:var(--text-color)}.search-results-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1;overflow-y:auto;padding:0}.search-result-item.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{border-bottom:1px solid var(--border-color);transition:background-color 0.2s}.search-result-item.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:var(--button-hover-bg)}.search-result-item.expanded.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--button-hover-bg)}.search-result-row.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;padding:0.75rem 1rem;cursor:pointer;gap:0.75rem;min-height:3rem}.search-result-avatar.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex-shrink:0;width:2rem;height:2rem;display:flex;align-items:center;justify-content:center}.search-result-info.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex-shrink:0;width:12rem;display:flex;flex-direction:column;gap:0.25rem}.search-result-author.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-family:monospace;font-size:0.8rem;color:var(--text-color);opacity:0.8}.search-result-kind.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;gap:0.5rem}.search-result-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{flex:1;color:var(--text-color);font-size:0.9rem;line-height:1.3;word-break:break-word}.search-result-content.svelte-1mgoo1i .event-timestamp.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.75rem;color:var(--text-color);opacity:0.7;margin-bottom:0.25rem;font-weight:500}.search-result-content.svelte-1mgoo1i .event-content-single-line.svelte-1mgoo1i.svelte-1mgoo1i{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.2}.search-result-details.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{border-top:1px solid var(--border-color);background:var(--header-bg);padding:1rem}.no-search-results.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.no-search-results.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;font-size:1rem}.loading-search-results.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:2rem;text-align:center;color:var(--text-color);opacity:0.7}.loading-search-results.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;font-size:0.9rem}.end-of-search-results.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{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-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0}@media(max-width: 1280px){.sidebar.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:60px}.main-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:60px}.events-view-container.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:60px}.compose-view.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:60px}.search-results-view.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:60px}.tab-label.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:none}.tab.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{justify-content:center;padding:0 0.5rem}.tab-icon.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:2em;height:2em;display:flex;align-items:center;justify-content:center;border-radius:0.25rem;background-color:var(--bg-color)}.tab.active.svelte-1mgoo1i .tab-icon.svelte-1mgoo1i.svelte-1mgoo1i{background-color:var(--primary);color:white}}@media(max-width: 640px){.settings-drawer.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:100%}.name-row.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:calc(8px + 56px + 8px);bottom:6px;right:8px;gap:6px}.profile-username.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:1rem}.profile-nip05-inline.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.8rem}.managed-acl-view.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:1rem}.export-section.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i,.import-section.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:1em;width:32em}.events-view-container.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:160px}.compose-view.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:160px}.events-view-info.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:8rem}.events-view-author.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.7rem}.kind-name.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.7rem}.events-view-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.8rem}.search-results-view.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{left:160px}.search-result-info.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:8rem}.search-result-author.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.7rem}.search-result-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:0.8rem}}.recovery-tab.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{padding:20px;max-width:1200px;margin:0}.recovery-header.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin-bottom:30px;text-align:left}.recovery-tab.svelte-1mgoo1i h3.svelte-1mgoo1i.svelte-1mgoo1i{margin:0 0 10px 0;color:var(--text-color)}.recovery-tab.svelte-1mgoo1i p.svelte-1mgoo1i.svelte-1mgoo1i{margin:0;color:var(--text-color);opacity:0.7;padding:0.5em}.recovery-controls-card.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:transparent;border:none;border-radius:0;padding:0}.recovery-controls.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;gap:20px;align-items:center;flex-wrap:wrap}.kind-selector.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;flex-direction:column;gap:5px}.kind-selector.svelte-1mgoo1i label.svelte-1mgoo1i.svelte-1mgoo1i{font-weight:500;color:var(--text-color)}.kind-selector.svelte-1mgoo1i select.svelte-1mgoo1i.svelte-1mgoo1i{padding:8px 12px;border:1px solid var(--border-color);border-radius:4px;background:var(--bg-color);color:var(--text-color);min-width:300px}.custom-kind-input.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;flex-direction:column;gap:5px}.custom-kind-input.svelte-1mgoo1i label.svelte-1mgoo1i.svelte-1mgoo1i{font-weight:500;color:var(--text-color)}.custom-kind-input.svelte-1mgoo1i input.svelte-1mgoo1i.svelte-1mgoo1i{padding:8px 12px;border:1px solid var(--border-color);border-radius:4px;background:var(--bg-color);color:var(--text-color);min-width:200px}.custom-kind-input.svelte-1mgoo1i input.svelte-1mgoo1i.svelte-1mgoo1i::placeholder{color:var(--text-color);opacity:0.6}.recovery-results.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin-top:20px}.loading.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i,.no-events.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{text-align:left;padding:40px 20px;color:var(--text-color);opacity:0.7}.events-list.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;flex-direction:column;gap:15px}.event-item.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--surface-bg);border:2px solid var(--primary);border-radius:8px;padding:20px;transition:all 0.2s ease;background:var(--header-bg)}.event-item.old-version.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{opacity:0.85;border:none;background:var(--header-bg)}.event-header.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px;flex-wrap:wrap;gap:10px}.event-header-left.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;gap:15px;flex-wrap:wrap}.event-header-actions.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{display:flex;align-items:center;gap:8px}.event-kind.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-weight:600;color:var(--primary)}.event-timestamp.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{color:var(--text-color);font-size:0.9em;opacity:0.7}.repost-button.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--primary);color:white;border:none;padding:6px 12px;border-radius:4px;cursor:pointer;font-size:0.9em;transition:background 0.2s ease}.repost-button.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover{background:#00acc1}.event-content.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin-bottom:15px}.load-more.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{width:100%;padding:12px;background:var(--primary);color:white;border:none;border-radius:4px;cursor:pointer;font-size:1em;margin-top:20px;transition:background 0.2s ease}.load-more.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:hover:not(:disabled){background:#00acc1}.load-more.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i:disabled{opacity:0.6;cursor:not-allowed}body.dark-theme .event-item.old-version.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background:var(--header-bg);border:none}.recovery-header.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{font-size:1.5em;font-weight:bold;margin-bottom:0.5em;color:var(--header-text-color)}.recovery-description.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{margin-bottom:1.5em;color:var(--description-text-color)}.recovery-controls-card.svelte-1mgoo1i.svelte-1mgoo1i.svelte-1mgoo1i{background-color:transparent;border-radius:8px;padding:1em;margin-bottom:1em;width:100%} html, body { position: relative; diff --git a/app/web/dist/bundle.js b/app/web/dist/bundle.js index 8f68ab2..7734d2e 100644 --- a/app/web/dist/bundle.js +++ b/app/web/dist/bundle.js @@ -1,22 +1,22 @@ -var app=function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function r(e){e.forEach(t)}function o(e){return"function"==typeof e}function i(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let s;function a(e,t){return s||(s=document.createElement("a")),s.href=t,e===s.href}const c="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:global;function l(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,r)}function v(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function w(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function b(e){return""===e?null:+e}function x(e,t){t=""+t,e.data!==t&&(e.data=t)}function E(e,t){e.value=null==t?"":t}function k(e,t,n){for(let n=0;n{const o=e.$$.callbacks[t];if(o){const i=function(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const o=document.createEvent("CustomEvent");return o.initCustomEvent(e,n,r,t),o}(t,n,{cancelable:r});return o.slice().forEach(t=>{t.call(e,i)}),!i.defaultPrevented}return!0}}function $(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const I=[],O=[];let R=[];const P=[],L=Promise.resolve();let B=!1;function N(e){R.push(e)}const U=new Set;let j=0;function M(){if(0!==j)return;const e=A;do{try{for(;j{D.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function J(e){e&&e.c()}function V(e,n,i,s){const{fragment:a,after_update:c}=e.$$;a&&a.m(n,i),s||N(()=>{const n=e.$$.on_mount.map(t).filter(o);e.$$.on_destroy?e.$$.on_destroy.push(...n):r(n),e.$$.on_mount=[]}),c.forEach(N)}function G(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];R.forEach(r=>-1===e.indexOf(r)?t.push(r):n.push(r)),n.forEach(e=>e()),R=t}(n.after_update),r(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Z(e,t){-1===e.$$.dirty[0]&&(I.push(e),B||(B=!0,L.then(M)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const o=r.length?r[0]:n;return h.ctx&&a(h.ctx[e],h.ctx[e]=o)&&(!h.skip_bound&&h.bound[e]&&h.bound[e](o),p&&Z(t,e)),n}):[],h.update(),p=!0,r(h.before_update),h.fragment=!!s&&s(h.ctx),o.target){if(o.hydrate){const e=function(e){return Array.from(e.childNodes)}(o.target);h.fragment&&h.fragment.l(e),e.forEach(d)}else h.fragment&&h.fragment.c();o.intro&&W(t.$$.fragment),V(t,o.target,o.anchor,o.customElement),M()}C(f)}class Q{$destroy(){G(this,1),this.$destroy=e}$on(t,n){if(!o(n))return e;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const e=r.indexOf(n);-1!==e&&r.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 X(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ee(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 te(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 ne="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,re=e=>e instanceof Uint8Array,oe=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),ie=(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 se(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)),!re(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let ae=class{clone(){return this._cloneInto()}};function ce(e){const t=t=>e().update(se(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function le(e=32){if(ne&&"function"==typeof ne.getRandomValues)return ne.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let ue=class extends ae{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=oe(this.buffer)}update(e){te(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=se(e)).length;for(let i=0;ir-i&&(this.process(n,0),i=0);for(let e=i;e>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=oe(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,fe=(e,t,n)=>e&t^e&n^t&n,he=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]),pe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ye=new Uint32Array(64);let ge=class extends ue{constructor(){super(64,32,8,!1),this.A=0|pe[0],this.B=0|pe[1],this.C=0|pe[2],this.D=0|pe[3],this.E=0|pe[4],this.F=0|pe[5],this.G=0|pe[6],this.H=0|pe[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)ye[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ye[e-15],n=ye[e-2],r=ie(t,7)^ie(t,18)^t>>>3,o=ie(n,17)^ie(n,19)^n>>>10;ye[e]=o+ye[e-7]+r+ye[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(ie(s,6)^ie(s,11)^ie(s,25))+de(s,a,c)+he[e]+ye[e]|0,u=(ie(n,2)^ie(n,13)^ie(n,22))+fe(n,r,o)|0;l=c,c=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,i,s,a,c,l)}roundClean(){ye.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const me=ce(()=>new ge),ve=BigInt(0),we=BigInt(1),be=BigInt(2),xe=e=>e instanceof Uint8Array,Ee=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")); -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ke(e){if(!xe(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!xe(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const Pe=e=>(be<new Uint8Array(e),Be=e=>Uint8Array.from(e);function Ne(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 r=Le(e),o=Le(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...e)=>n(o,r,...e),c=(e=Le())=>{o=a(Be([0]),e),r=a(),0!==e.length&&(o=a(Be([1]),e),r=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(s(),c(e);!(n=t(l()));)c();return s(),n}}const Ue={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 r=(t,n,r)=>{const o=Ue[n];if("function"!=typeof o)throw new Error(`Invalid validator "${n}", expected function`);const i=e[t];if(!(r&&void 0===i||o(i,e)))throw new Error(`Invalid param ${String(t)}=${i} (${typeof i}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var Me=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&we},bitLen:function(e){let t;for(t=0;e>ve;e>>=we,t+=1);return t},bitMask:Pe,bitSet:(e,t,n)=>e|(n?we:ve)<=Fe?n:t+n}function Ve(e,t,n){if(n<=Fe||t 0");if(n===De)return Fe;let r=De;for(;t>Fe;)t&De&&(r=r*e%n),e=e*e%n,t>>=De;return r}function Ge(e,t,n){let r=e;for(;t-- >Fe;)r*=r,r%=n;return r}function Ze(e,t){if(e===Fe||t<=Fe)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Je(e,t),r=t,o=Fe,i=De;for(;n!==Fe;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==De)throw new Error("invert: does not exist");return Je(o,t)}function Ye(e){if(e%ze===qe){const t=(e+De)/ze;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%Ke===We){const t=(e-We)/Ke;return function(e,n){const r=e.mul(n,He),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,He),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-De)/He;let n,r,o;for(n=e-De,r=0;n%He===Fe;n/=He,r++);for(o=He;oe.removeEventListener(t,n,r)}function v(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function w(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function b(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 k(e,t,n){for(let n=0;n{const o=e.$$.callbacks[t];if(o){const i=function(e,t,{bubbles:n=!1,cancelable:r=!1}={}){const o=document.createEvent("CustomEvent");return o.initCustomEvent(e,n,r,t),o}(t,n,{cancelable:r});return o.slice().forEach(t=>{t.call(e,i)}),!i.defaultPrevented}return!0}}function I(e,t){const n=e.$$.callbacks[t.type];n&&n.slice().forEach(e=>e.call(this,t))}const $=[],R=[];let O=[];const P=[],B=Promise.resolve();let N=!1;function L(e){O.push(e)}const U=new Set;let j=0;function F(){if(0!==j)return;const e=C;do{try{for(;j<$.length;){const e=$[j];j++,A(e),M(e.$$)}}catch(e){throw $.length=0,j=0,e}for(A(null),$.length=0,j=0;R.length;)R.pop()();for(let e=0;e{D.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function V(e){e&&e.c()}function J(e,n,i,s){const{fragment:a,after_update:l}=e.$$;a&&a.m(n,i),s||L(()=>{const n=e.$$.on_mount.map(t).filter(o);e.$$.on_destroy?e.$$.on_destroy.push(...n):r(n),e.$$.on_mount=[]}),l.forEach(L)}function G(e,t){const n=e.$$;null!==n.fragment&&(!function(e){const t=[],n=[];O.forEach(r=>-1===e.indexOf(r)?t.push(r):n.push(r)),n.forEach(e=>e()),O=t}(n.after_update),r(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Z(e,t){-1===e.$$.dirty[0]&&($.push(e),N||(N=!0,B.then(F)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const o=r.length?r[0]:n;return h.ctx&&a(h.ctx[e],h.ctx[e]=o)&&(!h.skip_bound&&h.bound[e]&&h.bound[e](o),p&&Z(t,e)),n}):[],h.update(),p=!0,r(h.before_update),h.fragment=!!s&&s(h.ctx),o.target){if(o.hydrate){const e=function(e){return Array.from(e.childNodes)}(o.target);h.fragment&&h.fragment.l(e),e.forEach(d)}else h.fragment&&h.fragment.c();o.intro&&K(t.$$.fragment),J(t,o.target,o.anchor,o.customElement),F()}A(f)}class Q{$destroy(){G(this,1),this.$destroy=e}$on(t,n){if(!o(n))return e;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const e=r.indexOf(n);-1!==e&&r.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 X(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ee(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 te(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 ne="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,re=e=>e instanceof Uint8Array,oe=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),ie=(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 se(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)),!re(e))throw new Error("expected Uint8Array, got "+typeof e);return e}let ae=class{clone(){return this._cloneInto()}};function le(e){const t=t=>e().update(se(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ce(e=32){if(ne&&"function"==typeof ne.getRandomValues)return ne.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}let ue=class extends ae{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=oe(this.buffer)}update(e){te(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=se(e)).length;for(let i=0;ir-i&&(this.process(n,0),i=0);for(let e=i;e>o&i),a=Number(n&i),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=oe(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,fe=(e,t,n)=>e&t^e&n^t&n,he=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]),pe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ge=new Uint32Array(64);let me=class extends ue{constructor(){super(64,32,8,!1),this.A=0|pe[0],this.B=0|pe[1],this.C=0|pe[2],this.D=0|pe[3],this.E=0|pe[4],this.F=0|pe[5],this.G=0|pe[6],this.H=0|pe[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)ge[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ge[e-15],n=ge[e-2],r=ie(t,7)^ie(t,18)^t>>>3,o=ie(n,17)^ie(n,19)^n>>>10;ge[e]=o+ge[e-7]+r+ge[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(ie(s,6)^ie(s,11)^ie(s,25))+de(s,a,l)+he[e]+ge[e]|0,u=(ie(n,2)^ie(n,13)^ie(n,22))+fe(n,r,o)|0;c=l,l=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,o,i,s,a,l,c)}roundClean(){ge.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const ye=le(()=>new me),ve=BigInt(0),we=BigInt(1),be=BigInt(2),Ee=e=>e instanceof Uint8Array,xe=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ke(e){if(!Ee(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!Ee(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}const Pe=e=>(be<new Uint8Array(e),Ne=e=>Uint8Array.from(e);function Le(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 r=Be(e),o=Be(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...e)=>n(o,r,...e),l=(e=Be())=>{o=a(Ne([0]),e),r=a(),0!==e.length&&(o=a(Ne([1]),e),r=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e{let n;for(s(),l(e);!(n=t(c()));)l();return s(),n}}const Ue={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 r=(t,n,r)=>{const o=Ue[n];if("function"!=typeof o)throw new Error(`Invalid validator "${n}", expected function`);const i=e[t];if(!(r&&void 0===i||o(i,e)))throw new Error(`Invalid param ${String(t)}=${i} (${typeof i}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var Fe=Object.freeze({__proto__:null,bitGet:function(e,t){return e>>BigInt(t)&we},bitLen:function(e){let t;for(t=0;e>ve;e>>=we,t+=1);return t},bitMask:Pe,bitSet:(e,t,n)=>e|(n?we:ve)<=Me?n:t+n}function Je(e,t,n){if(n<=Me||t 0");if(n===De)return Me;let r=De;for(;t>Me;)t&De&&(r=r*e%n),e=e*e%n,t>>=De;return r}function Ge(e,t,n){let r=e;for(;t-- >Me;)r*=r,r%=n;return r}function Ze(e,t){if(e===Me||t<=Me)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Ve(e,t),r=t,o=Me,i=De;for(;n!==Me;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==De)throw new Error("invert: does not exist");return Ve(o,t)}function Ye(e){if(e%ze===qe){const t=(e+De)/ze;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%We===Ke){const t=(e-Ke)/We;return function(e,n){const r=e.mul(n,He),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,He),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-De)/He;let n,r,o;for(n=e-De,r=0;n%He===Me;n/=He,r++);for(o=He;o(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({...Xe(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:it,hexToBytes:st}=Me,at={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=at;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:it(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=at,n="string"==typeof e?st(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=at._parseInt(n.subarray(2)),{d:s,l:a}=at._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:s}},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},r=t(n(e.s)),o=t(n(e.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},ct=BigInt(0),lt=BigInt(1);BigInt(2);const ut=BigInt(3);function dt(e){const t=function(e){const t=ot(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:r,a:o}=t;if(n){if(!r.eql(o,r.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,r=t.toBytes||((e,t,r)=>{const o=t.toAffine();return Re(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),o=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 i(e){const{a:r,b:o}=t,i=n.sqr(e),s=n.mul(i,e);return n.add(n.add(s,n.mul(e,r)),o)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"==typeof e&&ctn.eql(e,n.ZERO);return o(t)&&o(r)?d.ZERO:new d(t,r,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(o(Oe("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const o=n.sqr(r),s=i(e);if(!n.eql(o,s))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:r,pz:o}=this,{px:i,py:s,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(i,o)),l=n.eql(n.mul(r,a),n.mul(s,o));return c&&l}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,ut),{px:i,py:s,pz:a}=this;let c=n.ZERO,l=n.ZERO,u=n.ZERO,f=n.mul(i,i),h=n.mul(s,s),p=n.mul(a,a),y=n.mul(i,s);return y=n.add(y,y),u=n.mul(i,a),u=n.add(u,u),c=n.mul(e,u),l=n.mul(o,p),l=n.add(c,l),c=n.sub(h,l),l=n.add(h,l),l=n.mul(c,l),c=n.mul(y,c),u=n.mul(o,u),p=n.mul(e,p),y=n.sub(f,p),y=n.mul(e,y),y=n.add(y,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,p),f=n.mul(f,y),l=n.add(l,f),p=n.mul(s,a),p=n.add(p,p),f=n.mul(p,y),c=n.sub(c,f),u=n.mul(p,h),u=n.add(u,u),u=n.add(u,u),new d(c,l,u)}add(e){u(e);const{px:r,py:o,pz:i}=this,{px:s,py:a,pz:c}=e;let l=n.ZERO,f=n.ZERO,h=n.ZERO;const p=t.a,y=n.mul(t.b,ut);let g=n.mul(r,s),m=n.mul(o,a),v=n.mul(i,c),w=n.add(r,o),b=n.add(s,a);w=n.mul(w,b),b=n.add(g,m),w=n.sub(w,b),b=n.add(r,i);let x=n.add(s,c);return b=n.mul(b,x),x=n.add(g,v),b=n.sub(b,x),x=n.add(o,i),l=n.add(a,c),x=n.mul(x,l),l=n.add(m,v),x=n.sub(x,l),h=n.mul(p,b),l=n.mul(y,v),h=n.add(l,h),l=n.sub(m,h),h=n.add(m,h),f=n.mul(l,h),m=n.add(g,g),m=n.add(m,g),v=n.mul(p,v),b=n.mul(y,b),m=n.add(m,v),v=n.sub(g,v),v=n.mul(p,v),b=n.add(b,v),g=n.mul(m,b),f=n.add(f,g),g=n.mul(x,b),l=n.mul(w,l),l=n.sub(l,g),g=n.mul(w,m),h=n.mul(x,h),h=n.add(h,g),new d(l,f,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return h.wNAFCached(this,l,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 r=d.ZERO;if(e===ct)return r;if(a(e),e===lt)return this;const{endo:o}=t;if(!o)return h.unsafeLadder(this,e);let{k1neg:i,k1:s,k2neg:c,k2:l}=o.splitScalar(e),u=r,f=r,p=this;for(;s>ct||l>ct;)s<&&(u=u.add(p)),l<&&(f=f.add(p)),p=p.double(),s>>=lt,l>>=lt;return i&&(u=u.negate()),c&&(f=f.negate()),f=new d(n.mul(f.px,o.beta),f.py,f.pz),u.add(f)}multiply(e){a(e);let r,o,i=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:c}=s.splitScalar(i);let{p:l,f:u}=this.wNAF(t),{p:f,f:p}=this.wNAF(c);l=h.constTimeNegate(e,l),f=h.constTimeNegate(a,f),f=new d(n.mul(f.px,s.beta),f.py,f.pz),r=l.add(f),o=u.add(p)}else{const{p:e,f:t}=this.wNAF(i);r=e,o=t}return d.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,o=(e,t)=>t!==ct&&t!==lt&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:o}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(o));const s=n.mul(t,e),a=n.mul(r,e),c=n.mul(o,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===lt)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===lt?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return ke(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=t.nBitLength,h=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,o=t;for(;n>nt;)n&rt&&(r=r.add(o)),o=o.double(),n>>=rt;return r},precomputeWindow(e,t){const{windows:n,windowSize:o}=r(t),i=[];let s=e,a=s;for(let e=0;e>=f,r>a&&(r-=d,i+=rt);const s=t,h=t+Math.abs(r)-1,p=e%2!=0,y=r<0;0===r?l=l.add(n(p,o[s])):c=c.add(n(y,o[h]))}return{p:c,f:l}},wNAFCached(e,t,n,r){const o=e._WINDOW_SIZE||1;let i=t.get(e);return i||(i=this.precomputeWindow(e,o),1!==o&&t.set(e,r(i))),this.wNAF(o,i,n)}}}(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function ft(e){const t=function(e){const t=ot(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:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(e){return Je(e,r)}function a(e){return Ze(e,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:d}=dt({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=Re;return r?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==o||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}{const e=Te(s);if(!(ct<(a=e)&&ake($e(e,t.nByteLength));function h(e){return e>r>>lt}const p=(e,t,n)=>Te(e.slice(t,n));class y{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 y(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=at.toSig(Oe("DER",e));return new y(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 y(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:i}=this,l=w(Oe("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?r+t.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&i?"03":"02",h=c.fromHex(d+f(u)),p=a(u),y=s(-l*p),g=s(o*p),m=c.BASE.multiplyAndAddUnsafe(h,y,g);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Ce(this.toDERHex())}toDERHex(){return at.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ce(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const g={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=tt(t.n);return function(e,t,n=!1){const r=e.length,o=et(t),i=tt(t);if(r<16||r1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=Je(n?Te(e):_e(e),t-De)+De;return n?Ie(s,o):$e(s,o)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function m(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===o||r===i:n?r===2*o||r===2*i:e instanceof c}const v=t.bits2int||function(e){const n=Te(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},w=t.bits2int_modN||function(e){return s(v(e))},b=Pe(t.nBitLength);function x(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(ct<=e&&ee in o))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=t;let{lowS:f,prehash:p,extraEntropy:g}=o;null==f&&(f=!0),e=Oe("msgHash",e),p&&(e=Oe("prehashed msgHash",i(e)));const m=w(e),b=l(r),E=[x(b),x(m)];if(null!=g){const e=!0===g?u(n.BYTES):g;E.push(Oe("extraEntropy",e))}const S=Re(...E),A=m;return{seed:S,k2sig:function(e){const t=v(e);if(!d(t))return;const n=a(t),r=c.BASE.multiply(t).toAffine(),o=s(r.x);if(o===ct)return;const i=s(n*s(A+o*b));if(i===ct)return;let l=(r.x===o?0:2)|Number(r.y<),u=i;return f&&h(i)&&(u=function(e){return h(e)?s(-e):e}(i),l^=1),new y(o,u,l)}}}const k={lowS:t.lowS,prehash:!1},S={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(m(e))throw new Error("first arg must be private key");if(!m(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:o,k2sig:i}=E(e,n,r),s=t;return Ne(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(e,n,r,o=S){const i=e;if(n=Oe("msgHash",n),r=Oe("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:l,prehash:u}=o;let d,f;try{if("string"==typeof i||i instanceof Uint8Array)try{d=y.fromDER(i)}catch(e){if(!(e instanceof at.Err))throw e;d=y.fromCompact(i)}else{if("object"!=typeof i||"bigint"!=typeof i.r||"bigint"!=typeof i.s)throw new Error("PARSE");{const{r:e,s:t}=i;d=new y(e,t)}}f=c.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(l&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:h,s:p}=d,g=w(n),m=a(p),v=s(g*m),b=s(h*m),x=c.BASE.multiplyAndAddUnsafe(f,v,b)?.toAffine();return!!x&&s(x.x)===h},ProjectivePoint:c,Signature:y,utils:g}}BigInt(4);let ht=class extends ae{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");X(e.outputLen),X(e.blockLen)}(e);const n=se(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew ht(e,t).update(n).digest(); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:it,hexToBytes:st}=Fe,at={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=at;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:it(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=at,n="string"==typeof e?st(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=at._parseInt(n.subarray(2)),{d:s,l:a}=at._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s:s}},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},r=t(n(e.s)),o=t(n(e.r)),i=r.length/2,s=o.length/2,a=n(i),l=n(s);return`30${n(s+i+4)}02${l}${o}02${a}${r}`}},lt=BigInt(0),ct=BigInt(1);BigInt(2);const ut=BigInt(3);function dt(e){const t=function(e){const t=ot(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:r,a:o}=t;if(n){if(!r.eql(o,r.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,r=t.toBytes||((e,t,r)=>{const o=t.toAffine();return Oe(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),o=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 i(e){const{a:r,b:o}=t,i=n.sqr(e),s=n.mul(i,e);return n.add(n.add(s,n.mul(e,r)),o)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"==typeof e&<n.eql(e,n.ZERO);return o(t)&&o(r)?d.ZERO:new d(t,r,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(o(Re("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(l(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:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw new Error("bad point: x or y not FE");const o=n.sqr(r),s=i(e);if(!n.eql(o,s))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:r,pz:o}=this,{px:i,py:s,pz:a}=e,l=n.eql(n.mul(t,a),n.mul(i,o)),c=n.eql(n.mul(r,a),n.mul(s,o));return l&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,ut),{px:i,py:s,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,f=n.mul(i,i),h=n.mul(s,s),p=n.mul(a,a),g=n.mul(i,s);return g=n.add(g,g),u=n.mul(i,a),u=n.add(u,u),l=n.mul(e,u),c=n.mul(o,p),c=n.add(l,c),l=n.sub(h,c),c=n.add(h,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(o,u),p=n.mul(e,p),g=n.sub(f,p),g=n.mul(e,g),g=n.add(g,u),u=n.add(f,f),f=n.add(u,f),f=n.add(f,p),f=n.mul(f,g),c=n.add(c,f),p=n.mul(s,a),p=n.add(p,p),f=n.mul(p,g),l=n.sub(l,f),u=n.mul(p,h),u=n.add(u,u),u=n.add(u,u),new d(l,c,u)}add(e){u(e);const{px:r,py:o,pz:i}=this,{px:s,py:a,pz:l}=e;let c=n.ZERO,f=n.ZERO,h=n.ZERO;const p=t.a,g=n.mul(t.b,ut);let m=n.mul(r,s),y=n.mul(o,a),v=n.mul(i,l),w=n.add(r,o),b=n.add(s,a);w=n.mul(w,b),b=n.add(m,y),w=n.sub(w,b),b=n.add(r,i);let E=n.add(s,l);return b=n.mul(b,E),E=n.add(m,v),b=n.sub(b,E),E=n.add(o,i),c=n.add(a,l),E=n.mul(E,c),c=n.add(y,v),E=n.sub(E,c),h=n.mul(p,b),c=n.mul(g,v),h=n.add(c,h),c=n.sub(y,h),h=n.add(y,h),f=n.mul(c,h),y=n.add(m,m),y=n.add(y,m),v=n.mul(p,v),b=n.mul(g,b),y=n.add(y,v),v=n.sub(m,v),v=n.mul(p,v),b=n.add(b,v),m=n.mul(y,b),f=n.add(f,m),m=n.mul(E,b),c=n.mul(w,c),c=n.sub(c,m),m=n.mul(w,y),h=n.mul(E,h),h=n.add(h,m),new d(c,f,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return h.wNAFCached(this,c,e,e=>{const t=n.invertBatch(e.map(e=>e.pz));return e.map((e,n)=>e.toAffine(t[n])).map(d.fromAffine)})}multiplyUnsafe(e){const r=d.ZERO;if(e===lt)return r;if(a(e),e===ct)return this;const{endo:o}=t;if(!o)return h.unsafeLadder(this,e);let{k1neg:i,k1:s,k2neg:l,k2:c}=o.splitScalar(e),u=r,f=r,p=this;for(;s>lt||c>lt;)s&ct&&(u=u.add(p)),c&ct&&(f=f.add(p)),p=p.double(),s>>=ct,c>>=ct;return i&&(u=u.negate()),l&&(f=f.negate()),f=new d(n.mul(f.px,o.beta),f.py,f.pz),u.add(f)}multiply(e){a(e);let r,o,i=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:l}=s.splitScalar(i);let{p:c,f:u}=this.wNAF(t),{p:f,f:p}=this.wNAF(l);c=h.constTimeNegate(e,c),f=h.constTimeNegate(a,f),f=new d(n.mul(f.px,s.beta),f.py,f.pz),r=c.add(f),o=u.add(p)}else{const{p:e,f:t}=this.wNAF(i);r=e,o=t}return d.normalizeZ([r,o])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,o=(e,t)=>t!==lt&&t!==ct&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:o}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(o));const s=n.mul(t,e),a=n.mul(r,e),l=n.mul(o,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===ct)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===ct?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return ke(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const f=t.nBitLength,h=function(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,o=t;for(;n>nt;)n&rt&&(r=r.add(o)),o=o.double(),n>>=rt;return r},precomputeWindow(e,t){const{windows:n,windowSize:o}=r(t),i=[];let s=e,a=s;for(let e=0;e>=f,r>a&&(r-=d,i+=rt);const s=t,h=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?c=c.add(n(p,o[s])):l=l.add(n(g,o[h]))}return{p:l,f:c}},wNAFCached(e,t,n,r){const o=e._WINDOW_SIZE||1;let i=t.get(e);return i||(i=this.precomputeWindow(e,o),1!==o&&t.set(e,r(i))),this.wNAF(o,i,n)}}}(d,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:s}}function ft(e){const t=function(e){const t=ot(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:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(e){return Ve(e,r)}function a(e){return Ze(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=dt({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=Oe;return r?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==o||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}{const e=Te(s);if(!(lt<(a=e)&&ake(Ie(e,t.nByteLength));function h(e){return e>r>>ct}const p=(e,t,n)=>Te(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=Re("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=at.toSig(Re("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:r,s:o,recovery:i}=this,c=w(Re("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?r+t.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=1&i?"03":"02",h=l.fromHex(d+f(u)),p=a(u),g=s(-c*p),m=s(o*p),y=l.BASE.multiplyAndAddUnsafe(h,g,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Ae(this.toDERHex())}toDERHex(){return at.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ae(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=tt(t.n);return function(e,t,n=!1){const r=e.length,o=et(t),i=tt(t);if(r<16||r1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=Ve(n?Te(e):_e(e),t-De)+De;return n?$e(s,o):Ie(s,o)}(t.randomBytes(e),t.n)},precompute:(e=8,t=l.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){const t=e instanceof Uint8Array,n="string"==typeof e,r=(t||n)&&e.length;return t?r===o||r===i:n?r===2*o||r===2*i:e instanceof l}const v=t.bits2int||function(e){const n=Te(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},w=t.bits2int_modN||function(e){return s(v(e))},b=Pe(t.nBitLength);function E(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(lt<=e&&ee in o))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=t;let{lowS:f,prehash:p,extraEntropy:m}=o;null==f&&(f=!0),e=Re("msgHash",e),p&&(e=Re("prehashed msgHash",i(e)));const y=w(e),b=c(r),x=[E(b),E(y)];if(null!=m){const e=!0===m?u(n.BYTES):m;x.push(Re("extraEntropy",e))}const S=Oe(...x),C=y;return{seed:S,k2sig:function(e){const t=v(e);if(!d(t))return;const n=a(t),r=l.BASE.multiply(t).toAffine(),o=s(r.x);if(o===lt)return;const i=s(n*s(C+o*b));if(i===lt)return;let c=(r.x===o?0:2)|Number(r.y&ct),u=i;return f&&h(i)&&(u=function(e){return h(e)?s(-e):e}(i),c^=1),new g(o,u,c)}}}const k={lowS:t.lowS,prehash:!1},S={lowS:t.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return l.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return l.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,r=k){const{seed:o,k2sig:i}=x(e,n,r),s=t;return Le(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(e,n,r,o=S){const i=e;if(n=Re("msgHash",n),r=Re("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=o;let d,f;try{if("string"==typeof i||i instanceof Uint8Array)try{d=g.fromDER(i)}catch(e){if(!(e instanceof at.Err))throw e;d=g.fromCompact(i)}else{if("object"!=typeof i||"bigint"!=typeof i.r||"bigint"!=typeof i.s)throw new Error("PARSE");{const{r:e,s:t}=i;d=new g(e,t)}}f=l.fromHex(r)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:h,s:p}=d,m=w(n),y=a(p),v=s(m*y),b=s(h*y),E=l.BASE.multiplyAndAddUnsafe(f,v,b)?.toAffine();return!!E&&s(E.x)===h},ProjectivePoint:l,Signature:g,utils:m}}BigInt(4);let ht=class extends ae{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");X(e.outputLen),X(e.blockLen)}(e);const n=se(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;enew ht(e,t).update(n).digest(); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -function yt(e){return{hash:e,hmac:(t,...n)=>pt(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!re(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:le}}pt.create=(e,t)=>new ht(e,t); +function gt(e){return{hash:e,hmac:(t,...n)=>pt(e,t,function(...e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;return e.forEach(e=>{if(!re(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}(...n)),randomBytes:ce}}pt.create=(e,t)=>new ht(e,t); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const gt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),mt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),vt=BigInt(1),wt=BigInt(2),bt=(e,t)=>(e+t/wt)/t;function xt(e){const t=gt,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=Ge(u,n,t)*u%t,f=Ge(d,n,t)*u%t,h=Ge(f,wt,t)*l%t,p=Ge(h,o,t)*h%t,y=Ge(p,i,t)*p%t,g=Ge(y,a,t)*y%t,m=Ge(g,c,t)*g%t,v=Ge(m,a,t)*y%t,w=Ge(v,n,t)*u%t,b=Ge(w,s,t)*p%t,x=Ge(b,r,t)*l%t,E=Ge(x,wt,t);if(!Et.eql(Et.sqr(E),e))throw new Error("Cannot find square root");return E}const Et=function(e,t,n=!1,r={}){if(e<=Fe)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Xe(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Ye(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:Pe(o),ZERO:Fe,ONE:De,create:t=>Je(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Fe<=t&&te===Fe,isOdd:e=>(e&De)===De,neg:t=>Je(-t,e),eql:(e,t)=>e===t,sqr:t=>Je(t*t,e),add:(t,n)=>Je(t+n,e),sub:(t,n)=>Je(t-n,e),mul:(t,n)=>Je(t*n,e),pow:(e,t)=>function(e,t,n){if(n 0");if(n===Fe)return e.ONE;if(n===De)return t;let r=e.ONE,o=t;for(;n>Fe;)n&De&&(r=e.mul(r,o)),o=e.sqr(o),n>>=De;return r}(a,e,t),div:(t,n)=>Je(t*Ze(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Ze(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r)),e.ONE),o=e.inv(r);return t.reduceRight((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r)),o),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Ie(e,i):$e(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?_e(e):Te(e)}});return Object.freeze(a)}(gt,void 0,void 0,{sqrt:xt}),kt=function(e,t){const n=t=>ft({...e,...yt(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:Et,n:mt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=mt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-vt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=bt(i*e,t),c=bt(-r*e,t);let l=Je(e-a*n-c*o,t),u=Je(-a*r-c*i,t);const d=l>s,f=u>s;if(d&&(l=t-l),f&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}}},me),St=BigInt(0),At=e=>"bigint"==typeof e&&Ste.charCodeAt(0)));n=Re(t,t),Ct[e]=n}return me(Re(n,...t))}const _t=e=>e.toRawBytes(!0).slice(1),$t=e=>$e(e,32),It=e=>Je(e,gt),Ot=e=>Je(e,mt),Rt=kt.ProjectivePoint;function Pt(e){let t=kt.utils.normPrivateKeyToScalar(e),n=Rt.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Ot(-t),bytes:_t(n)}}function Lt(e){if(!At(e))throw new Error("bad x: need 0 < x < p");const t=It(e*e);let n=xt(It(t*e+BigInt(7)));n%wt!==St&&(n=It(-n));const r=new Rt(e,n,vt);return r.assertValidity(),r}function Bt(...e){return Ot(Te(Tt("BIP0340/challenge",...e)))}function Nt(e){return Pt(e).bytes}function Ut(e,t,n=le(32)){const r=Oe("message",e),{bytes:o,scalar:i}=Pt(t),s=Oe("auxRand",n,32),a=$t(i^Te(Tt("BIP0340/aux",s))),c=Tt("BIP0340/nonce",a,o,r),l=Ot(Te(c));if(l===St)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Pt(l),f=Bt(u,o,r),h=new Uint8Array(64);if(h.set(u,0),h.set($t(Ot(d+f*i)),32),!jt(h,r,o))throw new Error("sign: Invalid signature produced");return h}function jt(e,t,n){const r=Oe("signature",e,64),o=Oe("message",t),i=Oe("publicKey",n,32);try{const e=Lt(Te(i)),t=Te(r.subarray(0,32));if(!At(t))return!1;const n=Te(r.subarray(32,64));if(!("bigint"==typeof(l=n)&&St({getPublicKey:Nt,sign:Ut,verify:jt,utils:{randomPrivateKey:kt.utils.randomPrivateKey,lift_x:Lt,pointToBytes:_t,numberToBytesBE:$e,bytesToNumberBE:Te,taggedHash:Tt,mod:Je}}))(),Ft="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Dt=e=>e instanceof Uint8Array,Ht=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),qt=(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 Wt(e){if(!Dt(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!Dt(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}class Gt{clone(){return this._cloneInto()}}function Zt(e){const t=t=>e().update(Jt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Yt(e=32){if(Ft&&"function"==typeof Ft.getRandomValues)return Ft.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function Qt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Xt(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 en={number:Qt,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:Xt,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Qt(e.outputLen),Qt(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){Xt(e);const n=t.outputLen;if(e.lengthr-i&&(this.process(n,0),i=0);for(let e=i;e>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=Ht(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,rn=(e,t,n)=>e&t^e&n^t&n,on=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]),sn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=new Uint32Array(64);class cn extends tn{constructor(){super(64,32,8,!1),this.A=0|sn[0],this.B=0|sn[1],this.C=0|sn[2],this.D=0|sn[3],this.E=0|sn[4],this.F=0|sn[5],this.G=0|sn[6],this.H=0|sn[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)an[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=an[e-15],n=an[e-2],r=qt(t,7)^qt(t,18)^t>>>3,o=qt(n,17)^qt(n,19)^n>>>10;an[e]=o+an[e-7]+r+an[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(qt(s,6)^qt(s,11)^qt(s,25))+nn(s,a,c)+on[e]+an[e]|0,u=(qt(n,2)^qt(n,13)^qt(n,22))+rn(n,r,o)|0;l=c,c=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,o,i,s,a,c,l)}roundClean(){an.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class ln extends cn{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 un=Zt(()=>new cn);Zt(()=>new ln);var dn=Symbol("verified");function fn(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!==r.indexOf(t)))return!1}return!(e.since&&t.created_ate.until)}async function xn(){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 En,kn=e=>(e[dn]=!0,!0),Sn=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},An=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 gn;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=pn(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing}static async connect(e,t){const n=new An(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 xn();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 r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return e.slice(r+1,i)}(e);if(t){const n=this.openSubs.get(t);if(!n)return;const r=function(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}(e,"id"),o=n.alreadyHaveEvent?.(r);if(n.receivedEvent?.(this,r),o)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,r)=>{try{let o=await e(function(e,t){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}(this.url,t)),i=setTimeout(()=>{let e=this.openEventPublishes.get(o.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(o.id))},this.publishTimeout);this.openEventPublishes.set(o.id,{resolve:n,reject:r,timeout:i}),this.send('["AUTH",'+JSON.stringify(o)+"]")}catch(e){console.warn("subscribe auth function failed:",e)}})),this.authPromise}async publish(e){const t=new Promise((t,n)=>{const r=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:r})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;const n=t?.id||"count:"+this.serial,r=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),r}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,r=new Cn(this,n,e,t);return this.openSubs.set(n,r),r}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()}},Cn=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,r){this.relay=e,this.filters=n,this.id=t,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||e.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.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 Sn))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}},Tn=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=pn(e);let n=this.relays.get(e);return n||(n=new An(e,{verifyEvent:this.trustedRelayURLs.has(e)?kn: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(pn).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){n.onauth=n.onauth||n.doauth;const r=[];for(let n=0;ne.url===o)||r.push({url:o,filter:t})}return this.subscribeMap(r,n)}subscribeMany(e,t,n){n.onauth=n.onauth||n.doauth;const r=[],o=[];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 o=new Set,i=[],s=[];let a=n=>{s[n]||(s[n]=!0,s.filter(e=>e).length===e.length&&(t.oneose?.(),a=()=>{}))};const c=[];let l=(n,r)=>{c[n]||(a(n),c[n]=r,c.filter(e=>e).length===e.length&&(t.onclose?.(c),l=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=o.has(e);return o.add(e),n},d=Promise.all(r.map(async({url:e,filters:n},r)=>{let o;try{o=await this.ensureRelay(e,{connectionTimeout:t.maxWait?Math.max(.8*t.maxWait,t.maxWait-1e3):void 0})}catch(e){return void l(r,e?.message||String(e))}let s=o.subscribe(n,{...t,oneose:()=>a(r),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?o.auth(t.onauth).then(()=>{o.subscribe(n,{...t,oneose:()=>a(r),onclose:e=>{l(r,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait})}).catch(e=>{l(r,`auth was required and attempted, but failed with: ${e}`)}):l(r,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait});i.push(s)}));return{async close(e){await d,i.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){n.onauth=n.onauth||n.doauth;const r=this.subscribe(e,t,{...n,oneose(){r.close("closed automatically on eose")}});return r}subscribeManyEose(e,t,n){n.onauth=n.onauth||n.doauth;const r=this.subscribeMany(e,t,{...n,oneose(){r.close("closed automatically on eose")}});return r}async querySync(e,t,n){return new Promise(async r=>{const o=[];this.subscribeEose(e,t,{...n,onevent(e){o.push(e)},onclose(e){r(o)}})})}async get(e,t,n){t.limit=1;const r=await this.querySync(e,t,n);return r.sort((e,t)=>t.created_at-e.created_at),r[0]||null}publish(e,t,n){return e.map(pn).map(async(e,r,o)=>{if(o.indexOf(e)!==r)return Promise.reject("duplicate url");let i=await this.ensureRelay(e);return i.publish(t).catch(async e=>{if(e instanceof Error&&e.message.startsWith("auth-required: ")&&n?.onauth)return await i.auth(n.onauth),i.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(i)}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{En=WebSocket}catch{}var _n=class extends Tn{constructor(e){super({verifyEvent:wn,websocketImplementation:En,...e})}}; -/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $n(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function In(...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),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}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($n(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 Rn(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 Pn(e,t="="){if($n(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 r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function Ln(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function Bn(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 r=0;const o=[],i=Array.from(e);for(i.forEach(e=>{if($n(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,s=!0;for(let o=r;ot?Nn(t,e%t):e,Un=(e,t)=>e+(t-Nn(e,t));function jn(e,t,n,r){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(Un(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Un(t,n)}`);let o=0,i=0;const s=2**n-1,a=[];for(const r of e){if($n(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)a.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<=t)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&a.push(o>>>0),a}function Mn(e,t=!1){if($n(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Un(8,e)>32||Un(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 Fn(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 Dn=In(Mn(4),On("0123456789ABCDEF"),Rn("")),Hn=In(Mn(5),On("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Pn(5),Rn(""));In(Mn(5),On("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Pn(5),Rn("")),In(Mn(5),On("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Rn(""),Ln(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const qn=In(Mn(6),On("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Pn(6),Rn("")),zn=In(Mn(6),On("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Pn(6),Rn("")),Wn=e=>{return In(($n(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Bn(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(Bn(e,t,256))}}),On(e),Rn(""));var t},Kn=Wn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Wn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Wn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Jn=[0,2,3,5,6,7,9,10,11],Vn={encode(e){let t="";for(let n=0;n>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=Zn[e]);return n}function Qn(e,t,n=1){const r=e.length;let o=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);o=Yn(o)^n>>5}o=Yn(o);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=e.slice(0,o),s=e.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=Gn.decode(s).slice(0,-6),c=Qn(i,a,t);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(e,n,r=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 o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${Gn.encode(n)}${Qn(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:Fn(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}const er=Xn("bech32");Xn("bech32m");const tr={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:In(Mn(4),On("0123456789abcdef"),Rn(""),Ln(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:Dn,base32:Hn,base64:qn,base64url:zn,base58:Kn,base58xmr:Vn};function nr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function rr(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function or(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(tr).join(", ");const ir=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const sr=16;function ar(e){return e<<1^283&-(e>>7)}function cr(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=ar(e);return n}const lr=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=ar(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return t})(),ur=lr.map((e,t)=>lr.indexOf(t)),dr=e=>e<<24|e>>>8,fr=e=>e<<8|e>>>24;function hr(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(fr),o=r.map(fr),i=o.map(fr),s=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){const u=256*t+l;s[u]=n[t]^r[l],a[u]=o[t]^i[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:o,T3:i,T01:s,T23:a}}const pr=hr(lr,e=>cr(e,3)<<24|e<<16|e<<8|cr(e,2)),yr=hr(ur,e=>cr(e,11)<<24|cr(e,13)<<16|cr(e,9)<<8|cr(e,14)),gr=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=ar(n))e[t]=n;return e})();function mr(e){or(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=pr,r=ir(e),o=r.length,i=e=>wr(n,e,e,e,e),s=new Uint32Array(t+28);s.set(r);for(let e=o;e6&&e%o===4&&(t=i(t)),s[e]=s[e-o]^t}return s}function vr(e,t,n,r,o,i){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|i>>>24&255]}function wr(e,t,n,r,o){return e[255&t|65280&n]|e[r>>>16&255|o>>>16&65280]<<16}function br(e,t,n,r,o){const{sbox2:i,T01:s,T23:a}=pr;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],o^=e[c++];const l=e.length/4-2;for(let i=0;i{const i=mr(e),{b:s,o:a,out:c}=function(e,t,n){let r=e.length;const o=r%sr;if(!t&&0!==o)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=ir(e);if(t){let e=sr-o;e||(e=sr),r+=e}const s=Er(r,n);return{b:i,o:ir(s),out:s}}(n,r,o),l=ir(t);let u=l[0],d=l[1],f=l[2],h=l[3],p=0;for(;p+4<=s.length;)u^=s[p+0],d^=s[p+1],f^=s[p+2],h^=s[p+3],({s0:u,s1:d,s2:f,s3:h}=br(i,u,d,f,h)),a[p++]=u,a[p++]=d,a[p++]=f,a[p++]=h;if(r){const e=function(e){const t=new Uint8Array(16),n=ir(t);t.set(e);const r=sr-e.length;for(let e=sr-r;e{!function(e){if(or(e),e.length%sr!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const i=function(e){const t=mr(e),n=t.slice(),r=t.length,{sbox2:o}=pr,{T0:i,T1:s,T2:a,T3:c}=yr;for(let e=0;e>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}(e),s=ir(t),a=Er(n.length,o),c=ir(n),l=ir(a);let u=s[0],d=s[1],f=s[2],h=s[3];for(let e=0;e+4<=c.length;){const t=u,n=d,r=f,o=h;u=c[e+0],d=c[e+1],f=c[e+2],h=c[e+3];const{s0:s,s1:a,s2:p,s3:y}=xr(i,u,d,f,h);l[e++]=s^t,l[e++]=a^n,l[e++]=p^r,l[e++]=y^o}return i.fill(0),function(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=e.subarray(0,-r);for(let t=0;tUint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Tr=Cr("expand 16-byte k"),_r=Cr("expand 32-byte k"),$r=ir(Tr),Ir=ir(_r);function Or(e,t){return e<>>32-t}function Rr(e){return e.byteOffset%4==0}Ir.slice();const Pr=2**32-1,Lr=new Uint32Array;function Br(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return nr(o),nr(s),rr(i),rr(n),(t,a,c,l,u=0)=>{or(t),or(a),or(c);const d=c.length;if(l||(l=new Uint8Array(d)),or(l),nr(u),u<0||u>=Pr)throw new Error("arx: counter overflow");if(l.length=Pr)throw new Error("arx: counter overflow");const y=Math.min(64,c-p);if(d&&64===y){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,h[t]=f[t]^u[n];p+=64;continue}for(let e,t=0;t0;)f.pop().fill(0);return l}}function Nr(e,t,n,r,o,i=20){let s=e[0],a=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],h=t[3],p=t[4],y=t[5],g=t[6],m=t[7],v=o,w=n[0],b=n[1],x=n[2],E=s,k=a,S=c,A=l,C=u,T=d,_=f,$=h,I=p,O=y,R=g,P=m,L=v,B=w,N=b,U=x;for(let e=0;er?e.create().update(n).digest():n);for(let e=0;enew jr(e,t).update(n).digest();Mr.create=(e,t)=>new jr(e,t);const Fr=new Uint8Array([0]),Dr=new Uint8Array;var Hr=Object.defineProperty,qr=(e,t)=>{for(var n in t)Hr(e,n,{get:t[n],enumerable:!0})},zr=Symbol("verified");function Wr(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;tXr,QueueNode:()=>Qr,binarySearch:()=>Yr,bytesToHex:()=>Wt,hexToBytes:()=>Kt,insertEventIntoAscendingList:()=>Zr,insertEventIntoDescendingList:()=>Gr,normalizeURL:()=>Vr,utf8Decoder:()=>Kr,utf8Encoder:()=>Jr});var Kr=new TextDecoder("utf-8"),Jr=new TextEncoder;function Vr(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function Gr(e,t){const[n,r]=Yr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function Zr(e,t){const[n,r]=Yr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return r||e.splice(n,0,t),e}function Yr(e,t){let n=0,r=e.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t(e[o]);if(0===i)return[o,!0];i<0?r=o-1:n=o+1}return[n,!1]}var Qr=class{value;next=null;prev=null;constructor(e){this.value=e}},Xr=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new Qr(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}};function eo(e){return Wt(un(Jr.encode(function(e){if(!Wr(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}(e))))}var to=new class{generateSecretKey(){return Mt.utils.randomPrivateKey()}getPublicKey(e){return Wt(Mt.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Wt(Mt.getPublicKey(t)),n.id=eo(n),n.sig=Wt(Mt.sign(eo(n),t)),n[zr]=!0,n}verifyEvent(e){if("boolean"==typeof e[zr])return e[zr];const t=eo(e);if(t!==e.id)return e[zr]=!1,!1;try{const n=Mt.verify(e.sig,t,e.pubkey);return e[zr]=n,n}catch(t){return e[zr]=!1,!1}}},no=to.generateSecretKey,ro=to.getPublicKey,oo=to.finalizeEvent,io=to.verifyEvent,so={};function ao(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function co(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function lo(e){return 2e4<=e&&e<3e4}function uo(e){return 3e4<=e&&e<4e4}function fo(e){return ao(e)?"regular":co(e)?"replaceable":lo(e)?"ephemeral":uo(e)?"parameterized":"unknown"}function ho(e,t){const n=t instanceof Array?t:[t];return Wr(e)&&n.includes(e.kind)||!1}qr(so,{Application:()=>Ai,BadgeAward:()=>Eo,BadgeDefinition:()=>vi,BlockedRelaysList:()=>Xo,BookmarkList:()=>Zo,Bookmarksets:()=>yi,Calendar:()=>Ri,CalendarEventRSVP:()=>Pi,ChannelCreation:()=>Co,ChannelHideMessage:()=>$o,ChannelMessage:()=>_o,ChannelMetadata:()=>To,ChannelMuteUser:()=>Io,ClassifiedListing:()=>_i,ClientAuth:()=>ai,CommunitiesList:()=>Yo,CommunityDefinition:()=>Ni,CommunityPostApproval:()=>Mo,Contacts:()=>mo,CreateOrUpdateProduct:()=>xi,CreateOrUpdateStall:()=>bi,Curationsets:()=>gi,Date:()=>Ii,DirectMessageRelaysList:()=>ri,DraftClassifiedListing:()=>$i,DraftLong:()=>ki,Emojisets:()=>Si,EncryptedDirectMessage:()=>vo,EventDeletion:()=>wo,FileMetadata:()=>Po,FileServerPreference:()=>oi,Followsets:()=>fi,GenericRepost:()=>Ao,Genericlists:()=>hi,GiftWrap:()=>Ro,HTTPAuth:()=>di,Handlerinformation:()=>Bi,Handlerrecommendation:()=>Li,Highlights:()=>Ko,InterestsList:()=>ti,Interestsets:()=>wi,JobFeedback:()=>Ho,JobRequest:()=>Fo,JobResult:()=>Do,Label:()=>jo,LightningPubRPC:()=>si,LiveChatMessage:()=>Lo,LiveEvent:()=>Ci,LongFormArticle:()=>Ei,Metadata:()=>po,Mutelist:()=>Jo,NWCWalletInfo:()=>ii,NWCWalletRequest:()=>ci,NWCWalletResponse:()=>li,NostrConnect:()=>ui,OpenTimestamps:()=>Oo,Pinlist:()=>Vo,PrivateDirectMessage:()=>So,ProblemTracker:()=>Bo,ProfileBadges:()=>mi,PublicChatsList:()=>Qo,Reaction:()=>xo,RecommendRelay:()=>go,RelayList:()=>Go,Relaysets:()=>pi,Report:()=>No,Reporting:()=>Uo,Repost:()=>bo,Seal:()=>ko,SearchRelaysList:()=>ei,ShortTextNote:()=>yo,Time:()=>Oi,UserEmojiList:()=>ni,UserStatuses:()=>Ti,Zap:()=>Wo,ZapGoal:()=>qo,ZapRequest:()=>zo,classifyKind:()=>fo,isAddressableKind:()=>uo,isEphemeralKind:()=>lo,isKind:()=>ho,isRegularKind:()=>ao,isReplaceableKind:()=>co});var po=0,yo=1,go=2,mo=3,vo=4,wo=5,bo=6,xo=7,Eo=8,ko=13,So=14,Ao=16,Co=40,To=41,_o=42,$o=43,Io=44,Oo=1040,Ro=1059,Po=1063,Lo=1311,Bo=1971,No=1984,Uo=1984,jo=1985,Mo=4550,Fo=5999,Do=6999,Ho=7e3,qo=9041,zo=9734,Wo=9735,Ko=9802,Jo=1e4,Vo=10001,Go=10002,Zo=10003,Yo=10004,Qo=10005,Xo=10006,ei=10007,ti=10015,ni=10030,ri=10050,oi=10096,ii=13194,si=21e3,ai=22242,ci=23194,li=23195,ui=24133,di=27235,fi=3e4,hi=30001,pi=30002,yi=30003,gi=30004,mi=30008,vi=30009,wi=30015,bi=30017,xi=30018,Ei=30023,ki=30024,Si=30030,Ai=30078,Ci=30311,Ti=30315,_i=30402,$i=30403,Ii=31922,Oi=31923,Ri=31924,Pi=31925,Li=31989,Bi=31990,Ni=34550;function Ui(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}function ji(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,o=e.slice(r),i=Math.min(o.indexOf(","),o.indexOf("}"));return parseInt(o.slice(0,i),10)}function Mi(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return e.slice(r+1,i)}function Fi(e,t){return t===Ui(e,"id")}function Di(e,t){return t===Ui(e,"pubkey")}function Hi(e,t){return t===ji(e,"kind")}qr({},{getHex64:()=>Ui,getInt:()=>ji,getSubscriptionId:()=>Mi,matchEventId:()=>Fi,matchEventKind:()=>Hi,matchEventPubkey:()=>Di});function qi(e,t){return{kind:ai,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}qr({},{makeAuthEvent:()=>qi});try{WebSocket}catch{}try{WebSocket}catch{}var zi={};qr(zi,{BECH32_REGEX:()=>Ji,Bech32MaxSize:()=>Ki,NostrTypeGuard:()=>Wi,decode:()=>Gi,decodeNostrURI:()=>Vi,encodeBytes:()=>ts,naddrEncode:()=>os,neventEncode:()=>rs,noteEncode:()=>Xi,nprofileEncode:()=>ns,npubEncode:()=>Qi,nsecEncode:()=>Yi});var Wi={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||"")},Ki=5e3,Ji=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function Vi(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),Gi(e)}catch(e){return{type:"invalid",data:null}}}function Gi(e){let{prefix:t,words:n}=er.decode(e,Ki),r=new Uint8Array(er.fromWords(n));switch(t){case"nprofile":{let e=Zi(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Wt(e[0][0]),relays:e[1]?e[1].map(e=>Kr.decode(e)):[]}}}case"nevent":{let e=Zi(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Wt(e[0][0]),relays:e[1]?e[1].map(e=>Kr.decode(e)):[],author:e[2]?.[0]?Wt(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(Wt(e[3][0]),16):void 0}}}case"naddr":{let e=Zi(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Kr.decode(e[0][0]),pubkey:Wt(e[2][0]),kind:parseInt(Wt(e[3][0]),16),relays:e[1]?e[1].map(e=>Kr.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:Wt(r)};default:throw new Error(`unknown prefix ${t}`)}}function Zi(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],o=n.slice(2,2+r);if(n=n.slice(2+r),o.lengthJr.encode(e))}))}function rs(e){let t;return void 0!==e.kind&&(t=function(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}(e.kind)),es("nevent",is({0:[Kt(e.id)],1:(e.relays||[]).map(e=>Jr.encode(e)),2:e.author?[Kt(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function os(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),es("naddr",is({0:[Jr.encode(e.identifier)],1:(e.relays||[]).map(e=>Jr.encode(e)),2:[Kt(e.pubkey)],3:[new Uint8Array(t)]}))}function is(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),Vt(...t)}var ss={};function as(e,t,n){const r=e instanceof Uint8Array?Wt(e):e,o=ls(kt.getSharedSecret(r,"02"+t));let i=Uint8Array.from(Yt(16)),s=Jr.encode(n),a=kr(o,i).encrypt(s);return`${qn.encode(new Uint8Array(a))}?iv=${qn.encode(new Uint8Array(i.buffer))}`}function cs(e,t,n){const r=e instanceof Uint8Array?Wt(e):e;let[o,i]=n.split("?iv="),s=ls(kt.getSharedSecret(r,"02"+t)),a=qn.decode(i),c=qn.decode(o),l=kr(s,a).decrypt(c);return Kr.decode(l)}function ls(e){return e.slice(1,33)}qr(ss,{decrypt:()=>cs,encrypt:()=>as});qr({},{NIP05_REGEX:()=>ds,isNip05:()=>fs,isValid:()=>gs,queryProfile:()=>ys,searchDomain:()=>ps,useFetchImplementation:()=>hs});var us,ds=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,fs=e=>ds.test(e||"");try{us=fetch}catch(e){}function hs(e){us=e}async function ps(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await us(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function ys(e){const t=e.match(ds);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await us(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const o=await t.json(),i=o.names[n];return i?{pubkey:i,relays:o.relays?.[i]}:null}catch(e){return null}}async function gs(e,t){const n=await ys(t);return!!n&&n.pubkey===e}function ms(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let o=e.tags.length-1;o>=0;o--){const i=e.tags[o];if("e"===i[0]&&i[1]){const[e,o,s,a,c]=i,l={id:o,relays:s?[s]:[],author:c};if("root"===a){t.root=l;continue}if("reply"===a){t.reply=l;continue}if("mention"===a){t.mentions.push(l);continue}n?r=l:n=l,t.mentions.push(l);continue}if("q"===i[0]&&i[1]){const[e,n,r]=i;t.quotes.push({id:n,relays:r?[r]:[]})}"p"===i[0]&&i[1]&&t.profiles.push({pubkey:i[1],relays:i[2]?[i[2]]:[]})}return t.root||(t.root=r||n||t.reply),t.reply||(t.reply=n||t.root),[t.reply,t.root].forEach(e=>{if(!e)return;let n=t.mentions.indexOf(e);if(-1!==n&&t.mentions.splice(n,1),e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays?.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t.mentions.forEach(e=>{if(e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t}qr({},{parse:()=>ms});qr({},{fetchRelayInformation:()=>ws,useFetchImplementation:()=>vs});try{fetch}catch{}function vs(e){0}async function ws(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function bs(e){let t=0;for(let n=0;n<64;n+=8){const r=parseInt(e.substring(n,n+8),16);if(0!==r){t+=Math.clz32(r);break}t+=32}return t}function xs(e,t){let n=0;const r=e,o=["nonce",n.toString(),t.toString()];for(r.tags.push(o);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),o[1]=(++n).toString(),r.id=Es(r),bs(r.id)>=t)break}return r}function Es(e){return Wt(un(Jr.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}qr({},{fastEventHash:()=>Es,getPow:()=>bs,minePow:()=>xs});qr({},{unwrapEvent:()=>Vs,unwrapManyEvents:()=>Gs,wrapEvent:()=>Ks,wrapManyEvents:()=>Js});qr({},{createRumor:()=>Ms,createSeal:()=>Fs,createWrap:()=>Ds,unwrapEvent:()=>zs,unwrapManyEvents:()=>Ws,wrapEvent:()=>Hs,wrapManyEvents:()=>qs});var ks={};qr(ks,{decrypt:()=>Rs,encrypt:()=>Os,getConversationKey:()=>Cs,v2:()=>Ps});var Ss=1,As=65535;function Cs(e,t){const n=kt.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return en.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Mr(e,Jt(n),Jt(t))}(un,n,"nip44-v2")}function Ts(e,t){const n=function(e,t,n,r=32){if(en.hash(e),en.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/e.outputLen);void 0===n&&(n=Dr);const i=new Uint8Array(o*e.outputLen),s=Mr.create(e,t),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let t=0;tAs)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(_s(n)-n))}function Is(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=Vt(n,t);return Mr(un,e,r)}function Os(e,t,n=Yt(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=Ts(t,n),s=$s(e),a=Ur(r,o,s),c=Is(i,a,n);return qn.encode(Vt(new Uint8Array([2]),n,a,c))}function Rs(e,t){const{nonce:n,ciphertext:r,mac:o}=function(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=qn.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(2!==o)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:i,chacha_nonce:s,hmac_key:a}=Ts(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;rAs||n.length!==t||e.length!==2+_s(t))throw new Error("invalid padding");return Kr.decode(n)}(Ur(i,s,r))}var Ps={utils:{getConversationKey:Cs,calcPaddedLen:_s},encrypt:Os,decrypt:Rs},Ls=()=>Math.round(Date.now()/1e3),Bs=()=>Math.round(Ls()-172800*Math.random()),Ns=(e,t)=>Cs(e,t),Us=(e,t,n)=>Os(JSON.stringify(e),Ns(t,n)),js=(e,t)=>JSON.parse(Rs(e.content,Ns(t,e.pubkey)));function Ms(e,t){const n={created_at:Ls(),content:"",tags:[],...e,pubkey:ro(t)};return n.id=eo(n),n}function Fs(e,t,n){return oo({kind:ko,content:Us(e,t,n),created_at:Bs(),tags:[]},t)}function Ds(e,t){const n=no();return oo({kind:Ro,content:Us(e,n,t),created_at:Bs(),tags:[["p",t]]},n)}function Hs(e,t,n){return Ds(Fs(Ms(e,t),t,n),n)}function qs(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=ro(t),o=[Hs(e,t,r)];return n.forEach(n=>{o.push(Hs(e,t,n))}),o}function zs(e,t){const n=js(e,t);return js(n,t)}function Ws(e,t){let n=[];return e.forEach(e=>{n.push(zs(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function Ks(e,t,n,r,o){const i=function(e,t,n,r){const o={created_at:Math.ceil(Date.now()/1e3),kind:So,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{o.tags.push(t?["p",e,t]:["p",e])}),r&&o.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&o.tags.push(["subject",n]),o}(t,n,r,o);return Hs(i,e,t.publicKey)}function Js(e,t,n,r,o){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:ro(e)},...t].map(t=>Ks(e,t,n,r,o))}var Vs=zs,Gs=Ws;function Zs(e,t,n,r){let o;const i=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===yo?o=bo:(o=Ao,i.push(["k",String(t.kind)])),oo({kind:o,tags:i,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},r)}function Ys(e){if(![bo,Ao].includes(e.kind))return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function Qs(e,{skipVerification:t}={}){const n=Ys(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||io(r))?r:void 0}qr({},{finishRepostEvent:()=>Zs,getRepostedEvent:()=>Qs,getRepostedEventPointer:()=>Ys});qr({},{NOSTR_URI_REGEX:()=>Xs,parse:()=>ta,test:()=>ea});var Xs=new RegExp(`nostr:(${Ji.source})`);function ea(e){return"string"==typeof e&&new RegExp(`^${Xs.source}$`).test(e)}function ta(e){const t=e.match(new RegExp(`^${Xs.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:Gi(t[1])}}function na(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return oo({...e,kind:xo,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function ra(e){if(e.kind!==xo)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}qr({},{finishReactionEvent:()=>na,getReactedEventPointer:()=>ra});qr({},{parse:()=>sa});var oa=/\W/m,ia=/\W |\W$|$|,| /m;function*sa(e){const t=e.length;let n=0,r=0;for(;raa,channelHideMessageEvent:()=>ua,channelMessageEvent:()=>la,channelMetadataEvent:()=>ca,channelMuteUserEvent:()=>da});var aa=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return oo({kind:Co,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},ca=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return oo({kind:To,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},la=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),oo({kind:_o,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},ua=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return oo({kind:$o,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},da=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return oo({kind:Io,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};qr({},{EMOJI_SHORTCODE_REGEX:()=>fa,matchAll:()=>pa,regex:()=>ha,replaceAll:()=>ya});var fa=/:(\w+):/,ha=()=>new RegExp(`\\B${fa.source}\\B`,"g");function*pa(e){const t=e.matchAll(ha());for(const e of t)try{const[t,n]=e;yield{shortcode:t,name:n,start:e.index,end:e.index+t.length}}catch(e){}}function ya(e,t){return e.replaceAll(ha(),(e,n)=>t({shortcode:e,name:n}))}var ga;qr({},{useFetchImplementation:()=>ma,validateGithub:()=>va});try{ga=fetch}catch{}function ma(e){ga=e}async function va(e,t,n){try{return await(await ga(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function wa(e){const{host:t,pathname:n,searchParams:r}=new URL(e),o=n||t,i=r.get("relay"),s=r.get("secret");if(!o||!i||!s)throw new Error("invalid connection string");return{pubkey:o,relay:i,secret:s}}async function ba(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},o=as(t,e,JSON.stringify(r)),i={kind:ci,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",e]]};return oo(i,t)}qr({},{makeNwcRequestEvent:()=>ba,parseConnectionString:()=>wa});function xa(e){return e=(e=e.trim().toLowerCase()).normalize("NFKC"),Array.from(e).map(e=>/\p{Letter}/u.test(e)||/\p{Number}/u.test(e)?e:"-").join("")}qr({},{normalizeIdentifier:()=>xa});var Ea;qr({},{getSatoshisAmountFromBolt11:()=>_a,getZapEndpoint:()=>Sa,makeZapReceipt:()=>Ta,makeZapRequest:()=>Aa,useFetchImplementation:()=>ka,validateZapRequest:()=>Ca});try{Ea=fetch}catch{}function ka(e){Ea=e}async function Sa(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=er.decode(n,1e3),r=er.fromWords(e);t=Kr.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let o=await Ea(t),i=await o.json();if(i.allowsNostr&&i.nostrPubkey)return i.callback}catch(e){}return null}function Aa(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]),co(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(uo(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(r)}t.tags.push(["k",e.event.kind.toString()])}return t}function Ca(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!Wr(t))return"Zap request is not a valid Nostr event.";if(!io(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find(([e,t])=>"e"===e&&t);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function Ta({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let o=JSON.parse(e),i=o.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),s={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...i,["P",o.pubkey],["bolt11",n],["description",e]]};return t&&s.tags.push(["preimage",t]),s}function _a(e){if(e.length<50)return 0;const t=(e=e.substring(0,50)).lastIndexOf("1");if(-1===t)return 0;const n=e.substring(0,t);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const o=r[r.length-1],i=o.charCodeAt(0)-"0".charCodeAt(0),s=i>=0&&i<=9;let a=r.length-1;if(s&&a++,a<1)return 0;const c=parseInt(r.substring(0,a));switch(o){case"m":return 1e5*c;case"u":return 100*c;case"n":return c/10;case"p":return c/1e4;default:return 1e8*c}}qr({},{getToken:()=>Ia,hashPayload:()=>Ua,unpackEventFromToken:()=>Ra,validateEvent:()=>Ma,validateEventKind:()=>La,validateEventMethodTag:()=>Na,validateEventPayloadTag:()=>ja,validateEventTimestamp:()=>Pa,validateEventUrlTag:()=>Ba,validateToken:()=>Oa});var $a="Nostr ";async function Ia(e,t,n,r=!1,o){const i={kind:di,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};o&&i.tags.push(["payload",Ua(o)]);const s=await n(i);return(r?$a:"")+qn.encode(Jr.encode(JSON.stringify(s)))}async function Oa(e,t,n){const r=await Ra(e).catch(e=>{throw e});return await Ma(r,t,n).catch(e=>{throw e})}async function Ra(e){if(!e)throw new Error("Missing token");e=e.replace($a,"");const t=Kr.decode(qn.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Pa(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function La(e){return e.kind===di}function Ba(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function Na(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function Ua(e){return Wt(un(Jr.encode(JSON.stringify(e))))}function ja(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const r=Ua(t);return n.length>0&&n[1]===r}async function Ma(e,t,n,r){if(!io(e))throw new Error("Invalid nostr event, signature invalid");if(!La(e))throw new Error("Invalid nostr event, kind invalid");if(!Pa(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!Ba(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!Na(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!ja(e,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function Fa(e){return 3e4<=e&&e<4e4}var Da=function(e,t){return Da=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Da(e,t)};function Ha(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Da(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function qa(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})}function za(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ka(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function Ja(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o1||a(e,t)})},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof Va?Promise.resolve(n.value.v).then(c,l):u(i[0][2],n)}catch(e){u(i[0][3],e)}var n}function c(e){a("next",e)}function l(e){a("throw",e)}function u(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function Za(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Wa(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,o){(function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)})(r,o,(t=e[n](t)).done,t.value)})}}}function Ya(e){return"function"==typeof e}function Qa(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var Xa=Qa(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function ec(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var tc=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var s=Wa(i),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else i.remove(this);var c=this.initialTeardown;if(Ya(c))try{c()}catch(e){o=e instanceof Xa?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=Wa(l),d=u.next();!d.done;d=u.next()){var f=d.value;try{oc(f)}catch(e){o=null!=o?o:[],e instanceof Xa?o=Ja(Ja([],Ka(o)),Ka(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(o)throw new Xa(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)oc(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)&&ec(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&ec(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),nc=tc.EMPTY;function rc(e){return e instanceof tc||e&&"closed"in e&&Ya(e.remove)&&Ya(e.add)&&Ya(e.unsubscribe)}function oc(e){Ya(e)?e():e.unsubscribe()}var ic={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},sc={setTimeout:function(e,t){for(var n=[],r=2;r0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,o=n.isStopped,i=n.observers;return r||o?nc:(this.currentObservers=null,i.push(e),new tc(function(){t.currentObservers=null,ec(i,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new wc;return e.source=this,e},t.create=function(e,t){return new Cc(e,t)},t}(wc),Cc=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return Ha(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:nc},t}(Ac),Tc={now:function(){return(Tc.delegate||Date).now()},delegate:void 0},_c=function(e){function t(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=Tc);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=n,o._timestampProvider=r,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,n),o}return Ha(t,e),t.prototype.next=function(t){var n=this,r=n.isStopped,o=n._buffer,i=n._infiniteTimeWindow,s=n._timestampProvider,a=n._windowTime;r||(o.push(t),!i&&o.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,r=this._buffer.slice(),o=0;o=2,!0))}function $l(e,t){for(var n=[],r=2;rt.reduce((e,t)=>{const n=[];for(const r of e)try{const e=t(r);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);function Ml(e,t,n){if(Reflect.has(e,t))return Reflect.get(e,t);{const r=n();return Reflect.set(e,t,r),r}}function Fl(e,t){const[n,r]=Dl(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function Dl(e,t){let n=0,r=e.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t(e[o]);if(0===i)return[o,!0];i<0?r=o-1:n=o+1}return[n,!1]}new TextDecoder("utf-8"),new TextEncoder;const Hl=Symbol.for("event-store"),ql=Symbol.for("event-uid"),zl=Symbol.for("replaceable-address"),Wl=Symbol.for("from-cache"),Kl=Symbol.for("replaceable-identifier");function Jl(e){return function(e){return[0,3].includes(e)||1e4<=e&&e<2e4}(e)||Fa(e)}function Vl(e){let t=Reflect.get(e,ql);return t||(t=Jl(e.kind)?Gl(e):e.id,Reflect.set(e,ql,t)),t}function Gl(e){if(!Jl(e.kind))throw new Error("Event is not replaceable or addressable");return Ml(e,zl,()=>{const t=Fa(e.kind)?Yl(e):void 0;return Zl(e.kind,e.pubkey,t)})}function Zl(e,t,n){return e+":"+t+":"+(n??"")}function Yl(e){return Ml(e,Kl,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function Ql(){return Math.round(Date.now()/1e3)}const Xl=Symbol("expiration-timestamp");function eu(e){return Ml(e,Xl,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}function tu(e){let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),("80"!==t.port||"ws:"!==t.protocol&&"http:"!==t.protocol)&&("443"!==t.port||"wss:"!==t.protocol&&"https:"!==t.protocol)||(t.port=""),"string"==typeof e?t.toString():t}const nu=Symbol.for("seen-relays");function ru(e,t){return e[nu]||(e[nu]=new Set),e[nu].add(t),e[nu]}const ou=/^wss?:\/\/([-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}|localhost)\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)$/;function iu(e){return e.length>=8&&ou.test(e)}function su(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)} -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const au=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),cu=48,lu=57,uu=65,du=70,fu=97,hu=102;function pu(e){return e>=cu&&e<=lu?e-cu:e>=uu&&e<=du?e-(uu-10):e>=fu&&e<=hu?e-(fu-10):void 0}function yu(e,t=!1,n=!0){const r=e.split(":"),o=r[0]?parseInt(r[0]):void 0,i=r[1],s=r[2];if(void 0===o){if(n)return null;throw new Error("Missing kind")}if(void 0===i||""===i){if(n)return null;throw new Error("Missing pubkey")}if(t&&void 0===s){if(n)return null;throw new Error("Missing identifier")}return{kind:o,pubkey:i,identifier:s}}function gu(e){if(!e[1])throw new Error("Missing coordinate in tag");const t=yu(e[1],!0,!1);return e[2]&&iu(e[2])&&(t.relays=[e[2]]),t}function mu(e){if(!e[1])throw new Error("Missing pubkey in tag");if(!su(e[1]))throw new Error("Invalid pubkey");const t={pubkey:e[1]};return e[2]&&iu(e[2])&&(t.relays=[tu(e[2])]),t}function vu(e){return e.kind+":"+e.pubkey+":"+e.identifier}function wu(e){if(e instanceof Uint8Array)return e;if(su(e))return function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(au)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 r=new Uint8Array(n);for(let t=0,o=0;tArray.isArray(e)).map(e=>e.map(e=>String(e)));return Reflect.set(e,$u,r),r}const Lu="abcdefghijklmnopqrstuvwxyz",Bu=new Set((Lu+Lu.toUpperCase()).split("")),Nu=Symbol.for("indexable-tags");function Uu(e){let t=Reflect.get(e,Nu);if(!t){const n=new Set;for(const t of e.tags)t.length>=2&&1===t[0].length&&Bu.has(t[0])&&n.add(t[0]+":"+t[1]);t=n,Reflect.set(e,Nu,n)}return t}class ju{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,r=this.resetTtl){let o;if(n||this.has(e)){if(o=this.items[e],o.value=t,!1===n&&r&&(o.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==o){const e=this.last,t=o.next,n=o.prev;this.first===o&&(this.first=o.next),o.next=null,o.prev=this.last,e.next=o,null!==n&&(n.next=t),null!==t&&(t.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),o=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=o:this.last.next=o;return this.last=o,this}values(e=this.keys()){return e.map(e=>this.get(e))}}function Mu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fu,Du,Hu={exports:{}};function qu(){if(Du)return Fu;Du=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,i=365.25*r;function s(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return Fu=function(a,c){c=c||{};var l=typeof a;if("string"===l&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===l&&isFinite(a))return c.long?function(o){var i=Math.abs(o);if(i>=r)return s(o,i,r,"day");if(i>=n)return s(o,i,n,"hour");if(i>=t)return s(o,i,t,"minute");if(i>=e)return s(o,i,e,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=r)return Math.round(o/r)+"d";if(i>=n)return Math.round(o/n)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var zu=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e,t){let n=0,r=0,o=-1,i=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(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=qu(),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&&(r++,"%c"===e&&(o=r))}),t.splice(o,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=zu(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Hu,Hu.exports);const Wu=Mu(Hu.exports)("applesauce");class Ku{log=Wu.extend("EventMemory");kinds=new Map;authors=new Map;tags=new ju;created_at=[];events=new ju;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 r=this.replaceable.get(Zl(e,t,n));return!!r&&r.length>0}getReplaceable(e,t,n){const r=Zl(e,t,n),o=this.replaceable.get(r);return o?.[0]}getReplaceableHistory(e,t,n){const r=Zl(e,t,n);return this.replaceable.get(r)}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)Fl(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);for(const t of Uu(e))this.tags.has(t)&&this.getTagIndex(t).add(e);if(Fl(this.created_at,e),Jl(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=Zl(e.kind,e.pubkey,t);let r=this.replaceable.get(n);this.replaceable.has(n)||(r=[],this.replaceable.set(n,r)),Fl(r,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);for(const e of Uu(t))this.tags.has(e)&&this.getTagIndex(e).delete(t);const r=this.created_at.indexOf(t);if(this.created_at.splice(r,1),this.events.delete(n),Jl(t.kind)){const e=t.tags.find(e=>"d"===e[0])?.[1],n=Zl(t.kind,t.pubkey,e),r=this.replaceable.get(n);if(r&&r.includes(t)){const e=r.indexOf(t);r.splice(e,1)}}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,t){this.claims.has(e)||this.claims.set(e,t),this.touch(e)}isClaimed(e){return this.claims.has(e)}removeClaim(e,t){this.claims.get(e)===t&&this.claims.delete(e)}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 r of n)if(this.remove(r),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)}getTagIndex(e){if(!this.tags.has(e)){const t=new Set,n=Date.now();for(const n of this.events.values())Uu(n).has(e)&&t.add(n);const r=Date.now()-n;r>100&&this.log(`Built index ${e} took ${r}ms`),this.tags.set(e,t)}return this.tags.get(e)}*iterateAuthors(e){for(const t of e){const e=this.authors.get(t);if(e)for(const t of e)yield t}}*iterateTag(e,t){for(const n of t){const t=this.getTagIndex(e+":"+n);if(t)for(const e of t)yield e}}*iterateKinds(e){for(const t of e){const e=this.kinds.get(t);if(e)for(const t of e)yield t}}*iterateTime(e,t){let n=0,r=this.created_at.length-1,o=t?Dl(this.created_at,e=>e.created_at-t):void 0;o&&(n=o[0]);const i=e?Dl(this.created_at,t=>t.created_at-e):void 0;i&&(r=i[0]);for(let e=n;e{const r=e instanceof Set?e:new Set(e);if(t)n=r,t=!1;else for(const e of n)r.has(e)||n.delete(e);return n};e.ids&&r(this.iterateIds(e.ids));let o=null;void 0!==e.since&&(o=Array.from(this.iterateTime(e.since,e.until)),r(o));for(const t of Bu){const n=e[`#${t}`];n?.length&&r(this.iterateTag(t,n))}if(e.authors&&r(this.iterateAuthors(e.authors)),e.kinds&&r(this.iterateKinds(e.kinds)),void 0===e.since&&void 0!==e.until&&(o=Array.from(this.iterateTime(e.since,e.until)),r(o)),e.limit&&o){const t=new Set;for(const r of o){if(t.size>=e.limit)break;n.has(r)&&t.add(r)}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.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}}function Ju(e,t){var n,r;if(0===t.length)return e;for(n=0,r=t.length;ne.has(r+":"+t)))return!1}}return!(e.since&&t.created_ate.until)}function Qu(e,t){for(let n=0;nt.replaceable({kind:10063,pubkey:e.pubkey,relays:e.relays}).pipe(ol(e=>e?function(e){const t=Array.isArray(e)?e:e.tags;return jl(t,e=>Rl(e,"server")&&URL.canParse(e[1])?new URL("/",e[1]):void 0)}(e):[]))}const ed=Symbol.for("profile-content");function td(e){return Ml(e,ed,()=>{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 nd(e){return!!e&&((e.kind===so.Metadata||e.kind===so.Handlerinformation)&&!!td(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),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function r(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 o(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 i(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 r=t.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&t[r-1]===n;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,r)}}}function s(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function a(e,n,r){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let o=0;const i=[],s=Array.from(e);for(s.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let i=o;i(e+t/wt)/t;function Et(e){const t=mt,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=Ge(u,n,t)*u%t,f=Ge(d,n,t)*u%t,h=Ge(f,wt,t)*c%t,p=Ge(h,o,t)*h%t,g=Ge(p,i,t)*p%t,m=Ge(g,a,t)*g%t,y=Ge(m,l,t)*m%t,v=Ge(y,a,t)*g%t,w=Ge(v,n,t)*u%t,b=Ge(w,s,t)*p%t,E=Ge(b,r,t)*c%t,x=Ge(E,wt,t);if(!xt.eql(xt.sqr(x),e))throw new Error("Cannot find square root");return x}const xt=function(e,t,n=!1,r={}){if(e<=Me)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Xe(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Ye(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:Pe(o),ZERO:Me,ONE:De,create:t=>Ve(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Me<=t&&te===Me,isOdd:e=>(e&De)===De,neg:t=>Ve(-t,e),eql:(e,t)=>e===t,sqr:t=>Ve(t*t,e),add:(t,n)=>Ve(t+n,e),sub:(t,n)=>Ve(t-n,e),mul:(t,n)=>Ve(t*n,e),pow:(e,t)=>function(e,t,n){if(n 0");if(n===Me)return e.ONE;if(n===De)return t;let r=e.ONE,o=t;for(;n>Me;)n&De&&(r=e.mul(r,o)),o=e.sqr(o),n>>=De;return r}(a,e,t),div:(t,n)=>Ve(t*Ze(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Ze(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r)),e.ONE),o=e.inv(r);return t.reduceRight((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r)),o),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?$e(e,i):Ie(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?_e(e):Te(e)}});return Object.freeze(a)}(mt,void 0,void 0,{sqrt:Et}),kt=function(e,t){const n=t=>ft({...e,...gt(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:xt,n:yt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=yt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-vt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=bt(i*e,t),l=bt(-r*e,t);let c=Ve(e-a*n-l*o,t),u=Ve(-a*r-l*i,t);const d=c>s,f=u>s;if(d&&(c=t-c),f&&(u=t-u),c>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}}},ye),St=BigInt(0),Ct=e=>"bigint"==typeof e&&Ste.charCodeAt(0)));n=Oe(t,t),At[e]=n}return ye(Oe(n,...t))}const _t=e=>e.toRawBytes(!0).slice(1),It=e=>Ie(e,32),$t=e=>Ve(e,mt),Rt=e=>Ve(e,yt),Ot=kt.ProjectivePoint;function Pt(e){let t=kt.utils.normPrivateKeyToScalar(e),n=Ot.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:Rt(-t),bytes:_t(n)}}function Bt(e){if(!Ct(e))throw new Error("bad x: need 0 < x < p");const t=$t(e*e);let n=Et($t(t*e+BigInt(7)));n%wt!==St&&(n=$t(-n));const r=new Ot(e,n,vt);return r.assertValidity(),r}function Nt(...e){return Rt(Te(Tt("BIP0340/challenge",...e)))}function Lt(e){return Pt(e).bytes}function Ut(e,t,n=ce(32)){const r=Re("message",e),{bytes:o,scalar:i}=Pt(t),s=Re("auxRand",n,32),a=It(i^Te(Tt("BIP0340/aux",s))),l=Tt("BIP0340/nonce",a,o,r),c=Rt(Te(l));if(c===St)throw new Error("sign failed: k is zero");const{bytes:u,scalar:d}=Pt(c),f=Nt(u,o,r),h=new Uint8Array(64);if(h.set(u,0),h.set(It(Rt(d+f*i)),32),!jt(h,r,o))throw new Error("sign: Invalid signature produced");return h}function jt(e,t,n){const r=Re("signature",e,64),o=Re("message",t),i=Re("publicKey",n,32);try{const e=Bt(Te(i)),t=Te(r.subarray(0,32));if(!Ct(t))return!1;const n=Te(r.subarray(32,64));if(!("bigint"==typeof(c=n)&&St({getPublicKey:Lt,sign:Ut,verify:jt,utils:{randomPrivateKey:kt.utils.randomPrivateKey,lift_x:Bt,pointToBytes:_t,numberToBytesBE:Ie,bytesToNumberBE:Te,taggedHash:Tt,mod:Ve}}))(),Mt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Dt=e=>e instanceof Uint8Array,Ht=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),qt=(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 Kt(e){if(!Dt(e))throw new Error("Uint8Array expected");let t="";for(let n=0;ne+t.length,0));let n=0;return e.forEach(e=>{if(!Dt(e))throw new Error("Uint8Array expected");t.set(e,n),n+=e.length}),t}class Gt{clone(){return this._cloneInto()}}function Zt(e){const t=t=>e().update(Vt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Yt(e=32){if(Mt&&"function"==typeof Mt.getRandomValues)return Mt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function Qt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Xt(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 en={number:Qt,bool:function(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)},bytes:Xt,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Qt(e.outputLen),Qt(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){Xt(e);const n=t.outputLen;if(e.lengthr-i&&(this.process(n,0),i=0);for(let e=i;e>o&i),a=Number(n&i),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=Ht(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&n,rn=(e,t,n)=>e&t^e&n^t&n,on=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]),sn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),an=new Uint32Array(64);class ln extends tn{constructor(){super(64,32,8,!1),this.A=0|sn[0],this.B=0|sn[1],this.C=0|sn[2],this.D=0|sn[3],this.E=0|sn[4],this.F=0|sn[5],this.G=0|sn[6],this.H=0|sn[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)an[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=an[e-15],n=an[e-2],r=qt(t,7)^qt(t,18)^t>>>3,o=qt(n,17)^qt(n,19)^n>>>10;an[e]=o+an[e-7]+r+an[e-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){const t=c+(qt(s,6)^qt(s,11)^qt(s,25))+nn(s,a,l)+on[e]+an[e]|0,u=(qt(n,2)^qt(n,13)^qt(n,22))+rn(n,r,o)|0;c=l,l=a,a=s,s=i+t|0,i=o,o=r,r=n,n=t+u|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,o,i,s,a,l,c)}roundClean(){an.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class cn extends ln{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 un=Zt(()=>new ln);Zt(()=>new cn);var dn=Symbol("verified");function fn(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!==r.indexOf(t)))return!1}return!(e.since&&t.created_ate.until)}async function En(){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 xn,kn=e=>(e[dn]=!0,!0),Sn=class extends Error{constructor(e,t){super(`Tried to send message '${e} on a closed connection to ${t}.`),this.name="SendingOnClosedConnection"}},Cn=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 mn;queueRunning=!1;challenge;authPromise;serial=0;verifyEvent;_WebSocket;constructor(e,t){this.url=pn(e),this.verifyEvent=t.verifyEvent,this._WebSocket=t.websocketImplementation||WebSocket,this.enablePing=t.enablePing}static async connect(e,t){const n=new Cn(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 En();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 r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return e.slice(r+1,i)}(e);if(t){const n=this.openSubs.get(t);if(!n)return;const r=function(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}(e,"id"),o=n.alreadyHaveEvent?.(r);if(n.receivedEvent?.(this,r),o)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,r)=>{try{let o=await e(function(e,t){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}(this.url,t)),i=setTimeout(()=>{let e=this.openEventPublishes.get(o.id);e&&(e.reject(new Error("auth timed out")),this.openEventPublishes.delete(o.id))},this.publishTimeout);this.openEventPublishes.set(o.id,{resolve:n,reject:r,timeout:i}),this.send('["AUTH",'+JSON.stringify(o)+"]")}catch(e){console.warn("subscribe auth function failed:",e)}})),this.authPromise}async publish(e){const t=new Promise((t,n)=>{const r=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:r})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;const n=t?.id||"count:"+this.serial,r=new Promise((e,t)=>{this.openCountRequests.set(n,{resolve:e,reject:t})});return this.send('["COUNT","'+n+'",'+JSON.stringify(e).substring(1)),r}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,r=new An(this,n,e,t);return this.openSubs.set(n,r),r}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()}},An=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,n,r){this.relay=e,this.filters=n,this.id=t,this.alreadyHaveEvent=r.alreadyHaveEvent,this.receivedEvent=r.receivedEvent,this.eoseTimeout=r.eoseTimeout||e.baseEoseTimeout,this.oneose=r.oneose,this.onclose=r.onclose,this.onevent=r.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 Sn))throw e}this.closed=!0}this.relay.openSubs.delete(this.id),this.onclose?.(e)}},Tn=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=pn(e);let n=this.relays.get(e);return n||(n=new Cn(e,{verifyEvent:this.trustedRelayURLs.has(e)?kn: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(pn).forEach(e=>{this.relays.get(e)?.close(),this.relays.delete(e)})}subscribe(e,t,n){n.onauth=n.onauth||n.doauth;const r=[];for(let n=0;ne.url===o)||r.push({url:o,filter:t})}return this.subscribeMap(r,n)}subscribeMany(e,t,n){n.onauth=n.onauth||n.doauth;const r=[],o=[];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 o=new Set,i=[],s=[];let a=n=>{s[n]||(s[n]=!0,s.filter(e=>e).length===e.length&&(t.oneose?.(),a=()=>{}))};const l=[];let c=(n,r)=>{l[n]||(a(n),l[n]=r,l.filter(e=>e).length===e.length&&(t.onclose?.(l),c=()=>{}))};const u=e=>{if(t.alreadyHaveEvent?.(e))return!0;const n=o.has(e);return o.add(e),n},d=Promise.all(r.map(async({url:e,filters:n},r)=>{let o;try{o=await this.ensureRelay(e,{connectionTimeout:t.maxWait?Math.max(.8*t.maxWait,t.maxWait-1e3):void 0})}catch(e){return void c(r,e?.message||String(e))}let s=o.subscribe(n,{...t,oneose:()=>a(r),onclose:e=>{e.startsWith("auth-required: ")&&t.onauth?o.auth(t.onauth).then(()=>{o.subscribe(n,{...t,oneose:()=>a(r),onclose:e=>{c(r,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait})}).catch(e=>{c(r,`auth was required and attempted, but failed with: ${e}`)}):c(r,e)},alreadyHaveEvent:u,eoseTimeout:t.maxWait});i.push(s)}));return{async close(e){await d,i.forEach(t=>{t.close(e)})}}}subscribeEose(e,t,n){n.onauth=n.onauth||n.doauth;const r=this.subscribe(e,t,{...n,oneose(){r.close("closed automatically on eose")}});return r}subscribeManyEose(e,t,n){n.onauth=n.onauth||n.doauth;const r=this.subscribeMany(e,t,{...n,oneose(){r.close("closed automatically on eose")}});return r}async querySync(e,t,n){return new Promise(async r=>{const o=[];this.subscribeEose(e,t,{...n,onevent(e){o.push(e)},onclose(e){r(o)}})})}async get(e,t,n){t.limit=1;const r=await this.querySync(e,t,n);return r.sort((e,t)=>t.created_at-e.created_at),r[0]||null}publish(e,t,n){return e.map(pn).map(async(e,r,o)=>{if(o.indexOf(e)!==r)return Promise.reject("duplicate url");let i=await this.ensureRelay(e);return i.publish(t).catch(async e=>{if(e instanceof Error&&e.message.startsWith("auth-required: ")&&n?.onauth)return await i.auth(n.onauth),i.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(i)}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{xn=WebSocket}catch{}var _n=class extends Tn{constructor(e){super({verifyEvent:wn,websocketImplementation:xn,...e})}}; +/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function In(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),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function Rn(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(In(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 On(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 Pn(e,t="="){if(In(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 r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function Bn(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function Nn(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 r=0;const o=[],i=Array.from(e);for(i.forEach(e=>{if(In(e),e<0||e>=t)throw new Error(`Wrong integer: ${e}`)});;){let e=0,s=!0;for(let o=r;ot?Ln(t,e%t):e,Un=(e,t)=>e+(t-Ln(e,t));function jn(e,t,n,r){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(Un(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Un(t,n)}`);let o=0,i=0;const s=2**n-1,a=[];for(const r of e){if(In(r),r>=2**t)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)a.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<=t)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&a.push(o>>>0),a}function Fn(e,t=!1){if(In(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Un(8,e)>32||Un(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 Mn(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 Dn=$n(Fn(4),Rn("0123456789ABCDEF"),On("")),Hn=$n(Fn(5),Rn("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Pn(5),On(""));$n(Fn(5),Rn("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Pn(5),On("")),$n(Fn(5),Rn("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),On(""),Bn(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const qn=$n(Fn(6),Rn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Pn(6),On("")),zn=$n(Fn(6),Rn("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Pn(6),On("")),Kn=e=>{return $n((In(t=58),{encode:e=>{if(!(e instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Nn(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(Nn(e,t,256))}}),Rn(e),On(""));var t},Wn=Kn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");Kn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Kn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const Vn=[0,2,3,5,6,7,9,10,11],Jn={encode(e){let t="";for(let n=0;n>25;let n=(33554431&e)<<5;for(let e=0;e>e&1)&&(n^=Zn[e]);return n}function Qn(e,t,n=1){const r=e.length;let o=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);o=Yn(o)^n>>5}o=Yn(o);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=e.slice(0,o),s=e.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=Gn.decode(s).slice(0,-6),l=Qn(i,a,t);if(!s.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:i,words:a}}return{encode:function(e,n,r=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 o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${Gn.encode(n)}${Qn(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:Mn(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}const er=Xn("bech32");Xn("bech32m");const tr={utf8:{encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},hex:$n(Fn(4),Rn("0123456789abcdef"),On(""),Bn(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:Dn,base32:Hn,base64:qn,base64url:zn,base58:Wn,base58xmr:Jn};function nr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function rr(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function or(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(tr).join(", ");const ir=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");const sr=16;function ar(e){return e<<1^283&-(e>>7)}function lr(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=ar(e);return n}const cr=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=ar(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return t})(),ur=cr.map((e,t)=>cr.indexOf(t)),dr=e=>e<<24|e>>>8,fr=e=>e<<8|e>>>24;function hr(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(fr),o=r.map(fr),i=o.map(fr),s=new Uint32Array(65536),a=new Uint32Array(65536),l=new Uint16Array(65536);for(let t=0;t<256;t++)for(let c=0;c<256;c++){const u=256*t+c;s[u]=n[t]^r[c],a[u]=o[t]^i[c],l[u]=e[t]<<8|e[c]}return{sbox:e,sbox2:l,T0:n,T1:r,T2:o,T3:i,T01:s,T23:a}}const pr=hr(cr,e=>lr(e,3)<<24|e<<16|e<<8|lr(e,2)),gr=hr(ur,e=>lr(e,11)<<24|lr(e,13)<<16|lr(e,9)<<8|lr(e,14)),mr=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=ar(n))e[t]=n;return e})();function yr(e){or(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=pr,r=ir(e),o=r.length,i=e=>wr(n,e,e,e,e),s=new Uint32Array(t+28);s.set(r);for(let e=o;e6&&e%o===4&&(t=i(t)),s[e]=s[e-o]^t}return s}function vr(e,t,n,r,o,i){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|i>>>24&255]}function wr(e,t,n,r,o){return e[255&t|65280&n]|e[r>>>16&255|o>>>16&65280]<<16}function br(e,t,n,r,o){const{sbox2:i,T01:s,T23:a}=pr;let l=0;t^=e[l++],n^=e[l++],r^=e[l++],o^=e[l++];const c=e.length/4-2;for(let i=0;i{const i=yr(e),{b:s,o:a,out:l}=function(e,t,n){let r=e.length;const o=r%sr;if(!t&&0!==o)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");const i=ir(e);if(t){let e=sr-o;e||(e=sr),r+=e}const s=xr(r,n);return{b:i,o:ir(s),out:s}}(n,r,o),c=ir(t);let u=c[0],d=c[1],f=c[2],h=c[3],p=0;for(;p+4<=s.length;)u^=s[p+0],d^=s[p+1],f^=s[p+2],h^=s[p+3],({s0:u,s1:d,s2:f,s3:h}=br(i,u,d,f,h)),a[p++]=u,a[p++]=d,a[p++]=f,a[p++]=h;if(r){const e=function(e){const t=new Uint8Array(16),n=ir(t);t.set(e);const r=sr-e.length;for(let e=sr-r;e{!function(e){if(or(e),e.length%sr!==0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(n);const i=function(e){const t=yr(e),n=t.slice(),r=t.length,{sbox2:o}=pr,{T0:i,T1:s,T2:a,T3:l}=gr;for(let e=0;e>>8&255]^a[r>>>16&255]^l[r>>>24]}return n}(e),s=ir(t),a=xr(n.length,o),l=ir(n),c=ir(a);let u=s[0],d=s[1],f=s[2],h=s[3];for(let e=0;e+4<=l.length;){const t=u,n=d,r=f,o=h;u=l[e+0],d=l[e+1],f=l[e+2],h=l[e+3];const{s0:s,s1:a,s2:p,s3:g}=Er(i,u,d,f,h);c[e++]=s^t,c[e++]=a^n,c[e++]=p^r,c[e++]=g^o}return i.fill(0),function(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const o=e.subarray(0,-r);for(let t=0;tUint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Tr=Ar("expand 16-byte k"),_r=Ar("expand 32-byte k"),Ir=ir(Tr),$r=ir(_r);function Rr(e,t){return e<>>32-t}function Or(e){return e.byteOffset%4==0}$r.slice();const Pr=2**32-1,Br=new Uint32Array;function Nr(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return nr(o),nr(s),rr(i),rr(n),(t,a,l,c,u=0)=>{or(t),or(a),or(l);const d=l.length;if(c||(c=new Uint8Array(d)),or(c),nr(u),u<0||u>=Pr)throw new Error("arx: counter overflow");if(c.length=Pr)throw new Error("arx: counter overflow");const g=Math.min(64,l-p);if(d&&64===g){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,h[t]=f[t]^u[n];p+=64;continue}for(let e,t=0;t0;)f.pop().fill(0);return c}}function Lr(e,t,n,r,o,i=20){let s=e[0],a=e[1],l=e[2],c=e[3],u=t[0],d=t[1],f=t[2],h=t[3],p=t[4],g=t[5],m=t[6],y=t[7],v=o,w=n[0],b=n[1],E=n[2],x=s,k=a,S=l,C=c,A=u,T=d,_=f,I=h,$=p,R=g,O=m,P=y,B=v,N=w,L=b,U=E;for(let e=0;er?e.create().update(n).digest():n);for(let e=0;enew jr(e,t).update(n).digest();Fr.create=(e,t)=>new jr(e,t);const Mr=new Uint8Array([0]),Dr=new Uint8Array;var Hr=Object.defineProperty,qr=(e,t)=>{for(var n in t)Hr(e,n,{get:t[n],enumerable:!0})},zr=Symbol("verified");function Kr(e){if(!(e instanceof Object))return!1;if("number"!=typeof e.kind)return!1;if("string"!=typeof e.content)return!1;if("number"!=typeof e.created_at)return!1;if("string"!=typeof e.pubkey)return!1;if(!e.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(e.tags))return!1;for(let t=0;tXr,QueueNode:()=>Qr,binarySearch:()=>Yr,bytesToHex:()=>Kt,hexToBytes:()=>Wt,insertEventIntoAscendingList:()=>Zr,insertEventIntoDescendingList:()=>Gr,normalizeURL:()=>Jr,utf8Decoder:()=>Wr,utf8Encoder:()=>Vr});var Wr=new TextDecoder("utf-8"),Vr=new TextEncoder;function Jr(e){try{-1===e.indexOf("://")&&(e="wss://"+e);let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}catch(t){throw new Error(`Invalid URL: ${e}`)}}function Gr(e,t){const[n,r]=Yr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function Zr(e,t){const[n,r]=Yr(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return r||e.splice(n,0,t),e}function Yr(e,t){let n=0,r=e.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t(e[o]);if(0===i)return[o,!0];i<0?r=o-1:n=o+1}return[n,!1]}var Qr=class{value;next=null;prev=null;constructor(e){this.value=e}},Xr=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){const t=new Qr(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const e=this.first;return this.first=null,this.last=null,e.value}const e=this.first;return this.first=e.next,this.first&&(this.first.prev=null),e.value}};function eo(e){return Kt(un(Vr.encode(function(e){if(!Kr(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}(e))))}var to=new class{generateSecretKey(){return Ft.utils.randomPrivateKey()}getPublicKey(e){return Kt(Ft.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Kt(Ft.getPublicKey(t)),n.id=eo(n),n.sig=Kt(Ft.sign(eo(n),t)),n[zr]=!0,n}verifyEvent(e){if("boolean"==typeof e[zr])return e[zr];const t=eo(e);if(t!==e.id)return e[zr]=!1,!1;try{const n=Ft.verify(e.sig,t,e.pubkey);return e[zr]=n,n}catch(t){return e[zr]=!1,!1}}},no=to.generateSecretKey,ro=to.getPublicKey,oo=to.finalizeEvent,io=to.verifyEvent,so={};function ao(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function lo(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function co(e){return 2e4<=e&&e<3e4}function uo(e){return 3e4<=e&&e<4e4}function fo(e){return ao(e)?"regular":lo(e)?"replaceable":co(e)?"ephemeral":uo(e)?"parameterized":"unknown"}function ho(e,t){const n=t instanceof Array?t:[t];return Kr(e)&&n.includes(e.kind)||!1}qr(so,{Application:()=>Ci,BadgeAward:()=>xo,BadgeDefinition:()=>vi,BlockedRelaysList:()=>Xo,BookmarkList:()=>Zo,Bookmarksets:()=>gi,Calendar:()=>Oi,CalendarEventRSVP:()=>Pi,ChannelCreation:()=>Ao,ChannelHideMessage:()=>Io,ChannelMessage:()=>_o,ChannelMetadata:()=>To,ChannelMuteUser:()=>$o,ClassifiedListing:()=>_i,ClientAuth:()=>ai,CommunitiesList:()=>Yo,CommunityDefinition:()=>Li,CommunityPostApproval:()=>Fo,Contacts:()=>yo,CreateOrUpdateProduct:()=>Ei,CreateOrUpdateStall:()=>bi,Curationsets:()=>mi,Date:()=>$i,DirectMessageRelaysList:()=>ri,DraftClassifiedListing:()=>Ii,DraftLong:()=>ki,Emojisets:()=>Si,EncryptedDirectMessage:()=>vo,EventDeletion:()=>wo,FileMetadata:()=>Po,FileServerPreference:()=>oi,Followsets:()=>fi,GenericRepost:()=>Co,Genericlists:()=>hi,GiftWrap:()=>Oo,HTTPAuth:()=>di,Handlerinformation:()=>Ni,Handlerrecommendation:()=>Bi,Highlights:()=>Wo,InterestsList:()=>ti,Interestsets:()=>wi,JobFeedback:()=>Ho,JobRequest:()=>Mo,JobResult:()=>Do,Label:()=>jo,LightningPubRPC:()=>si,LiveChatMessage:()=>Bo,LiveEvent:()=>Ai,LongFormArticle:()=>xi,Metadata:()=>po,Mutelist:()=>Vo,NWCWalletInfo:()=>ii,NWCWalletRequest:()=>li,NWCWalletResponse:()=>ci,NostrConnect:()=>ui,OpenTimestamps:()=>Ro,Pinlist:()=>Jo,PrivateDirectMessage:()=>So,ProblemTracker:()=>No,ProfileBadges:()=>yi,PublicChatsList:()=>Qo,Reaction:()=>Eo,RecommendRelay:()=>mo,RelayList:()=>Go,Relaysets:()=>pi,Report:()=>Lo,Reporting:()=>Uo,Repost:()=>bo,Seal:()=>ko,SearchRelaysList:()=>ei,ShortTextNote:()=>go,Time:()=>Ri,UserEmojiList:()=>ni,UserStatuses:()=>Ti,Zap:()=>Ko,ZapGoal:()=>qo,ZapRequest:()=>zo,classifyKind:()=>fo,isAddressableKind:()=>uo,isEphemeralKind:()=>co,isKind:()=>ho,isRegularKind:()=>ao,isReplaceableKind:()=>lo});var po=0,go=1,mo=2,yo=3,vo=4,wo=5,bo=6,Eo=7,xo=8,ko=13,So=14,Co=16,Ao=40,To=41,_o=42,Io=43,$o=44,Ro=1040,Oo=1059,Po=1063,Bo=1311,No=1971,Lo=1984,Uo=1984,jo=1985,Fo=4550,Mo=5999,Do=6999,Ho=7e3,qo=9041,zo=9734,Ko=9735,Wo=9802,Vo=1e4,Jo=10001,Go=10002,Zo=10003,Yo=10004,Qo=10005,Xo=10006,ei=10007,ti=10015,ni=10030,ri=10050,oi=10096,ii=13194,si=21e3,ai=22242,li=23194,ci=23195,ui=24133,di=27235,fi=3e4,hi=30001,pi=30002,gi=30003,mi=30004,yi=30008,vi=30009,wi=30015,bi=30017,Ei=30018,xi=30023,ki=30024,Si=30030,Ci=30078,Ai=30311,Ti=30315,_i=30402,Ii=30403,$i=31922,Ri=31923,Oi=31924,Pi=31925,Bi=31989,Ni=31990,Li=34550;function Ui(e,t){let n=t.length+3,r=e.indexOf(`"${t}":`)+n,o=e.slice(r).indexOf('"')+r+1;return e.slice(o,o+64)}function ji(e,t){let n=t.length,r=e.indexOf(`"${t}":`)+n+3,o=e.slice(r),i=Math.min(o.indexOf(","),o.indexOf("}"));return parseInt(o.slice(0,i),10)}function Fi(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let n=e.slice(t+7+1).indexOf('"');if(-1===n)return null;let r=t+7+1+n,o=e.slice(r+1,80).indexOf('"');if(-1===o)return null;let i=r+1+o;return e.slice(r+1,i)}function Mi(e,t){return t===Ui(e,"id")}function Di(e,t){return t===Ui(e,"pubkey")}function Hi(e,t){return t===ji(e,"kind")}qr({},{getHex64:()=>Ui,getInt:()=>ji,getSubscriptionId:()=>Fi,matchEventId:()=>Mi,matchEventKind:()=>Hi,matchEventPubkey:()=>Di});function qi(e,t){return{kind:ai,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}qr({},{makeAuthEvent:()=>qi});try{WebSocket}catch{}try{WebSocket}catch{}var zi={};qr(zi,{BECH32_REGEX:()=>Vi,Bech32MaxSize:()=>Wi,NostrTypeGuard:()=>Ki,decode:()=>Gi,decodeNostrURI:()=>Ji,encodeBytes:()=>ts,naddrEncode:()=>os,neventEncode:()=>rs,noteEncode:()=>Xi,nprofileEncode:()=>ns,npubEncode:()=>Qi,nsecEncode:()=>Yi});var Ki={isNProfile:e=>/^nprofile1[a-z\d]+$/.test(e||""),isNEvent:e=>/^nevent1[a-z\d]+$/.test(e||""),isNAddr:e=>/^naddr1[a-z\d]+$/.test(e||""),isNSec:e=>/^nsec1[a-z\d]{58}$/.test(e||""),isNPub:e=>/^npub1[a-z\d]{58}$/.test(e||""),isNote:e=>/^note1[a-z\d]+$/.test(e||""),isNcryptsec:e=>/^ncryptsec1[a-z\d]+$/.test(e||"")},Wi=5e3,Vi=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function Ji(e){try{return e.startsWith("nostr:")&&(e=e.substring(6)),Gi(e)}catch(e){return{type:"invalid",data:null}}}function Gi(e){let{prefix:t,words:n}=er.decode(e,Wi),r=new Uint8Array(er.fromWords(n));switch(t){case"nprofile":{let e=Zi(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Kt(e[0][0]),relays:e[1]?e[1].map(e=>Wr.decode(e)):[]}}}case"nevent":{let e=Zi(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Kt(e[0][0]),relays:e[1]?e[1].map(e=>Wr.decode(e)):[],author:e[2]?.[0]?Kt(e[2][0]):void 0,kind:e[3]?.[0]?parseInt(Kt(e[3][0]),16):void 0}}}case"naddr":{let e=Zi(r);if(!e[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:Wr.decode(e[0][0]),pubkey:Kt(e[2][0]),kind:parseInt(Kt(e[3][0]),16),relays:e[1]?e[1].map(e=>Wr.decode(e)):[]}}}case"nsec":return{type:t,data:r};case"npub":case"note":return{type:t,data:Kt(r)};default:throw new Error(`unknown prefix ${t}`)}}function Zi(e){let t={},n=e;for(;n.length>0;){let e=n[0],r=n[1],o=n.slice(2,2+r);if(n=n.slice(2+r),o.lengthVr.encode(e))}))}function rs(e){let t;return void 0!==e.kind&&(t=function(e){const t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}(e.kind)),es("nevent",is({0:[Wt(e.id)],1:(e.relays||[]).map(e=>Vr.encode(e)),2:e.author?[Wt(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function os(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),es("naddr",is({0:[Vr.encode(e.identifier)],1:(e.relays||[]).map(e=>Vr.encode(e)),2:[Wt(e.pubkey)],3:[new Uint8Array(t)]}))}function is(e){let t=[];return Object.entries(e).reverse().forEach(([e,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(e)],0),r.set([n.length],1),r.set(n,2),t.push(r)})}),Jt(...t)}var ss={};function as(e,t,n){const r=e instanceof Uint8Array?Kt(e):e,o=cs(kt.getSharedSecret(r,"02"+t));let i=Uint8Array.from(Yt(16)),s=Vr.encode(n),a=kr(o,i).encrypt(s);return`${qn.encode(new Uint8Array(a))}?iv=${qn.encode(new Uint8Array(i.buffer))}`}function ls(e,t,n){const r=e instanceof Uint8Array?Kt(e):e;let[o,i]=n.split("?iv="),s=cs(kt.getSharedSecret(r,"02"+t)),a=qn.decode(i),l=qn.decode(o),c=kr(s,a).decrypt(l);return Wr.decode(c)}function cs(e){return e.slice(1,33)}qr(ss,{decrypt:()=>ls,encrypt:()=>as});qr({},{NIP05_REGEX:()=>ds,isNip05:()=>fs,isValid:()=>ms,queryProfile:()=>gs,searchDomain:()=>ps,useFetchImplementation:()=>hs});var us,ds=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,fs=e=>ds.test(e||"");try{us=fetch}catch(e){}function hs(e){us=e}async function ps(e,t=""){try{const n=`https://${e}/.well-known/nostr.json?name=${t}`,r=await us(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(e){return{}}}async function gs(e){const t=e.match(ds);if(!t)return null;const[,n="_",r]=t;try{const e=`https://${r}/.well-known/nostr.json?name=${n}`,t=await us(e,{redirect:"manual"});if(200!==t.status)throw Error("Wrong response code");const o=await t.json(),i=o.names[n];return i?{pubkey:i,relays:o.relays?.[i]}:null}catch(e){return null}}async function ms(e,t){const n=await gs(t);return!!n&&n.pubkey===e}function ys(e){const t={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let o=e.tags.length-1;o>=0;o--){const i=e.tags[o];if("e"===i[0]&&i[1]){const[e,o,s,a,l]=i,c={id:o,relays:s?[s]:[],author:l};if("root"===a){t.root=c;continue}if("reply"===a){t.reply=c;continue}if("mention"===a){t.mentions.push(c);continue}n?r=c:n=c,t.mentions.push(c);continue}if("q"===i[0]&&i[1]){const[e,n,r]=i;t.quotes.push({id:n,relays:r?[r]:[]})}"p"===i[0]&&i[1]&&t.profiles.push({pubkey:i[1],relays:i[2]?[i[2]]:[]})}return t.root||(t.root=r||n||t.reply),t.reply||(t.reply=n||t.root),[t.reply,t.root].forEach(e=>{if(!e)return;let n=t.mentions.indexOf(e);if(-1!==n&&t.mentions.splice(n,1),e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays?.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t.mentions.forEach(e=>{if(e.author){let n=t.profiles.find(t=>t.pubkey===e.author);n&&n.relays&&(e.relays||(e.relays=[]),n.relays.forEach(t=>{-1===e.relays.indexOf(t)&&e.relays.push(t)}),n.relays=e.relays)}}),t}qr({},{parse:()=>ys});qr({},{fetchRelayInformation:()=>ws,useFetchImplementation:()=>vs});try{fetch}catch{}function vs(e){0}async function ws(e){return await(await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function bs(e){let t=0;for(let n=0;n<64;n+=8){const r=parseInt(e.substring(n,n+8),16);if(0!==r){t+=Math.clz32(r);break}t+=32}return t}function Es(e,t){let n=0;const r=e,o=["nonce",n.toString(),t.toString()];for(r.tags.push(o);;){const e=Math.floor((new Date).getTime()/1e3);if(e!==r.created_at&&(n=0,r.created_at=e),o[1]=(++n).toString(),r.id=xs(r),bs(r.id)>=t)break}return r}function xs(e){return Kt(un(Vr.encode(JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]))))}qr({},{fastEventHash:()=>xs,getPow:()=>bs,minePow:()=>Es});qr({},{unwrapEvent:()=>Js,unwrapManyEvents:()=>Gs,wrapEvent:()=>Ws,wrapManyEvents:()=>Vs});qr({},{createRumor:()=>Fs,createSeal:()=>Ms,createWrap:()=>Ds,unwrapEvent:()=>zs,unwrapManyEvents:()=>Ks,wrapEvent:()=>Hs,wrapManyEvents:()=>qs});var ks={};qr(ks,{decrypt:()=>Os,encrypt:()=>Rs,getConversationKey:()=>As,v2:()=>Ps});var Ss=1,Cs=65535;function As(e,t){const n=kt.getSharedSecret(e,"02"+t).subarray(1,33);return function(e,t,n){return en.hash(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Fr(e,Vt(n),Vt(t))}(un,n,"nip44-v2")}function Ts(e,t){const n=function(e,t,n,r=32){if(en.hash(e),en.number(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/e.outputLen);void 0===n&&(n=Dr);const i=new Uint8Array(o*e.outputLen),s=Fr.create(e,t),a=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let t=0;tCs)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(_s(n)-n))}function $s(e,t,n){if(32!==n.length)throw new Error("AAD associated data must be 32 bytes");const r=Jt(n,t);return Fr(un,e,r)}function Rs(e,t,n=Yt(32)){const{chacha_key:r,chacha_nonce:o,hmac_key:i}=Ts(t,n),s=Is(e),a=Ur(r,o,s),l=$s(i,a,n);return qn.encode(Jt(new Uint8Array([2]),n,a,l))}function Os(e,t){const{nonce:n,ciphertext:r,mac:o}=function(e){if("string"!=typeof e)throw new Error("payload must be a valid string");const t=e.length;if(t<132||t>87472)throw new Error("invalid payload length: "+t);if("#"===e[0])throw new Error("unknown encryption version");let n;try{n=qn.decode(e)}catch(e){throw new Error("invalid base64: "+e.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const o=n[0];if(2!==o)throw new Error("unknown encryption version "+o);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(e),{chacha_key:i,chacha_nonce:s,hmac_key:a}=Ts(t,n);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;rCs||n.length!==t||e.length!==2+_s(t))throw new Error("invalid padding");return Wr.decode(n)}(Ur(i,s,r))}var Ps={utils:{getConversationKey:As,calcPaddedLen:_s},encrypt:Rs,decrypt:Os},Bs=()=>Math.round(Date.now()/1e3),Ns=()=>Math.round(Bs()-172800*Math.random()),Ls=(e,t)=>As(e,t),Us=(e,t,n)=>Rs(JSON.stringify(e),Ls(t,n)),js=(e,t)=>JSON.parse(Os(e.content,Ls(t,e.pubkey)));function Fs(e,t){const n={created_at:Bs(),content:"",tags:[],...e,pubkey:ro(t)};return n.id=eo(n),n}function Ms(e,t,n){return oo({kind:ko,content:Us(e,t,n),created_at:Ns(),tags:[]},t)}function Ds(e,t){const n=no();return oo({kind:Oo,content:Us(e,n,t),created_at:Ns(),tags:[["p",t]]},n)}function Hs(e,t,n){return Ds(Ms(Fs(e,t),t,n),n)}function qs(e,t,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=ro(t),o=[Hs(e,t,r)];return n.forEach(n=>{o.push(Hs(e,t,n))}),o}function zs(e,t){const n=js(e,t);return js(n,t)}function Ks(e,t){let n=[];return e.forEach(e=>{n.push(zs(e,t))}),n.sort((e,t)=>e.created_at-t.created_at),n}function Ws(e,t,n,r,o){const i=function(e,t,n,r){const o={created_at:Math.ceil(Date.now()/1e3),kind:So,tags:[],content:t};return(Array.isArray(e)?e:[e]).forEach(({publicKey:e,relayUrl:t})=>{o.tags.push(t?["p",e,t]:["p",e])}),r&&o.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&o.tags.push(["subject",n]),o}(t,n,r,o);return Hs(i,e,t.publicKey)}function Vs(e,t,n,r,o){if(!t||0===t.length)throw new Error("At least one recipient is required.");return[{publicKey:ro(e)},...t].map(t=>Ws(e,t,n,r,o))}var Js=zs,Gs=Ks;function Zs(e,t,n,r){let o;const i=[...e.tags??[],["e",t.id,n],["p",t.pubkey]];return t.kind===go?o=bo:(o=Co,i.push(["k",String(t.kind)])),oo({kind:o,tags:i,content:""===e.content||t.tags?.find(e=>"-"===e[0])?"":JSON.stringify(t),created_at:e.created_at},r)}function Ys(e){if(![bo,Co].includes(e.kind))return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t?{id:t[1],relays:[t[2],n?.[2]].filter(e=>"string"==typeof e),author:n?.[1]}:void 0}function Qs(e,{skipVerification:t}={}){const n=Ys(e);if(void 0===n||""===e.content)return;let r;try{r=JSON.parse(e.content)}catch(e){return}return r.id===n.id&&(t||io(r))?r:void 0}qr({},{finishRepostEvent:()=>Zs,getRepostedEvent:()=>Qs,getRepostedEventPointer:()=>Ys});qr({},{NOSTR_URI_REGEX:()=>Xs,parse:()=>ta,test:()=>ea});var Xs=new RegExp(`nostr:(${Vi.source})`);function ea(e){return"string"==typeof e&&new RegExp(`^${Xs.source}$`).test(e)}function ta(e){const t=e.match(new RegExp(`^${Xs.source}$`));if(!t)throw new Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:Gi(t[1])}}function na(e,t,n){const r=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return oo({...e,kind:Eo,tags:[...e.tags??[],...r,["e",t.id],["p",t.pubkey]],content:e.content??"+"},n)}function ra(e){if(e.kind!==Eo)return;let t,n;for(let r=e.tags.length-1;r>=0&&(void 0===t||void 0===n);r--){const o=e.tags[r];o.length>=2&&("e"===o[0]&&void 0===t?t=o:"p"===o[0]&&void 0===n&&(n=o))}return void 0!==t&&void 0!==n?{id:t[1],relays:[t[2],n[2]].filter(e=>void 0!==e),author:n[1]}:void 0}qr({},{finishReactionEvent:()=>na,getReactedEventPointer:()=>ra});qr({},{parse:()=>sa});var oa=/\W/m,ia=/\W |\W$|$|,| /m;function*sa(e){const t=e.length;let n=0,r=0;for(;raa,channelHideMessageEvent:()=>ua,channelMessageEvent:()=>ca,channelMetadataEvent:()=>la,channelMuteUserEvent:()=>da});var aa=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return oo({kind:Ao,tags:[...e.tags??[]],content:n,created_at:e.created_at},t)},la=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return oo({kind:To,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},ca=(e,t)=>{const n=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&n.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),oo({kind:_o,tags:[...n,...e.tags??[]],content:e.content,created_at:e.created_at},t)},ua=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return oo({kind:Io,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:n,created_at:e.created_at},t)},da=(e,t)=>{let n;if("object"==typeof e.content)n=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;n=e.content}return oo({kind:$o,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:n,created_at:e.created_at},t)};qr({},{EMOJI_SHORTCODE_REGEX:()=>fa,matchAll:()=>pa,regex:()=>ha,replaceAll:()=>ga});var fa=/:(\w+):/,ha=()=>new RegExp(`\\B${fa.source}\\B`,"g");function*pa(e){const t=e.matchAll(ha());for(const e of t)try{const[t,n]=e;yield{shortcode:t,name:n,start:e.index,end:e.index+t.length}}catch(e){}}function ga(e,t){return e.replaceAll(ha(),(e,n)=>t({shortcode:e,name:n}))}var ma;qr({},{useFetchImplementation:()=>ya,validateGithub:()=>va});try{ma=fetch}catch{}function ya(e){ma=e}async function va(e,t,n){try{return await(await ma(`https://gist.github.com/${t}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}function wa(e){const{host:t,pathname:n,searchParams:r}=new URL(e),o=n||t,i=r.get("relay"),s=r.get("secret");if(!o||!i||!s)throw new Error("invalid connection string");return{pubkey:o,relay:i,secret:s}}async function ba(e,t,n){const r={method:"pay_invoice",params:{invoice:n}},o=as(t,e,JSON.stringify(r)),i={kind:li,created_at:Math.round(Date.now()/1e3),content:o,tags:[["p",e]]};return oo(i,t)}qr({},{makeNwcRequestEvent:()=>ba,parseConnectionString:()=>wa});function Ea(e){return e=(e=e.trim().toLowerCase()).normalize("NFKC"),Array.from(e).map(e=>/\p{Letter}/u.test(e)||/\p{Number}/u.test(e)?e:"-").join("")}qr({},{normalizeIdentifier:()=>Ea});var xa;qr({},{getSatoshisAmountFromBolt11:()=>_a,getZapEndpoint:()=>Sa,makeZapReceipt:()=>Ta,makeZapRequest:()=>Ca,useFetchImplementation:()=>ka,validateZapRequest:()=>Aa});try{xa=fetch}catch{}function ka(e){xa=e}async function Sa(e){try{let t="",{lud06:n,lud16:r}=JSON.parse(e.content);if(n){let{words:e}=er.decode(n,1e3),r=er.fromWords(e);t=Wr.decode(r)}else{if(!r)return null;{let[e,n]=r.split("@");t=new URL(`/.well-known/lnurlp/${e}`,`https://${n}`).toString()}}let o=await xa(t),i=await o.json();if(i.allowsNostr&&i.nostrPubkey)return i.callback}catch(e){}return null}function Ca(e){let t={kind:9734,created_at:Math.round(Date.now()/1e3),content:e.comment||"",tags:[["p","pubkey"in e?e.pubkey:e.event.pubkey],["amount",e.amount.toString()],["relays",...e.relays]]};if("event"in e){if(t.tags.push(["e",e.event.id]),lo(e.event.kind)){const n=["a",`${e.event.kind}:${e.event.pubkey}:`];t.tags.push(n)}else if(uo(e.event.kind)){let n=e.event.tags.find(([e,t])=>"d"===e&&t);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${e.event.kind}:${e.event.pubkey}:${n[1]}`];t.tags.push(r)}t.tags.push(["k",e.event.kind.toString()])}return t}function Aa(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!Kr(t))return"Zap request is not a valid Nostr event.";if(!io(t))return"Invalid signature on zap request.";let n=t.tags.find(([e,t])=>"p"===e&&t);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=t.tags.find(([e,t])=>"e"===e&&t);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function Ta({zapRequest:e,preimage:t,bolt11:n,paidAt:r}){let o=JSON.parse(e),i=o.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),s={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...i,["P",o.pubkey],["bolt11",n],["description",e]]};return t&&s.tags.push(["preimage",t]),s}function _a(e){if(e.length<50)return 0;const t=(e=e.substring(0,50)).lastIndexOf("1");if(-1===t)return 0;const n=e.substring(0,t);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const o=r[r.length-1],i=o.charCodeAt(0)-"0".charCodeAt(0),s=i>=0&&i<=9;let a=r.length-1;if(s&&a++,a<1)return 0;const l=parseInt(r.substring(0,a));switch(o){case"m":return 1e5*l;case"u":return 100*l;case"n":return l/10;case"p":return l/1e4;default:return 1e8*l}}qr({},{getToken:()=>$a,hashPayload:()=>Ua,unpackEventFromToken:()=>Oa,validateEvent:()=>Fa,validateEventKind:()=>Ba,validateEventMethodTag:()=>La,validateEventPayloadTag:()=>ja,validateEventTimestamp:()=>Pa,validateEventUrlTag:()=>Na,validateToken:()=>Ra});var Ia="Nostr ";async function $a(e,t,n,r=!1,o){const i={kind:di,tags:[["u",e],["method",t]],created_at:Math.round((new Date).getTime()/1e3),content:""};o&&i.tags.push(["payload",Ua(o)]);const s=await n(i);return(r?Ia:"")+qn.encode(Vr.encode(JSON.stringify(s)))}async function Ra(e,t,n){const r=await Oa(e).catch(e=>{throw e});return await Fa(r,t,n).catch(e=>{throw e})}async function Oa(e){if(!e)throw new Error("Missing token");e=e.replace(Ia,"");const t=Wr.decode(qn.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw new Error("Invalid token");return JSON.parse(t)}function Pa(e){return!!e.created_at&&Math.round((new Date).getTime()/1e3)-e.created_at<60}function Ba(e){return e.kind===di}function Na(e,t){const n=e.tags.find(e=>"u"===e[0]);return!!n&&(n.length>0&&n[1]===t)}function La(e,t){const n=e.tags.find(e=>"method"===e[0]);return!!n&&(n.length>0&&n[1].toLowerCase()===t.toLowerCase())}function Ua(e){return Kt(un(Vr.encode(JSON.stringify(e))))}function ja(e,t){const n=e.tags.find(e=>"payload"===e[0]);if(!n)return!1;const r=Ua(t);return n.length>0&&n[1]===r}async function Fa(e,t,n,r){if(!io(e))throw new Error("Invalid nostr event, signature invalid");if(!Ba(e))throw new Error("Invalid nostr event, kind invalid");if(!Pa(e))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!Na(e,t))throw new Error("Invalid nostr event, url tag invalid");if(!La(e,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!ja(e,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}function Ma(e){return 3e4<=e&&e<4e4}var Da=function(e,t){return Da=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Da(e,t)};function Ha(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}Da(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function qa(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})}function za(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Wa(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function Va(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o1||a(e,t)})},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof Ja?Promise.resolve(n.value.v).then(l,c):u(i[0][2],n)}catch(e){u(i[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function Za(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Ka(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise(function(r,o){(function(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)})(r,o,(t=e[n](t)).done,t.value)})}}}function Ya(e){return"function"==typeof e}function Qa(e){var t=e(function(e){Error.call(e),e.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var Xa=Qa(function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}});function el(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var tl=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var s=Ka(i),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else i.remove(this);var l=this.initialTeardown;if(Ya(l))try{l()}catch(e){o=e instanceof Xa?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var u=Ka(c),d=u.next();!d.done;d=u.next()){var f=d.value;try{ol(f)}catch(e){o=null!=o?o:[],e instanceof Xa?o=Va(Va([],Wa(o)),Wa(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(o)throw new Xa(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)ol(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&el(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&el(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),nl=tl.EMPTY;function rl(e){return e instanceof tl||e&&"closed"in e&&Ya(e.remove)&&Ya(e.add)&&Ya(e.unsubscribe)}function ol(e){Ya(e)?e():e.unsubscribe()}var il={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},sl={setTimeout:function(e,t){for(var n=[],r=2;r0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,o=n.isStopped,i=n.observers;return r||o?nl:(this.currentObservers=null,i.push(e),new tl(function(){t.currentObservers=null,el(i,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new wl;return e.source=this,e},t.create=function(e,t){return new Al(e,t)},t}(wl),Al=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return Ha(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:nl},t}(Cl),Tl={now:function(){return(Tl.delegate||Date).now()},delegate:void 0},_l=function(e){function t(t,n,r){void 0===t&&(t=1/0),void 0===n&&(n=1/0),void 0===r&&(r=Tl);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=n,o._timestampProvider=r,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,n),o}return Ha(t,e),t.prototype.next=function(t){var n=this,r=n.isStopped,o=n._buffer,i=n._infiniteTimeWindow,s=n._timestampProvider,a=n._windowTime;r||(o.push(t),!i&&o.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this._infiniteTimeWindow,r=this._buffer.slice(),o=0;o=2,!0))}function Ic(e,t){for(var n=[],r=2;rt.reduce((e,t)=>{const n=[];for(const r of e)try{const e=t(r);if(void 0===e)continue;n.push(e)}catch(e){}return n},e);function Fc(e,t,n){if(Reflect.has(e,t))return Reflect.get(e,t);{const r=n();return Reflect.set(e,t,r),r}}function Mc(e,t){const[n,r]=Dc(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return r||e.splice(n,0,t),e}function Dc(e,t){let n=0,r=e.length-1;for(;n<=r;){const o=Math.floor((n+r)/2),i=t(e[o]);if(0===i)return[o,!0];i<0?r=o-1:n=o+1}return[n,!1]}new TextDecoder("utf-8"),new TextEncoder;const Hc=Symbol.for("event-store"),qc=Symbol.for("event-uid"),zc=Symbol.for("replaceable-address"),Kc=Symbol.for("from-cache"),Wc=Symbol.for("replaceable-identifier");function Vc(e){return function(e){return[0,3].includes(e)||1e4<=e&&e<2e4}(e)||Ma(e)}function Jc(e){let t=Reflect.get(e,qc);return t||(t=Vc(e.kind)?Gc(e):e.id,Reflect.set(e,qc,t)),t}function Gc(e){if(!Vc(e.kind))throw new Error("Event is not replaceable or addressable");return Fc(e,zc,()=>{const t=Ma(e.kind)?Yc(e):void 0;return Zc(e.kind,e.pubkey,t)})}function Zc(e,t,n){return e+":"+t+":"+(n??"")}function Yc(e){return Fc(e,Wc,()=>e.tags.find(e=>"d"===e[0])?.[1]??"")}function Qc(){return Math.round(Date.now()/1e3)}const Xc=Symbol("expiration-timestamp");function eu(e){return Fc(e,Xc,()=>{const t=e.tags.find(e=>"expiration"===e[0])?.[1];return t?parseInt(t):void 0})}function tu(e){let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),("80"!==t.port||"ws:"!==t.protocol&&"http:"!==t.protocol)&&("443"!==t.port||"wss:"!==t.protocol&&"https:"!==t.protocol)||(t.port=""),"string"==typeof e?t.toString():t}const nu=Symbol.for("seen-relays");function ru(e,t){return e[nu]||(e[nu]=new Set),e[nu].add(t),e[nu]}const ou=/^wss?:\/\/([-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}|localhost)\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)$/;function iu(e){return e.length>=8&&ou.test(e)}function su(e){return!!e?.toLowerCase()?.match(/^[0-9a-f]{64}$/)} +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const au=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),lu=48,cu=57,uu=65,du=70,fu=97,hu=102;function pu(e){return e>=lu&&e<=cu?e-lu:e>=uu&&e<=du?e-(uu-10):e>=fu&&e<=hu?e-(fu-10):void 0}function gu(e,t=!1,n=!0){const r=e.split(":"),o=r[0]?parseInt(r[0]):void 0,i=r[1],s=r[2];if(void 0===o){if(n)return null;throw new Error("Missing kind")}if(void 0===i||""===i){if(n)return null;throw new Error("Missing pubkey")}if(t&&void 0===s){if(n)return null;throw new Error("Missing identifier")}return{kind:o,pubkey:i,identifier:s}}function mu(e){if(!e[1])throw new Error("Missing coordinate in tag");const t=gu(e[1],!0,!1);return e[2]&&iu(e[2])&&(t.relays=[e[2]]),t}function yu(e){if(!e[1])throw new Error("Missing pubkey in tag");if(!su(e[1]))throw new Error("Invalid pubkey");const t={pubkey:e[1]};return e[2]&&iu(e[2])&&(t.relays=[tu(e[2])]),t}function vu(e){return e.kind+":"+e.pubkey+":"+e.identifier}function wu(e){if(e instanceof Uint8Array)return e;if(su(e))return function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(au)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 r=new Uint8Array(n);for(let t=0,o=0;tArray.isArray(e)).map(e=>e.map(e=>String(e)));return Reflect.set(e,Iu,r),r}const Bu="abcdefghijklmnopqrstuvwxyz",Nu=new Set((Bu+Bu.toUpperCase()).split("")),Lu=Symbol.for("indexable-tags");function Uu(e){let t=Reflect.get(e,Lu);if(!t){const n=new Set;for(const t of e.tags)t.length>=2&&1===t[0].length&&Nu.has(t[0])&&n.add(t[0]+":"+t[1]);t=n,Reflect.set(e,Lu,n)}return t}class ju{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,r=this.resetTtl){let o;if(n||this.has(e)){if(o=this.items[e],o.value=t,!1===n&&r&&(o.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==o){const e=this.last,t=o.next,n=o.prev;this.first===o&&(this.first=o.next),o.next=null,o.prev=this.last,e.next=o,null!==n&&(n.next=t),null!==t&&(t.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),o=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=o:this.last.next=o;return this.last=o,this}values(e=this.keys()){return e.map(e=>this.get(e))}}function Fu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mu,Du,Hu={exports:{}};function qu(){if(Du)return Mu;Du=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,i=365.25*r;function s(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return Mu=function(a,l){l=l||{};var c=typeof a;if("string"===c&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var l=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*i;case"weeks":case"week":case"w":return l*o;case"days":case"day":case"d":return l*r;case"hours":case"hour":case"hrs":case"hr":case"h":return l*n;case"minutes":case"minute":case"mins":case"min":case"m":return l*t;case"seconds":case"second":case"secs":case"sec":case"s":return l*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}(a);if("number"===c&&isFinite(a))return l.long?function(o){var i=Math.abs(o);if(i>=r)return s(o,i,r,"day");if(i>=n)return s(o,i,n,"hour");if(i>=t)return s(o,i,t,"minute");if(i>=e)return s(o,i,e,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=r)return Math.round(o/r)+"d";if(i>=n)return Math.round(o/n)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var zu=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e,t){let n=0,r=0,o=-1,i=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(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=qu(),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&&(r++,"%c"===e&&(o=r))}),t.splice(o,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=zu(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Hu,Hu.exports);const Ku=Fu(Hu.exports)("applesauce");class Wu{log=Ku.extend("EventMemory");kinds=new Map;authors=new Map;tags=new ju;created_at=[];events=new ju;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 r=this.replaceable.get(Zc(e,t,n));return!!r&&r.length>0}getReplaceable(e,t,n){const r=Zc(e,t,n),o=this.replaceable.get(r);return o?.[0]}getReplaceableHistory(e,t,n){const r=Zc(e,t,n);return this.replaceable.get(r)}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)Mc(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);for(const t of Uu(e))this.tags.has(t)&&this.getTagIndex(t).add(e);if(Mc(this.created_at,e),Vc(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=Zc(e.kind,e.pubkey,t);let r=this.replaceable.get(n);this.replaceable.has(n)||(r=[],this.replaceable.set(n,r)),Mc(r,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);for(const e of Uu(t))this.tags.has(e)&&this.getTagIndex(e).delete(t);const r=this.created_at.indexOf(t);if(this.created_at.splice(r,1),this.events.delete(n),Vc(t.kind)){const e=t.tags.find(e=>"d"===e[0])?.[1],n=Zc(t.kind,t.pubkey,e),r=this.replaceable.get(n);if(r&&r.includes(t)){const e=r.indexOf(t);r.splice(e,1)}}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,t){this.claims.has(e)||this.claims.set(e,t),this.touch(e)}isClaimed(e){return this.claims.has(e)}removeClaim(e,t){this.claims.get(e)===t&&this.claims.delete(e)}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 r of n)if(this.remove(r),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)}getTagIndex(e){if(!this.tags.has(e)){const t=new Set,n=Date.now();for(const n of this.events.values())Uu(n).has(e)&&t.add(n);const r=Date.now()-n;r>100&&this.log(`Built index ${e} took ${r}ms`),this.tags.set(e,t)}return this.tags.get(e)}*iterateAuthors(e){for(const t of e){const e=this.authors.get(t);if(e)for(const t of e)yield t}}*iterateTag(e,t){for(const n of t){const t=this.getTagIndex(e+":"+n);if(t)for(const e of t)yield e}}*iterateKinds(e){for(const t of e){const e=this.kinds.get(t);if(e)for(const t of e)yield t}}*iterateTime(e,t){let n=0,r=this.created_at.length-1,o=t?Dc(this.created_at,e=>e.created_at-t):void 0;o&&(n=o[0]);const i=e?Dc(this.created_at,t=>t.created_at-e):void 0;i&&(r=i[0]);for(let e=n;e{const r=e instanceof Set?e:new Set(e);if(t)n=r,t=!1;else for(const e of n)r.has(e)||n.delete(e);return n};e.ids&&r(this.iterateIds(e.ids));let o=null;void 0!==e.since&&(o=Array.from(this.iterateTime(e.since,e.until)),r(o));for(const t of Nu){const n=e[`#${t}`];n?.length&&r(this.iterateTag(t,n))}if(e.authors&&r(this.iterateAuthors(e.authors)),e.kinds&&r(this.iterateKinds(e.kinds)),void 0===e.since&&void 0!==e.until&&(o=Array.from(this.iterateTime(e.since,e.until)),r(o)),e.limit&&o){const t=new Set;for(const r of o){if(t.size>=e.limit)break;n.has(r)&&t.add(r)}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.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}}function Vu(e,t){var n,r;if(0===t.length)return e;for(n=0,r=t.length;ne.has(r+":"+t)))return!1}}return!(e.since&&t.created_ate.until)}function Qu(e,t){for(let n=0;nt.replaceable({kind:10063,pubkey:e.pubkey,relays:e.relays}).pipe(oc(e=>e?function(e){const t=Array.isArray(e)?e:e.tags;return jc(t,e=>Oc(e,"server")&&URL.canParse(e[1])?new URL("/",e[1]):void 0)}(e):[]))}const ed=Symbol.for("profile-content");function td(e){return Fc(e,ed,()=>{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 nd(e){return!!e&&((e.kind===so.Metadata||e.kind===so.Handlerinformation)&&!!td(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),r=e.reduce((e,n)=>e?t(e,n.decode):n.decode,void 0);return{encode:n,decode:r}}function r(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 o(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 i(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 r=t.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&t[r-1]===n;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,r)}}}function s(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function a(e,n,r){if(n<2)throw new Error(`convertRadix: wrong from=${n}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let o=0;const i=[],s=Array.from(e);for(s.forEach(e=>{if(t(e),e<0||e>=n)throw new Error(`Wrong integer: ${e}`)});;){let e=0,t=!0;for(let i=o;it?c(t,e%t):e,l=(e,t)=>e+(t-c(e,t));function u(e,n,r,o){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(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(l(n,r)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${r} carryBits=${l(n,r)}`);let i=0,s=0;const a=2**r-1,c=[];for(const o of e){if(t(o),o>=2**n)throw new Error(`convertRadix2: invalid data word=${o} from=${n}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${n}`);for(s+=n;s>=r;s-=r)c.push((i>>s-r&a)>>>0);i&=2**s-1}if(i=i<=n)throw new Error("Excess padding");if(!o&&i)throw new Error(`Non-zero padding: ${i}`);return o&&s>0&&c.push(i>>>0),c}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(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(a(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(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(t,e,8,n))}}}function h(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function p(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=n(t).slice(0,e),o=new Uint8Array(t.length+e);return o.set(t),o.set(r,t.length),o},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=t.slice(0,-e),o=n(r).slice(0,e),i=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),i(6),o("")),e.base64url=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),i(6),o(""));const y=e=>n(d(58),r(e),o(""));e.base58=y("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=y("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=y("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const g=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let r=0;rn(p(4,e=>t(t(e))),e.base58);const m=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),o("")),v=[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^=v[e]);return n}function b(e,t,n=1){const r=e.length;let o=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);o=w(o)^n>>5}o=w(o);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=e.slice(0,o),s=e.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=m.decode(s).slice(0,-6),c=b(i,a,t);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:i,words:a}}return{encode:function(e,n,r=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 o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${m.encode(n)}${b(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:h(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}e.bech32=x("bech32"),e.bech32m=x("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),r("0123456789abcdef"),o(""),s(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 E={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},k=`Invalid encoding type. Available types: ${Object.keys(E).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!E.hasOwnProperty(e))throw new TypeError(k);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return E[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!E.hasOwnProperty(e))throw new TypeError(k);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return E[e].decode(t)},e.bytes=e.stringToBytes}({}),BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const rd={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(rd);ejl(e.tags,e=>Ll(e)?e:void 0,mu))}(e),function(e){if(function(e){return Ru(e)&&Reflect.has(e,id)}(e))return e[id];const t=Pu(e);if(!t)return;const n=jl(t,e=>Ll(e)?e:void 0,mu);return Reflect.set(e,id,n),n}(e))}Wu.extend("EncryptedContentCache"),Wu.extend("event-cache"),new TextDecoder;const ad=Symbol.for("mailboxes-inboxes"),cd=Symbol.for("mailboxes-outboxes");function ld(e){return Ml(e,ad,()=>{const t=[];for(const n of e.tags)if(Bl(n))try{const[,e,r]=n;!e||!iu(e)||t.includes(e)||"read"!==r&&void 0!==r||t.push(tu(e))}catch{}return t})}function ud(e){return Ml(e,cd,()=>{const t=[];for(const n of e.tags)if(Bl(n))try{const[e,r,o]=n;"r"!==e||!iu(r)||t.includes(r)||"write"!==o&&void 0!==o||t.push(tu(r))}catch{}return t})}const dd=Symbol.for("mute-public"),fd=Symbol.for("mute-hidden");function hd(e){return{pubkeys:new Set(e.filter(Ll).map(e=>e[1])),threads:new Set(e.filter(Pl).map(e=>e[1])),hashtags:new Set(e.filter(Ul).map(e=>e[1].toLocaleLowerCase())),words:new Set(e.filter(e=>"word"===e[0]&&e[1]).map(e=>e[1].toLocaleLowerCase()))}}function pd(e){const t=function(e){if(function(e){return Ru(e)&&Reflect.has(e,fd)}(e))return e[fd];const t=Pu(e);if(!t)return;const n=hd(t);return Reflect.set(e,fd,n),n}(e),n=function(e){return Ml(e,dd,()=>hd(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 yd;!function(e){e.nudity="nudity",e.malware="malware",e.profanity="profanity",e.illegal="illegal",e.spam="spam",e.impersonation="impersonation",e.other="other"}(yd||(yd={}));const gd=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]&&iu(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 vd(e){return t=>{const n=new Set;return t.pipe(Ol(r=>{if(void 0!==r)if(Array.isArray(r))for(const o of r)n.add(o),e.claim(o,t);else n.add(r),e.claim(r,t)}),Al(()=>{for(const r of n)e.removeClaim(r,t)}))}}function wd(e){return t=>{let n;return t.pipe(Ol(r=>{n&&e.removeClaim(n,t),r&&e.claim(r,t),n=r}),Al(()=>{n&&e.removeClaim(n,t)}))}}function bd(){return e=>e.pipe(bl(e=>null!=e))}function xd(e){return t=>new wc(n=>{let r=!1;const o=t.subscribe({next:e=>{r=!0,n.next(e)},error:e=>n.error(e),complete:()=>n.complete()});return r||n.next(e),o})}function Ed(e){return"string"==typeof e&&(e={id:e}),t=>wl(ml(()=>function(e,t){const n=e.getEvent(t.id);return n instanceof Promise?nl(n):rl(n)}(t,e)).pipe(function(e,t){return Il(n=>n?rl(n):e.eventLoader?nl(e.eventLoader(t)):Bc)}(t,e),bd()),t.insert$.pipe(bl(t=>t.id===e.id)),t.remove$.pipe(bl(t=>t.id===e.id),xl(1),xc(function(e,t){e.subscribe(Ec(t,cc))}),Sl(void 0))).pipe(wd(t),El((e,t)=>e?.id===t?.id),xd(void 0))}function kd(e){return t=>{let n;return wl(ml(()=>function(e,t){const n=e.getReplaceable(t.kind,t.pubkey,t.identifier);return n instanceof Promise?nl(n):rl(n)}(t,e)).pipe(function(e,t){return Il(n=>n?rl(n):void 0!==t.identifier?e.addressableLoader?nl(e.addressableLoader(t)).pipe(bl(e=>!!e)):Bc:e.replaceableLoader?nl(e.replaceableLoader(t)).pipe(bl(e=>!!e)):Bc)}(t,e),bd()),t.insert$.pipe(bl(t=>t.pubkey==e.pubkey&&t.kind===e.kind&&(void 0===e.identifier||Yl(t)===e.identifier)))).pipe(El((e,t)=>e.created_at>=t.created_at),Ol(e=>n=e),(a=t.remove$.pipe(bl(e=>e.id===n?.id)),xc(function(e,t){Gc(a).subscribe(Ec(t,function(){return t.complete()},cc)),!t.closed&&e.subscribe(t)})),Sl(void 0),(s=1/0,null!=r&&("object"==typeof r?(o=r.count,s=void 0===o?1/0:o,i=r.delay):s=r),s<=0?function(){return Bc}:xc(function(e,t){var n,r=0,o=function(){if(null==n||n.unsubscribe(),n=null,null!=i){var e="number"==typeof i?vl(i):Gc(i(r)),o=Ec(t,function(){o.unsubscribe(),a()});e.subscribe(o)}else a()},a=function(){var i=!1;n=e.subscribe(Ec(t,void 0,function(){++r{const r=new Map;return ml(()=>{const t=n.getTimeline(e);return t instanceof Promise?nl(t):rl(t)}).pipe(vd(n),Tl(n.insert$.pipe(bl(t=>Qu(e,t)),vd(n))),Tl(n.remove$.pipe(bl(t=>Qu(e,t)),ol(e=>e.id))),_l((e,n)=>{if("string"==typeof n)return e.filter(e=>e.id!==n);if(Array.isArray(n)){if(!t)for(const e of n)Jl(e.kind)&&r.set(Vl(e),e);return n}let o=[...e];if(!t&&Jl(n.kind)){const t=Vl(n),i=r.get(t);if(i&&n.created_atr.clear()))}}function Ad(e){return t=>fl(Object.fromEntries(e.map(e=>[e,t.model(Ed,{id:e})])))}function Cd(e){return t=>fl(Object.fromEntries(e.map(e=>[Zl(e.kind,e.pubkey,e.identifier),t.model(kd,e)])))}function Td(e){return t=>{let n;return wl(t.pipe(Ol(e=>n=e)),e.update$.pipe(bl(e=>e.id===n?.id)))}}function _d(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:so.Contacts,pubkey:e.pubkey,relays:e.relays}).pipe(Td(t),ol(e=>e?sd(e):[]))}function $d(e){return t=>{const n=[{kinds:[1111],"#e":[e.id]}];return Fa(e.kind)&&n.push({kinds:[1111],"#a":[Gl(e)]}),t.timeline(n)}}function Id(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:so.RelayList,pubkey:e.pubkey,relays:e.relays}).pipe(ol(e=>e&&{inboxes:ld(e),outboxes:ud(e)}))}function Od(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:so.Mutelist,pubkey:e.pubkey,relays:e.relays}).pipe(Td(t),ol(e=>e&&pd(e)))}function Rd(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:so.Metadata,pubkey:e.pubkey,relays:e.relays}).pipe(bl(nd),ol(e=>e&&td(e)),xd(void 0))}function Pd(e){return t=>t.timeline(Jl(e.kind)?[{kinds:[so.Reaction],"#e":[e.id]},{kinds:[so.Reaction],"#a":[Vl(e)]}]:[{kinds:[so.Reaction],"#e":[e.id]}])}const Ld={kinds:[so.ShortTextNote]};function Bd(e,t){const n=new Map,r=new Map,{kinds:o}={...Ld,...t};let i="";const s={},a={kinds:o};var c;return"string"!=typeof(c=e)&&Reflect.has(c,"identifier")&&Reflect.has(c,"pubkey")&&Reflect.has(c,"kind")?(i=vu(e),s.kinds=[e.kind],s.authors=[e.pubkey],s["#d"]=[e.identifier],a["#a"]=[i]):"string"==typeof e?(i=e,s.ids=[e],a["#e"]=[e]):(i=e.id,s.ids=[e.id],a["#e"]=[e.id]),e=>e.filters([s,a]).pipe(ol(e=>{if(!r.has(Vl(e))){const t=function(e){return Ml(e,gd,()=>{const t=function(e){const t=e.filter(e=>"e"===e[0]&&e[1]),n=e.filter(e=>"a"===e[0]&&e[1]);let r=t.find(e=>"root"===e[3]),o=t.find(e=>"reply"===e[3]),i=n.find(e=>"root"===e[3]),s=n.find(e=>"reply"===e[3]);if(r&&o||(r=o=r||o),i&&s||(i=s=i||s),!r&&!o){const e=t.filter(e=>!e[3]);e.length>=1&&(r=e[0],o=e[e.length-1]??r)}return{root:r||i?{e:r,a:i}:void 0,reply:o||s?{e:o,a:s}:void 0}}(e.tags);let n,r;if(t.root)try{n={e:t.root.e&&md(t.root.e),a:t.root.a&&gu(t.root.a)}}catch(e){}if(t.reply)try{r={e:t.reply.e&&md(t.reply.e),a:t.reply.a&&gu(t.reply.a)}}catch(e){}return{root:n,reply:r}})}(e),o=n.get(Vl(e))||new Set,i={event:e,refs:t,replies:o};for(const e of o)e.parent=i;if(t.reply?.e||t.reply?.a){let e=t.reply.e?t.reply.e.id:vu(t.reply.a);if(i.parent=r.get(e),i.parent)i.parent.replies.add(i);else{let t=n.get(e);t||(t=new Set,n.set(e,t)),t.add(i)}}r.set(Vl(e),i)}return{root:r.get(i),all:r}}))}function Nd(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 r=e.getKey?e.getKey(...t):Zu(t);let o=n.get(r);if(!o){const i=()=>{n.get(r)===o&&n.delete(r)};o=e(...t)(this).pipe(Al(i),function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new Ac}:t,r=e.resetOnError,o=void 0===r||r,i=e.resetOnComplete,s=void 0===i||i,a=e.resetOnRefCountZero,c=void 0===a||a;return function(e){var t,r,i,a=0,l=!1,u=!1,d=function(){null==r||r.unsubscribe(),r=void 0},f=function(){d(),t=i=void 0,l=u=!1},h=function(){var e=t;f(),null==e||e.unsubscribe()};return xc(function(e,p){a++,u||l||d();var y=i=null!=i?i:n();p.add(function(){0!==--a||u||l||(r=$l(h,c))}),y.subscribe(p),!t&&a>0&&(t=new pc({next:function(e){return y.next(e)},error:function(e){u=!0,d(),r=$l(f,o,e),y.error(e)},complete:function(){l=!0,d(),r=$l(f,s),y.complete()}}),Gc(e).subscribe(t))})(e)}}({connector:()=>new _c(1),resetOnComplete:()=>vl(this.modelKeepWarm),resetOnRefCountZero:()=>vl(this.modelKeepWarm)})),n.set(r,o)}return o}filters(e,t=!1){e=Array.isArray(e)?e:[e];const n=this.getByFilters(e);return wl(t?Bc:n&&"function"==typeof n.then?nl(n).pipe(pl(e=>nl(Array.from(e)))):nl(Array.from(n)),this.insert$.pipe(bl(t=>Qu(e,t))))}event(e){return"string"==typeof e&&(e={id:e}),this.model(Ed,e)}replaceable(...e){let t;if(1===e.length)t=e[0];else if(3===e.length||2===e.length){let[n,r,o]=e;t={kind:n,pubkey:r,identifier:o}}if(!t)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(kd,t)}addressable(e){return this.model(kd,e)}timeline(e,t=!1){return this.model(Sd,e,t)}profile(e){return this.model(Rd,e)}contacts(e){return"string"==typeof e&&(e={pubkey:e}),this.model(_d,e)}mutes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Od,e)}mailboxes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Id,e)}blossomServers(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Xu,e)}reactions(e){return this.model(Pd,e)}thread(e){return this.model(Bd,e)}comments(e){return this.model($d,e)}events(e){return this.model(Ad,e)}replaceableSet(e){return this.model(Cd,e)}}}class Ud extends(Nd(class{})){database;memory;keepOldVersions=!1;keepExpired=!1;verifyEvent;insert$=new Ac;update$=new Ac;remove$=new Ac;eventLoader;replaceableLoader;addressableLoader;constructor(e=new Ku){super(),e?(this.database=e,this.memory=new Ku):this.database=this.memory=new Ku,this.insert$.subscribe(e=>{Reflect.set(e,Hl,this)}),this.remove$.subscribe(e=>{Reflect.deleteProperty(e,Hl)})}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(Fa(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=this.deletedCoords.get(Zl(e.kind,e.pubkey,t));if(n)return n>e.created_at}return!1}expirations=new Map;addExpiration(e){const t=eu(e);t&&Number.isFinite(t)&&this.expirations.set(e.id,t)}expirationTimeout=null;nextExpirationCheck=null;handleExpiringEvent(e){const t=eu(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(Nl).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=yu(t);if(!n)continue;const r=this.database.getReplaceableHistory(n.kind,n.pubkey,n.identifier)??[];for(const t of r)t.created_at"d"===e[0])?.[1]:void 0;if(!this.keepOldVersions&&Jl(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,r);if(t&&t.length>0&&t[0].created_at>=e.created_at)return Ud.mergeDuplicateEvent(e,t[0]),t[0]}if(this.verifyEvent&&!1===this.verifyEvent(e))return null;const o=this.memory?.add(e);if(o&&o!==e)return Ud.mergeDuplicateEvent(e,o),t&&ru(o,t),o;const i=this.mapToMemory(this.database.add(e));if(e!==i&&Ud.mergeDuplicateEvent(e,i),t&&ru(i,t),i===e&&this.insert$.next(i),!this.keepOldVersions&&Jl(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,r);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,t){return this.memory?.claim(e,t)}isClaimed(e){return this.memory?.isClaimed(e)??!1}removeClaim(e,t){return this.memory?.removeClaim(e,t)}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)?Bc:this.remove$.pipe(bl(t=>t.id===e),xl(1),pl(()=>Bc))}updated(e){return this.update$.pipe(bl(t=>t.id===e||t===e))}}function jd(){let e,t;const n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var Md,Fd;Au(so.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"}(Md||(Md={})),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"}(Fd||(Fd={}));class Dd{key;constructor(e){this.key=e||no()}async getPublicKey(){return ro(this.key)}async signEvent(e){return oo(e,this.key)}nip04={encrypt:async(e,t)=>ss.encrypt(this.key,e,t),decrypt:async(e,t)=>ss.decrypt(this.key,e,t)};nip44={encrypt:async(e,t)=>ks.v2.encrypt(t,ks.v2.utils.getConversationKey(this.key,e)),decrypt:async(e,t)=>ks.v2.decrypt(t,ks.v2.utils.getConversationKey(this.key,e))};static fromKey(e){return new Dd(wu(e))}}const Hd="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0; -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qd(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 zd=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Wd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Kd(e){if(qd(e),zd)return e.toHex();let t="";for(let n=0;n=Jd&&e<=Vd?e-Jd:e>=Gd&&e<=Zd?e-(Gd-10):e>=Yd&&e<=Qd?e-(Yd-10):void 0}function ef(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(zd)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 r=new Uint8Array(n);for(let t=0,o=0;tt?l(t,e%t):e,c=(e,t)=>e+(t-l(e,t));function u(e,n,r,o){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(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(c(n,r)>32)throw new Error(`convertRadix2: carry overflow from=${n} to=${r} carryBits=${c(n,r)}`);let i=0,s=0;const a=2**r-1,l=[];for(const o of e){if(t(o),o>=2**n)throw new Error(`convertRadix2: invalid data word=${o} from=${n}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${n}`);for(s+=n;s>=r;s-=r)l.push((i>>s-r&a)>>>0);i&=2**s-1}if(i=i<=n)throw new Error("Excess padding");if(!o&&i)throw new Error(`Non-zero padding: ${i}`);return o&&s>0&&l.push(i>>>0),l}function d(e){return t(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return a(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(a(t,e,256))}}}function f(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(c(8,e)>32||c(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return u(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(u(t,e,8,n))}}}function h(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function p(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=n(t).slice(0,e),o=new Uint8Array(t.length+e);return o.set(t),o.set(r,t.length),o},decode(t){if(!(t instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=t.slice(0,-e),o=n(r).slice(0,e),i=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),i(6),o("")),e.base64url=n(f(6),r("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),i(6),o(""));const g=e=>n(d(58),r(e),o(""));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 r=0;rn(p(4,e=>t(t(e))),e.base58);const y=n(r("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),o("")),v=[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^=v[e]);return n}function b(e,t,n=1){const r=e.length;let o=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);o=w(o)^n>>5}o=w(o);for(let t=0;tn)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${n})`);const r=e.toLowerCase();if(e!==r&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=(e=r).lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const i=e.slice(0,o),s=e.slice(o+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=y.decode(s).slice(0,-6),l=b(i,a,t);if(!s.endsWith(l))throw new Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:i,words:a}}return{encode:function(e,n,r=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 o=e.length+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);return`${e=e.toLowerCase()}1${y.encode(n)}${b(e,n,t)}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:n}=s(e,!1);return{prefix:t,words:n,bytes:r(n)}},decodeUnsafe:h(s),fromWords:r,fromWordsUnsafe:i,toWords:o}}e.bech32=E("bech32"),e.bech32m=E("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(f(4),r("0123456789abcdef"),o(""),s(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 x={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},k=`Invalid encoding type. Available types: ${Object.keys(x).join(", ")}`;e.bytesToString=(e,t)=>{if("string"!=typeof e||!x.hasOwnProperty(e))throw new TypeError(k);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return x[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!x.hasOwnProperty(e))throw new TypeError(k);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return x[e].decode(t)},e.bytes=e.stringToBytes}({}),BigInt(1e3),BigInt(1e6),BigInt(1e9),BigInt(1e12),BigInt("2100000000000000000"),BigInt(1e11);const rd={payment_hash:1,payment_secret:16,description:13,payee:19,description_hash:23,expiry:6,min_final_cltv_expiry:24,fallback_address:9,route_hint:3,feature_bits:5,metadata:27};for(let e=0,t=Object.keys(rd);ejc(e.tags,e=>Bc(e)?e:void 0,yu))}(e),function(e){if(function(e){return Ou(e)&&Reflect.has(e,id)}(e))return e[id];const t=Pu(e);if(!t)return;const n=jc(t,e=>Bc(e)?e:void 0,yu);return Reflect.set(e,id,n),n}(e))}Ku.extend("EncryptedContentCache"),Ku.extend("event-cache"),new TextDecoder;const ad=Symbol.for("mailboxes-inboxes"),ld=Symbol.for("mailboxes-outboxes");function cd(e){return Fc(e,ad,()=>{const t=[];for(const n of e.tags)if(Nc(n))try{const[,e,r]=n;!e||!iu(e)||t.includes(e)||"read"!==r&&void 0!==r||t.push(tu(e))}catch{}return t})}function ud(e){return Fc(e,ld,()=>{const t=[];for(const n of e.tags)if(Nc(n))try{const[e,r,o]=n;"r"!==e||!iu(r)||t.includes(r)||"write"!==o&&void 0!==o||t.push(tu(r))}catch{}return t})}const dd=Symbol.for("mute-public"),fd=Symbol.for("mute-hidden");function hd(e){return{pubkeys:new Set(e.filter(Bc).map(e=>e[1])),threads:new Set(e.filter(Pc).map(e=>e[1])),hashtags:new Set(e.filter(Uc).map(e=>e[1].toLocaleLowerCase())),words:new Set(e.filter(e=>"word"===e[0]&&e[1]).map(e=>e[1].toLocaleLowerCase()))}}function pd(e){const t=function(e){if(function(e){return Ou(e)&&Reflect.has(e,fd)}(e))return e[fd];const t=Pu(e);if(!t)return;const n=hd(t);return Reflect.set(e,fd,n),n}(e),n=function(e){return Fc(e,dd,()=>hd(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 gd;!function(e){e.nudity="nudity",e.malware="malware",e.profanity="profanity",e.illegal="illegal",e.spam="spam",e.impersonation="impersonation",e.other="other"}(gd||(gd={}));const md=Symbol.for("nip10-thread-refs");function yd(e){if(!e[1])throw new Error("Missing event id in tag");let t={id:e[1]};return e[2]&&iu(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 vd(e){return t=>{const n=new Set;return t.pipe(Rc(r=>{if(void 0!==r)if(Array.isArray(r))for(const o of r)n.add(o),e.claim(o,t);else n.add(r),e.claim(r,t)}),Cc(()=>{for(const r of n)e.removeClaim(r,t)}))}}function wd(e){return t=>{let n;return t.pipe(Rc(r=>{n&&e.removeClaim(n,t),r&&e.claim(r,t),n=r}),Cc(()=>{n&&e.removeClaim(n,t)}))}}function bd(){return e=>e.pipe(bc(e=>null!=e))}function Ed(e){return t=>new wl(n=>{let r=!1;const o=t.subscribe({next:e=>{r=!0,n.next(e)},error:e=>n.error(e),complete:()=>n.complete()});return r||n.next(e),o})}function xd(e){return"string"==typeof e&&(e={id:e}),t=>wc(yc(()=>function(e,t){const n=e.getEvent(t.id);return n instanceof Promise?nc(n):rc(n)}(t,e)).pipe(function(e,t){return $c(n=>n?rc(n):e.eventLoader?nc(e.eventLoader(t)):Nl)}(t,e),bd()),t.insert$.pipe(bc(t=>t.id===e.id)),t.remove$.pipe(bc(t=>t.id===e.id),Ec(1),El(function(e,t){e.subscribe(xl(t,ll))}),Sc(void 0))).pipe(wd(t),xc((e,t)=>e?.id===t?.id),Ed(void 0))}function kd(e){return t=>{let n;return wc(yc(()=>function(e,t){const n=e.getReplaceable(t.kind,t.pubkey,t.identifier);return n instanceof Promise?nc(n):rc(n)}(t,e)).pipe(function(e,t){return $c(n=>n?rc(n):void 0!==t.identifier?e.addressableLoader?nc(e.addressableLoader(t)).pipe(bc(e=>!!e)):Nl:e.replaceableLoader?nc(e.replaceableLoader(t)).pipe(bc(e=>!!e)):Nl)}(t,e),bd()),t.insert$.pipe(bc(t=>t.pubkey==e.pubkey&&t.kind===e.kind&&(void 0===e.identifier||Yc(t)===e.identifier)))).pipe(xc((e,t)=>e.created_at>=t.created_at),Rc(e=>n=e),(a=t.remove$.pipe(bc(e=>e.id===n?.id)),El(function(e,t){Gl(a).subscribe(xl(t,function(){return t.complete()},ll)),!t.closed&&e.subscribe(t)})),Sc(void 0),(s=1/0,null!=r&&("object"==typeof r?(o=r.count,s=void 0===o?1/0:o,i=r.delay):s=r),s<=0?function(){return Nl}:El(function(e,t){var n,r=0,o=function(){if(null==n||n.unsubscribe(),n=null,null!=i){var e="number"==typeof i?vc(i):Gl(i(r)),o=xl(t,function(){o.unsubscribe(),a()});e.subscribe(o)}else a()},a=function(){var i=!1;n=e.subscribe(xl(t,void 0,function(){++r{const r=new Map;return yc(()=>{const t=n.getTimeline(e);return t instanceof Promise?nc(t):rc(t)}).pipe(vd(n),Tc(n.insert$.pipe(bc(t=>Qu(e,t)),vd(n))),Tc(n.remove$.pipe(bc(t=>Qu(e,t)),oc(e=>e.id))),_c((e,n)=>{if("string"==typeof n)return e.filter(e=>e.id!==n);if(Array.isArray(n)){if(!t)for(const e of n)Vc(e.kind)&&r.set(Jc(e),e);return n}let o=[...e];if(!t&&Vc(n.kind)){const t=Jc(n),i=r.get(t);if(i&&n.created_atr.clear()))}}function Cd(e){return t=>fc(Object.fromEntries(e.map(e=>[e,t.model(xd,{id:e})])))}function Ad(e){return t=>fc(Object.fromEntries(e.map(e=>[Zc(e.kind,e.pubkey,e.identifier),t.model(kd,e)])))}function Td(e){return t=>{let n;return wc(t.pipe(Rc(e=>n=e)),e.update$.pipe(bc(e=>e.id===n?.id)))}}function _d(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:so.Contacts,pubkey:e.pubkey,relays:e.relays}).pipe(Td(t),oc(e=>e?sd(e):[]))}function Id(e){return t=>{const n=[{kinds:[1111],"#e":[e.id]}];return Ma(e.kind)&&n.push({kinds:[1111],"#a":[Gc(e)]}),t.timeline(n)}}function $d(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:so.RelayList,pubkey:e.pubkey,relays:e.relays}).pipe(oc(e=>e&&{inboxes:cd(e),outboxes:ud(e)}))}function Rd(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:so.Mutelist,pubkey:e.pubkey,relays:e.relays}).pipe(Td(t),oc(e=>e&&pd(e)))}function Od(e){return"string"==typeof e&&(e={pubkey:e}),t=>t.replaceable({kind:so.Metadata,pubkey:e.pubkey,relays:e.relays}).pipe(bc(nd),oc(e=>e&&td(e)),Ed(void 0))}function Pd(e){return t=>t.timeline(Vc(e.kind)?[{kinds:[so.Reaction],"#e":[e.id]},{kinds:[so.Reaction],"#a":[Jc(e)]}]:[{kinds:[so.Reaction],"#e":[e.id]}])}const Bd={kinds:[so.ShortTextNote]};function Nd(e,t){const n=new Map,r=new Map,{kinds:o}={...Bd,...t};let i="";const s={},a={kinds:o};var l;return"string"!=typeof(l=e)&&Reflect.has(l,"identifier")&&Reflect.has(l,"pubkey")&&Reflect.has(l,"kind")?(i=vu(e),s.kinds=[e.kind],s.authors=[e.pubkey],s["#d"]=[e.identifier],a["#a"]=[i]):"string"==typeof e?(i=e,s.ids=[e],a["#e"]=[e]):(i=e.id,s.ids=[e.id],a["#e"]=[e.id]),e=>e.filters([s,a]).pipe(oc(e=>{if(!r.has(Jc(e))){const t=function(e){return Fc(e,md,()=>{const t=function(e){const t=e.filter(e=>"e"===e[0]&&e[1]),n=e.filter(e=>"a"===e[0]&&e[1]);let r=t.find(e=>"root"===e[3]),o=t.find(e=>"reply"===e[3]),i=n.find(e=>"root"===e[3]),s=n.find(e=>"reply"===e[3]);if(r&&o||(r=o=r||o),i&&s||(i=s=i||s),!r&&!o){const e=t.filter(e=>!e[3]);e.length>=1&&(r=e[0],o=e[e.length-1]??r)}return{root:r||i?{e:r,a:i}:void 0,reply:o||s?{e:o,a:s}:void 0}}(e.tags);let n,r;if(t.root)try{n={e:t.root.e&&yd(t.root.e),a:t.root.a&&mu(t.root.a)}}catch(e){}if(t.reply)try{r={e:t.reply.e&&yd(t.reply.e),a:t.reply.a&&mu(t.reply.a)}}catch(e){}return{root:n,reply:r}})}(e),o=n.get(Jc(e))||new Set,i={event:e,refs:t,replies:o};for(const e of o)e.parent=i;if(t.reply?.e||t.reply?.a){let e=t.reply.e?t.reply.e.id:vu(t.reply.a);if(i.parent=r.get(e),i.parent)i.parent.replies.add(i);else{let t=n.get(e);t||(t=new Set,n.set(e,t)),t.add(i)}}r.set(Jc(e),i)}return{root:r.get(i),all:r}}))}function Ld(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 r=e.getKey?e.getKey(...t):Zu(t);let o=n.get(r);if(!o){const i=()=>{n.get(r)===o&&n.delete(r)};o=e(...t)(this).pipe(Cc(i),function(e){void 0===e&&(e={});var t=e.connector,n=void 0===t?function(){return new Cl}:t,r=e.resetOnError,o=void 0===r||r,i=e.resetOnComplete,s=void 0===i||i,a=e.resetOnRefCountZero,l=void 0===a||a;return function(e){var t,r,i,a=0,c=!1,u=!1,d=function(){null==r||r.unsubscribe(),r=void 0},f=function(){d(),t=i=void 0,c=u=!1},h=function(){var e=t;f(),null==e||e.unsubscribe()};return El(function(e,p){a++,u||c||d();var g=i=null!=i?i:n();p.add(function(){0!==--a||u||c||(r=Ic(h,l))}),g.subscribe(p),!t&&a>0&&(t=new pl({next:function(e){return g.next(e)},error:function(e){u=!0,d(),r=Ic(f,o,e),g.error(e)},complete:function(){c=!0,d(),r=Ic(f,s),g.complete()}}),Gl(e).subscribe(t))})(e)}}({connector:()=>new _l(1),resetOnComplete:()=>vc(this.modelKeepWarm),resetOnRefCountZero:()=>vc(this.modelKeepWarm)})),n.set(r,o)}return o}filters(e,t=!1){e=Array.isArray(e)?e:[e];const n=this.getByFilters(e);return wc(t?Nl:n&&"function"==typeof n.then?nc(n).pipe(pc(e=>nc(Array.from(e)))):nc(Array.from(n)),this.insert$.pipe(bc(t=>Qu(e,t))))}event(e){return"string"==typeof e&&(e={id:e}),this.model(xd,e)}replaceable(...e){let t;if(1===e.length)t=e[0];else if(3===e.length||2===e.length){let[n,r,o]=e;t={kind:n,pubkey:r,identifier:o}}if(!t)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(kd,t)}addressable(e){return this.model(kd,e)}timeline(e,t=!1){return this.model(Sd,e,t)}profile(e){return this.model(Od,e)}contacts(e){return"string"==typeof e&&(e={pubkey:e}),this.model(_d,e)}mutes(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Rd,e)}mailboxes(e){return"string"==typeof e&&(e={pubkey:e}),this.model($d,e)}blossomServers(e){return"string"==typeof e&&(e={pubkey:e}),this.model(Xu,e)}reactions(e){return this.model(Pd,e)}thread(e){return this.model(Nd,e)}comments(e){return this.model(Id,e)}events(e){return this.model(Cd,e)}replaceableSet(e){return this.model(Ad,e)}}}class Ud extends(Ld(class{})){database;memory;keepOldVersions=!1;keepExpired=!1;verifyEvent;insert$=new Cl;update$=new Cl;remove$=new Cl;eventLoader;replaceableLoader;addressableLoader;constructor(e=new Wu){super(),e?(this.database=e,this.memory=new Wu):this.database=this.memory=new Wu,this.insert$.subscribe(e=>{Reflect.set(e,Hc,this)}),this.remove$.subscribe(e=>{Reflect.deleteProperty(e,Hc)})}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(Ma(e.kind)){const t=e.tags.find(e=>"d"===e[0])?.[1],n=this.deletedCoords.get(Zc(e.kind,e.pubkey,t));if(n)return n>e.created_at}return!1}expirations=new Map;addExpiration(e){const t=eu(e);t&&Number.isFinite(t)&&this.expirations.set(e.id,t)}expirationTimeout=null;nextExpirationCheck=null;handleExpiringEvent(e){const t=eu(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(Lc).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=gu(t);if(!n)continue;const r=this.database.getReplaceableHistory(n.kind,n.pubkey,n.identifier)??[];for(const t of r)t.created_at"d"===e[0])?.[1]:void 0;if(!this.keepOldVersions&&Vc(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,r);if(t&&t.length>0&&t[0].created_at>=e.created_at)return Ud.mergeDuplicateEvent(e,t[0]),t[0]}if(this.verifyEvent&&!1===this.verifyEvent(e))return null;const o=this.memory?.add(e);if(o&&o!==e)return Ud.mergeDuplicateEvent(e,o),t&&ru(o,t),o;const i=this.mapToMemory(this.database.add(e));if(e!==i&&Ud.mergeDuplicateEvent(e,i),t&&ru(i,t),i===e&&this.insert$.next(i),!this.keepOldVersions&&Vc(e.kind)){const t=this.database.getReplaceableHistory(e.kind,e.pubkey,r);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,t){return this.memory?.claim(e,t)}isClaimed(e){return this.memory?.isClaimed(e)??!1}removeClaim(e,t){return this.memory?.removeClaim(e,t)}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)?Nl:this.remove$.pipe(bc(t=>t.id===e),Ec(1),pc(()=>Nl))}updated(e){return this.update$.pipe(bc(t=>t.id===e||t===e))}}function jd(){let e,t;const n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var Fd,Md;Cu(so.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"}(Fd||(Fd={})),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"}(Md||(Md={}));class Dd{key;constructor(e){this.key=e||no()}async getPublicKey(){return ro(this.key)}async signEvent(e){return oo(e,this.key)}nip04={encrypt:async(e,t)=>ss.encrypt(this.key,e,t),decrypt:async(e,t)=>ss.decrypt(this.key,e,t)};nip44={encrypt:async(e,t)=>ks.v2.encrypt(t,ks.v2.utils.getConversationKey(this.key,e)),decrypt:async(e,t)=>ks.v2.decrypt(t,ks.v2.utils.getConversationKey(this.key,e))};static fromKey(e){return new Dd(wu(e))}}const Hd="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0; +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qd(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 zd=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),Kd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Wd(e){if(qd(e),zd)return e.toHex();let t="";for(let n=0;n=Vd&&e<=Jd?e-Vd:e>=Gd&&e<=Zd?e-(Gd-10):e>=Yd&&e<=Qd?e-(Yd-10):void 0}function ef(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(zd)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 r=new Uint8Array(n);for(let t=0,o=0;t(e+t/rf)/t,lf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=af,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-nf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=cf(i*e,t),c=cf(-r*e,t);let l=Lf(e-a*n-c*o,t),u=Lf(-a*r-c*i,t);const d=l>s,f=u>s;if(d&&(l=t-l),f&&(u=t-u),l>s||u>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:l,k2neg:f,k2:u}}},uf=32;function df(e){const{a:t,b:n}=af,r=Lf(e*e),o=Lf(r*e);return Lf(o+t*e+n)}const ff=af.a===tf;function hf(e){if(!(e instanceof pf))throw new TypeError("JacobianPoint expected")}class pf{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof mf))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(mf.ZERO)?pf.ZERO:new pf(e.x,e.y,nf)}static toAffineBatch(e){const t=function(e,t=af.P){const n=new Array(e.length),r=e.reduce((e,r,o)=>r===tf?e:(n[o]=e,Lf(e*r,t)),nf),o=Nf(r,t);return e.reduceRight((e,r,o)=>r===tf?e:(n[o]=Lf(e*n[o],t),Lf(e*r,t)),o),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return pf.toAffineBatch(e).map(pf.fromAffine)}equals(e){hf(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e,a=Lf(r*r),c=Lf(s*s),l=Lf(t*c),u=Lf(o*a),d=Lf(Lf(n*s)*c),f=Lf(Lf(i*r)*a);return l===u&&d===f}negate(){return new pf(this.x,Lf(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,r=Lf(e*e),o=Lf(t*t),i=Lf(o*o),s=e+o,a=Lf(rf*(Lf(s*s)-r-i)),c=Lf(of*r),l=Lf(c*c),u=Lf(l-rf*a),d=Lf(c*(a-u)-sf*i),f=Lf(rf*t*n);return new pf(u,d,f)}add(e){hf(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e;if(o===tf||i===tf)return this;if(t===tf||n===tf)return e;const a=Lf(r*r),c=Lf(s*s),l=Lf(t*c),u=Lf(o*a),d=Lf(Lf(n*s)*c),f=Lf(Lf(i*r)*a),h=Lf(u-l),p=Lf(f-d);if(h===tf)return p===tf?this.double():pf.ZERO;const y=Lf(h*h),g=Lf(h*y),m=Lf(l*y),v=Lf(p*p-g-rf*m),w=Lf(p*(m-v)-d*g),b=Lf(r*s*h);return new pf(v,w,b)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=pf.ZERO;if("bigint"==typeof e&&e===tf)return t;let n=Pf(e);if(n===nf)return this;if(!ff){let e=t,r=this;for(;n>tf;)n&nf&&(e=e.add(r)),r=r.double(),n>>=nf;return e}let{k1neg:r,k1:o,k2neg:i,k2:s}=lf.splitScalar(n),a=t,c=t,l=this;for(;o>tf||s>tf;)o&nf&&(a=a.add(l)),s&nf&&(c=c.add(l)),l=l.double(),o>>=nf,s>>=nf;return r&&(a=a.negate()),i&&(c=c.negate()),c=new pf(Lf(c.x*lf.beta),c.y,c.z),a.add(c)}precomputeWindow(e){const t=ff?128/e+1:256/e+1,n=[];let r=this,o=r;for(let i=0;i>=u,s>a&&(s-=l,e+=nf);const d=n,f=n+Math.abs(s)-1,h=t%2!=0,p=s<0;0===s?i=i.add(yf(h,r[d])):o=o.add(yf(p,r[f]))}return{p:o,f:i}}multiply(e,t){let n,r,o=Pf(e);if(ff){const{k1neg:e,k1:i,k2neg:s,k2:a}=lf.splitScalar(o);let{p:c,f:l}=this.wNAF(i,t),{p:u,f:d}=this.wNAF(a,t);c=yf(e,c),u=yf(s,u),u=new pf(Lf(u.x*lf.beta),u.y,u.z),n=c.add(u),r=l.add(d)}else{const{p:e,f:i}=this.wNAF(o,t);n=e,r=i}return pf.normalizeZ([n,r])[0]}toAffine(e){const{x:t,y:n,z:r}=this,o=this.equals(pf.ZERO);null==e&&(e=o?sf:Nf(r));const i=e,s=Lf(i*i),a=Lf(s*i),c=Lf(t*s),l=Lf(n*a),u=Lf(r*i);if(o)return mf.ZERO;if(u!==nf)throw new Error("invZ was invalid");return new mf(c,l)}}function yf(e,t){const n=t.negate();return e?n:t}pf.BASE=new pf(af.Gx,af.Gy,nf),pf.ZERO=new pf(tf,nf,tf);const gf=new WeakMap;class mf{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,gf.delete(this)}hasEvenY(){return this.y%rf===tf}static fromCompressedHex(e){const t=32===e.length,n=Of(t?e:e.subarray(1));if(!jf(n))throw new Error("Point is not on curve");let r=function(e){const{P:t}=af,n=BigInt(6),r=BigInt(11),o=BigInt(22),i=BigInt(23),s=BigInt(44),a=BigInt(88),c=e*e*e%t,l=c*c*e%t,u=Bf(l,of)*l%t,d=Bf(u,of)*l%t,f=Bf(d,rf)*c%t,h=Bf(f,r)*f%t,p=Bf(h,o)*h%t,y=Bf(p,s)*p%t,g=Bf(y,a)*y%t,m=Bf(g,s)*p%t,v=Bf(m,of)*l%t,w=Bf(v,i)*h%t,b=Bf(w,n)*c%t,x=Bf(b,rf);if(x*x%t!==e)throw new Error("Cannot find square root");return x}(df(n));const o=(r&nf)===nf;if(t)o&&(r=Lf(-r));else{!(1&~e[0])!==o&&(r=Lf(-r))}const i=new mf(n,r);return i.assertValidity(),i}static fromUncompressedHex(e){const t=Of(e.subarray(1,33)),n=Of(e.subarray(33,65)),r=new mf(t,n);return r.assertValidity(),r}static fromHex(e){const t=Rf(e),n=t.length,r=t[0];if(n===uf)return this.fromCompressedHex(t);if(33===n&&(2===r||3===r))return this.fromCompressedHex(t);if(65===n&&4===r)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 mf.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=If(e)}else{if(!xf(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=Of(e)}if(!Uf(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:r,s:o}=function(e){if(e instanceof bf)return e.assertValidity(),e;try{return bf.fromDER(e)}catch(t){return bf.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const i=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=Of(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:r}=af;return n>=r?n-r:n}(Rf(e)),{n:s}=af,a=2===n||3===n?r+s:r,c=Nf(a,s),l=Lf(-i*c,s),u=Lf(o*c,s),d=1&n?"03":"02",f=mf.fromHex(d+_f(a)),h=mf.BASE.multiplyAndAddUnsafe(f,l,u);if(!h)throw new Error("Cannot recover signature: point at infinify");return h.assertValidity(),h}toRawBytes(e=!1){return Cf(this.toHex(e))}toHex(e=!1){const t=_f(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${_f(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(!jf(t)||!jf(n))throw new Error(e);const r=Lf(n*n);if(Lf(r-df(t))!==tf)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new mf(this.x,Lf(-this.y))}double(){return pf.fromAffine(this).double().toAffine()}add(e){return pf.fromAffine(this).add(pf.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return pf.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const r=pf.fromAffine(this),o=t===tf||t===nf||this!==mf.BASE?r.multiplyUnsafe(t):r.multiply(t),i=pf.fromAffine(e).multiplyUnsafe(n),s=o.add(i);return s.equals(pf.ZERO)?void 0:s.toAffine()}}function vf(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function wf(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${kf(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:Of(n),left:e.subarray(t+2)}}mf.BASE=new mf(af.Gx,af.Gy),mf.ZERO=new mf(tf,tf);class bf{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=xf(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=t?kf(e):e;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new bf(If(r.slice(0,64)),If(r.slice(64,128)))}static fromDER(e){const t=xf(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:r}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${kf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=wf(e.subarray(2)),{data:r,left:o}=wf(n);if(o.length)throw new Error(`Invalid signature: left bytes after parsing: ${kf(o)}`);return{r:t,s:r}}(t?e:Cf(e));return new bf(n,r)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Uf(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Uf(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=af.n>>nf;return this.s>e}normalizeS(){return this.hasHighS()?new bf(this.r,Lf(-this.s,af.n)):this}toDERRawBytes(){return Cf(this.toDERHex())}toDERHex(){const e=vf($f(this.s)),t=vf($f(this.r)),n=e.length/2,r=t.length/2,o=$f(n),i=$f(r);return`30${$f(r+n+4)}02${i}${t}02${o}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Cf(this.toCompactHex())}toCompactHex(){return _f(this.r)+_f(this.s)}}function xf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const Ef=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function kf(e){!function(e){if(!xf(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n=Sf._0&&e<=Sf._9?e-Sf._0:e>=Sf.A&&e<=Sf.F?e-(Sf.A-10):e>=Sf.a&&e<=Sf.f?e-(Sf.a-10):void 0}function Cf(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 r=new Uint8Array(n);for(let t=0,o=0;t0)return BigInt(e);if("bigint"==typeof e&&Uf(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Lf(e,t=af.P){const n=e%t;return n>=tf?n:t+n}function Bf(e,t){const{P:n}=af;let r=e;for(;t-- >tf;)r*=r,r%=n;return r}function Nf(e,t=af.P){if(e===tf||t<=tf)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Lf(e,t),r=t,o=tf,i=nf;for(;n!==tf;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==nf)throw new Error("invert: does not exist");return Lf(o,t)}function Uf(e){return tf(e+t/rf)/t,cf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=af,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-nf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=lf(i*e,t),l=lf(-r*e,t);let c=Bf(e-a*n-l*o,t),u=Bf(-a*r-l*i,t);const d=c>s,f=u>s;if(d&&(c=t-c),f&&(u=t-u),c>s||u>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:f,k2:u}}},uf=32;function df(e){const{a:t,b:n}=af,r=Bf(e*e),o=Bf(r*e);return Bf(o+t*e+n)}const ff=af.a===tf;function hf(e){if(!(e instanceof pf))throw new TypeError("JacobianPoint expected")}class pf{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof yf))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(yf.ZERO)?pf.ZERO:new pf(e.x,e.y,nf)}static toAffineBatch(e){const t=function(e,t=af.P){const n=new Array(e.length),r=e.reduce((e,r,o)=>r===tf?e:(n[o]=e,Bf(e*r,t)),nf),o=Lf(r,t);return e.reduceRight((e,r,o)=>r===tf?e:(n[o]=Bf(e*n[o],t),Bf(e*r,t)),o),n}(e.map(e=>e.z));return e.map((e,n)=>e.toAffine(t[n]))}static normalizeZ(e){return pf.toAffineBatch(e).map(pf.fromAffine)}equals(e){hf(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e,a=Bf(r*r),l=Bf(s*s),c=Bf(t*l),u=Bf(o*a),d=Bf(Bf(n*s)*l),f=Bf(Bf(i*r)*a);return c===u&&d===f}negate(){return new pf(this.x,Bf(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,r=Bf(e*e),o=Bf(t*t),i=Bf(o*o),s=e+o,a=Bf(rf*(Bf(s*s)-r-i)),l=Bf(of*r),c=Bf(l*l),u=Bf(c-rf*a),d=Bf(l*(a-u)-sf*i),f=Bf(rf*t*n);return new pf(u,d,f)}add(e){hf(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e;if(o===tf||i===tf)return this;if(t===tf||n===tf)return e;const a=Bf(r*r),l=Bf(s*s),c=Bf(t*l),u=Bf(o*a),d=Bf(Bf(n*s)*l),f=Bf(Bf(i*r)*a),h=Bf(u-c),p=Bf(f-d);if(h===tf)return p===tf?this.double():pf.ZERO;const g=Bf(h*h),m=Bf(h*g),y=Bf(c*g),v=Bf(p*p-m-rf*y),w=Bf(p*(y-v)-d*m),b=Bf(r*s*h);return new pf(v,w,b)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=pf.ZERO;if("bigint"==typeof e&&e===tf)return t;let n=Pf(e);if(n===nf)return this;if(!ff){let e=t,r=this;for(;n>tf;)n&nf&&(e=e.add(r)),r=r.double(),n>>=nf;return e}let{k1neg:r,k1:o,k2neg:i,k2:s}=cf.splitScalar(n),a=t,l=t,c=this;for(;o>tf||s>tf;)o&nf&&(a=a.add(c)),s&nf&&(l=l.add(c)),c=c.double(),o>>=nf,s>>=nf;return r&&(a=a.negate()),i&&(l=l.negate()),l=new pf(Bf(l.x*cf.beta),l.y,l.z),a.add(l)}precomputeWindow(e){const t=ff?128/e+1:256/e+1,n=[];let r=this,o=r;for(let i=0;i>=u,s>a&&(s-=c,e+=nf);const d=n,f=n+Math.abs(s)-1,h=t%2!=0,p=s<0;0===s?i=i.add(gf(h,r[d])):o=o.add(gf(p,r[f]))}return{p:o,f:i}}multiply(e,t){let n,r,o=Pf(e);if(ff){const{k1neg:e,k1:i,k2neg:s,k2:a}=cf.splitScalar(o);let{p:l,f:c}=this.wNAF(i,t),{p:u,f:d}=this.wNAF(a,t);l=gf(e,l),u=gf(s,u),u=new pf(Bf(u.x*cf.beta),u.y,u.z),n=l.add(u),r=c.add(d)}else{const{p:e,f:i}=this.wNAF(o,t);n=e,r=i}return pf.normalizeZ([n,r])[0]}toAffine(e){const{x:t,y:n,z:r}=this,o=this.equals(pf.ZERO);null==e&&(e=o?sf:Lf(r));const i=e,s=Bf(i*i),a=Bf(s*i),l=Bf(t*s),c=Bf(n*a),u=Bf(r*i);if(o)return yf.ZERO;if(u!==nf)throw new Error("invZ was invalid");return new yf(l,c)}}function gf(e,t){const n=t.negate();return e?n:t}pf.BASE=new pf(af.Gx,af.Gy,nf),pf.ZERO=new pf(tf,nf,tf);const mf=new WeakMap;class yf{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,mf.delete(this)}hasEvenY(){return this.y%rf===tf}static fromCompressedHex(e){const t=32===e.length,n=Rf(t?e:e.subarray(1));if(!jf(n))throw new Error("Point is not on curve");let r=function(e){const{P:t}=af,n=BigInt(6),r=BigInt(11),o=BigInt(22),i=BigInt(23),s=BigInt(44),a=BigInt(88),l=e*e*e%t,c=l*l*e%t,u=Nf(c,of)*c%t,d=Nf(u,of)*c%t,f=Nf(d,rf)*l%t,h=Nf(f,r)*f%t,p=Nf(h,o)*h%t,g=Nf(p,s)*p%t,m=Nf(g,a)*g%t,y=Nf(m,s)*p%t,v=Nf(y,of)*c%t,w=Nf(v,i)*h%t,b=Nf(w,n)*l%t,E=Nf(b,rf);if(E*E%t!==e)throw new Error("Cannot find square root");return E}(df(n));const o=(r&nf)===nf;if(t)o&&(r=Bf(-r));else{!(1&~e[0])!==o&&(r=Bf(-r))}const i=new yf(n,r);return i.assertValidity(),i}static fromUncompressedHex(e){const t=Rf(e.subarray(1,33)),n=Rf(e.subarray(33,65)),r=new yf(t,n);return r.assertValidity(),r}static fromHex(e){const t=Of(e),n=t.length,r=t[0];if(n===uf)return this.fromCompressedHex(t);if(33===n&&(2===r||3===r))return this.fromCompressedHex(t);if(65===n&&4===r)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 yf.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=$f(e)}else{if(!Ef(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=Rf(e)}if(!Uf(t))throw new Error("Expected private key: 0 < key < n");return t}(e))}static fromSignature(e,t,n){const{r:r,s:o}=function(e){if(e instanceof bf)return e.assertValidity(),e;try{return bf.fromDER(e)}catch(t){return bf.fromCompact(e)}}(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const i=function(e,t=!1){const n=function(e){const t=8*e.length-256,n=Rf(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:r}=af;return n>=r?n-r:n}(Of(e)),{n:s}=af,a=2===n||3===n?r+s:r,l=Lf(a,s),c=Bf(-i*l,s),u=Bf(o*l,s),d=1&n?"03":"02",f=yf.fromHex(d+_f(a)),h=yf.BASE.multiplyAndAddUnsafe(f,c,u);if(!h)throw new Error("Cannot recover signature: point at infinify");return h.assertValidity(),h}toRawBytes(e=!1){return Af(this.toHex(e))}toHex(e=!1){const t=_f(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${_f(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(!jf(t)||!jf(n))throw new Error(e);const r=Bf(n*n);if(Bf(r-df(t))!==tf)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new yf(this.x,Bf(-this.y))}double(){return pf.fromAffine(this).double().toAffine()}add(e){return pf.fromAffine(this).add(pf.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return pf.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const r=pf.fromAffine(this),o=t===tf||t===nf||this!==yf.BASE?r.multiplyUnsafe(t):r.multiply(t),i=pf.fromAffine(e).multiplyUnsafe(n),s=o.add(i);return s.equals(pf.ZERO)?void 0:s.toAffine()}}function vf(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function wf(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${kf(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:Rf(n),left:e.subarray(t+2)}}yf.BASE=new yf(af.Gx,af.Gy),yf.ZERO=new yf(tf,tf);class bf{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=Ef(e),n="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=t?kf(e):e;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new bf($f(r.slice(0,64)),$f(r.slice(64,128)))}static fromDER(e){const t=Ef(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:r}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${kf(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=wf(e.subarray(2)),{data:r,left:o}=wf(n);if(o.length)throw new Error(`Invalid signature: left bytes after parsing: ${kf(o)}`);return{r:t,s:r}}(t?e:Af(e));return new bf(n,r)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Uf(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Uf(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=af.n>>nf;return this.s>e}normalizeS(){return this.hasHighS()?new bf(this.r,Bf(-this.s,af.n)):this}toDERRawBytes(){return Af(this.toDERHex())}toDERHex(){const e=vf(If(this.s)),t=vf(If(this.r)),n=e.length/2,r=t.length/2,o=If(n),i=If(r);return`30${If(r+n+4)}02${i}${t}02${o}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Af(this.toCompactHex())}toCompactHex(){return _f(this.r)+_f(this.s)}}function Ef(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}const xf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function kf(e){!function(e){if(!Ef(e))throw new Error("Uint8Array expected")}(e);let t="";for(let n=0;n=Sf._0&&e<=Sf._9?e-Sf._0:e>=Sf.A&&e<=Sf.F?e-(Sf.A-10):e>=Sf.a&&e<=Sf.f?e-(Sf.a-10):void 0}function Af(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 r=new Uint8Array(n);for(let t=0,o=0;t0)return BigInt(e);if("bigint"==typeof e&&Uf(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Bf(e,t=af.P){const n=e%t;return n>=tf?n:t+n}function Nf(e,t){const{P:n}=af;let r=e;for(;t-- >tf;)r*=r,r%=n;return r}function Lf(e,t=af.P){if(e===tf||t<=tf)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Bf(e,t),r=t,o=tf,i=nf;for(;n!==tf;){const e=r%n,t=o-i*(r/n);r=n,n=e,o=i,i=t}if(r!==nf)throw new Error("invert: does not exist");return Bf(o,t)}function Uf(e){return tf"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function Df(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function Hf(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function qf(e){if(!Array.isArray(e))throw new Error("array expected")}function zf(e,t){if(!Ff(!0,t))throw new Error(`${e}: array of strings expected`)}mf.BASE._setWindowSize(8);const Wf=(e,t)=>0===t?e:Wf(t,e%t),Kf=(e,t)=>e+(t-Wf(e,t)),Jf=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Vf(e,t,n,r){if(qf(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Kf(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Kf(t,n)}`);let o=0,i=0;const s=Jf[t],a=Jf[n]-1,c=[];for(const r of e){if(Hf(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)c.push((o>>i-n&a)>>>0);const e=Jf[i];if(void 0===e)throw new Error("invalid carry");o&=e-1}if(o=o<=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&c.push(o>>>0),c}const Gf=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Mf(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}(e),e.toBase64()),decode:e=>((e,t)=>{Df("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(Hf(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Kf(8,e)>32||Kf(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Mf(n))throw new Error("radix2.encode input should be Uint8Array");return Vf(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!Ff(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(Vf(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;zf("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(qf(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(qf(t),t.map(t=>{Df("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return Hf(e),Df("padding",t),{encode(n){for(zf("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){zf("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}(6),function(e=""){return Df("join",e),{encode:t=>(zf("join.decode",t),t.join(e)),decode:t=>(Df("join.decode",t),t.split(e))}}(""));function Zf(e){return mf.fromHex(e).toHex().substring(2)}const Yf=new TextDecoder("utf-8"),Qf=new TextEncoder;class Xf{log=Wu.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=io;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!Xf.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const r=jd();return this.lastCommand=r,this.sendCommand(e,t),setTimeout(()=>{r.reject(new Error("Device timeout")),this.lastCommand===r&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:r}){let o,i=await window.navigator.serial.requestPort();await i.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;i&&i.readable;){const e=new window.TextDecoderStream;i.readable.pipeTo(e.writable),o=e.readable.getReader();const t=this.readFromSerialPort(o);try{for(;;){const{value:e,done:n}=await t("\n");if(e){const{method:t,data:n}=this.parseResponse(e);if("/ping"===t&&this.log("Pong"),-1===Xf.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(r&&r())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const s=new window.TextEncoderStream;s.readable.pipeTo(i.writable),this.writer=s.writable.getWriter(),await this.sendCommand(Xf.METHOD_PING),await this.sendCommand(Xf.METHOD_PING,[window.location.host]),e&&e(),i.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const o=[];for(t&&(o.push(t),t=void 0);;){const{value:i,done:s}=await e.read();if(i){const e=i.split(r);if(e.length>1)return o.push(e.shift()),t=e.pop(),n=e,{value:o.join("").trim(),done:!1};o.push(i)}if(s)return{value:o.join("").trim(),done:!0}}}}parseResponse(e){const t=e.split(" ")[0];return{method:t,data:e.substring(t.length).trim()}}async nip04Encrypt(e,t){const n=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let r=Uint8Array.from(function(e=32){if(Hd&&"function"==typeof Hd.getRandomValues)return Hd.getRandomValues(new Uint8Array(e));if(Hd&&"function"==typeof Hd.randomBytes)return Uint8Array.from(Hd.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),o=Qf.encode(t),i=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},i,o);return`${Gf.encode(new Uint8Array(s))}?iv=${Gf.encode(new Uint8Array(r.buffer))}`}async nip04Decrypt(e,t){let[n,r]=t.split("?iv=");const o=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let i=await crypto.subtle.importKey("raw",o,{name:"AES-CBC"},!1,["decrypt"]),s=Gf.decode(n),a=Gf.decode(r),c=await crypto.subtle.decrypt({name:"AES-CBC",iv:a},i,s);return Yf.decode(c)}async getPublicKey(){const e=await this.callMethodOnDevice(Xf.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(Xf.METHOD_RESTORE,[Kd(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:eo({...e,pubkey:t})},r=await this.callMethodOnDevice(Xf.METHOD_SIGN_MESSAGE,[n.id]),o={...n,sig:r,pubkey:t};if(!this.verifyEvent(o))throw new Error("Invalid signature");return o}ping(){this.sendCommand(Xf.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[Xf.METHOD_PUBLIC_KEY,Xf.METHOD_SIGN_MESSAGE,Xf.METHOD_SHARED_SECRET,Xf.METHOD_RESTORE]}const eh=[`wss://${window.location.host}/`];class th{constructor(){this.pool=new _n,this.eventStore=new Ud,this.isConnected=!1,this.signer=null,this.relays=[...eh]}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async publish(e){console.log("Publishing event:",e);try{const t=this.pool.publish(this.relays,e);return await Promise.allSettled(t),console.log("✓ Event published successfully"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const nh=new th,rh="events";function oh(){return new Promise((e,t)=>{try{const n=indexedDB.open("nostrCache",1);n.onupgradeneeded=()=>{const e=n.result;if(!e.objectStoreNames.contains(rh)){const t=e.createObjectStore(rh,{keyPath:"id"});t.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),t.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1})}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){t(e)}})}function ih(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 sh(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await oh();return await new Promise((n,r)=>{const o=t.transaction(rh,"readonly").objectStore(rh).index("byKindAuthorCreated"),i=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),s=o.openCursor(i,"prev");s.onsuccess=()=>{const e=s.result;n(e?e.value:null)},s.onerror=()=>r(s.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return ih(t)}}catch(e){console.warn("Failed to load cached profile",e)}try{const t=[{kinds:[0],authors:[e],limit:1}],n=await ah(t,{timeout:1e4});if(n.length>0){const t=n[0];console.log("Profile fetched:",t),await async function(e){try{const t=await oh();await new Promise((n,r)=>{const o=t.transaction(rh,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error),o.objectStore(rh).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}(t);const r=ih(t);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:r,event:t}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return r}throw new Error("No profile found")}catch(e){throw console.error("Failed to fetch profile:",e),e}}async function ah(e,t={}){console.log("Starting event fetch with filters:",e);const{timeout:n=3e4}=t;return new Promise((t,r)=>{const o=[],i=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${o.length} events`),sub.close(),t(o)},n);try{const n=nh.pool.subscribeMany(nh.relays,e,{onevent(e){console.log("Event received:",e),o.push(e)},oneose(){console.log(`EOSE received, got ${o.length} events`),clearTimeout(i),n.close(),t(o)}})}catch(e){clearTimeout(i),console.error("Failed to fetch events:",e),r(e)}})}async function ch(e={}){const{limit:t=100,since:n=null,until:r=null,authors:o=null,kinds:i=null,...s}=e,a=[{...s}];n&&(a[0].since=n),r&&(a[0].until=r),o&&(a[0].authors=o),i&&(a[0].kinds=i),t&&(a[0].limit=t);return await ah(a,{timeout:3e4})}async function lh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const r=await ah(t,{timeout:n});return console.log(`Fetched ${r.length} events`),r.length>0?r[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function uh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const r=await ah(t,{timeout:n});return console.log(`Fetched ${r.length} delete events`),r}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function dh(){await nh.connect()}const{window:fh}=c;function hh(e){let t,n,o,i,s,a,c,f,p,g,b,x,E,k,A,C,T,_;function $(e,t){return"extension"===e[2]?yh:ph}let I=$(e),O=I(e),R=e[5]&&gh(e),P=e[6]&&mh(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Login to Nostr",s=y(),a=h("button"),a.textContent="×",c=y(),f=h("div"),p=h("div"),g=h("button"),g.textContent="Extension",b=y(),x=h("button"),x.textContent="Nsec",E=y(),k=h("div"),O.c(),A=y(),R&&R.c(),C=y(),P&&P.c(),w(i,"class","svelte-1wl3v5c"),w(a,"class","close-btn svelte-1wl3v5c"),w(o,"class","modal-header svelte-1wl3v5c"),w(g,"class","tab-btn svelte-1wl3v5c"),S(g,"active","extension"===e[2]),w(x,"class","tab-btn svelte-1wl3v5c"),S(x,"active","nsec"===e[2]),w(p,"class","tabs svelte-1wl3v5c"),w(k,"class","tab-content svelte-1wl3v5c"),w(f,"class","tab-container svelte-1wl3v5c"),w(n,"class","modal svelte-1wl3v5c"),S(n,"dark-theme",e[1]),w(t,"class","modal-overlay svelte-1wl3v5c"),w(t,"role","button"),w(t,"tabindex","0")},m(r,d){u(r,t,d),l(t,n),l(n,o),l(o,i),l(o,s),l(o,a),l(n,c),l(n,f),l(f,p),l(p,g),l(p,b),l(p,x),l(f,E),l(f,k),O.m(k,null),l(k,A),R&&R.m(k,null),l(k,C),P&&P.m(k,null),T||(_=[m(a,"click",e[7]),m(g,"click",e[14]),m(x,"click",e[15]),m(n,"click",v(e[12])),m(n,"keydown",v(e[13])),m(t,"click",e[7]),m(t,"keydown",e[17])],T=!0)},p(e,t){4&t&&S(g,"active","extension"===e[2]),4&t&&S(x,"active","nsec"===e[2]),I===(I=$(e))&&O?O.p(e,t):(O.d(1),O=I(e),O&&(O.c(),O.m(k,A))),e[5]?R?R.p(e,t):(R=gh(e),R.c(),R.m(k,C)):R&&(R.d(1),R=null),e[6]?P?P.p(e,t):(P=mh(e),P.c(),P.m(k,null)):P&&(P.d(1),P=null),2&t&&S(n,"dark-theme",e[1])},d(e){e&&d(t),O.d(),R&&R.d(),P&&P.d(),T=!1,r(_)}}}function ph(e){let t,n,o,i,s,a,c,f,g,v,b=e[4]?"Logging in...":"Log in with nsec";return{c(){t=h("div"),n=h("p"),n.textContent="Enter your nsec (private key) to login. This\n will be stored securely in your browser.",o=y(),i=h("input"),s=y(),a=h("button"),c=p(b),w(n,"class","svelte-1wl3v5c"),w(i,"type","password"),w(i,"placeholder","nsec1..."),i.disabled=e[4],w(i,"class","nsec-input svelte-1wl3v5c"),w(a,"class","login-nsec-btn svelte-1wl3v5c"),a.disabled=f=e[4]||!e[3].trim(),w(t,"class","nsec-login svelte-1wl3v5c")},m(r,d){u(r,t,d),l(t,n),l(t,o),l(t,i),E(i,e[3]),l(t,s),l(t,a),l(a,c),g||(v=[m(i,"input",e[16]),m(a,"click",e[10])],g=!0)},p(e,t){16&t&&(i.disabled=e[4]),8&t&&i.value!==e[3]&&E(i,e[3]),16&t&&b!==(b=e[4]?"Logging in...":"Log in with nsec")&&x(c,b),24&t&&f!==(f=e[4]||!e[3].trim())&&(a.disabled=f)},d(e){e&&d(t),g=!1,r(v)}}}function yh(e){let t,n,r,o,i,s,a,c=e[4]?"Connecting...":"Log in using extension";return{c(){t=h("div"),n=h("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",r=y(),o=h("button"),i=p(c),w(n,"class","svelte-1wl3v5c"),w(o,"class","login-extension-btn svelte-1wl3v5c"),o.disabled=e[4],w(t,"class","extension-login svelte-1wl3v5c")},m(c,d){u(c,t,d),l(t,n),l(t,r),l(t,o),l(o,i),s||(a=m(o,"click",e[9]),s=!0)},p(e,t){16&t&&c!==(c=e[4]?"Connecting...":"Log in using extension")&&x(i,c),16&t&&(o.disabled=e[4])},d(e){e&&d(t),s=!1,a()}}}function gh(e){let t,n;return{c(){t=h("div"),n=p(e[5]),w(t,"class","message error-message svelte-1wl3v5c")},m(e,r){u(e,t,r),l(t,n)},p(e,t){32&t&&x(n,e[5])},d(e){e&&d(t)}}}function mh(e){let t,n;return{c(){t=h("div"),n=p(e[6]),w(t,"class","message success-message svelte-1wl3v5c")},m(e,r){u(e,t,r),l(t,n)},p(e,t){64&t&&x(n,e[6])},d(e){e&&d(t)}}}function vh(t){let n,r,o,i=t[0]&&hh(t);return{c(){i&&i.c(),n=g()},m(e,s){i&&i.m(e,s),u(e,n,s),r||(o=m(fh,"keydown",t[11]),r=!0)},p(e,[t]){e[0]?i?i.p(e,t):(i=hh(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&d(n),r=!1,o()}}}function wh(e,t,n){const r=_();let{showModal:o=!1}=t,{isDarkTheme:i=!1}=t,s="extension",a="",c=!1,l="",u="";function d(){n(0,o=!1),n(3,a=""),n(5,l=""),n(6,u=""),r("close")}function f(e){n(2,s=e),n(5,l=""),n(6,u="")}async function h(){n(4,c=!0),n(5,l=""),n(6,u="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!(e=a.trim()).startsWith("nsec1")||(e.length<60||e.length>70))throw new Error('Invalid nsec format. Must start with "nsec1"');const t=Dd.fromKey(a.trim()),o=await t.getPublicKey();localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",o),localStorage.setItem("nostr_privkey",a.trim()),n(6,u="Successfully logged in with nsec!"),r("login",{method:"nsec",pubkey:o,privateKey:a.trim(),signer:t}),setTimeout(()=>{d()},1500)}catch(e){n(5,l=e.message)}finally{n(4,c=!1)}var e}return e.$$set=e=>{"showModal"in e&&n(0,o=e.showModal),"isDarkTheme"in e&&n(1,i=e.isDarkTheme)},[o,i,s,a,c,l,u,d,f,async function(){n(4,c=!0),n(5,l=""),n(6,u="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(6,u="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{d()},1500))}catch(e){n(5,l=e.message)}finally{n(4,c=!1)}},h,function(e){"Escape"===e.key&&d(),"Enter"===e.key&&"nsec"===s&&h()},function(t){$.call(this,e,t)},function(t){$.call(this,e,t)},()=>f("extension"),()=>f("nsec"),function(){a=this.value,n(3,a)},e=>"Escape"===e.key&&d()]}class bh extends Q{constructor(e){super(),Y(this,e,wh,vh,i,{showModal:0,isDarkTheme:1})}}function xh(e,t,n){const r=e.slice();return r[72]=t[n],r}function Eh(e,t,n){const r=e.slice();return r[75]=t[n],r}function kh(e,t,n){const r=e.slice();return r[72]=t[n],r}function Sh(e,t,n){const r=e.slice();return r[72]=t[n],r}function Ah(e,t,n){const r=e.slice();return r[72]=t[n],r}function Ch(e,t,n){const r=e.slice();return r[72]=t[n],r}function Th(e,t,n){const r=e.slice();return r[72]=t[n],r}function _h(e){let t,n,r;return{c(){t=h("div"),n=p(e[3]),w(t,"class",r="message "+e[4]+" svelte-1smaj3x")},m(e,r){u(e,t,r),l(t,n)},p(e,o){8&o[0]&&x(n,e[3]),16&o[0]&&r!==(r="message "+e[4]+" svelte-1smaj3x")&&w(t,"class",r)},d(e){e&&d(t)}}}function $h(e){let t,n,o,i,s,a,c,f,g,v,b,x,k,S,A,C,T,_,$,I,O,R,P,L,B,N,U,j;function M(e,t){return e[5]&&e[5].length>0?Oh:Ih}let F=M(e),D=F(e);function H(e,t){return e[8]&&e[8].length>0?Bh:Lh}let q=H(e),z=q(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Banned Pubkeys",i=y(),s=h("div"),a=h("input"),c=y(),f=h("input"),g=y(),v=h("button"),b=p("Ban Pubkey"),x=y(),k=h("div"),D.c(),S=y(),A=h("div"),C=h("h3"),C.textContent="Allowed Pubkeys",T=y(),_=h("div"),$=h("input"),I=y(),O=h("input"),R=y(),P=h("button"),L=p("Allow Pubkey"),B=y(),N=h("div"),z.c(),w(o,"class","svelte-1smaj3x"),w(a,"type","text"),w(a,"placeholder","Pubkey (64 hex chars)"),w(a,"class","svelte-1smaj3x"),w(f,"type","text"),w(f,"placeholder","Reason (optional)"),w(f,"class","svelte-1smaj3x"),v.disabled=e[2],w(v,"class","svelte-1smaj3x"),w(s,"class","add-form svelte-1smaj3x"),w(k,"class","list svelte-1smaj3x"),w(n,"class","section svelte-1smaj3x"),w(C,"class","svelte-1smaj3x"),w($,"type","text"),w($,"placeholder","Pubkey (64 hex chars)"),w($,"class","svelte-1smaj3x"),w(O,"type","text"),w(O,"placeholder","Reason (optional)"),w(O,"class","svelte-1smaj3x"),P.disabled=e[2],w(P,"class","svelte-1smaj3x"),w(_,"class","add-form svelte-1smaj3x"),w(N,"class","list svelte-1smaj3x"),w(A,"class","section svelte-1smaj3x"),w(t,"class","pubkeys-section")},m(r,d){u(r,t,d),l(t,n),l(n,o),l(n,i),l(n,s),l(s,a),E(a,e[6]),l(s,c),l(s,f),E(f,e[7]),l(s,g),l(s,v),l(v,b),l(n,x),l(n,k),D.m(k,null),l(t,S),l(t,A),l(A,C),l(A,T),l(A,_),l(_,$),E($,e[9]),l(_,I),l(_,O),E(O,e[10]),l(_,R),l(_,P),l(P,L),l(A,B),l(A,N),z.m(N,null),U||(j=[m(a,"input",e[43]),m(f,"input",e[44]),m(v,"click",e[25]),m($,"input",e[45]),m(O,"input",e[46]),m(P,"click",e[26])],U=!0)},p(e,t){64&t[0]&&a.value!==e[6]&&E(a,e[6]),128&t[0]&&f.value!==e[7]&&E(f,e[7]),4&t[0]&&(v.disabled=e[2]),F===(F=M(e))&&D?D.p(e,t):(D.d(1),D=F(e),D&&(D.c(),D.m(k,null))),512&t[0]&&$.value!==e[9]&&E($,e[9]),1024&t[0]&&O.value!==e[10]&&E(O,e[10]),4&t[0]&&(P.disabled=e[2]),q===(q=H(e))&&z?z.p(e,t):(z.d(1),z=q(e),z&&(z.c(),z.m(N,null)))},d(e){e&&d(t),D.d(),z.d(),U=!1,r(j)}}}function Ih(t){let n;return{c(){n=h("div"),n.innerHTML="

No banned pubkeys configured.

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

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

No banned events configured.

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

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

No blocked IPs configured.

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

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

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

No events need moderation at this time.

",w(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function rp(e){let t,n=e[21],r=[];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.
',i=y(),V&&V.c(),s=y(),a=h("div"),c=h("button"),f=p("Pubkeys"),v=y(),b=h("button"),x=p("Events"),k=y(),S=h("button"),A=p("IPs"),T=y(),_=h("button"),$=p("Kinds"),O=y(),R=h("button"),P=p("Moderation"),B=y(),N=h("button"),U=p("Relay Config"),M=y(),F=h("div"),G&&G.c(),D=y(),Z&&Z.c(),H=y(),Y&&Y.c(),q=y(),Q&&Q.c(),z=y(),X&&X.c(),W=y(),ee&&ee.c(),w(o,"class","header svelte-1smaj3x"),w(c,"class",g="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1smaj3x"),w(b,"class",E="tab "+("events"===t[1]?"active":"")+" svelte-1smaj3x"),w(S,"class",C="tab "+("ips"===t[1]?"active":"")+" svelte-1smaj3x"),w(_,"class",I="tab "+("kinds"===t[1]?"active":"")+" svelte-1smaj3x"),w(R,"class",L="tab "+("moderation"===t[1]?"active":"")+" svelte-1smaj3x"),w(N,"class",j="tab "+("relay"===t[1]?"active":"")+" svelte-1smaj3x"),w(a,"class","tabs svelte-1smaj3x"),w(F,"class","tab-content svelte-1smaj3x")},m(e,r){u(e,n,r),l(n,o),l(n,i),V&&V.m(n,null),l(n,s),l(n,a),l(a,c),l(c,f),l(a,v),l(a,b),l(b,x),l(a,k),l(a,S),l(S,A),l(a,T),l(a,_),l(_,$),l(a,O),l(a,R),l(R,P),l(a,B),l(a,N),l(N,U),l(n,M),l(n,F),G&&G.m(F,null),l(F,D),Z&&Z.m(F,null),l(F,H),Y&&Y.m(F,null),l(F,q),Q&&Q.m(F,null),l(F,z),X&&X.m(F,null),l(F,W),ee&&ee.m(F,null),K||(J=[m(c,"click",t[37]),m(b,"click",t[38]),m(S,"click",t[39]),m(_,"click",t[40]),m(R,"click",t[41]),m(N,"click",t[42])],K=!0)},p(e,t){e[3]?V?V.p(e,t):(V=_h(e),V.c(),V.m(n,s)):V&&(V.d(1),V=null),2&t[0]&&g!==(g="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1smaj3x")&&w(c,"class",g),2&t[0]&&E!==(E="tab "+("events"===e[1]?"active":"")+" svelte-1smaj3x")&&w(b,"class",E),2&t[0]&&C!==(C="tab "+("ips"===e[1]?"active":"")+" svelte-1smaj3x")&&w(S,"class",C),2&t[0]&&I!==(I="tab "+("kinds"===e[1]?"active":"")+" svelte-1smaj3x")&&w(_,"class",I),2&t[0]&&L!==(L="tab "+("moderation"===e[1]?"active":"")+" svelte-1smaj3x")&&w(R,"class",L),2&t[0]&&j!==(j="tab "+("relay"===e[1]?"active":"")+" svelte-1smaj3x")&&w(N,"class",j),"pubkeys"===e[1]?G?G.p(e,t):(G=$h(e),G.c(),G.m(F,D)):G&&(G.d(1),G=null),"events"===e[1]?Z?Z.p(e,t):(Z=jh(e),Z.c(),Z.m(F,H)):Z&&(Z.d(1),Z=null),"ips"===e[1]?Y?Y.p(e,t):(Y=Kh(e),Y.c(),Y.m(F,q)):Y&&(Y.d(1),Y=null),"kinds"===e[1]?Q?Q.p(e,t):(Q=Yh(e),Q.c(),Q.m(F,z)):Q&&(Q.d(1),Q=null),"moderation"===e[1]?X?X.p(e,t):(X=tp(e),X.c(),X.m(F,W)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=sp(e),ee.c(),ee.m(F,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),V&&V.d(),G&&G.d(),Z&&Z.d(),Y&&Y.d(),Q&&Q.d(),X&&X.d(),ee&&ee.d(),K=!1,r(J)}}}function up(e,t,n){let{userSigner:r}=t,{userPubkey:o}=t,i="pubkeys",s=!1,a="",c="info",l=[],u="",d="",f=[],h="",p="",y=[],g="",m="",v="",w="",x=[],E="",k="",S=[],A="",C=[],_={relay_name:"",relay_description:"",relay_icon:""};var $;async function I(){try{n(2,s=!0),console.log("Fetching relay info from /");const e=await fetch(window.location.origin+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,_={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",_),console.log("Loaded relay info:",t),n(3,a="Relay configuration loaded successfully"),n(4,c="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,a=`Failed to fetch relay info: ${e.status}`),n(4,c="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,a=`Failed to fetch relay info: ${e.message}`),n(4,c="error")}finally{n(2,s=!1)}}async function O(e,t=[]){try{n(2,s=!0),n(3,a="");const i={method:e,params:t},c=await async function(e,t){if(!r)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!o)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,i={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:o},s=await r.signEvent(i),a=JSON.stringify(s);return`Nostr ${btoa(a)}`}("POST","/api/nip86"),l=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:c},body:JSON.stringify(i)});if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);const u=await l.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,a=e.message),n(4,c="error"),e}finally{n(2,s=!1)}}async function R(){try{n(5,l=await O("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function P(){try{n(8,f=await O("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function L(){try{n(11,y=await O("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function B(){try{n(16,x=await O("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function N(){try{n(19,S=await O("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function U(){try{n(2,s=!0),n(21,C=await O("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",C)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,a=`Failed to load moderation events: ${e.message}`),n(4,c="error"),n(21,C=[])}finally{n(2,s=!1)}}async function j(e){try{await O("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,c="success"),await N()}catch(e){console.error("Failed to disallow kind:",e)}}async function M(e){try{await O("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,c="success"),await U()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function F(e){try{await O("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,c="success"),await U()}catch(e){console.error("Failed to ban event from moderation:",e)}}$=()=>{setTimeout(()=>{I()},100)},T().$$.on_mount.push($),async function(){await Promise.all([R(),P(),L(),B(),N()])}();return e.$$set=e=>{"userSigner"in e&&n(35,r=e.userSigner),"userPubkey"in e&&n(36,o=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",_)},[_,i,s,a,c,l,u,d,f,h,p,y,g,m,v,w,x,E,k,S,A,C,[],I,U,async function(){if(u)try{await O("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,c="success"),n(6,u=""),n(7,d=""),await R()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await O("allowpubkey",[h,p]),n(3,a="Pubkey allowed successfully"),n(4,c="success"),n(9,h=""),n(10,p=""),await P()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(g)try{await O("banevent",[g,m]),n(3,a="Event banned successfully"),n(4,c="success"),n(12,g=""),n(13,m=""),await L()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(v)try{await O("allowevent",[v,w]),n(3,a="Event allowed successfully"),n(4,c="success"),n(14,v=""),n(15,w="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(E)try{await O("blockip",[E,k]),n(3,a="IP blocked successfully"),n(4,c="success"),n(17,E=""),n(18,k=""),await B()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!A)return;const e=parseInt(A);if(isNaN(e))return n(3,a="Invalid kind number"),void n(4,c="error");try{await O("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,c="success"),n(20,A=""),await N()}catch(e){console.error("Failed to allow kind:",e)}},j,async function(){try{n(2,s=!0),n(3,a="");const e=[];if(_.relay_name&&e.push(O("changerelayname",[_.relay_name])),_.relay_description&&e.push(O("changerelaydescription",[_.relay_description])),_.relay_icon&&e.push(O("changerelayicon",[_.relay_icon])),0===e.length)return n(3,a="No changes to update"),void n(4,c="info");await Promise.all(e),n(3,a="Relay configuration updated successfully"),n(4,c="success"),await I()}catch(e){console.error("Failed to update relay configuration:",e),n(3,a=`Failed to update relay configuration: ${e.message}`),n(4,c="error")}finally{n(2,s=!1)}},M,F,r,o,()=>n(1,i="pubkeys"),()=>n(1,i="events"),()=>n(1,i="ips"),()=>n(1,i="kinds"),()=>{n(1,i="moderation"),C&&0!==C.length||U()},()=>n(1,i="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){h=this.value,n(9,h)},function(){p=this.value,n(10,p)},function(){g=this.value,n(12,g)},function(){m=this.value,n(13,m)},function(){v=this.value,n(14,v)},function(){w=this.value,n(15,w)},function(){E=this.value,n(17,E)},function(){k=this.value,n(18,k)},function(){A=b(this.value),n(20,A)},e=>j(e),e=>M(e.id),e=>F(e.id),function(){_.relay_name=this.value,n(0,_)},function(){_.relay_description=this.value,n(0,_)},function(){_.relay_icon=this.value,n(0,_)}]}class dp extends Q{constructor(e){super(),Y(this,e,up,lp,i,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}class fp{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,r,o]=n;e&&r?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!r&&(console.error("Authentication failed:",o),this.authPromise&&(this.authPromise.reject(new Error(o||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const r=["EVENT",e];this.ws.send(JSON.stringify(r));const o=this.ws.onmessage,i=setTimeout(()=>{this.ws.onmessage=o,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async r=>{try{const s=JSON.parse(r.data),[a,c,l,u]=s;if("OK"===a&&c===e.id)if(clearTimeout(i),this.ws.onmessage=o,l)console.log("Event published successfully:",c),t({success:!0,eventId:c,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required")){console.log("Authentication required, attempting to authenticate...");try{await this.authenticate();const t=["EVENT",e];return void this.ws.send(JSON.stringify(t))}catch(e){return void n(new Error(`Authentication failed: ${e.message}`))}}n(new Error(`Publish failed: ${u}`))}else await this.handleMessage(s)}catch(e){clearTimeout(i),this.ws.onmessage=o,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function hp(e,t,n,r){const o=new fp(e,n,r);try{await o.connect();return await o.publishEvent(t)}finally{o.close()}}function pp(e,t,n){const r=e.slice();return r[165]=t[n],r}function yp(e,t,n){const r=e.slice();return r[145]=t[n],r}function gp(e,t,n){const r=e.slice();r[145]=t[n];const o=r[45](r[145]);return r[154]=o,r}function mp(e,t,n){const r=e.slice();return r[157]=t[n],r}function vp(e,t,n){const r=e.slice();return r[157]=t[n],r}function wp(e,t,n){const r=e.slice();return r[162]=t[n],r}function bp(e,t,n){const r=e.slice();return r[151]=t[n],r}function xp(e,t,n){const r=e.slice();return r[145]=t[n],r}function Ep(e,t,n){const r=e.slice();return r[148]=t[n],r}function kp(e,t,n){const r=e.slice();return r[170]=t[n],r}function Sp(e){let t,n,r,o=e[1]&&e[4]&&Cp(e);return{c(){t=h("div"),n=h("span"),r=p("ORLY? dashboard\n "),o&&o.c(),w(n,"class","app-title svelte-1a66x6i"),w(t,"class","header-title svelte-1a66x6i")},m(e,i){u(e,t,i),l(t,n),l(n,r),o&&o.m(n,null)},p(e,t){e[1]&&e[4]?o?o.p(e,t):(o=Cp(e),o.c(),o.m(n,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function Ap(e){let t,n,o,i;return{c(){t=h("div"),n=h("input"),w(n,"type","text"),w(n,"class","search-input svelte-1a66x6i"),w(n,"placeholder","Search..."),w(t,"class","search-input-container svelte-1a66x6i")},m(r,s){u(r,t,s),l(t,n),E(n,e[15]),o||(i=[m(n,"input",e[83]),m(n,"keydown",e[64])],o=!0)},p(e,t){32768&t[0]&&n.value!==e[15]&&E(n,e[15])},d(e){e&&d(t),o=!1,r(i)}}}function Cp(e){let t,n;return{c(){t=h("span"),n=p(e[4]),w(t,"class","permission-badge svelte-1a66x6i")},m(e,r){u(e,t,r),l(t,n)},p(e,t){16&t[0]&&x(n,e[4])},d(e){e&&d(t)}}}function Tp(t){let n,r,o;return{c(){n=h("button"),n.textContent="Log in",w(n,"class","login-btn svelte-1a66x6i")},m(e,i){u(e,n,i),r||(o=m(n,"click",t[57]),r=!0)},p:e,d(e){e&&d(n),r=!1,o()}}}function _p(e){let t,n,r,o,i,s,a,c=(e[3]?.name||e[2].slice(0,8)+"...")+"";function f(e,t){return e[3]?.picture?Ip:$p}let g=f(e),v=g(e);return{c(){t=h("div"),n=h("button"),v.c(),r=y(),o=h("span"),i=p(c),w(o,"class","user-name svelte-1a66x6i"),w(n,"class","user-profile-btn svelte-1a66x6i"),w(t,"class","user-info svelte-1a66x6i")},m(c,d){u(c,t,d),l(t,n),v.m(n,null),l(n,r),l(n,o),l(o,i),s||(a=m(n,"click",e[61]),s=!0)},p(e,t){g===(g=f(e))&&v?v.p(e,t):(v.d(1),v=g(e),v&&(v.c(),v.m(n,r))),12&t[0]&&c!==(c=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&x(i,c)},d(e){e&&d(t),v.d(),s=!1,a()}}}function $p(t){let n;return{c(){n=h("div"),n.textContent="👤",w(n,"class","user-avatar-placeholder svelte-1a66x6i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ip(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||w(t,"src",n),w(t,"alt","User avatar"),w(t,"class","user-avatar svelte-1a66x6i")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&w(t,"src",n)},d(e){e&&d(t)}}}function Op(e){let t,n,o;function i(){return e[84](e[170])}function s(...t){return e[85](e[170],...t)}return{c(){t=h("span"),t.textContent="✕",w(t,"class","tab-close-icon svelte-1a66x6i"),w(t,"role","button"),w(t,"tabindex","0")},m(e,r){u(e,t,r),n||(o=[m(t,"click",v(i)),m(t,"keydown",s)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r(o)}}}function Rp(e){let t,n,r,o,i,s,a,c,f,g,v=e[170].icon+"",b=e[170].label+"",E=e[170].isSearchTab&&Op(e);function k(){return e[86](e[170])}return{c(){t=h("button"),n=h("span"),r=p(v),o=y(),i=h("span"),s=p(b),a=y(),E&&E.c(),c=y(),w(n,"class","tab-icon svelte-1a66x6i"),w(i,"class","tab-label svelte-1a66x6i"),w(t,"class","tab svelte-1a66x6i"),S(t,"active",e[5]===e[170].id)},m(e,d){u(e,t,d),l(t,n),l(n,r),l(t,o),l(t,i),l(i,s),l(t,a),E&&E.m(t,null),l(t,c),f||(g=m(t,"click",k),f=!0)},p(n,o){e=n,1024&o[0]&&v!==(v=e[170].icon+"")&&x(r,v),1024&o[0]&&b!==(b=e[170].label+"")&&x(s,b),e[170].isSearchTab?E?E.p(e,o):(E=Op(e),E.c(),E.m(t,c)):E&&(E.d(1),E=null),1056&o[0]&&S(t,"active",e[5]===e[170].id)},d(e){e&&d(t),E&&E.d(),f=!1,g()}}}function Pp(t){let n;function r(e,t){return e[1]?qp:Hp}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),w(n,"class","welcome-message svelte-1a66x6i")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Lp(t){let n,r=t[6],o=[];for(let e=0;e🔄 Event Recovery \n

Search and recover old versions of replaceable events

',i=y(),s=h("div"),a=h("div"),c=h("label"),c.textContent="Select Event Kind:",p=y(),g=h("select"),v=h("option"),v.textContent="Choose a replaceable kind...";for(let e=0;et[99].call(g)),w(a,"class","kind-selector svelte-1a66x6i"),w(A,"for","custom-kind"),w(A,"class","svelte-1a66x6i"),w(T,"id","custom-kind"),w(T,"type","number"),w(T,"placeholder","e.g., 10001"),w(T,"min","0"),w(T,"class","svelte-1a66x6i"),w(S,"class","custom-kind-input svelte-1a66x6i"),w(s,"class","recovery-controls svelte-1a66x6i"),w(n,"class","recovery-tab svelte-1a66x6i")},m(e,r){u(e,n,r),l(n,o),l(n,i),l(n,s),l(s,a),l(a,c),l(a,p),l(a,g),l(g,v);for(let e=0;e{s[c]=null}),z(),r=s[n],r?r.p(e,o):(r=s[n]=i[n](e),r.c()),W(r,1),r.m(t,null))},i(e){o||(W(r),o=!0)},o(e){K(r),o=!1},d(e){e&&d(t),s[n].d()}}}function jp(t){let n,o,i,s,a,c,f,p,g,v,b,x;return{c(){n=h("div"),o=h("div"),i=h("button"),i.textContent="Reformat",s=y(),a=h("button"),a.textContent="Sign",c=y(),f=h("button"),f.textContent="Publish",p=y(),g=h("div"),v=h("textarea"),w(i,"class","compose-btn reformat-btn svelte-1a66x6i"),w(a,"class","compose-btn sign-btn svelte-1a66x6i"),w(f,"class","compose-btn publish-btn svelte-1a66x6i"),w(o,"class","compose-header svelte-1a66x6i"),w(v,"class","compose-textarea svelte-1a66x6i"),w(v,"placeholder","Enter your Nostr event JSON here..."),w(v,"spellcheck","false"),w(g,"class","compose-editor svelte-1a66x6i"),w(n,"class","compose-view svelte-1a66x6i")},m(e,r){u(e,n,r),l(n,o),l(o,i),l(o,s),l(o,a),l(o,c),l(o,f),l(n,p),l(n,g),l(g,v),E(v,t[27]),b||(x=[m(i,"click",t[75]),m(a,"click",t[76]),m(f,"click",t[77]),m(v,"input",t[95])],b=!0)},p(e,t){134217728&t[0]&&E(v,e[27])},i:e,o:e,d(e){e&&d(n),b=!1,r(x)}}}function Mp(t){let n,r;function o(e,t){return!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?Sy:Ay}let i=o(t),s=i(t),a=t[1]&&("write"===t[4]||"admin"===t[4]||"owner"===t[4])&&Uy(t);return{c(){n=h("div"),s.c(),r=y(),a&&a.c(),w(n,"class","events-view-container svelte-1a66x6i")},m(e,t){u(e,n,t),s.m(n,null),l(n,r),a&&a.m(n,null)},p(e,t){i===(i=o(e))&&s?s.p(e,t):(s.d(1),s=i(e),s&&(s.c(),s.m(n,r))),!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?a&&(a.d(1),a=null):a?a.p(e,t):(a=Uy(e),a.c(),a.m(n,null))},i:e,o:e,d(e){e&&d(n),s.d(),a&&a.d()}}}function Fp(t){let n;function r(e,t){return!e[1]||"admin"!==e[4]&&"owner"!==e[4]?e[1]?Dy:Fy:Hy}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),w(n,"class","import-view svelte-1a66x6i")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Dp(t){let n;function r(e,t){return e[1]?zy:qy}let o=r(t),i=o(t);return{c(){i.c(),n=g()},m(e,t){i.m(e,t),u(e,n,t)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n.parentNode,n)))},i:e,o:e,d(e){i.d(e),e&&d(n)}}}function Hp(t){let n;return{c(){n=h("p"),n.textContent="Log in to access your user dashboard",w(n,"class","svelte-1a66x6i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function qp(e){let t,n,r,o=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=h("p"),n=p("Welcome "),r=p(o),w(t,"class","svelte-1a66x6i")},m(e,o){u(e,t,o),l(t,n),l(t,r)},p(e,t){12&t[0]&&o!==(o=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&x(r,o)},d(e){e&&d(t)}}}function zp(e){let t,n,o,i,s,a,c,f,g,v,b,E,k,S,A,C,T,_,$,I=e[165].query+"",O=e[35].get(e[165].id)?.isLoading,R=!e[35].get(e[165].id)?.hasMore&&e[35].get(e[165].id)?.events?.length>0;function P(){return e[103](e[165])}function L(e,t){return 64&t[0]&&(k=null),64&t[0]&&(S=null),null==k&&(k=!!(e[35].get(e[165].id)?.events?.length>0)),k?Kp:(null==S&&(S=!e[35].get(e[165].id)?.isLoading),S?Wp:void 0)}let B=L(e,[-1,-1,-1,-1,-1,-1]),N=B&&B(e),U=O&&Zp(),j=R&&Yp();function M(...t){return e[108](e[165],...t)}return{c(){t=h("div"),n=h("div"),o=h("h2"),i=p('🔍 Search Results: "'),s=p(I),a=p('"'),c=y(),f=h("button"),g=p("🔄 Refresh"),b=y(),E=h("div"),N&&N.c(),A=y(),U&&U.c(),C=y(),j&&j.c(),T=y(),w(o,"class","svelte-1a66x6i"),w(f,"class","refresh-btn svelte-1a66x6i"),f.disabled=v=e[35].get(e[165].id)?.isLoading,w(n,"class","search-results-header svelte-1a66x6i"),w(E,"class","search-results-content svelte-1a66x6i"),w(t,"class","search-results-view svelte-1a66x6i")},m(e,r){u(e,t,r),l(t,n),l(n,o),l(o,i),l(o,s),l(o,a),l(n,c),l(n,f),l(f,g),l(t,b),l(t,E),N&&N.m(E,null),l(E,A),U&&U.m(E,null),l(E,C),j&&j.m(E,null),l(t,T),_||($=[m(f,"click",P),m(E,"scroll",M)],_=!0)},p(t,n){e=t,64&n[0]&&I!==(I=e[165].query+"")&&x(s,I),64&n[0]&&v!==(v=e[35].get(e[165].id)?.isLoading)&&(f.disabled=v),B===(B=L(e,n))&&N?N.p(e,n):(N&&N.d(1),N=B&&B(e),N&&(N.c(),N.m(E,A))),64&n[0]&&(O=e[35].get(e[165].id)?.isLoading),O?U||(U=Zp(),U.c(),U.m(E,C)):U&&(U.d(1),U=null),64&n[0]&&(R=!e[35].get(e[165].id)?.hasMore&&e[35].get(e[165].id)?.events?.length>0),R?j||(j=Yp(),j.c(),j.m(E,null)):j&&(j.d(1),j=null)},d(e){e&&d(t),N&&N.d(),U&&U.d(),j&&j.d(),_=!1,r($)}}}function Wp(e){let t,n,r,o,i,s=e[165].query+"";return{c(){t=h("div"),n=h("p"),r=p('No search results found for "'),o=p(s),i=p('".'),w(n,"class","svelte-1a66x6i"),w(t,"class","no-search-results svelte-1a66x6i")},m(e,s){u(e,t,s),l(t,n),l(n,r),l(n,o),l(n,i)},p(e,t){64&t[0]&&s!==(s=e[165].query+"")&&x(o,s)},d(e){e&&d(t)}}}function Kp(e){let t,n=e[35].get(e[165].id).events,r=[];for(let t=0;t👤',i=y(),s=h("div"),a=h("div"),c=p(j),f=y(),g=h("div"),v=h("span"),b=p(M),E=y(),k=h("span"),A=p(F),C=y(),T=h("div"),_=h("div"),$=p(D),I=y(),O=h("div"),R=p(H),P=y(),z&&z.c(),L=y(),J&&J.c(),B=y(),w(o,"class","search-result-avatar svelte-1a66x6i"),w(a,"class","search-result-author svelte-1a66x6i"),w(v,"class","kind-number svelte-1a66x6i"),w(k,"class","kind-name svelte-1a66x6i"),w(g,"class","search-result-kind svelte-1a66x6i"),w(s,"class","search-result-info svelte-1a66x6i"),w(_,"class","event-timestamp svelte-1a66x6i"),w(O,"class","event-content-single-line svelte-1a66x6i"),w(T,"class","search-result-content svelte-1a66x6i"),w(n,"class","search-result-row svelte-1a66x6i"),w(n,"role","button"),w(n,"tabindex","0"),w(t,"class","search-result-item svelte-1a66x6i"),S(t,"expanded",e[17].has(e[145].id))},m(e,r){u(e,t,r),l(t,n),l(n,o),l(n,i),l(n,s),l(s,a),l(a,c),l(s,f),l(s,g),l(g,v),l(v,b),l(g,E),l(g,k),l(k,A),l(n,C),l(n,T),l(T,_),l(_,$),l(T,I),l(T,O),l(O,R),l(n,P),z&&z.m(n,null),l(t,L),J&&J.m(t,null),l(t,B),N||(U=[m(n,"click",W),m(n,"keydown",K)],N=!0)},p(r,o){e=r,64&o[0]&&j!==(j=tg(e[145].pubkey)+"")&&x(c,j),64&o[0]&&M!==(M=e[145].kind+"")&&x(b,M),64&o[0]&&F!==(F=e[37](e[145].kind)+"")&&x(A,F),64&o[0]&&D!==(D=rg(e[145].created_at)+"")&&x($,D),64&o[0]&&H!==(H=ng(e[145].content)+"")&&x(R,H),5!==e[145].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[145].pubkey&&e[145].pubkey===e[2])?z?z.p(e,o):(z=Jp(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),131136&o[0]&&(q=e[17].has(e[145].id)),q?J?J.p(e,o):(J=Vp(e),J.c(),J.m(t,B)):J&&(J.d(1),J=null),131136&o[0]|16&o[1]&&S(t,"expanded",e[17].has(e[145].id))},d(e){e&&d(t),z&&z.d(),J&&J.d(),N=!1,r(U)}}}function Zp(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Searching...

',w(t,"class","loading-search-results svelte-1a66x6i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Yp(e){let t;return{c(){t=h("div"),t.innerHTML='

No more search results to load.

',w(t,"class","end-of-search-results svelte-1a66x6i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Qp(e){let t,n=e[165].id===e[5]&&zp(e);return{c(){n&&n.c(),t=g()},m(e,r){n&&n.m(e,r),u(e,t,r)},p(e,r){e[165].id===e[5]?n?n.p(e,r):(n=zp(e),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(e){n&&n.d(e),e&&d(t)}}}function Xp(t){let n,r,o=t[162].label+"";return{c(){n=h("option"),r=p(o),n.__value=t[162].value,n.value=n.__value},m(e,t){u(e,n,t),l(n,r)},p:e,d(e){e&&d(n)}}}function ey(e){let t;function n(e,t){return e[31]?ry:0===e[30].length?ny:ty}let r=n(e),o=r(e);return{c(){t=h("div"),o.c(),w(t,"class","recovery-results svelte-1a66x6i")},m(e,n){u(e,t,n),o.m(t,null)},p(e,i){r===(r=n(e))&&o?o.p(e,i):(o.d(1),o=r(e),o&&(o.c(),o.m(t,null)))},d(e){e&&d(t),o.d()}}}function ty(e){let t,n,r,o=e[30],i=[];for(let t=0;tORLY_OWNERS environment variable with your npub when starting the\n relay.",i=y(),s=h("p"),a=p("Current user role: "),c=h("strong"),f=p(g),w(n,"class","svelte-1a66x6i"),w(o,"class","svelte-1a66x6i"),w(s,"class","svelte-1a66x6i"),w(t,"class","permission-denied svelte-1a66x6i")},m(e,d){u(e,t,d),l(t,n),l(t,r),l(t,o),l(t,i),l(t,s),l(s,a),l(s,c),l(c,f)},p(e,t){16&t[0]&&g!==(g=(e[4]||"none")+"")&&x(f,g)},d(e){e&&d(t)}}}function yy(e){let t,n,o,i,s,a,c,g,v,b,k,A,C,T,_,$,I,O,R,P,L,B,N,U,j,M,F,D,H,q,z,W,K,J,V,G,Z,Y,Q,X,ee,te,ne,re,oe,ie,se,ae,ce,le,ue,de,fe,he,pe,ye,ge=e[21]?.is_running?"🟢 Running":"🔴 Stopped",me=e[21]?.script_exists?"✅ Exists":"❌ Not found",ve=e[21]?.pid&&gy(e),we=e[24]&&my(e),be=e[22],xe=[];for(let t=0;tORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',w(r,"class","svelte-1a66x6i"),w(i,"class","svelte-1a66x6i"),w(a,"class","svelte-1a66x6i"),w(v,"class","svelte-1a66x6i"),w(n,"class","acl-mode-warning svelte-1a66x6i")},m(e,t){u(e,n,t),l(n,r),l(n,o),l(n,i),l(n,s),l(n,a),l(a,c),l(a,f),l(f,g),l(n,m),l(n,v)},p(e,t){512&t[0]&&b!==(b=(e[9]||"unknown")+"")&&x(g,b)},i:e,o:e,d(e){e&&d(n)}}}function Sy(t){let n;return{c(){n=h("div"),n.innerHTML='

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

',w(n,"class","permission-denied svelte-1a66x6i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ay(e){let t,n,r,o,i;function s(e,t){return e[34].length>0?Ty:e[18]?void 0:Cy}let a=s(e),c=a&&a(e),f=e[18]&&By(),p=!e[19]&&e[7].length>0&&Ny();return{c(){t=h("div"),c&&c.c(),n=y(),f&&f.c(),r=y(),p&&p.c(),w(t,"class","events-view-content svelte-1a66x6i")},m(s,a){u(s,t,a),c&&c.m(t,null),l(t,n),f&&f.m(t,null),l(t,r),p&&p.m(t,null),o||(i=m(t,"scroll",e[74]),o=!0)},p(e,o){a===(a=s(e))&&c?c.p(e,o):(c&&c.d(1),c=a&&a(e),c&&(c.c(),c.m(t,n))),e[18]?f||(f=By(),f.c(),f.m(t,r)):f&&(f.d(1),f=null),!e[19]&&e[7].length>0?p||(p=Ny(),p.c(),p.m(t,null)):p&&(p.d(1),p=null)},d(e){e&&d(t),c&&c.d(),f&&f.d(),p&&p.d(),o=!1,i()}}}function Cy(t){let n;return{c(){n=h("div"),n.innerHTML='

No events found.

',w(n,"class","no-events svelte-1a66x6i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Ty(e){let t,n=e[34],r=[];for(let t=0;t0&&Iy(e);return{c(){t=h("div"),n=h("span"),n.textContent="🗑️ Delete Event",r=y(),o&&o.c(),w(n,"class","delete-event-label svelte-1a66x6i"),w(t,"class","delete-event-info svelte-1a66x6i")},m(e,i){u(e,t,i),l(t,n),l(t,r),o&&o.m(t,null)},p(e,n){e[145].tags&&e[145].tags.length>0?o?o.p(e,n):(o=Iy(e),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function Iy(e){let t,n=e[145].tags.filter(ig),r=[];for(let t=0;t👤',i=y(),s=h("div"),a=h("div"),c=p(N),f=y(),g=h("div"),v=h("span"),b=p(U),E=y(),k=h("span"),A=p(j),C=y(),T=h("div"),_=h("div"),$=p(M),I=y(),q.c(),O=y(),z&&z.c(),R=y(),J&&J.c(),P=y(),w(o,"class","events-view-avatar svelte-1a66x6i"),w(a,"class","events-view-author svelte-1a66x6i"),w(v,"class","kind-number svelte-1a66x6i"),S(v,"delete-event",5===e[145].kind),w(k,"class","kind-name svelte-1a66x6i"),w(g,"class","events-view-kind svelte-1a66x6i"),w(s,"class","events-view-info svelte-1a66x6i"),w(_,"class","event-timestamp svelte-1a66x6i"),w(T,"class","events-view-content svelte-1a66x6i"),w(n,"class","events-view-row svelte-1a66x6i"),w(n,"role","button"),w(n,"tabindex","0"),w(t,"class","events-view-item svelte-1a66x6i"),S(t,"expanded",e[17].has(e[145].id))},m(e,r){u(e,t,r),l(t,n),l(n,o),l(n,i),l(n,s),l(s,a),l(a,c),l(s,f),l(s,g),l(g,v),l(v,b),l(g,E),l(g,k),l(k,A),l(n,C),l(n,T),l(T,_),l(_,$),l(T,I),q.m(T,null),l(n,O),z&&z.m(n,null),l(t,R),J&&J.m(t,null),l(t,P),L||(B=[m(n,"click",W),m(n,"keydown",K)],L=!0)},p(r,o){e=r,8&o[1]&&N!==(N=tg(e[145].pubkey)+"")&&x(c,N),8&o[1]&&U!==(U=e[145].kind+"")&&x(b,U),8&o[1]&&S(v,"delete-event",5===e[145].kind),8&o[1]&&j!==(j=e[37](e[145].kind)+"")&&x(A,j),8&o[1]&&M!==(M=rg(e[145].created_at)+"")&&x($,M),H===(H=D(e))&&q?q.p(e,o):(q.d(1),q=H(e),q&&(q.c(),q.m(T,null))),5!==e[145].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[145].pubkey&&e[145].pubkey===e[2])?z?z.p(e,o):(z=Ry(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),131072&o[0]|8&o[1]&&(F=e[17].has(e[145].id)),F?J?J.p(e,o):(J=Py(e),J.c(),J.m(t,P)):J&&(J.d(1),J=null),131072&o[0]|8&o[1]&&S(t,"expanded",e[17].has(e[145].id))},d(e){e&&d(t),q.d(),z&&z.d(),J&&J.d(),L=!1,r(B)}}}function By(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Loading events...

',w(t,"class","loading-events svelte-1a66x6i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ny(e){let t;return{c(){t=h("div"),t.innerHTML='

No more events to load.

',w(t,"class","end-of-events svelte-1a66x6i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Uy(e){let t,n,o,i,s,a,c,f,g,v,b,x,E,k,S,A;function C(e,t){return e[18]?My:jy}let T=C(e),_=T(e);return{c(){t=h("div"),n=h("div"),o=h("label"),i=h("input"),s=y(),a=h("span"),c=y(),f=h("span"),f.textContent="Only show my events",g=y(),v=h("div"),b=h("button"),x=p("🔄 Load More"),E=y(),k=h("button"),_.c(),w(i,"type","checkbox"),w(i,"class","svelte-1a66x6i"),w(a,"class","toggle-slider svelte-1a66x6i"),w(f,"class","toggle-label svelte-1a66x6i"),w(o,"class","toggle-container svelte-1a66x6i"),w(n,"class","events-view-toggle svelte-1a66x6i"),w(b,"class","refresh-btn svelte-1a66x6i"),b.disabled=e[18],w(k,"class","reload-btn svelte-1a66x6i"),k.disabled=e[18],w(v,"class","events-view-buttons svelte-1a66x6i"),w(t,"class","events-view-header svelte-1a66x6i")},m(r,d){u(r,t,d),l(t,n),l(n,o),l(o,i),i.checked=e[8],l(o,s),l(o,a),l(o,c),l(o,f),l(t,g),l(t,v),l(v,b),l(b,x),l(v,E),l(v,k),_.m(k,null),S||(A=[m(i,"change",e[91]),m(i,"change",e[92]),m(b,"click",e[93]),m(k,"click",e[94])],S=!0)},p(e,t){256&t[0]&&(i.checked=e[8]),262144&t[0]&&(b.disabled=e[18]),T!==(T=C(e))&&(_.d(1),_=T(e),_&&(_.c(),_.m(k,null))),262144&t[0]&&(k.disabled=e[18])},d(e){e&&d(t),_.d(),S=!1,r(A)}}}function jy(e){let t;return{c(){t=p("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function My(e){let t;return{c(){t=h("div"),w(t,"class","spinner svelte-1a66x6i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Fy(t){let n,r,o,i,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access import functionality.",o=y(),i=h("button"),i.textContent="Log In",w(r,"class","svelte-1a66x6i"),w(i,"class","login-btn svelte-1a66x6i"),w(n,"class","login-prompt svelte-1a66x6i")},m(e,c){u(e,n,c),l(n,r),l(n,o),l(n,i),s||(a=m(i,"click",t[57]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function Dy(t){let n;return{c(){n=h("div"),n.innerHTML='

❌ Admin or owner permission required for import\n functionality.

',w(n,"class","permission-denied svelte-1a66x6i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Hy(e){let t,n,o,i,s,a,c,f,g,v,b;return{c(){t=h("h2"),t.textContent="Import Events",n=y(),o=h("p"),o.textContent="Upload a JSONL file to import events into the database.",i=y(),s=h("input"),a=y(),c=h("button"),f=p("📥 Import Events"),w(t,"class","svelte-1a66x6i"),w(s,"type","file"),w(s,"id","import-file"),w(s,"accept",".jsonl,.txt"),w(s,"class","svelte-1a66x6i"),w(c,"class","import-btn svelte-1a66x6i"),c.disabled=g=!e[16]},m(r,d){u(r,t,d),u(r,n,d),u(r,o,d),u(r,i,d),u(r,s,d),u(r,a,d),u(r,c,d),l(c,f),v||(b=[m(s,"change",e[71]),m(c,"click",e[72])],v=!0)},p(e,t){65536&t[0]&&g!==(g=!e[16])&&(c.disabled=g)},d(e){e&&d(t),e&&d(n),e&&d(o),e&&d(i),e&&d(s),e&&d(a),e&&d(c),v=!1,r(b)}}}function qy(t){let n,r,o,i,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access export functionality.",o=y(),i=h("button"),i.textContent="Log In",w(r,"class","svelte-1a66x6i"),w(i,"class","login-btn svelte-1a66x6i"),w(n,"class","login-prompt svelte-1a66x6i")},m(e,c){u(e,n,c),l(n,r),l(n,o),l(n,i),s||(a=m(i,"click",t[57]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function zy(e){let t,n,r,o,i,s,a,c,f,p,v=("admin"===e[4]||"owner"===e[4])&&Wy(e);return{c(){t=h("div"),n=h("h2"),n.textContent="Export My Events",r=y(),o=h("p"),o.textContent="Download your personal events as a JSONL file.",i=y(),s=h("button"),s.textContent="📤 Export My Events",a=y(),v&&v.c(),c=g(),w(o,"class","svelte-1a66x6i"),w(s,"class","export-btn svelte-1a66x6i"),w(t,"class","export-section svelte-1a66x6i")},m(d,h){u(d,t,h),l(t,n),l(t,r),l(t,o),l(t,i),l(t,s),u(d,a,h),v&&v.m(d,h),u(d,c,h),f||(p=m(s,"click",e[70]),f=!0)},p(e,t){"admin"===e[4]||"owner"===e[4]?v?v.p(e,t):(v=Wy(e),v.c(),v.m(c.parentNode,c)):v&&(v.d(1),v=null)},d(e){e&&d(t),e&&d(a),v&&v.d(e),e&&d(c),f=!1,p()}}}function Wy(t){let n,r,o,i,s,a,c,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export All Events",o=y(),i=h("p"),i.textContent="Download the complete database as a JSONL file. This\n includes all events from all users.",s=y(),a=h("button"),a.textContent="📤 Export All Events",w(r,"class","svelte-1a66x6i"),w(i,"class","svelte-1a66x6i"),w(a,"class","export-btn svelte-1a66x6i"),w(n,"class","export-section svelte-1a66x6i")},m(e,d){u(e,n,d),l(n,r),l(n,o),l(n,i),l(n,s),l(n,a),c||(f=m(a,"click",t[69]),c=!0)},p:e,d(e){e&&d(n),c=!1,f()}}}function Ky(e){let t,n,o,i,s,a,c,f,p,g;function b(e,t){return e[3]?Vy:e[1]&&e[2]?Jy:void 0}let x=b(e),E=x&&x(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Settings",s=y(),a=h("button"),a.textContent="✕",c=y(),f=h("div"),E&&E.c(),w(i,"class","svelte-1a66x6i"),w(a,"class","close-btn svelte-1a66x6i"),w(o,"class","drawer-header svelte-1a66x6i"),w(f,"class","drawer-content"),w(n,"class","settings-drawer svelte-1a66x6i"),S(n,"dark-theme",e[0]),w(t,"class","drawer-overlay svelte-1a66x6i"),w(t,"role","button"),w(t,"tabindex","0")},m(r,d){u(r,t,d),l(t,n),l(n,o),l(o,i),l(o,s),l(o,a),l(n,c),l(n,f),E&&E.m(f,null),p||(g=[m(a,"click",e[62]),m(n,"click",v(e[80])),m(n,"keydown",v(e[81])),m(t,"click",e[62]),m(t,"keydown",e[109])],p=!0)},p(e,t){x===(x=b(e))&&E?E.p(e,t):(E&&E.d(1),E=x&&x(e),E&&(E.c(),E.m(f,null))),1&t[0]&&S(n,"dark-theme",e[0])},d(e){e&&d(t),E&&E.d(),p=!1,r(g)}}}function Jy(e){let t,n,r,o,i,s,a,c,f,g,v,b,E,k,S,A=e[2].slice(0,16)+"",C=e[2].slice(-8)+"";return{c(){t=h("div"),n=h("h3"),n.textContent="Profile Loading",r=y(),o=h("p"),o.textContent="Your profile metadata is being loaded...",i=y(),s=h("button"),s.textContent="Retry Loading Profile",a=y(),c=h("div"),f=h("strong"),f.textContent="Public Key:",g=y(),v=p(A),b=p("..."),E=p(C),w(n,"class","svelte-1a66x6i"),w(o,"class","svelte-1a66x6i"),w(s,"class","retry-profile-btn svelte-1a66x6i"),w(c,"class","user-pubkey-display svelte-1a66x6i"),w(t,"class","profile-loading-section svelte-1a66x6i")},m(d,h){u(d,t,h),l(t,n),l(t,r),l(t,o),l(t,i),l(t,s),l(t,a),l(t,c),l(c,f),l(c,g),l(c,v),l(c,b),l(c,E),k||(S=m(s,"click",e[68]),k=!0)},p(e,t){4&t[0]&&A!==(A=e[2].slice(0,16)+"")&&x(v,A),4&t[0]&&C!==(C=e[2].slice(-8)+"")&&x(E,C)},d(e){e&&d(t),k=!1,S()}}}function Vy(e){let t,n,r,o,i,s,a,c,f,g,v,b,E,k=(e[3].name||"Unknown User")+"",S=e[3].banner&&Gy(e);function A(e,t){return e[3].picture?Yy:Zy}let C=A(e),T=C(e),_=e[3].nip05&&Qy(e),$=e[3].about&&Xy(e);return{c(){t=h("div"),n=h("div"),S&&S.c(),r=y(),o=h("button"),o.textContent="Log out",i=y(),T.c(),s=y(),a=h("div"),c=h("h3"),f=p(k),g=y(),_&&_.c(),v=y(),$&&$.c(),w(o,"class","logout-btn floating svelte-1a66x6i"),w(c,"class","profile-username svelte-1a66x6i"),w(a,"class","name-row svelte-1a66x6i"),w(n,"class","profile-hero svelte-1a66x6i"),w(t,"class","profile-section svelte-1a66x6i")},m(d,h){u(d,t,h),l(t,n),S&&S.m(n,null),l(n,r),l(n,o),l(n,i),T.m(n,null),l(n,s),l(n,a),l(a,c),l(c,f),l(a,g),_&&_.m(a,null),l(t,v),$&&$.m(t,null),b||(E=m(o,"click",e[59]),b=!0)},p(e,o){e[3].banner?S?S.p(e,o):(S=Gy(e),S.c(),S.m(n,r)):S&&(S.d(1),S=null),C===(C=A(e))&&T?T.p(e,o):(T.d(1),T=C(e),T&&(T.c(),T.m(n,s))),8&o[0]&&k!==(k=(e[3].name||"Unknown User")+"")&&x(f,k),e[3].nip05?_?_.p(e,o):(_=Qy(e),_.c(),_.m(a,null)):_&&(_.d(1),_=null),e[3].about?$?$.p(e,o):($=Xy(e),$.c(),$.m(t,null)):$&&($.d(1),$=null)},d(e){e&&d(t),S&&S.d(),T.d(),_&&_.d(),$&&$.d(),b=!1,E()}}}function Gy(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].banner)||w(t,"src",n),w(t,"alt","Profile banner"),w(t,"class","profile-banner svelte-1a66x6i")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].banner)&&w(t,"src",n)},d(e){e&&d(t)}}}function Zy(t){let n;return{c(){n=h("div"),n.textContent="👤",w(n,"class","profile-avatar-placeholder overlap svelte-1a66x6i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Yy(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||w(t,"src",n),w(t,"alt","User avatar"),w(t,"class","profile-avatar overlap svelte-1a66x6i")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&w(t,"src",n)},d(e){e&&d(t)}}}function Qy(e){let t,n,r=e[3].nip05+"";return{c(){t=h("span"),n=p(r),w(t,"class","profile-nip05-inline svelte-1a66x6i")},m(e,r){u(e,t,r),l(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&x(n,r)},d(e){e&&d(t)}}}function Xy(e){let t,n;return{c(){t=h("div"),n=h("p"),w(n,"class","profile-about svelte-1a66x6i"),w(t,"class","about-card svelte-1a66x6i")},m(r,o){u(r,t,o),l(t,n),n.innerHTML=e[33]},p(e,t){4&t[1]&&(n.innerHTML=e[33])},d(e){e&&d(t)}}}function eg(e){let t,n,o,i,s,c,g,v,b,E,k,A,C,T,_,$,I,R,L,B,N,U,j,M,F,D,H,Z,Y=e[0]?"☀️":"🌙";function Q(e,t){return e[14]?Ap:Sp}let X=Q(e),ee=X(e);function te(e,t){return e[1]?_p:Tp}let ne=te(e),re=ne(e),oe=e[10],ie=[];for(let t=0;tfunction(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}(M,"showModal",ue)),M.$on("login",e[58]),M.$on("close",e[60]),{c(){t=h("header"),n=h("div"),o=h("img"),s=y(),ee.c(),c=y(),g=h("button"),g.textContent="🔍",v=y(),b=h("button"),E=p(Y),k=y(),re.c(),A=y(),C=h("div"),T=h("aside"),_=h("div"),$=h("div");for(let e=0;e{ae[o]=null}),z(),N=ae[B],N?N.p(e,r):(N=ae[B]=se[B](e),N.c()),W(N,1),N.m(R,null)),(!D||1&r[0])&&S(C,"dark-theme",e[0]),e[13]?le?le.p(e,r):(le=Ky(e),le.c(),le.m(j.parentNode,j)):le&&(le.d(1),le=null);const i={};var s;1&r[0]&&(i.isDarkTheme=e[0]),!F&&2048&r[0]&&(F=!0,i.showModal=e[11],s=()=>F=!1,P.push(s)),M.$set(i)},i(e){D||(W(N),W(M.$$.fragment,e),D=!0)},o(e){K(N),K(M.$$.fragment,e),D=!1},d(e){e&&d(t),ee.d(),re.d(),e&&d(A),e&&d(C),f(ie,e),ae[B].d(),e&&d(U),le&&le.d(e),e&&d(j),G(M,e),H=!1,r(Z)}}}function tg(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function ng(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function rg(e){return e?new Date(1e3*e).toLocaleString():""}async function og(e,t){try{const n=JSON.stringify(e);await navigator.clipboard.writeText(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(n){console.error("Failed to copy to clipboard:",n);try{const n=document.createElement("textarea");n.value=JSON.stringify(e),document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(e){console.error("Fallback copy also failed:",e),alert("Failed to copy to clipboard. Please copy manually.")}}}const ig=e=>"e"===e[0],sg=e=>"p"===e[0],ag=e=>"p"===e[0];function cg(e,t,n){let r,o,i,s,a=!1,c=!1,l=!1,u="",d="",f=null,h="",p=null,y=!1,g="export",m=!1,v="",w=[],x=[],E=null,k=new Set,S=!1,A=!0,C=null,T=new Map,_=[],I=0;const O=3e5;let R=!1,P=[],L=!0,B=null,N="",U=null,j=[],M=!1,F="",D="info",H=!1,q=null,z="",W="",K=null,J="",V=[],G=!1,Z=!0,Y=null;const Q=[{value:0,label:"Profile Metadata (0)"},{value:3,label:"Follow List (3)"},{value:1e4,label:"Relay List Metadata (10000)"},{value:10001,label:"Mute List (10001)"},{value:10002,label:"Pin List (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:10015,label:"Interests List (10015)"},{value:10030,label:"Emoji Sets (10030)"},{value:3e4,label:"Categorized People List (30000)"},{value:30001,label:"Categorized Bookmark List (30001)"},{value:30002,label:"Relay Sets (30002)"},{value:30003,label:"Bookmark Sets (30003)"},{value:30004,label:"Curation Sets (30004)"},{value:30008,label:"Profile Badges (30008)"},{value:30009,label:"Badge Definition (30009)"},{value:30015,label:"Interest Sets (30015)"},{value:30017,label:"Stall Definition (30017)"},{value:30018,label:"Product Definition (30018)"},{value:30019,label:"Marketplace UI/UX (30019)"},{value:30020,label:"Product Sold as Auction (30020)"},{value:30023,label:"Article (30023)"},{value:30024,label:"Draft Long-form Content (30024)"},{value:30030,label:"Emoji Sets (30030)"},{value:30078,label:"Application Specific Data (30078)"},{value:30311,label:"Live Event (30311)"},{value:30315,label:"User Statuses (30315)"},{value:30402,label:"Classified Listing (30402)"},{value:30403,label:"Draft Classified Listing (30403)"},{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:32123,label:"WaveLake Track (32123)"},{value:34550,label:"Community Definition (34550)"}],X={0:"User Metadata",1:"Short Text Note",2:"Recommend Relay",3:"Follows",4:"Encrypted Direct Messages",5:"Event Deletion Request",6:"Repost",7:"Reaction",8:"Badge Award",9:"Chat Message",10:"Group Chat Threaded Reply",11:"Thread",12:"Group Thread Reply",13:"Seal",14:"Direct Message",15:"File Message",16:"Generic Repost",17:"Reaction to a website",20:"Picture",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1021:"Bid",1022:"Bid Confirmation",1040:"OpenTimestamps",1063:"File Metadata",1311:"Live Chat Message",1971:"Problem Tracker",1984:"Reporting",1985:"Label",4550:"Community Post Approval",5e3:"Job Request",5999:"Job Request",6e3:"Job Result",6999:"Job Result",7e3:"Job Feedback",9041:"Zap Goal",9734:"Zap Request",9735:"Zap",9882:"Highlights",1e4:"Mute list",10001:"Pin list",10002:"Relay List Metadata",10003:"Bookmarks list",10004:"Communities list",10005:"Public Chats list",10006:"Blocked Relays list",10007:"Search Relays list",10015:"Interests",10030:"User Emoji list",10050:"DM relays",10096:"File Storage Server List",13194:"Wallet Service Info",21e3:"Lightning pub RPC",22242:"Client Authentication",23194:"Wallet Request",23195:"Wallet Response",23196:"Wallet Notification",23197:"Wallet Notification",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Follow sets",30001:"Generic lists",30002:"Relay sets",30003:"Bookmark sets",30004:"Curation sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest sets",30017:"Stall Definition",30018:"Product Definition",30019:"Marketplace UI/UX",30020:"Product sold as an auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34235:"Video Event Horizontal",34236:"Video Event Vertical",34550:"Community Definition"};function ee(e){k.has(e)?k.delete(e):k.add(e),n(17,k)}async function te(){console.log("Toggle changed, showOnlyMyEvents:",R);const e=R&&l&&u?[u]:null;await ke(!0,e)}async function ne(e){if(!l)return void alert("Please log in first");const t=x.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===h||"owner"===h||"write"===h&&t.pubkey&&t.pubkey===u){if(confirm("Are you sure you want to delete this event?"))try{if(!p)throw new Error("Signer not available for signing");const r={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",r),console.log("User pubkey:",u),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const o=await p.signEvent(r);console.log("Signed delete event:",o),console.log("Signed delete event pubkey:",o.pubkey),console.log("Delete event tags:",o.tags);const i=`wss://${window.location.host}`;try{const e=await hp(i,o,p,u);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const s=t.pubkey&&t.pubkey===u;if(s){const t=await nh.publish(o);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await lh(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 uh(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===u);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(7,x=x.filter(t=>t.id!==e)),P=P.filter(t=>t.id!==e),_=_.filter(t=>t.id!==e);for(const[t,n]of T)n.events&&(n.events=n.events.filter(t=>t.id!==e),T.set(t,n));se(),console.log("Reloading events to show delete event...");const r=R&&l&&u?[u]:null;await ke(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`wss://${window.location.host}/`,r=new th;await r.connectToRelay(t);const i=await r.publish(o);if(console.log("Delete event published to local relay only:",i),!(i.success&&i.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await lh(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${i.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await uh(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===u);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(7,x=x.filter(t=>t.id!==e)),P=P.filter(t=>t.id!==e),_=_.filter(t=>t.id!==e);for(const[t,n]of T)n.events&&(n.events=n.events.filter(t=>t.id!==e),T.set(t,n));se(),console.log("Reloading events to show delete event...");const t=R&&l&&u?[u]:null;await ke(!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 re(){const e=J?parseInt(J):K;if(e&&l){console.log("Loading recovery events for kind:",e,"user:",u),n(31,G=!0);try{const t={kinds:[e],authors:[u],limit:100};Y&&(t.until=Y),console.log("Recovery filters:",t);const r=await ch(t);console.log("Recovery events received:",r.length),console.log("Recovery events kinds:",r.map(e=>e.kind)),n(30,V=Y?[...V,...r]:r),r.length>0?(Y=Math.min(...r.map(e=>e.created_at)),n(32,Z=100===r.length)):n(32,Z=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(31,G=!1)}}}async function oe(e){if(l&&p)try{const t={kind:e.kind,content:e.content,tags:e.tags,created_at:Math.floor(Date.now()/1e3),pubkey:u};(await hp(DEFAULT_RELAYS[0],t,p,u)).success?(alert("Event reposted successfully!"),n(30,V=[]),Y=null,await re()):alert("Failed to repost event")}catch(e){console.error("Failed to repost event:",e),alert("Failed to repost event: "+e.message)}else alert("Please log in to repost events")}function ie(e){n(28,K=e),n(29,J=""),n(30,V=[]),Y=null,n(32,Z=!0),re()}if("undefined"!=typeof localStorage){const e=localStorage.getItem("isDarkTheme");null!==e&&(a=JSON.parse(e));const t=localStorage.getItem("nostr_auth_method"),r=localStorage.getItem("nostr_pubkey");t&&r&&(l=!0,u=r,d=t,"extension"===t&&window.nostr&&(p=window.nostr),be(),xe()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&he.some(e=>e.id===r.selectedTab)&&n(5,g=r.selectedTab),r.expandedEvents&&n(17,k=new Set(r.expandedEvents)),r.globalEventsCache&&(_=r.globalEventsCache),r.globalCacheTimestamp&&(I=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&n(19,A=r.hasMoreEvents),r.oldestEventTimestamp&&(C=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(L=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(B=r.oldestMyEventTimestamp),_.length>0&&((e=I)&&Date.now()-et.created_at-e.created_at),I=Date.now(),se()}async function ce(){if(l&&"owner"===h&&H)try{n(23,M=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Ce("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(21,U=await e.json()):fe("Failed to load sprocket status","error")}catch(e){fe(`Error loading sprocket status: ${e.message}`,"error")}finally{n(23,M=!1)}}async function le(){if(l&&"owner"===h)try{n(23,M=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await Ce("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(22,j=await e.json()):fe("Failed to load versions","error")}catch(e){fe(`Error loading versions: ${e.message}`,"error")}finally{n(23,M=!1)}}async function ue(e){l&&"owner"===h&&(n(20,N=e.content),fe(`Loaded version: ${e.name}`,"success"))}async function de(e){if(l&&"owner"===h&&confirm(`Are you sure you want to delete version ${e}?`))try{n(23,M=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)fe(`Version ${e} deleted successfully`,"success"),await le();else{fe(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){fe(`Error deleting version: ${e.message}`,"error")}finally{n(23,M=!1)}}function fe(e,t="info"){n(24,F=e),n(25,D=t),setTimeout(()=>{n(24,F="")},5e3)}const he=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"compose",icon:"✏️",label:"Compose"},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0}];function pe(e){n(5,g=e),"sprocket"===e&&l&&"owner"===h&&H&&(ce(),le()),se()}function ye(){n(13,y=!1)}function ge(e){n(6,w=w.filter(t=>t.id!==e)),T.delete(e),g===e&&n(5,g="export")}async function me(e,t,n=!0){const r=T.get(e);if(r&&!r.isLoading){r.isLoading=!0,T.set(e,r);try{const o={limit:n?100:200,until:n?Math.floor(Date.now()/1e3):r.oldestTimestamp};console.log("Loading search results for query:",t,"with options:",o);const i=await async function(e,t={}){const{limit:n=100,since:r=null,until:o=null,kinds:i=null}=t,s=[{search:e}];return r&&(s[0].since=r),o&&(s[0].until=o),i&&(s[0].kinds=i),n&&(s[0].limit=n),await ah(s,{timeout:3e4})}(t,o);if(console.log("Received search results:",i.length,"events"),r.events=n?i.sort((e,t)=>t.created_at-e.created_at):[...r.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!r.oldestTimestamp||et.id===e);t&&await me(e,t.query,!1)}(t)}}async function we(){if(l&&u&&!f)try{console.log("Auto-fetching profile for:",u),await dh(),n(3,f=await sh(u)),console.log("Profile auto-loaded:",f)}catch(e){console.error("Failed to auto-load profile:",e)}}async function be(){if(l&&u)try{const e=await fetch(`/api/permissions/${u}`);if(e.ok){const t=await e.json();n(4,h=t.permission||""),console.log("User role loaded:",h),console.log("Is owner?","owner"===h)}else console.error("Failed to fetch user role:",e.status),n(4,h="")}catch(e){console.error("Error fetching user role:",e),n(4,h="")}else n(4,h="")}async function xe(){try{const e=await fetch("/api/acl-mode");if(e.ok){const t=await e.json();n(9,z=t.acl_mode||""),console.log("ACL mode loaded:",z)}else console.error("Failed to fetch ACL mode:",e.status),n(9,z="")}catch(e){console.error("Error fetching ACL mode:",e),n(9,z="")}}async function Ee(e=[]){if(l)if(0!==e.length||"admin"===h||"owner"===h)try{const t=await Ae("/api/export","POST"),n=await fetch("/api/export",{method:"POST",headers:{Authorization:t,"Content-Type":"application/json"},body:JSON.stringify({pubkeys:e})});if(!n.ok)throw new Error(`Export failed: ${n.status} ${n.statusText}`);const r=await n.blob(),o=window.URL.createObjectURL(r),i=document.createElement("a");i.href=o;const s=n.headers.get("Content-Disposition");let a="events.jsonl";if(s){const e=s.match(/filename="([^"]+)"/);e&&(a=e[1])}i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(o)}catch(e){console.error("Export failed:",e),alert("Export failed: "+e.message)}else alert("Admin or owner permission required to export all events");else alert("Please log in first")}async function ke(e=!1,t=null){if(!l||"write"!==h&&"admin"!==h&&"owner"!==h)alert("Write, admin, or owner permission required");else if(!S){n(18,S=!0),e&&(C=null);try{console.log("Loading events with authors filter:",t,"including delete events");const r=await ch({limit:e?100:200,until:e?Math.floor(Date.now()/1e3):C,authors:t});if(console.log("Received events:",r.length,"events"),t&&r.length>0){const e=r.filter(e=>e.pubkey&&e.pubkey!==u);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",r.length)}if(e?(n(7,x=r.sort((e,t)=>t.created_at-e.created_at)),ae(r)):(n(7,x=[...x,...r].sort((e,t)=>t.created_at-e.created_at)),ae(x)),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!C||e{if("events"===g){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Se()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(18,S=!1)}}}async function Se(){await ke(!1)}async function Ae(e,t){if(!l||!u)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:u};let r;if(p&&"extension"===d)try{r=await p.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==d)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return`Nostr ${btoa(o)}`}async function Ce(e,t){if(!l||!u)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:u};let r;if(p&&"extension"===d)try{r=await p.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==d)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return btoa(o)}return e.$$.update=()=>{var t;if(390&e.$$.dirty[0]&&n(34,r=(R&&l&&u?x.filter(e=>e.pubkey&&e.pubkey===u):x).sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(33,o=f?.about?(t=f.about,String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")).replace(/\n{2,}/g,"
"):""),530&e.$$.dirty[0]|65536&e.$$.dirty[2]&&n(79,i=he.filter(e=>!(e.requiresAdmin&&(!l||"admin"!==h&&"owner"!==h))&&(!(e.requiresOwner&&(!l||"owner"!==h))&&(!("sprocket"===e.id&&!H)&&(("managed-acl"!==e.id||"managed"===z)&&("managed-acl"===e.id&&console.log("Managed ACL tab check:",{isLoggedIn:l,userRole:h,requiresOwner:e.requiresOwner,aclMode:z}),!0)))))),64&e.$$.dirty[0]|131072&e.$$.dirty[2]&&n(10,s=[...i,...w]),1554&e.$$.dirty[0]|131072&e.$$.dirty[2]&&console.log("Tabs debug:",{isLoggedIn:l,userRole:h,aclMode:z,filteredBaseTabs:i.map(e=>e.id),allTabs:s.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]&&l&&u&&!f&&we(),438&e.$$.dirty[0]&&"events"===g&&l&&("write"===h||"admin"===h||"owner"===h)&&0===x.length){ke(!0,R&&u?[u]:null)}},[a,l,u,f,h,g,w,x,R,z,s,c,p,y,m,v,E,k,S,A,N,U,j,M,F,D,q,W,K,J,V,G,Z,o,r,T,Q,function(e){return X[e]||`Kind ${e}`},ee,te,ne,re,oe,ie,function(){J&&(n(28,K=null),n(30,V=[]),Y=null,n(32,Z=!0),re())},function(e){const t=V.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(l&&"owner"===h)try{n(23,M=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Ce("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(20,N=t.script_content||""),n(21,U=t),fe("Script loaded successfully","success")}else fe("Failed to load script","error")}catch(e){fe(`Error loading script: ${e.message}`,"error")}finally{n(23,M=!1)}},async function(){if(l&&"owner"===h)try{n(23,M=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:N});if(e.ok)fe("Script saved and updated successfully","success"),await ce(),await le();else{fe(`Failed to save script: ${await e.text()}`,"error")}}catch(e){fe(`Error saving script: ${e.message}`,"error")}finally{n(23,M=!1)}},async function(){if(l&&"owner"===h)try{n(23,M=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)fe("Sprocket restarted successfully","success"),await ce();else{fe(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){fe(`Error restarting sprocket: ${e.message}`,"error")}finally{n(23,M=!1)}},async function(){if(l&&"owner"===h&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(23,M=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(20,N=""),fe("Sprocket script deleted successfully","success"),await ce(),await le();else{fe(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){fe(`Error deleting script: ${e.message}`,"error")}finally{n(23,M=!1)}},le,ue,de,function(e){n(26,q=e.target.files[0])},async function(){if(l&&"owner"===h&&q)try{n(23,M=!0);const e=await q.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(20,N=e),fe("Script uploaded and updated successfully","success"),await ce(),await le();else{fe(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){fe(`Error uploading script: ${e.message}`,"error")}finally{n(23,M=!1),n(26,q=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},pe,function(){n(0,a=!a),"undefined"!=typeof localStorage&&localStorage.setItem("isDarkTheme",JSON.stringify(a))},function(){l||n(11,c=!0)},async function(e){const{method:t,pubkey:r,privateKey:o,signer:i}=e.detail;n(1,l=!0),n(2,u=r),d=t,n(12,p=i),n(11,c=!1);try{if(await dh(),"extension"===t&&i)nh.setSigner(i);else if("nsec"===t&&o){const e=new Dd(o);nh.setSigner(e)}n(3,f=await sh(r)),console.log("Profile loaded:",f)}catch(e){console.error("Failed to load profile:",e)}await be(),await xe()},function(){n(1,l=!1),n(2,u=""),d="",n(3,f=null),n(4,h=""),n(12,p=null),n(13,y=!1),P=[],n(7,x=[]),_=[],I=0,se(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(11,c=!1)},function(){n(13,y=!0)},ye,function(){n(14,m=!m),m||n(15,v="")},function(e){"Enter"===e.key&&v.trim()?(!function(e){const t=`search-${Date.now()}`,r={id:t,icon:"🔍",label:e,isSearchTab:!0,query:e};n(6,w=[...w,r]),n(5,g=t),T.set(t,{events:[],isLoading:!1,hasMore:!0,oldestTimestamp:null}),me(t,e)}(v.trim()),n(15,v=""),n(14,m=!1)):"Escape"===e.key&&(n(14,m=!1),n(15,v=""))},ge,me,ve,we,async function(){await Ee([])},async function(){await Ee([u])},function(e){n(16,E=e.target.files[0])},async function(){if(!l||"admin"!==h&&"owner"!==h)alert("Admin or owner permission required");else if(E)try{const e=await Ae("/api/import","POST"),t=new FormData;t.append("file",E);const r=await fetch("/api/import",{method:"POST",headers:{Authorization:e},body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();alert("Import started successfully"),n(16,E=null),document.getElementById("import-file").value=""}catch(e){console.error("Import failed:",e),alert("Import failed: "+e.message)}else alert("Please select a file")},ke,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&Se()},function(){try{if(!W.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(W);n(27,W=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!W.trim())return void alert("Please enter an event to sign");if(!l||!u)return void alert("Please log in to sign events");if(!p)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(W);e.pubkey=u,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await p.signEvent(e);n(27,W=JSON.stringify(t,null,2)),alert("Event signed successfully!")}catch(e){console.error("Error signing event:",e),alert("Error signing event: "+e.message)}},async function(){try{if(!W.trim())return void alert("Please enter an event to publish");if(!l)return void alert("Please log in to publish events");if(!p)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(W);if(!e.id||!e.sig)return void alert('Event must be signed before publishing. Please click "Sign" first.');const t=`wss://${window.location.host}`,n=await hp(t,e,p,u);n.success?alert("Event published successfully to ORLY relay!"):alert(`Event publishing failed: ${n.reason||"Unknown error"}`)}catch(e){console.error("Error publishing event:",e),alert("Error publishing event: "+e.message)}},H,i,function(t){$.call(this,e,t)},function(t){$.call(this,e,t)},e=>e.id===g,function(){v=this.value,n(15,v)},e=>ge(e.id),(e,t)=>"Enter"===t.key&&ge(e.id),e=>pe(e.id),e=>ne(e.id),e=>ee(e.id),(e,t)=>"Enter"===t.key&&ee(e.id),(e,t)=>og(e,t),function(){R=this.checked,n(8,R)},()=>te(),()=>{ke(!1,R&&u?[u]:null)},()=>{ke(!0,R&&u?[u]:null)},function(){W=this.value,n(27,W)},function(){N=this.value,n(20,N)},e=>ue(e),e=>de(e.name),function(){K=function(e){const t=e.querySelector(":checked");return t&&t.__value}(this),n(28,K),n(36,Q)},()=>ie(K),function(){J=b(this.value),n(29,J)},e=>oe(e),e=>me(e.id,e.query,!0),e=>ne(e.id),e=>ee(e.id),(e,t)=>"Enter"===t.key&&ee(e.id),(e,t)=>og(e,t),(e,t)=>ve(t,e.id),e=>"Escape"===e.key&&ye(),function(e){c=e,n(11,c)}]}return new class extends Q{constructor(e){super(),Y(this,e,cg,eg,i,{},null,[-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); +function Ff(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Mf(e,t){return!!Array.isArray(t)&&(0===t.length||(e?t.every(e=>"string"==typeof e):t.every(e=>Number.isSafeInteger(e))))}function Df(e,t){if("string"!=typeof t)throw new Error(`${e}: string expected`);return!0}function Hf(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function qf(e){if(!Array.isArray(e))throw new Error("array expected")}function zf(e,t){if(!Mf(!0,t))throw new Error(`${e}: array of strings expected`)}yf.BASE._setWindowSize(8);const Kf=(e,t)=>0===t?e:Kf(t,e%t),Wf=(e,t)=>e+(t-Kf(e,t)),Vf=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Jf(e,t,n,r){if(qf(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Wf(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Wf(t,n)}`);let o=0,i=0;const s=Vf[t],a=Vf[n]-1,l=[];for(const r of e){if(Hf(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${t}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)l.push((o>>i-n&a)>>>0);const e=Vf[i];if(void 0===e)throw new Error("invalid carry");o&=e-1}if(o=o<=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&l.push(o>>>0),l}const Gf=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)()?{encode:e=>(function(e,...t){if(!Ff(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}(e),e.toBase64()),decode:e=>((e,t)=>{Df("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})})(e,!1)}:function(...e){const t=e=>e,n=(e,t)=>n=>e(t(n));return{encode:e.map(e=>e.encode).reduceRight(n,t),decode:e.map(e=>e.decode).reduce(n,t)}}(function(e,t=!1){if(Hf(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Wf(8,e)>32||Wf(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Ff(n))throw new Error("radix2.encode input should be Uint8Array");return Jf(Array.from(n),8,e,!t)},decode:n=>(function(e,t){if(!Mf(!1,t))throw new Error(`${e}: array of numbers expected`)}("radix2.decode",n),Uint8Array.from(Jf(n,e,8,t)))}}(6),function(e){const t="string"==typeof e?e.split(""):e,n=t.length;zf("alphabet",t);const r=new Map(t.map((e,t)=>[e,t]));return{encode:r=>(qf(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${e}`);return t[r]})),decode:t=>(qf(t),t.map(t=>{Df("alphabet.decode",t);const n=r.get(t);if(void 0===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),function(e,t="="){return Hf(e),Df("padding",t),{encode(n){for(zf("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){zf("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--){if((r-1)*e%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}(6),function(e=""){return Df("join",e),{encode:t=>(zf("join.decode",t),t.join(e)),decode:t=>(Df("join.decode",t),t.split(e))}}(""));function Zf(e){return yf.fromHex(e).toHex().substring(2)}const Yf=new TextDecoder("utf-8"),Qf=new TextEncoder;class Xf{log=Ku.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=io;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,t,n={}){if(!Xf.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(n),this.lastCommand)throw new Error("Previous command to device still pending!");const r=jd();return this.lastCommand=r,this.sendCommand(e,t),setTimeout(()=>{r.reject(new Error("Device timeout")),this.lastCommand===r&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:t,onError:n,onDone:r}){let o,i=await window.navigator.serial.requestPort();await i.open({baudRate:9600}),await(e=>new Promise(t=>setTimeout(t,e)))(1e3),(async()=>{for(;i&&i.readable;){const e=new window.TextDecoderStream;i.readable.pipeTo(e.writable),o=e.readable.getReader();const t=this.readFromSerialPort(o);try{for(;;){const{value:e,done:n}=await t("\n");if(e){const{method:t,data:n}=this.parseResponse(e);if("/ping"===t&&this.log("Pong"),-1===Xf.PUBLIC_METHODS.indexOf(t))continue;this.log("Received: ",t,n),this.lastCommand&&(this.lastCommand.resolve(n),this.lastCommand=null)}if(n)return this.lastCommand=null,this.writer=null,void(r&&r())}}catch(e){if(e instanceof Error)throw this.writer=null,n&&n(e),this.lastCommand&&(this.lastCommand.reject(e),this.lastCommand=null),e}}})();const s=new window.TextEncoderStream;s.readable.pipeTo(i.writable),this.writer=s.writable.getWriter(),await this.sendCommand(Xf.METHOD_PING),await this.sendCommand(Xf.METHOD_PING,[window.location.host]),e&&e(),i.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,t&&t()})}async sendCommand(e,t=[]){if(!this.writer)return;this.log("Send command",e,t);const n=[e].concat(t).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(e){let t,n=[];return async(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const o=[];for(t&&(o.push(t),t=void 0);;){const{value:i,done:s}=await e.read();if(i){const e=i.split(r);if(e.length>1)return o.push(e.shift()),t=e.pop(),n=e,{value:o.join("").trim(),done:!1};o.push(i)}if(s)return{value:o.join("").trim(),done:!0}}}}parseResponse(e){const t=e.split(" ")[0];return{method:t,data:e.substring(t.length).trim()}}async nip04Encrypt(e,t){const n=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let r=Uint8Array.from(function(e=32){if(Hd&&"function"==typeof Hd.getRandomValues)return Hd.getRandomValues(new Uint8Array(e));if(Hd&&"function"==typeof Hd.randomBytes)return Uint8Array.from(Hd.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}(16)),o=Qf.encode(t),i=await crypto.subtle.importKey("raw",n,{name:"AES-CBC"},!1,["encrypt"]),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:r},i,o);return`${Gf.encode(new Uint8Array(s))}?iv=${Gf.encode(new Uint8Array(r.buffer))}`}async nip04Decrypt(e,t){let[n,r]=t.split("?iv=");const o=ef(await this.callMethodOnDevice(Xf.METHOD_SHARED_SECRET,[Zf(e)]));let i=await crypto.subtle.importKey("raw",o,{name:"AES-CBC"},!1,["decrypt"]),s=Gf.decode(n),a=Gf.decode(r),l=await crypto.subtle.decrypt({name:"AES-CBC",iv:a},i,s);return Yf.decode(l)}async getPublicKey(){const e=await this.callMethodOnDevice(Xf.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(Xf.METHOD_RESTORE,[Wd(e)])}async signEvent(e){const t=e.pubkey||this.pubkey;if(!t)throw new Error("Unknown signer pubkey");const n={...e,id:eo({...e,pubkey:t})},r=await this.callMethodOnDevice(Xf.METHOD_SIGN_MESSAGE,[n.id]),o={...n,sig:r,pubkey:t};if(!this.verifyEvent(o))throw new Error("Invalid signature");return o}ping(){this.sendCommand(Xf.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[Xf.METHOD_PUBLIC_KEY,Xf.METHOD_SIGN_MESSAGE,Xf.METHOD_SHARED_SECRET,Xf.METHOD_RESTORE]}const eh=[`wss://${window.location.host}/`];class th{constructor(){this.pool=new _n,this.eventStore=new Ud,this.isConnected=!1,this.signer=null,this.relays=[...eh]}async connect(){console.log("Starting connection to",this.relays.length,"relays...");try{this.isConnected=!0,console.log("✓ Successfully initialized relay pool"),await new Promise(e=>setTimeout(e,1e3))}catch(e){throw console.error("✗ Connection failed:",e),e}}async connectToRelay(e){console.log(`Adding relay: ${e}`);try{return this.relays.includes(e)||this.relays.push(e),console.log(`✓ Successfully added relay ${e}`),!0}catch(t){return console.error(`✗ Failed to add relay ${e}:`,t),!1}}subscribe(e,t){console.log("Creating subscription with filters:",e);const n=this.pool.subscribeMany(this.relays,e,{onevent(e){console.log("Event received:",e),t(e)},oneose(){console.log("EOSE received"),window.dispatchEvent(new CustomEvent("nostr-eose",{detail:{subscriptionId:n.id}}))}});return n}unsubscribe(e){console.log("Closing subscription"),e&&e.close&&e.close()}disconnect(){console.log("Disconnecting relay pool"),this.pool&&this.pool.close(this.relays),this.isConnected=!1}async publish(e,t=null){this.isConnected||(console.warn("Not connected to any relays, attempting to connect first"),await this.connect());try{const n=t||this.relays,r=this.pool.publish(n,e);return await Promise.allSettled(r),console.log("✓ Event published successfully"),await lh([e]),console.log("Event stored in IndexedDB"),{success:!0,okCount:1,errorCount:0}}catch(e){throw console.error("✗ Failed to publish event:",e),e}}getPool(){return this.pool}getEventStore(){return this.eventStore}getSigner(){return this.signer}setSigner(e){this.signer=e}}const nh=new th,rh="nostrCache",oh=2,ih="events";function sh(){return new Promise((e,t)=>{try{const n=indexedDB.open(rh,oh);n.onupgradeneeded=e=>{const t=n.result;e.oldVersion;let r;r=t.objectStoreNames.contains(ih)?n.transaction.objectStore(ih):t.createObjectStore(ih,{keyPath:"id"}),r.indexNames.contains("byKindAuthor")||r.createIndex("byKindAuthor",["kind","pubkey"],{unique:!1}),r.indexNames.contains("byKindAuthorCreated")||r.createIndex("byKindAuthorCreated",["kind","pubkey","created_at"],{unique:!1}),r.indexNames.contains("byKind")||r.createIndex("byKind","kind",{unique:!1}),r.indexNames.contains("byAuthor")||r.createIndex("byAuthor","pubkey",{unique:!1}),r.indexNames.contains("byCreatedAt")||r.createIndex("byCreatedAt","created_at",{unique:!1})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}catch(e){console.error("Failed to open IndexedDB",e),t(e)}})}async function ah(e){try{const t=await sh();await new Promise((n,r)=>{const o=t.transaction(ih,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error),o.objectStore(ih).put(e)})}catch(e){console.warn("IDB putEvent failed",e)}}async function lh(e){if(e&&0!==e.length)try{const t=await sh();await new Promise((n,r)=>{const o=t.transaction(ih,"readwrite");o.oncomplete=()=>n(),o.onerror=()=>r(o.error);const i=o.objectStore(ih);for(const t of e)i.put(t)}),console.log(`Stored ${e.length} events in IndexedDB`)}catch(e){console.warn("IDB putEvents failed",e)}}async function ch(e){try{const t=await sh(),n=[];console.log("QueryEventsFromDB: Starting query with filters:",e);for(const r of e){console.log("QueryEventsFromDB: Processing filter:",r);const e=await new Promise((e,n)=>{const o=t.transaction(ih,"readonly").objectStore(ih),i=[];let s;if(r.kinds&&r.kinds.length>0&&r.authors&&r.authors.length>0){const e=r.kinds[0],t=r.authors[0];console.log(`QueryEventsFromDB: Using byKindAuthorCreated index for kind=${e}, author=${t.substring(0,8)}...`);const n=o.index("byKindAuthorCreated"),i=IDBKeyRange.bound([e,t,-1/0],[e,t,1/0]);s=n.openCursor(i,"prev")}else if(r.kinds&&r.kinds.length>0){console.log(`QueryEventsFromDB: Using byKind index for kind=${r.kinds[0]}`);const e=o.index("byKind");s=e.openCursor(IDBKeyRange.only(r.kinds[0]))}else if(r.authors&&r.authors.length>0){console.log(`QueryEventsFromDB: Using byAuthor index for author=${r.authors[0].substring(0,8)}...`);const e=o.index("byAuthor");s=e.openCursor(IDBKeyRange.only(r.authors[0]))}else console.log("QueryEventsFromDB: Scanning all events (no specific index)"),s=o.openCursor();s.onsuccess=t=>{const n=t.target.result;if(n){const t=n.value;let o=!0;if(r.kinds&&r.kinds.length>0&&!r.kinds.includes(t.kind)&&(o=!1),r.authors&&r.authors.length>0&&!r.authors.includes(t.pubkey)&&(o=!1),r.since&&t.created_atr.until&&(o=!1),r.ids&&r.ids.length>0&&!r.ids.includes(t.id)&&(o=!1),o&&i.push(t),r.limit&&i.length>=r.limit)return console.log(`QueryEventsFromDB: Reached limit of ${r.limit}, found ${i.length} matching events`),void e(i);n.continue()}else console.log(`QueryEventsFromDB: Cursor exhausted, found ${i.length} matching events`),e(i)},s.onerror=()=>{console.error("QueryEventsFromDB: Cursor error:",s.error),n(s.error)}});console.log(`QueryEventsFromDB: Found ${e.length} events for this filter`),n.push(...e)}return n.sort((e,t)=>t.created_at-e.created_at),console.log(`QueryEventsFromDB: Returning ${n.length} total events`),n}catch(e){return console.error("QueryEventsFromDB failed:",e),[]}}function uh(e){try{const t=JSON.parse(e.content||"{}");return{name:t.name||t.display_name||"",picture:t.picture||"",banner:t.banner||"",about:t.about||"",nip05:t.nip05||"",lud16:t.lud16||t.lud06||""}}catch(e){return{name:"",picture:"",banner:"",about:"",nip05:"",lud16:""}}}async function dh(e){console.log(`Starting profile fetch for pubkey: ${e}`);try{const t=await async function(e){try{const t=await sh();return await new Promise((n,r)=>{const o=t.transaction(ih,"readonly").objectStore(ih).index("byKindAuthorCreated"),i=IDBKeyRange.bound([0,e,-1/0],[0,e,1/0]),s=o.openCursor(i,"prev");s.onsuccess=()=>{const e=s.result;n(e?e.value:null)},s.onerror=()=>r(s.error)})}catch(e){return console.warn("IDB getLatestProfileEvent failed",e),null}}(e);if(t){console.log("Using cached profile event");return uh(t)}}catch(e){console.warn("Failed to load cached profile",e)}try{const t=[{kinds:[0],authors:[e],limit:1}],n=await fh(t,{timeout:1e4});if(n.length>0){const t=n[0];console.log("Profile fetched:",t),await ah(t);try{console.log("Publishing profile event to local relay:",t.id),await nh.publish(t),console.log("Profile event successfully saved to local relay")}catch(e){console.warn("Failed to publish profile to local relay:",e)}const r=uh(t);try{"undefined"!=typeof window&&window.dispatchEvent&&window.dispatchEvent(new CustomEvent("profile-updated",{detail:{pubkey:e,profile:r,event:t}}))}catch(e){console.warn("Failed to dispatch profile-updated event",e)}return r}throw new Error("No profile found")}catch(e){throw console.error("Failed to fetch profile:",e),e}}async function fh(e,t={}){console.log("Starting event fetch with filters:",JSON.stringify(e,null,2)),console.log("Current relays:",nh.relays),nh.isConnected&&0!==nh.relays.length||(console.warn("Client not connected, initializing..."),await gh());const{timeout:n=3e4,useCache:r=!0}=t;if(r)try{const t=await ch(e);t.length>0&&console.log(`Found ${t.length} cached events in IndexedDB`)}catch(e){console.warn("Failed to query cached events",e)}return new Promise((t,r)=>{const o=[],i=setTimeout(()=>{console.log(`Timeout reached after ${n}ms, returning ${o.length} events`),sub.close(),o.length>0&&lh(o).catch(e=>console.warn("Failed to cache events",e)),t(o)},n);try{const n=Math.random().toString(36).substring(7);console.log(`📤 REQ [${n}]:`,JSON.stringify(["REQ",n,...e],null,2));const r=nh.pool.subscribeMany(nh.relays,e,{onevent(e){console.log(`📥 EVENT received for REQ [${n}]:`,{id:e.id?.substring(0,8)+"...",kind:e.kind,pubkey:e.pubkey?.substring(0,8)+"...",created_at:e.created_at,content_preview:e.content?.substring(0,50)}),o.push(e),ah(e).catch(e=>console.warn("Failed to cache event",e))},oneose(){console.log(`✅ EOSE received for REQ [${n}], got ${o.length} events`),clearTimeout(i),r.close(),o.length>0&&lh(o).catch(e=>console.warn("Failed to cache events",e)),t(o)}})}catch(e){clearTimeout(i),console.error("Failed to fetch events:",e),r(e)}})}async function hh(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching event by ID: ${e}`);try{const t=[{ids:[e]}];console.log("Fetching event with filters:",t);const r=await fh(t,{timeout:n});return console.log(`Fetched ${r.length} events`),r.length>0?r[0]:null}catch(e){throw console.error("Failed to fetch event by ID:",e),e}}async function ph(e,t={}){const{timeout:n=1e4}=t;console.log(`Fetching delete events for target: ${e}`);try{const t=[{kinds:[5],"#e":[e]}];console.log("Fetching delete events with filters:",t);const r=await fh(t,{timeout:n});return console.log(`Fetched ${r.length} delete events`),r}catch(e){throw console.error("Failed to fetch delete events:",e),e}}async function gh(){await nh.connect()}async function mh(){try{const e=await sh(),t=e.transaction(ih,"readonly").objectStore(ih),n=await new Promise((e,n)=>{const r=t.getAll();r.onsuccess=()=>e(r.result),r.onerror=()=>n(r.error)}),r=n.reduce((e,t)=>(e[t.kind]=(e[t.kind]||0)+1,e),{});return console.log("===== IndexedDB Contents ====="),console.log(`Total events: ${n.length}`),console.log("Events by kind:",r),console.log("Kind 0 events:",n.filter(e=>0===e.kind)),console.log("All event IDs:",n.map(e=>({id:e.id.substring(0,8),kind:e.kind,pubkey:e.pubkey.substring(0,8)}))),console.log("=============================="),{total:n.length,byKind:r,events:n}}catch(e){return console.error("Failed to debug IndexedDB:",e),null}}const{window:yh}=l;function vh(e){let t,n,o,i,s,a,l,f,p,m,b,E,x,k,C,A,T,_;function I(e,t){return"extension"===e[2]?bh:wh}let $=I(e),R=$(e),O=e[5]&&Eh(e),P=e[6]&&xh(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Login to Nostr",s=g(),a=h("button"),a.textContent="×",l=g(),f=h("div"),p=h("div"),m=h("button"),m.textContent="Extension",b=g(),E=h("button"),E.textContent="Nsec",x=g(),k=h("div"),R.c(),C=g(),O&&O.c(),A=g(),P&&P.c(),w(i,"class","svelte-1wl3v5c"),w(a,"class","close-btn svelte-1wl3v5c"),w(o,"class","modal-header svelte-1wl3v5c"),w(m,"class","tab-btn svelte-1wl3v5c"),S(m,"active","extension"===e[2]),w(E,"class","tab-btn svelte-1wl3v5c"),S(E,"active","nsec"===e[2]),w(p,"class","tabs svelte-1wl3v5c"),w(k,"class","tab-content svelte-1wl3v5c"),w(f,"class","tab-container svelte-1wl3v5c"),w(n,"class","modal svelte-1wl3v5c"),S(n,"dark-theme",e[1]),w(t,"class","modal-overlay svelte-1wl3v5c"),w(t,"role","button"),w(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),c(f,p),c(p,m),c(p,b),c(p,E),c(f,x),c(f,k),R.m(k,null),c(k,C),O&&O.m(k,null),c(k,A),P&&P.m(k,null),T||(_=[y(a,"click",e[7]),y(m,"click",e[14]),y(E,"click",e[15]),y(n,"click",v(e[12])),y(n,"keydown",v(e[13])),y(t,"click",e[7]),y(t,"keydown",e[17])],T=!0)},p(e,t){4&t&&S(m,"active","extension"===e[2]),4&t&&S(E,"active","nsec"===e[2]),$===($=I(e))&&R?R.p(e,t):(R.d(1),R=$(e),R&&(R.c(),R.m(k,C))),e[5]?O?O.p(e,t):(O=Eh(e),O.c(),O.m(k,A)):O&&(O.d(1),O=null),e[6]?P?P.p(e,t):(P=xh(e),P.c(),P.m(k,null)):P&&(P.d(1),P=null),2&t&&S(n,"dark-theme",e[1])},d(e){e&&d(t),R.d(),O&&O.d(),P&&P.d(),T=!1,r(_)}}}function wh(e){let t,n,o,i,s,a,l,f,m,v,b=e[4]?"Logging in...":"Log in with nsec";return{c(){t=h("div"),n=h("p"),n.textContent="Enter your nsec (private key) to login. This\n will be stored securely in your browser.",o=g(),i=h("input"),s=g(),a=h("button"),l=p(b),w(n,"class","svelte-1wl3v5c"),w(i,"type","password"),w(i,"placeholder","nsec1..."),i.disabled=e[4],w(i,"class","nsec-input svelte-1wl3v5c"),w(a,"class","login-nsec-btn svelte-1wl3v5c"),a.disabled=f=e[4]||!e[3].trim(),w(t,"class","nsec-login svelte-1wl3v5c")},m(r,d){u(r,t,d),c(t,n),c(t,o),c(t,i),x(i,e[3]),c(t,s),c(t,a),c(a,l),m||(v=[y(i,"input",e[16]),y(a,"click",e[10])],m=!0)},p(e,t){16&t&&(i.disabled=e[4]),8&t&&i.value!==e[3]&&x(i,e[3]),16&t&&b!==(b=e[4]?"Logging in...":"Log in with nsec")&&E(l,b),24&t&&f!==(f=e[4]||!e[3].trim())&&(a.disabled=f)},d(e){e&&d(t),m=!1,r(v)}}}function bh(e){let t,n,r,o,i,s,a,l=e[4]?"Connecting...":"Log in using extension";return{c(){t=h("div"),n=h("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",r=g(),o=h("button"),i=p(l),w(n,"class","svelte-1wl3v5c"),w(o,"class","login-extension-btn svelte-1wl3v5c"),o.disabled=e[4],w(t,"class","extension-login svelte-1wl3v5c")},m(l,d){u(l,t,d),c(t,n),c(t,r),c(t,o),c(o,i),s||(a=y(o,"click",e[9]),s=!0)},p(e,t){16&t&&l!==(l=e[4]?"Connecting...":"Log in using extension")&&E(i,l),16&t&&(o.disabled=e[4])},d(e){e&&d(t),s=!1,a()}}}function Eh(e){let t,n;return{c(){t=h("div"),n=p(e[5]),w(t,"class","message error-message svelte-1wl3v5c")},m(e,r){u(e,t,r),c(t,n)},p(e,t){32&t&&E(n,e[5])},d(e){e&&d(t)}}}function xh(e){let t,n;return{c(){t=h("div"),n=p(e[6]),w(t,"class","message success-message svelte-1wl3v5c")},m(e,r){u(e,t,r),c(t,n)},p(e,t){64&t&&E(n,e[6])},d(e){e&&d(t)}}}function kh(t){let n,r,o,i=t[0]&&vh(t);return{c(){i&&i.c(),n=m()},m(e,s){i&&i.m(e,s),u(e,n,s),r||(o=y(yh,"keydown",t[11]),r=!0)},p(e,[t]){e[0]?i?i.p(e,t):(i=vh(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&d(n),r=!1,o()}}}function Sh(e,t,n){const r=_();let{showModal:o=!1}=t,{isDarkTheme:i=!1}=t,s="extension",a="",l=!1,c="",u="";function d(){n(0,o=!1),n(3,a=""),n(5,c=""),n(6,u=""),r("close")}function f(e){n(2,s=e),n(5,c=""),n(6,u="")}async function h(){n(4,l=!0),n(5,c=""),n(6,u="");try{if(!a.trim())throw new Error("Please enter your nsec");if(!(e=a.trim()).startsWith("nsec1")||(e.length<60||e.length>70))throw new Error('Invalid nsec format. Must start with "nsec1"');const t=Dd.fromKey(a.trim()),o=await t.getPublicKey();localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",o),localStorage.setItem("nostr_privkey",a.trim()),n(6,u="Successfully logged in with nsec!"),r("login",{method:"nsec",pubkey:o,privateKey:a.trim(),signer:t}),setTimeout(()=>{d()},1500)}catch(e){n(5,c=e.message)}finally{n(4,l=!1)}var e}return e.$$set=e=>{"showModal"in e&&n(0,o=e.showModal),"isDarkTheme"in e&&n(1,i=e.isDarkTheme)},[o,i,s,a,l,c,u,d,f,async function(){n(4,l=!0),n(5,c=""),n(6,u="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(6,u="Successfully logged in with extension!"),r("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{d()},1500))}catch(e){n(5,c=e.message)}finally{n(4,l=!1)}},h,function(e){"Escape"===e.key&&d(),"Enter"===e.key&&"nsec"===s&&h()},function(t){I.call(this,e,t)},function(t){I.call(this,e,t)},()=>f("extension"),()=>f("nsec"),function(){a=this.value,n(3,a)},e=>"Escape"===e.key&&d()]}class Ch extends Q{constructor(e){super(),Y(this,e,Sh,kh,i,{showModal:0,isDarkTheme:1})}}function Ah(e,t,n){const r=e.slice();return r[72]=t[n],r}function Th(e,t,n){const r=e.slice();return r[75]=t[n],r}function _h(e,t,n){const r=e.slice();return r[72]=t[n],r}function Ih(e,t,n){const r=e.slice();return r[72]=t[n],r}function $h(e,t,n){const r=e.slice();return r[72]=t[n],r}function Rh(e,t,n){const r=e.slice();return r[72]=t[n],r}function Oh(e,t,n){const r=e.slice();return r[72]=t[n],r}function Ph(e){let t,n,r;return{c(){t=h("div"),n=p(e[3]),w(t,"class",r="message "+e[4]+" svelte-1smaj3x")},m(e,r){u(e,t,r),c(t,n)},p(e,o){8&o[0]&&E(n,e[3]),16&o[0]&&r!==(r="message "+e[4]+" svelte-1smaj3x")&&w(t,"class",r)},d(e){e&&d(t)}}}function Bh(e){let t,n,o,i,s,a,l,f,m,v,b,E,k,S,C,A,T,_,I,$,R,O,P,B,N,L,U,j;function F(e,t){return e[5]&&e[5].length>0?Lh:Nh}let M=F(e),D=M(e);function H(e,t){return e[8]&&e[8].length>0?Mh:Fh}let q=H(e),z=q(e);return{c(){t=h("div"),n=h("div"),o=h("h3"),o.textContent="Banned Pubkeys",i=g(),s=h("div"),a=h("input"),l=g(),f=h("input"),m=g(),v=h("button"),b=p("Ban Pubkey"),E=g(),k=h("div"),D.c(),S=g(),C=h("div"),A=h("h3"),A.textContent="Allowed Pubkeys",T=g(),_=h("div"),I=h("input"),$=g(),R=h("input"),O=g(),P=h("button"),B=p("Allow Pubkey"),N=g(),L=h("div"),z.c(),w(o,"class","svelte-1smaj3x"),w(a,"type","text"),w(a,"placeholder","Pubkey (64 hex chars)"),w(a,"class","svelte-1smaj3x"),w(f,"type","text"),w(f,"placeholder","Reason (optional)"),w(f,"class","svelte-1smaj3x"),v.disabled=e[2],w(v,"class","svelte-1smaj3x"),w(s,"class","add-form svelte-1smaj3x"),w(k,"class","list svelte-1smaj3x"),w(n,"class","section svelte-1smaj3x"),w(A,"class","svelte-1smaj3x"),w(I,"type","text"),w(I,"placeholder","Pubkey (64 hex chars)"),w(I,"class","svelte-1smaj3x"),w(R,"type","text"),w(R,"placeholder","Reason (optional)"),w(R,"class","svelte-1smaj3x"),P.disabled=e[2],w(P,"class","svelte-1smaj3x"),w(_,"class","add-form svelte-1smaj3x"),w(L,"class","list svelte-1smaj3x"),w(C,"class","section svelte-1smaj3x"),w(t,"class","pubkeys-section")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),x(a,e[6]),c(s,l),c(s,f),x(f,e[7]),c(s,m),c(s,v),c(v,b),c(n,E),c(n,k),D.m(k,null),c(t,S),c(t,C),c(C,A),c(C,T),c(C,_),c(_,I),x(I,e[9]),c(_,$),c(_,R),x(R,e[10]),c(_,O),c(_,P),c(P,B),c(C,N),c(C,L),z.m(L,null),U||(j=[y(a,"input",e[43]),y(f,"input",e[44]),y(v,"click",e[25]),y(I,"input",e[45]),y(R,"input",e[46]),y(P,"click",e[26])],U=!0)},p(e,t){64&t[0]&&a.value!==e[6]&&x(a,e[6]),128&t[0]&&f.value!==e[7]&&x(f,e[7]),4&t[0]&&(v.disabled=e[2]),M===(M=F(e))&&D?D.p(e,t):(D.d(1),D=M(e),D&&(D.c(),D.m(k,null))),512&t[0]&&I.value!==e[9]&&x(I,e[9]),1024&t[0]&&R.value!==e[10]&&x(R,e[10]),4&t[0]&&(P.disabled=e[2]),q===(q=H(e))&&z?z.p(e,t):(z.d(1),z=q(e),z&&(z.c(),z.m(L,null)))},d(e){e&&d(t),D.d(),z.d(),U=!1,r(j)}}}function Nh(t){let n;return{c(){n=h("div"),n.innerHTML="

No banned pubkeys configured.

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

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

No banned events configured.

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

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

No blocked IPs configured.

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

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

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

No events need moderation at this time.

",w(n,"class","no-items svelte-1smaj3x")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function lp(e){let t,n=e[21],r=[];for(let t=0;tManaged ACL Configuration \n

Configure access control using NIP-86 management API

\n
Owner Only: This interface is restricted to relay owners\n only.
',i=g(),J&&J.c(),s=g(),a=h("div"),l=h("button"),f=p("Pubkeys"),v=g(),b=h("button"),E=p("Events"),k=g(),S=h("button"),C=p("IPs"),T=g(),_=h("button"),I=p("Kinds"),R=g(),O=h("button"),P=p("Moderation"),N=g(),L=h("button"),U=p("Relay Config"),F=g(),M=h("div"),G&&G.c(),D=g(),Z&&Z.c(),H=g(),Y&&Y.c(),q=g(),Q&&Q.c(),z=g(),X&&X.c(),K=g(),ee&&ee.c(),w(o,"class","header svelte-1smaj3x"),w(l,"class",m="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1smaj3x"),w(b,"class",x="tab "+("events"===t[1]?"active":"")+" svelte-1smaj3x"),w(S,"class",A="tab "+("ips"===t[1]?"active":"")+" svelte-1smaj3x"),w(_,"class",$="tab "+("kinds"===t[1]?"active":"")+" svelte-1smaj3x"),w(O,"class",B="tab "+("moderation"===t[1]?"active":"")+" svelte-1smaj3x"),w(L,"class",j="tab "+("relay"===t[1]?"active":"")+" svelte-1smaj3x"),w(a,"class","tabs svelte-1smaj3x"),w(M,"class","tab-content svelte-1smaj3x")},m(e,r){u(e,n,r),c(n,o),c(n,i),J&&J.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,v),c(a,b),c(b,E),c(a,k),c(a,S),c(S,C),c(a,T),c(a,_),c(_,I),c(a,R),c(a,O),c(O,P),c(a,N),c(a,L),c(L,U),c(n,F),c(n,M),G&&G.m(M,null),c(M,D),Z&&Z.m(M,null),c(M,H),Y&&Y.m(M,null),c(M,q),Q&&Q.m(M,null),c(M,z),X&&X.m(M,null),c(M,K),ee&&ee.m(M,null),W||(V=[y(l,"click",t[37]),y(b,"click",t[38]),y(S,"click",t[39]),y(_,"click",t[40]),y(O,"click",t[41]),y(L,"click",t[42])],W=!0)},p(e,t){e[3]?J?J.p(e,t):(J=Ph(e),J.c(),J.m(n,s)):J&&(J.d(1),J=null),2&t[0]&&m!==(m="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1smaj3x")&&w(l,"class",m),2&t[0]&&x!==(x="tab "+("events"===e[1]?"active":"")+" svelte-1smaj3x")&&w(b,"class",x),2&t[0]&&A!==(A="tab "+("ips"===e[1]?"active":"")+" svelte-1smaj3x")&&w(S,"class",A),2&t[0]&&$!==($="tab "+("kinds"===e[1]?"active":"")+" svelte-1smaj3x")&&w(_,"class",$),2&t[0]&&B!==(B="tab "+("moderation"===e[1]?"active":"")+" svelte-1smaj3x")&&w(O,"class",B),2&t[0]&&j!==(j="tab "+("relay"===e[1]?"active":"")+" svelte-1smaj3x")&&w(L,"class",j),"pubkeys"===e[1]?G?G.p(e,t):(G=Bh(e),G.c(),G.m(M,D)):G&&(G.d(1),G=null),"events"===e[1]?Z?Z.p(e,t):(Z=qh(e),Z.c(),Z.m(M,H)):Z&&(Z.d(1),Z=null),"ips"===e[1]?Y?Y.p(e,t):(Y=Yh(e),Y.c(),Y.m(M,q)):Y&&(Y.d(1),Y=null),"kinds"===e[1]?Q?Q.p(e,t):(Q=np(e),Q.c(),Q.m(M,z)):Q&&(Q.d(1),Q=null),"moderation"===e[1]?X?X.p(e,t):(X=sp(e),X.c(),X.m(M,K)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=dp(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&d(n),J&&J.d(),G&&G.d(),Z&&Z.d(),Y&&Y.d(),Q&&Q.d(),X&&X.d(),ee&&ee.d(),W=!1,r(V)}}}function gp(e,t,n){let{userSigner:r}=t,{userPubkey:o}=t,i="pubkeys",s=!1,a="",l="info",c=[],u="",d="",f=[],h="",p="",g=[],m="",y="",v="",w="",E=[],x="",k="",S=[],C="",A=[],_={relay_name:"",relay_description:"",relay_icon:""};var I;async function $(){try{n(2,s=!0),console.log("Fetching relay info from /");const e=await fetch(window.location.origin+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,_={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",_),console.log("Loaded relay info:",t),n(3,a="Relay configuration loaded successfully"),n(4,l="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,a=`Failed to fetch relay info: ${e.status}`),n(4,l="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,a=`Failed to fetch relay info: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}}async function R(e,t=[]){try{n(2,s=!0),n(3,a="");const i={method:e,params:t},l=await async function(e,t){if(!r)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!o)throw new Error("No user pubkey available for authentication.");const n=window.location.origin+t,i={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:o},s=await r.signEvent(i),a=JSON.stringify(s);return`Nostr ${btoa(a)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:l},body:JSON.stringify(i)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,a=e.message),n(4,l="error"),e}finally{n(2,s=!1)}}async function O(){try{n(5,c=await R("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function P(){try{n(8,f=await R("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function B(){try{n(11,g=await R("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function N(){try{n(16,E=await R("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function L(){try{n(19,S=await R("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function U(){try{n(2,s=!0),n(21,A=await R("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",A)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,a=`Failed to load moderation events: ${e.message}`),n(4,l="error"),n(21,A=[])}finally{n(2,s=!1)}}async function j(e){try{await R("disallowkind",[e]),n(3,a="Kind disallowed successfully"),n(4,l="success"),await L()}catch(e){console.error("Failed to disallow kind:",e)}}async function F(e){try{await R("allowevent",[e,"Approved from moderation queue"]),n(3,a="Event allowed successfully"),n(4,l="success"),await U()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function M(e){try{await R("banevent",[e,"Banned from moderation queue"]),n(3,a="Event banned successfully"),n(4,l="success"),await U()}catch(e){console.error("Failed to ban event from moderation:",e)}}I=()=>{setTimeout(()=>{$()},100)},T().$$.on_mount.push(I),async function(){await Promise.all([O(),P(),B(),N(),L()])}();return e.$$set=e=>{"userSigner"in e&&n(35,r=e.userSigner),"userPubkey"in e&&n(36,o=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",_)},[_,i,s,a,l,c,u,d,f,h,p,g,m,y,v,w,E,x,k,S,C,A,[],$,U,async function(){if(u)try{await R("banpubkey",[u,d]),n(3,a="Pubkey banned successfully"),n(4,l="success"),n(6,u=""),n(7,d=""),await O()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(h)try{await R("allowpubkey",[h,p]),n(3,a="Pubkey allowed successfully"),n(4,l="success"),n(9,h=""),n(10,p=""),await P()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await R("banevent",[m,y]),n(3,a="Event banned successfully"),n(4,l="success"),n(12,m=""),n(13,y=""),await B()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(v)try{await R("allowevent",[v,w]),n(3,a="Event allowed successfully"),n(4,l="success"),n(14,v=""),n(15,w="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(x)try{await R("blockip",[x,k]),n(3,a="IP blocked successfully"),n(4,l="success"),n(17,x=""),n(18,k=""),await N()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!C)return;const e=parseInt(C);if(isNaN(e))return n(3,a="Invalid kind number"),void n(4,l="error");try{await R("allowkind",[e]),n(3,a="Kind allowed successfully"),n(4,l="success"),n(20,C=""),await L()}catch(e){console.error("Failed to allow kind:",e)}},j,async function(){try{n(2,s=!0),n(3,a="");const e=[];if(_.relay_name&&e.push(R("changerelayname",[_.relay_name])),_.relay_description&&e.push(R("changerelaydescription",[_.relay_description])),_.relay_icon&&e.push(R("changerelayicon",[_.relay_icon])),0===e.length)return n(3,a="No changes to update"),void n(4,l="info");await Promise.all(e),n(3,a="Relay configuration updated successfully"),n(4,l="success"),await $()}catch(e){console.error("Failed to update relay configuration:",e),n(3,a=`Failed to update relay configuration: ${e.message}`),n(4,l="error")}finally{n(2,s=!1)}},F,M,r,o,()=>n(1,i="pubkeys"),()=>n(1,i="events"),()=>n(1,i="ips"),()=>n(1,i="kinds"),()=>{n(1,i="moderation"),A&&0!==A.length||U()},()=>n(1,i="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){h=this.value,n(9,h)},function(){p=this.value,n(10,p)},function(){m=this.value,n(12,m)},function(){y=this.value,n(13,y)},function(){v=this.value,n(14,v)},function(){w=this.value,n(15,w)},function(){x=this.value,n(17,x)},function(){k=this.value,n(18,k)},function(){C=b(this.value),n(20,C)},e=>j(e),e=>F(e.id),e=>M(e.id),function(){_.relay_name=this.value,n(0,_)},function(){_.relay_description=this.value,n(0,_)},function(){_.relay_icon=this.value,n(0,_)}]}class mp extends Q{constructor(e){super(),Y(this,e,gp,pp,i,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}class yp{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,r,o]=n;e&&r?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!r&&(console.error("Authentication failed:",o),this.authPromise&&(this.authPromise.reject(new Error(o||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const r=["EVENT",e];this.ws.send(JSON.stringify(r));const o=this.ws.onmessage,i=setTimeout(()=>{this.ws.onmessage=o,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async r=>{try{const s=JSON.parse(r.data),[a,l,c,u]=s;if("OK"===a&&l===e.id)if(clearTimeout(i),this.ws.onmessage=o,c)console.log("Event published successfully:",l),t({success:!0,eventId:l,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required")){console.log("Authentication required, attempting to authenticate...");try{await this.authenticate();const t=["EVENT",e];return void this.ws.send(JSON.stringify(t))}catch(e){return void n(new Error(`Authentication failed: ${e.message}`))}}n(new Error(`Publish failed: ${u}`))}else await this.handleMessage(s)}catch(e){clearTimeout(i),this.ws.onmessage=o,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function vp(e,t,n,r){const o=new yp(e,n,r);try{await o.connect();return await o.publishEvent(t)}finally{o.close()}}function wp(e,t,n){const r=e.slice();return r[160]=t[n],r}function bp(e,t,n){const r=e.slice();return r[145]=t[n],r}function Ep(e,t,n){const r=e.slice();r[145]=t[n];const o=r[45](r[145]);return r[154]=o,r}function xp(e,t,n){const r=e.slice();return r[157]=t[n],r}function kp(e,t,n){const r=e.slice();return r[151]=t[n],r}function Sp(e,t,n){const r=e.slice();return r[145]=t[n],r}function Cp(e,t,n){const r=e.slice();return r[148]=t[n],r}function Ap(e,t,n){const r=e.slice();return r[165]=t[n],r}function Tp(e){let t,n,r,o=e[1]&&e[4]&&Ip(e);return{c(){t=h("div"),n=h("span"),r=p("ORLY? dashboard\n "),o&&o.c(),w(n,"class","app-title svelte-1mgoo1i"),w(t,"class","header-title svelte-1mgoo1i")},m(e,i){u(e,t,i),c(t,n),c(n,r),o&&o.m(n,null)},p(e,t){e[1]&&e[4]?o?o.p(e,t):(o=Ip(e),o.c(),o.m(n,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function _p(e){let t,n,o,i;return{c(){t=h("div"),n=h("input"),w(n,"type","text"),w(n,"class","search-input svelte-1mgoo1i"),w(n,"placeholder","Search..."),w(t,"class","search-input-container svelte-1mgoo1i")},m(r,s){u(r,t,s),c(t,n),x(n,e[15]),o||(i=[y(n,"input",e[83]),y(n,"keydown",e[64])],o=!0)},p(e,t){32768&t[0]&&n.value!==e[15]&&x(n,e[15])},d(e){e&&d(t),o=!1,r(i)}}}function Ip(e){let t,n;return{c(){t=h("span"),n=p(e[4]),w(t,"class","permission-badge svelte-1mgoo1i")},m(e,r){u(e,t,r),c(t,n)},p(e,t){16&t[0]&&E(n,e[4])},d(e){e&&d(t)}}}function $p(t){let n,r,o;return{c(){n=h("button"),n.textContent="Log in",w(n,"class","login-btn svelte-1mgoo1i")},m(e,i){u(e,n,i),r||(o=y(n,"click",t[57]),r=!0)},p:e,d(e){e&&d(n),r=!1,o()}}}function Rp(e){let t,n,r,o,i,s,a,l=(e[3]?.name||e[2].slice(0,8)+"...")+"";function f(e,t){return e[3]?.picture?Pp:Op}let m=f(e),v=m(e);return{c(){t=h("div"),n=h("button"),v.c(),r=g(),o=h("span"),i=p(l),w(o,"class","user-name svelte-1mgoo1i"),w(n,"class","user-profile-btn svelte-1mgoo1i"),w(t,"class","user-info svelte-1mgoo1i")},m(l,d){u(l,t,d),c(t,n),v.m(n,null),c(n,r),c(n,o),c(o,i),s||(a=y(n,"click",e[61]),s=!0)},p(e,t){m===(m=f(e))&&v?v.p(e,t):(v.d(1),v=m(e),v&&(v.c(),v.m(n,r))),12&t[0]&&l!==(l=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(i,l)},d(e){e&&d(t),v.d(),s=!1,a()}}}function Op(t){let n;return{c(){n=h("div"),n.textContent="👤",w(n,"class","user-avatar-placeholder svelte-1mgoo1i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Pp(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||w(t,"src",n),w(t,"alt","User avatar"),w(t,"class","user-avatar svelte-1mgoo1i")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&w(t,"src",n)},d(e){e&&d(t)}}}function Bp(e){let t,n,o;function i(){return e[84](e[165])}function s(...t){return e[85](e[165],...t)}return{c(){t=h("span"),t.textContent="✕",w(t,"class","tab-close-icon svelte-1mgoo1i"),w(t,"role","button"),w(t,"tabindex","0")},m(e,r){u(e,t,r),n||(o=[y(t,"click",v(i)),y(t,"keydown",s)],n=!0)},p(t,n){e=t},d(e){e&&d(t),n=!1,r(o)}}}function Np(e){let t,n,r,o,i,s,a,l,f,m,v=e[165].icon+"",b=e[165].label+"",x=e[165].isSearchTab&&Bp(e);function k(){return e[86](e[165])}return{c(){t=h("button"),n=h("span"),r=p(v),o=g(),i=h("span"),s=p(b),a=g(),x&&x.c(),l=g(),w(n,"class","tab-icon svelte-1mgoo1i"),w(i,"class","tab-label svelte-1mgoo1i"),w(t,"class","tab svelte-1mgoo1i"),S(t,"active",e[5]===e[165].id)},m(e,d){u(e,t,d),c(t,n),c(n,r),c(t,o),c(t,i),c(i,s),c(t,a),x&&x.m(t,null),c(t,l),f||(m=y(t,"click",k),f=!0)},p(n,o){e=n,1024&o[0]&&v!==(v=e[165].icon+"")&&E(r,v),1024&o[0]&&b!==(b=e[165].label+"")&&E(s,b),e[165].isSearchTab?x?x.p(e,o):(x=Bp(e),x.c(),x.m(t,l)):x&&(x.d(1),x=null),1056&o[0]&&S(t,"active",e[5]===e[165].id)},d(e){e&&d(t),x&&x.d(),f=!1,m()}}}function Lp(t){let n;function r(e,t){return e[1]?Wp:Kp}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),w(n,"class","welcome-message svelte-1mgoo1i")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function Up(t){let n,r=t[6],o=[];for(let e=0;e=0||""!==t[29]&&parseInt(t[29])>=0,P=t[36],B=[];for(let e=0;eEvent Recovery \n

Search and recover old versions of replaceable events

',i=g(),s=h("div"),a=h("div"),l=h("div"),p=h("label"),p.textContent="Select Event Kind:",m=g(),v=h("select"),E=h("option"),E.textContent="Choose a replaceable kind...";for(let e=0;et[99].call(v)),w(l,"class","kind-selector svelte-1mgoo1i"),w(A,"for","custom-kind"),w(A,"class","svelte-1mgoo1i"),w(_,"id","custom-kind"),w(_,"type","number"),w(_,"placeholder","e.g., 10001"),w(_,"min","0"),w(_,"class","svelte-1mgoo1i"),w(C,"class","custom-kind-input svelte-1mgoo1i"),w(a,"class","recovery-controls svelte-1mgoo1i"),w(s,"class","recovery-controls-card svelte-1mgoo1i"),w(n,"class","recovery-tab svelte-1mgoo1i")},m(e,r){u(e,n,r),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(l,p),c(l,m),c(l,v),c(v,E);for(let e=0;e=0||""!==e[29]&&parseInt(e[29])>=0),O?N?N.p(e,t):(N=rg(e),N.c(),N.m(n,null)):N&&(N.d(1),N=null)},i:e,o:e,d(e){e&&d(n),f(B,e),N&&N.d(),$=!1,r(R)}}}function Fp(t){let n,r,o;function i(e,t){return e[1]&&"owner"===e[4]?hg:e[1]?fg:dg}let s=i(t),a=s(t);return{c(){n=h("div"),r=h("h2"),r.textContent="Sprocket Script Management",o=g(),a.c(),w(n,"class","sprocket-view svelte-1mgoo1i")},m(e,t){u(e,n,t),c(n,r),c(n,o),a.m(n,null)},p(e,t){s===(s=i(e))&&a?a.p(e,t):(a.d(1),a=s(e),a&&(a.c(),a.m(n,null)))},i:e,o:e,d(e){e&&d(n),a.d()}}}function Mp(e){let t,n,r,o;const i=[Eg,bg,wg],s=[];function a(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=a(e),r=s[n]=i[n](e),{c(){t=h("div"),r.c(),w(t,"class","managed-acl-view svelte-1mgoo1i")},m(e,r){u(e,t,r),s[n].m(t,null),o=!0},p(e,o){let l=n;n=a(e),n===l?s[n].p(e,o):(q(),W(s[l],1,1,()=>{s[l]=null}),z(),r=s[n],r?r.p(e,o):(r=s[n]=i[n](e),r.c()),K(r,1),r.m(t,null))},i(e){o||(K(r),o=!0)},o(e){W(r),o=!1},d(e){e&&d(t),s[n].d()}}}function Dp(t){let n,o,i,s,a,l,f,p,m,v,b,E;return{c(){n=h("div"),o=h("div"),i=h("button"),i.textContent="Reformat",s=g(),a=h("button"),a.textContent="Sign",l=g(),f=h("button"),f.textContent="Publish",p=g(),m=h("div"),v=h("textarea"),w(i,"class","compose-btn reformat-btn svelte-1mgoo1i"),w(a,"class","compose-btn sign-btn svelte-1mgoo1i"),w(f,"class","compose-btn publish-btn svelte-1mgoo1i"),w(o,"class","compose-header svelte-1mgoo1i"),w(v,"class","compose-textarea svelte-1mgoo1i"),w(v,"placeholder","Enter your Nostr event JSON here..."),w(v,"spellcheck","false"),w(m,"class","compose-editor svelte-1mgoo1i"),w(n,"class","compose-view svelte-1mgoo1i")},m(e,r){u(e,n,r),c(n,o),c(o,i),c(o,s),c(o,a),c(o,l),c(o,f),c(n,p),c(n,m),c(m,v),x(v,t[27]),b||(E=[y(i,"click",t[75]),y(a,"click",t[76]),y(f,"click",t[77]),y(v,"input",t[95])],b=!0)},p(e,t){134217728&t[0]&&x(v,e[27])},i:e,o:e,d(e){e&&d(n),b=!1,r(E)}}}function Hp(t){let n,r;function o(e,t){return!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?xg:kg}let i=o(t),s=i(t),a=t[1]&&("write"===t[4]||"admin"===t[4]||"owner"===t[4])&&Ng(t);return{c(){n=h("div"),s.c(),r=g(),a&&a.c(),w(n,"class","events-view-container svelte-1mgoo1i")},m(e,t){u(e,n,t),s.m(n,null),c(n,r),a&&a.m(n,null)},p(e,t){i===(i=o(e))&&s?s.p(e,t):(s.d(1),s=i(e),s&&(s.c(),s.m(n,r))),!e[1]||"write"!==e[4]&&"admin"!==e[4]&&"owner"!==e[4]?a&&(a.d(1),a=null):a?a.p(e,t):(a=Ng(e),a.c(),a.m(n,null))},i:e,o:e,d(e){e&&d(n),s.d(),a&&a.d()}}}function qp(t){let n;function r(e,t){return!e[1]||"admin"!==e[4]&&"owner"!==e[4]?e[1]?Fg:jg:Mg}let o=r(t),i=o(t);return{c(){n=h("div"),i.c(),w(n,"class","import-section svelte-1mgoo1i")},m(e,t){u(e,n,t),i.m(n,null)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n,null)))},i:e,o:e,d(e){e&&d(n),i.d()}}}function zp(t){let n;function r(e,t){return e[1]?Hg:Dg}let o=r(t),i=o(t);return{c(){i.c(),n=m()},m(e,t){i.m(e,t),u(e,n,t)},p(e,t){o===(o=r(e))&&i?i.p(e,t):(i.d(1),i=o(e),i&&(i.c(),i.m(n.parentNode,n)))},i:e,o:e,d(e){i.d(e),e&&d(n)}}}function Kp(t){let n;return{c(){n=h("p"),n.textContent="Log in to access your user dashboard",w(n,"class","svelte-1mgoo1i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Wp(e){let t,n,r,o=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=h("p"),n=p("Welcome "),r=p(o),w(t,"class","svelte-1mgoo1i")},m(e,o){u(e,t,o),c(t,n),c(t,r)},p(e,t){12&t[0]&&o!==(o=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(r,o)},d(e){e&&d(t)}}}function Vp(e){let t,n,o,i,s,a,l,f,m,v,b,x,k,S,C,A,T,_,I,$=e[160].query+"",R=e[35].get(e[160].id)?.isLoading,O=!e[35].get(e[160].id)?.hasMore&&e[35].get(e[160].id)?.events?.length>0;function P(){return e[103](e[160])}function B(e,t){return 64&t[0]&&(k=null),64&t[0]&&(S=null),null==k&&(k=!!(e[35].get(e[160].id)?.events?.length>0)),k?Gp:(null==S&&(S=!e[35].get(e[160].id)?.isLoading),S?Jp:void 0)}let N=B(e,[-1,-1,-1,-1,-1,-1]),L=N&&N(e),U=R&&Xp(),j=O&&eg();function F(...t){return e[108](e[160],...t)}return{c(){t=h("div"),n=h("div"),o=h("h2"),i=p('🔍 Search Results: "'),s=p($),a=p('"'),l=g(),f=h("button"),m=p("🔄 Refresh"),b=g(),x=h("div"),L&&L.c(),C=g(),U&&U.c(),A=g(),j&&j.c(),T=g(),w(o,"class","svelte-1mgoo1i"),w(f,"class","refresh-btn svelte-1mgoo1i"),f.disabled=v=e[35].get(e[160].id)?.isLoading,w(n,"class","search-results-header svelte-1mgoo1i"),w(x,"class","search-results-content svelte-1mgoo1i"),w(t,"class","search-results-view svelte-1mgoo1i")},m(e,r){u(e,t,r),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),c(f,m),c(t,b),c(t,x),L&&L.m(x,null),c(x,C),U&&U.m(x,null),c(x,A),j&&j.m(x,null),c(t,T),_||(I=[y(f,"click",P),y(x,"scroll",F)],_=!0)},p(t,n){e=t,64&n[0]&&$!==($=e[160].query+"")&&E(s,$),64&n[0]&&v!==(v=e[35].get(e[160].id)?.isLoading)&&(f.disabled=v),N===(N=B(e,n))&&L?L.p(e,n):(L&&L.d(1),L=N&&N(e),L&&(L.c(),L.m(x,C))),64&n[0]&&(R=e[35].get(e[160].id)?.isLoading),R?U||(U=Xp(),U.c(),U.m(x,A)):U&&(U.d(1),U=null),64&n[0]&&(O=!e[35].get(e[160].id)?.hasMore&&e[35].get(e[160].id)?.events?.length>0),O?j||(j=eg(),j.c(),j.m(x,null)):j&&(j.d(1),j=null)},d(e){e&&d(t),L&&L.d(),U&&U.d(),j&&j.d(),_=!1,r(I)}}}function Jp(e){let t,n,r,o,i,s=e[160].query+"";return{c(){t=h("div"),n=h("p"),r=p('No search results found for "'),o=p(s),i=p('".'),w(n,"class","svelte-1mgoo1i"),w(t,"class","no-search-results svelte-1mgoo1i")},m(e,s){u(e,t,s),c(t,n),c(n,r),c(n,o),c(n,i)},p(e,t){64&t[0]&&s!==(s=e[160].query+"")&&E(o,s)},d(e){e&&d(t)}}}function Gp(e){let t,n=e[35].get(e[160].id).events,r=[];for(let t=0;t👤',i=g(),s=h("div"),a=h("div"),l=p(j),f=g(),m=h("div"),v=h("span"),b=p(F),x=g(),k=h("span"),C=p(M),A=g(),T=h("div"),_=h("div"),I=p(D),$=g(),R=h("div"),O=p(H),P=g(),z&&z.c(),B=g(),V&&V.c(),N=g(),w(o,"class","search-result-avatar svelte-1mgoo1i"),w(a,"class","search-result-author svelte-1mgoo1i"),w(v,"class","kind-number svelte-1mgoo1i"),w(k,"class","kind-name svelte-1mgoo1i"),w(m,"class","search-result-kind svelte-1mgoo1i"),w(s,"class","search-result-info svelte-1mgoo1i"),w(_,"class","event-timestamp svelte-1mgoo1i"),w(R,"class","event-content-single-line svelte-1mgoo1i"),w(T,"class","search-result-content svelte-1mgoo1i"),w(n,"class","search-result-row svelte-1mgoo1i"),w(n,"role","button"),w(n,"tabindex","0"),w(t,"class","search-result-item svelte-1mgoo1i"),S(t,"expanded",e[17].has(e[145].id))},m(e,r){u(e,t,r),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,f),c(s,m),c(m,v),c(v,b),c(m,x),c(m,k),c(k,C),c(n,A),c(n,T),c(T,_),c(_,I),c(T,$),c(T,R),c(R,O),c(n,P),z&&z.m(n,null),c(t,B),V&&V.m(t,null),c(t,N),L||(U=[y(n,"click",K),y(n,"keydown",W)],L=!0)},p(r,o){e=r,64&o[0]&&j!==(j=Xg(e[145].pubkey)+"")&&E(l,j),64&o[0]&&F!==(F=e[145].kind+"")&&E(b,F),64&o[0]&&M!==(M=e[37](e[145].kind)+"")&&E(C,M),64&o[0]&&D!==(D=tm(e[145].created_at)+"")&&E(I,D),64&o[0]&&H!==(H=em(e[145].content)+"")&&E(O,H),5!==e[145].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[145].pubkey&&e[145].pubkey===e[2])?z?z.p(e,o):(z=Zp(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),131136&o[0]&&(q=e[17].has(e[145].id)),q?V?V.p(e,o):(V=Yp(e),V.c(),V.m(t,N)):V&&(V.d(1),V=null),131136&o[0]|16&o[1]&&S(t,"expanded",e[17].has(e[145].id))},d(e){e&&d(t),z&&z.d(),V&&V.d(),L=!1,r(U)}}}function Xp(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Searching...

',w(t,"class","loading-search-results svelte-1mgoo1i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function eg(e){let t;return{c(){t=h("div"),t.innerHTML='

No more search results to load.

',w(t,"class","end-of-search-results svelte-1mgoo1i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function tg(e){let t,n=e[160].id===e[5]&&Vp(e);return{c(){n&&n.c(),t=m()},m(e,r){n&&n.m(e,r),u(e,t,r)},p(e,r){e[160].id===e[5]?n?n.p(e,r):(n=Vp(e),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},d(e){n&&n.d(e),e&&d(t)}}}function ng(t){let n,r,o=t[157].label+"";return{c(){n=h("option"),r=p(o),n.__value=t[157].value,n.value=n.__value},m(e,t){u(e,n,t),c(n,r)},p:e,d(e){e&&d(n)}}}function rg(e){let t;function n(e,t){return e[31]?sg:0===e[30].length?ig:og}let r=n(e),o=r(e);return{c(){t=h("div"),o.c(),w(t,"class","recovery-results svelte-1mgoo1i")},m(e,n){u(e,t,n),o.m(t,null)},p(e,i){r===(r=n(e))&&o?o.p(e,i):(o.d(1),o=r(e),o&&(o.c(),o.m(t,null)))},d(e){e&&d(t),o.d()}}}function og(e){let t,n,r,o=e[30],i=[];for(let t=0;tORLY_OWNERS environment variable with your npub when starting the\n relay.",i=g(),s=h("p"),a=p("Current user role: "),l=h("strong"),f=p(m),w(n,"class","svelte-1mgoo1i"),w(o,"class","svelte-1mgoo1i"),w(s,"class","svelte-1mgoo1i"),w(t,"class","permission-denied svelte-1mgoo1i")},m(e,d){u(e,t,d),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),c(s,a),c(s,l),c(l,f)},p(e,t){16&t[0]&&m!==(m=(e[4]||"none")+"")&&E(f,m)},d(e){e&&d(t)}}}function hg(e){let t,n,o,i,s,a,l,m,v,b,k,C,A,T,_,I,$,R,O,P,B,N,L,U,j,F,M,D,H,q,z,K,W,V,J,G,Z,Y,Q,X,ee,te,ne,re,oe,ie,se,ae,le,ce,ue,de,fe,he,pe,ge,me=e[21]?.is_running?"🟢 Running":"🔴 Stopped",ye=e[21]?.script_exists?"✅ Exists":"❌ Not found",ve=e[21]?.pid&&pg(e),we=e[24]&&gg(e),be=e[22],Ee=[];for(let t=0;tORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',w(r,"class","svelte-1mgoo1i"),w(i,"class","svelte-1mgoo1i"),w(a,"class","svelte-1mgoo1i"),w(v,"class","svelte-1mgoo1i"),w(n,"class","acl-mode-warning svelte-1mgoo1i")},m(e,t){u(e,n,t),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),c(a,l),c(a,f),c(f,m),c(n,y),c(n,v)},p(e,t){512&t[0]&&b!==(b=(e[9]||"unknown")+"")&&E(m,b)},i:e,o:e,d(e){e&&d(n)}}}function xg(t){let n;return{c(){n=h("div"),n.innerHTML='

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

',w(n,"class","permission-denied svelte-1mgoo1i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function kg(e){let t,n,r,o,i;function s(e,t){return e[34].length>0?Cg:e[18]?void 0:Sg}let a=s(e),l=a&&a(e),f=e[18]&&Pg(),p=!e[19]&&e[7].length>0&&Bg();return{c(){t=h("div"),l&&l.c(),n=g(),f&&f.c(),r=g(),p&&p.c(),w(t,"class","events-view-content svelte-1mgoo1i")},m(s,a){u(s,t,a),l&&l.m(t,null),c(t,n),f&&f.m(t,null),c(t,r),p&&p.m(t,null),o||(i=y(t,"scroll",e[74]),o=!0)},p(e,o){a===(a=s(e))&&l?l.p(e,o):(l&&l.d(1),l=a&&a(e),l&&(l.c(),l.m(t,n))),e[18]?f||(f=Pg(),f.c(),f.m(t,r)):f&&(f.d(1),f=null),!e[19]&&e[7].length>0?p||(p=Bg(),p.c(),p.m(t,null)):p&&(p.d(1),p=null)},d(e){e&&d(t),l&&l.d(),f&&f.d(),p&&p.d(),o=!1,i()}}}function Sg(t){let n;return{c(){n=h("div"),n.innerHTML='

No events found.

',w(n,"class","no-events svelte-1mgoo1i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Cg(e){let t,n=e[34],r=[];for(let t=0;t0&&_g(e);return{c(){t=h("div"),n=h("span"),n.textContent="🗑️ Delete Event",r=g(),o&&o.c(),w(n,"class","delete-event-label svelte-1mgoo1i"),w(t,"class","delete-event-info svelte-1mgoo1i")},m(e,i){u(e,t,i),c(t,n),c(t,r),o&&o.m(t,null)},p(e,n){e[145].tags&&e[145].tags.length>0?o?o.p(e,n):(o=_g(e),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(e){e&&d(t),o&&o.d()}}}function _g(e){let t,n=e[145].tags.filter(rm),r=[];for(let t=0;t👤',i=g(),s=h("div"),a=h("div"),l=p(L),f=g(),m=h("div"),v=h("span"),b=p(U),x=g(),k=h("span"),C=p(j),A=g(),T=h("div"),_=h("div"),I=p(F),$=g(),q.c(),R=g(),z&&z.c(),O=g(),V&&V.c(),P=g(),w(o,"class","events-view-avatar svelte-1mgoo1i"),w(a,"class","events-view-author svelte-1mgoo1i"),w(v,"class","kind-number svelte-1mgoo1i"),S(v,"delete-event",5===e[145].kind),w(k,"class","kind-name svelte-1mgoo1i"),w(m,"class","events-view-kind svelte-1mgoo1i"),w(s,"class","events-view-info svelte-1mgoo1i"),w(_,"class","event-timestamp svelte-1mgoo1i"),w(T,"class","events-view-content svelte-1mgoo1i"),w(n,"class","events-view-row svelte-1mgoo1i"),w(n,"role","button"),w(n,"tabindex","0"),w(t,"class","events-view-item svelte-1mgoo1i"),S(t,"expanded",e[17].has(e[145].id))},m(e,r){u(e,t,r),c(t,n),c(n,o),c(n,i),c(n,s),c(s,a),c(a,l),c(s,f),c(s,m),c(m,v),c(v,b),c(m,x),c(m,k),c(k,C),c(n,A),c(n,T),c(T,_),c(_,I),c(T,$),q.m(T,null),c(n,R),z&&z.m(n,null),c(t,O),V&&V.m(t,null),c(t,P),B||(N=[y(n,"click",K),y(n,"keydown",W)],B=!0)},p(r,o){e=r,8&o[1]&&L!==(L=Xg(e[145].pubkey)+"")&&E(l,L),8&o[1]&&U!==(U=e[145].kind+"")&&E(b,U),8&o[1]&&S(v,"delete-event",5===e[145].kind),8&o[1]&&j!==(j=e[37](e[145].kind)+"")&&E(C,j),8&o[1]&&F!==(F=tm(e[145].created_at)+"")&&E(I,F),H===(H=D(e))&&q?q.p(e,o):(q.d(1),q=H(e),q&&(q.c(),q.m(T,null))),5!==e[145].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[145].pubkey&&e[145].pubkey===e[2])?z?z.p(e,o):(z=$g(e),z.c(),z.m(n,null)):z&&(z.d(1),z=null),131072&o[0]|8&o[1]&&(M=e[17].has(e[145].id)),M?V?V.p(e,o):(V=Rg(e),V.c(),V.m(t,P)):V&&(V.d(1),V=null),131072&o[0]|8&o[1]&&S(t,"expanded",e[17].has(e[145].id))},d(e){e&&d(t),q.d(),z&&z.d(),V&&V.d(),B=!1,r(N)}}}function Pg(e){let t;return{c(){t=h("div"),t.innerHTML='
\n

Loading events...

',w(t,"class","loading-events svelte-1mgoo1i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Bg(e){let t;return{c(){t=h("div"),t.innerHTML='

No more events to load.

',w(t,"class","end-of-events svelte-1mgoo1i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ng(e){let t,n,o,i,s,a,l,f,m,v,b,E,x,k,S,C;function A(e,t){return e[18]?Ug:Lg}let T=A(e),_=T(e);return{c(){t=h("div"),n=h("div"),o=h("label"),i=h("input"),s=g(),a=h("span"),l=g(),f=h("span"),f.textContent="Only show my events",m=g(),v=h("div"),b=h("button"),E=p("🔄 Load More"),x=g(),k=h("button"),_.c(),w(i,"type","checkbox"),w(i,"class","svelte-1mgoo1i"),w(a,"class","toggle-slider svelte-1mgoo1i"),w(f,"class","toggle-label svelte-1mgoo1i"),w(o,"class","toggle-container svelte-1mgoo1i"),w(n,"class","events-view-toggle svelte-1mgoo1i"),w(b,"class","refresh-btn svelte-1mgoo1i"),b.disabled=e[18],w(k,"class","reload-btn svelte-1mgoo1i"),k.disabled=e[18],w(v,"class","events-view-buttons svelte-1mgoo1i"),w(t,"class","events-view-header svelte-1mgoo1i")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),i.checked=e[8],c(o,s),c(o,a),c(o,l),c(o,f),c(t,m),c(t,v),c(v,b),c(b,E),c(v,x),c(v,k),_.m(k,null),S||(C=[y(i,"change",e[91]),y(i,"change",e[92]),y(b,"click",e[93]),y(k,"click",e[94])],S=!0)},p(e,t){256&t[0]&&(i.checked=e[8]),262144&t[0]&&(b.disabled=e[18]),T!==(T=A(e))&&(_.d(1),_=T(e),_&&(_.c(),_.m(k,null))),262144&t[0]&&(k.disabled=e[18])},d(e){e&&d(t),_.d(),S=!1,r(C)}}}function Lg(e){let t;return{c(){t=p("🔄")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function Ug(e){let t;return{c(){t=h("div"),w(t,"class","spinner svelte-1mgoo1i")},m(e,n){u(e,t,n)},d(e){e&&d(t)}}}function jg(t){let n,r,o,i,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Import Events",o=g(),i=h("p"),i.textContent="Please log in to access import functionality.",s=g(),a=h("button"),a.textContent="Log In",w(r,"class","recovery-header svelte-1mgoo1i"),w(i,"class","recovery-description svelte-1mgoo1i"),w(a,"class","login-btn svelte-1mgoo1i"),w(n,"class","login-prompt svelte-1mgoo1i")},m(e,d){u(e,n,d),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),l||(f=y(a,"click",t[57]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function Fg(t){let n;return{c(){n=h("div"),n.innerHTML='

Import Events

\n

❌ Admin or owner permission required for import\n functionality.

',w(n,"class","permission-denied svelte-1mgoo1i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Mg(e){let t,n,o,i,s,a,l,f,m,v,b,E;return{c(){t=h("h3"),t.textContent="Import Events",n=g(),o=h("p"),o.textContent="Upload a JSONL file to import events into the database.",i=g(),s=h("div"),a=h("input"),l=g(),f=h("button"),m=p("Import Events"),w(t,"class","svelte-1mgoo1i"),w(o,"class","svelte-1mgoo1i"),w(a,"type","file"),w(a,"id","import-file"),w(a,"accept",".jsonl,.txt"),w(a,"class","svelte-1mgoo1i"),w(f,"class","import-btn svelte-1mgoo1i"),f.disabled=v=!e[16],w(s,"class","recovery-controls-card svelte-1mgoo1i")},m(r,d){u(r,t,d),u(r,n,d),u(r,o,d),u(r,i,d),u(r,s,d),c(s,a),c(s,l),c(s,f),c(f,m),b||(E=[y(a,"change",e[71]),y(f,"click",e[72])],b=!0)},p(e,t){65536&t[0]&&v!==(v=!e[16])&&(f.disabled=v)},d(e){e&&d(t),e&&d(n),e&&d(o),e&&d(i),e&&d(s),b=!1,r(E)}}}function Dg(t){let n,r,o,i,s,a;return{c(){n=h("div"),r=h("p"),r.textContent="Please log in to access export functionality.",o=g(),i=h("button"),i.textContent="Log In",w(r,"class","svelte-1mgoo1i"),w(i,"class","login-btn svelte-1mgoo1i"),w(n,"class","login-prompt svelte-1mgoo1i")},m(e,l){u(e,n,l),c(n,r),c(n,o),c(n,i),s||(a=y(i,"click",t[57]),s=!0)},p:e,d(e){e&&d(n),s=!1,a()}}}function Hg(e){let t,n,r,o,i,s,a,l,f,p,v=("admin"===e[4]||"owner"===e[4])&&qg(e);return{c(){t=h("div"),n=h("h3"),n.textContent="Export My Events",r=g(),o=h("p"),o.textContent="Download your personal events as a JSONL file.",i=g(),s=h("button"),s.textContent="📤 Export My Events",a=g(),v&&v.c(),l=m(),w(n,"class","svelte-1mgoo1i"),w(o,"class","svelte-1mgoo1i"),w(s,"class","export-btn svelte-1mgoo1i"),w(t,"class","export-section svelte-1mgoo1i")},m(d,h){u(d,t,h),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),u(d,a,h),v&&v.m(d,h),u(d,l,h),f||(p=y(s,"click",e[70]),f=!0)},p(e,t){"admin"===e[4]||"owner"===e[4]?v?v.p(e,t):(v=qg(e),v.c(),v.m(l.parentNode,l)):v&&(v.d(1),v=null)},d(e){e&&d(t),e&&d(a),v&&v.d(e),e&&d(l),f=!1,p()}}}function qg(t){let n,r,o,i,s,a,l,f;return{c(){n=h("div"),r=h("h3"),r.textContent="Export All Events",o=g(),i=h("p"),i.textContent="Download the complete database as a JSONL file. This\n includes all events from all users.",s=g(),a=h("button"),a.textContent="📤 Export All Events",w(r,"class","svelte-1mgoo1i"),w(i,"class","svelte-1mgoo1i"),w(a,"class","export-btn svelte-1mgoo1i"),w(n,"class","export-section svelte-1mgoo1i")},m(e,d){u(e,n,d),c(n,r),c(n,o),c(n,i),c(n,s),c(n,a),l||(f=y(a,"click",t[69]),l=!0)},p:e,d(e){e&&d(n),l=!1,f()}}}function zg(e){let t,n,o,i,s,a,l,f,p,m;function b(e,t){return e[3]?Wg:e[1]&&e[2]?Kg:void 0}let E=b(e),x=E&&E(e);return{c(){t=h("div"),n=h("div"),o=h("div"),i=h("h2"),i.textContent="Settings",s=g(),a=h("button"),a.textContent="✕",l=g(),f=h("div"),x&&x.c(),w(i,"class","svelte-1mgoo1i"),w(a,"class","close-btn svelte-1mgoo1i"),w(o,"class","drawer-header svelte-1mgoo1i"),w(f,"class","drawer-content"),w(n,"class","settings-drawer svelte-1mgoo1i"),S(n,"dark-theme",e[0]),w(t,"class","drawer-overlay svelte-1mgoo1i"),w(t,"role","button"),w(t,"tabindex","0")},m(r,d){u(r,t,d),c(t,n),c(n,o),c(o,i),c(o,s),c(o,a),c(n,l),c(n,f),x&&x.m(f,null),p||(m=[y(a,"click",e[62]),y(n,"click",v(e[80])),y(n,"keydown",v(e[81])),y(t,"click",e[62]),y(t,"keydown",e[109])],p=!0)},p(e,t){E===(E=b(e))&&x?x.p(e,t):(x&&x.d(1),x=E&&E(e),x&&(x.c(),x.m(f,null))),1&t[0]&&S(n,"dark-theme",e[0])},d(e){e&&d(t),x&&x.d(),p=!1,r(m)}}}function Kg(e){let t,n,r,o,i,s,a,l,f,m,v,b,x,k,S,C=e[2].slice(0,16)+"",A=e[2].slice(-8)+"";return{c(){t=h("div"),n=h("h3"),n.textContent="Profile Loading",r=g(),o=h("p"),o.textContent="Your profile metadata is being loaded...",i=g(),s=h("button"),s.textContent="Retry Loading Profile",a=g(),l=h("div"),f=h("strong"),f.textContent="Public Key:",m=g(),v=p(C),b=p("..."),x=p(A),w(n,"class","svelte-1mgoo1i"),w(o,"class","svelte-1mgoo1i"),w(s,"class","retry-profile-btn svelte-1mgoo1i"),w(l,"class","user-pubkey-display svelte-1mgoo1i"),w(t,"class","profile-loading-section svelte-1mgoo1i")},m(d,h){u(d,t,h),c(t,n),c(t,r),c(t,o),c(t,i),c(t,s),c(t,a),c(t,l),c(l,f),c(l,m),c(l,v),c(l,b),c(l,x),k||(S=y(s,"click",e[68]),k=!0)},p(e,t){4&t[0]&&C!==(C=e[2].slice(0,16)+"")&&E(v,C),4&t[0]&&A!==(A=e[2].slice(-8)+"")&&E(x,A)},d(e){e&&d(t),k=!1,S()}}}function Wg(e){let t,n,r,o,i,s,a,l,f,m,v,b,x,k=(e[3].name||"Unknown User")+"",S=e[3].banner&&Vg(e);function C(e,t){return e[3].picture?Gg:Jg}let A=C(e),T=A(e),_=e[3].nip05&&Zg(e),I=e[3].about&&Yg(e);return{c(){t=h("div"),n=h("div"),S&&S.c(),r=g(),o=h("button"),o.textContent="Log out",i=g(),T.c(),s=g(),a=h("div"),l=h("h3"),f=p(k),m=g(),_&&_.c(),v=g(),I&&I.c(),w(o,"class","logout-btn floating svelte-1mgoo1i"),w(l,"class","profile-username svelte-1mgoo1i"),w(a,"class","name-row svelte-1mgoo1i"),w(n,"class","profile-hero svelte-1mgoo1i"),w(t,"class","profile-section svelte-1mgoo1i")},m(d,h){u(d,t,h),c(t,n),S&&S.m(n,null),c(n,r),c(n,o),c(n,i),T.m(n,null),c(n,s),c(n,a),c(a,l),c(l,f),c(a,m),_&&_.m(a,null),c(t,v),I&&I.m(t,null),b||(x=y(o,"click",e[59]),b=!0)},p(e,o){e[3].banner?S?S.p(e,o):(S=Vg(e),S.c(),S.m(n,r)):S&&(S.d(1),S=null),A===(A=C(e))&&T?T.p(e,o):(T.d(1),T=A(e),T&&(T.c(),T.m(n,s))),8&o[0]&&k!==(k=(e[3].name||"Unknown User")+"")&&E(f,k),e[3].nip05?_?_.p(e,o):(_=Zg(e),_.c(),_.m(a,null)):_&&(_.d(1),_=null),e[3].about?I?I.p(e,o):(I=Yg(e),I.c(),I.m(t,null)):I&&(I.d(1),I=null)},d(e){e&&d(t),S&&S.d(),T.d(),_&&_.d(),I&&I.d(),b=!1,x()}}}function Vg(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].banner)||w(t,"src",n),w(t,"alt","Profile banner"),w(t,"class","profile-banner svelte-1mgoo1i")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].banner)&&w(t,"src",n)},d(e){e&&d(t)}}}function Jg(t){let n;return{c(){n=h("div"),n.textContent="👤",w(n,"class","profile-avatar-placeholder overlap svelte-1mgoo1i")},m(e,t){u(e,n,t)},p:e,d(e){e&&d(n)}}}function Gg(e){let t,n;return{c(){t=h("img"),a(t.src,n=e[3].picture)||w(t,"src",n),w(t,"alt","User avatar"),w(t,"class","profile-avatar overlap svelte-1mgoo1i")},m(e,n){u(e,t,n)},p(e,r){8&r[0]&&!a(t.src,n=e[3].picture)&&w(t,"src",n)},d(e){e&&d(t)}}}function Zg(e){let t,n,r=e[3].nip05+"";return{c(){t=h("span"),n=p(r),w(t,"class","profile-nip05-inline svelte-1mgoo1i")},m(e,r){u(e,t,r),c(t,n)},p(e,t){8&t[0]&&r!==(r=e[3].nip05+"")&&E(n,r)},d(e){e&&d(t)}}}function Yg(e){let t,n;return{c(){t=h("div"),n=h("p"),w(n,"class","profile-about svelte-1mgoo1i"),w(t,"class","about-card svelte-1mgoo1i")},m(r,o){u(r,t,o),c(t,n),n.innerHTML=e[33]},p(e,t){4&t[1]&&(n.innerHTML=e[33])},d(e){e&&d(t)}}}function Qg(e){let t,n,o,i,s,l,m,v,b,x,k,C,A,T,_,I,$,O,B,N,L,U,j,F,M,D,H,Z,Y=e[0]?"☀️":"🌙";function Q(e,t){return e[14]?_p:Tp}let X=Q(e),ee=X(e);function te(e,t){return e[1]?Rp:$p}let ne=te(e),re=ne(e),oe=e[10],ie=[];for(let t=0;tfunction(e,t,n){const r=e.$$.props[t];void 0!==r&&(e.$$.bound[r]=n,n(e.$$.ctx[r]))}(F,"showModal",ue)),F.$on("login",e[58]),F.$on("close",e[60]),{c(){t=h("header"),n=h("div"),o=h("img"),s=g(),ee.c(),l=g(),m=h("button"),m.textContent="🔍",v=g(),b=h("button"),x=p(Y),k=g(),re.c(),C=g(),A=h("div"),T=h("aside"),_=h("div"),I=h("div");for(let e=0;e{ae[o]=null}),z(),L=ae[N],L?L.p(e,r):(L=ae[N]=se[N](e),L.c()),K(L,1),L.m(O,null)),(!D||1&r[0])&&S(A,"dark-theme",e[0]),e[13]?ce?ce.p(e,r):(ce=zg(e),ce.c(),ce.m(j.parentNode,j)):ce&&(ce.d(1),ce=null);const i={};var s;1&r[0]&&(i.isDarkTheme=e[0]),!M&&2048&r[0]&&(M=!0,i.showModal=e[11],s=()=>M=!1,P.push(s)),F.$set(i)},i(e){D||(K(L),K(F.$$.fragment,e),D=!0)},o(e){W(L),W(F.$$.fragment,e),D=!1},d(e){e&&d(t),ee.d(),re.d(),e&&d(C),e&&d(A),f(ie,e),ae[N].d(),e&&d(U),ce&&ce.d(e),e&&d(j),G(F,e),H=!1,r(Z)}}}function Xg(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function em(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function tm(e){return e?new Date(1e3*e).toLocaleString():""}async function nm(e,t){try{const n=JSON.stringify(e);await navigator.clipboard.writeText(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(n){console.error("Failed to copy to clipboard:",n);try{const n=document.createElement("textarea");n.value=JSON.stringify(e),document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n);const r=t.target.closest(".copy-json-btn");if(r){const e=r.textContent;r.textContent="✅",r.style.backgroundColor="#4CAF50",setTimeout(()=>{r.textContent=e,r.style.backgroundColor=""},2e3)}}catch(e){console.error("Fallback copy also failed:",e),alert("Failed to copy to clipboard. Please copy manually.")}}}const rm=e=>"e"===e[0];function om(e,t,n){let r,o,i,s;"undefined"!=typeof window&&(window.debugIndexedDB=mh);let a=!1,l=!1,c=!1,u="",d="",f=null,h="",p=null,g=!1,m=localStorage.getItem("selectedTab")||"export",y=!1,v="",w=[],E=[],x=null,k=new Set,S=!1,C=!0,A=null,T=new Map,_=[],$=0;const R=3e5;let O=!1,P=[],B=!0,N=null,L="",U=null,j=[],F=!1,M="",D="info",H=!1,q=null,z="",K="",W=null,V="",J=[],G=!1,Z=!0,Y=null;const Q=[{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)"}],X={0:"User Metadata",1:"Short Text Note",2:"Recommend Relay",3:"Follows",4:"Encrypted Direct Messages",5:"Event Deletion Request",6:"Repost",7:"Reaction",8:"Badge Award",9:"Chat Message",10:"Group Chat Threaded Reply",11:"Thread",12:"Group Thread Reply",13:"Seal",14:"Direct Message",15:"File Message",16:"Generic Repost",17:"Reaction to a website",20:"Picture",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1021:"Bid",1022:"Bid Confirmation",1040:"OpenTimestamps",1063:"File Metadata",1311:"Live Chat Message",1971:"Problem Tracker",1984:"Reporting",1985:"Label",4550:"Community Post Approval",5e3:"Job Request",5999:"Job Request",6e3:"Job Result",6999:"Job Result",7e3:"Job Feedback",9041:"Zap Goal",9734:"Zap Request",9735:"Zap",9882:"Highlights",1e4:"Mute list",10001:"Pin list",10002:"Relay List Metadata",10003:"Bookmarks list",10004:"Communities list",10005:"Public Chats list",10006:"Blocked Relays list",10007:"Search Relays list",10015:"Interests",10030:"User Emoji list",10050:"DM relays",10096:"File Storage Server List",13194:"Wallet Service Info",21e3:"Lightning pub RPC",22242:"Client Authentication",23194:"Wallet Request",23195:"Wallet Response",23196:"Wallet Notification",23197:"Wallet Notification",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Follow sets",30001:"Generic lists",30002:"Relay sets",30003:"Bookmark sets",30004:"Curation sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest sets",30017:"Stall Definition",30018:"Product Definition",30019:"Marketplace UI/UX",30020:"Product sold as an auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34235:"Video Event Horizontal",34236:"Video Event Vertical",34550:"Community Definition"};function ee(e){k.has(e)?k.delete(e):k.add(e),n(17,k)}async function te(){console.log("Toggle changed, showOnlyMyEvents:",O);const e=O&&c&&u?[u]:null;await xe(!0,e)}async function ne(e){if(!c)return void alert("Please log in first");const t=E.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===h||"owner"===h||"write"===h&&t.pubkey&&t.pubkey===u){if(confirm("Are you sure you want to delete this event?"))try{if(!p)throw new Error("Signer not available for signing");const r={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",r),console.log("User pubkey:",u),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const o=await p.signEvent(r);console.log("Signed delete event:",o),console.log("Signed delete event pubkey:",o.pubkey),console.log("Delete event tags:",o.tags);const i=`wss://${window.location.host}`;try{const e=await vp(i,o,p,u);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const s=t.pubkey&&t.pubkey===u;if(s){const t=await nh.publish(o);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await hh(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await ph(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===u);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(7,E=E.filter(t=>t.id!==e)),P=P.filter(t=>t.id!==e),_=_.filter(t=>t.id!==e);for(const[t,n]of T)n.events&&(n.events=n.events.filter(t=>t.id!==e),T.set(t,n));ie(),console.log("Reloading events to show delete event...");const r=O&&c&&u?[u]:null;await xe(!0,r),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`wss://${window.location.host}/`,r=new th;await r.connectToRelay(t);const i=await r.publish(o);if(console.log("Delete event published to local relay only:",i),!(i.success&&i.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await hh(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${i.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await ph(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===u);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(7,E=E.filter(t=>t.id!==e)),P=P.filter(t=>t.id!==e),_=_.filter(t=>t.id!==e);for(const[t,n]of T)n.events&&(n.events=n.events.filter(t=>t.id!==e),T.set(t,n));ie(),console.log("Reloading events to show delete event...");const t=O&&c&&u?[u]:null;await xe(!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 re(){const e=V?parseInt(V):W;if(null==e||isNaN(e))console.log("No valid kind to load, kindToUse:",e);else if(c){console.log("Loading recovery events for kind:",e,"user:",u),n(31,G=!0);try{const t=[{kinds:[e],authors:[u],limit:100}];Y&&(t[0].until=Y),console.log("Recovery filters:",t);const r=await async function(e,t={}){const{timeout:n=3e4,cacheFirst:r=!0,cacheOnly:o=!1}=t;let i=[];if(r||o)try{if(i=await ch(e),console.log(`Found ${i.length} events in cache`),o||i.length>0)return i}catch(e){console.warn("Failed to query cache",e)}if(!o){const t=await fh(e,{timeout:n,useCache:!1});return console.log(`Fetched ${t.length} events from relay`),t}return i}(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",r.length),console.log("Recovery events kinds:",r.map(e=>e.kind)),n(30,J=Y?[...J,...r]:r),r.length>0?(Y=Math.min(...r.map(e=>e.created_at)),n(32,Z=100===r.length)):n(32,Z=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(31,G=!1)}}else console.log("Not logged in, cannot load recovery events")}async function oe(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`wss://${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const r={...e};if(r.created_at=Math.floor(Date.now()/1e3),r.id="",r.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(r.tags=r.tags.filter(e=>"d"!==e[0]),r.tags.push(t))}if(p){const e=await p.sign(r);console.log("Signed event for repost:",e);const o=await nh.publish(e,[t]);console.log("Repost publish result:",o),o.success&&o.okCount>0?(alert("Event reposted successfully!"),n(32,Z=!1),await re()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event:",e),alert("Error reposting event: "+e.message)}}if("undefined"!=typeof localStorage){const e=localStorage.getItem("isDarkTheme");null!==e&&(a=JSON.parse(e));const t=localStorage.getItem("nostr_auth_method"),r=localStorage.getItem("nostr_pubkey");t&&r&&(c=!0,u=r,d=t,"extension"===t&&window.nostr&&(p=window.nostr),we(),be()),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const r=JSON.parse(t);r.selectedTab&&fe.some(e=>e.id===r.selectedTab)&&n(5,m=r.selectedTab),r.expandedEvents&&n(17,k=new Set(r.expandedEvents)),r.globalEventsCache&&(_=r.globalEventsCache),r.globalCacheTimestamp&&($=r.globalCacheTimestamp),void 0!==r.hasMoreEvents&&n(19,C=r.hasMoreEvents),r.oldestEventTimestamp&&(A=r.oldestEventTimestamp),void 0!==r.hasMoreMyEvents&&(B=r.hasMoreMyEvents),r.oldestMyEventTimestamp&&(N=r.oldestMyEventTimestamp),_.length>0&&((e=$)&&Date.now()-et.created_at-e.created_at),$=Date.now(),ie()}async function ae(){if(c&&"owner"===h&&H)try{n(23,F=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Ce("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});e.ok?n(21,U=await e.json()):de("Failed to load sprocket status","error")}catch(e){de(`Error loading sprocket status: ${e.message}`,"error")}finally{n(23,F=!1)}}async function le(){if(c&&"owner"===h)try{n(23,F=!0);const e=await fetch("/api/sprocket/versions",{method:"GET",headers:{Authorization:`Nostr ${await Ce("GET","/api/sprocket/versions")}`,"Content-Type":"application/json"}});e.ok?n(22,j=await e.json()):de("Failed to load versions","error")}catch(e){de(`Error loading versions: ${e.message}`,"error")}finally{n(23,F=!1)}}async function ce(e){c&&"owner"===h&&(n(20,L=e.content),de(`Loaded version: ${e.name}`,"success"))}async function ue(e){if(c&&"owner"===h&&confirm(`Are you sure you want to delete version ${e}?`))try{n(23,F=!0);const t=await fetch("/api/sprocket/delete-version",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/delete-version")}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)de(`Version ${e} deleted successfully`,"success"),await le();else{de(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){de(`Error deleting version: ${e.message}`,"error")}finally{n(23,F=!1)}}function de(e,t="info"){n(24,M=e),n(25,D=t),setTimeout(()=>{n(24,M="")},5e3)}const fe=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"compose",icon:"✏️",label:"Compose"},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0}];function he(e){n(5,m=e),"sprocket"===e&&c&&"owner"===h&&H&&(ae(),le()),ie()}function pe(){n(13,g=!1)}function ge(e){n(6,w=w.filter(t=>t.id!==e)),T.delete(e),m===e&&n(5,m="export")}async function me(e,t,n=!0){const r=T.get(e);if(r&&!r.isLoading){r.isLoading=!0,T.set(e,r);try{const o={limit:n?100:200,until:n?Math.floor(Date.now()/1e3):r.oldestTimestamp};console.log("Loading search results for query:",t,"with options:",o);const i=await async function(e,t={}){const{limit:n=100,since:r=null,until:o=null,kinds:i=null}=t,s=[{search:e}];return r&&(s[0].since=r),o&&(s[0].until=o),i&&(s[0].kinds=i),n&&(s[0].limit=n),await fh(s,{timeout:3e4})}(t,o);if(console.log("Received search results:",i.length,"events"),r.events=n?i.sort((e,t)=>t.created_at-e.created_at):[...r.events,...i].sort((e,t)=>t.created_at-e.created_at),i.length>0){const e=Math.min(...i.map(e=>e.created_at));(!r.oldestTimestamp||et.id===e);t&&await me(e,t.query,!1)}(t)}}async function ve(){if(c&&u&&!f)try{console.log("Auto-fetching profile for:",u),await gh(),n(3,f=await dh(u)),console.log("Profile auto-loaded:",f)}catch(e){console.error("Failed to auto-load profile:",e)}}async function we(){if(c&&u)try{const e=await fetch(`/api/permissions/${u}`);if(e.ok){const t=await e.json();n(4,h=t.permission||""),console.log("User role loaded:",h),console.log("Is owner?","owner"===h)}else console.error("Failed to fetch user role:",e.status),n(4,h="")}catch(e){console.error("Error fetching user role:",e),n(4,h="")}else n(4,h="")}async function be(){try{const e=await fetch("/api/acl-mode");if(e.ok){const t=await e.json();n(9,z=t.acl_mode||""),console.log("ACL mode loaded:",z)}else console.error("Failed to fetch ACL mode:",e.status),n(9,z="")}catch(e){console.error("Error fetching ACL mode:",e),n(9,z="")}}async function Ee(e=[]){if(c)if(0!==e.length||"admin"===h||"owner"===h)try{const t=await Se("/api/export","POST"),n=await fetch("/api/export",{method:"POST",headers:{Authorization:t,"Content-Type":"application/json"},body:JSON.stringify({pubkeys:e})});if(!n.ok)throw new Error(`Export failed: ${n.status} ${n.statusText}`);const r=await n.blob(),o=window.URL.createObjectURL(r),i=document.createElement("a");i.href=o;const s=n.headers.get("Content-Disposition");let a="events.jsonl";if(s){const e=s.match(/filename="([^"]+)"/);e&&(a=e[1])}i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(o)}catch(e){console.error("Export failed:",e),alert("Export failed: "+e.message)}else alert("Admin or owner permission required to export all events");else alert("Please log in first")}async function xe(e=!1,t=null){if(!c||"write"!==h&&"admin"!==h&&"owner"!==h)alert("Write, admin, or owner permission required");else if(!S){n(18,S=!0),e&&(A=null);try{console.log("Loading events with authors filter:",t,"including delete events");const r=await async function(e={}){const{limit:t=100,since:n=null,until:r=null,authors:o=null,kinds:i=null,...s}=e,a=[{...s}];return n&&(a[0].since=n),r&&(a[0].until=r),o&&(a[0].authors=o),i&&(a[0].kinds=i),t&&(a[0].limit=t),await fh(a,{timeout:3e4})}({limit:e?100:200,until:e?Math.floor(Date.now()/1e3):A,authors:t});if(console.log("Received events:",r.length,"events"),t&&r.length>0){const e=r.filter(e=>e.pubkey&&e.pubkey!==u);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",r.length)}if(e?(n(7,E=r.sort((e,t)=>t.created_at-e.created_at)),se(r)):(n(7,E=[...E,...r].sort((e,t)=>t.created_at-e.created_at)),se(E)),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!A||e{if("events"===m){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&ke()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(18,S=!1)}}}async function ke(){await xe(!1)}async function Se(e,t){if(!c||!u)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:u};let r;if(p&&"extension"===d)try{r=await p.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==d)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return`Nostr ${btoa(o)}`}async function Ce(e,t){if(!c||!u)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:u};let r;if(p&&"extension"===d)try{r=await p.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==d)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),r=n}const o=JSON.stringify(r);return btoa(o)}return e.$$.update=()=>{var t;if(390&e.$$.dirty[0]&&n(34,r=(O&&c&&u?E.filter(e=>e.pubkey&&e.pubkey===u):E).sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(33,o=f?.about?(t=f.about,String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")).replace(/\n{2,}/g,"
"):""),530&e.$$.dirty[0]|65536&e.$$.dirty[2]&&n(79,i=fe.filter(e=>!(e.requiresAdmin&&(!c||"admin"!==h&&"owner"!==h))&&(!(e.requiresOwner&&(!c||"owner"!==h))&&(!("sprocket"===e.id&&!H)&&(("managed-acl"!==e.id||"managed"===z)&&("managed-acl"===e.id&&console.log("Managed ACL tab check:",{isLoggedIn:c,userRole:h,requiresOwner:e.requiresOwner,aclMode:z}),!0)))))),64&e.$$.dirty[0]|131072&e.$$.dirty[2]&&n(10,s=[...i,...w]),1554&e.$$.dirty[0]|131072&e.$$.dirty[2]&&console.log("Tabs debug:",{isLoggedIn:c,userRole:h,aclMode:z,filteredBaseTabs:i.map(e=>e.id),allTabs:s.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]&&c&&u&&!f&&ve(),438&e.$$.dirty[0]&&"events"===m&&c&&("write"===h||"admin"===h||"owner"===h)&&0===E.length){xe(!0,O&&u?[u]:null)}32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",m)},[a,c,u,f,h,m,w,E,O,z,s,l,p,g,y,v,x,k,S,C,L,U,j,F,M,D,q,K,W,V,J,G,Z,o,r,T,Q,function(e){return X[e]||`Kind ${e}`},ee,te,ne,re,oe,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",W),null!=W?(n(29,V=""),n(30,J=[]),Y=null,n(32,Z=!0),re()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",V);const e=parseInt(V);""!==V&&!isNaN(e)&&e>=0&&(n(28,W=null),n(30,J=[]),Y=null,n(32,Z=!0),re())},function(e){const t=J.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(c&&"owner"===h)try{n(23,F=!0);const e=await fetch("/api/sprocket/status",{method:"GET",headers:{Authorization:`Nostr ${await Ce("GET","/api/sprocket/status")}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(20,L=t.script_content||""),n(21,U=t),de("Script loaded successfully","success")}else de("Failed to load script","error")}catch(e){de(`Error loading script: ${e.message}`,"error")}finally{n(23,F=!1)}},async function(){if(c&&"owner"===h)try{n(23,F=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:L});if(e.ok)de("Script saved and updated successfully","success"),await ae(),await le();else{de(`Failed to save script: ${await e.text()}`,"error")}}catch(e){de(`Error saving script: ${e.message}`,"error")}finally{n(23,F=!1)}},async function(){if(c&&"owner"===h)try{n(23,F=!0);const e=await fetch("/api/sprocket/restart",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/restart")}`,"Content-Type":"application/json"}});if(e.ok)de("Sprocket restarted successfully","success"),await ae();else{de(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){de(`Error restarting sprocket: ${e.message}`,"error")}finally{n(23,F=!1)}},async function(){if(c&&"owner"===h&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(23,F=!0);const e=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(20,L=""),de("Sprocket script deleted successfully","success"),await ae(),await le();else{de(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){de(`Error deleting script: ${e.message}`,"error")}finally{n(23,F=!1)}},le,ce,ue,function(e){n(26,q=e.target.files[0])},async function(){if(c&&"owner"===h&&q)try{n(23,F=!0);const e=await q.text(),t=await fetch("/api/sprocket/update",{method:"POST",headers:{Authorization:`Nostr ${await Ce("POST","/api/sprocket/update")}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(20,L=e),de("Script uploaded and updated successfully","success"),await ae(),await le();else{de(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){de(`Error uploading script: ${e.message}`,"error")}finally{n(23,F=!1),n(26,q=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},he,function(){n(0,a=!a),"undefined"!=typeof localStorage&&localStorage.setItem("isDarkTheme",JSON.stringify(a))},function(){c||n(11,l=!0)},async function(e){const{method:t,pubkey:r,privateKey:o,signer:i}=e.detail;n(1,c=!0),n(2,u=r),d=t,n(12,p=i),n(11,l=!1);try{if(await gh(),"extension"===t&&i)nh.setSigner(i);else if("nsec"===t&&o){const e=new Dd(o);nh.setSigner(e)}n(3,f=await dh(r)),console.log("Profile loaded:",f)}catch(e){console.error("Failed to load profile:",e)}await we(),await be()},function(){n(1,c=!1),n(2,u=""),d="",n(3,f=null),n(4,h=""),n(12,p=null),n(13,g=!1),P=[],n(7,E=[]),_=[],$=0,ie(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(11,l=!1)},function(){n(13,g=!0)},pe,function(){n(14,y=!y),y||n(15,v="")},function(e){"Enter"===e.key&&v.trim()?(!function(e){const t=`search-${Date.now()}`,r={id:t,icon:"🔍",label:e,isSearchTab:!0,query:e};n(6,w=[...w,r]),n(5,m=t),T.set(t,{events:[],isLoading:!1,hasMore:!0,oldestTimestamp:null}),me(t,e)}(v.trim()),n(15,v=""),n(14,y=!1)):"Escape"===e.key&&(n(14,y=!1),n(15,v=""))},ge,me,ye,ve,async function(){await Ee([])},async function(){await Ee([u])},function(e){n(16,x=e.target.files[0])},async function(){if(!c||"admin"!==h&&"owner"!==h)alert("Admin or owner permission required");else if(x)try{const e=await Se("/api/import","POST"),t=new FormData;t.append("file",x);const r=await fetch("/api/import",{method:"POST",headers:{Authorization:e},body:t});if(!r.ok)throw new Error(`Import failed: ${r.status} ${r.statusText}`);await r.json();alert("Import started successfully"),n(16,x=null),document.getElementById("import-file").value=""}catch(e){console.error("Import failed:",e),alert("Import failed: "+e.message)}else alert("Please select a file")},xe,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:r}=e.target;n-t-r<100&&ke()},function(){try{if(!K.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(K);n(27,K=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!K.trim())return void alert("Please enter an event to sign");if(!c||!u)return void alert("Please log in to sign events");if(!p)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(K);e.pubkey=u,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await p.signEvent(e);n(27,K=JSON.stringify(t,null,2)),alert("Event signed successfully!")}catch(e){console.error("Error signing event:",e),alert("Error signing event: "+e.message)}},async function(){try{if(!K.trim())return void alert("Please enter an event to publish");if(!c)return void alert("Please log in to publish events");if(!p)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(K);if(!e.id||!e.sig)return void alert('Event must be signed before publishing. Please click "Sign" first.');const t=`wss://${window.location.host}`,n=await vp(t,e,p,u);n.success?alert("Event published successfully to ORLY relay!"):alert(`Event publishing failed: ${n.reason||"Unknown error"}`)}catch(e){console.error("Error publishing event:",e),alert("Error publishing event: "+e.message)}},H,i,function(t){I.call(this,e,t)},function(t){I.call(this,e,t)},e=>e.id===m,function(){v=this.value,n(15,v)},e=>ge(e.id),(e,t)=>"Enter"===t.key&&ge(e.id),e=>he(e.id),e=>ne(e.id),e=>ee(e.id),(e,t)=>"Enter"===t.key&&ee(e.id),(e,t)=>nm(e,t),function(){O=this.checked,n(8,O)},()=>te(),()=>{xe(!1,O&&u?[u]:null)},()=>{xe(!0,O&&u?[u]:null)},function(){K=this.value,n(27,K)},function(){L=this.value,n(20,L)},e=>ce(e),e=>ue(e.name),function(){W=function(e){const t=e.querySelector(":checked");return t&&t.__value}(this),n(28,W),n(36,Q)},function(){V=b(this.value),n(29,V)},e=>oe(e),(e,t)=>nm(e,t),e=>me(e.id,e.query,!0),e=>ne(e.id),e=>ee(e.id),(e,t)=>"Enter"===t.key&&ee(e.id),(e,t)=>nm(e,t),(e,t)=>ye(t,e.id),e=>"Escape"===e.key&&pe(),function(e){l=e,n(11,l)}]}return new class extends Q{constructor(e){super(),Y(this,e,om,Qg,i,{},null,[-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 e1e045d..f13b237 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/@noble/curves/node_modules/@noble/hashes/esm/_assert.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js","../node_modules/@noble/curves/esm/abstract/utils.js","../node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js","../node_modules/@noble/curves/esm/_shortw_utils.js","../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/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/applesauce-core/dist/helpers/url.js","../node_modules/applesauce-core/dist/helpers/relays.js","../node_modules/applesauce-core/dist/helpers/string.js","../node_modules/applesauce-core/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/hashes/esm/crypto.js","../node_modules/applesauce-signers/node_modules/@noble/hashes/esm/utils.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","../src/LoginModal.svelte","../src/ManagedACL.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