"use strict";
var version = document.getElementById("version-pospercetakan");
function readTextFile(e, o) {
    var i = new XMLHttpRequest;
    i.overrideMimeType("application/json"),
    i.open("GET", e, !0),
    i.onreadystatechange = function () {
        4 === i.readyState && "200" == i.status && o(i.responseText)
    },
    i.send(null)
}
function version_local() {
    readTextFile(base_url + "version.json", (function (e) {
            var o = JSON.parse(e),
            i = o.aplikasi[0].product,
            n = o.aplikasi[0].version;
            version.innerHTML = i + " Version " + n,
            Cookies.set("version_local", n, {
                expires: 1
            })
        }))
}
function loadnotif() {
    if (null == Cookies.get("notif") || "" == Cookies.get("notif")) {
        if (1 == navigator.onLine)
            if ("admin" == level) {
                var e = base_url + "updateversi/cek_notifikasi";
                $.ajax({
                    type: "POST",
                    url: e,
                    data: {
                        tipe: "cek_notif"
                    },
                    cache: !1,
                    success: function (e) {
                        "error" == e ? $(".load-notif").html("") : (Cookies.set("notif", e, {
                                expires: 1
                            }), $(".load-notif").html(e))
                    }
                })
            } else
                $(".load-notif").html("")
    } else
        Cookies.get("version") != Cookies.get("version_local") && $(".load-notif").html(Cookies.get("notif"))
}
function deleteCookies() {
    Cookies.remove("version_local"),
    Cookies.remove("notif"),
    Cookies.remove("product"),
    Cookies.remove("version")
}
// loadnotif(), version_local(), window.addEventListener("online", (() => loadnotif())), window.addEventListener("offline", (() => version_local())), navigator.onLine ? Cookies.get("version") == Cookies.get("version_local") ? version.innerHTML = Cookies.get("product") + " Version " + Cookies.get("version") : readTextFile("https://mywidget.github.io/update_checker_kasir.json", (function (e) {
            // var o = JSON.parse(e),
            // i = o.aplikasi.reverse()[0].product,
            // n = o.aplikasi.reverse()[0].version;
            // Cookies.set("product", i, {
                // expires: 1
            // }),
            // Cookies.set("version", n, {
                // expires: 1
            // })
        // })) : Cookies.get("version") ? version.innerHTML = Cookies.get("product") + " Version " + Cookies.get("version") : readTextFile(base_url + "version.json", (function (e) {
            // var o = JSON.parse(e),
            // i = o.aplikasi[0].product,
            // n = o.aplikasi[0].version;
            // version.innerHTML = i + " Version " + n,
            // Cookies.set("product", i, {
                // expires: 1
            // }),
            // Cookies.set("version", n, {
                // expires: 1
            // })
        // })), $(document).on("click", ".badge-counter", (function () {
        // location.reload(),
        // deleteCookies()
    // }));
