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U,EAAS,GAClC,IAEI,IAAI,EAAa,EAAI,SACrB,GAA2B,SAAvB,EAAM,cAAiD,iBAAf,EACxC,EAAQ,KAAK,MAAM,EAAI,oBAEtB,GAA2B,UAAvB,EAAM,aAA0B,CACrC,IAAI,EAAa,IAAI,gBAAgB,IACrC,EAAa,IAAI,OACN,IAAM,EACjB,EAAW,YAAc,YACzB,EAAW,OAAS,WAChB,IAAI,gBAAgB,GACpB,EAAQ,EACZ,CACJ,MAEI,EAAQ,EAEhB,CACA,MAAO,GACH,EAAO,CAAE,MAAO,8BACpB,CACJ,GACJ,EAMA,EAAQ,UAAU,MAAQ,WACtB,GAAiB,OAAb,KAAK,IACL,MAAM,IAAI,MAAM,+BAEpB,KAAK,IAAI,OACb,EACO,CACX,CA9Ic,GA+Id,QAAQ,QAAU","file":"/npm/requestq@0.9.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/requestq@0.9.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar RequestPriority;\n(function (RequestPriority) {\n    RequestPriority[RequestPriority[\"LOW\"] = 0] = \"LOW\";\n    RequestPriority[RequestPriority[\"MEDIUM\"] = 1] = \"MEDIUM\";\n    RequestPriority[RequestPriority[\"HIGH\"] = 2] = \"HIGH\";\n    RequestPriority[RequestPriority[\"HIGHEST\"] = 3] = \"HIGHEST\";\n})(RequestPriority = exports.RequestPriority || (exports.RequestPriority = {}));\nvar RequestStatus;\n(function (RequestStatus) {\n    RequestStatus[RequestStatus[\"PENDING\"] = 0] = \"PENDING\";\n    RequestStatus[RequestStatus[\"SENDING\"] = 1] = \"SENDING\";\n    RequestStatus[RequestStatus[\"FAILED\"] = 2] = \"FAILED\";\n    RequestStatus[RequestStatus[\"DONE\"] = 3] = \"DONE\";\n})(RequestStatus = exports.RequestStatus || (exports.RequestStatus = {}));\n/**\n * Utility: Cross-browser XHR request,\n * Only here to support IE <= 7...\n *\n * @param {string} method\n * @param {string} url\n * @param {boolean} withCredentials\n * @returns\n */\nfunction openXHR(method, url, withCredentials) {\n    var xhr;\n    if (typeof XMLHttpRequest !== 'undefined') {\n        xhr = new XMLHttpRequest();\n        xhr.withCredentials = withCredentials;\n    }\n    else if (typeof XDomainRequest !== 'undefined') {\n        xhr = new XDomainRequest();\n    }\n    else {\n        throw new Error('No XMLHTTPRequest or XDomainRequest... are you trying to run me in node? :(');\n    }\n    xhr.open(method, url, true);\n    return xhr;\n}\nvar RequestQueue = (function () {\n    function RequestQueue(_a) {\n        var _b = _a === void 0 ? {} : _a, _c = _b.retries, retries = _c === void 0 ? 3 : _c, _d = _b.concurrency, concurrency = _d === void 0 ? 6 : _d;\n        this.queue = [];\n        this.retries = retries;\n        this.concurrency = concurrency;\n    }\n    RequestQueue.prototype.get = function (url, options) {\n        return this.request('GET', url, options);\n    };\n    RequestQueue.prototype.head = function (url, options) {\n        return this.request('HEAD', url, options);\n    };\n    RequestQueue.prototype.options = function (url, options) {\n        return this.request('OPTIONS', url, options);\n    };\n    RequestQueue.prototype.post = function (url, options) {\n        return this.request('POST', url, options);\n    };\n    RequestQueue.prototype.put = function (url, options) {\n        return this.request('PUT', url, options);\n    };\n    RequestQueue.prototype.patch = function (url, options) {\n        return this.request('PATCH', url, options);\n    };\n    RequestQueue.prototype.delete = function (url, options) {\n        return this.request('DELETE', url, options);\n    };\n    RequestQueue.prototype.request = function (method, url, options) {\n        var req = new Request(method, url, options);\n        this.enqueue(req);\n        return req.promise;\n    };\n    /**\n     * Handle all queue changes, sending new requests etc\n     *\n     */\n    RequestQueue.prototype.update = function () {\n        var req;\n        while (req = this.getNextPendingRequest()) {\n            this.sendRequest(req);\n        }\n        // Cancel any requests that put us over our concurrency\n        // This happens when HIGHEST priority requests bump other requests\n        while (req = this.getNextOverflowingRequest()) {\n            req.abort();\n            req.status = RequestStatus.PENDING;\n        }\n        this.updateTimeout = null;\n    };\n    /**\n     * Enqueue a request, adding it to the right place\n     * in the queue based on the priority:\n     * Highest prioriy first, oldest requests first\n     * @private\n     * @param {Request} request\n     */\n    RequestQueue.prototype.enqueue = function (request) {\n        var _this = this;\n        var index = 0;\n        for (index = 0; index < this.queue.length; index++) {\n            var element = this.queue[index];\n            if (element.priority < request.priority) {\n                break;\n            }\n        }\n        this.queue.splice(index, 0, request);\n        // Update queue as soon as possible after this,\n        // sending the request. Waiting this way allows for queueing of requests with\n        // different priorities to be sent in the right order\n        if (!this.updateTimeout) {\n            this.updateTimeout = window.setTimeout(function () {\n                _this.update();\n            }, 1);\n        }\n    };\n    /**\n     * Remove an item from the queue.\n     * Usually because the request is done, or it failed.\n     * @private\n     * @param {Request} req\n     */\n    RequestQueue.prototype.dequeue = function (req) {\n        var index = this.queue.indexOf(req);\n        if (index === -1) {\n            throw new Error(\"Can't dequeue request not in queue\");\n        }\n        this.queue.splice(index, 1);\n        // Send new requests since this one is gone\n        this.update();\n    };\n    /**\n     * Get the next request that is ready to send\n     *\n     * @private\n     * @returns {(Request | null)}\n     */\n    RequestQueue.prototype.getNextPendingRequest = function () {\n        for (var index = 0; index < this.queue.length && index < this.concurrency; index++) {\n            var element = this.queue[index];\n            if (element.status === RequestStatus.PENDING) {\n                return element;\n            }\n        }\n        return null;\n    };\n    /**\n     * Get the next request that is currently in flight\n     * but pushes us over our concurrency limit\n     *\n     * @private\n     * @returns {(Request | null)}\n     */\n    RequestQueue.prototype.getNextOverflowingRequest = function () {\n        for (var index = this.concurrency; index < this.queue.length; index++) {\n            var element = this.queue[index];\n            if (element.status === RequestStatus.SENDING && element.priority !== RequestPriority.HIGHEST) {\n                return element;\n            }\n        }\n        return null;\n    };\n    /**\n     * Handle the actual sending of a request, statuses,\n     * retries, error and success callbacks\n     *\n     * @private\n     */\n    RequestQueue.prototype.sendRequest = function (req) {\n        var _this = this;\n        req.status = RequestStatus.SENDING;\n        req.send().then(function (response) {\n            req.status = RequestStatus.DONE;\n            _this.dequeue(req);\n            req.onDone(response);\n        }).catch(function (e) {\n            var retryCount = req.maxRetries !== null ? req.maxRetries : _this.retries;\n            if (req.sendAttempts < retryCount) {\n                req.status = RequestStatus.PENDING;\n                // Re-send request\n                _this.update();\n                console.warn(\"Retried \" + req.url);\n                console.warn(e);\n            }\n            else {\n                req.status = RequestStatus.FAILED;\n                _this.dequeue(req);\n                console.warn(\"Failed \" + req.url);\n                req.onFail(e);\n            }\n        });\n    };\n    return RequestQueue;\n}());\nexports.RequestQueue = RequestQueue;\nvar Request = (function () {\n    /**\n     * Creates an instance of Request.\n     *\n     * @param {string} method\n     * @param {string} url\n     * @param {any} options: {\n     *       priority = RequestPriority.MEDIUM,\n     *       responseType = null,\n     *       body = null,\n     *       auth = null,\n     *       maxRetries = null,\n     *       headers = {}\n     *     }\n     */\n    function Request(method, url, options) {\n        if (options === void 0) { options = {}; }\n        var _this = this;\n        this.sendAttempts = 0;\n        this.status = RequestStatus.PENDING;\n        this.url = url;\n        this.method = method;\n        this.auth = options.auth || null;\n        this.withCredentials = options.withCredentials || false;\n        this.priority = options.priority || RequestPriority.MEDIUM;\n        this.responseType = options.responseType || null;\n        this.body = options.body || null;\n        this.headers = options.headers || {};\n        this.maxRetries = options.maxRetries || null;\n        this.onProgress = options.onProgress;\n        this.promise = new Promise(function (resolve, reject) {\n            _this.onDone = resolve;\n            _this.onFail = reject;\n        });\n    }\n    /**\n     * Make and send this XHR\n     *\n     * @returns {Promise<any>}\n     */\n    Request.prototype.send = function () {\n        var _this = this;\n        var xhr = this.xhr = openXHR(this.method, this.url, this.withCredentials);\n        if (this.responseType) {\n            if (this.responseType === 'arraybuffer' ||\n                this.responseType === 'text' ||\n                this.responseType === 'json' ||\n                this.responseType === 'blob') {\n                xhr.responseType = this.responseType;\n            }\n            else if (this.responseType === 'image') {\n                xhr.responseType = 'blob';\n            }\n            else {\n                throw new Error('reponseType can only be one of \"arraybuffer\", \"text\", \"json\", \"blob\", \"image\"');\n            }\n        }\n        if (this.responseType === 'json') {\n            xhr.setRequestHeader('Accept', 'application/json');\n        }\n        if (this.auth && typeof this.auth === 'string') {\n            xhr.setRequestHeader('Authorization', this.auth);\n        }\n        for (var key in this.headers) {\n            xhr.setRequestHeader(key, this.headers[key]);\n        }\n        if (this.body && typeof this.body === 'object') {\n            if (!(this.body instanceof FormData)) {\n                this.body = JSON.stringify(this.body);\n                xhr.setRequestHeader('Content-Type', 'application/json');\n            }\n        }\n        if (this.onProgress) {\n            xhr.onprogress = this.onProgress;\n        }\n        return new Promise(function (resolve, reject) {\n            xhr.onreadystatechange = function (e) {\n                if (xhr.readyState === 4) {\n                    if (xhr.status === 200 || xhr.status === 201 || xhr.status === 204) {\n                        return _this.parseResponse(_this.xhr)\n                            .then(function (response) { resolve(response); });\n                    }\n                    else if (xhr.status !== 0) {\n                        reject({ status_code: xhr.status });\n                    }\n                }\n            };\n            xhr.onerror = function (e) {\n                reject(e);\n            };\n            xhr.send(_this.body);\n            _this.sendAttempts++;\n        });\n    };\n    /**\n     * Handle parsing the response into JSON or other types,\n     * depending on this.responseType\n     *\n     * @param {*} xhr\n     * @returns {*}\n     */\n    Request.prototype.parseResponse = function (xhr) {\n        var _this = this;\n        // IE does not support responseType = 'json'\n        return new Promise(function (resolve, reject) {\n            try {\n                // IE does not support responseType = 'json'\n                var response_1 = xhr.response;\n                if (_this.responseType === 'json' && typeof response_1 !== 'object') {\n                    resolve(JSON.parse(xhr.responseText));\n                }\n                else if (_this.responseType === 'image') {\n                    var imageUrl_1 = URL.createObjectURL(response_1);\n                    response_1 = new Image();\n                    response_1.src = imageUrl_1;\n                    response_1.crossOrigin = 'Anonymous';\n                    response_1.onload = function () {\n                        URL.revokeObjectURL(imageUrl_1);\n                        resolve(response_1);\n                    };\n                }\n                else {\n                    resolve(response_1);\n                }\n            }\n            catch (e) {\n                reject({ error: 'Payload was not valid JSON' });\n            }\n        });\n    };\n    /**\n     *\n     * Abort this request.\n     *\n     */\n    Request.prototype.abort = function () {\n        if (this.xhr === null) {\n            throw new Error('Cannot abort unsent Request');\n        }\n        this.xhr.abort();\n    };\n    return Request;\n}());\nexports.Request = Request;\n"]}