UNPKG

103 kBJavaScriptView Raw
1/** @license React v16.8.5
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
10'use strict';
11
12(function (global, factory) {
13 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
14 typeof define === 'function' && define.amd ? define(factory) :
15 (global.React = factory());
16}(this, (function () { 'use strict';
17
18// TODO: this is special because it gets imported during build.
19
20var ReactVersion = '16.8.5';
21
22// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
23// nor polyfill, then a plain number is used for performance.
24var hasSymbol = typeof Symbol === 'function' && Symbol.for;
25
26var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
27var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
28var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
29var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
30var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
31var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
32var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
33
34var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
35var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
36var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
37var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
38var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
39
40var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
41var FAUX_ITERATOR_SYMBOL = '@@iterator';
42
43function getIteratorFn(maybeIterable) {
44 if (maybeIterable === null || typeof maybeIterable !== 'object') {
45 return null;
46 }
47 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
48 if (typeof maybeIterator === 'function') {
49 return maybeIterator;
50 }
51 return null;
52}
53
54/*
55object-assign
56(c) Sindre Sorhus
57@license MIT
58*/
59
60
61/* eslint-disable no-unused-vars */
62var getOwnPropertySymbols = Object.getOwnPropertySymbols;
63var hasOwnProperty = Object.prototype.hasOwnProperty;
64var propIsEnumerable = Object.prototype.propertyIsEnumerable;
65
66function toObject(val) {
67 if (val === null || val === undefined) {
68 throw new TypeError('Object.assign cannot be called with null or undefined');
69 }
70
71 return Object(val);
72}
73
74function shouldUseNative() {
75 try {
76 if (!Object.assign) {
77 return false;
78 }
79
80 // Detect buggy property enumeration order in older V8 versions.
81
82 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
83 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
84 test1[5] = 'de';
85 if (Object.getOwnPropertyNames(test1)[0] === '5') {
86 return false;
87 }
88
89 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
90 var test2 = {};
91 for (var i = 0; i < 10; i++) {
92 test2['_' + String.fromCharCode(i)] = i;
93 }
94 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
95 return test2[n];
96 });
97 if (order2.join('') !== '0123456789') {
98 return false;
99 }
100
101 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
102 var test3 = {};
103 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
104 test3[letter] = letter;
105 });
106 if (Object.keys(Object.assign({}, test3)).join('') !==
107 'abcdefghijklmnopqrst') {
108 return false;
109 }
110
111 return true;
112 } catch (err) {
113 // We don't expect any of the above to throw, but better to be safe.
114 return false;
115 }
116}
117
118var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
119 var from;
120 var to = toObject(target);
121 var symbols;
122
123 for (var s = 1; s < arguments.length; s++) {
124 from = Object(arguments[s]);
125
126 for (var key in from) {
127 if (hasOwnProperty.call(from, key)) {
128 to[key] = from[key];
129 }
130 }
131
132 if (getOwnPropertySymbols) {
133 symbols = getOwnPropertySymbols(from);
134 for (var i = 0; i < symbols.length; i++) {
135 if (propIsEnumerable.call(from, symbols[i])) {
136 to[symbols[i]] = from[symbols[i]];
137 }
138 }
139 }
140 }
141
142 return to;
143};
144
145/**
146 * Use invariant() to assert state which your program assumes to be true.
147 *
148 * Provide sprintf-style format (only %s is supported) and arguments
149 * to provide information about what broke and what you were
150 * expecting.
151 *
152 * The invariant message will be stripped in production, but the invariant
153 * will remain to ensure logic does not differ in production.
154 */
155
156var validateFormat = function () {};
157
158{
159 validateFormat = function (format) {
160 if (format === undefined) {
161 throw new Error('invariant requires an error message argument');
162 }
163 };
164}
165
166function invariant(condition, format, a, b, c, d, e, f) {
167 validateFormat(format);
168
169 if (!condition) {
170 var error = void 0;
171 if (format === undefined) {
172 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
173 } else {
174 var args = [a, b, c, d, e, f];
175 var argIndex = 0;
176 error = new Error(format.replace(/%s/g, function () {
177 return args[argIndex++];
178 }));
179 error.name = 'Invariant Violation';
180 }
181
182 error.framesToPop = 1; // we don't care about invariant's own frame
183 throw error;
184 }
185}
186
187// Relying on the `invariant()` implementation lets us
188// preserve the format and params in the www builds.
189
190/**
191 * Forked from fbjs/warning:
192 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
193 *
194 * Only change is we use console.warn instead of console.error,
195 * and do nothing when 'console' is not supported.
196 * This really simplifies the code.
197 * ---
198 * Similar to invariant but only logs a warning if the condition is not met.
199 * This can be used to log issues in development environments in critical
200 * paths. Removing the logging code for production environments will keep the
201 * same logic and follow the same code paths.
202 */
203
204var lowPriorityWarning = function () {};
205
206{
207 var printWarning = function (format) {
208 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
209 args[_key - 1] = arguments[_key];
210 }
211
212 var argIndex = 0;
213 var message = 'Warning: ' + format.replace(/%s/g, function () {
214 return args[argIndex++];
215 });
216 if (typeof console !== 'undefined') {
217 console.warn(message);
218 }
219 try {
220 // --- Welcome to debugging React ---
221 // This error was thrown as a convenience so that you can use this stack
222 // to find the callsite that caused this warning to fire.
223 throw new Error(message);
224 } catch (x) {}
225 };
226
227 lowPriorityWarning = function (condition, format) {
228 if (format === undefined) {
229 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
230 }
231 if (!condition) {
232 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
233 args[_key2 - 2] = arguments[_key2];
234 }
235
236 printWarning.apply(undefined, [format].concat(args));
237 }
238 };
239}
240
241var lowPriorityWarning$1 = lowPriorityWarning;
242
243/**
244 * Similar to invariant but only logs a warning if the condition is not met.
245 * This can be used to log issues in development environments in critical
246 * paths. Removing the logging code for production environments will keep the
247 * same logic and follow the same code paths.
248 */
249
250var warningWithoutStack = function () {};
251
252{
253 warningWithoutStack = function (condition, format) {
254 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
255 args[_key - 2] = arguments[_key];
256 }
257
258 if (format === undefined) {
259 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
260 }
261 if (args.length > 8) {
262 // Check before the condition to catch violations early.
263 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
264 }
265 if (condition) {
266 return;
267 }
268 if (typeof console !== 'undefined') {
269 var argsWithFormat = args.map(function (item) {
270 return '' + item;
271 });
272 argsWithFormat.unshift('Warning: ' + format);
273
274 // We intentionally don't use spread (or .apply) directly because it
275 // breaks IE9: https://github.com/facebook/react/issues/13610
276 Function.prototype.apply.call(console.error, console, argsWithFormat);
277 }
278 try {
279 // --- Welcome to debugging React ---
280 // This error was thrown as a convenience so that you can use this stack
281 // to find the callsite that caused this warning to fire.
282 var argIndex = 0;
283 var message = 'Warning: ' + format.replace(/%s/g, function () {
284 return args[argIndex++];
285 });
286 throw new Error(message);
287 } catch (x) {}
288 };
289}
290
291var warningWithoutStack$1 = warningWithoutStack;
292
293var didWarnStateUpdateForUnmountedComponent = {};
294
295function warnNoop(publicInstance, callerName) {
296 {
297 var _constructor = publicInstance.constructor;
298 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
299 var warningKey = componentName + '.' + callerName;
300 if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
301 return;
302 }
303 warningWithoutStack$1(false, "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);
304 didWarnStateUpdateForUnmountedComponent[warningKey] = true;
305 }
306}
307
308/**
309 * This is the abstract API for an update queue.
310 */
311var ReactNoopUpdateQueue = {
312 /**
313 * Checks whether or not this composite component is mounted.
314 * @param {ReactClass} publicInstance The instance we want to test.
315 * @return {boolean} True if mounted, false otherwise.
316 * @protected
317 * @final
318 */
319 isMounted: function (publicInstance) {
320 return false;
321 },
322
323 /**
324 * Forces an update. This should only be invoked when it is known with
325 * certainty that we are **not** in a DOM transaction.
326 *
327 * You may want to call this when you know that some deeper aspect of the
328 * component's state has changed but `setState` was not called.
329 *
330 * This will not invoke `shouldComponentUpdate`, but it will invoke
331 * `componentWillUpdate` and `componentDidUpdate`.
332 *
333 * @param {ReactClass} publicInstance The instance that should rerender.
334 * @param {?function} callback Called after component is updated.
335 * @param {?string} callerName name of the calling function in the public API.
336 * @internal
337 */
338 enqueueForceUpdate: function (publicInstance, callback, callerName) {
339 warnNoop(publicInstance, 'forceUpdate');
340 },
341
342 /**
343 * Replaces all of the state. Always use this or `setState` to mutate state.
344 * You should treat `this.state` as immutable.
345 *
346 * There is no guarantee that `this.state` will be immediately updated, so
347 * accessing `this.state` after calling this method may return the old value.
348 *
349 * @param {ReactClass} publicInstance The instance that should rerender.
350 * @param {object} completeState Next state.
351 * @param {?function} callback Called after component is updated.
352 * @param {?string} callerName name of the calling function in the public API.
353 * @internal
354 */
355 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
356 warnNoop(publicInstance, 'replaceState');
357 },
358
359 /**
360 * Sets a subset of the state. This only exists because _pendingState is
361 * internal. This provides a merging strategy that is not available to deep
362 * properties which is confusing. TODO: Expose pendingState or don't use it
363 * during the merge.
364 *
365 * @param {ReactClass} publicInstance The instance that should rerender.
366 * @param {object} partialState Next partial state to be merged with state.
367 * @param {?function} callback Called after component is updated.
368 * @param {?string} Name of the calling function in the public API.
369 * @internal
370 */
371 enqueueSetState: function (publicInstance, partialState, callback, callerName) {
372 warnNoop(publicInstance, 'setState');
373 }
374};
375
376var emptyObject = {};
377{
378 Object.freeze(emptyObject);
379}
380
381/**
382 * Base class helpers for the updating state of a component.
383 */
384function Component(props, context, updater) {
385 this.props = props;
386 this.context = context;
387 // If a component has string refs, we will assign a different object later.
388 this.refs = emptyObject;
389 // We initialize the default updater but the real one gets injected by the
390 // renderer.
391 this.updater = updater || ReactNoopUpdateQueue;
392}
393
394Component.prototype.isReactComponent = {};
395
396/**
397 * Sets a subset of the state. Always use this to mutate
398 * state. You should treat `this.state` as immutable.
399 *
400 * There is no guarantee that `this.state` will be immediately updated, so
401 * accessing `this.state` after calling this method may return the old value.
402 *
403 * There is no guarantee that calls to `setState` will run synchronously,
404 * as they may eventually be batched together. You can provide an optional
405 * callback that will be executed when the call to setState is actually
406 * completed.
407 *
408 * When a function is provided to setState, it will be called at some point in
409 * the future (not synchronously). It will be called with the up to date
410 * component arguments (state, props, context). These values can be different
411 * from this.* because your function may be called after receiveProps but before
412 * shouldComponentUpdate, and this new state, props, and context will not yet be
413 * assigned to this.
414 *
415 * @param {object|function} partialState Next partial state or function to
416 * produce next partial state to be merged with current state.
417 * @param {?function} callback Called after state is updated.
418 * @final
419 * @protected
420 */
421Component.prototype.setState = function (partialState, callback) {
422 !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
423 this.updater.enqueueSetState(this, partialState, callback, 'setState');
424};
425
426/**
427 * Forces an update. This should only be invoked when it is known with
428 * certainty that we are **not** in a DOM transaction.
429 *
430 * You may want to call this when you know that some deeper aspect of the
431 * component's state has changed but `setState` was not called.
432 *
433 * This will not invoke `shouldComponentUpdate`, but it will invoke
434 * `componentWillUpdate` and `componentDidUpdate`.
435 *
436 * @param {?function} callback Called after update is complete.
437 * @final
438 * @protected
439 */
440Component.prototype.forceUpdate = function (callback) {
441 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
442};
443
444/**
445 * Deprecated APIs. These APIs used to exist on classic React classes but since
446 * we would like to deprecate them, we're not going to move them over to this
447 * modern base class. Instead, we define a getter that warns if it's accessed.
448 */
449{
450 var deprecatedAPIs = {
451 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
452 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
453 };
454 var defineDeprecationWarning = function (methodName, info) {
455 Object.defineProperty(Component.prototype, methodName, {
456 get: function () {
457 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
458 return undefined;
459 }
460 });
461 };
462 for (var fnName in deprecatedAPIs) {
463 if (deprecatedAPIs.hasOwnProperty(fnName)) {
464 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
465 }
466 }
467}
468
469function ComponentDummy() {}
470ComponentDummy.prototype = Component.prototype;
471
472/**
473 * Convenience component with default shallow equality check for sCU.
474 */
475function PureComponent(props, context, updater) {
476 this.props = props;
477 this.context = context;
478 // If a component has string refs, we will assign a different object later.
479 this.refs = emptyObject;
480 this.updater = updater || ReactNoopUpdateQueue;
481}
482
483var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
484pureComponentPrototype.constructor = PureComponent;
485// Avoid an extra prototype jump for these methods.
486objectAssign(pureComponentPrototype, Component.prototype);
487pureComponentPrototype.isPureReactComponent = true;
488
489// an immutable object with a single mutable value
490function createRef() {
491 var refObject = {
492 current: null
493 };
494 {
495 Object.seal(refObject);
496 }
497 return refObject;
498}
499
500var enableSchedulerDebugging = false;
501
502/* eslint-disable no-var */
503
504// TODO: Use symbols?
505var ImmediatePriority = 1;
506var UserBlockingPriority = 2;
507var NormalPriority = 3;
508var LowPriority = 4;
509var IdlePriority = 5;
510
511// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
512// Math.pow(2, 30) - 1
513// 0b111111111111111111111111111111
514var maxSigned31BitInt = 1073741823;
515
516// Times out immediately
517var IMMEDIATE_PRIORITY_TIMEOUT = -1;
518// Eventually times out
519var USER_BLOCKING_PRIORITY = 250;
520var NORMAL_PRIORITY_TIMEOUT = 5000;
521var LOW_PRIORITY_TIMEOUT = 10000;
522// Never times out
523var IDLE_PRIORITY = maxSigned31BitInt;
524
525// Callbacks are stored as a circular, doubly linked list.
526var firstCallbackNode = null;
527
528var currentDidTimeout = false;
529// Pausing the scheduler is useful for debugging.
530var isSchedulerPaused = false;
531
532var currentPriorityLevel = NormalPriority;
533var currentEventStartTime = -1;
534var currentExpirationTime = -1;
535
536// This is set when a callback is being executed, to prevent re-entrancy.
537var isExecutingCallback = false;
538
539var isHostCallbackScheduled = false;
540
541var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
542
543function ensureHostCallbackIsScheduled() {
544 if (isExecutingCallback) {
545 // Don't schedule work yet; wait until the next time we yield.
546 return;
547 }
548 // Schedule the host callback using the earliest expiration in the list.
549 var expirationTime = firstCallbackNode.expirationTime;
550 if (!isHostCallbackScheduled) {
551 isHostCallbackScheduled = true;
552 } else {
553 // Cancel the existing host callback.
554 cancelHostCallback();
555 }
556 requestHostCallback(flushWork, expirationTime);
557}
558
559function flushFirstCallback() {
560 var flushedNode = firstCallbackNode;
561
562 // Remove the node from the list before calling the callback. That way the
563 // list is in a consistent state even if the callback throws.
564 var next = firstCallbackNode.next;
565 if (firstCallbackNode === next) {
566 // This is the last callback in the list.
567 firstCallbackNode = null;
568 next = null;
569 } else {
570 var lastCallbackNode = firstCallbackNode.previous;
571 firstCallbackNode = lastCallbackNode.next = next;
572 next.previous = lastCallbackNode;
573 }
574
575 flushedNode.next = flushedNode.previous = null;
576
577 // Now it's safe to call the callback.
578 var callback = flushedNode.callback;
579 var expirationTime = flushedNode.expirationTime;
580 var priorityLevel = flushedNode.priorityLevel;
581 var previousPriorityLevel = currentPriorityLevel;
582 var previousExpirationTime = currentExpirationTime;
583 currentPriorityLevel = priorityLevel;
584 currentExpirationTime = expirationTime;
585 var continuationCallback;
586 try {
587 continuationCallback = callback();
588 } finally {
589 currentPriorityLevel = previousPriorityLevel;
590 currentExpirationTime = previousExpirationTime;
591 }
592
593 // A callback may return a continuation. The continuation should be scheduled
594 // with the same priority and expiration as the just-finished callback.
595 if (typeof continuationCallback === 'function') {
596 var continuationNode = {
597 callback: continuationCallback,
598 priorityLevel: priorityLevel,
599 expirationTime: expirationTime,
600 next: null,
601 previous: null
602 };
603
604 // Insert the new callback into the list, sorted by its expiration. This is
605 // almost the same as the code in `scheduleCallback`, except the callback
606 // is inserted into the list *before* callbacks of equal expiration instead
607 // of after.
608 if (firstCallbackNode === null) {
609 // This is the first callback in the list.
610 firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode;
611 } else {
612 var nextAfterContinuation = null;
613 var node = firstCallbackNode;
614 do {
615 if (node.expirationTime >= expirationTime) {
616 // This callback expires at or after the continuation. We will insert
617 // the continuation *before* this callback.
618 nextAfterContinuation = node;
619 break;
620 }
621 node = node.next;
622 } while (node !== firstCallbackNode);
623
624 if (nextAfterContinuation === null) {
625 // No equal or lower priority callback was found, which means the new
626 // callback is the lowest priority callback in the list.
627 nextAfterContinuation = firstCallbackNode;
628 } else if (nextAfterContinuation === firstCallbackNode) {
629 // The new callback is the highest priority callback in the list.
630 firstCallbackNode = continuationNode;
631 ensureHostCallbackIsScheduled();
632 }
633
634 var previous = nextAfterContinuation.previous;
635 previous.next = nextAfterContinuation.previous = continuationNode;
636 continuationNode.next = nextAfterContinuation;
637 continuationNode.previous = previous;
638 }
639 }
640}
641
642function flushImmediateWork() {
643 if (
644 // Confirm we've exited the outer most event handler
645 currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) {
646 isExecutingCallback = true;
647 try {
648 do {
649 flushFirstCallback();
650 } while (
651 // Keep flushing until there are no more immediate callbacks
652 firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority);
653 } finally {
654 isExecutingCallback = false;
655 if (firstCallbackNode !== null) {
656 // There's still work remaining. Request another callback.
657 ensureHostCallbackIsScheduled();
658 } else {
659 isHostCallbackScheduled = false;
660 }
661 }
662 }
663}
664
665function flushWork(didTimeout) {
666 // Exit right away if we're currently paused
667
668 if (enableSchedulerDebugging && isSchedulerPaused) {
669 return;
670 }
671
672 isExecutingCallback = true;
673 var previousDidTimeout = currentDidTimeout;
674 currentDidTimeout = didTimeout;
675 try {
676 if (didTimeout) {
677 // Flush all the expired callbacks without yielding.
678 while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) {
679 // TODO Wrap in feature flag
680 // Read the current time. Flush all the callbacks that expire at or
681 // earlier than that time. Then read the current time again and repeat.
682 // This optimizes for as few performance.now calls as possible.
683 var currentTime = getCurrentTime();
684 if (firstCallbackNode.expirationTime <= currentTime) {
685 do {
686 flushFirstCallback();
687 } while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused));
688 continue;
689 }
690 break;
691 }
692 } else {
693 // Keep flushing callbacks until we run out of time in the frame.
694 if (firstCallbackNode !== null) {
695 do {
696 if (enableSchedulerDebugging && isSchedulerPaused) {
697 break;
698 }
699 flushFirstCallback();
700 } while (firstCallbackNode !== null && !shouldYieldToHost());
701 }
702 }
703 } finally {
704 isExecutingCallback = false;
705 currentDidTimeout = previousDidTimeout;
706 if (firstCallbackNode !== null) {
707 // There's still work remaining. Request another callback.
708 ensureHostCallbackIsScheduled();
709 } else {
710 isHostCallbackScheduled = false;
711 }
712 // Before exiting, flush all the immediate work that was scheduled.
713 flushImmediateWork();
714 }
715}
716
717function unstable_runWithPriority(priorityLevel, eventHandler) {
718 switch (priorityLevel) {
719 case ImmediatePriority:
720 case UserBlockingPriority:
721 case NormalPriority:
722 case LowPriority:
723 case IdlePriority:
724 break;
725 default:
726 priorityLevel = NormalPriority;
727 }
728
729 var previousPriorityLevel = currentPriorityLevel;
730 var previousEventStartTime = currentEventStartTime;
731 currentPriorityLevel = priorityLevel;
732 currentEventStartTime = getCurrentTime();
733
734 try {
735 return eventHandler();
736 } finally {
737 currentPriorityLevel = previousPriorityLevel;
738 currentEventStartTime = previousEventStartTime;
739
740 // Before exiting, flush all the immediate work that was scheduled.
741 flushImmediateWork();
742 }
743}
744
745function unstable_next(eventHandler) {
746 var priorityLevel = void 0;
747 switch (currentPriorityLevel) {
748 case ImmediatePriority:
749 case UserBlockingPriority:
750 case NormalPriority:
751 // Shift down to normal priority
752 priorityLevel = NormalPriority;
753 break;
754 default:
755 // Anything lower than normal priority should remain at the current level.
756 priorityLevel = currentPriorityLevel;
757 break;
758 }
759
760 var previousPriorityLevel = currentPriorityLevel;
761 var previousEventStartTime = currentEventStartTime;
762 currentPriorityLevel = priorityLevel;
763 currentEventStartTime = getCurrentTime();
764
765 try {
766 return eventHandler();
767 } finally {
768 currentPriorityLevel = previousPriorityLevel;
769 currentEventStartTime = previousEventStartTime;
770
771 // Before exiting, flush all the immediate work that was scheduled.
772 flushImmediateWork();
773 }
774}
775
776function unstable_wrapCallback(callback) {
777 var parentPriorityLevel = currentPriorityLevel;
778 return function () {
779 // This is a fork of runWithPriority, inlined for performance.
780 var previousPriorityLevel = currentPriorityLevel;
781 var previousEventStartTime = currentEventStartTime;
782 currentPriorityLevel = parentPriorityLevel;
783 currentEventStartTime = getCurrentTime();
784
785 try {
786 return callback.apply(this, arguments);
787 } finally {
788 currentPriorityLevel = previousPriorityLevel;
789 currentEventStartTime = previousEventStartTime;
790 flushImmediateWork();
791 }
792 };
793}
794
795function unstable_scheduleCallback(callback, deprecated_options) {
796 var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
797
798 var expirationTime;
799 if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
800 // FIXME: Remove this branch once we lift expiration times out of React.
801 expirationTime = startTime + deprecated_options.timeout;
802 } else {
803 switch (currentPriorityLevel) {
804 case ImmediatePriority:
805 expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
806 break;
807 case UserBlockingPriority:
808 expirationTime = startTime + USER_BLOCKING_PRIORITY;
809 break;
810 case IdlePriority:
811 expirationTime = startTime + IDLE_PRIORITY;
812 break;
813 case LowPriority:
814 expirationTime = startTime + LOW_PRIORITY_TIMEOUT;
815 break;
816 case NormalPriority:
817 default:
818 expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
819 }
820 }
821
822 var newNode = {
823 callback: callback,
824 priorityLevel: currentPriorityLevel,
825 expirationTime: expirationTime,
826 next: null,
827 previous: null
828 };
829
830 // Insert the new callback into the list, ordered first by expiration, then
831 // by insertion. So the new callback is inserted any other callback with
832 // equal expiration.
833 if (firstCallbackNode === null) {
834 // This is the first callback in the list.
835 firstCallbackNode = newNode.next = newNode.previous = newNode;
836 ensureHostCallbackIsScheduled();
837 } else {
838 var next = null;
839 var node = firstCallbackNode;
840 do {
841 if (node.expirationTime > expirationTime) {
842 // The new callback expires before this one.
843 next = node;
844 break;
845 }
846 node = node.next;
847 } while (node !== firstCallbackNode);
848
849 if (next === null) {
850 // No callback with a later expiration was found, which means the new
851 // callback has the latest expiration in the list.
852 next = firstCallbackNode;
853 } else if (next === firstCallbackNode) {
854 // The new callback has the earliest expiration in the entire list.
855 firstCallbackNode = newNode;
856 ensureHostCallbackIsScheduled();
857 }
858
859 var previous = next.previous;
860 previous.next = next.previous = newNode;
861 newNode.next = next;
862 newNode.previous = previous;
863 }
864
865 return newNode;
866}
867
868function unstable_pauseExecution() {
869 isSchedulerPaused = true;
870}
871
872function unstable_continueExecution() {
873 isSchedulerPaused = false;
874 if (firstCallbackNode !== null) {
875 ensureHostCallbackIsScheduled();
876 }
877}
878
879function unstable_getFirstCallbackNode() {
880 return firstCallbackNode;
881}
882
883function unstable_cancelCallback(callbackNode) {
884 var next = callbackNode.next;
885 if (next === null) {
886 // Already cancelled.
887 return;
888 }
889
890 if (next === callbackNode) {
891 // This is the only scheduled callback. Clear the list.
892 firstCallbackNode = null;
893 } else {
894 // Remove the callback from its position in the list.
895 if (callbackNode === firstCallbackNode) {
896 firstCallbackNode = next;
897 }
898 var previous = callbackNode.previous;
899 previous.next = next;
900 next.previous = previous;
901 }
902
903 callbackNode.next = callbackNode.previous = null;
904}
905
906function unstable_getCurrentPriorityLevel() {
907 return currentPriorityLevel;
908}
909
910function unstable_shouldYield() {
911 return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
912}
913
914// The remaining code is essentially a polyfill for requestIdleCallback. It
915// works by scheduling a requestAnimationFrame, storing the time for the start
916// of the frame, then scheduling a postMessage which gets scheduled after paint.
917// Within the postMessage handler do as much work as possible until time + frame
918// rate. By separating the idle call into a separate event tick we ensure that
919// layout, paint and other browser work is counted against the available time.
920// The frame rate is dynamically adjusted.
921
922// We capture a local reference to any global, in case it gets polyfilled after
923// this module is initially evaluated. We want to be using a
924// consistent implementation.
925var localDate = Date;
926
927// This initialization code may run even on server environments if a component
928// just imports ReactDOM (e.g. for findDOMNode). Some environments might not
929// have setTimeout or clearTimeout. However, we always expect them to be defined
930// on the client. https://github.com/facebook/react/pull/13088
931var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
932var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
933
934// We don't expect either of these to necessarily be defined, but we will error
935// later if they are missing on the client.
936var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
937var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
938
939var getCurrentTime;
940
941// requestAnimationFrame does not run when the tab is in the background. If
942// we're backgrounded we prefer for that work to happen so that the page
943// continues to load in the background. So we also schedule a 'setTimeout' as
944// a fallback.
945// TODO: Need a better heuristic for backgrounded work.
946var ANIMATION_FRAME_TIMEOUT = 100;
947var rAFID;
948var rAFTimeoutID;
949var requestAnimationFrameWithTimeout = function (callback) {
950 // schedule rAF and also a setTimeout
951 rAFID = localRequestAnimationFrame(function (timestamp) {
952 // cancel the setTimeout
953 localClearTimeout(rAFTimeoutID);
954 callback(timestamp);
955 });
956 rAFTimeoutID = localSetTimeout(function () {
957 // cancel the requestAnimationFrame
958 localCancelAnimationFrame(rAFID);
959 callback(getCurrentTime());
960 }, ANIMATION_FRAME_TIMEOUT);
961};
962
963if (hasNativePerformanceNow) {
964 var Performance = performance;
965 getCurrentTime = function () {
966 return Performance.now();
967 };
968} else {
969 getCurrentTime = function () {
970 return localDate.now();
971 };
972}
973
974var requestHostCallback;
975var cancelHostCallback;
976var shouldYieldToHost;
977
978var globalValue = null;
979if (typeof window !== 'undefined') {
980 globalValue = window;
981} else if (typeof global !== 'undefined') {
982 globalValue = global;
983}
984
985if (globalValue && globalValue._schedMock) {
986 // Dynamic injection, only for testing purposes.
987 var globalImpl = globalValue._schedMock;
988 requestHostCallback = globalImpl[0];
989 cancelHostCallback = globalImpl[1];
990 shouldYieldToHost = globalImpl[2];
991 getCurrentTime = globalImpl[3];
992} else if (
993// If Scheduler runs in a non-DOM environment, it falls back to a naive
994// implementation using setTimeout.
995typeof window === 'undefined' ||
996// Check if MessageChannel is supported, too.
997typeof MessageChannel !== 'function') {
998 // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
999 // fallback to a naive implementation.
1000 var _callback = null;
1001 var _flushCallback = function (didTimeout) {
1002 if (_callback !== null) {
1003 try {
1004 _callback(didTimeout);
1005 } finally {
1006 _callback = null;
1007 }
1008 }
1009 };
1010 requestHostCallback = function (cb, ms) {
1011 if (_callback !== null) {
1012 // Protect against re-entrancy.
1013 setTimeout(requestHostCallback, 0, cb);
1014 } else {
1015 _callback = cb;
1016 setTimeout(_flushCallback, 0, false);
1017 }
1018 };
1019 cancelHostCallback = function () {
1020 _callback = null;
1021 };
1022 shouldYieldToHost = function () {
1023 return false;
1024 };
1025} else {
1026 if (typeof console !== 'undefined') {
1027 // TODO: Remove fb.me link
1028 if (typeof localRequestAnimationFrame !== 'function') {
1029 console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1030 }
1031 if (typeof localCancelAnimationFrame !== 'function') {
1032 console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1033 }
1034 }
1035
1036 var scheduledHostCallback = null;
1037 var isMessageEventScheduled = false;
1038 var timeoutTime = -1;
1039
1040 var isAnimationFrameScheduled = false;
1041
1042 var isFlushingHostCallback = false;
1043
1044 var frameDeadline = 0;
1045 // We start out assuming that we run at 30fps but then the heuristic tracking
1046 // will adjust this value to a faster fps if we get more frequent animation
1047 // frames.
1048 var previousFrameTime = 33;
1049 var activeFrameTime = 33;
1050
1051 shouldYieldToHost = function () {
1052 return frameDeadline <= getCurrentTime();
1053 };
1054
1055 // We use the postMessage trick to defer idle work until after the repaint.
1056 var channel = new MessageChannel();
1057 var port = channel.port2;
1058 channel.port1.onmessage = function (event) {
1059 isMessageEventScheduled = false;
1060
1061 var prevScheduledCallback = scheduledHostCallback;
1062 var prevTimeoutTime = timeoutTime;
1063 scheduledHostCallback = null;
1064 timeoutTime = -1;
1065
1066 var currentTime = getCurrentTime();
1067
1068 var didTimeout = false;
1069 if (frameDeadline - currentTime <= 0) {
1070 // There's no time left in this idle period. Check if the callback has
1071 // a timeout and whether it's been exceeded.
1072 if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
1073 // Exceeded the timeout. Invoke the callback even though there's no
1074 // time left.
1075 didTimeout = true;
1076 } else {
1077 // No timeout.
1078 if (!isAnimationFrameScheduled) {
1079 // Schedule another animation callback so we retry later.
1080 isAnimationFrameScheduled = true;
1081 requestAnimationFrameWithTimeout(animationTick);
1082 }
1083 // Exit without invoking the callback.
1084 scheduledHostCallback = prevScheduledCallback;
1085 timeoutTime = prevTimeoutTime;
1086 return;
1087 }
1088 }
1089
1090 if (prevScheduledCallback !== null) {
1091 isFlushingHostCallback = true;
1092 try {
1093 prevScheduledCallback(didTimeout);
1094 } finally {
1095 isFlushingHostCallback = false;
1096 }
1097 }
1098 };
1099
1100 var animationTick = function (rafTime) {
1101 if (scheduledHostCallback !== null) {
1102 // Eagerly schedule the next animation callback at the beginning of the
1103 // frame. If the scheduler queue is not empty at the end of the frame, it
1104 // will continue flushing inside that callback. If the queue *is* empty,
1105 // then it will exit immediately. Posting the callback at the start of the
1106 // frame ensures it's fired within the earliest possible frame. If we
1107 // waited until the end of the frame to post the callback, we risk the
1108 // browser skipping a frame and not firing the callback until the frame
1109 // after that.
1110 requestAnimationFrameWithTimeout(animationTick);
1111 } else {
1112 // No pending work. Exit.
1113 isAnimationFrameScheduled = false;
1114 return;
1115 }
1116
1117 var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
1118 if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
1119 if (nextFrameTime < 8) {
1120 // Defensive coding. We don't support higher frame rates than 120hz.
1121 // If the calculated frame time gets lower than 8, it is probably a bug.
1122 nextFrameTime = 8;
1123 }
1124 // If one frame goes long, then the next one can be short to catch up.
1125 // If two frames are short in a row, then that's an indication that we
1126 // actually have a higher frame rate than what we're currently optimizing.
1127 // We adjust our heuristic dynamically accordingly. For example, if we're
1128 // running on 120hz display or 90hz VR display.
1129 // Take the max of the two in case one of them was an anomaly due to
1130 // missed frame deadlines.
1131 activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
1132 } else {
1133 previousFrameTime = nextFrameTime;
1134 }
1135 frameDeadline = rafTime + activeFrameTime;
1136 if (!isMessageEventScheduled) {
1137 isMessageEventScheduled = true;
1138 port.postMessage(undefined);
1139 }
1140 };
1141
1142 requestHostCallback = function (callback, absoluteTimeout) {
1143 scheduledHostCallback = callback;
1144 timeoutTime = absoluteTimeout;
1145 if (isFlushingHostCallback || absoluteTimeout < 0) {
1146 // Don't wait for the next frame. Continue working ASAP, in a new event.
1147 port.postMessage(undefined);
1148 } else if (!isAnimationFrameScheduled) {
1149 // If rAF didn't already schedule one, we need to schedule a frame.
1150 // TODO: If this rAF doesn't materialize because the browser throttles, we
1151 // might want to still have setTimeout trigger rIC as a backup to ensure
1152 // that we keep performing work.
1153 isAnimationFrameScheduled = true;
1154 requestAnimationFrameWithTimeout(animationTick);
1155 }
1156 };
1157
1158 cancelHostCallback = function () {
1159 scheduledHostCallback = null;
1160 isMessageEventScheduled = false;
1161 timeoutTime = -1;
1162 };
1163}
1164
1165// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
1166
1167
1168// In some cases, StrictMode should also double-render lifecycles.
1169// This can be confusing for tests though,
1170// And it can be bad for performance in production.
1171// This feature flag can be used to control the behavior:
1172
1173
1174// To preserve the "Pause on caught exceptions" behavior of the debugger, we
1175// replay the begin phase of a failed component inside invokeGuardedCallback.
1176
1177
1178// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
1179
1180
1181// Gather advanced timing metrics for Profiler subtrees.
1182
1183
1184// Trace which interactions trigger each commit.
1185var enableSchedulerTracing = true;
1186
1187// Only used in www builds.
1188 // TODO: true? Here it might just be false.
1189
1190// Only used in www builds.
1191
1192
1193// Only used in www builds.
1194
1195
1196// React Fire: prevent the value and checked attributes from syncing
1197// with their related DOM properties
1198
1199
1200// These APIs will no longer be "unstable" in the upcoming 16.7 release,
1201// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
1202var enableStableConcurrentModeAPIs = false;
1203
1204var DEFAULT_THREAD_ID = 0;
1205
1206// Counters used to generate unique IDs.
1207var interactionIDCounter = 0;
1208var threadIDCounter = 0;
1209
1210// Set of currently traced interactions.
1211// Interactions "stack"–
1212// Meaning that newly traced interactions are appended to the previously active set.
1213// When an interaction goes out of scope, the previous set (if any) is restored.
1214var interactionsRef = null;
1215
1216// Listener(s) to notify when interactions begin and end.
1217var subscriberRef = null;
1218
1219if (enableSchedulerTracing) {
1220 interactionsRef = {
1221 current: new Set()
1222 };
1223 subscriberRef = {
1224 current: null
1225 };
1226}
1227
1228function unstable_clear(callback) {
1229 if (!enableSchedulerTracing) {
1230 return callback();
1231 }
1232
1233 var prevInteractions = interactionsRef.current;
1234 interactionsRef.current = new Set();
1235
1236 try {
1237 return callback();
1238 } finally {
1239 interactionsRef.current = prevInteractions;
1240 }
1241}
1242
1243function unstable_getCurrent() {
1244 if (!enableSchedulerTracing) {
1245 return null;
1246 } else {
1247 return interactionsRef.current;
1248 }
1249}
1250
1251function unstable_getThreadID() {
1252 return ++threadIDCounter;
1253}
1254
1255function unstable_trace(name, timestamp, callback) {
1256 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
1257
1258 if (!enableSchedulerTracing) {
1259 return callback();
1260 }
1261
1262 var interaction = {
1263 __count: 1,
1264 id: interactionIDCounter++,
1265 name: name,
1266 timestamp: timestamp
1267 };
1268
1269 var prevInteractions = interactionsRef.current;
1270
1271 // Traced interactions should stack/accumulate.
1272 // To do that, clone the current interactions.
1273 // The previous set will be restored upon completion.
1274 var interactions = new Set(prevInteractions);
1275 interactions.add(interaction);
1276 interactionsRef.current = interactions;
1277
1278 var subscriber = subscriberRef.current;
1279 var returnValue = void 0;
1280
1281 try {
1282 if (subscriber !== null) {
1283 subscriber.onInteractionTraced(interaction);
1284 }
1285 } finally {
1286 try {
1287 if (subscriber !== null) {
1288 subscriber.onWorkStarted(interactions, threadID);
1289 }
1290 } finally {
1291 try {
1292 returnValue = callback();
1293 } finally {
1294 interactionsRef.current = prevInteractions;
1295
1296 try {
1297 if (subscriber !== null) {
1298 subscriber.onWorkStopped(interactions, threadID);
1299 }
1300 } finally {
1301 interaction.__count--;
1302
1303 // If no async work was scheduled for this interaction,
1304 // Notify subscribers that it's completed.
1305 if (subscriber !== null && interaction.__count === 0) {
1306 subscriber.onInteractionScheduledWorkCompleted(interaction);
1307 }
1308 }
1309 }
1310 }
1311 }
1312
1313 return returnValue;
1314}
1315
1316function unstable_wrap(callback) {
1317 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
1318
1319 if (!enableSchedulerTracing) {
1320 return callback;
1321 }
1322
1323 var wrappedInteractions = interactionsRef.current;
1324
1325 var subscriber = subscriberRef.current;
1326 if (subscriber !== null) {
1327 subscriber.onWorkScheduled(wrappedInteractions, threadID);
1328 }
1329
1330 // Update the pending async work count for the current interactions.
1331 // Update after calling subscribers in case of error.
1332 wrappedInteractions.forEach(function (interaction) {
1333 interaction.__count++;
1334 });
1335
1336 var hasRun = false;
1337
1338 function wrapped() {
1339 var prevInteractions = interactionsRef.current;
1340 interactionsRef.current = wrappedInteractions;
1341
1342 subscriber = subscriberRef.current;
1343
1344 try {
1345 var returnValue = void 0;
1346
1347 try {
1348 if (subscriber !== null) {
1349 subscriber.onWorkStarted(wrappedInteractions, threadID);
1350 }
1351 } finally {
1352 try {
1353 returnValue = callback.apply(undefined, arguments);
1354 } finally {
1355 interactionsRef.current = prevInteractions;
1356
1357 if (subscriber !== null) {
1358 subscriber.onWorkStopped(wrappedInteractions, threadID);
1359 }
1360 }
1361 }
1362
1363 return returnValue;
1364 } finally {
1365 if (!hasRun) {
1366 // We only expect a wrapped function to be executed once,
1367 // But in the event that it's executed more than once–
1368 // Only decrement the outstanding interaction counts once.
1369 hasRun = true;
1370
1371 // Update pending async counts for all wrapped interactions.
1372 // If this was the last scheduled async work for any of them,
1373 // Mark them as completed.
1374 wrappedInteractions.forEach(function (interaction) {
1375 interaction.__count--;
1376
1377 if (subscriber !== null && interaction.__count === 0) {
1378 subscriber.onInteractionScheduledWorkCompleted(interaction);
1379 }
1380 });
1381 }
1382 }
1383 }
1384
1385 wrapped.cancel = function cancel() {
1386 subscriber = subscriberRef.current;
1387
1388 try {
1389 if (subscriber !== null) {
1390 subscriber.onWorkCanceled(wrappedInteractions, threadID);
1391 }
1392 } finally {
1393 // Update pending async counts for all wrapped interactions.
1394 // If this was the last scheduled async work for any of them,
1395 // Mark them as completed.
1396 wrappedInteractions.forEach(function (interaction) {
1397 interaction.__count--;
1398
1399 if (subscriber && interaction.__count === 0) {
1400 subscriber.onInteractionScheduledWorkCompleted(interaction);
1401 }
1402 });
1403 }
1404 };
1405
1406 return wrapped;
1407}
1408
1409var subscribers = null;
1410if (enableSchedulerTracing) {
1411 subscribers = new Set();
1412}
1413
1414function unstable_subscribe(subscriber) {
1415 if (enableSchedulerTracing) {
1416 subscribers.add(subscriber);
1417
1418 if (subscribers.size === 1) {
1419 subscriberRef.current = {
1420 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
1421 onInteractionTraced: onInteractionTraced,
1422 onWorkCanceled: onWorkCanceled,
1423 onWorkScheduled: onWorkScheduled,
1424 onWorkStarted: onWorkStarted,
1425 onWorkStopped: onWorkStopped
1426 };
1427 }
1428 }
1429}
1430
1431function unstable_unsubscribe(subscriber) {
1432 if (enableSchedulerTracing) {
1433 subscribers.delete(subscriber);
1434
1435 if (subscribers.size === 0) {
1436 subscriberRef.current = null;
1437 }
1438 }
1439}
1440
1441function onInteractionTraced(interaction) {
1442 var didCatchError = false;
1443 var caughtError = null;
1444
1445 subscribers.forEach(function (subscriber) {
1446 try {
1447 subscriber.onInteractionTraced(interaction);
1448 } catch (error) {
1449 if (!didCatchError) {
1450 didCatchError = true;
1451 caughtError = error;
1452 }
1453 }
1454 });
1455
1456 if (didCatchError) {
1457 throw caughtError;
1458 }
1459}
1460
1461function onInteractionScheduledWorkCompleted(interaction) {
1462 var didCatchError = false;
1463 var caughtError = null;
1464
1465 subscribers.forEach(function (subscriber) {
1466 try {
1467 subscriber.onInteractionScheduledWorkCompleted(interaction);
1468 } catch (error) {
1469 if (!didCatchError) {
1470 didCatchError = true;
1471 caughtError = error;
1472 }
1473 }
1474 });
1475
1476 if (didCatchError) {
1477 throw caughtError;
1478 }
1479}
1480
1481function onWorkScheduled(interactions, threadID) {
1482 var didCatchError = false;
1483 var caughtError = null;
1484
1485 subscribers.forEach(function (subscriber) {
1486 try {
1487 subscriber.onWorkScheduled(interactions, threadID);
1488 } catch (error) {
1489 if (!didCatchError) {
1490 didCatchError = true;
1491 caughtError = error;
1492 }
1493 }
1494 });
1495
1496 if (didCatchError) {
1497 throw caughtError;
1498 }
1499}
1500
1501function onWorkStarted(interactions, threadID) {
1502 var didCatchError = false;
1503 var caughtError = null;
1504
1505 subscribers.forEach(function (subscriber) {
1506 try {
1507 subscriber.onWorkStarted(interactions, threadID);
1508 } catch (error) {
1509 if (!didCatchError) {
1510 didCatchError = true;
1511 caughtError = error;
1512 }
1513 }
1514 });
1515
1516 if (didCatchError) {
1517 throw caughtError;
1518 }
1519}
1520
1521function onWorkStopped(interactions, threadID) {
1522 var didCatchError = false;
1523 var caughtError = null;
1524
1525 subscribers.forEach(function (subscriber) {
1526 try {
1527 subscriber.onWorkStopped(interactions, threadID);
1528 } catch (error) {
1529 if (!didCatchError) {
1530 didCatchError = true;
1531 caughtError = error;
1532 }
1533 }
1534 });
1535
1536 if (didCatchError) {
1537 throw caughtError;
1538 }
1539}
1540
1541function onWorkCanceled(interactions, threadID) {
1542 var didCatchError = false;
1543 var caughtError = null;
1544
1545 subscribers.forEach(function (subscriber) {
1546 try {
1547 subscriber.onWorkCanceled(interactions, threadID);
1548 } catch (error) {
1549 if (!didCatchError) {
1550 didCatchError = true;
1551 caughtError = error;
1552 }
1553 }
1554 });
1555
1556 if (didCatchError) {
1557 throw caughtError;
1558 }
1559}
1560
1561/**
1562 * Keeps track of the current dispatcher.
1563 */
1564var ReactCurrentDispatcher = {
1565 /**
1566 * @internal
1567 * @type {ReactComponent}
1568 */
1569 current: null
1570};
1571
1572/**
1573 * Keeps track of the current owner.
1574 *
1575 * The current owner is the component who should own any components that are
1576 * currently being constructed.
1577 */
1578var ReactCurrentOwner = {
1579 /**
1580 * @internal
1581 * @type {ReactComponent}
1582 */
1583 current: null
1584};
1585
1586var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
1587
1588var describeComponentFrame = function (name, source, ownerName) {
1589 var sourceInfo = '';
1590 if (source) {
1591 var path = source.fileName;
1592 var fileName = path.replace(BEFORE_SLASH_RE, '');
1593 {
1594 // In DEV, include code for a common special case:
1595 // prefer "folder/index.js" instead of just "index.js".
1596 if (/^index\./.test(fileName)) {
1597 var match = path.match(BEFORE_SLASH_RE);
1598 if (match) {
1599 var pathBeforeSlash = match[1];
1600 if (pathBeforeSlash) {
1601 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
1602 fileName = folderName + '/' + fileName;
1603 }
1604 }
1605 }
1606 }
1607 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
1608 } else if (ownerName) {
1609 sourceInfo = ' (created by ' + ownerName + ')';
1610 }
1611 return '\n in ' + (name || 'Unknown') + sourceInfo;
1612};
1613
1614var Resolved = 1;
1615
1616
1617function refineResolvedLazyComponent(lazyComponent) {
1618 return lazyComponent._status === Resolved ? lazyComponent._result : null;
1619}
1620
1621function getWrappedName(outerType, innerType, wrapperName) {
1622 var functionName = innerType.displayName || innerType.name || '';
1623 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
1624}
1625
1626function getComponentName(type) {
1627 if (type == null) {
1628 // Host root, text node or just invalid type.
1629 return null;
1630 }
1631 {
1632 if (typeof type.tag === 'number') {
1633 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
1634 }
1635 }
1636 if (typeof type === 'function') {
1637 return type.displayName || type.name || null;
1638 }
1639 if (typeof type === 'string') {
1640 return type;
1641 }
1642 switch (type) {
1643 case REACT_CONCURRENT_MODE_TYPE:
1644 return 'ConcurrentMode';
1645 case REACT_FRAGMENT_TYPE:
1646 return 'Fragment';
1647 case REACT_PORTAL_TYPE:
1648 return 'Portal';
1649 case REACT_PROFILER_TYPE:
1650 return 'Profiler';
1651 case REACT_STRICT_MODE_TYPE:
1652 return 'StrictMode';
1653 case REACT_SUSPENSE_TYPE:
1654 return 'Suspense';
1655 }
1656 if (typeof type === 'object') {
1657 switch (type.$$typeof) {
1658 case REACT_CONTEXT_TYPE:
1659 return 'Context.Consumer';
1660 case REACT_PROVIDER_TYPE:
1661 return 'Context.Provider';
1662 case REACT_FORWARD_REF_TYPE:
1663 return getWrappedName(type, type.render, 'ForwardRef');
1664 case REACT_MEMO_TYPE:
1665 return getComponentName(type.type);
1666 case REACT_LAZY_TYPE:
1667 {
1668 var thenable = type;
1669 var resolvedThenable = refineResolvedLazyComponent(thenable);
1670 if (resolvedThenable) {
1671 return getComponentName(resolvedThenable);
1672 }
1673 }
1674 }
1675 }
1676 return null;
1677}
1678
1679var ReactDebugCurrentFrame = {};
1680
1681var currentlyValidatingElement = null;
1682
1683function setCurrentlyValidatingElement(element) {
1684 {
1685 currentlyValidatingElement = element;
1686 }
1687}
1688
1689{
1690 // Stack implementation injected by the current renderer.
1691 ReactDebugCurrentFrame.getCurrentStack = null;
1692
1693 ReactDebugCurrentFrame.getStackAddendum = function () {
1694 var stack = '';
1695
1696 // Add an extra top frame while an element is being validated
1697 if (currentlyValidatingElement) {
1698 var name = getComponentName(currentlyValidatingElement.type);
1699 var owner = currentlyValidatingElement._owner;
1700 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
1701 }
1702
1703 // Delegate to the injected renderer-specific implementation
1704 var impl = ReactDebugCurrentFrame.getCurrentStack;
1705 if (impl) {
1706 stack += impl() || '';
1707 }
1708
1709 return stack;
1710 };
1711}
1712
1713var ReactSharedInternals = {
1714 ReactCurrentDispatcher: ReactCurrentDispatcher,
1715 ReactCurrentOwner: ReactCurrentOwner,
1716 // Used by renderers to avoid bundling object-assign twice in UMD bundles:
1717 assign: objectAssign
1718};
1719
1720{
1721 // Re-export the schedule API(s) for UMD bundles.
1722 // This avoids introducing a dependency on a new UMD global in a minor update,
1723 // Since that would be a breaking change (e.g. for all existing CodeSandboxes).
1724 // This re-export is only required for UMD bundles;
1725 // CJS bundles use the shared NPM package.
1726 objectAssign(ReactSharedInternals, {
1727 Scheduler: {
1728 unstable_cancelCallback: unstable_cancelCallback,
1729 unstable_shouldYield: unstable_shouldYield,
1730 unstable_now: getCurrentTime,
1731 unstable_scheduleCallback: unstable_scheduleCallback,
1732 unstable_runWithPriority: unstable_runWithPriority,
1733 unstable_next: unstable_next,
1734 unstable_wrapCallback: unstable_wrapCallback,
1735 unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
1736 unstable_pauseExecution: unstable_pauseExecution,
1737 unstable_continueExecution: unstable_continueExecution,
1738 unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel,
1739 unstable_IdlePriority: IdlePriority,
1740 unstable_ImmediatePriority: ImmediatePriority,
1741 unstable_LowPriority: LowPriority,
1742 unstable_NormalPriority: NormalPriority,
1743 unstable_UserBlockingPriority: UserBlockingPriority
1744 },
1745 SchedulerTracing: {
1746 __interactionsRef: interactionsRef,
1747 __subscriberRef: subscriberRef,
1748 unstable_clear: unstable_clear,
1749 unstable_getCurrent: unstable_getCurrent,
1750 unstable_getThreadID: unstable_getThreadID,
1751 unstable_subscribe: unstable_subscribe,
1752 unstable_trace: unstable_trace,
1753 unstable_unsubscribe: unstable_unsubscribe,
1754 unstable_wrap: unstable_wrap
1755 }
1756 });
1757}
1758
1759{
1760 objectAssign(ReactSharedInternals, {
1761 // These should not be included in production.
1762 ReactDebugCurrentFrame: ReactDebugCurrentFrame,
1763 // Shim for React DOM 16.0.0 which still destructured (but not used) this.
1764 // TODO: remove in React 17.0.
1765 ReactComponentTreeHook: {}
1766 });
1767}
1768
1769/**
1770 * Similar to invariant but only logs a warning if the condition is not met.
1771 * This can be used to log issues in development environments in critical
1772 * paths. Removing the logging code for production environments will keep the
1773 * same logic and follow the same code paths.
1774 */
1775
1776var warning = warningWithoutStack$1;
1777
1778{
1779 warning = function (condition, format) {
1780 if (condition) {
1781 return;
1782 }
1783 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1784 var stack = ReactDebugCurrentFrame.getStackAddendum();
1785 // eslint-disable-next-line react-internal/warning-and-invariant-args
1786
1787 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1788 args[_key - 2] = arguments[_key];
1789 }
1790
1791 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
1792 };
1793}
1794
1795var warning$1 = warning;
1796
1797var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1798
1799var RESERVED_PROPS = {
1800 key: true,
1801 ref: true,
1802 __self: true,
1803 __source: true
1804};
1805
1806var specialPropKeyWarningShown = void 0;
1807var specialPropRefWarningShown = void 0;
1808
1809function hasValidRef(config) {
1810 {
1811 if (hasOwnProperty$1.call(config, 'ref')) {
1812 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
1813 if (getter && getter.isReactWarning) {
1814 return false;
1815 }
1816 }
1817 }
1818 return config.ref !== undefined;
1819}
1820
1821function hasValidKey(config) {
1822 {
1823 if (hasOwnProperty$1.call(config, 'key')) {
1824 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
1825 if (getter && getter.isReactWarning) {
1826 return false;
1827 }
1828 }
1829 }
1830 return config.key !== undefined;
1831}
1832
1833function defineKeyPropWarningGetter(props, displayName) {
1834 var warnAboutAccessingKey = function () {
1835 if (!specialPropKeyWarningShown) {
1836 specialPropKeyWarningShown = true;
1837 warningWithoutStack$1(false, '%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://fb.me/react-special-props)', displayName);
1838 }
1839 };
1840 warnAboutAccessingKey.isReactWarning = true;
1841 Object.defineProperty(props, 'key', {
1842 get: warnAboutAccessingKey,
1843 configurable: true
1844 });
1845}
1846
1847function defineRefPropWarningGetter(props, displayName) {
1848 var warnAboutAccessingRef = function () {
1849 if (!specialPropRefWarningShown) {
1850 specialPropRefWarningShown = true;
1851 warningWithoutStack$1(false, '%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://fb.me/react-special-props)', displayName);
1852 }
1853 };
1854 warnAboutAccessingRef.isReactWarning = true;
1855 Object.defineProperty(props, 'ref', {
1856 get: warnAboutAccessingRef,
1857 configurable: true
1858 });
1859}
1860
1861/**
1862 * Factory method to create a new React element. This no longer adheres to
1863 * the class pattern, so do not use new to call it. Also, no instanceof check
1864 * will work. Instead test $$typeof field against Symbol.for('react.element') to check
1865 * if something is a React Element.
1866 *
1867 * @param {*} type
1868 * @param {*} key
1869 * @param {string|object} ref
1870 * @param {*} self A *temporary* helper to detect places where `this` is
1871 * different from the `owner` when React.createElement is called, so that we
1872 * can warn. We want to get rid of owner and replace string `ref`s with arrow
1873 * functions, and as long as `this` and owner are the same, there will be no
1874 * change in behavior.
1875 * @param {*} source An annotation object (added by a transpiler or otherwise)
1876 * indicating filename, line number, and/or other information.
1877 * @param {*} owner
1878 * @param {*} props
1879 * @internal
1880 */
1881var ReactElement = function (type, key, ref, self, source, owner, props) {
1882 var element = {
1883 // This tag allows us to uniquely identify this as a React Element
1884 $$typeof: REACT_ELEMENT_TYPE,
1885
1886 // Built-in properties that belong on the element
1887 type: type,
1888 key: key,
1889 ref: ref,
1890 props: props,
1891
1892 // Record the component responsible for creating this element.
1893 _owner: owner
1894 };
1895
1896 {
1897 // The validation flag is currently mutative. We put it on
1898 // an external backing store so that we can freeze the whole object.
1899 // This can be replaced with a WeakMap once they are implemented in
1900 // commonly used development environments.
1901 element._store = {};
1902
1903 // To make comparing ReactElements easier for testing purposes, we make
1904 // the validation flag non-enumerable (where possible, which should
1905 // include every environment we run tests in), so the test framework
1906 // ignores it.
1907 Object.defineProperty(element._store, 'validated', {
1908 configurable: false,
1909 enumerable: false,
1910 writable: true,
1911 value: false
1912 });
1913 // self and source are DEV only properties.
1914 Object.defineProperty(element, '_self', {
1915 configurable: false,
1916 enumerable: false,
1917 writable: false,
1918 value: self
1919 });
1920 // Two elements created in two different places should be considered
1921 // equal for testing purposes and therefore we hide it from enumeration.
1922 Object.defineProperty(element, '_source', {
1923 configurable: false,
1924 enumerable: false,
1925 writable: false,
1926 value: source
1927 });
1928 if (Object.freeze) {
1929 Object.freeze(element.props);
1930 Object.freeze(element);
1931 }
1932 }
1933
1934 return element;
1935};
1936
1937/**
1938 * Create and return a new ReactElement of the given type.
1939 * See https://reactjs.org/docs/react-api.html#createelement
1940 */
1941function createElement(type, config, children) {
1942 var propName = void 0;
1943
1944 // Reserved names are extracted
1945 var props = {};
1946
1947 var key = null;
1948 var ref = null;
1949 var self = null;
1950 var source = null;
1951
1952 if (config != null) {
1953 if (hasValidRef(config)) {
1954 ref = config.ref;
1955 }
1956 if (hasValidKey(config)) {
1957 key = '' + config.key;
1958 }
1959
1960 self = config.__self === undefined ? null : config.__self;
1961 source = config.__source === undefined ? null : config.__source;
1962 // Remaining properties are added to a new props object
1963 for (propName in config) {
1964 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1965 props[propName] = config[propName];
1966 }
1967 }
1968 }
1969
1970 // Children can be more than one argument, and those are transferred onto
1971 // the newly allocated props object.
1972 var childrenLength = arguments.length - 2;
1973 if (childrenLength === 1) {
1974 props.children = children;
1975 } else if (childrenLength > 1) {
1976 var childArray = Array(childrenLength);
1977 for (var i = 0; i < childrenLength; i++) {
1978 childArray[i] = arguments[i + 2];
1979 }
1980 {
1981 if (Object.freeze) {
1982 Object.freeze(childArray);
1983 }
1984 }
1985 props.children = childArray;
1986 }
1987
1988 // Resolve default props
1989 if (type && type.defaultProps) {
1990 var defaultProps = type.defaultProps;
1991 for (propName in defaultProps) {
1992 if (props[propName] === undefined) {
1993 props[propName] = defaultProps[propName];
1994 }
1995 }
1996 }
1997 {
1998 if (key || ref) {
1999 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
2000 if (key) {
2001 defineKeyPropWarningGetter(props, displayName);
2002 }
2003 if (ref) {
2004 defineRefPropWarningGetter(props, displayName);
2005 }
2006 }
2007 }
2008 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
2009}
2010
2011/**
2012 * Return a function that produces ReactElements of a given type.
2013 * See https://reactjs.org/docs/react-api.html#createfactory
2014 */
2015
2016
2017function cloneAndReplaceKey(oldElement, newKey) {
2018 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
2019
2020 return newElement;
2021}
2022
2023/**
2024 * Clone and return a new ReactElement using element as the starting point.
2025 * See https://reactjs.org/docs/react-api.html#cloneelement
2026 */
2027function cloneElement(element, config, children) {
2028 !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
2029
2030 var propName = void 0;
2031
2032 // Original props are copied
2033 var props = objectAssign({}, element.props);
2034
2035 // Reserved names are extracted
2036 var key = element.key;
2037 var ref = element.ref;
2038 // Self is preserved since the owner is preserved.
2039 var self = element._self;
2040 // Source is preserved since cloneElement is unlikely to be targeted by a
2041 // transpiler, and the original source is probably a better indicator of the
2042 // true owner.
2043 var source = element._source;
2044
2045 // Owner will be preserved, unless ref is overridden
2046 var owner = element._owner;
2047
2048 if (config != null) {
2049 if (hasValidRef(config)) {
2050 // Silently steal the ref from the parent.
2051 ref = config.ref;
2052 owner = ReactCurrentOwner.current;
2053 }
2054 if (hasValidKey(config)) {
2055 key = '' + config.key;
2056 }
2057
2058 // Remaining properties override existing props
2059 var defaultProps = void 0;
2060 if (element.type && element.type.defaultProps) {
2061 defaultProps = element.type.defaultProps;
2062 }
2063 for (propName in config) {
2064 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
2065 if (config[propName] === undefined && defaultProps !== undefined) {
2066 // Resolve default props
2067 props[propName] = defaultProps[propName];
2068 } else {
2069 props[propName] = config[propName];
2070 }
2071 }
2072 }
2073 }
2074
2075 // Children can be more than one argument, and those are transferred onto
2076 // the newly allocated props object.
2077 var childrenLength = arguments.length - 2;
2078 if (childrenLength === 1) {
2079 props.children = children;
2080 } else if (childrenLength > 1) {
2081 var childArray = Array(childrenLength);
2082 for (var i = 0; i < childrenLength; i++) {
2083 childArray[i] = arguments[i + 2];
2084 }
2085 props.children = childArray;
2086 }
2087
2088 return ReactElement(element.type, key, ref, self, source, owner, props);
2089}
2090
2091/**
2092 * Verifies the object is a ReactElement.
2093 * See https://reactjs.org/docs/react-api.html#isvalidelement
2094 * @param {?object} object
2095 * @return {boolean} True if `object` is a ReactElement.
2096 * @final
2097 */
2098function isValidElement(object) {
2099 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2100}
2101
2102var SEPARATOR = '.';
2103var SUBSEPARATOR = ':';
2104
2105/**
2106 * Escape and wrap key so it is safe to use as a reactid
2107 *
2108 * @param {string} key to be escaped.
2109 * @return {string} the escaped key.
2110 */
2111function escape(key) {
2112 var escapeRegex = /[=:]/g;
2113 var escaperLookup = {
2114 '=': '=0',
2115 ':': '=2'
2116 };
2117 var escapedString = ('' + key).replace(escapeRegex, function (match) {
2118 return escaperLookup[match];
2119 });
2120
2121 return '$' + escapedString;
2122}
2123
2124/**
2125 * TODO: Test that a single child and an array with one item have the same key
2126 * pattern.
2127 */
2128
2129var didWarnAboutMaps = false;
2130
2131var userProvidedKeyEscapeRegex = /\/+/g;
2132function escapeUserProvidedKey(text) {
2133 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
2134}
2135
2136var POOL_SIZE = 10;
2137var traverseContextPool = [];
2138function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
2139 if (traverseContextPool.length) {
2140 var traverseContext = traverseContextPool.pop();
2141 traverseContext.result = mapResult;
2142 traverseContext.keyPrefix = keyPrefix;
2143 traverseContext.func = mapFunction;
2144 traverseContext.context = mapContext;
2145 traverseContext.count = 0;
2146 return traverseContext;
2147 } else {
2148 return {
2149 result: mapResult,
2150 keyPrefix: keyPrefix,
2151 func: mapFunction,
2152 context: mapContext,
2153 count: 0
2154 };
2155 }
2156}
2157
2158function releaseTraverseContext(traverseContext) {
2159 traverseContext.result = null;
2160 traverseContext.keyPrefix = null;
2161 traverseContext.func = null;
2162 traverseContext.context = null;
2163 traverseContext.count = 0;
2164 if (traverseContextPool.length < POOL_SIZE) {
2165 traverseContextPool.push(traverseContext);
2166 }
2167}
2168
2169/**
2170 * @param {?*} children Children tree container.
2171 * @param {!string} nameSoFar Name of the key path so far.
2172 * @param {!function} callback Callback to invoke with each child found.
2173 * @param {?*} traverseContext Used to pass information throughout the traversal
2174 * process.
2175 * @return {!number} The number of children in this subtree.
2176 */
2177function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
2178 var type = typeof children;
2179
2180 if (type === 'undefined' || type === 'boolean') {
2181 // All of the above are perceived as null.
2182 children = null;
2183 }
2184
2185 var invokeCallback = false;
2186
2187 if (children === null) {
2188 invokeCallback = true;
2189 } else {
2190 switch (type) {
2191 case 'string':
2192 case 'number':
2193 invokeCallback = true;
2194 break;
2195 case 'object':
2196 switch (children.$$typeof) {
2197 case REACT_ELEMENT_TYPE:
2198 case REACT_PORTAL_TYPE:
2199 invokeCallback = true;
2200 }
2201 }
2202 }
2203
2204 if (invokeCallback) {
2205 callback(traverseContext, children,
2206 // If it's the only child, treat the name as if it was wrapped in an array
2207 // so that it's consistent if the number of children grows.
2208 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
2209 return 1;
2210 }
2211
2212 var child = void 0;
2213 var nextName = void 0;
2214 var subtreeCount = 0; // Count of children found in the current subtree.
2215 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
2216
2217 if (Array.isArray(children)) {
2218 for (var i = 0; i < children.length; i++) {
2219 child = children[i];
2220 nextName = nextNamePrefix + getComponentKey(child, i);
2221 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2222 }
2223 } else {
2224 var iteratorFn = getIteratorFn(children);
2225 if (typeof iteratorFn === 'function') {
2226 {
2227 // Warn about using Maps as children
2228 if (iteratorFn === children.entries) {
2229 !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
2230 didWarnAboutMaps = true;
2231 }
2232 }
2233
2234 var iterator = iteratorFn.call(children);
2235 var step = void 0;
2236 var ii = 0;
2237 while (!(step = iterator.next()).done) {
2238 child = step.value;
2239 nextName = nextNamePrefix + getComponentKey(child, ii++);
2240 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2241 }
2242 } else if (type === 'object') {
2243 var addendum = '';
2244 {
2245 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
2246 }
2247 var childrenString = '' + children;
2248 invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
2249 }
2250 }
2251
2252 return subtreeCount;
2253}
2254
2255/**
2256 * Traverses children that are typically specified as `props.children`, but
2257 * might also be specified through attributes:
2258 *
2259 * - `traverseAllChildren(this.props.children, ...)`
2260 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
2261 *
2262 * The `traverseContext` is an optional argument that is passed through the
2263 * entire traversal. It can be used to store accumulations or anything else that
2264 * the callback might find relevant.
2265 *
2266 * @param {?*} children Children tree object.
2267 * @param {!function} callback To invoke upon traversing each child.
2268 * @param {?*} traverseContext Context for traversal.
2269 * @return {!number} The number of children in this subtree.
2270 */
2271function traverseAllChildren(children, callback, traverseContext) {
2272 if (children == null) {
2273 return 0;
2274 }
2275
2276 return traverseAllChildrenImpl(children, '', callback, traverseContext);
2277}
2278
2279/**
2280 * Generate a key string that identifies a component within a set.
2281 *
2282 * @param {*} component A component that could contain a manual key.
2283 * @param {number} index Index that is used if a manual key is not provided.
2284 * @return {string}
2285 */
2286function getComponentKey(component, index) {
2287 // Do some typechecking here since we call this blindly. We want to ensure
2288 // that we don't block potential future ES APIs.
2289 if (typeof component === 'object' && component !== null && component.key != null) {
2290 // Explicit key
2291 return escape(component.key);
2292 }
2293 // Implicit key determined by the index in the set
2294 return index.toString(36);
2295}
2296
2297function forEachSingleChild(bookKeeping, child, name) {
2298 var func = bookKeeping.func,
2299 context = bookKeeping.context;
2300
2301 func.call(context, child, bookKeeping.count++);
2302}
2303
2304/**
2305 * Iterates through children that are typically specified as `props.children`.
2306 *
2307 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
2308 *
2309 * The provided forEachFunc(child, index) will be called for each
2310 * leaf child.
2311 *
2312 * @param {?*} children Children tree container.
2313 * @param {function(*, int)} forEachFunc
2314 * @param {*} forEachContext Context for forEachContext.
2315 */
2316function forEachChildren(children, forEachFunc, forEachContext) {
2317 if (children == null) {
2318 return children;
2319 }
2320 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
2321 traverseAllChildren(children, forEachSingleChild, traverseContext);
2322 releaseTraverseContext(traverseContext);
2323}
2324
2325function mapSingleChildIntoContext(bookKeeping, child, childKey) {
2326 var result = bookKeeping.result,
2327 keyPrefix = bookKeeping.keyPrefix,
2328 func = bookKeeping.func,
2329 context = bookKeeping.context;
2330
2331
2332 var mappedChild = func.call(context, child, bookKeeping.count++);
2333 if (Array.isArray(mappedChild)) {
2334 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
2335 return c;
2336 });
2337 } else if (mappedChild != null) {
2338 if (isValidElement(mappedChild)) {
2339 mappedChild = cloneAndReplaceKey(mappedChild,
2340 // Keep both the (mapped) and old keys if they differ, just as
2341 // traverseAllChildren used to do for objects as children
2342 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
2343 }
2344 result.push(mappedChild);
2345 }
2346}
2347
2348function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
2349 var escapedPrefix = '';
2350 if (prefix != null) {
2351 escapedPrefix = escapeUserProvidedKey(prefix) + '/';
2352 }
2353 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
2354 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
2355 releaseTraverseContext(traverseContext);
2356}
2357
2358/**
2359 * Maps children that are typically specified as `props.children`.
2360 *
2361 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
2362 *
2363 * The provided mapFunction(child, key, index) will be called for each
2364 * leaf child.
2365 *
2366 * @param {?*} children Children tree container.
2367 * @param {function(*, int)} func The map function.
2368 * @param {*} context Context for mapFunction.
2369 * @return {object} Object containing the ordered map of results.
2370 */
2371function mapChildren(children, func, context) {
2372 if (children == null) {
2373 return children;
2374 }
2375 var result = [];
2376 mapIntoWithKeyPrefixInternal(children, result, null, func, context);
2377 return result;
2378}
2379
2380/**
2381 * Count the number of children that are typically specified as
2382 * `props.children`.
2383 *
2384 * See https://reactjs.org/docs/react-api.html#reactchildrencount
2385 *
2386 * @param {?*} children Children tree container.
2387 * @return {number} The number of children.
2388 */
2389function countChildren(children) {
2390 return traverseAllChildren(children, function () {
2391 return null;
2392 }, null);
2393}
2394
2395/**
2396 * Flatten a children object (typically specified as `props.children`) and
2397 * return an array with appropriately re-keyed children.
2398 *
2399 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
2400 */
2401function toArray(children) {
2402 var result = [];
2403 mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
2404 return child;
2405 });
2406 return result;
2407}
2408
2409/**
2410 * Returns the first child in a collection of children and verifies that there
2411 * is only one child in the collection.
2412 *
2413 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
2414 *
2415 * The current implementation of this function assumes that a single child gets
2416 * passed without a wrapper, but the purpose of this helper function is to
2417 * abstract away the particular structure of children.
2418 *
2419 * @param {?object} children Child collection structure.
2420 * @return {ReactElement} The first and only `ReactElement` contained in the
2421 * structure.
2422 */
2423function onlyChild(children) {
2424 !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
2425 return children;
2426}
2427
2428function createContext(defaultValue, calculateChangedBits) {
2429 if (calculateChangedBits === undefined) {
2430 calculateChangedBits = null;
2431 } else {
2432 {
2433 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
2434 }
2435 }
2436
2437 var context = {
2438 $$typeof: REACT_CONTEXT_TYPE,
2439 _calculateChangedBits: calculateChangedBits,
2440 // As a workaround to support multiple concurrent renderers, we categorize
2441 // some renderers as primary and others as secondary. We only expect
2442 // there to be two concurrent renderers at most: React Native (primary) and
2443 // Fabric (secondary); React DOM (primary) and React ART (secondary).
2444 // Secondary renderers store their context values on separate fields.
2445 _currentValue: defaultValue,
2446 _currentValue2: defaultValue,
2447 // Used to track how many concurrent renderers this context currently
2448 // supports within in a single renderer. Such as parallel server rendering.
2449 _threadCount: 0,
2450 // These are circular
2451 Provider: null,
2452 Consumer: null
2453 };
2454
2455 context.Provider = {
2456 $$typeof: REACT_PROVIDER_TYPE,
2457 _context: context
2458 };
2459
2460 var hasWarnedAboutUsingNestedContextConsumers = false;
2461 var hasWarnedAboutUsingConsumerProvider = false;
2462
2463 {
2464 // A separate object, but proxies back to the original context object for
2465 // backwards compatibility. It has a different $$typeof, so we can properly
2466 // warn for the incorrect usage of Context as a Consumer.
2467 var Consumer = {
2468 $$typeof: REACT_CONTEXT_TYPE,
2469 _context: context,
2470 _calculateChangedBits: context._calculateChangedBits
2471 };
2472 // $FlowFixMe: Flow complains about not setting a value, which is intentional here
2473 Object.defineProperties(Consumer, {
2474 Provider: {
2475 get: function () {
2476 if (!hasWarnedAboutUsingConsumerProvider) {
2477 hasWarnedAboutUsingConsumerProvider = true;
2478 warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
2479 }
2480 return context.Provider;
2481 },
2482 set: function (_Provider) {
2483 context.Provider = _Provider;
2484 }
2485 },
2486 _currentValue: {
2487 get: function () {
2488 return context._currentValue;
2489 },
2490 set: function (_currentValue) {
2491 context._currentValue = _currentValue;
2492 }
2493 },
2494 _currentValue2: {
2495 get: function () {
2496 return context._currentValue2;
2497 },
2498 set: function (_currentValue2) {
2499 context._currentValue2 = _currentValue2;
2500 }
2501 },
2502 _threadCount: {
2503 get: function () {
2504 return context._threadCount;
2505 },
2506 set: function (_threadCount) {
2507 context._threadCount = _threadCount;
2508 }
2509 },
2510 Consumer: {
2511 get: function () {
2512 if (!hasWarnedAboutUsingNestedContextConsumers) {
2513 hasWarnedAboutUsingNestedContextConsumers = true;
2514 warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
2515 }
2516 return context.Consumer;
2517 }
2518 }
2519 });
2520 // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
2521 context.Consumer = Consumer;
2522 }
2523
2524 {
2525 context._currentRenderer = null;
2526 context._currentRenderer2 = null;
2527 }
2528
2529 return context;
2530}
2531
2532function lazy(ctor) {
2533 var lazyType = {
2534 $$typeof: REACT_LAZY_TYPE,
2535 _ctor: ctor,
2536 // React uses these fields to store the result.
2537 _status: -1,
2538 _result: null
2539 };
2540
2541 {
2542 // In production, this would just set it on the object.
2543 var defaultProps = void 0;
2544 var propTypes = void 0;
2545 Object.defineProperties(lazyType, {
2546 defaultProps: {
2547 configurable: true,
2548 get: function () {
2549 return defaultProps;
2550 },
2551 set: function (newDefaultProps) {
2552 warning$1(false, '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.');
2553 defaultProps = newDefaultProps;
2554 // Match production behavior more closely:
2555 Object.defineProperty(lazyType, 'defaultProps', {
2556 enumerable: true
2557 });
2558 }
2559 },
2560 propTypes: {
2561 configurable: true,
2562 get: function () {
2563 return propTypes;
2564 },
2565 set: function (newPropTypes) {
2566 warning$1(false, '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.');
2567 propTypes = newPropTypes;
2568 // Match production behavior more closely:
2569 Object.defineProperty(lazyType, 'propTypes', {
2570 enumerable: true
2571 });
2572 }
2573 }
2574 });
2575 }
2576
2577 return lazyType;
2578}
2579
2580function forwardRef(render) {
2581 {
2582 if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
2583 warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
2584 } else if (typeof render !== 'function') {
2585 warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
2586 } else {
2587 !(
2588 // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
2589 render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, '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.') : void 0;
2590 }
2591
2592 if (render != null) {
2593 !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
2594 }
2595 }
2596
2597 return {
2598 $$typeof: REACT_FORWARD_REF_TYPE,
2599 render: render
2600 };
2601}
2602
2603function isValidElementType(type) {
2604 return typeof type === 'string' || typeof type === 'function' ||
2605 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2606 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (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);
2607}
2608
2609function memo(type, compare) {
2610 {
2611 if (!isValidElementType(type)) {
2612 warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
2613 }
2614 }
2615 return {
2616 $$typeof: REACT_MEMO_TYPE,
2617 type: type,
2618 compare: compare === undefined ? null : compare
2619 };
2620}
2621
2622function resolveDispatcher() {
2623 var dispatcher = ReactCurrentDispatcher.current;
2624 !(dispatcher !== null) ? invariant(false, '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://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.') : void 0;
2625 return dispatcher;
2626}
2627
2628function useContext(Context, unstable_observedBits) {
2629 var dispatcher = resolveDispatcher();
2630 {
2631 !(unstable_observedBits === undefined) ? warning$1(false, '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://fb.me/rules-of-hooks' : '') : void 0;
2632
2633 // TODO: add a more generic warning for invalid values.
2634 if (Context._context !== undefined) {
2635 var realContext = Context._context;
2636 // Don't deduplicate because this legitimately causes bugs
2637 // and nobody should be using this in existing code.
2638 if (realContext.Consumer === Context) {
2639 warning$1(false, '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?');
2640 } else if (realContext.Provider === Context) {
2641 warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
2642 }
2643 }
2644 }
2645 return dispatcher.useContext(Context, unstable_observedBits);
2646}
2647
2648function useState(initialState) {
2649 var dispatcher = resolveDispatcher();
2650 return dispatcher.useState(initialState);
2651}
2652
2653function useReducer(reducer, initialArg, init) {
2654 var dispatcher = resolveDispatcher();
2655 return dispatcher.useReducer(reducer, initialArg, init);
2656}
2657
2658function useRef(initialValue) {
2659 var dispatcher = resolveDispatcher();
2660 return dispatcher.useRef(initialValue);
2661}
2662
2663function useEffect(create, inputs) {
2664 var dispatcher = resolveDispatcher();
2665 return dispatcher.useEffect(create, inputs);
2666}
2667
2668function useLayoutEffect(create, inputs) {
2669 var dispatcher = resolveDispatcher();
2670 return dispatcher.useLayoutEffect(create, inputs);
2671}
2672
2673function useCallback(callback, inputs) {
2674 var dispatcher = resolveDispatcher();
2675 return dispatcher.useCallback(callback, inputs);
2676}
2677
2678function useMemo(create, inputs) {
2679 var dispatcher = resolveDispatcher();
2680 return dispatcher.useMemo(create, inputs);
2681}
2682
2683function useImperativeHandle(ref, create, inputs) {
2684 var dispatcher = resolveDispatcher();
2685 return dispatcher.useImperativeHandle(ref, create, inputs);
2686}
2687
2688function useDebugValue(value, formatterFn) {
2689 {
2690 var dispatcher = resolveDispatcher();
2691 return dispatcher.useDebugValue(value, formatterFn);
2692 }
2693}
2694
2695/**
2696 * Copyright (c) 2013-present, Facebook, Inc.
2697 *
2698 * This source code is licensed under the MIT license found in the
2699 * LICENSE file in the root directory of this source tree.
2700 */
2701
2702
2703
2704var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
2705
2706var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
2707
2708/**
2709 * Copyright (c) 2013-present, Facebook, Inc.
2710 *
2711 * This source code is licensed under the MIT license found in the
2712 * LICENSE file in the root directory of this source tree.
2713 */
2714
2715
2716
2717var printWarning$1 = function() {};
2718
2719{
2720 var ReactPropTypesSecret = ReactPropTypesSecret_1;
2721 var loggedTypeFailures = {};
2722
2723 printWarning$1 = function(text) {
2724 var message = 'Warning: ' + text;
2725 if (typeof console !== 'undefined') {
2726 console.error(message);
2727 }
2728 try {
2729 // --- Welcome to debugging React ---
2730 // This error was thrown as a convenience so that you can use this stack
2731 // to find the callsite that caused this warning to fire.
2732 throw new Error(message);
2733 } catch (x) {}
2734 };
2735}
2736
2737/**
2738 * Assert that the values match with the type specs.
2739 * Error messages are memorized and will only be shown once.
2740 *
2741 * @param {object} typeSpecs Map of name to a ReactPropType
2742 * @param {object} values Runtime values that need to be type-checked
2743 * @param {string} location e.g. "prop", "context", "child context"
2744 * @param {string} componentName Name of the component for error messages.
2745 * @param {?Function} getStack Returns the component stack.
2746 * @private
2747 */
2748function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
2749 {
2750 for (var typeSpecName in typeSpecs) {
2751 if (typeSpecs.hasOwnProperty(typeSpecName)) {
2752 var error;
2753 // Prop type validation may throw. In case they do, we don't want to
2754 // fail the render phase where it didn't fail before. So we log it.
2755 // After these have been cleaned up, we'll let them throw.
2756 try {
2757 // This is intentionally an invariant that gets caught. It's the same
2758 // behavior as without this statement except with a better message.
2759 if (typeof typeSpecs[typeSpecName] !== 'function') {
2760 var err = Error(
2761 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
2762 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
2763 );
2764 err.name = 'Invariant Violation';
2765 throw err;
2766 }
2767 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
2768 } catch (ex) {
2769 error = ex;
2770 }
2771 if (error && !(error instanceof Error)) {
2772 printWarning$1(
2773 (componentName || 'React class') + ': type specification of ' +
2774 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
2775 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
2776 'You may have forgotten to pass an argument to the type checker ' +
2777 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
2778 'shape all require an argument).'
2779 );
2780
2781 }
2782 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
2783 // Only monitor this failure once because there tends to be a lot of the
2784 // same error.
2785 loggedTypeFailures[error.message] = true;
2786
2787 var stack = getStack ? getStack() : '';
2788
2789 printWarning$1(
2790 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
2791 );
2792 }
2793 }
2794 }
2795 }
2796}
2797
2798var checkPropTypes_1 = checkPropTypes;
2799
2800/**
2801 * ReactElementValidator provides a wrapper around a element factory
2802 * which validates the props passed to the element. This is intended to be
2803 * used only in DEV and could be replaced by a static type checker for languages
2804 * that support it.
2805 */
2806
2807var propTypesMisspellWarningShown = void 0;
2808
2809{
2810 propTypesMisspellWarningShown = false;
2811}
2812
2813function getDeclarationErrorAddendum() {
2814 if (ReactCurrentOwner.current) {
2815 var name = getComponentName(ReactCurrentOwner.current.type);
2816 if (name) {
2817 return '\n\nCheck the render method of `' + name + '`.';
2818 }
2819 }
2820 return '';
2821}
2822
2823function getSourceInfoErrorAddendum(elementProps) {
2824 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
2825 var source = elementProps.__source;
2826 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
2827 var lineNumber = source.lineNumber;
2828 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
2829 }
2830 return '';
2831}
2832
2833/**
2834 * Warn if there's no key explicitly set on dynamic arrays of children or
2835 * object keys are not valid. This allows us to keep track of children between
2836 * updates.
2837 */
2838var ownerHasKeyUseWarning = {};
2839
2840function getCurrentComponentErrorInfo(parentType) {
2841 var info = getDeclarationErrorAddendum();
2842
2843 if (!info) {
2844 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
2845 if (parentName) {
2846 info = '\n\nCheck the top-level render call using <' + parentName + '>.';
2847 }
2848 }
2849 return info;
2850}
2851
2852/**
2853 * Warn if the element doesn't have an explicit key assigned to it.
2854 * This element is in an array. The array could grow and shrink or be
2855 * reordered. All children that haven't already been validated are required to
2856 * have a "key" property assigned to it. Error statuses are cached so a warning
2857 * will only be shown once.
2858 *
2859 * @internal
2860 * @param {ReactElement} element Element that requires a key.
2861 * @param {*} parentType element's parent's type.
2862 */
2863function validateExplicitKey(element, parentType) {
2864 if (!element._store || element._store.validated || element.key != null) {
2865 return;
2866 }
2867 element._store.validated = true;
2868
2869 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
2870 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
2871 return;
2872 }
2873 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
2874
2875 // Usually the current owner is the offender, but if it accepts children as a
2876 // property, it may be the creator of the child that's responsible for
2877 // assigning it a key.
2878 var childOwner = '';
2879 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2880 // Give the component that originally created this child.
2881 childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
2882 }
2883
2884 setCurrentlyValidatingElement(element);
2885 {
2886 warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
2887 }
2888 setCurrentlyValidatingElement(null);
2889}
2890
2891/**
2892 * Ensure that every element either is passed in a static location, in an
2893 * array with an explicit keys property defined, or in an object literal
2894 * with valid key property.
2895 *
2896 * @internal
2897 * @param {ReactNode} node Statically passed child of any type.
2898 * @param {*} parentType node's parent's type.
2899 */
2900function validateChildKeys(node, parentType) {
2901 if (typeof node !== 'object') {
2902 return;
2903 }
2904 if (Array.isArray(node)) {
2905 for (var i = 0; i < node.length; i++) {
2906 var child = node[i];
2907 if (isValidElement(child)) {
2908 validateExplicitKey(child, parentType);
2909 }
2910 }
2911 } else if (isValidElement(node)) {
2912 // This element was passed in a valid location.
2913 if (node._store) {
2914 node._store.validated = true;
2915 }
2916 } else if (node) {
2917 var iteratorFn = getIteratorFn(node);
2918 if (typeof iteratorFn === 'function') {
2919 // Entry iterators used to provide implicit keys,
2920 // but now we print a separate warning for them later.
2921 if (iteratorFn !== node.entries) {
2922 var iterator = iteratorFn.call(node);
2923 var step = void 0;
2924 while (!(step = iterator.next()).done) {
2925 if (isValidElement(step.value)) {
2926 validateExplicitKey(step.value, parentType);
2927 }
2928 }
2929 }
2930 }
2931 }
2932}
2933
2934/**
2935 * Given an element, validate that its props follow the propTypes definition,
2936 * provided by the type.
2937 *
2938 * @param {ReactElement} element
2939 */
2940function validatePropTypes(element) {
2941 var type = element.type;
2942 if (type === null || type === undefined || typeof type === 'string') {
2943 return;
2944 }
2945 var name = getComponentName(type);
2946 var propTypes = void 0;
2947 if (typeof type === 'function') {
2948 propTypes = type.propTypes;
2949 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
2950 // Note: Memo only checks outer props here.
2951 // Inner props are checked in the reconciler.
2952 type.$$typeof === REACT_MEMO_TYPE)) {
2953 propTypes = type.propTypes;
2954 } else {
2955 return;
2956 }
2957 if (propTypes) {
2958 setCurrentlyValidatingElement(element);
2959 checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
2960 setCurrentlyValidatingElement(null);
2961 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2962 propTypesMisspellWarningShown = true;
2963 warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
2964 }
2965 if (typeof type.getDefaultProps === 'function') {
2966 !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
2967 }
2968}
2969
2970/**
2971 * Given a fragment, validate that it can only be provided with fragment props
2972 * @param {ReactElement} fragment
2973 */
2974function validateFragmentProps(fragment) {
2975 setCurrentlyValidatingElement(fragment);
2976
2977 var keys = Object.keys(fragment.props);
2978 for (var i = 0; i < keys.length; i++) {
2979 var key = keys[i];
2980 if (key !== 'children' && key !== 'key') {
2981 warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
2982 break;
2983 }
2984 }
2985
2986 if (fragment.ref !== null) {
2987 warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
2988 }
2989
2990 setCurrentlyValidatingElement(null);
2991}
2992
2993function createElementWithValidation(type, props, children) {
2994 var validType = isValidElementType(type);
2995
2996 // We warn in this case but don't throw. We expect the element creation to
2997 // succeed and there will likely be errors in render.
2998 if (!validType) {
2999 var info = '';
3000 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
3001 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.";
3002 }
3003
3004 var sourceInfo = getSourceInfoErrorAddendum(props);
3005 if (sourceInfo) {
3006 info += sourceInfo;
3007 } else {
3008 info += getDeclarationErrorAddendum();
3009 }
3010
3011 var typeString = void 0;
3012 if (type === null) {
3013 typeString = 'null';
3014 } else if (Array.isArray(type)) {
3015 typeString = 'array';
3016 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
3017 typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
3018 info = ' Did you accidentally export a JSX literal instead of a component?';
3019 } else {
3020 typeString = typeof type;
3021 }
3022
3023 warning$1(false, '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);
3024 }
3025
3026 var element = createElement.apply(this, arguments);
3027
3028 // The result can be nullish if a mock or a custom function is used.
3029 // TODO: Drop this when these are no longer allowed as the type argument.
3030 if (element == null) {
3031 return element;
3032 }
3033
3034 // Skip key warning if the type isn't valid since our key validation logic
3035 // doesn't expect a non-string/function type and can throw confusing errors.
3036 // We don't want exception behavior to differ between dev and prod.
3037 // (Rendering will throw with a helpful message and as soon as the type is
3038 // fixed, the key warnings will appear.)
3039 if (validType) {
3040 for (var i = 2; i < arguments.length; i++) {
3041 validateChildKeys(arguments[i], type);
3042 }
3043 }
3044
3045 if (type === REACT_FRAGMENT_TYPE) {
3046 validateFragmentProps(element);
3047 } else {
3048 validatePropTypes(element);
3049 }
3050
3051 return element;
3052}
3053
3054function createFactoryWithValidation(type) {
3055 var validatedFactory = createElementWithValidation.bind(null, type);
3056 validatedFactory.type = type;
3057 // Legacy hook: remove it
3058 {
3059 Object.defineProperty(validatedFactory, 'type', {
3060 enumerable: false,
3061 get: function () {
3062 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
3063 Object.defineProperty(this, 'type', {
3064 value: type
3065 });
3066 return type;
3067 }
3068 });
3069 }
3070
3071 return validatedFactory;
3072}
3073
3074function cloneElementWithValidation(element, props, children) {
3075 var newElement = cloneElement.apply(this, arguments);
3076 for (var i = 2; i < arguments.length; i++) {
3077 validateChildKeys(arguments[i], newElement.type);
3078 }
3079 validatePropTypes(newElement);
3080 return newElement;
3081}
3082
3083var React = {
3084 Children: {
3085 map: mapChildren,
3086 forEach: forEachChildren,
3087 count: countChildren,
3088 toArray: toArray,
3089 only: onlyChild
3090 },
3091
3092 createRef: createRef,
3093 Component: Component,
3094 PureComponent: PureComponent,
3095
3096 createContext: createContext,
3097 forwardRef: forwardRef,
3098 lazy: lazy,
3099 memo: memo,
3100
3101 useCallback: useCallback,
3102 useContext: useContext,
3103 useEffect: useEffect,
3104 useImperativeHandle: useImperativeHandle,
3105 useDebugValue: useDebugValue,
3106 useLayoutEffect: useLayoutEffect,
3107 useMemo: useMemo,
3108 useReducer: useReducer,
3109 useRef: useRef,
3110 useState: useState,
3111
3112 Fragment: REACT_FRAGMENT_TYPE,
3113 StrictMode: REACT_STRICT_MODE_TYPE,
3114 Suspense: REACT_SUSPENSE_TYPE,
3115
3116 createElement: createElementWithValidation,
3117 cloneElement: cloneElementWithValidation,
3118 createFactory: createFactoryWithValidation,
3119 isValidElement: isValidElement,
3120
3121 version: ReactVersion,
3122
3123 unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
3124 unstable_Profiler: REACT_PROFILER_TYPE,
3125
3126 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
3127};
3128
3129// Note: some APIs are added with feature flags.
3130// Make sure that stable builds for open source
3131// don't modify the React object to avoid deopts.
3132// Also let's not expose their names in stable builds.
3133
3134if (enableStableConcurrentModeAPIs) {
3135 React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
3136 React.Profiler = REACT_PROFILER_TYPE;
3137 React.unstable_ConcurrentMode = undefined;
3138 React.unstable_Profiler = undefined;
3139}
3140
3141
3142
3143var React$2 = Object.freeze({
3144 default: React
3145});
3146
3147var React$3 = ( React$2 && React ) || React$2;
3148
3149// TODO: decide on the top-level export form.
3150// This is hacky but makes it work with both Rollup and Jest.
3151var react = React$3.default || React$3;
3152
3153return react;
3154
3155})));