import { noise } from '@chainsafe/libp2p-noise';
import { yamux } from '@chainsafe/libp2p-yamux';
import { delegatedHTTPRoutingDefaults } from '@helia/delegated-routing-client';
import { delegatedRoutingV1HttpApiClientContentRouting, delegatedRoutingV1HttpApiClientPeerRouting } from '@helia/delegated-routing-v1-http-api-client';
import { autoNAT } from '@libp2p/autonat';
import { bootstrap } from '@libp2p/bootstrap';
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2';
import { dcutr } from '@libp2p/dcutr';
import { http } from '@libp2p/http';
import { identify, identifyPush } from '@libp2p/identify';
import { kadDHT } from '@libp2p/kad-dht';
import { keychain } from '@libp2p/keychain';
import { mplex } from '@libp2p/mplex';
import { ping } from '@libp2p/ping';
import { webRTC, webRTCDirect } from '@libp2p/webrtc';
import { webSockets } from '@libp2p/websockets';
import { userAgent } from 'libp2p/user-agent';
import { bootstrapConfig } from "./bootstrappers.js";
export function libp2pDefaults(options = {}) {
    let agentVersion;
    if (options.name != null && options.version != null) {
        agentVersion = `${options.name}/${options.version} ${userAgent()}`;
    }
    return {
        privateKey: options.privateKey,
        dns: options.dns,
        nodeInfo: {
            userAgent: agentVersion
        },
        addresses: {
            listen: [
                '/p2p-circuit',
                '/webrtc'
            ]
        },
        transports: [
            circuitRelayTransport(),
            webRTC(),
            webRTCDirect(),
            webSockets()
        ],
        connectionEncrypters: [
            noise()
        ],
        streamMuxers: [
            yamux(),
            mplex()
        ],
        peerDiscovery: [
            bootstrap(bootstrapConfig)
        ],
        services: {
            autoNAT: autoNAT(),
            dcutr: dcutr(),
            delegatedContentRouting: delegatedRoutingV1HttpApiClientContentRouting(delegatedHTTPRoutingDefaults()),
            delegatedPeerRouting: delegatedRoutingV1HttpApiClientPeerRouting(delegatedHTTPRoutingDefaults()),
            dht: kadDHT({
                clientMode: true
            }),
            identify: identify(),
            identifyPush: identifyPush(),
            keychain: keychain(options.keychain),
            ping: ping(),
            http: http()
        }
    };
}
//# sourceMappingURL=libp2p-defaults.browser.js.map