@lwrjs/loader 0.17.2-alpha.3 → 0.17.2-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +1 -0
  2. package/build/assets/prod/lwr-error-shim.js +1 -1
  3. package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +168 -46
  4. package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +4 -3
  5. package/build/assets/prod/lwr-loader-shim-legacy.js +58 -16
  6. package/build/assets/prod/lwr-loader-shim.bundle.js +180 -54
  7. package/build/assets/prod/lwr-loader-shim.bundle.min.js +4 -3
  8. package/build/assets/prod/lwr-loader-shim.js +58 -16
  9. package/build/cjs/modules/lwr/loader/constants/constants.cjs +8 -1
  10. package/build/cjs/modules/lwr/loader/moduleRegistry/importMetadataResolver.cjs +2 -2
  11. package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +49 -7
  12. package/build/cjs/modules/lwr/loaderLegacy/constants/constants.cjs +8 -1
  13. package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +50 -8
  14. package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
  15. package/build/modules/lwr/loader/constants/constants.d.ts +5 -0
  16. package/build/modules/lwr/loader/constants/constants.js +6 -0
  17. package/build/modules/lwr/loader/loader.d.ts +1 -0
  18. package/build/modules/lwr/loader/loader.js +122 -38
  19. package/build/modules/lwr/loader/moduleRegistry/importMetadataResolver.js +7 -7
  20. package/build/modules/lwr/loader/moduleRegistry/moduleRegistry.d.ts +4 -0
  21. package/build/modules/lwr/loader/moduleRegistry/moduleRegistry.js +66 -15
  22. package/build/modules/lwr/loaderLegacy/constants/constants.d.ts +5 -0
  23. package/build/modules/lwr/loaderLegacy/constants/constants.js +6 -0
  24. package/build/modules/lwr/loaderLegacy/loaderLegacy.d.ts +1 -0
  25. package/build/modules/lwr/loaderLegacy/loaderLegacy.js +110 -30
  26. package/build/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.d.ts +4 -0
  27. package/build/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.js +67 -16
  28. package/build/shim/shim.d.ts +2 -0
  29. package/build/shim/shim.js +45 -8
  30. package/build/shim-legacy/shimLegacy.d.ts +2 -0
  31. package/build/shim-legacy/shimLegacy.js +45 -8
  32. package/build/types.d.ts +1 -0
  33. package/package.json +8 -8
package/README.md CHANGED
@@ -329,6 +329,7 @@ globalThis.LWR: {
329
329
  // ...
330
330
  ],
331
331
  // (optional) modules being preloaded outside the LWR loader
332
+ // The LWR loader will not send requests to fetch preloadModules
332
333
  preloadModules: [
333
334
  'c/example/v/1',
334
335
  // ...
@@ -4,5 +4,5 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Error Shim v0.17.2-alpha.3 */
7
+ /* LWR Error Shim v0.17.2-alpha.31 */
8
8
  !function(){"use strict";const o=globalThis;if(!(o.LWR&&o.LWR.define)){const r=new Error("The LWR application failed to bootstrap");if(!o.LWR||!o.LWR.onError)throw r;o.LWR.onError(r)}}();
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Legacy Module Loader Shim v0.17.2-alpha.3 */
7
+ /* LWR Legacy Module Loader Shim v0.17.2-alpha.31 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -25,6 +25,7 @@
25
25
 
26
26
  // Check if the Performance API is available
27
27
  // e.g. JSDom (used in Jest) doesn't implement these
28
+ // eslint-disable-next-line
28
29
  const perf = globalThis.performance;
29
30
  const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
30
31
  function getMeasureName(id, specifier) {
@@ -57,7 +58,8 @@
57
58
  id,
58
59
  phase: Phase.Start,
59
60
  specifier,
60
- metadata
61
+ metadata,
62
+ specifierIndex
61
63
  });
62
64
  return;
63
65
  }
@@ -84,7 +86,8 @@
84
86
  id,
85
87
  phase: Phase.End,
86
88
  specifier,
87
- metadata
89
+ metadata,
90
+ specifierIndex
88
91
  });
89
92
  } else if (isPerfSupported) {
90
93
  const markName = getMarkName(id, specifier, specifierIndex);
@@ -178,13 +181,14 @@
178
181
  }
179
182
  }
180
183
 
181
- /* global document */
184
+ /* global document, process, console */
182
185
 
183
186
 
184
187
 
185
188
  /* eslint-disable lwr/no-unguarded-apis */
186
189
  const hasSetTimeout = typeof setTimeout === 'function';
187
190
  const hasConsole = typeof console !== 'undefined';
191
+ const hasProcess = typeof process !== 'undefined';
188
192
  /* eslint-enable lwr/no-unguarded-apis */
189
193
 
190
194
  class LoaderShim {
@@ -206,7 +210,7 @@
206
210
  // Parse configuration
207
211
  this.global = global;
208
212
  this.config = global.LWR ;
209
- this.loaderModule = 'lwr/loaderLegacy/v/0_17_2-alpha_3';
213
+ this.loaderModule = 'lwr/loaderLegacy/v/0_17_2-alpha_31';
210
214
 
211
215
  // Set up error handler
212
216
  this.errorHandler = this.config.onError ;
@@ -303,17 +307,40 @@
303
307
  this.config.preloadModules,
304
308
  );
305
309
  this.mountApp(loader);
310
+ if (
311
+ loader &&
312
+ typeof loader.getModuleWarnings === 'function' &&
313
+ hasProcess &&
314
+ hasConsole &&
315
+ // eslint-disable-next-line lwr/no-unguarded-apis
316
+ process.env.NODE_ENV !== 'production'
317
+ ) {
318
+ this.logWarnings(loader.getModuleWarnings(true)); // the true indicates the app is mounted
319
+ }
306
320
  } catch (e) {
307
321
  this.enterErrorState(e);
308
322
  }
309
323
  }
310
324
 
311
- waitForDOMContentLoaded() {
312
- // eslint-disable-next-line lwr/no-unguarded-apis
313
- if (typeof document === undefined) {
314
- return Promise.resolve();
315
- }
325
+ waitForBody() {
326
+ return new Promise((resolve) => {
327
+ // eslint-disable-next-line lwr/no-unguarded-apis
328
+ if (document.body) {
329
+ resolve();
330
+ } else {
331
+ const observer = new MutationObserver(() => {
332
+ // eslint-disable-next-line lwr/no-unguarded-apis
333
+ if (document.body) {
334
+ observer.disconnect();
335
+ resolve();
336
+ }
337
+ });
338
+ observer.observe(document.documentElement, { childList: true });
339
+ }
340
+ });
341
+ }
316
342
 
343
+ waitForDOMContentLoaded() {
317
344
  // Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
318
345
  // eslint-disable-next-line lwr/no-unguarded-apis
319
346
  if (document.readyState === 'interactive' || document.readyState === 'complete') {
@@ -333,7 +360,7 @@
333
360
  const exporter = (exports) => {
334
361
  Object.assign(exports, { logOperationStart, logOperationEnd });
335
362
  };
336
- define('lwr/profiler/v/0_17_2-alpha_3', ['exports'], exporter, {});
363
+ define('lwr/profiler/v/0_17_2-alpha_31', ['exports'], exporter, {});
337
364
  }
338
365
 
339
366
  // Set up the application globals, import map, root custom element...
@@ -359,16 +386,22 @@
359
386
  }
360
387
  });
361
388
 
362
- // by default, app initialization is gated on waiting for document to be parsed (via DOMContentLoaded)
363
- const { disableInitDefer } = this.config;
389
+ // by default, app initialization is gated on waiting for body to be available
390
+ // this flag uses the DOMContentLoaded event instead
391
+ const { initDeferDOM } = this.config;
364
392
 
365
393
  // Load the import mappings and application bootstrap module
366
394
  loader
367
395
  .registerImportMappings(importMappings)
368
396
  .then(() => {
369
- if (!disableInitDefer) {
397
+ // eslint-disable-next-line lwr/no-unguarded-apis
398
+ if (typeof window === 'undefined' || typeof document === undefined) {
399
+ return Promise.resolve();
400
+ }
401
+ if (initDeferDOM) {
370
402
  return this.waitForDOMContentLoaded();
371
403
  }
404
+ return this.waitForBody();
372
405
  })
373
406
  .then(() => loader.load(bootstrapModule))
374
407
  .catch((reason) => {
@@ -400,19 +433,28 @@
400
433
  this.enterErrorState(new Error('Failed to load required modules - timed out'));
401
434
  }, REQUIRED_MODULES_TIMEOUT);
402
435
  }
436
+
437
+ logWarnings(warnings) {
438
+ for (const warningKey in warnings) {
439
+ if (warnings[warningKey].length) {
440
+ // eslint-disable-next-line lwr/no-unguarded-apis
441
+ console.warn(warningKey, warnings[warningKey]);
442
+ }
443
+ }
444
+ }
403
445
  }
404
446
 
405
447
  // The loader module is ALWAYS required
406
448
  const GLOBAL = globalThis ;
407
449
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
408
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_17_2-alpha_3') < 0) {
409
- GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_17_2-alpha_3');
450
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_17_2-alpha_31') < 0) {
451
+ GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_17_2-alpha_31');
410
452
  }
411
453
  new LoaderShim(GLOBAL);
412
454
 
413
455
  })();
414
456
 
415
- LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports) { 'use strict';
457
+ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_31', ['exports'], (function (exports) { 'use strict';
416
458
 
417
459
  const templateRegex = /\{([0-9]+)\}/g;
418
460
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -517,7 +559,7 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
517
559
  level: 0,
518
560
  message: 'An error occurred handling module conflict',
519
561
  });
520
- const MODULE_ALREADY_LOADED = Object.freeze({
562
+ Object.freeze({
521
563
  code: 3017,
522
564
  level: 0,
523
565
  message: 'Marking module(s) as externally loaded, but they are already loaded: {0}',
@@ -729,20 +771,39 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
729
771
 
730
772
  const MODULE_LOAD_TIMEOUT_TIMER = 60 * 1000; // 1m
731
773
 
774
+ var MODULE_WARNING; (function (MODULE_WARNING) {
775
+ const MODULE_REDEFINE = 'Module redefine attempted'; MODULE_WARNING["MODULE_REDEFINE"] = MODULE_REDEFINE;
776
+ const MODULE_ALREADY_LOADED = 'Marking module(s) as externally loaded, but they are already loaded'; MODULE_WARNING["MODULE_ALREADY_LOADED"] = MODULE_ALREADY_LOADED;
777
+ const ALIAS_UPDATE = 'Alias update attempt'; MODULE_WARNING["ALIAS_UPDATE"] = ALIAS_UPDATE;
778
+ })(MODULE_WARNING || (MODULE_WARNING = {}));
779
+
732
780
  /*!
733
781
  * Copyright (C) 2023 salesforce.com, inc.
734
782
  */
735
783
  // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
736
784
  const SUPPORTS_TRUSTED_TYPES = typeof trustedTypes !== 'undefined';
737
- function createTrustedTypesPolicy(name, options) {
785
+ const trustedTypePolicyRegistry = {
786
+ __proto__: null
787
+ };
788
+ function createDuplicateSafeTrustedTypesPolicy(name, options) {
789
+ // istanbul ignore next: not testable in coverage collection
790
+ if (trustedTypePolicyRegistry[name]) {
791
+ return trustedTypePolicyRegistry[name];
792
+ }
738
793
  // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
739
- return trustedTypes.createPolicy(name, options);
794
+ // eslint-disable-next-line no-return-assign
795
+ return trustedTypePolicyRegistry[name] = trustedTypes.createPolicy(name, options);
740
796
  }
741
- function createFallbackPolicy(_name, options) {
742
- return options;
797
+ function createDuplicateSafeFallbackPolicy(name, options) {
798
+ if (trustedTypePolicyRegistry[name]) {
799
+ return trustedTypePolicyRegistry[name];
800
+ }
801
+ // @ts-ignore: Prevent cannot find name 'trustedTypes' error.
802
+ // eslint-disable-next-line no-return-assign
803
+ return trustedTypePolicyRegistry[name] = options;
743
804
  }
744
805
  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
745
- const createPolicy = SUPPORTS_TRUSTED_TYPES ? createTrustedTypesPolicy : createFallbackPolicy;
806
+ const createPolicy = SUPPORTS_TRUSTED_TYPES ? createDuplicateSafeTrustedTypesPolicy : createDuplicateSafeFallbackPolicy;
746
807
  const policyOptions = {
747
808
  createHTML(value) {
748
809
  return value;
@@ -790,7 +851,7 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
790
851
  // swallow
791
852
  }
792
853
  const trusted = createPolicy('trusted', policyOptions);
793
- /*! version: 0.23.6 */
854
+ /*! version: 0.24.6 */
794
855
 
795
856
  /* global console,process */
796
857
 
@@ -860,7 +921,7 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
860
921
  code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
861
922
  try {
862
923
  // TODO eval source maps for debugging
863
- eval(trusted.createScript(code));
924
+ eval(trusted.createScript(code) );
864
925
  } catch (e) {
865
926
  // eslint-disable-next-line lwr/no-unguarded-apis
866
927
  if (process.env.NODE_ENV !== 'production' && hasConsole) {
@@ -938,7 +999,7 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
938
999
  const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
939
1000
  const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
940
1001
 
941
- /* global console,process */
1002
+ /* global process console */
942
1003
 
943
1004
 
944
1005
 
@@ -992,10 +1053,17 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
992
1053
 
993
1054
  class ModuleRegistry {
994
1055
 
1056
+
1057
+ __init() {this.isAppMounted = false;}
995
1058
 
996
- constructor(config) {ModuleRegistry.prototype.__init.call(this);ModuleRegistry.prototype.__init2.call(this);ModuleRegistry.prototype.__init3.call(this);
1059
+ constructor(config) {ModuleRegistry.prototype.__init.call(this);ModuleRegistry.prototype.__init2.call(this);ModuleRegistry.prototype.__init3.call(this);ModuleRegistry.prototype.__init4.call(this);
997
1060
  this.baseUrl = config.baseUrl || '';
998
1061
  this.profiler = config.profiler;
1062
+ this.warnings = {
1063
+ [MODULE_WARNING.MODULE_REDEFINE]: [],
1064
+ [MODULE_WARNING.MODULE_ALREADY_LOADED]: [],
1065
+ [MODULE_WARNING.ALIAS_UPDATE]: [],
1066
+ };
999
1067
  }
1000
1068
 
1001
1069
  clearRegistry() {
@@ -1132,11 +1200,14 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
1132
1200
  // eslint-disable-next-line lwr/no-unguarded-apis
1133
1201
  process.env.NODE_ENV !== 'production' &&
1134
1202
  // eslint-disable-next-line lwr/no-unguarded-apis
1135
- process.env.MRT_HMR !== 'true' &&
1136
- hasConsole
1203
+ process.env.MRT_HMR !== 'true'
1137
1204
  ) {
1138
- // eslint-disable-next-line lwr/no-unguarded-apis
1139
- console.warn(`Module redefine attempted: ${name}`);
1205
+ if (!this.warnings[MODULE_WARNING.MODULE_REDEFINE].includes(name)) {
1206
+ this.warnings[MODULE_WARNING.MODULE_REDEFINE].push(name);
1207
+ }
1208
+ if (this.isAppMounted) {
1209
+ this.logMessage('warning', `${MODULE_WARNING.MODULE_REDEFINE}: ${name}`);
1210
+ }
1140
1211
  }
1141
1212
  this.lastDefine = mod;
1142
1213
  return;
@@ -1198,9 +1269,13 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
1198
1269
  };
1199
1270
  this.namedDefineRegistry.set(id, moduleDef );
1200
1271
  // eslint-disable-next-line lwr/no-unguarded-apis
1201
- } else if (process.env.NODE_ENV !== 'production' && hasConsole) {
1202
- // eslint-disable-next-line lwr/no-unguarded-apis
1203
- console.warn(MODULE_ALREADY_LOADED.message, id);
1272
+ } else if (process.env.NODE_ENV !== 'production') {
1273
+ if (!this.warnings[MODULE_WARNING.MODULE_ALREADY_LOADED].includes(id)) {
1274
+ this.warnings[MODULE_WARNING.MODULE_ALREADY_LOADED].push(id);
1275
+ }
1276
+ if (this.isAppMounted) {
1277
+ this.logMessage('warning', `${MODULE_WARNING.MODULE_ALREADY_LOADED}: ${id}`);
1278
+ }
1204
1279
  }
1205
1280
  });
1206
1281
  }
@@ -1249,13 +1324,13 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
1249
1324
 
1250
1325
 
1251
1326
  // A registry for named AMD defines containing the *metadata* of AMD module
1252
- __init() {this.namedDefineRegistry = new Map();}
1327
+ __init2() {this.namedDefineRegistry = new Map();}
1253
1328
 
1254
1329
  // The evaluated module registry where the module identifier (name or URL?) is the key
1255
- __init2() {this.moduleRegistry = new Map();}
1330
+ __init3() {this.moduleRegistry = new Map();}
1256
1331
 
1257
1332
  // Aliases of modules in the registry
1258
- __init3() {this.aliases = new Map();}
1333
+ __init4() {this.aliases = new Map();}
1259
1334
 
1260
1335
 
1261
1336
 
@@ -1325,14 +1400,17 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
1325
1400
  if (aliasId !== resolvedId) {
1326
1401
  if (!this.aliases.has(aliasId)) {
1327
1402
  this.aliases.set(aliasId, resolvedId);
1328
- } else if (hasConsole) {
1403
+ // eslint-disable-next-line lwr/no-unguarded-apis
1404
+ } else if (hasConsole && process.env.NODE_ENV !== 'production') {
1329
1405
  // Warn the user if they were not aliasing to the resolvedId
1330
1406
  const currentResolvedId = this.aliases.get(aliasId);
1331
1407
  if (currentResolvedId !== resolvedId) {
1332
- // eslint-disable-next-line lwr/no-unguarded-apis
1333
- if (process.env.NODE_ENV !== 'production' && hasConsole) {
1334
- // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
1335
- console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
1408
+ const warningMsg = `${aliasId}=>${currentResolvedId}, ${resolvedId}`;
1409
+ if (!this.warnings[MODULE_WARNING.ALIAS_UPDATE].includes(warningMsg)) {
1410
+ this.warnings[MODULE_WARNING.ALIAS_UPDATE].push(warningMsg);
1411
+ }
1412
+ if (this.isAppMounted) {
1413
+ this.logMessage('warning', `${MODULE_WARNING.ALIAS_UPDATE}: ${warningMsg}`);
1336
1414
  }
1337
1415
  }
1338
1416
  }
@@ -1340,7 +1418,23 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
1340
1418
  }
1341
1419
 
1342
1420
  async getModuleDependencyRecord(dependency) {
1343
- const resolvedDepId = await this.resolve(dependency);
1421
+ let resolvedDepId = await this.resolve(dependency);
1422
+ // If the resolved dependency ID is a URL, it indicates that the dependency
1423
+ // is provided by a bundle that hasn't been fully instantiated yet.
1424
+ if (isUrl(resolvedDepId)) {
1425
+ // Retrieve the module record corresponding to the bundle URL.
1426
+ const existingRecord = this.moduleRegistry.get(resolvedDepId);
1427
+
1428
+ // If a module record for the bundle exists and we haven't already created an alias for this dependency,
1429
+ // then the bundle is still pending instantiation.
1430
+ if (existingRecord && !this.aliases.has(dependency)) {
1431
+ // Wait for the bundle's instantiation promise to resolve.
1432
+ await existingRecord.instantiation;
1433
+ // After instantiation, re-resolve the dependency.
1434
+ // This should now return the final alias (the logical module ID) instead of the raw bundle URL.
1435
+ resolvedDepId = await this.resolve(dependency);
1436
+ }
1437
+ }
1344
1438
  return this.getModuleRecord(resolvedDepId, dependency);
1345
1439
  }
1346
1440
 
@@ -1565,6 +1659,10 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
1565
1659
 
1566
1660
  // Fallback to the last loader.define call
1567
1661
  if (!moduleDef) {
1662
+ this.logMessage(
1663
+ 'warning',
1664
+ `${moduleName} not found, falling back to the last loader.define call`,
1665
+ );
1568
1666
  moduleDef = this.lastDefine;
1569
1667
  }
1570
1668
 
@@ -1625,6 +1723,28 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
1625
1723
  res === null || typeof res === 'string' || (res && typeof (res ).url === 'string')
1626
1724
  );
1627
1725
  }
1726
+
1727
+ getModuleWarnings(isAppMounted = false) {
1728
+ this.isAppMounted = isAppMounted;
1729
+ return this.warnings;
1730
+ }
1731
+
1732
+ logMessage(logType, message) {
1733
+ if (
1734
+ !hasProcessEnv ||
1735
+ !hasConsole || // eslint-disable-next-line lwr/no-unguarded-apis
1736
+ process.env.NODE_ENV === 'production'
1737
+ ) {
1738
+ return;
1739
+ }
1740
+ if (logType == 'warning') {
1741
+ // eslint-disable-next-line lwr/no-unguarded-apis
1742
+ console.warn(message);
1743
+ } else {
1744
+ // eslint-disable-next-line lwr/no-unguarded-apis
1745
+ console.log(message);
1746
+ }
1747
+ }
1628
1748
  }
1629
1749
 
1630
1750
  // find the longest set of segments from path which are a key in matchObj
@@ -1967,11 +2087,9 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
1967
2087
  sigs = execute;
1968
2088
  }
1969
2089
 
1970
- sigs = sigs || {};
1971
-
1972
2090
  invariant(Array.isArray(deps), INVALID_DEPS);
1973
2091
 
1974
- this.registry.define(name, deps, ctor , sigs );
2092
+ this.registry.define(name, deps, ctor , (sigs || {}) );
1975
2093
  }
1976
2094
 
1977
2095
  /**
@@ -2038,6 +2156,10 @@ LWR.define('lwr/loaderLegacy/v/0_17_2-alpha_3', ['exports'], (function (exports)
2038
2156
  registerExternalModules(modules) {
2039
2157
  this.registry.registerExternalModules(modules);
2040
2158
  }
2159
+
2160
+ getModuleWarnings(isAppMounted = false) {
2161
+ return this.registry.getModuleWarnings(isAppMounted);
2162
+ }
2041
2163
  }
2042
2164
 
2043
2165
  exports.Loader = Loader;
@@ -4,8 +4,9 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Legacy Module Loader Shim v0.17.2-alpha.3 */
8
- !function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function n(e,t){return t?`${e}-${t}`:e}function i(e,t,r){const o=n(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:n,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:n,metadata:d});else if(s){const e=i(r,n,l),t=a(n,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c});else if(s){const e=i(r,l,d),t=n(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:n,customInit:i}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(n,i),i){i({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_17_2-alpha_3",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:n}=s;if(!n)throw new Error("Expected Loader class to be defined");const i=new n(r);return o&&o.length&&i.registerExternalModules(o),i.define(e,["exports"],(e=>{Object.assign(e,{define:i.define.bind(i),load:i.load.bind(i),services:i.services,clearRegistry:i.clearRegistry.bind(i)})}),t[3]),i}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t)}catch(e){this.enterErrorState(e)}}waitForDOMContentLoaded(){return void 0===typeof document||"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_17_2-alpha_3",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:n,endpoints:i}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:n||{},importMappings:o,endpoints:i,env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{disableInitDefer:a}=this.config;e.registerImportMappings(o).then((()=>{if(!a)return this.waitForDOMContentLoaded()})).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_17_2-alpha_3")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_17_2-alpha_3"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_17_2-alpha_3",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was {1}'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process,hasProcessEnv=hasProcess&&process.env;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const s=o.slice(0,o.lastIndexOf("/")+1)+e,n=[];let i=-1;for(let e=0;e<s.length;e++)-1!==i?"/"===s[e]&&(n.push(s.slice(i,e+1)),i=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:i=e:(n.pop(),e+=2):i=e;return-1!==i&&n.push(s.slice(i)),t.slice(0,t.length-o.length)+n.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=6e4,SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes;
7
+ /* LWR Legacy Module Loader Shim v0.17.2-alpha.31 */
8
+ !function(){"use strict";var e=function(e){return e[e.Start=0]="Start",e[e.End=1]="End",e}(e||{});let t;function r(e){t=e}const o=globalThis.performance,s=void 0!==o&&"function"==typeof o.mark&&"function"==typeof o.clearMarks&&"function"==typeof o.measure&&"function"==typeof o.clearMeasures;function i(e,t){return t?`${e}-${t}`:e}function n(e,t,r){const o=i(e,t);return t&&r?`${o}_${r}`:o}function a(e,t){const r=e||t?{...t}:null;return r&&e&&(r.specifier=e),r}function l({id:r,specifier:i,specifierIndex:l,metadata:d}){if(t)t({id:r,phase:e.Start,specifier:i,metadata:d,specifierIndex:l});else if(s){const e=n(r,i,l),t=a(i,d);o.mark(e,{detail:t})}}function d({id:r,specifier:l,specifierIndex:d,metadata:c}){if(t)t({id:r,phase:e.End,specifier:l,metadata:c,specifierIndex:d});else if(s){const e=n(r,l,d),t=i(r,l),s=a(l,c);o.measure(t,{start:e,detail:s}),o.clearMarks(e),o.clearMeasures(t)}}function c(e,t,o,s){const{autoBoot:i,customInit:n}=e;if(function(e,t){if(!e&&!t)throw new Error("The customInit hook is required when autoBoot is false");if(e&&t)throw new Error("The customInit hook must not be defined when autoBoot is true")}(i,n),n){n({initializeApp:t,define:o,onBootstrapError:s,attachDispatcher:r},e)}}const u="function"==typeof setTimeout,p="undefined"!=typeof console;class f{__init(){this.defineCache={}}__init2(){this.orderedDefs=[]}constructor(e){f.prototype.__init.call(this),f.prototype.__init2.call(this),u&&(this.watchdogTimerId=this.startWatchdogTimer()),this.global=e,this.config=e.LWR,this.loaderModule="lwr/loaderLegacy/v/0_17_2-alpha_31",this.errorHandler=this.config.onError;const t=this.tempDefine.bind(this);e.LWR.define=t,this.bootReady=this.config.autoBoot;try{this.createProfilerModule(e.LWR.define),c(Object.freeze(this.config),this.postCustomInit.bind(this),t,(e=>{this.errorHandler=e}))}catch(e){this.enterErrorState(e)}}canInit(){if(!this.config.requiredModules)throw new Error("Unexpected missing requiredModules");const e=this.config.requiredModules.every((e=>this.orderedDefs.includes(e)));return this.bootReady&&e}tempDefine(...e){const t=e[0];this.defineCache[t]=e,this.orderedDefs.push(t),this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}postCustomInit(){this.bootReady=!0,this.canInit()&&(u&&clearTimeout(this.watchdogTimerId),this.initApp())}initApp(){try{const e={baseUrl:this.config.baseUrl,profiler:{logOperationStart:l,logOperationEnd:d},appMetadata:{appId:this.config.appId,bootstrapModule:this.config.bootstrapModule,rootComponent:this.config.rootComponent,rootComponents:this.config.rootComponents}},t=function(e,t,r,o){if(!t||"function"!=typeof t[2])throw new Error(`Expected loader with specifier "${e}" to be a module`);const s={};t[2].call(null,s);const{Loader:i}=s;if(!i)throw new Error("Expected Loader class to be defined");const n=new i(r);return o&&o.length&&n.registerExternalModules(o),n.define(e,["exports"],(e=>{Object.assign(e,{define:n.define.bind(n),load:n.load.bind(n),services:n.services,clearRegistry:n.clearRegistry.bind(n)})}),t[3]),n}(this.loaderModule,this.defineCache[this.loaderModule],e,this.config.preloadModules);this.mountApp(t),t&&t.getModuleWarnings}catch(e){this.enterErrorState(e)}}waitForBody(){return new Promise((e=>{if(document.body)e();else{const t=new MutationObserver((()=>{document.body&&(t.disconnect(),e())}));t.observe(document.documentElement,{childList:!0})}}))}waitForDOMContentLoaded(){return"interactive"===document.readyState||"complete"===document.readyState?Promise.resolve():new Promise((e=>{document.addEventListener("DOMContentLoaded",(()=>{e()}))}))}createProfilerModule(e){e("lwr/profiler/v/0_17_2-alpha_31",["exports"],(e=>{Object.assign(e,{logOperationStart:l,logOperationEnd:d})}),{})}mountApp(e){const{bootstrapModule:t,rootComponent:r,importMappings:o,rootComponents:s,serverData:i,endpoints:n}=this.config;this.global.LWR=Object.freeze({define:e.define.bind(e),rootComponent:r,rootComponents:s,serverData:i||{},importMappings:o,endpoints:n,env:this.global.LWR.env}),this.orderedDefs.forEach((t=>{t!==this.loaderModule&&e.define(...this.defineCache[t])}));const{initDeferDOM:a}=this.config;e.registerImportMappings(o).then((()=>"undefined"==typeof window||void 0===typeof document?Promise.resolve():a?this.waitForDOMContentLoaded():this.waitForBody())).then((()=>e.load(t))).catch((e=>{this.enterErrorState(new Error(`Application ${r||t} could not be loaded: ${e}`))}))}enterErrorState(e){l({id:"lwr.bootstrap.error"}),this.errorHandler?this.errorHandler(e):p&&console.error(`An error occurred during LWR bootstrap. ${e.message}`,e.stack)}startWatchdogTimer(){return setTimeout((()=>{this.enterErrorState(new Error("Failed to load required modules - timed out"))}),6e4)}logWarnings(e){for(const t in e)e[t].length&&console.warn(t,e[t])}}const h=globalThis;h.LWR.requiredModules=h.LWR.requiredModules||[],h.LWR.requiredModules.indexOf("lwr/loaderLegacy/v/0_17_2-alpha_31")<0&&h.LWR.requiredModules.push("lwr/loaderLegacy/v/0_17_2-alpha_31"),new f(h)}(),LWR.define("lwr/loaderLegacy/v/0_17_2-alpha_31",["exports"],(function(exports){"use strict";const templateRegex=/\{([0-9]+)\}/g;function templateString(e,t){return e.replace(templateRegex,((e,r)=>t[r]))}function generateErrorMessage(e,t){const r=Array.isArray(t)?templateString(e.message,t):e.message;return`LWR${e.code}: ${r}`}class LoaderError extends Error{constructor(e,t){super(),this.message=generateErrorMessage(e,t)}}function invariant(e,t){if(!e)throw new LoaderError(t)}const MISSING_NAME=Object.freeze({code:3e3,message:"A module name is required.",level:0}),FAIL_INSTANTIATE=Object.freeze({code:3004,message:"Failed to instantiate module: {0}",level:0}),NO_AMD_REQUIRE=Object.freeze({code:3005,message:"AMD require not supported.",level:0}),FAILED_DEP=Object.freeze({code:3006,level:0,message:"Failed to load dependency: {0}"}),INVALID_DEPS=Object.freeze({code:3007,message:"Unexpected value received for dependencies argument; expected an array.",level:0}),FAIL_LOAD=Object.freeze({code:3008,level:0,message:"Error loading {0}"}),UNRESOLVED=Object.freeze({code:3009,level:0,message:"Unable to resolve bare specifier: {0}"}),NO_BASE_URL=Object.freeze({code:3010,level:0,message:"baseUrl not set"});Object.freeze({code:3011,level:0,message:"Cannot set a loader service multiple times"});const INVALID_HOOK=Object.freeze({code:3012,level:0,message:"Invalid hook received"}),INVALID_LOADER_SERVICE_RESPONSE=Object.freeze({code:3013,level:0,message:"Invalid response received from hook"}),MODULE_LOAD_TIMEOUT=Object.freeze({code:3014,level:0,message:"Error loading {0} - timed out"}),HTTP_FAIL_LOAD=Object.freeze({code:3015,level:0,message:"Error loading {0}, status code {1}"}),STALE_HOOK_ERROR=Object.freeze({code:3016,level:0,message:"An error occurred handling module conflict"});Object.freeze({code:3017,level:0,message:"Marking module(s) as externally loaded, but they are already loaded: {0}"});const FAIL_HOOK_LOAD=Object.freeze({code:3018,level:0,message:'Error loading "{0}" from hook'}),EXPORTER_ERROR=Object.freeze({code:3021,level:0,message:'Error evaluating module "{0}", error was {1}'}),BAD_IMPORT_MAP=Object.freeze({code:3011,level:0,message:"import map is not valid"}),hasDocument="undefined"!=typeof document,hasSetTimeout="function"==typeof setTimeout,hasConsole="undefined"!=typeof console,hasProcess="undefined"!=typeof process,hasProcessEnv=hasProcess&&process.env;function getBaseUrl(){let e;if(hasDocument){const t=document.querySelector("base[href]");e=t&&t.href}if(!e&&"undefined"!=typeof location){e=location.href.split("#")[0].split("?")[0];const t=e.lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}return e}function isUrl(e){return-1!==e.indexOf("://")}function resolveIfNotPlainOrUrl(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const r=t.slice(0,t.indexOf(":")+1);let o;if("/"===t[r.length+1]?"file:"!==r?(o=t.slice(r.length+2),o=o.slice(o.indexOf("/")+1)):o=t.slice(8):o=t.slice(r.length+("/"===t[r.length]?1:0)),"/"===e[0])return t.slice(0,t.length-o.length-1)+e;const s=o.slice(0,o.lastIndexOf("/")+1)+e,i=[];let n=-1;for(let e=0;e<s.length;e++)-1!==n?"/"===s[e]&&(i.push(s.slice(n,e+1)),n=-1):"."===s[e]?"."!==s[e+1]||"/"!==s[e+2]&&e+2!==s.length?"/"===s[e+1]||e+1===s.length?e+=1:n=e:(i.pop(),e+=2):n=e;return-1!==n&&i.push(s.slice(n)),t.slice(0,t.length-o.length)+i.join("")}}function resolveUrl(e,t){return resolveIfNotPlainOrUrl(e,t)||(isUrl(e)?e:resolveIfNotPlainOrUrl("./"+e,t))}function createScript(e){const t=document.createElement("script");return t.async=!0,t.crossOrigin="anonymous",t.src=e,t}let lastWindowError$1,lastWindowErrorUrl;function loadModuleDef(e){return new Promise((function(t,r){if(hasDocument){const o=createScript(e);o.addEventListener("error",(()=>{r(new LoaderError(FAIL_LOAD,[e]))})),o.addEventListener("load",(()=>{document.head.removeChild(o),lastWindowErrorUrl===e?r(lastWindowError$1):t()})),document.head.appendChild(o)}}))}hasDocument&&window.addEventListener("error",(e=>{lastWindowErrorUrl=e.filename,lastWindowError$1=e.error}));const MODULE_LOAD_TIMEOUT_TIMER=6e4;var MODULE_WARNING;!function(e){e.MODULE_REDEFINE="Module redefine attempted";e.MODULE_ALREADY_LOADED="Marking module(s) as externally loaded, but they are already loaded";e.ALIAS_UPDATE="Alias update attempt"}(MODULE_WARNING||(MODULE_WARNING={}));
9
9
  /*!
10
10
  * Copyright (C) 2023 salesforce.com, inc.
11
- */function createTrustedTypesPolicy(e,t){return trustedTypes.createPolicy(e,t)}function createFallbackPolicy(e,t){return t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createTrustedTypesPolicy:createFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response||!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(trusted.createScript(code))}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const s=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(s)}))})):t}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldHash:o,newHash:s}=t;for(let t=0;t<e.length;t++){const n=e[t];try{if(null!==n({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),this.baseUrl=e.baseUrl||"",this.profiler=e.profiler}clearRegistry(){this.moduleRegistry=new Map}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),s=await this.getModuleRecord(o,e);return s.evaluated?s.module:(s.evaluationPromise||(s.evaluationPromise=this.topLevelEvaluation(s)),s.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const n=this.resolveHook;let i=!0;if(n){for(let e=0;e<n.length;e++){const t=(0,n[e])(s,{parentUrl:r});let i;if((t||null===t)&&(i=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(i))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==i){if("string"==typeof i){if(resolveIfNotPlainOrUrl(i,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=i;continue}if(o=i&&i.url&&(resolveIfNotPlainOrUrl(i.url,r)||i.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){const e=this.resolver.resolve(t,r);if(o=e&&e.uri,i=e?!!e.defaultUri:i,this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.defined){if(!this.moduleRegistry.get(o)||!this.aliases.has(t))return t}}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return i&&t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const n={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(n),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,n),this.lastDefine=n,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}__init(){this.namedDefineRegistry=new Map}__init2(){this.moduleRegistry=new Map}__init3(){this.aliases=new Map}getExistingModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}return r}async getModuleRecord(e,t){const r=this.getExistingModuleRecord(e,t);if(r)return r;const o=this.getModuleDef(e,t),s=o.then((e=>{const t=(e&&e.dependencies||[]).map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),n={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,n),this.storeModuleAlias(t,e),s.then((()=>n))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)?hasConsole&&this.aliases.get(e):this.aliases.set(e,t))}async getModuleDependencyRecord(e){const t=await this.resolve(e);return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,n={},i=s?await Promise.all(s.map((async e=>{if("exports"===e)return n;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])}))):[];if(e.evaluated)return e.module;let a;try{a=o(...i)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(n)&&Object.defineProperty(n,"__useDefault",{value:!0});const l=a||n;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const s=this.baseUrl,n=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:n}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),n=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===n)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(n&&null!==n)return evaluateLoadHookResponse(n,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:n}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:n}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(e.length>1&&-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){if(e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length){return{uri:r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e)}}return{uri:r+e.slice(o.length)}}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e)){return{uri:r+encodeURIComponent(e),defaultUri:!0}}}function resolveImportMapEntry(e,t,r){e.scopes||(e.scopes={}),e.imports||(e.imports={});const o=e.scopes;let s=r&&getMatch(r,o);for(;s;){const e=applyPackages(t,o[s]);if(e)return e;s=getMatch(s.slice(0,s.lastIndexOf("/")),o)}return applyPackages(t,e.imports,e.default)||isUrl(t)&&{uri:t}||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const n in e){const i=resolveIfNotPlainOrUrl(n,r)||n,a=e[n];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[i]=l.uri:targetWarning(n,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const n=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[n]||(o.scopes[n]={}),t,r,n)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}function _optionalChain(e){let t,r=e[0],o=1;for(;o<e.length;){const s=e[o],n=e[o+1];if(o+=2,("optionalAccess"===s||"optionalCall"===s)&&null==r)return;"access"===s||"optionalAccess"===s?(t=r,r=n(r)):"call"!==s&&"optionalCall"!==s||(r=n(((...e)=>r.call(t,...e))),t=void 0)}return r}class Loader{constructor(e){const t=e||{};let r=t.baseUrl,o=t.profiler;if(r&&(r=r.replace(/\/?$/,"/")),r||(r=getBaseUrl()),!r)throw new LoaderError(NO_BASE_URL);this.baseUrl=r,o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:r,profiler:o}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:_optionalChain([e,"optionalAccess",e=>e.appMetadata])})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,n=t,i=o;"function"==typeof n&&(s=t,n=[],i=r),i=i||{},invariant(Array.isArray(n),INVALID_DEPS),this.registry.define(e,n,s,i)}async load(e,t){return this.registry.load(e,t)}clearRegistry(){this.registry.clearRegistry()}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));
11
+ */
12
+ const SUPPORTS_TRUSTED_TYPES="undefined"!=typeof trustedTypes,trustedTypePolicyRegistry={__proto__:null};function createDuplicateSafeTrustedTypesPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=trustedTypes.createPolicy(e,t)}function createDuplicateSafeFallbackPolicy(e,t){return trustedTypePolicyRegistry[e]?trustedTypePolicyRegistry[e]:trustedTypePolicyRegistry[e]=t}const createPolicy=SUPPORTS_TRUSTED_TYPES?createDuplicateSafeTrustedTypesPolicy:createDuplicateSafeFallbackPolicy,policyOptions={createHTML:e=>e,createScript:e=>e,createScriptURL:e=>e};try{createPolicy("default",{createHTML:e=>e,createScript(e){if("null"===e||"undefined"===e)return e},createScriptURL:e=>e})}catch(e){}const trusted=createPolicy("trusted",policyOptions);let lastWindowError;function isCustomResponse(e){return Object.prototype.hasOwnProperty.call(e,"data")&&!Object.prototype.hasOwnProperty.call(e,"blob")}function isFetchResponse(e){return"function"==typeof e.blob}function isResponseAPromise(e){return!(!e||!e.then)}async function evaluateLoadHookResponse(response,id){return Promise.resolve().then((async()=>{if(!response||!response.status)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(200!==response.status)throw new LoaderError(HTTP_FAIL_LOAD,[id,`${response.status}`]);const isResponse=isFetchResponse(response);let code;if(isCustomResponse(response))code=response.data;else{if(!isResponse)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);code=await response.text()}if(!code)throw new LoaderError(FAIL_LOAD,[id]);code=`${code}\n//# sourceURL=${id}`;try{eval(trusted.createScript(code))}catch(e){throw new LoaderError(FAIL_LOAD,[id])}if(lastWindowError)throw new LoaderError(FAIL_LOAD,[id]);return!0}))}async function evaluateLoadHook(e,t){return hasSetTimeout?new Promise(((r,o)=>{const s=setTimeout((()=>{o(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER);t.then((e=>{r(e)})).catch((()=>{o(new LoaderError(FAIL_HOOK_LOAD,[e]))})).finally((()=>{clearTimeout(s)}))})):t}function reportError(e){hasConsole&&console.error(e)}function evaluateHandleStaleModuleHooks(e,t){const{name:r,oldHash:o,newHash:s}=t;for(let t=0;t<e.length;t++){const i=e[t];try{if(null!==i({name:r,oldHash:o,newHash:s}))break}catch(e){reportError(new LoaderError(STALE_HOOK_ERROR))}}}hasDocument&&globalThis.addEventListener("error",(e=>{lastWindowError=e.error}));const LOADER_PREFIX="lwr.loader.",MODULE_DEFINE=`${LOADER_PREFIX}module.define`,MODULE_DYNAMIC_LOAD=`${LOADER_PREFIX}module.dynamicLoad`,MODULE_FETCH=`${LOADER_PREFIX}module.fetch`,MODULE_ERROR=`${LOADER_PREFIX}module.error`;class ModuleRegistry{__init(){this.isAppMounted=!1}constructor(e){ModuleRegistry.prototype.__init.call(this),ModuleRegistry.prototype.__init2.call(this),ModuleRegistry.prototype.__init3.call(this),ModuleRegistry.prototype.__init4.call(this),this.baseUrl=e.baseUrl||"",this.profiler=e.profiler,this.warnings={[MODULE_WARNING.MODULE_REDEFINE]:[],[MODULE_WARNING.MODULE_ALREADY_LOADED]:[],[MODULE_WARNING.ALIAS_UPDATE]:[]}}clearRegistry(){this.moduleRegistry=new Map}async load(e,t){const r=t?{importer:t}:{};this.profiler.logOperationStart({id:MODULE_DYNAMIC_LOAD,specifier:e,metadata:r});const o=await this.resolve(e,t),s=await this.getModuleRecord(o,e);return s.evaluated?s.module:(s.evaluationPromise||(s.evaluationPromise=this.topLevelEvaluation(s)),s.evaluationPromise)}async resolve(e,t){const r=this.baseUrl;let o,s=e;const i=this.resolveHook;let n=!0;if(i){for(let e=0;e<i.length;e++){const t=(0,i[e])(s,{parentUrl:r});let n;if((t||null===t)&&(n=isResponseAPromise(t)?await t:t),!this.isValidResolveResponse(n))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(null!==n){if("string"==typeof n){if(resolveIfNotPlainOrUrl(n,r))throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);s=n;continue}if(o=n&&n.url&&(resolveIfNotPlainOrUrl(n.url,r)||n.url),!o)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);break}}if(s!==e){if(!o&&this.namedDefineRegistry.has(s))return s;e=s}}if(!o){const t=resolveIfNotPlainOrUrl(e,r)||e;if(this.moduleRegistry.has(t))return t;if(this.resolver){const e=this.resolver.resolve(t,r);if(o=e&&e.uri,n=e?!!e.defaultUri:n,this.namedDefineRegistry.has(t)){const e=this.namedDefineRegistry.get(t);if(e.external||e.defined){if(!this.moduleRegistry.get(o)||!this.aliases.has(t))return t}}}else o=t}if(!o||!isUrl(o)){if(this.namedDefineRegistry.has(e))return e;throw new LoaderError(UNRESOLVED,[e])}return n&&t&&isUrl(o)&&(o+=`?importer=${encodeURIComponent(t)}`),o}has(e){return this.moduleRegistry.has(e)}define(e,t,r,o){const s=this.namedDefineRegistry.get(e);if(s&&s.defined)return void(this.lastDefine=s);const i={name:e,dependencies:t,exporter:r,signatures:o,defined:!0};s&&s.external&&s.external.resolveExternal(i),this.profiler.logOperationStart({id:MODULE_DEFINE,specifier:e}),this.namedDefineRegistry.set(e,i),this.lastDefine=i,o.hashes&&Object.entries(o.hashes).forEach((([e,t])=>{this.checkModuleSignature(e,t)}))}registerExternalModules(e){e.map((e=>{if(!this.namedDefineRegistry.has(e)){let t,r;const o=new Promise(((o,s)=>{t=o,r=setTimeout((()=>{s(new LoaderError(MODULE_LOAD_TIMEOUT,[e]))}),MODULE_LOAD_TIMEOUT_TIMER)})).finally((()=>{clearTimeout(r)})),s={name:e,defined:!1,external:{resolveExternal:t,moduleDefPromise:o}};this.namedDefineRegistry.set(e,s)}}))}checkModuleSignature(e,t){const r=this.namedDefineRegistry.get(e);if(!r){const r={name:e,signatures:{ownHash:t},defined:!1};return void this.namedDefineRegistry.set(e,r)}const o=r.signatures?r.signatures.ownHash:void 0;if(o&&t!==o){const r=this.handleStaleModuleHook;r&&evaluateHandleStaleModuleHooks(r,{name:e,oldHash:o,newHash:t})}}setImportResolver(e){this.resolver=e}__init2(){this.namedDefineRegistry=new Map}__init3(){this.moduleRegistry=new Map}__init4(){this.aliases=new Map}getExistingModuleRecord(e,t){const r=this.moduleRegistry.get(e);if(r)return this.storeModuleAlias(t,e),r;if(e!==t){const e=this.aliases.get(t);if(e){const t=this.moduleRegistry.get(e);if(t)return t}}return r}async getModuleRecord(e,t){const r=this.getExistingModuleRecord(e,t);if(r)return r;const o=this.getModuleDef(e,t),s=o.then((e=>{const t=(e&&e.dependencies||[]).map((e=>{if("exports"!==e)return invariant("require"!==e,NO_AMD_REQUIRE),this.getModuleDependencyRecord.call(this,e)})).filter((e=>void 0!==e));return Promise.all(t)})),i={id:e,module:Object.create(null),dependencyRecords:s,instantiation:o,evaluated:!1,evaluationPromise:null};return this.moduleRegistry.set(e,i),this.storeModuleAlias(t,e),s.then((()=>i))}storeModuleAlias(e,t){e!==t&&(this.aliases.has(e)||this.aliases.set(e,t))}async getModuleDependencyRecord(e){let t=await this.resolve(e);if(isUrl(t)){const r=this.moduleRegistry.get(t);r&&!this.aliases.has(e)&&(await r.instantiation,t=await this.resolve(e))}return this.getModuleRecord(t,e)}async topLevelEvaluation(e){return await this.instantiateAll(e,{}),this.evaluateModule(e,{})}async instantiateAll(e,t){if(!t[e.id]){t[e.id]=!0;const r=await e.dependencyRecords;if(r)for(let e=0;e<r.length;e++){const o=r[e];await this.instantiateAll(o,t)}}}async evaluateModule(e,t){const r=await e.dependencyRecords;r.length>0&&(t[e.id]=!0,await this.evaluateModuleDependencies(r,t));const{exporter:o,dependencies:s}=await e.instantiation,i={},n=s?await Promise.all(s.map((async e=>{if("exports"===e)return i;const t=await this.resolve(e),r=this.moduleRegistry.get(t);if(!r)throw new LoaderError(FAILED_DEP,[t]);const o=r.module;if(!r.evaluated)return this.getCircularDependencyWrapper(o);if(o)return o.__defaultInterop?o.default:o;throw new LoaderError(FAILED_DEP,[t])}))):[];if(e.evaluated)return e.module;let a;try{a=o(...n)}catch(t){throw new LoaderError(EXPORTER_ERROR,[e.id,t.message||t])}void 0!==a?(a={default:a},Object.defineProperty(a,"__defaultInterop",{value:!0})):this.isNamedExportDefaultOnly(i)&&Object.defineProperty(i,"__useDefault",{value:!0});const l=a||i;for(const t in l)Object.defineProperty(e.module,t,{enumerable:!0,set(e){l[t]=e},get:()=>l[t]});return l.__useDefault&&Object.defineProperty(e.module,"__useDefault",{value:!0}),l.__defaultInterop&&Object.defineProperty(e.module,"__defaultInterop",{value:!0}),l.__esModule&&Object.defineProperty(e.module,"__esModule",{value:!0}),e.evaluated=!0,Object.freeze(e.module),e.module}isNamedExportDefaultOnly(e){return void 0!==e&&2===Object.getOwnPropertyNames(e).length&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.prototype.hasOwnProperty.call(e,"__esModule")}getCircularDependencyWrapper(e){const t=()=>e.__useDefault||e.__defaultInterop?e.default:e;return t.__circular__=!0,t}async evaluateModuleDependencies(e,t){for(let r=0;r<e.length;r++){const o=e[r];o.evaluated||t[o.id]||(t[o.id]=!0,await this.evaluateModule(o,t))}}async getModuleDef(e,t){this.lastDefine=void 0;const r=isUrl(e)?t!==e?t:void 0:e;let o=r&&this.namedDefineRegistry.get(r);if(o&&o.external)return o.external.moduleDefPromise;if(o&&o.defined)return o;const s=this.baseUrl,i=r||t;return this.profiler.logOperationStart({id:MODULE_FETCH,specifier:i}),Promise.resolve().then((async()=>{const t=this.loadHook;if(t)for(let r=0;r<t.length;r++){const o=(0,t[r])(e,s),i=isResponseAPromise(o)?await evaluateLoadHook(e,o):o;if(void 0===i)throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);if(i&&null!==i)return evaluateLoadHookResponse(i,e)}return!1})).then((t=>{if(!0!==t&&hasDocument)return loadModuleDef(e)})).then((()=>{if(o=r&&this.namedDefineRegistry.get(r),o||(this.logMessage("warning",`${r} not found, falling back to the last loader.define call`),o=this.lastDefine),!o)throw new LoaderError(FAIL_INSTANTIATE,[e]);return this.profiler.logOperationEnd({id:MODULE_FETCH,specifier:i}),o})).catch((e=>{throw e instanceof LoaderError||this.profiler.logOperationStart({id:MODULE_ERROR,specifier:i}),e}))}addLoaderPlugin(e){if("object"!=typeof e)throw new LoaderError(INVALID_HOOK);const{loadModule:t,resolveModule:r}=e;r&&(this.resolveHook?this.resolveHook.push(r):this.resolveHook=[r]),t&&(this.loadHook?this.loadHook.push(t):this.loadHook=[t])}registerHandleStaleModuleHook(e){this.handleStaleModuleHook?this.handleStaleModuleHook.push(e):this.handleStaleModuleHook=[e]}isValidResolveResponse(e){return null===e||"string"==typeof e||e&&"string"==typeof e.url}getModuleWarnings(e=!1){return this.isAppMounted=e,this.warnings}logMessage(e,t){}}function getMatch(e,t){if(t[e])return e;let r=e.length;do{const o=e.slice(0,r+1);if(o in t)return o}while(e.length>1&&-1!==(r=e.lastIndexOf("/",r-1)))}function targetWarning(e,t,r){hasConsole&&console.warn("Package target "+r+", resolving target '"+t+"' for "+e)}function applyPackages(e,t,r){const o=getMatch(e,t);if(o){const r=t[o];if(null===r)return;if(!(e.length>o.length&&"/"!==r[r.length-1])){if(e.length>o.length&&"/"===r[r.length-1]&&r.lastIndexOf(o)===r.length-o.length){return{uri:r.substring(0,r.lastIndexOf(o))+encodeURIComponent(e)}}return{uri:r+e.slice(o.length)}}targetWarning(o,r,"should have a trailing '/'")}else if(r&&!isUrl(e)){return{uri:r+encodeURIComponent(e),defaultUri:!0}}}function resolveImportMapEntry(e,t,r){e.scopes||(e.scopes={}),e.imports||(e.imports={});const o=e.scopes;let s=r&&getMatch(r,o);for(;s;){const e=applyPackages(t,o[s]);if(e)return e;s=getMatch(s.slice(0,s.lastIndexOf("/")),o)}return applyPackages(t,e.imports,e.default)||isUrl(t)&&{uri:t}||void 0}function resolveAndComposePackages(e,t,r,o,s){for(const i in e){const n=resolveIfNotPlainOrUrl(i,r)||i,a=e[i];if("string"!=typeof a)continue;const l=resolveImportMapEntry(o,resolveIfNotPlainOrUrl(a,r)||a,s);l?t[n]=l.uri:targetWarning(i,a,"bare specifier did not resolve")}}function resolveAndComposeImportMap(e,t,r={imports:{},scopes:{}}){const o={imports:Object.assign({},r.imports),scopes:Object.assign({},r.scopes),default:e.default};if(e.imports&&resolveAndComposePackages(e.imports,o.imports,t,r),e.scopes)for(const s in e.scopes){const i=resolveUrl(s,t);resolveAndComposePackages(e.scopes[s],o.scopes[i]||(o.scopes[i]={}),t,r,i)}return e.default&&(o.default=resolveIfNotPlainOrUrl(e.default,t)),o}class ImportMapResolver{constructor(e){this.importMap=e}resolve(e,t){return resolveImportMapEntry(this.importMap,e,t)}}const IMPORTMAP_SCRIPT_TYPE="lwr-importmap";function iterateDocumentImportMaps(e,t){const r=document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]`+t),o=Array.from(r).filter((e=>!e.src||(hasConsole&&console.warn("LWR does not support import maps from script src"),!1)));Array.prototype.forEach.call(o,e)}async function getImportMapFromScript(e){return Promise.resolve(e.innerHTML)}async function evaluateImportMaps(e){let t={imports:{},scopes:{}},r=Promise.resolve(t);if(hasDocument){if(e||(e=getBaseUrl()),!e)throw new LoaderError(NO_BASE_URL);iterateDocumentImportMaps((o=>{r=r.then((()=>getImportMapFromScript(o))).then((e=>{try{return JSON.parse(e)}catch(e){throw new LoaderError(BAD_IMPORT_MAP)}})).then((r=>(t=resolveAndComposeImportMap(r,o.src||e,t),t)))}),"")}return r}function _optionalChain(e){let t,r=e[0],o=1;for(;o<e.length;){const s=e[o],i=e[o+1];if(o+=2,("optionalAccess"===s||"optionalCall"===s)&&null==r)return;"access"===s||"optionalAccess"===s?(t=r,r=i(r)):"call"!==s&&"optionalCall"!==s||(r=i(((...e)=>r.call(t,...e))),t=void 0)}return r}class Loader{constructor(e){const t=e||{};let r=t.baseUrl,o=t.profiler;if(r&&(r=r.replace(/\/?$/,"/")),r||(r=getBaseUrl()),!r)throw new LoaderError(NO_BASE_URL);this.baseUrl=r,o||(o={logOperationStart:()=>{},logOperationEnd:()=>{}}),this.registry=new ModuleRegistry({baseUrl:r,profiler:o}),this.services=Object.freeze({addLoaderPlugin:this.registry.addLoaderPlugin.bind(this.registry),handleStaleModule:this.registry.registerHandleStaleModuleHook.bind(this.registry),appMetadata:_optionalChain([e,"optionalAccess",e=>e.appMetadata])})}define(e,t,r,o){invariant("string"==typeof e,MISSING_NAME);let s=r,i=t,n=o;"function"==typeof i&&(s=t,i=[],n=r),invariant(Array.isArray(i),INVALID_DEPS),this.registry.define(e,i,s,n||{})}async load(e,t){return this.registry.load(e,t)}clearRegistry(){this.registry.clearRegistry()}has(e){return this.registry.has(e)}async resolve(e,t){return this.registry.resolve(e,t)}async registerImportMappings(e){let t;if(t=e?resolveAndComposeImportMap(e,this.baseUrl,this.parentImportMap):await evaluateImportMaps(this.baseUrl),this.parentImportMap=t,this.parentImportMap){const e=new ImportMapResolver(this.parentImportMap);this.registry.setImportResolver(e)}}registerExternalModules(e){this.registry.registerExternalModules(e)}getModuleWarnings(e=!1){return this.registry.getModuleWarnings(e)}}exports.Loader=Loader,Object.defineProperty(exports,"__esModule",{value:!0})}));