"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebkitBrowserEngine = void 0;
const mobileEmulationUtil_1 = require("../browserLauncher/mobileEmulationUtil");
const browserEngine_1 = require("./browserEngine");
const async_retry_1 = __importDefault(require("async-retry"));
class WebkitBrowserEngine {
    name() {
        return 'webkit';
    }
    getBrowserLaunchOptions(options) {
        return {
            commandLineArgs: [],
            ignoreCommandLineDefaultArgs: [],
            defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig),
        };
    }
    getExecutionEngineBrowserLaunchOptions(options, _proxyInfo) {
        return {
            commandLineArgs: [],
            defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig),
        };
    }
    prepareBrowserPreferencesDirectory(_windowPlacement) {
        return (0, async_retry_1.default)(() => {
            const tempBrowserPreferencesDirectory = (0, browserEngine_1.getTempBrowserPrefDirectory)(this.name());
            return tempBrowserPreferencesDirectory;
        }, {
            retries: 5,
        });
    }
    findBrowserExecutable() {
        return Promise.resolve('');
    }
    getProxySpec(proxyInfo) {
        const { httpProxy, socksProxy, excludeFromProxy } = proxyInfo;
        const server = httpProxy ?? socksProxy;
        if (!server) {
            throw new Error('no proxy provided for cloud run');
        }
        const bypass = excludeFromProxy?.length
            ? excludeFromProxy.join(',')
            : undefined;
        return { server, bypass };
    }
}
exports.WebkitBrowserEngine = WebkitBrowserEngine;
