"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const enums_1 = require("./lib/enums");
const android_controller_1 = require("./lib/android-controller");
const ios_controller_1 = require("./lib/ios-controller");
const device_controller_1 = require("./lib/device-controller");
var enums_2 = require("./lib/enums");
exports.Platform = enums_2.Platform;
exports.DeviceType = enums_2.DeviceType;
exports.Status = enums_2.Status;
exports.AndroidKeyEvent = enums_2.AndroidKeyEvent;
var android_controller_2 = require("./lib/android-controller");
exports.AndroidController = android_controller_2.AndroidController;
var ios_controller_2 = require("./lib/ios-controller");
exports.IOSController = ios_controller_2.IOSController;
var device_controller_2 = require("./lib/device-controller");
exports.DeviceController = device_controller_2.DeviceController;
var virtual_device_controller_1 = require("./lib/mobile-base/virtual-device-controller");
exports.VirtualDeviceController = virtual_device_controller_1.VirtualDeviceController;
var virtual_device_1 = require("./lib/mobile-base/virtual-device");
exports.VirtualDevice = virtual_device_1.VirtualDevice;
var DeviceSignals_1 = require("./lib/enums/DeviceSignals");
exports.DeviceSignal = DeviceSignals_1.DeviceSignal;
var utils_1 = require("./lib/utils");
exports.sortAscByApiLevelPredicate = utils_1.sortAscByApiLevelPredicate;
exports.sortDescByApiLevelPredicate = utils_1.sortDescByApiLevelPredicate;
exports.filterPredicate = utils_1.filterPredicate;
exports.killAllProcessAndRelatedCommand = utils_1.killAllProcessAndRelatedCommand;
exports.convertStringToRegExp = utils_1.convertStringToRegExp;
// (async () => await DeviceController.getDevices({ platform: Platform.ANDROID }))()
function getAndroidDevices(verbose = false) {
    return __awaiter(this, void 0, void 0, function* () {
        yield android_controller_1.AndroidController.getAllDevices(verbose);
    });
}
exports.getAndroidDevices = getAndroidDevices;
function getIOSDevices() {
    return __awaiter(this, void 0, void 0, function* () {
        return yield ios_controller_1.IOSController.getAllDevices();
    });
}
exports.getIOSDevices = getIOSDevices;
function getDevices(platform) {
    return __awaiter(this, void 0, void 0, function* () {
        return yield device_controller_1.DeviceController.getDevices({ platform: platform });
    });
}
exports.getDevices = getDevices;
function startEmulator(emulator, options) {
    return __awaiter(this, void 0, void 0, function* () {
        yield android_controller_1.AndroidController.startEmulator(emulator, options);
    });
}
exports.startEmulator = startEmulator;
function startSimulator(simulator, options) {
    return __awaiter(this, void 0, void 0, function* () {
        yield ios_controller_1.IOSController.startSimulator(simulator);
    });
}
exports.startSimulator = startSimulator;
function startDevice(device, options) {
    return __awaiter(this, void 0, void 0, function* () {
        yield device_controller_1.DeviceController.startDevice(device, options);
    });
}
exports.startDevice = startDevice;
/**
 * Still not impleneted
 */
function killAllEmulators() {
    android_controller_1.AndroidController.killAll();
}
exports.killAllEmulators = killAllEmulators;
function killAllSimulators() {
    ios_controller_1.IOSController.killAll();
}
exports.killAllSimulators = killAllSimulators;
function killEmulator(emulator) {
    android_controller_1.AndroidController.kill(emulator);
}
exports.killEmulator = killEmulator;
function killSimulator(simulator) {
    ios_controller_1.IOSController.kill(simulator.token);
}
exports.killSimulator = killSimulator;
/**
 * Still not implemented
 */
function restartDevice(device) {
    return __awaiter(this, void 0, void 0, function* () {
        if (device.platform === enums_1.Platform.ANDROID) {
            android_controller_1.AndroidController.restartDevice(device);
        }
        else {
            ios_controller_1.IOSController.restartDevice(device);
        }
    });
}
exports.restartDevice = restartDevice;
if (process.argv.indexOf("--startSimulator") >= 0) {
    const name = process.argv[process.argv.indexOf("--name") + 1];
    const apiLevel = process.argv.indexOf("--apiLevel") >= 0 ? process.argv[process.argv.indexOf("--apiLevel") + 1] : undefined;
    console.log("API LEVEL: ", apiLevel);
    getIOSDevices().then(devices => startSimulator(devices.get(name).filter(d => apiLevel ? d.apiLevel === apiLevel : true)[0])
        .then(d => console.log(d))
        .catch(e => console.log("", e)));
}
//# sourceMappingURL=index.js.map