import { __spreadArrays } from "tslib";
var ENGINE_EDGE = { expected: ['Edge'] };
var ENGINE_GECKO = { expected: ['Gecko'] };
var ENGINE_KHTML = { expected: ['KHTML'] };
var ENGINE_WEBKIT = { expected: ['AppleWebKit'] };
var ENGINE_BLINK = { expected: ['Chrome', 'Chromium'], not: ENGINE_EDGE.expected };
var ENGINE_PRESTO = { expected: ['Opera'] };
var ENGINE_TRIDENT = { expected: ['Trident', 'MSIE'] };
var OS_ANDROID = { expected: ['Android'] };
var OS_IOS = { expected: ['iPad', 'iPhone'] };
var OS_WINDOWS_PHONE = { expected: ['Windows Phone', 'XBLWP7', 'ZuneWP7', 'WP7'] };
var OS_WINDOWS = { expected: ['Windows NT'], not: OS_WINDOWS_PHONE.expected };
var OS_MACOS = { expected: ['Mac OS X', 'Mac Os X'] };
var OS_UNIX = { expected: ['X11'] };
var OS_LINUX = { expected: ['Linux'] };
var OS_MOBILE_GENERIC = { expected: ['Mobi'] };
var OS_MOBILE = { expected: __spreadArrays(OS_MOBILE_GENERIC.expected, OS_ANDROID.expected, OS_IOS.expected, OS_WINDOWS_PHONE.expected) };
var OS_DESKTOP = { expected: __spreadArrays(OS_WINDOWS.expected, OS_MACOS.expected, OS_UNIX.expected, OS_LINUX.expected) };
var UserAgent = /** @class */ (function () {
    function UserAgent() {
        this.state = {
            isEdge: false,
            isGecko: false,
            isKHTML: false,
            isWebKit: false,
            isBlink: false,
            isPresto: false,
            isTrident: false,
            isWindows: false,
            isMacOs: false,
            isUnix: false,
            isLinux: false,
            isAndroid: false,
            isIOs: false,
            isWindowsPhone: false,
            isMobile: false,
            isDesktop: false
        };
        this.initUserAgentEngines();
        this.initUserAgentOS();
        this.initHardware();
    }
    UserAgent.prototype.isMobile = function () {
        return this.state.isMobile;
    };
    UserAgent.prototype.isDesktop = function () {
        return this.state.isDesktop;
    };
    UserAgent.prototype.isEdge = function () {
        return this.state.isEdge;
    };
    UserAgent.prototype.isGecko = function () {
        return this.state.isGecko;
    };
    UserAgent.prototype.isKHTML = function () {
        return this.state.isKHTML;
    };
    UserAgent.prototype.isWebKit = function () {
        return this.state.isWebKit;
    };
    UserAgent.prototype.isBlink = function () {
        return this.state.isBlink;
    };
    UserAgent.prototype.isPresto = function () {
        return this.state.isPresto;
    };
    UserAgent.prototype.isTrident = function () {
        return this.state.isTrident;
    };
    UserAgent.prototype.isWindows = function () {
        return this.state.isWindows;
    };
    UserAgent.prototype.isMacOs = function () {
        return this.state.isMacOs;
    };
    UserAgent.prototype.isUnix = function () {
        return this.state.isUnix;
    };
    UserAgent.prototype.isLinux = function () {
        return this.state.isLinux;
    };
    UserAgent.prototype.isAndroid = function () {
        return this.state.isAndroid;
    };
    UserAgent.prototype.isIOs = function () {
        return this.state.isIOs;
    };
    UserAgent.prototype.isWindowsPhone = function () {
        return this.state.isWindowsPhone;
    };
    UserAgent.prototype.initHardware = function () {
        this.state.isMobile = this.userAgentIs(OS_MOBILE);
        this.state.isDesktop = !this.state.isMobile;
    };
    UserAgent.prototype.initUserAgentOS = function () {
        this.state.isWindows = this.userAgentIs(OS_WINDOWS);
        this.state.isMacOs = this.userAgentIs(OS_MACOS);
        this.state.isUnix = this.userAgentIs(OS_UNIX);
        this.state.isLinux = this.userAgentIs(OS_LINUX);
        this.state.isAndroid = this.userAgentIs(OS_ANDROID);
        this.state.isIOs = this.userAgentIs(OS_IOS);
        this.state.isWindowsPhone = this.userAgentIs(OS_WINDOWS_PHONE);
    };
    UserAgent.prototype.initUserAgentEngines = function () {
        this.state.isEdge = this.userAgentIs(ENGINE_EDGE);
        this.state.isGecko = this.userAgentIs(ENGINE_GECKO);
        this.state.isKHTML = this.userAgentIs(ENGINE_KHTML);
        this.state.isWebKit = this.userAgentIs(ENGINE_WEBKIT);
        this.state.isBlink = this.userAgentIs(ENGINE_BLINK);
        this.state.isPresto = this.userAgentIs(ENGINE_PRESTO);
        this.state.isTrident = this.userAgentIs(ENGINE_TRIDENT);
    };
    UserAgent.prototype.userAgentIs = function (specification) {
        var containsExpected = specification.expected.reduce(function (previous, value) {
            return previous || navigator.userAgent.indexOf(value) !== -1;
        }, false);
        if (!specification.not) {
            return containsExpected;
        }
        var containsNotExpected = specification.not.reduce(function (previous, value) {
            return previous || navigator.userAgent.indexOf(value) !== -1;
        }, false);
        return containsExpected && !containsNotExpected;
    };
    return UserAgent;
}());
export { UserAgent };
var UserAgentUtil = new UserAgent();
export default UserAgentUtil;
//# sourceMappingURL=user-agent.js.map