UNPKG

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