"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = connect;

function _ssh() {
  const data = _interopRequireDefault(require("./ssh"));

  _ssh = function () {
    return data;
  };

  return data;
}

function _fs() {
  const data = _interopRequireDefault(require("./fs"));

  _fs = function () {
    return data;
  };

  return data;
}

function _exceptions() {
  const data = require("./exceptions");

  _exceptions = function () {
    return data;
  };

  return data;
}

function _utils() {
  const data = require("../../utils");

  _utils = function () {
    return data;
  };

  return data;
}

function _logger() {
  const data = _interopRequireDefault(require("../../logger/logger"));

  _logger = function () {
    return data;
  };

  return data;
}

function connect(host, strategiesNames) {
  if (host.startsWith('ssh://') || host.startsWith('bit://')) {
    _logger().default.debug(`Establishing a new SSH connection to ${host}`);

    const sshProps = (0, _utils().parseSSHUrl)(host);
    return new (_ssh().default)(sshProps).connect(strategiesNames);
  }

  if (host.startsWith('file://')) {
    return new (_fs().default)(host.replace('file://', '')).connect();
  }

  throw new (_exceptions().ProtocolNotSupported)();
}