UNPKG

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