{"version":3,"file":"browser-es-module-loader.js","sources":["../../../node_modules/es-module-loader/core/common.js","../../../node_modules/es-module-loader/core/loader-polyfill.js","../../../node_modules/es-module-loader/core/resolve.js","../../../node_modules/es-module-loader/core/register-loader.js","../src/browser-es-module-loader.js"],"sourcesContent":["/*\r\n * Environment\r\n */\r\nexport var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\r\nexport var isNode = typeof process !== 'undefined' && process.versions && process.versions.node;\r\nexport var isWindows = typeof process !== 'undefined' && typeof process.platform === 'string' && process.platform.match(/^win/);\r\n\r\nvar envGlobal = typeof self !== 'undefined' ? self : global;\r\nexport { envGlobal as global }\r\n\r\n/*\r\n * Simple Symbol() shim\r\n */\r\nvar hasSymbol = typeof Symbol !== 'undefined';\r\nexport function createSymbol (name) {\r\n return hasSymbol ? Symbol() : '@@' + name;\r\n}\r\n\r\nexport var toStringTag = hasSymbol && Symbol.toStringTag;\r\n\r\nexport function pathToFileUrl (filePath) {\r\n return 'file://' + (isWindows ? '/' : '') + (isWindows ? filePath.replace(/\\\\/g, '/') : filePath);\r\n}\r\n\r\nexport function fileUrlToPath (fileUrl) {\r\n if (fileUrl.substr(0, 7) !== 'file://')\r\n throw new RangeError(fileUrl + ' is not a valid file url');\r\n if (isWindows)\r\n return fileUrl.substr(8).replace(/\\\\/g, '/');\r\n else\r\n return fileUrl.substr(7);\r\n}\r\n\r\n/*\r\n * Environment baseURI\r\n */\r\nexport var baseURI;\r\n\r\n// environent baseURI detection\r\nif (typeof document != 'undefined' && document.getElementsByTagName) {\r\n baseURI = document.baseURI;\r\n\r\n if (!baseURI) {\r\n var bases = document.getElementsByTagName('base');\r\n baseURI = bases[0] && bases[0].href || window.location.href;\r\n }\r\n}\r\nelse if (typeof location != 'undefined') {\r\n baseURI = location.href;\r\n}\r\n\r\n// sanitize out the hash and querystring\r\nif (baseURI) {\r\n baseURI = baseURI.split('#')[0].split('?')[0];\r\n var slashIndex = baseURI.lastIndexOf('/');\r\n if (slashIndex !== -1)\r\n baseURI = baseURI.substr(0, slashIndex + 1);\r\n}\r\nelse if (typeof process !== 'undefined' && process.cwd) {\r\n baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd();\r\n if (isWindows)\r\n baseURI = baseURI.replace(/\\\\/g, '/');\r\n}\r\nelse {\r\n throw new TypeError('No environment baseURI');\r\n}\r\n\r\n// ensure baseURI has trailing \"/\"\r\nif (baseURI[baseURI.length - 1] !== '/')\r\n baseURI += '/';\r\n\r\n/*\r\n * LoaderError with chaining for loader stacks\r\n */\r\nvar errArgs = new Error(0, '_').fileName == '_';\r\nfunction LoaderError__Check_error_message_for_loader_stack (childErr, newMessage) {\r\n // Convert file:/// URLs to paths in Node\r\n if (!isBrowser)\r\n newMessage = newMessage.replace(isWindows ? /file:\\/\\/\\//g : /file:\\/\\//g, '');\r\n\r\n var message = (childErr.message || childErr) + '\\n ' + newMessage;\r\n\r\n var err;\r\n if (errArgs && childErr.fileName)\r\n err = new Error(message, childErr.fileName, childErr.lineNumber);\r\n else\r\n err = new Error(message);\r\n\r\n\r\n var stack = childErr.originalErr ? childErr.originalErr.stack : childErr.stack;\r\n\r\n if (isNode)\r\n // node doesn't show the message otherwise\r\n err.stack = message + '\\n ' + stack;\r\n else\r\n err.stack = stack;\r\n\r\n err.originalErr = childErr.originalErr || childErr;\r\n\r\n return err;\r\n}\r\nexport { LoaderError__Check_error_message_for_loader_stack as addToError }\r\n","import { addToError, createSymbol, toStringTag } from './common.js';\r\n\r\nexport { Loader, ModuleNamespace, REGISTRY }\r\n\r\nvar resolvedPromise = Promise.resolve();\r\n\r\n/*\r\n * Simple Array values shim\r\n */\r\nfunction arrayValues (arr) {\r\n if (arr.values)\r\n return arr.values();\r\n\r\n if (typeof Symbol === 'undefined' || !Symbol.iterator)\r\n throw new Error('Symbol.iterator not supported in this browser');\r\n\r\n var iterable = {};\r\n iterable[Symbol.iterator] = function () {\r\n var keys = Object.keys(arr);\r\n var keyIndex = 0;\r\n return {\r\n next: function () {\r\n if (keyIndex < keys.length)\r\n return {\r\n value: arr[keys[keyIndex++]],\r\n done: false\r\n };\r\n else\r\n return {\r\n value: undefined,\r\n done: true\r\n };\r\n }\r\n };\r\n };\r\n return iterable;\r\n}\r\n\r\n/*\r\n * 3. Reflect.Loader\r\n *\r\n * We skip the entire native internal pipeline, just providing the bare API\r\n */\r\n// 3.1.1\r\nfunction Loader () {\r\n this.registry = new Registry();\r\n}\r\n// 3.3.1\r\nLoader.prototype.constructor = Loader;\r\n\r\nfunction ensureInstantiated (module) {\r\n if (module === undefined)\r\n return;\r\n if (module instanceof ModuleNamespace === false && module[toStringTag] !== 'module')\r\n throw new TypeError('Module instantiation did not return a valid namespace object.');\r\n return module;\r\n}\r\n\r\n// 3.3.2\r\nLoader.prototype.import = function (key, parent) {\r\n if (typeof key !== 'string')\r\n throw new TypeError('Loader import method must be passed a module key string');\r\n // custom resolveInstantiate combined hook for better perf\r\n var loader = this;\r\n return resolvedPromise\r\n .then(function () {\r\n return loader[RESOLVE_INSTANTIATE](key, parent);\r\n })\r\n .then(ensureInstantiated)\r\n //.then(Module.evaluate)\r\n .catch(function (err) {\r\n throw addToError(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));\r\n });\r\n};\r\n// 3.3.3\r\nvar RESOLVE = Loader.resolve = createSymbol('resolve');\r\n\r\n/*\r\n * Combined resolve / instantiate hook\r\n *\r\n * Not in current reduced spec, but necessary to separate RESOLVE from RESOLVE + INSTANTIATE as described\r\n * in the spec notes of this repo to ensure that loader.resolve doesn't instantiate when not wanted.\r\n *\r\n * We implement RESOLVE_INSTANTIATE as a single hook instead of a separate INSTANTIATE in order to avoid\r\n * the need for double registry lookups as a performance optimization.\r\n */\r\nvar RESOLVE_INSTANTIATE = Loader.resolveInstantiate = createSymbol('resolveInstantiate');\r\n\r\n// default resolveInstantiate is just to call resolve and then get from the registry\r\n// this provides compatibility for the resolveInstantiate optimization\r\nLoader.prototype[RESOLVE_INSTANTIATE] = function (key, parent) {\r\n var loader = this;\r\n return loader.resolve(key, parent)\r\n .then(function (resolved) {\r\n return loader.registry.get(resolved);\r\n });\r\n};\r\n\r\nfunction ensureResolution (resolvedKey) {\r\n if (resolvedKey === undefined)\r\n throw new RangeError('No resolution found.');\r\n return resolvedKey;\r\n}\r\n\r\nLoader.prototype.resolve = function (key, parent) {\r\n var loader = this;\r\n return resolvedPromise\r\n .then(function() {\r\n return loader[RESOLVE](key, parent);\r\n })\r\n .then(ensureResolution)\r\n .catch(function (err) {\r\n throw addToError(err, 'Resolving ' + key + (parent ? ' to ' + parent : ''));\r\n });\r\n};\r\n\r\n// 3.3.4 (import without evaluate)\r\n// this is not documented because the use of deferred evaluation as in Module.evaluate is not\r\n// documented, as it is not considered a stable feature to be encouraged\r\n// Loader.prototype.load may well be deprecated if this stays disabled\r\n/* Loader.prototype.load = function (key, parent) {\r\n return Promise.resolve(this[RESOLVE_INSTANTIATE](key, parent || this.key))\r\n .catch(function (err) {\r\n throw addToError(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));\r\n });\r\n}; */\r\n\r\n/*\r\n * 4. Registry\r\n *\r\n * Instead of structuring through a Map, just use a dictionary object\r\n * We throw for construction attempts so this doesn't affect the public API\r\n *\r\n * Registry has been adjusted to use Namespace objects over ModuleStatus objects\r\n * as part of simplifying loader API implementation\r\n */\r\nvar iteratorSupport = typeof Symbol !== 'undefined' && Symbol.iterator;\r\nvar REGISTRY = createSymbol('registry');\r\nfunction Registry() {\r\n this[REGISTRY] = {};\r\n}\r\n// 4.4.1\r\nif (iteratorSupport) {\r\n // 4.4.2\r\n Registry.prototype[Symbol.iterator] = function () {\r\n return this.entries()[Symbol.iterator]();\r\n };\r\n\r\n // 4.4.3\r\n Registry.prototype.entries = function () {\r\n var registry = this[REGISTRY];\r\n return arrayValues(Object.keys(registry).map(function (key) {\r\n return [key, registry[key]];\r\n }));\r\n };\r\n}\r\n\r\n// 4.4.4\r\nRegistry.prototype.keys = function () {\r\n return arrayValues(Object.keys(this[REGISTRY]));\r\n};\r\n// 4.4.5\r\nRegistry.prototype.values = function () {\r\n var registry = this[REGISTRY];\r\n return arrayValues(Object.keys(registry).map(function (key) {\r\n return registry[key];\r\n }));\r\n};\r\n// 4.4.6\r\nRegistry.prototype.get = function (key) {\r\n return this[REGISTRY][key];\r\n};\r\n// 4.4.7\r\nRegistry.prototype.set = function (key, namespace) {\r\n if (!(namespace instanceof ModuleNamespace || namespace[toStringTag] === 'module'))\r\n throw new Error('Registry must be set with an instance of Module Namespace');\r\n this[REGISTRY][key] = namespace;\r\n return this;\r\n};\r\n// 4.4.8\r\nRegistry.prototype.has = function (key) {\r\n return Object.hasOwnProperty.call(this[REGISTRY], key);\r\n};\r\n// 4.4.9\r\nRegistry.prototype.delete = function (key) {\r\n if (Object.hasOwnProperty.call(this[REGISTRY], key)) {\r\n delete this[REGISTRY][key];\r\n return true;\r\n }\r\n return false;\r\n};\r\n\r\n/*\r\n * Simple ModuleNamespace Exotic object based on a baseObject\r\n * We export this for allowing a fast-path for module namespace creation over Module descriptors\r\n */\r\n// var EVALUATE = createSymbol('evaluate');\r\nvar BASE_OBJECT = createSymbol('baseObject');\r\n\r\n// 8.3.1 Reflect.Module\r\n/*\r\n * Best-effort simplified non-spec implementation based on\r\n * a baseObject referenced via getters.\r\n *\r\n * Allows:\r\n *\r\n * loader.registry.set('x', new Module({ default: 'x' }));\r\n *\r\n * Optional evaluation function provides experimental Module.evaluate\r\n * support for non-executed modules in registry.\r\n */\r\nfunction ModuleNamespace (baseObject/*, evaluate*/) {\r\n Object.defineProperty(this, BASE_OBJECT, {\r\n value: baseObject\r\n });\r\n\r\n // evaluate defers namespace population\r\n /* if (evaluate) {\r\n Object.defineProperty(this, EVALUATE, {\r\n value: evaluate,\r\n configurable: true,\r\n writable: true\r\n });\r\n }\r\n else { */\r\n Object.keys(baseObject).forEach(extendNamespace, this);\r\n //}\r\n};\r\n// 8.4.2\r\nModuleNamespace.prototype = Object.create(null);\r\n\r\nif (toStringTag)\r\n Object.defineProperty(ModuleNamespace.prototype, toStringTag, {\r\n value: 'Module'\r\n });\r\n\r\nfunction extendNamespace (key) {\r\n Object.defineProperty(this, key, {\r\n enumerable: true,\r\n get: function () {\r\n return this[BASE_OBJECT][key];\r\n }\r\n });\r\n}\r\n\r\n/* function doEvaluate (evaluate, context) {\r\n try {\r\n evaluate.call(context);\r\n }\r\n catch (e) {\r\n return e;\r\n }\r\n}\r\n\r\n// 8.4.1 Module.evaluate... not documented or used because this is potentially unstable\r\nModule.evaluate = function (ns) {\r\n var evaluate = ns[EVALUATE];\r\n if (evaluate) {\r\n ns[EVALUATE] = undefined;\r\n var err = doEvaluate(evaluate);\r\n if (err) {\r\n // cache the error\r\n ns[EVALUATE] = function () {\r\n throw err;\r\n };\r\n throw err;\r\n }\r\n Object.keys(ns[BASE_OBJECT]).forEach(extendNamespace, ns);\r\n }\r\n // make chainable\r\n return ns;\r\n}; */\r\n","import { isNode } from './common.js';\r\n\r\n/*\r\n * Optimized URL normalization assuming a syntax-valid URL parent\r\n */\r\nfunction throwResolveError (relUrl, parentUrl) {\r\n throw new RangeError('Unable to resolve \"' + relUrl + '\" to ' + parentUrl);\r\n}\r\nvar backslashRegEx = /\\\\/g;\r\nexport function resolveIfNotPlain (relUrl, parentUrl) {\r\n if (relUrl[0] === ' ' || relUrl[relUrl.length - 1] === ' ')\r\n relUrl = relUrl.trim();\r\n var parentProtocol = parentUrl && parentUrl.substr(0, parentUrl.indexOf(':') + 1);\r\n\r\n var firstChar = relUrl[0];\r\n var secondChar = relUrl[1];\r\n\r\n // protocol-relative\r\n if (firstChar === '/' && secondChar === '/') {\r\n if (!parentProtocol)\r\n throwResolveError(relUrl, parentUrl);\r\n if (relUrl.indexOf('\\\\') !== -1)\r\n relUrl = relUrl.replace(backslashRegEx, '/');\r\n return parentProtocol + relUrl;\r\n }\r\n // relative-url\r\n else if (firstChar === '.' && (secondChar === '/' || secondChar === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||\r\n relUrl.length === 1 && (relUrl += '/')) ||\r\n firstChar === '/') {\r\n if (relUrl.indexOf('\\\\') !== -1)\r\n relUrl = relUrl.replace(backslashRegEx, '/');\r\n var parentIsPlain = !parentProtocol || parentUrl[parentProtocol.length] !== '/';\r\n\r\n // read pathname from parent if a URL\r\n // pathname taken to be part after leading \"/\"\r\n var pathname;\r\n if (parentIsPlain) {\r\n // resolving to a plain parent -> skip standard URL prefix, and treat entire parent as pathname\r\n if (parentUrl === undefined)\r\n throwResolveError(relUrl, parentUrl);\r\n pathname = parentUrl;\r\n }\r\n else if (parentUrl[parentProtocol.length + 1] === '/') {\r\n // resolving to a :// so we need to read out the auth and host\r\n if (parentProtocol !== 'file:') {\r\n pathname = parentUrl.substr(parentProtocol.length + 2);\r\n pathname = pathname.substr(pathname.indexOf('/') + 1);\r\n }\r\n else {\r\n pathname = parentUrl.substr(8);\r\n }\r\n }\r\n else {\r\n // resolving to :/ so pathname is the /... part\r\n pathname = parentUrl.substr(parentProtocol.length + 1);\r\n }\r\n\r\n if (firstChar === '/') {\r\n if (parentIsPlain)\r\n throwResolveError(relUrl, parentUrl);\r\n else\r\n return parentUrl.substr(0, parentUrl.length - pathname.length - 1) + relUrl;\r\n }\r\n\r\n // join together and split for removal of .. and . segments\r\n // looping the string instead of anything fancy for perf reasons\r\n // '../../../../../z' resolved to 'x/y' is just 'z' regardless of parentIsPlain\r\n var segmented = pathname.substr(0, pathname.lastIndexOf('/') + 1) + relUrl;\r\n\r\n var output = [];\r\n var segmentIndex = -1;\r\n\r\n for (var i = 0; i < segmented.length; i++) {\r\n // busy reading a segment - only terminate on '/'\r\n if (segmentIndex !== -1) {\r\n if (segmented[i] === '/') {\r\n output.push(segmented.substring(segmentIndex, i + 1));\r\n segmentIndex = -1;\r\n }\r\n continue;\r\n }\r\n\r\n // new segment - check if it is relative\r\n if (segmented[i] === '.') {\r\n // ../ segment\r\n if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {\r\n output.pop();\r\n i += 2;\r\n }\r\n // ./ segment\r\n else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {\r\n i += 1;\r\n }\r\n else {\r\n // the start of a new segment as below\r\n segmentIndex = i;\r\n continue;\r\n }\r\n\r\n // this is the plain URI backtracking error (../, package:x -> error)\r\n if (parentIsPlain && output.length === 0)\r\n throwResolveError(relUrl, parentUrl);\r\n\r\n continue;\r\n }\r\n\r\n // it is the start of a new segment\r\n segmentIndex = i;\r\n }\r\n // finish reading out the last segment\r\n if (segmentIndex !== -1)\r\n output.push(segmented.substr(segmentIndex));\r\n\r\n return parentUrl.substr(0, parentUrl.length - pathname.length) + output.join('');\r\n }\r\n\r\n // sanitizes and verifies (by returning undefined if not a valid URL-like form)\r\n // Windows filepath compatibility is an added convenience here\r\n var protocolIndex = relUrl.indexOf(':');\r\n if (protocolIndex !== -1) {\r\n if (isNode) {\r\n // C:\\x becomes file:///c:/x (we don't support C|\\x)\r\n if (relUrl[1] === ':' && relUrl[2] === '\\\\' && relUrl[0].match(/[a-z]/i))\r\n return 'file:///' + relUrl.replace(backslashRegEx, '/');\r\n }\r\n return relUrl;\r\n }\r\n}\r\n","import { Loader, ModuleNamespace, REGISTRY } from './loader-polyfill.js';\r\nimport { resolveIfNotPlain } from './resolve.js';\r\nimport { addToError, global, createSymbol, baseURI, toStringTag } from './common.js';\r\n\r\nexport default RegisterLoader;\r\n\r\nvar resolvedPromise = Promise.resolve();\r\nvar emptyArray = [];\r\n\r\n/*\r\n * Register Loader\r\n *\r\n * Builds directly on top of loader polyfill to provide:\r\n * - loader.register support\r\n * - hookable higher-level resolve\r\n * - instantiate hook returning a ModuleNamespace or undefined for es module loading\r\n * - loader error behaviour as in HTML and loader specs, caching load and eval errors separately\r\n * - build tracing support by providing a .trace=true and .loads object format\r\n */\r\n\r\nvar REGISTER_INTERNAL = createSymbol('register-internal');\r\n\r\nfunction RegisterLoader () {\r\n Loader.call(this);\r\n\r\n var registryDelete = this.registry.delete;\r\n this.registry.delete = function (key) {\r\n var deleted = registryDelete.call(this, key);\r\n\r\n // also delete from register registry if linked\r\n if (records.hasOwnProperty(key) && !records[key].linkRecord) {\r\n delete records[key];\r\n deleted = true;\r\n }\r\n\r\n return deleted;\r\n };\r\n\r\n var records = {};\r\n\r\n this[REGISTER_INTERNAL] = {\r\n // last anonymous System.register call\r\n lastRegister: undefined,\r\n // in-flight es module load records\r\n records: records\r\n };\r\n\r\n // tracing\r\n this.trace = false;\r\n}\r\n\r\nRegisterLoader.prototype = Object.create(Loader.prototype);\r\nRegisterLoader.prototype.constructor = RegisterLoader;\r\n\r\nvar INSTANTIATE = RegisterLoader.instantiate = createSymbol('instantiate');\r\n\r\n// default normalize is the WhatWG style normalizer\r\nRegisterLoader.prototype[RegisterLoader.resolve = Loader.resolve] = function (key, parentKey) {\r\n return resolveIfNotPlain(key, parentKey || baseURI);\r\n};\r\n\r\nRegisterLoader.prototype[INSTANTIATE] = function (key, processAnonRegister) {};\r\n\r\n// once evaluated, the linkRecord is set to undefined leaving just the other load record properties\r\n// this allows tracking new binding listeners for es modules through importerSetters\r\n// for dynamic modules, the load record is removed entirely.\r\nfunction createLoadRecord (state, key, registration) {\r\n return state.records[key] = {\r\n key: key,\r\n\r\n // defined System.register cache\r\n registration: registration,\r\n\r\n // module namespace object\r\n module: undefined,\r\n\r\n // es-only\r\n // this sticks around so new module loads can listen to binding changes\r\n // for already-loaded modules by adding themselves to their importerSetters\r\n importerSetters: undefined,\r\n\r\n loadError: undefined,\r\n evalError: undefined,\r\n\r\n // in-flight linking record\r\n linkRecord: {\r\n // promise for instantiated\r\n instantiatePromise: undefined,\r\n dependencies: undefined,\r\n execute: undefined,\r\n executingRequire: false,\r\n\r\n // underlying module object bindings\r\n moduleObj: undefined,\r\n\r\n // es only, also indicates if es or not\r\n setters: undefined,\r\n\r\n // promise for instantiated dependencies (dependencyInstantiations populated)\r\n depsInstantiatePromise: undefined,\r\n // will be the array of dependency load record or a module namespace\r\n dependencyInstantiations: undefined,\r\n\r\n // top-level await!\r\n evaluatePromise: undefined,\r\n\r\n // NB optimization and way of ensuring module objects in setters\r\n // indicates setters which should run pre-execution of that dependency\r\n // setters is then just for completely executed module objects\r\n // alternatively we just pass the partially filled module objects as\r\n // arguments into the execute function\r\n // hoisted: undefined\r\n }\r\n };\r\n}\r\n\r\nRegisterLoader.prototype[Loader.resolveInstantiate] = function (key, parentKey) {\r\n var loader = this;\r\n var state = this[REGISTER_INTERNAL];\r\n var registry = this.registry[REGISTRY];\r\n\r\n return resolveInstantiate(loader, key, parentKey, registry, state)\r\n .then(function (instantiated) {\r\n if (instantiated instanceof ModuleNamespace || instantiated[toStringTag] === 'module')\r\n return instantiated;\r\n\r\n // resolveInstantiate always returns a load record with a link record and no module value\r\n var link = instantiated.linkRecord;\r\n\r\n // if already beaten to done, return\r\n if (!link) {\r\n if (instantiated.module)\r\n return instantiated.module;\r\n throw instantiated.evalError;\r\n }\r\n\r\n return deepInstantiateDeps(loader, instantiated, link, registry, state)\r\n .then(function () {\r\n return ensureEvaluate(loader, instantiated, link, registry, state);\r\n });\r\n });\r\n};\r\n\r\nfunction resolveInstantiate (loader, key, parentKey, registry, state) {\r\n // normalization shortpath for already-normalized key\r\n // could add a plain name filter, but doesn't yet seem necessary for perf\r\n var module = registry[key];\r\n if (module)\r\n return Promise.resolve(module);\r\n\r\n var load = state.records[key];\r\n\r\n // already linked but not in main registry is ignored\r\n if (load && !load.module) {\r\n if (load.loadError)\r\n return Promise.reject(load.loadError);\r\n return instantiate(loader, load, load.linkRecord, registry, state);\r\n }\r\n\r\n return loader.resolve(key, parentKey)\r\n .then(function (resolvedKey) {\r\n // main loader registry always takes preference\r\n module = registry[resolvedKey];\r\n if (module)\r\n return module;\r\n\r\n load = state.records[resolvedKey];\r\n\r\n // already has a module value but not already in the registry (load.module)\r\n // means it was removed by registry.delete, so we should\r\n // disgard the current load record creating a new one over it\r\n // but keep any existing registration\r\n if (!load || load.module)\r\n load = createLoadRecord(state, resolvedKey, load && load.registration);\r\n\r\n if (load.loadError)\r\n return Promise.reject(load.loadError);\r\n\r\n var link = load.linkRecord;\r\n if (!link)\r\n return load;\r\n\r\n return instantiate(loader, load, link, registry, state);\r\n });\r\n}\r\n\r\nfunction createProcessAnonRegister (loader, load, state) {\r\n return function () {\r\n var lastRegister = state.lastRegister;\r\n\r\n if (!lastRegister)\r\n return !!load.registration;\r\n\r\n state.lastRegister = undefined;\r\n load.registration = lastRegister;\r\n\r\n return true;\r\n };\r\n}\r\n\r\nfunction instantiate (loader, load, link, registry, state) {\r\n return link.instantiatePromise || (link.instantiatePromise =\r\n // if there is already an existing registration, skip running instantiate\r\n (load.registration ? resolvedPromise : resolvedPromise.then(function () {\r\n state.lastRegister = undefined;\r\n return loader[INSTANTIATE](load.key, loader[INSTANTIATE].length > 1 && createProcessAnonRegister(loader, load, state));\r\n }))\r\n .then(function (instantiation) {\r\n // direct module return from instantiate -> we're done\r\n if (instantiation !== undefined) {\r\n if (!(instantiation instanceof ModuleNamespace || instantiation[toStringTag] === 'module'))\r\n throw new TypeError('Instantiate did not return a valid Module object.');\r\n\r\n delete state.records[load.key];\r\n if (loader.trace)\r\n traceLoad(loader, load, link);\r\n return registry[load.key] = instantiation;\r\n }\r\n\r\n // run the cached loader.register declaration if there is one\r\n var registration = load.registration;\r\n // clear to allow new registrations for future loads (combined with registry delete)\r\n load.registration = undefined;\r\n if (!registration)\r\n throw new TypeError('Module instantiation did not call an anonymous or correctly named System.register.');\r\n\r\n link.dependencies = registration[0];\r\n\r\n load.importerSetters = [];\r\n\r\n link.moduleObj = {};\r\n\r\n // process System.registerDynamic declaration\r\n if (registration[2]) {\r\n link.moduleObj.default = link.moduleObj.__useDefault = {};\r\n link.executingRequire = registration[1];\r\n link.execute = registration[2];\r\n }\r\n\r\n // process System.register declaration\r\n else {\r\n registerDeclarative(loader, load, link, registration[1]);\r\n }\r\n\r\n return load;\r\n })\r\n .catch(function (err) {\r\n load.linkRecord = undefined;\r\n throw load.loadError = load.loadError || addToError(err, 'Instantiating ' + load.key);\r\n }));\r\n}\r\n\r\n// like resolveInstantiate, but returning load records for linking\r\nfunction resolveInstantiateDep (loader, key, parentKey, registry, state, traceDepMap) {\r\n // normalization shortpaths for already-normalized key\r\n // DISABLED to prioritise consistent resolver calls\r\n // could add a plain name filter, but doesn't yet seem necessary for perf\r\n /* var load = state.records[key];\r\n var module = registry[key];\r\n\r\n if (module) {\r\n if (traceDepMap)\r\n traceDepMap[key] = key;\r\n\r\n // registry authority check in case module was deleted or replaced in main registry\r\n if (load && load.module && load.module === module)\r\n return load;\r\n else\r\n return module;\r\n }\r\n\r\n // already linked but not in main registry is ignored\r\n if (load && !load.module) {\r\n if (traceDepMap)\r\n traceDepMap[key] = key;\r\n return instantiate(loader, load, load.linkRecord, registry, state);\r\n } */\r\n return loader.resolve(key, parentKey)\r\n .then(function (resolvedKey) {\r\n if (traceDepMap)\r\n traceDepMap[key] = resolvedKey;\r\n\r\n // normalization shortpaths for already-normalized key\r\n var load = state.records[resolvedKey];\r\n var module = registry[resolvedKey];\r\n\r\n // main loader registry always takes preference\r\n if (module && (!load || load.module && module !== load.module))\r\n return module;\r\n\r\n if (load && load.loadError)\r\n throw load.loadError;\r\n\r\n // already has a module value but not already in the registry (load.module)\r\n // means it was removed by registry.delete, so we should\r\n // disgard the current load record creating a new one over it\r\n // but keep any existing registration\r\n if (!load || !module && load.module)\r\n load = createLoadRecord(state, resolvedKey, load && load.registration);\r\n\r\n var link = load.linkRecord;\r\n if (!link)\r\n return load;\r\n\r\n return instantiate(loader, load, link, registry, state);\r\n });\r\n}\r\n\r\nfunction traceLoad (loader, load, link) {\r\n loader.loads = loader.loads || {};\r\n loader.loads[load.key] = {\r\n key: load.key,\r\n deps: link.dependencies,\r\n dynamicDeps: [],\r\n depMap: link.depMap || {}\r\n };\r\n}\r\n\r\n/*\r\n * Convert a CJS module.exports into a valid object for new Module:\r\n *\r\n * new Module(getEsModule(module.exports))\r\n *\r\n * Sets the default value to the module, while also reading off named exports carefully.\r\n */\r\nfunction registerDeclarative (loader, load, link, declare) {\r\n var moduleObj = link.moduleObj;\r\n var importerSetters = load.importerSetters;\r\n\r\n var definedExports = false;\r\n\r\n // closure especially not based on link to allow link record disposal\r\n var declared = declare.call(global, function (name, value) {\r\n if (typeof name === 'object') {\r\n var changed = false;\r\n for (var p in name) {\r\n value = name[p];\r\n if (p !== '__useDefault' && (!(p in moduleObj) || moduleObj[p] !== value)) {\r\n changed = true;\r\n moduleObj[p] = value;\r\n }\r\n }\r\n if (changed === false)\r\n return value;\r\n }\r\n else {\r\n if ((definedExports || name in moduleObj) && moduleObj[name] === value)\r\n return value;\r\n moduleObj[name] = value;\r\n }\r\n\r\n for (var i = 0; i < importerSetters.length; i++)\r\n importerSetters[i](moduleObj);\r\n\r\n return value;\r\n }, new ContextualLoader(loader, load.key));\r\n\r\n link.setters = declared.setters || [];\r\n link.execute = declared.execute;\r\n if (declared.exports) {\r\n link.moduleObj = moduleObj = declared.exports;\r\n definedExports = true;\r\n }\r\n}\r\n\r\nfunction instantiateDeps (loader, load, link, registry, state) {\r\n if (link.depsInstantiatePromise)\r\n return link.depsInstantiatePromise;\r\n\r\n var depsInstantiatePromises = Array(link.dependencies.length);\r\n\r\n for (var i = 0; i < link.dependencies.length; i++)\r\n depsInstantiatePromises[i] = resolveInstantiateDep(loader, link.dependencies[i], load.key, registry, state, loader.trace && link.depMap || (link.depMap = {}));\r\n\r\n var depsInstantiatePromise = Promise.all(depsInstantiatePromises)\r\n .then(function (dependencyInstantiations) {\r\n link.dependencyInstantiations = dependencyInstantiations;\r\n\r\n // run setters to set up bindings to instantiated dependencies\r\n if (link.setters) {\r\n for (var i = 0; i < dependencyInstantiations.length; i++) {\r\n var setter = link.setters[i];\r\n if (setter) {\r\n var instantiation = dependencyInstantiations[i];\r\n\r\n if (instantiation instanceof ModuleNamespace || instantiation[toStringTag] === 'module') {\r\n setter(instantiation);\r\n }\r\n else {\r\n if (instantiation.loadError)\r\n throw instantiation.loadError;\r\n setter(instantiation.module || instantiation.linkRecord.moduleObj);\r\n // this applies to both es and dynamic registrations\r\n if (instantiation.importerSetters)\r\n instantiation.importerSetters.push(setter);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return load;\r\n });\r\n\r\n if (loader.trace)\r\n depsInstantiatePromise = depsInstantiatePromise.then(function () {\r\n traceLoad(loader, load, link);\r\n return load;\r\n });\r\n\r\n depsInstantiatePromise = depsInstantiatePromise.catch(function (err) {\r\n // throw up the instantiateDeps stack\r\n link.depsInstantiatePromise = undefined;\r\n throw addToError(err, 'Loading ' + load.key);\r\n });\r\n\r\n depsInstantiatePromise.catch(function () {});\r\n\r\n return link.depsInstantiatePromise = depsInstantiatePromise;\r\n}\r\n\r\nfunction deepInstantiateDeps (loader, load, link, registry, state) {\r\n var seen = [];\r\n function addDeps (load, link) {\r\n if (!link)\r\n return resolvedPromise;\r\n if (seen.indexOf(load) !== -1)\r\n return resolvedPromise;\r\n seen.push(load);\r\n \r\n return instantiateDeps(loader, load, link, registry, state)\r\n .then(function () {\r\n var depPromises;\r\n for (var i = 0; i < link.dependencies.length; i++) {\r\n var depLoad = link.dependencyInstantiations[i];\r\n if (!(depLoad instanceof ModuleNamespace || depLoad[toStringTag] === 'module')) {\r\n depPromises = depPromises || [];\r\n depPromises.push(addDeps(depLoad, depLoad.linkRecord));\r\n }\r\n }\r\n if (depPromises)\r\n return Promise.all(depPromises);\r\n });\r\n };\r\n\r\n return addDeps(load, link);\r\n}\r\n\r\n/*\r\n * System.register\r\n */\r\nRegisterLoader.prototype.register = function (key, deps, declare) {\r\n var state = this[REGISTER_INTERNAL];\r\n\r\n // anonymous modules get stored as lastAnon\r\n if (declare === undefined) {\r\n state.lastRegister = [key, deps, undefined];\r\n }\r\n\r\n // everything else registers into the register cache\r\n else {\r\n var load = state.records[key] || createLoadRecord(state, key, undefined);\r\n load.registration = [deps, declare, undefined];\r\n }\r\n};\r\n\r\n/*\r\n * System.registerDyanmic\r\n */\r\nRegisterLoader.prototype.registerDynamic = function (key, deps, executingRequire, execute) {\r\n var state = this[REGISTER_INTERNAL];\r\n\r\n // anonymous modules get stored as lastAnon\r\n if (typeof key !== 'string') {\r\n state.lastRegister = [key, deps, executingRequire];\r\n }\r\n\r\n // everything else registers into the register cache\r\n else {\r\n var load = state.records[key] || createLoadRecord(state, key, undefined);\r\n load.registration = [deps, executingRequire, execute];\r\n }\r\n};\r\n\r\n// ContextualLoader class\r\n// backwards-compatible with previous System.register context argument by exposing .id, .key\r\nfunction ContextualLoader (loader, key) {\r\n this.loader = loader;\r\n this.key = this.id = key;\r\n this.meta = {\r\n url: key\r\n // scriptElement: null\r\n };\r\n}\r\n/*ContextualLoader.prototype.constructor = function () {\r\n throw new TypeError('Cannot subclass the contextual loader only Reflect.Loader.');\r\n};*/\r\nContextualLoader.prototype.import = function (key) {\r\n if (this.loader.trace)\r\n this.loader.loads[this.key].dynamicDeps.push(key);\r\n return this.loader.import(key, this.key);\r\n};\r\n/*ContextualLoader.prototype.resolve = function (key) {\r\n return this.loader.resolve(key, this.key);\r\n};*/\r\n\r\nfunction ensureEvaluate (loader, load, link, registry, state) {\r\n if (load.module)\r\n return load.module;\r\n if (load.evalError)\r\n throw load.evalError;\r\n if (link.evaluatePromise)\r\n return link.evaluatePromise;\r\n\r\n if (link.setters) {\r\n var evaluatePromise = doEvaluateDeclarative(loader, load, link, registry, state, [load]);\r\n if (evaluatePromise)\r\n return evaluatePromise;\r\n }\r\n else {\r\n doEvaluateDynamic(loader, load, link, registry, state, [load]);\r\n }\r\n return load.module;\r\n}\r\n\r\nfunction makeDynamicRequire (loader, key, dependencies, dependencyInstantiations, registry, state, seen) {\r\n // we can only require from already-known dependencies\r\n return function (name) {\r\n for (var i = 0; i < dependencies.length; i++) {\r\n if (dependencies[i] === name) {\r\n var depLoad = dependencyInstantiations[i];\r\n var module;\r\n\r\n if (depLoad instanceof ModuleNamespace || depLoad[toStringTag] === 'module') {\r\n module = depLoad;\r\n }\r\n else {\r\n if (depLoad.evalError)\r\n throw depLoad.evalError;\r\n if (depLoad.module === undefined && seen.indexOf(depLoad) === -1 && !depLoad.linkRecord.evaluatePromise) {\r\n if (depLoad.linkRecord.setters) {\r\n doEvaluateDeclarative(loader, depLoad, depLoad.linkRecord, registry, state, [depLoad]);\r\n }\r\n else {\r\n seen.push(depLoad);\r\n doEvaluateDynamic(loader, depLoad, depLoad.linkRecord, registry, state, seen);\r\n }\r\n }\r\n module = depLoad.module || depLoad.linkRecord.moduleObj;\r\n }\r\n\r\n return '__useDefault' in module ? module.__useDefault : module;\r\n }\r\n }\r\n throw new Error('Module ' + name + ' not declared as a System.registerDynamic dependency of ' + key);\r\n };\r\n}\r\n\r\nfunction evalError (load, err) {\r\n load.linkRecord = undefined;\r\n var evalError = addToError(err, 'Evaluating ' + load.key);\r\n if (load.evalError === undefined)\r\n load.evalError = evalError;\r\n throw evalError;\r\n}\r\n\r\n// es modules evaluate dependencies first\r\n// returns the error if any\r\nfunction doEvaluateDeclarative (loader, load, link, registry, state, seen) {\r\n var depLoad, depLink;\r\n var depLoadPromises;\r\n for (var i = 0; i < link.dependencies.length; i++) {\r\n var depLoad = link.dependencyInstantiations[i];\r\n if (depLoad instanceof ModuleNamespace || depLoad[toStringTag] === 'module')\r\n continue;\r\n\r\n // custom Module returned from instantiate\r\n depLink = depLoad.linkRecord;\r\n if (depLink) {\r\n if (depLoad.evalError) {\r\n evalError(load, depLoad.evalError);\r\n }\r\n else if (depLink.setters) {\r\n if (seen.indexOf(depLoad) === -1) {\r\n seen.push(depLoad);\r\n try {\r\n var depLoadPromise = doEvaluateDeclarative(loader, depLoad, depLink, registry, state, seen);\r\n }\r\n catch (e) {\r\n evalError(load, e);\r\n }\r\n if (depLoadPromise) {\r\n depLoadPromises = depLoadPromises || [];\r\n depLoadPromises.push(depLoadPromise.catch(function (err) {\r\n evalError(load, err);\r\n }));\r\n }\r\n }\r\n }\r\n else {\r\n try {\r\n doEvaluateDynamic(loader, depLoad, depLink, registry, state, [depLoad]);\r\n }\r\n catch (e) {\r\n evalError(load, e);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (depLoadPromises)\r\n return link.evaluatePromise = Promise.all(depLoadPromises)\r\n .then(function () {\r\n if (link.execute) {\r\n // ES System.register execute\r\n // \"this\" is null in ES\r\n try {\r\n var execPromise = link.execute.call(nullContext);\r\n }\r\n catch (e) {\r\n evalError(load, e);\r\n }\r\n if (execPromise)\r\n return execPromise.catch(function (e) {\r\n evalError(load, e);\r\n })\r\n .then(function () {\r\n load.linkRecord = undefined;\r\n return registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);\r\n });\r\n }\r\n \r\n // dispose link record\r\n load.linkRecord = undefined;\r\n registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);\r\n });\r\n\r\n if (link.execute) {\r\n // ES System.register execute\r\n // \"this\" is null in ES\r\n try {\r\n var execPromise = link.execute.call(nullContext);\r\n }\r\n catch (e) {\r\n evalError(load, e);\r\n }\r\n if (execPromise)\r\n return link.evaluatePromise = execPromise.catch(function (e) {\r\n evalError(load, e);\r\n })\r\n .then(function () {\r\n load.linkRecord = undefined;\r\n return registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);\r\n });\r\n }\r\n\r\n // dispose link record\r\n load.linkRecord = undefined;\r\n registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);\r\n}\r\n\r\n// non es modules explicitly call moduleEvaluate through require\r\nfunction doEvaluateDynamic (loader, load, link, registry, state, seen) {\r\n // System.registerDynamic execute\r\n // \"this\" is \"exports\" in CJS\r\n var module = { id: load.key };\r\n var moduleObj = link.moduleObj;\r\n Object.defineProperty(module, 'exports', {\r\n configurable: true,\r\n set: function (exports) {\r\n moduleObj.default = moduleObj.__useDefault = exports;\r\n },\r\n get: function () {\r\n return moduleObj.__useDefault;\r\n }\r\n });\r\n\r\n var require = makeDynamicRequire(loader, load.key, link.dependencies, link.dependencyInstantiations, registry, state, seen);\r\n\r\n // evaluate deps first\r\n if (!link.executingRequire)\r\n for (var i = 0; i < link.dependencies.length; i++)\r\n require(link.dependencies[i]);\r\n\r\n try {\r\n var output = link.execute.call(global, require, moduleObj.default, module);\r\n if (output !== undefined)\r\n module.exports = output;\r\n }\r\n catch (e) {\r\n evalError(load, e);\r\n }\r\n\r\n load.linkRecord = undefined;\r\n\r\n // pick up defineProperty calls to module.exports when we can\r\n if (module.exports !== moduleObj.__useDefault)\r\n moduleObj.default = moduleObj.__useDefault = module.exports;\r\n\r\n var moduleDefault = moduleObj.default;\r\n\r\n // __esModule flag extension support via lifting\r\n if (moduleDefault && moduleDefault.__esModule) {\r\n for (var p in moduleDefault) {\r\n if (Object.hasOwnProperty.call(moduleDefault, p))\r\n moduleObj[p] = moduleDefault[p];\r\n }\r\n }\r\n\r\n registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);\r\n\r\n // run importer setters and clear them\r\n // this allows dynamic modules to update themselves into es modules\r\n // as soon as execution has completed\r\n if (load.importerSetters)\r\n for (var i = 0; i < load.importerSetters.length; i++)\r\n load.importerSetters[i](load.module);\r\n load.importerSetters = undefined;\r\n}\r\n\r\n// the closest we can get to call(undefined)\r\nvar nullContext = Object.create(null);\r\nif (Object.freeze)\r\n Object.freeze(nullContext);\r\n","import RegisterLoader from 'es-module-loader/core/register-loader.js';\n\nimport { baseURI, global, isBrowser } from 'es-module-loader/core/common.js';\nimport { resolveIfNotPlain } from 'es-module-loader/core/resolve.js';\n\nvar loader;\n\n//