"use strict";
/**
 * Copyright (c) Microsoft Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPlaywright = exports.Playwright = void 0;
const path = require("path");
const tracer_1 = require("../trace/tracer");
const android_1 = require("./android/android");
const backendAdb_1 = require("./android/backendAdb");
const chromium_1 = require("./chromium/chromium");
const electron_1 = require("./electron/electron");
const firefox_1 = require("./firefox/firefox");
const selectors_1 = require("./selectors");
const harTracer_1 = require("./supplements/har/harTracer");
const inspectorController_1 = require("./supplements/inspectorController");
const webkit_1 = require("./webkit/webkit");
class Playwright {
    constructor(isInternal, packagePath, browsers) {
        this.selectors = selectors_1.serverSelectors;
        this.options = {
            isInternal,
            contextListeners: isInternal ? [] : [
                new inspectorController_1.InspectorController(),
                new tracer_1.Tracer(),
                new harTracer_1.HarTracer()
            ]
        };
        const chromium = browsers.find(browser => browser.name === 'chromium');
        this.chromium = new chromium_1.Chromium(packagePath, chromium, this.options);
        const firefox = browsers.find(browser => browser.name === 'firefox');
        this.firefox = new firefox_1.Firefox(packagePath, firefox, this.options);
        const webkit = browsers.find(browser => browser.name === 'webkit');
        this.webkit = new webkit_1.WebKit(packagePath, webkit, this.options);
        this.electron = new electron_1.Electron(this.options);
        this.android = new android_1.Android(new backendAdb_1.AdbBackend(), this.options);
    }
}
exports.Playwright = Playwright;
function createPlaywright(isInternal = false) {
    return new Playwright(isInternal, path.join(__dirname, '..', '..'), require('../../browsers.json')['browsers']);
}
exports.createPlaywright = createPlaywright;
//# sourceMappingURL=playwright.js.map