UNPKG

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