@trackunit/custom-field-api 0.1.13 → 0.1.14

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 (3) hide show
  1. package/index.cjs.js +12 -3942
  2. package/index.esm.js +9 -3939
  3. package/package.json +13 -2
package/index.esm.js CHANGED
@@ -1,3937 +1,7 @@
1
+ import { useQuery } from '@apollo/client';
1
2
  import { useCurrentUserLanguage } from '@trackunit/react-core-hooks';
2
3
  import { nonNullable } from '@trackunit/shared-utils';
3
-
4
- function _mergeNamespaces(n, m) {
5
- m.forEach(function (e) {
6
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
7
- if (k !== 'default' && !(k in n)) {
8
- var d = Object.getOwnPropertyDescriptor(e, k);
9
- Object.defineProperty(n, k, d.get ? d : {
10
- enumerable: true,
11
- get: function () { return e[k]; }
12
- });
13
- }
14
- });
15
- });
16
- return Object.freeze(n);
17
- }
18
-
19
- /******************************************************************************
20
- Copyright (c) Microsoft Corporation.
21
-
22
- Permission to use, copy, modify, and/or distribute this software for any
23
- purpose with or without fee is hereby granted.
24
-
25
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
26
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
27
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
28
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
29
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31
- PERFORMANCE OF THIS SOFTWARE.
32
- ***************************************************************************** */
33
- /* global Reflect, Promise */
34
-
35
- var extendStatics = function(d, b) {
36
- extendStatics = Object.setPrototypeOf ||
37
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
38
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
39
- return extendStatics(d, b);
40
- };
41
-
42
- function __extends(d, b) {
43
- if (typeof b !== "function" && b !== null)
44
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
45
- extendStatics(d, b);
46
- function __() { this.constructor = d; }
47
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
48
- }
49
-
50
- var __assign = function() {
51
- __assign = Object.assign || function __assign(t) {
52
- for (var s, i = 1, n = arguments.length; i < n; i++) {
53
- s = arguments[i];
54
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
55
- }
56
- return t;
57
- };
58
- return __assign.apply(this, arguments);
59
- };
60
-
61
- function __rest(s, e) {
62
- var t = {};
63
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
64
- t[p] = s[p];
65
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
66
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
67
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
68
- t[p[i]] = s[p[i]];
69
- }
70
- return t;
71
- }
72
-
73
- var genericMessage = "Invariant Violation";
74
- var _a$1 = Object.setPrototypeOf, setPrototypeOf = _a$1 === void 0 ? function (obj, proto) {
75
- obj.__proto__ = proto;
76
- return obj;
77
- } : _a$1;
78
- var InvariantError = /** @class */ (function (_super) {
79
- __extends(InvariantError, _super);
80
- function InvariantError(message) {
81
- if (message === void 0) { message = genericMessage; }
82
- var _this = _super.call(this, typeof message === "number"
83
- ? genericMessage + ": " + message + " (see https://github.com/apollographql/invariant-packages)"
84
- : message) || this;
85
- _this.framesToPop = 1;
86
- _this.name = genericMessage;
87
- setPrototypeOf(_this, InvariantError.prototype);
88
- return _this;
89
- }
90
- return InvariantError;
91
- }(Error));
92
- function invariant(condition, message) {
93
- if (!condition) {
94
- throw new InvariantError(message);
95
- }
96
- }
97
- var verbosityLevels = ["debug", "log", "warn", "error", "silent"];
98
- var verbosityLevel = verbosityLevels.indexOf("log");
99
- function wrapConsoleMethod(name) {
100
- return function () {
101
- if (verbosityLevels.indexOf(name) >= verbosityLevel) {
102
- // Default to console.log if this host environment happens not to provide
103
- // all the console.* methods we need.
104
- var method = console[name] || console.log;
105
- return method.apply(console, arguments);
106
- }
107
- };
108
- }
109
- (function (invariant) {
110
- invariant.debug = wrapConsoleMethod("debug");
111
- invariant.log = wrapConsoleMethod("log");
112
- invariant.warn = wrapConsoleMethod("warn");
113
- invariant.error = wrapConsoleMethod("error");
114
- })(invariant || (invariant = {}));
115
-
116
- function maybe$1(thunk) {
117
- try {
118
- return thunk();
119
- }
120
- catch (_a) { }
121
- }
122
-
123
- var global$1 = (maybe$1(function () { return globalThis; }) ||
124
- maybe$1(function () { return window; }) ||
125
- maybe$1(function () { return self; }) ||
126
- maybe$1(function () { return global; }) || maybe$1(function () { return maybe$1.constructor("return this")(); }));
127
-
128
- var __ = "__";
129
- var GLOBAL_KEY = [__, __].join("DEV");
130
- function getDEV() {
131
- try {
132
- return Boolean(__DEV__);
133
- }
134
- catch (_a) {
135
- Object.defineProperty(global$1, GLOBAL_KEY, {
136
- value: maybe$1(function () { return process.env.NODE_ENV; }) !== "production",
137
- enumerable: false,
138
- configurable: true,
139
- writable: true,
140
- });
141
- return global$1[GLOBAL_KEY];
142
- }
143
- }
144
- var DEV = getDEV();
145
-
146
- function maybe(thunk) {
147
- try { return thunk() } catch (_) {}
148
- }
149
-
150
- var safeGlobal = (
151
- maybe(function() { return globalThis }) ||
152
- maybe(function() { return window }) ||
153
- maybe(function() { return self }) ||
154
- maybe(function() { return global }) ||
155
- // We don't expect the Function constructor ever to be invoked at runtime, as
156
- // long as at least one of globalThis, window, self, or global is defined, so
157
- // we are under no obligation to make it easy for static analysis tools to
158
- // detect syntactic usage of the Function constructor. If you think you can
159
- // improve your static analysis to detect this obfuscation, think again. This
160
- // is an arms race you cannot win, at least not in JavaScript.
161
- maybe(function() { return maybe.constructor("return this")() })
162
- );
163
-
164
- var needToRemove = false;
165
-
166
- function install() {
167
- if (safeGlobal &&
168
- !maybe(function() { return process.env.NODE_ENV }) &&
169
- !maybe(function() { return process })) {
170
- Object.defineProperty(safeGlobal, "process", {
171
- value: {
172
- env: {
173
- // This default needs to be "production" instead of "development", to
174
- // avoid the problem https://github.com/graphql/graphql-js/pull/2894
175
- // will eventually solve, once merged and released.
176
- NODE_ENV: "production",
177
- },
178
- },
179
- // Let anyone else change global.process as they see fit, but hide it from
180
- // Object.keys(global) enumeration.
181
- configurable: true,
182
- enumerable: false,
183
- writable: true,
184
- });
185
- needToRemove = true;
186
- }
187
- }
188
-
189
- // Call install() at least once, when this module is imported.
190
- install();
191
-
192
- function remove() {
193
- if (needToRemove) {
194
- delete safeGlobal.process;
195
- needToRemove = false;
196
- }
197
- }
198
-
199
- // In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
200
-
201
- var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag != null ? Symbol.toStringTag : '@@toStringTag';
202
-
203
- // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
204
- var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
205
- var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
206
-
207
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
208
- var MAX_ARRAY_LENGTH = 10;
209
- var MAX_RECURSIVE_DEPTH = 2;
210
- /**
211
- * Used to print values in error messages.
212
- */
213
-
214
- function inspect(value) {
215
- return formatValue(value, []);
216
- }
217
-
218
- function formatValue(value, seenValues) {
219
- switch (_typeof(value)) {
220
- case 'string':
221
- return JSON.stringify(value);
222
-
223
- case 'function':
224
- return value.name ? "[function ".concat(value.name, "]") : '[function]';
225
-
226
- case 'object':
227
- if (value === null) {
228
- return 'null';
229
- }
230
-
231
- return formatObjectValue(value, seenValues);
232
-
233
- default:
234
- return String(value);
235
- }
236
- }
237
-
238
- function formatObjectValue(value, previouslySeenValues) {
239
- if (previouslySeenValues.indexOf(value) !== -1) {
240
- return '[Circular]';
241
- }
242
-
243
- var seenValues = [].concat(previouslySeenValues, [value]);
244
- var customInspectFn = getCustomFn(value);
245
-
246
- if (customInspectFn !== undefined) {
247
- var customValue = customInspectFn.call(value); // check for infinite recursion
248
-
249
- if (customValue !== value) {
250
- return typeof customValue === 'string' ? customValue : formatValue(customValue, seenValues);
251
- }
252
- } else if (Array.isArray(value)) {
253
- return formatArray(value, seenValues);
254
- }
255
-
256
- return formatObject(value, seenValues);
257
- }
258
-
259
- function formatObject(object, seenValues) {
260
- var keys = Object.keys(object);
261
-
262
- if (keys.length === 0) {
263
- return '{}';
264
- }
265
-
266
- if (seenValues.length > MAX_RECURSIVE_DEPTH) {
267
- return '[' + getObjectTag(object) + ']';
268
- }
269
-
270
- var properties = keys.map(function (key) {
271
- var value = formatValue(object[key], seenValues);
272
- return key + ': ' + value;
273
- });
274
- return '{ ' + properties.join(', ') + ' }';
275
- }
276
-
277
- function formatArray(array, seenValues) {
278
- if (array.length === 0) {
279
- return '[]';
280
- }
281
-
282
- if (seenValues.length > MAX_RECURSIVE_DEPTH) {
283
- return '[Array]';
284
- }
285
-
286
- var len = Math.min(MAX_ARRAY_LENGTH, array.length);
287
- var remaining = array.length - len;
288
- var items = [];
289
-
290
- for (var i = 0; i < len; ++i) {
291
- items.push(formatValue(array[i], seenValues));
292
- }
293
-
294
- if (remaining === 1) {
295
- items.push('... 1 more item');
296
- } else if (remaining > 1) {
297
- items.push("... ".concat(remaining, " more items"));
298
- }
299
-
300
- return '[' + items.join(', ') + ']';
301
- }
302
-
303
- function getCustomFn(object) {
304
- var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
305
-
306
- if (typeof customInspectFn === 'function') {
307
- return customInspectFn;
308
- }
309
-
310
- if (typeof object.inspect === 'function') {
311
- return object.inspect;
312
- }
313
- }
314
-
315
- function getObjectTag(object) {
316
- var tag = Object.prototype.toString.call(object).replace(/^\[object /, '').replace(/]$/, '');
317
-
318
- if (tag === 'Object' && typeof object.constructor === 'function') {
319
- var name = object.constructor.name;
320
-
321
- if (typeof name === 'string' && name !== '') {
322
- return name;
323
- }
324
- }
325
-
326
- return tag;
327
- }
328
-
329
- function devAssert(condition, message) {
330
- var booleanCondition = Boolean(condition); // istanbul ignore else (See transformation done in './resources/inlineInvariant.js')
331
-
332
- if (!booleanCondition) {
333
- throw new Error(message);
334
- }
335
- }
336
-
337
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
338
-
339
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
340
-
341
- /**
342
- * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
343
- * optional, but they are useful for clients who store GraphQL documents in source files.
344
- * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
345
- * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
346
- * The `line` and `column` properties in `locationOffset` are 1-indexed.
347
- */
348
- var Source = /*#__PURE__*/function () {
349
- function Source(body) {
350
- var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GraphQL request';
351
- var locationOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
352
- line: 1,
353
- column: 1
354
- };
355
- typeof body === 'string' || devAssert(0, "Body must be a string. Received: ".concat(inspect(body), "."));
356
- this.body = body;
357
- this.name = name;
358
- this.locationOffset = locationOffset;
359
- this.locationOffset.line > 0 || devAssert(0, 'line in locationOffset is 1-indexed and must be positive.');
360
- this.locationOffset.column > 0 || devAssert(0, 'column in locationOffset is 1-indexed and must be positive.');
361
- } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
362
-
363
-
364
- _createClass(Source, [{
365
- key: SYMBOL_TO_STRING_TAG,
366
- get: function get() {
367
- return 'Source';
368
- }
369
- }]);
370
-
371
- return Source;
372
- }();
373
-
374
- function removeTemporaryGlobals() {
375
- return typeof Source === "function" ? remove() : remove();
376
- }
377
-
378
- function checkDEV() {
379
- __DEV__ ? invariant("boolean" === typeof DEV, DEV) : invariant("boolean" === typeof DEV, 39);
380
- }
381
- removeTemporaryGlobals();
382
- checkDEV();
383
-
384
- function isNonNullObject(obj) {
385
- return obj !== null && typeof obj === 'object';
386
- }
387
-
388
- function isNonEmptyArray(value) {
389
- return Array.isArray(value) && value.length > 0;
390
- }
391
-
392
- function deepFreeze(value) {
393
- var workSet = new Set([value]);
394
- workSet.forEach(function (obj) {
395
- if (isNonNullObject(obj) && shallowFreeze(obj) === obj) {
396
- Object.getOwnPropertyNames(obj).forEach(function (name) {
397
- if (isNonNullObject(obj[name]))
398
- workSet.add(obj[name]);
399
- });
400
- }
401
- });
402
- return value;
403
- }
404
- function shallowFreeze(obj) {
405
- if (__DEV__ && !Object.isFrozen(obj)) {
406
- try {
407
- Object.freeze(obj);
408
- }
409
- catch (e) {
410
- if (e instanceof TypeError)
411
- return null;
412
- throw e;
413
- }
414
- }
415
- return obj;
416
- }
417
- function maybeDeepFreeze(obj) {
418
- if (__DEV__) {
419
- deepFreeze(obj);
420
- }
421
- return obj;
422
- }
423
-
424
- var canUseWeakMap = typeof WeakMap === 'function' &&
425
- maybe$1(function () { return navigator.product; }) !== 'ReactNative';
426
- var canUseWeakSet = typeof WeakSet === 'function';
427
- var canUseSymbol = typeof Symbol === 'function' &&
428
- typeof Symbol.for === 'function';
429
- var canUseDOM = typeof maybe$1(function () { return window.document.createElement; }) === "function";
430
- var usingJSDOM = maybe$1(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
431
- var canUseLayoutEffect = canUseDOM && !usingJSDOM;
432
-
433
- function compact() {
434
- var objects = [];
435
- for (var _i = 0; _i < arguments.length; _i++) {
436
- objects[_i] = arguments[_i];
437
- }
438
- var result = Object.create(null);
439
- objects.forEach(function (obj) {
440
- if (!obj)
441
- return;
442
- Object.keys(obj).forEach(function (key) {
443
- var value = obj[key];
444
- if (value !== void 0) {
445
- result[key] = value;
446
- }
447
- });
448
- });
449
- return result;
450
- }
451
-
452
- function mergeOptions(defaults, options) {
453
- return compact(defaults, options, options.variables && {
454
- variables: __assign(__assign({}, (defaults && defaults.variables)), options.variables),
455
- });
456
- }
457
-
458
- var _a = Object.prototype, toString = _a.toString, hasOwnProperty$1 = _a.hasOwnProperty;
459
- var fnToStr = Function.prototype.toString;
460
- var previousComparisons = new Map();
461
- /**
462
- * Performs a deep equality check on two JavaScript values, tolerating cycles.
463
- */
464
- function equal(a, b) {
465
- try {
466
- return check(a, b);
467
- }
468
- finally {
469
- previousComparisons.clear();
470
- }
471
- }
472
- function check(a, b) {
473
- // If the two values are strictly equal, our job is easy.
474
- if (a === b) {
475
- return true;
476
- }
477
- // Object.prototype.toString returns a representation of the runtime type of
478
- // the given value that is considerably more precise than typeof.
479
- var aTag = toString.call(a);
480
- var bTag = toString.call(b);
481
- // If the runtime types of a and b are different, they could maybe be equal
482
- // under some interpretation of equality, but for simplicity and performance
483
- // we just return false instead.
484
- if (aTag !== bTag) {
485
- return false;
486
- }
487
- switch (aTag) {
488
- case '[object Array]':
489
- // Arrays are a lot like other objects, but we can cheaply compare their
490
- // lengths as a short-cut before comparing their elements.
491
- if (a.length !== b.length)
492
- return false;
493
- // Fall through to object case...
494
- case '[object Object]': {
495
- if (previouslyCompared(a, b))
496
- return true;
497
- var aKeys = definedKeys(a);
498
- var bKeys = definedKeys(b);
499
- // If `a` and `b` have a different number of enumerable keys, they
500
- // must be different.
501
- var keyCount = aKeys.length;
502
- if (keyCount !== bKeys.length)
503
- return false;
504
- // Now make sure they have the same keys.
505
- for (var k = 0; k < keyCount; ++k) {
506
- if (!hasOwnProperty$1.call(b, aKeys[k])) {
507
- return false;
508
- }
509
- }
510
- // Finally, check deep equality of all child properties.
511
- for (var k = 0; k < keyCount; ++k) {
512
- var key = aKeys[k];
513
- if (!check(a[key], b[key])) {
514
- return false;
515
- }
516
- }
517
- return true;
518
- }
519
- case '[object Error]':
520
- return a.name === b.name && a.message === b.message;
521
- case '[object Number]':
522
- // Handle NaN, which is !== itself.
523
- if (a !== a)
524
- return b !== b;
525
- // Fall through to shared +a === +b case...
526
- case '[object Boolean]':
527
- case '[object Date]':
528
- return +a === +b;
529
- case '[object RegExp]':
530
- case '[object String]':
531
- return a == "".concat(b);
532
- case '[object Map]':
533
- case '[object Set]': {
534
- if (a.size !== b.size)
535
- return false;
536
- if (previouslyCompared(a, b))
537
- return true;
538
- var aIterator = a.entries();
539
- var isMap = aTag === '[object Map]';
540
- while (true) {
541
- var info = aIterator.next();
542
- if (info.done)
543
- break;
544
- // If a instanceof Set, aValue === aKey.
545
- var _a = info.value, aKey = _a[0], aValue = _a[1];
546
- // So this works the same way for both Set and Map.
547
- if (!b.has(aKey)) {
548
- return false;
549
- }
550
- // However, we care about deep equality of values only when dealing
551
- // with Map structures.
552
- if (isMap && !check(aValue, b.get(aKey))) {
553
- return false;
554
- }
555
- }
556
- return true;
557
- }
558
- case '[object Uint16Array]':
559
- case '[object Uint8Array]': // Buffer, in Node.js.
560
- case '[object Uint32Array]':
561
- case '[object Int32Array]':
562
- case '[object Int8Array]':
563
- case '[object Int16Array]':
564
- case '[object ArrayBuffer]':
565
- // DataView doesn't need these conversions, but the equality check is
566
- // otherwise the same.
567
- a = new Uint8Array(a);
568
- b = new Uint8Array(b);
569
- // Fall through...
570
- case '[object DataView]': {
571
- var len = a.byteLength;
572
- if (len === b.byteLength) {
573
- while (len-- && a[len] === b[len]) {
574
- // Keep looping as long as the bytes are equal.
575
- }
576
- }
577
- return len === -1;
578
- }
579
- case '[object AsyncFunction]':
580
- case '[object GeneratorFunction]':
581
- case '[object AsyncGeneratorFunction]':
582
- case '[object Function]': {
583
- var aCode = fnToStr.call(a);
584
- if (aCode !== fnToStr.call(b)) {
585
- return false;
586
- }
587
- // We consider non-native functions equal if they have the same code
588
- // (native functions require === because their code is censored).
589
- // Note that this behavior is not entirely sound, since !== function
590
- // objects with the same code can behave differently depending on
591
- // their closure scope. However, any function can behave differently
592
- // depending on the values of its input arguments (including this)
593
- // and its calling context (including its closure scope), even
594
- // though the function object is === to itself; and it is entirely
595
- // possible for functions that are not === to behave exactly the
596
- // same under all conceivable circumstances. Because none of these
597
- // factors are statically decidable in JavaScript, JS function
598
- // equality is not well-defined. This ambiguity allows us to
599
- // consider the best possible heuristic among various imperfect
600
- // options, and equating non-native functions that have the same
601
- // code has enormous practical benefits, such as when comparing
602
- // functions that are repeatedly passed as fresh function
603
- // expressions within objects that are otherwise deeply equal. Since
604
- // any function created from the same syntactic expression (in the
605
- // same code location) will always stringify to the same code
606
- // according to fnToStr.call, we can reasonably expect these
607
- // repeatedly passed function expressions to have the same code, and
608
- // thus behave "the same" (with all the caveats mentioned above),
609
- // even though the runtime function objects are !== to one another.
610
- return !endsWith(aCode, nativeCodeSuffix);
611
- }
612
- }
613
- // Otherwise the values are not equal.
614
- return false;
615
- }
616
- function definedKeys(obj) {
617
- // Remember that the second argument to Array.prototype.filter will be
618
- // used as `this` within the callback function.
619
- return Object.keys(obj).filter(isDefinedKey, obj);
620
- }
621
- function isDefinedKey(key) {
622
- return this[key] !== void 0;
623
- }
624
- var nativeCodeSuffix = "{ [native code] }";
625
- function endsWith(full, suffix) {
626
- var fromIndex = full.length - suffix.length;
627
- return fromIndex >= 0 &&
628
- full.indexOf(suffix, fromIndex) === fromIndex;
629
- }
630
- function previouslyCompared(a, b) {
631
- // Though cyclic references can make an object graph appear infinite from the
632
- // perspective of a depth-first traversal, the graph still contains a finite
633
- // number of distinct object references. We use the previousComparisons cache
634
- // to avoid comparing the same pair of object references more than once, which
635
- // guarantees termination (even if we end up comparing every object in one
636
- // graph to every object in the other graph, which is extremely unlikely),
637
- // while still allowing weird isomorphic structures (like rings with different
638
- // lengths) a chance to pass the equality test.
639
- var bSet = previousComparisons.get(a);
640
- if (bSet) {
641
- // Return true here because we can be sure false will be returned somewhere
642
- // else if the objects are not equivalent.
643
- if (bSet.has(b))
644
- return true;
645
- }
646
- else {
647
- previousComparisons.set(a, bSet = new Set);
648
- }
649
- bSet.add(b);
650
- return false;
651
- }
652
-
653
- var generateErrorMessage = function (err) {
654
- var message = '';
655
- if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {
656
- var errors = (err.graphQLErrors || [])
657
- .concat(err.clientErrors || []);
658
- errors.forEach(function (error) {
659
- var errorMessage = error
660
- ? error.message
661
- : 'Error message not found.';
662
- message += "".concat(errorMessage, "\n");
663
- });
664
- }
665
- if (err.networkError) {
666
- message += "".concat(err.networkError.message, "\n");
667
- }
668
- message = message.replace(/\n$/, '');
669
- return message;
670
- };
671
- var ApolloError = (function (_super) {
672
- __extends(ApolloError, _super);
673
- function ApolloError(_a) {
674
- var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
675
- var _this = _super.call(this, errorMessage) || this;
676
- _this.name = 'ApolloError';
677
- _this.graphQLErrors = graphQLErrors || [];
678
- _this.clientErrors = clientErrors || [];
679
- _this.networkError = networkError || null;
680
- _this.message = errorMessage || generateErrorMessage(_this);
681
- _this.extraInfo = extraInfo;
682
- _this.__proto__ = ApolloError.prototype;
683
- return _this;
684
- }
685
- return ApolloError;
686
- }(Error));
687
-
688
- var NetworkStatus;
689
- (function (NetworkStatus) {
690
- NetworkStatus[NetworkStatus["loading"] = 1] = "loading";
691
- NetworkStatus[NetworkStatus["setVariables"] = 2] = "setVariables";
692
- NetworkStatus[NetworkStatus["fetchMore"] = 3] = "fetchMore";
693
- NetworkStatus[NetworkStatus["refetch"] = 4] = "refetch";
694
- NetworkStatus[NetworkStatus["poll"] = 6] = "poll";
695
- NetworkStatus[NetworkStatus["ready"] = 7] = "ready";
696
- NetworkStatus[NetworkStatus["error"] = 8] = "error";
697
- })(NetworkStatus || (NetworkStatus = {}));
698
-
699
- var react$1 = {exports: {}};
700
-
701
- var react_production_min = {};
702
-
703
- /**
704
- * @license React
705
- * react.production.min.js
706
- *
707
- * Copyright (c) Facebook, Inc. and its affiliates.
708
- *
709
- * This source code is licensed under the MIT license found in the
710
- * LICENSE file in the root directory of this source tree.
711
- */
712
- var l=Symbol.for("react.element"),n=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),t=Symbol.for("react.provider"),u=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),z=Symbol.iterator;function A(a){if(null===a||"object"!==typeof a)return null;a=z&&a[z]||a["@@iterator"];return "function"===typeof a?a:null}
713
- var B={isMounted:function(){return !1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(a,b,e){this.props=a;this.context=b;this.refs=D;this.updater=e||B;}E.prototype.isReactComponent={};
714
- E.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,a,b,"setState");};E.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate");};function F(){}F.prototype=E.prototype;function G(a,b,e){this.props=a;this.context=b;this.refs=D;this.updater=e||B;}var H=G.prototype=new F;
715
- H.constructor=G;C(H,E.prototype);H.isPureReactComponent=!0;var I=Array.isArray,J=Object.prototype.hasOwnProperty,K={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};
716
- function M(a,b,e){var d,c={},k=null,h=null;if(null!=b)for(d in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=""+b.key),b)J.call(b,d)&&!L.hasOwnProperty(d)&&(c[d]=b[d]);var g=arguments.length-2;if(1===g)c.children=e;else if(1<g){for(var f=Array(g),m=0;m<g;m++)f[m]=arguments[m+2];c.children=f;}if(a&&a.defaultProps)for(d in g=a.defaultProps,g)void 0===c[d]&&(c[d]=g[d]);return {$$typeof:l,type:a,key:k,ref:h,props:c,_owner:K.current}}
717
- function N(a,b){return {$$typeof:l,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function O(a){return "object"===typeof a&&null!==a&&a.$$typeof===l}function escape(a){var b={"=":"=0",":":"=2"};return "$"+a.replace(/[=:]/g,function(a){return b[a]})}var P=/\/+/g;function Q(a,b){return "object"===typeof a&&null!==a&&null!=a.key?escape(""+a.key):b.toString(36)}
718
- function R(a,b,e,d,c){var k=typeof a;if("undefined"===k||"boolean"===k)a=null;var h=!1;if(null===a)h=!0;else switch(k){case "string":case "number":h=!0;break;case "object":switch(a.$$typeof){case l:case n:h=!0;}}if(h)return h=a,c=c(h),a=""===d?"."+Q(h,0):d,I(c)?(e="",null!=a&&(e=a.replace(P,"$&/")+"/"),R(c,b,e,"",function(a){return a})):null!=c&&(O(c)&&(c=N(c,e+(!c.key||h&&h.key===c.key?"":(""+c.key).replace(P,"$&/")+"/")+a)),b.push(c)),1;h=0;d=""===d?".":d+":";if(I(a))for(var g=0;g<a.length;g++){k=
719
- a[g];var f=d+Q(k,g);h+=R(k,b,e,f,c);}else if(f=A(a),"function"===typeof f)for(a=f.call(a),g=0;!(k=a.next()).done;)k=k.value,f=d+Q(k,g++),h+=R(k,b,e,f,c);else if("object"===k)throw b=String(a),Error("Objects are not valid as a React child (found: "+("[object Object]"===b?"object with keys {"+Object.keys(a).join(", ")+"}":b)+"). If you meant to render a collection of children, use an array instead.");return h}
720
- function S(a,b,e){if(null==a)return a;var d=[],c=0;R(a,d,"","",function(a){return b.call(e,a,c++)});return d}function T(a){if(-1===a._status){var b=a._result;b=b();b.then(function(b){if(0===a._status||-1===a._status)a._status=1,a._result=b;},function(b){if(0===a._status||-1===a._status)a._status=2,a._result=b;});-1===a._status&&(a._status=0,a._result=b);}if(1===a._status)return a._result.default;throw a._result;}
721
- var U={current:null},V={transition:null},W={ReactCurrentDispatcher:U,ReactCurrentBatchConfig:V,ReactCurrentOwner:K};react_production_min.Children={map:S,forEach:function(a,b,e){S(a,function(){b.apply(this,arguments);},e);},count:function(a){var b=0;S(a,function(){b++;});return b},toArray:function(a){return S(a,function(a){return a})||[]},only:function(a){if(!O(a))throw Error("React.Children.only expected to receive a single React element child.");return a}};react_production_min.Component=E;react_production_min.Fragment=p;
722
- react_production_min.Profiler=r;react_production_min.PureComponent=G;react_production_min.StrictMode=q;react_production_min.Suspense=w;react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W;
723
- react_production_min.cloneElement=function(a,b,e){if(null===a||void 0===a)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+a+".");var d=C({},a.props),c=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=K.current);void 0!==b.key&&(c=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)J.call(b,f)&&!L.hasOwnProperty(f)&&(d[f]=void 0===b[f]&&void 0!==g?g[f]:b[f]);}var f=arguments.length-2;if(1===f)d.children=e;else if(1<f){g=Array(f);
724
- for(var m=0;m<f;m++)g[m]=arguments[m+2];d.children=g;}return {$$typeof:l,type:a.type,key:c,ref:k,props:d,_owner:h}};react_production_min.createContext=function(a){a={$$typeof:u,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};a.Provider={$$typeof:t,_context:a};return a.Consumer=a};react_production_min.createElement=M;react_production_min.createFactory=function(a){var b=M.bind(null,a);b.type=a;return b};react_production_min.createRef=function(){return {current:null}};
725
- react_production_min.forwardRef=function(a){return {$$typeof:v,render:a}};react_production_min.isValidElement=O;react_production_min.lazy=function(a){return {$$typeof:y,_payload:{_status:-1,_result:a},_init:T}};react_production_min.memo=function(a,b){return {$$typeof:x,type:a,compare:void 0===b?null:b}};react_production_min.startTransition=function(a){var b=V.transition;V.transition={};try{a();}finally{V.transition=b;}};react_production_min.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.");};
726
- react_production_min.useCallback=function(a,b){return U.current.useCallback(a,b)};react_production_min.useContext=function(a){return U.current.useContext(a)};react_production_min.useDebugValue=function(){};react_production_min.useDeferredValue=function(a){return U.current.useDeferredValue(a)};react_production_min.useEffect=function(a,b){return U.current.useEffect(a,b)};react_production_min.useId=function(){return U.current.useId()};react_production_min.useImperativeHandle=function(a,b,e){return U.current.useImperativeHandle(a,b,e)};
727
- react_production_min.useInsertionEffect=function(a,b){return U.current.useInsertionEffect(a,b)};react_production_min.useLayoutEffect=function(a,b){return U.current.useLayoutEffect(a,b)};react_production_min.useMemo=function(a,b){return U.current.useMemo(a,b)};react_production_min.useReducer=function(a,b,e){return U.current.useReducer(a,b,e)};react_production_min.useRef=function(a){return U.current.useRef(a)};react_production_min.useState=function(a){return U.current.useState(a)};react_production_min.useSyncExternalStore=function(a,b,e){return U.current.useSyncExternalStore(a,b,e)};
728
- react_production_min.useTransition=function(){return U.current.useTransition()};react_production_min.version="18.2.0";
729
-
730
- var react_development = {exports: {}};
731
-
732
- /**
733
- * @license React
734
- * react.development.js
735
- *
736
- * Copyright (c) Facebook, Inc. and its affiliates.
737
- *
738
- * This source code is licensed under the MIT license found in the
739
- * LICENSE file in the root directory of this source tree.
740
- */
741
-
742
- (function (module, exports) {
743
-
744
- if (process.env.NODE_ENV !== "production") {
745
- (function() {
746
-
747
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
748
- if (
749
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
750
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
751
- 'function'
752
- ) {
753
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
754
- }
755
- var ReactVersion = '18.2.0';
756
-
757
- // ATTENTION
758
- // When adding new symbols to this file,
759
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
760
- // The Symbol used to tag the ReactElement-like types.
761
- var REACT_ELEMENT_TYPE = Symbol.for('react.element');
762
- var REACT_PORTAL_TYPE = Symbol.for('react.portal');
763
- var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
764
- var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
765
- var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
766
- var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
767
- var REACT_CONTEXT_TYPE = Symbol.for('react.context');
768
- var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
769
- var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
770
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
771
- var REACT_MEMO_TYPE = Symbol.for('react.memo');
772
- var REACT_LAZY_TYPE = Symbol.for('react.lazy');
773
- var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
774
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
775
- var FAUX_ITERATOR_SYMBOL = '@@iterator';
776
- function getIteratorFn(maybeIterable) {
777
- if (maybeIterable === null || typeof maybeIterable !== 'object') {
778
- return null;
779
- }
780
-
781
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
782
-
783
- if (typeof maybeIterator === 'function') {
784
- return maybeIterator;
785
- }
786
-
787
- return null;
788
- }
789
-
790
- /**
791
- * Keeps track of the current dispatcher.
792
- */
793
- var ReactCurrentDispatcher = {
794
- /**
795
- * @internal
796
- * @type {ReactComponent}
797
- */
798
- current: null
799
- };
800
-
801
- /**
802
- * Keeps track of the current batch's configuration such as how long an update
803
- * should suspend for if it needs to.
804
- */
805
- var ReactCurrentBatchConfig = {
806
- transition: null
807
- };
808
-
809
- var ReactCurrentActQueue = {
810
- current: null,
811
- // Used to reproduce behavior of `batchedUpdates` in legacy mode.
812
- isBatchingLegacy: false,
813
- didScheduleLegacyUpdate: false
814
- };
815
-
816
- /**
817
- * Keeps track of the current owner.
818
- *
819
- * The current owner is the component who should own any components that are
820
- * currently being constructed.
821
- */
822
- var ReactCurrentOwner = {
823
- /**
824
- * @internal
825
- * @type {ReactComponent}
826
- */
827
- current: null
828
- };
829
-
830
- var ReactDebugCurrentFrame = {};
831
- var currentExtraStackFrame = null;
832
- function setExtraStackFrame(stack) {
833
- {
834
- currentExtraStackFrame = stack;
835
- }
836
- }
837
-
838
- {
839
- ReactDebugCurrentFrame.setExtraStackFrame = function (stack) {
840
- {
841
- currentExtraStackFrame = stack;
842
- }
843
- }; // Stack implementation injected by the current renderer.
844
-
845
-
846
- ReactDebugCurrentFrame.getCurrentStack = null;
847
-
848
- ReactDebugCurrentFrame.getStackAddendum = function () {
849
- var stack = ''; // Add an extra top frame while an element is being validated
850
-
851
- if (currentExtraStackFrame) {
852
- stack += currentExtraStackFrame;
853
- } // Delegate to the injected renderer-specific implementation
854
-
855
-
856
- var impl = ReactDebugCurrentFrame.getCurrentStack;
857
-
858
- if (impl) {
859
- stack += impl() || '';
860
- }
861
-
862
- return stack;
863
- };
864
- }
865
-
866
- // -----------------------------------------------------------------------------
867
-
868
- var enableScopeAPI = false; // Experimental Create Event Handle API.
869
- var enableCacheElement = false;
870
- var enableTransitionTracing = false; // No known bugs, but needs performance testing
871
-
872
- var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
873
- // stuff. Intended to enable React core members to more easily debug scheduling
874
- // issues in DEV builds.
875
-
876
- var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
877
-
878
- var ReactSharedInternals = {
879
- ReactCurrentDispatcher: ReactCurrentDispatcher,
880
- ReactCurrentBatchConfig: ReactCurrentBatchConfig,
881
- ReactCurrentOwner: ReactCurrentOwner
882
- };
883
-
884
- {
885
- ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
886
- ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
887
- }
888
-
889
- // by calls to these methods by a Babel plugin.
890
- //
891
- // In PROD (or in packages without access to React internals),
892
- // they are left as they are instead.
893
-
894
- function warn(format) {
895
- {
896
- {
897
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
898
- args[_key - 1] = arguments[_key];
899
- }
900
-
901
- printWarning('warn', format, args);
902
- }
903
- }
904
- }
905
- function error(format) {
906
- {
907
- {
908
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
909
- args[_key2 - 1] = arguments[_key2];
910
- }
911
-
912
- printWarning('error', format, args);
913
- }
914
- }
915
- }
916
-
917
- function printWarning(level, format, args) {
918
- // When changing this logic, you might want to also
919
- // update consoleWithStackDev.www.js as well.
920
- {
921
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
922
- var stack = ReactDebugCurrentFrame.getStackAddendum();
923
-
924
- if (stack !== '') {
925
- format += '%s';
926
- args = args.concat([stack]);
927
- } // eslint-disable-next-line react-internal/safe-string-coercion
928
-
929
-
930
- var argsWithFormat = args.map(function (item) {
931
- return String(item);
932
- }); // Careful: RN currently depends on this prefix
933
-
934
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
935
- // breaks IE9: https://github.com/facebook/react/issues/13610
936
- // eslint-disable-next-line react-internal/no-production-logging
937
-
938
- Function.prototype.apply.call(console[level], console, argsWithFormat);
939
- }
940
- }
941
-
942
- var didWarnStateUpdateForUnmountedComponent = {};
943
-
944
- function warnNoop(publicInstance, callerName) {
945
- {
946
- var _constructor = publicInstance.constructor;
947
- var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
948
- var warningKey = componentName + "." + callerName;
949
-
950
- if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
951
- return;
952
- }
953
-
954
- error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
955
-
956
- didWarnStateUpdateForUnmountedComponent[warningKey] = true;
957
- }
958
- }
959
- /**
960
- * This is the abstract API for an update queue.
961
- */
962
-
963
-
964
- var ReactNoopUpdateQueue = {
965
- /**
966
- * Checks whether or not this composite component is mounted.
967
- * @param {ReactClass} publicInstance The instance we want to test.
968
- * @return {boolean} True if mounted, false otherwise.
969
- * @protected
970
- * @final
971
- */
972
- isMounted: function (publicInstance) {
973
- return false;
974
- },
975
-
976
- /**
977
- * Forces an update. This should only be invoked when it is known with
978
- * certainty that we are **not** in a DOM transaction.
979
- *
980
- * You may want to call this when you know that some deeper aspect of the
981
- * component's state has changed but `setState` was not called.
982
- *
983
- * This will not invoke `shouldComponentUpdate`, but it will invoke
984
- * `componentWillUpdate` and `componentDidUpdate`.
985
- *
986
- * @param {ReactClass} publicInstance The instance that should rerender.
987
- * @param {?function} callback Called after component is updated.
988
- * @param {?string} callerName name of the calling function in the public API.
989
- * @internal
990
- */
991
- enqueueForceUpdate: function (publicInstance, callback, callerName) {
992
- warnNoop(publicInstance, 'forceUpdate');
993
- },
994
-
995
- /**
996
- * Replaces all of the state. Always use this or `setState` to mutate state.
997
- * You should treat `this.state` as immutable.
998
- *
999
- * There is no guarantee that `this.state` will be immediately updated, so
1000
- * accessing `this.state` after calling this method may return the old value.
1001
- *
1002
- * @param {ReactClass} publicInstance The instance that should rerender.
1003
- * @param {object} completeState Next state.
1004
- * @param {?function} callback Called after component is updated.
1005
- * @param {?string} callerName name of the calling function in the public API.
1006
- * @internal
1007
- */
1008
- enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
1009
- warnNoop(publicInstance, 'replaceState');
1010
- },
1011
-
1012
- /**
1013
- * Sets a subset of the state. This only exists because _pendingState is
1014
- * internal. This provides a merging strategy that is not available to deep
1015
- * properties which is confusing. TODO: Expose pendingState or don't use it
1016
- * during the merge.
1017
- *
1018
- * @param {ReactClass} publicInstance The instance that should rerender.
1019
- * @param {object} partialState Next partial state to be merged with state.
1020
- * @param {?function} callback Called after component is updated.
1021
- * @param {?string} Name of the calling function in the public API.
1022
- * @internal
1023
- */
1024
- enqueueSetState: function (publicInstance, partialState, callback, callerName) {
1025
- warnNoop(publicInstance, 'setState');
1026
- }
1027
- };
1028
-
1029
- var assign = Object.assign;
1030
-
1031
- var emptyObject = {};
1032
-
1033
- {
1034
- Object.freeze(emptyObject);
1035
- }
1036
- /**
1037
- * Base class helpers for the updating state of a component.
1038
- */
1039
-
1040
-
1041
- function Component(props, context, updater) {
1042
- this.props = props;
1043
- this.context = context; // If a component has string refs, we will assign a different object later.
1044
-
1045
- this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
1046
- // renderer.
1047
-
1048
- this.updater = updater || ReactNoopUpdateQueue;
1049
- }
1050
-
1051
- Component.prototype.isReactComponent = {};
1052
- /**
1053
- * Sets a subset of the state. Always use this to mutate
1054
- * state. You should treat `this.state` as immutable.
1055
- *
1056
- * There is no guarantee that `this.state` will be immediately updated, so
1057
- * accessing `this.state` after calling this method may return the old value.
1058
- *
1059
- * There is no guarantee that calls to `setState` will run synchronously,
1060
- * as they may eventually be batched together. You can provide an optional
1061
- * callback that will be executed when the call to setState is actually
1062
- * completed.
1063
- *
1064
- * When a function is provided to setState, it will be called at some point in
1065
- * the future (not synchronously). It will be called with the up to date
1066
- * component arguments (state, props, context). These values can be different
1067
- * from this.* because your function may be called after receiveProps but before
1068
- * shouldComponentUpdate, and this new state, props, and context will not yet be
1069
- * assigned to this.
1070
- *
1071
- * @param {object|function} partialState Next partial state or function to
1072
- * produce next partial state to be merged with current state.
1073
- * @param {?function} callback Called after state is updated.
1074
- * @final
1075
- * @protected
1076
- */
1077
-
1078
- Component.prototype.setState = function (partialState, callback) {
1079
- if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) {
1080
- throw new Error('setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.');
1081
- }
1082
-
1083
- this.updater.enqueueSetState(this, partialState, callback, 'setState');
1084
- };
1085
- /**
1086
- * Forces an update. This should only be invoked when it is known with
1087
- * certainty that we are **not** in a DOM transaction.
1088
- *
1089
- * You may want to call this when you know that some deeper aspect of the
1090
- * component's state has changed but `setState` was not called.
1091
- *
1092
- * This will not invoke `shouldComponentUpdate`, but it will invoke
1093
- * `componentWillUpdate` and `componentDidUpdate`.
1094
- *
1095
- * @param {?function} callback Called after update is complete.
1096
- * @final
1097
- * @protected
1098
- */
1099
-
1100
-
1101
- Component.prototype.forceUpdate = function (callback) {
1102
- this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
1103
- };
1104
- /**
1105
- * Deprecated APIs. These APIs used to exist on classic React classes but since
1106
- * we would like to deprecate them, we're not going to move them over to this
1107
- * modern base class. Instead, we define a getter that warns if it's accessed.
1108
- */
1109
-
1110
-
1111
- {
1112
- var deprecatedAPIs = {
1113
- isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
1114
- replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
1115
- };
1116
-
1117
- var defineDeprecationWarning = function (methodName, info) {
1118
- Object.defineProperty(Component.prototype, methodName, {
1119
- get: function () {
1120
- warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
1121
-
1122
- return undefined;
1123
- }
1124
- });
1125
- };
1126
-
1127
- for (var fnName in deprecatedAPIs) {
1128
- if (deprecatedAPIs.hasOwnProperty(fnName)) {
1129
- defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
1130
- }
1131
- }
1132
- }
1133
-
1134
- function ComponentDummy() {}
1135
-
1136
- ComponentDummy.prototype = Component.prototype;
1137
- /**
1138
- * Convenience component with default shallow equality check for sCU.
1139
- */
1140
-
1141
- function PureComponent(props, context, updater) {
1142
- this.props = props;
1143
- this.context = context; // If a component has string refs, we will assign a different object later.
1144
-
1145
- this.refs = emptyObject;
1146
- this.updater = updater || ReactNoopUpdateQueue;
1147
- }
1148
-
1149
- var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
1150
- pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
1151
-
1152
- assign(pureComponentPrototype, Component.prototype);
1153
- pureComponentPrototype.isPureReactComponent = true;
1154
-
1155
- // an immutable object with a single mutable value
1156
- function createRef() {
1157
- var refObject = {
1158
- current: null
1159
- };
1160
-
1161
- {
1162
- Object.seal(refObject);
1163
- }
1164
-
1165
- return refObject;
1166
- }
1167
-
1168
- var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
1169
-
1170
- function isArray(a) {
1171
- return isArrayImpl(a);
1172
- }
1173
-
1174
- /*
1175
- * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
1176
- * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
1177
- *
1178
- * The functions in this module will throw an easier-to-understand,
1179
- * easier-to-debug exception with a clear errors message message explaining the
1180
- * problem. (Instead of a confusing exception thrown inside the implementation
1181
- * of the `value` object).
1182
- */
1183
- // $FlowFixMe only called in DEV, so void return is not possible.
1184
- function typeName(value) {
1185
- {
1186
- // toStringTag is needed for namespaced types like Temporal.Instant
1187
- var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
1188
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
1189
- return type;
1190
- }
1191
- } // $FlowFixMe only called in DEV, so void return is not possible.
1192
-
1193
-
1194
- function willCoercionThrow(value) {
1195
- {
1196
- try {
1197
- testStringCoercion(value);
1198
- return false;
1199
- } catch (e) {
1200
- return true;
1201
- }
1202
- }
1203
- }
1204
-
1205
- function testStringCoercion(value) {
1206
- // If you ended up here by following an exception call stack, here's what's
1207
- // happened: you supplied an object or symbol value to React (as a prop, key,
1208
- // DOM attribute, CSS property, string ref, etc.) and when React tried to
1209
- // coerce it to a string using `'' + value`, an exception was thrown.
1210
- //
1211
- // The most common types that will cause this exception are `Symbol` instances
1212
- // and Temporal objects like `Temporal.Instant`. But any object that has a
1213
- // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
1214
- // exception. (Library authors do this to prevent users from using built-in
1215
- // numeric operators like `+` or comparison operators like `>=` because custom
1216
- // methods are needed to perform accurate arithmetic or comparison.)
1217
- //
1218
- // To fix the problem, coerce this object or symbol value to a string before
1219
- // passing it to React. The most reliable way is usually `String(value)`.
1220
- //
1221
- // To find which value is throwing, check the browser or debugger console.
1222
- // Before this exception was thrown, there should be `console.error` output
1223
- // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
1224
- // problem and how that type was used: key, atrribute, input value prop, etc.
1225
- // In most cases, this console output also shows the component and its
1226
- // ancestor components where the exception happened.
1227
- //
1228
- // eslint-disable-next-line react-internal/safe-string-coercion
1229
- return '' + value;
1230
- }
1231
- function checkKeyStringCoercion(value) {
1232
- {
1233
- if (willCoercionThrow(value)) {
1234
- error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
1235
-
1236
- return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
1237
- }
1238
- }
1239
- }
1240
-
1241
- function getWrappedName(outerType, innerType, wrapperName) {
1242
- var displayName = outerType.displayName;
1243
-
1244
- if (displayName) {
1245
- return displayName;
1246
- }
1247
-
1248
- var functionName = innerType.displayName || innerType.name || '';
1249
- return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
1250
- } // Keep in sync with react-reconciler/getComponentNameFromFiber
1251
-
1252
-
1253
- function getContextName(type) {
1254
- return type.displayName || 'Context';
1255
- } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
1256
-
1257
-
1258
- function getComponentNameFromType(type) {
1259
- if (type == null) {
1260
- // Host root, text node or just invalid type.
1261
- return null;
1262
- }
1263
-
1264
- {
1265
- if (typeof type.tag === 'number') {
1266
- error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
1267
- }
1268
- }
1269
-
1270
- if (typeof type === 'function') {
1271
- return type.displayName || type.name || null;
1272
- }
1273
-
1274
- if (typeof type === 'string') {
1275
- return type;
1276
- }
1277
-
1278
- switch (type) {
1279
- case REACT_FRAGMENT_TYPE:
1280
- return 'Fragment';
1281
-
1282
- case REACT_PORTAL_TYPE:
1283
- return 'Portal';
1284
-
1285
- case REACT_PROFILER_TYPE:
1286
- return 'Profiler';
1287
-
1288
- case REACT_STRICT_MODE_TYPE:
1289
- return 'StrictMode';
1290
-
1291
- case REACT_SUSPENSE_TYPE:
1292
- return 'Suspense';
1293
-
1294
- case REACT_SUSPENSE_LIST_TYPE:
1295
- return 'SuspenseList';
1296
-
1297
- }
1298
-
1299
- if (typeof type === 'object') {
1300
- switch (type.$$typeof) {
1301
- case REACT_CONTEXT_TYPE:
1302
- var context = type;
1303
- return getContextName(context) + '.Consumer';
1304
-
1305
- case REACT_PROVIDER_TYPE:
1306
- var provider = type;
1307
- return getContextName(provider._context) + '.Provider';
1308
-
1309
- case REACT_FORWARD_REF_TYPE:
1310
- return getWrappedName(type, type.render, 'ForwardRef');
1311
-
1312
- case REACT_MEMO_TYPE:
1313
- var outerName = type.displayName || null;
1314
-
1315
- if (outerName !== null) {
1316
- return outerName;
1317
- }
1318
-
1319
- return getComponentNameFromType(type.type) || 'Memo';
1320
-
1321
- case REACT_LAZY_TYPE:
1322
- {
1323
- var lazyComponent = type;
1324
- var payload = lazyComponent._payload;
1325
- var init = lazyComponent._init;
1326
-
1327
- try {
1328
- return getComponentNameFromType(init(payload));
1329
- } catch (x) {
1330
- return null;
1331
- }
1332
- }
1333
-
1334
- // eslint-disable-next-line no-fallthrough
1335
- }
1336
- }
1337
-
1338
- return null;
1339
- }
1340
-
1341
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1342
-
1343
- var RESERVED_PROPS = {
1344
- key: true,
1345
- ref: true,
1346
- __self: true,
1347
- __source: true
1348
- };
1349
- var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
1350
-
1351
- {
1352
- didWarnAboutStringRefs = {};
1353
- }
1354
-
1355
- function hasValidRef(config) {
1356
- {
1357
- if (hasOwnProperty.call(config, 'ref')) {
1358
- var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
1359
-
1360
- if (getter && getter.isReactWarning) {
1361
- return false;
1362
- }
1363
- }
1364
- }
1365
-
1366
- return config.ref !== undefined;
1367
- }
1368
-
1369
- function hasValidKey(config) {
1370
- {
1371
- if (hasOwnProperty.call(config, 'key')) {
1372
- var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
1373
-
1374
- if (getter && getter.isReactWarning) {
1375
- return false;
1376
- }
1377
- }
1378
- }
1379
-
1380
- return config.key !== undefined;
1381
- }
1382
-
1383
- function defineKeyPropWarningGetter(props, displayName) {
1384
- var warnAboutAccessingKey = function () {
1385
- {
1386
- if (!specialPropKeyWarningShown) {
1387
- specialPropKeyWarningShown = true;
1388
-
1389
- error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
1390
- }
1391
- }
1392
- };
1393
-
1394
- warnAboutAccessingKey.isReactWarning = true;
1395
- Object.defineProperty(props, 'key', {
1396
- get: warnAboutAccessingKey,
1397
- configurable: true
1398
- });
1399
- }
1400
-
1401
- function defineRefPropWarningGetter(props, displayName) {
1402
- var warnAboutAccessingRef = function () {
1403
- {
1404
- if (!specialPropRefWarningShown) {
1405
- specialPropRefWarningShown = true;
1406
-
1407
- error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
1408
- }
1409
- }
1410
- };
1411
-
1412
- warnAboutAccessingRef.isReactWarning = true;
1413
- Object.defineProperty(props, 'ref', {
1414
- get: warnAboutAccessingRef,
1415
- configurable: true
1416
- });
1417
- }
1418
-
1419
- function warnIfStringRefCannotBeAutoConverted(config) {
1420
- {
1421
- if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
1422
- var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
1423
-
1424
- if (!didWarnAboutStringRefs[componentName]) {
1425
- error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);
1426
-
1427
- didWarnAboutStringRefs[componentName] = true;
1428
- }
1429
- }
1430
- }
1431
- }
1432
- /**
1433
- * Factory method to create a new React element. This no longer adheres to
1434
- * the class pattern, so do not use new to call it. Also, instanceof check
1435
- * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1436
- * if something is a React Element.
1437
- *
1438
- * @param {*} type
1439
- * @param {*} props
1440
- * @param {*} key
1441
- * @param {string|object} ref
1442
- * @param {*} owner
1443
- * @param {*} self A *temporary* helper to detect places where `this` is
1444
- * different from the `owner` when React.createElement is called, so that we
1445
- * can warn. We want to get rid of owner and replace string `ref`s with arrow
1446
- * functions, and as long as `this` and owner are the same, there will be no
1447
- * change in behavior.
1448
- * @param {*} source An annotation object (added by a transpiler or otherwise)
1449
- * indicating filename, line number, and/or other information.
1450
- * @internal
1451
- */
1452
-
1453
-
1454
- var ReactElement = function (type, key, ref, self, source, owner, props) {
1455
- var element = {
1456
- // This tag allows us to uniquely identify this as a React Element
1457
- $$typeof: REACT_ELEMENT_TYPE,
1458
- // Built-in properties that belong on the element
1459
- type: type,
1460
- key: key,
1461
- ref: ref,
1462
- props: props,
1463
- // Record the component responsible for creating this element.
1464
- _owner: owner
1465
- };
1466
-
1467
- {
1468
- // The validation flag is currently mutative. We put it on
1469
- // an external backing store so that we can freeze the whole object.
1470
- // This can be replaced with a WeakMap once they are implemented in
1471
- // commonly used development environments.
1472
- element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
1473
- // the validation flag non-enumerable (where possible, which should
1474
- // include every environment we run tests in), so the test framework
1475
- // ignores it.
1476
-
1477
- Object.defineProperty(element._store, 'validated', {
1478
- configurable: false,
1479
- enumerable: false,
1480
- writable: true,
1481
- value: false
1482
- }); // self and source are DEV only properties.
1483
-
1484
- Object.defineProperty(element, '_self', {
1485
- configurable: false,
1486
- enumerable: false,
1487
- writable: false,
1488
- value: self
1489
- }); // Two elements created in two different places should be considered
1490
- // equal for testing purposes and therefore we hide it from enumeration.
1491
-
1492
- Object.defineProperty(element, '_source', {
1493
- configurable: false,
1494
- enumerable: false,
1495
- writable: false,
1496
- value: source
1497
- });
1498
-
1499
- if (Object.freeze) {
1500
- Object.freeze(element.props);
1501
- Object.freeze(element);
1502
- }
1503
- }
1504
-
1505
- return element;
1506
- };
1507
- /**
1508
- * Create and return a new ReactElement of the given type.
1509
- * See https://reactjs.org/docs/react-api.html#createelement
1510
- */
1511
-
1512
- function createElement(type, config, children) {
1513
- var propName; // Reserved names are extracted
1514
-
1515
- var props = {};
1516
- var key = null;
1517
- var ref = null;
1518
- var self = null;
1519
- var source = null;
1520
-
1521
- if (config != null) {
1522
- if (hasValidRef(config)) {
1523
- ref = config.ref;
1524
-
1525
- {
1526
- warnIfStringRefCannotBeAutoConverted(config);
1527
- }
1528
- }
1529
-
1530
- if (hasValidKey(config)) {
1531
- {
1532
- checkKeyStringCoercion(config.key);
1533
- }
1534
-
1535
- key = '' + config.key;
1536
- }
1537
-
1538
- self = config.__self === undefined ? null : config.__self;
1539
- source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
1540
-
1541
- for (propName in config) {
1542
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1543
- props[propName] = config[propName];
1544
- }
1545
- }
1546
- } // Children can be more than one argument, and those are transferred onto
1547
- // the newly allocated props object.
1548
-
1549
-
1550
- var childrenLength = arguments.length - 2;
1551
-
1552
- if (childrenLength === 1) {
1553
- props.children = children;
1554
- } else if (childrenLength > 1) {
1555
- var childArray = Array(childrenLength);
1556
-
1557
- for (var i = 0; i < childrenLength; i++) {
1558
- childArray[i] = arguments[i + 2];
1559
- }
1560
-
1561
- {
1562
- if (Object.freeze) {
1563
- Object.freeze(childArray);
1564
- }
1565
- }
1566
-
1567
- props.children = childArray;
1568
- } // Resolve default props
1569
-
1570
-
1571
- if (type && type.defaultProps) {
1572
- var defaultProps = type.defaultProps;
1573
-
1574
- for (propName in defaultProps) {
1575
- if (props[propName] === undefined) {
1576
- props[propName] = defaultProps[propName];
1577
- }
1578
- }
1579
- }
1580
-
1581
- {
1582
- if (key || ref) {
1583
- var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
1584
-
1585
- if (key) {
1586
- defineKeyPropWarningGetter(props, displayName);
1587
- }
1588
-
1589
- if (ref) {
1590
- defineRefPropWarningGetter(props, displayName);
1591
- }
1592
- }
1593
- }
1594
-
1595
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1596
- }
1597
- function cloneAndReplaceKey(oldElement, newKey) {
1598
- var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
1599
- return newElement;
1600
- }
1601
- /**
1602
- * Clone and return a new ReactElement using element as the starting point.
1603
- * See https://reactjs.org/docs/react-api.html#cloneelement
1604
- */
1605
-
1606
- function cloneElement(element, config, children) {
1607
- if (element === null || element === undefined) {
1608
- throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
1609
- }
1610
-
1611
- var propName; // Original props are copied
1612
-
1613
- var props = assign({}, element.props); // Reserved names are extracted
1614
-
1615
- var key = element.key;
1616
- var ref = element.ref; // Self is preserved since the owner is preserved.
1617
-
1618
- var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
1619
- // transpiler, and the original source is probably a better indicator of the
1620
- // true owner.
1621
-
1622
- var source = element._source; // Owner will be preserved, unless ref is overridden
1623
-
1624
- var owner = element._owner;
1625
-
1626
- if (config != null) {
1627
- if (hasValidRef(config)) {
1628
- // Silently steal the ref from the parent.
1629
- ref = config.ref;
1630
- owner = ReactCurrentOwner.current;
1631
- }
1632
-
1633
- if (hasValidKey(config)) {
1634
- {
1635
- checkKeyStringCoercion(config.key);
1636
- }
1637
-
1638
- key = '' + config.key;
1639
- } // Remaining properties override existing props
1640
-
1641
-
1642
- var defaultProps;
1643
-
1644
- if (element.type && element.type.defaultProps) {
1645
- defaultProps = element.type.defaultProps;
1646
- }
1647
-
1648
- for (propName in config) {
1649
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1650
- if (config[propName] === undefined && defaultProps !== undefined) {
1651
- // Resolve default props
1652
- props[propName] = defaultProps[propName];
1653
- } else {
1654
- props[propName] = config[propName];
1655
- }
1656
- }
1657
- }
1658
- } // Children can be more than one argument, and those are transferred onto
1659
- // the newly allocated props object.
1660
-
1661
-
1662
- var childrenLength = arguments.length - 2;
1663
-
1664
- if (childrenLength === 1) {
1665
- props.children = children;
1666
- } else if (childrenLength > 1) {
1667
- var childArray = Array(childrenLength);
1668
-
1669
- for (var i = 0; i < childrenLength; i++) {
1670
- childArray[i] = arguments[i + 2];
1671
- }
1672
-
1673
- props.children = childArray;
1674
- }
1675
-
1676
- return ReactElement(element.type, key, ref, self, source, owner, props);
1677
- }
1678
- /**
1679
- * Verifies the object is a ReactElement.
1680
- * See https://reactjs.org/docs/react-api.html#isvalidelement
1681
- * @param {?object} object
1682
- * @return {boolean} True if `object` is a ReactElement.
1683
- * @final
1684
- */
1685
-
1686
- function isValidElement(object) {
1687
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1688
- }
1689
-
1690
- var SEPARATOR = '.';
1691
- var SUBSEPARATOR = ':';
1692
- /**
1693
- * Escape and wrap key so it is safe to use as a reactid
1694
- *
1695
- * @param {string} key to be escaped.
1696
- * @return {string} the escaped key.
1697
- */
1698
-
1699
- function escape(key) {
1700
- var escapeRegex = /[=:]/g;
1701
- var escaperLookup = {
1702
- '=': '=0',
1703
- ':': '=2'
1704
- };
1705
- var escapedString = key.replace(escapeRegex, function (match) {
1706
- return escaperLookup[match];
1707
- });
1708
- return '$' + escapedString;
1709
- }
1710
- /**
1711
- * TODO: Test that a single child and an array with one item have the same key
1712
- * pattern.
1713
- */
1714
-
1715
-
1716
- var didWarnAboutMaps = false;
1717
- var userProvidedKeyEscapeRegex = /\/+/g;
1718
-
1719
- function escapeUserProvidedKey(text) {
1720
- return text.replace(userProvidedKeyEscapeRegex, '$&/');
1721
- }
1722
- /**
1723
- * Generate a key string that identifies a element within a set.
1724
- *
1725
- * @param {*} element A element that could contain a manual key.
1726
- * @param {number} index Index that is used if a manual key is not provided.
1727
- * @return {string}
1728
- */
1729
-
1730
-
1731
- function getElementKey(element, index) {
1732
- // Do some typechecking here since we call this blindly. We want to ensure
1733
- // that we don't block potential future ES APIs.
1734
- if (typeof element === 'object' && element !== null && element.key != null) {
1735
- // Explicit key
1736
- {
1737
- checkKeyStringCoercion(element.key);
1738
- }
1739
-
1740
- return escape('' + element.key);
1741
- } // Implicit key determined by the index in the set
1742
-
1743
-
1744
- return index.toString(36);
1745
- }
1746
-
1747
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1748
- var type = typeof children;
1749
-
1750
- if (type === 'undefined' || type === 'boolean') {
1751
- // All of the above are perceived as null.
1752
- children = null;
1753
- }
1754
-
1755
- var invokeCallback = false;
1756
-
1757
- if (children === null) {
1758
- invokeCallback = true;
1759
- } else {
1760
- switch (type) {
1761
- case 'string':
1762
- case 'number':
1763
- invokeCallback = true;
1764
- break;
1765
-
1766
- case 'object':
1767
- switch (children.$$typeof) {
1768
- case REACT_ELEMENT_TYPE:
1769
- case REACT_PORTAL_TYPE:
1770
- invokeCallback = true;
1771
- }
1772
-
1773
- }
1774
- }
1775
-
1776
- if (invokeCallback) {
1777
- var _child = children;
1778
- var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array
1779
- // so that it's consistent if the number of children grows:
1780
-
1781
- var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
1782
-
1783
- if (isArray(mappedChild)) {
1784
- var escapedChildKey = '';
1785
-
1786
- if (childKey != null) {
1787
- escapedChildKey = escapeUserProvidedKey(childKey) + '/';
1788
- }
1789
-
1790
- mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {
1791
- return c;
1792
- });
1793
- } else if (mappedChild != null) {
1794
- if (isValidElement(mappedChild)) {
1795
- {
1796
- // The `if` statement here prevents auto-disabling of the safe
1797
- // coercion ESLint rule, so we must manually disable it below.
1798
- // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1799
- if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
1800
- checkKeyStringCoercion(mappedChild.key);
1801
- }
1802
- }
1803
-
1804
- mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
1805
- // traverseAllChildren used to do for objects as children
1806
- escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1807
- mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number
1808
- // eslint-disable-next-line react-internal/safe-string-coercion
1809
- escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);
1810
- }
1811
-
1812
- array.push(mappedChild);
1813
- }
1814
-
1815
- return 1;
1816
- }
1817
-
1818
- var child;
1819
- var nextName;
1820
- var subtreeCount = 0; // Count of children found in the current subtree.
1821
-
1822
- var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1823
-
1824
- if (isArray(children)) {
1825
- for (var i = 0; i < children.length; i++) {
1826
- child = children[i];
1827
- nextName = nextNamePrefix + getElementKey(child, i);
1828
- subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
1829
- }
1830
- } else {
1831
- var iteratorFn = getIteratorFn(children);
1832
-
1833
- if (typeof iteratorFn === 'function') {
1834
- var iterableChildren = children;
1835
-
1836
- {
1837
- // Warn about using Maps as children
1838
- if (iteratorFn === iterableChildren.entries) {
1839
- if (!didWarnAboutMaps) {
1840
- warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
1841
- }
1842
-
1843
- didWarnAboutMaps = true;
1844
- }
1845
- }
1846
-
1847
- var iterator = iteratorFn.call(iterableChildren);
1848
- var step;
1849
- var ii = 0;
1850
-
1851
- while (!(step = iterator.next()).done) {
1852
- child = step.value;
1853
- nextName = nextNamePrefix + getElementKey(child, ii++);
1854
- subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
1855
- }
1856
- } else if (type === 'object') {
1857
- // eslint-disable-next-line react-internal/safe-string-coercion
1858
- var childrenString = String(children);
1859
- throw new Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.');
1860
- }
1861
- }
1862
-
1863
- return subtreeCount;
1864
- }
1865
-
1866
- /**
1867
- * Maps children that are typically specified as `props.children`.
1868
- *
1869
- * See https://reactjs.org/docs/react-api.html#reactchildrenmap
1870
- *
1871
- * The provided mapFunction(child, index) will be called for each
1872
- * leaf child.
1873
- *
1874
- * @param {?*} children Children tree container.
1875
- * @param {function(*, int)} func The map function.
1876
- * @param {*} context Context for mapFunction.
1877
- * @return {object} Object containing the ordered map of results.
1878
- */
1879
- function mapChildren(children, func, context) {
1880
- if (children == null) {
1881
- return children;
1882
- }
1883
-
1884
- var result = [];
1885
- var count = 0;
1886
- mapIntoArray(children, result, '', '', function (child) {
1887
- return func.call(context, child, count++);
1888
- });
1889
- return result;
1890
- }
1891
- /**
1892
- * Count the number of children that are typically specified as
1893
- * `props.children`.
1894
- *
1895
- * See https://reactjs.org/docs/react-api.html#reactchildrencount
1896
- *
1897
- * @param {?*} children Children tree container.
1898
- * @return {number} The number of children.
1899
- */
1900
-
1901
-
1902
- function countChildren(children) {
1903
- var n = 0;
1904
- mapChildren(children, function () {
1905
- n++; // Don't return anything
1906
- });
1907
- return n;
1908
- }
1909
-
1910
- /**
1911
- * Iterates through children that are typically specified as `props.children`.
1912
- *
1913
- * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
1914
- *
1915
- * The provided forEachFunc(child, index) will be called for each
1916
- * leaf child.
1917
- *
1918
- * @param {?*} children Children tree container.
1919
- * @param {function(*, int)} forEachFunc
1920
- * @param {*} forEachContext Context for forEachContext.
1921
- */
1922
- function forEachChildren(children, forEachFunc, forEachContext) {
1923
- mapChildren(children, function () {
1924
- forEachFunc.apply(this, arguments); // Don't return anything.
1925
- }, forEachContext);
1926
- }
1927
- /**
1928
- * Flatten a children object (typically specified as `props.children`) and
1929
- * return an array with appropriately re-keyed children.
1930
- *
1931
- * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
1932
- */
1933
-
1934
-
1935
- function toArray(children) {
1936
- return mapChildren(children, function (child) {
1937
- return child;
1938
- }) || [];
1939
- }
1940
- /**
1941
- * Returns the first child in a collection of children and verifies that there
1942
- * is only one child in the collection.
1943
- *
1944
- * See https://reactjs.org/docs/react-api.html#reactchildrenonly
1945
- *
1946
- * The current implementation of this function assumes that a single child gets
1947
- * passed without a wrapper, but the purpose of this helper function is to
1948
- * abstract away the particular structure of children.
1949
- *
1950
- * @param {?object} children Child collection structure.
1951
- * @return {ReactElement} The first and only `ReactElement` contained in the
1952
- * structure.
1953
- */
1954
-
1955
-
1956
- function onlyChild(children) {
1957
- if (!isValidElement(children)) {
1958
- throw new Error('React.Children.only expected to receive a single React element child.');
1959
- }
1960
-
1961
- return children;
1962
- }
1963
-
1964
- function createContext(defaultValue) {
1965
- // TODO: Second argument used to be an optional `calculateChangedBits`
1966
- // function. Warn to reserve for future use?
1967
- var context = {
1968
- $$typeof: REACT_CONTEXT_TYPE,
1969
- // As a workaround to support multiple concurrent renderers, we categorize
1970
- // some renderers as primary and others as secondary. We only expect
1971
- // there to be two concurrent renderers at most: React Native (primary) and
1972
- // Fabric (secondary); React DOM (primary) and React ART (secondary).
1973
- // Secondary renderers store their context values on separate fields.
1974
- _currentValue: defaultValue,
1975
- _currentValue2: defaultValue,
1976
- // Used to track how many concurrent renderers this context currently
1977
- // supports within in a single renderer. Such as parallel server rendering.
1978
- _threadCount: 0,
1979
- // These are circular
1980
- Provider: null,
1981
- Consumer: null,
1982
- // Add these to use same hidden class in VM as ServerContext
1983
- _defaultValue: null,
1984
- _globalName: null
1985
- };
1986
- context.Provider = {
1987
- $$typeof: REACT_PROVIDER_TYPE,
1988
- _context: context
1989
- };
1990
- var hasWarnedAboutUsingNestedContextConsumers = false;
1991
- var hasWarnedAboutUsingConsumerProvider = false;
1992
- var hasWarnedAboutDisplayNameOnConsumer = false;
1993
-
1994
- {
1995
- // A separate object, but proxies back to the original context object for
1996
- // backwards compatibility. It has a different $$typeof, so we can properly
1997
- // warn for the incorrect usage of Context as a Consumer.
1998
- var Consumer = {
1999
- $$typeof: REACT_CONTEXT_TYPE,
2000
- _context: context
2001
- }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
2002
-
2003
- Object.defineProperties(Consumer, {
2004
- Provider: {
2005
- get: function () {
2006
- if (!hasWarnedAboutUsingConsumerProvider) {
2007
- hasWarnedAboutUsingConsumerProvider = true;
2008
-
2009
- error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
2010
- }
2011
-
2012
- return context.Provider;
2013
- },
2014
- set: function (_Provider) {
2015
- context.Provider = _Provider;
2016
- }
2017
- },
2018
- _currentValue: {
2019
- get: function () {
2020
- return context._currentValue;
2021
- },
2022
- set: function (_currentValue) {
2023
- context._currentValue = _currentValue;
2024
- }
2025
- },
2026
- _currentValue2: {
2027
- get: function () {
2028
- return context._currentValue2;
2029
- },
2030
- set: function (_currentValue2) {
2031
- context._currentValue2 = _currentValue2;
2032
- }
2033
- },
2034
- _threadCount: {
2035
- get: function () {
2036
- return context._threadCount;
2037
- },
2038
- set: function (_threadCount) {
2039
- context._threadCount = _threadCount;
2040
- }
2041
- },
2042
- Consumer: {
2043
- get: function () {
2044
- if (!hasWarnedAboutUsingNestedContextConsumers) {
2045
- hasWarnedAboutUsingNestedContextConsumers = true;
2046
-
2047
- error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
2048
- }
2049
-
2050
- return context.Consumer;
2051
- }
2052
- },
2053
- displayName: {
2054
- get: function () {
2055
- return context.displayName;
2056
- },
2057
- set: function (displayName) {
2058
- if (!hasWarnedAboutDisplayNameOnConsumer) {
2059
- warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName);
2060
-
2061
- hasWarnedAboutDisplayNameOnConsumer = true;
2062
- }
2063
- }
2064
- }
2065
- }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
2066
-
2067
- context.Consumer = Consumer;
2068
- }
2069
-
2070
- {
2071
- context._currentRenderer = null;
2072
- context._currentRenderer2 = null;
2073
- }
2074
-
2075
- return context;
2076
- }
2077
-
2078
- var Uninitialized = -1;
2079
- var Pending = 0;
2080
- var Resolved = 1;
2081
- var Rejected = 2;
2082
-
2083
- function lazyInitializer(payload) {
2084
- if (payload._status === Uninitialized) {
2085
- var ctor = payload._result;
2086
- var thenable = ctor(); // Transition to the next state.
2087
- // This might throw either because it's missing or throws. If so, we treat it
2088
- // as still uninitialized and try again next time. Which is the same as what
2089
- // happens if the ctor or any wrappers processing the ctor throws. This might
2090
- // end up fixing it if the resolution was a concurrency bug.
2091
-
2092
- thenable.then(function (moduleObject) {
2093
- if (payload._status === Pending || payload._status === Uninitialized) {
2094
- // Transition to the next state.
2095
- var resolved = payload;
2096
- resolved._status = Resolved;
2097
- resolved._result = moduleObject;
2098
- }
2099
- }, function (error) {
2100
- if (payload._status === Pending || payload._status === Uninitialized) {
2101
- // Transition to the next state.
2102
- var rejected = payload;
2103
- rejected._status = Rejected;
2104
- rejected._result = error;
2105
- }
2106
- });
2107
-
2108
- if (payload._status === Uninitialized) {
2109
- // In case, we're still uninitialized, then we're waiting for the thenable
2110
- // to resolve. Set it as pending in the meantime.
2111
- var pending = payload;
2112
- pending._status = Pending;
2113
- pending._result = thenable;
2114
- }
2115
- }
2116
-
2117
- if (payload._status === Resolved) {
2118
- var moduleObject = payload._result;
2119
-
2120
- {
2121
- if (moduleObject === undefined) {
2122
- error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
2123
- 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))\n\n" + 'Did you accidentally put curly braces around the import?', moduleObject);
2124
- }
2125
- }
2126
-
2127
- {
2128
- if (!('default' in moduleObject)) {
2129
- error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
2130
- 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
2131
- }
2132
- }
2133
-
2134
- return moduleObject.default;
2135
- } else {
2136
- throw payload._result;
2137
- }
2138
- }
2139
-
2140
- function lazy(ctor) {
2141
- var payload = {
2142
- // We use these fields to store the result.
2143
- _status: Uninitialized,
2144
- _result: ctor
2145
- };
2146
- var lazyType = {
2147
- $$typeof: REACT_LAZY_TYPE,
2148
- _payload: payload,
2149
- _init: lazyInitializer
2150
- };
2151
-
2152
- {
2153
- // In production, this would just set it on the object.
2154
- var defaultProps;
2155
- var propTypes; // $FlowFixMe
2156
-
2157
- Object.defineProperties(lazyType, {
2158
- defaultProps: {
2159
- configurable: true,
2160
- get: function () {
2161
- return defaultProps;
2162
- },
2163
- set: function (newDefaultProps) {
2164
- error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
2165
-
2166
- defaultProps = newDefaultProps; // Match production behavior more closely:
2167
- // $FlowFixMe
2168
-
2169
- Object.defineProperty(lazyType, 'defaultProps', {
2170
- enumerable: true
2171
- });
2172
- }
2173
- },
2174
- propTypes: {
2175
- configurable: true,
2176
- get: function () {
2177
- return propTypes;
2178
- },
2179
- set: function (newPropTypes) {
2180
- error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
2181
-
2182
- propTypes = newPropTypes; // Match production behavior more closely:
2183
- // $FlowFixMe
2184
-
2185
- Object.defineProperty(lazyType, 'propTypes', {
2186
- enumerable: true
2187
- });
2188
- }
2189
- }
2190
- });
2191
- }
2192
-
2193
- return lazyType;
2194
- }
2195
-
2196
- function forwardRef(render) {
2197
- {
2198
- if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
2199
- error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
2200
- } else if (typeof render !== 'function') {
2201
- error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
2202
- } else {
2203
- if (render.length !== 0 && render.length !== 2) {
2204
- error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.');
2205
- }
2206
- }
2207
-
2208
- if (render != null) {
2209
- if (render.defaultProps != null || render.propTypes != null) {
2210
- error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');
2211
- }
2212
- }
2213
- }
2214
-
2215
- var elementType = {
2216
- $$typeof: REACT_FORWARD_REF_TYPE,
2217
- render: render
2218
- };
2219
-
2220
- {
2221
- var ownName;
2222
- Object.defineProperty(elementType, 'displayName', {
2223
- enumerable: false,
2224
- configurable: true,
2225
- get: function () {
2226
- return ownName;
2227
- },
2228
- set: function (name) {
2229
- ownName = name; // The inner component shouldn't inherit this display name in most cases,
2230
- // because the component may be used elsewhere.
2231
- // But it's nice for anonymous functions to inherit the name,
2232
- // so that our component-stack generation logic will display their frames.
2233
- // An anonymous function generally suggests a pattern like:
2234
- // React.forwardRef((props, ref) => {...});
2235
- // This kind of inner function is not used elsewhere so the side effect is okay.
2236
-
2237
- if (!render.name && !render.displayName) {
2238
- render.displayName = name;
2239
- }
2240
- }
2241
- });
2242
- }
2243
-
2244
- return elementType;
2245
- }
2246
-
2247
- var REACT_MODULE_REFERENCE;
2248
-
2249
- {
2250
- REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
2251
- }
2252
-
2253
- function isValidElementType(type) {
2254
- if (typeof type === 'string' || typeof type === 'function') {
2255
- return true;
2256
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
2257
-
2258
-
2259
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
2260
- return true;
2261
- }
2262
-
2263
- if (typeof type === 'object' && type !== null) {
2264
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
2265
- // types supported by any Flight configuration anywhere since
2266
- // we don't know which Flight build this will end up being used
2267
- // with.
2268
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
2269
- return true;
2270
- }
2271
- }
2272
-
2273
- return false;
2274
- }
2275
-
2276
- function memo(type, compare) {
2277
- {
2278
- if (!isValidElementType(type)) {
2279
- error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
2280
- }
2281
- }
2282
-
2283
- var elementType = {
2284
- $$typeof: REACT_MEMO_TYPE,
2285
- type: type,
2286
- compare: compare === undefined ? null : compare
2287
- };
2288
-
2289
- {
2290
- var ownName;
2291
- Object.defineProperty(elementType, 'displayName', {
2292
- enumerable: false,
2293
- configurable: true,
2294
- get: function () {
2295
- return ownName;
2296
- },
2297
- set: function (name) {
2298
- ownName = name; // The inner component shouldn't inherit this display name in most cases,
2299
- // because the component may be used elsewhere.
2300
- // But it's nice for anonymous functions to inherit the name,
2301
- // so that our component-stack generation logic will display their frames.
2302
- // An anonymous function generally suggests a pattern like:
2303
- // React.memo((props) => {...});
2304
- // This kind of inner function is not used elsewhere so the side effect is okay.
2305
-
2306
- if (!type.name && !type.displayName) {
2307
- type.displayName = name;
2308
- }
2309
- }
2310
- });
2311
- }
2312
-
2313
- return elementType;
2314
- }
2315
-
2316
- function resolveDispatcher() {
2317
- var dispatcher = ReactCurrentDispatcher.current;
2318
-
2319
- {
2320
- if (dispatcher === null) {
2321
- error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');
2322
- }
2323
- } // Will result in a null access error if accessed outside render phase. We
2324
- // intentionally don't throw our own error because this is in a hot path.
2325
- // Also helps ensure this is inlined.
2326
-
2327
-
2328
- return dispatcher;
2329
- }
2330
- function useContext(Context) {
2331
- var dispatcher = resolveDispatcher();
2332
-
2333
- {
2334
- // TODO: add a more generic warning for invalid values.
2335
- if (Context._context !== undefined) {
2336
- var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
2337
- // and nobody should be using this in existing code.
2338
-
2339
- if (realContext.Consumer === Context) {
2340
- error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
2341
- } else if (realContext.Provider === Context) {
2342
- error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
2343
- }
2344
- }
2345
- }
2346
-
2347
- return dispatcher.useContext(Context);
2348
- }
2349
- function useState(initialState) {
2350
- var dispatcher = resolveDispatcher();
2351
- return dispatcher.useState(initialState);
2352
- }
2353
- function useReducer(reducer, initialArg, init) {
2354
- var dispatcher = resolveDispatcher();
2355
- return dispatcher.useReducer(reducer, initialArg, init);
2356
- }
2357
- function useRef(initialValue) {
2358
- var dispatcher = resolveDispatcher();
2359
- return dispatcher.useRef(initialValue);
2360
- }
2361
- function useEffect(create, deps) {
2362
- var dispatcher = resolveDispatcher();
2363
- return dispatcher.useEffect(create, deps);
2364
- }
2365
- function useInsertionEffect(create, deps) {
2366
- var dispatcher = resolveDispatcher();
2367
- return dispatcher.useInsertionEffect(create, deps);
2368
- }
2369
- function useLayoutEffect(create, deps) {
2370
- var dispatcher = resolveDispatcher();
2371
- return dispatcher.useLayoutEffect(create, deps);
2372
- }
2373
- function useCallback(callback, deps) {
2374
- var dispatcher = resolveDispatcher();
2375
- return dispatcher.useCallback(callback, deps);
2376
- }
2377
- function useMemo(create, deps) {
2378
- var dispatcher = resolveDispatcher();
2379
- return dispatcher.useMemo(create, deps);
2380
- }
2381
- function useImperativeHandle(ref, create, deps) {
2382
- var dispatcher = resolveDispatcher();
2383
- return dispatcher.useImperativeHandle(ref, create, deps);
2384
- }
2385
- function useDebugValue(value, formatterFn) {
2386
- {
2387
- var dispatcher = resolveDispatcher();
2388
- return dispatcher.useDebugValue(value, formatterFn);
2389
- }
2390
- }
2391
- function useTransition() {
2392
- var dispatcher = resolveDispatcher();
2393
- return dispatcher.useTransition();
2394
- }
2395
- function useDeferredValue(value) {
2396
- var dispatcher = resolveDispatcher();
2397
- return dispatcher.useDeferredValue(value);
2398
- }
2399
- function useId() {
2400
- var dispatcher = resolveDispatcher();
2401
- return dispatcher.useId();
2402
- }
2403
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
2404
- var dispatcher = resolveDispatcher();
2405
- return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
2406
- }
2407
-
2408
- // Helpers to patch console.logs to avoid logging during side-effect free
2409
- // replaying on render function. This currently only patches the object
2410
- // lazily which won't cover if the log function was extracted eagerly.
2411
- // We could also eagerly patch the method.
2412
- var disabledDepth = 0;
2413
- var prevLog;
2414
- var prevInfo;
2415
- var prevWarn;
2416
- var prevError;
2417
- var prevGroup;
2418
- var prevGroupCollapsed;
2419
- var prevGroupEnd;
2420
-
2421
- function disabledLog() {}
2422
-
2423
- disabledLog.__reactDisabledLog = true;
2424
- function disableLogs() {
2425
- {
2426
- if (disabledDepth === 0) {
2427
- /* eslint-disable react-internal/no-production-logging */
2428
- prevLog = console.log;
2429
- prevInfo = console.info;
2430
- prevWarn = console.warn;
2431
- prevError = console.error;
2432
- prevGroup = console.group;
2433
- prevGroupCollapsed = console.groupCollapsed;
2434
- prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
2435
-
2436
- var props = {
2437
- configurable: true,
2438
- enumerable: true,
2439
- value: disabledLog,
2440
- writable: true
2441
- }; // $FlowFixMe Flow thinks console is immutable.
2442
-
2443
- Object.defineProperties(console, {
2444
- info: props,
2445
- log: props,
2446
- warn: props,
2447
- error: props,
2448
- group: props,
2449
- groupCollapsed: props,
2450
- groupEnd: props
2451
- });
2452
- /* eslint-enable react-internal/no-production-logging */
2453
- }
2454
-
2455
- disabledDepth++;
2456
- }
2457
- }
2458
- function reenableLogs() {
2459
- {
2460
- disabledDepth--;
2461
-
2462
- if (disabledDepth === 0) {
2463
- /* eslint-disable react-internal/no-production-logging */
2464
- var props = {
2465
- configurable: true,
2466
- enumerable: true,
2467
- writable: true
2468
- }; // $FlowFixMe Flow thinks console is immutable.
2469
-
2470
- Object.defineProperties(console, {
2471
- log: assign({}, props, {
2472
- value: prevLog
2473
- }),
2474
- info: assign({}, props, {
2475
- value: prevInfo
2476
- }),
2477
- warn: assign({}, props, {
2478
- value: prevWarn
2479
- }),
2480
- error: assign({}, props, {
2481
- value: prevError
2482
- }),
2483
- group: assign({}, props, {
2484
- value: prevGroup
2485
- }),
2486
- groupCollapsed: assign({}, props, {
2487
- value: prevGroupCollapsed
2488
- }),
2489
- groupEnd: assign({}, props, {
2490
- value: prevGroupEnd
2491
- })
2492
- });
2493
- /* eslint-enable react-internal/no-production-logging */
2494
- }
2495
-
2496
- if (disabledDepth < 0) {
2497
- error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
2498
- }
2499
- }
2500
- }
2501
-
2502
- var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
2503
- var prefix;
2504
- function describeBuiltInComponentFrame(name, source, ownerFn) {
2505
- {
2506
- if (prefix === undefined) {
2507
- // Extract the VM specific prefix used by each line.
2508
- try {
2509
- throw Error();
2510
- } catch (x) {
2511
- var match = x.stack.trim().match(/\n( *(at )?)/);
2512
- prefix = match && match[1] || '';
2513
- }
2514
- } // We use the prefix to ensure our stacks line up with native stack frames.
2515
-
2516
-
2517
- return '\n' + prefix + name;
2518
- }
2519
- }
2520
- var reentry = false;
2521
- var componentFrameCache;
2522
-
2523
- {
2524
- var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
2525
- componentFrameCache = new PossiblyWeakMap();
2526
- }
2527
-
2528
- function describeNativeComponentFrame(fn, construct) {
2529
- // If something asked for a stack inside a fake render, it should get ignored.
2530
- if ( !fn || reentry) {
2531
- return '';
2532
- }
2533
-
2534
- {
2535
- var frame = componentFrameCache.get(fn);
2536
-
2537
- if (frame !== undefined) {
2538
- return frame;
2539
- }
2540
- }
2541
-
2542
- var control;
2543
- reentry = true;
2544
- var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
2545
-
2546
- Error.prepareStackTrace = undefined;
2547
- var previousDispatcher;
2548
-
2549
- {
2550
- previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function
2551
- // for warnings.
2552
-
2553
- ReactCurrentDispatcher$1.current = null;
2554
- disableLogs();
2555
- }
2556
-
2557
- try {
2558
- // This should throw.
2559
- if (construct) {
2560
- // Something should be setting the props in the constructor.
2561
- var Fake = function () {
2562
- throw Error();
2563
- }; // $FlowFixMe
2564
-
2565
-
2566
- Object.defineProperty(Fake.prototype, 'props', {
2567
- set: function () {
2568
- // We use a throwing setter instead of frozen or non-writable props
2569
- // because that won't throw in a non-strict mode function.
2570
- throw Error();
2571
- }
2572
- });
2573
-
2574
- if (typeof Reflect === 'object' && Reflect.construct) {
2575
- // We construct a different control for this case to include any extra
2576
- // frames added by the construct call.
2577
- try {
2578
- Reflect.construct(Fake, []);
2579
- } catch (x) {
2580
- control = x;
2581
- }
2582
-
2583
- Reflect.construct(fn, [], Fake);
2584
- } else {
2585
- try {
2586
- Fake.call();
2587
- } catch (x) {
2588
- control = x;
2589
- }
2590
-
2591
- fn.call(Fake.prototype);
2592
- }
2593
- } else {
2594
- try {
2595
- throw Error();
2596
- } catch (x) {
2597
- control = x;
2598
- }
2599
-
2600
- fn();
2601
- }
2602
- } catch (sample) {
2603
- // This is inlined manually because closure doesn't do it for us.
2604
- if (sample && control && typeof sample.stack === 'string') {
2605
- // This extracts the first frame from the sample that isn't also in the control.
2606
- // Skipping one frame that we assume is the frame that calls the two.
2607
- var sampleLines = sample.stack.split('\n');
2608
- var controlLines = control.stack.split('\n');
2609
- var s = sampleLines.length - 1;
2610
- var c = controlLines.length - 1;
2611
-
2612
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
2613
- // We expect at least one stack frame to be shared.
2614
- // Typically this will be the root most one. However, stack frames may be
2615
- // cut off due to maximum stack limits. In this case, one maybe cut off
2616
- // earlier than the other. We assume that the sample is longer or the same
2617
- // and there for cut off earlier. So we should find the root most frame in
2618
- // the sample somewhere in the control.
2619
- c--;
2620
- }
2621
-
2622
- for (; s >= 1 && c >= 0; s--, c--) {
2623
- // Next we find the first one that isn't the same which should be the
2624
- // frame that called our sample function and the control.
2625
- if (sampleLines[s] !== controlLines[c]) {
2626
- // In V8, the first line is describing the message but other VMs don't.
2627
- // If we're about to return the first line, and the control is also on the same
2628
- // line, that's a pretty good indicator that our sample threw at same line as
2629
- // the control. I.e. before we entered the sample frame. So we ignore this result.
2630
- // This can happen if you passed a class to function component, or non-function.
2631
- if (s !== 1 || c !== 1) {
2632
- do {
2633
- s--;
2634
- c--; // We may still have similar intermediate frames from the construct call.
2635
- // The next one that isn't the same should be our match though.
2636
-
2637
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
2638
- // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
2639
- var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
2640
- // but we have a user-provided "displayName"
2641
- // splice it in to make the stack more readable.
2642
-
2643
-
2644
- if (fn.displayName && _frame.includes('<anonymous>')) {
2645
- _frame = _frame.replace('<anonymous>', fn.displayName);
2646
- }
2647
-
2648
- {
2649
- if (typeof fn === 'function') {
2650
- componentFrameCache.set(fn, _frame);
2651
- }
2652
- } // Return the line we found.
2653
-
2654
-
2655
- return _frame;
2656
- }
2657
- } while (s >= 1 && c >= 0);
2658
- }
2659
-
2660
- break;
2661
- }
2662
- }
2663
- }
2664
- } finally {
2665
- reentry = false;
2666
-
2667
- {
2668
- ReactCurrentDispatcher$1.current = previousDispatcher;
2669
- reenableLogs();
2670
- }
2671
-
2672
- Error.prepareStackTrace = previousPrepareStackTrace;
2673
- } // Fallback to just using the name if we couldn't make it throw.
2674
-
2675
-
2676
- var name = fn ? fn.displayName || fn.name : '';
2677
- var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
2678
-
2679
- {
2680
- if (typeof fn === 'function') {
2681
- componentFrameCache.set(fn, syntheticFrame);
2682
- }
2683
- }
2684
-
2685
- return syntheticFrame;
2686
- }
2687
- function describeFunctionComponentFrame(fn, source, ownerFn) {
2688
- {
2689
- return describeNativeComponentFrame(fn, false);
2690
- }
2691
- }
2692
-
2693
- function shouldConstruct(Component) {
2694
- var prototype = Component.prototype;
2695
- return !!(prototype && prototype.isReactComponent);
2696
- }
2697
-
2698
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
2699
-
2700
- if (type == null) {
2701
- return '';
2702
- }
2703
-
2704
- if (typeof type === 'function') {
2705
- {
2706
- return describeNativeComponentFrame(type, shouldConstruct(type));
2707
- }
2708
- }
2709
-
2710
- if (typeof type === 'string') {
2711
- return describeBuiltInComponentFrame(type);
2712
- }
2713
-
2714
- switch (type) {
2715
- case REACT_SUSPENSE_TYPE:
2716
- return describeBuiltInComponentFrame('Suspense');
2717
-
2718
- case REACT_SUSPENSE_LIST_TYPE:
2719
- return describeBuiltInComponentFrame('SuspenseList');
2720
- }
2721
-
2722
- if (typeof type === 'object') {
2723
- switch (type.$$typeof) {
2724
- case REACT_FORWARD_REF_TYPE:
2725
- return describeFunctionComponentFrame(type.render);
2726
-
2727
- case REACT_MEMO_TYPE:
2728
- // Memo may contain any component type so we recursively resolve it.
2729
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
2730
-
2731
- case REACT_LAZY_TYPE:
2732
- {
2733
- var lazyComponent = type;
2734
- var payload = lazyComponent._payload;
2735
- var init = lazyComponent._init;
2736
-
2737
- try {
2738
- // Lazy may contain any component type so we recursively resolve it.
2739
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
2740
- } catch (x) {}
2741
- }
2742
- }
2743
- }
2744
-
2745
- return '';
2746
- }
2747
-
2748
- var loggedTypeFailures = {};
2749
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
2750
-
2751
- function setCurrentlyValidatingElement(element) {
2752
- {
2753
- if (element) {
2754
- var owner = element._owner;
2755
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
2756
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
2757
- } else {
2758
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
2759
- }
2760
- }
2761
- }
2762
-
2763
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
2764
- {
2765
- // $FlowFixMe This is okay but Flow doesn't know it.
2766
- var has = Function.call.bind(hasOwnProperty);
2767
-
2768
- for (var typeSpecName in typeSpecs) {
2769
- if (has(typeSpecs, typeSpecName)) {
2770
- var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
2771
- // fail the render phase where it didn't fail before. So we log it.
2772
- // After these have been cleaned up, we'll let them throw.
2773
-
2774
- try {
2775
- // This is intentionally an invariant that gets caught. It's the same
2776
- // behavior as without this statement except with a better message.
2777
- if (typeof typeSpecs[typeSpecName] !== 'function') {
2778
- // eslint-disable-next-line react-internal/prod-error-codes
2779
- var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
2780
- err.name = 'Invariant Violation';
2781
- throw err;
2782
- }
2783
-
2784
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
2785
- } catch (ex) {
2786
- error$1 = ex;
2787
- }
2788
-
2789
- if (error$1 && !(error$1 instanceof Error)) {
2790
- setCurrentlyValidatingElement(element);
2791
-
2792
- error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
2793
-
2794
- setCurrentlyValidatingElement(null);
2795
- }
2796
-
2797
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
2798
- // Only monitor this failure once because there tends to be a lot of the
2799
- // same error.
2800
- loggedTypeFailures[error$1.message] = true;
2801
- setCurrentlyValidatingElement(element);
2802
-
2803
- error('Failed %s type: %s', location, error$1.message);
2804
-
2805
- setCurrentlyValidatingElement(null);
2806
- }
2807
- }
2808
- }
2809
- }
2810
- }
2811
-
2812
- function setCurrentlyValidatingElement$1(element) {
2813
- {
2814
- if (element) {
2815
- var owner = element._owner;
2816
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
2817
- setExtraStackFrame(stack);
2818
- } else {
2819
- setExtraStackFrame(null);
2820
- }
2821
- }
2822
- }
2823
-
2824
- var propTypesMisspellWarningShown;
2825
-
2826
- {
2827
- propTypesMisspellWarningShown = false;
2828
- }
2829
-
2830
- function getDeclarationErrorAddendum() {
2831
- if (ReactCurrentOwner.current) {
2832
- var name = getComponentNameFromType(ReactCurrentOwner.current.type);
2833
-
2834
- if (name) {
2835
- return '\n\nCheck the render method of `' + name + '`.';
2836
- }
2837
- }
2838
-
2839
- return '';
2840
- }
2841
-
2842
- function getSourceInfoErrorAddendum(source) {
2843
- if (source !== undefined) {
2844
- var fileName = source.fileName.replace(/^.*[\\\/]/, '');
2845
- var lineNumber = source.lineNumber;
2846
- return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
2847
- }
2848
-
2849
- return '';
2850
- }
2851
-
2852
- function getSourceInfoErrorAddendumForProps(elementProps) {
2853
- if (elementProps !== null && elementProps !== undefined) {
2854
- return getSourceInfoErrorAddendum(elementProps.__source);
2855
- }
2856
-
2857
- return '';
2858
- }
2859
- /**
2860
- * Warn if there's no key explicitly set on dynamic arrays of children or
2861
- * object keys are not valid. This allows us to keep track of children between
2862
- * updates.
2863
- */
2864
-
2865
-
2866
- var ownerHasKeyUseWarning = {};
2867
-
2868
- function getCurrentComponentErrorInfo(parentType) {
2869
- var info = getDeclarationErrorAddendum();
2870
-
2871
- if (!info) {
2872
- var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
2873
-
2874
- if (parentName) {
2875
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
2876
- }
2877
- }
2878
-
2879
- return info;
2880
- }
2881
- /**
2882
- * Warn if the element doesn't have an explicit key assigned to it.
2883
- * This element is in an array. The array could grow and shrink or be
2884
- * reordered. All children that haven't already been validated are required to
2885
- * have a "key" property assigned to it. Error statuses are cached so a warning
2886
- * will only be shown once.
2887
- *
2888
- * @internal
2889
- * @param {ReactElement} element Element that requires a key.
2890
- * @param {*} parentType element's parent's type.
2891
- */
2892
-
2893
-
2894
- function validateExplicitKey(element, parentType) {
2895
- if (!element._store || element._store.validated || element.key != null) {
2896
- return;
2897
- }
2898
-
2899
- element._store.validated = true;
2900
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
2901
-
2902
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
2903
- return;
2904
- }
2905
-
2906
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
2907
- // property, it may be the creator of the child that's responsible for
2908
- // assigning it a key.
2909
-
2910
- var childOwner = '';
2911
-
2912
- if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2913
- // Give the component that originally created this child.
2914
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
2915
- }
2916
-
2917
- {
2918
- setCurrentlyValidatingElement$1(element);
2919
-
2920
- error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
2921
-
2922
- setCurrentlyValidatingElement$1(null);
2923
- }
2924
- }
2925
- /**
2926
- * Ensure that every element either is passed in a static location, in an
2927
- * array with an explicit keys property defined, or in an object literal
2928
- * with valid key property.
2929
- *
2930
- * @internal
2931
- * @param {ReactNode} node Statically passed child of any type.
2932
- * @param {*} parentType node's parent's type.
2933
- */
2934
-
2935
-
2936
- function validateChildKeys(node, parentType) {
2937
- if (typeof node !== 'object') {
2938
- return;
2939
- }
2940
-
2941
- if (isArray(node)) {
2942
- for (var i = 0; i < node.length; i++) {
2943
- var child = node[i];
2944
-
2945
- if (isValidElement(child)) {
2946
- validateExplicitKey(child, parentType);
2947
- }
2948
- }
2949
- } else if (isValidElement(node)) {
2950
- // This element was passed in a valid location.
2951
- if (node._store) {
2952
- node._store.validated = true;
2953
- }
2954
- } else if (node) {
2955
- var iteratorFn = getIteratorFn(node);
2956
-
2957
- if (typeof iteratorFn === 'function') {
2958
- // Entry iterators used to provide implicit keys,
2959
- // but now we print a separate warning for them later.
2960
- if (iteratorFn !== node.entries) {
2961
- var iterator = iteratorFn.call(node);
2962
- var step;
2963
-
2964
- while (!(step = iterator.next()).done) {
2965
- if (isValidElement(step.value)) {
2966
- validateExplicitKey(step.value, parentType);
2967
- }
2968
- }
2969
- }
2970
- }
2971
- }
2972
- }
2973
- /**
2974
- * Given an element, validate that its props follow the propTypes definition,
2975
- * provided by the type.
2976
- *
2977
- * @param {ReactElement} element
2978
- */
2979
-
2980
-
2981
- function validatePropTypes(element) {
2982
- {
2983
- var type = element.type;
2984
-
2985
- if (type === null || type === undefined || typeof type === 'string') {
2986
- return;
2987
- }
2988
-
2989
- var propTypes;
2990
-
2991
- if (typeof type === 'function') {
2992
- propTypes = type.propTypes;
2993
- } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
2994
- // Inner props are checked in the reconciler.
2995
- type.$$typeof === REACT_MEMO_TYPE)) {
2996
- propTypes = type.propTypes;
2997
- } else {
2998
- return;
2999
- }
3000
-
3001
- if (propTypes) {
3002
- // Intentionally inside to avoid triggering lazy initializers:
3003
- var name = getComponentNameFromType(type);
3004
- checkPropTypes(propTypes, element.props, 'prop', name, element);
3005
- } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
3006
- propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
3007
-
3008
- var _name = getComponentNameFromType(type);
3009
-
3010
- error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
3011
- }
3012
-
3013
- if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
3014
- error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
3015
- }
3016
- }
3017
- }
3018
- /**
3019
- * Given a fragment, validate that it can only be provided with fragment props
3020
- * @param {ReactElement} fragment
3021
- */
3022
-
3023
-
3024
- function validateFragmentProps(fragment) {
3025
- {
3026
- var keys = Object.keys(fragment.props);
3027
-
3028
- for (var i = 0; i < keys.length; i++) {
3029
- var key = keys[i];
3030
-
3031
- if (key !== 'children' && key !== 'key') {
3032
- setCurrentlyValidatingElement$1(fragment);
3033
-
3034
- error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
3035
-
3036
- setCurrentlyValidatingElement$1(null);
3037
- break;
3038
- }
3039
- }
3040
-
3041
- if (fragment.ref !== null) {
3042
- setCurrentlyValidatingElement$1(fragment);
3043
-
3044
- error('Invalid attribute `ref` supplied to `React.Fragment`.');
3045
-
3046
- setCurrentlyValidatingElement$1(null);
3047
- }
3048
- }
3049
- }
3050
- function createElementWithValidation(type, props, children) {
3051
- var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
3052
- // succeed and there will likely be errors in render.
3053
-
3054
- if (!validType) {
3055
- var info = '';
3056
-
3057
- if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
3058
- info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
3059
- }
3060
-
3061
- var sourceInfo = getSourceInfoErrorAddendumForProps(props);
3062
-
3063
- if (sourceInfo) {
3064
- info += sourceInfo;
3065
- } else {
3066
- info += getDeclarationErrorAddendum();
3067
- }
3068
-
3069
- var typeString;
3070
-
3071
- if (type === null) {
3072
- typeString = 'null';
3073
- } else if (isArray(type)) {
3074
- typeString = 'array';
3075
- } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
3076
- typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
3077
- info = ' Did you accidentally export a JSX literal instead of a component?';
3078
- } else {
3079
- typeString = typeof type;
3080
- }
3081
-
3082
- {
3083
- error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
3084
- }
3085
- }
3086
-
3087
- var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
3088
- // TODO: Drop this when these are no longer allowed as the type argument.
3089
-
3090
- if (element == null) {
3091
- return element;
3092
- } // Skip key warning if the type isn't valid since our key validation logic
3093
- // doesn't expect a non-string/function type and can throw confusing errors.
3094
- // We don't want exception behavior to differ between dev and prod.
3095
- // (Rendering will throw with a helpful message and as soon as the type is
3096
- // fixed, the key warnings will appear.)
3097
-
3098
-
3099
- if (validType) {
3100
- for (var i = 2; i < arguments.length; i++) {
3101
- validateChildKeys(arguments[i], type);
3102
- }
3103
- }
3104
-
3105
- if (type === REACT_FRAGMENT_TYPE) {
3106
- validateFragmentProps(element);
3107
- } else {
3108
- validatePropTypes(element);
3109
- }
3110
-
3111
- return element;
3112
- }
3113
- var didWarnAboutDeprecatedCreateFactory = false;
3114
- function createFactoryWithValidation(type) {
3115
- var validatedFactory = createElementWithValidation.bind(null, type);
3116
- validatedFactory.type = type;
3117
-
3118
- {
3119
- if (!didWarnAboutDeprecatedCreateFactory) {
3120
- didWarnAboutDeprecatedCreateFactory = true;
3121
-
3122
- warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');
3123
- } // Legacy hook: remove it
3124
-
3125
-
3126
- Object.defineProperty(validatedFactory, 'type', {
3127
- enumerable: false,
3128
- get: function () {
3129
- warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
3130
-
3131
- Object.defineProperty(this, 'type', {
3132
- value: type
3133
- });
3134
- return type;
3135
- }
3136
- });
3137
- }
3138
-
3139
- return validatedFactory;
3140
- }
3141
- function cloneElementWithValidation(element, props, children) {
3142
- var newElement = cloneElement.apply(this, arguments);
3143
-
3144
- for (var i = 2; i < arguments.length; i++) {
3145
- validateChildKeys(arguments[i], newElement.type);
3146
- }
3147
-
3148
- validatePropTypes(newElement);
3149
- return newElement;
3150
- }
3151
-
3152
- function startTransition(scope, options) {
3153
- var prevTransition = ReactCurrentBatchConfig.transition;
3154
- ReactCurrentBatchConfig.transition = {};
3155
- var currentTransition = ReactCurrentBatchConfig.transition;
3156
-
3157
- {
3158
- ReactCurrentBatchConfig.transition._updatedFibers = new Set();
3159
- }
3160
-
3161
- try {
3162
- scope();
3163
- } finally {
3164
- ReactCurrentBatchConfig.transition = prevTransition;
3165
-
3166
- {
3167
- if (prevTransition === null && currentTransition._updatedFibers) {
3168
- var updatedFibersCount = currentTransition._updatedFibers.size;
3169
-
3170
- if (updatedFibersCount > 10) {
3171
- warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.');
3172
- }
3173
-
3174
- currentTransition._updatedFibers.clear();
3175
- }
3176
- }
3177
- }
3178
- }
3179
-
3180
- var didWarnAboutMessageChannel = false;
3181
- var enqueueTaskImpl = null;
3182
- function enqueueTask(task) {
3183
- if (enqueueTaskImpl === null) {
3184
- try {
3185
- // read require off the module object to get around the bundlers.
3186
- // we don't want them to detect a require and bundle a Node polyfill.
3187
- var requireString = ('require' + Math.random()).slice(0, 7);
3188
- var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
3189
- // version of setImmediate, bypassing fake timers if any.
3190
-
3191
- enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
3192
- } catch (_err) {
3193
- // we're in a browser
3194
- // we can't use regular timers because they may still be faked
3195
- // so we try MessageChannel+postMessage instead
3196
- enqueueTaskImpl = function (callback) {
3197
- {
3198
- if (didWarnAboutMessageChannel === false) {
3199
- didWarnAboutMessageChannel = true;
3200
-
3201
- if (typeof MessageChannel === 'undefined') {
3202
- error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
3203
- }
3204
- }
3205
- }
3206
-
3207
- var channel = new MessageChannel();
3208
- channel.port1.onmessage = callback;
3209
- channel.port2.postMessage(undefined);
3210
- };
3211
- }
3212
- }
3213
-
3214
- return enqueueTaskImpl(task);
3215
- }
3216
-
3217
- var actScopeDepth = 0;
3218
- var didWarnNoAwaitAct = false;
3219
- function act(callback) {
3220
- {
3221
- // `act` calls can be nested, so we track the depth. This represents the
3222
- // number of `act` scopes on the stack.
3223
- var prevActScopeDepth = actScopeDepth;
3224
- actScopeDepth++;
3225
-
3226
- if (ReactCurrentActQueue.current === null) {
3227
- // This is the outermost `act` scope. Initialize the queue. The reconciler
3228
- // will detect the queue and use it instead of Scheduler.
3229
- ReactCurrentActQueue.current = [];
3230
- }
3231
-
3232
- var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
3233
- var result;
3234
-
3235
- try {
3236
- // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only
3237
- // set to `true` while the given callback is executed, not for updates
3238
- // triggered during an async event, because this is how the legacy
3239
- // implementation of `act` behaved.
3240
- ReactCurrentActQueue.isBatchingLegacy = true;
3241
- result = callback(); // Replicate behavior of original `act` implementation in legacy mode,
3242
- // which flushed updates immediately after the scope function exits, even
3243
- // if it's an async function.
3244
-
3245
- if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
3246
- var queue = ReactCurrentActQueue.current;
3247
-
3248
- if (queue !== null) {
3249
- ReactCurrentActQueue.didScheduleLegacyUpdate = false;
3250
- flushActQueue(queue);
3251
- }
3252
- }
3253
- } catch (error) {
3254
- popActScope(prevActScopeDepth);
3255
- throw error;
3256
- } finally {
3257
- ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
3258
- }
3259
-
3260
- if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
3261
- var thenableResult = result; // The callback is an async function (i.e. returned a promise). Wait
3262
- // for it to resolve before exiting the current scope.
3263
-
3264
- var wasAwaited = false;
3265
- var thenable = {
3266
- then: function (resolve, reject) {
3267
- wasAwaited = true;
3268
- thenableResult.then(function (returnValue) {
3269
- popActScope(prevActScopeDepth);
3270
-
3271
- if (actScopeDepth === 0) {
3272
- // We've exited the outermost act scope. Recursively flush the
3273
- // queue until there's no remaining work.
3274
- recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3275
- } else {
3276
- resolve(returnValue);
3277
- }
3278
- }, function (error) {
3279
- // The callback threw an error.
3280
- popActScope(prevActScopeDepth);
3281
- reject(error);
3282
- });
3283
- }
3284
- };
3285
-
3286
- {
3287
- if (!didWarnNoAwaitAct && typeof Promise !== 'undefined') {
3288
- // eslint-disable-next-line no-undef
3289
- Promise.resolve().then(function () {}).then(function () {
3290
- if (!wasAwaited) {
3291
- didWarnNoAwaitAct = true;
3292
-
3293
- error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, ' + 'interleaving multiple act calls and mixing their ' + 'scopes. ' + 'You should - await act(async () => ...);');
3294
- }
3295
- });
3296
- }
3297
- }
3298
-
3299
- return thenable;
3300
- } else {
3301
- var returnValue = result; // The callback is not an async function. Exit the current scope
3302
- // immediately, without awaiting.
3303
-
3304
- popActScope(prevActScopeDepth);
3305
-
3306
- if (actScopeDepth === 0) {
3307
- // Exiting the outermost act scope. Flush the queue.
3308
- var _queue = ReactCurrentActQueue.current;
3309
-
3310
- if (_queue !== null) {
3311
- flushActQueue(_queue);
3312
- ReactCurrentActQueue.current = null;
3313
- } // Return a thenable. If the user awaits it, we'll flush again in
3314
- // case additional work was scheduled by a microtask.
3315
-
3316
-
3317
- var _thenable = {
3318
- then: function (resolve, reject) {
3319
- // Confirm we haven't re-entered another `act` scope, in case
3320
- // the user does something weird like await the thenable
3321
- // multiple times.
3322
- if (ReactCurrentActQueue.current === null) {
3323
- // Recursively flush the queue until there's no remaining work.
3324
- ReactCurrentActQueue.current = [];
3325
- recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3326
- } else {
3327
- resolve(returnValue);
3328
- }
3329
- }
3330
- };
3331
- return _thenable;
3332
- } else {
3333
- // Since we're inside a nested `act` scope, the returned thenable
3334
- // immediately resolves. The outer scope will flush the queue.
3335
- var _thenable2 = {
3336
- then: function (resolve, reject) {
3337
- resolve(returnValue);
3338
- }
3339
- };
3340
- return _thenable2;
3341
- }
3342
- }
3343
- }
3344
- }
3345
-
3346
- function popActScope(prevActScopeDepth) {
3347
- {
3348
- if (prevActScopeDepth !== actScopeDepth - 1) {
3349
- error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
3350
- }
3351
-
3352
- actScopeDepth = prevActScopeDepth;
3353
- }
3354
- }
3355
-
3356
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
3357
- {
3358
- var queue = ReactCurrentActQueue.current;
3359
-
3360
- if (queue !== null) {
3361
- try {
3362
- flushActQueue(queue);
3363
- enqueueTask(function () {
3364
- if (queue.length === 0) {
3365
- // No additional work was scheduled. Finish.
3366
- ReactCurrentActQueue.current = null;
3367
- resolve(returnValue);
3368
- } else {
3369
- // Keep flushing work until there's none left.
3370
- recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3371
- }
3372
- });
3373
- } catch (error) {
3374
- reject(error);
3375
- }
3376
- } else {
3377
- resolve(returnValue);
3378
- }
3379
- }
3380
- }
3381
-
3382
- var isFlushing = false;
3383
-
3384
- function flushActQueue(queue) {
3385
- {
3386
- if (!isFlushing) {
3387
- // Prevent re-entrance.
3388
- isFlushing = true;
3389
- var i = 0;
3390
-
3391
- try {
3392
- for (; i < queue.length; i++) {
3393
- var callback = queue[i];
3394
-
3395
- do {
3396
- callback = callback(true);
3397
- } while (callback !== null);
3398
- }
3399
-
3400
- queue.length = 0;
3401
- } catch (error) {
3402
- // If something throws, leave the remaining callbacks on the queue.
3403
- queue = queue.slice(i + 1);
3404
- throw error;
3405
- } finally {
3406
- isFlushing = false;
3407
- }
3408
- }
3409
- }
3410
- }
3411
-
3412
- var createElement$1 = createElementWithValidation ;
3413
- var cloneElement$1 = cloneElementWithValidation ;
3414
- var createFactory = createFactoryWithValidation ;
3415
- var Children = {
3416
- map: mapChildren,
3417
- forEach: forEachChildren,
3418
- count: countChildren,
3419
- toArray: toArray,
3420
- only: onlyChild
3421
- };
3422
-
3423
- exports.Children = Children;
3424
- exports.Component = Component;
3425
- exports.Fragment = REACT_FRAGMENT_TYPE;
3426
- exports.Profiler = REACT_PROFILER_TYPE;
3427
- exports.PureComponent = PureComponent;
3428
- exports.StrictMode = REACT_STRICT_MODE_TYPE;
3429
- exports.Suspense = REACT_SUSPENSE_TYPE;
3430
- exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
3431
- exports.cloneElement = cloneElement$1;
3432
- exports.createContext = createContext;
3433
- exports.createElement = createElement$1;
3434
- exports.createFactory = createFactory;
3435
- exports.createRef = createRef;
3436
- exports.forwardRef = forwardRef;
3437
- exports.isValidElement = isValidElement;
3438
- exports.lazy = lazy;
3439
- exports.memo = memo;
3440
- exports.startTransition = startTransition;
3441
- exports.unstable_act = act;
3442
- exports.useCallback = useCallback;
3443
- exports.useContext = useContext;
3444
- exports.useDebugValue = useDebugValue;
3445
- exports.useDeferredValue = useDeferredValue;
3446
- exports.useEffect = useEffect;
3447
- exports.useId = useId;
3448
- exports.useImperativeHandle = useImperativeHandle;
3449
- exports.useInsertionEffect = useInsertionEffect;
3450
- exports.useLayoutEffect = useLayoutEffect;
3451
- exports.useMemo = useMemo;
3452
- exports.useReducer = useReducer;
3453
- exports.useRef = useRef;
3454
- exports.useState = useState;
3455
- exports.useSyncExternalStore = useSyncExternalStore;
3456
- exports.useTransition = useTransition;
3457
- exports.version = ReactVersion;
3458
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
3459
- if (
3460
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
3461
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
3462
- 'function'
3463
- ) {
3464
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
3465
- }
3466
-
3467
- })();
3468
- }
3469
- }(react_development, react_development.exports));
3470
-
3471
- if (process.env.NODE_ENV === 'production') {
3472
- react$1.exports = react_production_min;
3473
- } else {
3474
- react$1.exports = react_development.exports;
3475
- }
3476
-
3477
- var react = react$1.exports;
3478
-
3479
- var React = /*#__PURE__*/_mergeNamespaces({
3480
- __proto__: null,
3481
- 'default': react
3482
- }, [react$1.exports]);
3483
-
3484
- var contextKey = canUseSymbol
3485
- ? Symbol.for('__APOLLO_CONTEXT__')
3486
- : '__APOLLO_CONTEXT__';
3487
- function getApolloContext() {
3488
- var context = react$1.exports.createContext[contextKey];
3489
- if (!context) {
3490
- Object.defineProperty(react$1.exports.createContext, contextKey, {
3491
- value: context = react$1.exports.createContext({}),
3492
- enumerable: false,
3493
- writable: false,
3494
- configurable: true,
3495
- });
3496
- context.displayName = 'ApolloContext';
3497
- }
3498
- return context;
3499
- }
3500
-
3501
- function useApolloClient(override) {
3502
- var context = react$1.exports.useContext(getApolloContext());
3503
- var client = override || context.client;
3504
- __DEV__ ? invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
3505
- 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
3506
- 'instance in via options.') : invariant(!!client, 32);
3507
- return client;
3508
- }
3509
-
3510
- var didWarnUncachedGetSnapshot = false;
3511
- var uSESKey = "useSyncExternalStore";
3512
- var realHook = React[uSESKey];
3513
- var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
3514
- var value = getSnapshot();
3515
- if (__DEV__ &&
3516
- !didWarnUncachedGetSnapshot &&
3517
- value !== getSnapshot()) {
3518
- didWarnUncachedGetSnapshot = true;
3519
- __DEV__ && invariant.error('The result of getSnapshot should be cached to avoid an infinite loop');
3520
- }
3521
- var _a = react$1.exports.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
3522
- if (canUseLayoutEffect) {
3523
- react$1.exports.useLayoutEffect(function () {
3524
- Object.assign(inst, { value: value, getSnapshot: getSnapshot });
3525
- if (checkIfSnapshotChanged(inst)) {
3526
- forceUpdate({ inst: inst });
3527
- }
3528
- }, [subscribe, value, getSnapshot]);
3529
- }
3530
- else {
3531
- Object.assign(inst, { value: value, getSnapshot: getSnapshot });
3532
- }
3533
- react$1.exports.useEffect(function () {
3534
- if (checkIfSnapshotChanged(inst)) {
3535
- forceUpdate({ inst: inst });
3536
- }
3537
- return subscribe(function handleStoreChange() {
3538
- if (checkIfSnapshotChanged(inst)) {
3539
- forceUpdate({ inst: inst });
3540
- }
3541
- });
3542
- }, [subscribe]);
3543
- return value;
3544
- });
3545
- function checkIfSnapshotChanged(_a) {
3546
- var value = _a.value, getSnapshot = _a.getSnapshot;
3547
- try {
3548
- return value !== getSnapshot();
3549
- }
3550
- catch (_b) {
3551
- return true;
3552
- }
3553
- }
3554
-
3555
- var DocumentType;
3556
- (function (DocumentType) {
3557
- DocumentType[DocumentType["Query"] = 0] = "Query";
3558
- DocumentType[DocumentType["Mutation"] = 1] = "Mutation";
3559
- DocumentType[DocumentType["Subscription"] = 2] = "Subscription";
3560
- })(DocumentType || (DocumentType = {}));
3561
- var cache = new Map();
3562
- function operationName(type) {
3563
- var name;
3564
- switch (type) {
3565
- case DocumentType.Query:
3566
- name = 'Query';
3567
- break;
3568
- case DocumentType.Mutation:
3569
- name = 'Mutation';
3570
- break;
3571
- case DocumentType.Subscription:
3572
- name = 'Subscription';
3573
- break;
3574
- }
3575
- return name;
3576
- }
3577
- function parser(document) {
3578
- var cached = cache.get(document);
3579
- if (cached)
3580
- return cached;
3581
- var variables, type, name;
3582
- __DEV__ ? invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
3583
- "DocumentNode. You may need to use 'graphql-tag' or another method " +
3584
- "to convert your operation into a document") : invariant(!!document && !!document.kind, 33);
3585
- var fragments = [];
3586
- var queries = [];
3587
- var mutations = [];
3588
- var subscriptions = [];
3589
- for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {
3590
- var x = _a[_i];
3591
- if (x.kind === 'FragmentDefinition') {
3592
- fragments.push(x);
3593
- continue;
3594
- }
3595
- if (x.kind === 'OperationDefinition') {
3596
- switch (x.operation) {
3597
- case 'query':
3598
- queries.push(x);
3599
- break;
3600
- case 'mutation':
3601
- mutations.push(x);
3602
- break;
3603
- case 'subscription':
3604
- subscriptions.push(x);
3605
- break;
3606
- }
3607
- }
3608
- }
3609
- __DEV__ ? invariant(!fragments.length ||
3610
- (queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
3611
- "You must include a query, subscription or mutation as well") : invariant(!fragments.length ||
3612
- (queries.length || mutations.length || subscriptions.length), 34);
3613
- __DEV__ ? invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
3614
- "".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
3615
- "subscriptions and ".concat(mutations.length, " mutations. ") +
3616
- "You can use 'compose' to join multiple operation types to a component") : invariant(queries.length + mutations.length + subscriptions.length <= 1, 35);
3617
- type = queries.length ? DocumentType.Query : DocumentType.Mutation;
3618
- if (!queries.length && !mutations.length)
3619
- type = DocumentType.Subscription;
3620
- var definitions = queries.length
3621
- ? queries
3622
- : mutations.length
3623
- ? mutations
3624
- : subscriptions;
3625
- __DEV__ ? invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
3626
- "".concat(definitions.length, " definitions. ") +
3627
- "You can use 'compose' to join multiple operation types to a component") : invariant(definitions.length === 1, 36);
3628
- var definition = definitions[0];
3629
- variables = definition.variableDefinitions || [];
3630
- if (definition.name && definition.name.kind === 'Name') {
3631
- name = definition.name.value;
3632
- }
3633
- else {
3634
- name = 'data';
3635
- }
3636
- var payload = { name: name, type: type, variables: variables };
3637
- cache.set(document, payload);
3638
- return payload;
3639
- }
3640
- function verifyDocumentType(document, type) {
3641
- var operation = parser(document);
3642
- var requiredOperationName = operationName(type);
3643
- var usedOperationName = operationName(operation.type);
3644
- __DEV__ ? invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
3645
- "".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : invariant(operation.type === type, 37);
3646
- }
3647
-
3648
- var hasOwnProperty = Object.prototype.hasOwnProperty;
3649
- function useQuery(query, options) {
3650
- if (options === void 0) { options = Object.create(null); }
3651
- return useInternalState(useApolloClient(options.client), query).useQuery(options);
3652
- }
3653
- function useInternalState(client, query) {
3654
- var stateRef = react$1.exports.useRef();
3655
- if (!stateRef.current ||
3656
- client !== stateRef.current.client ||
3657
- query !== stateRef.current.query) {
3658
- stateRef.current = new InternalState(client, query, stateRef.current);
3659
- }
3660
- var state = stateRef.current;
3661
- var _a = react$1.exports.useState(0); _a[0]; var setTick = _a[1];
3662
- state.forceUpdate = function () {
3663
- setTick(function (tick) { return tick + 1; });
3664
- };
3665
- return state;
3666
- }
3667
- var InternalState = (function () {
3668
- function InternalState(client, query, previous) {
3669
- this.client = client;
3670
- this.query = query;
3671
- this.asyncResolveFns = new Set();
3672
- this.optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)();
3673
- this.ssrDisabledResult = maybeDeepFreeze({
3674
- loading: true,
3675
- data: void 0,
3676
- error: void 0,
3677
- networkStatus: NetworkStatus.loading,
3678
- });
3679
- this.skipStandbyResult = maybeDeepFreeze({
3680
- loading: false,
3681
- data: void 0,
3682
- error: void 0,
3683
- networkStatus: NetworkStatus.ready,
3684
- });
3685
- this.toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)();
3686
- verifyDocumentType(query, DocumentType.Query);
3687
- var previousResult = previous && previous.result;
3688
- var previousData = previousResult && previousResult.data;
3689
- if (previousData) {
3690
- this.previousData = previousData;
3691
- }
3692
- }
3693
- InternalState.prototype.forceUpdate = function () {
3694
- __DEV__ && invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
3695
- };
3696
- InternalState.prototype.asyncUpdate = function (signal) {
3697
- var _this = this;
3698
- return new Promise(function (resolve, reject) {
3699
- var watchQueryOptions = _this.watchQueryOptions;
3700
- var handleAborted = function () {
3701
- _this.asyncResolveFns.delete(resolve);
3702
- _this.optionsToIgnoreOnce.delete(watchQueryOptions);
3703
- signal.removeEventListener('abort', handleAborted);
3704
- reject(signal.reason);
3705
- };
3706
- _this.asyncResolveFns.add(resolve);
3707
- _this.optionsToIgnoreOnce.add(watchQueryOptions);
3708
- signal.addEventListener('abort', handleAborted);
3709
- _this.forceUpdate();
3710
- });
3711
- };
3712
- InternalState.prototype.useQuery = function (options) {
3713
- var _this = this;
3714
- this.renderPromises = react$1.exports.useContext(getApolloContext()).renderPromises;
3715
- this.useOptions(options);
3716
- var obsQuery = this.useObservableQuery();
3717
- var result = useSyncExternalStore(react$1.exports.useCallback(function () {
3718
- if (_this.renderPromises) {
3719
- return function () { };
3720
- }
3721
- var onNext = function () {
3722
- var previousResult = _this.result;
3723
- var result = obsQuery.getCurrentResult();
3724
- if (previousResult &&
3725
- previousResult.loading === result.loading &&
3726
- previousResult.networkStatus === result.networkStatus &&
3727
- equal(previousResult.data, result.data)) {
3728
- return;
3729
- }
3730
- _this.setResult(result);
3731
- };
3732
- var onError = function (error) {
3733
- var last = obsQuery["last"];
3734
- subscription.unsubscribe();
3735
- try {
3736
- obsQuery.resetLastResults();
3737
- subscription = obsQuery.subscribe(onNext, onError);
3738
- }
3739
- finally {
3740
- obsQuery["last"] = last;
3741
- }
3742
- if (!hasOwnProperty.call(error, 'graphQLErrors')) {
3743
- throw error;
3744
- }
3745
- var previousResult = _this.result;
3746
- if (!previousResult ||
3747
- (previousResult && previousResult.loading) ||
3748
- !equal(error, previousResult.error)) {
3749
- _this.setResult({
3750
- data: (previousResult && previousResult.data),
3751
- error: error,
3752
- loading: false,
3753
- networkStatus: NetworkStatus.error,
3754
- });
3755
- }
3756
- };
3757
- var subscription = obsQuery.subscribe(onNext, onError);
3758
- return function () { return subscription.unsubscribe(); };
3759
- }, [
3760
- obsQuery,
3761
- this.renderPromises,
3762
- this.client.disableNetworkFetches,
3763
- ]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
3764
- this.unsafeHandlePartialRefetch(result);
3765
- var queryResult = this.toQueryResult(result);
3766
- if (!queryResult.loading && this.asyncResolveFns.size) {
3767
- this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
3768
- this.asyncResolveFns.clear();
3769
- }
3770
- return queryResult;
3771
- };
3772
- InternalState.prototype.useOptions = function (options) {
3773
- var _a;
3774
- var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
3775
- var currentWatchQueryOptions = this.watchQueryOptions;
3776
- if (this.optionsToIgnoreOnce.has(currentWatchQueryOptions) ||
3777
- !equal(watchQueryOptions, currentWatchQueryOptions)) {
3778
- this.watchQueryOptions = watchQueryOptions;
3779
- if (currentWatchQueryOptions && this.observable) {
3780
- this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
3781
- this.observable.reobserve(this.getObsQueryOptions());
3782
- this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
3783
- this.result = void 0;
3784
- }
3785
- }
3786
- this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
3787
- this.onError = options.onError || InternalState.prototype.onError;
3788
- if ((this.renderPromises || this.client.disableNetworkFetches) &&
3789
- this.queryHookOptions.ssr === false &&
3790
- !this.queryHookOptions.skip) {
3791
- this.result = this.ssrDisabledResult;
3792
- }
3793
- else if (this.queryHookOptions.skip ||
3794
- this.watchQueryOptions.fetchPolicy === 'standby') {
3795
- this.result = this.skipStandbyResult;
3796
- }
3797
- else if (this.result === this.ssrDisabledResult ||
3798
- this.result === this.skipStandbyResult) {
3799
- this.result = void 0;
3800
- }
3801
- };
3802
- InternalState.prototype.getObsQueryOptions = function () {
3803
- var toMerge = [];
3804
- var globalDefaults = this.client.defaultOptions.watchQuery;
3805
- if (globalDefaults)
3806
- toMerge.push(globalDefaults);
3807
- if (this.queryHookOptions.defaultOptions) {
3808
- toMerge.push(this.queryHookOptions.defaultOptions);
3809
- }
3810
- toMerge.push(compact(this.observable && this.observable.options, this.watchQueryOptions));
3811
- return toMerge.reduce(mergeOptions);
3812
- };
3813
- InternalState.prototype.createWatchQueryOptions = function (_a) {
3814
- var _b;
3815
- if (_a === void 0) { _a = {}; }
3816
- var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.defaultOptions; var otherOptions = __rest(_a, ["skip", "ssr", "onCompleted", "onError", "defaultOptions"]);
3817
- var watchQueryOptions = Object.assign(otherOptions, { query: this.query });
3818
- if (this.renderPromises &&
3819
- (watchQueryOptions.fetchPolicy === 'network-only' ||
3820
- watchQueryOptions.fetchPolicy === 'cache-and-network')) {
3821
- watchQueryOptions.fetchPolicy = 'cache-first';
3822
- }
3823
- if (!watchQueryOptions.variables) {
3824
- watchQueryOptions.variables = {};
3825
- }
3826
- if (skip) {
3827
- var _c = watchQueryOptions.fetchPolicy, fetchPolicy = _c === void 0 ? this.getDefaultFetchPolicy() : _c, _d = watchQueryOptions.initialFetchPolicy, initialFetchPolicy = _d === void 0 ? fetchPolicy : _d;
3828
- Object.assign(watchQueryOptions, {
3829
- initialFetchPolicy: initialFetchPolicy,
3830
- fetchPolicy: 'standby',
3831
- });
3832
- }
3833
- else if (!watchQueryOptions.fetchPolicy) {
3834
- watchQueryOptions.fetchPolicy =
3835
- ((_b = this.observable) === null || _b === void 0 ? void 0 : _b.options.initialFetchPolicy) ||
3836
- this.getDefaultFetchPolicy();
3837
- }
3838
- return watchQueryOptions;
3839
- };
3840
- InternalState.prototype.getDefaultFetchPolicy = function () {
3841
- var _a, _b;
3842
- return (((_a = this.queryHookOptions.defaultOptions) === null || _a === void 0 ? void 0 : _a.fetchPolicy) ||
3843
- ((_b = this.client.defaultOptions.watchQuery) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
3844
- "cache-first");
3845
- };
3846
- InternalState.prototype.onCompleted = function (data) { };
3847
- InternalState.prototype.onError = function (error) { };
3848
- InternalState.prototype.useObservableQuery = function () {
3849
- var obsQuery = this.observable =
3850
- this.renderPromises
3851
- && this.renderPromises.getSSRObservable(this.watchQueryOptions)
3852
- || this.observable
3853
- || this.client.watchQuery(this.getObsQueryOptions());
3854
- this.obsQueryFields = react$1.exports.useMemo(function () { return ({
3855
- refetch: obsQuery.refetch.bind(obsQuery),
3856
- reobserve: obsQuery.reobserve.bind(obsQuery),
3857
- fetchMore: obsQuery.fetchMore.bind(obsQuery),
3858
- updateQuery: obsQuery.updateQuery.bind(obsQuery),
3859
- startPolling: obsQuery.startPolling.bind(obsQuery),
3860
- stopPolling: obsQuery.stopPolling.bind(obsQuery),
3861
- subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
3862
- }); }, [obsQuery]);
3863
- var ssrAllowed = !(this.queryHookOptions.ssr === false ||
3864
- this.queryHookOptions.skip);
3865
- if (this.renderPromises && ssrAllowed) {
3866
- this.renderPromises.registerSSRObservable(obsQuery);
3867
- if (obsQuery.getCurrentResult().loading) {
3868
- this.renderPromises.addObservableQueryPromise(obsQuery);
3869
- }
3870
- }
3871
- return obsQuery;
3872
- };
3873
- InternalState.prototype.setResult = function (nextResult) {
3874
- var previousResult = this.result;
3875
- if (previousResult && previousResult.data) {
3876
- this.previousData = previousResult.data;
3877
- }
3878
- this.result = nextResult;
3879
- this.forceUpdate();
3880
- this.handleErrorOrCompleted(nextResult);
3881
- };
3882
- InternalState.prototype.handleErrorOrCompleted = function (result) {
3883
- var _this = this;
3884
- if (!result.loading) {
3885
- var error_1 = this.toApolloError(result);
3886
- Promise.resolve().then(function () {
3887
- if (error_1) {
3888
- _this.onError(error_1);
3889
- }
3890
- else if (result.data) {
3891
- _this.onCompleted(result.data);
3892
- }
3893
- }).catch(function (error) {
3894
- __DEV__ && invariant.warn(error);
3895
- });
3896
- }
3897
- };
3898
- InternalState.prototype.toApolloError = function (result) {
3899
- return isNonEmptyArray(result.errors)
3900
- ? new ApolloError({ graphQLErrors: result.errors })
3901
- : result.error;
3902
- };
3903
- InternalState.prototype.getCurrentResult = function () {
3904
- if (!this.result) {
3905
- this.handleErrorOrCompleted(this.result = this.observable.getCurrentResult());
3906
- }
3907
- return this.result;
3908
- };
3909
- InternalState.prototype.toQueryResult = function (result) {
3910
- var queryResult = this.toQueryResultCache.get(result);
3911
- if (queryResult)
3912
- return queryResult;
3913
- var data = result.data; result.partial; var resultWithoutPartial = __rest(result, ["data", "partial"]);
3914
- this.toQueryResultCache.set(result, queryResult = __assign(__assign(__assign({ data: data }, resultWithoutPartial), this.obsQueryFields), { client: this.client, observable: this.observable, variables: this.observable.variables, called: !this.queryHookOptions.skip, previousData: this.previousData }));
3915
- if (!queryResult.error && isNonEmptyArray(result.errors)) {
3916
- queryResult.error = new ApolloError({ graphQLErrors: result.errors });
3917
- }
3918
- return queryResult;
3919
- };
3920
- InternalState.prototype.unsafeHandlePartialRefetch = function (result) {
3921
- if (result.partial &&
3922
- this.queryHookOptions.partialRefetch &&
3923
- !result.loading &&
3924
- (!result.data || Object.keys(result.data).length === 0) &&
3925
- this.observable.options.fetchPolicy !== 'cache-only') {
3926
- Object.assign(result, {
3927
- loading: true,
3928
- networkStatus: NetworkStatus.refetch,
3929
- });
3930
- this.observable.refetch();
3931
- }
3932
- };
3933
- return InternalState;
3934
- }());
4
+ import { useMemo } from 'react';
3935
5
 
3936
6
  function getFragmentData(_documentNode, fragmentType) {
3937
7
  return fragmentType;
@@ -4822,12 +892,12 @@ const useCustomFieldDefinitions = ({ entityType, filterQuery, owners, }) => {
4822
892
  },
4823
893
  });
4824
894
  const { language } = useCurrentUserLanguage();
4825
- const definitionsArray = react$1.exports.useMemo(() => {
895
+ const definitionsArray = useMemo(() => {
4826
896
  var _a, _b;
4827
897
  return (((_b = (_a = definitions === null || definitions === void 0 ? void 0 : definitions.customFieldDefinitions) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b.map(edge => getCustomFieldDefinitionFromRelevantNode(edge === null || edge === void 0 ? void 0 : edge.node))) ||
4828
898
  []);
4829
899
  }, [(_a = definitions === null || definitions === void 0 ? void 0 : definitions.customFieldDefinitions) === null || _a === void 0 ? void 0 : _a.edges]);
4830
- const filteredDefinitions = react$1.exports.useMemo(() => definitionsArray
900
+ const filteredDefinitions = useMemo(() => definitionsArray
4831
901
  .filter(nonNullable)
4832
902
  .filter(def => { var _a; return (owners && ((_a = def.owner) === null || _a === void 0 ? void 0 : _a.ownerType) ? owners.includes(def.owner.ownerType) : true); })
4833
903
  .map(def => {
@@ -4840,7 +910,7 @@ const useCustomFieldDefinitions = ({ entityType, filterQuery, owners, }) => {
4840
910
  });
4841
911
  })
4842
912
  .filter(def => (filterQuery ? def.title.toLowerCase().includes(filterQuery.toLowerCase()) : true)), [definitionsArray, filterQuery, language, owners]);
4843
- return react$1.exports.useMemo(() => ({ definitions: filteredDefinitions, loading }), [filteredDefinitions, loading]);
913
+ return useMemo(() => ({ definitions: filteredDefinitions, loading }), [filteredDefinitions, loading]);
4844
914
  };
4845
915
 
4846
916
  /**
@@ -4887,7 +957,7 @@ const useCustomFieldsValueAndDefinition = ({ entityId, entityType, systemOfMeasu
4887
957
  }
4888
958
  }
4889
959
  });
4890
- const fields = react$1.exports.useMemo(() => {
960
+ const fields = useMemo(() => {
4891
961
  var _a, _b, _c, _d, _e, _f;
4892
962
  switch (entityType) {
4893
963
  case "ASSET":
@@ -4898,9 +968,9 @@ const useCustomFieldsValueAndDefinition = ({ entityId, entityType, systemOfMeasu
4898
968
  return [];
4899
969
  }
4900
970
  }, [(_b = (_a = assetFields === null || assetFields === void 0 ? void 0 : assetFields.asset) === null || _a === void 0 ? void 0 : _a.customFields) === null || _b === void 0 ? void 0 : _b.edges, entityType, (_d = (_c = siteFields === null || siteFields === void 0 ? void 0 : siteFields.site) === null || _c === void 0 ? void 0 : _c.customFields) === null || _d === void 0 ? void 0 : _d.edges]);
4901
- const loading = react$1.exports.useMemo(() => loadingAssetFields || loadingSiteFields, [loadingAssetFields, loadingSiteFields]);
4902
- const noneNullableFields = react$1.exports.useMemo(() => fields.filter(nonNullable), [fields]);
4903
- return react$1.exports.useMemo(() => ({ fields: noneNullableFields, loading }), [noneNullableFields, loading]);
971
+ const loading = useMemo(() => loadingAssetFields || loadingSiteFields, [loadingAssetFields, loadingSiteFields]);
972
+ const noneNullableFields = useMemo(() => fields.filter(nonNullable), [fields]);
973
+ return useMemo(() => ({ fields: noneNullableFields, loading }), [noneNullableFields, loading]);
4904
974
  };
4905
975
 
4906
976
  export { GetCustomFieldsForAssetDocument, GetCustomFieldsForSiteDocument, getCustomFieldValueAndDefinitionFromRelevantNode, useCustomFieldDefinitions, useCustomFieldsValueAndDefinition };