const DNS_PINNED_FETCH = Symbol.for("@steipete/summarize.dnsPinnedFetch");
const DNS_PINNED_ADDRESSES = Symbol.for("@steipete/summarize.dnsPinnedAddresses");
export function markFetchAsDnsPinned(fetchImpl, pinnedFetchImpl = fetchImpl) {
    Object.defineProperty(fetchImpl, DNS_PINNED_FETCH, {
        configurable: false,
        enumerable: false,
        value: pinnedFetchImpl,
    });
    return fetchImpl;
}
export function resolveDnsPinnedFetch(fetchImpl) {
    const pinnedFetchImpl = fetchImpl[DNS_PINNED_FETCH];
    return pinnedFetchImpl ?? null;
}
export function supportsDnsPinnedFetch(fetchImpl) {
    return resolveDnsPinnedFetch(fetchImpl) !== null;
}
export function isNativeOrBoundGlobalFetch(fetchImpl) {
    if (fetchImpl === globalThis.fetch)
        return true;
    const expectedBoundName = `bound ${globalThis.fetch.name || "fetch"}`;
    return (fetchImpl.name === expectedBoundName &&
        Function.prototype.toString.call(fetchImpl).includes("[native code]"));
}
export function attachDnsPinnedAddresses(init, addresses) {
    Object.defineProperty(init, DNS_PINNED_ADDRESSES, {
        configurable: true,
        enumerable: true,
        value: addresses,
    });
    return init;
}
export function readDnsPinnedAddresses(init) {
    const addresses = init?.[DNS_PINNED_ADDRESSES];
    return Array.isArray(addresses) && addresses.length > 0 ? addresses : null;
}
//# sourceMappingURL=fetch-capabilities.js.map