UNPKG

110 kBJavaScriptView Raw
1/**
2 * @license React
3 * react.development.js
4 *
5 * Copyright (c) Facebook, Inc. and its affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */
10(function (global, factory) {
11 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
12 typeof define === 'function' && define.amd ? define(['exports'], factory) :
13 (global = global || self, factory(global.React = {}));
14}(this, (function (exports) { 'use strict';
15
16 var ReactVersion = '18.0.0-fc46dba67-20220329';
17
18 // ATTENTION
19 // When adding new symbols to this file,
20 // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
21 // The Symbol used to tag the ReactElement-like types.
22 var REACT_ELEMENT_TYPE = Symbol.for('react.element');
23 var REACT_PORTAL_TYPE = Symbol.for('react.portal');
24 var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
25 var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
26 var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
27 var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
28 var REACT_CONTEXT_TYPE = Symbol.for('react.context');
29 var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
30 var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
31 var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
32 var REACT_MEMO_TYPE = Symbol.for('react.memo');
33 var REACT_LAZY_TYPE = Symbol.for('react.lazy');
34 var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
35 var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
36 var FAUX_ITERATOR_SYMBOL = '@@iterator';
37 function getIteratorFn(maybeIterable) {
38 if (maybeIterable === null || typeof maybeIterable !== 'object') {
39 return null;
40 }
41
42 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
43
44 if (typeof maybeIterator === 'function') {
45 return maybeIterator;
46 }
47
48 return null;
49 }
50
51 /**
52 * Keeps track of the current dispatcher.
53 */
54 var ReactCurrentDispatcher = {
55 /**
56 * @internal
57 * @type {ReactComponent}
58 */
59 current: null
60 };
61
62 /**
63 * Keeps track of the current batch's configuration such as how long an update
64 * should suspend for if it needs to.
65 */
66 var ReactCurrentBatchConfig = {
67 transition: null
68 };
69
70 var ReactCurrentActQueue = {
71 current: null,
72 // Used to reproduce behavior of `batchedUpdates` in legacy mode.
73 isBatchingLegacy: false,
74 didScheduleLegacyUpdate: false
75 };
76
77 /**
78 * Keeps track of the current owner.
79 *
80 * The current owner is the component who should own any components that are
81 * currently being constructed.
82 */
83 var ReactCurrentOwner = {
84 /**
85 * @internal
86 * @type {ReactComponent}
87 */
88 current: null
89 };
90
91 var ReactDebugCurrentFrame = {};
92 var currentExtraStackFrame = null;
93 function setExtraStackFrame(stack) {
94 {
95 currentExtraStackFrame = stack;
96 }
97 }
98
99 {
100 ReactDebugCurrentFrame.setExtraStackFrame = function (stack) {
101 {
102 currentExtraStackFrame = stack;
103 }
104 }; // Stack implementation injected by the current renderer.
105
106
107 ReactDebugCurrentFrame.getCurrentStack = null;
108
109 ReactDebugCurrentFrame.getStackAddendum = function () {
110 var stack = ''; // Add an extra top frame while an element is being validated
111
112 if (currentExtraStackFrame) {
113 stack += currentExtraStackFrame;
114 } // Delegate to the injected renderer-specific implementation
115
116
117 var impl = ReactDebugCurrentFrame.getCurrentStack;
118
119 if (impl) {
120 stack += impl() || '';
121 }
122
123 return stack;
124 };
125 }
126
127 // -----------------------------------------------------------------------------
128
129 var enableScopeAPI = false; // Experimental Create Event Handle API.
130 var enableCacheElement = false;
131 var enableTransitionTracing = false; // No known bugs, but needs performance testing
132
133 var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
134 // stuff. Intended to enable React core members to more easily debug scheduling
135 // issues in DEV builds.
136
137 var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
138
139 var ReactSharedInternals = {
140 ReactCurrentDispatcher: ReactCurrentDispatcher,
141 ReactCurrentBatchConfig: ReactCurrentBatchConfig,
142 ReactCurrentOwner: ReactCurrentOwner
143 };
144
145 {
146 ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
147 ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
148 }
149
150 // by calls to these methods by a Babel plugin.
151 //
152 // In PROD (or in packages without access to React internals),
153 // they are left as they are instead.
154
155 function warn(format) {
156 {
157 {
158 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
159 args[_key - 1] = arguments[_key];
160 }
161
162 printWarning('warn', format, args);
163 }
164 }
165 }
166 function error(format) {
167 {
168 {
169 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
170 args[_key2 - 1] = arguments[_key2];
171 }
172
173 printWarning('error', format, args);
174 }
175 }
176 }
177
178 function printWarning(level, format, args) {
179 // When changing this logic, you might want to also
180 // update consoleWithStackDev.www.js as well.
181 {
182 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
183 var stack = ReactDebugCurrentFrame.getStackAddendum();
184
185 if (stack !== '') {
186 format += '%s';
187 args = args.concat([stack]);
188 } // eslint-disable-next-line react-internal/safe-string-coercion
189
190
191 var argsWithFormat = args.map(function (item) {
192 return String(item);
193 }); // Careful: RN currently depends on this prefix
194
195 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
196 // breaks IE9: https://github.com/facebook/react/issues/13610
197 // eslint-disable-next-line react-internal/no-production-logging
198
199 Function.prototype.apply.call(console[level], console, argsWithFormat);
200 }
201 }
202
203 var didWarnStateUpdateForUnmountedComponent = {};
204
205 function warnNoop(publicInstance, callerName) {
206 {
207 var _constructor = publicInstance.constructor;
208 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
209 var warningKey = componentName + "." + callerName;
210
211 if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
212 return;
213 }
214
215 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);
216
217 didWarnStateUpdateForUnmountedComponent[warningKey] = true;
218 }
219 }
220 /**
221 * This is the abstract API for an update queue.
222 */
223
224
225 var ReactNoopUpdateQueue = {
226 /**
227 * Checks whether or not this composite component is mounted.
228 * @param {ReactClass} publicInstance The instance we want to test.
229 * @return {boolean} True if mounted, false otherwise.
230 * @protected
231 * @final
232 */
233 isMounted: function (publicInstance) {
234 return false;
235 },
236
237 /**
238 * Forces an update. This should only be invoked when it is known with
239 * certainty that we are **not** in a DOM transaction.
240 *
241 * You may want to call this when you know that some deeper aspect of the
242 * component's state has changed but `setState` was not called.
243 *
244 * This will not invoke `shouldComponentUpdate`, but it will invoke
245 * `componentWillUpdate` and `componentDidUpdate`.
246 *
247 * @param {ReactClass} publicInstance The instance that should rerender.
248 * @param {?function} callback Called after component is updated.
249 * @param {?string} callerName name of the calling function in the public API.
250 * @internal
251 */
252 enqueueForceUpdate: function (publicInstance, callback, callerName) {
253 warnNoop(publicInstance, 'forceUpdate');
254 },
255
256 /**
257 * Replaces all of the state. Always use this or `setState` to mutate state.
258 * You should treat `this.state` as immutable.
259 *
260 * There is no guarantee that `this.state` will be immediately updated, so
261 * accessing `this.state` after calling this method may return the old value.
262 *
263 * @param {ReactClass} publicInstance The instance that should rerender.
264 * @param {object} completeState Next state.
265 * @param {?function} callback Called after component is updated.
266 * @param {?string} callerName name of the calling function in the public API.
267 * @internal
268 */
269 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
270 warnNoop(publicInstance, 'replaceState');
271 },
272
273 /**
274 * Sets a subset of the state. This only exists because _pendingState is
275 * internal. This provides a merging strategy that is not available to deep
276 * properties which is confusing. TODO: Expose pendingState or don't use it
277 * during the merge.
278 *
279 * @param {ReactClass} publicInstance The instance that should rerender.
280 * @param {object} partialState Next partial state to be merged with state.
281 * @param {?function} callback Called after component is updated.
282 * @param {?string} Name of the calling function in the public API.
283 * @internal
284 */
285 enqueueSetState: function (publicInstance, partialState, callback, callerName) {
286 warnNoop(publicInstance, 'setState');
287 }
288 };
289
290 var assign = Object.assign;
291
292 var emptyObject = {};
293
294 {
295 Object.freeze(emptyObject);
296 }
297 /**
298 * Base class helpers for the updating state of a component.
299 */
300
301
302 function Component(props, context, updater) {
303 this.props = props;
304 this.context = context; // If a component has string refs, we will assign a different object later.
305
306 this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
307 // renderer.
308
309 this.updater = updater || ReactNoopUpdateQueue;
310 }
311
312 Component.prototype.isReactComponent = {};
313 /**
314 * Sets a subset of the state. Always use this to mutate
315 * state. You should treat `this.state` as immutable.
316 *
317 * There is no guarantee that `this.state` will be immediately updated, so
318 * accessing `this.state` after calling this method may return the old value.
319 *
320 * There is no guarantee that calls to `setState` will run synchronously,
321 * as they may eventually be batched together. You can provide an optional
322 * callback that will be executed when the call to setState is actually
323 * completed.
324 *
325 * When a function is provided to setState, it will be called at some point in
326 * the future (not synchronously). It will be called with the up to date
327 * component arguments (state, props, context). These values can be different
328 * from this.* because your function may be called after receiveProps but before
329 * shouldComponentUpdate, and this new state, props, and context will not yet be
330 * assigned to this.
331 *
332 * @param {object|function} partialState Next partial state or function to
333 * produce next partial state to be merged with current state.
334 * @param {?function} callback Called after state is updated.
335 * @final
336 * @protected
337 */
338
339 Component.prototype.setState = function (partialState, callback) {
340 if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) {
341 throw new Error('setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.');
342 }
343
344 this.updater.enqueueSetState(this, partialState, callback, 'setState');
345 };
346 /**
347 * Forces an update. This should only be invoked when it is known with
348 * certainty that we are **not** in a DOM transaction.
349 *
350 * You may want to call this when you know that some deeper aspect of the
351 * component's state has changed but `setState` was not called.
352 *
353 * This will not invoke `shouldComponentUpdate`, but it will invoke
354 * `componentWillUpdate` and `componentDidUpdate`.
355 *
356 * @param {?function} callback Called after update is complete.
357 * @final
358 * @protected
359 */
360
361
362 Component.prototype.forceUpdate = function (callback) {
363 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
364 };
365 /**
366 * Deprecated APIs. These APIs used to exist on classic React classes but since
367 * we would like to deprecate them, we're not going to move them over to this
368 * modern base class. Instead, we define a getter that warns if it's accessed.
369 */
370
371
372 {
373 var deprecatedAPIs = {
374 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
375 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
376 };
377
378 var defineDeprecationWarning = function (methodName, info) {
379 Object.defineProperty(Component.prototype, methodName, {
380 get: function () {
381 warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
382
383 return undefined;
384 }
385 });
386 };
387
388 for (var fnName in deprecatedAPIs) {
389 if (deprecatedAPIs.hasOwnProperty(fnName)) {
390 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
391 }
392 }
393 }
394
395 function ComponentDummy() {}
396
397 ComponentDummy.prototype = Component.prototype;
398 /**
399 * Convenience component with default shallow equality check for sCU.
400 */
401
402 function PureComponent(props, context, updater) {
403 this.props = props;
404 this.context = context; // If a component has string refs, we will assign a different object later.
405
406 this.refs = emptyObject;
407 this.updater = updater || ReactNoopUpdateQueue;
408 }
409
410 var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
411 pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
412
413 assign(pureComponentPrototype, Component.prototype);
414 pureComponentPrototype.isPureReactComponent = true;
415
416 // an immutable object with a single mutable value
417 function createRef() {
418 var refObject = {
419 current: null
420 };
421
422 {
423 Object.seal(refObject);
424 }
425
426 return refObject;
427 }
428
429 var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
430
431 function isArray(a) {
432 return isArrayImpl(a);
433 }
434
435 /*
436 * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
437 * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
438 *
439 * The functions in this module will throw an easier-to-understand,
440 * easier-to-debug exception with a clear errors message message explaining the
441 * problem. (Instead of a confusing exception thrown inside the implementation
442 * of the `value` object).
443 */
444 // $FlowFixMe only called in DEV, so void return is not possible.
445 function typeName(value) {
446 {
447 // toStringTag is needed for namespaced types like Temporal.Instant
448 var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
449 var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
450 return type;
451 }
452 } // $FlowFixMe only called in DEV, so void return is not possible.
453
454
455 function willCoercionThrow(value) {
456 {
457 try {
458 testStringCoercion(value);
459 return false;
460 } catch (e) {
461 return true;
462 }
463 }
464 }
465
466 function testStringCoercion(value) {
467 // If you ended up here by following an exception call stack, here's what's
468 // happened: you supplied an object or symbol value to React (as a prop, key,
469 // DOM attribute, CSS property, string ref, etc.) and when React tried to
470 // coerce it to a string using `'' + value`, an exception was thrown.
471 //
472 // The most common types that will cause this exception are `Symbol` instances
473 // and Temporal objects like `Temporal.Instant`. But any object that has a
474 // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
475 // exception. (Library authors do this to prevent users from using built-in
476 // numeric operators like `+` or comparison operators like `>=` because custom
477 // methods are needed to perform accurate arithmetic or comparison.)
478 //
479 // To fix the problem, coerce this object or symbol value to a string before
480 // passing it to React. The most reliable way is usually `String(value)`.
481 //
482 // To find which value is throwing, check the browser or debugger console.
483 // Before this exception was thrown, there should be `console.error` output
484 // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
485 // problem and how that type was used: key, atrribute, input value prop, etc.
486 // In most cases, this console output also shows the component and its
487 // ancestor components where the exception happened.
488 //
489 // eslint-disable-next-line react-internal/safe-string-coercion
490 return '' + value;
491 }
492 function checkKeyStringCoercion(value) {
493 {
494 if (willCoercionThrow(value)) {
495 error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
496
497 return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
498 }
499 }
500 }
501
502 function getWrappedName(outerType, innerType, wrapperName) {
503 var displayName = outerType.displayName;
504
505 if (displayName) {
506 return displayName;
507 }
508
509 var functionName = innerType.displayName || innerType.name || '';
510 return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
511 } // Keep in sync with react-reconciler/getComponentNameFromFiber
512
513
514 function getContextName(type) {
515 return type.displayName || 'Context';
516 } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
517
518
519 function getComponentNameFromType(type) {
520 if (type == null) {
521 // Host root, text node or just invalid type.
522 return null;
523 }
524
525 {
526 if (typeof type.tag === 'number') {
527 error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
528 }
529 }
530
531 if (typeof type === 'function') {
532 return type.displayName || type.name || null;
533 }
534
535 if (typeof type === 'string') {
536 return type;
537 }
538
539 switch (type) {
540 case REACT_FRAGMENT_TYPE:
541 return 'Fragment';
542
543 case REACT_PORTAL_TYPE:
544 return 'Portal';
545
546 case REACT_PROFILER_TYPE:
547 return 'Profiler';
548
549 case REACT_STRICT_MODE_TYPE:
550 return 'StrictMode';
551
552 case REACT_SUSPENSE_TYPE:
553 return 'Suspense';
554
555 case REACT_SUSPENSE_LIST_TYPE:
556 return 'SuspenseList';
557
558 }
559
560 if (typeof type === 'object') {
561 switch (type.$$typeof) {
562 case REACT_CONTEXT_TYPE:
563 var context = type;
564 return getContextName(context) + '.Consumer';
565
566 case REACT_PROVIDER_TYPE:
567 var provider = type;
568 return getContextName(provider._context) + '.Provider';
569
570 case REACT_FORWARD_REF_TYPE:
571 return getWrappedName(type, type.render, 'ForwardRef');
572
573 case REACT_MEMO_TYPE:
574 var outerName = type.displayName || null;
575
576 if (outerName !== null) {
577 return outerName;
578 }
579
580 return getComponentNameFromType(type.type) || 'Memo';
581
582 case REACT_LAZY_TYPE:
583 {
584 var lazyComponent = type;
585 var payload = lazyComponent._payload;
586 var init = lazyComponent._init;
587
588 try {
589 return getComponentNameFromType(init(payload));
590 } catch (x) {
591 return null;
592 }
593 }
594
595 // eslint-disable-next-line no-fallthrough
596 }
597 }
598
599 return null;
600 }
601
602 var hasOwnProperty = Object.prototype.hasOwnProperty;
603
604 var RESERVED_PROPS = {
605 key: true,
606 ref: true,
607 __self: true,
608 __source: true
609 };
610 var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
611
612 {
613 didWarnAboutStringRefs = {};
614 }
615
616 function hasValidRef(config) {
617 {
618 if (hasOwnProperty.call(config, 'ref')) {
619 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
620
621 if (getter && getter.isReactWarning) {
622 return false;
623 }
624 }
625 }
626
627 return config.ref !== undefined;
628 }
629
630 function hasValidKey(config) {
631 {
632 if (hasOwnProperty.call(config, 'key')) {
633 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
634
635 if (getter && getter.isReactWarning) {
636 return false;
637 }
638 }
639 }
640
641 return config.key !== undefined;
642 }
643
644 function defineKeyPropWarningGetter(props, displayName) {
645 var warnAboutAccessingKey = function () {
646 {
647 if (!specialPropKeyWarningShown) {
648 specialPropKeyWarningShown = true;
649
650 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);
651 }
652 }
653 };
654
655 warnAboutAccessingKey.isReactWarning = true;
656 Object.defineProperty(props, 'key', {
657 get: warnAboutAccessingKey,
658 configurable: true
659 });
660 }
661
662 function defineRefPropWarningGetter(props, displayName) {
663 var warnAboutAccessingRef = function () {
664 {
665 if (!specialPropRefWarningShown) {
666 specialPropRefWarningShown = true;
667
668 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);
669 }
670 }
671 };
672
673 warnAboutAccessingRef.isReactWarning = true;
674 Object.defineProperty(props, 'ref', {
675 get: warnAboutAccessingRef,
676 configurable: true
677 });
678 }
679
680 function warnIfStringRefCannotBeAutoConverted(config) {
681 {
682 if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
683 var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
684
685 if (!didWarnAboutStringRefs[componentName]) {
686 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);
687
688 didWarnAboutStringRefs[componentName] = true;
689 }
690 }
691 }
692 }
693 /**
694 * Factory method to create a new React element. This no longer adheres to
695 * the class pattern, so do not use new to call it. Also, instanceof check
696 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
697 * if something is a React Element.
698 *
699 * @param {*} type
700 * @param {*} props
701 * @param {*} key
702 * @param {string|object} ref
703 * @param {*} owner
704 * @param {*} self A *temporary* helper to detect places where `this` is
705 * different from the `owner` when React.createElement is called, so that we
706 * can warn. We want to get rid of owner and replace string `ref`s with arrow
707 * functions, and as long as `this` and owner are the same, there will be no
708 * change in behavior.
709 * @param {*} source An annotation object (added by a transpiler or otherwise)
710 * indicating filename, line number, and/or other information.
711 * @internal
712 */
713
714
715 var ReactElement = function (type, key, ref, self, source, owner, props) {
716 var element = {
717 // This tag allows us to uniquely identify this as a React Element
718 $$typeof: REACT_ELEMENT_TYPE,
719 // Built-in properties that belong on the element
720 type: type,
721 key: key,
722 ref: ref,
723 props: props,
724 // Record the component responsible for creating this element.
725 _owner: owner
726 };
727
728 {
729 // The validation flag is currently mutative. We put it on
730 // an external backing store so that we can freeze the whole object.
731 // This can be replaced with a WeakMap once they are implemented in
732 // commonly used development environments.
733 element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
734 // the validation flag non-enumerable (where possible, which should
735 // include every environment we run tests in), so the test framework
736 // ignores it.
737
738 Object.defineProperty(element._store, 'validated', {
739 configurable: false,
740 enumerable: false,
741 writable: true,
742 value: false
743 }); // self and source are DEV only properties.
744
745 Object.defineProperty(element, '_self', {
746 configurable: false,
747 enumerable: false,
748 writable: false,
749 value: self
750 }); // Two elements created in two different places should be considered
751 // equal for testing purposes and therefore we hide it from enumeration.
752
753 Object.defineProperty(element, '_source', {
754 configurable: false,
755 enumerable: false,
756 writable: false,
757 value: source
758 });
759
760 if (Object.freeze) {
761 Object.freeze(element.props);
762 Object.freeze(element);
763 }
764 }
765
766 return element;
767 };
768 /**
769 * Create and return a new ReactElement of the given type.
770 * See https://reactjs.org/docs/react-api.html#createelement
771 */
772
773 function createElement(type, config, children) {
774 var propName; // Reserved names are extracted
775
776 var props = {};
777 var key = null;
778 var ref = null;
779 var self = null;
780 var source = null;
781
782 if (config != null) {
783 if (hasValidRef(config)) {
784 ref = config.ref;
785
786 {
787 warnIfStringRefCannotBeAutoConverted(config);
788 }
789 }
790
791 if (hasValidKey(config)) {
792 {
793 checkKeyStringCoercion(config.key);
794 }
795
796 key = '' + config.key;
797 }
798
799 self = config.__self === undefined ? null : config.__self;
800 source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
801
802 for (propName in config) {
803 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
804 props[propName] = config[propName];
805 }
806 }
807 } // Children can be more than one argument, and those are transferred onto
808 // the newly allocated props object.
809
810
811 var childrenLength = arguments.length - 2;
812
813 if (childrenLength === 1) {
814 props.children = children;
815 } else if (childrenLength > 1) {
816 var childArray = Array(childrenLength);
817
818 for (var i = 0; i < childrenLength; i++) {
819 childArray[i] = arguments[i + 2];
820 }
821
822 {
823 if (Object.freeze) {
824 Object.freeze(childArray);
825 }
826 }
827
828 props.children = childArray;
829 } // Resolve default props
830
831
832 if (type && type.defaultProps) {
833 var defaultProps = type.defaultProps;
834
835 for (propName in defaultProps) {
836 if (props[propName] === undefined) {
837 props[propName] = defaultProps[propName];
838 }
839 }
840 }
841
842 {
843 if (key || ref) {
844 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
845
846 if (key) {
847 defineKeyPropWarningGetter(props, displayName);
848 }
849
850 if (ref) {
851 defineRefPropWarningGetter(props, displayName);
852 }
853 }
854 }
855
856 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
857 }
858 function cloneAndReplaceKey(oldElement, newKey) {
859 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
860 return newElement;
861 }
862 /**
863 * Clone and return a new ReactElement using element as the starting point.
864 * See https://reactjs.org/docs/react-api.html#cloneelement
865 */
866
867 function cloneElement(element, config, children) {
868 if (element === null || element === undefined) {
869 throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
870 }
871
872 var propName; // Original props are copied
873
874 var props = assign({}, element.props); // Reserved names are extracted
875
876 var key = element.key;
877 var ref = element.ref; // Self is preserved since the owner is preserved.
878
879 var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
880 // transpiler, and the original source is probably a better indicator of the
881 // true owner.
882
883 var source = element._source; // Owner will be preserved, unless ref is overridden
884
885 var owner = element._owner;
886
887 if (config != null) {
888 if (hasValidRef(config)) {
889 // Silently steal the ref from the parent.
890 ref = config.ref;
891 owner = ReactCurrentOwner.current;
892 }
893
894 if (hasValidKey(config)) {
895 {
896 checkKeyStringCoercion(config.key);
897 }
898
899 key = '' + config.key;
900 } // Remaining properties override existing props
901
902
903 var defaultProps;
904
905 if (element.type && element.type.defaultProps) {
906 defaultProps = element.type.defaultProps;
907 }
908
909 for (propName in config) {
910 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
911 if (config[propName] === undefined && defaultProps !== undefined) {
912 // Resolve default props
913 props[propName] = defaultProps[propName];
914 } else {
915 props[propName] = config[propName];
916 }
917 }
918 }
919 } // Children can be more than one argument, and those are transferred onto
920 // the newly allocated props object.
921
922
923 var childrenLength = arguments.length - 2;
924
925 if (childrenLength === 1) {
926 props.children = children;
927 } else if (childrenLength > 1) {
928 var childArray = Array(childrenLength);
929
930 for (var i = 0; i < childrenLength; i++) {
931 childArray[i] = arguments[i + 2];
932 }
933
934 props.children = childArray;
935 }
936
937 return ReactElement(element.type, key, ref, self, source, owner, props);
938 }
939 /**
940 * Verifies the object is a ReactElement.
941 * See https://reactjs.org/docs/react-api.html#isvalidelement
942 * @param {?object} object
943 * @return {boolean} True if `object` is a ReactElement.
944 * @final
945 */
946
947 function isValidElement(object) {
948 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
949 }
950
951 var SEPARATOR = '.';
952 var SUBSEPARATOR = ':';
953 /**
954 * Escape and wrap key so it is safe to use as a reactid
955 *
956 * @param {string} key to be escaped.
957 * @return {string} the escaped key.
958 */
959
960 function escape(key) {
961 var escapeRegex = /[=:]/g;
962 var escaperLookup = {
963 '=': '=0',
964 ':': '=2'
965 };
966 var escapedString = key.replace(escapeRegex, function (match) {
967 return escaperLookup[match];
968 });
969 return '$' + escapedString;
970 }
971 /**
972 * TODO: Test that a single child and an array with one item have the same key
973 * pattern.
974 */
975
976
977 var didWarnAboutMaps = false;
978 var userProvidedKeyEscapeRegex = /\/+/g;
979
980 function escapeUserProvidedKey(text) {
981 return text.replace(userProvidedKeyEscapeRegex, '$&/');
982 }
983 /**
984 * Generate a key string that identifies a element within a set.
985 *
986 * @param {*} element A element that could contain a manual key.
987 * @param {number} index Index that is used if a manual key is not provided.
988 * @return {string}
989 */
990
991
992 function getElementKey(element, index) {
993 // Do some typechecking here since we call this blindly. We want to ensure
994 // that we don't block potential future ES APIs.
995 if (typeof element === 'object' && element !== null && element.key != null) {
996 // Explicit key
997 {
998 checkKeyStringCoercion(element.key);
999 }
1000
1001 return escape('' + element.key);
1002 } // Implicit key determined by the index in the set
1003
1004
1005 return index.toString(36);
1006 }
1007
1008 function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
1009 var type = typeof children;
1010
1011 if (type === 'undefined' || type === 'boolean') {
1012 // All of the above are perceived as null.
1013 children = null;
1014 }
1015
1016 var invokeCallback = false;
1017
1018 if (children === null) {
1019 invokeCallback = true;
1020 } else {
1021 switch (type) {
1022 case 'string':
1023 case 'number':
1024 invokeCallback = true;
1025 break;
1026
1027 case 'object':
1028 switch (children.$$typeof) {
1029 case REACT_ELEMENT_TYPE:
1030 case REACT_PORTAL_TYPE:
1031 invokeCallback = true;
1032 }
1033
1034 }
1035 }
1036
1037 if (invokeCallback) {
1038 var _child = children;
1039 var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array
1040 // so that it's consistent if the number of children grows:
1041
1042 var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
1043
1044 if (isArray(mappedChild)) {
1045 var escapedChildKey = '';
1046
1047 if (childKey != null) {
1048 escapedChildKey = escapeUserProvidedKey(childKey) + '/';
1049 }
1050
1051 mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {
1052 return c;
1053 });
1054 } else if (mappedChild != null) {
1055 if (isValidElement(mappedChild)) {
1056 {
1057 // The `if` statement here prevents auto-disabling of the safe
1058 // coercion ESLint rule, so we must manually disable it below.
1059 // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1060 if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
1061 checkKeyStringCoercion(mappedChild.key);
1062 }
1063 }
1064
1065 mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
1066 // traverseAllChildren used to do for objects as children
1067 escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1068 mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number
1069 // eslint-disable-next-line react-internal/safe-string-coercion
1070 escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);
1071 }
1072
1073 array.push(mappedChild);
1074 }
1075
1076 return 1;
1077 }
1078
1079 var child;
1080 var nextName;
1081 var subtreeCount = 0; // Count of children found in the current subtree.
1082
1083 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1084
1085 if (isArray(children)) {
1086 for (var i = 0; i < children.length; i++) {
1087 child = children[i];
1088 nextName = nextNamePrefix + getElementKey(child, i);
1089 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
1090 }
1091 } else {
1092 var iteratorFn = getIteratorFn(children);
1093
1094 if (typeof iteratorFn === 'function') {
1095 var iterableChildren = children;
1096
1097 {
1098 // Warn about using Maps as children
1099 if (iteratorFn === iterableChildren.entries) {
1100 if (!didWarnAboutMaps) {
1101 warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
1102 }
1103
1104 didWarnAboutMaps = true;
1105 }
1106 }
1107
1108 var iterator = iteratorFn.call(iterableChildren);
1109 var step;
1110 var ii = 0;
1111
1112 while (!(step = iterator.next()).done) {
1113 child = step.value;
1114 nextName = nextNamePrefix + getElementKey(child, ii++);
1115 subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
1116 }
1117 } else if (type === 'object') {
1118 // eslint-disable-next-line react-internal/safe-string-coercion
1119 var childrenString = String(children);
1120 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.');
1121 }
1122 }
1123
1124 return subtreeCount;
1125 }
1126
1127 /**
1128 * Maps children that are typically specified as `props.children`.
1129 *
1130 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
1131 *
1132 * The provided mapFunction(child, index) will be called for each
1133 * leaf child.
1134 *
1135 * @param {?*} children Children tree container.
1136 * @param {function(*, int)} func The map function.
1137 * @param {*} context Context for mapFunction.
1138 * @return {object} Object containing the ordered map of results.
1139 */
1140 function mapChildren(children, func, context) {
1141 if (children == null) {
1142 return children;
1143 }
1144
1145 var result = [];
1146 var count = 0;
1147 mapIntoArray(children, result, '', '', function (child) {
1148 return func.call(context, child, count++);
1149 });
1150 return result;
1151 }
1152 /**
1153 * Count the number of children that are typically specified as
1154 * `props.children`.
1155 *
1156 * See https://reactjs.org/docs/react-api.html#reactchildrencount
1157 *
1158 * @param {?*} children Children tree container.
1159 * @return {number} The number of children.
1160 */
1161
1162
1163 function countChildren(children) {
1164 var n = 0;
1165 mapChildren(children, function () {
1166 n++; // Don't return anything
1167 });
1168 return n;
1169 }
1170
1171 /**
1172 * Iterates through children that are typically specified as `props.children`.
1173 *
1174 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
1175 *
1176 * The provided forEachFunc(child, index) will be called for each
1177 * leaf child.
1178 *
1179 * @param {?*} children Children tree container.
1180 * @param {function(*, int)} forEachFunc
1181 * @param {*} forEachContext Context for forEachContext.
1182 */
1183 function forEachChildren(children, forEachFunc, forEachContext) {
1184 mapChildren(children, function () {
1185 forEachFunc.apply(this, arguments); // Don't return anything.
1186 }, forEachContext);
1187 }
1188 /**
1189 * Flatten a children object (typically specified as `props.children`) and
1190 * return an array with appropriately re-keyed children.
1191 *
1192 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
1193 */
1194
1195
1196 function toArray(children) {
1197 return mapChildren(children, function (child) {
1198 return child;
1199 }) || [];
1200 }
1201 /**
1202 * Returns the first child in a collection of children and verifies that there
1203 * is only one child in the collection.
1204 *
1205 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
1206 *
1207 * The current implementation of this function assumes that a single child gets
1208 * passed without a wrapper, but the purpose of this helper function is to
1209 * abstract away the particular structure of children.
1210 *
1211 * @param {?object} children Child collection structure.
1212 * @return {ReactElement} The first and only `ReactElement` contained in the
1213 * structure.
1214 */
1215
1216
1217 function onlyChild(children) {
1218 if (!isValidElement(children)) {
1219 throw new Error('React.Children.only expected to receive a single React element child.');
1220 }
1221
1222 return children;
1223 }
1224
1225 function createContext(defaultValue) {
1226 // TODO: Second argument used to be an optional `calculateChangedBits`
1227 // function. Warn to reserve for future use?
1228 var context = {
1229 $$typeof: REACT_CONTEXT_TYPE,
1230 // As a workaround to support multiple concurrent renderers, we categorize
1231 // some renderers as primary and others as secondary. We only expect
1232 // there to be two concurrent renderers at most: React Native (primary) and
1233 // Fabric (secondary); React DOM (primary) and React ART (secondary).
1234 // Secondary renderers store their context values on separate fields.
1235 _currentValue: defaultValue,
1236 _currentValue2: defaultValue,
1237 // Used to track how many concurrent renderers this context currently
1238 // supports within in a single renderer. Such as parallel server rendering.
1239 _threadCount: 0,
1240 // These are circular
1241 Provider: null,
1242 Consumer: null,
1243 // Add these to use same hidden class in VM as ServerContext
1244 _defaultValue: null,
1245 _globalName: null
1246 };
1247 context.Provider = {
1248 $$typeof: REACT_PROVIDER_TYPE,
1249 _context: context
1250 };
1251 var hasWarnedAboutUsingNestedContextConsumers = false;
1252 var hasWarnedAboutUsingConsumerProvider = false;
1253 var hasWarnedAboutDisplayNameOnConsumer = false;
1254
1255 {
1256 // A separate object, but proxies back to the original context object for
1257 // backwards compatibility. It has a different $$typeof, so we can properly
1258 // warn for the incorrect usage of Context as a Consumer.
1259 var Consumer = {
1260 $$typeof: REACT_CONTEXT_TYPE,
1261 _context: context
1262 }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
1263
1264 Object.defineProperties(Consumer, {
1265 Provider: {
1266 get: function () {
1267 if (!hasWarnedAboutUsingConsumerProvider) {
1268 hasWarnedAboutUsingConsumerProvider = true;
1269
1270 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?');
1271 }
1272
1273 return context.Provider;
1274 },
1275 set: function (_Provider) {
1276 context.Provider = _Provider;
1277 }
1278 },
1279 _currentValue: {
1280 get: function () {
1281 return context._currentValue;
1282 },
1283 set: function (_currentValue) {
1284 context._currentValue = _currentValue;
1285 }
1286 },
1287 _currentValue2: {
1288 get: function () {
1289 return context._currentValue2;
1290 },
1291 set: function (_currentValue2) {
1292 context._currentValue2 = _currentValue2;
1293 }
1294 },
1295 _threadCount: {
1296 get: function () {
1297 return context._threadCount;
1298 },
1299 set: function (_threadCount) {
1300 context._threadCount = _threadCount;
1301 }
1302 },
1303 Consumer: {
1304 get: function () {
1305 if (!hasWarnedAboutUsingNestedContextConsumers) {
1306 hasWarnedAboutUsingNestedContextConsumers = true;
1307
1308 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?');
1309 }
1310
1311 return context.Consumer;
1312 }
1313 },
1314 displayName: {
1315 get: function () {
1316 return context.displayName;
1317 },
1318 set: function (displayName) {
1319 if (!hasWarnedAboutDisplayNameOnConsumer) {
1320 warn('Setting `displayName` on Context.Consumer has no effect. ' + "You should set it directly on the context with Context.displayName = '%s'.", displayName);
1321
1322 hasWarnedAboutDisplayNameOnConsumer = true;
1323 }
1324 }
1325 }
1326 }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
1327
1328 context.Consumer = Consumer;
1329 }
1330
1331 {
1332 context._currentRenderer = null;
1333 context._currentRenderer2 = null;
1334 }
1335
1336 return context;
1337 }
1338
1339 var Uninitialized = -1;
1340 var Pending = 0;
1341 var Resolved = 1;
1342 var Rejected = 2;
1343
1344 function lazyInitializer(payload) {
1345 if (payload._status === Uninitialized) {
1346 var ctor = payload._result;
1347 var thenable = ctor(); // Transition to the next state.
1348 // This might throw either because it's missing or throws. If so, we treat it
1349 // as still uninitialized and try again next time. Which is the same as what
1350 // happens if the ctor or any wrappers processing the ctor throws. This might
1351 // end up fixing it if the resolution was a concurrency bug.
1352
1353 thenable.then(function (moduleObject) {
1354 if (payload._status === Pending || payload._status === Uninitialized) {
1355 // Transition to the next state.
1356 var resolved = payload;
1357 resolved._status = Resolved;
1358 resolved._result = moduleObject;
1359 }
1360 }, function (error) {
1361 if (payload._status === Pending || payload._status === Uninitialized) {
1362 // Transition to the next state.
1363 var rejected = payload;
1364 rejected._status = Rejected;
1365 rejected._result = error;
1366 }
1367 });
1368
1369 if (payload._status === Uninitialized) {
1370 // In case, we're still uninitialized, then we're waiting for the thenable
1371 // to resolve. Set it as pending in the meantime.
1372 var pending = payload;
1373 pending._status = Pending;
1374 pending._result = thenable;
1375 }
1376 }
1377
1378 if (payload._status === Resolved) {
1379 var moduleObject = payload._result;
1380
1381 {
1382 if (moduleObject === undefined) {
1383 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.
1384 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))\n\n" + 'Did you accidentally put curly braces around the import?', moduleObject);
1385 }
1386 }
1387
1388 {
1389 if (!('default' in moduleObject)) {
1390 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.
1391 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
1392 }
1393 }
1394
1395 return moduleObject.default;
1396 } else {
1397 throw payload._result;
1398 }
1399 }
1400
1401 function lazy(ctor) {
1402 var payload = {
1403 // We use these fields to store the result.
1404 _status: Uninitialized,
1405 _result: ctor
1406 };
1407 var lazyType = {
1408 $$typeof: REACT_LAZY_TYPE,
1409 _payload: payload,
1410 _init: lazyInitializer
1411 };
1412
1413 {
1414 // In production, this would just set it on the object.
1415 var defaultProps;
1416 var propTypes; // $FlowFixMe
1417
1418 Object.defineProperties(lazyType, {
1419 defaultProps: {
1420 configurable: true,
1421 get: function () {
1422 return defaultProps;
1423 },
1424 set: function (newDefaultProps) {
1425 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.');
1426
1427 defaultProps = newDefaultProps; // Match production behavior more closely:
1428 // $FlowFixMe
1429
1430 Object.defineProperty(lazyType, 'defaultProps', {
1431 enumerable: true
1432 });
1433 }
1434 },
1435 propTypes: {
1436 configurable: true,
1437 get: function () {
1438 return propTypes;
1439 },
1440 set: function (newPropTypes) {
1441 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.');
1442
1443 propTypes = newPropTypes; // Match production behavior more closely:
1444 // $FlowFixMe
1445
1446 Object.defineProperty(lazyType, 'propTypes', {
1447 enumerable: true
1448 });
1449 }
1450 }
1451 });
1452 }
1453
1454 return lazyType;
1455 }
1456
1457 function forwardRef(render) {
1458 {
1459 if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
1460 error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
1461 } else if (typeof render !== 'function') {
1462 error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
1463 } else {
1464 if (render.length !== 0 && render.length !== 2) {
1465 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.');
1466 }
1467 }
1468
1469 if (render != null) {
1470 if (render.defaultProps != null || render.propTypes != null) {
1471 error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');
1472 }
1473 }
1474 }
1475
1476 var elementType = {
1477 $$typeof: REACT_FORWARD_REF_TYPE,
1478 render: render
1479 };
1480
1481 {
1482 var ownName;
1483 Object.defineProperty(elementType, 'displayName', {
1484 enumerable: false,
1485 configurable: true,
1486 get: function () {
1487 return ownName;
1488 },
1489 set: function (name) {
1490 ownName = name; // The inner component shouldn't inherit this display name in most cases,
1491 // because the component may be used elsewhere.
1492 // But it's nice for anonymous functions to inherit the name,
1493 // so that our component-stack generation logic will display their frames.
1494 // An anonymous function generally suggests a pattern like:
1495 // React.forwardRef((props, ref) => {...});
1496 // This kind of inner function is not used elsewhere so the side effect is okay.
1497
1498 if (!render.name && !render.displayName) {
1499 render.displayName = name;
1500 }
1501 }
1502 });
1503 }
1504
1505 return elementType;
1506 }
1507
1508 var REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
1509 function isValidElementType(type) {
1510 if (typeof type === 'string' || typeof type === 'function') {
1511 return true;
1512 } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
1513
1514
1515 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 ) {
1516 return true;
1517 }
1518
1519 if (typeof type === 'object' && type !== null) {
1520 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
1521 // types supported by any Flight configuration anywhere since
1522 // we don't know which Flight build this will end up being used
1523 // with.
1524 type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
1525 return true;
1526 }
1527 }
1528
1529 return false;
1530 }
1531
1532 function memo(type, compare) {
1533 {
1534 if (!isValidElementType(type)) {
1535 error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
1536 }
1537 }
1538
1539 var elementType = {
1540 $$typeof: REACT_MEMO_TYPE,
1541 type: type,
1542 compare: compare === undefined ? null : compare
1543 };
1544
1545 {
1546 var ownName;
1547 Object.defineProperty(elementType, 'displayName', {
1548 enumerable: false,
1549 configurable: true,
1550 get: function () {
1551 return ownName;
1552 },
1553 set: function (name) {
1554 ownName = name; // The inner component shouldn't inherit this display name in most cases,
1555 // because the component may be used elsewhere.
1556 // But it's nice for anonymous functions to inherit the name,
1557 // so that our component-stack generation logic will display their frames.
1558 // An anonymous function generally suggests a pattern like:
1559 // React.memo((props) => {...});
1560 // This kind of inner function is not used elsewhere so the side effect is okay.
1561
1562 if (!type.name && !type.displayName) {
1563 type.displayName = name;
1564 }
1565 }
1566 });
1567 }
1568
1569 return elementType;
1570 }
1571
1572 function resolveDispatcher() {
1573 var dispatcher = ReactCurrentDispatcher.current;
1574
1575 {
1576 if (dispatcher === null) {
1577 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.');
1578 }
1579 } // Will result in a null access error if accessed outside render phase. We
1580 // intentionally don't throw our own error because this is in a hot path.
1581 // Also helps ensure this is inlined.
1582
1583
1584 return dispatcher;
1585 }
1586 function useContext(Context) {
1587 var dispatcher = resolveDispatcher();
1588
1589 {
1590 // TODO: add a more generic warning for invalid values.
1591 if (Context._context !== undefined) {
1592 var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
1593 // and nobody should be using this in existing code.
1594
1595 if (realContext.Consumer === Context) {
1596 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?');
1597 } else if (realContext.Provider === Context) {
1598 error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
1599 }
1600 }
1601 }
1602
1603 return dispatcher.useContext(Context);
1604 }
1605 function useState(initialState) {
1606 var dispatcher = resolveDispatcher();
1607 return dispatcher.useState(initialState);
1608 }
1609 function useReducer(reducer, initialArg, init) {
1610 var dispatcher = resolveDispatcher();
1611 return dispatcher.useReducer(reducer, initialArg, init);
1612 }
1613 function useRef(initialValue) {
1614 var dispatcher = resolveDispatcher();
1615 return dispatcher.useRef(initialValue);
1616 }
1617 function useEffect(create, deps) {
1618 var dispatcher = resolveDispatcher();
1619 return dispatcher.useEffect(create, deps);
1620 }
1621 function useInsertionEffect(create, deps) {
1622 var dispatcher = resolveDispatcher();
1623 return dispatcher.useInsertionEffect(create, deps);
1624 }
1625 function useLayoutEffect(create, deps) {
1626 var dispatcher = resolveDispatcher();
1627 return dispatcher.useLayoutEffect(create, deps);
1628 }
1629 function useCallback(callback, deps) {
1630 var dispatcher = resolveDispatcher();
1631 return dispatcher.useCallback(callback, deps);
1632 }
1633 function useMemo(create, deps) {
1634 var dispatcher = resolveDispatcher();
1635 return dispatcher.useMemo(create, deps);
1636 }
1637 function useImperativeHandle(ref, create, deps) {
1638 var dispatcher = resolveDispatcher();
1639 return dispatcher.useImperativeHandle(ref, create, deps);
1640 }
1641 function useDebugValue(value, formatterFn) {
1642 {
1643 var dispatcher = resolveDispatcher();
1644 return dispatcher.useDebugValue(value, formatterFn);
1645 }
1646 }
1647 function useTransition() {
1648 var dispatcher = resolveDispatcher();
1649 return dispatcher.useTransition();
1650 }
1651 function useDeferredValue(value) {
1652 var dispatcher = resolveDispatcher();
1653 return dispatcher.useDeferredValue(value);
1654 }
1655 function useId() {
1656 var dispatcher = resolveDispatcher();
1657 return dispatcher.useId();
1658 }
1659 function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
1660 var dispatcher = resolveDispatcher();
1661 return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
1662 }
1663
1664 // Helpers to patch console.logs to avoid logging during side-effect free
1665 // replaying on render function. This currently only patches the object
1666 // lazily which won't cover if the log function was extracted eagerly.
1667 // We could also eagerly patch the method.
1668 var disabledDepth = 0;
1669 var prevLog;
1670 var prevInfo;
1671 var prevWarn;
1672 var prevError;
1673 var prevGroup;
1674 var prevGroupCollapsed;
1675 var prevGroupEnd;
1676
1677 function disabledLog() {}
1678
1679 disabledLog.__reactDisabledLog = true;
1680 function disableLogs() {
1681 {
1682 if (disabledDepth === 0) {
1683 /* eslint-disable react-internal/no-production-logging */
1684 prevLog = console.log;
1685 prevInfo = console.info;
1686 prevWarn = console.warn;
1687 prevError = console.error;
1688 prevGroup = console.group;
1689 prevGroupCollapsed = console.groupCollapsed;
1690 prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
1691
1692 var props = {
1693 configurable: true,
1694 enumerable: true,
1695 value: disabledLog,
1696 writable: true
1697 }; // $FlowFixMe Flow thinks console is immutable.
1698
1699 Object.defineProperties(console, {
1700 info: props,
1701 log: props,
1702 warn: props,
1703 error: props,
1704 group: props,
1705 groupCollapsed: props,
1706 groupEnd: props
1707 });
1708 /* eslint-enable react-internal/no-production-logging */
1709 }
1710
1711 disabledDepth++;
1712 }
1713 }
1714 function reenableLogs() {
1715 {
1716 disabledDepth--;
1717
1718 if (disabledDepth === 0) {
1719 /* eslint-disable react-internal/no-production-logging */
1720 var props = {
1721 configurable: true,
1722 enumerable: true,
1723 writable: true
1724 }; // $FlowFixMe Flow thinks console is immutable.
1725
1726 Object.defineProperties(console, {
1727 log: assign({}, props, {
1728 value: prevLog
1729 }),
1730 info: assign({}, props, {
1731 value: prevInfo
1732 }),
1733 warn: assign({}, props, {
1734 value: prevWarn
1735 }),
1736 error: assign({}, props, {
1737 value: prevError
1738 }),
1739 group: assign({}, props, {
1740 value: prevGroup
1741 }),
1742 groupCollapsed: assign({}, props, {
1743 value: prevGroupCollapsed
1744 }),
1745 groupEnd: assign({}, props, {
1746 value: prevGroupEnd
1747 })
1748 });
1749 /* eslint-enable react-internal/no-production-logging */
1750 }
1751
1752 if (disabledDepth < 0) {
1753 error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
1754 }
1755 }
1756 }
1757
1758 var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
1759 var prefix;
1760 function describeBuiltInComponentFrame(name, source, ownerFn) {
1761 {
1762 if (prefix === undefined) {
1763 // Extract the VM specific prefix used by each line.
1764 try {
1765 throw Error();
1766 } catch (x) {
1767 var match = x.stack.trim().match(/\n( *(at )?)/);
1768 prefix = match && match[1] || '';
1769 }
1770 } // We use the prefix to ensure our stacks line up with native stack frames.
1771
1772
1773 return '\n' + prefix + name;
1774 }
1775 }
1776 var reentry = false;
1777 var componentFrameCache;
1778
1779 {
1780 var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
1781 componentFrameCache = new PossiblyWeakMap();
1782 }
1783
1784 function describeNativeComponentFrame(fn, construct) {
1785 // If something asked for a stack inside a fake render, it should get ignored.
1786 if ( !fn || reentry) {
1787 return '';
1788 }
1789
1790 {
1791 var frame = componentFrameCache.get(fn);
1792
1793 if (frame !== undefined) {
1794 return frame;
1795 }
1796 }
1797
1798 var control;
1799 reentry = true;
1800 var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
1801
1802 Error.prepareStackTrace = undefined;
1803 var previousDispatcher;
1804
1805 {
1806 previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function
1807 // for warnings.
1808
1809 ReactCurrentDispatcher$1.current = null;
1810 disableLogs();
1811 }
1812
1813 try {
1814 // This should throw.
1815 if (construct) {
1816 // Something should be setting the props in the constructor.
1817 var Fake = function () {
1818 throw Error();
1819 }; // $FlowFixMe
1820
1821
1822 Object.defineProperty(Fake.prototype, 'props', {
1823 set: function () {
1824 // We use a throwing setter instead of frozen or non-writable props
1825 // because that won't throw in a non-strict mode function.
1826 throw Error();
1827 }
1828 });
1829
1830 if (typeof Reflect === 'object' && Reflect.construct) {
1831 // We construct a different control for this case to include any extra
1832 // frames added by the construct call.
1833 try {
1834 Reflect.construct(Fake, []);
1835 } catch (x) {
1836 control = x;
1837 }
1838
1839 Reflect.construct(fn, [], Fake);
1840 } else {
1841 try {
1842 Fake.call();
1843 } catch (x) {
1844 control = x;
1845 }
1846
1847 fn.call(Fake.prototype);
1848 }
1849 } else {
1850 try {
1851 throw Error();
1852 } catch (x) {
1853 control = x;
1854 }
1855
1856 fn();
1857 }
1858 } catch (sample) {
1859 // This is inlined manually because closure doesn't do it for us.
1860 if (sample && control && typeof sample.stack === 'string') {
1861 // This extracts the first frame from the sample that isn't also in the control.
1862 // Skipping one frame that we assume is the frame that calls the two.
1863 var sampleLines = sample.stack.split('\n');
1864 var controlLines = control.stack.split('\n');
1865 var s = sampleLines.length - 1;
1866 var c = controlLines.length - 1;
1867
1868 while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
1869 // We expect at least one stack frame to be shared.
1870 // Typically this will be the root most one. However, stack frames may be
1871 // cut off due to maximum stack limits. In this case, one maybe cut off
1872 // earlier than the other. We assume that the sample is longer or the same
1873 // and there for cut off earlier. So we should find the root most frame in
1874 // the sample somewhere in the control.
1875 c--;
1876 }
1877
1878 for (; s >= 1 && c >= 0; s--, c--) {
1879 // Next we find the first one that isn't the same which should be the
1880 // frame that called our sample function and the control.
1881 if (sampleLines[s] !== controlLines[c]) {
1882 // In V8, the first line is describing the message but other VMs don't.
1883 // If we're about to return the first line, and the control is also on the same
1884 // line, that's a pretty good indicator that our sample threw at same line as
1885 // the control. I.e. before we entered the sample frame. So we ignore this result.
1886 // This can happen if you passed a class to function component, or non-function.
1887 if (s !== 1 || c !== 1) {
1888 do {
1889 s--;
1890 c--; // We may still have similar intermediate frames from the construct call.
1891 // The next one that isn't the same should be our match though.
1892
1893 if (c < 0 || sampleLines[s] !== controlLines[c]) {
1894 // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
1895 var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
1896 // but we have a user-provided "displayName"
1897 // splice it in to make the stack more readable.
1898
1899
1900 if (fn.displayName && _frame.includes('<anonymous>')) {
1901 _frame = _frame.replace('<anonymous>', fn.displayName);
1902 }
1903
1904 {
1905 if (typeof fn === 'function') {
1906 componentFrameCache.set(fn, _frame);
1907 }
1908 } // Return the line we found.
1909
1910
1911 return _frame;
1912 }
1913 } while (s >= 1 && c >= 0);
1914 }
1915
1916 break;
1917 }
1918 }
1919 }
1920 } finally {
1921 reentry = false;
1922
1923 {
1924 ReactCurrentDispatcher$1.current = previousDispatcher;
1925 reenableLogs();
1926 }
1927
1928 Error.prepareStackTrace = previousPrepareStackTrace;
1929 } // Fallback to just using the name if we couldn't make it throw.
1930
1931
1932 var name = fn ? fn.displayName || fn.name : '';
1933 var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
1934
1935 {
1936 if (typeof fn === 'function') {
1937 componentFrameCache.set(fn, syntheticFrame);
1938 }
1939 }
1940
1941 return syntheticFrame;
1942 }
1943 function describeFunctionComponentFrame(fn, source, ownerFn) {
1944 {
1945 return describeNativeComponentFrame(fn, false);
1946 }
1947 }
1948
1949 function shouldConstruct(Component) {
1950 var prototype = Component.prototype;
1951 return !!(prototype && prototype.isReactComponent);
1952 }
1953
1954 function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
1955
1956 if (type == null) {
1957 return '';
1958 }
1959
1960 if (typeof type === 'function') {
1961 {
1962 return describeNativeComponentFrame(type, shouldConstruct(type));
1963 }
1964 }
1965
1966 if (typeof type === 'string') {
1967 return describeBuiltInComponentFrame(type);
1968 }
1969
1970 switch (type) {
1971 case REACT_SUSPENSE_TYPE:
1972 return describeBuiltInComponentFrame('Suspense');
1973
1974 case REACT_SUSPENSE_LIST_TYPE:
1975 return describeBuiltInComponentFrame('SuspenseList');
1976 }
1977
1978 if (typeof type === 'object') {
1979 switch (type.$$typeof) {
1980 case REACT_FORWARD_REF_TYPE:
1981 return describeFunctionComponentFrame(type.render);
1982
1983 case REACT_MEMO_TYPE:
1984 // Memo may contain any component type so we recursively resolve it.
1985 return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
1986
1987 case REACT_LAZY_TYPE:
1988 {
1989 var lazyComponent = type;
1990 var payload = lazyComponent._payload;
1991 var init = lazyComponent._init;
1992
1993 try {
1994 // Lazy may contain any component type so we recursively resolve it.
1995 return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
1996 } catch (x) {}
1997 }
1998 }
1999 }
2000
2001 return '';
2002 }
2003
2004 var loggedTypeFailures = {};
2005 var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
2006
2007 function setCurrentlyValidatingElement(element) {
2008 {
2009 if (element) {
2010 var owner = element._owner;
2011 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
2012 ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
2013 } else {
2014 ReactDebugCurrentFrame$1.setExtraStackFrame(null);
2015 }
2016 }
2017 }
2018
2019 function checkPropTypes(typeSpecs, values, location, componentName, element) {
2020 {
2021 // $FlowFixMe This is okay but Flow doesn't know it.
2022 var has = Function.call.bind(hasOwnProperty);
2023
2024 for (var typeSpecName in typeSpecs) {
2025 if (has(typeSpecs, typeSpecName)) {
2026 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
2027 // fail the render phase where it didn't fail before. So we log it.
2028 // After these have been cleaned up, we'll let them throw.
2029
2030 try {
2031 // This is intentionally an invariant that gets caught. It's the same
2032 // behavior as without this statement except with a better message.
2033 if (typeof typeSpecs[typeSpecName] !== 'function') {
2034 // eslint-disable-next-line react-internal/prod-error-codes
2035 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`.');
2036 err.name = 'Invariant Violation';
2037 throw err;
2038 }
2039
2040 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
2041 } catch (ex) {
2042 error$1 = ex;
2043 }
2044
2045 if (error$1 && !(error$1 instanceof Error)) {
2046 setCurrentlyValidatingElement(element);
2047
2048 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);
2049
2050 setCurrentlyValidatingElement(null);
2051 }
2052
2053 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
2054 // Only monitor this failure once because there tends to be a lot of the
2055 // same error.
2056 loggedTypeFailures[error$1.message] = true;
2057 setCurrentlyValidatingElement(element);
2058
2059 error('Failed %s type: %s', location, error$1.message);
2060
2061 setCurrentlyValidatingElement(null);
2062 }
2063 }
2064 }
2065 }
2066 }
2067
2068 function setCurrentlyValidatingElement$1(element) {
2069 {
2070 if (element) {
2071 var owner = element._owner;
2072 var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
2073 setExtraStackFrame(stack);
2074 } else {
2075 setExtraStackFrame(null);
2076 }
2077 }
2078 }
2079
2080 var propTypesMisspellWarningShown;
2081
2082 {
2083 propTypesMisspellWarningShown = false;
2084 }
2085
2086 function getDeclarationErrorAddendum() {
2087 if (ReactCurrentOwner.current) {
2088 var name = getComponentNameFromType(ReactCurrentOwner.current.type);
2089
2090 if (name) {
2091 return '\n\nCheck the render method of `' + name + '`.';
2092 }
2093 }
2094
2095 return '';
2096 }
2097
2098 function getSourceInfoErrorAddendum(source) {
2099 if (source !== undefined) {
2100 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
2101 var lineNumber = source.lineNumber;
2102 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
2103 }
2104
2105 return '';
2106 }
2107
2108 function getSourceInfoErrorAddendumForProps(elementProps) {
2109 if (elementProps !== null && elementProps !== undefined) {
2110 return getSourceInfoErrorAddendum(elementProps.__source);
2111 }
2112
2113 return '';
2114 }
2115 /**
2116 * Warn if there's no key explicitly set on dynamic arrays of children or
2117 * object keys are not valid. This allows us to keep track of children between
2118 * updates.
2119 */
2120
2121
2122 var ownerHasKeyUseWarning = {};
2123
2124 function getCurrentComponentErrorInfo(parentType) {
2125 var info = getDeclarationErrorAddendum();
2126
2127 if (!info) {
2128 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
2129
2130 if (parentName) {
2131 info = "\n\nCheck the top-level render call using <" + parentName + ">.";
2132 }
2133 }
2134
2135 return info;
2136 }
2137 /**
2138 * Warn if the element doesn't have an explicit key assigned to it.
2139 * This element is in an array. The array could grow and shrink or be
2140 * reordered. All children that haven't already been validated are required to
2141 * have a "key" property assigned to it. Error statuses are cached so a warning
2142 * will only be shown once.
2143 *
2144 * @internal
2145 * @param {ReactElement} element Element that requires a key.
2146 * @param {*} parentType element's parent's type.
2147 */
2148
2149
2150 function validateExplicitKey(element, parentType) {
2151 if (!element._store || element._store.validated || element.key != null) {
2152 return;
2153 }
2154
2155 element._store.validated = true;
2156 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
2157
2158 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
2159 return;
2160 }
2161
2162 ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
2163 // property, it may be the creator of the child that's responsible for
2164 // assigning it a key.
2165
2166 var childOwner = '';
2167
2168 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2169 // Give the component that originally created this child.
2170 childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
2171 }
2172
2173 {
2174 setCurrentlyValidatingElement$1(element);
2175
2176 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);
2177
2178 setCurrentlyValidatingElement$1(null);
2179 }
2180 }
2181 /**
2182 * Ensure that every element either is passed in a static location, in an
2183 * array with an explicit keys property defined, or in an object literal
2184 * with valid key property.
2185 *
2186 * @internal
2187 * @param {ReactNode} node Statically passed child of any type.
2188 * @param {*} parentType node's parent's type.
2189 */
2190
2191
2192 function validateChildKeys(node, parentType) {
2193 if (typeof node !== 'object') {
2194 return;
2195 }
2196
2197 if (isArray(node)) {
2198 for (var i = 0; i < node.length; i++) {
2199 var child = node[i];
2200
2201 if (isValidElement(child)) {
2202 validateExplicitKey(child, parentType);
2203 }
2204 }
2205 } else if (isValidElement(node)) {
2206 // This element was passed in a valid location.
2207 if (node._store) {
2208 node._store.validated = true;
2209 }
2210 } else if (node) {
2211 var iteratorFn = getIteratorFn(node);
2212
2213 if (typeof iteratorFn === 'function') {
2214 // Entry iterators used to provide implicit keys,
2215 // but now we print a separate warning for them later.
2216 if (iteratorFn !== node.entries) {
2217 var iterator = iteratorFn.call(node);
2218 var step;
2219
2220 while (!(step = iterator.next()).done) {
2221 if (isValidElement(step.value)) {
2222 validateExplicitKey(step.value, parentType);
2223 }
2224 }
2225 }
2226 }
2227 }
2228 }
2229 /**
2230 * Given an element, validate that its props follow the propTypes definition,
2231 * provided by the type.
2232 *
2233 * @param {ReactElement} element
2234 */
2235
2236
2237 function validatePropTypes(element) {
2238 {
2239 var type = element.type;
2240
2241 if (type === null || type === undefined || typeof type === 'string') {
2242 return;
2243 }
2244
2245 var propTypes;
2246
2247 if (typeof type === 'function') {
2248 propTypes = type.propTypes;
2249 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
2250 // Inner props are checked in the reconciler.
2251 type.$$typeof === REACT_MEMO_TYPE)) {
2252 propTypes = type.propTypes;
2253 } else {
2254 return;
2255 }
2256
2257 if (propTypes) {
2258 // Intentionally inside to avoid triggering lazy initializers:
2259 var name = getComponentNameFromType(type);
2260 checkPropTypes(propTypes, element.props, 'prop', name, element);
2261 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2262 propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
2263
2264 var _name = getComponentNameFromType(type);
2265
2266 error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
2267 }
2268
2269 if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
2270 error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
2271 }
2272 }
2273 }
2274 /**
2275 * Given a fragment, validate that it can only be provided with fragment props
2276 * @param {ReactElement} fragment
2277 */
2278
2279
2280 function validateFragmentProps(fragment) {
2281 {
2282 var keys = Object.keys(fragment.props);
2283
2284 for (var i = 0; i < keys.length; i++) {
2285 var key = keys[i];
2286
2287 if (key !== 'children' && key !== 'key') {
2288 setCurrentlyValidatingElement$1(fragment);
2289
2290 error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
2291
2292 setCurrentlyValidatingElement$1(null);
2293 break;
2294 }
2295 }
2296
2297 if (fragment.ref !== null) {
2298 setCurrentlyValidatingElement$1(fragment);
2299
2300 error('Invalid attribute `ref` supplied to `React.Fragment`.');
2301
2302 setCurrentlyValidatingElement$1(null);
2303 }
2304 }
2305 }
2306 function createElementWithValidation(type, props, children) {
2307 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
2308 // succeed and there will likely be errors in render.
2309
2310 if (!validType) {
2311 var info = '';
2312
2313 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
2314 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.";
2315 }
2316
2317 var sourceInfo = getSourceInfoErrorAddendumForProps(props);
2318
2319 if (sourceInfo) {
2320 info += sourceInfo;
2321 } else {
2322 info += getDeclarationErrorAddendum();
2323 }
2324
2325 var typeString;
2326
2327 if (type === null) {
2328 typeString = 'null';
2329 } else if (isArray(type)) {
2330 typeString = 'array';
2331 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
2332 typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
2333 info = ' Did you accidentally export a JSX literal instead of a component?';
2334 } else {
2335 typeString = typeof type;
2336 }
2337
2338 {
2339 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);
2340 }
2341 }
2342
2343 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
2344 // TODO: Drop this when these are no longer allowed as the type argument.
2345
2346 if (element == null) {
2347 return element;
2348 } // Skip key warning if the type isn't valid since our key validation logic
2349 // doesn't expect a non-string/function type and can throw confusing errors.
2350 // We don't want exception behavior to differ between dev and prod.
2351 // (Rendering will throw with a helpful message and as soon as the type is
2352 // fixed, the key warnings will appear.)
2353
2354
2355 if (validType) {
2356 for (var i = 2; i < arguments.length; i++) {
2357 validateChildKeys(arguments[i], type);
2358 }
2359 }
2360
2361 if (type === REACT_FRAGMENT_TYPE) {
2362 validateFragmentProps(element);
2363 } else {
2364 validatePropTypes(element);
2365 }
2366
2367 return element;
2368 }
2369 var didWarnAboutDeprecatedCreateFactory = false;
2370 function createFactoryWithValidation(type) {
2371 var validatedFactory = createElementWithValidation.bind(null, type);
2372 validatedFactory.type = type;
2373
2374 {
2375 if (!didWarnAboutDeprecatedCreateFactory) {
2376 didWarnAboutDeprecatedCreateFactory = true;
2377
2378 warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');
2379 } // Legacy hook: remove it
2380
2381
2382 Object.defineProperty(validatedFactory, 'type', {
2383 enumerable: false,
2384 get: function () {
2385 warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
2386
2387 Object.defineProperty(this, 'type', {
2388 value: type
2389 });
2390 return type;
2391 }
2392 });
2393 }
2394
2395 return validatedFactory;
2396 }
2397 function cloneElementWithValidation(element, props, children) {
2398 var newElement = cloneElement.apply(this, arguments);
2399
2400 for (var i = 2; i < arguments.length; i++) {
2401 validateChildKeys(arguments[i], newElement.type);
2402 }
2403
2404 validatePropTypes(newElement);
2405 return newElement;
2406 }
2407
2408 var enableSchedulerDebugging = false;
2409 var enableProfiling = false;
2410 var frameYieldMs = 5;
2411
2412 function push(heap, node) {
2413 var index = heap.length;
2414 heap.push(node);
2415 siftUp(heap, node, index);
2416 }
2417 function peek(heap) {
2418 return heap.length === 0 ? null : heap[0];
2419 }
2420 function pop(heap) {
2421 if (heap.length === 0) {
2422 return null;
2423 }
2424
2425 var first = heap[0];
2426 var last = heap.pop();
2427
2428 if (last !== first) {
2429 heap[0] = last;
2430 siftDown(heap, last, 0);
2431 }
2432
2433 return first;
2434 }
2435
2436 function siftUp(heap, node, i) {
2437 var index = i;
2438
2439 while (index > 0) {
2440 var parentIndex = index - 1 >>> 1;
2441 var parent = heap[parentIndex];
2442
2443 if (compare(parent, node) > 0) {
2444 // The parent is larger. Swap positions.
2445 heap[parentIndex] = node;
2446 heap[index] = parent;
2447 index = parentIndex;
2448 } else {
2449 // The parent is smaller. Exit.
2450 return;
2451 }
2452 }
2453 }
2454
2455 function siftDown(heap, node, i) {
2456 var index = i;
2457 var length = heap.length;
2458 var halfLength = length >>> 1;
2459
2460 while (index < halfLength) {
2461 var leftIndex = (index + 1) * 2 - 1;
2462 var left = heap[leftIndex];
2463 var rightIndex = leftIndex + 1;
2464 var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
2465
2466 if (compare(left, node) < 0) {
2467 if (rightIndex < length && compare(right, left) < 0) {
2468 heap[index] = right;
2469 heap[rightIndex] = node;
2470 index = rightIndex;
2471 } else {
2472 heap[index] = left;
2473 heap[leftIndex] = node;
2474 index = leftIndex;
2475 }
2476 } else if (rightIndex < length && compare(right, node) < 0) {
2477 heap[index] = right;
2478 heap[rightIndex] = node;
2479 index = rightIndex;
2480 } else {
2481 // Neither child is smaller. Exit.
2482 return;
2483 }
2484 }
2485 }
2486
2487 function compare(a, b) {
2488 // Compare sort index first, then task id.
2489 var diff = a.sortIndex - b.sortIndex;
2490 return diff !== 0 ? diff : a.id - b.id;
2491 }
2492
2493 // TODO: Use symbols?
2494 var ImmediatePriority = 1;
2495 var UserBlockingPriority = 2;
2496 var NormalPriority = 3;
2497 var LowPriority = 4;
2498 var IdlePriority = 5;
2499
2500 function markTaskErrored(task, ms) {
2501 }
2502
2503 /* eslint-disable no-var */
2504 var getCurrentTime;
2505 var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
2506
2507 if (hasPerformanceNow) {
2508 var localPerformance = performance;
2509
2510 getCurrentTime = function () {
2511 return localPerformance.now();
2512 };
2513 } else {
2514 var localDate = Date;
2515 var initialTime = localDate.now();
2516
2517 getCurrentTime = function () {
2518 return localDate.now() - initialTime;
2519 };
2520 } // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
2521 // Math.pow(2, 30) - 1
2522 // 0b111111111111111111111111111111
2523
2524
2525 var maxSigned31BitInt = 1073741823; // Times out immediately
2526
2527 var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
2528
2529 var USER_BLOCKING_PRIORITY_TIMEOUT = 250;
2530 var NORMAL_PRIORITY_TIMEOUT = 5000;
2531 var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
2532
2533 var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap
2534
2535 var taskQueue = [];
2536 var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
2537
2538 var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
2539 var currentTask = null;
2540 var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrance.
2541
2542 var isPerformingWork = false;
2543 var isHostCallbackScheduled = false;
2544 var isHostTimeoutScheduled = false; // Capture local references to native APIs, in case a polyfill overrides them.
2545
2546 var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : null;
2547 var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : null;
2548 var localSetImmediate = typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom
2549
2550 var isInputPending = typeof navigator !== 'undefined' && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined ? navigator.scheduling.isInputPending.bind(navigator.scheduling) : null;
2551
2552 function advanceTimers(currentTime) {
2553 // Check for tasks that are no longer delayed and add them to the queue.
2554 var timer = peek(timerQueue);
2555
2556 while (timer !== null) {
2557 if (timer.callback === null) {
2558 // Timer was cancelled.
2559 pop(timerQueue);
2560 } else if (timer.startTime <= currentTime) {
2561 // Timer fired. Transfer to the task queue.
2562 pop(timerQueue);
2563 timer.sortIndex = timer.expirationTime;
2564 push(taskQueue, timer);
2565 } else {
2566 // Remaining timers are pending.
2567 return;
2568 }
2569
2570 timer = peek(timerQueue);
2571 }
2572 }
2573
2574 function handleTimeout(currentTime) {
2575 isHostTimeoutScheduled = false;
2576 advanceTimers(currentTime);
2577
2578 if (!isHostCallbackScheduled) {
2579 if (peek(taskQueue) !== null) {
2580 isHostCallbackScheduled = true;
2581 requestHostCallback(flushWork);
2582 } else {
2583 var firstTimer = peek(timerQueue);
2584
2585 if (firstTimer !== null) {
2586 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
2587 }
2588 }
2589 }
2590 }
2591
2592 function flushWork(hasTimeRemaining, initialTime) {
2593
2594
2595 isHostCallbackScheduled = false;
2596
2597 if (isHostTimeoutScheduled) {
2598 // We scheduled a timeout but it's no longer needed. Cancel it.
2599 isHostTimeoutScheduled = false;
2600 cancelHostTimeout();
2601 }
2602
2603 isPerformingWork = true;
2604 var previousPriorityLevel = currentPriorityLevel;
2605
2606 try {
2607 if (enableProfiling) {
2608 try {
2609 return workLoop(hasTimeRemaining, initialTime);
2610 } catch (error) {
2611 if (currentTask !== null) {
2612 var currentTime = getCurrentTime();
2613 markTaskErrored(currentTask, currentTime);
2614 currentTask.isQueued = false;
2615 }
2616
2617 throw error;
2618 }
2619 } else {
2620 // No catch in prod code path.
2621 return workLoop(hasTimeRemaining, initialTime);
2622 }
2623 } finally {
2624 currentTask = null;
2625 currentPriorityLevel = previousPriorityLevel;
2626 isPerformingWork = false;
2627 }
2628 }
2629
2630 function workLoop(hasTimeRemaining, initialTime) {
2631 var currentTime = initialTime;
2632 advanceTimers(currentTime);
2633 currentTask = peek(taskQueue);
2634
2635 while (currentTask !== null && !(enableSchedulerDebugging )) {
2636 if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
2637 // This currentTask hasn't expired, and we've reached the deadline.
2638 break;
2639 }
2640
2641 var callback = currentTask.callback;
2642
2643 if (typeof callback === 'function') {
2644 currentTask.callback = null;
2645 currentPriorityLevel = currentTask.priorityLevel;
2646 var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
2647
2648 var continuationCallback = callback(didUserCallbackTimeout);
2649 currentTime = getCurrentTime();
2650
2651 if (typeof continuationCallback === 'function') {
2652 currentTask.callback = continuationCallback;
2653 } else {
2654
2655 if (currentTask === peek(taskQueue)) {
2656 pop(taskQueue);
2657 }
2658 }
2659
2660 advanceTimers(currentTime);
2661 } else {
2662 pop(taskQueue);
2663 }
2664
2665 currentTask = peek(taskQueue);
2666 } // Return whether there's additional work
2667
2668
2669 if (currentTask !== null) {
2670 return true;
2671 } else {
2672 var firstTimer = peek(timerQueue);
2673
2674 if (firstTimer !== null) {
2675 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
2676 }
2677
2678 return false;
2679 }
2680 }
2681
2682 function unstable_runWithPriority(priorityLevel, eventHandler) {
2683 switch (priorityLevel) {
2684 case ImmediatePriority:
2685 case UserBlockingPriority:
2686 case NormalPriority:
2687 case LowPriority:
2688 case IdlePriority:
2689 break;
2690
2691 default:
2692 priorityLevel = NormalPriority;
2693 }
2694
2695 var previousPriorityLevel = currentPriorityLevel;
2696 currentPriorityLevel = priorityLevel;
2697
2698 try {
2699 return eventHandler();
2700 } finally {
2701 currentPriorityLevel = previousPriorityLevel;
2702 }
2703 }
2704
2705 function unstable_next(eventHandler) {
2706 var priorityLevel;
2707
2708 switch (currentPriorityLevel) {
2709 case ImmediatePriority:
2710 case UserBlockingPriority:
2711 case NormalPriority:
2712 // Shift down to normal priority
2713 priorityLevel = NormalPriority;
2714 break;
2715
2716 default:
2717 // Anything lower than normal priority should remain at the current level.
2718 priorityLevel = currentPriorityLevel;
2719 break;
2720 }
2721
2722 var previousPriorityLevel = currentPriorityLevel;
2723 currentPriorityLevel = priorityLevel;
2724
2725 try {
2726 return eventHandler();
2727 } finally {
2728 currentPriorityLevel = previousPriorityLevel;
2729 }
2730 }
2731
2732 function unstable_wrapCallback(callback) {
2733 var parentPriorityLevel = currentPriorityLevel;
2734 return function () {
2735 // This is a fork of runWithPriority, inlined for performance.
2736 var previousPriorityLevel = currentPriorityLevel;
2737 currentPriorityLevel = parentPriorityLevel;
2738
2739 try {
2740 return callback.apply(this, arguments);
2741 } finally {
2742 currentPriorityLevel = previousPriorityLevel;
2743 }
2744 };
2745 }
2746
2747 function unstable_scheduleCallback(priorityLevel, callback, options) {
2748 var currentTime = getCurrentTime();
2749 var startTime;
2750
2751 if (typeof options === 'object' && options !== null) {
2752 var delay = options.delay;
2753
2754 if (typeof delay === 'number' && delay > 0) {
2755 startTime = currentTime + delay;
2756 } else {
2757 startTime = currentTime;
2758 }
2759 } else {
2760 startTime = currentTime;
2761 }
2762
2763 var timeout;
2764
2765 switch (priorityLevel) {
2766 case ImmediatePriority:
2767 timeout = IMMEDIATE_PRIORITY_TIMEOUT;
2768 break;
2769
2770 case UserBlockingPriority:
2771 timeout = USER_BLOCKING_PRIORITY_TIMEOUT;
2772 break;
2773
2774 case IdlePriority:
2775 timeout = IDLE_PRIORITY_TIMEOUT;
2776 break;
2777
2778 case LowPriority:
2779 timeout = LOW_PRIORITY_TIMEOUT;
2780 break;
2781
2782 case NormalPriority:
2783 default:
2784 timeout = NORMAL_PRIORITY_TIMEOUT;
2785 break;
2786 }
2787
2788 var expirationTime = startTime + timeout;
2789 var newTask = {
2790 id: taskIdCounter++,
2791 callback: callback,
2792 priorityLevel: priorityLevel,
2793 startTime: startTime,
2794 expirationTime: expirationTime,
2795 sortIndex: -1
2796 };
2797
2798 if (startTime > currentTime) {
2799 // This is a delayed task.
2800 newTask.sortIndex = startTime;
2801 push(timerQueue, newTask);
2802
2803 if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
2804 // All tasks are delayed, and this is the task with the earliest delay.
2805 if (isHostTimeoutScheduled) {
2806 // Cancel an existing timeout.
2807 cancelHostTimeout();
2808 } else {
2809 isHostTimeoutScheduled = true;
2810 } // Schedule a timeout.
2811
2812
2813 requestHostTimeout(handleTimeout, startTime - currentTime);
2814 }
2815 } else {
2816 newTask.sortIndex = expirationTime;
2817 push(taskQueue, newTask);
2818 // wait until the next time we yield.
2819
2820
2821 if (!isHostCallbackScheduled && !isPerformingWork) {
2822 isHostCallbackScheduled = true;
2823 requestHostCallback(flushWork);
2824 }
2825 }
2826
2827 return newTask;
2828 }
2829
2830 function unstable_pauseExecution() {
2831 }
2832
2833 function unstable_continueExecution() {
2834
2835 if (!isHostCallbackScheduled && !isPerformingWork) {
2836 isHostCallbackScheduled = true;
2837 requestHostCallback(flushWork);
2838 }
2839 }
2840
2841 function unstable_getFirstCallbackNode() {
2842 return peek(taskQueue);
2843 }
2844
2845 function unstable_cancelCallback(task) {
2846 // remove from the queue because you can't remove arbitrary nodes from an
2847 // array based heap, only the first one.)
2848
2849
2850 task.callback = null;
2851 }
2852
2853 function unstable_getCurrentPriorityLevel() {
2854 return currentPriorityLevel;
2855 }
2856
2857 var isMessageLoopRunning = false;
2858 var scheduledHostCallback = null;
2859 var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
2860 // thread, like user events. By default, it yields multiple times per frame.
2861 // It does not attempt to align with frame boundaries, since most tasks don't
2862 // need to be frame aligned; for those that do, use requestAnimationFrame.
2863
2864 var frameInterval = frameYieldMs;
2865 var startTime = -1;
2866
2867 function shouldYieldToHost() {
2868 var timeElapsed = getCurrentTime() - startTime;
2869
2870 if (timeElapsed < frameInterval) {
2871 // The main thread has only been blocked for a really short amount of time;
2872 // smaller than a single frame. Don't yield yet.
2873 return false;
2874 } // The main thread has been blocked for a non-negligible amount of time. We
2875
2876
2877 return true;
2878 }
2879
2880 function requestPaint() {
2881
2882 }
2883
2884 function forceFrameRate(fps) {
2885 if (fps < 0 || fps > 125) {
2886 // Using console['error'] to evade Babel and ESLint
2887 console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported');
2888 return;
2889 }
2890
2891 if (fps > 0) {
2892 frameInterval = Math.floor(1000 / fps);
2893 } else {
2894 // reset the framerate
2895 frameInterval = frameYieldMs;
2896 }
2897 }
2898
2899 var performWorkUntilDeadline = function () {
2900 if (scheduledHostCallback !== null) {
2901 var currentTime = getCurrentTime(); // Keep track of the start time so we can measure how long the main thread
2902 // has been blocked.
2903
2904 startTime = currentTime;
2905 var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the
2906 // error can be observed.
2907 //
2908 // Intentionally not using a try-catch, since that makes some debugging
2909 // techniques harder. Instead, if `scheduledHostCallback` errors, then
2910 // `hasMoreWork` will remain true, and we'll continue the work loop.
2911
2912 var hasMoreWork = true;
2913
2914 try {
2915 hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
2916 } finally {
2917 if (hasMoreWork) {
2918 // If there's more work, schedule the next message event at the end
2919 // of the preceding one.
2920 schedulePerformWorkUntilDeadline();
2921 } else {
2922 isMessageLoopRunning = false;
2923 scheduledHostCallback = null;
2924 }
2925 }
2926 } else {
2927 isMessageLoopRunning = false;
2928 } // Yielding to the browser will give it a chance to paint, so we can
2929 };
2930
2931 var schedulePerformWorkUntilDeadline;
2932
2933 if (typeof localSetImmediate === 'function') {
2934 // Node.js and old IE.
2935 // There's a few reasons for why we prefer setImmediate.
2936 //
2937 // Unlike MessageChannel, it doesn't prevent a Node.js process from exiting.
2938 // (Even though this is a DOM fork of the Scheduler, you could get here
2939 // with a mix of Node.js 15+, which has a MessageChannel, and jsdom.)
2940 // https://github.com/facebook/react/issues/20756
2941 //
2942 // But also, it runs earlier which is the semantic we want.
2943 // If other browsers ever implement it, it's better to use it.
2944 // Although both of these would be inferior to native scheduling.
2945 schedulePerformWorkUntilDeadline = function () {
2946 localSetImmediate(performWorkUntilDeadline);
2947 };
2948 } else if (typeof MessageChannel !== 'undefined') {
2949 // DOM and Worker environments.
2950 // We prefer MessageChannel because of the 4ms setTimeout clamping.
2951 var channel = new MessageChannel();
2952 var port = channel.port2;
2953 channel.port1.onmessage = performWorkUntilDeadline;
2954
2955 schedulePerformWorkUntilDeadline = function () {
2956 port.postMessage(null);
2957 };
2958 } else {
2959 // We should only fallback here in non-browser environments.
2960 schedulePerformWorkUntilDeadline = function () {
2961 localSetTimeout(performWorkUntilDeadline, 0);
2962 };
2963 }
2964
2965 function requestHostCallback(callback) {
2966 scheduledHostCallback = callback;
2967
2968 if (!isMessageLoopRunning) {
2969 isMessageLoopRunning = true;
2970 schedulePerformWorkUntilDeadline();
2971 }
2972 }
2973
2974 function requestHostTimeout(callback, ms) {
2975 taskTimeoutID = localSetTimeout(function () {
2976 callback(getCurrentTime());
2977 }, ms);
2978 }
2979
2980 function cancelHostTimeout() {
2981 localClearTimeout(taskTimeoutID);
2982 taskTimeoutID = -1;
2983 }
2984
2985 var unstable_requestPaint = requestPaint;
2986 var unstable_Profiling = null;
2987
2988
2989
2990 var Scheduler = /*#__PURE__*/Object.freeze({
2991 __proto__: null,
2992 unstable_ImmediatePriority: ImmediatePriority,
2993 unstable_UserBlockingPriority: UserBlockingPriority,
2994 unstable_NormalPriority: NormalPriority,
2995 unstable_IdlePriority: IdlePriority,
2996 unstable_LowPriority: LowPriority,
2997 unstable_runWithPriority: unstable_runWithPriority,
2998 unstable_next: unstable_next,
2999 unstable_scheduleCallback: unstable_scheduleCallback,
3000 unstable_cancelCallback: unstable_cancelCallback,
3001 unstable_wrapCallback: unstable_wrapCallback,
3002 unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel,
3003 unstable_shouldYield: shouldYieldToHost,
3004 unstable_requestPaint: unstable_requestPaint,
3005 unstable_continueExecution: unstable_continueExecution,
3006 unstable_pauseExecution: unstable_pauseExecution,
3007 unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
3008 get unstable_now () { return getCurrentTime; },
3009 unstable_forceFrameRate: forceFrameRate,
3010 unstable_Profiling: unstable_Profiling
3011 });
3012
3013 var ReactSharedInternals$1 = {
3014 ReactCurrentDispatcher: ReactCurrentDispatcher,
3015 ReactCurrentOwner: ReactCurrentOwner,
3016 ReactCurrentBatchConfig: ReactCurrentBatchConfig,
3017 // Re-export the schedule API(s) for UMD bundles.
3018 // This avoids introducing a dependency on a new UMD global in a minor update,
3019 // Since that would be a breaking change (e.g. for all existing CodeSandboxes).
3020 // This re-export is only required for UMD bundles;
3021 // CJS bundles use the shared NPM package.
3022 Scheduler: Scheduler
3023 };
3024
3025 {
3026 ReactSharedInternals$1.ReactCurrentActQueue = ReactCurrentActQueue;
3027 ReactSharedInternals$1.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
3028 }
3029
3030 function startTransition(scope, options) {
3031 var prevTransition = ReactCurrentBatchConfig.transition;
3032 ReactCurrentBatchConfig.transition = {};
3033 var currentTransition = ReactCurrentBatchConfig.transition;
3034
3035 {
3036 ReactCurrentBatchConfig.transition._updatedFibers = new Set();
3037 }
3038
3039 try {
3040 scope();
3041 } finally {
3042 ReactCurrentBatchConfig.transition = prevTransition;
3043
3044 {
3045 if (prevTransition === null && currentTransition._updatedFibers) {
3046 var updatedFibersCount = currentTransition._updatedFibers.size;
3047
3048 if (updatedFibersCount > 10) {
3049 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.');
3050 }
3051
3052 currentTransition._updatedFibers.clear();
3053 }
3054 }
3055 }
3056 }
3057
3058 var didWarnAboutMessageChannel = false;
3059 var enqueueTaskImpl = null;
3060 function enqueueTask(task) {
3061 if (enqueueTaskImpl === null) {
3062 try {
3063 // read require off the module object to get around the bundlers.
3064 // we don't want them to detect a require and bundle a Node polyfill.
3065 var requireString = ('require' + Math.random()).slice(0, 7);
3066 var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
3067 // version of setImmediate, bypassing fake timers if any.
3068
3069 enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
3070 } catch (_err) {
3071 // we're in a browser
3072 // we can't use regular timers because they may still be faked
3073 // so we try MessageChannel+postMessage instead
3074 enqueueTaskImpl = function (callback) {
3075 {
3076 if (didWarnAboutMessageChannel === false) {
3077 didWarnAboutMessageChannel = true;
3078
3079 if (typeof MessageChannel === 'undefined') {
3080 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.');
3081 }
3082 }
3083 }
3084
3085 var channel = new MessageChannel();
3086 channel.port1.onmessage = callback;
3087 channel.port2.postMessage(undefined);
3088 };
3089 }
3090 }
3091
3092 return enqueueTaskImpl(task);
3093 }
3094
3095 var actScopeDepth = 0;
3096 var didWarnNoAwaitAct = false;
3097 function act(callback) {
3098 {
3099 // `act` calls can be nested, so we track the depth. This represents the
3100 // number of `act` scopes on the stack.
3101 var prevActScopeDepth = actScopeDepth;
3102 actScopeDepth++;
3103
3104 if (ReactCurrentActQueue.current === null) {
3105 // This is the outermost `act` scope. Initialize the queue. The reconciler
3106 // will detect the queue and use it instead of Scheduler.
3107 ReactCurrentActQueue.current = [];
3108 }
3109
3110 var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
3111 var result;
3112
3113 try {
3114 // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only
3115 // set to `true` while the given callback is executed, not for updates
3116 // triggered during an async event, because this is how the legacy
3117 // implementation of `act` behaved.
3118 ReactCurrentActQueue.isBatchingLegacy = true;
3119 result = callback(); // Replicate behavior of original `act` implementation in legacy mode,
3120 // which flushed updates immediately after the scope function exits, even
3121 // if it's an async function.
3122
3123 if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
3124 var queue = ReactCurrentActQueue.current;
3125
3126 if (queue !== null) {
3127 ReactCurrentActQueue.didScheduleLegacyUpdate = false;
3128 flushActQueue(queue);
3129 }
3130 }
3131 } catch (error) {
3132 popActScope(prevActScopeDepth);
3133 throw error;
3134 } finally {
3135 ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
3136 }
3137
3138 if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
3139 var thenableResult = result; // The callback is an async function (i.e. returned a promise). Wait
3140 // for it to resolve before exiting the current scope.
3141
3142 var wasAwaited = false;
3143 var thenable = {
3144 then: function (resolve, reject) {
3145 wasAwaited = true;
3146 thenableResult.then(function (returnValue) {
3147 popActScope(prevActScopeDepth);
3148
3149 if (actScopeDepth === 0) {
3150 // We've exited the outermost act scope. Recursively flush the
3151 // queue until there's no remaining work.
3152 recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3153 } else {
3154 resolve(returnValue);
3155 }
3156 }, function (error) {
3157 // The callback threw an error.
3158 popActScope(prevActScopeDepth);
3159 reject(error);
3160 });
3161 }
3162 };
3163
3164 {
3165 if (!didWarnNoAwaitAct && typeof Promise !== 'undefined') {
3166 // eslint-disable-next-line no-undef
3167 Promise.resolve().then(function () {}).then(function () {
3168 if (!wasAwaited) {
3169 didWarnNoAwaitAct = true;
3170
3171 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 () => ...);');
3172 }
3173 });
3174 }
3175 }
3176
3177 return thenable;
3178 } else {
3179 var returnValue = result; // The callback is not an async function. Exit the current scope
3180 // immediately, without awaiting.
3181
3182 popActScope(prevActScopeDepth);
3183
3184 if (actScopeDepth === 0) {
3185 // Exiting the outermost act scope. Flush the queue.
3186 var _queue = ReactCurrentActQueue.current;
3187
3188 if (_queue !== null) {
3189 flushActQueue(_queue);
3190 ReactCurrentActQueue.current = null;
3191 } // Return a thenable. If the user awaits it, we'll flush again in
3192 // case additional work was scheduled by a microtask.
3193
3194
3195 var _thenable = {
3196 then: function (resolve, reject) {
3197 // Confirm we haven't re-entered another `act` scope, in case
3198 // the user does something weird like await the thenable
3199 // multiple times.
3200 if (ReactCurrentActQueue.current === null) {
3201 // Recursively flush the queue until there's no remaining work.
3202 ReactCurrentActQueue.current = [];
3203 recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3204 } else {
3205 resolve(returnValue);
3206 }
3207 }
3208 };
3209 return _thenable;
3210 } else {
3211 // Since we're inside a nested `act` scope, the returned thenable
3212 // immediately resolves. The outer scope will flush the queue.
3213 var _thenable2 = {
3214 then: function (resolve, reject) {
3215 resolve(returnValue);
3216 }
3217 };
3218 return _thenable2;
3219 }
3220 }
3221 }
3222 }
3223
3224 function popActScope(prevActScopeDepth) {
3225 {
3226 if (prevActScopeDepth !== actScopeDepth - 1) {
3227 error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
3228 }
3229
3230 actScopeDepth = prevActScopeDepth;
3231 }
3232 }
3233
3234 function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
3235 {
3236 var queue = ReactCurrentActQueue.current;
3237
3238 if (queue !== null) {
3239 try {
3240 flushActQueue(queue);
3241 enqueueTask(function () {
3242 if (queue.length === 0) {
3243 // No additional work was scheduled. Finish.
3244 ReactCurrentActQueue.current = null;
3245 resolve(returnValue);
3246 } else {
3247 // Keep flushing work until there's none left.
3248 recursivelyFlushAsyncActWork(returnValue, resolve, reject);
3249 }
3250 });
3251 } catch (error) {
3252 reject(error);
3253 }
3254 } else {
3255 resolve(returnValue);
3256 }
3257 }
3258 }
3259
3260 var isFlushing = false;
3261
3262 function flushActQueue(queue) {
3263 {
3264 if (!isFlushing) {
3265 // Prevent re-entrance.
3266 isFlushing = true;
3267 var i = 0;
3268
3269 try {
3270 for (; i < queue.length; i++) {
3271 var callback = queue[i];
3272
3273 do {
3274 callback = callback(true);
3275 } while (callback !== null);
3276 }
3277
3278 queue.length = 0;
3279 } catch (error) {
3280 // If something throws, leave the remaining callbacks on the queue.
3281 queue = queue.slice(i + 1);
3282 throw error;
3283 } finally {
3284 isFlushing = false;
3285 }
3286 }
3287 }
3288 }
3289
3290 var createElement$1 = createElementWithValidation ;
3291 var cloneElement$1 = cloneElementWithValidation ;
3292 var createFactory = createFactoryWithValidation ;
3293 var Children = {
3294 map: mapChildren,
3295 forEach: forEachChildren,
3296 count: countChildren,
3297 toArray: toArray,
3298 only: onlyChild
3299 };
3300
3301 exports.Children = Children;
3302 exports.Component = Component;
3303 exports.Fragment = REACT_FRAGMENT_TYPE;
3304 exports.Profiler = REACT_PROFILER_TYPE;
3305 exports.PureComponent = PureComponent;
3306 exports.StrictMode = REACT_STRICT_MODE_TYPE;
3307 exports.Suspense = REACT_SUSPENSE_TYPE;
3308 exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals$1;
3309 exports.cloneElement = cloneElement$1;
3310 exports.createContext = createContext;
3311 exports.createElement = createElement$1;
3312 exports.createFactory = createFactory;
3313 exports.createRef = createRef;
3314 exports.forwardRef = forwardRef;
3315 exports.isValidElement = isValidElement;
3316 exports.lazy = lazy;
3317 exports.memo = memo;
3318 exports.startTransition = startTransition;
3319 exports.unstable_act = act;
3320 exports.useCallback = useCallback;
3321 exports.useContext = useContext;
3322 exports.useDebugValue = useDebugValue;
3323 exports.useDeferredValue = useDeferredValue;
3324 exports.useEffect = useEffect;
3325 exports.useId = useId;
3326 exports.useImperativeHandle = useImperativeHandle;
3327 exports.useInsertionEffect = useInsertionEffect;
3328 exports.useLayoutEffect = useLayoutEffect;
3329 exports.useMemo = useMemo;
3330 exports.useReducer = useReducer;
3331 exports.useRef = useRef;
3332 exports.useState = useState;
3333 exports.useSyncExternalStore = useSyncExternalStore;
3334 exports.useTransition = useTransition;
3335 exports.version = ReactVersion;
3336
3337})));