var reqcache = {};
var cacheHashContents = {};
var cache = {};
var responsecache = {};


var PrecacheStaleRevalidateURLs = [
    '/NewLeads',
    '/ListLeads',
    '/AccountSettings',
    '/Home',
    '/account_settings/details',
    '/NewLeads/Form/PreferredSitesOption',
    '/Datalist/NewPropertySubCategory',
    '/Datalist/NewPropertyCategory',
    '/starter.js',
    '/synclib.js',
    '/lib.js',
    '/UIALT.js',
    '/PhotoViewer',
    '/ViewAllPhotos',
    '/TransferMyCredit',
    '/UserList',
    '/UserModify',
    '/UserCreateUltimate',

];


const revision_no = 1;
var PrecacheStaticURLs = [
    {
        revision: 1,
        url: 'plugins/googlefonts/fonts.googleapis.com_css_familySourceSansPro300400400i700&displayfallback.css'
    },
    {
        revision: 1,
        url: 'plugins/fontawesome-free/css/all.min.css'
    },
    {
        revision: 1,
        url: '/dist/alt-theme/styles.css'
    },
    {
        revision: 1,
        url: '  https://fonts.gstatic.com/s/plusjakartasans/v7/LDIoaomQNQcsA88c7O9yZ4KMCoOg4Ko20yw.woff2'
    },
    {
        revision: 1,
        url: 'plugins/jquery/jquery.min.js'
    },
    {
        revision: 1,
        url: 'dist/css/jquery.dataTables.min.css'
    },
    {
        revision: 1,
        url: 'dist/js/jquery.dataTables.min.js'
    },
    {
        revision: 1,
        url: 'dist/js/moment.min.js'
    },
    {
        revision: 1,
        url: 'plugins/bootstrap/js/bootstrap.bundle.min.js'
    },
    {
        revision: 1,
        url: 'dist/js/adminlte.min.js'
    },
    {
        revision: 1,
        url: 'dist/js/bower.json'
    },
    {
        revision: 1,
        url: 'dist/js/qrcode.min.js'
    },
    {
        revision: 1,
        url: 'dist/js/FileSaver.min.js'
    },
    {
        revision: 1,
        url: 'dist/js/print.min.js'
    },
    {
        revision: 1,
        url: 'dist/css/select2.min.css'
    },
    {
        revision: 1,
        url: 'dist/js/select2.min.js'
    },
    {
        revision: 1,
        url: 'plugins/fontawesome-free/webfonts/fa-solid-900.woff2'
    },
    {
        revision: 1,
        url: 'plugins/googlefonts/6xK3dSBYKcSV-LCoeQqfX1RYOo3qOK7l.woff2'
    },
    {
        revision: revision_no,
        url: 'assets/qrcode.svg'
    },
    {
        revision: revision_no,
        url: 'assets/user-list.png'
    },
    {
        revision: revision_no,
        url: 'assets/CreateUser.png'
    },
    {
        revision: revision_no,
        url: 'assets/drawlottery.png'
    },
    {
        revision: revision_no,
        url: 'assets/creditrequests.png'
    },
    {
        revision: revision_no,
        url: 'assets/reports.png'
    },
    {
        revision: revision_no,
        url: 'assets/briefcase.png'
    },
    {
        revision: revision_no,
        url: 'assets/gear.png'
    },
    {
        revision: revision_no,
        url: 'assets/betshistory.png'
    },
    {
        revision: revision_no,
        url: 'assets/calendarhistory.png'
    },
    {
        revision: revision_no,
        url: 'assets/disableuser.png'
    },
    {
        revision: revision_no,
        url: 'assets/enable-user.png'
    },
    {
        revision: revision_no,
        url: 'assets/edituser.png'
    },
    {
        revision: 1,
        url: '/dist/js/toastr.min.js'
    },
    {
        revision: 1,
        url: '/dist/css/toastr.min.css'
    },
    {
        revision: revision_no,
        url: 'assets/exec.png'
    },
    {
        revision: revision_no,
        url: 'assets/notes.png'
    },
    {
        revision: revision_no,
        url: 'assets/profitgrowth.png'
    },
    {
        revision: revision_no,
        url: 'assets/transfercredit.png'
    },
    {
        revision: revision_no,
        url: 'assets/resetpassword.png'
    },
    {
        revision: revision_no,
        url: 'assets/accounting.png'
    },
    {
        revision: 1,
        url: 'plugins/googlefonts/6xKydSBYKcSV-LCoeQqfX1RYOo3ig4vwlxdu.woff2'
    },
    {
        revision: 1,
        url: 'plugins/googlefonts/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwlxdu.woff2'
    },

    {
        revision: 1,
        url: 'dist/css/adminlte.min.css'
    },
    {
        revision: 1,
        url: 'dist//css/adminlte.min.css'
    },
    {
        revision: 1,
        url: '/dist/alt-theme/icons-alipay.css'
    },
    {
        revision: 1,
        url: '/dist/alt-theme/icomoon.ttf?f1t4q3'
    },
    {
        revision: 1,
        url: '/dist/alt-theme/fonts.css'
    },
    {
        revision: 1,
        url: '/dist/alt-theme/bootstrap.css'
    },
    {
        revision: 1,
        url: '/assets/ListLeads.png'
    },
    {
        revision: 1,
        url: '/assets/NewLeads.png'
    },
    {
        revision: 1,
        url: '/dist/js/workbox-sw.js'
    },
    {
        revision: 1,
        url: '/assets/logs.png'
    },
    {
        revision: 1,
        url: '/assets/edit.png'
    },
    {
        revision: 1,
        url: '/assets/changestatus.png'
    },
    {
        revision: 1,
        url: '/dist/js/dropzone.min.js'
    },
    {
        revision: 1,
        url: '/dist/css/dropzone.min.css'
    },
    {
        revision: 1,
        url: '/assets/NewProperty.png'
    },
    {
        revision: 1,
        url: '/assets/house.png'
    },
    {
        revision: 1,
        url: '/assets/clear.png'
    },
    {
        revision: 1,
        url: '/dist/css/splide.min.css'
    },
    {
        revision: 1,
        url: '/dist/js/splide.min.js'
    },
    {
        revision: 1,
        url: '/dist/js/dexie.js'
    },
    {
        revision: 1,
        url: '/assets/sold.png'
    }
];

function inPrecacheStaticURLs(URL) {
    return PrecacheStaticURLs.some(item => item.url.includes(URL));
}

function replaceLineBreaks(input) {
    let output = input.replace(/\r\n/g, '<br>');
    output = output.replace(/\r/g, '<br>');
    output = output.replace(/\n/g, '<br>');
    return output;
}

function iterateArray(array, func) {
    if (!array || !func) { return false; }
    for (let i = 0; i < array.length; i++) {
        func(array[i], i);
    }
}

function divideArrayIntoSets(arr, setSize) {
    const result = [];
    for (let i = 0; i < arr.length; i += setSize) {
        const set = arr.slice(i, i + setSize);
        result.push(set);
    }
    return result;
}

function getFullURL(relativePath) {
    return new URL(relativePath, self.location.origin).href;
}
function isIndexAccessible(obj, path) {
    let current = obj;
    for (let key of path) {
        if (current !== undefined && current.hasOwnProperty(key)) {
            current = current[key];
        } else {
            return false;
        }
    }
    return true;
}
function isIndexAccessibleArray(array, index) {
    if (!Array.isArray(array) || typeof index !== 'number') {
        return false;
    }
    return index >= 0 && index < array.length;
}

let RegularURLCacheFUNC = {};
let CacheHash = {};

RegularURLCacheFUNC.Load = function (url, hashkey, dataobject = '') {
    const stringifydata = JSON.stringify(dataobject);
    if (cache[url][stringifydata] && cache[url][stringifydata].hash === hashkey) {
        return cache[url].data;
    }
    return false;
}
RegularURLCacheFUNC.DeleteByURL = function (url) {
    delete cache[url];
};

RegularURLCacheFUNC.Update = function (url, content, dataobject, hashkey) {
    //  console.log('updating ', url, ' data ', content);
    if (!url) { return false; }
    const stringifydata = JSON.stringify(dataobject);
    cache[url][stringifydata] = { hash: hashkey, data: content };
};


CacheHash.Load = function (hash) {
    if (!hash) {
        return false;
    }
    if (cacheHashContents[hash]) {
        return cacheHashContents[hash];
    } else {
        return false;
    }
};


CacheHash.Delete = function (hash) {
    if (!hash) { return false; }
    delete cacheHashContents[hash];
}

CacheHash.Update = function (hash, content) {
    if (!hash) { return false; }
    // console.log('updating ', hash, ' data ', content);
    cacheHashContents[hash] = content;
}

function InitializeReqCache(url, datavalue = '', object = '') {
    if (!object) { object = ''; }
    if (object) { object = JSON.stringify(object); }
    if (!reqcache[url]) {
        reqcache[url] = {};
    }
    if (!reqcache[url][datavalue]) {
        reqcache[url][datavalue] = {};
    }
    if (!reqcache[url][datavalue][object]) {
        reqcache[url][datavalue][object] = '';
    }
}

function reqcacheload(url, datavalue = '', object = '') {
    if (!url) return false;

    if (!object) object = '';
    if (object == 'null') object = 'object';
    if (!datavalue) datavalue = '';
    if (object) object = JSON.stringify(object);

    const OriginalURL = url;

    // ✅ Helper: join origin + path safely (removes duplicate slashes)
    const joinURL = (base, path) => {
        return base.replace(/\/+$/, '') + '/' + path.replace(/^\/+/, '');
    };

    // ✅ 1. Try original (exact) URL first
    if (isIndexAccessible(reqcache, [url, datavalue, object])) {
        // console.log('Loaded from exact url', url);
        return reqcache[url][datavalue][object];
    }

    // ✅ 2. Browser mode — handle absolute vs relative URLs properly
    if (typeof window !== 'undefined') {
        const origin = window.location.origin;
        const isAbsolute = /^https?:\/\//i.test(OriginalURL);

        // 🔹 Only prefix if it's *not* an absolute URL
        if (!isAbsolute) {
            // Try normalized URL variations
            const combined1 = joinURL(origin, OriginalURL);
            if (isIndexAccessible(reqcache, [combined1, datavalue, object])) {
                // console.log('Loaded from full url', combined1);
                return reqcache[combined1][datavalue][object];
            }

            const combined2 = joinURL(origin, '/' + OriginalURL);
            if (isIndexAccessible(reqcache, [combined2, datavalue, object])) {
                // console.log('Loaded from full url', combined2);
                return reqcache[combined2][datavalue][object];
            }
        }
    }

    // console.warn('Unable to Load Cache', url, datavalue, object);
    return false;
}


function reqcacheloadOLD(url, datavalue = '', object = '') {
    if (!url) { return false; }
    if (!object) { object = ''; }
    if (object == 'null') { object = 'object'; }
    if (!datavalue) { datavalue = ''; }
    if (object) { object = JSON.stringify(object); }
    const OriginalURL = url;

    if (isIndexAccessible(reqcache, [url, datavalue, object])) {
        console.log('Loaded from full url', url);
        return reqcache[url][datavalue][object];
    }

    if (typeof window !== 'undefined') {
        url = window.location.origin + '' + OriginalURL;
        if (isIndexAccessible(reqcache, [url, datavalue, object])) {
            console.log('Loaded from full url', url);
            return reqcache[url][datavalue][object];
        }
        url = window.location.origin + '/' + OriginalURL;
        if (isIndexAccessible(reqcache, [url, datavalue, object])) {
            console.log('Loaded from full url', url);
            return reqcache[url][datavalue][object];
        }
    }
    console.log('Unable to Load Cache', url, datavalue, object);

    /*
    if (typeof window !== 'undefined') {
        url=window.location.origin+''+url;
        if (isIndexAccessible(reqcache, [url, datavalue, object])) {
            return reqcache[url][datavalue][object];
        }
    }
        */

    return false;
}


function reqcacheupdate(url, content = '', datavalue = '', object = '') {
    if (!url) { return false; }
    if (!object) { object = ''; }
    if (object == 'null') { object = ''; }
    if (!datavalue) { datavalue = ''; }
    if (typeof object === 'object') {
        object = JSON.stringify(object);
    }
    // console.log('updated ',url,content,datavalue,object);
    InitializeReqCache(url, datavalue, object);
    //  console.log(url,object, content);
    reqcache[url][datavalue][object] = content;
}

responsecacheFunc = {};
responsecacheFunc.Update = function (url, reqbody, response) {
    reqbody = JSON.stringify(reqbody);
    if (!responsecache.url) {
        responsecache[url] = {};
    }
    responsecache.url.reqbody = response;

};
responsecache.Delete = function () {

};
responsecacheFunc.Load = function () {
    if (responsecache) {

    }
};

function checkIfHostIsOnline() {
    const host = window.location.origin;

    return fetch(host, { method: 'HEAD', mode: 'no-cors' })
        .then(() => true) // If the fetch is successful, return true
        .catch(() => false); // If there's an error, return false
}

function FetchDataAndPostInterval(url, message_type, interval, method = 'GET', data = null, fromVarCache = false) {
    if (!url || !message_type || !interval) { return false; }
    if (SWInterval[message_type]) {
        // console.warn(`Interval for type "${message_type}" is already set. Aborting.`);
        return;
    }
    function sendPostCode(response, type) {
        self.postMessage({ type: message_type, 'data': response });
    }
    SWInterval[message_type] = setInterval(() => fetchDataAndProcess(getFullURL(url), sendPostCode, method, data, null, fromVarCache), interval);
}

function base64ToBlob(base64, type) {
    const binary = atob(base64);
    const len = binary.length;
    const bytes = new Uint8Array(len);
    for (let i = 0; i < len; i++) {
        bytes[i] = binary.charCodeAt(i);
    }
    return new Blob([bytes], { type: type });
}

function reqcacheupdateFile(filehashkey, blobdata) {
    return reqcacheupdate('/RequestData/File/' + filehashkey, blobdata);
}

function reqcacheupdateBase64toFile(filehashkey, base64, fileMimetype) {
    const blobdata = base64ToBlob(base64, fileMimetype);
    return reqcacheupdateFile(filehashkey, blobdata);
}

function toQueryStringLegacy(params, prefix) {
    const queryString = [];

    for (const key in params) {
        if (params.hasOwnProperty(key)) {
            const value = params[key];
            const encodedKey = prefix ? `${prefix}[${encodeURIComponent(key)}]` : encodeURIComponent(key);

            if (value !== null && typeof value === 'object') {
                if (Array.isArray(value)) {
                    value.forEach((item, index) => {
                        queryString.push(toQueryStringLegacy(item, `${encodedKey}[${index}]`));
                    });
                } else {
                    queryString.push(toQueryStringLegacy(value, encodedKey));
                }
            } else {
                queryString.push(`${encodedKey}=${encodeURIComponent(value)}`);
            }
        }
    }

    return queryString.join('&');
}

function toQueryString(params, prefix) {
    const queryString = [];

    for (const key in params) {
        if (params.hasOwnProperty(key)) {
            const value = params[key];
            const encodedKey = prefix ? `${prefix}[${encodeURIComponent(key)}]` : encodeURIComponent(key);

            if (value !== null && typeof value === 'object') {
                if (Array.isArray(value)) {
                    value.forEach(item => {
                        // Fix: treat item as primitive here
                        queryString.push(`${encodedKey}[]=${encodeURIComponent(item)}`);
                    });
                } else {
                    queryString.push(toQueryString(value, encodedKey));
                }
            } else {
                queryString.push(`${encodedKey}=${encodeURIComponent(value)}`);
            }
        }
    }

    return queryString.join('&');
}

function fetchDataAndProcess(url, callback = null, method = 'GET', data = null, errfunc = false, fromVarCache = false, withcache = false) {
    let nRequest = new RequestData(withcache);

    request
        .url(getFullURL(url))
        .type(method)
        .data(data)
        .fromVarCache(fromVarCache)
        .success((response) => {
            if (callback) { callback(response); }
        })
        .error((err) => {
            // console.error(err);
            if (errfunc) { errfunc(err); }
        })
        .go();

}

function AjaxDo(url, data, functionsuccess, functionerror, reqtype = 'POST', caching = false) {
    const options = {
        method: reqtype,
        headers: {}
    };
    const stringifydata = JSON.stringify(data);

    if (reqtype === 'POST' || reqtype === 'PUT') {
        options.headers['Content-Type'] = 'application/x-www-form-urlencoded';

        if (typeof data === 'object' && !Array.isArray(data)) {
            options.body = toQueryString(data);
        } else {
            options.body = data;
        }
    }

    fetch(url, options)
        .then(async response => {
            let functionErrorRunOnce = false;
            const contentType = response.headers.get('Content-Type');
            let responsedata;
            if (contentType && contentType.includes('application/json')) {
                responsedata = await response.json();
            } else if (contentType && contentType.includes('application/octet-stream')) {
                responsedata = await response.blob();
            } else if (contentType && contentType.includes('image')) {
                responsedata = await response.blob();
            } else {
                responsedata = await response.text();
            }
            if (!response.ok) {
                functionErrorRunOnce = true;
                if (functionerror && typeof functionerror === 'function') {
                    functionerror(responsedata);
                }
                return;
                // throw new Error(`Network response was not ok: ${response.statusText}`);
            }
            return responsedata;
        })
        .then(data => {
            reqcacheupdate(url, data, datavalue = '', stringifydata);
            if (functionsuccess && typeof functionsuccess === 'function') {
                functionsuccess(data);
            }
        })
        .catch(error => {

            console.error('Request failed:', error, url);
            if (functionerror && typeof functionerror === 'function') {
                functionerror(error);
            }
        });
}





function ajaxDoWithHash(url, data, functionsuccess, functionerror, reqtype = 'POST', caching = false, cachemode = 2) {
    const hashUrl = `${url}/hash`;
    const stringifydata = JSON.stringify(data);
    let hashkey = null;
    let cachedata;
    let cacheupdate;

    AjaxDo(hashUrl, data, (hashkey) => {


        if (cachemode === 1) {
            cachedata = RegularURLCacheFUNC.Load(url, hashkey, data);
            cacheupdate = function (url, content, hashkey = '', dataobject = '', datastringvalue = '') {
                RegularURLCacheFUNC.Update(url, content, dataobject, hashkey);
            };

        } else if (cachemode === 2) {
            cachedata = CacheHash.Load(hashkey);
            cacheupdate = function (url = '', content, hashkey, dataobject = '', datastringvalue = '') {
                if (!hashkey) { return false; }
                CacheHash.Update(hashkey, content);
            };
        } else {
            cachedata = CacheHash.Load(hashkey);
            cacheupdate = function (url, content, hashkey = '', dataobject = '', datastringvalue = '') {

                if (!hashkey) { return false; }

                CacheHash.Update(hashkey, content);
            };
        }


        if (!hashkey) {
            AjaxDo(url, data, (rdata) => {
                cacheupdate(url, rdata, hashkey, data);
                if (functionsuccess && typeof functionsuccess === 'function') { functionsuccess(rdata); }
            }, functionerror, reqtype, caching);
        } else if (cachedata) {
            if (functionsuccess && typeof functionsuccess === 'function') { functionsuccess(cachedata); }
        } else {

            AjaxDo(url, data, (rdata) => {
                cacheupdate(url, rdata, hashkey, data);
                if (functionsuccess && typeof functionsuccess === 'function') { functionsuccess(rdata, hashkey); }

            }, functionerror, reqtype, caching);
        }
    }, () => {
        AjaxDo(url, data, (rdata) => {
            cacheupdate(url, rdata, hashkey, data);
            if (functionsuccess && typeof functionsuccess === 'function') { functionsuccess(rdata); }
        }, functionerror, reqtype, caching);

    }, reqtype, caching);
}


function ajaxDoWithHashNew(url, data, functionsuccess, functionerror, reqtype = 'POST', caching = false, cachemode = 2) {
    const hashUrl = `${url}/hash`;
    let hashkey = null;
    let cachedata;
    let cacheupdate;

    // Always ensure we keep a clean copy of the object (not stringified)
    const requestData = (typeof data === 'string') ? JSON.parse(data) : data;

    // 1️⃣ Step 1: Get hash from the server
    AjaxDo(hashUrl, requestData, (receivedHash) => {
        hashkey = receivedHash;

        // Determine cache behavior
        if (cachemode === 1) {
            cachedata = RegularURLCacheFUNC.Load(url, hashkey, requestData);
            cacheupdate = function (url, content, hashkey = '', dataobject = '', datastringvalue = '') {
                RegularURLCacheFUNC.Update(url, content, dataobject, hashkey);
            };
        } else if (cachemode === 2) {
            cachedata = CacheHash.Load(hashkey);
            cacheupdate = function (url = '', content, hashkey, dataobject = '', datastringvalue = '') {
                if (!hashkey) return false;
                CacheHash.Update(hashkey, content);
            };
        } else {
            cachedata = CacheHash.Load(hashkey);
            cacheupdate = function (url, content, hashkey = '', dataobject = '', datastringvalue = '') {
                if (!hashkey) return false;
                CacheHash.Update(hashkey, content);
            };
        }

        // 2️⃣ Step 2: Serve from cache if available
        if (cachedata) {
            if (typeof functionsuccess === 'function') {
                functionsuccess(cachedata);
            }
            return;
        }

        // 3️⃣ Step 3: Otherwise, perform the actual request (form-encoded)
        AjaxDo(url, requestData, (rdata) => {
            cacheupdate(url, rdata, hashkey, requestData);
            if (typeof functionsuccess === 'function') {
                functionsuccess(rdata, hashkey);
            }
        }, functionerror, reqtype, caching);

    }, () => {
        // 4️⃣ Step 4: If hash endpoint fails, fallback to direct request
        AjaxDo(url, requestData, (rdata) => {
            if (typeof functionsuccess === 'function') {
                functionsuccess(rdata);
            }
        }, functionerror, reqtype, caching);
    }, reqtype, caching);
}

function RequestData(withhashcheck = false, quickfetchdontrevalidate = false) {
    this.datatosend = null;
    this.functionerror = null;
    this.reqtype = 'GET';
    this.cacheE = false;
    this.urlstring = '';
    this.functionsuccess = null;
    this.fromVARCacheFirstandRevalidate = false;
    this.cachemode = 2;

    this.url = function (newUrl) {
        this.urlstring = newUrl;
        return this;
    };

    this.type = function (type) {
        this.reqtype = type;
        return this;
    };
    this.fromVarCache = function (fromvar) {
        this.fromVARCacheFirstandRevalidate = fromvar;
        return this;
    };

    this.data = function (newData) {
        this.datatosend = newData;
        return this;
    };
    this.success = function (callback) {
        this.functionsuccess = callback;
        return this;
    };

    this.error = function (callback) {
        this.functionerror = callback;
        return this;
    };

    this.caching = function (cache) {
        if (cache) { this.cacheE = true; } else { this.cacheE = false; }
        return this;
    };

    this.cachestyle = function (cachemodestyle) {
        this.cachemode = cachemodestyle;
    };



    this.go = function () {



        if (!this.urlstring || !this.functionsuccess) {
            // console.log('URL is undefined or false. Aborting request.');
            return;
        }
        /* 
                console.group('RequestData');
                console.log(this.urlstring);
                console.log(this.datatosend,'data');
                console.log(this.fromVARCacheFirstandRevalidate ,'varcache');
                console.groupEnd(); */

        let reqcached = false;
        if (reqcacheload(this.urlstring, '', this.datatosend) && this.fromVARCacheFirstandRevalidate) {
            reqcached = true;
            this.functionsuccess(reqcacheload(this.urlstring, '', this.datatosend));
            this.functionsuccess = function () { };
        }

        if (reqcached && this.fromVARCacheFirstandRevalidate) {
            return;
        }

        if (!withhashcheck) {
            AjaxDo(
                this.urlstring,
                this.datatosend,
                this.functionsuccess,
                this.functionerror,
                this.reqtype,
                this.cacheE
            );
        } else {
            ajaxDoWithHash(
                this.urlstring,
                this.datatosend,
                this.functionsuccess,
                this.functionerror,
                this.reqtype,
                this.cacheE,
                this.cachemode
            );
        }

    };
}



function AjaxDoOLD(url, data, functionsuccess, functionerorr, reqtype = 'POST', caching = false) {
    $.ajax({
        url: url,
        type: reqtype,
        data: data,
        success: function (response) {
            if (!functionsuccess) { return null }
            functionsuccess(response);
        },
        error: function (response) {
            if (!functionerorr) { return null }
            functionerorr(response);
        }
    });

}

function CheckReqCacheforRequestFile(hash) {
    if (!hash) { return false; }

    const mainURL = window.location.origin + '/RequestData/File/' + hashcontent;
    const ShortURL = '/RequestData/File/' + hashcontent;
    if (reqcacheload(mainURL)) { return reqcacheload(mainURL); }
    else if (reqcacheload(ShortURL)) { return reqcacheload(ShortURL); } else {
        return false;
    }
}

function binaryStringToBlob(binaryString) {
    const byteCharacters = binaryString;
    const byteNumbers = new Uint8Array(byteCharacters.length);
    for (let i = 0; i < byteCharacters.length; i++) {
        byteNumbers[i] = byteCharacters.charCodeAt(i);
    }
    return new Blob([byteNumbers]);
}

function CreateObjectURLfrombinaryStringforIMGUse(binaryString) {
    const blob = binaryStringToBlob(binaryString);
    return URL.createObjectURL(blob);
}

function LoadAndCreateURLfromFileHash(FileListHash, fromvarcache = true, fileRequestURL = '/RequestData/File/') {
    if (!FileListHash) {
        return Promise.resolve(false);
    }
    let bloburl = '';
    let fullurl = fileRequestURL + FileListHash;
    let photoblob = reqcacheload(fullurl);
    let bloburlnow = '';

    const photoblobToURL = function (photoblobData) {
        const bloburlLink = URL.createObjectURL(photoblobData);
        fileBlobURLList[FileListHash] = bloburlLink;
        return bloburlLink;
    };

    if (typeof fileBlobURLList[FileListHash] !== 'undefined' && fileBlobURLList[FileListHash]) {
        bloburl = fileBlobURLList[FileListHash];
        return Promise.resolve(bloburl);
    } else if (photoblob) {
        bloburlnow = photoblobToURL(photoblob);
        return Promise.resolve(bloburlnow);
    }
    return new Promise((resolve, reject) => {

        let REQF = new RequestData(false);
        REQF.url(getFullURL(fullurl))
            .fromVarCache(fromvarcache)
            .success((response) => {
                if (!response) {
                    resolve(false);
                    return false;
                }

                photoblob = response;
                // bloburl = URL.createObjectURL(photoblob);
                // fileBlobURLList[FileListHash] = bloburl;
                bloburl = photoblobToURL(photoblob);
                resolve(bloburl);
            })
            .error((err) => {
                reject(err);
            })
            .go();
    });
}

async function FileHashtoURL(FileListHash, fromvarcache = true) {
    try {
        const bloburl = await LoadAndCreateURLfromFileHash(FileListHash, fromvarcache);
        return bloburl;
    } catch (error) {
        return false;
    }
}



function strtolower(inputString) {
    return inputString.toLowerCase();
}


function binaryStringToBase64(binaryString) {
    const binaryLen = binaryString.length;
    const bytes = new Uint8Array(binaryLen);
    for (let i = 0; i < binaryLen; i++) {
        bytes[i] = binaryString.charCodeAt(i);
    }
    binaryString = String.fromCharCode.apply(null, bytes);
    const base64String = btoa(binaryString);
    return base64String;
}
function Base64toIMGsrc(base64string) {
    if (!base64string) { return ''; }
    return imageUrl = `data:image/*;base64,${base64string}`;
}



function LoopArrayorObject(arg1, successfunc) {
    if (!(Array.isArray(arg1) || typeof arg1 === 'object' && arg1 !== null)) {
        return false;
    }
    if (typeof successfunc !== 'function') {
        return false;
    }
    if (Array.isArray(arg1)) {
        /*
        let indexnumber =0
        arg1.forEach(item => {
            successfunc(item,indexnumber);
            indexnumber++;
        });
        */
        for (let indexnumber = 0; indexnumber < arg1.length; indexnumber++) {
            const element = arg1[indexnumber];
            if (successfunc) {
                successfunc(element, indexnumber);
            }
        }
    } else {
        for (let key in arg1) {
            if (arg1.hasOwnProperty(key)) {
                if (successfunc) {
                    successfunc(arg1[key], key);
                }
            }
        }
    }
}


function interceptImageSrcandChangetoBlob(fromvarcache = true, replacewithnologo = true) {

    const images = document.querySelectorAll('img');
    const LoadAndChangeSRC = function (img, photohash) {

        LoadAndCreateURLfromFileHash(photohash, fromvarcache).then(bloburl => {
            if (!bloburl && replacewithnologo) {
                img.src = '/assets/noproductphoto.png';
                return false;
            } else if (!bloburl && !replacewithnologo) {
                return false;
            }
            if (bloburl) {
                img.src = bloburl;
                return true;
            }
        });
    };

    images.forEach(img => {
        const imgsrc = img.src;
        const origin = window.location.origin + '/';
        const photohashfromOrigin = img.src.split(origin)[1];
        const imgRequestDatahash = img.src.split('/RequestData/File/')[1];
        const imgSPhotohash = photohash = img.src.split('/s/')[1];




        const IS_OriginHash = typeof photohashfromOrigin === 'string' && photohashfromOrigin.length === 72;
        const IS_imgRequestDatahash = typeof imgRequestDatahash === 'string' && imgRequestDatahash.length === 72;
        const IS_imgSPhotohash = typeof imgSPhotohash === 'string' && imgSPhotohash.length === 72;
        const IS_mhash = typeof imgsrc === 'string' && imgsrc.length === 72;

        const No_ProperHash = !IS_OriginHash && !IS_imgRequestDatahash && !IS_imgSPhotohash && !IS_mhash;
        let imgmainhash = '';

        if (No_ProperHash) {
            return false;
        }

        if (IS_OriginHash) {
            imgmainhash = photohashfromOrigin;
        } else if (IS_imgRequestDatahash) {
            imgmainhash = imgRequestDatahash;
        } else if (IS_imgSPhotohash) {
            imgmainhash = imgSPhotohash;
        } else if (IS_mhash) {
            imgmainhash = imgsrc;
        }



        LoadAndChangeSRC(img, imgmainhash);




    });


}
function tryparsingJSON(jsonstring) {
    if (!jsonstring) { return false; }
    let mainvar = jsonstring;
    try {
        mainvar = JSON.parse(jsonstring);
    } catch (error) {
        mainvar = jsonstring;
    }
    return mainvar;

}
function trimStringToMaxLength(str, maxLength, suffix = '...') {
    if (typeof str !== 'string' || maxLength < 0) {
        return '';
    }

    if (str.length <= maxLength) {
        return str;
    }

    // Trim the string and append the suffix
    return str.slice(0, maxLength) + suffix;
}

function base64Decode(base64String) {
    try {
        const decodedString = atob(base64String);
        return decodedString;
    } catch (error) {

        return null;
    }
}

/*   function objectToUrlSafeBase64(obj,compressed=true) {
    if(typeof obj!=='object'){return false;}
    let jsonString = JSON.stringify(obj);

    let base64String = btoa(unescape(encodeURIComponent(jsonString)));
    let urlSafeBase64 = base64String.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
    return urlSafeBase64;
}

function urlSafeBase64ToObject(urlSafeBase64,compressed=true) {
    if (typeof urlSafeBase64 !== 'string') {
        return false;
    }
    let base64String = urlSafeBase64.replace(/-/g, '+').replace(/_/g, '/');
    const padding = base64String.length % 4;
    if (padding) {
        base64String += '='.repeat(4 - padding);
    }
    try {
        let jsonString = atob(base64String);
        return JSON.parse(jsonString);
    } catch (e) {
        return null;
    }
} */


function objectToUrlSafeBase64(obj, compressed = true) {
    if (typeof obj !== 'object') {
        return false;
    }
    let jsonString = JSON.stringify(obj);
    if (compressed) {
        const compressedData = pako.deflate(jsonString, { to: 'string' });
        jsonString = btoa(compressedData);
    }
    let urlSafeBase64 = jsonString.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
    return urlSafeBase64;
}

function urlSafeBase64ToObject(urlSafeBase64, compressed = true) {
    if (typeof urlSafeBase64 !== 'string') {
        return false;
    }
    let base64String = urlSafeBase64.replace(/-/g, '+').replace(/_/g, '/');

    const padding = base64String.length % 4;
    if (padding) {
        base64String += '='.repeat(4 - padding);
    }

    try {
        let compressedData = atob(base64String);
        if (compressed) {
            let jsonString = pako.inflate(compressedData, { to: 'string' });
            return JSON.parse(jsonString);
        }
        return JSON.parse(compressedData);
    } catch (e) {
        //           console.error("Error during decoding or parsing:", e);
        return null;
    }
}


var LZString = function () { function o(o, r) { if (!t[o]) { t[o] = {}; for (var n = 0; n < o.length; n++)t[o][o.charAt(n)] = n } return t[o][r] } var r = String.fromCharCode, n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$", t = {}, i = { compressToBase64: function (o) { if (null == o) return ""; var r = i._compress(o, 6, function (o) { return n.charAt(o) }); switch (r.length % 4) { default: case 0: return r; case 1: return r + "==="; case 2: return r + "=="; case 3: return r + "=" } }, decompressFromBase64: function (r) { return null == r ? "" : "" == r ? null : i._decompress(r.length, 32, function (e) { return o(n, r.charAt(e)) }) }, compressToUTF16: function (o) { return null == o ? "" : i._compress(o, 15, function (o) { return r(o + 32) }) + " " }, decompressFromUTF16: function (o) { return null == o ? "" : "" == o ? null : i._decompress(o.length, 16384, function (r) { return o.charCodeAt(r) - 32 }) }, compressToUint8Array: function (o) { for (var r = i.compress(o), n = new Uint8Array(2 * r.length), e = 0, t = r.length; t > e; e++) { var s = r.charCodeAt(e); n[2 * e] = s >>> 8, n[2 * e + 1] = s % 256 } return n }, decompressFromUint8Array: function (o) { if (null === o || void 0 === o) return i.decompress(o); for (var n = new Array(o.length / 2), e = 0, t = n.length; t > e; e++)n[e] = 256 * o[2 * e] + o[2 * e + 1]; var s = []; return n.forEach(function (o) { s.push(r(o)) }), i.decompress(s.join("")) }, compressToEncodedURIComponent: function (o) { return null == o ? "" : i._compress(o, 6, function (o) { return e.charAt(o) }) }, decompressFromEncodedURIComponent: function (r) { return null == r ? "" : "" == r ? null : (r = r.replace(/ /g, "+"), i._decompress(r.length, 32, function (n) { return o(e, r.charAt(n)) })) }, compress: function (o) { return i._compress(o, 16, function (o) { return r(o) }) }, _compress: function (o, r, n) { if (null == o) return ""; var e, t, i, s = {}, p = {}, u = "", c = "", a = "", l = 2, f = 3, h = 2, d = [], m = 0, v = 0; for (i = 0; i < o.length; i += 1)if (u = o.charAt(i), Object.prototype.hasOwnProperty.call(s, u) || (s[u] = f++, p[u] = !0), c = a + u, Object.prototype.hasOwnProperty.call(s, c)) a = c; else { if (Object.prototype.hasOwnProperty.call(p, a)) { if (a.charCodeAt(0) < 256) { for (e = 0; h > e; e++)m <<= 1, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++; for (t = a.charCodeAt(0), e = 0; 8 > e; e++)m = m << 1 | 1 & t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1 } else { for (t = 1, e = 0; h > e; e++)m = m << 1 | t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t = 0; for (t = a.charCodeAt(0), e = 0; 16 > e; e++)m = m << 1 | 1 & t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1 } l--, 0 == l && (l = Math.pow(2, h), h++), delete p[a] } else for (t = s[a], e = 0; h > e; e++)m = m << 1 | 1 & t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1; l--, 0 == l && (l = Math.pow(2, h), h++), s[c] = f++, a = String(u) } if ("" !== a) { if (Object.prototype.hasOwnProperty.call(p, a)) { if (a.charCodeAt(0) < 256) { for (e = 0; h > e; e++)m <<= 1, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++; for (t = a.charCodeAt(0), e = 0; 8 > e; e++)m = m << 1 | 1 & t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1 } else { for (t = 1, e = 0; h > e; e++)m = m << 1 | t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t = 0; for (t = a.charCodeAt(0), e = 0; 16 > e; e++)m = m << 1 | 1 & t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1 } l--, 0 == l && (l = Math.pow(2, h), h++), delete p[a] } else for (t = s[a], e = 0; h > e; e++)m = m << 1 | 1 & t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1; l--, 0 == l && (l = Math.pow(2, h), h++) } for (t = 2, e = 0; h > e; e++)m = m << 1 | 1 & t, v == r - 1 ? (v = 0, d.push(n(m)), m = 0) : v++, t >>= 1; for (; ;) { if (m <<= 1, v == r - 1) { d.push(n(m)); break } v++ } return d.join("") }, decompress: function (o) { return null == o ? "" : "" == o ? null : i._decompress(o.length, 32768, function (r) { return o.charCodeAt(r) }) }, _decompress: function (o, n, e) { var t, i, s, p, u, c, a, l, f = [], h = 4, d = 4, m = 3, v = "", w = [], A = { val: e(0), position: n, index: 1 }; for (i = 0; 3 > i; i += 1)f[i] = i; for (p = 0, c = Math.pow(2, 2), a = 1; a != c;)u = A.val & A.position, A.position >>= 1, 0 == A.position && (A.position = n, A.val = e(A.index++)), p |= (u > 0 ? 1 : 0) * a, a <<= 1; switch (t = p) { case 0: for (p = 0, c = Math.pow(2, 8), a = 1; a != c;)u = A.val & A.position, A.position >>= 1, 0 == A.position && (A.position = n, A.val = e(A.index++)), p |= (u > 0 ? 1 : 0) * a, a <<= 1; l = r(p); break; case 1: for (p = 0, c = Math.pow(2, 16), a = 1; a != c;)u = A.val & A.position, A.position >>= 1, 0 == A.position && (A.position = n, A.val = e(A.index++)), p |= (u > 0 ? 1 : 0) * a, a <<= 1; l = r(p); break; case 2: return "" }for (f[3] = l, s = l, w.push(l); ;) { if (A.index > o) return ""; for (p = 0, c = Math.pow(2, m), a = 1; a != c;)u = A.val & A.position, A.position >>= 1, 0 == A.position && (A.position = n, A.val = e(A.index++)), p |= (u > 0 ? 1 : 0) * a, a <<= 1; switch (l = p) { case 0: for (p = 0, c = Math.pow(2, 8), a = 1; a != c;)u = A.val & A.position, A.position >>= 1, 0 == A.position && (A.position = n, A.val = e(A.index++)), p |= (u > 0 ? 1 : 0) * a, a <<= 1; f[d++] = r(p), l = d - 1, h--; break; case 1: for (p = 0, c = Math.pow(2, 16), a = 1; a != c;)u = A.val & A.position, A.position >>= 1, 0 == A.position && (A.position = n, A.val = e(A.index++)), p |= (u > 0 ? 1 : 0) * a, a <<= 1; f[d++] = r(p), l = d - 1, h--; break; case 2: return w.join("") }if (0 == h && (h = Math.pow(2, m), m++), f[l]) v = f[l]; else { if (l !== d) return null; v = s + s.charAt(0) } w.push(v), f[d++] = s + v.charAt(0), h--, s = v, 0 == h && (h = Math.pow(2, m), m++) } } }; return i }(); "function" == typeof define && define.amd ? define(function () { return LZString }) : "undefined" != typeof module && null != module && (module.exports = LZString);

//pako library
!function (t) { if ("object" == typeof exports && "undefined" != typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else { ("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this).pako = t() } }(function () { return function r(s, o, l) { function h(e, t) { if (!o[e]) { if (!s[e]) { var a = "function" == typeof require && require; if (!t && a) return a(e, !0); if (d) return d(e, !0); var i = new Error("Cannot find module '" + e + "'"); throw i.code = "MODULE_NOT_FOUND", i } var n = o[e] = { exports: {} }; s[e][0].call(n.exports, function (t) { return h(s[e][1][t] || t) }, n, n.exports, r, s, o, l) } return o[e].exports } for (var d = "function" == typeof require && require, t = 0; t < l.length; t++)h(l[t]); return h }({ 1: [function (t, e, a) { "use strict"; var s = t("./zlib/deflate"), o = t("./utils/common"), l = t("./utils/strings"), n = t("./zlib/messages"), r = t("./zlib/zstream"), h = Object.prototype.toString, d = 0, f = -1, _ = 0, u = 8; function c(t) { if (!(this instanceof c)) return new c(t); this.options = o.assign({ level: f, method: u, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: _, to: "" }, t || {}); var e = this.options; e.raw && 0 < e.windowBits ? e.windowBits = -e.windowBits : e.gzip && 0 < e.windowBits && e.windowBits < 16 && (e.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new r, this.strm.avail_out = 0; var a = s.deflateInit2(this.strm, e.level, e.method, e.windowBits, e.memLevel, e.strategy); if (a !== d) throw new Error(n[a]); if (e.header && s.deflateSetHeader(this.strm, e.header), e.dictionary) { var i; if (i = "string" == typeof e.dictionary ? l.string2buf(e.dictionary) : "[object ArrayBuffer]" === h.call(e.dictionary) ? new Uint8Array(e.dictionary) : e.dictionary, (a = s.deflateSetDictionary(this.strm, i)) !== d) throw new Error(n[a]); this._dict_set = !0 } } function i(t, e) { var a = new c(e); if (a.push(t, !0), a.err) throw a.msg || n[a.err]; return a.result } c.prototype.push = function (t, e) { var a, i, n = this.strm, r = this.options.chunkSize; if (this.ended) return !1; i = e === ~~e ? e : !0 === e ? 4 : 0, "string" == typeof t ? n.input = l.string2buf(t) : "[object ArrayBuffer]" === h.call(t) ? n.input = new Uint8Array(t) : n.input = t, n.next_in = 0, n.avail_in = n.input.length; do { if (0 === n.avail_out && (n.output = new o.Buf8(r), n.next_out = 0, n.avail_out = r), 1 !== (a = s.deflate(n, i)) && a !== d) return this.onEnd(a), !(this.ended = !0); 0 !== n.avail_out && (0 !== n.avail_in || 4 !== i && 2 !== i) || ("string" === this.options.to ? this.onData(l.buf2binstring(o.shrinkBuf(n.output, n.next_out))) : this.onData(o.shrinkBuf(n.output, n.next_out))) } while ((0 < n.avail_in || 0 === n.avail_out) && 1 !== a); return 4 === i ? (a = s.deflateEnd(this.strm), this.onEnd(a), this.ended = !0, a === d) : 2 !== i || (this.onEnd(d), !(n.avail_out = 0)) }, c.prototype.onData = function (t) { this.chunks.push(t) }, c.prototype.onEnd = function (t) { t === d && ("string" === this.options.to ? this.result = this.chunks.join("") : this.result = o.flattenChunks(this.chunks)), this.chunks = [], this.err = t, this.msg = this.strm.msg }, a.Deflate = c, a.deflate = i, a.deflateRaw = function (t, e) { return (e = e || {}).raw = !0, i(t, e) }, a.gzip = function (t, e) { return (e = e || {}).gzip = !0, i(t, e) } }, { "./utils/common": 3, "./utils/strings": 4, "./zlib/deflate": 8, "./zlib/messages": 13, "./zlib/zstream": 15 }], 2: [function (t, e, a) { "use strict"; var f = t("./zlib/inflate"), _ = t("./utils/common"), u = t("./utils/strings"), c = t("./zlib/constants"), i = t("./zlib/messages"), n = t("./zlib/zstream"), r = t("./zlib/gzheader"), b = Object.prototype.toString; function s(t) { if (!(this instanceof s)) return new s(t); this.options = _.assign({ chunkSize: 16384, windowBits: 0, to: "" }, t || {}); var e = this.options; e.raw && 0 <= e.windowBits && e.windowBits < 16 && (e.windowBits = -e.windowBits, 0 === e.windowBits && (e.windowBits = -15)), !(0 <= e.windowBits && e.windowBits < 16) || t && t.windowBits || (e.windowBits += 32), 15 < e.windowBits && e.windowBits < 48 && 0 == (15 & e.windowBits) && (e.windowBits |= 15), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new n, this.strm.avail_out = 0; var a = f.inflateInit2(this.strm, e.windowBits); if (a !== c.Z_OK) throw new Error(i[a]); if (this.header = new r, f.inflateGetHeader(this.strm, this.header), e.dictionary && ("string" == typeof e.dictionary ? e.dictionary = u.string2buf(e.dictionary) : "[object ArrayBuffer]" === b.call(e.dictionary) && (e.dictionary = new Uint8Array(e.dictionary)), e.raw && (a = f.inflateSetDictionary(this.strm, e.dictionary)) !== c.Z_OK)) throw new Error(i[a]) } function o(t, e) { var a = new s(e); if (a.push(t, !0), a.err) throw a.msg || i[a.err]; return a.result } s.prototype.push = function (t, e) { var a, i, n, r, s, o = this.strm, l = this.options.chunkSize, h = this.options.dictionary, d = !1; if (this.ended) return !1; i = e === ~~e ? e : !0 === e ? c.Z_FINISH : c.Z_NO_FLUSH, "string" == typeof t ? o.input = u.binstring2buf(t) : "[object ArrayBuffer]" === b.call(t) ? o.input = new Uint8Array(t) : o.input = t, o.next_in = 0, o.avail_in = o.input.length; do { if (0 === o.avail_out && (o.output = new _.Buf8(l), o.next_out = 0, o.avail_out = l), (a = f.inflate(o, c.Z_NO_FLUSH)) === c.Z_NEED_DICT && h && (a = f.inflateSetDictionary(this.strm, h)), a === c.Z_BUF_ERROR && !0 === d && (a = c.Z_OK, d = !1), a !== c.Z_STREAM_END && a !== c.Z_OK) return this.onEnd(a), !(this.ended = !0); o.next_out && (0 !== o.avail_out && a !== c.Z_STREAM_END && (0 !== o.avail_in || i !== c.Z_FINISH && i !== c.Z_SYNC_FLUSH) || ("string" === this.options.to ? (n = u.utf8border(o.output, o.next_out), r = o.next_out - n, s = u.buf2string(o.output, n), o.next_out = r, o.avail_out = l - r, r && _.arraySet(o.output, o.output, n, r, 0), this.onData(s)) : this.onData(_.shrinkBuf(o.output, o.next_out)))), 0 === o.avail_in && 0 === o.avail_out && (d = !0) } while ((0 < o.avail_in || 0 === o.avail_out) && a !== c.Z_STREAM_END); return a === c.Z_STREAM_END && (i = c.Z_FINISH), i === c.Z_FINISH ? (a = f.inflateEnd(this.strm), this.onEnd(a), this.ended = !0, a === c.Z_OK) : i !== c.Z_SYNC_FLUSH || (this.onEnd(c.Z_OK), !(o.avail_out = 0)) }, s.prototype.onData = function (t) { this.chunks.push(t) }, s.prototype.onEnd = function (t) { t === c.Z_OK && ("string" === this.options.to ? this.result = this.chunks.join("") : this.result = _.flattenChunks(this.chunks)), this.chunks = [], this.err = t, this.msg = this.strm.msg }, a.Inflate = s, a.inflate = o, a.inflateRaw = function (t, e) { return (e = e || {}).raw = !0, o(t, e) }, a.ungzip = o }, { "./utils/common": 3, "./utils/strings": 4, "./zlib/constants": 6, "./zlib/gzheader": 9, "./zlib/inflate": 11, "./zlib/messages": 13, "./zlib/zstream": 15 }], 3: [function (t, e, a) { "use strict"; var i = "undefined" != typeof Uint8Array && "undefined" != typeof Uint16Array && "undefined" != typeof Int32Array; a.assign = function (t) { for (var e, a, i = Array.prototype.slice.call(arguments, 1); i.length;) { var n = i.shift(); if (n) { if ("object" != typeof n) throw new TypeError(n + "must be non-object"); for (var r in n) e = n, a = r, Object.prototype.hasOwnProperty.call(e, a) && (t[r] = n[r]) } } return t }, a.shrinkBuf = function (t, e) { return t.length === e ? t : t.subarray ? t.subarray(0, e) : (t.length = e, t) }; var n = { arraySet: function (t, e, a, i, n) { if (e.subarray && t.subarray) t.set(e.subarray(a, a + i), n); else for (var r = 0; r < i; r++)t[n + r] = e[a + r] }, flattenChunks: function (t) { var e, a, i, n, r, s; for (e = i = 0, a = t.length; e < a; e++)i += t[e].length; for (s = new Uint8Array(i), e = n = 0, a = t.length; e < a; e++)r = t[e], s.set(r, n), n += r.length; return s } }, r = { arraySet: function (t, e, a, i, n) { for (var r = 0; r < i; r++)t[n + r] = e[a + r] }, flattenChunks: function (t) { return [].concat.apply([], t) } }; a.setTyped = function (t) { t ? (a.Buf8 = Uint8Array, a.Buf16 = Uint16Array, a.Buf32 = Int32Array, a.assign(a, n)) : (a.Buf8 = Array, a.Buf16 = Array, a.Buf32 = Array, a.assign(a, r)) }, a.setTyped(i) }, {}], 4: [function (t, e, a) { "use strict"; var l = t("./common"), n = !0, r = !0; try { String.fromCharCode.apply(null, [0]) } catch (t) { n = !1 } try { String.fromCharCode.apply(null, new Uint8Array(1)) } catch (t) { r = !1 } for (var h = new l.Buf8(256), i = 0; i < 256; i++)h[i] = 252 <= i ? 6 : 248 <= i ? 5 : 240 <= i ? 4 : 224 <= i ? 3 : 192 <= i ? 2 : 1; function d(t, e) { if (e < 65534 && (t.subarray && r || !t.subarray && n)) return String.fromCharCode.apply(null, l.shrinkBuf(t, e)); for (var a = "", i = 0; i < e; i++)a += String.fromCharCode(t[i]); return a } h[254] = h[254] = 1, a.string2buf = function (t) { var e, a, i, n, r, s = t.length, o = 0; for (n = 0; n < s; n++)55296 == (64512 & (a = t.charCodeAt(n))) && n + 1 < s && 56320 == (64512 & (i = t.charCodeAt(n + 1))) && (a = 65536 + (a - 55296 << 10) + (i - 56320), n++), o += a < 128 ? 1 : a < 2048 ? 2 : a < 65536 ? 3 : 4; for (e = new l.Buf8(o), n = r = 0; r < o; n++)55296 == (64512 & (a = t.charCodeAt(n))) && n + 1 < s && 56320 == (64512 & (i = t.charCodeAt(n + 1))) && (a = 65536 + (a - 55296 << 10) + (i - 56320), n++), a < 128 ? e[r++] = a : (a < 2048 ? e[r++] = 192 | a >>> 6 : (a < 65536 ? e[r++] = 224 | a >>> 12 : (e[r++] = 240 | a >>> 18, e[r++] = 128 | a >>> 12 & 63), e[r++] = 128 | a >>> 6 & 63), e[r++] = 128 | 63 & a); return e }, a.buf2binstring = function (t) { return d(t, t.length) }, a.binstring2buf = function (t) { for (var e = new l.Buf8(t.length), a = 0, i = e.length; a < i; a++)e[a] = t.charCodeAt(a); return e }, a.buf2string = function (t, e) { var a, i, n, r, s = e || t.length, o = new Array(2 * s); for (a = i = 0; a < s;)if ((n = t[a++]) < 128) o[i++] = n; else if (4 < (r = h[n])) o[i++] = 65533, a += r - 1; else { for (n &= 2 === r ? 31 : 3 === r ? 15 : 7; 1 < r && a < s;)n = n << 6 | 63 & t[a++], r--; 1 < r ? o[i++] = 65533 : n < 65536 ? o[i++] = n : (n -= 65536, o[i++] = 55296 | n >> 10 & 1023, o[i++] = 56320 | 1023 & n) } return d(o, i) }, a.utf8border = function (t, e) { var a; for ((e = e || t.length) > t.length && (e = t.length), a = e - 1; 0 <= a && 128 == (192 & t[a]);)a--; return a < 0 ? e : 0 === a ? e : a + h[t[a]] > e ? a : e } }, { "./common": 3 }], 5: [function (t, e, a) { "use strict"; e.exports = function (t, e, a, i) { for (var n = 65535 & t | 0, r = t >>> 16 & 65535 | 0, s = 0; 0 !== a;) { for (a -= s = 2e3 < a ? 2e3 : a; r = r + (n = n + e[i++] | 0) | 0, --s;); n %= 65521, r %= 65521 } return n | r << 16 | 0 } }, {}], 6: [function (t, e, a) { "use strict"; e.exports = { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_TREES: 6, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_BUF_ERROR: -5, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, Z_BINARY: 0, Z_TEXT: 1, Z_UNKNOWN: 2, Z_DEFLATED: 8 } }, {}], 7: [function (t, e, a) { "use strict"; var o = function () { for (var t, e = [], a = 0; a < 256; a++) { t = a; for (var i = 0; i < 8; i++)t = 1 & t ? 3988292384 ^ t >>> 1 : t >>> 1; e[a] = t } return e }(); e.exports = function (t, e, a, i) { var n = o, r = i + a; t ^= -1; for (var s = i; s < r; s++)t = t >>> 8 ^ n[255 & (t ^ e[s])]; return -1 ^ t } }, {}], 8: [function (t, e, a) { "use strict"; var l, _ = t("../utils/common"), h = t("./trees"), u = t("./adler32"), c = t("./crc32"), i = t("./messages"), d = 0, f = 4, b = 0, g = -2, m = -1, w = 4, n = 2, p = 8, v = 9, r = 286, s = 30, o = 19, k = 2 * r + 1, y = 15, x = 3, z = 258, B = z + x + 1, S = 42, E = 113, A = 1, Z = 2, R = 3, C = 4; function N(t, e) { return t.msg = i[e], e } function O(t) { return (t << 1) - (4 < t ? 9 : 0) } function D(t) { for (var e = t.length; 0 <= --e;)t[e] = 0 } function I(t) { var e = t.state, a = e.pending; a > t.avail_out && (a = t.avail_out), 0 !== a && (_.arraySet(t.output, e.pending_buf, e.pending_out, a, t.next_out), t.next_out += a, e.pending_out += a, t.total_out += a, t.avail_out -= a, e.pending -= a, 0 === e.pending && (e.pending_out = 0)) } function U(t, e) { h._tr_flush_block(t, 0 <= t.block_start ? t.block_start : -1, t.strstart - t.block_start, e), t.block_start = t.strstart, I(t.strm) } function T(t, e) { t.pending_buf[t.pending++] = e } function F(t, e) { t.pending_buf[t.pending++] = e >>> 8 & 255, t.pending_buf[t.pending++] = 255 & e } function L(t, e) { var a, i, n = t.max_chain_length, r = t.strstart, s = t.prev_length, o = t.nice_match, l = t.strstart > t.w_size - B ? t.strstart - (t.w_size - B) : 0, h = t.window, d = t.w_mask, f = t.prev, _ = t.strstart + z, u = h[r + s - 1], c = h[r + s]; t.prev_length >= t.good_match && (n >>= 2), o > t.lookahead && (o = t.lookahead); do { if (h[(a = e) + s] === c && h[a + s - 1] === u && h[a] === h[r] && h[++a] === h[r + 1]) { r += 2, a++; do { } while (h[++r] === h[++a] && h[++r] === h[++a] && h[++r] === h[++a] && h[++r] === h[++a] && h[++r] === h[++a] && h[++r] === h[++a] && h[++r] === h[++a] && h[++r] === h[++a] && r < _); if (i = z - (_ - r), r = _ - z, s < i) { if (t.match_start = e, o <= (s = i)) break; u = h[r + s - 1], c = h[r + s] } } } while ((e = f[e & d]) > l && 0 != --n); return s <= t.lookahead ? s : t.lookahead } function H(t) { var e, a, i, n, r, s, o, l, h, d, f = t.w_size; do { if (n = t.window_size - t.lookahead - t.strstart, t.strstart >= f + (f - B)) { for (_.arraySet(t.window, t.window, f, f, 0), t.match_start -= f, t.strstart -= f, t.block_start -= f, e = a = t.hash_size; i = t.head[--e], t.head[e] = f <= i ? i - f : 0, --a;); for (e = a = f; i = t.prev[--e], t.prev[e] = f <= i ? i - f : 0, --a;); n += f } if (0 === t.strm.avail_in) break; if (s = t.strm, o = t.window, l = t.strstart + t.lookahead, h = n, d = void 0, d = s.avail_in, h < d && (d = h), a = 0 === d ? 0 : (s.avail_in -= d, _.arraySet(o, s.input, s.next_in, d, l), 1 === s.state.wrap ? s.adler = u(s.adler, o, d, l) : 2 === s.state.wrap && (s.adler = c(s.adler, o, d, l)), s.next_in += d, s.total_in += d, d), t.lookahead += a, t.lookahead + t.insert >= x) for (r = t.strstart - t.insert, t.ins_h = t.window[r], t.ins_h = (t.ins_h << t.hash_shift ^ t.window[r + 1]) & t.hash_mask; t.insert && (t.ins_h = (t.ins_h << t.hash_shift ^ t.window[r + x - 1]) & t.hash_mask, t.prev[r & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = r, r++, t.insert--, !(t.lookahead + t.insert < x));); } while (t.lookahead < B && 0 !== t.strm.avail_in) } function j(t, e) { for (var a, i; ;) { if (t.lookahead < B) { if (H(t), t.lookahead < B && e === d) return A; if (0 === t.lookahead) break } if (a = 0, t.lookahead >= x && (t.ins_h = (t.ins_h << t.hash_shift ^ t.window[t.strstart + x - 1]) & t.hash_mask, a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 !== a && t.strstart - a <= t.w_size - B && (t.match_length = L(t, a)), t.match_length >= x) if (i = h._tr_tally(t, t.strstart - t.match_start, t.match_length - x), t.lookahead -= t.match_length, t.match_length <= t.max_lazy_match && t.lookahead >= x) { for (t.match_length--; t.strstart++, t.ins_h = (t.ins_h << t.hash_shift ^ t.window[t.strstart + x - 1]) & t.hash_mask, a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart, 0 != --t.match_length;); t.strstart++ } else t.strstart += t.match_length, t.match_length = 0, t.ins_h = t.window[t.strstart], t.ins_h = (t.ins_h << t.hash_shift ^ t.window[t.strstart + 1]) & t.hash_mask; else i = h._tr_tally(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++; if (i && (U(t, !1), 0 === t.strm.avail_out)) return A } return t.insert = t.strstart < x - 1 ? t.strstart : x - 1, e === f ? (U(t, !0), 0 === t.strm.avail_out ? R : C) : t.last_lit && (U(t, !1), 0 === t.strm.avail_out) ? A : Z } function K(t, e) { for (var a, i, n; ;) { if (t.lookahead < B) { if (H(t), t.lookahead < B && e === d) return A; if (0 === t.lookahead) break } if (a = 0, t.lookahead >= x && (t.ins_h = (t.ins_h << t.hash_shift ^ t.window[t.strstart + x - 1]) & t.hash_mask, a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), t.prev_length = t.match_length, t.prev_match = t.match_start, t.match_length = x - 1, 0 !== a && t.prev_length < t.max_lazy_match && t.strstart - a <= t.w_size - B && (t.match_length = L(t, a), t.match_length <= 5 && (1 === t.strategy || t.match_length === x && 4096 < t.strstart - t.match_start) && (t.match_length = x - 1)), t.prev_length >= x && t.match_length <= t.prev_length) { for (n = t.strstart + t.lookahead - x, i = h._tr_tally(t, t.strstart - 1 - t.prev_match, t.prev_length - x), t.lookahead -= t.prev_length - 1, t.prev_length -= 2; ++t.strstart <= n && (t.ins_h = (t.ins_h << t.hash_shift ^ t.window[t.strstart + x - 1]) & t.hash_mask, a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h], t.head[t.ins_h] = t.strstart), 0 != --t.prev_length;); if (t.match_available = 0, t.match_length = x - 1, t.strstart++, i && (U(t, !1), 0 === t.strm.avail_out)) return A } else if (t.match_available) { if ((i = h._tr_tally(t, 0, t.window[t.strstart - 1])) && U(t, !1), t.strstart++, t.lookahead--, 0 === t.strm.avail_out) return A } else t.match_available = 1, t.strstart++, t.lookahead-- } return t.match_available && (i = h._tr_tally(t, 0, t.window[t.strstart - 1]), t.match_available = 0), t.insert = t.strstart < x - 1 ? t.strstart : x - 1, e === f ? (U(t, !0), 0 === t.strm.avail_out ? R : C) : t.last_lit && (U(t, !1), 0 === t.strm.avail_out) ? A : Z } function M(t, e, a, i, n) { this.good_length = t, this.max_lazy = e, this.nice_length = a, this.max_chain = i, this.func = n } function P() { this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = p, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new _.Buf16(2 * k), this.dyn_dtree = new _.Buf16(2 * (2 * s + 1)), this.bl_tree = new _.Buf16(2 * (2 * o + 1)), D(this.dyn_ltree), D(this.dyn_dtree), D(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new _.Buf16(y + 1), this.heap = new _.Buf16(2 * r + 1), D(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new _.Buf16(2 * r + 1), D(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0 } function Y(t) { var e; return t && t.state ? (t.total_in = t.total_out = 0, t.data_type = n, (e = t.state).pending = 0, e.pending_out = 0, e.wrap < 0 && (e.wrap = -e.wrap), e.status = e.wrap ? S : E, t.adler = 2 === e.wrap ? 0 : 1, e.last_flush = d, h._tr_init(e), b) : N(t, g) } function q(t) { var e, a = Y(t); return a === b && ((e = t.state).window_size = 2 * e.w_size, D(e.head), e.max_lazy_match = l[e.level].max_lazy, e.good_match = l[e.level].good_length, e.nice_match = l[e.level].nice_length, e.max_chain_length = l[e.level].max_chain, e.strstart = 0, e.block_start = 0, e.lookahead = 0, e.insert = 0, e.match_length = e.prev_length = x - 1, e.match_available = 0, e.ins_h = 0), a } function G(t, e, a, i, n, r) { if (!t) return g; var s = 1; if (e === m && (e = 6), i < 0 ? (s = 0, i = -i) : 15 < i && (s = 2, i -= 16), n < 1 || v < n || a !== p || i < 8 || 15 < i || e < 0 || 9 < e || r < 0 || w < r) return N(t, g); 8 === i && (i = 9); var o = new P; return (t.state = o).strm = t, o.wrap = s, o.gzhead = null, o.w_bits = i, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = n + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + x - 1) / x), o.window = new _.Buf8(2 * o.w_size), o.head = new _.Buf16(o.hash_size), o.prev = new _.Buf16(o.w_size), o.lit_bufsize = 1 << n + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new _.Buf8(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = e, o.strategy = r, o.method = a, q(t) } l = [new M(0, 0, 0, 0, function (t, e) { var a = 65535; for (a > t.pending_buf_size - 5 && (a = t.pending_buf_size - 5); ;) { if (t.lookahead <= 1) { if (H(t), 0 === t.lookahead && e === d) return A; if (0 === t.lookahead) break } t.strstart += t.lookahead, t.lookahead = 0; var i = t.block_start + a; if ((0 === t.strstart || t.strstart >= i) && (t.lookahead = t.strstart - i, t.strstart = i, U(t, !1), 0 === t.strm.avail_out)) return A; if (t.strstart - t.block_start >= t.w_size - B && (U(t, !1), 0 === t.strm.avail_out)) return A } return t.insert = 0, e === f ? (U(t, !0), 0 === t.strm.avail_out ? R : C) : (t.strstart > t.block_start && (U(t, !1), t.strm.avail_out), A) }), new M(4, 4, 8, 4, j), new M(4, 5, 16, 8, j), new M(4, 6, 32, 32, j), new M(4, 4, 16, 16, K), new M(8, 16, 32, 32, K), new M(8, 16, 128, 128, K), new M(8, 32, 128, 256, K), new M(32, 128, 258, 1024, K), new M(32, 258, 258, 4096, K)], a.deflateInit = function (t, e) { return G(t, e, p, 15, 8, 0) }, a.deflateInit2 = G, a.deflateReset = q, a.deflateResetKeep = Y, a.deflateSetHeader = function (t, e) { return t && t.state ? 2 !== t.state.wrap ? g : (t.state.gzhead = e, b) : g }, a.deflate = function (t, e) { var a, i, n, r; if (!t || !t.state || 5 < e || e < 0) return t ? N(t, g) : g; if (i = t.state, !t.output || !t.input && 0 !== t.avail_in || 666 === i.status && e !== f) return N(t, 0 === t.avail_out ? -5 : g); if (i.strm = t, a = i.last_flush, i.last_flush = e, i.status === S) if (2 === i.wrap) t.adler = 0, T(i, 31), T(i, 139), T(i, 8), i.gzhead ? (T(i, (i.gzhead.text ? 1 : 0) + (i.gzhead.hcrc ? 2 : 0) + (i.gzhead.extra ? 4 : 0) + (i.gzhead.name ? 8 : 0) + (i.gzhead.comment ? 16 : 0)), T(i, 255 & i.gzhead.time), T(i, i.gzhead.time >> 8 & 255), T(i, i.gzhead.time >> 16 & 255), T(i, i.gzhead.time >> 24 & 255), T(i, 9 === i.level ? 2 : 2 <= i.strategy || i.level < 2 ? 4 : 0), T(i, 255 & i.gzhead.os), i.gzhead.extra && i.gzhead.extra.length && (T(i, 255 & i.gzhead.extra.length), T(i, i.gzhead.extra.length >> 8 & 255)), i.gzhead.hcrc && (t.adler = c(t.adler, i.pending_buf, i.pending, 0)), i.gzindex = 0, i.status = 69) : (T(i, 0), T(i, 0), T(i, 0), T(i, 0), T(i, 0), T(i, 9 === i.level ? 2 : 2 <= i.strategy || i.level < 2 ? 4 : 0), T(i, 3), i.status = E); else { var s = p + (i.w_bits - 8 << 4) << 8; s |= (2 <= i.strategy || i.level < 2 ? 0 : i.level < 6 ? 1 : 6 === i.level ? 2 : 3) << 6, 0 !== i.strstart && (s |= 32), s += 31 - s % 31, i.status = E, F(i, s), 0 !== i.strstart && (F(i, t.adler >>> 16), F(i, 65535 & t.adler)), t.adler = 1 } if (69 === i.status) if (i.gzhead.extra) { for (n = i.pending; i.gzindex < (65535 & i.gzhead.extra.length) && (i.pending !== i.pending_buf_size || (i.gzhead.hcrc && i.pending > n && (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), I(t), n = i.pending, i.pending !== i.pending_buf_size));)T(i, 255 & i.gzhead.extra[i.gzindex]), i.gzindex++; i.gzhead.hcrc && i.pending > n && (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), i.gzindex === i.gzhead.extra.length && (i.gzindex = 0, i.status = 73) } else i.status = 73; if (73 === i.status) if (i.gzhead.name) { n = i.pending; do { if (i.pending === i.pending_buf_size && (i.gzhead.hcrc && i.pending > n && (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), I(t), n = i.pending, i.pending === i.pending_buf_size)) { r = 1; break } T(i, r = i.gzindex < i.gzhead.name.length ? 255 & i.gzhead.name.charCodeAt(i.gzindex++) : 0) } while (0 !== r); i.gzhead.hcrc && i.pending > n && (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), 0 === r && (i.gzindex = 0, i.status = 91) } else i.status = 91; if (91 === i.status) if (i.gzhead.comment) { n = i.pending; do { if (i.pending === i.pending_buf_size && (i.gzhead.hcrc && i.pending > n && (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), I(t), n = i.pending, i.pending === i.pending_buf_size)) { r = 1; break } T(i, r = i.gzindex < i.gzhead.comment.length ? 255 & i.gzhead.comment.charCodeAt(i.gzindex++) : 0) } while (0 !== r); i.gzhead.hcrc && i.pending > n && (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), 0 === r && (i.status = 103) } else i.status = 103; if (103 === i.status && (i.gzhead.hcrc ? (i.pending + 2 > i.pending_buf_size && I(t), i.pending + 2 <= i.pending_buf_size && (T(i, 255 & t.adler), T(i, t.adler >> 8 & 255), t.adler = 0, i.status = E)) : i.status = E), 0 !== i.pending) { if (I(t), 0 === t.avail_out) return i.last_flush = -1, b } else if (0 === t.avail_in && O(e) <= O(a) && e !== f) return N(t, -5); if (666 === i.status && 0 !== t.avail_in) return N(t, -5); if (0 !== t.avail_in || 0 !== i.lookahead || e !== d && 666 !== i.status) { var o = 2 === i.strategy ? function (t, e) { for (var a; ;) { if (0 === t.lookahead && (H(t), 0 === t.lookahead)) { if (e === d) return A; break } if (t.match_length = 0, a = h._tr_tally(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++, a && (U(t, !1), 0 === t.strm.avail_out)) return A } return t.insert = 0, e === f ? (U(t, !0), 0 === t.strm.avail_out ? R : C) : t.last_lit && (U(t, !1), 0 === t.strm.avail_out) ? A : Z }(i, e) : 3 === i.strategy ? function (t, e) { for (var a, i, n, r, s = t.window; ;) { if (t.lookahead <= z) { if (H(t), t.lookahead <= z && e === d) return A; if (0 === t.lookahead) break } if (t.match_length = 0, t.lookahead >= x && 0 < t.strstart && (i = s[n = t.strstart - 1]) === s[++n] && i === s[++n] && i === s[++n]) { r = t.strstart + z; do { } while (i === s[++n] && i === s[++n] && i === s[++n] && i === s[++n] && i === s[++n] && i === s[++n] && i === s[++n] && i === s[++n] && n < r); t.match_length = z - (r - n), t.match_length > t.lookahead && (t.match_length = t.lookahead) } if (t.match_length >= x ? (a = h._tr_tally(t, 1, t.match_length - x), t.lookahead -= t.match_length, t.strstart += t.match_length, t.match_length = 0) : (a = h._tr_tally(t, 0, t.window[t.strstart]), t.lookahead--, t.strstart++), a && (U(t, !1), 0 === t.strm.avail_out)) return A } return t.insert = 0, e === f ? (U(t, !0), 0 === t.strm.avail_out ? R : C) : t.last_lit && (U(t, !1), 0 === t.strm.avail_out) ? A : Z }(i, e) : l[i.level].func(i, e); if (o !== R && o !== C || (i.status = 666), o === A || o === R) return 0 === t.avail_out && (i.last_flush = -1), b; if (o === Z && (1 === e ? h._tr_align(i) : 5 !== e && (h._tr_stored_block(i, 0, 0, !1), 3 === e && (D(i.head), 0 === i.lookahead && (i.strstart = 0, i.block_start = 0, i.insert = 0))), I(t), 0 === t.avail_out)) return i.last_flush = -1, b } return e !== f ? b : i.wrap <= 0 ? 1 : (2 === i.wrap ? (T(i, 255 & t.adler), T(i, t.adler >> 8 & 255), T(i, t.adler >> 16 & 255), T(i, t.adler >> 24 & 255), T(i, 255 & t.total_in), T(i, t.total_in >> 8 & 255), T(i, t.total_in >> 16 & 255), T(i, t.total_in >> 24 & 255)) : (F(i, t.adler >>> 16), F(i, 65535 & t.adler)), I(t), 0 < i.wrap && (i.wrap = -i.wrap), 0 !== i.pending ? b : 1) }, a.deflateEnd = function (t) { var e; return t && t.state ? (e = t.state.status) !== S && 69 !== e && 73 !== e && 91 !== e && 103 !== e && e !== E && 666 !== e ? N(t, g) : (t.state = null, e === E ? N(t, -3) : b) : g }, a.deflateSetDictionary = function (t, e) { var a, i, n, r, s, o, l, h, d = e.length; if (!t || !t.state) return g; if (2 === (r = (a = t.state).wrap) || 1 === r && a.status !== S || a.lookahead) return g; for (1 === r && (t.adler = u(t.adler, e, d, 0)), a.wrap = 0, d >= a.w_size && (0 === r && (D(a.head), a.strstart = 0, a.block_start = 0, a.insert = 0), h = new _.Buf8(a.w_size), _.arraySet(h, e, d - a.w_size, a.w_size, 0), e = h, d = a.w_size), s = t.avail_in, o = t.next_in, l = t.input, t.avail_in = d, t.next_in = 0, t.input = e, H(a); a.lookahead >= x;) { for (i = a.strstart, n = a.lookahead - (x - 1); a.ins_h = (a.ins_h << a.hash_shift ^ a.window[i + x - 1]) & a.hash_mask, a.prev[i & a.w_mask] = a.head[a.ins_h], a.head[a.ins_h] = i, i++, --n;); a.strstart = i, a.lookahead = x - 1, H(a) } return a.strstart += a.lookahead, a.block_start = a.strstart, a.insert = a.lookahead, a.lookahead = 0, a.match_length = a.prev_length = x - 1, a.match_available = 0, t.next_in = o, t.input = l, t.avail_in = s, a.wrap = r, b }, a.deflateInfo = "pako deflate (from Nodeca project)" }, { "../utils/common": 3, "./adler32": 5, "./crc32": 7, "./messages": 13, "./trees": 14 }], 9: [function (t, e, a) { "use strict"; e.exports = function () { this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1 } }, {}], 10: [function (t, e, a) { "use strict"; e.exports = function (t, e) { var a, i, n, r, s, o, l, h, d, f, _, u, c, b, g, m, w, p, v, k, y, x, z, B, S; a = t.state, i = t.next_in, B = t.input, n = i + (t.avail_in - 5), r = t.next_out, S = t.output, s = r - (e - t.avail_out), o = r + (t.avail_out - 257), l = a.dmax, h = a.wsize, d = a.whave, f = a.wnext, _ = a.window, u = a.hold, c = a.bits, b = a.lencode, g = a.distcode, m = (1 << a.lenbits) - 1, w = (1 << a.distbits) - 1; t: do { c < 15 && (u += B[i++] << c, c += 8, u += B[i++] << c, c += 8), p = b[u & m]; e: for (; ;) { if (u >>>= v = p >>> 24, c -= v, 0 === (v = p >>> 16 & 255)) S[r++] = 65535 & p; else { if (!(16 & v)) { if (0 == (64 & v)) { p = b[(65535 & p) + (u & (1 << v) - 1)]; continue e } if (32 & v) { a.mode = 12; break t } t.msg = "invalid literal/length code", a.mode = 30; break t } k = 65535 & p, (v &= 15) && (c < v && (u += B[i++] << c, c += 8), k += u & (1 << v) - 1, u >>>= v, c -= v), c < 15 && (u += B[i++] << c, c += 8, u += B[i++] << c, c += 8), p = g[u & w]; a: for (; ;) { if (u >>>= v = p >>> 24, c -= v, !(16 & (v = p >>> 16 & 255))) { if (0 == (64 & v)) { p = g[(65535 & p) + (u & (1 << v) - 1)]; continue a } t.msg = "invalid distance code", a.mode = 30; break t } if (y = 65535 & p, c < (v &= 15) && (u += B[i++] << c, (c += 8) < v && (u += B[i++] << c, c += 8)), l < (y += u & (1 << v) - 1)) { t.msg = "invalid distance too far back", a.mode = 30; break t } if (u >>>= v, c -= v, (v = r - s) < y) { if (d < (v = y - v) && a.sane) { t.msg = "invalid distance too far back", a.mode = 30; break t } if (z = _, (x = 0) === f) { if (x += h - v, v < k) { for (k -= v; S[r++] = _[x++], --v;); x = r - y, z = S } } else if (f < v) { if (x += h + f - v, (v -= f) < k) { for (k -= v; S[r++] = _[x++], --v;); if (x = 0, f < k) { for (k -= v = f; S[r++] = _[x++], --v;); x = r - y, z = S } } } else if (x += f - v, v < k) { for (k -= v; S[r++] = _[x++], --v;); x = r - y, z = S } for (; 2 < k;)S[r++] = z[x++], S[r++] = z[x++], S[r++] = z[x++], k -= 3; k && (S[r++] = z[x++], 1 < k && (S[r++] = z[x++])) } else { for (x = r - y; S[r++] = S[x++], S[r++] = S[x++], S[r++] = S[x++], 2 < (k -= 3);); k && (S[r++] = S[x++], 1 < k && (S[r++] = S[x++])) } break } } break } } while (i < n && r < o); i -= k = c >> 3, u &= (1 << (c -= k << 3)) - 1, t.next_in = i, t.next_out = r, t.avail_in = i < n ? n - i + 5 : 5 - (i - n), t.avail_out = r < o ? o - r + 257 : 257 - (r - o), a.hold = u, a.bits = c } }, {}], 11: [function (t, e, a) { "use strict"; var Z = t("../utils/common"), R = t("./adler32"), C = t("./crc32"), N = t("./inffast"), O = t("./inftrees"), D = 1, I = 2, U = 0, T = -2, F = 1, i = 852, n = 592; function L(t) { return (t >>> 24 & 255) + (t >>> 8 & 65280) + ((65280 & t) << 8) + ((255 & t) << 24) } function r() { this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Z.Buf16(320), this.work = new Z.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0 } function s(t) { var e; return t && t.state ? (e = t.state, t.total_in = t.total_out = e.total = 0, t.msg = "", e.wrap && (t.adler = 1 & e.wrap), e.mode = F, e.last = 0, e.havedict = 0, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Z.Buf32(i), e.distcode = e.distdyn = new Z.Buf32(n), e.sane = 1, e.back = -1, U) : T } function o(t) { var e; return t && t.state ? ((e = t.state).wsize = 0, e.whave = 0, e.wnext = 0, s(t)) : T } function l(t, e) { var a, i; return t && t.state ? (i = t.state, e < 0 ? (a = 0, e = -e) : (a = 1 + (e >> 4), e < 48 && (e &= 15)), e && (e < 8 || 15 < e) ? T : (null !== i.window && i.wbits !== e && (i.window = null), i.wrap = a, i.wbits = e, o(t))) : T } function h(t, e) { var a, i; return t ? (i = new r, (t.state = i).window = null, (a = l(t, e)) !== U && (t.state = null), a) : T } var d, f, _ = !0; function H(t) { if (_) { var e; for (d = new Z.Buf32(512), f = new Z.Buf32(32), e = 0; e < 144;)t.lens[e++] = 8; for (; e < 256;)t.lens[e++] = 9; for (; e < 280;)t.lens[e++] = 7; for (; e < 288;)t.lens[e++] = 8; for (O(D, t.lens, 0, 288, d, 0, t.work, { bits: 9 }), e = 0; e < 32;)t.lens[e++] = 5; O(I, t.lens, 0, 32, f, 0, t.work, { bits: 5 }), _ = !1 } t.lencode = d, t.lenbits = 9, t.distcode = f, t.distbits = 5 } function j(t, e, a, i) { var n, r = t.state; return null === r.window && (r.wsize = 1 << r.wbits, r.wnext = 0, r.whave = 0, r.window = new Z.Buf8(r.wsize)), i >= r.wsize ? (Z.arraySet(r.window, e, a - r.wsize, r.wsize, 0), r.wnext = 0, r.whave = r.wsize) : (i < (n = r.wsize - r.wnext) && (n = i), Z.arraySet(r.window, e, a - i, n, r.wnext), (i -= n) ? (Z.arraySet(r.window, e, a - i, i, 0), r.wnext = i, r.whave = r.wsize) : (r.wnext += n, r.wnext === r.wsize && (r.wnext = 0), r.whave < r.wsize && (r.whave += n))), 0 } a.inflateReset = o, a.inflateReset2 = l, a.inflateResetKeep = s, a.inflateInit = function (t) { return h(t, 15) }, a.inflateInit2 = h, a.inflate = function (t, e) { var a, i, n, r, s, o, l, h, d, f, _, u, c, b, g, m, w, p, v, k, y, x, z, B, S = 0, E = new Z.Buf8(4), A = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; if (!t || !t.state || !t.output || !t.input && 0 !== t.avail_in) return T; 12 === (a = t.state).mode && (a.mode = 13), s = t.next_out, n = t.output, l = t.avail_out, r = t.next_in, i = t.input, o = t.avail_in, h = a.hold, d = a.bits, f = o, _ = l, x = U; t: for (; ;)switch (a.mode) { case F: if (0 === a.wrap) { a.mode = 13; break } for (; d < 16;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (2 & a.wrap && 35615 === h) { E[a.check = 0] = 255 & h, E[1] = h >>> 8 & 255, a.check = C(a.check, E, 2, 0), d = h = 0, a.mode = 2; break } if (a.flags = 0, a.head && (a.head.done = !1), !(1 & a.wrap) || (((255 & h) << 8) + (h >> 8)) % 31) { t.msg = "incorrect header check", a.mode = 30; break } if (8 != (15 & h)) { t.msg = "unknown compression method", a.mode = 30; break } if (d -= 4, y = 8 + (15 & (h >>>= 4)), 0 === a.wbits) a.wbits = y; else if (y > a.wbits) { t.msg = "invalid window size", a.mode = 30; break } a.dmax = 1 << y, t.adler = a.check = 1, a.mode = 512 & h ? 10 : 12, d = h = 0; break; case 2: for (; d < 16;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (a.flags = h, 8 != (255 & a.flags)) { t.msg = "unknown compression method", a.mode = 30; break } if (57344 & a.flags) { t.msg = "unknown header flags set", a.mode = 30; break } a.head && (a.head.text = h >> 8 & 1), 512 & a.flags && (E[0] = 255 & h, E[1] = h >>> 8 & 255, a.check = C(a.check, E, 2, 0)), d = h = 0, a.mode = 3; case 3: for (; d < 32;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } a.head && (a.head.time = h), 512 & a.flags && (E[0] = 255 & h, E[1] = h >>> 8 & 255, E[2] = h >>> 16 & 255, E[3] = h >>> 24 & 255, a.check = C(a.check, E, 4, 0)), d = h = 0, a.mode = 4; case 4: for (; d < 16;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } a.head && (a.head.xflags = 255 & h, a.head.os = h >> 8), 512 & a.flags && (E[0] = 255 & h, E[1] = h >>> 8 & 255, a.check = C(a.check, E, 2, 0)), d = h = 0, a.mode = 5; case 5: if (1024 & a.flags) { for (; d < 16;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } a.length = h, a.head && (a.head.extra_len = h), 512 & a.flags && (E[0] = 255 & h, E[1] = h >>> 8 & 255, a.check = C(a.check, E, 2, 0)), d = h = 0 } else a.head && (a.head.extra = null); a.mode = 6; case 6: if (1024 & a.flags && (o < (u = a.length) && (u = o), u && (a.head && (y = a.head.extra_len - a.length, a.head.extra || (a.head.extra = new Array(a.head.extra_len)), Z.arraySet(a.head.extra, i, r, u, y)), 512 & a.flags && (a.check = C(a.check, i, u, r)), o -= u, r += u, a.length -= u), a.length)) break t; a.length = 0, a.mode = 7; case 7: if (2048 & a.flags) { if (0 === o) break t; for (u = 0; y = i[r + u++], a.head && y && a.length < 65536 && (a.head.name += String.fromCharCode(y)), y && u < o;); if (512 & a.flags && (a.check = C(a.check, i, u, r)), o -= u, r += u, y) break t } else a.head && (a.head.name = null); a.length = 0, a.mode = 8; case 8: if (4096 & a.flags) { if (0 === o) break t; for (u = 0; y = i[r + u++], a.head && y && a.length < 65536 && (a.head.comment += String.fromCharCode(y)), y && u < o;); if (512 & a.flags && (a.check = C(a.check, i, u, r)), o -= u, r += u, y) break t } else a.head && (a.head.comment = null); a.mode = 9; case 9: if (512 & a.flags) { for (; d < 16;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (h !== (65535 & a.check)) { t.msg = "header crc mismatch", a.mode = 30; break } d = h = 0 } a.head && (a.head.hcrc = a.flags >> 9 & 1, a.head.done = !0), t.adler = a.check = 0, a.mode = 12; break; case 10: for (; d < 32;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } t.adler = a.check = L(h), d = h = 0, a.mode = 11; case 11: if (0 === a.havedict) return t.next_out = s, t.avail_out = l, t.next_in = r, t.avail_in = o, a.hold = h, a.bits = d, 2; t.adler = a.check = 1, a.mode = 12; case 12: if (5 === e || 6 === e) break t; case 13: if (a.last) { h >>>= 7 & d, d -= 7 & d, a.mode = 27; break } for (; d < 3;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } switch (a.last = 1 & h, d -= 1, 3 & (h >>>= 1)) { case 0: a.mode = 14; break; case 1: if (H(a), a.mode = 20, 6 !== e) break; h >>>= 2, d -= 2; break t; case 2: a.mode = 17; break; case 3: t.msg = "invalid block type", a.mode = 30 }h >>>= 2, d -= 2; break; case 14: for (h >>>= 7 & d, d -= 7 & d; d < 32;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if ((65535 & h) != (h >>> 16 ^ 65535)) { t.msg = "invalid stored block lengths", a.mode = 30; break } if (a.length = 65535 & h, d = h = 0, a.mode = 15, 6 === e) break t; case 15: a.mode = 16; case 16: if (u = a.length) { if (o < u && (u = o), l < u && (u = l), 0 === u) break t; Z.arraySet(n, i, r, u, s), o -= u, r += u, l -= u, s += u, a.length -= u; break } a.mode = 12; break; case 17: for (; d < 14;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (a.nlen = 257 + (31 & h), h >>>= 5, d -= 5, a.ndist = 1 + (31 & h), h >>>= 5, d -= 5, a.ncode = 4 + (15 & h), h >>>= 4, d -= 4, 286 < a.nlen || 30 < a.ndist) { t.msg = "too many length or distance symbols", a.mode = 30; break } a.have = 0, a.mode = 18; case 18: for (; a.have < a.ncode;) { for (; d < 3;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } a.lens[A[a.have++]] = 7 & h, h >>>= 3, d -= 3 } for (; a.have < 19;)a.lens[A[a.have++]] = 0; if (a.lencode = a.lendyn, a.lenbits = 7, z = { bits: a.lenbits }, x = O(0, a.lens, 0, 19, a.lencode, 0, a.work, z), a.lenbits = z.bits, x) { t.msg = "invalid code lengths set", a.mode = 30; break } a.have = 0, a.mode = 19; case 19: for (; a.have < a.nlen + a.ndist;) { for (; m = (S = a.lencode[h & (1 << a.lenbits) - 1]) >>> 16 & 255, w = 65535 & S, !((g = S >>> 24) <= d);) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (w < 16) h >>>= g, d -= g, a.lens[a.have++] = w; else { if (16 === w) { for (B = g + 2; d < B;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (h >>>= g, d -= g, 0 === a.have) { t.msg = "invalid bit length repeat", a.mode = 30; break } y = a.lens[a.have - 1], u = 3 + (3 & h), h >>>= 2, d -= 2 } else if (17 === w) { for (B = g + 3; d < B;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } d -= g, y = 0, u = 3 + (7 & (h >>>= g)), h >>>= 3, d -= 3 } else { for (B = g + 7; d < B;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } d -= g, y = 0, u = 11 + (127 & (h >>>= g)), h >>>= 7, d -= 7 } if (a.have + u > a.nlen + a.ndist) { t.msg = "invalid bit length repeat", a.mode = 30; break } for (; u--;)a.lens[a.have++] = y } } if (30 === a.mode) break; if (0 === a.lens[256]) { t.msg = "invalid code -- missing end-of-block", a.mode = 30; break } if (a.lenbits = 9, z = { bits: a.lenbits }, x = O(D, a.lens, 0, a.nlen, a.lencode, 0, a.work, z), a.lenbits = z.bits, x) { t.msg = "invalid literal/lengths set", a.mode = 30; break } if (a.distbits = 6, a.distcode = a.distdyn, z = { bits: a.distbits }, x = O(I, a.lens, a.nlen, a.ndist, a.distcode, 0, a.work, z), a.distbits = z.bits, x) { t.msg = "invalid distances set", a.mode = 30; break } if (a.mode = 20, 6 === e) break t; case 20: a.mode = 21; case 21: if (6 <= o && 258 <= l) { t.next_out = s, t.avail_out = l, t.next_in = r, t.avail_in = o, a.hold = h, a.bits = d, N(t, _), s = t.next_out, n = t.output, l = t.avail_out, r = t.next_in, i = t.input, o = t.avail_in, h = a.hold, d = a.bits, 12 === a.mode && (a.back = -1); break } for (a.back = 0; m = (S = a.lencode[h & (1 << a.lenbits) - 1]) >>> 16 & 255, w = 65535 & S, !((g = S >>> 24) <= d);) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (m && 0 == (240 & m)) { for (p = g, v = m, k = w; m = (S = a.lencode[k + ((h & (1 << p + v) - 1) >> p)]) >>> 16 & 255, w = 65535 & S, !(p + (g = S >>> 24) <= d);) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } h >>>= p, d -= p, a.back += p } if (h >>>= g, d -= g, a.back += g, a.length = w, 0 === m) { a.mode = 26; break } if (32 & m) { a.back = -1, a.mode = 12; break } if (64 & m) { t.msg = "invalid literal/length code", a.mode = 30; break } a.extra = 15 & m, a.mode = 22; case 22: if (a.extra) { for (B = a.extra; d < B;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } a.length += h & (1 << a.extra) - 1, h >>>= a.extra, d -= a.extra, a.back += a.extra } a.was = a.length, a.mode = 23; case 23: for (; m = (S = a.distcode[h & (1 << a.distbits) - 1]) >>> 16 & 255, w = 65535 & S, !((g = S >>> 24) <= d);) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (0 == (240 & m)) { for (p = g, v = m, k = w; m = (S = a.distcode[k + ((h & (1 << p + v) - 1) >> p)]) >>> 16 & 255, w = 65535 & S, !(p + (g = S >>> 24) <= d);) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } h >>>= p, d -= p, a.back += p } if (h >>>= g, d -= g, a.back += g, 64 & m) { t.msg = "invalid distance code", a.mode = 30; break } a.offset = w, a.extra = 15 & m, a.mode = 24; case 24: if (a.extra) { for (B = a.extra; d < B;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } a.offset += h & (1 << a.extra) - 1, h >>>= a.extra, d -= a.extra, a.back += a.extra } if (a.offset > a.dmax) { t.msg = "invalid distance too far back", a.mode = 30; break } a.mode = 25; case 25: if (0 === l) break t; if (u = _ - l, a.offset > u) { if ((u = a.offset - u) > a.whave && a.sane) { t.msg = "invalid distance too far back", a.mode = 30; break } u > a.wnext ? (u -= a.wnext, c = a.wsize - u) : c = a.wnext - u, u > a.length && (u = a.length), b = a.window } else b = n, c = s - a.offset, u = a.length; for (l < u && (u = l), l -= u, a.length -= u; n[s++] = b[c++], --u;); 0 === a.length && (a.mode = 21); break; case 26: if (0 === l) break t; n[s++] = a.length, l--, a.mode = 21; break; case 27: if (a.wrap) { for (; d < 32;) { if (0 === o) break t; o--, h |= i[r++] << d, d += 8 } if (_ -= l, t.total_out += _, a.total += _, _ && (t.adler = a.check = a.flags ? C(a.check, n, _, s - _) : R(a.check, n, _, s - _)), _ = l, (a.flags ? h : L(h)) !== a.check) { t.msg = "incorrect data check", a.mode = 30; break } d = h = 0 } a.mode = 28; case 28: if (a.wrap && a.flags) { for (; d < 32;) { if (0 === o) break t; o--, h += i[r++] << d, d += 8 } if (h !== (4294967295 & a.total)) { t.msg = "incorrect length check", a.mode = 30; break } d = h = 0 } a.mode = 29; case 29: x = 1; break t; case 30: x = -3; break t; case 31: return -4; case 32: default: return T }return t.next_out = s, t.avail_out = l, t.next_in = r, t.avail_in = o, a.hold = h, a.bits = d, (a.wsize || _ !== t.avail_out && a.mode < 30 && (a.mode < 27 || 4 !== e)) && j(t, t.output, t.next_out, _ - t.avail_out) ? (a.mode = 31, -4) : (f -= t.avail_in, _ -= t.avail_out, t.total_in += f, t.total_out += _, a.total += _, a.wrap && _ && (t.adler = a.check = a.flags ? C(a.check, n, _, t.next_out - _) : R(a.check, n, _, t.next_out - _)), t.data_type = a.bits + (a.last ? 64 : 0) + (12 === a.mode ? 128 : 0) + (20 === a.mode || 15 === a.mode ? 256 : 0), (0 === f && 0 === _ || 4 === e) && x === U && (x = -5), x) }, a.inflateEnd = function (t) { if (!t || !t.state) return T; var e = t.state; return e.window && (e.window = null), t.state = null, U }, a.inflateGetHeader = function (t, e) { var a; return t && t.state ? 0 == (2 & (a = t.state).wrap) ? T : ((a.head = e).done = !1, U) : T }, a.inflateSetDictionary = function (t, e) { var a, i = e.length; return t && t.state ? 0 !== (a = t.state).wrap && 11 !== a.mode ? T : 11 === a.mode && R(1, e, i, 0) !== a.check ? -3 : j(t, e, i, i) ? (a.mode = 31, -4) : (a.havedict = 1, U) : T }, a.inflateInfo = "pako inflate (from Nodeca project)" }, { "../utils/common": 3, "./adler32": 5, "./crc32": 7, "./inffast": 10, "./inftrees": 12 }], 12: [function (t, e, a) { "use strict"; var D = t("../utils/common"), I = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0], U = [16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78], T = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0], F = [16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64]; e.exports = function (t, e, a, i, n, r, s, o) { var l, h, d, f, _, u, c, b, g, m = o.bits, w = 0, p = 0, v = 0, k = 0, y = 0, x = 0, z = 0, B = 0, S = 0, E = 0, A = null, Z = 0, R = new D.Buf16(16), C = new D.Buf16(16), N = null, O = 0; for (w = 0; w <= 15; w++)R[w] = 0; for (p = 0; p < i; p++)R[e[a + p]]++; for (y = m, k = 15; 1 <= k && 0 === R[k]; k--); if (k < y && (y = k), 0 === k) return n[r++] = 20971520, n[r++] = 20971520, o.bits = 1, 0; for (v = 1; v < k && 0 === R[v]; v++); for (y < v && (y = v), w = B = 1; w <= 15; w++)if (B <<= 1, (B -= R[w]) < 0) return -1; if (0 < B && (0 === t || 1 !== k)) return -1; for (C[1] = 0, w = 1; w < 15; w++)C[w + 1] = C[w] + R[w]; for (p = 0; p < i; p++)0 !== e[a + p] && (s[C[e[a + p]]++] = p); if (0 === t ? (A = N = s, u = 19) : 1 === t ? (A = I, Z -= 257, N = U, O -= 257, u = 256) : (A = T, N = F, u = -1), w = v, _ = r, z = p = E = 0, d = -1, f = (S = 1 << (x = y)) - 1, 1 === t && 852 < S || 2 === t && 592 < S) return 1; for (; ;) { for (c = w - z, s[p] < u ? (b = 0, g = s[p]) : s[p] > u ? (b = N[O + s[p]], g = A[Z + s[p]]) : (b = 96, g = 0), l = 1 << w - z, v = h = 1 << x; n[_ + (E >> z) + (h -= l)] = c << 24 | b << 16 | g | 0, 0 !== h;); for (l = 1 << w - 1; E & l;)l >>= 1; if (0 !== l ? (E &= l - 1, E += l) : E = 0, p++, 0 == --R[w]) { if (w === k) break; w = e[a + s[p]] } if (y < w && (E & f) !== d) { for (0 === z && (z = y), _ += v, B = 1 << (x = w - z); x + z < k && !((B -= R[x + z]) <= 0);)x++, B <<= 1; if (S += 1 << x, 1 === t && 852 < S || 2 === t && 592 < S) return 1; n[d = E & f] = y << 24 | x << 16 | _ - r | 0 } } return 0 !== E && (n[_ + E] = w - z << 24 | 64 << 16 | 0), o.bits = y, 0 } }, { "../utils/common": 3 }], 13: [function (t, e, a) { "use strict"; e.exports = { 2: "need dictionary", 1: "stream end", 0: "", "-1": "file error", "-2": "stream error", "-3": "data error", "-4": "insufficient memory", "-5": "buffer error", "-6": "incompatible version" } }, {}], 14: [function (t, e, a) { "use strict"; var l = t("../utils/common"), o = 0, h = 1; function i(t) { for (var e = t.length; 0 <= --e;)t[e] = 0 } var d = 0, s = 29, f = 256, _ = f + 1 + s, u = 30, c = 19, g = 2 * _ + 1, m = 15, n = 16, b = 7, w = 256, p = 16, v = 17, k = 18, y = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], x = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13], z = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], B = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], S = new Array(2 * (_ + 2)); i(S); var E = new Array(2 * u); i(E); var A = new Array(512); i(A); var Z = new Array(256); i(Z); var R = new Array(s); i(R); var C, N, O, D = new Array(u); function I(t, e, a, i, n) { this.static_tree = t, this.extra_bits = e, this.extra_base = a, this.elems = i, this.max_length = n, this.has_stree = t && t.length } function r(t, e) { this.dyn_tree = t, this.max_code = 0, this.stat_desc = e } function U(t) { return t < 256 ? A[t] : A[256 + (t >>> 7)] } function T(t, e) { t.pending_buf[t.pending++] = 255 & e, t.pending_buf[t.pending++] = e >>> 8 & 255 } function F(t, e, a) { t.bi_valid > n - a ? (t.bi_buf |= e << t.bi_valid & 65535, T(t, t.bi_buf), t.bi_buf = e >> n - t.bi_valid, t.bi_valid += a - n) : (t.bi_buf |= e << t.bi_valid & 65535, t.bi_valid += a) } function L(t, e, a) { F(t, a[2 * e], a[2 * e + 1]) } function H(t, e) { for (var a = 0; a |= 1 & t, t >>>= 1, a <<= 1, 0 < --e;); return a >>> 1 } function j(t, e, a) { var i, n, r = new Array(m + 1), s = 0; for (i = 1; i <= m; i++)r[i] = s = s + a[i - 1] << 1; for (n = 0; n <= e; n++) { var o = t[2 * n + 1]; 0 !== o && (t[2 * n] = H(r[o]++, o)) } } function K(t) { var e; for (e = 0; e < _; e++)t.dyn_ltree[2 * e] = 0; for (e = 0; e < u; e++)t.dyn_dtree[2 * e] = 0; for (e = 0; e < c; e++)t.bl_tree[2 * e] = 0; t.dyn_ltree[2 * w] = 1, t.opt_len = t.static_len = 0, t.last_lit = t.matches = 0 } function M(t) { 8 < t.bi_valid ? T(t, t.bi_buf) : 0 < t.bi_valid && (t.pending_buf[t.pending++] = t.bi_buf), t.bi_buf = 0, t.bi_valid = 0 } function P(t, e, a, i) { var n = 2 * e, r = 2 * a; return t[n] < t[r] || t[n] === t[r] && i[e] <= i[a] } function Y(t, e, a) { for (var i = t.heap[a], n = a << 1; n <= t.heap_len && (n < t.heap_len && P(e, t.heap[n + 1], t.heap[n], t.depth) && n++, !P(e, i, t.heap[n], t.depth));)t.heap[a] = t.heap[n], a = n, n <<= 1; t.heap[a] = i } function q(t, e, a) { var i, n, r, s, o = 0; if (0 !== t.last_lit) for (; i = t.pending_buf[t.d_buf + 2 * o] << 8 | t.pending_buf[t.d_buf + 2 * o + 1], n = t.pending_buf[t.l_buf + o], o++, 0 === i ? L(t, n, e) : (L(t, (r = Z[n]) + f + 1, e), 0 !== (s = y[r]) && F(t, n -= R[r], s), L(t, r = U(--i), a), 0 !== (s = x[r]) && F(t, i -= D[r], s)), o < t.last_lit;); L(t, w, e) } function G(t, e) { var a, i, n, r = e.dyn_tree, s = e.stat_desc.static_tree, o = e.stat_desc.has_stree, l = e.stat_desc.elems, h = -1; for (t.heap_len = 0, t.heap_max = g, a = 0; a < l; a++)0 !== r[2 * a] ? (t.heap[++t.heap_len] = h = a, t.depth[a] = 0) : r[2 * a + 1] = 0; for (; t.heap_len < 2;)r[2 * (n = t.heap[++t.heap_len] = h < 2 ? ++h : 0)] = 1, t.depth[n] = 0, t.opt_len--, o && (t.static_len -= s[2 * n + 1]); for (e.max_code = h, a = t.heap_len >> 1; 1 <= a; a--)Y(t, r, a); for (n = l; a = t.heap[1], t.heap[1] = t.heap[t.heap_len--], Y(t, r, 1), i = t.heap[1], t.heap[--t.heap_max] = a, t.heap[--t.heap_max] = i, r[2 * n] = r[2 * a] + r[2 * i], t.depth[n] = (t.depth[a] >= t.depth[i] ? t.depth[a] : t.depth[i]) + 1, r[2 * a + 1] = r[2 * i + 1] = n, t.heap[1] = n++, Y(t, r, 1), 2 <= t.heap_len;); t.heap[--t.heap_max] = t.heap[1], function (t, e) { var a, i, n, r, s, o, l = e.dyn_tree, h = e.max_code, d = e.stat_desc.static_tree, f = e.stat_desc.has_stree, _ = e.stat_desc.extra_bits, u = e.stat_desc.extra_base, c = e.stat_desc.max_length, b = 0; for (r = 0; r <= m; r++)t.bl_count[r] = 0; for (l[2 * t.heap[t.heap_max] + 1] = 0, a = t.heap_max + 1; a < g; a++)c < (r = l[2 * l[2 * (i = t.heap[a]) + 1] + 1] + 1) && (r = c, b++), l[2 * i + 1] = r, h < i || (t.bl_count[r]++, s = 0, u <= i && (s = _[i - u]), o = l[2 * i], t.opt_len += o * (r + s), f && (t.static_len += o * (d[2 * i + 1] + s))); if (0 !== b) { do { for (r = c - 1; 0 === t.bl_count[r];)r--; t.bl_count[r]--, t.bl_count[r + 1] += 2, t.bl_count[c]--, b -= 2 } while (0 < b); for (r = c; 0 !== r; r--)for (i = t.bl_count[r]; 0 !== i;)h < (n = t.heap[--a]) || (l[2 * n + 1] !== r && (t.opt_len += (r - l[2 * n + 1]) * l[2 * n], l[2 * n + 1] = r), i--) } }(t, e), j(r, h, t.bl_count) } function X(t, e, a) { var i, n, r = -1, s = e[1], o = 0, l = 7, h = 4; for (0 === s && (l = 138, h = 3), e[2 * (a + 1) + 1] = 65535, i = 0; i <= a; i++)n = s, s = e[2 * (i + 1) + 1], ++o < l && n === s || (o < h ? t.bl_tree[2 * n] += o : 0 !== n ? (n !== r && t.bl_tree[2 * n]++, t.bl_tree[2 * p]++) : o <= 10 ? t.bl_tree[2 * v]++ : t.bl_tree[2 * k]++, r = n, (o = 0) === s ? (l = 138, h = 3) : n === s ? (l = 6, h = 3) : (l = 7, h = 4)) } function W(t, e, a) { var i, n, r = -1, s = e[1], o = 0, l = 7, h = 4; for (0 === s && (l = 138, h = 3), i = 0; i <= a; i++)if (n = s, s = e[2 * (i + 1) + 1], !(++o < l && n === s)) { if (o < h) for (; L(t, n, t.bl_tree), 0 != --o;); else 0 !== n ? (n !== r && (L(t, n, t.bl_tree), o--), L(t, p, t.bl_tree), F(t, o - 3, 2)) : o <= 10 ? (L(t, v, t.bl_tree), F(t, o - 3, 3)) : (L(t, k, t.bl_tree), F(t, o - 11, 7)); r = n, (o = 0) === s ? (l = 138, h = 3) : n === s ? (l = 6, h = 3) : (l = 7, h = 4) } } i(D); var J = !1; function Q(t, e, a, i) { var n, r, s, o; F(t, (d << 1) + (i ? 1 : 0), 3), r = e, s = a, o = !0, M(n = t), o && (T(n, s), T(n, ~s)), l.arraySet(n.pending_buf, n.window, r, s, n.pending), n.pending += s } a._tr_init = function (t) { J || (function () { var t, e, a, i, n, r = new Array(m + 1); for (i = a = 0; i < s - 1; i++)for (R[i] = a, t = 0; t < 1 << y[i]; t++)Z[a++] = i; for (Z[a - 1] = i, i = n = 0; i < 16; i++)for (D[i] = n, t = 0; t < 1 << x[i]; t++)A[n++] = i; for (n >>= 7; i < u; i++)for (D[i] = n << 7, t = 0; t < 1 << x[i] - 7; t++)A[256 + n++] = i; for (e = 0; e <= m; e++)r[e] = 0; for (t = 0; t <= 143;)S[2 * t + 1] = 8, t++, r[8]++; for (; t <= 255;)S[2 * t + 1] = 9, t++, r[9]++; for (; t <= 279;)S[2 * t + 1] = 7, t++, r[7]++; for (; t <= 287;)S[2 * t + 1] = 8, t++, r[8]++; for (j(S, _ + 1, r), t = 0; t < u; t++)E[2 * t + 1] = 5, E[2 * t] = H(t, 5); C = new I(S, y, f + 1, _, m), N = new I(E, x, 0, u, m), O = new I(new Array(0), z, 0, c, b) }(), J = !0), t.l_desc = new r(t.dyn_ltree, C), t.d_desc = new r(t.dyn_dtree, N), t.bl_desc = new r(t.bl_tree, O), t.bi_buf = 0, t.bi_valid = 0, K(t) }, a._tr_stored_block = Q, a._tr_flush_block = function (t, e, a, i) { var n, r, s = 0; 0 < t.level ? (2 === t.strm.data_type && (t.strm.data_type = function (t) { var e, a = 4093624447; for (e = 0; e <= 31; e++, a >>>= 1)if (1 & a && 0 !== t.dyn_ltree[2 * e]) return o; if (0 !== t.dyn_ltree[18] || 0 !== t.dyn_ltree[20] || 0 !== t.dyn_ltree[26]) return h; for (e = 32; e < f; e++)if (0 !== t.dyn_ltree[2 * e]) return h; return o }(t)), G(t, t.l_desc), G(t, t.d_desc), s = function (t) { var e; for (X(t, t.dyn_ltree, t.l_desc.max_code), X(t, t.dyn_dtree, t.d_desc.max_code), G(t, t.bl_desc), e = c - 1; 3 <= e && 0 === t.bl_tree[2 * B[e] + 1]; e--); return t.opt_len += 3 * (e + 1) + 5 + 5 + 4, e }(t), n = t.opt_len + 3 + 7 >>> 3, (r = t.static_len + 3 + 7 >>> 3) <= n && (n = r)) : n = r = a + 5, a + 4 <= n && -1 !== e ? Q(t, e, a, i) : 4 === t.strategy || r === n ? (F(t, 2 + (i ? 1 : 0), 3), q(t, S, E)) : (F(t, 4 + (i ? 1 : 0), 3), function (t, e, a, i) { var n; for (F(t, e - 257, 5), F(t, a - 1, 5), F(t, i - 4, 4), n = 0; n < i; n++)F(t, t.bl_tree[2 * B[n] + 1], 3); W(t, t.dyn_ltree, e - 1), W(t, t.dyn_dtree, a - 1) }(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, s + 1), q(t, t.dyn_ltree, t.dyn_dtree)), K(t), i && M(t) }, a._tr_tally = function (t, e, a) { return t.pending_buf[t.d_buf + 2 * t.last_lit] = e >>> 8 & 255, t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e, t.pending_buf[t.l_buf + t.last_lit] = 255 & a, t.last_lit++, 0 === e ? t.dyn_ltree[2 * a]++ : (t.matches++, e--, t.dyn_ltree[2 * (Z[a] + f + 1)]++, t.dyn_dtree[2 * U(e)]++), t.last_lit === t.lit_bufsize - 1 }, a._tr_align = function (t) { var e; F(t, 2, 3), L(t, w, S), 16 === (e = t).bi_valid ? (T(e, e.bi_buf), e.bi_buf = 0, e.bi_valid = 0) : 8 <= e.bi_valid && (e.pending_buf[e.pending++] = 255 & e.bi_buf, e.bi_buf >>= 8, e.bi_valid -= 8) } }, { "../utils/common": 3 }], 15: [function (t, e, a) { "use strict"; e.exports = function () { this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0 } }, {}], "/": [function (t, e, a) { "use strict"; var i = {}; (0, t("./lib/utils/common").assign)(i, t("./lib/deflate"), t("./lib/inflate"), t("./lib/zlib/constants")), e.exports = i }, { "./lib/deflate": 1, "./lib/inflate": 2, "./lib/utils/common": 3, "./lib/zlib/constants": 6 }] }, {}, [])("/") });

function StringCompress(originalString) {
    return LZString.compress(originalString);
}

function StringDecompress(compressedString) {
    return LZString.decompress(compressedString);
}


function getResponseHashkeyOrErrorMessage(response, successFunc, errorFunc) {
    if (!response || typeof response.success === 'undefined') {
        if (typeof errorFunc === 'function') errorFunc();
        return false;
    }

    const { success, message, data, hashkey } = response;

    const resolvedHashkey = data?.hashkey ?? hashkey ?? null;

    if (success === true) {
        if (typeof successFunc === 'function') {
            try {
                successFunc(resolvedHashkey, data);
            } catch {
                successFunc();
            }
        }
        return true;
    }

    if (success === false) {
        if (typeof errorFunc === 'function') {
            try {
                errorFunc(message ?? 'An unknown error occurred');
            } catch {
                errorFunc();
            }
        }
        return false;
    }

    return false;
}

function getCurrentDataOrFetch(url, dataToSend, successFunc, errorFunc, method = 'POST', varcachefirst = false, pageName = '') {
    if (typeof currentData !== 'undefined' && currentData) {
        // console.log('Using direct data',currentData);
        if (typeof successFunc === 'function') successFunc(currentData);
        return currentData;
    }





    // console.log('Requesting data',url,dataToSend);
    let Req = new RequestData();
    Req.url(url)
        .type(method)
        .data(dataToSend)
        .fromVarCache(varcachefirst)
        .success((response) => {
            // console.log('Data Found',response);
            currentData = response.data || response;

            executeFuncifSamePage(true, pageName, successFunc, response);


        })
        .error((response) => {
            // console.log('Data Error',response);
            // if (typeof errorFunc === 'function') errorFunc(response);
            executeFuncifSamePage(true, pageName, errorFunc, response);

        })
        .go();

    if (varcachefirst) {
        Req.url(url)
            .type(method)
            .data(dataToSend)
            .fromVarCache(false)
            .success((response) => {
                // console.log('Data Found',response);
                currentData = response.data || response;
                // if (typeof successFunc === 'function') successFunc(currentData);
                executeFuncifSamePage(true, pageName, successFunc, response);
            })
            .error((response) => {
                // console.log('Data Error',response);
                // if (typeof errorFunc === 'function') errorFunc(response);
                executeFuncifSamePage(true, pageName, errorFunc, response);
            })
            .go();
    }

    return null;
}


function hashString(str) {
    let hash = 0, i, chr;
    if (str.length === 0) return hash;
    for (i = 0; i < str.length; i++) {
        chr = str.charCodeAt(i);
        hash = ((hash << 5) - hash) + chr;
        hash |= 0;
    }
    return hash;
}

function normalizeHTML(html) {
    const $temp = $('<div>').html(html.trim());
    $temp.find('*').each(function () {
        $(this).removeAttr('id');
        $(this).removeAttr('style');
    });

    return $temp.html()
        .replace(/\s+/g, ' ')
        .trim();
}

function updateHTMLifChanged(newhtml, elementIDstring) {
    const $container = $('#' + elementIDstring);
    const currentNormalized = normalizeHTML($container.html());
    const newNormalized = normalizeHTML(newhtml);

    if (currentNormalized !== newNormalized) {
        console.log('Content differs — updating container.');
        $container.html(newhtml);
    } else {
        console.log('Content identical — no update performed.');
    }
}

function executeFuncifSamePage(errortrue, pageName, functoexec, functdata = false) {
    if (!pageName || !currentPage) {
        logDev('executeFuncifSamePage Page name or current page is not defined.');
        return false;
    }


    if (errortrue && currentPage === pageName) {
        logDev('executeFuncifSamePage Executing function for page:', pageName);
        if (functoexec && typeof functoexec === 'function') {
            functoexec(functdata);
        }
        return true;
    }
    logDev('executeFuncifSamePage Page has changed; not executing function.', pageName, currentPage);
}

function isArrayEqual(a, b) {
    return JSON.stringify(a) === JSON.stringify(b);
}



function loadDataWithCache({
    url,
    current_page,
    executeFunction,
    requestData = null,
    requestType = null,
    errorFunction = null,
}) {
    const baseConfig = r => r.url(url).type(requestType).data(requestData);
    if (!requestType) {
        if (typeof LoadDataPageFunc !== 'undefined' && typeof LoadDataPageFunc.Settings !== 'undefined' && typeof LoadDataPageFunc.Settings.DefaultRequestType !== 'undefined' && LoadDataPageFunc.Settings.DefaultRequestType) {
            requestType = LoadDataPageFunc.Settings.DefaultRequestType;
        } else {
            requestType = 'POST';
        }
    }

    const PageCount = PageCounterTracker;


    const normalizeResponse = (res) => {
        if (res && typeof res === 'object' && 'data' in res && res.success) {
            return res.data;
        }
        return res;
    };

    const handleSuccess = (cachedResponse) => {
        cachedResponse = normalizeResponse(cachedResponse);

        currentData = cachedResponse;
        executeFuncifSamePage(true, current_page, executeFunction, cachedResponse);
        logDev('loadDataWithCache currentPage', current_page);

        //Same page check must there be a  buffer that empties that  currentPageData after a traverse to another page


        baseConfig(new RequestData(false))
            .fromVarCache(false)
            .success(freshResponse => {
                freshResponse = normalizeResponse(freshResponse);
                logDev('loadDataWithCache Fetched fresh data from server:', freshResponse);
                logDev('loadDataWithCache Cached data:', cachedResponse);


                if (!deepEqual(cachedResponse, freshResponse)) {
                    currentData = freshResponse;
                    logDev('loadDataWithCache Data updated from server:', freshResponse);
                    executeFuncifSamePage(true, currentPage, executeFunction, freshResponse);
                } else {

                    if (PageCount != PageCounterTracker) {
                        executeFuncifSamePage(true, currentPage, executeFunction, freshResponse);
                    } else {
                        logDev('loadDataWithCache Data from server is identical to cached data; no update needed.');
                    }


                }

            })
            .error(response => {
                logDev('loadDataWithCache Error fetching fresh data:', response);
                if (typeof errorFunction === 'function') {
                    errorFunction(response);
                }
            })
            .go();
    };

    baseConfig(new RequestData(false))
        .fromVarCache(true)
        .success(handleSuccess)
        .error(response => {
            if (typeof errorFunction === 'function') { errorFunction(response); }
        })
        .go();
}


/**
 * Initialize a global variable if it doesn't already exist.
 *
 * @param {string} name - Variable name
 * @param {*} value - Initial value
 * @param {Object} [options]
 * @param {boolean} [options.constant=false] - If true, makes it read-only
 */
function initGlobal(name, value, { constant = false } = {}) {
    const globalObj = globalThis;

    if (!(name in globalObj)) {
        if (constant) {
            Object.defineProperty(globalObj, name, {
                value,
                writable: false,
                configurable: false,
                enumerable: true
            });
        } else {
            globalObj[name] = value;
        }
    }

    return globalObj[name];
}