importmap-rails 1.2.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -96
- data/app/helpers/importmap/importmap_tags_helper.rb +3 -20
- data/lib/importmap/commands.rb +16 -22
- data/lib/importmap/engine.rb +0 -1
- data/lib/importmap/map.rb +4 -4
- data/lib/importmap/npm.rb +2 -2
- data/lib/importmap/reloader.rb +3 -0
- data/lib/importmap/version.rb +1 -1
- data/lib/importmap-rails.rb +1 -1
- data/lib/install/config/importmap.rb +1 -1
- data/lib/tasks/importmap_tasks.rake +1 -1
- metadata +17 -7
- data/app/assets/javascripts/es-module-shims.js +0 -947
- data/app/assets/javascripts/es-module-shims.js.map +0 -1
- data/app/assets/javascripts/es-module-shims.min.js +0 -3
- data/lib/shim.js +0 -1
@@ -1,947 +0,0 @@
|
|
1
|
-
/* ES Module Shims 1.7.3 */
|
2
|
-
(function () {
|
3
|
-
|
4
|
-
const hasWindow = typeof window !== 'undefined';
|
5
|
-
const hasDocument = typeof document !== 'undefined';
|
6
|
-
|
7
|
-
const noop = () => {};
|
8
|
-
|
9
|
-
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
10
|
-
|
11
|
-
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
12
|
-
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
13
|
-
|
14
|
-
let shimMode = hasDocument ? !!esmsInitOptions.shimMode : true;
|
15
|
-
|
16
|
-
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
17
|
-
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
18
|
-
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
19
|
-
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
20
|
-
|
21
|
-
const mapOverrides = esmsInitOptions.mapOverrides;
|
22
|
-
|
23
|
-
let nonce = esmsInitOptions.nonce;
|
24
|
-
if (!nonce && hasDocument) {
|
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) : () => {
|
32
|
-
console.log('%c^^ Module TypeError above is polyfilled and can be ignored ^^', 'font-weight:900;color:#391');
|
33
|
-
};
|
34
|
-
|
35
|
-
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
36
|
-
|
37
|
-
function globalHook (name) {
|
38
|
-
return typeof name === 'string' ? self[name] : name;
|
39
|
-
}
|
40
|
-
|
41
|
-
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
42
|
-
const cssModulesEnabled = enable.includes('css-modules');
|
43
|
-
const jsonModulesEnabled = enable.includes('json-modules');
|
44
|
-
|
45
|
-
const edge = !navigator.userAgentData && !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
|
46
|
-
|
47
|
-
const baseUrl = hasDocument
|
48
|
-
? document.baseURI
|
49
|
-
: `${location.protocol}//${location.host}${location.pathname.includes('/')
|
50
|
-
? location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
51
|
-
: location.pathname}`;
|
52
|
-
|
53
|
-
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
54
|
-
let { skip } = esmsInitOptions;
|
55
|
-
if (Array.isArray(skip)) {
|
56
|
-
const l = skip.map(s => new URL(s, baseUrl).href);
|
57
|
-
skip = s => l.some(i => i[i.length - 1] === '/' && s.startsWith(i) || s === i);
|
58
|
-
}
|
59
|
-
else if (typeof skip === 'string') {
|
60
|
-
const r = new RegExp(skip);
|
61
|
-
skip = s => r.test(s);
|
62
|
-
}
|
63
|
-
|
64
|
-
const eoop = err => setTimeout(() => { throw err });
|
65
|
-
|
66
|
-
const throwError = err => { (self.reportError || hasWindow && window.safari && console.error || eoop)(err), void onerror(err); };
|
67
|
-
|
68
|
-
function fromParent (parent) {
|
69
|
-
return parent ? ` imported from ${parent}` : '';
|
70
|
-
}
|
71
|
-
|
72
|
-
let importMapSrcOrLazy = false;
|
73
|
-
|
74
|
-
function setImportMapSrcOrLazy () {
|
75
|
-
importMapSrcOrLazy = true;
|
76
|
-
}
|
77
|
-
|
78
|
-
// shim mode is determined on initialization, no late shim mode
|
79
|
-
if (!shimMode) {
|
80
|
-
if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
|
81
|
-
shimMode = true;
|
82
|
-
}
|
83
|
-
else {
|
84
|
-
let seenScript = false;
|
85
|
-
for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
|
86
|
-
if (!seenScript) {
|
87
|
-
if (script.type === 'module' && !script.ep)
|
88
|
-
seenScript = true;
|
89
|
-
}
|
90
|
-
else if (script.type === 'importmap' && seenScript) {
|
91
|
-
importMapSrcOrLazy = true;
|
92
|
-
break;
|
93
|
-
}
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
const backslashRegEx = /\\/g;
|
99
|
-
|
100
|
-
function isURL (url) {
|
101
|
-
if (url.indexOf(':') === -1) return false;
|
102
|
-
try {
|
103
|
-
new URL(url);
|
104
|
-
return true;
|
105
|
-
}
|
106
|
-
catch (_) {
|
107
|
-
return false;
|
108
|
-
}
|
109
|
-
}
|
110
|
-
|
111
|
-
function resolveUrl (relUrl, parentUrl) {
|
112
|
-
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
113
|
-
}
|
114
|
-
|
115
|
-
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
116
|
-
const hIdx = parentUrl.indexOf('#'), qIdx = parentUrl.indexOf('?');
|
117
|
-
if (hIdx + qIdx > -2)
|
118
|
-
parentUrl = parentUrl.slice(0, hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx);
|
119
|
-
if (relUrl.indexOf('\\') !== -1)
|
120
|
-
relUrl = relUrl.replace(backslashRegEx, '/');
|
121
|
-
// protocol-relative
|
122
|
-
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
123
|
-
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
124
|
-
}
|
125
|
-
// relative-url
|
126
|
-
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
|
127
|
-
relUrl.length === 1 && (relUrl += '/')) ||
|
128
|
-
relUrl[0] === '/') {
|
129
|
-
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
130
|
-
// Disabled, but these cases will give inconsistent results for deep backtracking
|
131
|
-
//if (parentUrl[parentProtocol.length] !== '/')
|
132
|
-
// throw new Error('Cannot resolve');
|
133
|
-
// read pathname from parent URL
|
134
|
-
// pathname taken to be part after leading "/"
|
135
|
-
let pathname;
|
136
|
-
if (parentUrl[parentProtocol.length + 1] === '/') {
|
137
|
-
// resolving to a :// so we need to read out the auth and host
|
138
|
-
if (parentProtocol !== 'file:') {
|
139
|
-
pathname = parentUrl.slice(parentProtocol.length + 2);
|
140
|
-
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
141
|
-
}
|
142
|
-
else {
|
143
|
-
pathname = parentUrl.slice(8);
|
144
|
-
}
|
145
|
-
}
|
146
|
-
else {
|
147
|
-
// resolving to :/ so pathname is the /... part
|
148
|
-
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
149
|
-
}
|
150
|
-
|
151
|
-
if (relUrl[0] === '/')
|
152
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
153
|
-
|
154
|
-
// join together and split for removal of .. and . segments
|
155
|
-
// looping the string instead of anything fancy for perf reasons
|
156
|
-
// '../../../../../z' resolved to 'x/y' is just 'z'
|
157
|
-
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
158
|
-
|
159
|
-
const output = [];
|
160
|
-
let segmentIndex = -1;
|
161
|
-
for (let i = 0; i < segmented.length; i++) {
|
162
|
-
// busy reading a segment - only terminate on '/'
|
163
|
-
if (segmentIndex !== -1) {
|
164
|
-
if (segmented[i] === '/') {
|
165
|
-
output.push(segmented.slice(segmentIndex, i + 1));
|
166
|
-
segmentIndex = -1;
|
167
|
-
}
|
168
|
-
continue;
|
169
|
-
}
|
170
|
-
// new segment - check if it is relative
|
171
|
-
else if (segmented[i] === '.') {
|
172
|
-
// ../ segment
|
173
|
-
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
174
|
-
output.pop();
|
175
|
-
i += 2;
|
176
|
-
continue;
|
177
|
-
}
|
178
|
-
// ./ segment
|
179
|
-
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
180
|
-
i += 1;
|
181
|
-
continue;
|
182
|
-
}
|
183
|
-
}
|
184
|
-
// it is the start of a new segment
|
185
|
-
while (segmented[i] === '/') i++;
|
186
|
-
segmentIndex = i;
|
187
|
-
}
|
188
|
-
// finish reading out the last segment
|
189
|
-
if (segmentIndex !== -1)
|
190
|
-
output.push(segmented.slice(segmentIndex));
|
191
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
192
|
-
}
|
193
|
-
}
|
194
|
-
|
195
|
-
function resolveAndComposeImportMap (json, baseUrl, parentMap) {
|
196
|
-
const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
|
197
|
-
|
198
|
-
if (json.imports)
|
199
|
-
resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
200
|
-
|
201
|
-
if (json.scopes)
|
202
|
-
for (let s in json.scopes) {
|
203
|
-
const resolvedScope = resolveUrl(s, baseUrl);
|
204
|
-
resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
|
205
|
-
}
|
206
|
-
|
207
|
-
return outMap;
|
208
|
-
}
|
209
|
-
|
210
|
-
function getMatch (path, matchObj) {
|
211
|
-
if (matchObj[path])
|
212
|
-
return path;
|
213
|
-
let sepIndex = path.length;
|
214
|
-
do {
|
215
|
-
const segment = path.slice(0, sepIndex + 1);
|
216
|
-
if (segment in matchObj)
|
217
|
-
return segment;
|
218
|
-
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
|
219
|
-
}
|
220
|
-
|
221
|
-
function applyPackages (id, packages) {
|
222
|
-
const pkgName = getMatch(id, packages);
|
223
|
-
if (pkgName) {
|
224
|
-
const pkg = packages[pkgName];
|
225
|
-
if (pkg === null) return;
|
226
|
-
return pkg + id.slice(pkgName.length);
|
227
|
-
}
|
228
|
-
}
|
229
|
-
|
230
|
-
|
231
|
-
function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
|
232
|
-
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
233
|
-
while (scopeUrl) {
|
234
|
-
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
235
|
-
if (packageResolution)
|
236
|
-
return packageResolution;
|
237
|
-
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
238
|
-
}
|
239
|
-
return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
|
240
|
-
}
|
241
|
-
|
242
|
-
function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
|
243
|
-
for (let p in packages) {
|
244
|
-
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
245
|
-
if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
|
246
|
-
throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
|
247
|
-
}
|
248
|
-
let target = packages[p];
|
249
|
-
if (typeof target !== 'string')
|
250
|
-
continue;
|
251
|
-
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
252
|
-
if (mapped) {
|
253
|
-
outPackages[resolvedLhs] = mapped;
|
254
|
-
continue;
|
255
|
-
}
|
256
|
-
console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
257
|
-
}
|
258
|
-
}
|
259
|
-
|
260
|
-
let dynamicImport = !hasDocument && (0, eval)('u=>import(u)');
|
261
|
-
|
262
|
-
let supportsDynamicImport;
|
263
|
-
|
264
|
-
const dynamicImportCheck = hasDocument && new Promise(resolve => {
|
265
|
-
const s = Object.assign(document.createElement('script'), {
|
266
|
-
src: createBlob('self._d=u=>import(u)'),
|
267
|
-
ep: true
|
268
|
-
});
|
269
|
-
s.setAttribute('nonce', nonce);
|
270
|
-
s.addEventListener('load', () => {
|
271
|
-
if (!(supportsDynamicImport = !!(dynamicImport = self._d))) {
|
272
|
-
let err;
|
273
|
-
window.addEventListener('error', _err => err = _err);
|
274
|
-
dynamicImport = (url, opts) => new Promise((resolve, reject) => {
|
275
|
-
const s = Object.assign(document.createElement('script'), {
|
276
|
-
type: 'module',
|
277
|
-
src: createBlob(`import*as m from'${url}';self._esmsi=m`)
|
278
|
-
});
|
279
|
-
err = undefined;
|
280
|
-
s.ep = true;
|
281
|
-
if (nonce)
|
282
|
-
s.setAttribute('nonce', nonce);
|
283
|
-
// Safari is unique in supporting module script error events
|
284
|
-
s.addEventListener('error', cb);
|
285
|
-
s.addEventListener('load', cb);
|
286
|
-
function cb (_err) {
|
287
|
-
document.head.removeChild(s);
|
288
|
-
if (self._esmsi) {
|
289
|
-
resolve(self._esmsi, baseUrl);
|
290
|
-
self._esmsi = undefined;
|
291
|
-
}
|
292
|
-
else {
|
293
|
-
reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading ${opts && opts.errUrl || url} (${s.src}).`));
|
294
|
-
err = undefined;
|
295
|
-
}
|
296
|
-
}
|
297
|
-
document.head.appendChild(s);
|
298
|
-
});
|
299
|
-
}
|
300
|
-
document.head.removeChild(s);
|
301
|
-
delete self._d;
|
302
|
-
resolve();
|
303
|
-
});
|
304
|
-
document.head.appendChild(s);
|
305
|
-
});
|
306
|
-
|
307
|
-
// support browsers without dynamic import support (eg Firefox 6x)
|
308
|
-
let supportsJsonAssertions = false;
|
309
|
-
let supportsCssAssertions = false;
|
310
|
-
|
311
|
-
const supports = hasDocument && HTMLScriptElement.supports;
|
312
|
-
|
313
|
-
let supportsImportMaps = supports && supports.name === 'supports' && supports('importmap');
|
314
|
-
let supportsImportMeta = supportsDynamicImport;
|
315
|
-
|
316
|
-
const importMetaCheck = 'import.meta';
|
317
|
-
const cssModulesCheck = `import"x"assert{type:"css"}`;
|
318
|
-
const jsonModulesCheck = `import"x"assert{type:"json"}`;
|
319
|
-
|
320
|
-
let featureDetectionPromise = Promise.resolve(dynamicImportCheck).then(() => {
|
321
|
-
if (!supportsDynamicImport)
|
322
|
-
return;
|
323
|
-
|
324
|
-
if (!hasDocument)
|
325
|
-
return Promise.all([
|
326
|
-
supportsImportMaps || dynamicImport(createBlob(importMetaCheck)).then(() => supportsImportMeta = true, noop),
|
327
|
-
cssModulesEnabled && dynamicImport(createBlob(cssModulesCheck.replace('x', createBlob('', 'text/css')))).then(() => supportsCssAssertions = true, noop),
|
328
|
-
jsonModulesEnabled && dynamicImport(createBlob(jsonModulescheck.replace('x', createBlob('{}', 'text/json')))).then(() => supportsJsonAssertions = true, noop),
|
329
|
-
]);
|
330
|
-
|
331
|
-
return new Promise(resolve => {
|
332
|
-
const iframe = document.createElement('iframe');
|
333
|
-
iframe.style.display = 'none';
|
334
|
-
iframe.setAttribute('nonce', nonce);
|
335
|
-
function cb ({ data }) {
|
336
|
-
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
337
|
-
if (!isFeatureDetectionMessage) {
|
338
|
-
return;
|
339
|
-
}
|
340
|
-
supportsImportMaps = data[1];
|
341
|
-
supportsImportMeta = data[2];
|
342
|
-
supportsCssAssertions = data[3];
|
343
|
-
supportsJsonAssertions = data[4];
|
344
|
-
resolve();
|
345
|
-
document.head.removeChild(iframe);
|
346
|
-
window.removeEventListener('message', cb, false);
|
347
|
-
}
|
348
|
-
window.addEventListener('message', cb, false);
|
349
|
-
|
350
|
-
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
351
|
-
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
352
|
-
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
353
|
-
|
354
|
-
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
355
|
-
// path to trigger before setting srcdoc, therefore we track the timing
|
356
|
-
let readyForOnload = false, onloadCalledWhileNotReady = false;
|
357
|
-
function doOnload () {
|
358
|
-
if (!readyForOnload) {
|
359
|
-
onloadCalledWhileNotReady = true;
|
360
|
-
return;
|
361
|
-
}
|
362
|
-
// WeChat browser doesn't support setting srcdoc scripts
|
363
|
-
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
364
|
-
const doc = iframe.contentDocument;
|
365
|
-
if (doc && doc.head.childNodes.length === 0) {
|
366
|
-
const s = doc.createElement('script');
|
367
|
-
if (nonce)
|
368
|
-
s.setAttribute('nonce', nonce);
|
369
|
-
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
370
|
-
doc.head.appendChild(s);
|
371
|
-
}
|
372
|
-
}
|
373
|
-
|
374
|
-
iframe.onload = doOnload;
|
375
|
-
// WeChat browser requires append before setting srcdoc
|
376
|
-
document.head.appendChild(iframe);
|
377
|
-
|
378
|
-
// setting srcdoc is not supported in React native webviews on iOS
|
379
|
-
// setting src to a blob URL results in a navigation event in webviews
|
380
|
-
// document.write gives usability warnings
|
381
|
-
readyForOnload = true;
|
382
|
-
if ('srcdoc' in iframe)
|
383
|
-
iframe.srcdoc = importMapTest;
|
384
|
-
else
|
385
|
-
iframe.contentDocument.write(importMapTest);
|
386
|
-
// retrigger onload for Safari only if necessary
|
387
|
-
if (onloadCalledWhileNotReady) doOnload();
|
388
|
-
});
|
389
|
-
});
|
390
|
-
|
391
|
-
/* es-module-lexer 1.2.1 */
|
392
|
-
let e,a,r,i=2<<19;const s=1===new Uint8Array(new Uint16Array([1]).buffer)[0]?function(e,a){const r=e.length;let i=0;for(;i<r;)a[i]=e.charCodeAt(i++);}:function(e,a){const r=e.length;let i=0;for(;i<r;){const r=e.charCodeAt(i);a[i++]=(255&r)<<8|r>>>8;}},t="xportmportlassetaromsyncunctionssertvoyiedelecontininstantybreareturdebuggeawaithrwhileforifcatcfinallels";let c$1,f,n;function parse(l,k="@"){c$1=l,f=k;const u=2*c$1.length+(2<<18);if(u>i||!e){for(;u>i;)i*=2;a=new ArrayBuffer(i),s(t,new Uint16Array(a,16,105)),e=function(e,a,r){"use asm";var i=new e.Int8Array(r),s=new e.Int16Array(r),t=new e.Int32Array(r),c=new e.Uint8Array(r),f=new e.Uint16Array(r),n=1024;function b(){var e=0,a=0,r=0,c=0,b=0,u=0,w=0;w=n;n=n+10240|0;i[795]=1;s[395]=0;s[396]=0;t[67]=t[2];i[796]=0;t[66]=0;i[794]=0;t[68]=w+2048;t[69]=w;i[797]=0;e=(t[3]|0)+-2|0;t[70]=e;a=e+(t[64]<<1)|0;t[71]=a;e:while(1){r=e+2|0;t[70]=r;if(e>>>0>=a>>>0){b=18;break}a:do{switch(s[r>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if((((s[396]|0)==0?H(r)|0:0)?(m(e+4|0,16,10)|0)==0:0)?(l(),(i[795]|0)==0):0){b=9;break e}else b=17;break}case 105:{if(H(r)|0?(m(e+4|0,26,10)|0)==0:0){k();b=17;}else b=17;break}case 59:{b=17;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{b=16;break e}}default:{b=16;break e}}}while(0);if((b|0)==17){b=0;t[67]=t[70];}e=t[70]|0;a=t[71]|0;}if((b|0)==9){e=t[70]|0;t[67]=e;b=19;}else if((b|0)==16){i[795]=0;t[70]=e;b=19;}else if((b|0)==18)if(!(i[794]|0)){e=r;b=19;}else e=0;do{if((b|0)==19){e:while(1){a=e+2|0;t[70]=a;c=a;if(e>>>0>=(t[71]|0)>>>0){b=82;break}a:do{switch(s[a>>1]|0){case 9:case 10:case 11:case 12:case 13:case 32:break;case 101:{if(((s[396]|0)==0?H(a)|0:0)?(m(e+4|0,16,10)|0)==0:0){l();b=81;}else b=81;break}case 105:{if(H(a)|0?(m(e+4|0,26,10)|0)==0:0){k();b=81;}else b=81;break}case 99:{if((H(a)|0?(m(e+4|0,36,8)|0)==0:0)?V(s[e+12>>1]|0)|0:0){i[797]=1;b=81;}else b=81;break}case 40:{c=t[68]|0;a=s[396]|0;b=a&65535;t[c+(b<<3)>>2]=1;r=t[67]|0;s[396]=a+1<<16>>16;t[c+(b<<3)+4>>2]=r;b=81;break}case 41:{a=s[396]|0;if(!(a<<16>>16)){b=36;break e}a=a+-1<<16>>16;s[396]=a;r=s[395]|0;if(r<<16>>16!=0?(u=t[(t[69]|0)+((r&65535)+-1<<2)>>2]|0,(t[u+20>>2]|0)==(t[(t[68]|0)+((a&65535)<<3)+4>>2]|0)):0){a=u+4|0;if(!(t[a>>2]|0))t[a>>2]=c;t[u+12>>2]=e+4;s[395]=r+-1<<16>>16;b=81;}else b=81;break}case 123:{b=t[67]|0;c=t[61]|0;e=b;do{if((s[b>>1]|0)==41&(c|0)!=0?(t[c+4>>2]|0)==(b|0):0){a=t[62]|0;t[61]=a;if(!a){t[57]=0;break}else {t[a+28>>2]=0;break}}}while(0);c=t[68]|0;r=s[396]|0;b=r&65535;t[c+(b<<3)>>2]=(i[797]|0)==0?2:6;s[396]=r+1<<16>>16;t[c+(b<<3)+4>>2]=e;i[797]=0;b=81;break}case 125:{e=s[396]|0;if(!(e<<16>>16)){b=49;break e}c=t[68]|0;b=e+-1<<16>>16;s[396]=b;if((t[c+((b&65535)<<3)>>2]|0)==4){h();b=81;}else b=81;break}case 39:{d(39);b=81;break}case 34:{d(34);b=81;break}case 47:switch(s[e+4>>1]|0){case 47:{P();break a}case 42:{y(1);break a}default:{e=t[67]|0;c=s[e>>1]|0;r:do{if(!(U(c)|0)){switch(c<<16>>16){case 41:if(D(t[(t[68]|0)+(f[396]<<3)+4>>2]|0)|0){b=69;break r}else {b=66;break r}case 125:break;default:{b=66;break r}}a=t[68]|0;r=f[396]|0;if(!(p(t[a+(r<<3)+4>>2]|0)|0)?(t[a+(r<<3)>>2]|0)!=6:0)b=66;else b=69;}else switch(c<<16>>16){case 46:if(((s[e+-2>>1]|0)+-48&65535)<10){b=66;break r}else {b=69;break r}case 43:if((s[e+-2>>1]|0)==43){b=66;break r}else {b=69;break r}case 45:if((s[e+-2>>1]|0)==45){b=66;break r}else {b=69;break r}default:{b=69;break r}}}while(0);r:do{if((b|0)==66){b=0;if(!(o(e)|0)){switch(c<<16>>16){case 0:{b=69;break r}case 47:{if(i[796]|0){b=69;break r}break}default:{}}r=t[3]|0;a=c;do{if(e>>>0<=r>>>0)break;e=e+-2|0;t[67]=e;a=s[e>>1]|0;}while(!(E(a)|0));if(F(a)|0){do{if(e>>>0<=r>>>0)break;e=e+-2|0;t[67]=e;}while(F(s[e>>1]|0)|0);if(j(e)|0){g();i[796]=0;b=81;break a}else e=1;}else e=1;}else b=69;}}while(0);if((b|0)==69){g();e=0;}i[796]=e;b=81;break a}}case 96:{c=t[68]|0;r=s[396]|0;b=r&65535;t[c+(b<<3)+4>>2]=t[67];s[396]=r+1<<16>>16;t[c+(b<<3)>>2]=3;h();b=81;break}default:b=81;}}while(0);if((b|0)==81){b=0;t[67]=t[70];}e=t[70]|0;}if((b|0)==36){T();e=0;break}else if((b|0)==49){T();e=0;break}else if((b|0)==82){e=(i[794]|0)==0?(s[395]|s[396])<<16>>16==0:0;break}}}while(0);n=w;return e|0}function l(){var e=0,a=0,r=0,c=0,f=0,n=0,b=0,l=0,k=0,o=0,h=0,A=0,C=0,g=0;l=t[70]|0;k=t[63]|0;g=l+12|0;t[70]=g;r=w(1)|0;e=t[70]|0;if(!((e|0)==(g|0)?!(I(r)|0):0))C=3;e:do{if((C|0)==3){a:do{switch(r<<16>>16){case 123:{t[70]=e+2;e=w(1)|0;r=t[70]|0;while(1){if(W(e)|0){d(e);e=(t[70]|0)+2|0;t[70]=e;}else {q(e)|0;e=t[70]|0;}w(1)|0;e=v(r,e)|0;if(e<<16>>16==44){t[70]=(t[70]|0)+2;e=w(1)|0;}a=r;r=t[70]|0;if(e<<16>>16==125){C=15;break}if((r|0)==(a|0)){C=12;break}if(r>>>0>(t[71]|0)>>>0){C=14;break}}if((C|0)==12){T();break e}else if((C|0)==14){T();break e}else if((C|0)==15){t[70]=r+2;break a}break}case 42:{t[70]=e+2;w(1)|0;g=t[70]|0;v(g,g)|0;break}default:{i[795]=0;switch(r<<16>>16){case 100:{l=e+14|0;t[70]=l;switch((w(1)|0)<<16>>16){case 97:{a=t[70]|0;if((m(a+2|0,56,8)|0)==0?(f=a+10|0,F(s[f>>1]|0)|0):0){t[70]=f;w(0)|0;C=22;}break}case 102:{C=22;break}case 99:{a=t[70]|0;if(((m(a+2|0,36,8)|0)==0?(c=a+10|0,g=s[c>>1]|0,V(g)|0|g<<16>>16==123):0)?(t[70]=c,n=w(1)|0,n<<16>>16!=123):0){A=n;C=31;}break}default:{}}r:do{if((C|0)==22?(b=t[70]|0,(m(b+2|0,64,14)|0)==0):0){r=b+16|0;a=s[r>>1]|0;if(!(V(a)|0))switch(a<<16>>16){case 40:case 42:break;default:break r}t[70]=r;a=w(1)|0;if(a<<16>>16==42){t[70]=(t[70]|0)+2;a=w(1)|0;}if(a<<16>>16!=40){A=a;C=31;}}}while(0);if((C|0)==31?(o=t[70]|0,q(A)|0,h=t[70]|0,h>>>0>o>>>0):0){$(e,l,o,h);t[70]=(t[70]|0)+-2;break e}$(e,l,0,0);t[70]=e+12;break e}case 97:{t[70]=e+10;w(0)|0;e=t[70]|0;C=35;break}case 102:{C=35;break}case 99:{if((m(e+2|0,36,8)|0)==0?(a=e+10|0,E(s[a>>1]|0)|0):0){t[70]=a;g=w(1)|0;C=t[70]|0;q(g)|0;g=t[70]|0;$(C,g,C,g);t[70]=(t[70]|0)+-2;break e}e=e+4|0;t[70]=e;break}case 108:case 118:break;default:break e}if((C|0)==35){t[70]=e+16;e=w(1)|0;if(e<<16>>16==42){t[70]=(t[70]|0)+2;e=w(1)|0;}C=t[70]|0;q(e)|0;g=t[70]|0;$(C,g,C,g);t[70]=(t[70]|0)+-2;break e}e=e+4|0;t[70]=e;i[795]=0;r:while(1){t[70]=e+2;g=w(1)|0;e=t[70]|0;switch((q(g)|0)<<16>>16){case 91:case 123:break r;default:{}}a=t[70]|0;if((a|0)==(e|0))break e;$(e,a,e,a);if((w(1)|0)<<16>>16!=44)break;e=t[70]|0;}t[70]=(t[70]|0)+-2;break e}}}while(0);g=(w(1)|0)<<16>>16==102;e=t[70]|0;if(g?(m(e+2|0,50,6)|0)==0:0){t[70]=e+8;u(l,w(1)|0);e=(k|0)==0?232:k+16|0;while(1){e=t[e>>2]|0;if(!e)break e;t[e+12>>2]=0;t[e+8>>2]=0;e=e+16|0;}}t[70]=e+-2;}}while(0);return}function k(){var e=0,a=0,r=0,c=0,f=0,n=0;f=t[70]|0;e=f+12|0;t[70]=e;e:do{switch((w(1)|0)<<16>>16){case 40:{a=t[68]|0;n=s[396]|0;r=n&65535;t[a+(r<<3)>>2]=5;e=t[70]|0;s[396]=n+1<<16>>16;t[a+(r<<3)+4>>2]=e;if((s[t[67]>>1]|0)!=46){t[70]=e+2;n=w(1)|0;A(f,t[70]|0,0,e);a=t[61]|0;r=t[69]|0;f=s[395]|0;s[395]=f+1<<16>>16;t[r+((f&65535)<<2)>>2]=a;switch(n<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{t[70]=(t[70]|0)+-2;break e}}e=(t[70]|0)+2|0;t[70]=e;switch((w(1)|0)<<16>>16){case 44:{t[70]=(t[70]|0)+2;w(1)|0;f=t[61]|0;t[f+4>>2]=e;n=t[70]|0;t[f+16>>2]=n;i[f+24>>0]=1;t[70]=n+-2;break e}case 41:{s[396]=(s[396]|0)+-1<<16>>16;n=t[61]|0;t[n+4>>2]=e;t[n+12>>2]=(t[70]|0)+2;i[n+24>>0]=1;s[395]=(s[395]|0)+-1<<16>>16;break e}default:{t[70]=(t[70]|0)+-2;break e}}}break}case 46:{t[70]=(t[70]|0)+2;if((w(1)|0)<<16>>16==109?(a=t[70]|0,(m(a+2|0,44,6)|0)==0):0){e=t[67]|0;if(!(G(e)|0)?(s[e>>1]|0)==46:0)break e;A(f,f,a+8|0,2);}break}case 42:case 39:case 34:{c=18;break}case 123:{e=t[70]|0;if(s[396]|0){t[70]=e+-2;break e}while(1){if(e>>>0>=(t[71]|0)>>>0)break;e=w(1)|0;if(!(W(e)|0)){if(e<<16>>16==125){c=33;break}}else d(e);e=(t[70]|0)+2|0;t[70]=e;}if((c|0)==33)t[70]=(t[70]|0)+2;n=(w(1)|0)<<16>>16==102;e=t[70]|0;if(n?m(e+2|0,50,6)|0:0){T();break e}t[70]=e+8;e=w(1)|0;if(W(e)|0){u(f,e);break e}else {T();break e}}default:if((t[70]|0)==(e|0))t[70]=f+10;else c=18;}}while(0);do{if((c|0)==18){if(s[396]|0){t[70]=(t[70]|0)+-2;break}e=t[71]|0;a=t[70]|0;while(1){if(a>>>0>=e>>>0){c=25;break}r=s[a>>1]|0;if(W(r)|0){c=23;break}n=a+2|0;t[70]=n;a=n;}if((c|0)==23){u(f,r);break}else if((c|0)==25){T();break}}}while(0);return}function u(e,a){e=e|0;a=a|0;var r=0,i=0;r=(t[70]|0)+2|0;switch(a<<16>>16){case 39:{d(39);i=5;break}case 34:{d(34);i=5;break}default:T();}do{if((i|0)==5){A(e,r,t[70]|0,1);t[70]=(t[70]|0)+2;a=w(0)|0;e=a<<16>>16==97;if(e){r=t[70]|0;if(m(r+2|0,78,10)|0)i=11;}else {r=t[70]|0;if(!(((a<<16>>16==119?(s[r+2>>1]|0)==105:0)?(s[r+4>>1]|0)==116:0)?(s[r+6>>1]|0)==104:0))i=11;}if((i|0)==11){t[70]=r+-2;break}t[70]=r+((e?6:4)<<1);if((w(1)|0)<<16>>16!=123){t[70]=r;break}e=t[70]|0;a=e;e:while(1){t[70]=a+2;a=w(1)|0;switch(a<<16>>16){case 39:{d(39);t[70]=(t[70]|0)+2;a=w(1)|0;break}case 34:{d(34);t[70]=(t[70]|0)+2;a=w(1)|0;break}default:a=q(a)|0;}if(a<<16>>16!=58){i=20;break}t[70]=(t[70]|0)+2;switch((w(1)|0)<<16>>16){case 39:{d(39);break}case 34:{d(34);break}default:{i=24;break e}}t[70]=(t[70]|0)+2;switch((w(1)|0)<<16>>16){case 125:{i=29;break e}case 44:break;default:{i=28;break e}}t[70]=(t[70]|0)+2;if((w(1)|0)<<16>>16==125){i=29;break}a=t[70]|0;}if((i|0)==20){t[70]=r;break}else if((i|0)==24){t[70]=r;break}else if((i|0)==28){t[70]=r;break}else if((i|0)==29){i=t[61]|0;t[i+16>>2]=e;t[i+12>>2]=(t[70]|0)+2;break}}}while(0);return}function o(e){e=e|0;e:do{switch(s[e>>1]|0){case 100:switch(s[e+-2>>1]|0){case 105:{e=O(e+-4|0,88,2)|0;break e}case 108:{e=O(e+-4|0,92,3)|0;break e}default:{e=0;break e}}case 101:switch(s[e+-2>>1]|0){case 115:switch(s[e+-4>>1]|0){case 108:{e=B(e+-6|0,101)|0;break e}case 97:{e=B(e+-6|0,99)|0;break e}default:{e=0;break e}}case 116:{e=O(e+-4|0,98,4)|0;break e}case 117:{e=O(e+-4|0,106,6)|0;break e}default:{e=0;break e}}case 102:{if((s[e+-2>>1]|0)==111?(s[e+-4>>1]|0)==101:0)switch(s[e+-6>>1]|0){case 99:{e=O(e+-8|0,118,6)|0;break e}case 112:{e=O(e+-8|0,130,2)|0;break e}default:{e=0;break e}}else e=0;break}case 107:{e=O(e+-2|0,134,4)|0;break}case 110:{e=e+-2|0;if(B(e,105)|0)e=1;else e=O(e,142,5)|0;break}case 111:{e=B(e+-2|0,100)|0;break}case 114:{e=O(e+-2|0,152,7)|0;break}case 116:{e=O(e+-2|0,166,4)|0;break}case 119:switch(s[e+-2>>1]|0){case 101:{e=B(e+-4|0,110)|0;break e}case 111:{e=O(e+-4|0,174,3)|0;break e}default:{e=0;break e}}default:e=0;}}while(0);return e|0}function h(){var e=0,a=0,r=0,i=0;a=t[71]|0;r=t[70]|0;e:while(1){e=r+2|0;if(r>>>0>=a>>>0){a=10;break}switch(s[e>>1]|0){case 96:{a=7;break e}case 36:{if((s[r+4>>1]|0)==123){a=6;break e}break}case 92:{e=r+4|0;break}default:{}}r=e;}if((a|0)==6){e=r+4|0;t[70]=e;a=t[68]|0;i=s[396]|0;r=i&65535;t[a+(r<<3)>>2]=4;s[396]=i+1<<16>>16;t[a+(r<<3)+4>>2]=e;}else if((a|0)==7){t[70]=e;r=t[68]|0;i=(s[396]|0)+-1<<16>>16;s[396]=i;if((t[r+((i&65535)<<3)>>2]|0)!=3)T();}else if((a|0)==10){t[70]=e;T();}return}function w(e){e=e|0;var a=0,r=0,i=0;r=t[70]|0;e:do{a=s[r>>1]|0;a:do{if(a<<16>>16!=47)if(e)if(V(a)|0)break;else break e;else if(F(a)|0)break;else break e;else switch(s[r+2>>1]|0){case 47:{P();break a}case 42:{y(e);break a}default:{a=47;break e}}}while(0);i=t[70]|0;r=i+2|0;t[70]=r;}while(i>>>0<(t[71]|0)>>>0);return a|0}function d(e){e=e|0;var a=0,r=0,i=0,c=0;c=t[71]|0;a=t[70]|0;while(1){i=a+2|0;if(a>>>0>=c>>>0){a=9;break}r=s[i>>1]|0;if(r<<16>>16==e<<16>>16){a=10;break}if(r<<16>>16==92){r=a+4|0;if((s[r>>1]|0)==13){a=a+6|0;a=(s[a>>1]|0)==10?a:r;}else a=r;}else if(Z(r)|0){a=9;break}else a=i;}if((a|0)==9){t[70]=i;T();}else if((a|0)==10)t[70]=i;return}function v(e,a){e=e|0;a=a|0;var r=0,i=0,c=0,f=0;r=t[70]|0;i=s[r>>1]|0;f=(e|0)==(a|0);c=f?0:e;f=f?0:a;if(i<<16>>16==97){t[70]=r+4;r=w(1)|0;e=t[70]|0;if(W(r)|0){d(r);a=(t[70]|0)+2|0;t[70]=a;}else {q(r)|0;a=t[70]|0;}i=w(1)|0;r=t[70]|0;}if((r|0)!=(e|0))$(e,a,c,f);return i|0}function A(e,a,r,s){e=e|0;a=a|0;r=r|0;s=s|0;var c=0,f=0;c=t[65]|0;t[65]=c+32;f=t[61]|0;t[((f|0)==0?228:f+28|0)>>2]=c;t[62]=f;t[61]=c;t[c+8>>2]=e;if(2==(s|0))e=r;else e=1==(s|0)?r+2|0:0;t[c+12>>2]=e;t[c>>2]=a;t[c+4>>2]=r;t[c+16>>2]=0;t[c+20>>2]=s;i[c+24>>0]=1==(s|0)&1;t[c+28>>2]=0;return}function C(){var e=0,a=0,r=0;r=t[71]|0;a=t[70]|0;e:while(1){e=a+2|0;if(a>>>0>=r>>>0){a=6;break}switch(s[e>>1]|0){case 13:case 10:{a=6;break e}case 93:{a=7;break e}case 92:{e=a+4|0;break}default:{}}a=e;}if((a|0)==6){t[70]=e;T();e=0;}else if((a|0)==7){t[70]=e;e=93;}return e|0}function g(){var e=0,a=0,r=0;e:while(1){e=t[70]|0;a=e+2|0;t[70]=a;if(e>>>0>=(t[71]|0)>>>0){r=7;break}switch(s[a>>1]|0){case 13:case 10:{r=7;break e}case 47:break e;case 91:{C()|0;break}case 92:{t[70]=e+4;break}default:{}}}if((r|0)==7)T();return}function p(e){e=e|0;switch(s[e>>1]|0){case 62:{e=(s[e+-2>>1]|0)==61;break}case 41:case 59:{e=1;break}case 104:{e=O(e+-2|0,200,4)|0;break}case 121:{e=O(e+-2|0,208,6)|0;break}case 101:{e=O(e+-2|0,220,3)|0;break}default:e=0;}return e|0}function y(e){e=e|0;var a=0,r=0,i=0,c=0,f=0;c=(t[70]|0)+2|0;t[70]=c;r=t[71]|0;while(1){a=c+2|0;if(c>>>0>=r>>>0)break;i=s[a>>1]|0;if(!e?Z(i)|0:0)break;if(i<<16>>16==42?(s[c+4>>1]|0)==47:0){f=8;break}c=a;}if((f|0)==8){t[70]=a;a=c+4|0;}t[70]=a;return}function m(e,a,r){e=e|0;a=a|0;r=r|0;var s=0,t=0;e:do{if(!r)e=0;else {while(1){s=i[e>>0]|0;t=i[a>>0]|0;if(s<<24>>24!=t<<24>>24)break;r=r+-1|0;if(!r){e=0;break e}else {e=e+1|0;a=a+1|0;}}e=(s&255)-(t&255)|0;}}while(0);return e|0}function I(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:{e=1;break}default:if((e&-8)<<16>>16==40|(e+-58&65535)<6)e=1;else {switch(e<<16>>16){case 91:case 93:case 94:{e=1;break e}default:{}}e=(e+-123&65535)<4;}}}while(0);return e|0}function U(e){e=e|0;e:do{switch(e<<16>>16){case 38:case 37:case 33:break;default:if(!((e+-58&65535)<6|(e+-40&65535)<7&e<<16>>16!=41)){switch(e<<16>>16){case 91:case 94:break e;default:{}}return e<<16>>16!=125&(e+-123&65535)<4|0}}}while(0);return 1}function x(e){e=e|0;var a=0;a=s[e>>1]|0;e:do{if((a+-9&65535)>=5){switch(a<<16>>16){case 160:case 32:{a=1;break e}default:{}}if(I(a)|0)return a<<16>>16!=46|(G(e)|0)|0;else a=0;}else a=1;}while(0);return a|0}function S(e){e=e|0;var a=0,r=0,i=0,c=0;r=n;n=n+16|0;i=r;t[i>>2]=0;t[64]=e;a=t[3]|0;c=a+(e<<1)|0;e=c+2|0;s[c>>1]=0;t[i>>2]=e;t[65]=e;t[57]=0;t[61]=0;t[59]=0;t[58]=0;t[63]=0;t[60]=0;n=r;return a|0}function O(e,a,r){e=e|0;a=a|0;r=r|0;var i=0,s=0;i=e+(0-r<<1)|0;s=i+2|0;e=t[3]|0;if(s>>>0>=e>>>0?(m(s,a,r<<1)|0)==0:0)if((s|0)==(e|0))e=1;else e=x(i)|0;else e=0;return e|0}function $(e,a,r,i){e=e|0;a=a|0;r=r|0;i=i|0;var s=0,c=0;s=t[65]|0;t[65]=s+20;c=t[63]|0;t[((c|0)==0?232:c+16|0)>>2]=s;t[63]=s;t[s>>2]=e;t[s+4>>2]=a;t[s+8>>2]=r;t[s+12>>2]=i;t[s+16>>2]=0;return}function j(e){e=e|0;switch(s[e>>1]|0){case 107:{e=O(e+-2|0,134,4)|0;break}case 101:{if((s[e+-2>>1]|0)==117)e=O(e+-4|0,106,6)|0;else e=0;break}default:e=0;}return e|0}function B(e,a){e=e|0;a=a|0;var r=0;r=t[3]|0;if(r>>>0<=e>>>0?(s[e>>1]|0)==a<<16>>16:0)if((r|0)==(e|0))r=1;else r=E(s[e+-2>>1]|0)|0;else r=0;return r|0}function E(e){e=e|0;e:do{if((e+-9&65535)<5)e=1;else {switch(e<<16>>16){case 32:case 160:{e=1;break e}default:{}}e=e<<16>>16!=46&(I(e)|0);}}while(0);return e|0}function P(){var e=0,a=0,r=0;e=t[71]|0;r=t[70]|0;e:while(1){a=r+2|0;if(r>>>0>=e>>>0)break;switch(s[a>>1]|0){case 13:case 10:break e;default:r=a;}}t[70]=a;return}function q(e){e=e|0;while(1){if(V(e)|0)break;if(I(e)|0)break;e=(t[70]|0)+2|0;t[70]=e;e=s[e>>1]|0;if(!(e<<16>>16)){e=0;break}}return e|0}function z(){var e=0;e=t[(t[59]|0)+20>>2]|0;switch(e|0){case 1:{e=-1;break}case 2:{e=-2;break}default:e=e-(t[3]|0)>>1;}return e|0}function D(e){e=e|0;if(!(O(e,180,5)|0)?!(O(e,190,3)|0):0)e=O(e,196,2)|0;else e=1;return e|0}function F(e){e=e|0;switch(e<<16>>16){case 160:case 32:case 12:case 11:case 9:{e=1;break}default:e=0;}return e|0}function G(e){e=e|0;if((s[e>>1]|0)==46?(s[e+-2>>1]|0)==46:0)e=(s[e+-4>>1]|0)==46;else e=0;return e|0}function H(e){e=e|0;if((t[3]|0)==(e|0))e=1;else e=x(e+-2|0)|0;return e|0}function J(){var e=0;e=t[(t[60]|0)+12>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function K(){var e=0;e=t[(t[59]|0)+12>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function L(){var e=0;e=t[(t[60]|0)+8>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function M(){var e=0;e=t[(t[59]|0)+16>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function N(){var e=0;e=t[(t[59]|0)+4>>2]|0;if(!e)e=-1;else e=e-(t[3]|0)>>1;return e|0}function Q(){var e=0;e=t[59]|0;e=t[((e|0)==0?228:e+28|0)>>2]|0;t[59]=e;return (e|0)!=0|0}function R(){var e=0;e=t[60]|0;e=t[((e|0)==0?232:e+16|0)>>2]|0;t[60]=e;return (e|0)!=0|0}function T(){i[794]=1;t[66]=(t[70]|0)-(t[3]|0)>>1;t[70]=(t[71]|0)+2;return}function V(e){e=e|0;return (e|128)<<16>>16==160|(e+-9&65535)<5|0}function W(e){e=e|0;return e<<16>>16==39|e<<16>>16==34|0}function X(){return (t[(t[59]|0)+8>>2]|0)-(t[3]|0)>>1|0}function Y(){return (t[(t[60]|0)+4>>2]|0)-(t[3]|0)>>1|0}function Z(e){e=e|0;return e<<16>>16==13|e<<16>>16==10|0}function _(){return (t[t[59]>>2]|0)-(t[3]|0)>>1|0}function ee(){return (t[t[60]>>2]|0)-(t[3]|0)>>1|0}function ae(){return c[(t[59]|0)+24>>0]|0|0}function re(e){e=e|0;t[3]=e;return}function ie(){return (i[795]|0)!=0|0}function se(){return t[66]|0}function te(e){e=e|0;n=e+992+15&-16;return 992}return {su:te,ai:M,e:se,ee:Y,ele:J,els:L,es:ee,f:ie,id:z,ie:N,ip:ae,is:_,p:b,re:R,ri:Q,sa:S,se:K,ses:re,ss:X}}("undefined"!=typeof self?self:global,{},a),r=e.su(i-(2<<17));}const h=c$1.length+1;e.ses(r),e.sa(h-1),s(c$1,new Uint16Array(a,r,h)),e.p()||(n=e.e(),o());const w=[],d=[];for(;e.ri();){const a=e.is(),r=e.ie(),i=e.ai(),s=e.id(),t=e.ss(),f=e.se();let n;e.ip()&&(n=b(-1===s?a:a+1,c$1.charCodeAt(-1===s?a-1:a))),w.push({n:n,s:a,e:r,ss:t,se:f,d:s,a:i});}for(;e.re();){const a=e.es(),r=e.ee(),i=e.els(),s=e.ele(),t=c$1.charCodeAt(a),f=i>=0?c$1.charCodeAt(i):-1;d.push({s:a,e:r,ls:i,le:s,n:34===t||39===t?b(a+1,t):c$1.slice(a,r),ln:i<0?void 0:34===f||39===f?b(i+1,f):c$1.slice(i,s)});}return [w,d,!!e.f()]}function b(e,a){n=e;let r="",i=n;for(;;){n>=c$1.length&&o();const e=c$1.charCodeAt(n);if(e===a)break;92===e?(r+=c$1.slice(i,n),r+=l(),i=n):(8232===e||8233===e||u(e)&&o(),++n);}return r+=c$1.slice(i,n++),r}function l(){let e=c$1.charCodeAt(++n);switch(++n,e){case 110:return "\n";case 114:return "\r";case 120:return String.fromCharCode(k(2));case 117:return function(){const e=c$1.charCodeAt(n);let a;123===e?(++n,a=k(c$1.indexOf("}",n)-n),++n,a>1114111&&o()):a=k(4);return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode(55296+(a>>10),56320+(1023&a)))}();case 116:return "\t";case 98:return "\b";case 118:return "\v";case 102:return "\f";case 13:10===c$1.charCodeAt(n)&&++n;case 10:return "";case 56:case 57:o();default:if(e>=48&&e<=55){let a=c$1.substr(n-1,3).match(/^[0-7]+/)[0],r=parseInt(a,8);return r>255&&(a=a.slice(0,-1),r=parseInt(a,8)),n+=a.length-1,e=c$1.charCodeAt(n),"0"===a&&56!==e&&57!==e||o(),String.fromCharCode(r)}return u(e)?"":String.fromCharCode(e)}}function k(e){const a=n;let r=0,i=0;for(let a=0;a<e;++a,++n){let e,s=c$1.charCodeAt(n);if(95!==s){if(s>=97)e=s-97+10;else if(s>=65)e=s-65+10;else {if(!(s>=48&&s<=57))break;e=s-48;}if(e>=16)break;i=s,r=16*r+e;}else 95!==i&&0!==a||o(),i=s;}return 95!==i&&n-a===e||o(),r}function u(e){return 13===e||10===e}function o(){throw Object.assign(Error(`Parse error ${f}:${c$1.slice(0,n).split("\n").length}:${n-c$1.lastIndexOf("\n",n-1)}`),{idx:n})}
|
393
|
-
|
394
|
-
async function _resolve (id, parentUrl) {
|
395
|
-
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
|
396
|
-
return {
|
397
|
-
r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl),
|
398
|
-
// b = bare specifier
|
399
|
-
b: !urlResolved && !isURL(id)
|
400
|
-
};
|
401
|
-
}
|
402
|
-
|
403
|
-
const resolve = resolveHook ? async (id, parentUrl) => {
|
404
|
-
let result = resolveHook(id, parentUrl, defaultResolve);
|
405
|
-
// will be deprecated in next major
|
406
|
-
if (result && result.then)
|
407
|
-
result = await result;
|
408
|
-
return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !isURL(id) } : _resolve(id, parentUrl);
|
409
|
-
} : _resolve;
|
410
|
-
|
411
|
-
// importShim('mod');
|
412
|
-
// importShim('mod', { opts });
|
413
|
-
// importShim('mod', { opts }, parentUrl);
|
414
|
-
// importShim('mod', parentUrl);
|
415
|
-
async function importShim (id, ...args) {
|
416
|
-
// parentUrl if present will be the last argument
|
417
|
-
let parentUrl = args[args.length - 1];
|
418
|
-
if (typeof parentUrl !== 'string')
|
419
|
-
parentUrl = baseUrl;
|
420
|
-
// needed for shim check
|
421
|
-
await initPromise;
|
422
|
-
if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
|
423
|
-
if (acceptingImportMaps || shimMode || !baselinePassthrough) {
|
424
|
-
if (hasDocument)
|
425
|
-
processScriptsAndPreloads(true);
|
426
|
-
if (!shimMode)
|
427
|
-
acceptingImportMaps = false;
|
428
|
-
}
|
429
|
-
await importMapPromise;
|
430
|
-
return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' });
|
431
|
-
}
|
432
|
-
|
433
|
-
self.importShim = importShim;
|
434
|
-
|
435
|
-
function defaultResolve (id, parentUrl) {
|
436
|
-
return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
|
437
|
-
}
|
438
|
-
|
439
|
-
function throwUnresolved (id, parentUrl) {
|
440
|
-
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
441
|
-
}
|
442
|
-
|
443
|
-
const resolveSync = (id, parentUrl = baseUrl) => {
|
444
|
-
parentUrl = `${parentUrl}`;
|
445
|
-
const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
|
446
|
-
return result && !result.then ? result : defaultResolve(id, parentUrl);
|
447
|
-
};
|
448
|
-
|
449
|
-
function metaResolve (id, parentUrl = this.url) {
|
450
|
-
return resolveSync(id, parentUrl);
|
451
|
-
}
|
452
|
-
|
453
|
-
importShim.resolve = resolveSync;
|
454
|
-
importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
|
455
|
-
importShim.addImportMap = importMapIn => {
|
456
|
-
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
457
|
-
importMap = resolveAndComposeImportMap(importMapIn, baseUrl, importMap);
|
458
|
-
};
|
459
|
-
|
460
|
-
const registry = importShim._r = {};
|
461
|
-
|
462
|
-
async function loadAll (load, seen) {
|
463
|
-
if (load.b || seen[load.u])
|
464
|
-
return;
|
465
|
-
seen[load.u] = 1;
|
466
|
-
await load.L;
|
467
|
-
await Promise.all(load.d.map(dep => loadAll(dep, seen)));
|
468
|
-
if (!load.n)
|
469
|
-
load.n = load.d.some(dep => dep.n);
|
470
|
-
}
|
471
|
-
|
472
|
-
let importMap = { imports: {}, scopes: {} };
|
473
|
-
let baselinePassthrough;
|
474
|
-
|
475
|
-
const initPromise = featureDetectionPromise.then(() => {
|
476
|
-
baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy;
|
477
|
-
if (hasDocument) {
|
478
|
-
if (!supportsImportMaps) {
|
479
|
-
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
480
|
-
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
481
|
-
}
|
482
|
-
if (shimMode || !baselinePassthrough) {
|
483
|
-
new MutationObserver(mutations => {
|
484
|
-
for (const mutation of mutations) {
|
485
|
-
if (mutation.type !== 'childList') continue;
|
486
|
-
for (const node of mutation.addedNodes) {
|
487
|
-
if (node.tagName === 'SCRIPT') {
|
488
|
-
if (node.type === (shimMode ? 'module-shim' : 'module'))
|
489
|
-
processScript(node, true);
|
490
|
-
if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
|
491
|
-
processImportMap(node, true);
|
492
|
-
}
|
493
|
-
else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload')) {
|
494
|
-
processPreload(node);
|
495
|
-
}
|
496
|
-
}
|
497
|
-
}
|
498
|
-
}).observe(document, {childList: true, subtree: true});
|
499
|
-
processScriptsAndPreloads();
|
500
|
-
if (document.readyState === 'complete') {
|
501
|
-
readyStateCompleteCheck();
|
502
|
-
}
|
503
|
-
else {
|
504
|
-
async function readyListener() {
|
505
|
-
await initPromise;
|
506
|
-
processScriptsAndPreloads();
|
507
|
-
if (document.readyState === 'complete') {
|
508
|
-
readyStateCompleteCheck();
|
509
|
-
document.removeEventListener('readystatechange', readyListener);
|
510
|
-
}
|
511
|
-
}
|
512
|
-
document.addEventListener('readystatechange', readyListener);
|
513
|
-
}
|
514
|
-
}
|
515
|
-
}
|
516
|
-
return undefined;
|
517
|
-
});
|
518
|
-
let importMapPromise = initPromise;
|
519
|
-
let firstPolyfillLoad = true;
|
520
|
-
let acceptingImportMaps = true;
|
521
|
-
|
522
|
-
async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
|
523
|
-
if (!shimMode)
|
524
|
-
acceptingImportMaps = false;
|
525
|
-
await initPromise;
|
526
|
-
await importMapPromise;
|
527
|
-
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
|
528
|
-
// early analysis opt-out - no need to even fetch if we have feature support
|
529
|
-
if (!shimMode && baselinePassthrough) {
|
530
|
-
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
531
|
-
if (nativelyLoaded)
|
532
|
-
return null;
|
533
|
-
await lastStaticLoadPromise;
|
534
|
-
return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
|
535
|
-
}
|
536
|
-
const load = getOrCreateLoad(url, fetchOpts, null, source);
|
537
|
-
const seen = {};
|
538
|
-
await loadAll(load, seen);
|
539
|
-
lastLoad = undefined;
|
540
|
-
resolveDeps(load, seen);
|
541
|
-
await lastStaticLoadPromise;
|
542
|
-
if (source && !shimMode && !load.n) {
|
543
|
-
if (nativelyLoaded) return;
|
544
|
-
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
545
|
-
return await dynamicImport(createBlob(source), { errUrl: source });
|
546
|
-
}
|
547
|
-
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
548
|
-
onpolyfill();
|
549
|
-
firstPolyfillLoad = false;
|
550
|
-
}
|
551
|
-
const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
|
552
|
-
// if the top-level load is a shell, run its update function
|
553
|
-
if (load.s)
|
554
|
-
(await dynamicImport(load.s)).u$_(module);
|
555
|
-
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
556
|
-
// when tla is supported, this should return the tla promise as an actual handle
|
557
|
-
// so readystate can still correspond to the sync subgraph exec completions
|
558
|
-
return module;
|
559
|
-
}
|
560
|
-
|
561
|
-
function revokeObjectURLs(registryKeys) {
|
562
|
-
let batch = 0;
|
563
|
-
const keysLength = registryKeys.length;
|
564
|
-
const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
|
565
|
-
schedule(cleanup);
|
566
|
-
function cleanup() {
|
567
|
-
const batchStartIndex = batch * 100;
|
568
|
-
if (batchStartIndex > keysLength) return
|
569
|
-
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
|
570
|
-
const load = registry[key];
|
571
|
-
if (load) URL.revokeObjectURL(load.b);
|
572
|
-
}
|
573
|
-
batch++;
|
574
|
-
schedule(cleanup);
|
575
|
-
}
|
576
|
-
}
|
577
|
-
|
578
|
-
function urlJsString (url) {
|
579
|
-
return `'${url.replace(/'/g, "\\'")}'`;
|
580
|
-
}
|
581
|
-
|
582
|
-
let lastLoad;
|
583
|
-
function resolveDeps (load, seen) {
|
584
|
-
if (load.b || !seen[load.u])
|
585
|
-
return;
|
586
|
-
seen[load.u] = 0;
|
587
|
-
|
588
|
-
for (const dep of load.d)
|
589
|
-
resolveDeps(dep, seen);
|
590
|
-
|
591
|
-
const [imports, exports] = load.a;
|
592
|
-
|
593
|
-
// "execution"
|
594
|
-
const source = load.S;
|
595
|
-
|
596
|
-
// edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
|
597
|
-
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
598
|
-
|
599
|
-
// once all deps have loaded we can inline the dependency resolution blobs
|
600
|
-
// and define this blob
|
601
|
-
let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
|
602
|
-
function pushStringTo (originalIndex) {
|
603
|
-
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
604
|
-
const dynamicImportEnd = dynamicImportEndStack.pop();
|
605
|
-
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
606
|
-
lastIndex = dynamicImportEnd;
|
607
|
-
}
|
608
|
-
resolvedSource += source.slice(lastIndex, originalIndex);
|
609
|
-
lastIndex = originalIndex;
|
610
|
-
}
|
611
|
-
|
612
|
-
for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
|
613
|
-
// dependency source replacements
|
614
|
-
if (dynamicImportIndex === -1) {
|
615
|
-
let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
|
616
|
-
if (cycleShell) {
|
617
|
-
// circular shell creation
|
618
|
-
if (!(blobUrl = depLoad.s)) {
|
619
|
-
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
620
|
-
depLoad.a[1].map(({ s, e }, i) => {
|
621
|
-
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
622
|
-
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
623
|
-
}).join(',')
|
624
|
-
}}${
|
625
|
-
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
626
|
-
}export {${
|
627
|
-
depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
|
628
|
-
}}\n//# sourceURL=${depLoad.r}?cycle`);
|
629
|
-
}
|
630
|
-
}
|
631
|
-
|
632
|
-
pushStringTo(start - 1);
|
633
|
-
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
|
634
|
-
|
635
|
-
// circular shell execution
|
636
|
-
if (!cycleShell && depLoad.s) {
|
637
|
-
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
638
|
-
depLoad.s = undefined;
|
639
|
-
}
|
640
|
-
lastIndex = statementEnd;
|
641
|
-
}
|
642
|
-
// import.meta
|
643
|
-
else if (dynamicImportIndex === -2) {
|
644
|
-
load.m = { url: load.r, resolve: metaResolve };
|
645
|
-
metaHook(load.m, load.u);
|
646
|
-
pushStringTo(start);
|
647
|
-
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
648
|
-
lastIndex = statementEnd;
|
649
|
-
}
|
650
|
-
// dynamic import
|
651
|
-
else {
|
652
|
-
pushStringTo(statementStart + 6);
|
653
|
-
resolvedSource += `Shim(`;
|
654
|
-
dynamicImportEndStack.push(statementEnd - 1);
|
655
|
-
lastIndex = start;
|
656
|
-
}
|
657
|
-
}
|
658
|
-
|
659
|
-
// support progressive cycle binding updates (try statement avoids tdz errors)
|
660
|
-
if (load.s)
|
661
|
-
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports.filter(e => e.ln).map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`).join(',')}})}catch(_){};\n`;
|
662
|
-
|
663
|
-
function pushSourceURL (commentPrefix, commentStart) {
|
664
|
-
const urlStart = commentStart + commentPrefix.length;
|
665
|
-
const commentEnd = source.indexOf('\n', urlStart);
|
666
|
-
const urlEnd = commentEnd !== -1 ? commentEnd : source.length;
|
667
|
-
pushStringTo(urlStart);
|
668
|
-
resolvedSource += new URL(source.slice(urlStart, urlEnd), load.r).href;
|
669
|
-
lastIndex = urlEnd;
|
670
|
-
}
|
671
|
-
|
672
|
-
let sourceURLCommentStart = source.lastIndexOf(sourceURLCommentPrefix);
|
673
|
-
let sourceMapURLCommentStart = source.lastIndexOf(sourceMapURLCommentPrefix);
|
674
|
-
|
675
|
-
// ignore sourceMap comments before already spliced code
|
676
|
-
if (sourceURLCommentStart < lastIndex) sourceURLCommentStart = -1;
|
677
|
-
if (sourceMapURLCommentStart < lastIndex) sourceMapURLCommentStart = -1;
|
678
|
-
|
679
|
-
// sourceURL first / only
|
680
|
-
if (sourceURLCommentStart !== -1 && (sourceMapURLCommentStart === -1 || sourceMapURLCommentStart > sourceURLCommentStart)) {
|
681
|
-
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
682
|
-
}
|
683
|
-
// sourceMappingURL
|
684
|
-
if (sourceMapURLCommentStart !== -1) {
|
685
|
-
pushSourceURL(sourceMapURLCommentPrefix, sourceMapURLCommentStart);
|
686
|
-
// sourceURL last
|
687
|
-
if (sourceURLCommentStart !== -1 && (sourceURLCommentStart > sourceMapURLCommentStart))
|
688
|
-
pushSourceURL(sourceURLCommentPrefix, sourceURLCommentStart);
|
689
|
-
}
|
690
|
-
|
691
|
-
pushStringTo(source.length);
|
692
|
-
|
693
|
-
if (sourceURLCommentStart === -1)
|
694
|
-
resolvedSource += sourceURLCommentPrefix + load.r;
|
695
|
-
|
696
|
-
load.b = lastLoad = createBlob(resolvedSource);
|
697
|
-
load.S = undefined;
|
698
|
-
}
|
699
|
-
|
700
|
-
const sourceURLCommentPrefix = '\n//# sourceURL=';
|
701
|
-
const sourceMapURLCommentPrefix = '\n//# sourceMappingURL=';
|
702
|
-
|
703
|
-
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
704
|
-
const jsonContentType = /^(text|application)\/json(;|$)/;
|
705
|
-
const cssContentType = /^(text|application)\/css(;|$)/;
|
706
|
-
|
707
|
-
const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
|
708
|
-
|
709
|
-
// restrict in-flight fetches to a pool of 100
|
710
|
-
let p = [];
|
711
|
-
let c = 0;
|
712
|
-
function pushFetchPool () {
|
713
|
-
if (++c > 100)
|
714
|
-
return new Promise(r => p.push(r));
|
715
|
-
}
|
716
|
-
function popFetchPool () {
|
717
|
-
c--;
|
718
|
-
if (p.length)
|
719
|
-
p.shift()();
|
720
|
-
}
|
721
|
-
|
722
|
-
async function doFetch (url, fetchOpts, parent) {
|
723
|
-
if (enforceIntegrity && !fetchOpts.integrity)
|
724
|
-
throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
725
|
-
const poolQueue = pushFetchPool();
|
726
|
-
if (poolQueue) await poolQueue;
|
727
|
-
try {
|
728
|
-
var res = await fetchHook(url, fetchOpts);
|
729
|
-
}
|
730
|
-
catch (e) {
|
731
|
-
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
|
732
|
-
throw e;
|
733
|
-
}
|
734
|
-
finally {
|
735
|
-
popFetchPool();
|
736
|
-
}
|
737
|
-
if (!res.ok)
|
738
|
-
throw Error(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
|
739
|
-
return res;
|
740
|
-
}
|
741
|
-
|
742
|
-
async function fetchModule (url, fetchOpts, parent) {
|
743
|
-
const res = await doFetch(url, fetchOpts, parent);
|
744
|
-
const contentType = res.headers.get('content-type');
|
745
|
-
if (jsContentType.test(contentType))
|
746
|
-
return { r: res.url, s: await res.text(), t: 'js' };
|
747
|
-
else if (jsonContentType.test(contentType))
|
748
|
-
return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
|
749
|
-
else if (cssContentType.test(contentType)) {
|
750
|
-
return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
|
751
|
-
JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
|
752
|
-
});export default s;`, t: 'css' };
|
753
|
-
}
|
754
|
-
else
|
755
|
-
throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
|
756
|
-
}
|
757
|
-
|
758
|
-
function getOrCreateLoad (url, fetchOpts, parent, source) {
|
759
|
-
let load = registry[url];
|
760
|
-
if (load && !source)
|
761
|
-
return load;
|
762
|
-
|
763
|
-
load = {
|
764
|
-
// url
|
765
|
-
u: url,
|
766
|
-
// response url
|
767
|
-
r: source ? url : undefined,
|
768
|
-
// fetchPromise
|
769
|
-
f: undefined,
|
770
|
-
// source
|
771
|
-
S: undefined,
|
772
|
-
// linkPromise
|
773
|
-
L: undefined,
|
774
|
-
// analysis
|
775
|
-
a: undefined,
|
776
|
-
// deps
|
777
|
-
d: undefined,
|
778
|
-
// blobUrl
|
779
|
-
b: undefined,
|
780
|
-
// shellUrl
|
781
|
-
s: undefined,
|
782
|
-
// needsShim
|
783
|
-
n: false,
|
784
|
-
// type
|
785
|
-
t: null,
|
786
|
-
// meta
|
787
|
-
m: null
|
788
|
-
};
|
789
|
-
if (registry[url]) {
|
790
|
-
let i = 0;
|
791
|
-
while (registry[load.u + ++i]);
|
792
|
-
load.u += i;
|
793
|
-
}
|
794
|
-
registry[load.u] = load;
|
795
|
-
|
796
|
-
load.f = (async () => {
|
797
|
-
if (!source) {
|
798
|
-
// preload fetch options override fetch options (race)
|
799
|
-
let t;
|
800
|
-
({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
801
|
-
if (t && !shimMode) {
|
802
|
-
if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
|
803
|
-
throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
|
804
|
-
if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
|
805
|
-
load.n = true;
|
806
|
-
}
|
807
|
-
}
|
808
|
-
try {
|
809
|
-
load.a = parse(source, load.u);
|
810
|
-
}
|
811
|
-
catch (e) {
|
812
|
-
throwError(e);
|
813
|
-
load.a = [[], [], false];
|
814
|
-
}
|
815
|
-
load.S = source;
|
816
|
-
return load;
|
817
|
-
})();
|
818
|
-
|
819
|
-
load.L = load.f.then(async () => {
|
820
|
-
let childFetchOpts = fetchOpts;
|
821
|
-
load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
|
822
|
-
if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
|
823
|
-
load.n = true;
|
824
|
-
if (d !== -1 || !n) return;
|
825
|
-
const { r, b } = await resolve(n, load.r || load.u);
|
826
|
-
if (b && (!supportsImportMaps || importMapSrcOrLazy))
|
827
|
-
load.n = true;
|
828
|
-
if (d !== -1) return;
|
829
|
-
if (skip && skip(r)) return { b: r };
|
830
|
-
if (childFetchOpts.integrity)
|
831
|
-
childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
832
|
-
return getOrCreateLoad(r, childFetchOpts, load.r).f;
|
833
|
-
}))).filter(l => l);
|
834
|
-
});
|
835
|
-
|
836
|
-
return load;
|
837
|
-
}
|
838
|
-
|
839
|
-
function processScriptsAndPreloads (mapsOnly = false) {
|
840
|
-
if (!mapsOnly)
|
841
|
-
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
|
842
|
-
processPreload(link);
|
843
|
-
for (const script of document.querySelectorAll(shimMode ? 'script[type=importmap-shim]' : 'script[type=importmap]'))
|
844
|
-
processImportMap(script);
|
845
|
-
if (!mapsOnly)
|
846
|
-
for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
|
847
|
-
processScript(script);
|
848
|
-
}
|
849
|
-
|
850
|
-
function getFetchOpts (script) {
|
851
|
-
const fetchOpts = {};
|
852
|
-
if (script.integrity)
|
853
|
-
fetchOpts.integrity = script.integrity;
|
854
|
-
if (script.referrerPolicy)
|
855
|
-
fetchOpts.referrerPolicy = script.referrerPolicy;
|
856
|
-
if (script.crossOrigin === 'use-credentials')
|
857
|
-
fetchOpts.credentials = 'include';
|
858
|
-
else if (script.crossOrigin === 'anonymous')
|
859
|
-
fetchOpts.credentials = 'omit';
|
860
|
-
else
|
861
|
-
fetchOpts.credentials = 'same-origin';
|
862
|
-
return fetchOpts;
|
863
|
-
}
|
864
|
-
|
865
|
-
let lastStaticLoadPromise = Promise.resolve();
|
866
|
-
|
867
|
-
let domContentLoadedCnt = 1;
|
868
|
-
function domContentLoadedCheck () {
|
869
|
-
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
870
|
-
document.dispatchEvent(new Event('DOMContentLoaded'));
|
871
|
-
}
|
872
|
-
}
|
873
|
-
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
874
|
-
if (hasDocument) {
|
875
|
-
document.addEventListener('DOMContentLoaded', async () => {
|
876
|
-
await initPromise;
|
877
|
-
domContentLoadedCheck();
|
878
|
-
});
|
879
|
-
}
|
880
|
-
|
881
|
-
let readyStateCompleteCnt = 1;
|
882
|
-
function readyStateCompleteCheck () {
|
883
|
-
if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers && (shimMode || !baselinePassthrough)) {
|
884
|
-
document.dispatchEvent(new Event('readystatechange'));
|
885
|
-
}
|
886
|
-
}
|
887
|
-
|
888
|
-
const hasNext = script => script.nextSibling || script.parentNode && hasNext(script.parentNode);
|
889
|
-
const epCheck = (script, ready) => script.ep || !ready && (!script.src && !script.innerHTML || !hasNext(script)) || script.getAttribute('noshim') !== null || !(script.ep = true);
|
890
|
-
|
891
|
-
function processImportMap (script, ready = readyStateCompleteCnt > 0) {
|
892
|
-
if (epCheck(script, ready)) return;
|
893
|
-
// we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
|
894
|
-
if (script.src) {
|
895
|
-
if (!shimMode)
|
896
|
-
return;
|
897
|
-
setImportMapSrcOrLazy();
|
898
|
-
}
|
899
|
-
if (acceptingImportMaps) {
|
900
|
-
importMapPromise = importMapPromise
|
901
|
-
.then(async () => {
|
902
|
-
importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
|
903
|
-
})
|
904
|
-
.catch(e => {
|
905
|
-
console.log(e);
|
906
|
-
if (e instanceof SyntaxError)
|
907
|
-
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
908
|
-
throwError(e);
|
909
|
-
});
|
910
|
-
if (!shimMode)
|
911
|
-
acceptingImportMaps = false;
|
912
|
-
}
|
913
|
-
}
|
914
|
-
|
915
|
-
function processScript (script, ready = readyStateCompleteCnt > 0) {
|
916
|
-
if (epCheck(script, ready)) return;
|
917
|
-
// does this load block readystate complete
|
918
|
-
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
919
|
-
// does this load block DOMContentLoaded
|
920
|
-
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
921
|
-
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
922
|
-
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
923
|
-
const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isBlockingReadyScript && lastStaticLoadPromise)
|
924
|
-
.then(() => {
|
925
|
-
// if the type of the script tag "module-shim", browser does not dispatch a "load" event
|
926
|
-
// see https://github.com/guybedford/es-module-shims/issues/346
|
927
|
-
if (shimMode) {
|
928
|
-
script.dispatchEvent(new Event('load'));
|
929
|
-
}
|
930
|
-
})
|
931
|
-
.catch(throwError);
|
932
|
-
if (isBlockingReadyScript)
|
933
|
-
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
934
|
-
if (isDomContentLoadedScript)
|
935
|
-
loadPromise.then(domContentLoadedCheck);
|
936
|
-
}
|
937
|
-
|
938
|
-
const fetchCache = {};
|
939
|
-
function processPreload (link) {
|
940
|
-
if (link.ep) return;
|
941
|
-
link.ep = true;
|
942
|
-
if (fetchCache[link.href])
|
943
|
-
return;
|
944
|
-
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
945
|
-
}
|
946
|
-
|
947
|
-
})();
|