/**
* PDA v1.1.2
* (c) 2024 Product Designer App
* @license GPLv3
* Theme
* Free version
* Unminify code for Dev
**/
var pdappAPI = {
    tool: {
        toDate: function (r) {
            let e = new Date(r.replaceAll("-", "/")).toLocaleTimeString(),
                t = r.split(" "),
                o = e.split(" "),
                a = o[0].split(":");
            return void 0 !== o[1] ? t[0] + " " + a[0] + ":" + a[1] + o[1] : r;
        },
        setLocalVar: function (r, e) {
            localStorage.setItem(r, e);
        },
        getLocalVar: function (r, e = "") {
            var t = localStorage.getItem(r);
            return null != t ? t : e;
        },
        getData: function (r) {
            return new Promise(function (e, t) {
                let o = {
                    method: "GET",
                    url: r,
                    dataType: "json",
                    success: function (r) {
                        0 == r
                            ? t({ msg: "403 Forbidden", error: 1 })
                            : (void 0 === r.error && (r.error = 1),
                              0 === r.error ? e({ msg: r.msg, data: r.data }) : t({ msg: r.msg, error: r.error }));
                    },
                    error: function (r, e, o) {
                        t({ msg: o, error: 1 });
                    },
                };
                jQuery.ajax(o);
            });
        },
        postData: function (r, e) {
            return new Promise(function (t, o) {
                let a = {
                    method: "POST",
                    url: r,
                    dataType: "json",
                    data: e,
                    success: function (r) {
                        0 == r
                            ? o({ msg: "403 Forbidden", error: 1 })
                            : (void 0 === r.error && (r.error = 1),
                              0 === r.error ? t({ msg: r.msg, data: r.data }) : o({ msg: r.msg, error: r.error }));
                    },
                    error: function (r, e, t) {
                        o({ msg: t, error: 1 });
                    },
                };
                jQuery.ajax(a);
            });
        },
        updateURL: function (r) {
            let e = pdappAdminUrl + "admin.php?page=product-designer-app-" + r;
            window.history.pushState(null, "", e);
        },
    },
};