/**
 * Registry of core protocols. Owned by a `Dwn` instance (not a static singleton)
 * so that each DWN — including those in tests — gets an isolated registry.
 */
export class CoreProtocolRegistry {
    _protocols = new Map();
    /** Register a core protocol. */
    register(protocol) {
        this._protocols.set(protocol.uri, protocol);
    }
    /** Get a core protocol by URI, or `undefined` if not registered. */
    get(uri) {
        return this._protocols.get(uri);
    }
    /**
     * Get the protocol definition for a core protocol, or `undefined`.
     * Used by `fetchProtocolDefinition()` to bypass the message store for core protocols.
     */
    getDefinition(uri) {
        return this._protocols.get(uri)?.definition;
    }
    /** Check whether a URI is a registered core protocol. */
    has(uri) {
        return this._protocols.has(uri);
    }
    /** Get all registered core protocols. */
    all() {
        return [...this._protocols.values()];
    }
    /**
     * Delegate error code mapping to all registered core protocols.
     * Returns the first non-`undefined` status code, or `undefined` if no protocol claims the error.
     */
    mapErrorToStatusCode(errorCode) {
        for (const protocol of this._protocols.values()) {
            const status = protocol.mapErrorToStatusCode?.(errorCode);
            if (status !== undefined) {
                return status;
            }
        }
        return undefined;
    }
}
//# sourceMappingURL=core-protocol.js.map