UNPKG

101 kBJavaScriptView Raw
1/** @license React v16.8.0
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.0';
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_wrapCallback(callback) {
746 var parentPriorityLevel = currentPriorityLevel;
747 return function () {
748 // This is a fork of runWithPriority, inlined for performance.
749 var previousPriorityLevel = currentPriorityLevel;
750 var previousEventStartTime = currentEventStartTime;
751 currentPriorityLevel = parentPriorityLevel;
752 currentEventStartTime = getCurrentTime();
753
754 try {
755 return callback.apply(this, arguments);
756 } finally {
757 currentPriorityLevel = previousPriorityLevel;
758 currentEventStartTime = previousEventStartTime;
759 flushImmediateWork();
760 }
761 };
762}
763
764function unstable_scheduleCallback(callback, deprecated_options) {
765 var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
766
767 var expirationTime;
768 if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
769 // FIXME: Remove this branch once we lift expiration times out of React.
770 expirationTime = startTime + deprecated_options.timeout;
771 } else {
772 switch (currentPriorityLevel) {
773 case ImmediatePriority:
774 expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
775 break;
776 case UserBlockingPriority:
777 expirationTime = startTime + USER_BLOCKING_PRIORITY;
778 break;
779 case IdlePriority:
780 expirationTime = startTime + IDLE_PRIORITY;
781 break;
782 case LowPriority:
783 expirationTime = startTime + LOW_PRIORITY_TIMEOUT;
784 break;
785 case NormalPriority:
786 default:
787 expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
788 }
789 }
790
791 var newNode = {
792 callback: callback,
793 priorityLevel: currentPriorityLevel,
794 expirationTime: expirationTime,
795 next: null,
796 previous: null
797 };
798
799 // Insert the new callback into the list, ordered first by expiration, then
800 // by insertion. So the new callback is inserted any other callback with
801 // equal expiration.
802 if (firstCallbackNode === null) {
803 // This is the first callback in the list.
804 firstCallbackNode = newNode.next = newNode.previous = newNode;
805 ensureHostCallbackIsScheduled();
806 } else {
807 var next = null;
808 var node = firstCallbackNode;
809 do {
810 if (node.expirationTime > expirationTime) {
811 // The new callback expires before this one.
812 next = node;
813 break;
814 }
815 node = node.next;
816 } while (node !== firstCallbackNode);
817
818 if (next === null) {
819 // No callback with a later expiration was found, which means the new
820 // callback has the latest expiration in the list.
821 next = firstCallbackNode;
822 } else if (next === firstCallbackNode) {
823 // The new callback has the earliest expiration in the entire list.
824 firstCallbackNode = newNode;
825 ensureHostCallbackIsScheduled();
826 }
827
828 var previous = next.previous;
829 previous.next = next.previous = newNode;
830 newNode.next = next;
831 newNode.previous = previous;
832 }
833
834 return newNode;
835}
836
837function unstable_pauseExecution() {
838 isSchedulerPaused = true;
839}
840
841function unstable_continueExecution() {
842 isSchedulerPaused = false;
843 if (firstCallbackNode !== null) {
844 ensureHostCallbackIsScheduled();
845 }
846}
847
848function unstable_getFirstCallbackNode() {
849 return firstCallbackNode;
850}
851
852function unstable_cancelCallback(callbackNode) {
853 var next = callbackNode.next;
854 if (next === null) {
855 // Already cancelled.
856 return;
857 }
858
859 if (next === callbackNode) {
860 // This is the only scheduled callback. Clear the list.
861 firstCallbackNode = null;
862 } else {
863 // Remove the callback from its position in the list.
864 if (callbackNode === firstCallbackNode) {
865 firstCallbackNode = next;
866 }
867 var previous = callbackNode.previous;
868 previous.next = next;
869 next.previous = previous;
870 }
871
872 callbackNode.next = callbackNode.previous = null;
873}
874
875function unstable_getCurrentPriorityLevel() {
876 return currentPriorityLevel;
877}
878
879function unstable_shouldYield() {
880 return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
881}
882
883// The remaining code is essentially a polyfill for requestIdleCallback. It
884// works by scheduling a requestAnimationFrame, storing the time for the start
885// of the frame, then scheduling a postMessage which gets scheduled after paint.
886// Within the postMessage handler do as much work as possible until time + frame
887// rate. By separating the idle call into a separate event tick we ensure that
888// layout, paint and other browser work is counted against the available time.
889// The frame rate is dynamically adjusted.
890
891// We capture a local reference to any global, in case it gets polyfilled after
892// this module is initially evaluated. We want to be using a
893// consistent implementation.
894var localDate = Date;
895
896// This initialization code may run even on server environments if a component
897// just imports ReactDOM (e.g. for findDOMNode). Some environments might not
898// have setTimeout or clearTimeout. However, we always expect them to be defined
899// on the client. https://github.com/facebook/react/pull/13088
900var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
901var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
902
903// We don't expect either of these to necessarily be defined, but we will error
904// later if they are missing on the client.
905var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
906var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
907
908var getCurrentTime;
909
910// requestAnimationFrame does not run when the tab is in the background. If
911// we're backgrounded we prefer for that work to happen so that the page
912// continues to load in the background. So we also schedule a 'setTimeout' as
913// a fallback.
914// TODO: Need a better heuristic for backgrounded work.
915var ANIMATION_FRAME_TIMEOUT = 100;
916var rAFID;
917var rAFTimeoutID;
918var requestAnimationFrameWithTimeout = function (callback) {
919 // schedule rAF and also a setTimeout
920 rAFID = localRequestAnimationFrame(function (timestamp) {
921 // cancel the setTimeout
922 localClearTimeout(rAFTimeoutID);
923 callback(timestamp);
924 });
925 rAFTimeoutID = localSetTimeout(function () {
926 // cancel the requestAnimationFrame
927 localCancelAnimationFrame(rAFID);
928 callback(getCurrentTime());
929 }, ANIMATION_FRAME_TIMEOUT);
930};
931
932if (hasNativePerformanceNow) {
933 var Performance = performance;
934 getCurrentTime = function () {
935 return Performance.now();
936 };
937} else {
938 getCurrentTime = function () {
939 return localDate.now();
940 };
941}
942
943var requestHostCallback;
944var cancelHostCallback;
945var shouldYieldToHost;
946
947var globalValue = null;
948if (typeof window !== 'undefined') {
949 globalValue = window;
950} else if (typeof global !== 'undefined') {
951 globalValue = global;
952}
953
954if (globalValue && globalValue._schedMock) {
955 // Dynamic injection, only for testing purposes.
956 var globalImpl = globalValue._schedMock;
957 requestHostCallback = globalImpl[0];
958 cancelHostCallback = globalImpl[1];
959 shouldYieldToHost = globalImpl[2];
960 getCurrentTime = globalImpl[3];
961} else if (
962// If Scheduler runs in a non-DOM environment, it falls back to a naive
963// implementation using setTimeout.
964typeof window === 'undefined' ||
965// Check if MessageChannel is supported, too.
966typeof MessageChannel !== 'function') {
967 // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
968 // fallback to a naive implementation.
969 var _callback = null;
970 var _flushCallback = function (didTimeout) {
971 if (_callback !== null) {
972 try {
973 _callback(didTimeout);
974 } finally {
975 _callback = null;
976 }
977 }
978 };
979 requestHostCallback = function (cb, ms) {
980 if (_callback !== null) {
981 // Protect against re-entrancy.
982 setTimeout(requestHostCallback, 0, cb);
983 } else {
984 _callback = cb;
985 setTimeout(_flushCallback, 0, false);
986 }
987 };
988 cancelHostCallback = function () {
989 _callback = null;
990 };
991 shouldYieldToHost = function () {
992 return false;
993 };
994} else {
995 if (typeof console !== 'undefined') {
996 // TODO: Remove fb.me link
997 if (typeof localRequestAnimationFrame !== 'function') {
998 console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
999 }
1000 if (typeof localCancelAnimationFrame !== 'function') {
1001 console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1002 }
1003 }
1004
1005 var scheduledHostCallback = null;
1006 var isMessageEventScheduled = false;
1007 var timeoutTime = -1;
1008
1009 var isAnimationFrameScheduled = false;
1010
1011 var isFlushingHostCallback = false;
1012
1013 var frameDeadline = 0;
1014 // We start out assuming that we run at 30fps but then the heuristic tracking
1015 // will adjust this value to a faster fps if we get more frequent animation
1016 // frames.
1017 var previousFrameTime = 33;
1018 var activeFrameTime = 33;
1019
1020 shouldYieldToHost = function () {
1021 return frameDeadline <= getCurrentTime();
1022 };
1023
1024 // We use the postMessage trick to defer idle work until after the repaint.
1025 var channel = new MessageChannel();
1026 var port = channel.port2;
1027 channel.port1.onmessage = function (event) {
1028 isMessageEventScheduled = false;
1029
1030 var prevScheduledCallback = scheduledHostCallback;
1031 var prevTimeoutTime = timeoutTime;
1032 scheduledHostCallback = null;
1033 timeoutTime = -1;
1034
1035 var currentTime = getCurrentTime();
1036
1037 var didTimeout = false;
1038 if (frameDeadline - currentTime <= 0) {
1039 // There's no time left in this idle period. Check if the callback has
1040 // a timeout and whether it's been exceeded.
1041 if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
1042 // Exceeded the timeout. Invoke the callback even though there's no
1043 // time left.
1044 didTimeout = true;
1045 } else {
1046 // No timeout.
1047 if (!isAnimationFrameScheduled) {
1048 // Schedule another animation callback so we retry later.
1049 isAnimationFrameScheduled = true;
1050 requestAnimationFrameWithTimeout(animationTick);
1051 }
1052 // Exit without invoking the callback.
1053 scheduledHostCallback = prevScheduledCallback;
1054 timeoutTime = prevTimeoutTime;
1055 return;
1056 }
1057 }
1058
1059 if (prevScheduledCallback !== null) {
1060 isFlushingHostCallback = true;
1061 try {
1062 prevScheduledCallback(didTimeout);
1063 } finally {
1064 isFlushingHostCallback = false;
1065 }
1066 }
1067 };
1068
1069 var animationTick = function (rafTime) {
1070 if (scheduledHostCallback !== null) {
1071 // Eagerly schedule the next animation callback at the beginning of the
1072 // frame. If the scheduler queue is not empty at the end of the frame, it
1073 // will continue flushing inside that callback. If the queue *is* empty,
1074 // then it will exit immediately. Posting the callback at the start of the
1075 // frame ensures it's fired within the earliest possible frame. If we
1076 // waited until the end of the frame to post the callback, we risk the
1077 // browser skipping a frame and not firing the callback until the frame
1078 // after that.
1079 requestAnimationFrameWithTimeout(animationTick);
1080 } else {
1081 // No pending work. Exit.
1082 isAnimationFrameScheduled = false;
1083 return;
1084 }
1085
1086 var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
1087 if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
1088 if (nextFrameTime < 8) {
1089 // Defensive coding. We don't support higher frame rates than 120hz.
1090 // If the calculated frame time gets lower than 8, it is probably a bug.
1091 nextFrameTime = 8;
1092 }
1093 // If one frame goes long, then the next one can be short to catch up.
1094 // If two frames are short in a row, then that's an indication that we
1095 // actually have a higher frame rate than what we're currently optimizing.
1096 // We adjust our heuristic dynamically accordingly. For example, if we're
1097 // running on 120hz display or 90hz VR display.
1098 // Take the max of the two in case one of them was an anomaly due to
1099 // missed frame deadlines.
1100 activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
1101 } else {
1102 previousFrameTime = nextFrameTime;
1103 }
1104 frameDeadline = rafTime + activeFrameTime;
1105 if (!isMessageEventScheduled) {
1106 isMessageEventScheduled = true;
1107 port.postMessage(undefined);
1108 }
1109 };
1110
1111 requestHostCallback = function (callback, absoluteTimeout) {
1112 scheduledHostCallback = callback;
1113 timeoutTime = absoluteTimeout;
1114 if (isFlushingHostCallback || absoluteTimeout < 0) {
1115 // Don't wait for the next frame. Continue working ASAP, in a new event.
1116 port.postMessage(undefined);
1117 } else if (!isAnimationFrameScheduled) {
1118 // If rAF didn't already schedule one, we need to schedule a frame.
1119 // TODO: If this rAF doesn't materialize because the browser throttles, we
1120 // might want to still have setTimeout trigger rIC as a backup to ensure
1121 // that we keep performing work.
1122 isAnimationFrameScheduled = true;
1123 requestAnimationFrameWithTimeout(animationTick);
1124 }
1125 };
1126
1127 cancelHostCallback = function () {
1128 scheduledHostCallback = null;
1129 isMessageEventScheduled = false;
1130 timeoutTime = -1;
1131 };
1132}
1133
1134// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
1135
1136
1137// In some cases, StrictMode should also double-render lifecycles.
1138// This can be confusing for tests though,
1139// And it can be bad for performance in production.
1140// This feature flag can be used to control the behavior:
1141
1142
1143// To preserve the "Pause on caught exceptions" behavior of the debugger, we
1144// replay the begin phase of a failed component inside invokeGuardedCallback.
1145
1146
1147// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
1148
1149
1150// Gather advanced timing metrics for Profiler subtrees.
1151
1152
1153// Trace which interactions trigger each commit.
1154var enableSchedulerTracing = true;
1155
1156// Only used in www builds.
1157 // TODO: true? Here it might just be false.
1158
1159// Only used in www builds.
1160
1161
1162// Only used in www builds.
1163
1164
1165// React Fire: prevent the value and checked attributes from syncing
1166// with their related DOM properties
1167
1168
1169// These APIs will no longer be "unstable" in the upcoming 16.7 release,
1170// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
1171var enableStableConcurrentModeAPIs = false;
1172
1173var DEFAULT_THREAD_ID = 0;
1174
1175// Counters used to generate unique IDs.
1176var interactionIDCounter = 0;
1177var threadIDCounter = 0;
1178
1179// Set of currently traced interactions.
1180// Interactions "stack"–
1181// Meaning that newly traced interactions are appended to the previously active set.
1182// When an interaction goes out of scope, the previous set (if any) is restored.
1183var interactionsRef = null;
1184
1185// Listener(s) to notify when interactions begin and end.
1186var subscriberRef = null;
1187
1188if (enableSchedulerTracing) {
1189 interactionsRef = {
1190 current: new Set()
1191 };
1192 subscriberRef = {
1193 current: null
1194 };
1195}
1196
1197function unstable_clear(callback) {
1198 if (!enableSchedulerTracing) {
1199 return callback();
1200 }
1201
1202 var prevInteractions = interactionsRef.current;
1203 interactionsRef.current = new Set();
1204
1205 try {
1206 return callback();
1207 } finally {
1208 interactionsRef.current = prevInteractions;
1209 }
1210}
1211
1212function unstable_getCurrent() {
1213 if (!enableSchedulerTracing) {
1214 return null;
1215 } else {
1216 return interactionsRef.current;
1217 }
1218}
1219
1220function unstable_getThreadID() {
1221 return ++threadIDCounter;
1222}
1223
1224function unstable_trace(name, timestamp, callback) {
1225 var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
1226
1227 if (!enableSchedulerTracing) {
1228 return callback();
1229 }
1230
1231 var interaction = {
1232 __count: 1,
1233 id: interactionIDCounter++,
1234 name: name,
1235 timestamp: timestamp
1236 };
1237
1238 var prevInteractions = interactionsRef.current;
1239
1240 // Traced interactions should stack/accumulate.
1241 // To do that, clone the current interactions.
1242 // The previous set will be restored upon completion.
1243 var interactions = new Set(prevInteractions);
1244 interactions.add(interaction);
1245 interactionsRef.current = interactions;
1246
1247 var subscriber = subscriberRef.current;
1248 var returnValue = void 0;
1249
1250 try {
1251 if (subscriber !== null) {
1252 subscriber.onInteractionTraced(interaction);
1253 }
1254 } finally {
1255 try {
1256 if (subscriber !== null) {
1257 subscriber.onWorkStarted(interactions, threadID);
1258 }
1259 } finally {
1260 try {
1261 returnValue = callback();
1262 } finally {
1263 interactionsRef.current = prevInteractions;
1264
1265 try {
1266 if (subscriber !== null) {
1267 subscriber.onWorkStopped(interactions, threadID);
1268 }
1269 } finally {
1270 interaction.__count--;
1271
1272 // If no async work was scheduled for this interaction,
1273 // Notify subscribers that it's completed.
1274 if (subscriber !== null && interaction.__count === 0) {
1275 subscriber.onInteractionScheduledWorkCompleted(interaction);
1276 }
1277 }
1278 }
1279 }
1280 }
1281
1282 return returnValue;
1283}
1284
1285function unstable_wrap(callback) {
1286 var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
1287
1288 if (!enableSchedulerTracing) {
1289 return callback;
1290 }
1291
1292 var wrappedInteractions = interactionsRef.current;
1293
1294 var subscriber = subscriberRef.current;
1295 if (subscriber !== null) {
1296 subscriber.onWorkScheduled(wrappedInteractions, threadID);
1297 }
1298
1299 // Update the pending async work count for the current interactions.
1300 // Update after calling subscribers in case of error.
1301 wrappedInteractions.forEach(function (interaction) {
1302 interaction.__count++;
1303 });
1304
1305 var hasRun = false;
1306
1307 function wrapped() {
1308 var prevInteractions = interactionsRef.current;
1309 interactionsRef.current = wrappedInteractions;
1310
1311 subscriber = subscriberRef.current;
1312
1313 try {
1314 var returnValue = void 0;
1315
1316 try {
1317 if (subscriber !== null) {
1318 subscriber.onWorkStarted(wrappedInteractions, threadID);
1319 }
1320 } finally {
1321 try {
1322 returnValue = callback.apply(undefined, arguments);
1323 } finally {
1324 interactionsRef.current = prevInteractions;
1325
1326 if (subscriber !== null) {
1327 subscriber.onWorkStopped(wrappedInteractions, threadID);
1328 }
1329 }
1330 }
1331
1332 return returnValue;
1333 } finally {
1334 if (!hasRun) {
1335 // We only expect a wrapped function to be executed once,
1336 // But in the event that it's executed more than once–
1337 // Only decrement the outstanding interaction counts once.
1338 hasRun = true;
1339
1340 // Update pending async counts for all wrapped interactions.
1341 // If this was the last scheduled async work for any of them,
1342 // Mark them as completed.
1343 wrappedInteractions.forEach(function (interaction) {
1344 interaction.__count--;
1345
1346 if (subscriber !== null && interaction.__count === 0) {
1347 subscriber.onInteractionScheduledWorkCompleted(interaction);
1348 }
1349 });
1350 }
1351 }
1352 }
1353
1354 wrapped.cancel = function cancel() {
1355 subscriber = subscriberRef.current;
1356
1357 try {
1358 if (subscriber !== null) {
1359 subscriber.onWorkCanceled(wrappedInteractions, threadID);
1360 }
1361 } finally {
1362 // Update pending async counts for all wrapped interactions.
1363 // If this was the last scheduled async work for any of them,
1364 // Mark them as completed.
1365 wrappedInteractions.forEach(function (interaction) {
1366 interaction.__count--;
1367
1368 if (subscriber && interaction.__count === 0) {
1369 subscriber.onInteractionScheduledWorkCompleted(interaction);
1370 }
1371 });
1372 }
1373 };
1374
1375 return wrapped;
1376}
1377
1378var subscribers = null;
1379if (enableSchedulerTracing) {
1380 subscribers = new Set();
1381}
1382
1383function unstable_subscribe(subscriber) {
1384 if (enableSchedulerTracing) {
1385 subscribers.add(subscriber);
1386
1387 if (subscribers.size === 1) {
1388 subscriberRef.current = {
1389 onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
1390 onInteractionTraced: onInteractionTraced,
1391 onWorkCanceled: onWorkCanceled,
1392 onWorkScheduled: onWorkScheduled,
1393 onWorkStarted: onWorkStarted,
1394 onWorkStopped: onWorkStopped
1395 };
1396 }
1397 }
1398}
1399
1400function unstable_unsubscribe(subscriber) {
1401 if (enableSchedulerTracing) {
1402 subscribers.delete(subscriber);
1403
1404 if (subscribers.size === 0) {
1405 subscriberRef.current = null;
1406 }
1407 }
1408}
1409
1410function onInteractionTraced(interaction) {
1411 var didCatchError = false;
1412 var caughtError = null;
1413
1414 subscribers.forEach(function (subscriber) {
1415 try {
1416 subscriber.onInteractionTraced(interaction);
1417 } catch (error) {
1418 if (!didCatchError) {
1419 didCatchError = true;
1420 caughtError = error;
1421 }
1422 }
1423 });
1424
1425 if (didCatchError) {
1426 throw caughtError;
1427 }
1428}
1429
1430function onInteractionScheduledWorkCompleted(interaction) {
1431 var didCatchError = false;
1432 var caughtError = null;
1433
1434 subscribers.forEach(function (subscriber) {
1435 try {
1436 subscriber.onInteractionScheduledWorkCompleted(interaction);
1437 } catch (error) {
1438 if (!didCatchError) {
1439 didCatchError = true;
1440 caughtError = error;
1441 }
1442 }
1443 });
1444
1445 if (didCatchError) {
1446 throw caughtError;
1447 }
1448}
1449
1450function onWorkScheduled(interactions, threadID) {
1451 var didCatchError = false;
1452 var caughtError = null;
1453
1454 subscribers.forEach(function (subscriber) {
1455 try {
1456 subscriber.onWorkScheduled(interactions, threadID);
1457 } catch (error) {
1458 if (!didCatchError) {
1459 didCatchError = true;
1460 caughtError = error;
1461 }
1462 }
1463 });
1464
1465 if (didCatchError) {
1466 throw caughtError;
1467 }
1468}
1469
1470function onWorkStarted(interactions, threadID) {
1471 var didCatchError = false;
1472 var caughtError = null;
1473
1474 subscribers.forEach(function (subscriber) {
1475 try {
1476 subscriber.onWorkStarted(interactions, threadID);
1477 } catch (error) {
1478 if (!didCatchError) {
1479 didCatchError = true;
1480 caughtError = error;
1481 }
1482 }
1483 });
1484
1485 if (didCatchError) {
1486 throw caughtError;
1487 }
1488}
1489
1490function onWorkStopped(interactions, threadID) {
1491 var didCatchError = false;
1492 var caughtError = null;
1493
1494 subscribers.forEach(function (subscriber) {
1495 try {
1496 subscriber.onWorkStopped(interactions, threadID);
1497 } catch (error) {
1498 if (!didCatchError) {
1499 didCatchError = true;
1500 caughtError = error;
1501 }
1502 }
1503 });
1504
1505 if (didCatchError) {
1506 throw caughtError;
1507 }
1508}
1509
1510function onWorkCanceled(interactions, threadID) {
1511 var didCatchError = false;
1512 var caughtError = null;
1513
1514 subscribers.forEach(function (subscriber) {
1515 try {
1516 subscriber.onWorkCanceled(interactions, threadID);
1517 } catch (error) {
1518 if (!didCatchError) {
1519 didCatchError = true;
1520 caughtError = error;
1521 }
1522 }
1523 });
1524
1525 if (didCatchError) {
1526 throw caughtError;
1527 }
1528}
1529
1530/**
1531 * Keeps track of the current dispatcher.
1532 */
1533var ReactCurrentDispatcher = {
1534 /**
1535 * @internal
1536 * @type {ReactComponent}
1537 */
1538 current: null
1539};
1540
1541/**
1542 * Keeps track of the current owner.
1543 *
1544 * The current owner is the component who should own any components that are
1545 * currently being constructed.
1546 */
1547var ReactCurrentOwner = {
1548 /**
1549 * @internal
1550 * @type {ReactComponent}
1551 */
1552 current: null
1553};
1554
1555var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
1556
1557var describeComponentFrame = function (name, source, ownerName) {
1558 var sourceInfo = '';
1559 if (source) {
1560 var path = source.fileName;
1561 var fileName = path.replace(BEFORE_SLASH_RE, '');
1562 {
1563 // In DEV, include code for a common special case:
1564 // prefer "folder/index.js" instead of just "index.js".
1565 if (/^index\./.test(fileName)) {
1566 var match = path.match(BEFORE_SLASH_RE);
1567 if (match) {
1568 var pathBeforeSlash = match[1];
1569 if (pathBeforeSlash) {
1570 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
1571 fileName = folderName + '/' + fileName;
1572 }
1573 }
1574 }
1575 }
1576 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
1577 } else if (ownerName) {
1578 sourceInfo = ' (created by ' + ownerName + ')';
1579 }
1580 return '\n in ' + (name || 'Unknown') + sourceInfo;
1581};
1582
1583var Resolved = 1;
1584
1585
1586function refineResolvedLazyComponent(lazyComponent) {
1587 return lazyComponent._status === Resolved ? lazyComponent._result : null;
1588}
1589
1590function getWrappedName(outerType, innerType, wrapperName) {
1591 var functionName = innerType.displayName || innerType.name || '';
1592 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
1593}
1594
1595function getComponentName(type) {
1596 if (type == null) {
1597 // Host root, text node or just invalid type.
1598 return null;
1599 }
1600 {
1601 if (typeof type.tag === 'number') {
1602 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
1603 }
1604 }
1605 if (typeof type === 'function') {
1606 return type.displayName || type.name || null;
1607 }
1608 if (typeof type === 'string') {
1609 return type;
1610 }
1611 switch (type) {
1612 case REACT_CONCURRENT_MODE_TYPE:
1613 return 'ConcurrentMode';
1614 case REACT_FRAGMENT_TYPE:
1615 return 'Fragment';
1616 case REACT_PORTAL_TYPE:
1617 return 'Portal';
1618 case REACT_PROFILER_TYPE:
1619 return 'Profiler';
1620 case REACT_STRICT_MODE_TYPE:
1621 return 'StrictMode';
1622 case REACT_SUSPENSE_TYPE:
1623 return 'Suspense';
1624 }
1625 if (typeof type === 'object') {
1626 switch (type.$$typeof) {
1627 case REACT_CONTEXT_TYPE:
1628 return 'Context.Consumer';
1629 case REACT_PROVIDER_TYPE:
1630 return 'Context.Provider';
1631 case REACT_FORWARD_REF_TYPE:
1632 return getWrappedName(type, type.render, 'ForwardRef');
1633 case REACT_MEMO_TYPE:
1634 return getComponentName(type.type);
1635 case REACT_LAZY_TYPE:
1636 {
1637 var thenable = type;
1638 var resolvedThenable = refineResolvedLazyComponent(thenable);
1639 if (resolvedThenable) {
1640 return getComponentName(resolvedThenable);
1641 }
1642 }
1643 }
1644 }
1645 return null;
1646}
1647
1648var ReactDebugCurrentFrame = {};
1649
1650var currentlyValidatingElement = null;
1651
1652function setCurrentlyValidatingElement(element) {
1653 {
1654 currentlyValidatingElement = element;
1655 }
1656}
1657
1658{
1659 // Stack implementation injected by the current renderer.
1660 ReactDebugCurrentFrame.getCurrentStack = null;
1661
1662 ReactDebugCurrentFrame.getStackAddendum = function () {
1663 var stack = '';
1664
1665 // Add an extra top frame while an element is being validated
1666 if (currentlyValidatingElement) {
1667 var name = getComponentName(currentlyValidatingElement.type);
1668 var owner = currentlyValidatingElement._owner;
1669 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
1670 }
1671
1672 // Delegate to the injected renderer-specific implementation
1673 var impl = ReactDebugCurrentFrame.getCurrentStack;
1674 if (impl) {
1675 stack += impl() || '';
1676 }
1677
1678 return stack;
1679 };
1680}
1681
1682var ReactSharedInternals = {
1683 ReactCurrentDispatcher: ReactCurrentDispatcher,
1684 ReactCurrentOwner: ReactCurrentOwner,
1685 // Used by renderers to avoid bundling object-assign twice in UMD bundles:
1686 assign: objectAssign
1687};
1688
1689{
1690 // Re-export the schedule API(s) for UMD bundles.
1691 // This avoids introducing a dependency on a new UMD global in a minor update,
1692 // Since that would be a breaking change (e.g. for all existing CodeSandboxes).
1693 // This re-export is only required for UMD bundles;
1694 // CJS bundles use the shared NPM package.
1695 objectAssign(ReactSharedInternals, {
1696 Scheduler: {
1697 unstable_cancelCallback: unstable_cancelCallback,
1698 unstable_shouldYield: unstable_shouldYield,
1699 unstable_now: getCurrentTime,
1700 unstable_scheduleCallback: unstable_scheduleCallback,
1701 unstable_runWithPriority: unstable_runWithPriority,
1702 unstable_wrapCallback: unstable_wrapCallback,
1703 unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
1704 unstable_pauseExecution: unstable_pauseExecution,
1705 unstable_continueExecution: unstable_continueExecution,
1706 unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel
1707 },
1708 SchedulerTracing: {
1709 __interactionsRef: interactionsRef,
1710 __subscriberRef: subscriberRef,
1711 unstable_clear: unstable_clear,
1712 unstable_getCurrent: unstable_getCurrent,
1713 unstable_getThreadID: unstable_getThreadID,
1714 unstable_subscribe: unstable_subscribe,
1715 unstable_trace: unstable_trace,
1716 unstable_unsubscribe: unstable_unsubscribe,
1717 unstable_wrap: unstable_wrap
1718 }
1719 });
1720}
1721
1722{
1723 objectAssign(ReactSharedInternals, {
1724 // These should not be included in production.
1725 ReactDebugCurrentFrame: ReactDebugCurrentFrame,
1726 // Shim for React DOM 16.0.0 which still destructured (but not used) this.
1727 // TODO: remove in React 17.0.
1728 ReactComponentTreeHook: {}
1729 });
1730}
1731
1732/**
1733 * Similar to invariant but only logs a warning if the condition is not met.
1734 * This can be used to log issues in development environments in critical
1735 * paths. Removing the logging code for production environments will keep the
1736 * same logic and follow the same code paths.
1737 */
1738
1739var warning = warningWithoutStack$1;
1740
1741{
1742 warning = function (condition, format) {
1743 if (condition) {
1744 return;
1745 }
1746 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1747 var stack = ReactDebugCurrentFrame.getStackAddendum();
1748 // eslint-disable-next-line react-internal/warning-and-invariant-args
1749
1750 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1751 args[_key - 2] = arguments[_key];
1752 }
1753
1754 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
1755 };
1756}
1757
1758var warning$1 = warning;
1759
1760var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1761
1762var RESERVED_PROPS = {
1763 key: true,
1764 ref: true,
1765 __self: true,
1766 __source: true
1767};
1768
1769var specialPropKeyWarningShown = void 0;
1770var specialPropRefWarningShown = void 0;
1771
1772function hasValidRef(config) {
1773 {
1774 if (hasOwnProperty$1.call(config, 'ref')) {
1775 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
1776 if (getter && getter.isReactWarning) {
1777 return false;
1778 }
1779 }
1780 }
1781 return config.ref !== undefined;
1782}
1783
1784function hasValidKey(config) {
1785 {
1786 if (hasOwnProperty$1.call(config, 'key')) {
1787 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
1788 if (getter && getter.isReactWarning) {
1789 return false;
1790 }
1791 }
1792 }
1793 return config.key !== undefined;
1794}
1795
1796function defineKeyPropWarningGetter(props, displayName) {
1797 var warnAboutAccessingKey = function () {
1798 if (!specialPropKeyWarningShown) {
1799 specialPropKeyWarningShown = true;
1800 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);
1801 }
1802 };
1803 warnAboutAccessingKey.isReactWarning = true;
1804 Object.defineProperty(props, 'key', {
1805 get: warnAboutAccessingKey,
1806 configurable: true
1807 });
1808}
1809
1810function defineRefPropWarningGetter(props, displayName) {
1811 var warnAboutAccessingRef = function () {
1812 if (!specialPropRefWarningShown) {
1813 specialPropRefWarningShown = true;
1814 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);
1815 }
1816 };
1817 warnAboutAccessingRef.isReactWarning = true;
1818 Object.defineProperty(props, 'ref', {
1819 get: warnAboutAccessingRef,
1820 configurable: true
1821 });
1822}
1823
1824/**
1825 * Factory method to create a new React element. This no longer adheres to
1826 * the class pattern, so do not use new to call it. Also, no instanceof check
1827 * will work. Instead test $$typeof field against Symbol.for('react.element') to check
1828 * if something is a React Element.
1829 *
1830 * @param {*} type
1831 * @param {*} key
1832 * @param {string|object} ref
1833 * @param {*} self A *temporary* helper to detect places where `this` is
1834 * different from the `owner` when React.createElement is called, so that we
1835 * can warn. We want to get rid of owner and replace string `ref`s with arrow
1836 * functions, and as long as `this` and owner are the same, there will be no
1837 * change in behavior.
1838 * @param {*} source An annotation object (added by a transpiler or otherwise)
1839 * indicating filename, line number, and/or other information.
1840 * @param {*} owner
1841 * @param {*} props
1842 * @internal
1843 */
1844var ReactElement = function (type, key, ref, self, source, owner, props) {
1845 var element = {
1846 // This tag allows us to uniquely identify this as a React Element
1847 $$typeof: REACT_ELEMENT_TYPE,
1848
1849 // Built-in properties that belong on the element
1850 type: type,
1851 key: key,
1852 ref: ref,
1853 props: props,
1854
1855 // Record the component responsible for creating this element.
1856 _owner: owner
1857 };
1858
1859 {
1860 // The validation flag is currently mutative. We put it on
1861 // an external backing store so that we can freeze the whole object.
1862 // This can be replaced with a WeakMap once they are implemented in
1863 // commonly used development environments.
1864 element._store = {};
1865
1866 // To make comparing ReactElements easier for testing purposes, we make
1867 // the validation flag non-enumerable (where possible, which should
1868 // include every environment we run tests in), so the test framework
1869 // ignores it.
1870 Object.defineProperty(element._store, 'validated', {
1871 configurable: false,
1872 enumerable: false,
1873 writable: true,
1874 value: false
1875 });
1876 // self and source are DEV only properties.
1877 Object.defineProperty(element, '_self', {
1878 configurable: false,
1879 enumerable: false,
1880 writable: false,
1881 value: self
1882 });
1883 // Two elements created in two different places should be considered
1884 // equal for testing purposes and therefore we hide it from enumeration.
1885 Object.defineProperty(element, '_source', {
1886 configurable: false,
1887 enumerable: false,
1888 writable: false,
1889 value: source
1890 });
1891 if (Object.freeze) {
1892 Object.freeze(element.props);
1893 Object.freeze(element);
1894 }
1895 }
1896
1897 return element;
1898};
1899
1900/**
1901 * Create and return a new ReactElement of the given type.
1902 * See https://reactjs.org/docs/react-api.html#createelement
1903 */
1904function createElement(type, config, children) {
1905 var propName = void 0;
1906
1907 // Reserved names are extracted
1908 var props = {};
1909
1910 var key = null;
1911 var ref = null;
1912 var self = null;
1913 var source = null;
1914
1915 if (config != null) {
1916 if (hasValidRef(config)) {
1917 ref = config.ref;
1918 }
1919 if (hasValidKey(config)) {
1920 key = '' + config.key;
1921 }
1922
1923 self = config.__self === undefined ? null : config.__self;
1924 source = config.__source === undefined ? null : config.__source;
1925 // Remaining properties are added to a new props object
1926 for (propName in config) {
1927 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1928 props[propName] = config[propName];
1929 }
1930 }
1931 }
1932
1933 // Children can be more than one argument, and those are transferred onto
1934 // the newly allocated props object.
1935 var childrenLength = arguments.length - 2;
1936 if (childrenLength === 1) {
1937 props.children = children;
1938 } else if (childrenLength > 1) {
1939 var childArray = Array(childrenLength);
1940 for (var i = 0; i < childrenLength; i++) {
1941 childArray[i] = arguments[i + 2];
1942 }
1943 {
1944 if (Object.freeze) {
1945 Object.freeze(childArray);
1946 }
1947 }
1948 props.children = childArray;
1949 }
1950
1951 // Resolve default props
1952 if (type && type.defaultProps) {
1953 var defaultProps = type.defaultProps;
1954 for (propName in defaultProps) {
1955 if (props[propName] === undefined) {
1956 props[propName] = defaultProps[propName];
1957 }
1958 }
1959 }
1960 {
1961 if (key || ref) {
1962 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
1963 if (key) {
1964 defineKeyPropWarningGetter(props, displayName);
1965 }
1966 if (ref) {
1967 defineRefPropWarningGetter(props, displayName);
1968 }
1969 }
1970 }
1971 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1972}
1973
1974/**
1975 * Return a function that produces ReactElements of a given type.
1976 * See https://reactjs.org/docs/react-api.html#createfactory
1977 */
1978
1979
1980function cloneAndReplaceKey(oldElement, newKey) {
1981 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
1982
1983 return newElement;
1984}
1985
1986/**
1987 * Clone and return a new ReactElement using element as the starting point.
1988 * See https://reactjs.org/docs/react-api.html#cloneelement
1989 */
1990function cloneElement(element, config, children) {
1991 !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
1992
1993 var propName = void 0;
1994
1995 // Original props are copied
1996 var props = objectAssign({}, element.props);
1997
1998 // Reserved names are extracted
1999 var key = element.key;
2000 var ref = element.ref;
2001 // Self is preserved since the owner is preserved.
2002 var self = element._self;
2003 // Source is preserved since cloneElement is unlikely to be targeted by a
2004 // transpiler, and the original source is probably a better indicator of the
2005 // true owner.
2006 var source = element._source;
2007
2008 // Owner will be preserved, unless ref is overridden
2009 var owner = element._owner;
2010
2011 if (config != null) {
2012 if (hasValidRef(config)) {
2013 // Silently steal the ref from the parent.
2014 ref = config.ref;
2015 owner = ReactCurrentOwner.current;
2016 }
2017 if (hasValidKey(config)) {
2018 key = '' + config.key;
2019 }
2020
2021 // Remaining properties override existing props
2022 var defaultProps = void 0;
2023 if (element.type && element.type.defaultProps) {
2024 defaultProps = element.type.defaultProps;
2025 }
2026 for (propName in config) {
2027 if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
2028 if (config[propName] === undefined && defaultProps !== undefined) {
2029 // Resolve default props
2030 props[propName] = defaultProps[propName];
2031 } else {
2032 props[propName] = config[propName];
2033 }
2034 }
2035 }
2036 }
2037
2038 // Children can be more than one argument, and those are transferred onto
2039 // the newly allocated props object.
2040 var childrenLength = arguments.length - 2;
2041 if (childrenLength === 1) {
2042 props.children = children;
2043 } else if (childrenLength > 1) {
2044 var childArray = Array(childrenLength);
2045 for (var i = 0; i < childrenLength; i++) {
2046 childArray[i] = arguments[i + 2];
2047 }
2048 props.children = childArray;
2049 }
2050
2051 return ReactElement(element.type, key, ref, self, source, owner, props);
2052}
2053
2054/**
2055 * Verifies the object is a ReactElement.
2056 * See https://reactjs.org/docs/react-api.html#isvalidelement
2057 * @param {?object} object
2058 * @return {boolean} True if `object` is a ReactElement.
2059 * @final
2060 */
2061function isValidElement(object) {
2062 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2063}
2064
2065var SEPARATOR = '.';
2066var SUBSEPARATOR = ':';
2067
2068/**
2069 * Escape and wrap key so it is safe to use as a reactid
2070 *
2071 * @param {string} key to be escaped.
2072 * @return {string} the escaped key.
2073 */
2074function escape(key) {
2075 var escapeRegex = /[=:]/g;
2076 var escaperLookup = {
2077 '=': '=0',
2078 ':': '=2'
2079 };
2080 var escapedString = ('' + key).replace(escapeRegex, function (match) {
2081 return escaperLookup[match];
2082 });
2083
2084 return '$' + escapedString;
2085}
2086
2087/**
2088 * TODO: Test that a single child and an array with one item have the same key
2089 * pattern.
2090 */
2091
2092var didWarnAboutMaps = false;
2093
2094var userProvidedKeyEscapeRegex = /\/+/g;
2095function escapeUserProvidedKey(text) {
2096 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
2097}
2098
2099var POOL_SIZE = 10;
2100var traverseContextPool = [];
2101function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
2102 if (traverseContextPool.length) {
2103 var traverseContext = traverseContextPool.pop();
2104 traverseContext.result = mapResult;
2105 traverseContext.keyPrefix = keyPrefix;
2106 traverseContext.func = mapFunction;
2107 traverseContext.context = mapContext;
2108 traverseContext.count = 0;
2109 return traverseContext;
2110 } else {
2111 return {
2112 result: mapResult,
2113 keyPrefix: keyPrefix,
2114 func: mapFunction,
2115 context: mapContext,
2116 count: 0
2117 };
2118 }
2119}
2120
2121function releaseTraverseContext(traverseContext) {
2122 traverseContext.result = null;
2123 traverseContext.keyPrefix = null;
2124 traverseContext.func = null;
2125 traverseContext.context = null;
2126 traverseContext.count = 0;
2127 if (traverseContextPool.length < POOL_SIZE) {
2128 traverseContextPool.push(traverseContext);
2129 }
2130}
2131
2132/**
2133 * @param {?*} children Children tree container.
2134 * @param {!string} nameSoFar Name of the key path so far.
2135 * @param {!function} callback Callback to invoke with each child found.
2136 * @param {?*} traverseContext Used to pass information throughout the traversal
2137 * process.
2138 * @return {!number} The number of children in this subtree.
2139 */
2140function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
2141 var type = typeof children;
2142
2143 if (type === 'undefined' || type === 'boolean') {
2144 // All of the above are perceived as null.
2145 children = null;
2146 }
2147
2148 var invokeCallback = false;
2149
2150 if (children === null) {
2151 invokeCallback = true;
2152 } else {
2153 switch (type) {
2154 case 'string':
2155 case 'number':
2156 invokeCallback = true;
2157 break;
2158 case 'object':
2159 switch (children.$$typeof) {
2160 case REACT_ELEMENT_TYPE:
2161 case REACT_PORTAL_TYPE:
2162 invokeCallback = true;
2163 }
2164 }
2165 }
2166
2167 if (invokeCallback) {
2168 callback(traverseContext, children,
2169 // If it's the only child, treat the name as if it was wrapped in an array
2170 // so that it's consistent if the number of children grows.
2171 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
2172 return 1;
2173 }
2174
2175 var child = void 0;
2176 var nextName = void 0;
2177 var subtreeCount = 0; // Count of children found in the current subtree.
2178 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
2179
2180 if (Array.isArray(children)) {
2181 for (var i = 0; i < children.length; i++) {
2182 child = children[i];
2183 nextName = nextNamePrefix + getComponentKey(child, i);
2184 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2185 }
2186 } else {
2187 var iteratorFn = getIteratorFn(children);
2188 if (typeof iteratorFn === 'function') {
2189 {
2190 // Warn about using Maps as children
2191 if (iteratorFn === children.entries) {
2192 !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;
2193 didWarnAboutMaps = true;
2194 }
2195 }
2196
2197 var iterator = iteratorFn.call(children);
2198 var step = void 0;
2199 var ii = 0;
2200 while (!(step = iterator.next()).done) {
2201 child = step.value;
2202 nextName = nextNamePrefix + getComponentKey(child, ii++);
2203 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
2204 }
2205 } else if (type === 'object') {
2206 var addendum = '';
2207 {
2208 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
2209 }
2210 var childrenString = '' + children;
2211 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);
2212 }
2213 }
2214
2215 return subtreeCount;
2216}
2217
2218/**
2219 * Traverses children that are typically specified as `props.children`, but
2220 * might also be specified through attributes:
2221 *
2222 * - `traverseAllChildren(this.props.children, ...)`
2223 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
2224 *
2225 * The `traverseContext` is an optional argument that is passed through the
2226 * entire traversal. It can be used to store accumulations or anything else that
2227 * the callback might find relevant.
2228 *
2229 * @param {?*} children Children tree object.
2230 * @param {!function} callback To invoke upon traversing each child.
2231 * @param {?*} traverseContext Context for traversal.
2232 * @return {!number} The number of children in this subtree.
2233 */
2234function traverseAllChildren(children, callback, traverseContext) {
2235 if (children == null) {
2236 return 0;
2237 }
2238
2239 return traverseAllChildrenImpl(children, '', callback, traverseContext);
2240}
2241
2242/**
2243 * Generate a key string that identifies a component within a set.
2244 *
2245 * @param {*} component A component that could contain a manual key.
2246 * @param {number} index Index that is used if a manual key is not provided.
2247 * @return {string}
2248 */
2249function getComponentKey(component, index) {
2250 // Do some typechecking here since we call this blindly. We want to ensure
2251 // that we don't block potential future ES APIs.
2252 if (typeof component === 'object' && component !== null && component.key != null) {
2253 // Explicit key
2254 return escape(component.key);
2255 }
2256 // Implicit key determined by the index in the set
2257 return index.toString(36);
2258}
2259
2260function forEachSingleChild(bookKeeping, child, name) {
2261 var func = bookKeeping.func,
2262 context = bookKeeping.context;
2263
2264 func.call(context, child, bookKeeping.count++);
2265}
2266
2267/**
2268 * Iterates through children that are typically specified as `props.children`.
2269 *
2270 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
2271 *
2272 * The provided forEachFunc(child, index) will be called for each
2273 * leaf child.
2274 *
2275 * @param {?*} children Children tree container.
2276 * @param {function(*, int)} forEachFunc
2277 * @param {*} forEachContext Context for forEachContext.
2278 */
2279function forEachChildren(children, forEachFunc, forEachContext) {
2280 if (children == null) {
2281 return children;
2282 }
2283 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
2284 traverseAllChildren(children, forEachSingleChild, traverseContext);
2285 releaseTraverseContext(traverseContext);
2286}
2287
2288function mapSingleChildIntoContext(bookKeeping, child, childKey) {
2289 var result = bookKeeping.result,
2290 keyPrefix = bookKeeping.keyPrefix,
2291 func = bookKeeping.func,
2292 context = bookKeeping.context;
2293
2294
2295 var mappedChild = func.call(context, child, bookKeeping.count++);
2296 if (Array.isArray(mappedChild)) {
2297 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
2298 return c;
2299 });
2300 } else if (mappedChild != null) {
2301 if (isValidElement(mappedChild)) {
2302 mappedChild = cloneAndReplaceKey(mappedChild,
2303 // Keep both the (mapped) and old keys if they differ, just as
2304 // traverseAllChildren used to do for objects as children
2305 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
2306 }
2307 result.push(mappedChild);
2308 }
2309}
2310
2311function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
2312 var escapedPrefix = '';
2313 if (prefix != null) {
2314 escapedPrefix = escapeUserProvidedKey(prefix) + '/';
2315 }
2316 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
2317 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
2318 releaseTraverseContext(traverseContext);
2319}
2320
2321/**
2322 * Maps children that are typically specified as `props.children`.
2323 *
2324 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
2325 *
2326 * The provided mapFunction(child, key, index) will be called for each
2327 * leaf child.
2328 *
2329 * @param {?*} children Children tree container.
2330 * @param {function(*, int)} func The map function.
2331 * @param {*} context Context for mapFunction.
2332 * @return {object} Object containing the ordered map of results.
2333 */
2334function mapChildren(children, func, context) {
2335 if (children == null) {
2336 return children;
2337 }
2338 var result = [];
2339 mapIntoWithKeyPrefixInternal(children, result, null, func, context);
2340 return result;
2341}
2342
2343/**
2344 * Count the number of children that are typically specified as
2345 * `props.children`.
2346 *
2347 * See https://reactjs.org/docs/react-api.html#reactchildrencount
2348 *
2349 * @param {?*} children Children tree container.
2350 * @return {number} The number of children.
2351 */
2352function countChildren(children) {
2353 return traverseAllChildren(children, function () {
2354 return null;
2355 }, null);
2356}
2357
2358/**
2359 * Flatten a children object (typically specified as `props.children`) and
2360 * return an array with appropriately re-keyed children.
2361 *
2362 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
2363 */
2364function toArray(children) {
2365 var result = [];
2366 mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
2367 return child;
2368 });
2369 return result;
2370}
2371
2372/**
2373 * Returns the first child in a collection of children and verifies that there
2374 * is only one child in the collection.
2375 *
2376 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
2377 *
2378 * The current implementation of this function assumes that a single child gets
2379 * passed without a wrapper, but the purpose of this helper function is to
2380 * abstract away the particular structure of children.
2381 *
2382 * @param {?object} children Child collection structure.
2383 * @return {ReactElement} The first and only `ReactElement` contained in the
2384 * structure.
2385 */
2386function onlyChild(children) {
2387 !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
2388 return children;
2389}
2390
2391function createContext(defaultValue, calculateChangedBits) {
2392 if (calculateChangedBits === undefined) {
2393 calculateChangedBits = null;
2394 } else {
2395 {
2396 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
2397 }
2398 }
2399
2400 var context = {
2401 $$typeof: REACT_CONTEXT_TYPE,
2402 _calculateChangedBits: calculateChangedBits,
2403 // As a workaround to support multiple concurrent renderers, we categorize
2404 // some renderers as primary and others as secondary. We only expect
2405 // there to be two concurrent renderers at most: React Native (primary) and
2406 // Fabric (secondary); React DOM (primary) and React ART (secondary).
2407 // Secondary renderers store their context values on separate fields.
2408 _currentValue: defaultValue,
2409 _currentValue2: defaultValue,
2410 // Used to track how many concurrent renderers this context currently
2411 // supports within in a single renderer. Such as parallel server rendering.
2412 _threadCount: 0,
2413 // These are circular
2414 Provider: null,
2415 Consumer: null
2416 };
2417
2418 context.Provider = {
2419 $$typeof: REACT_PROVIDER_TYPE,
2420 _context: context
2421 };
2422
2423 var hasWarnedAboutUsingNestedContextConsumers = false;
2424 var hasWarnedAboutUsingConsumerProvider = false;
2425
2426 {
2427 // A separate object, but proxies back to the original context object for
2428 // backwards compatibility. It has a different $$typeof, so we can properly
2429 // warn for the incorrect usage of Context as a Consumer.
2430 var Consumer = {
2431 $$typeof: REACT_CONTEXT_TYPE,
2432 _context: context,
2433 _calculateChangedBits: context._calculateChangedBits
2434 };
2435 // $FlowFixMe: Flow complains about not setting a value, which is intentional here
2436 Object.defineProperties(Consumer, {
2437 Provider: {
2438 get: function () {
2439 if (!hasWarnedAboutUsingConsumerProvider) {
2440 hasWarnedAboutUsingConsumerProvider = true;
2441 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?');
2442 }
2443 return context.Provider;
2444 },
2445 set: function (_Provider) {
2446 context.Provider = _Provider;
2447 }
2448 },
2449 _currentValue: {
2450 get: function () {
2451 return context._currentValue;
2452 },
2453 set: function (_currentValue) {
2454 context._currentValue = _currentValue;
2455 }
2456 },
2457 _currentValue2: {
2458 get: function () {
2459 return context._currentValue2;
2460 },
2461 set: function (_currentValue2) {
2462 context._currentValue2 = _currentValue2;
2463 }
2464 },
2465 _threadCount: {
2466 get: function () {
2467 return context._threadCount;
2468 },
2469 set: function (_threadCount) {
2470 context._threadCount = _threadCount;
2471 }
2472 },
2473 Consumer: {
2474 get: function () {
2475 if (!hasWarnedAboutUsingNestedContextConsumers) {
2476 hasWarnedAboutUsingNestedContextConsumers = true;
2477 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?');
2478 }
2479 return context.Consumer;
2480 }
2481 }
2482 });
2483 // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
2484 context.Consumer = Consumer;
2485 }
2486
2487 {
2488 context._currentRenderer = null;
2489 context._currentRenderer2 = null;
2490 }
2491
2492 return context;
2493}
2494
2495function lazy(ctor) {
2496 var lazyType = {
2497 $$typeof: REACT_LAZY_TYPE,
2498 _ctor: ctor,
2499 // React uses these fields to store the result.
2500 _status: -1,
2501 _result: null
2502 };
2503
2504 {
2505 // In production, this would just set it on the object.
2506 var defaultProps = void 0;
2507 var propTypes = void 0;
2508 Object.defineProperties(lazyType, {
2509 defaultProps: {
2510 configurable: true,
2511 get: function () {
2512 return defaultProps;
2513 },
2514 set: function (newDefaultProps) {
2515 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.');
2516 defaultProps = newDefaultProps;
2517 // Match production behavior more closely:
2518 Object.defineProperty(lazyType, 'defaultProps', {
2519 enumerable: true
2520 });
2521 }
2522 },
2523 propTypes: {
2524 configurable: true,
2525 get: function () {
2526 return propTypes;
2527 },
2528 set: function (newPropTypes) {
2529 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.');
2530 propTypes = newPropTypes;
2531 // Match production behavior more closely:
2532 Object.defineProperty(lazyType, 'propTypes', {
2533 enumerable: true
2534 });
2535 }
2536 }
2537 });
2538 }
2539
2540 return lazyType;
2541}
2542
2543function forwardRef(render) {
2544 {
2545 if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
2546 warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
2547 } else if (typeof render !== 'function') {
2548 warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
2549 } else {
2550 !(
2551 // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
2552 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;
2553 }
2554
2555 if (render != null) {
2556 !(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;
2557 }
2558 }
2559
2560 return {
2561 $$typeof: REACT_FORWARD_REF_TYPE,
2562 render: render
2563 };
2564}
2565
2566function isValidElementType(type) {
2567 return typeof type === 'string' || typeof type === 'function' ||
2568 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2569 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);
2570}
2571
2572function memo(type, compare) {
2573 {
2574 if (!isValidElementType(type)) {
2575 warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
2576 }
2577 }
2578 return {
2579 $$typeof: REACT_MEMO_TYPE,
2580 type: type,
2581 compare: compare === undefined ? null : compare
2582 };
2583}
2584
2585function resolveDispatcher() {
2586 var dispatcher = ReactCurrentDispatcher.current;
2587 !(dispatcher !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)') : void 0;
2588 return dispatcher;
2589}
2590
2591function useContext(Context, unstable_observedBits) {
2592 var dispatcher = resolveDispatcher();
2593 {
2594 !(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;
2595
2596 // TODO: add a more generic warning for invalid values.
2597 if (Context._context !== undefined) {
2598 var realContext = Context._context;
2599 // Don't deduplicate because this legitimately causes bugs
2600 // and nobody should be using this in existing code.
2601 if (realContext.Consumer === Context) {
2602 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?');
2603 } else if (realContext.Provider === Context) {
2604 warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
2605 }
2606 }
2607 }
2608 return dispatcher.useContext(Context, unstable_observedBits);
2609}
2610
2611function useState(initialState) {
2612 var dispatcher = resolveDispatcher();
2613 return dispatcher.useState(initialState);
2614}
2615
2616function useReducer(reducer, initialArg, init) {
2617 var dispatcher = resolveDispatcher();
2618 return dispatcher.useReducer(reducer, initialArg, init);
2619}
2620
2621function useRef(initialValue) {
2622 var dispatcher = resolveDispatcher();
2623 return dispatcher.useRef(initialValue);
2624}
2625
2626function useEffect(create, inputs) {
2627 var dispatcher = resolveDispatcher();
2628 return dispatcher.useEffect(create, inputs);
2629}
2630
2631function useLayoutEffect(create, inputs) {
2632 var dispatcher = resolveDispatcher();
2633 return dispatcher.useLayoutEffect(create, inputs);
2634}
2635
2636function useCallback(callback, inputs) {
2637 var dispatcher = resolveDispatcher();
2638 return dispatcher.useCallback(callback, inputs);
2639}
2640
2641function useMemo(create, inputs) {
2642 var dispatcher = resolveDispatcher();
2643 return dispatcher.useMemo(create, inputs);
2644}
2645
2646function useImperativeHandle(ref, create, inputs) {
2647 var dispatcher = resolveDispatcher();
2648 return dispatcher.useImperativeHandle(ref, create, inputs);
2649}
2650
2651function useDebugValue(value, formatterFn) {
2652 {
2653 var dispatcher = resolveDispatcher();
2654 return dispatcher.useDebugValue(value, formatterFn);
2655 }
2656}
2657
2658/**
2659 * Copyright (c) 2013-present, Facebook, Inc.
2660 *
2661 * This source code is licensed under the MIT license found in the
2662 * LICENSE file in the root directory of this source tree.
2663 */
2664
2665
2666
2667var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
2668
2669var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
2670
2671/**
2672 * Copyright (c) 2013-present, Facebook, Inc.
2673 *
2674 * This source code is licensed under the MIT license found in the
2675 * LICENSE file in the root directory of this source tree.
2676 */
2677
2678
2679
2680var printWarning$1 = function() {};
2681
2682{
2683 var ReactPropTypesSecret = ReactPropTypesSecret_1;
2684 var loggedTypeFailures = {};
2685
2686 printWarning$1 = function(text) {
2687 var message = 'Warning: ' + text;
2688 if (typeof console !== 'undefined') {
2689 console.error(message);
2690 }
2691 try {
2692 // --- Welcome to debugging React ---
2693 // This error was thrown as a convenience so that you can use this stack
2694 // to find the callsite that caused this warning to fire.
2695 throw new Error(message);
2696 } catch (x) {}
2697 };
2698}
2699
2700/**
2701 * Assert that the values match with the type specs.
2702 * Error messages are memorized and will only be shown once.
2703 *
2704 * @param {object} typeSpecs Map of name to a ReactPropType
2705 * @param {object} values Runtime values that need to be type-checked
2706 * @param {string} location e.g. "prop", "context", "child context"
2707 * @param {string} componentName Name of the component for error messages.
2708 * @param {?Function} getStack Returns the component stack.
2709 * @private
2710 */
2711function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
2712 {
2713 for (var typeSpecName in typeSpecs) {
2714 if (typeSpecs.hasOwnProperty(typeSpecName)) {
2715 var error;
2716 // Prop type validation may throw. In case they do, we don't want to
2717 // fail the render phase where it didn't fail before. So we log it.
2718 // After these have been cleaned up, we'll let them throw.
2719 try {
2720 // This is intentionally an invariant that gets caught. It's the same
2721 // behavior as without this statement except with a better message.
2722 if (typeof typeSpecs[typeSpecName] !== 'function') {
2723 var err = Error(
2724 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
2725 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
2726 );
2727 err.name = 'Invariant Violation';
2728 throw err;
2729 }
2730 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
2731 } catch (ex) {
2732 error = ex;
2733 }
2734 if (error && !(error instanceof Error)) {
2735 printWarning$1(
2736 (componentName || 'React class') + ': type specification of ' +
2737 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
2738 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
2739 'You may have forgotten to pass an argument to the type checker ' +
2740 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
2741 'shape all require an argument).'
2742 );
2743
2744 }
2745 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
2746 // Only monitor this failure once because there tends to be a lot of the
2747 // same error.
2748 loggedTypeFailures[error.message] = true;
2749
2750 var stack = getStack ? getStack() : '';
2751
2752 printWarning$1(
2753 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
2754 );
2755 }
2756 }
2757 }
2758 }
2759}
2760
2761var checkPropTypes_1 = checkPropTypes;
2762
2763/**
2764 * ReactElementValidator provides a wrapper around a element factory
2765 * which validates the props passed to the element. This is intended to be
2766 * used only in DEV and could be replaced by a static type checker for languages
2767 * that support it.
2768 */
2769
2770var propTypesMisspellWarningShown = void 0;
2771
2772{
2773 propTypesMisspellWarningShown = false;
2774}
2775
2776function getDeclarationErrorAddendum() {
2777 if (ReactCurrentOwner.current) {
2778 var name = getComponentName(ReactCurrentOwner.current.type);
2779 if (name) {
2780 return '\n\nCheck the render method of `' + name + '`.';
2781 }
2782 }
2783 return '';
2784}
2785
2786function getSourceInfoErrorAddendum(elementProps) {
2787 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
2788 var source = elementProps.__source;
2789 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
2790 var lineNumber = source.lineNumber;
2791 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
2792 }
2793 return '';
2794}
2795
2796/**
2797 * Warn if there's no key explicitly set on dynamic arrays of children or
2798 * object keys are not valid. This allows us to keep track of children between
2799 * updates.
2800 */
2801var ownerHasKeyUseWarning = {};
2802
2803function getCurrentComponentErrorInfo(parentType) {
2804 var info = getDeclarationErrorAddendum();
2805
2806 if (!info) {
2807 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
2808 if (parentName) {
2809 info = '\n\nCheck the top-level render call using <' + parentName + '>.';
2810 }
2811 }
2812 return info;
2813}
2814
2815/**
2816 * Warn if the element doesn't have an explicit key assigned to it.
2817 * This element is in an array. The array could grow and shrink or be
2818 * reordered. All children that haven't already been validated are required to
2819 * have a "key" property assigned to it. Error statuses are cached so a warning
2820 * will only be shown once.
2821 *
2822 * @internal
2823 * @param {ReactElement} element Element that requires a key.
2824 * @param {*} parentType element's parent's type.
2825 */
2826function validateExplicitKey(element, parentType) {
2827 if (!element._store || element._store.validated || element.key != null) {
2828 return;
2829 }
2830 element._store.validated = true;
2831
2832 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
2833 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
2834 return;
2835 }
2836 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
2837
2838 // Usually the current owner is the offender, but if it accepts children as a
2839 // property, it may be the creator of the child that's responsible for
2840 // assigning it a key.
2841 var childOwner = '';
2842 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2843 // Give the component that originally created this child.
2844 childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
2845 }
2846
2847 setCurrentlyValidatingElement(element);
2848 {
2849 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);
2850 }
2851 setCurrentlyValidatingElement(null);
2852}
2853
2854/**
2855 * Ensure that every element either is passed in a static location, in an
2856 * array with an explicit keys property defined, or in an object literal
2857 * with valid key property.
2858 *
2859 * @internal
2860 * @param {ReactNode} node Statically passed child of any type.
2861 * @param {*} parentType node's parent's type.
2862 */
2863function validateChildKeys(node, parentType) {
2864 if (typeof node !== 'object') {
2865 return;
2866 }
2867 if (Array.isArray(node)) {
2868 for (var i = 0; i < node.length; i++) {
2869 var child = node[i];
2870 if (isValidElement(child)) {
2871 validateExplicitKey(child, parentType);
2872 }
2873 }
2874 } else if (isValidElement(node)) {
2875 // This element was passed in a valid location.
2876 if (node._store) {
2877 node._store.validated = true;
2878 }
2879 } else if (node) {
2880 var iteratorFn = getIteratorFn(node);
2881 if (typeof iteratorFn === 'function') {
2882 // Entry iterators used to provide implicit keys,
2883 // but now we print a separate warning for them later.
2884 if (iteratorFn !== node.entries) {
2885 var iterator = iteratorFn.call(node);
2886 var step = void 0;
2887 while (!(step = iterator.next()).done) {
2888 if (isValidElement(step.value)) {
2889 validateExplicitKey(step.value, parentType);
2890 }
2891 }
2892 }
2893 }
2894 }
2895}
2896
2897/**
2898 * Given an element, validate that its props follow the propTypes definition,
2899 * provided by the type.
2900 *
2901 * @param {ReactElement} element
2902 */
2903function validatePropTypes(element) {
2904 var type = element.type;
2905 if (type === null || type === undefined || typeof type === 'string') {
2906 return;
2907 }
2908 var name = getComponentName(type);
2909 var propTypes = void 0;
2910 if (typeof type === 'function') {
2911 propTypes = type.propTypes;
2912 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
2913 // Note: Memo only checks outer props here.
2914 // Inner props are checked in the reconciler.
2915 type.$$typeof === REACT_MEMO_TYPE)) {
2916 propTypes = type.propTypes;
2917 } else {
2918 return;
2919 }
2920 if (propTypes) {
2921 setCurrentlyValidatingElement(element);
2922 checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
2923 setCurrentlyValidatingElement(null);
2924 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2925 propTypesMisspellWarningShown = true;
2926 warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
2927 }
2928 if (typeof type.getDefaultProps === 'function') {
2929 !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
2930 }
2931}
2932
2933/**
2934 * Given a fragment, validate that it can only be provided with fragment props
2935 * @param {ReactElement} fragment
2936 */
2937function validateFragmentProps(fragment) {
2938 setCurrentlyValidatingElement(fragment);
2939
2940 var keys = Object.keys(fragment.props);
2941 for (var i = 0; i < keys.length; i++) {
2942 var key = keys[i];
2943 if (key !== 'children' && key !== 'key') {
2944 warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
2945 break;
2946 }
2947 }
2948
2949 if (fragment.ref !== null) {
2950 warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
2951 }
2952
2953 setCurrentlyValidatingElement(null);
2954}
2955
2956function createElementWithValidation(type, props, children) {
2957 var validType = isValidElementType(type);
2958
2959 // We warn in this case but don't throw. We expect the element creation to
2960 // succeed and there will likely be errors in render.
2961 if (!validType) {
2962 var info = '';
2963 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
2964 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.";
2965 }
2966
2967 var sourceInfo = getSourceInfoErrorAddendum(props);
2968 if (sourceInfo) {
2969 info += sourceInfo;
2970 } else {
2971 info += getDeclarationErrorAddendum();
2972 }
2973
2974 var typeString = void 0;
2975 if (type === null) {
2976 typeString = 'null';
2977 } else if (Array.isArray(type)) {
2978 typeString = 'array';
2979 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
2980 typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
2981 info = ' Did you accidentally export a JSX literal instead of a component?';
2982 } else {
2983 typeString = typeof type;
2984 }
2985
2986 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);
2987 }
2988
2989 var element = createElement.apply(this, arguments);
2990
2991 // The result can be nullish if a mock or a custom function is used.
2992 // TODO: Drop this when these are no longer allowed as the type argument.
2993 if (element == null) {
2994 return element;
2995 }
2996
2997 // Skip key warning if the type isn't valid since our key validation logic
2998 // doesn't expect a non-string/function type and can throw confusing errors.
2999 // We don't want exception behavior to differ between dev and prod.
3000 // (Rendering will throw with a helpful message and as soon as the type is
3001 // fixed, the key warnings will appear.)
3002 if (validType) {
3003 for (var i = 2; i < arguments.length; i++) {
3004 validateChildKeys(arguments[i], type);
3005 }
3006 }
3007
3008 if (type === REACT_FRAGMENT_TYPE) {
3009 validateFragmentProps(element);
3010 } else {
3011 validatePropTypes(element);
3012 }
3013
3014 return element;
3015}
3016
3017function createFactoryWithValidation(type) {
3018 var validatedFactory = createElementWithValidation.bind(null, type);
3019 validatedFactory.type = type;
3020 // Legacy hook: remove it
3021 {
3022 Object.defineProperty(validatedFactory, 'type', {
3023 enumerable: false,
3024 get: function () {
3025 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
3026 Object.defineProperty(this, 'type', {
3027 value: type
3028 });
3029 return type;
3030 }
3031 });
3032 }
3033
3034 return validatedFactory;
3035}
3036
3037function cloneElementWithValidation(element, props, children) {
3038 var newElement = cloneElement.apply(this, arguments);
3039 for (var i = 2; i < arguments.length; i++) {
3040 validateChildKeys(arguments[i], newElement.type);
3041 }
3042 validatePropTypes(newElement);
3043 return newElement;
3044}
3045
3046var React = {
3047 Children: {
3048 map: mapChildren,
3049 forEach: forEachChildren,
3050 count: countChildren,
3051 toArray: toArray,
3052 only: onlyChild
3053 },
3054
3055 createRef: createRef,
3056 Component: Component,
3057 PureComponent: PureComponent,
3058
3059 createContext: createContext,
3060 forwardRef: forwardRef,
3061 lazy: lazy,
3062 memo: memo,
3063
3064 useCallback: useCallback,
3065 useContext: useContext,
3066 useEffect: useEffect,
3067 useImperativeHandle: useImperativeHandle,
3068 useDebugValue: useDebugValue,
3069 useLayoutEffect: useLayoutEffect,
3070 useMemo: useMemo,
3071 useReducer: useReducer,
3072 useRef: useRef,
3073 useState: useState,
3074
3075 Fragment: REACT_FRAGMENT_TYPE,
3076 StrictMode: REACT_STRICT_MODE_TYPE,
3077 Suspense: REACT_SUSPENSE_TYPE,
3078
3079 createElement: createElementWithValidation,
3080 cloneElement: cloneElementWithValidation,
3081 createFactory: createFactoryWithValidation,
3082 isValidElement: isValidElement,
3083
3084 version: ReactVersion,
3085
3086 unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
3087 unstable_Profiler: REACT_PROFILER_TYPE,
3088
3089 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
3090};
3091
3092// Note: some APIs are added with feature flags.
3093// Make sure that stable builds for open source
3094// don't modify the React object to avoid deopts.
3095// Also let's not expose their names in stable builds.
3096
3097if (enableStableConcurrentModeAPIs) {
3098 React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
3099 React.Profiler = REACT_PROFILER_TYPE;
3100 React.unstable_ConcurrentMode = undefined;
3101 React.unstable_Profiler = undefined;
3102}
3103
3104
3105
3106var React$2 = Object.freeze({
3107 default: React
3108});
3109
3110var React$3 = ( React$2 && React ) || React$2;
3111
3112// TODO: decide on the top-level export form.
3113// This is hacky but makes it work with both Rollup and Jest.
3114var react = React$3.default || React$3;
3115
3116return react;
3117
3118})));