const ua = window.navigator.userAgent;

export const isAndroid = /Android/.test(ua)

export const isWebView = () => {
    return ua.includes("Instagram") || ua.includes("FBAN") || ua.includes("FBAV") || ua.includes("FBIOS");
}

export const webviewToSystemBrowser = (includeSystems: Array<"android" | "ios">) => {
    if (!isWebView()) return;

    if (includeSystems.includes("ios") && /iPad|iPhone|iPod/.test(ua)) {
        window.location.href = "x-safari-" + window.location.href;
    } else if (includeSystems.includes("android") && /Android/.test(ua)) {
        window.location.href = "intent:" + window.location.href + "#Intent;end";
    }
}