import { nip18 } from "nostr-tools";
import { getOrComputeCachedValue } from "./cache.js";
import { isATag } from "./tags.js";
import { getAddressPointerFromATag } from "./pointers.js";
export const SharedEventSymbol = Symbol.for("shared-event");
export const SharedEventPointerSymbol = Symbol.for("shared-event-pointer");
export const SharedAddressPointerSymbol = Symbol.for("shared-address-pointer");
/** Returns the event pointer of a kind 6 or 16 share event */
export function getSharedEventPointer(event) {
    return getOrComputeCachedValue(event, SharedEventPointerSymbol, () => nip18.getRepostedEventPointer(event));
}
/** Returns the address pointer of a kind 6 or 16 share event */
export function getSharedAddressPointer(event) {
    return getOrComputeCachedValue(event, SharedAddressPointerSymbol, () => {
        const a = event.tags.find(isATag);
        if (!a)
            return undefined;
        return getAddressPointerFromATag(a);
    });
}
/** Returns the stringified event in the content of a kind 6 or 16 share event */
export function getEmbededSharedEvent(event) {
    return getOrComputeCachedValue(event, SharedEventSymbol, () => nip18.getRepostedEvent(event));
}
/** @deprecated use getEmbededSharedEvent instead */
export const parseSharedEvent = getEmbededSharedEvent;
