import { NDKEvent, NDKUser, NDKUserProfile } from '@nostr-dev-kit/ndk'; import { NostrBaseComponent, NCStatus } from '../base-component/nostr-base-component'; /** * NostrEventComponent * ================== * Extension of `NostrBaseComponent` that resolves and manages a Nostr Event. * * Overview * - Accepts identity attributes (`hex`, `noteid`, `eventid`, or `naddr`) and validates them. * - Resolves an `NDKEvent` via the shared `nostrService` and fetches the event. * - Exposes resolved `event` to subclasses for rendering or logic. * - Emits lifecycle events for status and event readiness. * * Observed attributes * - `hex` — raw hex-encoded event ID * - `noteid` — bech32-encoded event ID starting with 'note1...' * - `eventid` — bech32-encoded event pointer starting with 'nevent1...' (encodes extra metadata) * - `naddr` — bech32-encoded addressable event code starting with 'naddr1...' (NIP-19) * * Important: Only one identifier type should be provided (naddr XOR hex/noteid/eventid). * Providing multiple identifiers will result in a validation error. * * Events * - `nc:status` — from base, reflects connection and event loading status * - `nc:event` — fired when an event is successfully resolved */ export declare class NostrEventComponent extends NostrBaseComponent { protected event: NDKEvent | null; protected author: NDKUser | null; protected authorProfile: NDKUserProfile | null; protected formattedDate: string; protected decodedNaddr: { kind: number; pubkey: string; dTag: string; relays?: string[]; } | null; protected eventStatus: { set: (s: NCStatus, e?: string) => void; get: () => NCStatus; }; protected authorStatus: { set: (s: NCStatus, e?: string) => void; get: () => NCStatus; }; private loadSeq; private eventResolver; private userResolver; constructor(shadow?: boolean); /** Lifecycle methods */ static get observedAttributes(): string[]; connectedCallback(): void; attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void; /** * Returns true if this component requires naddr (addressable events). * Returns false if this component uses hex/noteid/eventid (regular events). * Override this method in subclasses to specify which identifier type is required. * Right now NostrLivestreamComponent uses this function to return true, * so it requires naddr only. * In future, if more components need naddr only, * we can create a NostrAddressableEventComponent that extends NostrEventComponent and requires naddr only. */ protected requiresNaddr(): boolean; /** Protected methods */ protected validateInputs(): boolean; protected resolveEventAndLoad(): Promise; private loadAuthorProfile; private checkEventAndAuthorReady; private formatEventDate; protected renderContent(): void; /** Hook for subclasses to react when event is ready (e.g., render). */ protected onEventReady(_event: NDKEvent): void; }