es-module-shims 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,822 +1,834 @@
1
- /* ES Module Shims Wasm 1.5.1 */
1
+ /* ES Module Shims Wasm 1.5.2 */
2
2
  (function () {
3
3
 
4
- const noop = () => {};
5
-
6
- const optionsScript = document.querySelector('script[type=esms-options]');
7
-
8
- const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
9
- Object.assign(esmsInitOptions, self.esmsInitOptions || {});
10
-
11
- let shimMode = !!esmsInitOptions.shimMode;
12
-
13
- const importHook = globalHook(shimMode && esmsInitOptions.onimport);
14
- const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
15
- let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
16
- const metaHook = esmsInitOptions.meta ? globalHook(shimModule && esmsInitOptions.meta) : noop;
17
-
18
- const skip = esmsInitOptions.skip ? new RegExp(esmsInitOptions.skip) : null;
19
-
20
- let nonce = esmsInitOptions.nonce;
21
-
22
- const mapOverrides = esmsInitOptions.mapOverrides;
23
-
24
- if (!nonce) {
25
- const nonceElement = document.querySelector('script[nonce]');
26
- if (nonceElement)
27
- nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
28
- }
29
-
30
- const onerror = globalHook(esmsInitOptions.onerror || noop);
31
- const onpolyfill = esmsInitOptions.onpolyfill ? globalHook(esmsInitOptions.onpolyfill) : () => console.info(`OK: ^ TypeError module failure has been polyfilled`);
32
-
33
- const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
34
-
35
- function globalHook (name) {
36
- return typeof name === 'string' ? self[name] : name;
37
- }
38
-
39
- const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
40
- const cssModulesEnabled = enable.includes('css-modules');
41
- const jsonModulesEnabled = enable.includes('json-modules');
42
-
43
- function setShimMode () {
44
- shimMode = true;
45
- }
46
-
47
- const edge = !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
48
-
49
- const baseUrl = document.baseURI;
50
-
51
- function createBlob (source, type = 'text/javascript') {
52
- return URL.createObjectURL(new Blob([source], { type }));
53
- }
54
-
55
- const eoop = err => setTimeout(() => { throw err });
56
-
57
- const throwError = err => { (window.reportError || window.safari && console.error || eoop)(err), void onerror(err); };
58
-
59
- function fromParent (parent) {
60
- return parent ? ` imported from ${parent}` : '';
61
- }
62
-
63
- const backslashRegEx = /\\/g;
64
-
65
- function isURL (url) {
66
- if (url.indexOf(':') === -1) return false;
67
- try {
68
- new URL(url);
69
- return true;
70
- }
71
- catch (_) {
72
- return false;
73
- }
74
- }
75
-
76
- /*
77
- * Import maps implementation
78
- *
79
- * To make lookups fast we pre-resolve the entire import map
80
- * and then match based on backtracked hash lookups
81
- *
82
- */
83
- function resolveUrl (relUrl, parentUrl) {
84
- return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
85
- }
86
-
87
- function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
88
- // strip off any trailing query params or hashes
89
- const queryHashIndex = parentUrl.indexOf('?', parentUrl.indexOf('#') === -1 ? parentUrl.indexOf('#') : parentUrl.length);
90
- if (queryHashIndex !== -1)
91
- parentUrl = parentUrl.slice(0, queryHashIndex);
92
- if (relUrl.indexOf('\\') !== -1)
93
- relUrl = relUrl.replace(backslashRegEx, '/');
94
- // protocol-relative
95
- if (relUrl[0] === '/' && relUrl[1] === '/') {
96
- return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
97
- }
98
- // relative-url
99
- else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
100
- relUrl.length === 1 && (relUrl += '/')) ||
101
- relUrl[0] === '/') {
102
- const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
103
- // Disabled, but these cases will give inconsistent results for deep backtracking
104
- //if (parentUrl[parentProtocol.length] !== '/')
105
- // throw new Error('Cannot resolve');
106
- // read pathname from parent URL
107
- // pathname taken to be part after leading "/"
108
- let pathname;
109
- if (parentUrl[parentProtocol.length + 1] === '/') {
110
- // resolving to a :// so we need to read out the auth and host
111
- if (parentProtocol !== 'file:') {
112
- pathname = parentUrl.slice(parentProtocol.length + 2);
113
- pathname = pathname.slice(pathname.indexOf('/') + 1);
114
- }
115
- else {
116
- pathname = parentUrl.slice(8);
117
- }
118
- }
119
- else {
120
- // resolving to :/ so pathname is the /... part
121
- pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
122
- }
123
-
124
- if (relUrl[0] === '/')
125
- return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
126
-
127
- // join together and split for removal of .. and . segments
128
- // looping the string instead of anything fancy for perf reasons
129
- // '../../../../../z' resolved to 'x/y' is just 'z'
130
- const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
131
-
132
- const output = [];
133
- let segmentIndex = -1;
134
- for (let i = 0; i < segmented.length; i++) {
135
- // busy reading a segment - only terminate on '/'
136
- if (segmentIndex !== -1) {
137
- if (segmented[i] === '/') {
138
- output.push(segmented.slice(segmentIndex, i + 1));
139
- segmentIndex = -1;
140
- }
141
- continue;
142
- }
143
- // new segment - check if it is relative
144
- else if (segmented[i] === '.') {
145
- // ../ segment
146
- if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
147
- output.pop();
148
- i += 2;
149
- continue;
150
- }
151
- // ./ segment
152
- else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
153
- i += 1;
154
- continue;
155
- }
156
- }
157
- // it is the start of a new segment
158
- while (segmented[i] === '/') i++;
159
- segmentIndex = i;
160
- }
161
- // finish reading out the last segment
162
- if (segmentIndex !== -1)
163
- output.push(segmented.slice(segmentIndex));
164
- return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
165
- }
166
- }
167
-
168
- function resolveAndComposeImportMap (json, baseUrl, parentMap) {
169
- const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
170
-
171
- if (json.imports)
172
- resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
173
-
174
- if (json.scopes)
175
- for (let s in json.scopes) {
176
- const resolvedScope = resolveUrl(s, baseUrl);
177
- resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
178
- }
179
-
180
- return outMap;
181
- }
182
-
183
- function getMatch (path, matchObj) {
184
- if (matchObj[path])
185
- return path;
186
- let sepIndex = path.length;
187
- do {
188
- const segment = path.slice(0, sepIndex + 1);
189
- if (segment in matchObj)
190
- return segment;
191
- } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
192
- }
193
-
194
- function applyPackages (id, packages) {
195
- const pkgName = getMatch(id, packages);
196
- if (pkgName) {
197
- const pkg = packages[pkgName];
198
- if (pkg === null) return;
199
- return pkg + id.slice(pkgName.length);
200
- }
201
- }
202
-
203
-
204
- function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
205
- let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
206
- while (scopeUrl) {
207
- const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
208
- if (packageResolution)
209
- return packageResolution;
210
- scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
211
- }
212
- return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
213
- }
214
-
215
- function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
216
- for (let p in packages) {
217
- const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
218
- if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
219
- throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
220
- }
221
- let target = packages[p];
222
- if (typeof target !== 'string')
223
- continue;
224
- const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
225
- if (mapped) {
226
- outPackages[resolvedLhs] = mapped;
227
- continue;
228
- }
229
- console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
230
- }
231
- }
232
-
233
- let supportsDynamicImportCheck = false;
234
-
235
- let dynamicImport;
236
- try {
237
- dynamicImport = (0, eval)('u=>import(u)');
238
- supportsDynamicImportCheck = true;
239
- }
240
- catch (e) {}
241
-
242
- if (!supportsDynamicImportCheck) {
243
- let err;
244
- window.addEventListener('error', _err => err = _err);
245
- dynamicImport = (url, { errUrl = url }) => {
246
- err = undefined;
247
- const src = createBlob(`import*as m from'${url}';self._esmsi=m;`);
248
- const s = Object.assign(document.createElement('script'), { type: 'module', src });
249
- s.setAttribute('noshim', '');
250
- s.setAttribute('nonce', nonce);
251
- document.head.appendChild(s);
252
- return new Promise((resolve, reject) => {
253
- s.addEventListener('load', () => {
254
- document.head.removeChild(s);
255
- if (self._esmsi) {
256
- resolve(self._esmsi, baseUrl);
257
- self._esmsi = null;
258
- }
259
- else {
260
- reject(err.error || new Error(`Error loading or executing the graph of ${errUrl} (check the console for ${src}).`));
261
- err = undefined;
262
- }
263
- });
264
- });
265
- };
266
- }
267
-
268
- // support browsers without dynamic import support (eg Firefox 6x)
269
- let supportsJsonAssertions = false;
270
- let supportsCssAssertions = false;
271
-
272
- let supportsImportMeta = false;
273
- let supportsImportMaps = false;
274
-
275
- let supportsDynamicImport = false;
276
-
277
- const featureDetectionPromise = Promise.resolve(supportsDynamicImportCheck).then(_supportsDynamicImport => {
278
- if (!_supportsDynamicImport)
279
- return;
280
- supportsDynamicImport = true;
281
-
282
- return Promise.all([
283
- dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
284
- cssModulesEnabled && dynamicImport(createBlob('import"data:text/css,{}"assert{type:"css"}')).then(() => supportsCssAssertions = true, noop),
285
- jsonModulesEnabled && dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, noop),
286
- new Promise(resolve => {
287
- self._$s = v => {
288
- document.head.removeChild(iframe);
289
- if (v) supportsImportMaps = true;
290
- delete self._$s;
291
- resolve();
292
- };
293
- const iframe = document.createElement('iframe');
294
- iframe.style.display = 'none';
295
- iframe.srcdoc = `<script type=importmap nonce="${nonce}">{"imports":{"x":"data:text/javascript,"}}<${''}/script><script nonce="${nonce}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`;
296
- document.head.appendChild(iframe);
297
- })
298
- ]);
4
+ const noop = () => {};
5
+
6
+ const optionsScript = document.querySelector('script[type=esms-options]');
7
+
8
+ const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
9
+ Object.assign(esmsInitOptions, self.esmsInitOptions || {});
10
+
11
+ let shimMode = !!esmsInitOptions.shimMode;
12
+
13
+ const importHook = globalHook(shimMode && esmsInitOptions.onimport);
14
+ const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
15
+ let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
16
+ const metaHook = esmsInitOptions.meta ? globalHook(shimModule && esmsInitOptions.meta) : noop;
17
+
18
+ const skip = esmsInitOptions.skip ? new RegExp(esmsInitOptions.skip) : null;
19
+
20
+ let nonce = esmsInitOptions.nonce;
21
+
22
+ const mapOverrides = esmsInitOptions.mapOverrides;
23
+
24
+ if (!nonce) {
25
+ const nonceElement = document.querySelector('script[nonce]');
26
+ if (nonceElement)
27
+ nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
28
+ }
29
+
30
+ const onerror = globalHook(esmsInitOptions.onerror || noop);
31
+ const onpolyfill = esmsInitOptions.onpolyfill ? globalHook(esmsInitOptions.onpolyfill) : () => console.log('%c^^ Module TypeError above is polyfilled and can be ignored ^^', 'font-weight:900;color:#391');
32
+
33
+ const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
34
+
35
+ function globalHook (name) {
36
+ return typeof name === 'string' ? self[name] : name;
37
+ }
38
+
39
+ const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
40
+ const cssModulesEnabled = enable.includes('css-modules');
41
+ const jsonModulesEnabled = enable.includes('json-modules');
42
+
43
+ function setShimMode () {
44
+ shimMode = true;
45
+ }
46
+
47
+ const edge = !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
48
+
49
+ const baseUrl = document.baseURI;
50
+
51
+ function createBlob (source, type = 'text/javascript') {
52
+ return URL.createObjectURL(new Blob([source], { type }));
53
+ }
54
+
55
+ const eoop = err => setTimeout(() => { throw err });
56
+
57
+ const throwError = err => { (window.reportError || window.safari && console.error || eoop)(err), void onerror(err); };
58
+
59
+ function fromParent (parent) {
60
+ return parent ? ` imported from ${parent}` : '';
61
+ }
62
+
63
+ const backslashRegEx = /\\/g;
64
+
65
+ function isURL (url) {
66
+ if (url.indexOf(':') === -1) return false;
67
+ try {
68
+ new URL(url);
69
+ return true;
70
+ }
71
+ catch (_) {
72
+ return false;
73
+ }
74
+ }
75
+
76
+ /*
77
+ * Import maps implementation
78
+ *
79
+ * To make lookups fast we pre-resolve the entire import map
80
+ * and then match based on backtracked hash lookups
81
+ *
82
+ */
83
+ function resolveUrl (relUrl, parentUrl) {
84
+ return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
85
+ }
86
+
87
+ function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
88
+ // strip off any trailing query params or hashes
89
+ const queryHashIndex = parentUrl.indexOf('?', parentUrl.indexOf('#') === -1 ? parentUrl.indexOf('#') : parentUrl.length);
90
+ if (queryHashIndex !== -1)
91
+ parentUrl = parentUrl.slice(0, queryHashIndex);
92
+ if (relUrl.indexOf('\\') !== -1)
93
+ relUrl = relUrl.replace(backslashRegEx, '/');
94
+ // protocol-relative
95
+ if (relUrl[0] === '/' && relUrl[1] === '/') {
96
+ return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
97
+ }
98
+ // relative-url
99
+ else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
100
+ relUrl.length === 1 && (relUrl += '/')) ||
101
+ relUrl[0] === '/') {
102
+ const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
103
+ // Disabled, but these cases will give inconsistent results for deep backtracking
104
+ //if (parentUrl[parentProtocol.length] !== '/')
105
+ // throw new Error('Cannot resolve');
106
+ // read pathname from parent URL
107
+ // pathname taken to be part after leading "/"
108
+ let pathname;
109
+ if (parentUrl[parentProtocol.length + 1] === '/') {
110
+ // resolving to a :// so we need to read out the auth and host
111
+ if (parentProtocol !== 'file:') {
112
+ pathname = parentUrl.slice(parentProtocol.length + 2);
113
+ pathname = pathname.slice(pathname.indexOf('/') + 1);
114
+ }
115
+ else {
116
+ pathname = parentUrl.slice(8);
117
+ }
118
+ }
119
+ else {
120
+ // resolving to :/ so pathname is the /... part
121
+ pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
122
+ }
123
+
124
+ if (relUrl[0] === '/')
125
+ return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
126
+
127
+ // join together and split for removal of .. and . segments
128
+ // looping the string instead of anything fancy for perf reasons
129
+ // '../../../../../z' resolved to 'x/y' is just 'z'
130
+ const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
131
+
132
+ const output = [];
133
+ let segmentIndex = -1;
134
+ for (let i = 0; i < segmented.length; i++) {
135
+ // busy reading a segment - only terminate on '/'
136
+ if (segmentIndex !== -1) {
137
+ if (segmented[i] === '/') {
138
+ output.push(segmented.slice(segmentIndex, i + 1));
139
+ segmentIndex = -1;
140
+ }
141
+ continue;
142
+ }
143
+ // new segment - check if it is relative
144
+ else if (segmented[i] === '.') {
145
+ // ../ segment
146
+ if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
147
+ output.pop();
148
+ i += 2;
149
+ continue;
150
+ }
151
+ // ./ segment
152
+ else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
153
+ i += 1;
154
+ continue;
155
+ }
156
+ }
157
+ // it is the start of a new segment
158
+ while (segmented[i] === '/') i++;
159
+ segmentIndex = i;
160
+ }
161
+ // finish reading out the last segment
162
+ if (segmentIndex !== -1)
163
+ output.push(segmented.slice(segmentIndex));
164
+ return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
165
+ }
166
+ }
167
+
168
+ function resolveAndComposeImportMap (json, baseUrl, parentMap) {
169
+ const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
170
+
171
+ if (json.imports)
172
+ resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
173
+
174
+ if (json.scopes)
175
+ for (let s in json.scopes) {
176
+ const resolvedScope = resolveUrl(s, baseUrl);
177
+ resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
178
+ }
179
+
180
+ return outMap;
181
+ }
182
+
183
+ function getMatch (path, matchObj) {
184
+ if (matchObj[path])
185
+ return path;
186
+ let sepIndex = path.length;
187
+ do {
188
+ const segment = path.slice(0, sepIndex + 1);
189
+ if (segment in matchObj)
190
+ return segment;
191
+ } while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
192
+ }
193
+
194
+ function applyPackages (id, packages) {
195
+ const pkgName = getMatch(id, packages);
196
+ if (pkgName) {
197
+ const pkg = packages[pkgName];
198
+ if (pkg === null) return;
199
+ return pkg + id.slice(pkgName.length);
200
+ }
201
+ }
202
+
203
+
204
+ function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
205
+ let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
206
+ while (scopeUrl) {
207
+ const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
208
+ if (packageResolution)
209
+ return packageResolution;
210
+ scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
211
+ }
212
+ return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
213
+ }
214
+
215
+ function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
216
+ for (let p in packages) {
217
+ const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
218
+ if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
219
+ throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
220
+ }
221
+ let target = packages[p];
222
+ if (typeof target !== 'string')
223
+ continue;
224
+ const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
225
+ if (mapped) {
226
+ outPackages[resolvedLhs] = mapped;
227
+ continue;
228
+ }
229
+ console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
230
+ }
231
+ }
232
+
233
+ let supportsDynamicImportCheck = false;
234
+
235
+ let dynamicImport;
236
+ try {
237
+ dynamicImport = (0, eval)('u=>import(u)');
238
+ supportsDynamicImportCheck = true;
239
+ }
240
+ catch (e) {}
241
+
242
+ if (!supportsDynamicImportCheck) {
243
+ let err;
244
+ window.addEventListener('error', _err => err = _err);
245
+ dynamicImport = (url, { errUrl = url }) => {
246
+ err = undefined;
247
+ const src = createBlob(`import*as m from'${url}';self._esmsi=m;`);
248
+ const s = Object.assign(document.createElement('script'), { type: 'module', src });
249
+ s.setAttribute('noshim', '');
250
+ s.setAttribute('nonce', nonce);
251
+ document.head.appendChild(s);
252
+ return new Promise((resolve, reject) => {
253
+ s.addEventListener('load', () => {
254
+ document.head.removeChild(s);
255
+ if (self._esmsi) {
256
+ resolve(self._esmsi, baseUrl);
257
+ self._esmsi = null;
258
+ }
259
+ else {
260
+ reject(err.error || new Error(`Error loading or executing the graph of ${errUrl} (check the console for ${src}).`));
261
+ err = undefined;
262
+ }
263
+ });
264
+ });
265
+ };
266
+ }
267
+
268
+ // support browsers without dynamic import support (eg Firefox 6x)
269
+ let supportsJsonAssertions = false;
270
+ let supportsCssAssertions = false;
271
+
272
+ let supportsImportMeta = false;
273
+ let supportsImportMaps = false;
274
+
275
+ let supportsDynamicImport = false;
276
+
277
+ const featureDetectionPromise = Promise.resolve(supportsDynamicImportCheck).then(_supportsDynamicImport => {
278
+ if (!_supportsDynamicImport)
279
+ return;
280
+ supportsDynamicImport = true;
281
+
282
+ return Promise.all([
283
+ dynamicImport(createBlob('import.meta')).then(() => supportsImportMeta = true, noop),
284
+ cssModulesEnabled && dynamicImport(createBlob('import"data:text/css,{}"assert{type:"css"}')).then(() => supportsCssAssertions = true, noop),
285
+ jsonModulesEnabled && dynamicImport(createBlob('import"data:text/json,{}"assert{type:"json"}')).then(() => supportsJsonAssertions = true, noop),
286
+ new Promise(resolve => {
287
+ self._$s = v => {
288
+ document.head.removeChild(iframe);
289
+ if (v) supportsImportMaps = true;
290
+ delete self._$s;
291
+ resolve();
292
+ };
293
+ const iframe = document.createElement('iframe');
294
+ iframe.style.display = 'none';
295
+ iframe.srcdoc = `<script type=importmap nonce="${nonce}">{"imports":{"x":"data:text/javascript,"}}<${''}/script><script nonce="${nonce}">import('x').then(()=>1,()=>0).then(v=>parent._$s(v))<${''}/script>`;
296
+ document.head.appendChild(iframe);
297
+ })
298
+ ]);
299
299
  });
300
300
 
301
301
  /* es-module-lexer 0.10.1 */
302
302
  const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!C)return init.then(()=>parse(E));const I=E.length+1,o=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;o>0&&C.memory.grow(Math.ceil(o/65536));const k=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,k,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const J=[],i=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.ai(),g=C.id(),I=C.ss(),o=C.se();let k;C.ip()&&(k=w(E.slice(-1===g?A-1:A,-1===g?Q+1:Q))),J.push({n:k,s:A,e:Q,ss:I,se:o,d:g,a:B});}for(;C.re();){const A=E.slice(C.es(),C.ee()),Q=A[0];i.push('"'===Q||"'"===Q?w(A):A);}function w(A){try{return (0,eval)(A)}catch(A){}}return [J,i,!!C.f()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const init=WebAssembly.compile((E="AGFzbQEAAAABKghgAX8Bf2AEf39/fwBgAn9/AGAAAX9gAABgAX8AYAN/f38Bf2ACf38BfwMqKQABAgMDAwMDAwMDAwMDAwMAAAQEBAUEBQAAAAAEBAAGBwACAAAABwMGBAUBcAEBAQUDAQABBg8CfwFBkPIAC38AQZDyAAsHZBEGbWVtb3J5AgACc2EAAAFlAAMCaXMABAJpZQAFAnNzAAYCc2UABwJhaQAIAmlkAAkCaXAACgJlcwALAmVlAAwCcmkADQJyZQAOAWYADwVwYXJzZQAQC19faGVhcF9iYXNlAwEKhjQpaAEBf0EAIAA2AtQJQQAoArAJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgLYCUEAIAA2AtwJQQBBADYCtAlBAEEANgLECUEAQQA2ArwJQQBBADYCuAlBAEEANgLMCUEAQQA2AsAJIAEL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0EBECEhAgtBACgCiAohAwJAIAJB5gBHDQAgA0ECakGeCEEGECgNAEEAIANBCGo2AogKIABBARAhECIPC0EAIANBfmo2AogKDAMLEB0PCwJAIAMpAAJC7ICEg7COwDlSDQAgAy8BChAeRQ0AQQAgA0EKajYCiApBARAhIQJBACgCiAohAyACECQaIANBACgCiAoQAkEAQQAoAogKQX5qNgKICg8LQQAgA0EEaiIDNgKICgtBACADQQRqIgI2AogKQQBBADoA5AkDQEEAIAJBAmo2AogKQQEQISEDQQAoAogKIQICQCADECRBIHJB+wBHDQBBAEEAKAKICkF+ajYCiAoPC0EAKAKICiIDIAJGDQEgAiADEAICQEEBECEiAkEsRg0AAkAgAkE9Rw0AQQBBACgCiApBfmo2AogKDwtBAEEAKAKICkF+ajYCiAoPC0EAKAKICiECDAALCw8LQQAgA0EKajYCiApBARAhGkEAKAKICiEDC0EAIANBEGo2AogKAkBBARAhIgJBKkcNAEEAQQAoAogKQQJqNgKICkEBECEhAgtBACgCiAohAyACECQaIANBACgCiAoQAkEAQQAoAogKQX5qNgKICg8LIAMgA0EOahACC6sGAQR/QQBBACgCiAoiAEEMaiIBNgKICgJAAkACQAJAAkACQAJAAkACQAJAQQEQISICQVlqDggCCAECAQEBBwALIAJBIkYNASACQfsARg0CC0EAKAKICiABRg0HC0EALwHqCQ0BQQAoAogKIQJBACgCjAohAwNAIAIgA08NBAJAAkAgAi8BACIBQSdGDQAgAUEiRw0BCyAAIAEQIg8LQQAgAkECaiICNgKICgwACwtBACgCiAohAkEALwHqCQ0BAkADQAJAAkACQCACQQAoAowKTw0AQQEQISICQSJGDQEgAkEnRg0BIAJB/QBHDQJBAEEAKAKICkECajYCiAoLQQEQIRpBACgCiAoiAikAAELmgMiD8I3ANlINBkEAIAJBCGo2AogKQQEQISICQSJGDQMgAkEnRg0DDAYLIAIQFwtBAEEAKAKICkECaiICNgKICgwACwsgACACECIMBQtBAEEAKAKICkF+ajYCiAoPC0EAIAJBfmo2AogKDwsQHQ8LQQBBACgCiApBAmo2AogKQQEQIUHtAEcNAUEAKAKICiICQQJqQZYIQQYQKA0BQQAoAvAJLwEAQS5GDQEgACAAIAJBCGpBACgCqAkQAQ8LQQAoAvwJQQAvAeoJIgJBAnRqQQAoAogKNgIAQQAgAkEBajsB6glBACgC8AkvAQBBLkYNAEEAQQAoAogKIgFBAmo2AogKQQEQISECIABBACgCiApBACABEAFBAEEALwHoCSIBQQFqOwHoCUEAKAKACiABQQJ0akEAKALECTYCAAJAIAJBIkYNACACQSdGDQBBAEEAKAKICkF+ajYCiAoPCyACEBdBAEEAKAKICkECaiICNgKICgJAAkACQEEBECFBV2oOBAECAgACC0EAQQAoAogKQQJqNgKICkEBECEaQQAoAsQJIgEgAjYCBCABQQE6ABggAUEAKAKICiICNgIQQQAgAkF+ajYCiAoPC0EAKALECSIBIAI2AgQgAUEBOgAYQQBBAC8B6glBf2o7AeoJIAFBACgCiApBAmo2AgxBAEEALwHoCUF/ajsB6AkPC0EAQQAoAogKQX5qNgKICg8LC0cBA39BACgCiApBAmohAEEAKAKMCiEBAkADQCAAIgJBfmogAU8NASACQQJqIQAgAi8BAEF2ag4EAQAAAQALC0EAIAI2AogKC5gBAQN/QQBBACgCiAoiAUECajYCiAogAUEGaiEBQQAoAowKIQIDQAJAAkACQCABQXxqIAJPDQAgAUF+ai8BACEDAkACQCAADQAgA0EqRg0BIANBdmoOBAIEBAIECyADQSpHDQMLIAEvAQBBL0cNAkEAIAFBfmo2AogKDAELIAFBfmohAQtBACABNgKICg8LIAFBAmohAQwACwu/AQEEf0EAKAKICiEAQQAoAowKIQECQAJAA0AgACICQQJqIQAgAiABTw0BAkACQCAALwEAIgNBpH9qDgUBAgICBAALIANBJEcNASACLwEEQfsARw0BQQBBAC8B5gkiAEEBajsB5glBACgC+AkgAEEBdGpBAC8B7Ak7AQBBACACQQRqNgKICkEAQQAvAeoJQQFqIgA7AewJQQAgADsB6gkPCyACQQRqIQAMAAsLQQAgADYCiAoQHQ8LQQAgADYCiAoLiAE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AdQBnAGcAZQBhAHcAYQBpAHQAaAByAHcAaABpAGwAZQBmAG8AcgBpAGYAYwBhAHQAYwBmAGkAbgBhAGwAbABlAGwAcwAAQaQJCxABAAAAAgAAAAAEAAAQOQAA","undefined"!=typeof Buffer?Buffer.from(E,"base64"):Uint8Array.from(atob(E),A=>A.charCodeAt(0)))).then(WebAssembly.instantiate).then(({exports:A})=>{C=A;});var E;
303
303
 
304
- async function _resolve (id, parentUrl) {
305
- const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
306
- return {
307
- r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl),
308
- // b = bare specifier
309
- b: !urlResolved && !isURL(id)
310
- };
311
- }
312
-
313
- const resolve = resolveHook ? async (id, parentUrl) => {
314
- let result = resolveHook(id, parentUrl, defaultResolve);
315
- // will be deprecated in next major
316
- if (result && result.then)
317
- result = await result;
318
- return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !isURL(id) } : _resolve(id, parentUrl);
319
- } : _resolve;
320
-
321
- // importShim('mod');
322
- // importShim('mod', { opts });
323
- // importShim('mod', { opts }, parentUrl);
324
- // importShim('mod', parentUrl);
325
- async function importShim (id, ...args) {
326
- // parentUrl if present will be the last argument
327
- let parentUrl = args[args.length - 1];
328
- if (typeof parentUrl !== 'string')
329
- parentUrl = baseUrl;
330
- // needed for shim check
331
- await initPromise;
332
- if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
333
- if (acceptingImportMaps || shimMode || !baselinePassthrough) {
334
- processImportMaps();
335
- if (!shimMode)
336
- acceptingImportMaps = false;
337
- }
338
- await importMapPromise;
339
- return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' });
340
- }
341
-
342
- self.importShim = importShim;
343
-
344
- function defaultResolve (id, parentUrl) {
345
- return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
346
- }
347
-
348
- function throwUnresolved (id, parentUrl) {
349
- throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
350
- }
351
-
352
- const resolveSync = (id, parentUrl = baseUrl) => {
353
- parentUrl = `${parentUrl}`;
354
- const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
355
- return result && !result.then ? result : defaultResolve(id, parentUrl);
356
- };
357
-
358
- function metaResolve (id, parentUrl = this.url) {
359
- return resolveSync(id, parentUrl);
360
- }
361
-
362
- importShim.resolve = resolveSync;
363
- importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
364
-
365
- const registry = importShim._r = {};
366
-
367
- async function loadAll (load, seen) {
368
- if (load.b || seen[load.u])
369
- return;
370
- seen[load.u] = 1;
371
- await load.L;
372
- await Promise.all(load.d.map(dep => loadAll(dep, seen)));
373
- if (!load.n)
374
- load.n = load.d.some(dep => dep.n);
375
- }
376
-
377
- let importMap = { imports: {}, scopes: {} };
378
- let importMapSrcOrLazy = false;
379
- let baselinePassthrough;
380
-
381
- const initPromise = featureDetectionPromise.then(() => {
382
- // shim mode is determined on initialization, no late shim mode
383
- if (!shimMode) {
384
- if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
385
- setShimMode();
386
- }
387
- else {
388
- let seenScript = false;
389
- for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
390
- if (!seenScript) {
391
- if (script.type === 'module')
392
- seenScript = true;
393
- }
394
- else if (script.type === 'importmap') {
395
- importMapSrcOrLazy = true;
396
- break;
397
- }
398
- }
399
- }
400
- }
401
- baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false;
402
- if (shimMode || !baselinePassthrough) {
403
- new MutationObserver(mutations => {
404
- for (const mutation of mutations) {
405
- if (mutation.type !== 'childList') continue;
406
- for (const node of mutation.addedNodes) {
407
- if (node.tagName === 'SCRIPT') {
408
- if (node.type === (shimMode ? 'module-shim' : 'module'))
409
- processScript(node);
410
- if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
411
- processImportMap(node);
412
- }
413
- else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload'))
414
- processPreload(node);
415
- }
416
- }
417
- }).observe(document, { childList: true, subtree: true });
418
- processImportMaps();
419
- processScriptsAndPreloads();
420
- return init;
421
- }
422
- });
423
- let importMapPromise = initPromise;
424
- let firstPolyfillLoad = true;
425
- let acceptingImportMaps = true;
426
-
427
- async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
428
- if (!shimMode)
429
- acceptingImportMaps = false;
430
- await importMapPromise;
431
- if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
432
- // early analysis opt-out - no need to even fetch if we have feature support
433
- if (!shimMode && baselinePassthrough) {
434
- // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
435
- if (nativelyLoaded)
436
- return null;
437
- await lastStaticLoadPromise;
438
- return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
439
- }
440
- const load = getOrCreateLoad(url, fetchOpts, null, source);
441
- const seen = {};
442
- await loadAll(load, seen);
443
- lastLoad = undefined;
444
- resolveDeps(load, seen);
445
- await lastStaticLoadPromise;
446
- if (source && !shimMode && !load.n && !false) {
447
- const module = await dynamicImport(createBlob(source), { errUrl: source });
448
- if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
449
- return module;
450
- }
451
- if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
452
- onpolyfill();
453
- firstPolyfillLoad = false;
454
- }
455
- const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
456
- // if the top-level load is a shell, run its update function
457
- if (load.s)
458
- (await dynamicImport(load.s)).u$_(module);
459
- if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
460
- // when tla is supported, this should return the tla promise as an actual handle
461
- // so readystate can still correspond to the sync subgraph exec completions
462
- return module;
463
- }
464
-
465
- function revokeObjectURLs(registryKeys) {
466
- let batch = 0;
467
- const keysLength = registryKeys.length;
468
- const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
469
- schedule(cleanup);
470
- function cleanup() {
471
- const batchStartIndex = batch * 100;
472
- if (batchStartIndex > keysLength) return
473
- for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
474
- const load = registry[key];
475
- if (load) URL.revokeObjectURL(load.b);
476
- }
477
- batch++;
478
- schedule(cleanup);
479
- }
480
- }
481
-
482
- function urlJsString (url) {
483
- return `'${url.replace(/'/g, "\\'")}'`;
484
- }
485
-
486
- let lastLoad;
487
- function resolveDeps (load, seen) {
488
- if (load.b || !seen[load.u])
489
- return;
490
- seen[load.u] = 0;
491
-
492
- for (const dep of load.d)
493
- resolveDeps(dep, seen);
494
-
495
- const [imports] = load.a;
496
-
497
- // "execution"
498
- const source = load.S;
499
-
500
- // edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
501
- let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
502
-
503
- if (!imports.length) {
504
- resolvedSource += source;
505
- }
506
- else {
507
- // once all deps have loaded we can inline the dependency resolution blobs
508
- // and define this blob
509
- let lastIndex = 0, depIndex = 0;
510
- for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
511
- // dependency source replacements
512
- if (dynamicImportIndex === -1) {
513
- const depLoad = load.d[depIndex++];
514
- let blobUrl = depLoad.b;
515
- if (!blobUrl) {
516
- // circular shell creation
517
- if (!(blobUrl = depLoad.s)) {
518
- blobUrl = depLoad.s = createBlob(`export function u$_(m){${
519
- depLoad.a[1].map(
520
- name => name === 'default' ? `$_default=m.default` : `${name}=m.${name}`
521
- ).join(',')
522
- }}${
523
- depLoad.a[1].map(name =>
524
- name === 'default' ? `let $_default;export{$_default as default}` : `export let ${name}`
525
- ).join(';')
526
- }\n//# sourceURL=${depLoad.r}?cycle`);
527
- }
528
- }
529
- // circular shell execution
530
- else if (depLoad.s) {
531
- resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)};import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
532
- lastIndex = statementEnd;
533
- depLoad.s = undefined;
534
- continue;
535
- }
536
- resolvedSource += `${source.slice(lastIndex, start - 1)}/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
537
- lastIndex = statementEnd;
538
- }
539
- // import.meta
540
- else if (dynamicImportIndex === -2) {
541
- load.m = { url: load.r, resolve: metaResolve };
542
- metaHook(load.m, load.u);
543
- resolvedSource += `${source.slice(lastIndex, start)}importShim._r[${urlJsString(load.u)}].m`;
544
- lastIndex = statementEnd;
545
- }
546
- // dynamic import
547
- else {
548
- resolvedSource += `${source.slice(lastIndex, statementStart + 6)}Shim(${source.slice(start, statementEnd - 1)}, ${urlJsString(load.r)})`;
549
- lastIndex = statementEnd;
550
- }
551
- }
552
-
553
- resolvedSource += source.slice(lastIndex);
554
- }
555
-
556
- let hasSourceURL = false;
557
- resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
558
- if (!hasSourceURL)
559
- resolvedSource += '\n//# sourceURL=' + load.r;
560
-
561
- load.b = lastLoad = createBlob(resolvedSource);
562
- load.S = undefined;
563
- }
564
-
565
- // ; and // trailer support added for Ruby on Rails 7 source maps compatibility
566
- // https://github.com/guybedford/es-module-shims/issues/228
567
- const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
568
-
569
- const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
570
- const jsonContentType = /^(text|application)\/json(;|$)/;
571
- const cssContentType = /^(text|application)\/css(;|$)/;
572
-
573
- const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
574
-
575
- // restrict in-flight fetches to a pool of 100
576
- let p = [];
577
- let c = 0;
578
- function pushFetchPool () {
579
- if (++c > 100)
580
- return new Promise(r => p.push(r));
581
- }
582
- function popFetchPool () {
583
- c--;
584
- if (p.length)
585
- p.shift()();
586
- }
587
-
588
- async function doFetch (url, fetchOpts, parent) {
589
- if (enforceIntegrity && !fetchOpts.integrity)
590
- throw Error(`No integrity for ${url}${fromParent(parent)}.`);
591
- const poolQueue = pushFetchPool();
592
- if (poolQueue) await poolQueue;
593
- try {
594
- var res = await fetchHook(url, fetchOpts);
595
- }
596
- catch (e) {
597
- e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
598
- throw e;
599
- }
600
- finally {
601
- popFetchPool();
602
- }
603
- if (!res.ok)
604
- throw Error(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
605
- return res;
606
- }
607
-
608
- async function fetchModule (url, fetchOpts, parent) {
609
- const res = await doFetch(url, fetchOpts, parent);
610
- const contentType = res.headers.get('content-type');
611
- if (jsContentType.test(contentType))
612
- return { r: res.url, s: await res.text(), t: 'js' };
613
- else if (jsonContentType.test(contentType))
614
- return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
615
- else if (cssContentType.test(contentType)) {
616
- return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
617
- JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
618
- });export default s;`, t: 'css' };
619
- }
620
- else
621
- throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
622
- }
623
-
624
- function getOrCreateLoad (url, fetchOpts, parent, source) {
625
- let load = registry[url];
626
- if (load && !source)
627
- return load;
628
-
629
- load = {
630
- // url
631
- u: url,
632
- // response url
633
- r: source ? url : undefined,
634
- // fetchPromise
635
- f: undefined,
636
- // source
637
- S: undefined,
638
- // linkPromise
639
- L: undefined,
640
- // analysis
641
- a: undefined,
642
- // deps
643
- d: undefined,
644
- // blobUrl
645
- b: undefined,
646
- // shellUrl
647
- s: undefined,
648
- // needsShim
649
- n: false,
650
- // type
651
- t: null,
652
- // meta
653
- m: null
654
- };
655
- if (registry[url]) {
656
- let i = 0;
657
- while (registry[load.u + ++i]);
658
- load.u += i;
659
- }
660
- registry[load.u] = load;
661
-
662
- load.f = (async () => {
663
- if (!source) {
664
- // preload fetch options override fetch options (race)
665
- let t;
666
- ({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
667
- if (t && !shimMode) {
668
- if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
669
- throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
670
- if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
671
- load.n = true;
672
- }
673
- }
674
- try {
675
- load.a = parse(source, load.u);
676
- }
677
- catch (e) {
678
- throwError(e);
679
- load.a = [[], [], false];
680
- }
681
- load.S = source;
682
- return load;
683
- })();
684
-
685
- load.L = load.f.then(async () => {
686
- let childFetchOpts = fetchOpts;
687
- load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
688
- if (d >= 0 && !supportsDynamicImport || d === 2 && !supportsImportMeta)
689
- load.n = true;
690
- if (!n) return;
691
- const { r, b } = await resolve(n, load.r || load.u);
692
- if (b && (!supportsImportMaps || importMapSrcOrLazy))
693
- load.n = true;
694
- if (d !== -1) return;
695
- if (skip && skip.test(r)) return { b: r };
696
- if (childFetchOpts.integrity)
697
- childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
698
- return getOrCreateLoad(r, childFetchOpts, load.r).f;
699
- }))).filter(l => l);
700
- });
701
-
702
- return load;
703
- }
704
-
705
- function processScriptsAndPreloads () {
706
- for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
707
- processScript(script);
708
- for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
709
- processPreload(link);
710
- }
711
-
712
- function processImportMaps () {
713
- for (const script of document.querySelectorAll(shimMode ? 'script[type="importmap-shim"]' : 'script[type="importmap"]'))
714
- processImportMap(script);
715
- }
716
-
717
- function getFetchOpts (script) {
718
- const fetchOpts = {};
719
- if (script.integrity)
720
- fetchOpts.integrity = script.integrity;
721
- if (script.referrerpolicy)
722
- fetchOpts.referrerPolicy = script.referrerpolicy;
723
- if (script.crossorigin === 'use-credentials')
724
- fetchOpts.credentials = 'include';
725
- else if (script.crossorigin === 'anonymous')
726
- fetchOpts.credentials = 'omit';
727
- else
728
- fetchOpts.credentials = 'same-origin';
729
- return fetchOpts;
730
- }
731
-
732
- let lastStaticLoadPromise = Promise.resolve();
733
-
734
- let domContentLoadedCnt = 1;
735
- function domContentLoadedCheck () {
736
- if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers)
737
- document.dispatchEvent(new Event('DOMContentLoaded'));
738
- }
739
- // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
740
- document.addEventListener('DOMContentLoaded', async () => {
741
- await initPromise;
742
- domContentLoadedCheck();
743
- if (shimMode || !baselinePassthrough) {
744
- processImportMaps();
745
- processScriptsAndPreloads();
746
- }
747
- });
748
-
749
- let readyStateCompleteCnt = 1;
750
- if (document.readyState === 'complete') {
751
- readyStateCompleteCheck();
752
- }
753
- else {
754
- document.addEventListener('readystatechange', async () => {
755
- processImportMaps();
756
- await initPromise;
757
- readyStateCompleteCheck();
758
- });
759
- }
760
- function readyStateCompleteCheck () {
761
- if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
762
- document.dispatchEvent(new Event('readystatechange'));
763
- }
764
-
765
- function processImportMap (script) {
766
- if (script.ep) // ep marker = script processed
767
- return;
768
- // empty inline scripts sometimes show before domready
769
- if (!script.src && !script.innerHTML)
770
- return;
771
- script.ep = true;
772
- // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
773
- if (script.src) {
774
- if (!shimMode)
775
- return;
776
- importMapSrcOrLazy = true;
777
- }
778
- if (acceptingImportMaps) {
779
- importMapPromise = importMapPromise
780
- .then(async () => {
781
- importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
782
- })
783
- .catch(throwError);
784
- if (!shimMode)
785
- acceptingImportMaps = false;
786
- }
787
- }
788
-
789
- function processScript (script) {
790
- if (script.ep) // ep marker = script processed
791
- return;
792
- if (script.getAttribute('noshim') !== null)
793
- return;
794
- // empty inline scripts sometimes show before domready
795
- if (!script.src && !script.innerHTML)
796
- return;
797
- script.ep = true;
798
- // does this load block readystate complete
799
- const isReadyScript = readyStateCompleteCnt > 0;
800
- // does this load block DOMContentLoaded
801
- const isDomContentLoadedScript = domContentLoadedCnt > 0;
802
- if (isReadyScript) readyStateCompleteCnt++;
803
- if (isDomContentLoadedScript) domContentLoadedCnt++;
804
- const blocks = script.getAttribute('async') === null && isReadyScript;
805
- const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, blocks && lastStaticLoadPromise).catch(throwError);
806
- if (blocks)
807
- lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
808
- if (isDomContentLoadedScript)
809
- loadPromise.then(domContentLoadedCheck);
810
- }
811
-
812
- const fetchCache = {};
813
- function processPreload (link) {
814
- if (link.ep) // ep marker = processed
815
- return;
816
- link.ep = true;
817
- if (fetchCache[link.href])
818
- return;
819
- fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
820
- }
821
-
822
- })();
304
+ async function _resolve (id, parentUrl) {
305
+ const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
306
+ return {
307
+ r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl),
308
+ // b = bare specifier
309
+ b: !urlResolved && !isURL(id)
310
+ };
311
+ }
312
+
313
+ const resolve = resolveHook ? async (id, parentUrl) => {
314
+ let result = resolveHook(id, parentUrl, defaultResolve);
315
+ // will be deprecated in next major
316
+ if (result && result.then)
317
+ result = await result;
318
+ return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !isURL(id) } : _resolve(id, parentUrl);
319
+ } : _resolve;
320
+
321
+ // importShim('mod');
322
+ // importShim('mod', { opts });
323
+ // importShim('mod', { opts }, parentUrl);
324
+ // importShim('mod', parentUrl);
325
+ async function importShim (id, ...args) {
326
+ // parentUrl if present will be the last argument
327
+ let parentUrl = args[args.length - 1];
328
+ if (typeof parentUrl !== 'string')
329
+ parentUrl = baseUrl;
330
+ // needed for shim check
331
+ await initPromise;
332
+ if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
333
+ if (acceptingImportMaps || shimMode || !baselinePassthrough) {
334
+ processImportMaps();
335
+ if (!shimMode)
336
+ acceptingImportMaps = false;
337
+ }
338
+ await importMapPromise;
339
+ return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' });
340
+ }
341
+
342
+ self.importShim = importShim;
343
+
344
+ function defaultResolve (id, parentUrl) {
345
+ return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
346
+ }
347
+
348
+ function throwUnresolved (id, parentUrl) {
349
+ throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
350
+ }
351
+
352
+ const resolveSync = (id, parentUrl = baseUrl) => {
353
+ parentUrl = `${parentUrl}`;
354
+ const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
355
+ return result && !result.then ? result : defaultResolve(id, parentUrl);
356
+ };
357
+
358
+ function metaResolve (id, parentUrl = this.url) {
359
+ return resolveSync(id, parentUrl);
360
+ }
361
+
362
+ importShim.resolve = resolveSync;
363
+ importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
364
+
365
+ const registry = importShim._r = {};
366
+
367
+ async function loadAll (load, seen) {
368
+ if (load.b || seen[load.u])
369
+ return;
370
+ seen[load.u] = 1;
371
+ await load.L;
372
+ await Promise.all(load.d.map(dep => loadAll(dep, seen)));
373
+ if (!load.n)
374
+ load.n = load.d.some(dep => dep.n);
375
+ }
376
+
377
+ let importMap = { imports: {}, scopes: {} };
378
+ let importMapSrcOrLazy = false;
379
+ let baselinePassthrough;
380
+
381
+ const initPromise = featureDetectionPromise.then(() => {
382
+ // shim mode is determined on initialization, no late shim mode
383
+ if (!shimMode) {
384
+ if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
385
+ setShimMode();
386
+ }
387
+ else {
388
+ let seenScript = false;
389
+ for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
390
+ if (!seenScript) {
391
+ if (script.type === 'module')
392
+ seenScript = true;
393
+ }
394
+ else if (script.type === 'importmap') {
395
+ importMapSrcOrLazy = true;
396
+ break;
397
+ }
398
+ }
399
+ }
400
+ }
401
+ baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !false;
402
+ if (shimMode || !baselinePassthrough) {
403
+ new MutationObserver(mutations => {
404
+ for (const mutation of mutations) {
405
+ if (mutation.type !== 'childList') continue;
406
+ for (const node of mutation.addedNodes) {
407
+ if (node.tagName === 'SCRIPT') {
408
+ if (node.type === (shimMode ? 'module-shim' : 'module'))
409
+ processScript(node);
410
+ if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
411
+ processImportMap(node);
412
+ }
413
+ else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload'))
414
+ processPreload(node);
415
+ }
416
+ }
417
+ }).observe(document, { childList: true, subtree: true });
418
+ processImportMaps();
419
+ processScriptsAndPreloads();
420
+ return init;
421
+ }
422
+ });
423
+ let importMapPromise = initPromise;
424
+ let firstPolyfillLoad = true;
425
+ let acceptingImportMaps = true;
426
+
427
+ async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
428
+ if (!shimMode)
429
+ acceptingImportMaps = false;
430
+ await importMapPromise;
431
+ if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
432
+ // early analysis opt-out - no need to even fetch if we have feature support
433
+ if (!shimMode && baselinePassthrough) {
434
+ // for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
435
+ if (nativelyLoaded)
436
+ return null;
437
+ await lastStaticLoadPromise;
438
+ return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
439
+ }
440
+ const load = getOrCreateLoad(url, fetchOpts, null, source);
441
+ const seen = {};
442
+ await loadAll(load, seen);
443
+ lastLoad = undefined;
444
+ resolveDeps(load, seen);
445
+ await lastStaticLoadPromise;
446
+ if (source && !shimMode && !load.n && !false) {
447
+ const module = await dynamicImport(createBlob(source), { errUrl: source });
448
+ if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
449
+ return module;
450
+ }
451
+ if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
452
+ onpolyfill();
453
+ firstPolyfillLoad = false;
454
+ }
455
+ const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
456
+ // if the top-level load is a shell, run its update function
457
+ if (load.s)
458
+ (await dynamicImport(load.s)).u$_(module);
459
+ if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
460
+ // when tla is supported, this should return the tla promise as an actual handle
461
+ // so readystate can still correspond to the sync subgraph exec completions
462
+ return module;
463
+ }
464
+
465
+ function revokeObjectURLs(registryKeys) {
466
+ let batch = 0;
467
+ const keysLength = registryKeys.length;
468
+ const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
469
+ schedule(cleanup);
470
+ function cleanup() {
471
+ const batchStartIndex = batch * 100;
472
+ if (batchStartIndex > keysLength) return
473
+ for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
474
+ const load = registry[key];
475
+ if (load) URL.revokeObjectURL(load.b);
476
+ }
477
+ batch++;
478
+ schedule(cleanup);
479
+ }
480
+ }
481
+
482
+ function urlJsString (url) {
483
+ return `'${url.replace(/'/g, "\\'")}'`;
484
+ }
485
+
486
+ let lastLoad;
487
+ function resolveDeps (load, seen) {
488
+ if (load.b || !seen[load.u])
489
+ return;
490
+ seen[load.u] = 0;
491
+
492
+ for (const dep of load.d)
493
+ resolveDeps(dep, seen);
494
+
495
+ const [imports] = load.a;
496
+
497
+ // "execution"
498
+ const source = load.S;
499
+
500
+ // edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
501
+ let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
502
+
503
+ if (!imports.length) {
504
+ resolvedSource += source;
505
+ }
506
+ else {
507
+ // once all deps have loaded we can inline the dependency resolution blobs
508
+ // and define this blob
509
+ let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
510
+ function pushStringTo (originalIndex) {
511
+ while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
512
+ const dynamicImportEnd = dynamicImportEndStack.pop();
513
+ resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
514
+ lastIndex = dynamicImportEnd;
515
+ }
516
+ resolvedSource += source.slice(lastIndex, originalIndex);
517
+ lastIndex = originalIndex;
518
+ }
519
+ for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
520
+ // dependency source replacements
521
+ if (dynamicImportIndex === -1) {
522
+ let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
523
+ if (cycleShell) {
524
+ // circular shell creation
525
+ if (!(blobUrl = depLoad.s)) {
526
+ blobUrl = depLoad.s = createBlob(`export function u$_(m){${
527
+ depLoad.a[1].map(
528
+ name => name === 'default' ? `d$_=m.default` : `${name}=m.${name}`
529
+ ).join(',')
530
+ }}${
531
+ depLoad.a[1].map(name =>
532
+ name === 'default' ? `let d$_;export{d$_ as default}` : `export let ${name}`
533
+ ).join(';')
534
+ }\n//# sourceURL=${depLoad.r}?cycle`);
535
+ }
536
+ }
537
+
538
+ pushStringTo(start - 1);
539
+ resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
540
+
541
+ // circular shell execution
542
+ if (!cycleShell && depLoad.s) {
543
+ resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
544
+ depLoad.s = undefined;
545
+ }
546
+ lastIndex = statementEnd;
547
+ }
548
+ // import.meta
549
+ else if (dynamicImportIndex === -2) {
550
+ load.m = { url: load.r, resolve: metaResolve };
551
+ metaHook(load.m, load.u);
552
+ pushStringTo(start);
553
+ resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
554
+ lastIndex = statementEnd;
555
+ }
556
+ // dynamic import
557
+ else {
558
+ pushStringTo(statementStart + 6);
559
+ resolvedSource += `Shim(`;
560
+ dynamicImportEndStack.push(statementEnd - 1);
561
+ lastIndex = start;
562
+ }
563
+ }
564
+
565
+ pushStringTo(source.length);
566
+ }
567
+
568
+ let hasSourceURL = false;
569
+ resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
570
+ if (!hasSourceURL)
571
+ resolvedSource += '\n//# sourceURL=' + load.r;
572
+
573
+ load.b = lastLoad = createBlob(resolvedSource);
574
+ load.S = undefined;
575
+ }
576
+
577
+ // ; and // trailer support added for Ruby on Rails 7 source maps compatibility
578
+ // https://github.com/guybedford/es-module-shims/issues/228
579
+ const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
580
+
581
+ const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
582
+ const jsonContentType = /^(text|application)\/json(;|$)/;
583
+ const cssContentType = /^(text|application)\/css(;|$)/;
584
+
585
+ const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
586
+
587
+ // restrict in-flight fetches to a pool of 100
588
+ let p = [];
589
+ let c = 0;
590
+ function pushFetchPool () {
591
+ if (++c > 100)
592
+ return new Promise(r => p.push(r));
593
+ }
594
+ function popFetchPool () {
595
+ c--;
596
+ if (p.length)
597
+ p.shift()();
598
+ }
599
+
600
+ async function doFetch (url, fetchOpts, parent) {
601
+ if (enforceIntegrity && !fetchOpts.integrity)
602
+ throw Error(`No integrity for ${url}${fromParent(parent)}.`);
603
+ const poolQueue = pushFetchPool();
604
+ if (poolQueue) await poolQueue;
605
+ try {
606
+ var res = await fetchHook(url, fetchOpts);
607
+ }
608
+ catch (e) {
609
+ e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
610
+ throw e;
611
+ }
612
+ finally {
613
+ popFetchPool();
614
+ }
615
+ if (!res.ok)
616
+ throw Error(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
617
+ return res;
618
+ }
619
+
620
+ async function fetchModule (url, fetchOpts, parent) {
621
+ const res = await doFetch(url, fetchOpts, parent);
622
+ const contentType = res.headers.get('content-type');
623
+ if (jsContentType.test(contentType))
624
+ return { r: res.url, s: await res.text(), t: 'js' };
625
+ else if (jsonContentType.test(contentType))
626
+ return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
627
+ else if (cssContentType.test(contentType)) {
628
+ return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
629
+ JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
630
+ });export default s;`, t: 'css' };
631
+ }
632
+ else
633
+ throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
634
+ }
635
+
636
+ function getOrCreateLoad (url, fetchOpts, parent, source) {
637
+ let load = registry[url];
638
+ if (load && !source)
639
+ return load;
640
+
641
+ load = {
642
+ // url
643
+ u: url,
644
+ // response url
645
+ r: source ? url : undefined,
646
+ // fetchPromise
647
+ f: undefined,
648
+ // source
649
+ S: undefined,
650
+ // linkPromise
651
+ L: undefined,
652
+ // analysis
653
+ a: undefined,
654
+ // deps
655
+ d: undefined,
656
+ // blobUrl
657
+ b: undefined,
658
+ // shellUrl
659
+ s: undefined,
660
+ // needsShim
661
+ n: false,
662
+ // type
663
+ t: null,
664
+ // meta
665
+ m: null
666
+ };
667
+ if (registry[url]) {
668
+ let i = 0;
669
+ while (registry[load.u + ++i]);
670
+ load.u += i;
671
+ }
672
+ registry[load.u] = load;
673
+
674
+ load.f = (async () => {
675
+ if (!source) {
676
+ // preload fetch options override fetch options (race)
677
+ let t;
678
+ ({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
679
+ if (t && !shimMode) {
680
+ if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
681
+ throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
682
+ if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
683
+ load.n = true;
684
+ }
685
+ }
686
+ try {
687
+ load.a = parse(source, load.u);
688
+ }
689
+ catch (e) {
690
+ throwError(e);
691
+ load.a = [[], [], false];
692
+ }
693
+ load.S = source;
694
+ return load;
695
+ })();
696
+
697
+ load.L = load.f.then(async () => {
698
+ let childFetchOpts = fetchOpts;
699
+ load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
700
+ if (d >= 0 && !supportsDynamicImport || d === 2 && !supportsImportMeta)
701
+ load.n = true;
702
+ if (!n) return;
703
+ const { r, b } = await resolve(n, load.r || load.u);
704
+ if (b && (!supportsImportMaps || importMapSrcOrLazy))
705
+ load.n = true;
706
+ if (d !== -1) return;
707
+ if (skip && skip.test(r)) return { b: r };
708
+ if (childFetchOpts.integrity)
709
+ childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
710
+ return getOrCreateLoad(r, childFetchOpts, load.r).f;
711
+ }))).filter(l => l);
712
+ });
713
+
714
+ return load;
715
+ }
716
+
717
+ function processScriptsAndPreloads () {
718
+ for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
719
+ processScript(script);
720
+ for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
721
+ processPreload(link);
722
+ }
723
+
724
+ function processImportMaps () {
725
+ for (const script of document.querySelectorAll(shimMode ? 'script[type="importmap-shim"]' : 'script[type="importmap"]'))
726
+ processImportMap(script);
727
+ }
728
+
729
+ function getFetchOpts (script) {
730
+ const fetchOpts = {};
731
+ if (script.integrity)
732
+ fetchOpts.integrity = script.integrity;
733
+ if (script.referrerpolicy)
734
+ fetchOpts.referrerPolicy = script.referrerpolicy;
735
+ if (script.crossorigin === 'use-credentials')
736
+ fetchOpts.credentials = 'include';
737
+ else if (script.crossorigin === 'anonymous')
738
+ fetchOpts.credentials = 'omit';
739
+ else
740
+ fetchOpts.credentials = 'same-origin';
741
+ return fetchOpts;
742
+ }
743
+
744
+ let lastStaticLoadPromise = Promise.resolve();
745
+
746
+ let domContentLoadedCnt = 1;
747
+ function domContentLoadedCheck () {
748
+ if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers)
749
+ document.dispatchEvent(new Event('DOMContentLoaded'));
750
+ }
751
+ // this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
752
+ document.addEventListener('DOMContentLoaded', async () => {
753
+ await initPromise;
754
+ domContentLoadedCheck();
755
+ if (shimMode || !baselinePassthrough) {
756
+ processImportMaps();
757
+ processScriptsAndPreloads();
758
+ }
759
+ });
760
+
761
+ let readyStateCompleteCnt = 1;
762
+ if (document.readyState === 'complete') {
763
+ readyStateCompleteCheck();
764
+ }
765
+ else {
766
+ document.addEventListener('readystatechange', async () => {
767
+ processImportMaps();
768
+ await initPromise;
769
+ readyStateCompleteCheck();
770
+ });
771
+ }
772
+ function readyStateCompleteCheck () {
773
+ if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
774
+ document.dispatchEvent(new Event('readystatechange'));
775
+ }
776
+
777
+ function processImportMap (script) {
778
+ if (script.ep) // ep marker = script processed
779
+ return;
780
+ // empty inline scripts sometimes show before domready
781
+ if (!script.src && !script.innerHTML)
782
+ return;
783
+ script.ep = true;
784
+ // we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
785
+ if (script.src) {
786
+ if (!shimMode)
787
+ return;
788
+ importMapSrcOrLazy = true;
789
+ }
790
+ if (acceptingImportMaps) {
791
+ importMapPromise = importMapPromise
792
+ .then(async () => {
793
+ importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
794
+ })
795
+ .catch(throwError);
796
+ if (!shimMode)
797
+ acceptingImportMaps = false;
798
+ }
799
+ }
800
+
801
+ function processScript (script) {
802
+ if (script.ep) // ep marker = script processed
803
+ return;
804
+ if (script.getAttribute('noshim') !== null)
805
+ return;
806
+ // empty inline scripts sometimes show before domready
807
+ if (!script.src && !script.innerHTML)
808
+ return;
809
+ script.ep = true;
810
+ // does this load block readystate complete
811
+ const isReadyScript = readyStateCompleteCnt > 0;
812
+ // does this load block DOMContentLoaded
813
+ const isDomContentLoadedScript = domContentLoadedCnt > 0;
814
+ if (isReadyScript) readyStateCompleteCnt++;
815
+ if (isDomContentLoadedScript) domContentLoadedCnt++;
816
+ const blocks = script.getAttribute('async') === null && isReadyScript;
817
+ const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, blocks && lastStaticLoadPromise).catch(throwError);
818
+ if (blocks)
819
+ lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
820
+ if (isDomContentLoadedScript)
821
+ loadPromise.then(domContentLoadedCheck);
822
+ }
823
+
824
+ const fetchCache = {};
825
+ function processPreload (link) {
826
+ if (link.ep) // ep marker = processed
827
+ return;
828
+ link.ep = true;
829
+ if (fetchCache[link.href])
830
+ return;
831
+ fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
832
+ }
833
+
834
+ }());