/**
 * Minified by jsDelivr using Terser v3.14.1.
 * Original file: /npm/js-cookie@2.2.1/src/js.cookie.js
 * 
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function (e) { var n; if ("function" == typeof define && define.amd && (define(e), n = !0), "object" == typeof exports && (module.exports = e(), n = !0), !n) { var t = window.Cookies, o = window.Cookies = e(); o.noConflict = function () { return window.Cookies = t, o } } }(function () { function e() { for (var e = 0, n = {}; e < arguments.length; e++) { var t = arguments[e]; for (var o in t) n[o] = t[o] } return n } function n(e) { return e.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent) } return function t(o) { function r() { } function i(n, t, i) { if ("undefined" != typeof document) { "number" == typeof (i = e({ path: "/" }, r.defaults, i)).expires && (i.expires = new Date(1 * new Date + 864e5 * i.expires)), i.expires = i.expires ? i.expires.toUTCString() : ""; try { var c = JSON.stringify(t); /^[\{\[]/.test(c) && (t = c) } catch (e) { } t = o.write ? o.write(t, n) : encodeURIComponent(String(t)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent), n = encodeURIComponent(String(n)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[\(\)]/g, escape); var f = ""; for (var u in i) i[u] && (f += "; " + u, !0 !== i[u] && (f += "=" + i[u].split(";")[0])); return document.cookie = n + "=" + t + f } } function c(e, t) { if ("undefined" != typeof document) { for (var r = {}, i = document.cookie ? document.cookie.split("; ") : [], c = 0; c < i.length; c++) { var f = i[c].split("="), u = f.slice(1).join("="); t || '"' !== u.charAt(0) || (u = u.slice(1, -1)); try { var a = n(f[0]); if (u = (o.read || o)(u, a) || n(u), t) try { u = JSON.parse(u) } catch (e) { } if (r[a] = u, e === a) break } catch (e) { } } return e ? r[e] : r } } return r.set = i, r.get = function (e) { return c(e, !1) }, r.getJSON = function (e) { return c(e, !0) }, r.remove = function (n, t) { i(n, "", e(t, { expires: -1 })) }, r.defaults = {}, r.withConverter = t, r }(function () { }) });
//# sourceMappingURL=/sm/b0ce608ffc029736e9ac80a8dd6a7db2da8e1d45d2dcfc92043deb2214aa30d8.map

window.GreenApplication = {
    localKey: "GreenWidgetData",
    inited: false,
    loading: false,
    init: function () {
        var _this = window.GreenApplication;
        console.log("[Green] GreenApplication.init called...");
        if (storageAvailable("localStorage")) {
            _this.localStorage.storage = window.localStorage;
        }
        if (storageAvailable("sessionStorage")) {
            _this.sessionStorage.storage = window.sessionStorage;
        }

        if (!isVoid(_this.localStorage.storage)) {
            var data = _this.localStorage.get(_this.localKey);
            if (data === false || isVoid(data)) {
                data = {
                    "Customer": "",
                    "Accounts": []
                };
                _this.localStorage.set(_this.localKey, JSON.stringify(data));
            }
        }

        _this.inited = true;
    },
    localStorage: {
        storage: null,
        get: function (key) {
            if (isVoid(window.GreenApplication.localStorage.storage)) { return false; }
            return window.GreenApplication.localStorage.storage.getItem(key);
        },
        set: function (key, value) {
            if (isVoid(window.GreenApplication.localStorage.storage)) { return false; }
            window.GreenApplication.localStorage.storage.setItem(key, value);
            return true;
        }
    },
    sessionStorage: {
        storage: null,
        get: function (key) {
            if (isVoid(window.GreenApplication.sessionStorage.storage)) { return false; }
            return window.GreenApplication.sessionStorage.storage.getItem(key);
        },
        set: function (key, value) {
            if (isVoid(window.GreenApplication.sessionStorage.storage)) { return false; }
            window.GreenApplication.sessionStorage.storage.setItem(key, value);
            return true;
        }
    },
    Greenflow: {
        loadWidgetData: function (amount, display, firstName, lastName, emailAddress) {
            console.log("[Green] loadWidgetData called...", amount, firstName, lastName, emailAddress);
            var d = {
                "amount": amount
            };
            if (!isVoid(display)) { d.display = display; } else { d.display = "modal"; }

            if (GreenApplication.localStorage.get(GreenApplication.localKey)) {
                d.customerId = jQuery.parseJSON(GreenApplication.localStorage.get(GreenApplication.localKey)).Customer;
            } else {
                if (!isVoid(firstName) || !isVoid(lastName) || !isVoid(emailAddress)) {
                    d.customerData = {};
                    if (!isVoid(firstName)) d.customerData.firstName = firstName;
                    if (!isVoid(lastName)) d.customerData.lastName = lastName;
                    if (!isVoid(emailAddress)) d.customerData.emailAddress = emailAddress;
                }
            }

            return d;
        }
    }
};
window.GreenApplication.init();

function storageAvailable(type) {
    var storage;
    try {
        storage = window[type];
        var x = '__storage_test__';
        storage.setItem(x, x);
        storage.removeItem(x);
        return true;
    }
    catch (e) {
        return e instanceof DOMException && (
            e.code === 22 ||
            e.code === 1014 ||
            e.name === 'QuotaExceededError' ||
            e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
            (storage && storage.length !== 0);
    }
}

function showBSLoader(div, call, additionalClasses, append) {
    if (isVoid(additionalClasses)) {
        additionalClasses = "";
    }
    if (isVoid(append)) {
        append = true;
    }

    var loader = jQuery("<div class='spinner-border " + additionalClasses + "' role='status'>Loading</div>");

    if (append) {
        div.append(loader);
    } else {
        div.prepend(loader);
    }

    if (Array.isArray(call)) {
        Promise.all(call).then(function () {
            loader.remove();
        }, function (err) {
            unexpectedResponse(err);
            loader.remove();
        });
    } else if (Promise.resolve(call) === call) {
        call.then(function () {
            loader.remove();
        }, function (err) {
            unexpectedResponse(err);
            loader.remove();
        });
    }

    return loader;
}

function isVoid(obj) {
    return obj === null || obj === undefined;
}