@nocobase/client-v2 2.0.0-alpha.20

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 (70) hide show
  1. package/LICENSE.txt +172 -0
  2. package/lib/Application.d.ts +124 -0
  3. package/lib/Application.js +489 -0
  4. package/lib/MockApplication.d.ts +16 -0
  5. package/lib/MockApplication.js +96 -0
  6. package/lib/Plugin.d.ts +33 -0
  7. package/lib/Plugin.js +89 -0
  8. package/lib/PluginManager.d.ts +46 -0
  9. package/lib/PluginManager.js +114 -0
  10. package/lib/PluginSettingsManager.d.ts +67 -0
  11. package/lib/PluginSettingsManager.js +148 -0
  12. package/lib/RouterManager.d.ts +61 -0
  13. package/lib/RouterManager.js +198 -0
  14. package/lib/WebSocketClient.d.ts +45 -0
  15. package/lib/WebSocketClient.js +217 -0
  16. package/lib/components/BlankComponent.d.ts +12 -0
  17. package/lib/components/BlankComponent.js +48 -0
  18. package/lib/components/MainComponent.d.ts +10 -0
  19. package/lib/components/MainComponent.js +54 -0
  20. package/lib/components/RouterBridge.d.ts +13 -0
  21. package/lib/components/RouterBridge.js +66 -0
  22. package/lib/components/RouterContextCleaner.d.ts +12 -0
  23. package/lib/components/RouterContextCleaner.js +61 -0
  24. package/lib/components/index.d.ts +10 -0
  25. package/lib/components/index.js +32 -0
  26. package/lib/context.d.ts +11 -0
  27. package/lib/context.js +38 -0
  28. package/lib/hooks/index.d.ts +11 -0
  29. package/lib/hooks/index.js +34 -0
  30. package/lib/hooks/useApp.d.ts +10 -0
  31. package/lib/hooks/useApp.js +41 -0
  32. package/lib/hooks/usePlugin.d.ts +11 -0
  33. package/lib/hooks/usePlugin.js +42 -0
  34. package/lib/hooks/useRouter.d.ts +9 -0
  35. package/lib/hooks/useRouter.js +41 -0
  36. package/lib/index.d.ts +14 -0
  37. package/lib/index.js +40 -0
  38. package/lib/utils/index.d.ts +11 -0
  39. package/lib/utils/index.js +79 -0
  40. package/lib/utils/remotePlugins.d.ts +44 -0
  41. package/lib/utils/remotePlugins.js +131 -0
  42. package/lib/utils/requirejs.d.ts +18 -0
  43. package/lib/utils/requirejs.js +1361 -0
  44. package/lib/utils/types.d.ts +330 -0
  45. package/lib/utils/types.js +28 -0
  46. package/package.json +16 -0
  47. package/src/Application.tsx +539 -0
  48. package/src/MockApplication.tsx +53 -0
  49. package/src/Plugin.ts +78 -0
  50. package/src/PluginManager.ts +114 -0
  51. package/src/PluginSettingsManager.ts +182 -0
  52. package/src/RouterManager.tsx +239 -0
  53. package/src/WebSocketClient.ts +220 -0
  54. package/src/__tests__/app.test.tsx +141 -0
  55. package/src/components/BlankComponent.tsx +12 -0
  56. package/src/components/MainComponent.tsx +20 -0
  57. package/src/components/RouterBridge.tsx +38 -0
  58. package/src/components/RouterContextCleaner.tsx +26 -0
  59. package/src/components/index.ts +11 -0
  60. package/src/context.ts +14 -0
  61. package/src/hooks/index.ts +12 -0
  62. package/src/hooks/useApp.ts +16 -0
  63. package/src/hooks/usePlugin.ts +17 -0
  64. package/src/hooks/useRouter.ts +15 -0
  65. package/src/index.ts +15 -0
  66. package/src/utils/index.tsx +48 -0
  67. package/src/utils/remotePlugins.ts +140 -0
  68. package/src/utils/requirejs.ts +2164 -0
  69. package/src/utils/types.ts +375 -0
  70. package/tsconfig.json +7 -0
@@ -0,0 +1,1361 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var requirejs_exports = {};
29
+ __export(requirejs_exports, {
30
+ getRequireJs: () => getRequireJs
31
+ });
32
+ module.exports = __toCommonJS(requirejs_exports);
33
+ /* istanbul ignore file -- @preserve */
34
+ function getRequireJs() {
35
+ var requirejs, require, define;
36
+ var req, s, head, baseElement, dataMain, src, interactiveScript, currentlyAddingScript, mainScript, subPath, version = "2.3.6", commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, jsSuffixRegExp = /\.js$/, currDirRegExp = /^\.\//, op = Object.prototype, ostring = op.toString, hasOwn = op.hasOwnProperty, isBrowser = !!(typeof window !== "undefined" && typeof navigator !== "undefined" && window.document), isWebWorker = !isBrowser && typeof importScripts !== "undefined", readyRegExp = isBrowser && navigator.platform === "PLAYSTATION 3" ? /^complete$/ : /^(complete|loaded)$/, defContextName = "_", isOpera = typeof opera !== "undefined" && opera.toString() === "[object Opera]", contexts = {}, cfg = {}, globalDefQueue = [], useInteractive = false;
37
+ function commentReplace(match, singlePrefix) {
38
+ return singlePrefix || "";
39
+ }
40
+ __name(commentReplace, "commentReplace");
41
+ function isFunction(it) {
42
+ return ostring.call(it) === "[object Function]";
43
+ }
44
+ __name(isFunction, "isFunction");
45
+ function isArray(it) {
46
+ return ostring.call(it) === "[object Array]";
47
+ }
48
+ __name(isArray, "isArray");
49
+ function each(ary, func) {
50
+ if (ary) {
51
+ var i;
52
+ for (i = 0; i < ary.length; i += 1) {
53
+ if (ary[i] && func(ary[i], i, ary)) {
54
+ break;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ __name(each, "each");
60
+ function eachReverse(ary, func) {
61
+ if (ary) {
62
+ var i;
63
+ for (i = ary.length - 1; i > -1; i -= 1) {
64
+ if (ary[i] && func(ary[i], i, ary)) {
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ }
70
+ __name(eachReverse, "eachReverse");
71
+ function hasProp(obj, prop) {
72
+ return hasOwn.call(obj, prop);
73
+ }
74
+ __name(hasProp, "hasProp");
75
+ function getOwn(obj, prop) {
76
+ return hasProp(obj, prop) && obj[prop];
77
+ }
78
+ __name(getOwn, "getOwn");
79
+ function eachProp(obj, func) {
80
+ var prop;
81
+ for (prop in obj) {
82
+ if (hasProp(obj, prop)) {
83
+ if (func(obj[prop], prop)) {
84
+ break;
85
+ }
86
+ }
87
+ }
88
+ }
89
+ __name(eachProp, "eachProp");
90
+ function mixin(target, source, force, deepStringMixin) {
91
+ if (source) {
92
+ eachProp(source, function(value, prop) {
93
+ if (force || !hasProp(target, prop)) {
94
+ if (deepStringMixin && typeof value === "object" && value && !isArray(value) && !isFunction(value) && !(value instanceof RegExp)) {
95
+ if (!target[prop]) {
96
+ target[prop] = {};
97
+ }
98
+ mixin(target[prop], value, force, deepStringMixin);
99
+ } else {
100
+ target[prop] = value;
101
+ }
102
+ }
103
+ });
104
+ }
105
+ return target;
106
+ }
107
+ __name(mixin, "mixin");
108
+ function bind(obj, fn) {
109
+ return function() {
110
+ return fn.apply(obj, arguments);
111
+ };
112
+ }
113
+ __name(bind, "bind");
114
+ function scripts() {
115
+ return document.getElementsByTagName("script");
116
+ }
117
+ __name(scripts, "scripts");
118
+ function defaultOnError(err) {
119
+ throw err;
120
+ }
121
+ __name(defaultOnError, "defaultOnError");
122
+ function getGlobal(value) {
123
+ if (!value) {
124
+ return value;
125
+ }
126
+ var g = global;
127
+ each(value.split("."), function(part) {
128
+ g = g[part];
129
+ });
130
+ return g;
131
+ }
132
+ __name(getGlobal, "getGlobal");
133
+ function makeError(id, msg, err, requireModules) {
134
+ var e = new Error(msg + "\nhttps://requirejs.org/docs/errors.html#" + id);
135
+ e.requireType = id;
136
+ e.requireModules = requireModules;
137
+ if (err) {
138
+ e.originalError = err;
139
+ }
140
+ return e;
141
+ }
142
+ __name(makeError, "makeError");
143
+ if (typeof define !== "undefined") {
144
+ return;
145
+ }
146
+ if (typeof requirejs !== "undefined") {
147
+ if (isFunction(requirejs)) {
148
+ return;
149
+ }
150
+ cfg = requirejs;
151
+ requirejs = void 0;
152
+ }
153
+ if (typeof require !== "undefined" && !isFunction(require)) {
154
+ cfg = require;
155
+ require = void 0;
156
+ }
157
+ function newContext(contextName) {
158
+ var inCheckLoaded, Module, context, handlers, checkLoadedTimeoutId, config = {
159
+ //Defaults. Do not set a default for map
160
+ //config to speed up normalize(), which
161
+ //will run faster if there is no default.
162
+ waitSeconds: 7,
163
+ baseUrl: "./",
164
+ paths: {},
165
+ bundles: {},
166
+ pkgs: {},
167
+ shim: {},
168
+ config: {}
169
+ }, registry = {}, enabledRegistry = {}, undefEvents = {}, defQueue = [], defined = {}, urlFetched = {}, bundlesMap = {}, requireCounter = 1, unnormalizedCounter = 1;
170
+ function trimDots(ary) {
171
+ var i, part;
172
+ for (i = 0; i < ary.length; i++) {
173
+ part = ary[i];
174
+ if (part === ".") {
175
+ ary.splice(i, 1);
176
+ i -= 1;
177
+ } else if (part === "..") {
178
+ if (i === 0 || i === 1 && ary[2] === ".." || ary[i - 1] === "..") {
179
+ continue;
180
+ } else if (i > 0) {
181
+ ary.splice(i - 1, 2);
182
+ i -= 2;
183
+ }
184
+ }
185
+ }
186
+ }
187
+ __name(trimDots, "trimDots");
188
+ function normalize(name, baseName, applyMap) {
189
+ var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, foundMap, foundI, foundStarMap, starI, normalizedBaseParts, baseParts = baseName && baseName.split("/"), map = config.map, starMap = map && map["*"];
190
+ if (name) {
191
+ name = name.split("/");
192
+ lastIndex = name.length - 1;
193
+ if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
194
+ name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, "");
195
+ }
196
+ if (name[0].charAt(0) === "." && baseParts) {
197
+ normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
198
+ name = normalizedBaseParts.concat(name);
199
+ }
200
+ trimDots(name);
201
+ name = name.join("/");
202
+ }
203
+ if (applyMap && map && (baseParts || starMap)) {
204
+ nameParts = name.split("/");
205
+ outerLoop: for (i = nameParts.length; i > 0; i -= 1) {
206
+ nameSegment = nameParts.slice(0, i).join("/");
207
+ if (baseParts) {
208
+ for (j = baseParts.length; j > 0; j -= 1) {
209
+ mapValue = getOwn(map, baseParts.slice(0, j).join("/"));
210
+ if (mapValue) {
211
+ mapValue = getOwn(mapValue, nameSegment);
212
+ if (mapValue) {
213
+ foundMap = mapValue;
214
+ foundI = i;
215
+ break outerLoop;
216
+ }
217
+ }
218
+ }
219
+ }
220
+ if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
221
+ foundStarMap = getOwn(starMap, nameSegment);
222
+ starI = i;
223
+ }
224
+ }
225
+ if (!foundMap && foundStarMap) {
226
+ foundMap = foundStarMap;
227
+ foundI = starI;
228
+ }
229
+ if (foundMap) {
230
+ nameParts.splice(0, foundI, foundMap);
231
+ name = nameParts.join("/");
232
+ }
233
+ }
234
+ pkgMain = getOwn(config.pkgs, name);
235
+ return pkgMain ? pkgMain : name;
236
+ }
237
+ __name(normalize, "normalize");
238
+ function removeScript(name) {
239
+ if (isBrowser) {
240
+ each(scripts(), function(scriptNode) {
241
+ if (scriptNode.getAttribute("data-requiremodule") === name && scriptNode.getAttribute("data-requirecontext") === context.contextName) {
242
+ scriptNode.parentNode.removeChild(scriptNode);
243
+ return true;
244
+ }
245
+ });
246
+ }
247
+ }
248
+ __name(removeScript, "removeScript");
249
+ function hasPathFallback(id) {
250
+ var pathConfig = getOwn(config.paths, id);
251
+ if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
252
+ pathConfig.shift();
253
+ context.require.undef(id);
254
+ context.makeRequire(null, {
255
+ skipMap: true
256
+ })([id]);
257
+ return true;
258
+ }
259
+ }
260
+ __name(hasPathFallback, "hasPathFallback");
261
+ function splitPrefix(name) {
262
+ var prefix, index = name ? name.indexOf("!") : -1;
263
+ if (index > -1) {
264
+ prefix = name.substring(0, index);
265
+ name = name.substring(index + 1, name.length);
266
+ }
267
+ return [prefix, name];
268
+ }
269
+ __name(splitPrefix, "splitPrefix");
270
+ function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
271
+ var url, pluginModule, suffix, nameParts, prefix = null, parentName = parentModuleMap ? parentModuleMap.name : null, originalName = name, isDefine = true, normalizedName = "";
272
+ if (!name) {
273
+ isDefine = false;
274
+ name = "_@r" + (requireCounter += 1);
275
+ }
276
+ nameParts = splitPrefix(name);
277
+ prefix = nameParts[0];
278
+ name = nameParts[1];
279
+ if (prefix) {
280
+ prefix = normalize(prefix, parentName, applyMap);
281
+ pluginModule = getOwn(defined, prefix);
282
+ }
283
+ if (name) {
284
+ if (prefix) {
285
+ if (isNormalized) {
286
+ normalizedName = name;
287
+ } else if (pluginModule && pluginModule.normalize) {
288
+ normalizedName = pluginModule.normalize(name, function(name2) {
289
+ return normalize(name2, parentName, applyMap);
290
+ });
291
+ } else {
292
+ normalizedName = name.indexOf("!") === -1 ? normalize(name, parentName, applyMap) : name;
293
+ }
294
+ } else {
295
+ normalizedName = normalize(name, parentName, applyMap);
296
+ nameParts = splitPrefix(normalizedName);
297
+ prefix = nameParts[0];
298
+ normalizedName = nameParts[1];
299
+ isNormalized = true;
300
+ url = context.nameToUrl(normalizedName);
301
+ }
302
+ }
303
+ suffix = prefix && !pluginModule && !isNormalized ? "_unnormalized" + (unnormalizedCounter += 1) : "";
304
+ return {
305
+ prefix,
306
+ name: normalizedName,
307
+ parentMap: parentModuleMap,
308
+ unnormalized: !!suffix,
309
+ url,
310
+ originalName,
311
+ isDefine,
312
+ id: (prefix ? prefix + "!" + normalizedName : normalizedName) + suffix
313
+ };
314
+ }
315
+ __name(makeModuleMap, "makeModuleMap");
316
+ function getModule(depMap) {
317
+ var id = depMap.id, mod = getOwn(registry, id);
318
+ if (!mod) {
319
+ mod = registry[id] = new context.Module(depMap);
320
+ }
321
+ return mod;
322
+ }
323
+ __name(getModule, "getModule");
324
+ function on(depMap, name, fn) {
325
+ var id = depMap.id, mod = getOwn(registry, id);
326
+ if (hasProp(defined, id) && (!mod || mod.defineEmitComplete)) {
327
+ if (name === "defined") {
328
+ fn(defined[id]);
329
+ }
330
+ } else {
331
+ mod = getModule(depMap);
332
+ if (mod.error && name === "error") {
333
+ fn(mod.error);
334
+ } else {
335
+ mod.on(name, fn);
336
+ }
337
+ }
338
+ }
339
+ __name(on, "on");
340
+ function onError(err, errback) {
341
+ var ids = err.requireModules, notified = false;
342
+ if (errback) {
343
+ errback(err);
344
+ } else {
345
+ each(ids, function(id) {
346
+ var mod = getOwn(registry, id);
347
+ if (mod) {
348
+ mod.error = err;
349
+ if (mod.events.error) {
350
+ notified = true;
351
+ mod.emit("error", err);
352
+ }
353
+ }
354
+ });
355
+ if (!notified) {
356
+ req.onError(err);
357
+ }
358
+ }
359
+ }
360
+ __name(onError, "onError");
361
+ function takeGlobalQueue() {
362
+ if (globalDefQueue.length) {
363
+ each(globalDefQueue, function(queueItem) {
364
+ var id = queueItem[0];
365
+ if (typeof id === "string") {
366
+ context.defQueueMap[id] = true;
367
+ }
368
+ defQueue.push(queueItem);
369
+ });
370
+ globalDefQueue = [];
371
+ }
372
+ }
373
+ __name(takeGlobalQueue, "takeGlobalQueue");
374
+ handlers = {
375
+ "require": /* @__PURE__ */ __name(function(mod) {
376
+ if (mod.require) {
377
+ return mod.require;
378
+ } else {
379
+ return mod.require = context.makeRequire(mod.map);
380
+ }
381
+ }, "require"),
382
+ "exports": /* @__PURE__ */ __name(function(mod) {
383
+ mod.usingExports = true;
384
+ if (mod.map.isDefine) {
385
+ if (mod.exports) {
386
+ return defined[mod.map.id] = mod.exports;
387
+ } else {
388
+ return mod.exports = defined[mod.map.id] = {};
389
+ }
390
+ }
391
+ }, "exports"),
392
+ "module": /* @__PURE__ */ __name(function(mod) {
393
+ if (mod.module) {
394
+ return mod.module;
395
+ } else {
396
+ return mod.module = {
397
+ id: mod.map.id,
398
+ uri: mod.map.url,
399
+ config: /* @__PURE__ */ __name(function() {
400
+ return getOwn(config.config, mod.map.id) || {};
401
+ }, "config"),
402
+ exports: mod.exports || (mod.exports = {})
403
+ };
404
+ }
405
+ }, "module")
406
+ };
407
+ function cleanRegistry(id) {
408
+ delete registry[id];
409
+ delete enabledRegistry[id];
410
+ }
411
+ __name(cleanRegistry, "cleanRegistry");
412
+ function breakCycle(mod, traced, processed) {
413
+ var id = mod.map.id;
414
+ if (mod.error) {
415
+ mod.emit("error", mod.error);
416
+ } else {
417
+ traced[id] = true;
418
+ each(mod.depMaps, function(depMap, i) {
419
+ var depId = depMap.id, dep = getOwn(registry, depId);
420
+ if (dep && !mod.depMatched[i] && !processed[depId]) {
421
+ if (getOwn(traced, depId)) {
422
+ mod.defineDep(i, defined[depId]);
423
+ mod.check();
424
+ } else {
425
+ breakCycle(dep, traced, processed);
426
+ }
427
+ }
428
+ });
429
+ processed[id] = true;
430
+ }
431
+ }
432
+ __name(breakCycle, "breakCycle");
433
+ function checkLoaded() {
434
+ var err, usingPathFallback, waitInterval = config.waitSeconds * 1e3, expired = waitInterval && context.startTime + waitInterval < (/* @__PURE__ */ new Date()).getTime(), noLoads = [], reqCalls = [], stillLoading = false, needCycleCheck = true;
435
+ if (inCheckLoaded) {
436
+ return;
437
+ }
438
+ inCheckLoaded = true;
439
+ eachProp(enabledRegistry, function(mod) {
440
+ var map = mod.map, modId = map.id;
441
+ if (!mod.enabled) {
442
+ return;
443
+ }
444
+ if (!map.isDefine) {
445
+ reqCalls.push(mod);
446
+ }
447
+ if (!mod.error) {
448
+ if (!mod.inited && expired) {
449
+ if (hasPathFallback(modId)) {
450
+ usingPathFallback = true;
451
+ stillLoading = true;
452
+ } else {
453
+ noLoads.push(modId);
454
+ removeScript(modId);
455
+ }
456
+ } else if (!mod.inited && mod.fetched && map.isDefine) {
457
+ stillLoading = true;
458
+ if (!map.prefix) {
459
+ return needCycleCheck = false;
460
+ }
461
+ }
462
+ }
463
+ });
464
+ if (expired && noLoads.length) {
465
+ err = makeError("timeout", "Load timeout for modules: " + noLoads, null, noLoads);
466
+ err.contextName = context.contextName;
467
+ return onError(err);
468
+ }
469
+ if (needCycleCheck) {
470
+ each(reqCalls, function(mod) {
471
+ breakCycle(mod, {}, {});
472
+ });
473
+ }
474
+ if ((!expired || usingPathFallback) && stillLoading) {
475
+ if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
476
+ checkLoadedTimeoutId = setTimeout(function() {
477
+ checkLoadedTimeoutId = 0;
478
+ checkLoaded();
479
+ }, 50);
480
+ }
481
+ }
482
+ inCheckLoaded = false;
483
+ }
484
+ __name(checkLoaded, "checkLoaded");
485
+ Module = /* @__PURE__ */ __name(function(map) {
486
+ this.events = getOwn(undefEvents, map.id) || {};
487
+ this.map = map;
488
+ this.shim = getOwn(config.shim, map.id);
489
+ this.depExports = [];
490
+ this.depMaps = [];
491
+ this.depMatched = [];
492
+ this.pluginMaps = {};
493
+ this.depCount = 0;
494
+ }, "Module");
495
+ Module.prototype = {
496
+ init: /* @__PURE__ */ __name(function(depMaps, factory, errback, options) {
497
+ options = options || {};
498
+ if (this.inited) {
499
+ return;
500
+ }
501
+ this.factory = factory;
502
+ if (errback) {
503
+ this.on("error", errback);
504
+ } else if (this.events.error) {
505
+ errback = bind(this, function(err) {
506
+ this.emit("error", err);
507
+ });
508
+ }
509
+ this.depMaps = depMaps && depMaps.slice(0);
510
+ this.errback = errback;
511
+ this.inited = true;
512
+ this.ignore = options.ignore;
513
+ if (options.enabled || this.enabled) {
514
+ this.enable();
515
+ } else {
516
+ this.check();
517
+ }
518
+ }, "init"),
519
+ defineDep: /* @__PURE__ */ __name(function(i, depExports) {
520
+ if (!this.depMatched[i]) {
521
+ this.depMatched[i] = true;
522
+ this.depCount -= 1;
523
+ this.depExports[i] = depExports;
524
+ }
525
+ }, "defineDep"),
526
+ fetch: /* @__PURE__ */ __name(function() {
527
+ if (this.fetched) {
528
+ return;
529
+ }
530
+ this.fetched = true;
531
+ context.startTime = (/* @__PURE__ */ new Date()).getTime();
532
+ var map = this.map;
533
+ if (this.shim) {
534
+ context.makeRequire(this.map, {
535
+ enableBuildCallback: true
536
+ })(this.shim.deps || [], bind(this, function() {
537
+ return map.prefix ? this.callPlugin() : this.load();
538
+ }));
539
+ } else {
540
+ return map.prefix ? this.callPlugin() : this.load();
541
+ }
542
+ }, "fetch"),
543
+ load: /* @__PURE__ */ __name(function() {
544
+ var url = this.map.url;
545
+ if (!urlFetched[url]) {
546
+ urlFetched[url] = true;
547
+ context.load(this.map.id, url);
548
+ }
549
+ }, "load"),
550
+ /**
551
+ * Checks if the module is ready to define itself, and if so,
552
+ * define it.
553
+ */
554
+ check: /* @__PURE__ */ __name(function() {
555
+ if (!this.enabled || this.enabling) {
556
+ return;
557
+ }
558
+ var err, cjsModule, id = this.map.id, depExports = this.depExports, exports2 = this.exports, factory = this.factory;
559
+ if (!this.inited) {
560
+ if (!hasProp(context.defQueueMap, id)) {
561
+ this.fetch();
562
+ }
563
+ } else if (this.error) {
564
+ this.emit("error", this.error);
565
+ } else if (!this.defining) {
566
+ this.defining = true;
567
+ if (this.depCount < 1 && !this.defined) {
568
+ if (isFunction(factory)) {
569
+ if (this.events.error && this.map.isDefine || req.onError !== defaultOnError) {
570
+ try {
571
+ exports2 = context.execCb(id, factory, depExports, exports2);
572
+ } catch (e) {
573
+ err = e;
574
+ }
575
+ } else {
576
+ exports2 = context.execCb(id, factory, depExports, exports2);
577
+ }
578
+ if (this.map.isDefine && exports2 === void 0) {
579
+ cjsModule = this.module;
580
+ if (cjsModule) {
581
+ exports2 = cjsModule.exports;
582
+ } else if (this.usingExports) {
583
+ exports2 = this.exports;
584
+ }
585
+ }
586
+ if (err) {
587
+ err.requireMap = this.map;
588
+ err.requireModules = this.map.isDefine ? [this.map.id] : null;
589
+ err.requireType = this.map.isDefine ? "define" : "require";
590
+ return onError(this.error = err);
591
+ }
592
+ } else {
593
+ exports2 = factory;
594
+ }
595
+ this.exports = exports2;
596
+ if (this.map.isDefine && !this.ignore) {
597
+ defined[id] = exports2;
598
+ if (req.onResourceLoad) {
599
+ var resLoadMaps = [];
600
+ each(this.depMaps, function(depMap) {
601
+ resLoadMaps.push(depMap.normalizedMap || depMap);
602
+ });
603
+ req.onResourceLoad(context, this.map, resLoadMaps);
604
+ }
605
+ }
606
+ cleanRegistry(id);
607
+ this.defined = true;
608
+ }
609
+ this.defining = false;
610
+ if (this.defined && !this.defineEmitted) {
611
+ this.defineEmitted = true;
612
+ this.emit("defined", this.exports);
613
+ this.defineEmitComplete = true;
614
+ }
615
+ }
616
+ }, "check"),
617
+ callPlugin: /* @__PURE__ */ __name(function() {
618
+ var map = this.map, id = map.id, pluginMap = makeModuleMap(map.prefix);
619
+ this.depMaps.push(pluginMap);
620
+ on(pluginMap, "defined", bind(this, function(plugin) {
621
+ var load, normalizedMap, normalizedMod, bundleId = getOwn(bundlesMap, this.map.id), name = this.map.name, parentName = this.map.parentMap ? this.map.parentMap.name : null, localRequire = context.makeRequire(map.parentMap, {
622
+ enableBuildCallback: true
623
+ });
624
+ if (this.map.unnormalized) {
625
+ if (plugin.normalize) {
626
+ name = plugin.normalize(name, function(name2) {
627
+ return normalize(name2, parentName, true);
628
+ }) || "";
629
+ }
630
+ normalizedMap = makeModuleMap(
631
+ map.prefix + "!" + name,
632
+ this.map.parentMap,
633
+ true
634
+ );
635
+ on(
636
+ normalizedMap,
637
+ "defined",
638
+ bind(this, function(value) {
639
+ this.map.normalizedMap = normalizedMap;
640
+ this.init([], function() {
641
+ return value;
642
+ }, null, {
643
+ enabled: true,
644
+ ignore: true
645
+ });
646
+ })
647
+ );
648
+ normalizedMod = getOwn(registry, normalizedMap.id);
649
+ if (normalizedMod) {
650
+ this.depMaps.push(normalizedMap);
651
+ if (this.events.error) {
652
+ normalizedMod.on("error", bind(this, function(err) {
653
+ this.emit("error", err);
654
+ }));
655
+ }
656
+ normalizedMod.enable();
657
+ }
658
+ return;
659
+ }
660
+ if (bundleId) {
661
+ this.map.url = context.nameToUrl(bundleId);
662
+ this.load();
663
+ return;
664
+ }
665
+ load = bind(this, function(value) {
666
+ this.init([], function() {
667
+ return value;
668
+ }, null, {
669
+ enabled: true
670
+ });
671
+ });
672
+ load.error = bind(this, function(err) {
673
+ this.inited = true;
674
+ this.error = err;
675
+ err.requireModules = [id];
676
+ eachProp(registry, function(mod) {
677
+ if (mod.map.id.indexOf(id + "_unnormalized") === 0) {
678
+ cleanRegistry(mod.map.id);
679
+ }
680
+ });
681
+ onError(err);
682
+ });
683
+ load.fromText = bind(this, function(text2, textAlt) {
684
+ var moduleName = map.name, moduleMap = makeModuleMap(moduleName), hasInteractive = useInteractive;
685
+ if (textAlt) {
686
+ text2 = textAlt;
687
+ }
688
+ if (hasInteractive) {
689
+ useInteractive = false;
690
+ }
691
+ getModule(moduleMap);
692
+ if (hasProp(config.config, id)) {
693
+ config.config[moduleName] = config.config[id];
694
+ }
695
+ try {
696
+ req.exec(text2);
697
+ } catch (e) {
698
+ return onError(makeError(
699
+ "fromtexteval",
700
+ "fromText eval for " + id + " failed: " + e,
701
+ e,
702
+ [id]
703
+ ));
704
+ }
705
+ if (hasInteractive) {
706
+ useInteractive = true;
707
+ }
708
+ this.depMaps.push(moduleMap);
709
+ context.completeLoad(moduleName);
710
+ localRequire([moduleName], load);
711
+ });
712
+ plugin.load(map.name, localRequire, load, config);
713
+ }));
714
+ context.enable(pluginMap, this);
715
+ this.pluginMaps[pluginMap.id] = pluginMap;
716
+ }, "callPlugin"),
717
+ enable: /* @__PURE__ */ __name(function() {
718
+ enabledRegistry[this.map.id] = this;
719
+ this.enabled = true;
720
+ this.enabling = true;
721
+ each(this.depMaps, bind(this, function(depMap, i) {
722
+ var id, mod, handler;
723
+ if (typeof depMap === "string") {
724
+ depMap = makeModuleMap(
725
+ depMap,
726
+ this.map.isDefine ? this.map : this.map.parentMap,
727
+ false,
728
+ !this.skipMap
729
+ );
730
+ this.depMaps[i] = depMap;
731
+ handler = getOwn(handlers, depMap.id);
732
+ if (handler) {
733
+ this.depExports[i] = handler(this);
734
+ return;
735
+ }
736
+ this.depCount += 1;
737
+ on(depMap, "defined", bind(this, function(depExports) {
738
+ if (this.undefed) {
739
+ return;
740
+ }
741
+ this.defineDep(i, depExports);
742
+ this.check();
743
+ }));
744
+ if (this.errback) {
745
+ on(depMap, "error", bind(this, this.errback));
746
+ } else if (this.events.error) {
747
+ on(depMap, "error", bind(this, function(err) {
748
+ this.emit("error", err);
749
+ }));
750
+ }
751
+ }
752
+ id = depMap.id;
753
+ mod = registry[id];
754
+ if (!hasProp(handlers, id) && mod && !mod.enabled) {
755
+ context.enable(depMap, this);
756
+ }
757
+ }));
758
+ eachProp(this.pluginMaps, bind(this, function(pluginMap) {
759
+ var mod = getOwn(registry, pluginMap.id);
760
+ if (mod && !mod.enabled) {
761
+ context.enable(pluginMap, this);
762
+ }
763
+ }));
764
+ this.enabling = false;
765
+ this.check();
766
+ }, "enable"),
767
+ on: /* @__PURE__ */ __name(function(name, cb) {
768
+ var cbs = this.events[name];
769
+ if (!cbs) {
770
+ cbs = this.events[name] = [];
771
+ }
772
+ cbs.push(cb);
773
+ }, "on"),
774
+ emit: /* @__PURE__ */ __name(function(name, evt) {
775
+ each(this.events[name], function(cb) {
776
+ cb(evt);
777
+ });
778
+ if (name === "error") {
779
+ delete this.events[name];
780
+ }
781
+ }, "emit")
782
+ };
783
+ function callGetModule(args) {
784
+ if (!hasProp(defined, args[0])) {
785
+ getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
786
+ }
787
+ }
788
+ __name(callGetModule, "callGetModule");
789
+ function removeListener(node, func, name, ieName) {
790
+ if (node.detachEvent && !isOpera) {
791
+ if (ieName) {
792
+ node.detachEvent(ieName, func);
793
+ }
794
+ } else {
795
+ node.removeEventListener(name, func, false);
796
+ }
797
+ }
798
+ __name(removeListener, "removeListener");
799
+ function getScriptData(evt) {
800
+ var node = evt.currentTarget || evt.srcElement;
801
+ removeListener(node, context.onScriptLoad, "load", "onreadystatechange");
802
+ removeListener(node, context.onScriptError, "error");
803
+ return {
804
+ node,
805
+ id: node && node.getAttribute("data-requiremodule")
806
+ };
807
+ }
808
+ __name(getScriptData, "getScriptData");
809
+ function intakeDefines() {
810
+ var args;
811
+ takeGlobalQueue();
812
+ while (defQueue.length) {
813
+ args = defQueue.shift();
814
+ if (args[0] === null) {
815
+ return onError(makeError("mismatch", "Mismatched anonymous define() module: " + args[args.length - 1]));
816
+ } else {
817
+ callGetModule(args);
818
+ }
819
+ }
820
+ context.defQueueMap = {};
821
+ }
822
+ __name(intakeDefines, "intakeDefines");
823
+ context = {
824
+ config,
825
+ contextName,
826
+ registry,
827
+ defined,
828
+ urlFetched,
829
+ defQueue,
830
+ defQueueMap: {},
831
+ Module,
832
+ makeModuleMap,
833
+ nextTick: req.nextTick,
834
+ onError,
835
+ /**
836
+ * Set a configuration for the context.
837
+ * @param {Object} cfg config object to integrate.
838
+ */
839
+ configure: /* @__PURE__ */ __name(function(cfg2) {
840
+ if (cfg2.baseUrl) {
841
+ if (cfg2.baseUrl.charAt(cfg2.baseUrl.length - 1) !== "/") {
842
+ cfg2.baseUrl += "/";
843
+ }
844
+ }
845
+ if (typeof cfg2.urlArgs === "string") {
846
+ var urlArgs = cfg2.urlArgs;
847
+ cfg2.urlArgs = function(id, url) {
848
+ return (url.indexOf("?") === -1 ? "?" : "&") + urlArgs;
849
+ };
850
+ }
851
+ var shim = config.shim, objs = {
852
+ paths: true,
853
+ bundles: true,
854
+ config: true,
855
+ map: true
856
+ };
857
+ eachProp(cfg2, function(value, prop) {
858
+ if (objs[prop]) {
859
+ if (!config[prop]) {
860
+ config[prop] = {};
861
+ }
862
+ mixin(config[prop], value, true, true);
863
+ } else {
864
+ config[prop] = value;
865
+ }
866
+ });
867
+ if (cfg2.bundles) {
868
+ eachProp(cfg2.bundles, function(value, prop) {
869
+ each(value, function(v) {
870
+ if (v !== prop) {
871
+ bundlesMap[v] = prop;
872
+ }
873
+ });
874
+ });
875
+ }
876
+ if (cfg2.shim) {
877
+ eachProp(cfg2.shim, function(value, id) {
878
+ if (isArray(value)) {
879
+ value = {
880
+ deps: value
881
+ };
882
+ }
883
+ if ((value.exports || value.init) && !value.exportsFn) {
884
+ value.exportsFn = context.makeShimExports(value);
885
+ }
886
+ shim[id] = value;
887
+ });
888
+ config.shim = shim;
889
+ }
890
+ if (cfg2.packages) {
891
+ each(cfg2.packages, function(pkgObj) {
892
+ var location, name;
893
+ pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
894
+ name = pkgObj.name;
895
+ location = pkgObj.location;
896
+ if (location) {
897
+ config.paths[name] = pkgObj.location;
898
+ }
899
+ config.pkgs[name] = pkgObj.name + "/" + (pkgObj.main || "main").replace(currDirRegExp, "").replace(jsSuffixRegExp, "");
900
+ });
901
+ }
902
+ eachProp(registry, function(mod, id) {
903
+ if (!mod.inited && !mod.map.unnormalized) {
904
+ mod.map = makeModuleMap(id, null, true);
905
+ }
906
+ });
907
+ if (cfg2.deps || cfg2.callback) {
908
+ context.require(cfg2.deps || [], cfg2.callback);
909
+ }
910
+ }, "configure"),
911
+ makeShimExports: /* @__PURE__ */ __name(function(value) {
912
+ function fn() {
913
+ var ret;
914
+ if (value.init) {
915
+ ret = value.init.apply(global, arguments);
916
+ }
917
+ return ret || value.exports && getGlobal(value.exports);
918
+ }
919
+ __name(fn, "fn");
920
+ return fn;
921
+ }, "makeShimExports"),
922
+ makeRequire: /* @__PURE__ */ __name(function(relMap, options) {
923
+ options = options || {};
924
+ function localRequire(deps, callback, errback) {
925
+ var id, map, requireMod;
926
+ if (options.enableBuildCallback && callback && isFunction(callback)) {
927
+ callback.__requireJsBuild = true;
928
+ }
929
+ if (typeof deps === "string") {
930
+ if (isFunction(callback)) {
931
+ return onError(makeError("requireargs", "Invalid require call"), errback);
932
+ }
933
+ if (relMap && hasProp(handlers, deps)) {
934
+ return handlers[deps](registry[relMap.id]);
935
+ }
936
+ if (req.get) {
937
+ return req.get(context, deps, relMap, localRequire);
938
+ }
939
+ map = makeModuleMap(deps, relMap, false, true);
940
+ id = map.id;
941
+ if (!hasProp(defined, id)) {
942
+ return onError(makeError("notloaded", 'Module name "' + id + '" has not been loaded yet for context: ' + contextName + (relMap ? "" : ". Use require([])")));
943
+ }
944
+ return defined[id];
945
+ }
946
+ intakeDefines();
947
+ context.nextTick(function() {
948
+ intakeDefines();
949
+ requireMod = getModule(makeModuleMap(null, relMap));
950
+ requireMod.skipMap = options.skipMap;
951
+ requireMod.init(deps, callback, errback, {
952
+ enabled: true
953
+ });
954
+ checkLoaded();
955
+ });
956
+ return localRequire;
957
+ }
958
+ __name(localRequire, "localRequire");
959
+ mixin(localRequire, {
960
+ isBrowser,
961
+ /**
962
+ * Converts a module name + .extension into an URL path.
963
+ * *Requires* the use of a module name. It does not support using
964
+ * plain URLs like nameToUrl.
965
+ */
966
+ toUrl: /* @__PURE__ */ __name(function(moduleNamePlusExt) {
967
+ var ext, index = moduleNamePlusExt.lastIndexOf("."), segment = moduleNamePlusExt.split("/")[0], isRelative = segment === "." || segment === "..";
968
+ if (index !== -1 && (!isRelative || index > 1)) {
969
+ ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
970
+ moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
971
+ }
972
+ return context.nameToUrl(normalize(
973
+ moduleNamePlusExt,
974
+ relMap && relMap.id,
975
+ true
976
+ ), ext, true);
977
+ }, "toUrl"),
978
+ defined: /* @__PURE__ */ __name(function(id) {
979
+ return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
980
+ }, "defined"),
981
+ specified: /* @__PURE__ */ __name(function(id) {
982
+ id = makeModuleMap(id, relMap, false, true).id;
983
+ return hasProp(defined, id) || hasProp(registry, id);
984
+ }, "specified")
985
+ });
986
+ if (!relMap) {
987
+ localRequire.undef = function(id) {
988
+ takeGlobalQueue();
989
+ var map = makeModuleMap(id, relMap, true), mod = getOwn(registry, id);
990
+ mod.undefed = true;
991
+ removeScript(id);
992
+ delete defined[id];
993
+ delete urlFetched[map.url];
994
+ delete undefEvents[id];
995
+ eachReverse(defQueue, function(args, i) {
996
+ if (args[0] === id) {
997
+ defQueue.splice(i, 1);
998
+ }
999
+ });
1000
+ delete context.defQueueMap[id];
1001
+ if (mod) {
1002
+ if (mod.events.defined) {
1003
+ undefEvents[id] = mod.events;
1004
+ }
1005
+ cleanRegistry(id);
1006
+ }
1007
+ };
1008
+ }
1009
+ return localRequire;
1010
+ }, "makeRequire"),
1011
+ /**
1012
+ * Called to enable a module if it is still in the registry
1013
+ * awaiting enablement. A second arg, parent, the parent module,
1014
+ * is passed in for context, when this method is overridden by
1015
+ * the optimizer. Not shown here to keep code compact.
1016
+ */
1017
+ enable: /* @__PURE__ */ __name(function(depMap) {
1018
+ var mod = getOwn(registry, depMap.id);
1019
+ if (mod) {
1020
+ getModule(depMap).enable();
1021
+ }
1022
+ }, "enable"),
1023
+ /**
1024
+ * Internal method used by environment adapters to complete a load event.
1025
+ * A load event could be a script load or just a load pass from a synchronous
1026
+ * load call.
1027
+ * @param {String} moduleName the name of the module to potentially complete.
1028
+ */
1029
+ completeLoad: /* @__PURE__ */ __name(function(moduleName) {
1030
+ var found, args, mod, shim = getOwn(config.shim, moduleName) || {}, shExports = shim.exports;
1031
+ takeGlobalQueue();
1032
+ while (defQueue.length) {
1033
+ args = defQueue.shift();
1034
+ if (args[0] === null) {
1035
+ args[0] = moduleName;
1036
+ if (found) {
1037
+ break;
1038
+ }
1039
+ found = true;
1040
+ } else if (args[0] === moduleName) {
1041
+ found = true;
1042
+ }
1043
+ callGetModule(args);
1044
+ }
1045
+ context.defQueueMap = {};
1046
+ mod = getOwn(registry, moduleName);
1047
+ if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
1048
+ if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
1049
+ if (hasPathFallback(moduleName)) {
1050
+ return;
1051
+ } else {
1052
+ return onError(makeError(
1053
+ "nodefine",
1054
+ "No define call for " + moduleName,
1055
+ null,
1056
+ [moduleName]
1057
+ ));
1058
+ }
1059
+ } else {
1060
+ callGetModule([moduleName, shim.deps || [], shim.exportsFn]);
1061
+ }
1062
+ }
1063
+ checkLoaded();
1064
+ }, "completeLoad"),
1065
+ /**
1066
+ * Converts a module name to a file path. Supports cases where
1067
+ * moduleName may actually be just an URL.
1068
+ * Note that it **does not** call normalize on the moduleName,
1069
+ * it is assumed to have already been normalized. This is an
1070
+ * internal API, not a public one. Use toUrl for the public API.
1071
+ */
1072
+ nameToUrl: /* @__PURE__ */ __name(function(moduleName, ext, skipExt) {
1073
+ var paths, syms, i, parentModule, url, parentPath, bundleId, pkgMain = getOwn(config.pkgs, moduleName);
1074
+ if (pkgMain) {
1075
+ moduleName = pkgMain;
1076
+ }
1077
+ bundleId = getOwn(bundlesMap, moduleName);
1078
+ if (bundleId) {
1079
+ return context.nameToUrl(bundleId, ext, skipExt);
1080
+ }
1081
+ if (req.jsExtRegExp.test(moduleName)) {
1082
+ url = moduleName + (ext || "");
1083
+ } else {
1084
+ paths = config.paths;
1085
+ syms = moduleName.split("/");
1086
+ for (i = syms.length; i > 0; i -= 1) {
1087
+ parentModule = syms.slice(0, i).join("/");
1088
+ parentPath = getOwn(paths, parentModule);
1089
+ if (parentPath) {
1090
+ if (isArray(parentPath)) {
1091
+ parentPath = parentPath[0];
1092
+ }
1093
+ syms.splice(0, i, parentPath);
1094
+ break;
1095
+ }
1096
+ }
1097
+ url = syms.join("/");
1098
+ url += ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? "" : ".js");
1099
+ url = (url.charAt(0) === "/" || url.match(/^[\w\+\.\-]+:/) ? "" : config.baseUrl) + url;
1100
+ }
1101
+ return config.urlArgs && !/^blob\:/.test(url) ? url + config.urlArgs(moduleName, url) : url;
1102
+ }, "nameToUrl"),
1103
+ //Delegates to req.load. Broken out as a separate function to
1104
+ //allow overriding in the optimizer.
1105
+ load: /* @__PURE__ */ __name(function(id, url) {
1106
+ req.load(context, id, url);
1107
+ }, "load"),
1108
+ /**
1109
+ * Executes a module callback function. Broken out as a separate function
1110
+ * solely to allow the build system to sequence the files in the built
1111
+ * layer in the right sequence.
1112
+ *
1113
+ * @private
1114
+ */
1115
+ execCb: /* @__PURE__ */ __name(function(name, callback, args, exports2) {
1116
+ return callback.apply(exports2, args);
1117
+ }, "execCb"),
1118
+ /**
1119
+ * callback for script loads, used to check status of loading.
1120
+ *
1121
+ * @param {Event} evt the event from the browser for the script
1122
+ * that was loaded.
1123
+ */
1124
+ onScriptLoad: /* @__PURE__ */ __name(function(evt) {
1125
+ if (evt.type === "load" || readyRegExp.test((evt.currentTarget || evt.srcElement).readyState)) {
1126
+ interactiveScript = null;
1127
+ var data = getScriptData(evt);
1128
+ context.completeLoad(data.id);
1129
+ }
1130
+ }, "onScriptLoad"),
1131
+ /**
1132
+ * Callback for script errors.
1133
+ */
1134
+ onScriptError: /* @__PURE__ */ __name(function(evt) {
1135
+ var data = getScriptData(evt);
1136
+ if (!hasPathFallback(data.id)) {
1137
+ var parents = [];
1138
+ eachProp(registry, function(value, key) {
1139
+ if (key.indexOf("_@r") !== 0) {
1140
+ each(value.depMaps, function(depMap) {
1141
+ if (depMap.id === data.id) {
1142
+ parents.push(key);
1143
+ return true;
1144
+ }
1145
+ });
1146
+ }
1147
+ });
1148
+ return onError(makeError("scripterror", 'Script error for "' + data.id + (parents.length ? '", needed by: ' + parents.join(", ") : '"'), evt, [data.id]));
1149
+ }
1150
+ }, "onScriptError")
1151
+ };
1152
+ context.require = context.makeRequire();
1153
+ return context;
1154
+ }
1155
+ __name(newContext, "newContext");
1156
+ req = requirejs = /* @__PURE__ */ __name(function(deps, callback, errback, optional) {
1157
+ var context, config, contextName = defContextName;
1158
+ if (!isArray(deps) && typeof deps !== "string") {
1159
+ config = deps;
1160
+ if (isArray(callback)) {
1161
+ deps = callback;
1162
+ callback = errback;
1163
+ errback = optional;
1164
+ } else {
1165
+ deps = [];
1166
+ }
1167
+ }
1168
+ if (config && config.context) {
1169
+ contextName = config.context;
1170
+ }
1171
+ context = getOwn(contexts, contextName);
1172
+ if (!context) {
1173
+ context = contexts[contextName] = req.s.newContext(contextName);
1174
+ }
1175
+ if (config) {
1176
+ context.configure(config);
1177
+ }
1178
+ return context.require(deps, callback, errback);
1179
+ }, "requirejs");
1180
+ req.config = function(config) {
1181
+ return req(config);
1182
+ };
1183
+ req.nextTick = typeof setTimeout !== "undefined" ? function(fn) {
1184
+ setTimeout(fn, 4);
1185
+ } : function(fn) {
1186
+ fn();
1187
+ };
1188
+ if (!require) {
1189
+ require = req;
1190
+ }
1191
+ req.version = version;
1192
+ req.jsExtRegExp = /^\/|:|\?|\.js$/;
1193
+ req.isBrowser = isBrowser;
1194
+ s = req.s = {
1195
+ contexts,
1196
+ newContext
1197
+ };
1198
+ req({});
1199
+ each([
1200
+ "toUrl",
1201
+ "undef",
1202
+ "defined",
1203
+ "specified"
1204
+ ], function(prop) {
1205
+ req[prop] = function() {
1206
+ var ctx = contexts[defContextName];
1207
+ return ctx.require[prop].apply(ctx, arguments);
1208
+ };
1209
+ });
1210
+ if (isBrowser) {
1211
+ head = s.head = document.getElementsByTagName("head")[0];
1212
+ baseElement = document.getElementsByTagName("base")[0];
1213
+ if (baseElement) {
1214
+ head = s.head = baseElement.parentNode;
1215
+ }
1216
+ }
1217
+ req.onError = defaultOnError;
1218
+ req.createNode = function(config, moduleName, url) {
1219
+ var node = config.xhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") : document.createElement("script");
1220
+ node.type = config.scriptType || "text/javascript";
1221
+ node.charset = "utf-8";
1222
+ node.async = true;
1223
+ return node;
1224
+ };
1225
+ req.load = function(context, moduleName, url) {
1226
+ var config = context && context.config || {}, node;
1227
+ if (isBrowser) {
1228
+ node = req.createNode(config, moduleName, url);
1229
+ node.setAttribute("data-requirecontext", context.contextName);
1230
+ node.setAttribute("data-requiremodule", moduleName);
1231
+ if (node.attachEvent && //Check if node.attachEvent is artificially added by custom script or
1232
+ //natively supported by browser
1233
+ //read https://github.com/requirejs/requirejs/issues/187
1234
+ //if we can NOT find [native code] then it must NOT natively supported.
1235
+ //in IE8, node.attachEvent does not have toString()
1236
+ //Note the test for "[native code" with no closing brace, see:
1237
+ //https://github.com/requirejs/requirejs/issues/273
1238
+ !(node.attachEvent.toString && node.attachEvent.toString().indexOf("[native code") < 0) && !isOpera) {
1239
+ useInteractive = true;
1240
+ node.attachEvent("onreadystatechange", context.onScriptLoad);
1241
+ } else {
1242
+ node.addEventListener("load", context.onScriptLoad, false);
1243
+ node.addEventListener("error", context.onScriptError, false);
1244
+ }
1245
+ node.src = url;
1246
+ if (config.onNodeCreated) {
1247
+ config.onNodeCreated(node, config, moduleName, url);
1248
+ }
1249
+ currentlyAddingScript = node;
1250
+ if (baseElement) {
1251
+ head.insertBefore(node, baseElement);
1252
+ } else {
1253
+ head.appendChild(node);
1254
+ }
1255
+ currentlyAddingScript = null;
1256
+ return node;
1257
+ } else if (isWebWorker) {
1258
+ try {
1259
+ setTimeout(function() {
1260
+ }, 0);
1261
+ importScripts(url);
1262
+ context.completeLoad(moduleName);
1263
+ } catch (e) {
1264
+ context.onError(makeError(
1265
+ "importscripts",
1266
+ "importScripts failed for " + moduleName + " at " + url,
1267
+ e,
1268
+ [moduleName]
1269
+ ));
1270
+ }
1271
+ }
1272
+ };
1273
+ function getInteractiveScript() {
1274
+ if (interactiveScript && interactiveScript.readyState === "interactive") {
1275
+ return interactiveScript;
1276
+ }
1277
+ eachReverse(scripts(), function(script) {
1278
+ if (script.readyState === "interactive") {
1279
+ return interactiveScript = script;
1280
+ }
1281
+ });
1282
+ return interactiveScript;
1283
+ }
1284
+ __name(getInteractiveScript, "getInteractiveScript");
1285
+ if (isBrowser && !cfg.skipDataMain) {
1286
+ eachReverse(scripts(), function(script) {
1287
+ if (!head) {
1288
+ head = script.parentNode;
1289
+ }
1290
+ dataMain = script.getAttribute("data-main");
1291
+ if (dataMain) {
1292
+ mainScript = dataMain;
1293
+ if (!cfg.baseUrl && mainScript.indexOf("!") === -1) {
1294
+ src = mainScript.split("/");
1295
+ mainScript = src.pop();
1296
+ subPath = src.length ? src.join("/") + "/" : "./";
1297
+ cfg.baseUrl = subPath;
1298
+ }
1299
+ mainScript = mainScript.replace(jsSuffixRegExp, "");
1300
+ if (req.jsExtRegExp.test(mainScript)) {
1301
+ mainScript = dataMain;
1302
+ }
1303
+ cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];
1304
+ return true;
1305
+ }
1306
+ });
1307
+ }
1308
+ define = /* @__PURE__ */ __name(function(name, deps, callback) {
1309
+ var node, context;
1310
+ if (typeof name !== "string") {
1311
+ callback = deps;
1312
+ deps = name;
1313
+ name = null;
1314
+ }
1315
+ if (!isArray(deps)) {
1316
+ callback = deps;
1317
+ deps = null;
1318
+ }
1319
+ if (!deps && isFunction(callback)) {
1320
+ deps = [];
1321
+ if (callback.length) {
1322
+ callback.toString().replace(commentRegExp, commentReplace).replace(cjsRequireRegExp, function(match, dep) {
1323
+ deps.push(dep);
1324
+ });
1325
+ deps = (callback.length === 1 ? ["require"] : ["require", "exports", "module"]).concat(deps);
1326
+ }
1327
+ }
1328
+ if (useInteractive) {
1329
+ node = currentlyAddingScript || getInteractiveScript();
1330
+ if (node) {
1331
+ if (!name) {
1332
+ name = node.getAttribute("data-requiremodule");
1333
+ }
1334
+ context = contexts[node.getAttribute("data-requirecontext")];
1335
+ }
1336
+ }
1337
+ if (context) {
1338
+ context.defQueue.push([name, deps, callback]);
1339
+ context.defQueueMap[name] = true;
1340
+ } else {
1341
+ globalDefQueue.push([name, deps, callback]);
1342
+ }
1343
+ }, "define");
1344
+ define.amd = {
1345
+ jQuery: true
1346
+ };
1347
+ req.exec = function(text) {
1348
+ return eval(text);
1349
+ };
1350
+ req(cfg);
1351
+ return {
1352
+ requirejs,
1353
+ require,
1354
+ define
1355
+ };
1356
+ }
1357
+ __name(getRequireJs, "getRequireJs");
1358
+ // Annotate the CommonJS export names for ESM import in node:
1359
+ 0 && (module.exports = {
1360
+ getRequireJs
1361
+ });