es-module-shims.js 45 KB

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