"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createNetworkNode = void 0;
const uuid_1 = require("uuid");
const utils_1 = require("@streamr/utils");
const NodeToTracker_1 = require("./protocol/NodeToTracker");
const NodeToNode_1 = require("./protocol/NodeToNode");
const RtcSignaller_1 = require("./logic/RtcSignaller");
const NetworkNode_1 = require("./logic/NetworkNode");
const NegotiatedProtocolVersions_1 = require("./connection/NegotiatedProtocolVersions");
const PeerInfo_1 = require("./connection/PeerInfo");
const NodeClientWsEndpoint_1 = __importDefault(require("./connection/ws/NodeClientWsEndpoint"));
const WebRtcEndpoint_1 = require("./connection/webrtc/WebRtcEndpoint");
const NodeWebRtcConnection_1 = require("./connection/webrtc/NodeWebRtcConnection");
const createNetworkNode = ({ id = (0, uuid_1.v4)(), location, trackers, metricsContext = new utils_1.MetricsContext(), peerPingInterval, trackerPingInterval, disconnectionWaitTime, newWebrtcConnectionTimeout, rttUpdateTimeout, webrtcDatachannelBufferThresholdLow, webrtcDatachannelBufferThresholdHigh, iceServers = [], trackerConnectionMaintenanceInterval, webrtcDisallowPrivateAddresses = true, acceptProxyConnections }) => {
    const peerInfo = PeerInfo_1.PeerInfo.newNode(id, undefined, undefined, location);
    const endpoint = new NodeClientWsEndpoint_1.default(peerInfo, trackerPingInterval);
    const nodeToTracker = new NodeToTracker_1.NodeToTracker(endpoint);
    const webRtcSignaller = new RtcSignaller_1.RtcSignaller(peerInfo, nodeToTracker);
    const negotiatedProtocolVersions = new NegotiatedProtocolVersions_1.NegotiatedProtocolVersions(peerInfo);
    const nodeToNode = new NodeToNode_1.NodeToNode(new WebRtcEndpoint_1.WebRtcEndpoint(peerInfo, iceServers, webRtcSignaller, metricsContext, negotiatedProtocolVersions, NodeWebRtcConnection_1.webRtcConnectionFactory, newWebrtcConnectionTimeout, peerPingInterval, webrtcDatachannelBufferThresholdLow, webrtcDatachannelBufferThresholdHigh, webrtcDisallowPrivateAddresses));
    return new NetworkNode_1.NetworkNode({
        peerInfo,
        trackers,
        protocols: {
            nodeToTracker,
            nodeToNode
        },
        metricsContext,
        disconnectionWaitTime,
        rttUpdateTimeout,
        trackerConnectionMaintenanceInterval,
        acceptProxyConnections
    });
};
exports.createNetworkNode = createNetworkNode;
//# sourceMappingURL=createNetworkNode.js.map