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EAAG,KAAM,GAEjB,IAAK,EAAK,SAAW,EAAK,OAAS,EAAO,QACzC,MAAM,IAAI,MAAM,+BAAiC,EAAK,KAAO,sCAAwC,EAAO,SAI7G,IAAK,IAAI,KAFT,EAAO,QAAU,EAAK,IAAM,EAAK,QACjC,EAAO,MAAQ,EAAK,OAAS,EAAO,MACnB,EAAK,QAIhB,EAAK,QAAQ,GAGjB,EAAO,QAAQ,GAAQ,EAAK,QAAQ,UAF7B,EAAO,QAAQ,GAKxB,EAAG,KAAM,EACV,GACD,CA0BE,CAAa,EAAM,EAAQ,IAE3B,EAAY,EAAK,UAAW,EAE9B,CAEA,EACD,CAGsB,iBAAX,SAAqB,OAAO,QAAU","file":"/npm/browserify-json-bundle-loader@0.0.5/bundleLoader.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/browserify-json-bundle-loader@0.0.5/bundleLoader.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Module loader script.\n * This is a wrapper around the browserify-prelude function with support for intelligent updating of scripts.\n * It keeps track of the version already downloaded to the user's pc (localstorage) and explicitely\n * requests the server for a changeset. It will then update it's module cache with the changes.\n *\n * TODOs:\n * - [ ] If diff fails & cannot download latest, use from cache (configurable?)\n *       the correct diff.\n * - [ ] Expose a function that enables the user code to invalidate the cache.\n */\nfunction loadBundle(opts) {\n\topts.storage = opts.storage || window.localStorage;\n\topts.storageKey = opts.storageKey || '__bundle';\n\topts.sourceRoot = opts.sourceRoot || window.location.href;\n\t//ensure trailing slash\n\topts.sourceRoot = opts.sourceRoot.replace(/\\/$/, '') + '/';\n\n\t//--START IMPORT PRELUDE-- TODO: don't copy-paste\n\t// Save the require from previous bundle to this closure if any\n\tfunction outer (modules, cache, entry) {\n\t\tvar previousRequire = typeof require == \"function\" && require;\n\t\tfunction newRequire(name, jumped){\n\t\t\tif(!cache[name]) {\n\t\t\t\tif(!modules[name]) {\n\t\t\t\t\t// if we cannot find the the module within our internal map or\n\t\t\t\t\t// cache jump to the current global require ie. the last bundle\n\t\t\t\t\t// that was added to the page.\n\t\t\t\t\tvar currentRequire = typeof require == \"function\" && require;\n\t\t\t\t\tif (!jumped && currentRequire) return currentRequire(name, true);\n\t\t\t\t\t// If there are other bundles on this page the require from the\n\t\t\t\t\t// previous one is saved to 'previousRequire'. Repeat this as\n\t\t\t\t\t// many times as there are bundles until the module is found or\n\t\t\t\t\t// we exhaust the require chain.\n\t\t\t\t\tif (previousRequire) return previousRequire(name, true);\n\t\t\t\t\tthrow new Error('Cannot find module \\'' + name + '\\'');\n\t\t\t\t}\n\t\t\t\tvar m = cache[name] = {exports:{}};\n\t\t\t\tmodules[name][0].call(m.exports, function(x){\n\t\t\t\t\tvar id = modules[name][1][x];\n\t\t\t\t\treturn newRequire(id ? id : x);\n\t\t\t\t},m,m.exports,outer,modules,cache,entry);\n\t\t\t}\n\t\t\treturn cache[name].exports;\n\t\t}\n\t\tfor(var i=0;i<entry.length;i++) newRequire(entry[i]);\n\t}\n\t//---END IMPORT PRELUDE---\n\n\n\t/**\n\t * This function deserializes a module function such that it can both be run and debugged.\n\t *\n\t * @param {String} moduleString - The string containing the module function.\n\t * @param {String} name - The name of the module\n\t * @return {Function} The module function.\n\t */\n\tfunction deserializeModuleFunction(moduleString, name) {\n\t\tmoduleString = moduleString.trim();\n\n\t\t//Add the sourceURL if there isn't already one, such that the script can be debugged properly\n\t\tif (!moduleString.match(/\\/\\/#\\s*sourceURL=/)) {\n\t\t\t//Strip leading slash, since there is already a trailing slash on the sourceRoot url.\n\t\t\tif (name.charAt(0) === '/') {\n\t\t\t\tname = name.substr(1);\n\t\t\t}\n\t\t\tvar sourceURL = opts.sourceRoot + name;\n\t\t\t//Replace /./ with just /\n\t\t\tsourceURL = sourceURL.replace(/\\/\\.\\//g, '/');\n\n\t\t\tmoduleString += \"\\n\\/\\/# sourceURL=\" + sourceURL;\n\t\t}\n\t\treturn new Function(['require', 'module', 'exports'], moduleString);\n\t}\n\n\t/**\n\t * Deserialize an entire bundle\n\t *\n\t * @param {String} bundle - A JSON bundle string (e.g. from cache)\n\t * @return {Object} A deserialized bundle object.\n\t */\n\tfunction deserializeBundle(bundle) {\n\t\tif (!bundle) {\n\t\t\treturn null;\n\t\t}\n\t\tbundle = JSON.parse(bundle);\n\t\tvar deserializedModules = {};\n\t\tfor (var name in bundle.modules) {\n\t\t\tvar module = bundle.modules[name];\n\t\t\tif (module) {\n\t\t\t\tvar moduleFunction = deserializeModuleFunction(module[0], name);\n\t\t\t\tvar moduleDeps = module[1];\n\t\t\t\tdeserializedModules[name] = [ moduleFunction, moduleDeps ];\n\t\t\t} else {\n\t\t\t\tdeserializedModules[name] = null;\n\t\t\t}\n\t\t}\n\t\tbundle.modules = deserializedModules;\n\t\treturn bundle;\n\t}\n\n\t/**\n\t * Fetches a bundle.\n\t *\n\t * @param {String} url - The url to fetch the bundle from\n\t * @param {(String, Object) -> any} - A node-style callback function that will be called with the\n\t *                                    (deserialized) bundle on success.\n\t */\n\tfunction fetchBundle(url, cb) {\n\t\tvar feyenoord = new XMLHttpRequest();\n\t\tfeyenoord.addEventListener('readystatechange', function() {\n\t\t\tif (feyenoord.readyState === 4) {\n\t\t\t\tif (feyenoord.status >= 200 && feyenoord.status < 300) {\n\t\t\t\t\tvar modules = deserializeBundle(feyenoord.responseText);\n\t\t\t\t\tcb(null, modules);\n\t\t\t\t} else {\n\t\t\t\t\tcb(new Error(\"Could not fetch bundle. Status code: \" + feyenoord.status));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfeyenoord.open('GET', url, true);\n\t\tfeyenoord.send();\n\t}\n\n\t/**\n\t * Updates the cache with a new bundle.\n\t *\n\t * @param {Object} bundle - The bundle to store in cache\n\t */\n\tfunction updateCache(bundle) {\n\t\topts.storage.setItem(opts.storageKey, JSON.stringify(bundle, function serializer(key, value) {\n\t\t\tif (typeof value === 'function') {\n\t\t\t\tvar functionString = value.toString();\n\t\t\t\t//We're only interested in the body\n\t\t\t\treturn functionString.slice(functionString.indexOf('{') + 1, functionString.lastIndexOf('}'));\n\t\t\t}\n\t\t\treturn value;\n\t\t}));\n\t}\n\n\t/**\n\t * Updates a bundle by fetching the diff from the server and applying it against the base bundle.\n\t *\n\t * @param {Object} opts - The options for the loader.\n\t * @param {Object} bundle - A base bundle\n\t * @param {(String, Object) -> any} cb - A node style callback function that will be called with\n\t *                                       the new bundle on success.\n\t */\n\tfunction updateBundle(opts, bundle, cb) {\n\t\tvar url;\n\t\t//If there is no diff url or base version then we just load the full version again\n\t\tif (opts.diffUrl && bundle.version) {\n\t\t\turl = opts.diffUrl.replace('%v', bundle.version);\n\t\t} else {\n\t\t\turl = opts.sourceUrl;\n\t\t}\n\t\tfetchBundle(url, function(err, diff) {\n\t\t\tif (err) {\n\t\t\t\treturn cb(err);\n\t\t\t}\n\t\t\tif (!diff) {\n\t\t\t\treturn cb(null, bundle);\n\t\t\t}\n\t\t\tif (!diff.version && diff.from !== bundle.version) {\n\t\t\t\tthrow new Error(\"Received diff since version \" + diff.from + \", but requested diff since version \" + bundle.version);\n\t\t\t}\n\t\t\tbundle.version = diff.to || diff.version; //diffs use to, full bundles use version\n\t\t\tbundle.entry = diff.entry || bundle.entry;\n\t\t\tfor (var name in diff.modules) {\n\t\t\t\t//if a module is null than it means it has been removed from the bundle. Thus, we need\n\t\t\t\t//to delete it as well. Simply setting it to null will lead to \"storage leaks\", since it\n\t\t\t\t//will then still be serialized.\n\t\t\t\tif (!diff.modules[name]) {\n\t\t\t\t\tdelete bundle.modules[name];\n\t\t\t\t} else {\n\t\t\t\t\tbundle.modules[name] = diff.modules[name];\n\t\t\t\t}\n\t\t\t}\n\t\t\tcb(null, bundle);\n\t\t});\n\t}\n\n\t/**\n\t * Starts the application contained in the bundle.\n\t * @param {Object} bundle - The bundle to launch.\n\t */\n\tfunction start(bundle) {\n\t\touter(bundle.modules, {}, bundle.entry);\n\t}\n\n\tfunction bundleFetchCallback(err, bundle) {\n\t\tif (err) throw err;\n\t\tupdateCache(bundle);\n\t\tstart(bundle);\n\t}\n\t/**\n\t * Initializes the entire application.\n\t * It fetches the latest version, applies diffs when necessary, and then starts the application.\n\t */\n\tfunction initialize() {\n\t\tvar bundle;\n\t\ttry {\n\t\t\tbundle = opts.storage.getItem(opts.storageKey);\n\t\t} catch (e) {} //ignore errors, we just reload the entire bundle when it fails to retrieve it from storage\n\t\tif (bundle) {\n\t\t\tbundle = deserializeBundle(bundle);\n\t\t\tupdateBundle(opts, bundle, bundleFetchCallback);\n\t\t} else {\n\t\t\tfetchBundle(opts.sourceUrl, bundleFetchCallback);\n\t\t}\n\t}\n\n\tinitialize();\n}\n\n//Export the module if we're used as a CommonJS module.\nif (typeof module === 'object') module.exports = loadBundle;\n"]}