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