UNPKG

617 kBJavaScriptView Raw
1/** @license React v0.22.0
2 * react-reconciler.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
12if (process.env.NODE_ENV !== "production") {
13 module.exports = function $$$reconciler($$$hostConfig) {
14'use strict';
15
16var _assign = require('object-assign');
17var React = require('react');
18var checkPropTypes = require('prop-types/checkPropTypes');
19var Scheduler = require('scheduler');
20var tracing = require('scheduler/tracing');
21
22// Do not require this module directly! Use normal `invariant` calls with
23// template literal strings. The messages will be converted to ReactError during
24// build, and in production they will be minified.
25
26// Do not require this module directly! Use normal `invariant` calls with
27// template literal strings. The messages will be converted to ReactError during
28// build, and in production they will be minified.
29function ReactError(error) {
30 error.name = 'Invariant Violation';
31 return error;
32}
33
34var FunctionComponent = 0;
35var ClassComponent = 1;
36var IndeterminateComponent = 2; // Before we know whether it is function or class
37
38var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
39
40var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
41
42var HostComponent = 5;
43var HostText = 6;
44var Fragment = 7;
45var Mode = 8;
46var ContextConsumer = 9;
47var ContextProvider = 10;
48var ForwardRef = 11;
49var Profiler = 12;
50var SuspenseComponent = 13;
51var MemoComponent = 14;
52var SimpleMemoComponent = 15;
53var LazyComponent = 16;
54var IncompleteClassComponent = 17;
55var DehydratedFragment = 18;
56var SuspenseListComponent = 19;
57var FundamentalComponent = 20;
58var ScopeComponent = 21;
59
60/**
61 * Use invariant() to assert state which your program assumes to be true.
62 *
63 * Provide sprintf-style format (only %s is supported) and arguments
64 * to provide information about what broke and what you were
65 * expecting.
66 *
67 * The invariant message will be stripped in production, but the invariant
68 * will remain to ensure logic does not differ in production.
69 */
70
71/**
72 * Similar to invariant but only logs a warning if the condition is not met.
73 * This can be used to log issues in development environments in critical
74 * paths. Removing the logging code for production environments will keep the
75 * same logic and follow the same code paths.
76 */
77var warningWithoutStack = function () {};
78
79{
80 warningWithoutStack = function (condition, format) {
81 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
82 args[_key - 2] = arguments[_key];
83 }
84
85 if (format === undefined) {
86 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
87 }
88
89 if (args.length > 8) {
90 // Check before the condition to catch violations early.
91 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
92 }
93
94 if (condition) {
95 return;
96 }
97
98 if (typeof console !== 'undefined') {
99 var argsWithFormat = args.map(function (item) {
100 return '' + item;
101 });
102 argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
103 // breaks IE9: https://github.com/facebook/react/issues/13610
104
105 Function.prototype.apply.call(console.error, console, argsWithFormat);
106 }
107
108 try {
109 // --- Welcome to debugging React ---
110 // This error was thrown as a convenience so that you can use this stack
111 // to find the callsite that caused this warning to fire.
112 var argIndex = 0;
113 var message = 'Warning: ' + format.replace(/%s/g, function () {
114 return args[argIndex++];
115 });
116 throw new Error(message);
117 } catch (x) {}
118 };
119}
120
121var warningWithoutStack$1 = warningWithoutStack;
122
123/**
124 * `ReactInstanceMap` maintains a mapping from a public facing stateful
125 * instance (key) and the internal representation (value). This allows public
126 * methods to accept the user facing instance as an argument and map them back
127 * to internal methods.
128 *
129 * Note that this module is currently shared and assumed to be stateless.
130 * If this becomes an actual Map, that will break.
131 */
132
133/**
134 * This API should be called `delete` but we'd have to make sure to always
135 * transform these to strings for IE support. When this transform is fully
136 * supported we can rename it.
137 */
138
139function get(key) {
140 return key._reactInternalFiber;
141}
142
143function set(key, value) {
144 key._reactInternalFiber = value;
145}
146
147var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
148// Current owner and dispatcher used to share the same ref,
149// but PR #14548 split them out to better support the react-debug-tools package.
150
151if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
152 ReactSharedInternals.ReactCurrentDispatcher = {
153 current: null
154 };
155}
156
157if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
158 ReactSharedInternals.ReactCurrentBatchConfig = {
159 suspense: null
160 };
161}
162
163// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
164// nor polyfill, then a plain number is used for performance.
165var hasSymbol = typeof Symbol === 'function' && Symbol.for;
166var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
167var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
168var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
169var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
170var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
171var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
172var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
173// (unstable) APIs that have been removed. Can we remove the symbols?
174
175
176var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
177var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
178var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
179var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
180var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
181var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
182var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
183var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
184var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
185var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
186var FAUX_ITERATOR_SYMBOL = '@@iterator';
187function getIteratorFn(maybeIterable) {
188 if (maybeIterable === null || typeof maybeIterable !== 'object') {
189 return null;
190 }
191
192 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
193
194 if (typeof maybeIterator === 'function') {
195 return maybeIterator;
196 }
197
198 return null;
199}
200
201/**
202 * Similar to invariant but only logs a warning if the condition is not met.
203 * This can be used to log issues in development environments in critical
204 * paths. Removing the logging code for production environments will keep the
205 * same logic and follow the same code paths.
206 */
207
208var warning = warningWithoutStack$1;
209
210{
211 warning = function (condition, format) {
212 if (condition) {
213 return;
214 }
215
216 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
217 var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
218
219 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
220 args[_key - 2] = arguments[_key];
221 }
222
223 warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
224 };
225}
226
227var warning$1 = warning;
228
229var Uninitialized = -1;
230var Pending = 0;
231var Resolved = 1;
232var Rejected = 2;
233function refineResolvedLazyComponent(lazyComponent) {
234 return lazyComponent._status === Resolved ? lazyComponent._result : null;
235}
236function initializeLazyComponentType(lazyComponent) {
237 if (lazyComponent._status === Uninitialized) {
238 lazyComponent._status = Pending;
239 var ctor = lazyComponent._ctor;
240 var thenable = ctor();
241 lazyComponent._result = thenable;
242 thenable.then(function (moduleObject) {
243 if (lazyComponent._status === Pending) {
244 var defaultExport = moduleObject.default;
245
246 {
247 if (defaultExport === undefined) {
248 warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
249 }
250 }
251
252 lazyComponent._status = Resolved;
253 lazyComponent._result = defaultExport;
254 }
255 }, function (error) {
256 if (lazyComponent._status === Pending) {
257 lazyComponent._status = Rejected;
258 lazyComponent._result = error;
259 }
260 });
261 }
262}
263
264function getWrappedName(outerType, innerType, wrapperName) {
265 var functionName = innerType.displayName || innerType.name || '';
266 return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
267}
268
269function getComponentName(type) {
270 if (type == null) {
271 // Host root, text node or just invalid type.
272 return null;
273 }
274
275 {
276 if (typeof type.tag === 'number') {
277 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
278 }
279 }
280
281 if (typeof type === 'function') {
282 return type.displayName || type.name || null;
283 }
284
285 if (typeof type === 'string') {
286 return type;
287 }
288
289 switch (type) {
290 case REACT_FRAGMENT_TYPE:
291 return 'Fragment';
292
293 case REACT_PORTAL_TYPE:
294 return 'Portal';
295
296 case REACT_PROFILER_TYPE:
297 return "Profiler";
298
299 case REACT_STRICT_MODE_TYPE:
300 return 'StrictMode';
301
302 case REACT_SUSPENSE_TYPE:
303 return 'Suspense';
304
305 case REACT_SUSPENSE_LIST_TYPE:
306 return 'SuspenseList';
307 }
308
309 if (typeof type === 'object') {
310 switch (type.$$typeof) {
311 case REACT_CONTEXT_TYPE:
312 return 'Context.Consumer';
313
314 case REACT_PROVIDER_TYPE:
315 return 'Context.Provider';
316
317 case REACT_FORWARD_REF_TYPE:
318 return getWrappedName(type, type.render, 'ForwardRef');
319
320 case REACT_MEMO_TYPE:
321 return getComponentName(type.type);
322
323 case REACT_LAZY_TYPE:
324 {
325 var thenable = type;
326 var resolvedThenable = refineResolvedLazyComponent(thenable);
327
328 if (resolvedThenable) {
329 return getComponentName(resolvedThenable);
330 }
331
332 break;
333 }
334 }
335 }
336
337 return null;
338}
339
340// Don't change these two values. They're used by React Dev Tools.
341var NoEffect =
342/* */
3430;
344var PerformedWork =
345/* */
3461; // You can change the rest (and add more).
347
348var Placement =
349/* */
3502;
351var Update =
352/* */
3534;
354var PlacementAndUpdate =
355/* */
3566;
357var Deletion =
358/* */
3598;
360var ContentReset =
361/* */
36216;
363var Callback =
364/* */
36532;
366var DidCapture =
367/* */
36864;
369var Ref =
370/* */
371128;
372var Snapshot =
373/* */
374256;
375var Passive =
376/* */
377512;
378var Hydrating =
379/* */
3801024;
381var HydratingAndUpdate =
382/* */
3831028; // Passive & Update & Callback & Ref & Snapshot
384
385var LifecycleEffectMask =
386/* */
387932; // Union of all host effects
388
389var HostEffectMask =
390/* */
3912047;
392var Incomplete =
393/* */
3942048;
395var ShouldCapture =
396/* */
3974096;
398
399var enableUserTimingAPI = true; // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
400
401var debugRenderPhaseSideEffects = false; // In some cases, StrictMode should also double-render lifecycles.
402// This can be confusing for tests though,
403// And it can be bad for performance in production.
404// This feature flag can be used to control the behavior:
405
406var debugRenderPhaseSideEffectsForStrictMode = true; // To preserve the "Pause on caught exceptions" behavior of the debugger, we
407// replay the begin phase of a failed component inside invokeGuardedCallback.
408
409var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
410
411var warnAboutDeprecatedLifecycles = true; // Gather advanced timing metrics for Profiler subtrees.
412
413var enableProfilerTimer = true; // Trace which interactions trigger each commit.
414
415var enableSchedulerTracing = true; // Only used in www builds.
416
417var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
418
419 // Only used in www builds.
420
421 // Only used in www builds.
422
423 // Disable javascript: URL strings in href for XSS protection.
424
425 // React Fire: prevent the value and checked attributes from syncing
426// with their related DOM properties
427
428 // These APIs will no longer be "unstable" in the upcoming 16.7 release,
429// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
430
431
432 // See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
433// This is a flag so we can fix warnings in RN core before turning it on
434
435 // Experimental React Flare event system and event components support.
436
437var enableFlareAPI = false; // Experimental Host Component support.
438
439var enableFundamentalAPI = false; // Experimental Scope support.
440
441var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
442
443 // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
444// Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
445
446var warnAboutUnmockedScheduler = false; // For tests, we flush suspense fallbacks in an act scope;
447// *except* in some of our own tests, where we test incremental loading states.
448
449var flushSuspenseFallbacksInTests = true; // Changes priority of some events like mousemove to user-blocking priority,
450// but without making them discrete. The flag exists in case it causes
451// starvation problems.
452
453 // Add a callback property to suspense to notify which promises are currently
454// in the update queue. This allows reporting and tracing of what is causing
455// the user to see a loading state.
456// Also allows hydration callbacks to fire when a dehydrated boundary gets
457// hydrated or deleted.
458
459var enableSuspenseCallback = false; // Part of the simplification of React.createElement so we can eventually move
460// from React.createElement to React.jsx
461// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
462
463var warnAboutDefaultPropsOnFunctionComponents = false;
464var warnAboutStringRefs = false;
465var disableLegacyContext = false;
466var disableSchedulerTimeoutBasedOnReactExpirationTime = false;
467
468var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
469function getNearestMountedFiber(fiber) {
470 var node = fiber;
471 var nearestMounted = fiber;
472
473 if (!fiber.alternate) {
474 // If there is no alternate, this might be a new tree that isn't inserted
475 // yet. If it is, then it will have a pending insertion effect on it.
476 var nextNode = node;
477
478 do {
479 node = nextNode;
480
481 if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
482 // This is an insertion or in-progress hydration. The nearest possible
483 // mounted fiber is the parent but we need to continue to figure out
484 // if that one is still mounted.
485 nearestMounted = node.return;
486 }
487
488 nextNode = node.return;
489 } while (nextNode);
490 } else {
491 while (node.return) {
492 node = node.return;
493 }
494 }
495
496 if (node.tag === HostRoot) {
497 // TODO: Check if this was a nested HostRoot when used with
498 // renderContainerIntoSubtree.
499 return nearestMounted;
500 } // If we didn't hit the root, that means that we're in an disconnected tree
501 // that has been unmounted.
502
503
504 return null;
505}
506
507
508function isFiberMounted(fiber) {
509 return getNearestMountedFiber(fiber) === fiber;
510}
511function isMounted(component) {
512 {
513 var owner = ReactCurrentOwner.current;
514
515 if (owner !== null && owner.tag === ClassComponent) {
516 var ownerFiber = owner;
517 var instance = ownerFiber.stateNode;
518 !instance._warnedAboutRefsInRender ? warningWithoutStack$1(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component') : void 0;
519 instance._warnedAboutRefsInRender = true;
520 }
521 }
522
523 var fiber = get(component);
524
525 if (!fiber) {
526 return false;
527 }
528
529 return getNearestMountedFiber(fiber) === fiber;
530}
531
532function assertIsMounted(fiber) {
533 (function () {
534 if (!(getNearestMountedFiber(fiber) === fiber)) {
535 {
536 throw ReactError(Error("Unable to find node on an unmounted component."));
537 }
538 }
539 })();
540}
541
542function findCurrentFiberUsingSlowPath(fiber) {
543 var alternate = fiber.alternate;
544
545 if (!alternate) {
546 // If there is no alternate, then we only need to check if it is mounted.
547 var nearestMounted = getNearestMountedFiber(fiber);
548
549 (function () {
550 if (!(nearestMounted !== null)) {
551 {
552 throw ReactError(Error("Unable to find node on an unmounted component."));
553 }
554 }
555 })();
556
557 if (nearestMounted !== fiber) {
558 return null;
559 }
560
561 return fiber;
562 } // If we have two possible branches, we'll walk backwards up to the root
563 // to see what path the root points to. On the way we may hit one of the
564 // special cases and we'll deal with them.
565
566
567 var a = fiber;
568 var b = alternate;
569
570 while (true) {
571 var parentA = a.return;
572
573 if (parentA === null) {
574 // We're at the root.
575 break;
576 }
577
578 var parentB = parentA.alternate;
579
580 if (parentB === null) {
581 // There is no alternate. This is an unusual case. Currently, it only
582 // happens when a Suspense component is hidden. An extra fragment fiber
583 // is inserted in between the Suspense fiber and its children. Skip
584 // over this extra fragment fiber and proceed to the next parent.
585 var nextParent = parentA.return;
586
587 if (nextParent !== null) {
588 a = b = nextParent;
589 continue;
590 } // If there's no parent, we're at the root.
591
592
593 break;
594 } // If both copies of the parent fiber point to the same child, we can
595 // assume that the child is current. This happens when we bailout on low
596 // priority: the bailed out fiber's child reuses the current child.
597
598
599 if (parentA.child === parentB.child) {
600 var child = parentA.child;
601
602 while (child) {
603 if (child === a) {
604 // We've determined that A is the current branch.
605 assertIsMounted(parentA);
606 return fiber;
607 }
608
609 if (child === b) {
610 // We've determined that B is the current branch.
611 assertIsMounted(parentA);
612 return alternate;
613 }
614
615 child = child.sibling;
616 } // We should never have an alternate for any mounting node. So the only
617 // way this could possibly happen is if this was unmounted, if at all.
618
619
620 (function () {
621 {
622 {
623 throw ReactError(Error("Unable to find node on an unmounted component."));
624 }
625 }
626 })();
627 }
628
629 if (a.return !== b.return) {
630 // The return pointer of A and the return pointer of B point to different
631 // fibers. We assume that return pointers never criss-cross, so A must
632 // belong to the child set of A.return, and B must belong to the child
633 // set of B.return.
634 a = parentA;
635 b = parentB;
636 } else {
637 // The return pointers point to the same fiber. We'll have to use the
638 // default, slow path: scan the child sets of each parent alternate to see
639 // which child belongs to which set.
640 //
641 // Search parent A's child set
642 var didFindChild = false;
643 var _child = parentA.child;
644
645 while (_child) {
646 if (_child === a) {
647 didFindChild = true;
648 a = parentA;
649 b = parentB;
650 break;
651 }
652
653 if (_child === b) {
654 didFindChild = true;
655 b = parentA;
656 a = parentB;
657 break;
658 }
659
660 _child = _child.sibling;
661 }
662
663 if (!didFindChild) {
664 // Search parent B's child set
665 _child = parentB.child;
666
667 while (_child) {
668 if (_child === a) {
669 didFindChild = true;
670 a = parentB;
671 b = parentA;
672 break;
673 }
674
675 if (_child === b) {
676 didFindChild = true;
677 b = parentB;
678 a = parentA;
679 break;
680 }
681
682 _child = _child.sibling;
683 }
684
685 (function () {
686 if (!didFindChild) {
687 {
688 throw ReactError(Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue."));
689 }
690 }
691 })();
692 }
693 }
694
695 (function () {
696 if (!(a.alternate === b)) {
697 {
698 throw ReactError(Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."));
699 }
700 }
701 })();
702 } // If the root is not a host container, we're in a disconnected tree. I.e.
703 // unmounted.
704
705
706 (function () {
707 if (!(a.tag === HostRoot)) {
708 {
709 throw ReactError(Error("Unable to find node on an unmounted component."));
710 }
711 }
712 })();
713
714 if (a.stateNode.current === a) {
715 // We've determined that A is the current branch.
716 return fiber;
717 } // Otherwise B has to be current branch.
718
719
720 return alternate;
721}
722function findCurrentHostFiber(parent) {
723 var currentParent = findCurrentFiberUsingSlowPath(parent);
724
725 if (!currentParent) {
726 return null;
727 } // Next we'll drill down this component to find the first HostComponent/Text.
728
729
730 var node = currentParent;
731
732 while (true) {
733 if (node.tag === HostComponent || node.tag === HostText) {
734 return node;
735 } else if (node.child) {
736 node.child.return = node;
737 node = node.child;
738 continue;
739 }
740
741 if (node === currentParent) {
742 return null;
743 }
744
745 while (!node.sibling) {
746 if (!node.return || node.return === currentParent) {
747 return null;
748 }
749
750 node = node.return;
751 }
752
753 node.sibling.return = node.return;
754 node = node.sibling;
755 } // Flow needs the return null here, but ESLint complains about it.
756 // eslint-disable-next-line no-unreachable
757
758
759 return null;
760}
761function findCurrentHostFiberWithNoPortals(parent) {
762 var currentParent = findCurrentFiberUsingSlowPath(parent);
763
764 if (!currentParent) {
765 return null;
766 } // Next we'll drill down this component to find the first HostComponent/Text.
767
768
769 var node = currentParent;
770
771 while (true) {
772 if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI && node.tag === FundamentalComponent) {
773 return node;
774 } else if (node.child && node.tag !== HostPortal) {
775 node.child.return = node;
776 node = node.child;
777 continue;
778 }
779
780 if (node === currentParent) {
781 return null;
782 }
783
784 while (!node.sibling) {
785 if (!node.return || node.return === currentParent) {
786 return null;
787 }
788
789 node = node.return;
790 }
791
792 node.sibling.return = node.return;
793 node = node.sibling;
794 } // Flow needs the return null here, but ESLint complains about it.
795 // eslint-disable-next-line no-unreachable
796
797
798 return null;
799}
800
801// This is a host config that's used for the `react-reconciler` package on npm.
802// It is only used by third-party renderers.
803//
804// Its API lets you pass the host config as an argument.
805// However, inside the `react-reconciler` we treat host config as a module.
806// This file is a shim between two worlds.
807//
808// It works because the `react-reconciler` bundle is wrapped in something like:
809//
810// module.exports = function ($$$config) {
811// /* reconciler code */
812// }
813//
814// So `$$$config` looks like a global variable, but it's
815// really an argument to a top-level wrapping function.
816// eslint-disable-line no-undef
817// eslint-disable-line no-undef
818// eslint-disable-line no-undef
819// eslint-disable-line no-undef
820// eslint-disable-line no-undef
821// eslint-disable-line no-undef
822// eslint-disable-line no-undef
823// eslint-disable-line no-undef
824// eslint-disable-line no-undef
825// eslint-disable-line no-undef
826// eslint-disable-line no-undef
827// eslint-disable-line no-undef
828// eslint-disable-line no-undef
829var getPublicInstance = $$$hostConfig.getPublicInstance;
830var getRootHostContext = $$$hostConfig.getRootHostContext;
831var getChildHostContext = $$$hostConfig.getChildHostContext;
832var prepareForCommit = $$$hostConfig.prepareForCommit;
833var resetAfterCommit = $$$hostConfig.resetAfterCommit;
834var createInstance = $$$hostConfig.createInstance;
835var appendInitialChild = $$$hostConfig.appendInitialChild;
836var finalizeInitialChildren = $$$hostConfig.finalizeInitialChildren;
837var prepareUpdate = $$$hostConfig.prepareUpdate;
838var shouldSetTextContent = $$$hostConfig.shouldSetTextContent;
839var shouldDeprioritizeSubtree = $$$hostConfig.shouldDeprioritizeSubtree;
840var createTextInstance = $$$hostConfig.createTextInstance;
841var scheduleTimeout = $$$hostConfig.setTimeout;
842var cancelTimeout = $$$hostConfig.clearTimeout;
843var noTimeout = $$$hostConfig.noTimeout;
844var now = $$$hostConfig.now;
845var isPrimaryRenderer = $$$hostConfig.isPrimaryRenderer;
846var warnsIfNotActing = $$$hostConfig.warnsIfNotActing;
847var supportsMutation = $$$hostConfig.supportsMutation;
848var supportsPersistence = $$$hostConfig.supportsPersistence;
849var supportsHydration = $$$hostConfig.supportsHydration;
850var mountResponderInstance = $$$hostConfig.mountResponderInstance;
851var unmountResponderInstance = $$$hostConfig.unmountResponderInstance;
852var getFundamentalComponentInstance = $$$hostConfig.getFundamentalComponentInstance;
853var mountFundamentalComponent = $$$hostConfig.mountFundamentalComponent;
854var shouldUpdateFundamentalComponent = $$$hostConfig.shouldUpdateFundamentalComponent; // -------------------
855// Mutation
856// (optional)
857// -------------------
858
859var appendChild = $$$hostConfig.appendChild;
860var appendChildToContainer = $$$hostConfig.appendChildToContainer;
861var commitTextUpdate = $$$hostConfig.commitTextUpdate;
862var commitMount = $$$hostConfig.commitMount;
863var commitUpdate = $$$hostConfig.commitUpdate;
864var insertBefore = $$$hostConfig.insertBefore;
865var insertInContainerBefore = $$$hostConfig.insertInContainerBefore;
866var removeChild = $$$hostConfig.removeChild;
867var removeChildFromContainer = $$$hostConfig.removeChildFromContainer;
868var resetTextContent = $$$hostConfig.resetTextContent;
869var hideInstance = $$$hostConfig.hideInstance;
870var hideTextInstance = $$$hostConfig.hideTextInstance;
871var unhideInstance = $$$hostConfig.unhideInstance;
872var unhideTextInstance = $$$hostConfig.unhideTextInstance;
873var updateFundamentalComponent = $$$hostConfig.updateFundamentalComponent;
874var unmountFundamentalComponent = $$$hostConfig.unmountFundamentalComponent; // -------------------
875// Persistence
876// (optional)
877// -------------------
878
879var cloneInstance = $$$hostConfig.cloneInstance;
880var createContainerChildSet = $$$hostConfig.createContainerChildSet;
881var appendChildToContainerChildSet = $$$hostConfig.appendChildToContainerChildSet;
882var finalizeContainerChildren = $$$hostConfig.finalizeContainerChildren;
883var replaceContainerChildren = $$$hostConfig.replaceContainerChildren;
884var cloneHiddenInstance = $$$hostConfig.cloneHiddenInstance;
885var cloneHiddenTextInstance = $$$hostConfig.cloneHiddenTextInstance;
886var cloneFundamentalInstance = $$$hostConfig.cloneInstance; // -------------------
887// Hydration
888// (optional)
889// -------------------
890
891var canHydrateInstance = $$$hostConfig.canHydrateInstance;
892var canHydrateTextInstance = $$$hostConfig.canHydrateTextInstance;
893var canHydrateSuspenseInstance = $$$hostConfig.canHydrateSuspenseInstance;
894var isSuspenseInstancePending = $$$hostConfig.isSuspenseInstancePending;
895var isSuspenseInstanceFallback = $$$hostConfig.isSuspenseInstanceFallback;
896var registerSuspenseInstanceRetry = $$$hostConfig.registerSuspenseInstanceRetry;
897var getNextHydratableSibling = $$$hostConfig.getNextHydratableSibling;
898var getFirstHydratableChild = $$$hostConfig.getFirstHydratableChild;
899var hydrateInstance = $$$hostConfig.hydrateInstance;
900var hydrateTextInstance = $$$hostConfig.hydrateTextInstance;
901var hydrateSuspenseInstance = $$$hostConfig.hydrateSuspenseInstance;
902var getNextHydratableInstanceAfterSuspenseInstance = $$$hostConfig.getNextHydratableInstanceAfterSuspenseInstance;
903var commitHydratedContainer = $$$hostConfig.commitHydratedContainer;
904var commitHydratedSuspenseInstance = $$$hostConfig.commitHydratedSuspenseInstance;
905var clearSuspenseBoundary = $$$hostConfig.clearSuspenseBoundary;
906var clearSuspenseBoundaryFromContainer = $$$hostConfig.clearSuspenseBoundaryFromContainer;
907var didNotMatchHydratedContainerTextInstance = $$$hostConfig.didNotMatchHydratedContainerTextInstance;
908var didNotMatchHydratedTextInstance = $$$hostConfig.didNotMatchHydratedTextInstance;
909var didNotHydrateContainerInstance = $$$hostConfig.didNotHydrateContainerInstance;
910var didNotHydrateInstance = $$$hostConfig.didNotHydrateInstance;
911var didNotFindHydratableContainerInstance = $$$hostConfig.didNotFindHydratableContainerInstance;
912var didNotFindHydratableContainerTextInstance = $$$hostConfig.didNotFindHydratableContainerTextInstance;
913var didNotFindHydratableContainerSuspenseInstance = $$$hostConfig.didNotFindHydratableContainerSuspenseInstance;
914var didNotFindHydratableInstance = $$$hostConfig.didNotFindHydratableInstance;
915var didNotFindHydratableTextInstance = $$$hostConfig.didNotFindHydratableTextInstance;
916var didNotFindHydratableSuspenseInstance = $$$hostConfig.didNotFindHydratableSuspenseInstance;
917
918var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
919var describeComponentFrame = function (name, source, ownerName) {
920 var sourceInfo = '';
921
922 if (source) {
923 var path = source.fileName;
924 var fileName = path.replace(BEFORE_SLASH_RE, '');
925
926 {
927 // In DEV, include code for a common special case:
928 // prefer "folder/index.js" instead of just "index.js".
929 if (/^index\./.test(fileName)) {
930 var match = path.match(BEFORE_SLASH_RE);
931
932 if (match) {
933 var pathBeforeSlash = match[1];
934
935 if (pathBeforeSlash) {
936 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
937 fileName = folderName + '/' + fileName;
938 }
939 }
940 }
941 }
942
943 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
944 } else if (ownerName) {
945 sourceInfo = ' (created by ' + ownerName + ')';
946 }
947
948 return '\n in ' + (name || 'Unknown') + sourceInfo;
949};
950
951var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
952
953function describeFiber(fiber) {
954 switch (fiber.tag) {
955 case HostRoot:
956 case HostPortal:
957 case HostText:
958 case Fragment:
959 case ContextProvider:
960 case ContextConsumer:
961 return '';
962
963 default:
964 var owner = fiber._debugOwner;
965 var source = fiber._debugSource;
966 var name = getComponentName(fiber.type);
967 var ownerName = null;
968
969 if (owner) {
970 ownerName = getComponentName(owner.type);
971 }
972
973 return describeComponentFrame(name, source, ownerName);
974 }
975}
976
977function getStackByFiberInDevAndProd(workInProgress) {
978 var info = '';
979 var node = workInProgress;
980
981 do {
982 info += describeFiber(node);
983 node = node.return;
984 } while (node);
985
986 return info;
987}
988var current = null;
989var phase = null;
990function getCurrentFiberOwnerNameInDevOrNull() {
991 {
992 if (current === null) {
993 return null;
994 }
995
996 var owner = current._debugOwner;
997
998 if (owner !== null && typeof owner !== 'undefined') {
999 return getComponentName(owner.type);
1000 }
1001 }
1002
1003 return null;
1004}
1005function getCurrentFiberStackInDev() {
1006 {
1007 if (current === null) {
1008 return '';
1009 } // Safe because if current fiber exists, we are reconciling,
1010 // and it is guaranteed to be the work-in-progress version.
1011
1012
1013 return getStackByFiberInDevAndProd(current);
1014 }
1015
1016 return '';
1017}
1018function resetCurrentFiber() {
1019 {
1020 ReactDebugCurrentFrame.getCurrentStack = null;
1021 current = null;
1022 phase = null;
1023 }
1024}
1025function setCurrentFiber(fiber) {
1026 {
1027 ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
1028 current = fiber;
1029 phase = null;
1030 }
1031}
1032function setCurrentPhase(lifeCyclePhase) {
1033 {
1034 phase = lifeCyclePhase;
1035 }
1036}
1037
1038// Prefix measurements so that it's possible to filter them.
1039// Longer prefixes are hard to read in DevTools.
1040var reactEmoji = "\u269B";
1041var warningEmoji = "\u26D4";
1042var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; // Keep track of current fiber so that we know the path to unwind on pause.
1043// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
1044
1045var currentFiber = null; // If we're in the middle of user code, which fiber and method is it?
1046// Reusing `currentFiber` would be confusing for this because user code fiber
1047// can change during commit phase too, but we don't need to unwind it (since
1048// lifecycles in the commit phase don't resemble a tree).
1049
1050var currentPhase = null;
1051var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem,
1052// so we will keep track of it, and include it in the report.
1053// Track commits caused by cascading updates.
1054
1055var isCommitting = false;
1056var hasScheduledUpdateInCurrentCommit = false;
1057var hasScheduledUpdateInCurrentPhase = false;
1058var commitCountInCurrentWorkLoop = 0;
1059var effectCountInCurrentCommit = 0;
1060// to avoid stretch the commit phase with measurement overhead.
1061
1062var labelsInCurrentCommit = new Set();
1063
1064var formatMarkName = function (markName) {
1065 return reactEmoji + " " + markName;
1066};
1067
1068var formatLabel = function (label, warning) {
1069 var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
1070 var suffix = warning ? " Warning: " + warning : '';
1071 return "" + prefix + label + suffix;
1072};
1073
1074var beginMark = function (markName) {
1075 performance.mark(formatMarkName(markName));
1076};
1077
1078var clearMark = function (markName) {
1079 performance.clearMarks(formatMarkName(markName));
1080};
1081
1082var endMark = function (label, markName, warning) {
1083 var formattedMarkName = formatMarkName(markName);
1084 var formattedLabel = formatLabel(label, warning);
1085
1086 try {
1087 performance.measure(formattedLabel, formattedMarkName);
1088 } catch (err) {} // If previous mark was missing for some reason, this will throw.
1089 // This could only happen if React crashed in an unexpected place earlier.
1090 // Don't pile on with more errors.
1091 // Clear marks immediately to avoid growing buffer.
1092
1093
1094 performance.clearMarks(formattedMarkName);
1095 performance.clearMeasures(formattedLabel);
1096};
1097
1098var getFiberMarkName = function (label, debugID) {
1099 return label + " (#" + debugID + ")";
1100};
1101
1102var getFiberLabel = function (componentName, isMounted, phase) {
1103 if (phase === null) {
1104 // These are composite component total time measurements.
1105 return componentName + " [" + (isMounted ? 'update' : 'mount') + "]";
1106 } else {
1107 // Composite component methods.
1108 return componentName + "." + phase;
1109 }
1110};
1111
1112var beginFiberMark = function (fiber, phase) {
1113 var componentName = getComponentName(fiber.type) || 'Unknown';
1114 var debugID = fiber._debugID;
1115 var isMounted = fiber.alternate !== null;
1116 var label = getFiberLabel(componentName, isMounted, phase);
1117
1118 if (isCommitting && labelsInCurrentCommit.has(label)) {
1119 // During the commit phase, we don't show duplicate labels because
1120 // there is a fixed overhead for every measurement, and we don't
1121 // want to stretch the commit phase beyond necessary.
1122 return false;
1123 }
1124
1125 labelsInCurrentCommit.add(label);
1126 var markName = getFiberMarkName(label, debugID);
1127 beginMark(markName);
1128 return true;
1129};
1130
1131var clearFiberMark = function (fiber, phase) {
1132 var componentName = getComponentName(fiber.type) || 'Unknown';
1133 var debugID = fiber._debugID;
1134 var isMounted = fiber.alternate !== null;
1135 var label = getFiberLabel(componentName, isMounted, phase);
1136 var markName = getFiberMarkName(label, debugID);
1137 clearMark(markName);
1138};
1139
1140var endFiberMark = function (fiber, phase, warning) {
1141 var componentName = getComponentName(fiber.type) || 'Unknown';
1142 var debugID = fiber._debugID;
1143 var isMounted = fiber.alternate !== null;
1144 var label = getFiberLabel(componentName, isMounted, phase);
1145 var markName = getFiberMarkName(label, debugID);
1146 endMark(label, markName, warning);
1147};
1148
1149var shouldIgnoreFiber = function (fiber) {
1150 // Host components should be skipped in the timeline.
1151 // We could check typeof fiber.type, but does this work with RN?
1152 switch (fiber.tag) {
1153 case HostRoot:
1154 case HostComponent:
1155 case HostText:
1156 case HostPortal:
1157 case Fragment:
1158 case ContextProvider:
1159 case ContextConsumer:
1160 case Mode:
1161 return true;
1162
1163 default:
1164 return false;
1165 }
1166};
1167
1168var clearPendingPhaseMeasurement = function () {
1169 if (currentPhase !== null && currentPhaseFiber !== null) {
1170 clearFiberMark(currentPhaseFiber, currentPhase);
1171 }
1172
1173 currentPhaseFiber = null;
1174 currentPhase = null;
1175 hasScheduledUpdateInCurrentPhase = false;
1176};
1177
1178var pauseTimers = function () {
1179 // Stops all currently active measurements so that they can be resumed
1180 // if we continue in a later deferred loop from the same unit of work.
1181 var fiber = currentFiber;
1182
1183 while (fiber) {
1184 if (fiber._debugIsCurrentlyTiming) {
1185 endFiberMark(fiber, null, null);
1186 }
1187
1188 fiber = fiber.return;
1189 }
1190};
1191
1192var resumeTimersRecursively = function (fiber) {
1193 if (fiber.return !== null) {
1194 resumeTimersRecursively(fiber.return);
1195 }
1196
1197 if (fiber._debugIsCurrentlyTiming) {
1198 beginFiberMark(fiber, null);
1199 }
1200};
1201
1202var resumeTimers = function () {
1203 // Resumes all measurements that were active during the last deferred loop.
1204 if (currentFiber !== null) {
1205 resumeTimersRecursively(currentFiber);
1206 }
1207};
1208
1209function recordEffect() {
1210 if (enableUserTimingAPI) {
1211 effectCountInCurrentCommit++;
1212 }
1213}
1214function recordScheduleUpdate() {
1215 if (enableUserTimingAPI) {
1216 if (isCommitting) {
1217 hasScheduledUpdateInCurrentCommit = true;
1218 }
1219
1220 if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
1221 hasScheduledUpdateInCurrentPhase = true;
1222 }
1223 }
1224}
1225
1226
1227function startWorkTimer(fiber) {
1228 if (enableUserTimingAPI) {
1229 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1230 return;
1231 } // If we pause, this is the fiber to unwind from.
1232
1233
1234 currentFiber = fiber;
1235
1236 if (!beginFiberMark(fiber, null)) {
1237 return;
1238 }
1239
1240 fiber._debugIsCurrentlyTiming = true;
1241 }
1242}
1243function cancelWorkTimer(fiber) {
1244 if (enableUserTimingAPI) {
1245 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1246 return;
1247 } // Remember we shouldn't complete measurement for this fiber.
1248 // Otherwise flamechart will be deep even for small updates.
1249
1250
1251 fiber._debugIsCurrentlyTiming = false;
1252 clearFiberMark(fiber, null);
1253 }
1254}
1255function stopWorkTimer(fiber) {
1256 if (enableUserTimingAPI) {
1257 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1258 return;
1259 } // If we pause, its parent is the fiber to unwind from.
1260
1261
1262 currentFiber = fiber.return;
1263
1264 if (!fiber._debugIsCurrentlyTiming) {
1265 return;
1266 }
1267
1268 fiber._debugIsCurrentlyTiming = false;
1269 endFiberMark(fiber, null, null);
1270 }
1271}
1272function stopFailedWorkTimer(fiber) {
1273 if (enableUserTimingAPI) {
1274 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1275 return;
1276 } // If we pause, its parent is the fiber to unwind from.
1277
1278
1279 currentFiber = fiber.return;
1280
1281 if (!fiber._debugIsCurrentlyTiming) {
1282 return;
1283 }
1284
1285 fiber._debugIsCurrentlyTiming = false;
1286 var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1287 endFiberMark(fiber, null, warning);
1288 }
1289}
1290function startPhaseTimer(fiber, phase) {
1291 if (enableUserTimingAPI) {
1292 if (!supportsUserTiming) {
1293 return;
1294 }
1295
1296 clearPendingPhaseMeasurement();
1297
1298 if (!beginFiberMark(fiber, phase)) {
1299 return;
1300 }
1301
1302 currentPhaseFiber = fiber;
1303 currentPhase = phase;
1304 }
1305}
1306function stopPhaseTimer() {
1307 if (enableUserTimingAPI) {
1308 if (!supportsUserTiming) {
1309 return;
1310 }
1311
1312 if (currentPhase !== null && currentPhaseFiber !== null) {
1313 var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
1314 endFiberMark(currentPhaseFiber, currentPhase, warning);
1315 }
1316
1317 currentPhase = null;
1318 currentPhaseFiber = null;
1319 }
1320}
1321function startWorkLoopTimer(nextUnitOfWork) {
1322 if (enableUserTimingAPI) {
1323 currentFiber = nextUnitOfWork;
1324
1325 if (!supportsUserTiming) {
1326 return;
1327 }
1328
1329 commitCountInCurrentWorkLoop = 0; // This is top level call.
1330 // Any other measurements are performed within.
1331
1332 beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop.
1333
1334 resumeTimers();
1335 }
1336}
1337function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
1338 if (enableUserTimingAPI) {
1339 if (!supportsUserTiming) {
1340 return;
1341 }
1342
1343 var warning = null;
1344
1345 if (interruptedBy !== null) {
1346 if (interruptedBy.tag === HostRoot) {
1347 warning = 'A top-level update interrupted the previous render';
1348 } else {
1349 var componentName = getComponentName(interruptedBy.type) || 'Unknown';
1350 warning = "An update to " + componentName + " interrupted the previous render";
1351 }
1352 } else if (commitCountInCurrentWorkLoop > 1) {
1353 warning = 'There were cascading updates';
1354 }
1355
1356 commitCountInCurrentWorkLoop = 0;
1357 var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; // Pause any measurements until the next loop.
1358
1359 pauseTimers();
1360 endMark(label, '(React Tree Reconciliation)', warning);
1361 }
1362}
1363function startCommitTimer() {
1364 if (enableUserTimingAPI) {
1365 if (!supportsUserTiming) {
1366 return;
1367 }
1368
1369 isCommitting = true;
1370 hasScheduledUpdateInCurrentCommit = false;
1371 labelsInCurrentCommit.clear();
1372 beginMark('(Committing Changes)');
1373 }
1374}
1375function stopCommitTimer() {
1376 if (enableUserTimingAPI) {
1377 if (!supportsUserTiming) {
1378 return;
1379 }
1380
1381 var warning = null;
1382
1383 if (hasScheduledUpdateInCurrentCommit) {
1384 warning = 'Lifecycle hook scheduled a cascading update';
1385 } else if (commitCountInCurrentWorkLoop > 0) {
1386 warning = 'Caused by a cascading update in earlier commit';
1387 }
1388
1389 hasScheduledUpdateInCurrentCommit = false;
1390 commitCountInCurrentWorkLoop++;
1391 isCommitting = false;
1392 labelsInCurrentCommit.clear();
1393 endMark('(Committing Changes)', '(Committing Changes)', warning);
1394 }
1395}
1396function startCommitSnapshotEffectsTimer() {
1397 if (enableUserTimingAPI) {
1398 if (!supportsUserTiming) {
1399 return;
1400 }
1401
1402 effectCountInCurrentCommit = 0;
1403 beginMark('(Committing Snapshot Effects)');
1404 }
1405}
1406function stopCommitSnapshotEffectsTimer() {
1407 if (enableUserTimingAPI) {
1408 if (!supportsUserTiming) {
1409 return;
1410 }
1411
1412 var count = effectCountInCurrentCommit;
1413 effectCountInCurrentCommit = 0;
1414 endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null);
1415 }
1416}
1417function startCommitHostEffectsTimer() {
1418 if (enableUserTimingAPI) {
1419 if (!supportsUserTiming) {
1420 return;
1421 }
1422
1423 effectCountInCurrentCommit = 0;
1424 beginMark('(Committing Host Effects)');
1425 }
1426}
1427function stopCommitHostEffectsTimer() {
1428 if (enableUserTimingAPI) {
1429 if (!supportsUserTiming) {
1430 return;
1431 }
1432
1433 var count = effectCountInCurrentCommit;
1434 effectCountInCurrentCommit = 0;
1435 endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null);
1436 }
1437}
1438function startCommitLifeCyclesTimer() {
1439 if (enableUserTimingAPI) {
1440 if (!supportsUserTiming) {
1441 return;
1442 }
1443
1444 effectCountInCurrentCommit = 0;
1445 beginMark('(Calling Lifecycle Methods)');
1446 }
1447}
1448function stopCommitLifeCyclesTimer() {
1449 if (enableUserTimingAPI) {
1450 if (!supportsUserTiming) {
1451 return;
1452 }
1453
1454 var count = effectCountInCurrentCommit;
1455 effectCountInCurrentCommit = 0;
1456 endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null);
1457 }
1458}
1459
1460var valueStack = [];
1461var fiberStack;
1462
1463{
1464 fiberStack = [];
1465}
1466
1467var index = -1;
1468
1469function createCursor(defaultValue) {
1470 return {
1471 current: defaultValue
1472 };
1473}
1474
1475function pop(cursor, fiber) {
1476 if (index < 0) {
1477 {
1478 warningWithoutStack$1(false, 'Unexpected pop.');
1479 }
1480
1481 return;
1482 }
1483
1484 {
1485 if (fiber !== fiberStack[index]) {
1486 warningWithoutStack$1(false, 'Unexpected Fiber popped.');
1487 }
1488 }
1489
1490 cursor.current = valueStack[index];
1491 valueStack[index] = null;
1492
1493 {
1494 fiberStack[index] = null;
1495 }
1496
1497 index--;
1498}
1499
1500function push(cursor, value, fiber) {
1501 index++;
1502 valueStack[index] = cursor.current;
1503
1504 {
1505 fiberStack[index] = fiber;
1506 }
1507
1508 cursor.current = value;
1509}
1510
1511var warnedAboutMissingGetChildContext;
1512
1513{
1514 warnedAboutMissingGetChildContext = {};
1515}
1516
1517var emptyContextObject = {};
1518
1519{
1520 Object.freeze(emptyContextObject);
1521} // A cursor to the current merged context object on the stack.
1522
1523
1524var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed.
1525
1526var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack.
1527// We use this to get access to the parent context after we have already
1528// pushed the next context provider, and now need to merge their contexts.
1529
1530var previousContext = emptyContextObject;
1531
1532function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
1533 if (disableLegacyContext) {
1534 return emptyContextObject;
1535 } else {
1536 if (didPushOwnContextIfProvider && isContextProvider(Component)) {
1537 // If the fiber is a context provider itself, when we read its context
1538 // we may have already pushed its own child context on the stack. A context
1539 // provider should not "see" its own child context. Therefore we read the
1540 // previous (parent) context instead for a context provider.
1541 return previousContext;
1542 }
1543
1544 return contextStackCursor.current;
1545 }
1546}
1547
1548function cacheContext(workInProgress, unmaskedContext, maskedContext) {
1549 if (disableLegacyContext) {
1550 return;
1551 } else {
1552 var instance = workInProgress.stateNode;
1553 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
1554 instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
1555 }
1556}
1557
1558function getMaskedContext(workInProgress, unmaskedContext) {
1559 if (disableLegacyContext) {
1560 return emptyContextObject;
1561 } else {
1562 var type = workInProgress.type;
1563 var contextTypes = type.contextTypes;
1564
1565 if (!contextTypes) {
1566 return emptyContextObject;
1567 } // Avoid recreating masked context unless unmasked context has changed.
1568 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
1569 // This may trigger infinite loops if componentWillReceiveProps calls setState.
1570
1571
1572 var instance = workInProgress.stateNode;
1573
1574 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
1575 return instance.__reactInternalMemoizedMaskedChildContext;
1576 }
1577
1578 var context = {};
1579
1580 for (var key in contextTypes) {
1581 context[key] = unmaskedContext[key];
1582 }
1583
1584 {
1585 var name = getComponentName(type) || 'Unknown';
1586 checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
1587 } // Cache unmasked context so we can avoid recreating masked context unless necessary.
1588 // Context is created before the class component is instantiated so check for instance.
1589
1590
1591 if (instance) {
1592 cacheContext(workInProgress, unmaskedContext, context);
1593 }
1594
1595 return context;
1596 }
1597}
1598
1599function hasContextChanged() {
1600 if (disableLegacyContext) {
1601 return false;
1602 } else {
1603 return didPerformWorkStackCursor.current;
1604 }
1605}
1606
1607function isContextProvider(type) {
1608 if (disableLegacyContext) {
1609 return false;
1610 } else {
1611 var childContextTypes = type.childContextTypes;
1612 return childContextTypes !== null && childContextTypes !== undefined;
1613 }
1614}
1615
1616function popContext(fiber) {
1617 if (disableLegacyContext) {
1618 return;
1619 } else {
1620 pop(didPerformWorkStackCursor, fiber);
1621 pop(contextStackCursor, fiber);
1622 }
1623}
1624
1625function popTopLevelContextObject(fiber) {
1626 if (disableLegacyContext) {
1627 return;
1628 } else {
1629 pop(didPerformWorkStackCursor, fiber);
1630 pop(contextStackCursor, fiber);
1631 }
1632}
1633
1634function pushTopLevelContextObject(fiber, context, didChange) {
1635 if (disableLegacyContext) {
1636 return;
1637 } else {
1638 (function () {
1639 if (!(contextStackCursor.current === emptyContextObject)) {
1640 {
1641 throw ReactError(Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue."));
1642 }
1643 }
1644 })();
1645
1646 push(contextStackCursor, context, fiber);
1647 push(didPerformWorkStackCursor, didChange, fiber);
1648 }
1649}
1650
1651function processChildContext(fiber, type, parentContext) {
1652 if (disableLegacyContext) {
1653 return parentContext;
1654 } else {
1655 var instance = fiber.stateNode;
1656 var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future.
1657 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
1658
1659 if (typeof instance.getChildContext !== 'function') {
1660 {
1661 var componentName = getComponentName(type) || 'Unknown';
1662
1663 if (!warnedAboutMissingGetChildContext[componentName]) {
1664 warnedAboutMissingGetChildContext[componentName] = true;
1665 warningWithoutStack$1(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
1666 }
1667 }
1668
1669 return parentContext;
1670 }
1671
1672 var childContext;
1673
1674 {
1675 setCurrentPhase('getChildContext');
1676 }
1677
1678 startPhaseTimer(fiber, 'getChildContext');
1679 childContext = instance.getChildContext();
1680 stopPhaseTimer();
1681
1682 {
1683 setCurrentPhase(null);
1684 }
1685
1686 for (var contextKey in childContext) {
1687 (function () {
1688 if (!(contextKey in childContextTypes)) {
1689 {
1690 throw ReactError(Error((getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes."));
1691 }
1692 }
1693 })();
1694 }
1695
1696 {
1697 var name = getComponentName(type) || 'Unknown';
1698 checkPropTypes(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when
1699 // somebody calls unstable_renderSubtreeIntoContainer() and we process
1700 // context from the parent component instance. The stack will be missing
1701 // because it's outside of the reconciliation, and so the pointer has not
1702 // been set. This is rare and doesn't matter. We'll also remove that API.
1703 getCurrentFiberStackInDev);
1704 }
1705
1706 return _assign({}, parentContext, {}, childContext);
1707 }
1708}
1709
1710function pushContextProvider(workInProgress) {
1711 if (disableLegacyContext) {
1712 return false;
1713 } else {
1714 var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity.
1715 // If the instance does not exist yet, we will push null at first,
1716 // and replace it on the stack later when invalidating the context.
1717
1718 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later.
1719 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
1720
1721 previousContext = contextStackCursor.current;
1722 push(contextStackCursor, memoizedMergedChildContext, workInProgress);
1723 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
1724 return true;
1725 }
1726}
1727
1728function invalidateContextProvider(workInProgress, type, didChange) {
1729 if (disableLegacyContext) {
1730 return;
1731 } else {
1732 var instance = workInProgress.stateNode;
1733
1734 (function () {
1735 if (!instance) {
1736 {
1737 throw ReactError(Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue."));
1738 }
1739 }
1740 })();
1741
1742 if (didChange) {
1743 // Merge parent and own context.
1744 // Skip this if we're not updating due to sCU.
1745 // This avoids unnecessarily recomputing memoized values.
1746 var mergedContext = processChildContext(workInProgress, type, previousContext);
1747 instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one.
1748 // It is important to unwind the context in the reverse order.
1749
1750 pop(didPerformWorkStackCursor, workInProgress);
1751 pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed.
1752
1753 push(contextStackCursor, mergedContext, workInProgress);
1754 push(didPerformWorkStackCursor, didChange, workInProgress);
1755 } else {
1756 pop(didPerformWorkStackCursor, workInProgress);
1757 push(didPerformWorkStackCursor, didChange, workInProgress);
1758 }
1759 }
1760}
1761
1762function findCurrentUnmaskedContext(fiber) {
1763 if (disableLegacyContext) {
1764 return emptyContextObject;
1765 } else {
1766 // Currently this is only used with renderSubtreeIntoContainer; not sure if it
1767 // makes sense elsewhere
1768 (function () {
1769 if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
1770 {
1771 throw ReactError(Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue."));
1772 }
1773 }
1774 })();
1775
1776 var node = fiber;
1777
1778 do {
1779 switch (node.tag) {
1780 case HostRoot:
1781 return node.stateNode.context;
1782
1783 case ClassComponent:
1784 {
1785 var Component = node.type;
1786
1787 if (isContextProvider(Component)) {
1788 return node.stateNode.__reactInternalMemoizedMergedChildContext;
1789 }
1790
1791 break;
1792 }
1793 }
1794
1795 node = node.return;
1796 } while (node !== null);
1797
1798 (function () {
1799 {
1800 {
1801 throw ReactError(Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue."));
1802 }
1803 }
1804 })();
1805 }
1806}
1807
1808var BatchedRoot = 1;
1809var ConcurrentRoot = 2;
1810
1811// Intentionally not named imports because Rollup would use dynamic dispatch for
1812// CommonJS interop named imports.
1813var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority;
1814var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback;
1815var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback;
1816var Scheduler_shouldYield = Scheduler.unstable_shouldYield;
1817var Scheduler_requestPaint = Scheduler.unstable_requestPaint;
1818var Scheduler_now = Scheduler.unstable_now;
1819var Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel;
1820var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority;
1821var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
1822var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority;
1823var Scheduler_LowPriority = Scheduler.unstable_LowPriority;
1824var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
1825
1826if (enableSchedulerTracing) {
1827 // Provide explicit error message when production+profiling bundle of e.g.
1828 // react-dom is used with production (non-profiling) bundle of
1829 // scheduler/tracing
1830 (function () {
1831 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
1832 {
1833 throw ReactError(Error("It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling"));
1834 }
1835 }
1836 })();
1837}
1838
1839var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
1840// ascending numbers so we can compare them like numbers. They start at 90 to
1841// avoid clashing with Scheduler's priorities.
1842
1843var ImmediatePriority = 99;
1844var UserBlockingPriority = 98;
1845var NormalPriority = 97;
1846var LowPriority = 96;
1847var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only.
1848
1849var NoPriority = 90;
1850var shouldYield = Scheduler_shouldYield;
1851var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
1852Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
1853var syncQueue = null;
1854var immediateQueueCallbackNode = null;
1855var isFlushingSyncQueue = false;
1856var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
1857// This will be the case for modern browsers that support `performance.now`. In
1858// older browsers, Scheduler falls back to `Date.now`, which returns a Unix
1859// timestamp. In that case, subtract the module initialization time to simulate
1860// the behavior of performance.now and keep our times small enough to fit
1861// within 32 bits.
1862// TODO: Consider lifting this into Scheduler.
1863
1864var now$1 = initialTimeMs < 10000 ? Scheduler_now : function () {
1865 return Scheduler_now() - initialTimeMs;
1866};
1867function getCurrentPriorityLevel() {
1868 switch (Scheduler_getCurrentPriorityLevel()) {
1869 case Scheduler_ImmediatePriority:
1870 return ImmediatePriority;
1871
1872 case Scheduler_UserBlockingPriority:
1873 return UserBlockingPriority;
1874
1875 case Scheduler_NormalPriority:
1876 return NormalPriority;
1877
1878 case Scheduler_LowPriority:
1879 return LowPriority;
1880
1881 case Scheduler_IdlePriority:
1882 return IdlePriority;
1883
1884 default:
1885 (function () {
1886 {
1887 {
1888 throw ReactError(Error("Unknown priority level."));
1889 }
1890 }
1891 })();
1892
1893 }
1894}
1895
1896function reactPriorityToSchedulerPriority(reactPriorityLevel) {
1897 switch (reactPriorityLevel) {
1898 case ImmediatePriority:
1899 return Scheduler_ImmediatePriority;
1900
1901 case UserBlockingPriority:
1902 return Scheduler_UserBlockingPriority;
1903
1904 case NormalPriority:
1905 return Scheduler_NormalPriority;
1906
1907 case LowPriority:
1908 return Scheduler_LowPriority;
1909
1910 case IdlePriority:
1911 return Scheduler_IdlePriority;
1912
1913 default:
1914 (function () {
1915 {
1916 {
1917 throw ReactError(Error("Unknown priority level."));
1918 }
1919 }
1920 })();
1921
1922 }
1923}
1924
1925function runWithPriority(reactPriorityLevel, fn) {
1926 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
1927 return Scheduler_runWithPriority(priorityLevel, fn);
1928}
1929function scheduleCallback(reactPriorityLevel, callback, options) {
1930 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
1931 return Scheduler_scheduleCallback(priorityLevel, callback, options);
1932}
1933function scheduleSyncCallback(callback) {
1934 // Push this callback into an internal queue. We'll flush these either in
1935 // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
1936 if (syncQueue === null) {
1937 syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
1938
1939 immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
1940 } else {
1941 // Push onto existing queue. Don't need to schedule a callback because
1942 // we already scheduled one when we created the queue.
1943 syncQueue.push(callback);
1944 }
1945
1946 return fakeCallbackNode;
1947}
1948function cancelCallback(callbackNode) {
1949 if (callbackNode !== fakeCallbackNode) {
1950 Scheduler_cancelCallback(callbackNode);
1951 }
1952}
1953function flushSyncCallbackQueue() {
1954 if (immediateQueueCallbackNode !== null) {
1955 var node = immediateQueueCallbackNode;
1956 immediateQueueCallbackNode = null;
1957 Scheduler_cancelCallback(node);
1958 }
1959
1960 flushSyncCallbackQueueImpl();
1961}
1962
1963function flushSyncCallbackQueueImpl() {
1964 if (!isFlushingSyncQueue && syncQueue !== null) {
1965 // Prevent re-entrancy.
1966 isFlushingSyncQueue = true;
1967 var i = 0;
1968
1969 try {
1970 var _isSync = true;
1971 var queue = syncQueue;
1972 runWithPriority(ImmediatePriority, function () {
1973 for (; i < queue.length; i++) {
1974 var callback = queue[i];
1975
1976 do {
1977 callback = callback(_isSync);
1978 } while (callback !== null);
1979 }
1980 });
1981 syncQueue = null;
1982 } catch (error) {
1983 // If something throws, leave the remaining callbacks on the queue.
1984 if (syncQueue !== null) {
1985 syncQueue = syncQueue.slice(i + 1);
1986 } // Resume flushing in the next tick
1987
1988
1989 Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
1990 throw error;
1991 } finally {
1992 isFlushingSyncQueue = false;
1993 }
1994 }
1995}
1996
1997var NoMode = 0;
1998var StrictMode = 1; // TODO: Remove BatchedMode and ConcurrentMode by reading from the root
1999// tag instead
2000
2001var BatchedMode = 2;
2002var ConcurrentMode = 4;
2003var ProfileMode = 8;
2004
2005// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
2006// Math.pow(2, 30) - 1
2007// 0b111111111111111111111111111111
2008var MAX_SIGNED_31_BIT_INT = 1073741823;
2009
2010var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that
2011// Never work can be committed in an inconsistent state without tearing the UI.
2012// The main example is offscreen content, like a hidden subtree. So one possible
2013// name is Offscreen. However, it also includes dehydrated Suspense boundaries,
2014// which are inconsistent in the sense that they haven't finished yet, but
2015// aren't visibly inconsistent because the server rendered HTML matches what the
2016// hydrated tree would look like.
2017
2018var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in
2019// order to be consistent.
2020
2021var Idle = 2;
2022var Sync = MAX_SIGNED_31_BIT_INT;
2023var Batched = Sync - 1;
2024var UNIT_SIZE = 10;
2025var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms.
2026
2027function msToExpirationTime(ms) {
2028 // Always add an offset so that we don't clash with the magic number for NoWork.
2029 return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
2030}
2031function expirationTimeToMs(expirationTime) {
2032 return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
2033}
2034
2035function ceiling(num, precision) {
2036 return ((num / precision | 0) + 1) * precision;
2037}
2038
2039function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
2040 return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
2041} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
2042// the names to reflect.
2043
2044
2045var LOW_PRIORITY_EXPIRATION = 5000;
2046var LOW_PRIORITY_BATCH_SIZE = 250;
2047function computeAsyncExpiration(currentTime) {
2048 return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
2049}
2050function computeSuspenseExpiration(currentTime, timeoutMs) {
2051 // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
2052 return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
2053} // We intentionally set a higher expiration time for interactive updates in
2054// dev than in production.
2055//
2056// If the main thread is being blocked so long that you hit the expiration,
2057// it's a problem that could be solved with better scheduling.
2058//
2059// People will be more likely to notice this and fix it with the long
2060// expiration time in development.
2061//
2062// In production we opt for better UX at the risk of masking scheduling
2063// problems, by expiring fast.
2064
2065var HIGH_PRIORITY_EXPIRATION = 500;
2066var HIGH_PRIORITY_BATCH_SIZE = 100;
2067function computeInteractiveExpiration(currentTime) {
2068 return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
2069}
2070function inferPriorityFromExpirationTime(currentTime, expirationTime) {
2071 if (expirationTime === Sync) {
2072 return ImmediatePriority;
2073 }
2074
2075 if (expirationTime === Never || expirationTime === Idle) {
2076 return IdlePriority;
2077 }
2078
2079 var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
2080
2081 if (msUntil <= 0) {
2082 return ImmediatePriority;
2083 }
2084
2085 if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
2086 return UserBlockingPriority;
2087 }
2088
2089 if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
2090 return NormalPriority;
2091 } // TODO: Handle LowPriority
2092 // Assume anything lower has idle priority
2093
2094
2095 return IdlePriority;
2096}
2097
2098/**
2099 * inlined Object.is polyfill to avoid requiring consumers ship their own
2100 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
2101 */
2102function is(x, y) {
2103 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
2104 ;
2105}
2106
2107var is$1 = typeof Object.is === 'function' ? Object.is : is;
2108
2109var hasOwnProperty = Object.prototype.hasOwnProperty;
2110/**
2111 * Performs equality by iterating through keys on an object and returning false
2112 * when any key has values which are not strictly equal between the arguments.
2113 * Returns true when the values of all keys are strictly equal.
2114 */
2115
2116function shallowEqual(objA, objB) {
2117 if (is$1(objA, objB)) {
2118 return true;
2119 }
2120
2121 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
2122 return false;
2123 }
2124
2125 var keysA = Object.keys(objA);
2126 var keysB = Object.keys(objB);
2127
2128 if (keysA.length !== keysB.length) {
2129 return false;
2130 } // Test for A's keys different from B.
2131
2132
2133 for (var i = 0; i < keysA.length; i++) {
2134 if (!hasOwnProperty.call(objB, keysA[i]) || !is$1(objA[keysA[i]], objB[keysA[i]])) {
2135 return false;
2136 }
2137 }
2138
2139 return true;
2140}
2141
2142/**
2143 * Forked from fbjs/warning:
2144 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
2145 *
2146 * Only change is we use console.warn instead of console.error,
2147 * and do nothing when 'console' is not supported.
2148 * This really simplifies the code.
2149 * ---
2150 * Similar to invariant but only logs a warning if the condition is not met.
2151 * This can be used to log issues in development environments in critical
2152 * paths. Removing the logging code for production environments will keep the
2153 * same logic and follow the same code paths.
2154 */
2155var lowPriorityWarningWithoutStack = function () {};
2156
2157{
2158 var printWarning = function (format) {
2159 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2160 args[_key - 1] = arguments[_key];
2161 }
2162
2163 var argIndex = 0;
2164 var message = 'Warning: ' + format.replace(/%s/g, function () {
2165 return args[argIndex++];
2166 });
2167
2168 if (typeof console !== 'undefined') {
2169 console.warn(message);
2170 }
2171
2172 try {
2173 // --- Welcome to debugging React ---
2174 // This error was thrown as a convenience so that you can use this stack
2175 // to find the callsite that caused this warning to fire.
2176 throw new Error(message);
2177 } catch (x) {}
2178 };
2179
2180 lowPriorityWarningWithoutStack = function (condition, format) {
2181 if (format === undefined) {
2182 throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
2183 }
2184
2185 if (!condition) {
2186 for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2187 args[_key2 - 2] = arguments[_key2];
2188 }
2189
2190 printWarning.apply(void 0, [format].concat(args));
2191 }
2192 };
2193}
2194
2195var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
2196
2197var ReactStrictModeWarnings = {
2198 recordUnsafeLifecycleWarnings: function (fiber, instance) {},
2199 flushPendingUnsafeLifecycleWarnings: function () {},
2200 recordLegacyContextWarning: function (fiber, instance) {},
2201 flushLegacyContextWarning: function () {},
2202 discardPendingWarnings: function () {}
2203};
2204
2205{
2206 var findStrictRoot = function (fiber) {
2207 var maybeStrictRoot = null;
2208 var node = fiber;
2209
2210 while (node !== null) {
2211 if (node.mode & StrictMode) {
2212 maybeStrictRoot = node;
2213 }
2214
2215 node = node.return;
2216 }
2217
2218 return maybeStrictRoot;
2219 };
2220
2221 var setToSortedString = function (set) {
2222 var array = [];
2223 set.forEach(function (value) {
2224 array.push(value);
2225 });
2226 return array.sort().join(', ');
2227 };
2228
2229 var pendingComponentWillMountWarnings = [];
2230 var pendingUNSAFE_ComponentWillMountWarnings = [];
2231 var pendingComponentWillReceivePropsWarnings = [];
2232 var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2233 var pendingComponentWillUpdateWarnings = [];
2234 var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
2235
2236 var didWarnAboutUnsafeLifecycles = new Set();
2237
2238 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
2239 // Dedup strategy: Warn once per component.
2240 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
2241 return;
2242 }
2243
2244 if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components.
2245 instance.componentWillMount.__suppressDeprecationWarning !== true) {
2246 pendingComponentWillMountWarnings.push(fiber);
2247 }
2248
2249 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
2250 pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
2251 }
2252
2253 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
2254 pendingComponentWillReceivePropsWarnings.push(fiber);
2255 }
2256
2257 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
2258 pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
2259 }
2260
2261 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
2262 pendingComponentWillUpdateWarnings.push(fiber);
2263 }
2264
2265 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
2266 pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
2267 }
2268 };
2269
2270 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
2271 // We do an initial pass to gather component names
2272 var componentWillMountUniqueNames = new Set();
2273
2274 if (pendingComponentWillMountWarnings.length > 0) {
2275 pendingComponentWillMountWarnings.forEach(function (fiber) {
2276 componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
2277 didWarnAboutUnsafeLifecycles.add(fiber.type);
2278 });
2279 pendingComponentWillMountWarnings = [];
2280 }
2281
2282 var UNSAFE_componentWillMountUniqueNames = new Set();
2283
2284 if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
2285 pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
2286 UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
2287 didWarnAboutUnsafeLifecycles.add(fiber.type);
2288 });
2289 pendingUNSAFE_ComponentWillMountWarnings = [];
2290 }
2291
2292 var componentWillReceivePropsUniqueNames = new Set();
2293
2294 if (pendingComponentWillReceivePropsWarnings.length > 0) {
2295 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
2296 componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
2297 didWarnAboutUnsafeLifecycles.add(fiber.type);
2298 });
2299 pendingComponentWillReceivePropsWarnings = [];
2300 }
2301
2302 var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
2303
2304 if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
2305 pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
2306 UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
2307 didWarnAboutUnsafeLifecycles.add(fiber.type);
2308 });
2309 pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2310 }
2311
2312 var componentWillUpdateUniqueNames = new Set();
2313
2314 if (pendingComponentWillUpdateWarnings.length > 0) {
2315 pendingComponentWillUpdateWarnings.forEach(function (fiber) {
2316 componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
2317 didWarnAboutUnsafeLifecycles.add(fiber.type);
2318 });
2319 pendingComponentWillUpdateWarnings = [];
2320 }
2321
2322 var UNSAFE_componentWillUpdateUniqueNames = new Set();
2323
2324 if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
2325 pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
2326 UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
2327 didWarnAboutUnsafeLifecycles.add(fiber.type);
2328 });
2329 pendingUNSAFE_ComponentWillUpdateWarnings = [];
2330 } // Finally, we flush all the warnings
2331 // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
2332
2333
2334 if (UNSAFE_componentWillMountUniqueNames.size > 0) {
2335 var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
2336 warningWithoutStack$1(false, 'Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames);
2337 }
2338
2339 if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
2340 var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
2341
2342 warningWithoutStack$1(false, 'Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames);
2343 }
2344
2345 if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
2346 var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
2347
2348 warningWithoutStack$1(false, 'Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
2349 }
2350
2351 if (componentWillMountUniqueNames.size > 0) {
2352 var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
2353
2354 lowPriorityWarningWithoutStack$1(false, 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3);
2355 }
2356
2357 if (componentWillReceivePropsUniqueNames.size > 0) {
2358 var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
2359
2360 lowPriorityWarningWithoutStack$1(false, 'componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4);
2361 }
2362
2363 if (componentWillUpdateUniqueNames.size > 0) {
2364 var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
2365
2366 lowPriorityWarningWithoutStack$1(false, 'componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5);
2367 }
2368 };
2369
2370 var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
2371
2372 var didWarnAboutLegacyContext = new Set();
2373
2374 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
2375 var strictRoot = findStrictRoot(fiber);
2376
2377 if (strictRoot === null) {
2378 warningWithoutStack$1(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
2379 return;
2380 } // Dedup strategy: Warn once per component.
2381
2382
2383 if (didWarnAboutLegacyContext.has(fiber.type)) {
2384 return;
2385 }
2386
2387 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
2388
2389 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
2390 if (warningsForRoot === undefined) {
2391 warningsForRoot = [];
2392 pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
2393 }
2394
2395 warningsForRoot.push(fiber);
2396 }
2397 };
2398
2399 ReactStrictModeWarnings.flushLegacyContextWarning = function () {
2400 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
2401 var uniqueNames = new Set();
2402 fiberArray.forEach(function (fiber) {
2403 uniqueNames.add(getComponentName(fiber.type) || 'Component');
2404 didWarnAboutLegacyContext.add(fiber.type);
2405 });
2406 var sortedNames = setToSortedString(uniqueNames);
2407 var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
2408 warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' + '%s', sortedNames, strictRootComponentStack);
2409 });
2410 };
2411
2412 ReactStrictModeWarnings.discardPendingWarnings = function () {
2413 pendingComponentWillMountWarnings = [];
2414 pendingUNSAFE_ComponentWillMountWarnings = [];
2415 pendingComponentWillReceivePropsWarnings = [];
2416 pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2417 pendingComponentWillUpdateWarnings = [];
2418 pendingUNSAFE_ComponentWillUpdateWarnings = [];
2419 pendingLegacyContextWarning = new Map();
2420 };
2421}
2422
2423var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
2424
2425var failedBoundaries = null;
2426var setRefreshHandler = function (handler) {
2427 {
2428 resolveFamily = handler;
2429 }
2430};
2431function resolveFunctionForHotReloading(type) {
2432 {
2433 if (resolveFamily === null) {
2434 // Hot reloading is disabled.
2435 return type;
2436 }
2437
2438 var family = resolveFamily(type);
2439
2440 if (family === undefined) {
2441 return type;
2442 } // Use the latest known implementation.
2443
2444
2445 return family.current;
2446 }
2447}
2448function resolveClassForHotReloading(type) {
2449 // No implementation differences.
2450 return resolveFunctionForHotReloading(type);
2451}
2452function resolveForwardRefForHotReloading(type) {
2453 {
2454 if (resolveFamily === null) {
2455 // Hot reloading is disabled.
2456 return type;
2457 }
2458
2459 var family = resolveFamily(type);
2460
2461 if (family === undefined) {
2462 // Check if we're dealing with a real forwardRef. Don't want to crash early.
2463 if (type !== null && type !== undefined && typeof type.render === 'function') {
2464 // ForwardRef is special because its resolved .type is an object,
2465 // but it's possible that we only have its inner render function in the map.
2466 // If that inner render function is different, we'll build a new forwardRef type.
2467 var currentRender = resolveFunctionForHotReloading(type.render);
2468
2469 if (type.render !== currentRender) {
2470 var syntheticType = {
2471 $$typeof: REACT_FORWARD_REF_TYPE,
2472 render: currentRender
2473 };
2474
2475 if (type.displayName !== undefined) {
2476 syntheticType.displayName = type.displayName;
2477 }
2478
2479 return syntheticType;
2480 }
2481 }
2482
2483 return type;
2484 } // Use the latest known implementation.
2485
2486
2487 return family.current;
2488 }
2489}
2490function isCompatibleFamilyForHotReloading(fiber, element) {
2491 {
2492 if (resolveFamily === null) {
2493 // Hot reloading is disabled.
2494 return false;
2495 }
2496
2497 var prevType = fiber.elementType;
2498 var nextType = element.type; // If we got here, we know types aren't === equal.
2499
2500 var needsCompareFamilies = false;
2501 var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
2502
2503 switch (fiber.tag) {
2504 case ClassComponent:
2505 {
2506 if (typeof nextType === 'function') {
2507 needsCompareFamilies = true;
2508 }
2509
2510 break;
2511 }
2512
2513 case FunctionComponent:
2514 {
2515 if (typeof nextType === 'function') {
2516 needsCompareFamilies = true;
2517 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2518 // We don't know the inner type yet.
2519 // We're going to assume that the lazy inner type is stable,
2520 // and so it is sufficient to avoid reconciling it away.
2521 // We're not going to unwrap or actually use the new lazy type.
2522 needsCompareFamilies = true;
2523 }
2524
2525 break;
2526 }
2527
2528 case ForwardRef:
2529 {
2530 if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
2531 needsCompareFamilies = true;
2532 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2533 needsCompareFamilies = true;
2534 }
2535
2536 break;
2537 }
2538
2539 case MemoComponent:
2540 case SimpleMemoComponent:
2541 {
2542 if ($$typeofNextType === REACT_MEMO_TYPE) {
2543 // TODO: if it was but can no longer be simple,
2544 // we shouldn't set this.
2545 needsCompareFamilies = true;
2546 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2547 needsCompareFamilies = true;
2548 }
2549
2550 break;
2551 }
2552
2553 default:
2554 return false;
2555 } // Check if both types have a family and it's the same one.
2556
2557
2558 if (needsCompareFamilies) {
2559 // Note: memo() and forwardRef() we'll compare outer rather than inner type.
2560 // This means both of them need to be registered to preserve state.
2561 // If we unwrapped and compared the inner types for wrappers instead,
2562 // then we would risk falsely saying two separate memo(Foo)
2563 // calls are equivalent because they wrap the same Foo function.
2564 var prevFamily = resolveFamily(prevType);
2565
2566 if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
2567 return true;
2568 }
2569 }
2570
2571 return false;
2572 }
2573}
2574function markFailedErrorBoundaryForHotReloading(fiber) {
2575 {
2576 if (resolveFamily === null) {
2577 // Hot reloading is disabled.
2578 return;
2579 }
2580
2581 if (typeof WeakSet !== 'function') {
2582 return;
2583 }
2584
2585 if (failedBoundaries === null) {
2586 failedBoundaries = new WeakSet();
2587 }
2588
2589 failedBoundaries.add(fiber);
2590 }
2591}
2592var scheduleRefresh = function (root, update) {
2593 {
2594 if (resolveFamily === null) {
2595 // Hot reloading is disabled.
2596 return;
2597 }
2598
2599 var staleFamilies = update.staleFamilies,
2600 updatedFamilies = update.updatedFamilies;
2601 flushPassiveEffects();
2602 flushSync(function () {
2603 scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
2604 });
2605 }
2606};
2607var scheduleRoot = function (root, element) {
2608 {
2609 if (root.context !== emptyContextObject) {
2610 // Super edge case: root has a legacy _renderSubtree context
2611 // but we don't know the parentComponent so we can't pass it.
2612 // Just ignore. We'll delete this with _renderSubtree code path later.
2613 return;
2614 }
2615
2616 flushPassiveEffects();
2617 updateContainerAtExpirationTime(element, root, null, Sync, null);
2618 }
2619};
2620
2621function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
2622 {
2623 var alternate = fiber.alternate,
2624 child = fiber.child,
2625 sibling = fiber.sibling,
2626 tag = fiber.tag,
2627 type = fiber.type;
2628 var candidateType = null;
2629
2630 switch (tag) {
2631 case FunctionComponent:
2632 case SimpleMemoComponent:
2633 case ClassComponent:
2634 candidateType = type;
2635 break;
2636
2637 case ForwardRef:
2638 candidateType = type.render;
2639 break;
2640
2641 default:
2642 break;
2643 }
2644
2645 if (resolveFamily === null) {
2646 throw new Error('Expected resolveFamily to be set during hot reload.');
2647 }
2648
2649 var needsRender = false;
2650 var needsRemount = false;
2651
2652 if (candidateType !== null) {
2653 var family = resolveFamily(candidateType);
2654
2655 if (family !== undefined) {
2656 if (staleFamilies.has(family)) {
2657 needsRemount = true;
2658 } else if (updatedFamilies.has(family)) {
2659 if (tag === ClassComponent) {
2660 needsRemount = true;
2661 } else {
2662 needsRender = true;
2663 }
2664 }
2665 }
2666 }
2667
2668 if (failedBoundaries !== null) {
2669 if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
2670 needsRemount = true;
2671 }
2672 }
2673
2674 if (needsRemount) {
2675 fiber._debugNeedsRemount = true;
2676 }
2677
2678 if (needsRemount || needsRender) {
2679 scheduleWork(fiber, Sync);
2680 }
2681
2682 if (child !== null && !needsRemount) {
2683 scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
2684 }
2685
2686 if (sibling !== null) {
2687 scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
2688 }
2689 }
2690}
2691
2692var findHostInstancesForRefresh = function (root, families) {
2693 {
2694 var hostInstances = new Set();
2695 var types = new Set(families.map(function (family) {
2696 return family.current;
2697 }));
2698 findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
2699 return hostInstances;
2700 }
2701};
2702
2703function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
2704 {
2705 var child = fiber.child,
2706 sibling = fiber.sibling,
2707 tag = fiber.tag,
2708 type = fiber.type;
2709 var candidateType = null;
2710
2711 switch (tag) {
2712 case FunctionComponent:
2713 case SimpleMemoComponent:
2714 case ClassComponent:
2715 candidateType = type;
2716 break;
2717
2718 case ForwardRef:
2719 candidateType = type.render;
2720 break;
2721
2722 default:
2723 break;
2724 }
2725
2726 var didMatch = false;
2727
2728 if (candidateType !== null) {
2729 if (types.has(candidateType)) {
2730 didMatch = true;
2731 }
2732 }
2733
2734 if (didMatch) {
2735 // We have a match. This only drills down to the closest host components.
2736 // There's no need to search deeper because for the purpose of giving
2737 // visual feedback, "flashing" outermost parent rectangles is sufficient.
2738 findHostInstancesForFiberShallowly(fiber, hostInstances);
2739 } else {
2740 // If there's no match, maybe there will be one further down in the child tree.
2741 if (child !== null) {
2742 findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
2743 }
2744 }
2745
2746 if (sibling !== null) {
2747 findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
2748 }
2749 }
2750}
2751
2752function findHostInstancesForFiberShallowly(fiber, hostInstances) {
2753 {
2754 var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
2755
2756 if (foundHostInstances) {
2757 return;
2758 } // If we didn't find any host children, fallback to closest host parent.
2759
2760
2761 var node = fiber;
2762
2763 while (true) {
2764 switch (node.tag) {
2765 case HostComponent:
2766 hostInstances.add(node.stateNode);
2767 return;
2768
2769 case HostPortal:
2770 hostInstances.add(node.stateNode.containerInfo);
2771 return;
2772
2773 case HostRoot:
2774 hostInstances.add(node.stateNode.containerInfo);
2775 return;
2776 }
2777
2778 if (node.return === null) {
2779 throw new Error('Expected to reach root first.');
2780 }
2781
2782 node = node.return;
2783 }
2784 }
2785}
2786
2787function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
2788 {
2789 var node = fiber;
2790 var foundHostInstances = false;
2791
2792 while (true) {
2793 if (node.tag === HostComponent) {
2794 // We got a match.
2795 foundHostInstances = true;
2796 hostInstances.add(node.stateNode); // There may still be more, so keep searching.
2797 } else if (node.child !== null) {
2798 node.child.return = node;
2799 node = node.child;
2800 continue;
2801 }
2802
2803 if (node === fiber) {
2804 return foundHostInstances;
2805 }
2806
2807 while (node.sibling === null) {
2808 if (node.return === null || node.return === fiber) {
2809 return foundHostInstances;
2810 }
2811
2812 node = node.return;
2813 }
2814
2815 node.sibling.return = node.return;
2816 node = node.sibling;
2817 }
2818 }
2819
2820 return false;
2821}
2822
2823function resolveDefaultProps(Component, baseProps) {
2824 if (Component && Component.defaultProps) {
2825 // Resolve default props. Taken from ReactElement
2826 var props = _assign({}, baseProps);
2827
2828 var defaultProps = Component.defaultProps;
2829
2830 for (var propName in defaultProps) {
2831 if (props[propName] === undefined) {
2832 props[propName] = defaultProps[propName];
2833 }
2834 }
2835
2836 return props;
2837 }
2838
2839 return baseProps;
2840}
2841function readLazyComponentType(lazyComponent) {
2842 initializeLazyComponentType(lazyComponent);
2843
2844 if (lazyComponent._status !== Resolved) {
2845 throw lazyComponent._result;
2846 }
2847
2848 return lazyComponent._result;
2849}
2850
2851var valueCursor = createCursor(null);
2852var rendererSigil;
2853
2854{
2855 // Use this to detect multiple renderers using the same context
2856 rendererSigil = {};
2857}
2858
2859var currentlyRenderingFiber = null;
2860var lastContextDependency = null;
2861var lastContextWithAllBitsObserved = null;
2862var isDisallowedContextReadInDEV = false;
2863function resetContextDependencies() {
2864 // This is called right before React yields execution, to ensure `readContext`
2865 // cannot be called outside the render phase.
2866 currentlyRenderingFiber = null;
2867 lastContextDependency = null;
2868 lastContextWithAllBitsObserved = null;
2869
2870 {
2871 isDisallowedContextReadInDEV = false;
2872 }
2873}
2874function enterDisallowedContextReadInDEV() {
2875 {
2876 isDisallowedContextReadInDEV = true;
2877 }
2878}
2879function exitDisallowedContextReadInDEV() {
2880 {
2881 isDisallowedContextReadInDEV = false;
2882 }
2883}
2884function pushProvider(providerFiber, nextValue) {
2885 var context = providerFiber.type._context;
2886
2887 if (isPrimaryRenderer) {
2888 push(valueCursor, context._currentValue, providerFiber);
2889 context._currentValue = nextValue;
2890
2891 {
2892 !(context._currentRenderer === undefined || context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
2893 context._currentRenderer = rendererSigil;
2894 }
2895 } else {
2896 push(valueCursor, context._currentValue2, providerFiber);
2897 context._currentValue2 = nextValue;
2898
2899 {
2900 !(context._currentRenderer2 === undefined || context._currentRenderer2 === null || context._currentRenderer2 === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
2901 context._currentRenderer2 = rendererSigil;
2902 }
2903 }
2904}
2905function popProvider(providerFiber) {
2906 var currentValue = valueCursor.current;
2907 pop(valueCursor, providerFiber);
2908 var context = providerFiber.type._context;
2909
2910 if (isPrimaryRenderer) {
2911 context._currentValue = currentValue;
2912 } else {
2913 context._currentValue2 = currentValue;
2914 }
2915}
2916function calculateChangedBits(context, newValue, oldValue) {
2917 if (is$1(oldValue, newValue)) {
2918 // No change
2919 return 0;
2920 } else {
2921 var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
2922
2923 {
2924 !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
2925 }
2926
2927 return changedBits | 0;
2928 }
2929}
2930function scheduleWorkOnParentPath(parent, renderExpirationTime) {
2931 // Update the child expiration time of all the ancestors, including
2932 // the alternates.
2933 var node = parent;
2934
2935 while (node !== null) {
2936 var alternate = node.alternate;
2937
2938 if (node.childExpirationTime < renderExpirationTime) {
2939 node.childExpirationTime = renderExpirationTime;
2940
2941 if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
2942 alternate.childExpirationTime = renderExpirationTime;
2943 }
2944 } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
2945 alternate.childExpirationTime = renderExpirationTime;
2946 } else {
2947 // Neither alternate was updated, which means the rest of the
2948 // ancestor path already has sufficient priority.
2949 break;
2950 }
2951
2952 node = node.return;
2953 }
2954}
2955function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
2956 var fiber = workInProgress.child;
2957
2958 if (fiber !== null) {
2959 // Set the return pointer of the child to the work-in-progress fiber.
2960 fiber.return = workInProgress;
2961 }
2962
2963 while (fiber !== null) {
2964 var nextFiber = void 0; // Visit this fiber.
2965
2966 var list = fiber.dependencies;
2967
2968 if (list !== null) {
2969 nextFiber = fiber.child;
2970 var dependency = list.firstContext;
2971
2972 while (dependency !== null) {
2973 // Check if the context matches.
2974 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
2975 // Match! Schedule an update on this fiber.
2976 if (fiber.tag === ClassComponent) {
2977 // Schedule a force update on the work-in-progress.
2978 var update = createUpdate(renderExpirationTime, null);
2979 update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
2980 // update to the current fiber, too, which means it will persist even if
2981 // this render is thrown away. Since it's a race condition, not sure it's
2982 // worth fixing.
2983
2984 enqueueUpdate(fiber, update);
2985 }
2986
2987 if (fiber.expirationTime < renderExpirationTime) {
2988 fiber.expirationTime = renderExpirationTime;
2989 }
2990
2991 var alternate = fiber.alternate;
2992
2993 if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
2994 alternate.expirationTime = renderExpirationTime;
2995 }
2996
2997 scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too.
2998
2999 if (list.expirationTime < renderExpirationTime) {
3000 list.expirationTime = renderExpirationTime;
3001 } // Since we already found a match, we can stop traversing the
3002 // dependency list.
3003
3004
3005 break;
3006 }
3007
3008 dependency = dependency.next;
3009 }
3010 } else if (fiber.tag === ContextProvider) {
3011 // Don't scan deeper if this is a matching provider
3012 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
3013 } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedFragment) {
3014 // If a dehydrated suspense bounudary is in this subtree, we don't know
3015 // if it will have any context consumers in it. The best we can do is
3016 // mark it as having updates.
3017 var parentSuspense = fiber.return;
3018
3019 (function () {
3020 if (!(parentSuspense !== null)) {
3021 {
3022 throw ReactError(Error("We just came from a parent so we must have had a parent. This is a bug in React."));
3023 }
3024 }
3025 })();
3026
3027 if (parentSuspense.expirationTime < renderExpirationTime) {
3028 parentSuspense.expirationTime = renderExpirationTime;
3029 }
3030
3031 var _alternate = parentSuspense.alternate;
3032
3033 if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
3034 _alternate.expirationTime = renderExpirationTime;
3035 } // This is intentionally passing this fiber as the parent
3036 // because we want to schedule this fiber as having work
3037 // on its children. We'll use the childExpirationTime on
3038 // this fiber to indicate that a context has changed.
3039
3040
3041 scheduleWorkOnParentPath(parentSuspense, renderExpirationTime);
3042 nextFiber = fiber.sibling;
3043 } else {
3044 // Traverse down.
3045 nextFiber = fiber.child;
3046 }
3047
3048 if (nextFiber !== null) {
3049 // Set the return pointer of the child to the work-in-progress fiber.
3050 nextFiber.return = fiber;
3051 } else {
3052 // No child. Traverse to next sibling.
3053 nextFiber = fiber;
3054
3055 while (nextFiber !== null) {
3056 if (nextFiber === workInProgress) {
3057 // We're back to the root of this subtree. Exit.
3058 nextFiber = null;
3059 break;
3060 }
3061
3062 var sibling = nextFiber.sibling;
3063
3064 if (sibling !== null) {
3065 // Set the return pointer of the sibling to the work-in-progress fiber.
3066 sibling.return = nextFiber.return;
3067 nextFiber = sibling;
3068 break;
3069 } // No more siblings. Traverse up.
3070
3071
3072 nextFiber = nextFiber.return;
3073 }
3074 }
3075
3076 fiber = nextFiber;
3077 }
3078}
3079function prepareToReadContext(workInProgress, renderExpirationTime) {
3080 currentlyRenderingFiber = workInProgress;
3081 lastContextDependency = null;
3082 lastContextWithAllBitsObserved = null;
3083 var dependencies = workInProgress.dependencies;
3084
3085 if (dependencies !== null) {
3086 var firstContext = dependencies.firstContext;
3087
3088 if (firstContext !== null) {
3089 if (dependencies.expirationTime >= renderExpirationTime) {
3090 // Context list has a pending update. Mark that this fiber performed work.
3091 markWorkInProgressReceivedUpdate();
3092 } // Reset the work-in-progress list
3093
3094
3095 dependencies.firstContext = null;
3096 }
3097 }
3098}
3099function readContext(context, observedBits) {
3100 {
3101 // This warning would fire if you read context inside a Hook like useMemo.
3102 // Unlike the class check below, it's not enforced in production for perf.
3103 !!isDisallowedContextReadInDEV ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
3104 }
3105
3106 if (lastContextWithAllBitsObserved === context) {// Nothing to do. We already observe everything in this context.
3107 } else if (observedBits === false || observedBits === 0) {// Do not observe any updates.
3108 } else {
3109 var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types.
3110
3111 if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
3112 // Observe all updates.
3113 lastContextWithAllBitsObserved = context;
3114 resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
3115 } else {
3116 resolvedObservedBits = observedBits;
3117 }
3118
3119 var contextItem = {
3120 context: context,
3121 observedBits: resolvedObservedBits,
3122 next: null
3123 };
3124
3125 if (lastContextDependency === null) {
3126 (function () {
3127 if (!(currentlyRenderingFiber !== null)) {
3128 {
3129 throw ReactError(Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."));
3130 }
3131 }
3132 })(); // This is the first dependency for this component. Create a new list.
3133
3134
3135 lastContextDependency = contextItem;
3136 currentlyRenderingFiber.dependencies = {
3137 expirationTime: NoWork,
3138 firstContext: contextItem,
3139 responders: null
3140 };
3141 } else {
3142 // Append a new context item.
3143 lastContextDependency = lastContextDependency.next = contextItem;
3144 }
3145 }
3146
3147 return isPrimaryRenderer ? context._currentValue : context._currentValue2;
3148}
3149
3150// UpdateQueue is a linked list of prioritized updates.
3151//
3152// Like fibers, update queues come in pairs: a current queue, which represents
3153// the visible state of the screen, and a work-in-progress queue, which can be
3154// mutated and processed asynchronously before it is committed — a form of
3155// double buffering. If a work-in-progress render is discarded before finishing,
3156// we create a new work-in-progress by cloning the current queue.
3157//
3158// Both queues share a persistent, singly-linked list structure. To schedule an
3159// update, we append it to the end of both queues. Each queue maintains a
3160// pointer to first update in the persistent list that hasn't been processed.
3161// The work-in-progress pointer always has a position equal to or greater than
3162// the current queue, since we always work on that one. The current queue's
3163// pointer is only updated during the commit phase, when we swap in the
3164// work-in-progress.
3165//
3166// For example:
3167//
3168// Current pointer: A - B - C - D - E - F
3169// Work-in-progress pointer: D - E - F
3170// ^
3171// The work-in-progress queue has
3172// processed more updates than current.
3173//
3174// The reason we append to both queues is because otherwise we might drop
3175// updates without ever processing them. For example, if we only add updates to
3176// the work-in-progress queue, some updates could be lost whenever a work-in
3177// -progress render restarts by cloning from current. Similarly, if we only add
3178// updates to the current queue, the updates will be lost whenever an already
3179// in-progress queue commits and swaps with the current queue. However, by
3180// adding to both queues, we guarantee that the update will be part of the next
3181// work-in-progress. (And because the work-in-progress queue becomes the
3182// current queue once it commits, there's no danger of applying the same
3183// update twice.)
3184//
3185// Prioritization
3186// --------------
3187//
3188// Updates are not sorted by priority, but by insertion; new updates are always
3189// appended to the end of the list.
3190//
3191// The priority is still important, though. When processing the update queue
3192// during the render phase, only the updates with sufficient priority are
3193// included in the result. If we skip an update because it has insufficient
3194// priority, it remains in the queue to be processed later, during a lower
3195// priority render. Crucially, all updates subsequent to a skipped update also
3196// remain in the queue *regardless of their priority*. That means high priority
3197// updates are sometimes processed twice, at two separate priorities. We also
3198// keep track of a base state, that represents the state before the first
3199// update in the queue is applied.
3200//
3201// For example:
3202//
3203// Given a base state of '', and the following queue of updates
3204//
3205// A1 - B2 - C1 - D2
3206//
3207// where the number indicates the priority, and the update is applied to the
3208// previous state by appending a letter, React will process these updates as
3209// two separate renders, one per distinct priority level:
3210//
3211// First render, at priority 1:
3212// Base state: ''
3213// Updates: [A1, C1]
3214// Result state: 'AC'
3215//
3216// Second render, at priority 2:
3217// Base state: 'A' <- The base state does not include C1,
3218// because B2 was skipped.
3219// Updates: [B2, C1, D2] <- C1 was rebased on top of B2
3220// Result state: 'ABCD'
3221//
3222// Because we process updates in insertion order, and rebase high priority
3223// updates when preceding updates are skipped, the final result is deterministic
3224// regardless of priority. Intermediate state may vary according to system
3225// resources, but the final state is always the same.
3226var UpdateState = 0;
3227var ReplaceState = 1;
3228var ForceUpdate = 2;
3229var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`.
3230// It should only be read right after calling `processUpdateQueue`, via
3231// `checkHasForceUpdateAfterProcessing`.
3232
3233var hasForceUpdate = false;
3234var didWarnUpdateInsideUpdate;
3235var currentlyProcessingQueue;
3236
3237
3238{
3239 didWarnUpdateInsideUpdate = false;
3240 currentlyProcessingQueue = null;
3241
3242
3243}
3244
3245function createUpdateQueue(baseState) {
3246 var queue = {
3247 baseState: baseState,
3248 firstUpdate: null,
3249 lastUpdate: null,
3250 firstCapturedUpdate: null,
3251 lastCapturedUpdate: null,
3252 firstEffect: null,
3253 lastEffect: null,
3254 firstCapturedEffect: null,
3255 lastCapturedEffect: null
3256 };
3257 return queue;
3258}
3259
3260function cloneUpdateQueue(currentQueue) {
3261 var queue = {
3262 baseState: currentQueue.baseState,
3263 firstUpdate: currentQueue.firstUpdate,
3264 lastUpdate: currentQueue.lastUpdate,
3265 // TODO: With resuming, if we bail out and resuse the child tree, we should
3266 // keep these effects.
3267 firstCapturedUpdate: null,
3268 lastCapturedUpdate: null,
3269 firstEffect: null,
3270 lastEffect: null,
3271 firstCapturedEffect: null,
3272 lastCapturedEffect: null
3273 };
3274 return queue;
3275}
3276
3277function createUpdate(expirationTime, suspenseConfig) {
3278 var update = {
3279 expirationTime: expirationTime,
3280 suspenseConfig: suspenseConfig,
3281 tag: UpdateState,
3282 payload: null,
3283 callback: null,
3284 next: null,
3285 nextEffect: null
3286 };
3287
3288 {
3289 update.priority = getCurrentPriorityLevel();
3290 }
3291
3292 return update;
3293}
3294
3295function appendUpdateToQueue(queue, update) {
3296 // Append the update to the end of the list.
3297 if (queue.lastUpdate === null) {
3298 // Queue is empty
3299 queue.firstUpdate = queue.lastUpdate = update;
3300 } else {
3301 queue.lastUpdate.next = update;
3302 queue.lastUpdate = update;
3303 }
3304}
3305
3306function enqueueUpdate(fiber, update) {
3307 // Update queues are created lazily.
3308 var alternate = fiber.alternate;
3309 var queue1;
3310 var queue2;
3311
3312 if (alternate === null) {
3313 // There's only one fiber.
3314 queue1 = fiber.updateQueue;
3315 queue2 = null;
3316
3317 if (queue1 === null) {
3318 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
3319 }
3320 } else {
3321 // There are two owners.
3322 queue1 = fiber.updateQueue;
3323 queue2 = alternate.updateQueue;
3324
3325 if (queue1 === null) {
3326 if (queue2 === null) {
3327 // Neither fiber has an update queue. Create new ones.
3328 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
3329 queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
3330 } else {
3331 // Only one fiber has an update queue. Clone to create a new one.
3332 queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
3333 }
3334 } else {
3335 if (queue2 === null) {
3336 // Only one fiber has an update queue. Clone to create a new one.
3337 queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
3338 } else {// Both owners have an update queue.
3339 }
3340 }
3341 }
3342
3343 if (queue2 === null || queue1 === queue2) {
3344 // There's only a single queue.
3345 appendUpdateToQueue(queue1, update);
3346 } else {
3347 // There are two queues. We need to append the update to both queues,
3348 // while accounting for the persistent structure of the list — we don't
3349 // want the same update to be added multiple times.
3350 if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
3351 // One of the queues is not empty. We must add the update to both queues.
3352 appendUpdateToQueue(queue1, update);
3353 appendUpdateToQueue(queue2, update);
3354 } else {
3355 // Both queues are non-empty. The last update is the same in both lists,
3356 // because of structural sharing. So, only append to one of the lists.
3357 appendUpdateToQueue(queue1, update); // But we still need to update the `lastUpdate` pointer of queue2.
3358
3359 queue2.lastUpdate = update;
3360 }
3361 }
3362
3363 {
3364 if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
3365 warningWithoutStack$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
3366 didWarnUpdateInsideUpdate = true;
3367 }
3368 }
3369}
3370function enqueueCapturedUpdate(workInProgress, update) {
3371 // Captured updates go into a separate list, and only on the work-in-
3372 // progress queue.
3373 var workInProgressQueue = workInProgress.updateQueue;
3374
3375 if (workInProgressQueue === null) {
3376 workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
3377 } else {
3378 // TODO: I put this here rather than createWorkInProgress so that we don't
3379 // clone the queue unnecessarily. There's probably a better way to
3380 // structure this.
3381 workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
3382 } // Append the update to the end of the list.
3383
3384
3385 if (workInProgressQueue.lastCapturedUpdate === null) {
3386 // This is the first render phase update
3387 workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
3388 } else {
3389 workInProgressQueue.lastCapturedUpdate.next = update;
3390 workInProgressQueue.lastCapturedUpdate = update;
3391 }
3392}
3393
3394function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
3395 var current = workInProgress.alternate;
3396
3397 if (current !== null) {
3398 // If the work-in-progress queue is equal to the current queue,
3399 // we need to clone it first.
3400 if (queue === current.updateQueue) {
3401 queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
3402 }
3403 }
3404
3405 return queue;
3406}
3407
3408function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
3409 switch (update.tag) {
3410 case ReplaceState:
3411 {
3412 var payload = update.payload;
3413
3414 if (typeof payload === 'function') {
3415 // Updater function
3416 {
3417 enterDisallowedContextReadInDEV();
3418
3419 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3420 payload.call(instance, prevState, nextProps);
3421 }
3422 }
3423
3424 var nextState = payload.call(instance, prevState, nextProps);
3425
3426 {
3427 exitDisallowedContextReadInDEV();
3428 }
3429
3430 return nextState;
3431 } // State object
3432
3433
3434 return payload;
3435 }
3436
3437 case CaptureUpdate:
3438 {
3439 workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
3440 }
3441 // Intentional fallthrough
3442
3443 case UpdateState:
3444 {
3445 var _payload = update.payload;
3446 var partialState;
3447
3448 if (typeof _payload === 'function') {
3449 // Updater function
3450 {
3451 enterDisallowedContextReadInDEV();
3452
3453 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3454 _payload.call(instance, prevState, nextProps);
3455 }
3456 }
3457
3458 partialState = _payload.call(instance, prevState, nextProps);
3459
3460 {
3461 exitDisallowedContextReadInDEV();
3462 }
3463 } else {
3464 // Partial state object
3465 partialState = _payload;
3466 }
3467
3468 if (partialState === null || partialState === undefined) {
3469 // Null and undefined are treated as no-ops.
3470 return prevState;
3471 } // Merge the partial state and the previous state.
3472
3473
3474 return _assign({}, prevState, partialState);
3475 }
3476
3477 case ForceUpdate:
3478 {
3479 hasForceUpdate = true;
3480 return prevState;
3481 }
3482 }
3483
3484 return prevState;
3485}
3486
3487function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
3488 hasForceUpdate = false;
3489 queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
3490
3491 {
3492 currentlyProcessingQueue = queue;
3493 } // These values may change as we process the queue.
3494
3495
3496 var newBaseState = queue.baseState;
3497 var newFirstUpdate = null;
3498 var newExpirationTime = NoWork; // Iterate through the list of updates to compute the result.
3499
3500 var update = queue.firstUpdate;
3501 var resultState = newBaseState;
3502
3503 while (update !== null) {
3504 var updateExpirationTime = update.expirationTime;
3505
3506 if (updateExpirationTime < renderExpirationTime) {
3507 // This update does not have sufficient priority. Skip it.
3508 if (newFirstUpdate === null) {
3509 // This is the first skipped update. It will be the first update in
3510 // the new list.
3511 newFirstUpdate = update; // Since this is the first update that was skipped, the current result
3512 // is the new base state.
3513
3514 newBaseState = resultState;
3515 } // Since this update will remain in the list, update the remaining
3516 // expiration time.
3517
3518
3519 if (newExpirationTime < updateExpirationTime) {
3520 newExpirationTime = updateExpirationTime;
3521 }
3522 } else {
3523 // This update does have sufficient priority.
3524 // Mark the event time of this update as relevant to this render pass.
3525 // TODO: This should ideally use the true event time of this update rather than
3526 // its priority which is a derived and not reverseable value.
3527 // TODO: We should skip this update if it was already committed but currently
3528 // we have no way of detecting the difference between a committed and suspended
3529 // update here.
3530 markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process it and compute a new result.
3531
3532 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
3533 var callback = update.callback;
3534
3535 if (callback !== null) {
3536 workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render.
3537
3538 update.nextEffect = null;
3539
3540 if (queue.lastEffect === null) {
3541 queue.firstEffect = queue.lastEffect = update;
3542 } else {
3543 queue.lastEffect.nextEffect = update;
3544 queue.lastEffect = update;
3545 }
3546 }
3547 } // Continue to the next update.
3548
3549
3550 update = update.next;
3551 } // Separately, iterate though the list of captured updates.
3552
3553
3554 var newFirstCapturedUpdate = null;
3555 update = queue.firstCapturedUpdate;
3556
3557 while (update !== null) {
3558 var _updateExpirationTime = update.expirationTime;
3559
3560 if (_updateExpirationTime < renderExpirationTime) {
3561 // This update does not have sufficient priority. Skip it.
3562 if (newFirstCapturedUpdate === null) {
3563 // This is the first skipped captured update. It will be the first
3564 // update in the new list.
3565 newFirstCapturedUpdate = update; // If this is the first update that was skipped, the current result is
3566 // the new base state.
3567
3568 if (newFirstUpdate === null) {
3569 newBaseState = resultState;
3570 }
3571 } // Since this update will remain in the list, update the remaining
3572 // expiration time.
3573
3574
3575 if (newExpirationTime < _updateExpirationTime) {
3576 newExpirationTime = _updateExpirationTime;
3577 }
3578 } else {
3579 // This update does have sufficient priority. Process it and compute
3580 // a new result.
3581 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
3582 var _callback = update.callback;
3583
3584 if (_callback !== null) {
3585 workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render.
3586
3587 update.nextEffect = null;
3588
3589 if (queue.lastCapturedEffect === null) {
3590 queue.firstCapturedEffect = queue.lastCapturedEffect = update;
3591 } else {
3592 queue.lastCapturedEffect.nextEffect = update;
3593 queue.lastCapturedEffect = update;
3594 }
3595 }
3596 }
3597
3598 update = update.next;
3599 }
3600
3601 if (newFirstUpdate === null) {
3602 queue.lastUpdate = null;
3603 }
3604
3605 if (newFirstCapturedUpdate === null) {
3606 queue.lastCapturedUpdate = null;
3607 } else {
3608 workInProgress.effectTag |= Callback;
3609 }
3610
3611 if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
3612 // We processed every update, without skipping. That means the new base
3613 // state is the same as the result state.
3614 newBaseState = resultState;
3615 }
3616
3617 queue.baseState = newBaseState;
3618 queue.firstUpdate = newFirstUpdate;
3619 queue.firstCapturedUpdate = newFirstCapturedUpdate; // Set the remaining expiration time to be whatever is remaining in the queue.
3620 // This should be fine because the only two other things that contribute to
3621 // expiration time are props and context. We're already in the middle of the
3622 // begin phase by the time we start processing the queue, so we've already
3623 // dealt with the props. Context in components that specify
3624 // shouldComponentUpdate is tricky; but we'll have to account for
3625 // that regardless.
3626
3627 markUnprocessedUpdateTime(newExpirationTime);
3628 workInProgress.expirationTime = newExpirationTime;
3629 workInProgress.memoizedState = resultState;
3630
3631 {
3632 currentlyProcessingQueue = null;
3633 }
3634}
3635
3636function callCallback(callback, context) {
3637 (function () {
3638 if (!(typeof callback === 'function')) {
3639 {
3640 throw ReactError(Error("Invalid argument passed as callback. Expected a function. Instead received: " + callback));
3641 }
3642 }
3643 })();
3644
3645 callback.call(context);
3646}
3647
3648function resetHasForceUpdateBeforeProcessing() {
3649 hasForceUpdate = false;
3650}
3651function checkHasForceUpdateAfterProcessing() {
3652 return hasForceUpdate;
3653}
3654function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
3655 // If the finished render included captured updates, and there are still
3656 // lower priority updates left over, we need to keep the captured updates
3657 // in the queue so that they are rebased and not dropped once we process the
3658 // queue again at the lower priority.
3659 if (finishedQueue.firstCapturedUpdate !== null) {
3660 // Join the captured update list to the end of the normal list.
3661 if (finishedQueue.lastUpdate !== null) {
3662 finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
3663 finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
3664 } // Clear the list of captured updates.
3665
3666
3667 finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
3668 } // Commit the effects
3669
3670
3671 commitUpdateEffects(finishedQueue.firstEffect, instance);
3672 finishedQueue.firstEffect = finishedQueue.lastEffect = null;
3673 commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
3674 finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
3675}
3676
3677function commitUpdateEffects(effect, instance) {
3678 while (effect !== null) {
3679 var callback = effect.callback;
3680
3681 if (callback !== null) {
3682 effect.callback = null;
3683 callCallback(callback, instance);
3684 }
3685
3686 effect = effect.nextEffect;
3687 }
3688}
3689
3690var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
3691function requestCurrentSuspenseConfig() {
3692 return ReactCurrentBatchConfig.suspense;
3693}
3694
3695var fakeInternalInstance = {};
3696var isArray$1 = Array.isArray; // React.Component uses a shared frozen object by default.
3697// We'll use it to determine whether we need to initialize legacy refs.
3698
3699var emptyRefsObject = new React.Component().refs;
3700var didWarnAboutStateAssignmentForComponent;
3701var didWarnAboutUninitializedState;
3702var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
3703var didWarnAboutLegacyLifecyclesAndDerivedState;
3704var didWarnAboutUndefinedDerivedState;
3705var warnOnUndefinedDerivedState;
3706var warnOnInvalidCallback;
3707var didWarnAboutDirectlyAssigningPropsToState;
3708var didWarnAboutContextTypeAndContextTypes;
3709var didWarnAboutInvalidateContextType;
3710
3711{
3712 didWarnAboutStateAssignmentForComponent = new Set();
3713 didWarnAboutUninitializedState = new Set();
3714 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
3715 didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
3716 didWarnAboutDirectlyAssigningPropsToState = new Set();
3717 didWarnAboutUndefinedDerivedState = new Set();
3718 didWarnAboutContextTypeAndContextTypes = new Set();
3719 didWarnAboutInvalidateContextType = new Set();
3720 var didWarnOnInvalidCallback = new Set();
3721
3722 warnOnInvalidCallback = function (callback, callerName) {
3723 if (callback === null || typeof callback === 'function') {
3724 return;
3725 }
3726
3727 var key = callerName + "_" + callback;
3728
3729 if (!didWarnOnInvalidCallback.has(key)) {
3730 didWarnOnInvalidCallback.add(key);
3731 warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
3732 }
3733 };
3734
3735 warnOnUndefinedDerivedState = function (type, partialState) {
3736 if (partialState === undefined) {
3737 var componentName = getComponentName(type) || 'Component';
3738
3739 if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
3740 didWarnAboutUndefinedDerivedState.add(componentName);
3741 warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
3742 }
3743 }
3744 }; // This is so gross but it's at least non-critical and can be removed if
3745 // it causes problems. This is meant to give a nicer error message for
3746 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
3747 // ...)) which otherwise throws a "_processChildContext is not a function"
3748 // exception.
3749
3750
3751 Object.defineProperty(fakeInternalInstance, '_processChildContext', {
3752 enumerable: false,
3753 value: function () {
3754 (function () {
3755 {
3756 {
3757 throw ReactError(Error("_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)."));
3758 }
3759 }
3760 })();
3761 }
3762 });
3763 Object.freeze(fakeInternalInstance);
3764}
3765
3766function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
3767 var prevState = workInProgress.memoizedState;
3768
3769 {
3770 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3771 // Invoke the function an extra time to help detect side-effects.
3772 getDerivedStateFromProps(nextProps, prevState);
3773 }
3774 }
3775
3776 var partialState = getDerivedStateFromProps(nextProps, prevState);
3777
3778 {
3779 warnOnUndefinedDerivedState(ctor, partialState);
3780 } // Merge the partial state and the previous state.
3781
3782
3783 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
3784 workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
3785 // base state.
3786
3787 var updateQueue = workInProgress.updateQueue;
3788
3789 if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
3790 updateQueue.baseState = memoizedState;
3791 }
3792}
3793var classComponentUpdater = {
3794 isMounted: isMounted,
3795 enqueueSetState: function (inst, payload, callback) {
3796 var fiber = get(inst);
3797 var currentTime = requestCurrentTime();
3798 var suspenseConfig = requestCurrentSuspenseConfig();
3799 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
3800 var update = createUpdate(expirationTime, suspenseConfig);
3801 update.payload = payload;
3802
3803 if (callback !== undefined && callback !== null) {
3804 {
3805 warnOnInvalidCallback(callback, 'setState');
3806 }
3807
3808 update.callback = callback;
3809 }
3810
3811 enqueueUpdate(fiber, update);
3812 scheduleWork(fiber, expirationTime);
3813 },
3814 enqueueReplaceState: function (inst, payload, callback) {
3815 var fiber = get(inst);
3816 var currentTime = requestCurrentTime();
3817 var suspenseConfig = requestCurrentSuspenseConfig();
3818 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
3819 var update = createUpdate(expirationTime, suspenseConfig);
3820 update.tag = ReplaceState;
3821 update.payload = payload;
3822
3823 if (callback !== undefined && callback !== null) {
3824 {
3825 warnOnInvalidCallback(callback, 'replaceState');
3826 }
3827
3828 update.callback = callback;
3829 }
3830
3831 enqueueUpdate(fiber, update);
3832 scheduleWork(fiber, expirationTime);
3833 },
3834 enqueueForceUpdate: function (inst, callback) {
3835 var fiber = get(inst);
3836 var currentTime = requestCurrentTime();
3837 var suspenseConfig = requestCurrentSuspenseConfig();
3838 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
3839 var update = createUpdate(expirationTime, suspenseConfig);
3840 update.tag = ForceUpdate;
3841
3842 if (callback !== undefined && callback !== null) {
3843 {
3844 warnOnInvalidCallback(callback, 'forceUpdate');
3845 }
3846
3847 update.callback = callback;
3848 }
3849
3850 enqueueUpdate(fiber, update);
3851 scheduleWork(fiber, expirationTime);
3852 }
3853};
3854
3855function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
3856 var instance = workInProgress.stateNode;
3857
3858 if (typeof instance.shouldComponentUpdate === 'function') {
3859 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
3860 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
3861 stopPhaseTimer();
3862
3863 {
3864 !(shouldUpdate !== undefined) ? warningWithoutStack$1(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component') : void 0;
3865 }
3866
3867 return shouldUpdate;
3868 }
3869
3870 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
3871 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
3872 }
3873
3874 return true;
3875}
3876
3877function checkClassInstance(workInProgress, ctor, newProps) {
3878 var instance = workInProgress.stateNode;
3879
3880 {
3881 var name = getComponentName(ctor) || 'Component';
3882 var renderPresent = instance.render;
3883
3884 if (!renderPresent) {
3885 if (ctor.prototype && typeof ctor.prototype.render === 'function') {
3886 warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
3887 } else {
3888 warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
3889 }
3890 }
3891
3892 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
3893 !noGetInitialStateOnES6 ? warningWithoutStack$1(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0;
3894 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
3895 !noGetDefaultPropsOnES6 ? warningWithoutStack$1(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
3896 var noInstancePropTypes = !instance.propTypes;
3897 !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
3898 var noInstanceContextType = !instance.contextType;
3899 !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
3900
3901 if (disableLegacyContext) {
3902 if (ctor.childContextTypes) {
3903 warningWithoutStack$1(false, '%s uses the legacy childContextTypes API which is no longer supported. ' + 'Use React.createContext() instead.', name);
3904 }
3905
3906 if (ctor.contextTypes) {
3907 warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with static contextType instead.', name);
3908 }
3909 } else {
3910 var noInstanceContextTypes = !instance.contextTypes;
3911 !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
3912
3913 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
3914 didWarnAboutContextTypeAndContextTypes.add(ctor);
3915 warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
3916 }
3917 }
3918
3919 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
3920 !noComponentShouldUpdate ? warningWithoutStack$1(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
3921
3922 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
3923 warningWithoutStack$1(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component');
3924 }
3925
3926 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
3927 !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
3928 var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
3929 !noComponentDidReceiveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0;
3930 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
3931 !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
3932 var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
3933 !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
3934 var hasMutatedProps = instance.props !== newProps;
3935 !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
3936 var noInstanceDefaultProps = !instance.defaultProps;
3937 !noInstanceDefaultProps ? warningWithoutStack$1(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0;
3938
3939 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
3940 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
3941 warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
3942 }
3943
3944 var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
3945 !noInstanceGetDerivedStateFromProps ? warningWithoutStack$1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
3946 var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
3947 !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
3948 var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
3949 !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
3950 var _state = instance.state;
3951
3952 if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
3953 warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
3954 }
3955
3956 if (typeof instance.getChildContext === 'function') {
3957 !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
3958 }
3959 }
3960}
3961
3962function adoptClassInstance(workInProgress, instance) {
3963 instance.updater = classComponentUpdater;
3964 workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates
3965
3966 set(instance, workInProgress);
3967
3968 {
3969 instance._reactInternalInstance = fakeInternalInstance;
3970 }
3971}
3972
3973function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
3974 var isLegacyContextConsumer = false;
3975 var unmaskedContext = emptyContextObject;
3976 var context = emptyContextObject;
3977 var contextType = ctor.contextType;
3978
3979 {
3980 if ('contextType' in ctor) {
3981 var isValid = // Allow null for conditional declaration
3982 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
3983
3984 if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
3985 didWarnAboutInvalidateContextType.add(ctor);
3986 var addendum = '';
3987
3988 if (contextType === undefined) {
3989 addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
3990 } else if (typeof contextType !== 'object') {
3991 addendum = ' However, it is set to a ' + typeof contextType + '.';
3992 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
3993 addendum = ' Did you accidentally pass the Context.Provider instead?';
3994 } else if (contextType._context !== undefined) {
3995 // <Context.Consumer>
3996 addendum = ' Did you accidentally pass the Context.Consumer instead?';
3997 } else {
3998 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
3999 }
4000
4001 warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
4002 }
4003 }
4004 }
4005
4006 if (typeof contextType === 'object' && contextType !== null) {
4007 context = readContext(contextType);
4008 } else if (!disableLegacyContext) {
4009 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4010 var contextTypes = ctor.contextTypes;
4011 isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
4012 context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
4013 } // Instantiate twice to help detect side-effects.
4014
4015
4016 {
4017 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
4018 new ctor(props, context); // eslint-disable-line no-new
4019 }
4020 }
4021
4022 var instance = new ctor(props, context);
4023 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
4024 adoptClassInstance(workInProgress, instance);
4025
4026 {
4027 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
4028 var componentName = getComponentName(ctor) || 'Component';
4029
4030 if (!didWarnAboutUninitializedState.has(componentName)) {
4031 didWarnAboutUninitializedState.add(componentName);
4032 warningWithoutStack$1(false, '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName);
4033 }
4034 } // If new component APIs are defined, "unsafe" lifecycles won't be called.
4035 // Warn about these lifecycles if they are present.
4036 // Don't warn about react-lifecycles-compat polyfilled methods though.
4037
4038
4039 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
4040 var foundWillMountName = null;
4041 var foundWillReceivePropsName = null;
4042 var foundWillUpdateName = null;
4043
4044 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
4045 foundWillMountName = 'componentWillMount';
4046 } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
4047 foundWillMountName = 'UNSAFE_componentWillMount';
4048 }
4049
4050 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
4051 foundWillReceivePropsName = 'componentWillReceiveProps';
4052 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4053 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
4054 }
4055
4056 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
4057 foundWillUpdateName = 'componentWillUpdate';
4058 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4059 foundWillUpdateName = 'UNSAFE_componentWillUpdate';
4060 }
4061
4062 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
4063 var _componentName = getComponentName(ctor) || 'Component';
4064
4065 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
4066
4067 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
4068 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
4069 warningWithoutStack$1(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : '');
4070 }
4071 }
4072 }
4073 } // Cache unmasked context so we can avoid recreating masked context unless necessary.
4074 // ReactFiberContext usually updates this cache but can't for newly-created instances.
4075
4076
4077 if (isLegacyContextConsumer) {
4078 cacheContext(workInProgress, unmaskedContext, context);
4079 }
4080
4081 return instance;
4082}
4083
4084function callComponentWillMount(workInProgress, instance) {
4085 startPhaseTimer(workInProgress, 'componentWillMount');
4086 var oldState = instance.state;
4087
4088 if (typeof instance.componentWillMount === 'function') {
4089 instance.componentWillMount();
4090 }
4091
4092 if (typeof instance.UNSAFE_componentWillMount === 'function') {
4093 instance.UNSAFE_componentWillMount();
4094 }
4095
4096 stopPhaseTimer();
4097
4098 if (oldState !== instance.state) {
4099 {
4100 warningWithoutStack$1(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
4101 }
4102
4103 classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
4104 }
4105}
4106
4107function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
4108 var oldState = instance.state;
4109 startPhaseTimer(workInProgress, 'componentWillReceiveProps');
4110
4111 if (typeof instance.componentWillReceiveProps === 'function') {
4112 instance.componentWillReceiveProps(newProps, nextContext);
4113 }
4114
4115 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4116 instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
4117 }
4118
4119 stopPhaseTimer();
4120
4121 if (instance.state !== oldState) {
4122 {
4123 var componentName = getComponentName(workInProgress.type) || 'Component';
4124
4125 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
4126 didWarnAboutStateAssignmentForComponent.add(componentName);
4127 warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
4128 }
4129 }
4130
4131 classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
4132 }
4133} // Invokes the mount life-cycles on a previously never rendered instance.
4134
4135
4136function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
4137 {
4138 checkClassInstance(workInProgress, ctor, newProps);
4139 }
4140
4141 var instance = workInProgress.stateNode;
4142 instance.props = newProps;
4143 instance.state = workInProgress.memoizedState;
4144 instance.refs = emptyRefsObject;
4145 var contextType = ctor.contextType;
4146
4147 if (typeof contextType === 'object' && contextType !== null) {
4148 instance.context = readContext(contextType);
4149 } else if (disableLegacyContext) {
4150 instance.context = emptyContextObject;
4151 } else {
4152 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4153 instance.context = getMaskedContext(workInProgress, unmaskedContext);
4154 }
4155
4156 {
4157 if (instance.state === newProps) {
4158 var componentName = getComponentName(ctor) || 'Component';
4159
4160 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
4161 didWarnAboutDirectlyAssigningPropsToState.add(componentName);
4162 warningWithoutStack$1(false, '%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName);
4163 }
4164 }
4165
4166 if (workInProgress.mode & StrictMode) {
4167 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
4168 }
4169
4170 if (warnAboutDeprecatedLifecycles) {
4171 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
4172 }
4173 }
4174
4175 var updateQueue = workInProgress.updateQueue;
4176
4177 if (updateQueue !== null) {
4178 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4179 instance.state = workInProgress.memoizedState;
4180 }
4181
4182 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4183
4184 if (typeof getDerivedStateFromProps === 'function') {
4185 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4186 instance.state = workInProgress.memoizedState;
4187 } // In order to support react-lifecycles-compat polyfilled components,
4188 // Unsafe lifecycles should not be invoked for components using the new APIs.
4189
4190
4191 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
4192 callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
4193 // process them now.
4194
4195 updateQueue = workInProgress.updateQueue;
4196
4197 if (updateQueue !== null) {
4198 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4199 instance.state = workInProgress.memoizedState;
4200 }
4201 }
4202
4203 if (typeof instance.componentDidMount === 'function') {
4204 workInProgress.effectTag |= Update;
4205 }
4206}
4207
4208function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
4209 var instance = workInProgress.stateNode;
4210 var oldProps = workInProgress.memoizedProps;
4211 instance.props = oldProps;
4212 var oldContext = instance.context;
4213 var contextType = ctor.contextType;
4214 var nextContext = emptyContextObject;
4215
4216 if (typeof contextType === 'object' && contextType !== null) {
4217 nextContext = readContext(contextType);
4218 } else if (!disableLegacyContext) {
4219 var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4220 nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4221 }
4222
4223 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4224 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
4225 // ever the previously attempted to render - not the "current". However,
4226 // during componentDidUpdate we pass the "current" props.
4227 // In order to support react-lifecycles-compat polyfilled components,
4228 // Unsafe lifecycles should not be invoked for components using the new APIs.
4229
4230 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4231 if (oldProps !== newProps || oldContext !== nextContext) {
4232 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4233 }
4234 }
4235
4236 resetHasForceUpdateBeforeProcessing();
4237 var oldState = workInProgress.memoizedState;
4238 var newState = instance.state = oldState;
4239 var updateQueue = workInProgress.updateQueue;
4240
4241 if (updateQueue !== null) {
4242 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4243 newState = workInProgress.memoizedState;
4244 }
4245
4246 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
4247 // If an update was already in progress, we should schedule an Update
4248 // effect even though we're bailing out, so that cWU/cDU are called.
4249 if (typeof instance.componentDidMount === 'function') {
4250 workInProgress.effectTag |= Update;
4251 }
4252
4253 return false;
4254 }
4255
4256 if (typeof getDerivedStateFromProps === 'function') {
4257 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4258 newState = workInProgress.memoizedState;
4259 }
4260
4261 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4262
4263 if (shouldUpdate) {
4264 // In order to support react-lifecycles-compat polyfilled components,
4265 // Unsafe lifecycles should not be invoked for components using the new APIs.
4266 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
4267 startPhaseTimer(workInProgress, 'componentWillMount');
4268
4269 if (typeof instance.componentWillMount === 'function') {
4270 instance.componentWillMount();
4271 }
4272
4273 if (typeof instance.UNSAFE_componentWillMount === 'function') {
4274 instance.UNSAFE_componentWillMount();
4275 }
4276
4277 stopPhaseTimer();
4278 }
4279
4280 if (typeof instance.componentDidMount === 'function') {
4281 workInProgress.effectTag |= Update;
4282 }
4283 } else {
4284 // If an update was already in progress, we should schedule an Update
4285 // effect even though we're bailing out, so that cWU/cDU are called.
4286 if (typeof instance.componentDidMount === 'function') {
4287 workInProgress.effectTag |= Update;
4288 } // If shouldComponentUpdate returned false, we should still update the
4289 // memoized state to indicate that this work can be reused.
4290
4291
4292 workInProgress.memoizedProps = newProps;
4293 workInProgress.memoizedState = newState;
4294 } // Update the existing instance's state, props, and context pointers even
4295 // if shouldComponentUpdate returns false.
4296
4297
4298 instance.props = newProps;
4299 instance.state = newState;
4300 instance.context = nextContext;
4301 return shouldUpdate;
4302} // Invokes the update life-cycles and returns false if it shouldn't rerender.
4303
4304
4305function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
4306 var instance = workInProgress.stateNode;
4307 var oldProps = workInProgress.memoizedProps;
4308 instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
4309 var oldContext = instance.context;
4310 var contextType = ctor.contextType;
4311 var nextContext = emptyContextObject;
4312
4313 if (typeof contextType === 'object' && contextType !== null) {
4314 nextContext = readContext(contextType);
4315 } else if (!disableLegacyContext) {
4316 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4317 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
4318 }
4319
4320 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4321 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
4322 // ever the previously attempted to render - not the "current". However,
4323 // during componentDidUpdate we pass the "current" props.
4324 // In order to support react-lifecycles-compat polyfilled components,
4325 // Unsafe lifecycles should not be invoked for components using the new APIs.
4326
4327 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4328 if (oldProps !== newProps || oldContext !== nextContext) {
4329 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4330 }
4331 }
4332
4333 resetHasForceUpdateBeforeProcessing();
4334 var oldState = workInProgress.memoizedState;
4335 var newState = instance.state = oldState;
4336 var updateQueue = workInProgress.updateQueue;
4337
4338 if (updateQueue !== null) {
4339 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4340 newState = workInProgress.memoizedState;
4341 }
4342
4343 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
4344 // If an update was already in progress, we should schedule an Update
4345 // effect even though we're bailing out, so that cWU/cDU are called.
4346 if (typeof instance.componentDidUpdate === 'function') {
4347 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4348 workInProgress.effectTag |= Update;
4349 }
4350 }
4351
4352 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4353 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4354 workInProgress.effectTag |= Snapshot;
4355 }
4356 }
4357
4358 return false;
4359 }
4360
4361 if (typeof getDerivedStateFromProps === 'function') {
4362 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4363 newState = workInProgress.memoizedState;
4364 }
4365
4366 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4367
4368 if (shouldUpdate) {
4369 // In order to support react-lifecycles-compat polyfilled components,
4370 // Unsafe lifecycles should not be invoked for components using the new APIs.
4371 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
4372 startPhaseTimer(workInProgress, 'componentWillUpdate');
4373
4374 if (typeof instance.componentWillUpdate === 'function') {
4375 instance.componentWillUpdate(newProps, newState, nextContext);
4376 }
4377
4378 if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4379 instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
4380 }
4381
4382 stopPhaseTimer();
4383 }
4384
4385 if (typeof instance.componentDidUpdate === 'function') {
4386 workInProgress.effectTag |= Update;
4387 }
4388
4389 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4390 workInProgress.effectTag |= Snapshot;
4391 }
4392 } else {
4393 // If an update was already in progress, we should schedule an Update
4394 // effect even though we're bailing out, so that cWU/cDU are called.
4395 if (typeof instance.componentDidUpdate === 'function') {
4396 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4397 workInProgress.effectTag |= Update;
4398 }
4399 }
4400
4401 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4402 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4403 workInProgress.effectTag |= Snapshot;
4404 }
4405 } // If shouldComponentUpdate returned false, we should still update the
4406 // memoized props/state to indicate that this work can be reused.
4407
4408
4409 workInProgress.memoizedProps = newProps;
4410 workInProgress.memoizedState = newState;
4411 } // Update the existing instance's state, props, and context pointers even
4412 // if shouldComponentUpdate returns false.
4413
4414
4415 instance.props = newProps;
4416 instance.state = newState;
4417 instance.context = nextContext;
4418 return shouldUpdate;
4419}
4420
4421var didWarnAboutMaps;
4422var didWarnAboutGenerators;
4423var didWarnAboutStringRefs;
4424var ownerHasKeyUseWarning;
4425var ownerHasFunctionTypeWarning;
4426
4427var warnForMissingKey = function (child) {};
4428
4429{
4430 didWarnAboutMaps = false;
4431 didWarnAboutGenerators = false;
4432 didWarnAboutStringRefs = {};
4433 /**
4434 * Warn if there's no key explicitly set on dynamic arrays of children or
4435 * object keys are not valid. This allows us to keep track of children between
4436 * updates.
4437 */
4438
4439 ownerHasKeyUseWarning = {};
4440 ownerHasFunctionTypeWarning = {};
4441
4442 warnForMissingKey = function (child) {
4443 if (child === null || typeof child !== 'object') {
4444 return;
4445 }
4446
4447 if (!child._store || child._store.validated || child.key != null) {
4448 return;
4449 }
4450
4451 (function () {
4452 if (!(typeof child._store === 'object')) {
4453 {
4454 throw ReactError(Error("React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue."));
4455 }
4456 }
4457 })();
4458
4459 child._store.validated = true;
4460 var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
4461
4462 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
4463 return;
4464 }
4465
4466 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
4467 warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
4468 };
4469}
4470
4471var isArray = Array.isArray;
4472
4473function coerceRef(returnFiber, current$$1, element) {
4474 var mixedRef = element.ref;
4475
4476 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
4477 {
4478 // TODO: Clean this up once we turn on the string ref warning for
4479 // everyone, because the strict mode case will no longer be relevant
4480 if (returnFiber.mode & StrictMode || warnAboutStringRefs) {
4481 var componentName = getComponentName(returnFiber.type) || 'Component';
4482
4483 if (!didWarnAboutStringRefs[componentName]) {
4484 if (warnAboutStringRefs) {
4485 warningWithoutStack$1(false, 'Component "%s" contains the string ref "%s". Support for string refs ' + 'will be removed in a future major release. We recommend using ' + 'useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', componentName, mixedRef, getStackByFiberInDevAndProd(returnFiber));
4486 } else {
4487 warningWithoutStack$1(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', mixedRef, getStackByFiberInDevAndProd(returnFiber));
4488 }
4489
4490 didWarnAboutStringRefs[componentName] = true;
4491 }
4492 }
4493 }
4494
4495 if (element._owner) {
4496 var owner = element._owner;
4497 var inst;
4498
4499 if (owner) {
4500 var ownerFiber = owner;
4501
4502 (function () {
4503 if (!(ownerFiber.tag === ClassComponent)) {
4504 {
4505 throw ReactError(Error("Function components cannot have refs. Did you mean to use React.forwardRef()?"));
4506 }
4507 }
4508 })();
4509
4510 inst = ownerFiber.stateNode;
4511 }
4512
4513 (function () {
4514 if (!inst) {
4515 {
4516 throw ReactError(Error("Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue."));
4517 }
4518 }
4519 })();
4520
4521 var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref
4522
4523 if (current$$1 !== null && current$$1.ref !== null && typeof current$$1.ref === 'function' && current$$1.ref._stringRef === stringRef) {
4524 return current$$1.ref;
4525 }
4526
4527 var ref = function (value) {
4528 var refs = inst.refs;
4529
4530 if (refs === emptyRefsObject) {
4531 // This is a lazy pooled frozen object, so we need to initialize.
4532 refs = inst.refs = {};
4533 }
4534
4535 if (value === null) {
4536 delete refs[stringRef];
4537 } else {
4538 refs[stringRef] = value;
4539 }
4540 };
4541
4542 ref._stringRef = stringRef;
4543 return ref;
4544 } else {
4545 (function () {
4546 if (!(typeof mixedRef === 'string')) {
4547 {
4548 throw ReactError(Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null."));
4549 }
4550 }
4551 })();
4552
4553 (function () {
4554 if (!element._owner) {
4555 {
4556 throw ReactError(Error("Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information."));
4557 }
4558 }
4559 })();
4560 }
4561 }
4562
4563 return mixedRef;
4564}
4565
4566function throwOnInvalidObjectType(returnFiber, newChild) {
4567 if (returnFiber.type !== 'textarea') {
4568 var addendum = '';
4569
4570 {
4571 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
4572 }
4573
4574 (function () {
4575 {
4576 {
4577 throw ReactError(Error("Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ")." + addendum));
4578 }
4579 }
4580 })();
4581 }
4582}
4583
4584function warnOnFunctionType() {
4585 var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + getCurrentFiberStackInDev();
4586
4587 if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
4588 return;
4589 }
4590
4591 ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
4592 warning$1(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.');
4593} // This wrapper function exists because I expect to clone the code in each path
4594// to be able to optimize each path individually by branching early. This needs
4595// a compiler or we can do it manually. Helpers that don't need this branching
4596// live outside of this function.
4597
4598
4599function ChildReconciler(shouldTrackSideEffects) {
4600 function deleteChild(returnFiber, childToDelete) {
4601 if (!shouldTrackSideEffects) {
4602 // Noop.
4603 return;
4604 } // Deletions are added in reversed order so we add it to the front.
4605 // At this point, the return fiber's effect list is empty except for
4606 // deletions, so we can just append the deletion to the list. The remaining
4607 // effects aren't added until the complete phase. Once we implement
4608 // resuming, this may not be true.
4609
4610
4611 var last = returnFiber.lastEffect;
4612
4613 if (last !== null) {
4614 last.nextEffect = childToDelete;
4615 returnFiber.lastEffect = childToDelete;
4616 } else {
4617 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
4618 }
4619
4620 childToDelete.nextEffect = null;
4621 childToDelete.effectTag = Deletion;
4622 }
4623
4624 function deleteRemainingChildren(returnFiber, currentFirstChild) {
4625 if (!shouldTrackSideEffects) {
4626 // Noop.
4627 return null;
4628 } // TODO: For the shouldClone case, this could be micro-optimized a bit by
4629 // assuming that after the first child we've already added everything.
4630
4631
4632 var childToDelete = currentFirstChild;
4633
4634 while (childToDelete !== null) {
4635 deleteChild(returnFiber, childToDelete);
4636 childToDelete = childToDelete.sibling;
4637 }
4638
4639 return null;
4640 }
4641
4642 function mapRemainingChildren(returnFiber, currentFirstChild) {
4643 // Add the remaining children to a temporary map so that we can find them by
4644 // keys quickly. Implicit (null) keys get added to this set with their index
4645 // instead.
4646 var existingChildren = new Map();
4647 var existingChild = currentFirstChild;
4648
4649 while (existingChild !== null) {
4650 if (existingChild.key !== null) {
4651 existingChildren.set(existingChild.key, existingChild);
4652 } else {
4653 existingChildren.set(existingChild.index, existingChild);
4654 }
4655
4656 existingChild = existingChild.sibling;
4657 }
4658
4659 return existingChildren;
4660 }
4661
4662 function useFiber(fiber, pendingProps, expirationTime) {
4663 // We currently set sibling to null and index to 0 here because it is easy
4664 // to forget to do before returning it. E.g. for the single child case.
4665 var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
4666 clone.index = 0;
4667 clone.sibling = null;
4668 return clone;
4669 }
4670
4671 function placeChild(newFiber, lastPlacedIndex, newIndex) {
4672 newFiber.index = newIndex;
4673
4674 if (!shouldTrackSideEffects) {
4675 // Noop.
4676 return lastPlacedIndex;
4677 }
4678
4679 var current$$1 = newFiber.alternate;
4680
4681 if (current$$1 !== null) {
4682 var oldIndex = current$$1.index;
4683
4684 if (oldIndex < lastPlacedIndex) {
4685 // This is a move.
4686 newFiber.effectTag = Placement;
4687 return lastPlacedIndex;
4688 } else {
4689 // This item can stay in place.
4690 return oldIndex;
4691 }
4692 } else {
4693 // This is an insertion.
4694 newFiber.effectTag = Placement;
4695 return lastPlacedIndex;
4696 }
4697 }
4698
4699 function placeSingleChild(newFiber) {
4700 // This is simpler for the single child case. We only need to do a
4701 // placement for inserting new children.
4702 if (shouldTrackSideEffects && newFiber.alternate === null) {
4703 newFiber.effectTag = Placement;
4704 }
4705
4706 return newFiber;
4707 }
4708
4709 function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {
4710 if (current$$1 === null || current$$1.tag !== HostText) {
4711 // Insert
4712 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
4713 created.return = returnFiber;
4714 return created;
4715 } else {
4716 // Update
4717 var existing = useFiber(current$$1, textContent, expirationTime);
4718 existing.return = returnFiber;
4719 return existing;
4720 }
4721 }
4722
4723 function updateElement(returnFiber, current$$1, element, expirationTime) {
4724 if (current$$1 !== null && (current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
4725 isCompatibleFamilyForHotReloading(current$$1, element)))) {
4726 // Move based on index
4727 var existing = useFiber(current$$1, element.props, expirationTime);
4728 existing.ref = coerceRef(returnFiber, current$$1, element);
4729 existing.return = returnFiber;
4730
4731 {
4732 existing._debugSource = element._source;
4733 existing._debugOwner = element._owner;
4734 }
4735
4736 return existing;
4737 } else {
4738 // Insert
4739 var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
4740 created.ref = coerceRef(returnFiber, current$$1, element);
4741 created.return = returnFiber;
4742 return created;
4743 }
4744 }
4745
4746 function updatePortal(returnFiber, current$$1, portal, expirationTime) {
4747 if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {
4748 // Insert
4749 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
4750 created.return = returnFiber;
4751 return created;
4752 } else {
4753 // Update
4754 var existing = useFiber(current$$1, portal.children || [], expirationTime);
4755 existing.return = returnFiber;
4756 return existing;
4757 }
4758 }
4759
4760 function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {
4761 if (current$$1 === null || current$$1.tag !== Fragment) {
4762 // Insert
4763 var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
4764 created.return = returnFiber;
4765 return created;
4766 } else {
4767 // Update
4768 var existing = useFiber(current$$1, fragment, expirationTime);
4769 existing.return = returnFiber;
4770 return existing;
4771 }
4772 }
4773
4774 function createChild(returnFiber, newChild, expirationTime) {
4775 if (typeof newChild === 'string' || typeof newChild === 'number') {
4776 // Text nodes don't have keys. If the previous node is implicitly keyed
4777 // we can continue to replace it without aborting even if it is not a text
4778 // node.
4779 var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
4780 created.return = returnFiber;
4781 return created;
4782 }
4783
4784 if (typeof newChild === 'object' && newChild !== null) {
4785 switch (newChild.$$typeof) {
4786 case REACT_ELEMENT_TYPE:
4787 {
4788 var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
4789
4790 _created.ref = coerceRef(returnFiber, null, newChild);
4791 _created.return = returnFiber;
4792 return _created;
4793 }
4794
4795 case REACT_PORTAL_TYPE:
4796 {
4797 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
4798
4799 _created2.return = returnFiber;
4800 return _created2;
4801 }
4802 }
4803
4804 if (isArray(newChild) || getIteratorFn(newChild)) {
4805 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
4806
4807 _created3.return = returnFiber;
4808 return _created3;
4809 }
4810
4811 throwOnInvalidObjectType(returnFiber, newChild);
4812 }
4813
4814 {
4815 if (typeof newChild === 'function') {
4816 warnOnFunctionType();
4817 }
4818 }
4819
4820 return null;
4821 }
4822
4823 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
4824 // Update the fiber if the keys match, otherwise return null.
4825 var key = oldFiber !== null ? oldFiber.key : null;
4826
4827 if (typeof newChild === 'string' || typeof newChild === 'number') {
4828 // Text nodes don't have keys. If the previous node is implicitly keyed
4829 // we can continue to replace it without aborting even if it is not a text
4830 // node.
4831 if (key !== null) {
4832 return null;
4833 }
4834
4835 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
4836 }
4837
4838 if (typeof newChild === 'object' && newChild !== null) {
4839 switch (newChild.$$typeof) {
4840 case REACT_ELEMENT_TYPE:
4841 {
4842 if (newChild.key === key) {
4843 if (newChild.type === REACT_FRAGMENT_TYPE) {
4844 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
4845 }
4846
4847 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
4848 } else {
4849 return null;
4850 }
4851 }
4852
4853 case REACT_PORTAL_TYPE:
4854 {
4855 if (newChild.key === key) {
4856 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
4857 } else {
4858 return null;
4859 }
4860 }
4861 }
4862
4863 if (isArray(newChild) || getIteratorFn(newChild)) {
4864 if (key !== null) {
4865 return null;
4866 }
4867
4868 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
4869 }
4870
4871 throwOnInvalidObjectType(returnFiber, newChild);
4872 }
4873
4874 {
4875 if (typeof newChild === 'function') {
4876 warnOnFunctionType();
4877 }
4878 }
4879
4880 return null;
4881 }
4882
4883 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
4884 if (typeof newChild === 'string' || typeof newChild === 'number') {
4885 // Text nodes don't have keys, so we neither have to check the old nor
4886 // new node for the key. If both are text nodes, they match.
4887 var matchedFiber = existingChildren.get(newIdx) || null;
4888 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
4889 }
4890
4891 if (typeof newChild === 'object' && newChild !== null) {
4892 switch (newChild.$$typeof) {
4893 case REACT_ELEMENT_TYPE:
4894 {
4895 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
4896
4897 if (newChild.type === REACT_FRAGMENT_TYPE) {
4898 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
4899 }
4900
4901 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
4902 }
4903
4904 case REACT_PORTAL_TYPE:
4905 {
4906 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
4907
4908 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
4909 }
4910 }
4911
4912 if (isArray(newChild) || getIteratorFn(newChild)) {
4913 var _matchedFiber3 = existingChildren.get(newIdx) || null;
4914
4915 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
4916 }
4917
4918 throwOnInvalidObjectType(returnFiber, newChild);
4919 }
4920
4921 {
4922 if (typeof newChild === 'function') {
4923 warnOnFunctionType();
4924 }
4925 }
4926
4927 return null;
4928 }
4929 /**
4930 * Warns if there is a duplicate or missing key
4931 */
4932
4933
4934 function warnOnInvalidKey(child, knownKeys) {
4935 {
4936 if (typeof child !== 'object' || child === null) {
4937 return knownKeys;
4938 }
4939
4940 switch (child.$$typeof) {
4941 case REACT_ELEMENT_TYPE:
4942 case REACT_PORTAL_TYPE:
4943 warnForMissingKey(child);
4944 var key = child.key;
4945
4946 if (typeof key !== 'string') {
4947 break;
4948 }
4949
4950 if (knownKeys === null) {
4951 knownKeys = new Set();
4952 knownKeys.add(key);
4953 break;
4954 }
4955
4956 if (!knownKeys.has(key)) {
4957 knownKeys.add(key);
4958 break;
4959 }
4960
4961 warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);
4962 break;
4963
4964 default:
4965 break;
4966 }
4967 }
4968
4969 return knownKeys;
4970 }
4971
4972 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
4973 // This algorithm can't optimize by searching from both ends since we
4974 // don't have backpointers on fibers. I'm trying to see how far we can get
4975 // with that model. If it ends up not being worth the tradeoffs, we can
4976 // add it later.
4977 // Even with a two ended optimization, we'd want to optimize for the case
4978 // where there are few changes and brute force the comparison instead of
4979 // going for the Map. It'd like to explore hitting that path first in
4980 // forward-only mode and only go for the Map once we notice that we need
4981 // lots of look ahead. This doesn't handle reversal as well as two ended
4982 // search but that's unusual. Besides, for the two ended optimization to
4983 // work on Iterables, we'd need to copy the whole set.
4984 // In this first iteration, we'll just live with hitting the bad case
4985 // (adding everything to a Map) in for every insert/move.
4986 // If you change this code, also update reconcileChildrenIterator() which
4987 // uses the same algorithm.
4988 {
4989 // First, validate keys.
4990 var knownKeys = null;
4991
4992 for (var i = 0; i < newChildren.length; i++) {
4993 var child = newChildren[i];
4994 knownKeys = warnOnInvalidKey(child, knownKeys);
4995 }
4996 }
4997
4998 var resultingFirstChild = null;
4999 var previousNewFiber = null;
5000 var oldFiber = currentFirstChild;
5001 var lastPlacedIndex = 0;
5002 var newIdx = 0;
5003 var nextOldFiber = null;
5004
5005 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
5006 if (oldFiber.index > newIdx) {
5007 nextOldFiber = oldFiber;
5008 oldFiber = null;
5009 } else {
5010 nextOldFiber = oldFiber.sibling;
5011 }
5012
5013 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
5014
5015 if (newFiber === null) {
5016 // TODO: This breaks on empty slots like null children. That's
5017 // unfortunate because it triggers the slow path all the time. We need
5018 // a better way to communicate whether this was a miss or null,
5019 // boolean, undefined, etc.
5020 if (oldFiber === null) {
5021 oldFiber = nextOldFiber;
5022 }
5023
5024 break;
5025 }
5026
5027 if (shouldTrackSideEffects) {
5028 if (oldFiber && newFiber.alternate === null) {
5029 // We matched the slot, but we didn't reuse the existing fiber, so we
5030 // need to delete the existing child.
5031 deleteChild(returnFiber, oldFiber);
5032 }
5033 }
5034
5035 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
5036
5037 if (previousNewFiber === null) {
5038 // TODO: Move out of the loop. This only happens for the first run.
5039 resultingFirstChild = newFiber;
5040 } else {
5041 // TODO: Defer siblings if we're not at the right index for this slot.
5042 // I.e. if we had null values before, then we want to defer this
5043 // for each null value. However, we also don't want to call updateSlot
5044 // with the previous one.
5045 previousNewFiber.sibling = newFiber;
5046 }
5047
5048 previousNewFiber = newFiber;
5049 oldFiber = nextOldFiber;
5050 }
5051
5052 if (newIdx === newChildren.length) {
5053 // We've reached the end of the new children. We can delete the rest.
5054 deleteRemainingChildren(returnFiber, oldFiber);
5055 return resultingFirstChild;
5056 }
5057
5058 if (oldFiber === null) {
5059 // If we don't have any more existing children we can choose a fast path
5060 // since the rest will all be insertions.
5061 for (; newIdx < newChildren.length; newIdx++) {
5062 var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
5063
5064 if (_newFiber === null) {
5065 continue;
5066 }
5067
5068 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
5069
5070 if (previousNewFiber === null) {
5071 // TODO: Move out of the loop. This only happens for the first run.
5072 resultingFirstChild = _newFiber;
5073 } else {
5074 previousNewFiber.sibling = _newFiber;
5075 }
5076
5077 previousNewFiber = _newFiber;
5078 }
5079
5080 return resultingFirstChild;
5081 } // Add all children to a key map for quick lookups.
5082
5083
5084 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
5085
5086 for (; newIdx < newChildren.length; newIdx++) {
5087 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
5088
5089 if (_newFiber2 !== null) {
5090 if (shouldTrackSideEffects) {
5091 if (_newFiber2.alternate !== null) {
5092 // The new fiber is a work in progress, but if there exists a
5093 // current, that means that we reused the fiber. We need to delete
5094 // it from the child list so that we don't add it to the deletion
5095 // list.
5096 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
5097 }
5098 }
5099
5100 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
5101
5102 if (previousNewFiber === null) {
5103 resultingFirstChild = _newFiber2;
5104 } else {
5105 previousNewFiber.sibling = _newFiber2;
5106 }
5107
5108 previousNewFiber = _newFiber2;
5109 }
5110 }
5111
5112 if (shouldTrackSideEffects) {
5113 // Any existing children that weren't consumed above were deleted. We need
5114 // to add them to the deletion list.
5115 existingChildren.forEach(function (child) {
5116 return deleteChild(returnFiber, child);
5117 });
5118 }
5119
5120 return resultingFirstChild;
5121 }
5122
5123 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
5124 // This is the same implementation as reconcileChildrenArray(),
5125 // but using the iterator instead.
5126 var iteratorFn = getIteratorFn(newChildrenIterable);
5127
5128 (function () {
5129 if (!(typeof iteratorFn === 'function')) {
5130 {
5131 throw ReactError(Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue."));
5132 }
5133 }
5134 })();
5135
5136 {
5137 // We don't support rendering Generators because it's a mutation.
5138 // See https://github.com/facebook/react/issues/12995
5139 if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag
5140 newChildrenIterable[Symbol.toStringTag] === 'Generator') {
5141 !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;
5142 didWarnAboutGenerators = true;
5143 } // Warn about using Maps as children
5144
5145
5146 if (newChildrenIterable.entries === iteratorFn) {
5147 !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;
5148 didWarnAboutMaps = true;
5149 } // First, validate keys.
5150 // We'll get a different iterator later for the main pass.
5151
5152
5153 var _newChildren = iteratorFn.call(newChildrenIterable);
5154
5155 if (_newChildren) {
5156 var knownKeys = null;
5157
5158 var _step = _newChildren.next();
5159
5160 for (; !_step.done; _step = _newChildren.next()) {
5161 var child = _step.value;
5162 knownKeys = warnOnInvalidKey(child, knownKeys);
5163 }
5164 }
5165 }
5166
5167 var newChildren = iteratorFn.call(newChildrenIterable);
5168
5169 (function () {
5170 if (!(newChildren != null)) {
5171 {
5172 throw ReactError(Error("An iterable object provided no iterator."));
5173 }
5174 }
5175 })();
5176
5177 var resultingFirstChild = null;
5178 var previousNewFiber = null;
5179 var oldFiber = currentFirstChild;
5180 var lastPlacedIndex = 0;
5181 var newIdx = 0;
5182 var nextOldFiber = null;
5183 var step = newChildren.next();
5184
5185 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
5186 if (oldFiber.index > newIdx) {
5187 nextOldFiber = oldFiber;
5188 oldFiber = null;
5189 } else {
5190 nextOldFiber = oldFiber.sibling;
5191 }
5192
5193 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
5194
5195 if (newFiber === null) {
5196 // TODO: This breaks on empty slots like null children. That's
5197 // unfortunate because it triggers the slow path all the time. We need
5198 // a better way to communicate whether this was a miss or null,
5199 // boolean, undefined, etc.
5200 if (oldFiber === null) {
5201 oldFiber = nextOldFiber;
5202 }
5203
5204 break;
5205 }
5206
5207 if (shouldTrackSideEffects) {
5208 if (oldFiber && newFiber.alternate === null) {
5209 // We matched the slot, but we didn't reuse the existing fiber, so we
5210 // need to delete the existing child.
5211 deleteChild(returnFiber, oldFiber);
5212 }
5213 }
5214
5215 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
5216
5217 if (previousNewFiber === null) {
5218 // TODO: Move out of the loop. This only happens for the first run.
5219 resultingFirstChild = newFiber;
5220 } else {
5221 // TODO: Defer siblings if we're not at the right index for this slot.
5222 // I.e. if we had null values before, then we want to defer this
5223 // for each null value. However, we also don't want to call updateSlot
5224 // with the previous one.
5225 previousNewFiber.sibling = newFiber;
5226 }
5227
5228 previousNewFiber = newFiber;
5229 oldFiber = nextOldFiber;
5230 }
5231
5232 if (step.done) {
5233 // We've reached the end of the new children. We can delete the rest.
5234 deleteRemainingChildren(returnFiber, oldFiber);
5235 return resultingFirstChild;
5236 }
5237
5238 if (oldFiber === null) {
5239 // If we don't have any more existing children we can choose a fast path
5240 // since the rest will all be insertions.
5241 for (; !step.done; newIdx++, step = newChildren.next()) {
5242 var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
5243
5244 if (_newFiber3 === null) {
5245 continue;
5246 }
5247
5248 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
5249
5250 if (previousNewFiber === null) {
5251 // TODO: Move out of the loop. This only happens for the first run.
5252 resultingFirstChild = _newFiber3;
5253 } else {
5254 previousNewFiber.sibling = _newFiber3;
5255 }
5256
5257 previousNewFiber = _newFiber3;
5258 }
5259
5260 return resultingFirstChild;
5261 } // Add all children to a key map for quick lookups.
5262
5263
5264 var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
5265
5266 for (; !step.done; newIdx++, step = newChildren.next()) {
5267 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
5268
5269 if (_newFiber4 !== null) {
5270 if (shouldTrackSideEffects) {
5271 if (_newFiber4.alternate !== null) {
5272 // The new fiber is a work in progress, but if there exists a
5273 // current, that means that we reused the fiber. We need to delete
5274 // it from the child list so that we don't add it to the deletion
5275 // list.
5276 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
5277 }
5278 }
5279
5280 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
5281
5282 if (previousNewFiber === null) {
5283 resultingFirstChild = _newFiber4;
5284 } else {
5285 previousNewFiber.sibling = _newFiber4;
5286 }
5287
5288 previousNewFiber = _newFiber4;
5289 }
5290 }
5291
5292 if (shouldTrackSideEffects) {
5293 // Any existing children that weren't consumed above were deleted. We need
5294 // to add them to the deletion list.
5295 existingChildren.forEach(function (child) {
5296 return deleteChild(returnFiber, child);
5297 });
5298 }
5299
5300 return resultingFirstChild;
5301 }
5302
5303 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
5304 // There's no need to check for keys on text nodes since we don't have a
5305 // way to define them.
5306 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
5307 // We already have an existing node so let's just update it and delete
5308 // the rest.
5309 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
5310 var existing = useFiber(currentFirstChild, textContent, expirationTime);
5311 existing.return = returnFiber;
5312 return existing;
5313 } // The existing first child is not a text node so we need to create one
5314 // and delete the existing ones.
5315
5316
5317 deleteRemainingChildren(returnFiber, currentFirstChild);
5318 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
5319 created.return = returnFiber;
5320 return created;
5321 }
5322
5323 function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
5324 var key = element.key;
5325 var child = currentFirstChild;
5326
5327 while (child !== null) {
5328 // TODO: If key === null and child.key === null, then this only applies to
5329 // the first item in the list.
5330 if (child.key === key) {
5331 if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
5332 isCompatibleFamilyForHotReloading(child, element))) {
5333 deleteRemainingChildren(returnFiber, child.sibling);
5334 var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
5335 existing.ref = coerceRef(returnFiber, child, element);
5336 existing.return = returnFiber;
5337
5338 {
5339 existing._debugSource = element._source;
5340 existing._debugOwner = element._owner;
5341 }
5342
5343 return existing;
5344 } else {
5345 deleteRemainingChildren(returnFiber, child);
5346 break;
5347 }
5348 } else {
5349 deleteChild(returnFiber, child);
5350 }
5351
5352 child = child.sibling;
5353 }
5354
5355 if (element.type === REACT_FRAGMENT_TYPE) {
5356 var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
5357 created.return = returnFiber;
5358 return created;
5359 } else {
5360 var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
5361
5362 _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
5363 _created4.return = returnFiber;
5364 return _created4;
5365 }
5366 }
5367
5368 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
5369 var key = portal.key;
5370 var child = currentFirstChild;
5371
5372 while (child !== null) {
5373 // TODO: If key === null and child.key === null, then this only applies to
5374 // the first item in the list.
5375 if (child.key === key) {
5376 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
5377 deleteRemainingChildren(returnFiber, child.sibling);
5378 var existing = useFiber(child, portal.children || [], expirationTime);
5379 existing.return = returnFiber;
5380 return existing;
5381 } else {
5382 deleteRemainingChildren(returnFiber, child);
5383 break;
5384 }
5385 } else {
5386 deleteChild(returnFiber, child);
5387 }
5388
5389 child = child.sibling;
5390 }
5391
5392 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
5393 created.return = returnFiber;
5394 return created;
5395 } // This API will tag the children with the side-effect of the reconciliation
5396 // itself. They will be added to the side-effect list as we pass through the
5397 // children and the parent.
5398
5399
5400 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
5401 // This function is not recursive.
5402 // If the top level item is an array, we treat it as a set of children,
5403 // not as a fragment. Nested arrays on the other hand will be treated as
5404 // fragment nodes. Recursion happens at the normal flow.
5405 // Handle top level unkeyed fragments as if they were arrays.
5406 // This leads to an ambiguity between <>{[...]}</> and <>...</>.
5407 // We treat the ambiguous cases above the same.
5408 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
5409
5410 if (isUnkeyedTopLevelFragment) {
5411 newChild = newChild.props.children;
5412 } // Handle object types
5413
5414
5415 var isObject = typeof newChild === 'object' && newChild !== null;
5416
5417 if (isObject) {
5418 switch (newChild.$$typeof) {
5419 case REACT_ELEMENT_TYPE:
5420 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
5421
5422 case REACT_PORTAL_TYPE:
5423 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
5424 }
5425 }
5426
5427 if (typeof newChild === 'string' || typeof newChild === 'number') {
5428 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
5429 }
5430
5431 if (isArray(newChild)) {
5432 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
5433 }
5434
5435 if (getIteratorFn(newChild)) {
5436 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
5437 }
5438
5439 if (isObject) {
5440 throwOnInvalidObjectType(returnFiber, newChild);
5441 }
5442
5443 {
5444 if (typeof newChild === 'function') {
5445 warnOnFunctionType();
5446 }
5447 }
5448
5449 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
5450 // If the new child is undefined, and the return fiber is a composite
5451 // component, throw an error. If Fiber return types are disabled,
5452 // we already threw above.
5453 switch (returnFiber.tag) {
5454 case ClassComponent:
5455 {
5456 {
5457 var instance = returnFiber.stateNode;
5458
5459 if (instance.render._isMockFunction) {
5460 // We allow auto-mocks to proceed as if they're returning null.
5461 break;
5462 }
5463 }
5464 }
5465 // Intentionally fall through to the next case, which handles both
5466 // functions and classes
5467 // eslint-disable-next-lined no-fallthrough
5468
5469 case FunctionComponent:
5470 {
5471 var Component = returnFiber.type;
5472
5473 (function () {
5474 {
5475 {
5476 throw ReactError(Error((Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null."));
5477 }
5478 }
5479 })();
5480 }
5481 }
5482 } // Remaining cases are all treated as empty.
5483
5484
5485 return deleteRemainingChildren(returnFiber, currentFirstChild);
5486 }
5487
5488 return reconcileChildFibers;
5489}
5490
5491var reconcileChildFibers = ChildReconciler(true);
5492var mountChildFibers = ChildReconciler(false);
5493function cloneChildFibers(current$$1, workInProgress) {
5494 (function () {
5495 if (!(current$$1 === null || workInProgress.child === current$$1.child)) {
5496 {
5497 throw ReactError(Error("Resuming work not yet implemented."));
5498 }
5499 }
5500 })();
5501
5502 if (workInProgress.child === null) {
5503 return;
5504 }
5505
5506 var currentChild = workInProgress.child;
5507 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
5508 workInProgress.child = newChild;
5509 newChild.return = workInProgress;
5510
5511 while (currentChild.sibling !== null) {
5512 currentChild = currentChild.sibling;
5513 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
5514 newChild.return = workInProgress;
5515 }
5516
5517 newChild.sibling = null;
5518} // Reset a workInProgress child set to prepare it for a second pass.
5519
5520function resetChildFibers(workInProgress, renderExpirationTime) {
5521 var child = workInProgress.child;
5522
5523 while (child !== null) {
5524 resetWorkInProgress(child, renderExpirationTime);
5525 child = child.sibling;
5526 }
5527}
5528
5529var NO_CONTEXT = {};
5530var contextStackCursor$1 = createCursor(NO_CONTEXT);
5531var contextFiberStackCursor = createCursor(NO_CONTEXT);
5532var rootInstanceStackCursor = createCursor(NO_CONTEXT);
5533
5534function requiredContext(c) {
5535 (function () {
5536 if (!(c !== NO_CONTEXT)) {
5537 {
5538 throw ReactError(Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."));
5539 }
5540 }
5541 })();
5542
5543 return c;
5544}
5545
5546function getRootHostContainer() {
5547 var rootInstance = requiredContext(rootInstanceStackCursor.current);
5548 return rootInstance;
5549}
5550
5551function pushHostContainer(fiber, nextRootInstance) {
5552 // Push current root instance onto the stack;
5553 // This allows us to reset root when portals are popped.
5554 push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it.
5555 // This enables us to pop only Fibers that provide unique contexts.
5556
5557 push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack.
5558 // However, we can't just call getRootHostContext() and push it because
5559 // we'd have a different number of entries on the stack depending on
5560 // whether getRootHostContext() throws somewhere in renderer code or not.
5561 // So we push an empty value first. This lets us safely unwind on errors.
5562
5563 push(contextStackCursor$1, NO_CONTEXT, fiber);
5564 var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it.
5565
5566 pop(contextStackCursor$1, fiber);
5567 push(contextStackCursor$1, nextRootContext, fiber);
5568}
5569
5570function popHostContainer(fiber) {
5571 pop(contextStackCursor$1, fiber);
5572 pop(contextFiberStackCursor, fiber);
5573 pop(rootInstanceStackCursor, fiber);
5574}
5575
5576function getHostContext() {
5577 var context = requiredContext(contextStackCursor$1.current);
5578 return context;
5579}
5580
5581function pushHostContext(fiber) {
5582 var rootInstance = requiredContext(rootInstanceStackCursor.current);
5583 var context = requiredContext(contextStackCursor$1.current);
5584 var nextContext = getChildHostContext(context, fiber.type, rootInstance); // Don't push this Fiber's context unless it's unique.
5585
5586 if (context === nextContext) {
5587 return;
5588 } // Track the context and the Fiber that provided it.
5589 // This enables us to pop only Fibers that provide unique contexts.
5590
5591
5592 push(contextFiberStackCursor, fiber, fiber);
5593 push(contextStackCursor$1, nextContext, fiber);
5594}
5595
5596function popHostContext(fiber) {
5597 // Do not pop unless this Fiber provided the current context.
5598 // pushHostContext() only pushes Fibers that provide unique contexts.
5599 if (contextFiberStackCursor.current !== fiber) {
5600 return;
5601 }
5602
5603 pop(contextStackCursor$1, fiber);
5604 pop(contextFiberStackCursor, fiber);
5605}
5606
5607var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is
5608// inherited deeply down the subtree. The upper bits only affect
5609// this immediate suspense boundary and gets reset each new
5610// boundary or suspense list.
5611
5612var SubtreeSuspenseContextMask = 1; // Subtree Flags:
5613// InvisibleParentSuspenseContext indicates that one of our parent Suspense
5614// boundaries is not currently showing visible main content.
5615// Either because it is already showing a fallback or is not mounted at all.
5616// We can use this to determine if it is desirable to trigger a fallback at
5617// the parent. If not, then we might need to trigger undesirable boundaries
5618// and/or suspend the commit to avoid hiding the parent content.
5619
5620var InvisibleParentSuspenseContext = 1; // Shallow Flags:
5621// ForceSuspenseFallback can be used by SuspenseList to force newly added
5622// items into their fallback state during one of the render passes.
5623
5624var ForceSuspenseFallback = 2;
5625var suspenseStackCursor = createCursor(DefaultSuspenseContext);
5626function hasSuspenseContext(parentContext, flag) {
5627 return (parentContext & flag) !== 0;
5628}
5629function setDefaultShallowSuspenseContext(parentContext) {
5630 return parentContext & SubtreeSuspenseContextMask;
5631}
5632function setShallowSuspenseContext(parentContext, shallowContext) {
5633 return parentContext & SubtreeSuspenseContextMask | shallowContext;
5634}
5635function addSubtreeSuspenseContext(parentContext, subtreeContext) {
5636 return parentContext | subtreeContext;
5637}
5638function pushSuspenseContext(fiber, newContext) {
5639 push(suspenseStackCursor, newContext, fiber);
5640}
5641function popSuspenseContext(fiber) {
5642 pop(suspenseStackCursor, fiber);
5643}
5644
5645function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
5646 // If it was the primary children that just suspended, capture and render the
5647 // fallback. Otherwise, don't capture and bubble to the next boundary.
5648 var nextState = workInProgress.memoizedState;
5649
5650 if (nextState !== null) {
5651 if (nextState.dehydrated !== null) {
5652 // A dehydrated boundary always captures.
5653 return true;
5654 }
5655
5656 return false;
5657 }
5658
5659 var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop.
5660
5661 if (props.fallback === undefined) {
5662 return false;
5663 } // Regular boundaries always capture.
5664
5665
5666 if (props.unstable_avoidThisFallback !== true) {
5667 return true;
5668 } // If it's a boundary we should avoid, then we prefer to bubble up to the
5669 // parent boundary if it is currently invisible.
5670
5671
5672 if (hasInvisibleParent) {
5673 return false;
5674 } // If the parent is not able to handle it, we must handle it.
5675
5676
5677 return true;
5678}
5679function findFirstSuspended(row) {
5680 var node = row;
5681
5682 while (node !== null) {
5683 if (node.tag === SuspenseComponent) {
5684 var state = node.memoizedState;
5685
5686 if (state !== null) {
5687 var dehydrated = state.dehydrated;
5688
5689 if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
5690 return node;
5691 }
5692 }
5693 } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't
5694 // keep track of whether it suspended or not.
5695 node.memoizedProps.revealOrder !== undefined) {
5696 var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
5697
5698 if (didSuspend) {
5699 return node;
5700 }
5701 } else if (node.child !== null) {
5702 node.child.return = node;
5703 node = node.child;
5704 continue;
5705 }
5706
5707 if (node === row) {
5708 return null;
5709 }
5710
5711 while (node.sibling === null) {
5712 if (node.return === null || node.return === row) {
5713 return null;
5714 }
5715
5716 node = node.return;
5717 }
5718
5719 node.sibling.return = node.return;
5720 node = node.sibling;
5721 }
5722
5723 return null;
5724}
5725
5726var emptyObject = {};
5727var isArray$2 = Array.isArray;
5728function createResponderInstance(responder, responderProps, responderState, fiber) {
5729 return {
5730 fiber: fiber,
5731 props: responderProps,
5732 responder: responder,
5733 rootEventTypes: null,
5734 state: responderState
5735 };
5736}
5737
5738function mountEventResponder(responder, responderProps, fiber, respondersMap, rootContainerInstance) {
5739 var responderState = emptyObject;
5740 var getInitialState = responder.getInitialState;
5741
5742 if (getInitialState !== null) {
5743 responderState = getInitialState(responderProps);
5744 }
5745
5746 var responderInstance = createResponderInstance(responder, responderProps, responderState, fiber);
5747
5748 if (!rootContainerInstance) {
5749 var node = fiber;
5750
5751 while (node !== null) {
5752 var tag = node.tag;
5753
5754 if (tag === HostComponent) {
5755 rootContainerInstance = node.stateNode;
5756 break;
5757 } else if (tag === HostRoot) {
5758 rootContainerInstance = node.stateNode.containerInfo;
5759 break;
5760 }
5761
5762 node = node.return;
5763 }
5764 }
5765
5766 mountResponderInstance(responder, responderInstance, responderProps, responderState, rootContainerInstance);
5767 respondersMap.set(responder, responderInstance);
5768}
5769
5770function updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance) {
5771 var responder;
5772 var props;
5773
5774 if (listener) {
5775 responder = listener.responder;
5776 props = listener.props;
5777 }
5778
5779 (function () {
5780 if (!(responder && responder.$$typeof === REACT_RESPONDER_TYPE)) {
5781 {
5782 throw ReactError(Error("An invalid value was used as an event listener. Expect one or many event listeners created via React.unstable_useResponder()."));
5783 }
5784 }
5785 })();
5786
5787 var listenerProps = props;
5788
5789 if (visistedResponders.has(responder)) {
5790 // show warning
5791 {
5792 warning$1(false, 'Duplicate event responder "%s" found in event listeners. ' + 'Event listeners passed to elements cannot use the same event responder more than once.', responder.displayName);
5793 }
5794
5795 return;
5796 }
5797
5798 visistedResponders.add(responder);
5799 var responderInstance = respondersMap.get(responder);
5800
5801 if (responderInstance === undefined) {
5802 // Mount (happens in either complete or commit phase)
5803 mountEventResponder(responder, listenerProps, fiber, respondersMap, rootContainerInstance);
5804 } else {
5805 // Update (happens during commit phase only)
5806 responderInstance.props = listenerProps;
5807 responderInstance.fiber = fiber;
5808 }
5809}
5810
5811function updateEventListeners(listeners, fiber, rootContainerInstance) {
5812 var visistedResponders = new Set();
5813 var dependencies = fiber.dependencies;
5814
5815 if (listeners != null) {
5816 if (dependencies === null) {
5817 dependencies = fiber.dependencies = {
5818 expirationTime: NoWork,
5819 firstContext: null,
5820 responders: new Map()
5821 };
5822 }
5823
5824 var respondersMap = dependencies.responders;
5825
5826 if (respondersMap === null) {
5827 respondersMap = new Map();
5828 }
5829
5830 if (isArray$2(listeners)) {
5831 for (var i = 0, length = listeners.length; i < length; i++) {
5832 var listener = listeners[i];
5833 updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance);
5834 }
5835 } else {
5836 updateEventListener(listeners, fiber, visistedResponders, respondersMap, rootContainerInstance);
5837 }
5838 }
5839
5840 if (dependencies !== null) {
5841 var _respondersMap = dependencies.responders;
5842
5843 if (_respondersMap !== null) {
5844 // Unmount
5845 var mountedResponders = Array.from(_respondersMap.keys());
5846
5847 for (var _i = 0, _length = mountedResponders.length; _i < _length; _i++) {
5848 var mountedResponder = mountedResponders[_i];
5849
5850 if (!visistedResponders.has(mountedResponder)) {
5851 var responderInstance = _respondersMap.get(mountedResponder);
5852
5853 unmountResponderInstance(responderInstance);
5854
5855 _respondersMap.delete(mountedResponder);
5856 }
5857 }
5858 }
5859 }
5860}
5861function createResponderListener(responder, props) {
5862 var eventResponderListener = {
5863 responder: responder,
5864 props: props
5865 };
5866
5867 {
5868 Object.freeze(eventResponderListener);
5869 }
5870
5871 return eventResponderListener;
5872}
5873
5874var NoEffect$1 =
5875/* */
58760;
5877var UnmountSnapshot =
5878/* */
58792;
5880var UnmountMutation =
5881/* */
58824;
5883var MountMutation =
5884/* */
58858;
5886var UnmountLayout =
5887/* */
588816;
5889var MountLayout =
5890/* */
589132;
5892var MountPassive =
5893/* */
589464;
5895var UnmountPassive =
5896/* */
5897128;
5898
5899var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
5900var didWarnAboutMismatchedHooksForComponent;
5901
5902{
5903 didWarnAboutMismatchedHooksForComponent = new Set();
5904}
5905
5906// These are set right before calling the component.
5907var renderExpirationTime$1 = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from
5908// the work-in-progress hook.
5909
5910var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The
5911// current hook list is the list that belongs to the current fiber. The
5912// work-in-progress hook list is a new list that will be added to the
5913// work-in-progress fiber.
5914
5915var currentHook = null;
5916var nextCurrentHook = null;
5917var firstWorkInProgressHook = null;
5918var workInProgressHook = null;
5919var nextWorkInProgressHook = null;
5920var remainingExpirationTime = NoWork;
5921var componentUpdateQueue = null;
5922var sideEffectTag = 0; // Updates scheduled during render will trigger an immediate re-render at the
5923// end of the current pass. We can't store these updates on the normal queue,
5924// because if the work is aborted, they should be discarded. Because this is
5925// a relatively rare case, we also don't want to add an additional field to
5926// either the hook or queue object types. So we store them in a lazily create
5927// map of queue -> render-phase updates, which are discarded once the component
5928// completes without re-rendering.
5929// Whether an update was scheduled during the currently executing render pass.
5930
5931var didScheduleRenderPhaseUpdate = false; // Lazily created map of render-phase updates
5932
5933var renderPhaseUpdates = null; // Counter to prevent infinite loops.
5934
5935var numberOfReRenders = 0;
5936var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook
5937
5938var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders.
5939// The list stores the order of hooks used during the initial render (mount).
5940// Subsequent renders (updates) reference this list.
5941
5942var hookTypesDev = null;
5943var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore
5944// the dependencies for Hooks that need them (e.g. useEffect or useMemo).
5945// When true, such Hooks will always be "remounted". Only used during hot reload.
5946
5947var ignorePreviousDependencies = false;
5948
5949function mountHookTypesDev() {
5950 {
5951 var hookName = currentHookNameInDev;
5952
5953 if (hookTypesDev === null) {
5954 hookTypesDev = [hookName];
5955 } else {
5956 hookTypesDev.push(hookName);
5957 }
5958 }
5959}
5960
5961function updateHookTypesDev() {
5962 {
5963 var hookName = currentHookNameInDev;
5964
5965 if (hookTypesDev !== null) {
5966 hookTypesUpdateIndexDev++;
5967
5968 if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
5969 warnOnHookMismatchInDev(hookName);
5970 }
5971 }
5972 }
5973}
5974
5975function checkDepsAreArrayDev(deps) {
5976 {
5977 if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
5978 // Verify deps, but only on mount to avoid extra checks.
5979 // It's unlikely their type would change as usually you define them inline.
5980 warning$1(false, '%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps);
5981 }
5982 }
5983}
5984
5985function warnOnHookMismatchInDev(currentHookName) {
5986 {
5987 var componentName = getComponentName(currentlyRenderingFiber$1.type);
5988
5989 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
5990 didWarnAboutMismatchedHooksForComponent.add(componentName);
5991
5992 if (hookTypesDev !== null) {
5993 var table = '';
5994 var secondColumnStart = 30;
5995
5996 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
5997 var oldHookName = hookTypesDev[i];
5998 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
5999 var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up
6000 // lol @ IE not supporting String#repeat
6001
6002 while (row.length < secondColumnStart) {
6003 row += ' ';
6004 }
6005
6006 row += newHookName + '\n';
6007 table += row;
6008 }
6009
6010 warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
6011 }
6012 }
6013 }
6014}
6015
6016function throwInvalidHookError() {
6017 (function () {
6018 {
6019 {
6020 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."));
6021 }
6022 }
6023 })();
6024}
6025
6026function areHookInputsEqual(nextDeps, prevDeps) {
6027 {
6028 if (ignorePreviousDependencies) {
6029 // Only true when this component is being hot reloaded.
6030 return false;
6031 }
6032 }
6033
6034 if (prevDeps === null) {
6035 {
6036 warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
6037 }
6038
6039 return false;
6040 }
6041
6042 {
6043 // Don't bother comparing lengths in prod because these arrays should be
6044 // passed inline.
6045 if (nextDeps.length !== prevDeps.length) {
6046 warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]");
6047 }
6048 }
6049
6050 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
6051 if (is$1(nextDeps[i], prevDeps[i])) {
6052 continue;
6053 }
6054
6055 return false;
6056 }
6057
6058 return true;
6059}
6060
6061function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
6062 renderExpirationTime$1 = nextRenderExpirationTime;
6063 currentlyRenderingFiber$1 = workInProgress;
6064 nextCurrentHook = current !== null ? current.memoizedState : null;
6065
6066 {
6067 hookTypesDev = current !== null ? current._debugHookTypes : null;
6068 hookTypesUpdateIndexDev = -1; // Used for hot reloading:
6069
6070 ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
6071 } // The following should have already been reset
6072 // currentHook = null;
6073 // workInProgressHook = null;
6074 // remainingExpirationTime = NoWork;
6075 // componentUpdateQueue = null;
6076 // didScheduleRenderPhaseUpdate = false;
6077 // renderPhaseUpdates = null;
6078 // numberOfReRenders = 0;
6079 // sideEffectTag = 0;
6080 // TODO Warn if no hooks are used at all during mount, then some are used during update.
6081 // Currently we will identify the update render as a mount because nextCurrentHook === null.
6082 // This is tricky because it's valid for certain types of components (e.g. React.lazy)
6083 // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
6084 // Non-stateful hooks (e.g. context) don't get added to memoizedState,
6085 // so nextCurrentHook would be null during updates and mounts.
6086
6087
6088 {
6089 if (nextCurrentHook !== null) {
6090 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
6091 } else if (hookTypesDev !== null) {
6092 // This dispatcher handles an edge case where a component is updating,
6093 // but no stateful hooks have been used.
6094 // We want to match the production code behavior (which will use HooksDispatcherOnMount),
6095 // but with the extra DEV validation to ensure hooks ordering hasn't changed.
6096 // This dispatcher does that.
6097 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
6098 } else {
6099 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
6100 }
6101 }
6102
6103 var children = Component(props, refOrContext);
6104
6105 if (didScheduleRenderPhaseUpdate) {
6106 do {
6107 didScheduleRenderPhaseUpdate = false;
6108 numberOfReRenders += 1;
6109
6110 {
6111 // Even when hot reloading, allow dependencies to stabilize
6112 // after first render to prevent infinite render phase updates.
6113 ignorePreviousDependencies = false;
6114 } // Start over from the beginning of the list
6115
6116
6117 nextCurrentHook = current !== null ? current.memoizedState : null;
6118 nextWorkInProgressHook = firstWorkInProgressHook;
6119 currentHook = null;
6120 workInProgressHook = null;
6121 componentUpdateQueue = null;
6122
6123 {
6124 // Also validate hook order for cascading updates.
6125 hookTypesUpdateIndexDev = -1;
6126 }
6127
6128 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
6129 children = Component(props, refOrContext);
6130 } while (didScheduleRenderPhaseUpdate);
6131
6132 renderPhaseUpdates = null;
6133 numberOfReRenders = 0;
6134 } // We can assume the previous dispatcher is always this one, since we set it
6135 // at the beginning of the render phase and there's no re-entrancy.
6136
6137
6138 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
6139 var renderedWork = currentlyRenderingFiber$1;
6140 renderedWork.memoizedState = firstWorkInProgressHook;
6141 renderedWork.expirationTime = remainingExpirationTime;
6142 renderedWork.updateQueue = componentUpdateQueue;
6143 renderedWork.effectTag |= sideEffectTag;
6144
6145 {
6146 renderedWork._debugHookTypes = hookTypesDev;
6147 } // This check uses currentHook so that it works the same in DEV and prod bundles.
6148 // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
6149
6150
6151 var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
6152 renderExpirationTime$1 = NoWork;
6153 currentlyRenderingFiber$1 = null;
6154 currentHook = null;
6155 nextCurrentHook = null;
6156 firstWorkInProgressHook = null;
6157 workInProgressHook = null;
6158 nextWorkInProgressHook = null;
6159
6160 {
6161 currentHookNameInDev = null;
6162 hookTypesDev = null;
6163 hookTypesUpdateIndexDev = -1;
6164 }
6165
6166 remainingExpirationTime = NoWork;
6167 componentUpdateQueue = null;
6168 sideEffectTag = 0; // These were reset above
6169 // didScheduleRenderPhaseUpdate = false;
6170 // renderPhaseUpdates = null;
6171 // numberOfReRenders = 0;
6172
6173 (function () {
6174 if (!!didRenderTooFewHooks) {
6175 {
6176 throw ReactError(Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement."));
6177 }
6178 }
6179 })();
6180
6181 return children;
6182}
6183function bailoutHooks(current, workInProgress, expirationTime) {
6184 workInProgress.updateQueue = current.updateQueue;
6185 workInProgress.effectTag &= ~(Passive | Update);
6186
6187 if (current.expirationTime <= expirationTime) {
6188 current.expirationTime = NoWork;
6189 }
6190}
6191function resetHooks() {
6192 // We can assume the previous dispatcher is always this one, since we set it
6193 // at the beginning of the render phase and there's no re-entrancy.
6194 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; // This is used to reset the state of this module when a component throws.
6195 // It's also called inside mountIndeterminateComponent if we determine the
6196 // component is a module-style component.
6197
6198 renderExpirationTime$1 = NoWork;
6199 currentlyRenderingFiber$1 = null;
6200 currentHook = null;
6201 nextCurrentHook = null;
6202 firstWorkInProgressHook = null;
6203 workInProgressHook = null;
6204 nextWorkInProgressHook = null;
6205
6206 {
6207 hookTypesDev = null;
6208 hookTypesUpdateIndexDev = -1;
6209 currentHookNameInDev = null;
6210 }
6211
6212 remainingExpirationTime = NoWork;
6213 componentUpdateQueue = null;
6214 sideEffectTag = 0;
6215 didScheduleRenderPhaseUpdate = false;
6216 renderPhaseUpdates = null;
6217 numberOfReRenders = 0;
6218}
6219
6220function mountWorkInProgressHook() {
6221 var hook = {
6222 memoizedState: null,
6223 baseState: null,
6224 queue: null,
6225 baseUpdate: null,
6226 next: null
6227 };
6228
6229 if (workInProgressHook === null) {
6230 // This is the first hook in the list
6231 firstWorkInProgressHook = workInProgressHook = hook;
6232 } else {
6233 // Append to the end of the list
6234 workInProgressHook = workInProgressHook.next = hook;
6235 }
6236
6237 return workInProgressHook;
6238}
6239
6240function updateWorkInProgressHook() {
6241 // This function is used both for updates and for re-renders triggered by a
6242 // render phase update. It assumes there is either a current hook we can
6243 // clone, or a work-in-progress hook from a previous render pass that we can
6244 // use as a base. When we reach the end of the base list, we must switch to
6245 // the dispatcher used for mounts.
6246 if (nextWorkInProgressHook !== null) {
6247 // There's already a work-in-progress. Reuse it.
6248 workInProgressHook = nextWorkInProgressHook;
6249 nextWorkInProgressHook = workInProgressHook.next;
6250 currentHook = nextCurrentHook;
6251 nextCurrentHook = currentHook !== null ? currentHook.next : null;
6252 } else {
6253 // Clone from the current hook.
6254 (function () {
6255 if (!(nextCurrentHook !== null)) {
6256 {
6257 throw ReactError(Error("Rendered more hooks than during the previous render."));
6258 }
6259 }
6260 })();
6261
6262 currentHook = nextCurrentHook;
6263 var newHook = {
6264 memoizedState: currentHook.memoizedState,
6265 baseState: currentHook.baseState,
6266 queue: currentHook.queue,
6267 baseUpdate: currentHook.baseUpdate,
6268 next: null
6269 };
6270
6271 if (workInProgressHook === null) {
6272 // This is the first hook in the list.
6273 workInProgressHook = firstWorkInProgressHook = newHook;
6274 } else {
6275 // Append to the end of the list.
6276 workInProgressHook = workInProgressHook.next = newHook;
6277 }
6278
6279 nextCurrentHook = currentHook.next;
6280 }
6281
6282 return workInProgressHook;
6283}
6284
6285function createFunctionComponentUpdateQueue() {
6286 return {
6287 lastEffect: null
6288 };
6289}
6290
6291function basicStateReducer(state, action) {
6292 return typeof action === 'function' ? action(state) : action;
6293}
6294
6295function mountReducer(reducer, initialArg, init) {
6296 var hook = mountWorkInProgressHook();
6297 var initialState;
6298
6299 if (init !== undefined) {
6300 initialState = init(initialArg);
6301 } else {
6302 initialState = initialArg;
6303 }
6304
6305 hook.memoizedState = hook.baseState = initialState;
6306 var queue = hook.queue = {
6307 last: null,
6308 dispatch: null,
6309 lastRenderedReducer: reducer,
6310 lastRenderedState: initialState
6311 };
6312 var dispatch = queue.dispatch = dispatchAction.bind(null, // Flow doesn't know this is non-null, but we do.
6313 currentlyRenderingFiber$1, queue);
6314 return [hook.memoizedState, dispatch];
6315}
6316
6317function updateReducer(reducer, initialArg, init) {
6318 var hook = updateWorkInProgressHook();
6319 var queue = hook.queue;
6320
6321 (function () {
6322 if (!(queue !== null)) {
6323 {
6324 throw ReactError(Error("Should have a queue. This is likely a bug in React. Please file an issue."));
6325 }
6326 }
6327 })();
6328
6329 queue.lastRenderedReducer = reducer;
6330
6331 if (numberOfReRenders > 0) {
6332 // This is a re-render. Apply the new render phase updates to the previous
6333 // work-in-progress hook.
6334 var _dispatch = queue.dispatch;
6335
6336 if (renderPhaseUpdates !== null) {
6337 // Render phase updates are stored in a map of queue -> linked list
6338 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
6339
6340 if (firstRenderPhaseUpdate !== undefined) {
6341 renderPhaseUpdates.delete(queue);
6342 var newState = hook.memoizedState;
6343 var update = firstRenderPhaseUpdate;
6344
6345 do {
6346 // Process this render phase update. We don't have to check the
6347 // priority because it will always be the same as the current
6348 // render's.
6349 var action = update.action;
6350 newState = reducer(newState, action);
6351 update = update.next;
6352 } while (update !== null); // Mark that the fiber performed work, but only if the new state is
6353 // different from the current state.
6354
6355
6356 if (!is$1(newState, hook.memoizedState)) {
6357 markWorkInProgressReceivedUpdate();
6358 }
6359
6360 hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to
6361 // the base state unless the queue is empty.
6362 // TODO: Not sure if this is the desired semantics, but it's what we
6363 // do for gDSFP. I can't remember why.
6364
6365 if (hook.baseUpdate === queue.last) {
6366 hook.baseState = newState;
6367 }
6368
6369 queue.lastRenderedState = newState;
6370 return [newState, _dispatch];
6371 }
6372 }
6373
6374 return [hook.memoizedState, _dispatch];
6375 } // The last update in the entire queue
6376
6377
6378 var last = queue.last; // The last update that is part of the base state.
6379
6380 var baseUpdate = hook.baseUpdate;
6381 var baseState = hook.baseState; // Find the first unprocessed update.
6382
6383 var first;
6384
6385 if (baseUpdate !== null) {
6386 if (last !== null) {
6387 // For the first update, the queue is a circular linked list where
6388 // `queue.last.next = queue.first`. Once the first update commits, and
6389 // the `baseUpdate` is no longer empty, we can unravel the list.
6390 last.next = null;
6391 }
6392
6393 first = baseUpdate.next;
6394 } else {
6395 first = last !== null ? last.next : null;
6396 }
6397
6398 if (first !== null) {
6399 var _newState = baseState;
6400 var newBaseState = null;
6401 var newBaseUpdate = null;
6402 var prevUpdate = baseUpdate;
6403 var _update = first;
6404 var didSkip = false;
6405
6406 do {
6407 var updateExpirationTime = _update.expirationTime;
6408
6409 if (updateExpirationTime < renderExpirationTime$1) {
6410 // Priority is insufficient. Skip this update. If this is the first
6411 // skipped update, the previous update/state is the new base
6412 // update/state.
6413 if (!didSkip) {
6414 didSkip = true;
6415 newBaseUpdate = prevUpdate;
6416 newBaseState = _newState;
6417 } // Update the remaining priority in the queue.
6418
6419
6420 if (updateExpirationTime > remainingExpirationTime) {
6421 remainingExpirationTime = updateExpirationTime;
6422 markUnprocessedUpdateTime(remainingExpirationTime);
6423 }
6424 } else {
6425 // This update does have sufficient priority.
6426 // Mark the event time of this update as relevant to this render pass.
6427 // TODO: This should ideally use the true event time of this update rather than
6428 // its priority which is a derived and not reverseable value.
6429 // TODO: We should skip this update if it was already committed but currently
6430 // we have no way of detecting the difference between a committed and suspended
6431 // update here.
6432 markRenderEventTimeAndConfig(updateExpirationTime, _update.suspenseConfig); // Process this update.
6433
6434 if (_update.eagerReducer === reducer) {
6435 // If this update was processed eagerly, and its reducer matches the
6436 // current reducer, we can use the eagerly computed state.
6437 _newState = _update.eagerState;
6438 } else {
6439 var _action = _update.action;
6440 _newState = reducer(_newState, _action);
6441 }
6442 }
6443
6444 prevUpdate = _update;
6445 _update = _update.next;
6446 } while (_update !== null && _update !== first);
6447
6448 if (!didSkip) {
6449 newBaseUpdate = prevUpdate;
6450 newBaseState = _newState;
6451 } // Mark that the fiber performed work, but only if the new state is
6452 // different from the current state.
6453
6454
6455 if (!is$1(_newState, hook.memoizedState)) {
6456 markWorkInProgressReceivedUpdate();
6457 }
6458
6459 hook.memoizedState = _newState;
6460 hook.baseUpdate = newBaseUpdate;
6461 hook.baseState = newBaseState;
6462 queue.lastRenderedState = _newState;
6463 }
6464
6465 var dispatch = queue.dispatch;
6466 return [hook.memoizedState, dispatch];
6467}
6468
6469function mountState(initialState) {
6470 var hook = mountWorkInProgressHook();
6471
6472 if (typeof initialState === 'function') {
6473 initialState = initialState();
6474 }
6475
6476 hook.memoizedState = hook.baseState = initialState;
6477 var queue = hook.queue = {
6478 last: null,
6479 dispatch: null,
6480 lastRenderedReducer: basicStateReducer,
6481 lastRenderedState: initialState
6482 };
6483 var dispatch = queue.dispatch = dispatchAction.bind(null, // Flow doesn't know this is non-null, but we do.
6484 currentlyRenderingFiber$1, queue);
6485 return [hook.memoizedState, dispatch];
6486}
6487
6488function updateState(initialState) {
6489 return updateReducer(basicStateReducer, initialState);
6490}
6491
6492function pushEffect(tag, create, destroy, deps) {
6493 var effect = {
6494 tag: tag,
6495 create: create,
6496 destroy: destroy,
6497 deps: deps,
6498 // Circular
6499 next: null
6500 };
6501
6502 if (componentUpdateQueue === null) {
6503 componentUpdateQueue = createFunctionComponentUpdateQueue();
6504 componentUpdateQueue.lastEffect = effect.next = effect;
6505 } else {
6506 var lastEffect = componentUpdateQueue.lastEffect;
6507
6508 if (lastEffect === null) {
6509 componentUpdateQueue.lastEffect = effect.next = effect;
6510 } else {
6511 var firstEffect = lastEffect.next;
6512 lastEffect.next = effect;
6513 effect.next = firstEffect;
6514 componentUpdateQueue.lastEffect = effect;
6515 }
6516 }
6517
6518 return effect;
6519}
6520
6521function mountRef(initialValue) {
6522 var hook = mountWorkInProgressHook();
6523 var ref = {
6524 current: initialValue
6525 };
6526
6527 {
6528 Object.seal(ref);
6529 }
6530
6531 hook.memoizedState = ref;
6532 return ref;
6533}
6534
6535function updateRef(initialValue) {
6536 var hook = updateWorkInProgressHook();
6537 return hook.memoizedState;
6538}
6539
6540function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
6541 var hook = mountWorkInProgressHook();
6542 var nextDeps = deps === undefined ? null : deps;
6543 sideEffectTag |= fiberEffectTag;
6544 hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
6545}
6546
6547function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
6548 var hook = updateWorkInProgressHook();
6549 var nextDeps = deps === undefined ? null : deps;
6550 var destroy = undefined;
6551
6552 if (currentHook !== null) {
6553 var prevEffect = currentHook.memoizedState;
6554 destroy = prevEffect.destroy;
6555
6556 if (nextDeps !== null) {
6557 var prevDeps = prevEffect.deps;
6558
6559 if (areHookInputsEqual(nextDeps, prevDeps)) {
6560 pushEffect(NoEffect$1, create, destroy, nextDeps);
6561 return;
6562 }
6563 }
6564 }
6565
6566 sideEffectTag |= fiberEffectTag;
6567 hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
6568}
6569
6570function mountEffect(create, deps) {
6571 {
6572 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6573 if ('undefined' !== typeof jest) {
6574 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
6575 }
6576 }
6577
6578 return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
6579}
6580
6581function updateEffect(create, deps) {
6582 {
6583 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6584 if ('undefined' !== typeof jest) {
6585 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
6586 }
6587 }
6588
6589 return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
6590}
6591
6592function mountLayoutEffect(create, deps) {
6593 return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
6594}
6595
6596function updateLayoutEffect(create, deps) {
6597 return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
6598}
6599
6600function imperativeHandleEffect(create, ref) {
6601 if (typeof ref === 'function') {
6602 var refCallback = ref;
6603
6604 var _inst = create();
6605
6606 refCallback(_inst);
6607 return function () {
6608 refCallback(null);
6609 };
6610 } else if (ref !== null && ref !== undefined) {
6611 var refObject = ref;
6612
6613 {
6614 !refObject.hasOwnProperty('current') ? warning$1(false, 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}') : void 0;
6615 }
6616
6617 var _inst2 = create();
6618
6619 refObject.current = _inst2;
6620 return function () {
6621 refObject.current = null;
6622 };
6623 }
6624}
6625
6626function mountImperativeHandle(ref, create, deps) {
6627 {
6628 !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
6629 } // TODO: If deps are provided, should we skip comparing the ref itself?
6630
6631
6632 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
6633 return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
6634}
6635
6636function updateImperativeHandle(ref, create, deps) {
6637 {
6638 !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
6639 } // TODO: If deps are provided, should we skip comparing the ref itself?
6640
6641
6642 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
6643 return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
6644}
6645
6646function mountDebugValue(value, formatterFn) {// This hook is normally a no-op.
6647 // The react-debug-hooks package injects its own implementation
6648 // so that e.g. DevTools can display custom hook values.
6649}
6650
6651var updateDebugValue = mountDebugValue;
6652
6653function mountCallback(callback, deps) {
6654 var hook = mountWorkInProgressHook();
6655 var nextDeps = deps === undefined ? null : deps;
6656 hook.memoizedState = [callback, nextDeps];
6657 return callback;
6658}
6659
6660function updateCallback(callback, deps) {
6661 var hook = updateWorkInProgressHook();
6662 var nextDeps = deps === undefined ? null : deps;
6663 var prevState = hook.memoizedState;
6664
6665 if (prevState !== null) {
6666 if (nextDeps !== null) {
6667 var prevDeps = prevState[1];
6668
6669 if (areHookInputsEqual(nextDeps, prevDeps)) {
6670 return prevState[0];
6671 }
6672 }
6673 }
6674
6675 hook.memoizedState = [callback, nextDeps];
6676 return callback;
6677}
6678
6679function mountMemo(nextCreate, deps) {
6680 var hook = mountWorkInProgressHook();
6681 var nextDeps = deps === undefined ? null : deps;
6682 var nextValue = nextCreate();
6683 hook.memoizedState = [nextValue, nextDeps];
6684 return nextValue;
6685}
6686
6687function updateMemo(nextCreate, deps) {
6688 var hook = updateWorkInProgressHook();
6689 var nextDeps = deps === undefined ? null : deps;
6690 var prevState = hook.memoizedState;
6691
6692 if (prevState !== null) {
6693 // Assume these are defined. If they're not, areHookInputsEqual will warn.
6694 if (nextDeps !== null) {
6695 var prevDeps = prevState[1];
6696
6697 if (areHookInputsEqual(nextDeps, prevDeps)) {
6698 return prevState[0];
6699 }
6700 }
6701 }
6702
6703 var nextValue = nextCreate();
6704 hook.memoizedState = [nextValue, nextDeps];
6705 return nextValue;
6706}
6707
6708function dispatchAction(fiber, queue, action) {
6709 (function () {
6710 if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
6711 {
6712 throw ReactError(Error("Too many re-renders. React limits the number of renders to prevent an infinite loop."));
6713 }
6714 }
6715 })();
6716
6717 {
6718 !(typeof arguments[3] !== 'function') ? warning$1(false, "State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().') : void 0;
6719 }
6720
6721 var alternate = fiber.alternate;
6722
6723 if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
6724 // This is a render phase update. Stash it in a lazily-created map of
6725 // queue -> linked list of updates. After this render pass, we'll restart
6726 // and apply the stashed updates on top of the work-in-progress hook.
6727 didScheduleRenderPhaseUpdate = true;
6728 var update = {
6729 expirationTime: renderExpirationTime$1,
6730 suspenseConfig: null,
6731 action: action,
6732 eagerReducer: null,
6733 eagerState: null,
6734 next: null
6735 };
6736
6737 {
6738 update.priority = getCurrentPriorityLevel();
6739 }
6740
6741 if (renderPhaseUpdates === null) {
6742 renderPhaseUpdates = new Map();
6743 }
6744
6745 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
6746
6747 if (firstRenderPhaseUpdate === undefined) {
6748 renderPhaseUpdates.set(queue, update);
6749 } else {
6750 // Append the update to the end of the list.
6751 var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
6752
6753 while (lastRenderPhaseUpdate.next !== null) {
6754 lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
6755 }
6756
6757 lastRenderPhaseUpdate.next = update;
6758 }
6759 } else {
6760 var currentTime = requestCurrentTime();
6761 var suspenseConfig = requestCurrentSuspenseConfig();
6762 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
6763 var _update2 = {
6764 expirationTime: expirationTime,
6765 suspenseConfig: suspenseConfig,
6766 action: action,
6767 eagerReducer: null,
6768 eagerState: null,
6769 next: null
6770 };
6771
6772 {
6773 _update2.priority = getCurrentPriorityLevel();
6774 } // Append the update to the end of the list.
6775
6776
6777 var last = queue.last;
6778
6779 if (last === null) {
6780 // This is the first update. Create a circular list.
6781 _update2.next = _update2;
6782 } else {
6783 var first = last.next;
6784
6785 if (first !== null) {
6786 // Still circular.
6787 _update2.next = first;
6788 }
6789
6790 last.next = _update2;
6791 }
6792
6793 queue.last = _update2;
6794
6795 if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
6796 // The queue is currently empty, which means we can eagerly compute the
6797 // next state before entering the render phase. If the new state is the
6798 // same as the current state, we may be able to bail out entirely.
6799 var lastRenderedReducer = queue.lastRenderedReducer;
6800
6801 if (lastRenderedReducer !== null) {
6802 var prevDispatcher;
6803
6804 {
6805 prevDispatcher = ReactCurrentDispatcher$1.current;
6806 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6807 }
6808
6809 try {
6810 var currentState = queue.lastRenderedState;
6811 var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute
6812 // it, on the update object. If the reducer hasn't changed by the
6813 // time we enter the render phase, then the eager state can be used
6814 // without calling the reducer again.
6815
6816 _update2.eagerReducer = lastRenderedReducer;
6817 _update2.eagerState = eagerState;
6818
6819 if (is$1(eagerState, currentState)) {
6820 // Fast path. We can bail out without scheduling React to re-render.
6821 // It's still possible that we'll need to rebase this update later,
6822 // if the component re-renders for a different reason and by that
6823 // time the reducer has changed.
6824 return;
6825 }
6826 } catch (error) {// Suppress the error. It will throw again in the render phase.
6827 } finally {
6828 {
6829 ReactCurrentDispatcher$1.current = prevDispatcher;
6830 }
6831 }
6832 }
6833 }
6834
6835 {
6836 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6837 if ('undefined' !== typeof jest) {
6838 warnIfNotScopedWithMatchingAct(fiber);
6839 warnIfNotCurrentlyActingUpdatesInDev(fiber);
6840 }
6841 }
6842
6843 scheduleWork(fiber, expirationTime);
6844 }
6845}
6846
6847var ContextOnlyDispatcher = {
6848 readContext: readContext,
6849 useCallback: throwInvalidHookError,
6850 useContext: throwInvalidHookError,
6851 useEffect: throwInvalidHookError,
6852 useImperativeHandle: throwInvalidHookError,
6853 useLayoutEffect: throwInvalidHookError,
6854 useMemo: throwInvalidHookError,
6855 useReducer: throwInvalidHookError,
6856 useRef: throwInvalidHookError,
6857 useState: throwInvalidHookError,
6858 useDebugValue: throwInvalidHookError,
6859 useResponder: throwInvalidHookError
6860};
6861var HooksDispatcherOnMountInDEV = null;
6862var HooksDispatcherOnMountWithHookTypesInDEV = null;
6863var HooksDispatcherOnUpdateInDEV = null;
6864var InvalidNestedHooksDispatcherOnMountInDEV = null;
6865var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
6866
6867{
6868 var warnInvalidContextAccess = function () {
6869 warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
6870 };
6871
6872 var warnInvalidHookAccess = function () {
6873 warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks');
6874 };
6875
6876 HooksDispatcherOnMountInDEV = {
6877 readContext: function (context, observedBits) {
6878 return readContext(context, observedBits);
6879 },
6880 useCallback: function (callback, deps) {
6881 currentHookNameInDev = 'useCallback';
6882 mountHookTypesDev();
6883 checkDepsAreArrayDev(deps);
6884 return mountCallback(callback, deps);
6885 },
6886 useContext: function (context, observedBits) {
6887 currentHookNameInDev = 'useContext';
6888 mountHookTypesDev();
6889 return readContext(context, observedBits);
6890 },
6891 useEffect: function (create, deps) {
6892 currentHookNameInDev = 'useEffect';
6893 mountHookTypesDev();
6894 checkDepsAreArrayDev(deps);
6895 return mountEffect(create, deps);
6896 },
6897 useImperativeHandle: function (ref, create, deps) {
6898 currentHookNameInDev = 'useImperativeHandle';
6899 mountHookTypesDev();
6900 checkDepsAreArrayDev(deps);
6901 return mountImperativeHandle(ref, create, deps);
6902 },
6903 useLayoutEffect: function (create, deps) {
6904 currentHookNameInDev = 'useLayoutEffect';
6905 mountHookTypesDev();
6906 checkDepsAreArrayDev(deps);
6907 return mountLayoutEffect(create, deps);
6908 },
6909 useMemo: function (create, deps) {
6910 currentHookNameInDev = 'useMemo';
6911 mountHookTypesDev();
6912 checkDepsAreArrayDev(deps);
6913 var prevDispatcher = ReactCurrentDispatcher$1.current;
6914 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6915
6916 try {
6917 return mountMemo(create, deps);
6918 } finally {
6919 ReactCurrentDispatcher$1.current = prevDispatcher;
6920 }
6921 },
6922 useReducer: function (reducer, initialArg, init) {
6923 currentHookNameInDev = 'useReducer';
6924 mountHookTypesDev();
6925 var prevDispatcher = ReactCurrentDispatcher$1.current;
6926 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6927
6928 try {
6929 return mountReducer(reducer, initialArg, init);
6930 } finally {
6931 ReactCurrentDispatcher$1.current = prevDispatcher;
6932 }
6933 },
6934 useRef: function (initialValue) {
6935 currentHookNameInDev = 'useRef';
6936 mountHookTypesDev();
6937 return mountRef(initialValue);
6938 },
6939 useState: function (initialState) {
6940 currentHookNameInDev = 'useState';
6941 mountHookTypesDev();
6942 var prevDispatcher = ReactCurrentDispatcher$1.current;
6943 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6944
6945 try {
6946 return mountState(initialState);
6947 } finally {
6948 ReactCurrentDispatcher$1.current = prevDispatcher;
6949 }
6950 },
6951 useDebugValue: function (value, formatterFn) {
6952 currentHookNameInDev = 'useDebugValue';
6953 mountHookTypesDev();
6954 return mountDebugValue(value, formatterFn);
6955 },
6956 useResponder: function (responder, props) {
6957 currentHookNameInDev = 'useResponder';
6958 mountHookTypesDev();
6959 return createResponderListener(responder, props);
6960 }
6961 };
6962 HooksDispatcherOnMountWithHookTypesInDEV = {
6963 readContext: function (context, observedBits) {
6964 return readContext(context, observedBits);
6965 },
6966 useCallback: function (callback, deps) {
6967 currentHookNameInDev = 'useCallback';
6968 updateHookTypesDev();
6969 return mountCallback(callback, deps);
6970 },
6971 useContext: function (context, observedBits) {
6972 currentHookNameInDev = 'useContext';
6973 updateHookTypesDev();
6974 return readContext(context, observedBits);
6975 },
6976 useEffect: function (create, deps) {
6977 currentHookNameInDev = 'useEffect';
6978 updateHookTypesDev();
6979 return mountEffect(create, deps);
6980 },
6981 useImperativeHandle: function (ref, create, deps) {
6982 currentHookNameInDev = 'useImperativeHandle';
6983 updateHookTypesDev();
6984 return mountImperativeHandle(ref, create, deps);
6985 },
6986 useLayoutEffect: function (create, deps) {
6987 currentHookNameInDev = 'useLayoutEffect';
6988 updateHookTypesDev();
6989 return mountLayoutEffect(create, deps);
6990 },
6991 useMemo: function (create, deps) {
6992 currentHookNameInDev = 'useMemo';
6993 updateHookTypesDev();
6994 var prevDispatcher = ReactCurrentDispatcher$1.current;
6995 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6996
6997 try {
6998 return mountMemo(create, deps);
6999 } finally {
7000 ReactCurrentDispatcher$1.current = prevDispatcher;
7001 }
7002 },
7003 useReducer: function (reducer, initialArg, init) {
7004 currentHookNameInDev = 'useReducer';
7005 updateHookTypesDev();
7006 var prevDispatcher = ReactCurrentDispatcher$1.current;
7007 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7008
7009 try {
7010 return mountReducer(reducer, initialArg, init);
7011 } finally {
7012 ReactCurrentDispatcher$1.current = prevDispatcher;
7013 }
7014 },
7015 useRef: function (initialValue) {
7016 currentHookNameInDev = 'useRef';
7017 updateHookTypesDev();
7018 return mountRef(initialValue);
7019 },
7020 useState: function (initialState) {
7021 currentHookNameInDev = 'useState';
7022 updateHookTypesDev();
7023 var prevDispatcher = ReactCurrentDispatcher$1.current;
7024 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7025
7026 try {
7027 return mountState(initialState);
7028 } finally {
7029 ReactCurrentDispatcher$1.current = prevDispatcher;
7030 }
7031 },
7032 useDebugValue: function (value, formatterFn) {
7033 currentHookNameInDev = 'useDebugValue';
7034 updateHookTypesDev();
7035 return mountDebugValue(value, formatterFn);
7036 },
7037 useResponder: function (responder, props) {
7038 currentHookNameInDev = 'useResponder';
7039 updateHookTypesDev();
7040 return createResponderListener(responder, props);
7041 }
7042 };
7043 HooksDispatcherOnUpdateInDEV = {
7044 readContext: function (context, observedBits) {
7045 return readContext(context, observedBits);
7046 },
7047 useCallback: function (callback, deps) {
7048 currentHookNameInDev = 'useCallback';
7049 updateHookTypesDev();
7050 return updateCallback(callback, deps);
7051 },
7052 useContext: function (context, observedBits) {
7053 currentHookNameInDev = 'useContext';
7054 updateHookTypesDev();
7055 return readContext(context, observedBits);
7056 },
7057 useEffect: function (create, deps) {
7058 currentHookNameInDev = 'useEffect';
7059 updateHookTypesDev();
7060 return updateEffect(create, deps);
7061 },
7062 useImperativeHandle: function (ref, create, deps) {
7063 currentHookNameInDev = 'useImperativeHandle';
7064 updateHookTypesDev();
7065 return updateImperativeHandle(ref, create, deps);
7066 },
7067 useLayoutEffect: function (create, deps) {
7068 currentHookNameInDev = 'useLayoutEffect';
7069 updateHookTypesDev();
7070 return updateLayoutEffect(create, deps);
7071 },
7072 useMemo: function (create, deps) {
7073 currentHookNameInDev = 'useMemo';
7074 updateHookTypesDev();
7075 var prevDispatcher = ReactCurrentDispatcher$1.current;
7076 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7077
7078 try {
7079 return updateMemo(create, deps);
7080 } finally {
7081 ReactCurrentDispatcher$1.current = prevDispatcher;
7082 }
7083 },
7084 useReducer: function (reducer, initialArg, init) {
7085 currentHookNameInDev = 'useReducer';
7086 updateHookTypesDev();
7087 var prevDispatcher = ReactCurrentDispatcher$1.current;
7088 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7089
7090 try {
7091 return updateReducer(reducer, initialArg, init);
7092 } finally {
7093 ReactCurrentDispatcher$1.current = prevDispatcher;
7094 }
7095 },
7096 useRef: function (initialValue) {
7097 currentHookNameInDev = 'useRef';
7098 updateHookTypesDev();
7099 return updateRef(initialValue);
7100 },
7101 useState: function (initialState) {
7102 currentHookNameInDev = 'useState';
7103 updateHookTypesDev();
7104 var prevDispatcher = ReactCurrentDispatcher$1.current;
7105 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7106
7107 try {
7108 return updateState(initialState);
7109 } finally {
7110 ReactCurrentDispatcher$1.current = prevDispatcher;
7111 }
7112 },
7113 useDebugValue: function (value, formatterFn) {
7114 currentHookNameInDev = 'useDebugValue';
7115 updateHookTypesDev();
7116 return updateDebugValue(value, formatterFn);
7117 },
7118 useResponder: function (responder, props) {
7119 currentHookNameInDev = 'useResponder';
7120 updateHookTypesDev();
7121 return createResponderListener(responder, props);
7122 }
7123 };
7124 InvalidNestedHooksDispatcherOnMountInDEV = {
7125 readContext: function (context, observedBits) {
7126 warnInvalidContextAccess();
7127 return readContext(context, observedBits);
7128 },
7129 useCallback: function (callback, deps) {
7130 currentHookNameInDev = 'useCallback';
7131 warnInvalidHookAccess();
7132 mountHookTypesDev();
7133 return mountCallback(callback, deps);
7134 },
7135 useContext: function (context, observedBits) {
7136 currentHookNameInDev = 'useContext';
7137 warnInvalidHookAccess();
7138 mountHookTypesDev();
7139 return readContext(context, observedBits);
7140 },
7141 useEffect: function (create, deps) {
7142 currentHookNameInDev = 'useEffect';
7143 warnInvalidHookAccess();
7144 mountHookTypesDev();
7145 return mountEffect(create, deps);
7146 },
7147 useImperativeHandle: function (ref, create, deps) {
7148 currentHookNameInDev = 'useImperativeHandle';
7149 warnInvalidHookAccess();
7150 mountHookTypesDev();
7151 return mountImperativeHandle(ref, create, deps);
7152 },
7153 useLayoutEffect: function (create, deps) {
7154 currentHookNameInDev = 'useLayoutEffect';
7155 warnInvalidHookAccess();
7156 mountHookTypesDev();
7157 return mountLayoutEffect(create, deps);
7158 },
7159 useMemo: function (create, deps) {
7160 currentHookNameInDev = 'useMemo';
7161 warnInvalidHookAccess();
7162 mountHookTypesDev();
7163 var prevDispatcher = ReactCurrentDispatcher$1.current;
7164 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7165
7166 try {
7167 return mountMemo(create, deps);
7168 } finally {
7169 ReactCurrentDispatcher$1.current = prevDispatcher;
7170 }
7171 },
7172 useReducer: function (reducer, initialArg, init) {
7173 currentHookNameInDev = 'useReducer';
7174 warnInvalidHookAccess();
7175 mountHookTypesDev();
7176 var prevDispatcher = ReactCurrentDispatcher$1.current;
7177 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7178
7179 try {
7180 return mountReducer(reducer, initialArg, init);
7181 } finally {
7182 ReactCurrentDispatcher$1.current = prevDispatcher;
7183 }
7184 },
7185 useRef: function (initialValue) {
7186 currentHookNameInDev = 'useRef';
7187 warnInvalidHookAccess();
7188 mountHookTypesDev();
7189 return mountRef(initialValue);
7190 },
7191 useState: function (initialState) {
7192 currentHookNameInDev = 'useState';
7193 warnInvalidHookAccess();
7194 mountHookTypesDev();
7195 var prevDispatcher = ReactCurrentDispatcher$1.current;
7196 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7197
7198 try {
7199 return mountState(initialState);
7200 } finally {
7201 ReactCurrentDispatcher$1.current = prevDispatcher;
7202 }
7203 },
7204 useDebugValue: function (value, formatterFn) {
7205 currentHookNameInDev = 'useDebugValue';
7206 warnInvalidHookAccess();
7207 mountHookTypesDev();
7208 return mountDebugValue(value, formatterFn);
7209 },
7210 useResponder: function (responder, props) {
7211 currentHookNameInDev = 'useResponder';
7212 warnInvalidHookAccess();
7213 mountHookTypesDev();
7214 return createResponderListener(responder, props);
7215 }
7216 };
7217 InvalidNestedHooksDispatcherOnUpdateInDEV = {
7218 readContext: function (context, observedBits) {
7219 warnInvalidContextAccess();
7220 return readContext(context, observedBits);
7221 },
7222 useCallback: function (callback, deps) {
7223 currentHookNameInDev = 'useCallback';
7224 warnInvalidHookAccess();
7225 updateHookTypesDev();
7226 return updateCallback(callback, deps);
7227 },
7228 useContext: function (context, observedBits) {
7229 currentHookNameInDev = 'useContext';
7230 warnInvalidHookAccess();
7231 updateHookTypesDev();
7232 return readContext(context, observedBits);
7233 },
7234 useEffect: function (create, deps) {
7235 currentHookNameInDev = 'useEffect';
7236 warnInvalidHookAccess();
7237 updateHookTypesDev();
7238 return updateEffect(create, deps);
7239 },
7240 useImperativeHandle: function (ref, create, deps) {
7241 currentHookNameInDev = 'useImperativeHandle';
7242 warnInvalidHookAccess();
7243 updateHookTypesDev();
7244 return updateImperativeHandle(ref, create, deps);
7245 },
7246 useLayoutEffect: function (create, deps) {
7247 currentHookNameInDev = 'useLayoutEffect';
7248 warnInvalidHookAccess();
7249 updateHookTypesDev();
7250 return updateLayoutEffect(create, deps);
7251 },
7252 useMemo: function (create, deps) {
7253 currentHookNameInDev = 'useMemo';
7254 warnInvalidHookAccess();
7255 updateHookTypesDev();
7256 var prevDispatcher = ReactCurrentDispatcher$1.current;
7257 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7258
7259 try {
7260 return updateMemo(create, deps);
7261 } finally {
7262 ReactCurrentDispatcher$1.current = prevDispatcher;
7263 }
7264 },
7265 useReducer: function (reducer, initialArg, init) {
7266 currentHookNameInDev = 'useReducer';
7267 warnInvalidHookAccess();
7268 updateHookTypesDev();
7269 var prevDispatcher = ReactCurrentDispatcher$1.current;
7270 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7271
7272 try {
7273 return updateReducer(reducer, initialArg, init);
7274 } finally {
7275 ReactCurrentDispatcher$1.current = prevDispatcher;
7276 }
7277 },
7278 useRef: function (initialValue) {
7279 currentHookNameInDev = 'useRef';
7280 warnInvalidHookAccess();
7281 updateHookTypesDev();
7282 return updateRef(initialValue);
7283 },
7284 useState: function (initialState) {
7285 currentHookNameInDev = 'useState';
7286 warnInvalidHookAccess();
7287 updateHookTypesDev();
7288 var prevDispatcher = ReactCurrentDispatcher$1.current;
7289 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7290
7291 try {
7292 return updateState(initialState);
7293 } finally {
7294 ReactCurrentDispatcher$1.current = prevDispatcher;
7295 }
7296 },
7297 useDebugValue: function (value, formatterFn) {
7298 currentHookNameInDev = 'useDebugValue';
7299 warnInvalidHookAccess();
7300 updateHookTypesDev();
7301 return updateDebugValue(value, formatterFn);
7302 },
7303 useResponder: function (responder, props) {
7304 currentHookNameInDev = 'useResponder';
7305 warnInvalidHookAccess();
7306 updateHookTypesDev();
7307 return createResponderListener(responder, props);
7308 }
7309 };
7310}
7311
7312// CommonJS interop named imports.
7313
7314var now$2 = Scheduler.unstable_now;
7315var commitTime = 0;
7316var profilerStartTime = -1;
7317
7318function getCommitTime() {
7319 return commitTime;
7320}
7321
7322function recordCommitTime() {
7323 if (!enableProfilerTimer) {
7324 return;
7325 }
7326
7327 commitTime = now$2();
7328}
7329
7330function startProfilerTimer(fiber) {
7331 if (!enableProfilerTimer) {
7332 return;
7333 }
7334
7335 profilerStartTime = now$2();
7336
7337 if (fiber.actualStartTime < 0) {
7338 fiber.actualStartTime = now$2();
7339 }
7340}
7341
7342function stopProfilerTimerIfRunning(fiber) {
7343 if (!enableProfilerTimer) {
7344 return;
7345 }
7346
7347 profilerStartTime = -1;
7348}
7349
7350function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
7351 if (!enableProfilerTimer) {
7352 return;
7353 }
7354
7355 if (profilerStartTime >= 0) {
7356 var elapsedTime = now$2() - profilerStartTime;
7357 fiber.actualDuration += elapsedTime;
7358
7359 if (overrideBaseTime) {
7360 fiber.selfBaseDuration = elapsedTime;
7361 }
7362
7363 profilerStartTime = -1;
7364 }
7365}
7366
7367// This may have been an insertion or a hydration.
7368
7369var hydrationParentFiber = null;
7370var nextHydratableInstance = null;
7371var isHydrating = false;
7372
7373function warnIfHydrating() {
7374 {
7375 !!isHydrating ? warning$1(false, 'We should not be hydrating here. This is a bug in React. Please file a bug.') : void 0;
7376 }
7377}
7378
7379function enterHydrationState(fiber) {
7380 if (!supportsHydration) {
7381 return false;
7382 }
7383
7384 var parentInstance = fiber.stateNode.containerInfo;
7385 nextHydratableInstance = getFirstHydratableChild(parentInstance);
7386 hydrationParentFiber = fiber;
7387 isHydrating = true;
7388 return true;
7389}
7390
7391function reenterHydrationStateFromDehydratedSuspenseInstance(fiber, suspenseInstance) {
7392 if (!supportsHydration) {
7393 return false;
7394 }
7395
7396 nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
7397 popToNextHostParent(fiber);
7398 isHydrating = true;
7399 return true;
7400}
7401
7402function deleteHydratableInstance(returnFiber, instance) {
7403 {
7404 switch (returnFiber.tag) {
7405 case HostRoot:
7406 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
7407 break;
7408
7409 case HostComponent:
7410 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
7411 break;
7412 }
7413 }
7414
7415 var childToDelete = createFiberFromHostInstanceForDeletion();
7416 childToDelete.stateNode = instance;
7417 childToDelete.return = returnFiber;
7418 childToDelete.effectTag = Deletion; // This might seem like it belongs on progressedFirstDeletion. However,
7419 // these children are not part of the reconciliation list of children.
7420 // Even if we abort and rereconcile the children, that will try to hydrate
7421 // again and the nodes are still in the host tree so these will be
7422 // recreated.
7423
7424 if (returnFiber.lastEffect !== null) {
7425 returnFiber.lastEffect.nextEffect = childToDelete;
7426 returnFiber.lastEffect = childToDelete;
7427 } else {
7428 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
7429 }
7430}
7431
7432function insertNonHydratedInstance(returnFiber, fiber) {
7433 fiber.effectTag = fiber.effectTag & ~Hydrating | Placement;
7434
7435 {
7436 switch (returnFiber.tag) {
7437 case HostRoot:
7438 {
7439 var parentContainer = returnFiber.stateNode.containerInfo;
7440
7441 switch (fiber.tag) {
7442 case HostComponent:
7443 var type = fiber.type;
7444 var props = fiber.pendingProps;
7445 didNotFindHydratableContainerInstance(parentContainer, type, props);
7446 break;
7447
7448 case HostText:
7449 var text = fiber.pendingProps;
7450 didNotFindHydratableContainerTextInstance(parentContainer, text);
7451 break;
7452
7453 case SuspenseComponent:
7454 didNotFindHydratableContainerSuspenseInstance(parentContainer);
7455 break;
7456 }
7457
7458 break;
7459 }
7460
7461 case HostComponent:
7462 {
7463 var parentType = returnFiber.type;
7464 var parentProps = returnFiber.memoizedProps;
7465 var parentInstance = returnFiber.stateNode;
7466
7467 switch (fiber.tag) {
7468 case HostComponent:
7469 var _type = fiber.type;
7470 var _props = fiber.pendingProps;
7471 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
7472 break;
7473
7474 case HostText:
7475 var _text = fiber.pendingProps;
7476 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
7477 break;
7478
7479 case SuspenseComponent:
7480 didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
7481 break;
7482 }
7483
7484 break;
7485 }
7486
7487 default:
7488 return;
7489 }
7490 }
7491}
7492
7493function tryHydrate(fiber, nextInstance) {
7494 switch (fiber.tag) {
7495 case HostComponent:
7496 {
7497 var type = fiber.type;
7498 var props = fiber.pendingProps;
7499 var instance = canHydrateInstance(nextInstance, type, props);
7500
7501 if (instance !== null) {
7502 fiber.stateNode = instance;
7503 return true;
7504 }
7505
7506 return false;
7507 }
7508
7509 case HostText:
7510 {
7511 var text = fiber.pendingProps;
7512 var textInstance = canHydrateTextInstance(nextInstance, text);
7513
7514 if (textInstance !== null) {
7515 fiber.stateNode = textInstance;
7516 return true;
7517 }
7518
7519 return false;
7520 }
7521
7522 case SuspenseComponent:
7523 {
7524 if (enableSuspenseServerRenderer) {
7525 var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
7526
7527 if (suspenseInstance !== null) {
7528 var suspenseState = {
7529 dehydrated: suspenseInstance,
7530 retryTime: Never
7531 };
7532 fiber.memoizedState = suspenseState; // Store the dehydrated fragment as a child fiber.
7533 // This simplifies the code for getHostSibling and deleting nodes,
7534 // since it doesn't have to consider all Suspense boundaries and
7535 // check if they're dehydrated ones or not.
7536
7537 var dehydratedFragment = createFiberFromDehydratedFragment(suspenseInstance);
7538 dehydratedFragment.return = fiber;
7539 fiber.child = dehydratedFragment;
7540 return true;
7541 }
7542 }
7543
7544 return false;
7545 }
7546
7547 default:
7548 return false;
7549 }
7550}
7551
7552function tryToClaimNextHydratableInstance(fiber) {
7553 if (!isHydrating) {
7554 return;
7555 }
7556
7557 var nextInstance = nextHydratableInstance;
7558
7559 if (!nextInstance) {
7560 // Nothing to hydrate. Make it an insertion.
7561 insertNonHydratedInstance(hydrationParentFiber, fiber);
7562 isHydrating = false;
7563 hydrationParentFiber = fiber;
7564 return;
7565 }
7566
7567 var firstAttemptedInstance = nextInstance;
7568
7569 if (!tryHydrate(fiber, nextInstance)) {
7570 // If we can't hydrate this instance let's try the next one.
7571 // We use this as a heuristic. It's based on intuition and not data so it
7572 // might be flawed or unnecessary.
7573 nextInstance = getNextHydratableSibling(firstAttemptedInstance);
7574
7575 if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
7576 // Nothing to hydrate. Make it an insertion.
7577 insertNonHydratedInstance(hydrationParentFiber, fiber);
7578 isHydrating = false;
7579 hydrationParentFiber = fiber;
7580 return;
7581 } // We matched the next one, we'll now assume that the first one was
7582 // superfluous and we'll delete it. Since we can't eagerly delete it
7583 // we'll have to schedule a deletion. To do that, this node needs a dummy
7584 // fiber associated with it.
7585
7586
7587 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
7588 }
7589
7590 hydrationParentFiber = fiber;
7591 nextHydratableInstance = getFirstHydratableChild(nextInstance);
7592}
7593
7594function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
7595 if (!supportsHydration) {
7596 (function () {
7597 {
7598 {
7599 throw ReactError(Error("Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
7600 }
7601 }
7602 })();
7603 }
7604
7605 var instance = fiber.stateNode;
7606 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component.
7607
7608 fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
7609 // is a new ref we mark this as an update.
7610
7611 if (updatePayload !== null) {
7612 return true;
7613 }
7614
7615 return false;
7616}
7617
7618function prepareToHydrateHostTextInstance(fiber) {
7619 if (!supportsHydration) {
7620 (function () {
7621 {
7622 {
7623 throw ReactError(Error("Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
7624 }
7625 }
7626 })();
7627 }
7628
7629 var textInstance = fiber.stateNode;
7630 var textContent = fiber.memoizedProps;
7631 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
7632
7633 {
7634 if (shouldUpdate) {
7635 // We assume that prepareToHydrateHostTextInstance is called in a context where the
7636 // hydration parent is the parent host component of this host text.
7637 var returnFiber = hydrationParentFiber;
7638
7639 if (returnFiber !== null) {
7640 switch (returnFiber.tag) {
7641 case HostRoot:
7642 {
7643 var parentContainer = returnFiber.stateNode.containerInfo;
7644 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
7645 break;
7646 }
7647
7648 case HostComponent:
7649 {
7650 var parentType = returnFiber.type;
7651 var parentProps = returnFiber.memoizedProps;
7652 var parentInstance = returnFiber.stateNode;
7653 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
7654 break;
7655 }
7656 }
7657 }
7658 }
7659 }
7660
7661 return shouldUpdate;
7662}
7663
7664function prepareToHydrateHostSuspenseInstance(fiber) {
7665 if (!supportsHydration) {
7666 (function () {
7667 {
7668 {
7669 throw ReactError(Error("Expected prepareToHydrateHostSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
7670 }
7671 }
7672 })();
7673 }
7674
7675 var suspenseState = fiber.memoizedState;
7676 var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
7677
7678 (function () {
7679 if (!suspenseInstance) {
7680 {
7681 throw ReactError(Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue."));
7682 }
7683 }
7684 })();
7685
7686 hydrateSuspenseInstance(suspenseInstance, fiber);
7687}
7688
7689function skipPastDehydratedSuspenseInstance(fiber) {
7690 if (!supportsHydration) {
7691 (function () {
7692 {
7693 {
7694 throw ReactError(Error("Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue."));
7695 }
7696 }
7697 })();
7698 }
7699
7700 var suspenseState = fiber.memoizedState;
7701 var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
7702
7703 (function () {
7704 if (!suspenseInstance) {
7705 {
7706 throw ReactError(Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue."));
7707 }
7708 }
7709 })();
7710
7711 return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
7712}
7713
7714function popToNextHostParent(fiber) {
7715 var parent = fiber.return;
7716
7717 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) {
7718 parent = parent.return;
7719 }
7720
7721 hydrationParentFiber = parent;
7722}
7723
7724function popHydrationState(fiber) {
7725 if (!supportsHydration) {
7726 return false;
7727 }
7728
7729 if (fiber !== hydrationParentFiber) {
7730 // We're deeper than the current hydration context, inside an inserted
7731 // tree.
7732 return false;
7733 }
7734
7735 if (!isHydrating) {
7736 // If we're not currently hydrating but we're in a hydration context, then
7737 // we were an insertion and now need to pop up reenter hydration of our
7738 // siblings.
7739 popToNextHostParent(fiber);
7740 isHydrating = true;
7741 return false;
7742 }
7743
7744 var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now.
7745 // We only do this deeper than head and body since they tend to have random
7746 // other nodes in them. We also ignore components with pure text content in
7747 // side of them.
7748 // TODO: Better heuristic.
7749
7750 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
7751 var nextInstance = nextHydratableInstance;
7752
7753 while (nextInstance) {
7754 deleteHydratableInstance(fiber, nextInstance);
7755 nextInstance = getNextHydratableSibling(nextInstance);
7756 }
7757 }
7758
7759 popToNextHostParent(fiber);
7760
7761 if (fiber.tag === SuspenseComponent) {
7762 nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
7763 } else {
7764 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
7765 }
7766
7767 return true;
7768}
7769
7770function resetHydrationState() {
7771 if (!supportsHydration) {
7772 return;
7773 }
7774
7775 hydrationParentFiber = null;
7776 nextHydratableInstance = null;
7777 isHydrating = false;
7778}
7779
7780var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
7781var didReceiveUpdate = false;
7782var didWarnAboutBadClass;
7783var didWarnAboutModulePatternComponent;
7784var didWarnAboutContextTypeOnFunctionComponent;
7785var didWarnAboutGetDerivedStateOnFunctionComponent;
7786var didWarnAboutFunctionRefs;
7787var didWarnAboutReassigningProps;
7788var didWarnAboutMaxDuration;
7789var didWarnAboutRevealOrder;
7790var didWarnAboutTailOptions;
7791var didWarnAboutDefaultPropsOnFunctionComponent;
7792
7793{
7794 didWarnAboutBadClass = {};
7795 didWarnAboutModulePatternComponent = {};
7796 didWarnAboutContextTypeOnFunctionComponent = {};
7797 didWarnAboutGetDerivedStateOnFunctionComponent = {};
7798 didWarnAboutFunctionRefs = {};
7799 didWarnAboutReassigningProps = false;
7800 didWarnAboutMaxDuration = false;
7801 didWarnAboutRevealOrder = {};
7802 didWarnAboutTailOptions = {};
7803 didWarnAboutDefaultPropsOnFunctionComponent = {};
7804}
7805
7806function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
7807 if (current$$1 === null) {
7808 // If this is a fresh new component that hasn't been rendered yet, we
7809 // won't update its child set by applying minimal side-effects. Instead,
7810 // we will add them all to the child before it gets rendered. That means
7811 // we can optimize this reconciliation pass by not tracking side-effects.
7812 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7813 } else {
7814 // If the current child is the same as the work in progress, it means that
7815 // we haven't yet started any work on these children. Therefore, we use
7816 // the clone algorithm to create a copy of all the current children.
7817 // If we had any progressed work already, that is invalid at this point so
7818 // let's throw it out.
7819 workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, nextChildren, renderExpirationTime);
7820 }
7821}
7822
7823function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
7824 // This function is fork of reconcileChildren. It's used in cases where we
7825 // want to reconcile without matching against the existing set. This has the
7826 // effect of all current children being unmounted; even if the type and key
7827 // are the same, the old child is unmounted and a new child is created.
7828 //
7829 // To do this, we're going to go through the reconcile algorithm twice. In
7830 // the first pass, we schedule a deletion for all the current children by
7831 // passing null.
7832 workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime); // In the second pass, we mount the new children. The trick here is that we
7833 // pass null in place of where we usually pass the current child set. This has
7834 // the effect of remounting all children regardless of whether their their
7835 // identity matches.
7836
7837 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7838}
7839
7840function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
7841 // TODO: current can be non-null here even if the component
7842 // hasn't yet mounted. This happens after the first render suspends.
7843 // We'll need to figure out if this is fine or can cause issues.
7844 {
7845 if (workInProgress.type !== workInProgress.elementType) {
7846 // Lazy component props can't be validated in createElement
7847 // because they're only guaranteed to be resolved here.
7848 var innerPropTypes = Component.propTypes;
7849
7850 if (innerPropTypes) {
7851 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7852 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7853 }
7854 }
7855 }
7856
7857 var render = Component.render;
7858 var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
7859
7860 var nextChildren;
7861 prepareToReadContext(workInProgress, renderExpirationTime);
7862
7863 {
7864 ReactCurrentOwner$2.current = workInProgress;
7865 setCurrentPhase('render');
7866 nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
7867
7868 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7869 // Only double-render components with Hooks
7870 if (workInProgress.memoizedState !== null) {
7871 nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
7872 }
7873 }
7874
7875 setCurrentPhase(null);
7876 }
7877
7878 if (current$$1 !== null && !didReceiveUpdate) {
7879 bailoutHooks(current$$1, workInProgress, renderExpirationTime);
7880 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7881 } // React DevTools reads this flag.
7882
7883
7884 workInProgress.effectTag |= PerformedWork;
7885 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7886 return workInProgress.child;
7887}
7888
7889function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
7890 if (current$$1 === null) {
7891 var type = Component.type;
7892
7893 if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
7894 Component.defaultProps === undefined) {
7895 var resolvedType = type;
7896
7897 {
7898 resolvedType = resolveFunctionForHotReloading(type);
7899 } // If this is a plain function component without default props,
7900 // and with only the default shallow comparison, we upgrade it
7901 // to a SimpleMemoComponent to allow fast path updates.
7902
7903
7904 workInProgress.tag = SimpleMemoComponent;
7905 workInProgress.type = resolvedType;
7906
7907 {
7908 validateFunctionComponentInDev(workInProgress, type);
7909 }
7910
7911 return updateSimpleMemoComponent(current$$1, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
7912 }
7913
7914 {
7915 var innerPropTypes = type.propTypes;
7916
7917 if (innerPropTypes) {
7918 // Inner memo component props aren't currently validated in createElement.
7919 // We could move it there, but we'd still need this for lazy code path.
7920 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7921 'prop', getComponentName(type), getCurrentFiberStackInDev);
7922 }
7923 }
7924
7925 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
7926 child.ref = workInProgress.ref;
7927 child.return = workInProgress;
7928 workInProgress.child = child;
7929 return child;
7930 }
7931
7932 {
7933 var _type = Component.type;
7934 var _innerPropTypes = _type.propTypes;
7935
7936 if (_innerPropTypes) {
7937 // Inner memo component props aren't currently validated in createElement.
7938 // We could move it there, but we'd still need this for lazy code path.
7939 checkPropTypes(_innerPropTypes, nextProps, // Resolved props
7940 'prop', getComponentName(_type), getCurrentFiberStackInDev);
7941 }
7942 }
7943
7944 var currentChild = current$$1.child; // This is always exactly one child
7945
7946 if (updateExpirationTime < renderExpirationTime) {
7947 // This will be the props with resolved defaultProps,
7948 // unlike current.memoizedProps which will be the unresolved ones.
7949 var prevProps = currentChild.memoizedProps; // Default to shallow comparison
7950
7951 var compare = Component.compare;
7952 compare = compare !== null ? compare : shallowEqual;
7953
7954 if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
7955 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7956 }
7957 } // React DevTools reads this flag.
7958
7959
7960 workInProgress.effectTag |= PerformedWork;
7961 var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
7962 newChild.ref = workInProgress.ref;
7963 newChild.return = workInProgress;
7964 workInProgress.child = newChild;
7965 return newChild;
7966}
7967
7968function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
7969 // TODO: current can be non-null here even if the component
7970 // hasn't yet mounted. This happens when the inner render suspends.
7971 // We'll need to figure out if this is fine or can cause issues.
7972 {
7973 if (workInProgress.type !== workInProgress.elementType) {
7974 // Lazy component props can't be validated in createElement
7975 // because they're only guaranteed to be resolved here.
7976 var outerMemoType = workInProgress.elementType;
7977
7978 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
7979 // We warn when you define propTypes on lazy()
7980 // so let's just skip over it to find memo() outer wrapper.
7981 // Inner props for memo are validated later.
7982 outerMemoType = refineResolvedLazyComponent(outerMemoType);
7983 }
7984
7985 var outerPropTypes = outerMemoType && outerMemoType.propTypes;
7986
7987 if (outerPropTypes) {
7988 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
7989 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
7990 } // Inner propTypes will be validated in the function component path.
7991
7992 }
7993 }
7994
7995 if (current$$1 !== null) {
7996 var prevProps = current$$1.memoizedProps;
7997
7998 if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload:
7999 workInProgress.type === current$$1.type)) {
8000 didReceiveUpdate = false;
8001
8002 if (updateExpirationTime < renderExpirationTime) {
8003 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8004 }
8005 }
8006 }
8007
8008 return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
8009}
8010
8011function updateFragment(current$$1, workInProgress, renderExpirationTime) {
8012 var nextChildren = workInProgress.pendingProps;
8013 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8014 return workInProgress.child;
8015}
8016
8017function updateMode(current$$1, workInProgress, renderExpirationTime) {
8018 var nextChildren = workInProgress.pendingProps.children;
8019 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8020 return workInProgress.child;
8021}
8022
8023function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
8024 if (enableProfilerTimer) {
8025 workInProgress.effectTag |= Update;
8026 }
8027
8028 var nextProps = workInProgress.pendingProps;
8029 var nextChildren = nextProps.children;
8030 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8031 return workInProgress.child;
8032}
8033
8034function markRef(current$$1, workInProgress) {
8035 var ref = workInProgress.ref;
8036
8037 if (current$$1 === null && ref !== null || current$$1 !== null && current$$1.ref !== ref) {
8038 // Schedule a Ref effect
8039 workInProgress.effectTag |= Ref;
8040 }
8041}
8042
8043function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
8044 {
8045 if (workInProgress.type !== workInProgress.elementType) {
8046 // Lazy component props can't be validated in createElement
8047 // because they're only guaranteed to be resolved here.
8048 var innerPropTypes = Component.propTypes;
8049
8050 if (innerPropTypes) {
8051 checkPropTypes(innerPropTypes, nextProps, // Resolved props
8052 'prop', getComponentName(Component), getCurrentFiberStackInDev);
8053 }
8054 }
8055 }
8056
8057 var context;
8058
8059 if (!disableLegacyContext) {
8060 var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
8061 context = getMaskedContext(workInProgress, unmaskedContext);
8062 }
8063
8064 var nextChildren;
8065 prepareToReadContext(workInProgress, renderExpirationTime);
8066
8067 {
8068 ReactCurrentOwner$2.current = workInProgress;
8069 setCurrentPhase('render');
8070 nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
8071
8072 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8073 // Only double-render components with Hooks
8074 if (workInProgress.memoizedState !== null) {
8075 nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
8076 }
8077 }
8078
8079 setCurrentPhase(null);
8080 }
8081
8082 if (current$$1 !== null && !didReceiveUpdate) {
8083 bailoutHooks(current$$1, workInProgress, renderExpirationTime);
8084 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8085 } // React DevTools reads this flag.
8086
8087
8088 workInProgress.effectTag |= PerformedWork;
8089 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8090 return workInProgress.child;
8091}
8092
8093function updateClassComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
8094 {
8095 if (workInProgress.type !== workInProgress.elementType) {
8096 // Lazy component props can't be validated in createElement
8097 // because they're only guaranteed to be resolved here.
8098 var innerPropTypes = Component.propTypes;
8099
8100 if (innerPropTypes) {
8101 checkPropTypes(innerPropTypes, nextProps, // Resolved props
8102 'prop', getComponentName(Component), getCurrentFiberStackInDev);
8103 }
8104 }
8105 } // Push context providers early to prevent context stack mismatches.
8106 // During mounting we don't know the child context yet as the instance doesn't exist.
8107 // We will invalidate the child context in finishClassComponent() right after rendering.
8108
8109
8110 var hasContext;
8111
8112 if (isContextProvider(Component)) {
8113 hasContext = true;
8114 pushContextProvider(workInProgress);
8115 } else {
8116 hasContext = false;
8117 }
8118
8119 prepareToReadContext(workInProgress, renderExpirationTime);
8120 var instance = workInProgress.stateNode;
8121 var shouldUpdate;
8122
8123 if (instance === null) {
8124 if (current$$1 !== null) {
8125 // An class component without an instance only mounts if it suspended
8126 // inside a non- concurrent tree, in an inconsistent state. We want to
8127 // tree it like a new mount, even though an empty version of it already
8128 // committed. Disconnect the alternate pointers.
8129 current$$1.alternate = null;
8130 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
8131
8132 workInProgress.effectTag |= Placement;
8133 } // In the initial pass we might need to construct the instance.
8134
8135
8136 constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8137 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8138 shouldUpdate = true;
8139 } else if (current$$1 === null) {
8140 // In a resume, we'll already have an instance we can reuse.
8141 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8142 } else {
8143 shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
8144 }
8145
8146 var nextUnitOfWork = finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
8147
8148 {
8149 var inst = workInProgress.stateNode;
8150
8151 if (inst.props !== nextProps) {
8152 !didWarnAboutReassigningProps ? warning$1(false, 'It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component') : void 0;
8153 didWarnAboutReassigningProps = true;
8154 }
8155 }
8156
8157 return nextUnitOfWork;
8158}
8159
8160function finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
8161 // Refs should update even if shouldComponentUpdate returns false
8162 markRef(current$$1, workInProgress);
8163 var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
8164
8165 if (!shouldUpdate && !didCaptureError) {
8166 // Context providers should defer to sCU for rendering
8167 if (hasContext) {
8168 invalidateContextProvider(workInProgress, Component, false);
8169 }
8170
8171 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8172 }
8173
8174 var instance = workInProgress.stateNode; // Rerender
8175
8176 ReactCurrentOwner$2.current = workInProgress;
8177 var nextChildren;
8178
8179 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
8180 // If we captured an error, but getDerivedStateFrom catch is not defined,
8181 // unmount all the children. componentDidCatch will schedule an update to
8182 // re-render a fallback. This is temporary until we migrate everyone to
8183 // the new API.
8184 // TODO: Warn in a future release.
8185 nextChildren = null;
8186
8187 if (enableProfilerTimer) {
8188 stopProfilerTimerIfRunning(workInProgress);
8189 }
8190 } else {
8191 {
8192 setCurrentPhase('render');
8193 nextChildren = instance.render();
8194
8195 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8196 instance.render();
8197 }
8198
8199 setCurrentPhase(null);
8200 }
8201 } // React DevTools reads this flag.
8202
8203
8204 workInProgress.effectTag |= PerformedWork;
8205
8206 if (current$$1 !== null && didCaptureError) {
8207 // If we're recovering from an error, reconcile without reusing any of
8208 // the existing children. Conceptually, the normal children and the children
8209 // that are shown on error are two different sets, so we shouldn't reuse
8210 // normal children even if their identities match.
8211 forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
8212 } else {
8213 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8214 } // Memoize state using the values we just used to render.
8215 // TODO: Restructure so we never read values from the instance.
8216
8217
8218 workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
8219
8220 if (hasContext) {
8221 invalidateContextProvider(workInProgress, Component, true);
8222 }
8223
8224 return workInProgress.child;
8225}
8226
8227function pushHostRootContext(workInProgress) {
8228 var root = workInProgress.stateNode;
8229
8230 if (root.pendingContext) {
8231 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
8232 } else if (root.context) {
8233 // Should always be set
8234 pushTopLevelContextObject(workInProgress, root.context, false);
8235 }
8236
8237 pushHostContainer(workInProgress, root.containerInfo);
8238}
8239
8240function updateHostRoot(current$$1, workInProgress, renderExpirationTime) {
8241 pushHostRootContext(workInProgress);
8242 var updateQueue = workInProgress.updateQueue;
8243
8244 (function () {
8245 if (!(updateQueue !== null)) {
8246 {
8247 throw ReactError(Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue."));
8248 }
8249 }
8250 })();
8251
8252 var nextProps = workInProgress.pendingProps;
8253 var prevState = workInProgress.memoizedState;
8254 var prevChildren = prevState !== null ? prevState.element : null;
8255 processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
8256 var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
8257 // being called "element".
8258
8259 var nextChildren = nextState.element;
8260
8261 if (nextChildren === prevChildren) {
8262 // If the state is the same as before, that's a bailout because we had
8263 // no work that expires at this time.
8264 resetHydrationState();
8265 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8266 }
8267
8268 var root = workInProgress.stateNode;
8269
8270 if (root.hydrate && enterHydrationState(workInProgress)) {
8271 // If we don't have any current children this might be the first pass.
8272 // We always try to hydrate. If this isn't a hydration pass there won't
8273 // be any children to hydrate which is effectively the same thing as
8274 // not hydrating.
8275 var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
8276 workInProgress.child = child;
8277 var node = child;
8278
8279 while (node) {
8280 // Mark each child as hydrating. This is a fast path to know whether this
8281 // tree is part of a hydrating tree. This is used to determine if a child
8282 // node has fully mounted yet, and for scheduling event replaying.
8283 // Conceptually this is similar to Placement in that a new subtree is
8284 // inserted into the React tree here. It just happens to not need DOM
8285 // mutations because it already exists.
8286 node.effectTag = node.effectTag & ~Placement | Hydrating;
8287 node = node.sibling;
8288 }
8289 } else {
8290 // Otherwise reset hydration state in case we aborted and resumed another
8291 // root.
8292 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8293 resetHydrationState();
8294 }
8295
8296 return workInProgress.child;
8297}
8298
8299function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
8300 pushHostContext(workInProgress);
8301
8302 if (current$$1 === null) {
8303 tryToClaimNextHydratableInstance(workInProgress);
8304 }
8305
8306 var type = workInProgress.type;
8307 var nextProps = workInProgress.pendingProps;
8308 var prevProps = current$$1 !== null ? current$$1.memoizedProps : null;
8309 var nextChildren = nextProps.children;
8310 var isDirectTextChild = shouldSetTextContent(type, nextProps);
8311
8312 if (isDirectTextChild) {
8313 // We special case a direct text child of a host node. This is a common
8314 // case. We won't handle it as a reified child. We will instead handle
8315 // this in the host environment that also have access to this prop. That
8316 // avoids allocating another HostText fiber and traversing it.
8317 nextChildren = null;
8318 } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
8319 // If we're switching from a direct text child to a normal child, or to
8320 // empty, we need to schedule the text content to be reset.
8321 workInProgress.effectTag |= ContentReset;
8322 }
8323
8324 markRef(current$$1, workInProgress); // Check the host config to see if the children are offscreen/hidden.
8325
8326 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) {
8327 if (enableSchedulerTracing) {
8328 markSpawnedWork(Never);
8329 } // Schedule this fiber to re-render at offscreen priority. Then bailout.
8330
8331
8332 workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
8333 return null;
8334 }
8335
8336 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8337 return workInProgress.child;
8338}
8339
8340function updateHostText(current$$1, workInProgress) {
8341 if (current$$1 === null) {
8342 tryToClaimNextHydratableInstance(workInProgress);
8343 } // Nothing to do here. This is terminal. We'll do the completion step
8344 // immediately after.
8345
8346
8347 return null;
8348}
8349
8350function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
8351 if (_current !== null) {
8352 // An lazy component only mounts if it suspended inside a non-
8353 // concurrent tree, in an inconsistent state. We want to treat it like
8354 // a new mount, even though an empty version of it already committed.
8355 // Disconnect the alternate pointers.
8356 _current.alternate = null;
8357 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
8358
8359 workInProgress.effectTag |= Placement;
8360 }
8361
8362 var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet.
8363 // Cancel and resume right after we know the tag.
8364
8365 cancelWorkTimer(workInProgress);
8366 var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type.
8367
8368 workInProgress.type = Component;
8369 var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
8370 startWorkTimer(workInProgress);
8371 var resolvedProps = resolveDefaultProps(Component, props);
8372 var child;
8373
8374 switch (resolvedTag) {
8375 case FunctionComponent:
8376 {
8377 {
8378 validateFunctionComponentInDev(workInProgress, Component);
8379 workInProgress.type = Component = resolveFunctionForHotReloading(Component);
8380 }
8381
8382 child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8383 break;
8384 }
8385
8386 case ClassComponent:
8387 {
8388 {
8389 workInProgress.type = Component = resolveClassForHotReloading(Component);
8390 }
8391
8392 child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8393 break;
8394 }
8395
8396 case ForwardRef:
8397 {
8398 {
8399 workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
8400 }
8401
8402 child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8403 break;
8404 }
8405
8406 case MemoComponent:
8407 {
8408 {
8409 if (workInProgress.type !== workInProgress.elementType) {
8410 var outerPropTypes = Component.propTypes;
8411
8412 if (outerPropTypes) {
8413 checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
8414 'prop', getComponentName(Component), getCurrentFiberStackInDev);
8415 }
8416 }
8417 }
8418
8419 child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
8420 updateExpirationTime, renderExpirationTime);
8421 break;
8422 }
8423
8424 default:
8425 {
8426 var hint = '';
8427
8428 {
8429 if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
8430 hint = ' Did you wrap a component in React.lazy() more than once?';
8431 }
8432 } // This message intentionally doesn't mention ForwardRef or MemoComponent
8433 // because the fact that it's a separate type of work is an
8434 // implementation detail.
8435
8436
8437 (function () {
8438 {
8439 {
8440 throw ReactError(Error("Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint));
8441 }
8442 }
8443 })();
8444 }
8445 }
8446
8447 return child;
8448}
8449
8450function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
8451 if (_current !== null) {
8452 // An incomplete component only mounts if it suspended inside a non-
8453 // concurrent tree, in an inconsistent state. We want to treat it like
8454 // a new mount, even though an empty version of it already committed.
8455 // Disconnect the alternate pointers.
8456 _current.alternate = null;
8457 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
8458
8459 workInProgress.effectTag |= Placement;
8460 } // Promote the fiber to a class and try rendering again.
8461
8462
8463 workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
8464 // Push context providers early to prevent context stack mismatches.
8465 // During mounting we don't know the child context yet as the instance doesn't exist.
8466 // We will invalidate the child context in finishClassComponent() right after rendering.
8467
8468 var hasContext;
8469
8470 if (isContextProvider(Component)) {
8471 hasContext = true;
8472 pushContextProvider(workInProgress);
8473 } else {
8474 hasContext = false;
8475 }
8476
8477 prepareToReadContext(workInProgress, renderExpirationTime);
8478 constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8479 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8480 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
8481}
8482
8483function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
8484 if (_current !== null) {
8485 // An indeterminate component only mounts if it suspended inside a non-
8486 // concurrent tree, in an inconsistent state. We want to treat it like
8487 // a new mount, even though an empty version of it already committed.
8488 // Disconnect the alternate pointers.
8489 _current.alternate = null;
8490 workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
8491
8492 workInProgress.effectTag |= Placement;
8493 }
8494
8495 var props = workInProgress.pendingProps;
8496 var context;
8497
8498 if (!disableLegacyContext) {
8499 var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
8500 context = getMaskedContext(workInProgress, unmaskedContext);
8501 }
8502
8503 prepareToReadContext(workInProgress, renderExpirationTime);
8504 var value;
8505
8506 {
8507 if (Component.prototype && typeof Component.prototype.render === 'function') {
8508 var componentName = getComponentName(Component) || 'Unknown';
8509
8510 if (!didWarnAboutBadClass[componentName]) {
8511 warningWithoutStack$1(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
8512 didWarnAboutBadClass[componentName] = true;
8513 }
8514 }
8515
8516 if (workInProgress.mode & StrictMode) {
8517 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
8518 }
8519
8520 ReactCurrentOwner$2.current = workInProgress;
8521 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
8522 } // React DevTools reads this flag.
8523
8524
8525 workInProgress.effectTag |= PerformedWork;
8526
8527 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
8528 {
8529 var _componentName = getComponentName(Component) || 'Unknown';
8530
8531 if (!didWarnAboutModulePatternComponent[_componentName]) {
8532 warningWithoutStack$1(false, 'The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName);
8533 didWarnAboutModulePatternComponent[_componentName] = true;
8534 }
8535 } // Proceed under the assumption that this is a class instance
8536
8537
8538 workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
8539
8540 resetHooks(); // Push context providers early to prevent context stack mismatches.
8541 // During mounting we don't know the child context yet as the instance doesn't exist.
8542 // We will invalidate the child context in finishClassComponent() right after rendering.
8543
8544 var hasContext = false;
8545
8546 if (isContextProvider(Component)) {
8547 hasContext = true;
8548 pushContextProvider(workInProgress);
8549 } else {
8550 hasContext = false;
8551 }
8552
8553 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
8554 var getDerivedStateFromProps = Component.getDerivedStateFromProps;
8555
8556 if (typeof getDerivedStateFromProps === 'function') {
8557 applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
8558 }
8559
8560 adoptClassInstance(workInProgress, value);
8561 mountClassInstance(workInProgress, Component, props, renderExpirationTime);
8562 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
8563 } else {
8564 // Proceed under the assumption that this is a function component
8565 workInProgress.tag = FunctionComponent;
8566
8567 {
8568 if (disableLegacyContext && Component.contextTypes) {
8569 warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with React.useContext() instead.', getComponentName(Component) || 'Unknown');
8570 }
8571
8572 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8573 // Only double-render components with Hooks
8574 if (workInProgress.memoizedState !== null) {
8575 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
8576 }
8577 }
8578 }
8579
8580 reconcileChildren(null, workInProgress, value, renderExpirationTime);
8581
8582 {
8583 validateFunctionComponentInDev(workInProgress, Component);
8584 }
8585
8586 return workInProgress.child;
8587 }
8588}
8589
8590function validateFunctionComponentInDev(workInProgress, Component) {
8591 if (Component) {
8592 !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
8593 }
8594
8595 if (workInProgress.ref !== null) {
8596 var info = '';
8597 var ownerName = getCurrentFiberOwnerNameInDevOrNull();
8598
8599 if (ownerName) {
8600 info += '\n\nCheck the render method of `' + ownerName + '`.';
8601 }
8602
8603 var warningKey = ownerName || workInProgress._debugID || '';
8604 var debugSource = workInProgress._debugSource;
8605
8606 if (debugSource) {
8607 warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
8608 }
8609
8610 if (!didWarnAboutFunctionRefs[warningKey]) {
8611 didWarnAboutFunctionRefs[warningKey] = true;
8612 warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
8613 }
8614 }
8615
8616 if (warnAboutDefaultPropsOnFunctionComponents && Component.defaultProps !== undefined) {
8617 var componentName = getComponentName(Component) || 'Unknown';
8618
8619 if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
8620 warningWithoutStack$1(false, '%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
8621 didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
8622 }
8623 }
8624
8625 if (typeof Component.getDerivedStateFromProps === 'function') {
8626 var _componentName2 = getComponentName(Component) || 'Unknown';
8627
8628 if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
8629 warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName2);
8630 didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
8631 }
8632 }
8633
8634 if (typeof Component.contextType === 'object' && Component.contextType !== null) {
8635 var _componentName3 = getComponentName(Component) || 'Unknown';
8636
8637 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
8638 warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName3);
8639 didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
8640 }
8641 }
8642}
8643
8644var SUSPENDED_MARKER = {
8645 dehydrated: null,
8646 retryTime: Never
8647};
8648
8649function shouldRemainOnFallback(suspenseContext, current$$1, workInProgress) {
8650 // If the context is telling us that we should show a fallback, and we're not
8651 // already showing content, then we should show the fallback instead.
8652 return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current$$1 === null || current$$1.memoizedState !== null);
8653}
8654
8655function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
8656 var mode = workInProgress.mode;
8657 var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
8658
8659 {
8660 if (shouldSuspend(workInProgress)) {
8661 workInProgress.effectTag |= DidCapture;
8662 }
8663 }
8664
8665 var suspenseContext = suspenseStackCursor.current;
8666 var nextDidTimeout = false;
8667 var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
8668
8669 if (didSuspend || shouldRemainOnFallback(suspenseContext, current$$1, workInProgress)) {
8670 // Something in this boundary's subtree already suspended. Switch to
8671 // rendering the fallback children.
8672 nextDidTimeout = true;
8673 workInProgress.effectTag &= ~DidCapture;
8674 } else {
8675 // Attempting the main content
8676 if (current$$1 === null || current$$1.memoizedState !== null) {
8677 // This is a new mount or this boundary is already showing a fallback state.
8678 // Mark this subtree context as having at least one invisible parent that could
8679 // handle the fallback state.
8680 // Boundaries without fallbacks or should be avoided are not considered since
8681 // they cannot handle preferred fallback states.
8682 if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
8683 suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
8684 }
8685 }
8686 }
8687
8688 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
8689 pushSuspenseContext(workInProgress, suspenseContext);
8690
8691 {
8692 if ('maxDuration' in nextProps) {
8693 if (!didWarnAboutMaxDuration) {
8694 didWarnAboutMaxDuration = true;
8695 warning$1(false, 'maxDuration has been removed from React. ' + 'Remove the maxDuration prop.');
8696 }
8697 }
8698 } // This next part is a bit confusing. If the children timeout, we switch to
8699 // showing the fallback children in place of the "primary" children.
8700 // However, we don't want to delete the primary children because then their
8701 // state will be lost (both the React state and the host state, e.g.
8702 // uncontrolled form inputs). Instead we keep them mounted and hide them.
8703 // Both the fallback children AND the primary children are rendered at the
8704 // same time. Once the primary children are un-suspended, we can delete
8705 // the fallback children — don't need to preserve their state.
8706 //
8707 // The two sets of children are siblings in the host environment, but
8708 // semantically, for purposes of reconciliation, they are two separate sets.
8709 // So we store them using two fragment fibers.
8710 //
8711 // However, we want to avoid allocating extra fibers for every placeholder.
8712 // They're only necessary when the children time out, because that's the
8713 // only time when both sets are mounted.
8714 //
8715 // So, the extra fragment fibers are only used if the children time out.
8716 // Otherwise, we render the primary children directly. This requires some
8717 // custom reconciliation logic to preserve the state of the primary
8718 // children. It's essentially a very basic form of re-parenting.
8719
8720
8721 if (current$$1 === null) {
8722 if (enableSuspenseServerRenderer) {
8723 // If we're currently hydrating, try to hydrate this boundary.
8724 // But only if this has a fallback.
8725 if (nextProps.fallback !== undefined) {
8726 tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component.
8727
8728 var suspenseState = workInProgress.memoizedState;
8729
8730 if (suspenseState !== null) {
8731 var dehydrated = suspenseState.dehydrated;
8732
8733 if (dehydrated !== null) {
8734 return mountDehydratedSuspenseComponent(workInProgress, dehydrated, renderExpirationTime);
8735 }
8736 }
8737 }
8738 } // This is the initial mount. This branch is pretty simple because there's
8739 // no previous state that needs to be preserved.
8740
8741
8742 if (nextDidTimeout) {
8743 // Mount separate fragments for primary and fallback children.
8744 var nextFallbackChildren = nextProps.fallback;
8745 var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
8746 primaryChildFragment.return = workInProgress;
8747
8748 if ((workInProgress.mode & BatchedMode) === NoMode) {
8749 // Outside of batched mode, we commit the effects from the
8750 // partially completed, timed-out tree, too.
8751 var progressedState = workInProgress.memoizedState;
8752 var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
8753 primaryChildFragment.child = progressedPrimaryChild;
8754 var progressedChild = progressedPrimaryChild;
8755
8756 while (progressedChild !== null) {
8757 progressedChild.return = primaryChildFragment;
8758 progressedChild = progressedChild.sibling;
8759 }
8760 }
8761
8762 var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
8763 fallbackChildFragment.return = workInProgress;
8764 primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the
8765 // fallback children.
8766
8767 workInProgress.memoizedState = SUSPENDED_MARKER;
8768 workInProgress.child = primaryChildFragment;
8769 return fallbackChildFragment;
8770 } else {
8771 // Mount the primary children without an intermediate fragment fiber.
8772 var nextPrimaryChildren = nextProps.children;
8773 workInProgress.memoizedState = null;
8774 return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
8775 }
8776 } else {
8777 // This is an update. This branch is more complicated because we need to
8778 // ensure the state of the primary children is preserved.
8779 var prevState = current$$1.memoizedState;
8780
8781 if (prevState !== null) {
8782 if (enableSuspenseServerRenderer) {
8783 var _dehydrated = prevState.dehydrated;
8784
8785 if (_dehydrated !== null) {
8786 if (!didSuspend) {
8787 return updateDehydratedSuspenseComponent(current$$1, workInProgress, _dehydrated, prevState, renderExpirationTime);
8788 } else if (workInProgress.memoizedState !== null) {
8789 // Something suspended and we should still be in dehydrated mode.
8790 // Leave the existing child in place.
8791 workInProgress.child = current$$1.child; // The dehydrated completion pass expects this flag to be there
8792 // but the normal suspense pass doesn't.
8793
8794 workInProgress.effectTag |= DidCapture;
8795 return null;
8796 } else {
8797 // Suspended but we should no longer be in dehydrated mode.
8798 // Therefore we now have to render the fallback. Wrap the children
8799 // in a fragment fiber to keep them separate from the fallback
8800 // children.
8801 var _nextFallbackChildren = nextProps.fallback;
8802
8803 var _primaryChildFragment = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
8804 // going to render this fragment.
8805 null, mode, NoWork, null);
8806
8807 _primaryChildFragment.return = workInProgress; // This is always null since we never want the previous child
8808 // that we're not going to hydrate.
8809
8810 _primaryChildFragment.child = null;
8811
8812 if ((workInProgress.mode & BatchedMode) === NoMode) {
8813 // Outside of batched mode, we commit the effects from the
8814 // partially completed, timed-out tree, too.
8815 var _progressedChild = _primaryChildFragment.child = workInProgress.child;
8816
8817 while (_progressedChild !== null) {
8818 _progressedChild.return = _primaryChildFragment;
8819 _progressedChild = _progressedChild.sibling;
8820 }
8821 } else {
8822 // We will have dropped the effect list which contains the deletion.
8823 // We need to reconcile to delete the current child.
8824 reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
8825 } // Because primaryChildFragment is a new fiber that we're inserting as the
8826 // parent of a new tree, we need to set its treeBaseDuration.
8827
8828
8829 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8830 // treeBaseDuration is the sum of all the child tree base durations.
8831 var treeBaseDuration = 0;
8832 var hiddenChild = _primaryChildFragment.child;
8833
8834 while (hiddenChild !== null) {
8835 treeBaseDuration += hiddenChild.treeBaseDuration;
8836 hiddenChild = hiddenChild.sibling;
8837 }
8838
8839 _primaryChildFragment.treeBaseDuration = treeBaseDuration;
8840 } // Create a fragment from the fallback children, too.
8841
8842
8843 var _fallbackChildFragment = createFiberFromFragment(_nextFallbackChildren, mode, renderExpirationTime, null);
8844
8845 _fallbackChildFragment.return = workInProgress;
8846 _primaryChildFragment.sibling = _fallbackChildFragment;
8847 _fallbackChildFragment.effectTag |= Placement;
8848 _primaryChildFragment.childExpirationTime = NoWork;
8849 workInProgress.memoizedState = SUSPENDED_MARKER;
8850 workInProgress.child = _primaryChildFragment; // Skip the primary children, and continue working on the
8851 // fallback children.
8852
8853 return _fallbackChildFragment;
8854 }
8855 }
8856 } // The current tree already timed out. That means each child set is
8857 // wrapped in a fragment fiber.
8858
8859
8860 var currentPrimaryChildFragment = current$$1.child;
8861 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
8862
8863 if (nextDidTimeout) {
8864 // Still timed out. Reuse the current primary children by cloning
8865 // its fragment. We're going to skip over these entirely.
8866 var _nextFallbackChildren2 = nextProps.fallback;
8867
8868 var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
8869
8870 _primaryChildFragment2.return = workInProgress;
8871
8872 if ((workInProgress.mode & BatchedMode) === NoMode) {
8873 // Outside of batched mode, we commit the effects from the
8874 // partially completed, timed-out tree, too.
8875 var _progressedState = workInProgress.memoizedState;
8876
8877 var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
8878
8879 if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
8880 _primaryChildFragment2.child = _progressedPrimaryChild;
8881 var _progressedChild2 = _progressedPrimaryChild;
8882
8883 while (_progressedChild2 !== null) {
8884 _progressedChild2.return = _primaryChildFragment2;
8885 _progressedChild2 = _progressedChild2.sibling;
8886 }
8887 }
8888 } // Because primaryChildFragment is a new fiber that we're inserting as the
8889 // parent of a new tree, we need to set its treeBaseDuration.
8890
8891
8892 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8893 // treeBaseDuration is the sum of all the child tree base durations.
8894 var _treeBaseDuration = 0;
8895 var _hiddenChild = _primaryChildFragment2.child;
8896
8897 while (_hiddenChild !== null) {
8898 _treeBaseDuration += _hiddenChild.treeBaseDuration;
8899 _hiddenChild = _hiddenChild.sibling;
8900 }
8901
8902 _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
8903 } // Clone the fallback child fragment, too. These we'll continue
8904 // working on.
8905
8906
8907 var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2, currentFallbackChildFragment.expirationTime);
8908
8909 _fallbackChildFragment2.return = workInProgress;
8910 _primaryChildFragment2.sibling = _fallbackChildFragment2;
8911 _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
8912 // fallback children.
8913
8914 workInProgress.memoizedState = SUSPENDED_MARKER;
8915 workInProgress.child = _primaryChildFragment2;
8916 return _fallbackChildFragment2;
8917 } else {
8918 // No longer suspended. Switch back to showing the primary children,
8919 // and remove the intermediate fragment fiber.
8920 var _nextPrimaryChildren = nextProps.children;
8921 var currentPrimaryChild = currentPrimaryChildFragment.child;
8922 var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime); // If this render doesn't suspend, we need to delete the fallback
8923 // children. Wait until the complete phase, after we've confirmed the
8924 // fallback is no longer needed.
8925 // TODO: Would it be better to store the fallback fragment on
8926 // the stateNode?
8927 // Continue rendering the children, like we normally do.
8928
8929 workInProgress.memoizedState = null;
8930 return workInProgress.child = primaryChild;
8931 }
8932 } else {
8933 // The current tree has not already timed out. That means the primary
8934 // children are not wrapped in a fragment fiber.
8935 var _currentPrimaryChild = current$$1.child;
8936
8937 if (nextDidTimeout) {
8938 // Timed out. Wrap the children in a fragment fiber to keep them
8939 // separate from the fallback children.
8940 var _nextFallbackChildren3 = nextProps.fallback;
8941
8942 var _primaryChildFragment3 = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
8943 // going to render this fragment.
8944 null, mode, NoWork, null);
8945
8946 _primaryChildFragment3.return = workInProgress;
8947 _primaryChildFragment3.child = _currentPrimaryChild;
8948
8949 if (_currentPrimaryChild !== null) {
8950 _currentPrimaryChild.return = _primaryChildFragment3;
8951 } // Even though we're creating a new fiber, there are no new children,
8952 // because we're reusing an already mounted tree. So we don't need to
8953 // schedule a placement.
8954 // primaryChildFragment.effectTag |= Placement;
8955
8956
8957 if ((workInProgress.mode & BatchedMode) === NoMode) {
8958 // Outside of batched mode, we commit the effects from the
8959 // partially completed, timed-out tree, too.
8960 var _progressedState2 = workInProgress.memoizedState;
8961
8962 var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
8963
8964 _primaryChildFragment3.child = _progressedPrimaryChild2;
8965 var _progressedChild3 = _progressedPrimaryChild2;
8966
8967 while (_progressedChild3 !== null) {
8968 _progressedChild3.return = _primaryChildFragment3;
8969 _progressedChild3 = _progressedChild3.sibling;
8970 }
8971 } // Because primaryChildFragment is a new fiber that we're inserting as the
8972 // parent of a new tree, we need to set its treeBaseDuration.
8973
8974
8975 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8976 // treeBaseDuration is the sum of all the child tree base durations.
8977 var _treeBaseDuration2 = 0;
8978 var _hiddenChild2 = _primaryChildFragment3.child;
8979
8980 while (_hiddenChild2 !== null) {
8981 _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
8982 _hiddenChild2 = _hiddenChild2.sibling;
8983 }
8984
8985 _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
8986 } // Create a fragment from the fallback children, too.
8987
8988
8989 var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null);
8990
8991 _fallbackChildFragment3.return = workInProgress;
8992 _primaryChildFragment3.sibling = _fallbackChildFragment3;
8993 _fallbackChildFragment3.effectTag |= Placement;
8994 _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
8995 // fallback children.
8996
8997 workInProgress.memoizedState = SUSPENDED_MARKER;
8998 workInProgress.child = _primaryChildFragment3;
8999 return _fallbackChildFragment3;
9000 } else {
9001 // Still haven't timed out. Continue rendering the children, like we
9002 // normally do.
9003 workInProgress.memoizedState = null;
9004 var _nextPrimaryChildren2 = nextProps.children;
9005 return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
9006 }
9007 }
9008 }
9009}
9010
9011function retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime) {
9012 // We're now not suspended nor dehydrated.
9013 workInProgress.memoizedState = null; // Retry with the full children.
9014
9015 var nextProps = workInProgress.pendingProps;
9016 var nextChildren = nextProps.children; // This will ensure that the children get Placement effects and
9017 // that the old child gets a Deletion effect.
9018 // We could also call forceUnmountCurrentAndReconcile.
9019
9020 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9021 return workInProgress.child;
9022}
9023
9024function mountDehydratedSuspenseComponent(workInProgress, suspenseInstance, renderExpirationTime) {
9025 // During the first pass, we'll bail out and not drill into the children.
9026 // Instead, we'll leave the content in place and try to hydrate it later.
9027 if ((workInProgress.mode & BatchedMode) === NoMode) {
9028 {
9029 warning$1(false, 'Cannot hydrate Suspense in legacy mode. Switch from ' + 'ReactDOM.hydrate(element, container) to ' + 'ReactDOM.unstable_createSyncRoot(container, { hydrate: true })' + '.render(element) or remove the Suspense components from ' + 'the server rendered components.');
9030 }
9031
9032 workInProgress.expirationTime = Sync;
9033 } else if (isSuspenseInstanceFallback(suspenseInstance)) {
9034 // This is a client-only boundary. Since we won't get any content from the server
9035 // for this, we need to schedule that at a higher priority based on when it would
9036 // have timed out. In theory we could render it in this pass but it would have the
9037 // wrong priority associated with it and will prevent hydration of parent path.
9038 // Instead, we'll leave work left on it to render it in a separate commit.
9039 // TODO This time should be the time at which the server rendered response that is
9040 // a parent to this boundary was displayed. However, since we currently don't have
9041 // a protocol to transfer that time, we'll just estimate it by using the current
9042 // time. This will mean that Suspense timeouts are slightly shifted to later than
9043 // they should be.
9044 var serverDisplayTime = requestCurrentTime(); // Schedule a normal pri update to render this content.
9045
9046 var newExpirationTime = computeAsyncExpiration(serverDisplayTime);
9047
9048 if (enableSchedulerTracing) {
9049 markSpawnedWork(newExpirationTime);
9050 }
9051
9052 workInProgress.expirationTime = newExpirationTime;
9053 } else {
9054 // We'll continue hydrating the rest at offscreen priority since we'll already
9055 // be showing the right content coming from the server, it is no rush.
9056 workInProgress.expirationTime = Never;
9057
9058 if (enableSchedulerTracing) {
9059 markSpawnedWork(Never);
9060 }
9061 }
9062
9063 return null;
9064}
9065
9066function updateDehydratedSuspenseComponent(current$$1, workInProgress, suspenseInstance, suspenseState, renderExpirationTime) {
9067 // We should never be hydrating at this point because it is the first pass,
9068 // but after we've already committed once.
9069 warnIfHydrating();
9070
9071 if ((workInProgress.mode & BatchedMode) === NoMode) {
9072 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
9073 }
9074
9075 if (isSuspenseInstanceFallback(suspenseInstance)) {
9076 // This boundary is in a permanent fallback state. In this case, we'll never
9077 // get an update and we'll never be able to hydrate the final content. Let's just try the
9078 // client side render instead.
9079 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
9080 } // We use childExpirationTime to indicate that a child might depend on context, so if
9081 // any context has changed, we need to treat is as if the input might have changed.
9082
9083
9084 var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
9085
9086 if (didReceiveUpdate || hasContextChanged$$1) {
9087 // This boundary has changed since the first render. This means that we are now unable to
9088 // hydrate it. We might still be able to hydrate it using an earlier expiration time, if
9089 // we are rendering at lower expiration than sync.
9090 if (renderExpirationTime < Sync) {
9091 if (suspenseState.retryTime <= renderExpirationTime) {
9092 // This render is even higher pri than we've seen before, let's try again
9093 // at even higher pri.
9094 var attemptHydrationAtExpirationTime = renderExpirationTime + 1;
9095 suspenseState.retryTime = attemptHydrationAtExpirationTime;
9096 scheduleWork(current$$1, attemptHydrationAtExpirationTime); // TODO: Early abort this render.
9097 } else {// We have already tried to ping at a higher priority than we're rendering with
9098 // so if we got here, we must have failed to hydrate at those levels. We must
9099 // now give up. Instead, we're going to delete the whole subtree and instead inject
9100 // a new real Suspense boundary to take its place, which may render content
9101 // or fallback. This might suspend for a while and if it does we might still have
9102 // an opportunity to hydrate before this pass commits.
9103 }
9104 } // If we have scheduled higher pri work above, this will probably just abort the render
9105 // since we now have higher priority work, but in case it doesn't, we need to prepare to
9106 // render something, if we time out. Even if that requires us to delete everything and
9107 // skip hydration.
9108 // Delay having to do this as long as the suspense timeout allows us.
9109
9110
9111 renderDidSuspendDelayIfPossible();
9112 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
9113 } else if (isSuspenseInstancePending(suspenseInstance)) {
9114 // This component is still pending more data from the server, so we can't hydrate its
9115 // content. We treat it as if this component suspended itself. It might seem as if
9116 // we could just try to render it client-side instead. However, this will perform a
9117 // lot of unnecessary work and is unlikely to complete since it often will suspend
9118 // on missing data anyway. Additionally, the server might be able to render more
9119 // than we can on the client yet. In that case we'd end up with more fallback states
9120 // on the client than if we just leave it alone. If the server times out or errors
9121 // these should update this boundary to the permanent Fallback state instead.
9122 // Mark it as having captured (i.e. suspended).
9123 workInProgress.effectTag |= DidCapture; // Leave the child in place. I.e. the dehydrated fragment.
9124
9125 workInProgress.child = current$$1.child; // Register a callback to retry this boundary once the server has sent the result.
9126
9127 registerSuspenseInstanceRetry(suspenseInstance, retryDehydratedSuspenseBoundary.bind(null, current$$1));
9128 return null;
9129 } else {
9130 // This is the first attempt.
9131 reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress, suspenseInstance);
9132 var nextProps = workInProgress.pendingProps;
9133 var nextChildren = nextProps.children;
9134 var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
9135 var node = child;
9136
9137 while (node) {
9138 // Mark each child as hydrating. This is a fast path to know whether this
9139 // tree is part of a hydrating tree. This is used to determine if a child
9140 // node has fully mounted yet, and for scheduling event replaying.
9141 // Conceptually this is similar to Placement in that a new subtree is
9142 // inserted into the React tree here. It just happens to not need DOM
9143 // mutations because it already exists.
9144 node.effectTag |= Hydrating;
9145 node = node.sibling;
9146 }
9147
9148 workInProgress.child = child;
9149 return workInProgress.child;
9150 }
9151}
9152
9153function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
9154 // Mark any Suspense boundaries with fallbacks as having work to do.
9155 // If they were previously forced into fallbacks, they may now be able
9156 // to unblock.
9157 var node = firstChild;
9158
9159 while (node !== null) {
9160 if (node.tag === SuspenseComponent) {
9161 var state = node.memoizedState;
9162
9163 if (state !== null) {
9164 if (node.expirationTime < renderExpirationTime) {
9165 node.expirationTime = renderExpirationTime;
9166 }
9167
9168 var alternate = node.alternate;
9169
9170 if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
9171 alternate.expirationTime = renderExpirationTime;
9172 }
9173
9174 scheduleWorkOnParentPath(node.return, renderExpirationTime);
9175 }
9176 } else if (node.child !== null) {
9177 node.child.return = node;
9178 node = node.child;
9179 continue;
9180 }
9181
9182 if (node === workInProgress) {
9183 return;
9184 }
9185
9186 while (node.sibling === null) {
9187 if (node.return === null || node.return === workInProgress) {
9188 return;
9189 }
9190
9191 node = node.return;
9192 }
9193
9194 node.sibling.return = node.return;
9195 node = node.sibling;
9196 }
9197}
9198
9199function findLastContentRow(firstChild) {
9200 // This is going to find the last row among these children that is already
9201 // showing content on the screen, as opposed to being in fallback state or
9202 // new. If a row has multiple Suspense boundaries, any of them being in the
9203 // fallback state, counts as the whole row being in a fallback state.
9204 // Note that the "rows" will be workInProgress, but any nested children
9205 // will still be current since we haven't rendered them yet. The mounted
9206 // order may not be the same as the new order. We use the new order.
9207 var row = firstChild;
9208 var lastContentRow = null;
9209
9210 while (row !== null) {
9211 var currentRow = row.alternate; // New rows can't be content rows.
9212
9213 if (currentRow !== null && findFirstSuspended(currentRow) === null) {
9214 lastContentRow = row;
9215 }
9216
9217 row = row.sibling;
9218 }
9219
9220 return lastContentRow;
9221}
9222
9223function validateRevealOrder(revealOrder) {
9224 {
9225 if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
9226 didWarnAboutRevealOrder[revealOrder] = true;
9227
9228 if (typeof revealOrder === 'string') {
9229 switch (revealOrder.toLowerCase()) {
9230 case 'together':
9231 case 'forwards':
9232 case 'backwards':
9233 {
9234 warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
9235 break;
9236 }
9237
9238 case 'forward':
9239 case 'backward':
9240 {
9241 warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
9242 break;
9243 }
9244
9245 default:
9246 warning$1(false, '"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
9247 break;
9248 }
9249 } else {
9250 warning$1(false, '%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
9251 }
9252 }
9253 }
9254}
9255
9256function validateTailOptions(tailMode, revealOrder) {
9257 {
9258 if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
9259 if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
9260 didWarnAboutTailOptions[tailMode] = true;
9261 warning$1(false, '"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
9262 } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
9263 didWarnAboutTailOptions[tailMode] = true;
9264 warning$1(false, '<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
9265 }
9266 }
9267 }
9268}
9269
9270function validateSuspenseListNestedChild(childSlot, index) {
9271 {
9272 var isArray = Array.isArray(childSlot);
9273 var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
9274
9275 if (isArray || isIterable) {
9276 var type = isArray ? 'array' : 'iterable';
9277 warning$1(false, 'A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type);
9278 return false;
9279 }
9280 }
9281
9282 return true;
9283}
9284
9285function validateSuspenseListChildren(children, revealOrder) {
9286 {
9287 if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
9288 if (Array.isArray(children)) {
9289 for (var i = 0; i < children.length; i++) {
9290 if (!validateSuspenseListNestedChild(children[i], i)) {
9291 return;
9292 }
9293 }
9294 } else {
9295 var iteratorFn = getIteratorFn(children);
9296
9297 if (typeof iteratorFn === 'function') {
9298 var childrenIterator = iteratorFn.call(children);
9299
9300 if (childrenIterator) {
9301 var step = childrenIterator.next();
9302 var _i = 0;
9303
9304 for (; !step.done; step = childrenIterator.next()) {
9305 if (!validateSuspenseListNestedChild(step.value, _i)) {
9306 return;
9307 }
9308
9309 _i++;
9310 }
9311 }
9312 } else {
9313 warning$1(false, 'A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder);
9314 }
9315 }
9316 }
9317 }
9318}
9319
9320function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode) {
9321 var renderState = workInProgress.memoizedState;
9322
9323 if (renderState === null) {
9324 workInProgress.memoizedState = {
9325 isBackwards: isBackwards,
9326 rendering: null,
9327 last: lastContentRow,
9328 tail: tail,
9329 tailExpiration: 0,
9330 tailMode: tailMode
9331 };
9332 } else {
9333 // We can reuse the existing object from previous renders.
9334 renderState.isBackwards = isBackwards;
9335 renderState.rendering = null;
9336 renderState.last = lastContentRow;
9337 renderState.tail = tail;
9338 renderState.tailExpiration = 0;
9339 renderState.tailMode = tailMode;
9340 }
9341} // This can end up rendering this component multiple passes.
9342// The first pass splits the children fibers into two sets. A head and tail.
9343// We first render the head. If anything is in fallback state, we do another
9344// pass through beginWork to rerender all children (including the tail) with
9345// the force suspend context. If the first render didn't have anything in
9346// in fallback state. Then we render each row in the tail one-by-one.
9347// That happens in the completeWork phase without going back to beginWork.
9348
9349
9350function updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime) {
9351 var nextProps = workInProgress.pendingProps;
9352 var revealOrder = nextProps.revealOrder;
9353 var tailMode = nextProps.tail;
9354 var newChildren = nextProps.children;
9355 validateRevealOrder(revealOrder);
9356 validateTailOptions(tailMode, revealOrder);
9357 validateSuspenseListChildren(newChildren, revealOrder);
9358 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
9359 var suspenseContext = suspenseStackCursor.current;
9360 var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
9361
9362 if (shouldForceFallback) {
9363 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
9364 workInProgress.effectTag |= DidCapture;
9365 } else {
9366 var didSuspendBefore = current$$1 !== null && (current$$1.effectTag & DidCapture) !== NoEffect;
9367
9368 if (didSuspendBefore) {
9369 // If we previously forced a fallback, we need to schedule work
9370 // on any nested boundaries to let them know to try to render
9371 // again. This is the same as context updating.
9372 propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
9373 }
9374
9375 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
9376 }
9377
9378 pushSuspenseContext(workInProgress, suspenseContext);
9379
9380 if ((workInProgress.mode & BatchedMode) === NoMode) {
9381 // Outside of batched mode, SuspenseList doesn't work so we just
9382 // use make it a noop by treating it as the default revealOrder.
9383 workInProgress.memoizedState = null;
9384 } else {
9385 switch (revealOrder) {
9386 case 'forwards':
9387 {
9388 var lastContentRow = findLastContentRow(workInProgress.child);
9389 var tail;
9390
9391 if (lastContentRow === null) {
9392 // The whole list is part of the tail.
9393 // TODO: We could fast path by just rendering the tail now.
9394 tail = workInProgress.child;
9395 workInProgress.child = null;
9396 } else {
9397 // Disconnect the tail rows after the content row.
9398 // We're going to render them separately later.
9399 tail = lastContentRow.sibling;
9400 lastContentRow.sibling = null;
9401 }
9402
9403 initSuspenseListRenderState(workInProgress, false, // isBackwards
9404 tail, lastContentRow, tailMode);
9405 break;
9406 }
9407
9408 case 'backwards':
9409 {
9410 // We're going to find the first row that has existing content.
9411 // At the same time we're going to reverse the list of everything
9412 // we pass in the meantime. That's going to be our tail in reverse
9413 // order.
9414 var _tail = null;
9415 var row = workInProgress.child;
9416 workInProgress.child = null;
9417
9418 while (row !== null) {
9419 var currentRow = row.alternate; // New rows can't be content rows.
9420
9421 if (currentRow !== null && findFirstSuspended(currentRow) === null) {
9422 // This is the beginning of the main content.
9423 workInProgress.child = row;
9424 break;
9425 }
9426
9427 var nextRow = row.sibling;
9428 row.sibling = _tail;
9429 _tail = row;
9430 row = nextRow;
9431 } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
9432
9433
9434 initSuspenseListRenderState(workInProgress, true, // isBackwards
9435 _tail, null, // last
9436 tailMode);
9437 break;
9438 }
9439
9440 case 'together':
9441 {
9442 initSuspenseListRenderState(workInProgress, false, // isBackwards
9443 null, // tail
9444 null, // last
9445 undefined);
9446 break;
9447 }
9448
9449 default:
9450 {
9451 // The default reveal order is the same as not having
9452 // a boundary.
9453 workInProgress.memoizedState = null;
9454 }
9455 }
9456 }
9457
9458 return workInProgress.child;
9459}
9460
9461function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
9462 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
9463 var nextChildren = workInProgress.pendingProps;
9464
9465 if (current$$1 === null) {
9466 // Portals are special because we don't append the children during mount
9467 // but at commit. Therefore we need to track insertions which the normal
9468 // flow doesn't do during mount. This doesn't happen at the root because
9469 // the root always starts with a "current" with a null child.
9470 // TODO: Consider unifying this with how the root works.
9471 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
9472 } else {
9473 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9474 }
9475
9476 return workInProgress.child;
9477}
9478
9479function updateContextProvider(current$$1, workInProgress, renderExpirationTime) {
9480 var providerType = workInProgress.type;
9481 var context = providerType._context;
9482 var newProps = workInProgress.pendingProps;
9483 var oldProps = workInProgress.memoizedProps;
9484 var newValue = newProps.value;
9485
9486 {
9487 var providerPropTypes = workInProgress.type.propTypes;
9488
9489 if (providerPropTypes) {
9490 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
9491 }
9492 }
9493
9494 pushProvider(workInProgress, newValue);
9495
9496 if (oldProps !== null) {
9497 var oldValue = oldProps.value;
9498 var changedBits = calculateChangedBits(context, newValue, oldValue);
9499
9500 if (changedBits === 0) {
9501 // No change. Bailout early if children are the same.
9502 if (oldProps.children === newProps.children && !hasContextChanged()) {
9503 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9504 }
9505 } else {
9506 // The context value changed. Search for matching consumers and schedule
9507 // them to update.
9508 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
9509 }
9510 }
9511
9512 var newChildren = newProps.children;
9513 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
9514 return workInProgress.child;
9515}
9516
9517var hasWarnedAboutUsingContextAsConsumer = false;
9518
9519function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
9520 var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
9521 // DEV mode, we create a separate object for Context.Consumer that acts
9522 // like a proxy to Context. This proxy object adds unnecessary code in PROD
9523 // so we use the old behaviour (Context.Consumer references Context) to
9524 // reduce size and overhead. The separate object references context via
9525 // a property called "_context", which also gives us the ability to check
9526 // in DEV mode if this property exists or not and warn if it does not.
9527
9528 {
9529 if (context._context === undefined) {
9530 // This may be because it's a Context (rather than a Consumer).
9531 // Or it may be because it's older React where they're the same thing.
9532 // We only want to warn if we're sure it's a new React.
9533 if (context !== context.Consumer) {
9534 if (!hasWarnedAboutUsingContextAsConsumer) {
9535 hasWarnedAboutUsingContextAsConsumer = true;
9536 warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
9537 }
9538 }
9539 } else {
9540 context = context._context;
9541 }
9542 }
9543
9544 var newProps = workInProgress.pendingProps;
9545 var render = newProps.children;
9546
9547 {
9548 !(typeof render === 'function') ? warningWithoutStack$1(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0;
9549 }
9550
9551 prepareToReadContext(workInProgress, renderExpirationTime);
9552 var newValue = readContext(context, newProps.unstable_observedBits);
9553 var newChildren;
9554
9555 {
9556 ReactCurrentOwner$2.current = workInProgress;
9557 setCurrentPhase('render');
9558 newChildren = render(newValue);
9559 setCurrentPhase(null);
9560 } // React DevTools reads this flag.
9561
9562
9563 workInProgress.effectTag |= PerformedWork;
9564 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
9565 return workInProgress.child;
9566}
9567
9568function updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime) {
9569 var fundamentalImpl = workInProgress.type.impl;
9570
9571 if (fundamentalImpl.reconcileChildren === false) {
9572 return null;
9573 }
9574
9575 var nextProps = workInProgress.pendingProps;
9576 var nextChildren = nextProps.children;
9577 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9578 return workInProgress.child;
9579}
9580
9581function updateScopeComponent(current$$1, workInProgress, renderExpirationTime) {
9582 var nextProps = workInProgress.pendingProps;
9583 var nextChildren = nextProps.children;
9584 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9585 return workInProgress.child;
9586}
9587
9588function markWorkInProgressReceivedUpdate() {
9589 didReceiveUpdate = true;
9590}
9591
9592function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime) {
9593 cancelWorkTimer(workInProgress);
9594
9595 if (current$$1 !== null) {
9596 // Reuse previous dependencies
9597 workInProgress.dependencies = current$$1.dependencies;
9598 }
9599
9600 if (enableProfilerTimer) {
9601 // Don't update "base" render times for bailouts.
9602 stopProfilerTimerIfRunning(workInProgress);
9603 }
9604
9605 var updateExpirationTime = workInProgress.expirationTime;
9606
9607 if (updateExpirationTime !== NoWork) {
9608 markUnprocessedUpdateTime(updateExpirationTime);
9609 } // Check if the children have any pending work.
9610
9611
9612 var childExpirationTime = workInProgress.childExpirationTime;
9613
9614 if (childExpirationTime < renderExpirationTime) {
9615 // The children don't have any work either. We can skip them.
9616 // TODO: Once we add back resuming, we should check if the children are
9617 // a work-in-progress set. If so, we need to transfer their effects.
9618 return null;
9619 } else {
9620 // This fiber doesn't have work, but its subtree does. Clone the child
9621 // fibers and continue.
9622 cloneChildFibers(current$$1, workInProgress);
9623 return workInProgress.child;
9624 }
9625}
9626
9627function remountFiber(current$$1, oldWorkInProgress, newWorkInProgress) {
9628 {
9629 var returnFiber = oldWorkInProgress.return;
9630
9631 if (returnFiber === null) {
9632 throw new Error('Cannot swap the root fiber.');
9633 } // Disconnect from the old current.
9634 // It will get deleted.
9635
9636
9637 current$$1.alternate = null;
9638 oldWorkInProgress.alternate = null; // Connect to the new tree.
9639
9640 newWorkInProgress.index = oldWorkInProgress.index;
9641 newWorkInProgress.sibling = oldWorkInProgress.sibling;
9642 newWorkInProgress.return = oldWorkInProgress.return;
9643 newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
9644
9645 if (oldWorkInProgress === returnFiber.child) {
9646 returnFiber.child = newWorkInProgress;
9647 } else {
9648 var prevSibling = returnFiber.child;
9649
9650 if (prevSibling === null) {
9651 throw new Error('Expected parent to have a child.');
9652 }
9653
9654 while (prevSibling.sibling !== oldWorkInProgress) {
9655 prevSibling = prevSibling.sibling;
9656
9657 if (prevSibling === null) {
9658 throw new Error('Expected to find the previous sibling.');
9659 }
9660 }
9661
9662 prevSibling.sibling = newWorkInProgress;
9663 } // Delete the old fiber and place the new one.
9664 // Since the old fiber is disconnected, we have to schedule it manually.
9665
9666
9667 var last = returnFiber.lastEffect;
9668
9669 if (last !== null) {
9670 last.nextEffect = current$$1;
9671 returnFiber.lastEffect = current$$1;
9672 } else {
9673 returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
9674 }
9675
9676 current$$1.nextEffect = null;
9677 current$$1.effectTag = Deletion;
9678 newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber.
9679
9680 return newWorkInProgress;
9681 }
9682}
9683
9684function beginWork$1(current$$1, workInProgress, renderExpirationTime) {
9685 var updateExpirationTime = workInProgress.expirationTime;
9686
9687 {
9688 if (workInProgress._debugNeedsRemount && current$$1 !== null) {
9689 // This will restart the begin phase with a new fiber.
9690 return remountFiber(current$$1, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
9691 }
9692 }
9693
9694 if (current$$1 !== null) {
9695 var oldProps = current$$1.memoizedProps;
9696 var newProps = workInProgress.pendingProps;
9697
9698 if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload:
9699 workInProgress.type !== current$$1.type)) {
9700 // If props or context changed, mark the fiber as having performed work.
9701 // This may be unset if the props are determined to be equal later (memo).
9702 didReceiveUpdate = true;
9703 } else if (updateExpirationTime < renderExpirationTime) {
9704 didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
9705 // the begin phase. There's still some bookkeeping we that needs to be done
9706 // in this optimized path, mostly pushing stuff onto the stack.
9707
9708 switch (workInProgress.tag) {
9709 case HostRoot:
9710 pushHostRootContext(workInProgress);
9711 resetHydrationState();
9712 break;
9713
9714 case HostComponent:
9715 pushHostContext(workInProgress);
9716
9717 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
9718 if (enableSchedulerTracing) {
9719 markSpawnedWork(Never);
9720 } // Schedule this fiber to re-render at offscreen priority. Then bailout.
9721
9722
9723 workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
9724 return null;
9725 }
9726
9727 break;
9728
9729 case ClassComponent:
9730 {
9731 var Component = workInProgress.type;
9732
9733 if (isContextProvider(Component)) {
9734 pushContextProvider(workInProgress);
9735 }
9736
9737 break;
9738 }
9739
9740 case HostPortal:
9741 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
9742 break;
9743
9744 case ContextProvider:
9745 {
9746 var newValue = workInProgress.memoizedProps.value;
9747 pushProvider(workInProgress, newValue);
9748 break;
9749 }
9750
9751 case Profiler:
9752 if (enableProfilerTimer) {
9753 workInProgress.effectTag |= Update;
9754 }
9755
9756 break;
9757
9758 case SuspenseComponent:
9759 {
9760 var state = workInProgress.memoizedState;
9761
9762 if (state !== null) {
9763 if (enableSuspenseServerRenderer) {
9764 if (state.dehydrated !== null) {
9765 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // We know that this component will suspend again because if it has
9766 // been unsuspended it has committed as a resolved Suspense component.
9767 // If it needs to be retried, it should have work scheduled on it.
9768
9769 workInProgress.effectTag |= DidCapture;
9770 break;
9771 }
9772 } // If this boundary is currently timed out, we need to decide
9773 // whether to retry the primary children, or to skip over it and
9774 // go straight to the fallback. Check the priority of the primary
9775 // child fragment.
9776
9777
9778 var primaryChildFragment = workInProgress.child;
9779 var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
9780
9781 if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
9782 // The primary children have pending work. Use the normal path
9783 // to attempt to render the primary children again.
9784 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
9785 } else {
9786 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient
9787 // priority. Bailout.
9788
9789 var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9790
9791 if (child !== null) {
9792 // The fallback children have pending work. Skip over the
9793 // primary children and work on the fallback.
9794 return child.sibling;
9795 } else {
9796 return null;
9797 }
9798 }
9799 } else {
9800 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
9801 }
9802
9803 break;
9804 }
9805
9806 case SuspenseListComponent:
9807 {
9808 var didSuspendBefore = (current$$1.effectTag & DidCapture) !== NoEffect;
9809 var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
9810
9811 if (didSuspendBefore) {
9812 if (hasChildWork) {
9813 // If something was in fallback state last time, and we have all the
9814 // same children then we're still in progressive loading state.
9815 // Something might get unblocked by state updates or retries in the
9816 // tree which will affect the tail. So we need to use the normal
9817 // path to compute the correct tail.
9818 return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
9819 } // If none of the children had any work, that means that none of
9820 // them got retried so they'll still be blocked in the same way
9821 // as before. We can fast bail out.
9822
9823
9824 workInProgress.effectTag |= DidCapture;
9825 } // If nothing suspended before and we're rendering the same children,
9826 // then the tail doesn't matter. Anything new that suspends will work
9827 // in the "together" mode, so we can continue from the state we had.
9828
9829
9830 var renderState = workInProgress.memoizedState;
9831
9832 if (renderState !== null) {
9833 // Reset to the "together" mode in case we've started a different
9834 // update in the past but didn't complete it.
9835 renderState.rendering = null;
9836 renderState.tail = null;
9837 }
9838
9839 pushSuspenseContext(workInProgress, suspenseStackCursor.current);
9840
9841 if (hasChildWork) {
9842 break;
9843 } else {
9844 // If none of the children had any work, that means that none of
9845 // them got retried so they'll still be blocked in the same way
9846 // as before. We can fast bail out.
9847 return null;
9848 }
9849 }
9850 }
9851
9852 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9853 } else {
9854 // An update was scheduled on this fiber, but there are no new props
9855 // nor legacy context. Set this to false. If an update queue or context
9856 // consumer produces a changed value, it will set this to true. Otherwise,
9857 // the component will assume the children have not changed and bail out.
9858 didReceiveUpdate = false;
9859 }
9860 } else {
9861 didReceiveUpdate = false;
9862 } // Before entering the begin phase, clear the expiration time.
9863
9864
9865 workInProgress.expirationTime = NoWork;
9866
9867 switch (workInProgress.tag) {
9868 case IndeterminateComponent:
9869 {
9870 return mountIndeterminateComponent(current$$1, workInProgress, workInProgress.type, renderExpirationTime);
9871 }
9872
9873 case LazyComponent:
9874 {
9875 var elementType = workInProgress.elementType;
9876 return mountLazyComponent(current$$1, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
9877 }
9878
9879 case FunctionComponent:
9880 {
9881 var _Component = workInProgress.type;
9882 var unresolvedProps = workInProgress.pendingProps;
9883 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
9884 return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
9885 }
9886
9887 case ClassComponent:
9888 {
9889 var _Component2 = workInProgress.type;
9890 var _unresolvedProps = workInProgress.pendingProps;
9891
9892 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
9893
9894 return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
9895 }
9896
9897 case HostRoot:
9898 return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
9899
9900 case HostComponent:
9901 return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
9902
9903 case HostText:
9904 return updateHostText(current$$1, workInProgress);
9905
9906 case SuspenseComponent:
9907 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
9908
9909 case HostPortal:
9910 return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
9911
9912 case ForwardRef:
9913 {
9914 var type = workInProgress.type;
9915 var _unresolvedProps2 = workInProgress.pendingProps;
9916
9917 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
9918
9919 return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
9920 }
9921
9922 case Fragment:
9923 return updateFragment(current$$1, workInProgress, renderExpirationTime);
9924
9925 case Mode:
9926 return updateMode(current$$1, workInProgress, renderExpirationTime);
9927
9928 case Profiler:
9929 return updateProfiler(current$$1, workInProgress, renderExpirationTime);
9930
9931 case ContextProvider:
9932 return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
9933
9934 case ContextConsumer:
9935 return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
9936
9937 case MemoComponent:
9938 {
9939 var _type2 = workInProgress.type;
9940 var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
9941
9942 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
9943
9944 {
9945 if (workInProgress.type !== workInProgress.elementType) {
9946 var outerPropTypes = _type2.propTypes;
9947
9948 if (outerPropTypes) {
9949 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
9950 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
9951 }
9952 }
9953 }
9954
9955 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
9956 return updateMemoComponent(current$$1, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
9957 }
9958
9959 case SimpleMemoComponent:
9960 {
9961 return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
9962 }
9963
9964 case IncompleteClassComponent:
9965 {
9966 var _Component3 = workInProgress.type;
9967 var _unresolvedProps4 = workInProgress.pendingProps;
9968
9969 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
9970
9971 return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
9972 }
9973
9974 case SuspenseListComponent:
9975 {
9976 return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
9977 }
9978
9979 case FundamentalComponent:
9980 {
9981 if (enableFundamentalAPI) {
9982 return updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime);
9983 }
9984
9985 break;
9986 }
9987
9988 case ScopeComponent:
9989 {
9990 if (enableScopeAPI) {
9991 return updateScopeComponent(current$$1, workInProgress, renderExpirationTime);
9992 }
9993
9994 break;
9995 }
9996 }
9997
9998 (function () {
9999 {
10000 {
10001 throw ReactError(Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue."));
10002 }
10003 }
10004 })();
10005}
10006
10007function createFundamentalStateInstance(currentFiber, props, impl, state) {
10008 return {
10009 currentFiber: currentFiber,
10010 impl: impl,
10011 instance: null,
10012 prevProps: null,
10013 props: props,
10014 state: state
10015 };
10016}
10017
10018function isFiberSuspenseAndTimedOut(fiber) {
10019 return fiber.tag === SuspenseComponent && fiber.memoizedState !== null;
10020}
10021
10022function getSuspenseFallbackChild(fiber) {
10023 return fiber.child.sibling.child;
10024}
10025
10026function collectScopedNodes(node, fn, scopedNodes) {
10027 if (enableScopeAPI) {
10028 if (node.tag === HostComponent) {
10029 var _type = node.type,
10030 memoizedProps = node.memoizedProps;
10031
10032 if (fn(_type, memoizedProps) === true) {
10033 scopedNodes.push(getPublicInstance(node.stateNode));
10034 }
10035 }
10036
10037 var child = node.child;
10038
10039 if (isFiberSuspenseAndTimedOut(node)) {
10040 child = getSuspenseFallbackChild(node);
10041 }
10042
10043 if (child !== null) {
10044 collectScopedNodesFromChildren(child, fn, scopedNodes);
10045 }
10046 }
10047}
10048
10049function collectScopedNodesFromChildren(startingChild, fn, scopedNodes) {
10050 var child = startingChild;
10051
10052 while (child !== null) {
10053 collectScopedNodes(child, fn, scopedNodes);
10054 child = child.sibling;
10055 }
10056}
10057
10058function collectNearestScopeMethods(node, scope, childrenScopes) {
10059 if (isValidScopeNode(node, scope)) {
10060 childrenScopes.push(node.stateNode.methods);
10061 } else {
10062 var child = node.child;
10063
10064 if (isFiberSuspenseAndTimedOut(node)) {
10065 child = getSuspenseFallbackChild(node);
10066 }
10067
10068 if (child !== null) {
10069 collectNearestChildScopeMethods(child, scope, childrenScopes);
10070 }
10071 }
10072}
10073
10074function collectNearestChildScopeMethods(startingChild, scope, childrenScopes) {
10075 var child = startingChild;
10076
10077 while (child !== null) {
10078 collectNearestScopeMethods(child, scope, childrenScopes);
10079 child = child.sibling;
10080 }
10081}
10082
10083function isValidScopeNode(node, scope) {
10084 return node.tag === ScopeComponent && node.type === scope;
10085}
10086
10087function createScopeMethods(scope, instance) {
10088 var fn = scope.fn;
10089 return {
10090 getChildren: function () {
10091 var currentFiber = instance.fiber;
10092 var child = currentFiber.child;
10093 var childrenScopes = [];
10094
10095 if (child !== null) {
10096 collectNearestChildScopeMethods(child, scope, childrenScopes);
10097 }
10098
10099 return childrenScopes.length === 0 ? null : childrenScopes;
10100 },
10101 getChildrenFromRoot: function () {
10102 var currentFiber = instance.fiber;
10103 var node = currentFiber;
10104
10105 while (node !== null) {
10106 var parent = node.return;
10107
10108 if (parent === null) {
10109 break;
10110 }
10111
10112 node = parent;
10113
10114 if (node.tag === ScopeComponent && node.type === scope) {
10115 break;
10116 }
10117 }
10118
10119 var childrenScopes = [];
10120 collectNearestChildScopeMethods(node.child, scope, childrenScopes);
10121 return childrenScopes.length === 0 ? null : childrenScopes;
10122 },
10123 getParent: function () {
10124 var node = instance.fiber.return;
10125
10126 while (node !== null) {
10127 if (node.tag === ScopeComponent && node.type === scope) {
10128 return node.stateNode.methods;
10129 }
10130
10131 node = node.return;
10132 }
10133
10134 return null;
10135 },
10136 getProps: function () {
10137 var currentFiber = instance.fiber;
10138 return currentFiber.memoizedProps;
10139 },
10140 getScopedNodes: function () {
10141 var currentFiber = instance.fiber;
10142 var child = currentFiber.child;
10143 var scopedNodes = [];
10144
10145 if (child !== null) {
10146 collectScopedNodesFromChildren(child, fn, scopedNodes);
10147 }
10148
10149 return scopedNodes.length === 0 ? null : scopedNodes;
10150 }
10151 };
10152}
10153
10154function markUpdate(workInProgress) {
10155 // Tag the fiber with an update effect. This turns a Placement into
10156 // a PlacementAndUpdate.
10157 workInProgress.effectTag |= Update;
10158}
10159
10160function markRef$1(workInProgress) {
10161 workInProgress.effectTag |= Ref;
10162}
10163
10164var appendAllChildren;
10165var updateHostContainer;
10166var updateHostComponent$1;
10167var updateHostText$1;
10168
10169if (supportsMutation) {
10170 // Mutation mode
10171 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
10172 // We only have the top Fiber that was created but we need recurse down its
10173 // children to find all the terminal nodes.
10174 var node = workInProgress.child;
10175
10176 while (node !== null) {
10177 if (node.tag === HostComponent || node.tag === HostText) {
10178 appendInitialChild(parent, node.stateNode);
10179 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
10180 appendInitialChild(parent, node.stateNode.instance);
10181 } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
10182 // down its children. Instead, we'll get insertions from each child in
10183 // the portal directly.
10184 } else if (node.child !== null) {
10185 node.child.return = node;
10186 node = node.child;
10187 continue;
10188 }
10189
10190 if (node === workInProgress) {
10191 return;
10192 }
10193
10194 while (node.sibling === null) {
10195 if (node.return === null || node.return === workInProgress) {
10196 return;
10197 }
10198
10199 node = node.return;
10200 }
10201
10202 node.sibling.return = node.return;
10203 node = node.sibling;
10204 }
10205 };
10206
10207 updateHostContainer = function (workInProgress) {// Noop
10208 };
10209
10210 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
10211 // If we have an alternate, that means this is an update and we need to
10212 // schedule a side-effect to do the updates.
10213 var oldProps = current.memoizedProps;
10214
10215 if (oldProps === newProps) {
10216 // In mutation mode, this is sufficient for a bailout because
10217 // we won't touch this node even if children changed.
10218 return;
10219 } // If we get updated because one of our children updated, we don't
10220 // have newProps so we'll have to reuse them.
10221 // TODO: Split the update API as separate for the props vs. children.
10222 // Even better would be if children weren't special cased at all tho.
10223
10224
10225 var instance = workInProgress.stateNode;
10226 var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host
10227 // component is hitting the resume path. Figure out why. Possibly
10228 // related to `hidden`.
10229
10230 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component.
10231
10232 workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
10233 // is a new ref we mark this as an update. All the work is done in commitWork.
10234
10235 if (updatePayload) {
10236 markUpdate(workInProgress);
10237 }
10238 };
10239
10240 updateHostText$1 = function (current, workInProgress, oldText, newText) {
10241 // If the text differs, mark it as an update. All the work in done in commitWork.
10242 if (oldText !== newText) {
10243 markUpdate(workInProgress);
10244 }
10245 };
10246} else if (supportsPersistence) {
10247 // Persistent host tree mode
10248 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
10249 // We only have the top Fiber that was created but we need recurse down its
10250 // children to find all the terminal nodes.
10251 var node = workInProgress.child;
10252
10253 while (node !== null) {
10254 // eslint-disable-next-line no-labels
10255 branches: if (node.tag === HostComponent) {
10256 var instance = node.stateNode;
10257
10258 if (needsVisibilityToggle && isHidden) {
10259 // This child is inside a timed out tree. Hide it.
10260 var props = node.memoizedProps;
10261 var type = node.type;
10262 instance = cloneHiddenInstance(instance, type, props, node);
10263 }
10264
10265 appendInitialChild(parent, instance);
10266 } else if (node.tag === HostText) {
10267 var _instance = node.stateNode;
10268
10269 if (needsVisibilityToggle && isHidden) {
10270 // This child is inside a timed out tree. Hide it.
10271 var text = node.memoizedProps;
10272 _instance = cloneHiddenTextInstance(_instance, text, node);
10273 }
10274
10275 appendInitialChild(parent, _instance);
10276 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
10277 var _instance2 = node.stateNode.instance;
10278
10279 if (needsVisibilityToggle && isHidden) {
10280 // This child is inside a timed out tree. Hide it.
10281 var _props = node.memoizedProps;
10282 var _type = node.type;
10283 _instance2 = cloneHiddenInstance(_instance2, _type, _props, node);
10284 }
10285
10286 appendInitialChild(parent, _instance2);
10287 } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
10288 // down its children. Instead, we'll get insertions from each child in
10289 // the portal directly.
10290 } else if (node.tag === SuspenseComponent) {
10291 if ((node.effectTag & Update) !== NoEffect) {
10292 // Need to toggle the visibility of the primary children.
10293 var newIsHidden = node.memoizedState !== null;
10294
10295 if (newIsHidden) {
10296 var primaryChildParent = node.child;
10297
10298 if (primaryChildParent !== null) {
10299 if (primaryChildParent.child !== null) {
10300 primaryChildParent.child.return = primaryChildParent;
10301 appendAllChildren(parent, primaryChildParent, true, newIsHidden);
10302 }
10303
10304 var fallbackChildParent = primaryChildParent.sibling;
10305
10306 if (fallbackChildParent !== null) {
10307 fallbackChildParent.return = node;
10308 node = fallbackChildParent;
10309 continue;
10310 }
10311 }
10312 }
10313 }
10314
10315 if (node.child !== null) {
10316 // Continue traversing like normal
10317 node.child.return = node;
10318 node = node.child;
10319 continue;
10320 }
10321 } else if (node.child !== null) {
10322 node.child.return = node;
10323 node = node.child;
10324 continue;
10325 } // $FlowFixMe This is correct but Flow is confused by the labeled break.
10326
10327
10328 node = node;
10329
10330 if (node === workInProgress) {
10331 return;
10332 }
10333
10334 while (node.sibling === null) {
10335 if (node.return === null || node.return === workInProgress) {
10336 return;
10337 }
10338
10339 node = node.return;
10340 }
10341
10342 node.sibling.return = node.return;
10343 node = node.sibling;
10344 }
10345 }; // An unfortunate fork of appendAllChildren because we have two different parent types.
10346
10347
10348 var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
10349 // We only have the top Fiber that was created but we need recurse down its
10350 // children to find all the terminal nodes.
10351 var node = workInProgress.child;
10352
10353 while (node !== null) {
10354 // eslint-disable-next-line no-labels
10355 branches: if (node.tag === HostComponent) {
10356 var instance = node.stateNode;
10357
10358 if (needsVisibilityToggle && isHidden) {
10359 // This child is inside a timed out tree. Hide it.
10360 var props = node.memoizedProps;
10361 var type = node.type;
10362 instance = cloneHiddenInstance(instance, type, props, node);
10363 }
10364
10365 appendChildToContainerChildSet(containerChildSet, instance);
10366 } else if (node.tag === HostText) {
10367 var _instance3 = node.stateNode;
10368
10369 if (needsVisibilityToggle && isHidden) {
10370 // This child is inside a timed out tree. Hide it.
10371 var text = node.memoizedProps;
10372 _instance3 = cloneHiddenTextInstance(_instance3, text, node);
10373 }
10374
10375 appendChildToContainerChildSet(containerChildSet, _instance3);
10376 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
10377 var _instance4 = node.stateNode.instance;
10378
10379 if (needsVisibilityToggle && isHidden) {
10380 // This child is inside a timed out tree. Hide it.
10381 var _props2 = node.memoizedProps;
10382 var _type2 = node.type;
10383 _instance4 = cloneHiddenInstance(_instance4, _type2, _props2, node);
10384 }
10385
10386 appendChildToContainerChildSet(containerChildSet, _instance4);
10387 } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
10388 // down its children. Instead, we'll get insertions from each child in
10389 // the portal directly.
10390 } else if (node.tag === SuspenseComponent) {
10391 if ((node.effectTag & Update) !== NoEffect) {
10392 // Need to toggle the visibility of the primary children.
10393 var newIsHidden = node.memoizedState !== null;
10394
10395 if (newIsHidden) {
10396 var primaryChildParent = node.child;
10397
10398 if (primaryChildParent !== null) {
10399 if (primaryChildParent.child !== null) {
10400 primaryChildParent.child.return = primaryChildParent;
10401 appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
10402 }
10403
10404 var fallbackChildParent = primaryChildParent.sibling;
10405
10406 if (fallbackChildParent !== null) {
10407 fallbackChildParent.return = node;
10408 node = fallbackChildParent;
10409 continue;
10410 }
10411 }
10412 }
10413 }
10414
10415 if (node.child !== null) {
10416 // Continue traversing like normal
10417 node.child.return = node;
10418 node = node.child;
10419 continue;
10420 }
10421 } else if (node.child !== null) {
10422 node.child.return = node;
10423 node = node.child;
10424 continue;
10425 } // $FlowFixMe This is correct but Flow is confused by the labeled break.
10426
10427
10428 node = node;
10429
10430 if (node === workInProgress) {
10431 return;
10432 }
10433
10434 while (node.sibling === null) {
10435 if (node.return === null || node.return === workInProgress) {
10436 return;
10437 }
10438
10439 node = node.return;
10440 }
10441
10442 node.sibling.return = node.return;
10443 node = node.sibling;
10444 }
10445 };
10446
10447 updateHostContainer = function (workInProgress) {
10448 var portalOrRoot = workInProgress.stateNode;
10449 var childrenUnchanged = workInProgress.firstEffect === null;
10450
10451 if (childrenUnchanged) {// No changes, just reuse the existing instance.
10452 } else {
10453 var container = portalOrRoot.containerInfo;
10454 var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set.
10455
10456 appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
10457 portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container.
10458
10459 markUpdate(workInProgress);
10460 finalizeContainerChildren(container, newChildSet);
10461 }
10462 };
10463
10464 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
10465 var currentInstance = current.stateNode;
10466 var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates.
10467 // This guarantees that we can reuse all of them.
10468
10469 var childrenUnchanged = workInProgress.firstEffect === null;
10470
10471 if (childrenUnchanged && oldProps === newProps) {
10472 // No changes, just reuse the existing instance.
10473 // Note that this might release a previous clone.
10474 workInProgress.stateNode = currentInstance;
10475 return;
10476 }
10477
10478 var recyclableInstance = workInProgress.stateNode;
10479 var currentHostContext = getHostContext();
10480 var updatePayload = null;
10481
10482 if (oldProps !== newProps) {
10483 updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
10484 }
10485
10486 if (childrenUnchanged && updatePayload === null) {
10487 // No changes, just reuse the existing instance.
10488 // Note that this might release a previous clone.
10489 workInProgress.stateNode = currentInstance;
10490 return;
10491 }
10492
10493 var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
10494
10495 if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
10496 markUpdate(workInProgress);
10497 }
10498
10499 workInProgress.stateNode = newInstance;
10500
10501 if (childrenUnchanged) {
10502 // If there are no other effects in this tree, we need to flag this node as having one.
10503 // Even though we're not going to use it for anything.
10504 // Otherwise parents won't know that there are new children to propagate upwards.
10505 markUpdate(workInProgress);
10506 } else {
10507 // If children might have changed, we have to add them all to the set.
10508 appendAllChildren(newInstance, workInProgress, false, false);
10509 }
10510 };
10511
10512 updateHostText$1 = function (current, workInProgress, oldText, newText) {
10513 if (oldText !== newText) {
10514 // If the text content differs, we'll create a new text instance for it.
10515 var rootContainerInstance = getRootHostContainer();
10516 var currentHostContext = getHostContext();
10517 workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress); // We'll have to mark it as having an effect, even though we won't use the effect for anything.
10518 // This lets the parents know that at least one of their children has changed.
10519
10520 markUpdate(workInProgress);
10521 }
10522 };
10523} else {
10524 // No host operations
10525 updateHostContainer = function (workInProgress) {// Noop
10526 };
10527
10528 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {// Noop
10529 };
10530
10531 updateHostText$1 = function (current, workInProgress, oldText, newText) {// Noop
10532 };
10533}
10534
10535function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
10536 switch (renderState.tailMode) {
10537 case 'hidden':
10538 {
10539 // Any insertions at the end of the tail list after this point
10540 // should be invisible. If there are already mounted boundaries
10541 // anything before them are not considered for collapsing.
10542 // Therefore we need to go through the whole tail to find if
10543 // there are any.
10544 var tailNode = renderState.tail;
10545 var lastTailNode = null;
10546
10547 while (tailNode !== null) {
10548 if (tailNode.alternate !== null) {
10549 lastTailNode = tailNode;
10550 }
10551
10552 tailNode = tailNode.sibling;
10553 } // Next we're simply going to delete all insertions after the
10554 // last rendered item.
10555
10556
10557 if (lastTailNode === null) {
10558 // All remaining items in the tail are insertions.
10559 renderState.tail = null;
10560 } else {
10561 // Detach the insertion after the last node that was already
10562 // inserted.
10563 lastTailNode.sibling = null;
10564 }
10565
10566 break;
10567 }
10568
10569 case 'collapsed':
10570 {
10571 // Any insertions at the end of the tail list after this point
10572 // should be invisible. If there are already mounted boundaries
10573 // anything before them are not considered for collapsing.
10574 // Therefore we need to go through the whole tail to find if
10575 // there are any.
10576 var _tailNode = renderState.tail;
10577 var _lastTailNode = null;
10578
10579 while (_tailNode !== null) {
10580 if (_tailNode.alternate !== null) {
10581 _lastTailNode = _tailNode;
10582 }
10583
10584 _tailNode = _tailNode.sibling;
10585 } // Next we're simply going to delete all insertions after the
10586 // last rendered item.
10587
10588
10589 if (_lastTailNode === null) {
10590 // All remaining items in the tail are insertions.
10591 if (!hasRenderedATailFallback && renderState.tail !== null) {
10592 // We suspended during the head. We want to show at least one
10593 // row at the tail. So we'll keep on and cut off the rest.
10594 renderState.tail.sibling = null;
10595 } else {
10596 renderState.tail = null;
10597 }
10598 } else {
10599 // Detach the insertion after the last node that was already
10600 // inserted.
10601 _lastTailNode.sibling = null;
10602 }
10603
10604 break;
10605 }
10606 }
10607}
10608
10609function completeWork(current, workInProgress, renderExpirationTime) {
10610 var newProps = workInProgress.pendingProps;
10611
10612 switch (workInProgress.tag) {
10613 case IndeterminateComponent:
10614 break;
10615
10616 case LazyComponent:
10617 break;
10618
10619 case SimpleMemoComponent:
10620 case FunctionComponent:
10621 break;
10622
10623 case ClassComponent:
10624 {
10625 var Component = workInProgress.type;
10626
10627 if (isContextProvider(Component)) {
10628 popContext(workInProgress);
10629 }
10630
10631 break;
10632 }
10633
10634 case HostRoot:
10635 {
10636 popHostContainer(workInProgress);
10637 popTopLevelContextObject(workInProgress);
10638 var fiberRoot = workInProgress.stateNode;
10639
10640 if (fiberRoot.pendingContext) {
10641 fiberRoot.context = fiberRoot.pendingContext;
10642 fiberRoot.pendingContext = null;
10643 }
10644
10645 if (current === null || current.child === null) {
10646 // If we hydrated, pop so that we can delete any remaining children
10647 // that weren't hydrated.
10648 var wasHydrated = popHydrationState(workInProgress);
10649
10650 if (wasHydrated) {
10651 // If we hydrated, then we'll need to schedule an update for
10652 // the commit side-effects on the root.
10653 markUpdate(workInProgress);
10654 }
10655 }
10656
10657 updateHostContainer(workInProgress);
10658 break;
10659 }
10660
10661 case HostComponent:
10662 {
10663 popHostContext(workInProgress);
10664 var rootContainerInstance = getRootHostContainer();
10665 var type = workInProgress.type;
10666
10667 if (current !== null && workInProgress.stateNode != null) {
10668 updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
10669
10670 if (enableFlareAPI) {
10671 var prevListeners = current.memoizedProps.listeners;
10672 var nextListeners = newProps.listeners;
10673
10674 if (prevListeners !== nextListeners) {
10675 markUpdate(workInProgress);
10676 }
10677 }
10678
10679 if (current.ref !== workInProgress.ref) {
10680 markRef$1(workInProgress);
10681 }
10682 } else {
10683 if (!newProps) {
10684 (function () {
10685 if (!(workInProgress.stateNode !== null)) {
10686 {
10687 throw ReactError(Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."));
10688 }
10689 }
10690 })(); // This can happen when we abort work.
10691
10692
10693 break;
10694 }
10695
10696 var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
10697 // "stack" as the parent. Then append children as we go in beginWork
10698 // or completeWork depending on we want to add then top->down or
10699 // bottom->up. Top->down is faster in IE11.
10700
10701 var _wasHydrated = popHydrationState(workInProgress);
10702
10703 if (_wasHydrated) {
10704 // TODO: Move this and createInstance step into the beginPhase
10705 // to consolidate.
10706 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
10707 // If changes to the hydrated node needs to be applied at the
10708 // commit-phase we mark this as such.
10709 markUpdate(workInProgress);
10710 }
10711
10712 if (enableFlareAPI) {
10713 var listeners = newProps.listeners;
10714
10715 if (listeners != null) {
10716 updateEventListeners(listeners, workInProgress, rootContainerInstance);
10717 }
10718 }
10719 } else {
10720 var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
10721 appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners
10722
10723 workInProgress.stateNode = instance;
10724
10725 if (enableFlareAPI) {
10726 var _listeners = newProps.listeners;
10727
10728 if (_listeners != null) {
10729 updateEventListeners(_listeners, workInProgress, rootContainerInstance);
10730 }
10731 } // Certain renderers require commit-time effects for initial mount.
10732 // (eg DOM renderer supports auto-focus for certain elements).
10733 // Make sure such renderers get scheduled for later work.
10734
10735
10736 if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance, currentHostContext)) {
10737 markUpdate(workInProgress);
10738 }
10739 }
10740
10741 if (workInProgress.ref !== null) {
10742 // If there is a ref on a host node we need to schedule a callback
10743 markRef$1(workInProgress);
10744 }
10745 }
10746
10747 break;
10748 }
10749
10750 case HostText:
10751 {
10752 var newText = newProps;
10753
10754 if (current && workInProgress.stateNode != null) {
10755 var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
10756 // to schedule a side-effect to do the updates.
10757
10758 updateHostText$1(current, workInProgress, oldText, newText);
10759 } else {
10760 if (typeof newText !== 'string') {
10761 (function () {
10762 if (!(workInProgress.stateNode !== null)) {
10763 {
10764 throw ReactError(Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue."));
10765 }
10766 }
10767 })(); // This can happen when we abort work.
10768
10769 }
10770
10771 var _rootContainerInstance = getRootHostContainer();
10772
10773 var _currentHostContext = getHostContext();
10774
10775 var _wasHydrated2 = popHydrationState(workInProgress);
10776
10777 if (_wasHydrated2) {
10778 if (prepareToHydrateHostTextInstance(workInProgress)) {
10779 markUpdate(workInProgress);
10780 }
10781 } else {
10782 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
10783 }
10784 }
10785
10786 break;
10787 }
10788
10789 case ForwardRef:
10790 break;
10791
10792 case SuspenseComponent:
10793 {
10794 popSuspenseContext(workInProgress);
10795 var nextState = workInProgress.memoizedState;
10796
10797 if (enableSuspenseServerRenderer) {
10798 if (nextState !== null && nextState.dehydrated !== null) {
10799 if (current === null) {
10800 var _wasHydrated3 = popHydrationState(workInProgress);
10801
10802 (function () {
10803 if (!_wasHydrated3) {
10804 {
10805 throw ReactError(Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React."));
10806 }
10807 }
10808 })();
10809
10810 prepareToHydrateHostSuspenseInstance(workInProgress);
10811
10812 if (enableSchedulerTracing) {
10813 markSpawnedWork(Never);
10814 }
10815
10816 return null;
10817 } else {
10818 // We should never have been in a hydration state if we didn't have a current.
10819 // However, in some of those paths, we might have reentered a hydration state
10820 // and then we might be inside a hydration state. In that case, we'll need to
10821 // exit out of it.
10822 resetHydrationState();
10823
10824 if ((workInProgress.effectTag & DidCapture) === NoEffect) {
10825 // This boundary did not suspend so it's now hydrated and unsuspended.
10826 workInProgress.memoizedState = null;
10827 } // If nothing suspended, we need to schedule an effect to mark this boundary
10828 // as having hydrated so events know that they're free be invoked.
10829 // It's also a signal to replay events and the suspense callback.
10830 // If something suspended, schedule an effect to attach retry listeners.
10831 // So we might as well always mark this.
10832
10833
10834 workInProgress.effectTag |= Update;
10835 return null;
10836 }
10837 }
10838 }
10839
10840 if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
10841 // Something suspended. Re-render with the fallback children.
10842 workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list.
10843
10844 return workInProgress;
10845 }
10846
10847 var nextDidTimeout = nextState !== null;
10848 var prevDidTimeout = false;
10849
10850 if (current === null) {
10851 // In cases where we didn't find a suitable hydration boundary we never
10852 // put this in dehydrated mode, but we still need to pop the hydration
10853 // state since we might be inside the insertion tree.
10854 popHydrationState(workInProgress);
10855 } else {
10856 var prevState = current.memoizedState;
10857 prevDidTimeout = prevState !== null;
10858
10859 if (!nextDidTimeout && prevState !== null) {
10860 // We just switched from the fallback to the normal children.
10861 // Delete the fallback.
10862 // TODO: Would it be better to store the fallback fragment on
10863 // the stateNode during the begin phase?
10864 var currentFallbackChild = current.child.sibling;
10865
10866 if (currentFallbackChild !== null) {
10867 // Deletions go at the beginning of the return fiber's effect list
10868 var first = workInProgress.firstEffect;
10869
10870 if (first !== null) {
10871 workInProgress.firstEffect = currentFallbackChild;
10872 currentFallbackChild.nextEffect = first;
10873 } else {
10874 workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
10875 currentFallbackChild.nextEffect = null;
10876 }
10877
10878 currentFallbackChild.effectTag = Deletion;
10879 }
10880 }
10881 }
10882
10883 if (nextDidTimeout && !prevDidTimeout) {
10884 // If this subtreee is running in batched mode we can suspend,
10885 // otherwise we won't suspend.
10886 // TODO: This will still suspend a synchronous tree if anything
10887 // in the concurrent tree already suspended during this render.
10888 // This is a known bug.
10889 if ((workInProgress.mode & BatchedMode) !== NoMode) {
10890 // TODO: Move this back to throwException because this is too late
10891 // if this is a large tree which is common for initial loads. We
10892 // don't know if we should restart a render or not until we get
10893 // this marker, and this is too late.
10894 // If this render already had a ping or lower pri updates,
10895 // and this is the first time we know we're going to suspend we
10896 // should be able to immediately restart from within throwException.
10897 var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
10898
10899 if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
10900 // If this was in an invisible tree or a new render, then showing
10901 // this boundary is ok.
10902 renderDidSuspend();
10903 } else {
10904 // Otherwise, we're going to have to hide content so we should
10905 // suspend for longer if possible.
10906 renderDidSuspendDelayIfPossible();
10907 }
10908 }
10909 }
10910
10911 if (supportsPersistence) {
10912 // TODO: Only schedule updates if not prevDidTimeout.
10913 if (nextDidTimeout) {
10914 // If this boundary just timed out, schedule an effect to attach a
10915 // retry listener to the proimse. This flag is also used to hide the
10916 // primary children.
10917 workInProgress.effectTag |= Update;
10918 }
10919 }
10920
10921 if (supportsMutation) {
10922 // TODO: Only schedule updates if these values are non equal, i.e. it changed.
10923 if (nextDidTimeout || prevDidTimeout) {
10924 // If this boundary just timed out, schedule an effect to attach a
10925 // retry listener to the proimse. This flag is also used to hide the
10926 // primary children. In mutation mode, we also need the flag to
10927 // *unhide* children that were previously hidden, so check if the
10928 // is currently timed out, too.
10929 workInProgress.effectTag |= Update;
10930 }
10931 }
10932
10933 if (enableSuspenseCallback && workInProgress.updateQueue !== null && workInProgress.memoizedProps.suspenseCallback != null) {
10934 // Always notify the callback
10935 workInProgress.effectTag |= Update;
10936 }
10937
10938 break;
10939 }
10940
10941 case Fragment:
10942 break;
10943
10944 case Mode:
10945 break;
10946
10947 case Profiler:
10948 break;
10949
10950 case HostPortal:
10951 popHostContainer(workInProgress);
10952 updateHostContainer(workInProgress);
10953 break;
10954
10955 case ContextProvider:
10956 // Pop provider fiber
10957 popProvider(workInProgress);
10958 break;
10959
10960 case ContextConsumer:
10961 break;
10962
10963 case MemoComponent:
10964 break;
10965
10966 case IncompleteClassComponent:
10967 {
10968 // Same as class component case. I put it down here so that the tags are
10969 // sequential to ensure this switch is compiled to a jump table.
10970 var _Component = workInProgress.type;
10971
10972 if (isContextProvider(_Component)) {
10973 popContext(workInProgress);
10974 }
10975
10976 break;
10977 }
10978
10979 case SuspenseListComponent:
10980 {
10981 popSuspenseContext(workInProgress);
10982 var renderState = workInProgress.memoizedState;
10983
10984 if (renderState === null) {
10985 // We're running in the default, "independent" mode. We don't do anything
10986 // in this mode.
10987 break;
10988 }
10989
10990 var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
10991 var renderedTail = renderState.rendering;
10992
10993 if (renderedTail === null) {
10994 // We just rendered the head.
10995 if (!didSuspendAlready) {
10996 // This is the first pass. We need to figure out if anything is still
10997 // suspended in the rendered set.
10998 // If new content unsuspended, but there's still some content that
10999 // didn't. Then we need to do a second pass that forces everything
11000 // to keep showing their fallbacks.
11001 // We might be suspended if something in this render pass suspended, or
11002 // something in the previous committed pass suspended. Otherwise,
11003 // there's no chance so we can skip the expensive call to
11004 // findFirstSuspended.
11005 var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
11006
11007 if (!cannotBeSuspended) {
11008 var row = workInProgress.child;
11009
11010 while (row !== null) {
11011 var suspended = findFirstSuspended(row);
11012
11013 if (suspended !== null) {
11014 didSuspendAlready = true;
11015 workInProgress.effectTag |= DidCapture;
11016 cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
11017 // part of the second pass. In that case nothing will subscribe to
11018 // its thennables. Instead, we'll transfer its thennables to the
11019 // SuspenseList so that it can retry if they resolve.
11020 // There might be multiple of these in the list but since we're
11021 // going to wait for all of them anyway, it doesn't really matter
11022 // which ones gets to ping. In theory we could get clever and keep
11023 // track of how many dependencies remain but it gets tricky because
11024 // in the meantime, we can add/remove/change items and dependencies.
11025 // We might bail out of the loop before finding any but that
11026 // doesn't matter since that means that the other boundaries that
11027 // we did find already has their listeners attached.
11028
11029 var newThennables = suspended.updateQueue;
11030
11031 if (newThennables !== null) {
11032 workInProgress.updateQueue = newThennables;
11033 workInProgress.effectTag |= Update;
11034 } // Rerender the whole list, but this time, we'll force fallbacks
11035 // to stay in place.
11036 // Reset the effect list before doing the second pass since that's now invalid.
11037
11038
11039 workInProgress.firstEffect = workInProgress.lastEffect = null; // Reset the child fibers to their original state.
11040
11041 resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately
11042 // rerender the children.
11043
11044 pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
11045 return workInProgress.child;
11046 }
11047
11048 row = row.sibling;
11049 }
11050 }
11051 } else {
11052 cutOffTailIfNeeded(renderState, false);
11053 } // Next we're going to render the tail.
11054
11055 } else {
11056 // Append the rendered row to the child list.
11057 if (!didSuspendAlready) {
11058 var _suspended = findFirstSuspended(renderedTail);
11059
11060 if (_suspended !== null) {
11061 workInProgress.effectTag |= DidCapture;
11062 didSuspendAlready = true;
11063 cutOffTailIfNeeded(renderState, true); // This might have been modified.
11064
11065 if (renderState.tail === null && renderState.tailMode === 'hidden') {
11066 // We need to delete the row we just rendered.
11067 // Ensure we transfer the update queue to the parent.
11068 var _newThennables = _suspended.updateQueue;
11069
11070 if (_newThennables !== null) {
11071 workInProgress.updateQueue = _newThennables;
11072 workInProgress.effectTag |= Update;
11073 } // Reset the effect list to what it w as before we rendered this
11074 // child. The nested children have already appended themselves.
11075
11076
11077 var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point.
11078
11079 if (lastEffect !== null) {
11080 lastEffect.nextEffect = null;
11081 } // We're done.
11082
11083
11084 return null;
11085 }
11086 } else if (now$1() > renderState.tailExpiration && renderExpirationTime > Never) {
11087 // We have now passed our CPU deadline and we'll just give up further
11088 // attempts to render the main content and only render fallbacks.
11089 // The assumption is that this is usually faster.
11090 workInProgress.effectTag |= DidCapture;
11091 didSuspendAlready = true;
11092 cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
11093 // to get it started back up to attempt the next item. If we can show
11094 // them, then they really have the same priority as this render.
11095 // So we'll pick it back up the very next render pass once we've had
11096 // an opportunity to yield for paint.
11097
11098 var nextPriority = renderExpirationTime - 1;
11099 workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
11100
11101 if (enableSchedulerTracing) {
11102 markSpawnedWork(nextPriority);
11103 }
11104 }
11105 }
11106
11107 if (renderState.isBackwards) {
11108 // The effect list of the backwards tail will have been added
11109 // to the end. This breaks the guarantee that life-cycles fire in
11110 // sibling order but that isn't a strong guarantee promised by React.
11111 // Especially since these might also just pop in during future commits.
11112 // Append to the beginning of the list.
11113 renderedTail.sibling = workInProgress.child;
11114 workInProgress.child = renderedTail;
11115 } else {
11116 var previousSibling = renderState.last;
11117
11118 if (previousSibling !== null) {
11119 previousSibling.sibling = renderedTail;
11120 } else {
11121 workInProgress.child = renderedTail;
11122 }
11123
11124 renderState.last = renderedTail;
11125 }
11126 }
11127
11128 if (renderState.tail !== null) {
11129 // We still have tail rows to render.
11130 if (renderState.tailExpiration === 0) {
11131 // Heuristic for how long we're willing to spend rendering rows
11132 // until we just give up and show what we have so far.
11133 var TAIL_EXPIRATION_TIMEOUT_MS = 500;
11134 renderState.tailExpiration = now$1() + TAIL_EXPIRATION_TIMEOUT_MS;
11135 } // Pop a row.
11136
11137
11138 var next = renderState.tail;
11139 renderState.rendering = next;
11140 renderState.tail = next.sibling;
11141 renderState.lastEffect = workInProgress.lastEffect;
11142 next.sibling = null; // Restore the context.
11143 // TODO: We can probably just avoid popping it instead and only
11144 // setting it the first time we go from not suspended to suspended.
11145
11146 var suspenseContext = suspenseStackCursor.current;
11147
11148 if (didSuspendAlready) {
11149 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
11150 } else {
11151 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
11152 }
11153
11154 pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
11155
11156 return next;
11157 }
11158
11159 break;
11160 }
11161
11162 case FundamentalComponent:
11163 {
11164 if (enableFundamentalAPI) {
11165 var fundamentalImpl = workInProgress.type.impl;
11166 var fundamentalInstance = workInProgress.stateNode;
11167
11168 if (fundamentalInstance === null) {
11169 var getInitialState = fundamentalImpl.getInitialState;
11170 var fundamentalState;
11171
11172 if (getInitialState !== undefined) {
11173 fundamentalState = getInitialState(newProps);
11174 }
11175
11176 fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance(workInProgress, newProps, fundamentalImpl, fundamentalState || {});
11177
11178 var _instance5 = getFundamentalComponentInstance(fundamentalInstance);
11179
11180 fundamentalInstance.instance = _instance5;
11181
11182 if (fundamentalImpl.reconcileChildren === false) {
11183 return null;
11184 }
11185
11186 appendAllChildren(_instance5, workInProgress, false, false);
11187 mountFundamentalComponent(fundamentalInstance);
11188 } else {
11189 // We fire update in commit phase
11190 var prevProps = fundamentalInstance.props;
11191 fundamentalInstance.prevProps = prevProps;
11192 fundamentalInstance.props = newProps;
11193 fundamentalInstance.currentFiber = workInProgress;
11194
11195 if (supportsPersistence) {
11196 var _instance6 = cloneFundamentalInstance(fundamentalInstance);
11197
11198 fundamentalInstance.instance = _instance6;
11199 appendAllChildren(_instance6, workInProgress, false, false);
11200 }
11201
11202 var shouldUpdate = shouldUpdateFundamentalComponent(fundamentalInstance);
11203
11204 if (shouldUpdate) {
11205 markUpdate(workInProgress);
11206 }
11207 }
11208 }
11209
11210 break;
11211 }
11212
11213 case ScopeComponent:
11214 {
11215 if (enableScopeAPI) {
11216 if (current === null) {
11217 var _type3 = workInProgress.type;
11218 var scopeInstance = {
11219 fiber: workInProgress,
11220 methods: null
11221 };
11222 workInProgress.stateNode = scopeInstance;
11223 scopeInstance.methods = createScopeMethods(_type3, scopeInstance);
11224
11225 if (enableFlareAPI) {
11226 var _listeners2 = newProps.listeners;
11227
11228 if (_listeners2 != null) {
11229 var _rootContainerInstance2 = getRootHostContainer();
11230
11231 updateEventListeners(_listeners2, workInProgress, _rootContainerInstance2);
11232 }
11233 }
11234
11235 if (workInProgress.ref !== null) {
11236 markRef$1(workInProgress);
11237 markUpdate(workInProgress);
11238 }
11239 } else {
11240 if (enableFlareAPI) {
11241 var _prevListeners = current.memoizedProps.listeners;
11242 var _nextListeners = newProps.listeners;
11243
11244 if (_prevListeners !== _nextListeners || workInProgress.ref !== null) {
11245 markUpdate(workInProgress);
11246 }
11247 } else {
11248 if (workInProgress.ref !== null) {
11249 markUpdate(workInProgress);
11250 }
11251 }
11252
11253 if (current.ref !== workInProgress.ref) {
11254 markRef$1(workInProgress);
11255 }
11256 }
11257 }
11258
11259 break;
11260 }
11261
11262 default:
11263 (function () {
11264 {
11265 {
11266 throw ReactError(Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue."));
11267 }
11268 }
11269 })();
11270
11271 }
11272
11273 return null;
11274}
11275
11276function unwindWork(workInProgress, renderExpirationTime) {
11277 switch (workInProgress.tag) {
11278 case ClassComponent:
11279 {
11280 var Component = workInProgress.type;
11281
11282 if (isContextProvider(Component)) {
11283 popContext(workInProgress);
11284 }
11285
11286 var effectTag = workInProgress.effectTag;
11287
11288 if (effectTag & ShouldCapture) {
11289 workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
11290 return workInProgress;
11291 }
11292
11293 return null;
11294 }
11295
11296 case HostRoot:
11297 {
11298 popHostContainer(workInProgress);
11299 popTopLevelContextObject(workInProgress);
11300 var _effectTag = workInProgress.effectTag;
11301
11302 (function () {
11303 if (!((_effectTag & DidCapture) === NoEffect)) {
11304 {
11305 throw ReactError(Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue."));
11306 }
11307 }
11308 })();
11309
11310 workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
11311 return workInProgress;
11312 }
11313
11314 case HostComponent:
11315 {
11316 // TODO: popHydrationState
11317 popHostContext(workInProgress);
11318 return null;
11319 }
11320
11321 case SuspenseComponent:
11322 {
11323 popSuspenseContext(workInProgress);
11324
11325 if (enableSuspenseServerRenderer) {
11326 var suspenseState = workInProgress.memoizedState;
11327
11328 if (suspenseState !== null && suspenseState.dehydrated !== null) {
11329 (function () {
11330 if (!(workInProgress.alternate !== null)) {
11331 {
11332 throw ReactError(Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue."));
11333 }
11334 }
11335 })();
11336
11337 resetHydrationState();
11338 }
11339 }
11340
11341 var _effectTag2 = workInProgress.effectTag;
11342
11343 if (_effectTag2 & ShouldCapture) {
11344 workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary.
11345
11346 return workInProgress;
11347 }
11348
11349 return null;
11350 }
11351
11352 case SuspenseListComponent:
11353 {
11354 popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been
11355 // caught by a nested boundary. If not, it should bubble through.
11356
11357 return null;
11358 }
11359
11360 case HostPortal:
11361 popHostContainer(workInProgress);
11362 return null;
11363
11364 case ContextProvider:
11365 popProvider(workInProgress);
11366 return null;
11367
11368 default:
11369 return null;
11370 }
11371}
11372
11373function unwindInterruptedWork(interruptedWork) {
11374 switch (interruptedWork.tag) {
11375 case ClassComponent:
11376 {
11377 var childContextTypes = interruptedWork.type.childContextTypes;
11378
11379 if (childContextTypes !== null && childContextTypes !== undefined) {
11380 popContext(interruptedWork);
11381 }
11382
11383 break;
11384 }
11385
11386 case HostRoot:
11387 {
11388 popHostContainer(interruptedWork);
11389 popTopLevelContextObject(interruptedWork);
11390 break;
11391 }
11392
11393 case HostComponent:
11394 {
11395 popHostContext(interruptedWork);
11396 break;
11397 }
11398
11399 case HostPortal:
11400 popHostContainer(interruptedWork);
11401 break;
11402
11403 case SuspenseComponent:
11404 popSuspenseContext(interruptedWork);
11405 break;
11406
11407 case SuspenseListComponent:
11408 popSuspenseContext(interruptedWork);
11409 break;
11410
11411 case ContextProvider:
11412 popProvider(interruptedWork);
11413 break;
11414
11415 default:
11416 break;
11417 }
11418}
11419
11420function createCapturedValue(value, source) {
11421 // If the value is an error, call this function immediately after it is thrown
11422 // so the stack is accurate.
11423 return {
11424 value: value,
11425 source: source,
11426 stack: getStackByFiberInDevAndProd(source)
11427 };
11428}
11429
11430var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
11431 var funcArgs = Array.prototype.slice.call(arguments, 3);
11432
11433 try {
11434 func.apply(context, funcArgs);
11435 } catch (error) {
11436 this.onError(error);
11437 }
11438};
11439
11440{
11441 // In DEV mode, we swap out invokeGuardedCallback for a special version
11442 // that plays more nicely with the browser's DevTools. The idea is to preserve
11443 // "Pause on exceptions" behavior. Because React wraps all user-provided
11444 // functions in invokeGuardedCallback, and the production version of
11445 // invokeGuardedCallback uses a try-catch, all user exceptions are treated
11446 // like caught exceptions, and the DevTools won't pause unless the developer
11447 // takes the extra step of enabling pause on caught exceptions. This is
11448 // unintuitive, though, because even though React has caught the error, from
11449 // the developer's perspective, the error is uncaught.
11450 //
11451 // To preserve the expected "Pause on exceptions" behavior, we don't use a
11452 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
11453 // DOM node, and call the user-provided callback from inside an event handler
11454 // for that fake event. If the callback throws, the error is "captured" using
11455 // a global event handler. But because the error happens in a different
11456 // event loop context, it does not interrupt the normal program flow.
11457 // Effectively, this gives us try-catch behavior without actually using
11458 // try-catch. Neat!
11459 // Check that the browser supports the APIs we need to implement our special
11460 // DEV version of invokeGuardedCallback
11461 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
11462 var fakeNode = document.createElement('react');
11463
11464 var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
11465 // If document doesn't exist we know for sure we will crash in this method
11466 // when we call document.createEvent(). However this can cause confusing
11467 // errors: https://github.com/facebookincubator/create-react-app/issues/3482
11468 // So we preemptively throw with a better message instead.
11469 (function () {
11470 if (!(typeof document !== 'undefined')) {
11471 {
11472 throw ReactError(Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous."));
11473 }
11474 }
11475 })();
11476
11477 var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We
11478 // set this to true at the beginning, then set it to false right after
11479 // calling the function. If the function errors, `didError` will never be
11480 // set to false. This strategy works even if the browser is flaky and
11481 // fails to call our global error handler, because it doesn't rely on
11482 // the error event at all.
11483
11484 var didError = true; // Keeps track of the value of window.event so that we can reset it
11485 // during the callback to let user code access window.event in the
11486 // browsers that support it.
11487
11488 var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event
11489 // dispatching: https://github.com/facebook/react/issues/13688
11490
11491 var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously
11492 // dispatch our fake event using `dispatchEvent`. Inside the handler, we
11493 // call the user-provided callback.
11494
11495 var funcArgs = Array.prototype.slice.call(arguments, 3);
11496
11497 function callCallback() {
11498 // We immediately remove the callback from event listeners so that
11499 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
11500 // nested call would trigger the fake event handlers of any call higher
11501 // in the stack.
11502 fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the
11503 // window.event assignment in both IE <= 10 as they throw an error
11504 // "Member not found" in strict mode, and in Firefox which does not
11505 // support window.event.
11506
11507 if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
11508 window.event = windowEvent;
11509 }
11510
11511 func.apply(context, funcArgs);
11512 didError = false;
11513 } // Create a global error event handler. We use this to capture the value
11514 // that was thrown. It's possible that this error handler will fire more
11515 // than once; for example, if non-React code also calls `dispatchEvent`
11516 // and a handler for that event throws. We should be resilient to most of
11517 // those cases. Even if our error event handler fires more than once, the
11518 // last error event is always used. If the callback actually does error,
11519 // we know that the last error event is the correct one, because it's not
11520 // possible for anything else to have happened in between our callback
11521 // erroring and the code that follows the `dispatchEvent` call below. If
11522 // the callback doesn't error, but the error event was fired, we know to
11523 // ignore it because `didError` will be false, as described above.
11524
11525
11526 var error; // Use this to track whether the error event is ever called.
11527
11528 var didSetError = false;
11529 var isCrossOriginError = false;
11530
11531 function handleWindowError(event) {
11532 error = event.error;
11533 didSetError = true;
11534
11535 if (error === null && event.colno === 0 && event.lineno === 0) {
11536 isCrossOriginError = true;
11537 }
11538
11539 if (event.defaultPrevented) {
11540 // Some other error handler has prevented default.
11541 // Browsers silence the error report if this happens.
11542 // We'll remember this to later decide whether to log it or not.
11543 if (error != null && typeof error === 'object') {
11544 try {
11545 error._suppressLogging = true;
11546 } catch (inner) {// Ignore.
11547 }
11548 }
11549 }
11550 } // Create a fake event type.
11551
11552
11553 var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers
11554
11555 window.addEventListener('error', handleWindowError);
11556 fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function
11557 // errors, it will trigger our global error handler.
11558
11559 evt.initEvent(evtType, false, false);
11560 fakeNode.dispatchEvent(evt);
11561
11562 if (windowEventDescriptor) {
11563 Object.defineProperty(window, 'event', windowEventDescriptor);
11564 }
11565
11566 if (didError) {
11567 if (!didSetError) {
11568 // The callback errored, but the error event never fired.
11569 error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
11570 } else if (isCrossOriginError) {
11571 error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
11572 }
11573
11574 this.onError(error);
11575 } // Remove our event listeners
11576
11577
11578 window.removeEventListener('error', handleWindowError);
11579 };
11580
11581 invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
11582 }
11583}
11584
11585var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
11586
11587var hasError = false;
11588var caughtError = null; // Used by event system to capture/rethrow the first error.
11589
11590var reporter = {
11591 onError: function (error) {
11592 hasError = true;
11593 caughtError = error;
11594 }
11595};
11596/**
11597 * Call a function while guarding against errors that happens within it.
11598 * Returns an error if it throws, otherwise null.
11599 *
11600 * In production, this is implemented using a try-catch. The reason we don't
11601 * use a try-catch directly is so that we can swap out a different
11602 * implementation in DEV mode.
11603 *
11604 * @param {String} name of the guard to use for logging or debugging
11605 * @param {Function} func The function to invoke
11606 * @param {*} context The context to use when calling the function
11607 * @param {...*} args Arguments for function
11608 */
11609
11610function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
11611 hasError = false;
11612 caughtError = null;
11613 invokeGuardedCallbackImpl$1.apply(reporter, arguments);
11614}
11615/**
11616 * Same as invokeGuardedCallback, but instead of returning an error, it stores
11617 * it in a global so it can be rethrown by `rethrowCaughtError` later.
11618 * TODO: See if caughtError and rethrowError can be unified.
11619 *
11620 * @param {String} name of the guard to use for logging or debugging
11621 * @param {Function} func The function to invoke
11622 * @param {*} context The context to use when calling the function
11623 * @param {...*} args Arguments for function
11624 */
11625
11626
11627/**
11628 * During execution of guarded functions we will capture the first error which
11629 * we will rethrow to be handled by the top level error handler.
11630 */
11631
11632
11633function hasCaughtError() {
11634 return hasError;
11635}
11636function clearCaughtError() {
11637 if (hasError) {
11638 var error = caughtError;
11639 hasError = false;
11640 caughtError = null;
11641 return error;
11642 } else {
11643 (function () {
11644 {
11645 {
11646 throw ReactError(Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue."));
11647 }
11648 }
11649 })();
11650 }
11651}
11652
11653// This module is forked in different environments.
11654// By default, return `true` to log errors to the console.
11655// Forks can return `false` if this isn't desirable.
11656function showErrorDialog(capturedError) {
11657 return true;
11658}
11659
11660function logCapturedError(capturedError) {
11661 var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging.
11662 // This enables renderers like ReactNative to better manage redbox behavior.
11663
11664 if (logError === false) {
11665 return;
11666 }
11667
11668 var error = capturedError.error;
11669
11670 {
11671 var componentName = capturedError.componentName,
11672 componentStack = capturedError.componentStack,
11673 errorBoundaryName = capturedError.errorBoundaryName,
11674 errorBoundaryFound = capturedError.errorBoundaryFound,
11675 willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling
11676 // `preventDefault()` in window `error` handler.
11677 // We record this information as an expando on the error.
11678
11679 if (error != null && error._suppressLogging) {
11680 if (errorBoundaryFound && willRetry) {
11681 // The error is recoverable and was silenced.
11682 // Ignore it and don't print the stack addendum.
11683 // This is handy for testing error boundaries without noise.
11684 return;
11685 } // The error is fatal. Since the silencing might have
11686 // been accidental, we'll surface it anyway.
11687 // However, the browser would have silenced the original error
11688 // so we'll print it first, and then print the stack addendum.
11689
11690
11691 console.error(error); // For a more detailed description of this block, see:
11692 // https://github.com/facebook/react/pull/13384
11693 }
11694
11695 var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
11696 var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
11697
11698 if (errorBoundaryFound && errorBoundaryName) {
11699 if (willRetry) {
11700 errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
11701 } else {
11702 errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree.";
11703 }
11704 } else {
11705 errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
11706 }
11707
11708 var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
11709 // We don't include the original error message and JS stack because the browser
11710 // has already printed it. Even if the application swallows the error, it is still
11711 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
11712
11713 console.error(combinedMessage);
11714 }
11715}
11716
11717var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
11718
11719{
11720 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
11721}
11722
11723var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
11724function logError(boundary, errorInfo) {
11725 var source = errorInfo.source;
11726 var stack = errorInfo.stack;
11727
11728 if (stack === null && source !== null) {
11729 stack = getStackByFiberInDevAndProd(source);
11730 }
11731
11732 var capturedError = {
11733 componentName: source !== null ? getComponentName(source.type) : null,
11734 componentStack: stack !== null ? stack : '',
11735 error: errorInfo.value,
11736 errorBoundary: null,
11737 errorBoundaryName: null,
11738 errorBoundaryFound: false,
11739 willRetry: false
11740 };
11741
11742 if (boundary !== null && boundary.tag === ClassComponent) {
11743 capturedError.errorBoundary = boundary.stateNode;
11744 capturedError.errorBoundaryName = getComponentName(boundary.type);
11745 capturedError.errorBoundaryFound = true;
11746 capturedError.willRetry = true;
11747 }
11748
11749 try {
11750 logCapturedError(capturedError);
11751 } catch (e) {
11752 // This method must not throw, or React internal state will get messed up.
11753 // If console.error is overridden, or logCapturedError() shows a dialog that throws,
11754 // we want to report this error outside of the normal stack as a last resort.
11755 // https://github.com/facebook/react/issues/13188
11756 setTimeout(function () {
11757 throw e;
11758 });
11759 }
11760}
11761
11762var callComponentWillUnmountWithTimer = function (current$$1, instance) {
11763 startPhaseTimer(current$$1, 'componentWillUnmount');
11764 instance.props = current$$1.memoizedProps;
11765 instance.state = current$$1.memoizedState;
11766 instance.componentWillUnmount();
11767 stopPhaseTimer();
11768}; // Capture errors so they don't interrupt unmounting.
11769
11770
11771function safelyCallComponentWillUnmount(current$$1, instance) {
11772 {
11773 invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
11774
11775 if (hasCaughtError()) {
11776 var unmountError = clearCaughtError();
11777 captureCommitPhaseError(current$$1, unmountError);
11778 }
11779 }
11780}
11781
11782function safelyDetachRef(current$$1) {
11783 var ref = current$$1.ref;
11784
11785 if (ref !== null) {
11786 if (typeof ref === 'function') {
11787 {
11788 invokeGuardedCallback(null, ref, null, null);
11789
11790 if (hasCaughtError()) {
11791 var refError = clearCaughtError();
11792 captureCommitPhaseError(current$$1, refError);
11793 }
11794 }
11795 } else {
11796 ref.current = null;
11797 }
11798 }
11799}
11800
11801function safelyCallDestroy(current$$1, destroy) {
11802 {
11803 invokeGuardedCallback(null, destroy, null);
11804
11805 if (hasCaughtError()) {
11806 var error = clearCaughtError();
11807 captureCommitPhaseError(current$$1, error);
11808 }
11809 }
11810}
11811
11812function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
11813 switch (finishedWork.tag) {
11814 case FunctionComponent:
11815 case ForwardRef:
11816 case SimpleMemoComponent:
11817 {
11818 commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
11819 return;
11820 }
11821
11822 case ClassComponent:
11823 {
11824 if (finishedWork.effectTag & Snapshot) {
11825 if (current$$1 !== null) {
11826 var prevProps = current$$1.memoizedProps;
11827 var prevState = current$$1.memoizedState;
11828 startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
11829 var instance = finishedWork.stateNode; // We could update instance props and state here,
11830 // but instead we rely on them being set during last render.
11831 // TODO: revisit this when we implement resuming.
11832
11833 {
11834 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11835 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11836 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11837 }
11838 }
11839
11840 var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
11841
11842 {
11843 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
11844
11845 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
11846 didWarnSet.add(finishedWork.type);
11847 warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
11848 }
11849 }
11850
11851 instance.__reactInternalSnapshotBeforeUpdate = snapshot;
11852 stopPhaseTimer();
11853 }
11854 }
11855
11856 return;
11857 }
11858
11859 case HostRoot:
11860 case HostComponent:
11861 case HostText:
11862 case HostPortal:
11863 case IncompleteClassComponent:
11864 // Nothing to do for these component types
11865 return;
11866
11867 default:
11868 {
11869 (function () {
11870 {
11871 {
11872 throw ReactError(Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."));
11873 }
11874 }
11875 })();
11876 }
11877 }
11878}
11879
11880function commitHookEffectList(unmountTag, mountTag, finishedWork) {
11881 var updateQueue = finishedWork.updateQueue;
11882 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
11883
11884 if (lastEffect !== null) {
11885 var firstEffect = lastEffect.next;
11886 var effect = firstEffect;
11887
11888 do {
11889 if ((effect.tag & unmountTag) !== NoEffect$1) {
11890 // Unmount
11891 var destroy = effect.destroy;
11892 effect.destroy = undefined;
11893
11894 if (destroy !== undefined) {
11895 destroy();
11896 }
11897 }
11898
11899 if ((effect.tag & mountTag) !== NoEffect$1) {
11900 // Mount
11901 var create = effect.create;
11902 effect.destroy = create();
11903
11904 {
11905 var _destroy = effect.destroy;
11906
11907 if (_destroy !== undefined && typeof _destroy !== 'function') {
11908 var addendum = void 0;
11909
11910 if (_destroy === null) {
11911 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
11912 } else if (typeof _destroy.then === 'function') {
11913 addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
11914 } else {
11915 addendum = ' You returned: ' + _destroy;
11916 }
11917
11918 warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
11919 }
11920 }
11921 }
11922
11923 effect = effect.next;
11924 } while (effect !== firstEffect);
11925 }
11926}
11927
11928function commitPassiveHookEffects(finishedWork) {
11929 if ((finishedWork.effectTag & Passive) !== NoEffect) {
11930 switch (finishedWork.tag) {
11931 case FunctionComponent:
11932 case ForwardRef:
11933 case SimpleMemoComponent:
11934 {
11935 commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
11936 commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
11937 break;
11938 }
11939
11940 default:
11941 break;
11942 }
11943 }
11944}
11945
11946function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
11947 switch (finishedWork.tag) {
11948 case FunctionComponent:
11949 case ForwardRef:
11950 case SimpleMemoComponent:
11951 {
11952 commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
11953 break;
11954 }
11955
11956 case ClassComponent:
11957 {
11958 var instance = finishedWork.stateNode;
11959
11960 if (finishedWork.effectTag & Update) {
11961 if (current$$1 === null) {
11962 startPhaseTimer(finishedWork, 'componentDidMount'); // We could update instance props and state here,
11963 // but instead we rely on them being set during last render.
11964 // TODO: revisit this when we implement resuming.
11965
11966 {
11967 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11968 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11969 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11970 }
11971 }
11972
11973 instance.componentDidMount();
11974 stopPhaseTimer();
11975 } else {
11976 var prevProps = finishedWork.elementType === finishedWork.type ? current$$1.memoizedProps : resolveDefaultProps(finishedWork.type, current$$1.memoizedProps);
11977 var prevState = current$$1.memoizedState;
11978 startPhaseTimer(finishedWork, 'componentDidUpdate'); // We could update instance props and state here,
11979 // but instead we rely on them being set during last render.
11980 // TODO: revisit this when we implement resuming.
11981
11982 {
11983 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11984 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11985 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
11986 }
11987 }
11988
11989 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
11990 stopPhaseTimer();
11991 }
11992 }
11993
11994 var updateQueue = finishedWork.updateQueue;
11995
11996 if (updateQueue !== null) {
11997 {
11998 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11999 !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
12000 !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
12001 }
12002 } // We could update instance props and state here,
12003 // but instead we rely on them being set during last render.
12004 // TODO: revisit this when we implement resuming.
12005
12006
12007 commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
12008 }
12009
12010 return;
12011 }
12012
12013 case HostRoot:
12014 {
12015 var _updateQueue = finishedWork.updateQueue;
12016
12017 if (_updateQueue !== null) {
12018 var _instance = null;
12019
12020 if (finishedWork.child !== null) {
12021 switch (finishedWork.child.tag) {
12022 case HostComponent:
12023 _instance = getPublicInstance(finishedWork.child.stateNode);
12024 break;
12025
12026 case ClassComponent:
12027 _instance = finishedWork.child.stateNode;
12028 break;
12029 }
12030 }
12031
12032 commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
12033 }
12034
12035 return;
12036 }
12037
12038 case HostComponent:
12039 {
12040 var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted
12041 // (eg DOM renderer may schedule auto-focus for inputs and form controls).
12042 // These effects should only be committed when components are first mounted,
12043 // aka when there is no current/alternate.
12044
12045 if (current$$1 === null && finishedWork.effectTag & Update) {
12046 var type = finishedWork.type;
12047 var props = finishedWork.memoizedProps;
12048 commitMount(_instance2, type, props, finishedWork);
12049 }
12050
12051 return;
12052 }
12053
12054 case HostText:
12055 {
12056 // We have no life-cycles associated with text.
12057 return;
12058 }
12059
12060 case HostPortal:
12061 {
12062 // We have no life-cycles associated with portals.
12063 return;
12064 }
12065
12066 case Profiler:
12067 {
12068 if (enableProfilerTimer) {
12069 var onRender = finishedWork.memoizedProps.onRender;
12070
12071 if (typeof onRender === 'function') {
12072 if (enableSchedulerTracing) {
12073 onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
12074 } else {
12075 onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
12076 }
12077 }
12078 }
12079
12080 return;
12081 }
12082
12083 case SuspenseComponent:
12084 {
12085 commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
12086 return;
12087 }
12088
12089 case SuspenseListComponent:
12090 case IncompleteClassComponent:
12091 case FundamentalComponent:
12092 case ScopeComponent:
12093 return;
12094
12095 default:
12096 {
12097 (function () {
12098 {
12099 {
12100 throw ReactError(Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."));
12101 }
12102 }
12103 })();
12104 }
12105 }
12106}
12107
12108function hideOrUnhideAllChildren(finishedWork, isHidden) {
12109 if (supportsMutation) {
12110 // We only have the top Fiber that was inserted but we need to recurse down its
12111 // children to find all the terminal nodes.
12112 var node = finishedWork;
12113
12114 while (true) {
12115 if (node.tag === HostComponent) {
12116 var instance = node.stateNode;
12117
12118 if (isHidden) {
12119 hideInstance(instance);
12120 } else {
12121 unhideInstance(node.stateNode, node.memoizedProps);
12122 }
12123 } else if (node.tag === HostText) {
12124 var _instance3 = node.stateNode;
12125
12126 if (isHidden) {
12127 hideTextInstance(_instance3);
12128 } else {
12129 unhideTextInstance(_instance3, node.memoizedProps);
12130 }
12131 } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) {
12132 // Found a nested Suspense component that timed out. Skip over the
12133 // primary child fragment, which should remain hidden.
12134 var fallbackChildFragment = node.child.sibling;
12135 fallbackChildFragment.return = node;
12136 node = fallbackChildFragment;
12137 continue;
12138 } else if (node.child !== null) {
12139 node.child.return = node;
12140 node = node.child;
12141 continue;
12142 }
12143
12144 if (node === finishedWork) {
12145 return;
12146 }
12147
12148 while (node.sibling === null) {
12149 if (node.return === null || node.return === finishedWork) {
12150 return;
12151 }
12152
12153 node = node.return;
12154 }
12155
12156 node.sibling.return = node.return;
12157 node = node.sibling;
12158 }
12159 }
12160}
12161
12162function commitAttachRef(finishedWork) {
12163 var ref = finishedWork.ref;
12164
12165 if (ref !== null) {
12166 var instance = finishedWork.stateNode;
12167 var instanceToUse;
12168
12169 switch (finishedWork.tag) {
12170 case HostComponent:
12171 instanceToUse = getPublicInstance(instance);
12172 break;
12173
12174 default:
12175 instanceToUse = instance;
12176 } // Moved outside to ensure DCE works with this flag
12177
12178
12179 if (enableScopeAPI && finishedWork.tag === ScopeComponent) {
12180 instanceToUse = instance.methods;
12181 }
12182
12183 if (typeof ref === 'function') {
12184 ref(instanceToUse);
12185 } else {
12186 {
12187 if (!ref.hasOwnProperty('current')) {
12188 warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
12189 }
12190 }
12191
12192 ref.current = instanceToUse;
12193 }
12194 }
12195}
12196
12197function commitDetachRef(current$$1) {
12198 var currentRef = current$$1.ref;
12199
12200 if (currentRef !== null) {
12201 if (typeof currentRef === 'function') {
12202 currentRef(null);
12203 } else {
12204 currentRef.current = null;
12205 }
12206 }
12207} // User-originating errors (lifecycles and refs) should not interrupt
12208// deletion, so don't let them throw. Host-originating errors should
12209// interrupt deletion, so it's okay
12210
12211
12212function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) {
12213 onCommitUnmount(current$$1);
12214
12215 switch (current$$1.tag) {
12216 case FunctionComponent:
12217 case ForwardRef:
12218 case MemoComponent:
12219 case SimpleMemoComponent:
12220 {
12221 var updateQueue = current$$1.updateQueue;
12222
12223 if (updateQueue !== null) {
12224 var lastEffect = updateQueue.lastEffect;
12225
12226 if (lastEffect !== null) {
12227 var firstEffect = lastEffect.next; // When the owner fiber is deleted, the destroy function of a passive
12228 // effect hook is called during the synchronous commit phase. This is
12229 // a concession to implementation complexity. Calling it in the
12230 // passive effect phase (like they usually are, when dependencies
12231 // change during an update) would require either traversing the
12232 // children of the deleted fiber again, or including unmount effects
12233 // as part of the fiber effect list.
12234 //
12235 // Because this is during the sync commit phase, we need to change
12236 // the priority.
12237 //
12238 // TODO: Reconsider this implementation trade off.
12239
12240 var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
12241 runWithPriority(priorityLevel, function () {
12242 var effect = firstEffect;
12243
12244 do {
12245 var destroy = effect.destroy;
12246
12247 if (destroy !== undefined) {
12248 safelyCallDestroy(current$$1, destroy);
12249 }
12250
12251 effect = effect.next;
12252 } while (effect !== firstEffect);
12253 });
12254 }
12255 }
12256
12257 break;
12258 }
12259
12260 case ClassComponent:
12261 {
12262 safelyDetachRef(current$$1);
12263 var instance = current$$1.stateNode;
12264
12265 if (typeof instance.componentWillUnmount === 'function') {
12266 safelyCallComponentWillUnmount(current$$1, instance);
12267 }
12268
12269 return;
12270 }
12271
12272 case HostComponent:
12273 {
12274 if (enableFlareAPI) {
12275 var dependencies = current$$1.dependencies;
12276
12277 if (dependencies !== null) {
12278 var respondersMap = dependencies.responders;
12279
12280 if (respondersMap !== null) {
12281 var responderInstances = Array.from(respondersMap.values());
12282
12283 for (var i = 0, length = responderInstances.length; i < length; i++) {
12284 var responderInstance = responderInstances[i];
12285 unmountResponderInstance(responderInstance);
12286 }
12287
12288 dependencies.responders = null;
12289 }
12290 }
12291 }
12292
12293 safelyDetachRef(current$$1);
12294 return;
12295 }
12296
12297 case HostPortal:
12298 {
12299 // TODO: this is recursive.
12300 // We are also not using this parent because
12301 // the portal will get pushed immediately.
12302 if (supportsMutation) {
12303 unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel);
12304 } else if (supportsPersistence) {
12305 emptyPortalContainer(current$$1);
12306 }
12307
12308 return;
12309 }
12310
12311 case FundamentalComponent:
12312 {
12313 if (enableFundamentalAPI) {
12314 var fundamentalInstance = current$$1.stateNode;
12315
12316 if (fundamentalInstance !== null) {
12317 unmountFundamentalComponent(fundamentalInstance);
12318 current$$1.stateNode = null;
12319 }
12320 }
12321
12322 return;
12323 }
12324
12325 case DehydratedFragment:
12326 {
12327 if (enableSuspenseCallback) {
12328 var hydrationCallbacks = finishedRoot.hydrationCallbacks;
12329
12330 if (hydrationCallbacks !== null) {
12331 var onDeleted = hydrationCallbacks.onDeleted;
12332
12333 if (onDeleted) {
12334 onDeleted(current$$1.stateNode);
12335 }
12336 }
12337 }
12338
12339 return;
12340 }
12341
12342 case ScopeComponent:
12343 {
12344 if (enableScopeAPI) {
12345 safelyDetachRef(current$$1);
12346 }
12347 }
12348 }
12349}
12350
12351function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
12352 // While we're inside a removed host node we don't want to call
12353 // removeChild on the inner nodes because they're removed by the top
12354 // call anyway. We also want to call componentWillUnmount on all
12355 // composites before this host node is removed from the tree. Therefore
12356 // we do an inner loop while we're still inside the host node.
12357 var node = root;
12358
12359 while (true) {
12360 commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes.
12361 // Skip portals because commitUnmount() currently visits them recursively.
12362
12363 if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above.
12364 // If we don't use mutation we drill down into portals here instead.
12365 !supportsMutation || node.tag !== HostPortal)) {
12366 node.child.return = node;
12367 node = node.child;
12368 continue;
12369 }
12370
12371 if (node === root) {
12372 return;
12373 }
12374
12375 while (node.sibling === null) {
12376 if (node.return === null || node.return === root) {
12377 return;
12378 }
12379
12380 node = node.return;
12381 }
12382
12383 node.sibling.return = node.return;
12384 node = node.sibling;
12385 }
12386}
12387
12388function detachFiber(current$$1) {
12389 var alternate = current$$1.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we
12390 // should clear the child pointer of the parent alternate to let this
12391 // get GC:ed but we don't know which for sure which parent is the current
12392 // one so we'll settle for GC:ing the subtree of this child. This child
12393 // itself will be GC:ed when the parent updates the next time.
12394
12395 current$$1.return = null;
12396 current$$1.child = null;
12397 current$$1.memoizedState = null;
12398 current$$1.updateQueue = null;
12399 current$$1.dependencies = null;
12400 current$$1.alternate = null;
12401 current$$1.firstEffect = null;
12402 current$$1.lastEffect = null;
12403 current$$1.pendingProps = null;
12404 current$$1.memoizedProps = null;
12405
12406 if (alternate !== null) {
12407 detachFiber(alternate);
12408 }
12409}
12410
12411function emptyPortalContainer(current$$1) {
12412 if (!supportsPersistence) {
12413 return;
12414 }
12415
12416 var portal = current$$1.stateNode;
12417 var containerInfo = portal.containerInfo;
12418 var emptyChildSet = createContainerChildSet(containerInfo);
12419 replaceContainerChildren(containerInfo, emptyChildSet);
12420}
12421
12422function commitContainer(finishedWork) {
12423 if (!supportsPersistence) {
12424 return;
12425 }
12426
12427 switch (finishedWork.tag) {
12428 case ClassComponent:
12429 case HostComponent:
12430 case HostText:
12431 case FundamentalComponent:
12432 {
12433 return;
12434 }
12435
12436 case HostRoot:
12437 case HostPortal:
12438 {
12439 var portalOrRoot = finishedWork.stateNode;
12440 var containerInfo = portalOrRoot.containerInfo,
12441 pendingChildren = portalOrRoot.pendingChildren;
12442 replaceContainerChildren(containerInfo, pendingChildren);
12443 return;
12444 }
12445
12446 default:
12447 {
12448 (function () {
12449 {
12450 {
12451 throw ReactError(Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."));
12452 }
12453 }
12454 })();
12455 }
12456 }
12457}
12458
12459function getHostParentFiber(fiber) {
12460 var parent = fiber.return;
12461
12462 while (parent !== null) {
12463 if (isHostParent(parent)) {
12464 return parent;
12465 }
12466
12467 parent = parent.return;
12468 }
12469
12470 (function () {
12471 {
12472 {
12473 throw ReactError(Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."));
12474 }
12475 }
12476 })();
12477}
12478
12479function isHostParent(fiber) {
12480 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
12481}
12482
12483function getHostSibling(fiber) {
12484 // We're going to search forward into the tree until we find a sibling host
12485 // node. Unfortunately, if multiple insertions are done in a row we have to
12486 // search past them. This leads to exponential search for the next sibling.
12487 // TODO: Find a more efficient way to do this.
12488 var node = fiber;
12489
12490 siblings: while (true) {
12491 // If we didn't find anything, let's try the next sibling.
12492 while (node.sibling === null) {
12493 if (node.return === null || isHostParent(node.return)) {
12494 // If we pop out of the root or hit the parent the fiber we are the
12495 // last sibling.
12496 return null;
12497 }
12498
12499 node = node.return;
12500 }
12501
12502 node.sibling.return = node.return;
12503 node = node.sibling;
12504
12505 while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
12506 // If it is not host node and, we might have a host node inside it.
12507 // Try to search down until we find one.
12508 if (node.effectTag & Placement) {
12509 // If we don't have a child, try the siblings instead.
12510 continue siblings;
12511 } // If we don't have a child, try the siblings instead.
12512 // We also skip portals because they are not part of this host tree.
12513
12514
12515 if (node.child === null || node.tag === HostPortal) {
12516 continue siblings;
12517 } else {
12518 node.child.return = node;
12519 node = node.child;
12520 }
12521 } // Check if this host node is stable or about to be placed.
12522
12523
12524 if (!(node.effectTag & Placement)) {
12525 // Found it!
12526 return node.stateNode;
12527 }
12528 }
12529}
12530
12531function commitPlacement(finishedWork) {
12532 if (!supportsMutation) {
12533 return;
12534 } // Recursively insert all host nodes into the parent.
12535
12536
12537 var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together.
12538
12539 var parent;
12540 var isContainer;
12541 var parentStateNode = parentFiber.stateNode;
12542
12543 switch (parentFiber.tag) {
12544 case HostComponent:
12545 parent = parentStateNode;
12546 isContainer = false;
12547 break;
12548
12549 case HostRoot:
12550 parent = parentStateNode.containerInfo;
12551 isContainer = true;
12552 break;
12553
12554 case HostPortal:
12555 parent = parentStateNode.containerInfo;
12556 isContainer = true;
12557 break;
12558
12559 case FundamentalComponent:
12560 if (enableFundamentalAPI) {
12561 parent = parentStateNode.instance;
12562 isContainer = false;
12563 }
12564
12565 // eslint-disable-next-line-no-fallthrough
12566
12567 default:
12568 (function () {
12569 {
12570 {
12571 throw ReactError(Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue."));
12572 }
12573 }
12574 })();
12575
12576 }
12577
12578 if (parentFiber.effectTag & ContentReset) {
12579 // Reset the text content of the parent before doing any insertions
12580 resetTextContent(parent); // Clear ContentReset from the effect tag
12581
12582 parentFiber.effectTag &= ~ContentReset;
12583 }
12584
12585 var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its
12586 // children to find all the terminal nodes.
12587
12588 var node = finishedWork;
12589
12590 while (true) {
12591 var isHost = node.tag === HostComponent || node.tag === HostText;
12592
12593 if (isHost || enableFundamentalAPI && node.tag === FundamentalComponent) {
12594 var stateNode = isHost ? node.stateNode : node.stateNode.instance;
12595
12596 if (before) {
12597 if (isContainer) {
12598 insertInContainerBefore(parent, stateNode, before);
12599 } else {
12600 insertBefore(parent, stateNode, before);
12601 }
12602 } else {
12603 if (isContainer) {
12604 appendChildToContainer(parent, stateNode);
12605 } else {
12606 appendChild(parent, stateNode);
12607 }
12608 }
12609 } else if (node.tag === HostPortal) {// If the insertion itself is a portal, then we don't want to traverse
12610 // down its children. Instead, we'll get insertions from each child in
12611 // the portal directly.
12612 } else if (node.child !== null) {
12613 node.child.return = node;
12614 node = node.child;
12615 continue;
12616 }
12617
12618 if (node === finishedWork) {
12619 return;
12620 }
12621
12622 while (node.sibling === null) {
12623 if (node.return === null || node.return === finishedWork) {
12624 return;
12625 }
12626
12627 node = node.return;
12628 }
12629
12630 node.sibling.return = node.return;
12631 node = node.sibling;
12632 }
12633}
12634
12635function unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel) {
12636 // We only have the top Fiber that was deleted but we need to recurse down its
12637 // children to find all the terminal nodes.
12638 var node = current$$1; // Each iteration, currentParent is populated with node's host parent if not
12639 // currentParentIsValid.
12640
12641 var currentParentIsValid = false; // Note: these two variables *must* always be updated together.
12642
12643 var currentParent;
12644 var currentParentIsContainer;
12645
12646 while (true) {
12647 if (!currentParentIsValid) {
12648 var parent = node.return;
12649
12650 findParent: while (true) {
12651 (function () {
12652 if (!(parent !== null)) {
12653 {
12654 throw ReactError(Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue."));
12655 }
12656 }
12657 })();
12658
12659 var parentStateNode = parent.stateNode;
12660
12661 switch (parent.tag) {
12662 case HostComponent:
12663 currentParent = parentStateNode;
12664 currentParentIsContainer = false;
12665 break findParent;
12666
12667 case HostRoot:
12668 currentParent = parentStateNode.containerInfo;
12669 currentParentIsContainer = true;
12670 break findParent;
12671
12672 case HostPortal:
12673 currentParent = parentStateNode.containerInfo;
12674 currentParentIsContainer = true;
12675 break findParent;
12676
12677 case FundamentalComponent:
12678 if (enableFundamentalAPI) {
12679 currentParent = parentStateNode.instance;
12680 currentParentIsContainer = false;
12681 }
12682
12683 }
12684
12685 parent = parent.return;
12686 }
12687
12688 currentParentIsValid = true;
12689 }
12690
12691 if (node.tag === HostComponent || node.tag === HostText) {
12692 commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
12693 // node from the tree.
12694
12695 if (currentParentIsContainer) {
12696 removeChildFromContainer(currentParent, node.stateNode);
12697 } else {
12698 removeChild(currentParent, node.stateNode);
12699 } // Don't visit children because we already visited them.
12700
12701 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
12702 var fundamentalNode = node.stateNode.instance;
12703 commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
12704 // node from the tree.
12705
12706 if (currentParentIsContainer) {
12707 removeChildFromContainer(currentParent, fundamentalNode);
12708 } else {
12709 removeChild(currentParent, fundamentalNode);
12710 }
12711 } else if (enableSuspenseServerRenderer && node.tag === DehydratedFragment) {
12712 if (enableSuspenseCallback) {
12713 var hydrationCallbacks = finishedRoot.hydrationCallbacks;
12714
12715 if (hydrationCallbacks !== null) {
12716 var onDeleted = hydrationCallbacks.onDeleted;
12717
12718 if (onDeleted) {
12719 onDeleted(node.stateNode);
12720 }
12721 }
12722 } // Delete the dehydrated suspense boundary and all of its content.
12723
12724
12725 if (currentParentIsContainer) {
12726 clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
12727 } else {
12728 clearSuspenseBoundary(currentParent, node.stateNode);
12729 }
12730 } else if (node.tag === HostPortal) {
12731 if (node.child !== null) {
12732 // When we go into a portal, it becomes the parent to remove from.
12733 // We will reassign it back when we pop the portal on the way up.
12734 currentParent = node.stateNode.containerInfo;
12735 currentParentIsContainer = true; // Visit children because portals might contain host components.
12736
12737 node.child.return = node;
12738 node = node.child;
12739 continue;
12740 }
12741 } else {
12742 commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below.
12743
12744 if (node.child !== null) {
12745 node.child.return = node;
12746 node = node.child;
12747 continue;
12748 }
12749 }
12750
12751 if (node === current$$1) {
12752 return;
12753 }
12754
12755 while (node.sibling === null) {
12756 if (node.return === null || node.return === current$$1) {
12757 return;
12758 }
12759
12760 node = node.return;
12761
12762 if (node.tag === HostPortal) {
12763 // When we go out of the portal, we need to restore the parent.
12764 // Since we don't keep a stack of them, we will search for it.
12765 currentParentIsValid = false;
12766 }
12767 }
12768
12769 node.sibling.return = node.return;
12770 node = node.sibling;
12771 }
12772}
12773
12774function commitDeletion(finishedRoot, current$$1, renderPriorityLevel) {
12775 if (supportsMutation) {
12776 // Recursively delete all host nodes from the parent.
12777 // Detach refs and call componentWillUnmount() on the whole subtree.
12778 unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel);
12779 } else {
12780 // Detach refs and call componentWillUnmount() on the whole subtree.
12781 commitNestedUnmounts(finishedRoot, current$$1, renderPriorityLevel);
12782 }
12783
12784 detachFiber(current$$1);
12785}
12786
12787function commitWork(current$$1, finishedWork) {
12788 if (!supportsMutation) {
12789 switch (finishedWork.tag) {
12790 case FunctionComponent:
12791 case ForwardRef:
12792 case MemoComponent:
12793 case SimpleMemoComponent:
12794 {
12795 // Note: We currently never use MountMutation, but useLayout uses
12796 // UnmountMutation.
12797 commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
12798 return;
12799 }
12800
12801 case Profiler:
12802 {
12803 return;
12804 }
12805
12806 case SuspenseComponent:
12807 {
12808 commitSuspenseComponent(finishedWork);
12809 attachSuspenseRetryListeners(finishedWork);
12810 return;
12811 }
12812
12813 case SuspenseListComponent:
12814 {
12815 attachSuspenseRetryListeners(finishedWork);
12816 return;
12817 }
12818
12819 case HostRoot:
12820 {
12821 if (supportsHydration) {
12822 var root = finishedWork.stateNode;
12823
12824 if (root.hydrate) {
12825 // We've just hydrated. No need to hydrate again.
12826 root.hydrate = false;
12827 commitHydratedContainer(root.containerInfo);
12828 }
12829 }
12830
12831 break;
12832 }
12833 }
12834
12835 commitContainer(finishedWork);
12836 return;
12837 }
12838
12839 switch (finishedWork.tag) {
12840 case FunctionComponent:
12841 case ForwardRef:
12842 case MemoComponent:
12843 case SimpleMemoComponent:
12844 {
12845 // Note: We currently never use MountMutation, but useLayout uses
12846 // UnmountMutation.
12847 commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
12848 return;
12849 }
12850
12851 case ClassComponent:
12852 {
12853 return;
12854 }
12855
12856 case HostComponent:
12857 {
12858 var instance = finishedWork.stateNode;
12859
12860 if (instance != null) {
12861 // Commit the work prepared earlier.
12862 var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
12863 // as the newProps. The updatePayload will contain the real change in
12864 // this case.
12865
12866 var oldProps = current$$1 !== null ? current$$1.memoizedProps : newProps;
12867 var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components.
12868
12869 var updatePayload = finishedWork.updateQueue;
12870 finishedWork.updateQueue = null;
12871
12872 if (updatePayload !== null) {
12873 commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
12874 }
12875
12876 if (enableFlareAPI) {
12877 var prevListeners = oldProps.listeners;
12878 var nextListeners = newProps.listeners;
12879
12880 if (prevListeners !== nextListeners) {
12881 updateEventListeners(nextListeners, finishedWork, null);
12882 }
12883 }
12884 }
12885
12886 return;
12887 }
12888
12889 case HostText:
12890 {
12891 (function () {
12892 if (!(finishedWork.stateNode !== null)) {
12893 {
12894 throw ReactError(Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue."));
12895 }
12896 }
12897 })();
12898
12899 var textInstance = finishedWork.stateNode;
12900 var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
12901 // as the newProps. The updatePayload will contain the real change in
12902 // this case.
12903
12904 var oldText = current$$1 !== null ? current$$1.memoizedProps : newText;
12905 commitTextUpdate(textInstance, oldText, newText);
12906 return;
12907 }
12908
12909 case HostRoot:
12910 {
12911 if (supportsHydration) {
12912 var _root = finishedWork.stateNode;
12913
12914 if (_root.hydrate) {
12915 // We've just hydrated. No need to hydrate again.
12916 _root.hydrate = false;
12917 commitHydratedContainer(_root.containerInfo);
12918 }
12919 }
12920
12921 return;
12922 }
12923
12924 case Profiler:
12925 {
12926 return;
12927 }
12928
12929 case SuspenseComponent:
12930 {
12931 commitSuspenseComponent(finishedWork);
12932 attachSuspenseRetryListeners(finishedWork);
12933 return;
12934 }
12935
12936 case SuspenseListComponent:
12937 {
12938 attachSuspenseRetryListeners(finishedWork);
12939 return;
12940 }
12941
12942 case IncompleteClassComponent:
12943 {
12944 return;
12945 }
12946
12947 case FundamentalComponent:
12948 {
12949 if (enableFundamentalAPI) {
12950 var fundamentalInstance = finishedWork.stateNode;
12951 updateFundamentalComponent(fundamentalInstance);
12952 }
12953
12954 return;
12955 }
12956
12957 case ScopeComponent:
12958 {
12959 if (enableScopeAPI) {
12960 var scopeInstance = finishedWork.stateNode;
12961 scopeInstance.fiber = finishedWork;
12962
12963 if (enableFlareAPI) {
12964 var _newProps = finishedWork.memoizedProps;
12965
12966 var _oldProps = current$$1 !== null ? current$$1.memoizedProps : _newProps;
12967
12968 var _prevListeners = _oldProps.listeners;
12969 var _nextListeners = _newProps.listeners;
12970
12971 if (_prevListeners !== _nextListeners) {
12972 updateEventListeners(_nextListeners, finishedWork, null);
12973 }
12974 }
12975 }
12976
12977 return;
12978 }
12979
12980 default:
12981 {
12982 (function () {
12983 {
12984 {
12985 throw ReactError(Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue."));
12986 }
12987 }
12988 })();
12989 }
12990 }
12991}
12992
12993function commitSuspenseComponent(finishedWork) {
12994 var newState = finishedWork.memoizedState;
12995 var newDidTimeout;
12996 var primaryChildParent = finishedWork;
12997
12998 if (newState === null) {
12999 newDidTimeout = false;
13000 } else {
13001 newDidTimeout = true;
13002 primaryChildParent = finishedWork.child;
13003 markCommitTimeOfFallback();
13004 }
13005
13006 if (supportsMutation && primaryChildParent !== null) {
13007 hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
13008 }
13009
13010 if (enableSuspenseCallback && newState !== null) {
13011 var suspenseCallback = finishedWork.memoizedProps.suspenseCallback;
13012
13013 if (typeof suspenseCallback === 'function') {
13014 var thenables = finishedWork.updateQueue;
13015
13016 if (thenables !== null) {
13017 suspenseCallback(new Set(thenables));
13018 }
13019 } else {
13020 if (suspenseCallback !== undefined) {
13021 warning$1(false, 'Unexpected type for suspenseCallback.');
13022 }
13023 }
13024 }
13025}
13026
13027function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
13028 if (!supportsHydration) {
13029 return;
13030 }
13031
13032 var newState = finishedWork.memoizedState;
13033
13034 if (newState === null) {
13035 var current$$1 = finishedWork.alternate;
13036
13037 if (current$$1 !== null) {
13038 var prevState = current$$1.memoizedState;
13039
13040 if (prevState !== null) {
13041 var suspenseInstance = prevState.dehydrated;
13042
13043 if (suspenseInstance !== null) {
13044 commitHydratedSuspenseInstance(suspenseInstance);
13045
13046 if (enableSuspenseCallback) {
13047 var hydrationCallbacks = finishedRoot.hydrationCallbacks;
13048
13049 if (hydrationCallbacks !== null) {
13050 var onHydrated = hydrationCallbacks.onHydrated;
13051
13052 if (onHydrated) {
13053 onHydrated(suspenseInstance);
13054 }
13055 }
13056 }
13057 }
13058 }
13059 }
13060 }
13061}
13062
13063function attachSuspenseRetryListeners(finishedWork) {
13064 // If this boundary just timed out, then it will have a set of thenables.
13065 // For each thenable, attach a listener so that when it resolves, React
13066 // attempts to re-render the boundary in the primary (pre-timeout) state.
13067 var thenables = finishedWork.updateQueue;
13068
13069 if (thenables !== null) {
13070 finishedWork.updateQueue = null;
13071 var retryCache = finishedWork.stateNode;
13072
13073 if (retryCache === null) {
13074 retryCache = finishedWork.stateNode = new PossiblyWeakSet();
13075 }
13076
13077 thenables.forEach(function (thenable) {
13078 // Memoize using the boundary fiber to prevent redundant listeners.
13079 var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
13080
13081 if (!retryCache.has(thenable)) {
13082 if (enableSchedulerTracing) {
13083 if (thenable.__reactDoNotTraceInteractions !== true) {
13084 retry = tracing.unstable_wrap(retry);
13085 }
13086 }
13087
13088 retryCache.add(thenable);
13089 thenable.then(retry, retry);
13090 }
13091 });
13092 }
13093}
13094
13095function commitResetTextContent(current$$1) {
13096 if (!supportsMutation) {
13097 return;
13098 }
13099
13100 resetTextContent(current$$1.stateNode);
13101}
13102
13103var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
13104
13105function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
13106 var update = createUpdate(expirationTime, null); // Unmount the root by rendering null.
13107
13108 update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
13109 // being called "element".
13110
13111 update.payload = {
13112 element: null
13113 };
13114 var error = errorInfo.value;
13115
13116 update.callback = function () {
13117 onUncaughtError(error);
13118 logError(fiber, errorInfo);
13119 };
13120
13121 return update;
13122}
13123
13124function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
13125 var update = createUpdate(expirationTime, null);
13126 update.tag = CaptureUpdate;
13127 var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
13128
13129 if (typeof getDerivedStateFromError === 'function') {
13130 var error = errorInfo.value;
13131
13132 update.payload = function () {
13133 logError(fiber, errorInfo);
13134 return getDerivedStateFromError(error);
13135 };
13136 }
13137
13138 var inst = fiber.stateNode;
13139
13140 if (inst !== null && typeof inst.componentDidCatch === 'function') {
13141 update.callback = function callback() {
13142 {
13143 markFailedErrorBoundaryForHotReloading(fiber);
13144 }
13145
13146 if (typeof getDerivedStateFromError !== 'function') {
13147 // To preserve the preexisting retry behavior of error boundaries,
13148 // we keep track of which ones already failed during this batch.
13149 // This gets reset before we yield back to the browser.
13150 // TODO: Warn in strict mode if getDerivedStateFromError is
13151 // not defined.
13152 markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
13153
13154 logError(fiber, errorInfo);
13155 }
13156
13157 var error = errorInfo.value;
13158 var stack = errorInfo.stack;
13159 this.componentDidCatch(error, {
13160 componentStack: stack !== null ? stack : ''
13161 });
13162
13163 {
13164 if (typeof getDerivedStateFromError !== 'function') {
13165 // If componentDidCatch is the only error boundary method defined,
13166 // then it needs to call setState to recover from errors.
13167 // If no state update is scheduled then the boundary will swallow the error.
13168 !(fiber.expirationTime === Sync) ? warningWithoutStack$1(false, '%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown') : void 0;
13169 }
13170 }
13171 };
13172 } else {
13173 update.callback = function () {
13174 markFailedErrorBoundaryForHotReloading(fiber);
13175 };
13176 }
13177
13178 return update;
13179}
13180
13181function attachPingListener(root, renderExpirationTime, thenable) {
13182 // Attach a listener to the promise to "ping" the root and retry. But
13183 // only if one does not already exist for the current render expiration
13184 // time (which acts like a "thread ID" here).
13185 var pingCache = root.pingCache;
13186 var threadIDs;
13187
13188 if (pingCache === null) {
13189 pingCache = root.pingCache = new PossiblyWeakMap();
13190 threadIDs = new Set();
13191 pingCache.set(thenable, threadIDs);
13192 } else {
13193 threadIDs = pingCache.get(thenable);
13194
13195 if (threadIDs === undefined) {
13196 threadIDs = new Set();
13197 pingCache.set(thenable, threadIDs);
13198 }
13199 }
13200
13201 if (!threadIDs.has(renderExpirationTime)) {
13202 // Memoize using the thread ID to prevent redundant listeners.
13203 threadIDs.add(renderExpirationTime);
13204 var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
13205 thenable.then(ping, ping);
13206 }
13207}
13208
13209function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
13210 // The source fiber did not complete.
13211 sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
13212
13213 sourceFiber.firstEffect = sourceFiber.lastEffect = null;
13214
13215 if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
13216 // This is a thenable.
13217 var thenable = value;
13218 checkForWrongSuspensePriorityInDEV(sourceFiber);
13219 var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view.
13220
13221 var _workInProgress = returnFiber;
13222
13223 do {
13224 if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
13225 // Found the nearest boundary.
13226 // Stash the promise on the boundary fiber. If the boundary times out, we'll
13227 // attach another listener to flip the boundary back to its normal state.
13228 var thenables = _workInProgress.updateQueue;
13229
13230 if (thenables === null) {
13231 var updateQueue = new Set();
13232 updateQueue.add(thenable);
13233 _workInProgress.updateQueue = updateQueue;
13234 } else {
13235 thenables.add(thenable);
13236 } // If the boundary is outside of batched mode, we should *not*
13237 // suspend the commit. Pretend as if the suspended component rendered
13238 // null and keep rendering. In the commit phase, we'll schedule a
13239 // subsequent synchronous update to re-render the Suspense.
13240 //
13241 // Note: It doesn't matter whether the component that suspended was
13242 // inside a batched mode tree. If the Suspense is outside of it, we
13243 // should *not* suspend the commit.
13244
13245
13246 if ((_workInProgress.mode & BatchedMode) === NoMode) {
13247 _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete.
13248 // But we shouldn't call any lifecycle methods or callbacks. Remove
13249 // all lifecycle effect tags.
13250
13251 sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
13252
13253 if (sourceFiber.tag === ClassComponent) {
13254 var currentSourceFiber = sourceFiber.alternate;
13255
13256 if (currentSourceFiber === null) {
13257 // This is a new mount. Change the tag so it's not mistaken for a
13258 // completed class component. For example, we should not call
13259 // componentWillUnmount if it is deleted.
13260 sourceFiber.tag = IncompleteClassComponent;
13261 } else {
13262 // When we try rendering again, we should not reuse the current fiber,
13263 // since it's known to be in an inconsistent state. Use a force update to
13264 // prevent a bail out.
13265 var update = createUpdate(Sync, null);
13266 update.tag = ForceUpdate;
13267 enqueueUpdate(sourceFiber, update);
13268 }
13269 } // The source fiber did not complete. Mark it with Sync priority to
13270 // indicate that it still has pending work.
13271
13272
13273 sourceFiber.expirationTime = Sync; // Exit without suspending.
13274
13275 return;
13276 } // Confirmed that the boundary is in a concurrent mode tree. Continue
13277 // with the normal suspend path.
13278 //
13279 // After this we'll use a set of heuristics to determine whether this
13280 // render pass will run to completion or restart or "suspend" the commit.
13281 // The actual logic for this is spread out in different places.
13282 //
13283 // This first principle is that if we're going to suspend when we complete
13284 // a root, then we should also restart if we get an update or ping that
13285 // might unsuspend it, and vice versa. The only reason to suspend is
13286 // because you think you might want to restart before committing. However,
13287 // it doesn't make sense to restart only while in the period we're suspended.
13288 //
13289 // Restarting too aggressively is also not good because it starves out any
13290 // intermediate loading state. So we use heuristics to determine when.
13291 // Suspense Heuristics
13292 //
13293 // If nothing threw a Promise or all the same fallbacks are already showing,
13294 // then don't suspend/restart.
13295 //
13296 // If this is an initial render of a new tree of Suspense boundaries and
13297 // those trigger a fallback, then don't suspend/restart. We want to ensure
13298 // that we can show the initial loading state as quickly as possible.
13299 //
13300 // If we hit a "Delayed" case, such as when we'd switch from content back into
13301 // a fallback, then we should always suspend/restart. SuspenseConfig applies to
13302 // this case. If none is defined, JND is used instead.
13303 //
13304 // If we're already showing a fallback and it gets "retried", allowing us to show
13305 // another level, but there's still an inner boundary that would show a fallback,
13306 // then we suspend/restart for 500ms since the last time we showed a fallback
13307 // anywhere in the tree. This effectively throttles progressive loading into a
13308 // consistent train of commits. This also gives us an opportunity to restart to
13309 // get to the completed state slightly earlier.
13310 //
13311 // If there's ambiguity due to batching it's resolved in preference of:
13312 // 1) "delayed", 2) "initial render", 3) "retry".
13313 //
13314 // We want to ensure that a "busy" state doesn't get force committed. We want to
13315 // ensure that new initial loading states can commit as soon as possible.
13316
13317
13318 attachPingListener(root, renderExpirationTime, thenable);
13319 _workInProgress.effectTag |= ShouldCapture;
13320 _workInProgress.expirationTime = renderExpirationTime;
13321 return;
13322 } // This boundary already captured during this render. Continue to the next
13323 // boundary.
13324
13325
13326 _workInProgress = _workInProgress.return;
13327 } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
13328 // TODO: Use invariant so the message is stripped in prod?
13329
13330
13331 value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber));
13332 } // We didn't find a boundary that could handle this type of exception. Start
13333 // over and traverse parent path again, this time treating the exception
13334 // as an error.
13335
13336
13337 renderDidError();
13338 value = createCapturedValue(value, sourceFiber);
13339 var workInProgress = returnFiber;
13340
13341 do {
13342 switch (workInProgress.tag) {
13343 case HostRoot:
13344 {
13345 var _errorInfo = value;
13346 workInProgress.effectTag |= ShouldCapture;
13347 workInProgress.expirationTime = renderExpirationTime;
13348
13349 var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
13350
13351 enqueueCapturedUpdate(workInProgress, _update);
13352 return;
13353 }
13354
13355 case ClassComponent:
13356 // Capture and retry
13357 var errorInfo = value;
13358 var ctor = workInProgress.type;
13359 var instance = workInProgress.stateNode;
13360
13361 if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
13362 workInProgress.effectTag |= ShouldCapture;
13363 workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state
13364
13365 var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
13366
13367 enqueueCapturedUpdate(workInProgress, _update2);
13368 return;
13369 }
13370
13371 break;
13372
13373 default:
13374 break;
13375 }
13376
13377 workInProgress = workInProgress.return;
13378 } while (workInProgress !== null);
13379}
13380
13381var ceil = Math.ceil;
13382var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
13383var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
13384var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
13385var NoContext =
13386/* */
133870;
13388var BatchedContext =
13389/* */
133901;
13391var EventContext =
13392/* */
133932;
13394var DiscreteEventContext =
13395/* */
133964;
13397var LegacyUnbatchedContext =
13398/* */
133998;
13400var RenderContext =
13401/* */
1340216;
13403var CommitContext =
13404/* */
1340532;
13406var RootIncomplete = 0;
13407var RootFatalErrored = 1;
13408var RootErrored = 2;
13409var RootSuspended = 3;
13410var RootSuspendedWithDelay = 4;
13411var RootCompleted = 5;
13412var RootLocked = 6;
13413// Describes where we are in the React execution stack
13414var executionContext = NoContext; // The root we're working on
13415
13416var workInProgressRoot = null; // The fiber we're working on
13417
13418var workInProgress = null; // The expiration time we're rendering
13419
13420var renderExpirationTime = NoWork; // Whether to root completed, errored, suspended, etc.
13421
13422var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
13423
13424var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render.
13425// This is conceptually a time stamp but expressed in terms of an ExpirationTime
13426// because we deal mostly with expiration times in the hot path, so this avoids
13427// the conversion happening in the hot path.
13428
13429var workInProgressRootLatestProcessedExpirationTime = Sync;
13430var workInProgressRootLatestSuspenseTimeout = Sync;
13431var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only
13432// includes unprocessed updates, not work in bailed out children.
13433
13434var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately.
13435// This flag determines if it might be worthwhile to restart if an opportunity
13436// happens latere.
13437
13438var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train
13439// model where we don't commit new loading states in too quick succession.
13440
13441var globalMostRecentFallbackTime = 0;
13442var FALLBACK_THROTTLE_MS = 500;
13443var nextEffect = null;
13444var hasUncaughtError = false;
13445var firstUncaughtError = null;
13446var legacyErrorBoundariesThatAlreadyFailed = null;
13447var rootDoesHavePassiveEffects = false;
13448var rootWithPendingPassiveEffects = null;
13449var pendingPassiveEffectsRenderPriority = NoPriority;
13450var pendingPassiveEffectsExpirationTime = NoWork;
13451var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
13452
13453var NESTED_UPDATE_LIMIT = 50;
13454var nestedUpdateCount = 0;
13455var rootWithNestedUpdates = null;
13456var NESTED_PASSIVE_UPDATE_LIMIT = 50;
13457var nestedPassiveUpdateCount = 0;
13458var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times
13459// during the commit phase. This enables them to be traced across components
13460// that spawn new work during render. E.g. hidden boundaries, suspended SSR
13461// hydration or SuspenseList.
13462
13463var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start
13464// time). However, if two updates are scheduled within the same event, we
13465// should treat their start times as simultaneous, even if the actual clock
13466// time has advanced between the first and second call.
13467// In other words, because expiration times determine how updates are batched,
13468// we want all updates of like priority that occur within the same event to
13469// receive the same expiration time. Otherwise we get tearing.
13470
13471var currentEventTime = NoWork;
13472function requestCurrentTime() {
13473 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
13474 // We're inside React, so it's fine to read the actual time.
13475 return msToExpirationTime(now$1());
13476 } // We're not inside React, so we may be in the middle of a browser event.
13477
13478
13479 if (currentEventTime !== NoWork) {
13480 // Use the same start time for all updates until we enter React again.
13481 return currentEventTime;
13482 } // This is the first update since React yielded. Compute a new start time.
13483
13484
13485 currentEventTime = msToExpirationTime(now$1());
13486 return currentEventTime;
13487}
13488function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
13489 var mode = fiber.mode;
13490
13491 if ((mode & BatchedMode) === NoMode) {
13492 return Sync;
13493 }
13494
13495 var priorityLevel = getCurrentPriorityLevel();
13496
13497 if ((mode & ConcurrentMode) === NoMode) {
13498 return priorityLevel === ImmediatePriority ? Sync : Batched;
13499 }
13500
13501 if ((executionContext & RenderContext) !== NoContext) {
13502 // Use whatever time we're already rendering
13503 // TODO: Should there be a way to opt out, like with `runWithPriority`?
13504 return renderExpirationTime;
13505 }
13506
13507 var expirationTime;
13508
13509 if (suspenseConfig !== null) {
13510 // Compute an expiration time based on the Suspense timeout.
13511 expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
13512 } else {
13513 // Compute an expiration time based on the Scheduler priority.
13514 switch (priorityLevel) {
13515 case ImmediatePriority:
13516 expirationTime = Sync;
13517 break;
13518
13519 case UserBlockingPriority:
13520 // TODO: Rename this to computeUserBlockingExpiration
13521 expirationTime = computeInteractiveExpiration(currentTime);
13522 break;
13523
13524 case NormalPriority:
13525 case LowPriority:
13526 // TODO: Handle LowPriority
13527 // TODO: Rename this to... something better.
13528 expirationTime = computeAsyncExpiration(currentTime);
13529 break;
13530
13531 case IdlePriority:
13532 expirationTime = Idle;
13533 break;
13534
13535 default:
13536 (function () {
13537 {
13538 {
13539 throw ReactError(Error("Expected a valid priority level"));
13540 }
13541 }
13542 })();
13543
13544 }
13545 } // If we're in the middle of rendering a tree, do not update at the same
13546 // expiration time that is already rendering.
13547 // TODO: We shouldn't have to do this if the update is on a different root.
13548 // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
13549 // the root when we check for this condition.
13550
13551
13552 if (workInProgressRoot !== null && expirationTime === renderExpirationTime) {
13553 // This is a trick to move this update into a separate batch
13554 expirationTime -= 1;
13555 }
13556
13557 return expirationTime;
13558}
13559var lastUniqueAsyncExpiration = NoWork;
13560function computeUniqueAsyncExpiration() {
13561 var currentTime = requestCurrentTime();
13562 var result = computeAsyncExpiration(currentTime);
13563
13564 if (result <= lastUniqueAsyncExpiration) {
13565 // Since we assume the current time monotonically increases, we only hit
13566 // this branch when computeUniqueAsyncExpiration is fired multiple times
13567 // within a 200ms window (or whatever the async bucket size is).
13568 result -= 1;
13569 }
13570
13571 lastUniqueAsyncExpiration = result;
13572 return result;
13573}
13574function scheduleUpdateOnFiber(fiber, expirationTime) {
13575 checkForNestedUpdates();
13576 warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber);
13577 var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
13578
13579 if (root === null) {
13580 warnAboutUpdateOnUnmountedFiberInDEV(fiber);
13581 return;
13582 }
13583
13584 checkForInterruption(fiber, expirationTime);
13585 recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
13586 // priority as an argument to that function and this one.
13587
13588 var priorityLevel = getCurrentPriorityLevel();
13589
13590 if (expirationTime === Sync) {
13591 if ( // Check if we're inside unbatchedUpdates
13592 (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
13593 (executionContext & (RenderContext | CommitContext)) === NoContext) {
13594 // Register pending interactions on the root to avoid losing traced interaction data.
13595 schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
13596 // root inside of batchedUpdates should be synchronous, but layout updates
13597 // should be deferred until the end of the batch.
13598
13599 performSyncWorkOnRoot(root);
13600 } else {
13601 ensureRootIsScheduled(root);
13602 schedulePendingInteractions(root, expirationTime);
13603
13604 if (executionContext === NoContext) {
13605 // Flush the synchronous work now, unless we're already working or inside
13606 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
13607 // scheduleCallbackForFiber to preserve the ability to schedule a callback
13608 // without immediately flushing it. We only do this for user-initiated
13609 // updates, to preserve historical behavior of sync mode.
13610 flushSyncCallbackQueue();
13611 }
13612 }
13613 } else {
13614 ensureRootIsScheduled(root);
13615 schedulePendingInteractions(root, expirationTime);
13616 }
13617
13618 if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered
13619 // discrete, even inside a discrete event.
13620 priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority)) {
13621 // This is the result of a discrete event. Track the lowest priority
13622 // discrete update per root so we can flush them early, if needed.
13623 if (rootsWithPendingDiscreteUpdates === null) {
13624 rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
13625 } else {
13626 var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
13627
13628 if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
13629 rootsWithPendingDiscreteUpdates.set(root, expirationTime);
13630 }
13631 }
13632 }
13633}
13634var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending
13635// work without treating it as a typical update that originates from an event;
13636// e.g. retrying a Suspense boundary isn't an update, but it does schedule work
13637// on a fiber.
13638
13639function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
13640 // Update the source fiber's expiration time
13641 if (fiber.expirationTime < expirationTime) {
13642 fiber.expirationTime = expirationTime;
13643 }
13644
13645 var alternate = fiber.alternate;
13646
13647 if (alternate !== null && alternate.expirationTime < expirationTime) {
13648 alternate.expirationTime = expirationTime;
13649 } // Walk the parent path to the root and update the child expiration time.
13650
13651
13652 var node = fiber.return;
13653 var root = null;
13654
13655 if (node === null && fiber.tag === HostRoot) {
13656 root = fiber.stateNode;
13657 } else {
13658 while (node !== null) {
13659 alternate = node.alternate;
13660
13661 if (node.childExpirationTime < expirationTime) {
13662 node.childExpirationTime = expirationTime;
13663
13664 if (alternate !== null && alternate.childExpirationTime < expirationTime) {
13665 alternate.childExpirationTime = expirationTime;
13666 }
13667 } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
13668 alternate.childExpirationTime = expirationTime;
13669 }
13670
13671 if (node.return === null && node.tag === HostRoot) {
13672 root = node.stateNode;
13673 break;
13674 }
13675
13676 node = node.return;
13677 }
13678 }
13679
13680 if (root !== null) {
13681 if (workInProgressRoot === root) {
13682 // Received an update to a tree that's in the middle of rendering. Mark
13683 // that's unprocessed work on this root.
13684 markUnprocessedUpdateTime(expirationTime);
13685
13686 if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
13687 // The root already suspended with a delay, which means this render
13688 // definitely won't finish. Since we have a new update, let's mark it as
13689 // suspended now, right before marking the incoming update. This has the
13690 // effect of interrupting the current render and switching to the update.
13691 // TODO: This happens to work when receiving an update during the render
13692 // phase, because of the trick inside computeExpirationForFiber to
13693 // subtract 1 from `renderExpirationTime` to move it into a
13694 // separate bucket. But we should probably model it with an exception,
13695 // using the same mechanism we use to force hydration of a subtree.
13696 // TODO: This does not account for low pri updates that were already
13697 // scheduled before the root started rendering. Need to track the next
13698 // pending expiration time (perhaps by backtracking the return path) and
13699 // then trigger a restart in the `renderDidSuspendDelayIfPossible` path.
13700 markRootSuspendedAtTime(root, renderExpirationTime);
13701 }
13702 } // Mark that the root has a pending update.
13703
13704
13705 markRootUpdatedAtTime(root, expirationTime);
13706 }
13707
13708 return root;
13709}
13710
13711function getNextRootExpirationTimeToWorkOn(root) {
13712 // Determines the next expiration time that the root should render, taking
13713 // into account levels that may be suspended, or levels that may have
13714 // received a ping.
13715 var lastExpiredTime = root.lastExpiredTime;
13716
13717 if (lastExpiredTime !== NoWork) {
13718 return lastExpiredTime;
13719 } // "Pending" refers to any update that hasn't committed yet, including if it
13720 // suspended. The "suspended" range is therefore a subset.
13721
13722
13723 var firstPendingTime = root.firstPendingTime;
13724
13725 if (!isRootSuspendedAtTime(root, firstPendingTime)) {
13726 // The highest priority pending time is not suspended. Let's work on that.
13727 return firstPendingTime;
13728 } // If the first pending time is suspended, check if there's a lower priority
13729 // pending level that we know about. Or check if we received a ping. Work
13730 // on whichever is higher priority.
13731
13732
13733 var lastPingedTime = root.lastPingedTime;
13734 var nextKnownPendingLevel = root.nextKnownPendingLevel;
13735 return lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel;
13736} // Use this function to schedule a task for a root. There's only one task per
13737// root; if a task was already scheduled, we'll check to make sure the
13738// expiration time of the existing task is the same as the expiration time of
13739// the next level that the root has work on. This function is called on every
13740// update, and right before exiting a task.
13741
13742
13743function ensureRootIsScheduled(root) {
13744 var lastExpiredTime = root.lastExpiredTime;
13745
13746 if (lastExpiredTime !== NoWork) {
13747 // Special case: Expired work should flush synchronously.
13748 root.callbackExpirationTime = Sync;
13749 root.callbackPriority = ImmediatePriority;
13750 root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
13751 return;
13752 }
13753
13754 var expirationTime = getNextRootExpirationTimeToWorkOn(root);
13755 var existingCallbackNode = root.callbackNode;
13756
13757 if (expirationTime === NoWork) {
13758 // There's nothing to work on.
13759 if (existingCallbackNode !== null) {
13760 root.callbackNode = null;
13761 root.callbackExpirationTime = NoWork;
13762 root.callbackPriority = NoPriority;
13763 }
13764
13765 return;
13766 } // TODO: If this is an update, we already read the current time. Pass the
13767 // time as an argument.
13768
13769
13770 var currentTime = requestCurrentTime();
13771 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and
13772 // expiration time. Otherwise, we'll cancel it and schedule a new one.
13773
13774 if (existingCallbackNode !== null) {
13775 var existingCallbackPriority = root.callbackPriority;
13776 var existingCallbackExpirationTime = root.callbackExpirationTime;
13777
13778 if ( // Callback must have the exact same expiration time.
13779 existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority.
13780 existingCallbackPriority >= priorityLevel) {
13781 // Existing callback is sufficient.
13782 return;
13783 } // Need to schedule a new task.
13784 // TODO: Instead of scheduling a new task, we should be able to change the
13785 // priority of the existing one.
13786
13787
13788 cancelCallback(existingCallbackNode);
13789 }
13790
13791 root.callbackExpirationTime = expirationTime;
13792 root.callbackPriority = priorityLevel;
13793 var callbackNode;
13794
13795 if (expirationTime === Sync) {
13796 // Sync React callbacks are scheduled on a special internal queue
13797 callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
13798 } else if (disableSchedulerTimeoutBasedOnReactExpirationTime) {
13799 callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root));
13800 } else {
13801 callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects
13802 // ordering because tasks are processed in timeout order.
13803 {
13804 timeout: expirationTimeToMs(expirationTime) - now$1()
13805 });
13806 }
13807
13808 root.callbackNode = callbackNode;
13809} // This is the entry point for every concurrent task, i.e. anything that
13810// goes through Scheduler.
13811
13812
13813function performConcurrentWorkOnRoot(root, didTimeout) {
13814 // Since we know we're in a React event, we can clear the current
13815 // event time. The next update will compute a new event time.
13816 currentEventTime = NoWork;
13817
13818 if (didTimeout) {
13819 // The render task took too long to complete. Mark the current time as
13820 // expired to synchronously render all expired work in a single batch.
13821 var currentTime = requestCurrentTime();
13822 markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback.
13823
13824 ensureRootIsScheduled(root);
13825 return null;
13826 } // Determine the next expiration time to work on, using the fields stored
13827 // on the root.
13828
13829
13830 var expirationTime = getNextRootExpirationTimeToWorkOn(root);
13831
13832 if (expirationTime !== NoWork) {
13833 var originalCallbackNode = root.callbackNode;
13834
13835 (function () {
13836 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
13837 {
13838 throw ReactError(Error("Should not already be working."));
13839 }
13840 }
13841 })();
13842
13843 flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
13844 // and prepare a fresh one. Otherwise we'll continue where we left off.
13845
13846 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
13847 prepareFreshStack(root, expirationTime);
13848 startWorkOnPendingInteractions(root, expirationTime);
13849 } // If we have a work-in-progress fiber, it means there's still work to do
13850 // in this root.
13851
13852
13853 if (workInProgress !== null) {
13854 var prevExecutionContext = executionContext;
13855 executionContext |= RenderContext;
13856 var prevDispatcher = pushDispatcher(root);
13857 var prevInteractions = pushInteractions(root);
13858 startWorkLoopTimer(workInProgress);
13859
13860 do {
13861 try {
13862 workLoopConcurrent();
13863 break;
13864 } catch (thrownValue) {
13865 handleError(root, thrownValue);
13866 }
13867 } while (true);
13868
13869 resetContextDependencies();
13870 executionContext = prevExecutionContext;
13871 popDispatcher(prevDispatcher);
13872
13873 if (enableSchedulerTracing) {
13874 popInteractions(prevInteractions);
13875 }
13876
13877 if (workInProgressRootExitStatus === RootFatalErrored) {
13878 var fatalError = workInProgressRootFatalError;
13879 stopInterruptedWorkLoopTimer();
13880 prepareFreshStack(root, expirationTime);
13881 markRootSuspendedAtTime(root, expirationTime);
13882 ensureRootIsScheduled(root);
13883 throw fatalError;
13884 }
13885
13886 if (workInProgress !== null) {
13887 // There's still work left over. Exit without committing.
13888 stopInterruptedWorkLoopTimer();
13889 } else {
13890 // We now have a consistent tree. The next step is either to commit it,
13891 // or, if something suspended, wait to commit it after a timeout.
13892 stopFinishedWorkLoopTimer();
13893 var finishedWork = root.finishedWork = root.current.alternate;
13894 root.finishedExpirationTime = expirationTime;
13895 resolveLocksOnRoot(root, expirationTime);
13896 finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime);
13897 }
13898
13899 ensureRootIsScheduled(root);
13900
13901 if (root.callbackNode === originalCallbackNode) {
13902 // The task node scheduled for this root is the same one that's
13903 // currently executed. Need to return a continuation.
13904 return performConcurrentWorkOnRoot.bind(null, root);
13905 }
13906 }
13907 }
13908
13909 return null;
13910}
13911
13912function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) {
13913 // Set this to null to indicate there's no in-progress render.
13914 workInProgressRoot = null;
13915
13916 switch (exitStatus) {
13917 case RootIncomplete:
13918 case RootFatalErrored:
13919 {
13920 (function () {
13921 {
13922 {
13923 throw ReactError(Error("Root did not complete. This is a bug in React."));
13924 }
13925 }
13926 })();
13927 }
13928 // Flow knows about invariant, so it complains if I add a break
13929 // statement, but eslint doesn't know about invariant, so it complains
13930 // if I do. eslint-disable-next-line no-fallthrough
13931
13932 case RootErrored:
13933 {
13934 if (expirationTime !== Idle) {
13935 // If this was an async render, the error may have happened due to
13936 // a mutation in a concurrent event. Try rendering one more time,
13937 // synchronously, to see if the error goes away. If there are
13938 // lower priority updates, let's include those, too, in case they
13939 // fix the inconsistency. Render at Idle to include all updates.
13940 markRootExpiredAtTime(root, Idle);
13941 break;
13942 } // Commit the root in its errored state.
13943
13944
13945 commitRoot(root);
13946 break;
13947 }
13948
13949 case RootSuspended:
13950 {
13951 markRootSuspendedAtTime(root, expirationTime);
13952 var lastSuspendedTime = root.lastSuspendedTime;
13953
13954 if (expirationTime === lastSuspendedTime) {
13955 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
13956 }
13957
13958 flushSuspensePriorityWarningInDEV(); // We have an acceptable loading state. We need to figure out if we
13959 // should immediately commit it or wait a bit.
13960 // If we have processed new updates during this render, we may now
13961 // have a new loading state ready. We want to ensure that we commit
13962 // that as soon as possible.
13963
13964 var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
13965
13966 if (hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope
13967 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
13968 // If we have not processed any new updates during this pass, then
13969 // this is either a retry of an existing fallback state or a
13970 // hidden tree. Hidden trees shouldn't be batched with other work
13971 // and after that's fixed it can only be a retry. We're going to
13972 // throttle committing retries so that we don't show too many
13973 // loading states too quickly.
13974 var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now$1(); // Don't bother with a very short suspense time.
13975
13976 if (msUntilTimeout > 10) {
13977 if (workInProgressRootHasPendingPing) {
13978 var lastPingedTime = root.lastPingedTime;
13979
13980 if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
13981 // This render was pinged but we didn't get to restart
13982 // earlier so try restarting now instead.
13983 root.lastPingedTime = expirationTime;
13984 prepareFreshStack(root, expirationTime);
13985 break;
13986 }
13987 }
13988
13989 var nextTime = getNextRootExpirationTimeToWorkOn(root);
13990
13991 if (nextTime !== NoWork && nextTime !== expirationTime) {
13992 // There's additional work on this root.
13993 break;
13994 }
13995
13996 if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) {
13997 // We should prefer to render the fallback of at the last
13998 // suspended level. Ping the last suspended level to try
13999 // rendering it again.
14000 root.lastPingedTime = lastSuspendedTime;
14001 break;
14002 } // The render is suspended, it hasn't timed out, and there's no
14003 // lower priority work to do. Instead of committing the fallback
14004 // immediately, wait for more data to arrive.
14005
14006
14007 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
14008 break;
14009 }
14010 } // The work expired. Commit immediately.
14011
14012
14013 commitRoot(root);
14014 break;
14015 }
14016
14017 case RootSuspendedWithDelay:
14018 {
14019 markRootSuspendedAtTime(root, expirationTime);
14020 var _lastSuspendedTime = root.lastSuspendedTime;
14021
14022 if (expirationTime === _lastSuspendedTime) {
14023 root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
14024 }
14025
14026 flushSuspensePriorityWarningInDEV();
14027
14028 if ( // do not delay if we're inside an act() scope
14029 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
14030 // We're suspended in a state that should be avoided. We'll try to
14031 // avoid committing it for as long as the timeouts let us.
14032 if (workInProgressRootHasPendingPing) {
14033 var _lastPingedTime = root.lastPingedTime;
14034
14035 if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
14036 // This render was pinged but we didn't get to restart earlier
14037 // so try restarting now instead.
14038 root.lastPingedTime = expirationTime;
14039 prepareFreshStack(root, expirationTime);
14040 break;
14041 }
14042 }
14043
14044 var _nextTime = getNextRootExpirationTimeToWorkOn(root);
14045
14046 if (_nextTime !== NoWork && _nextTime !== expirationTime) {
14047 // There's additional work on this root.
14048 break;
14049 }
14050
14051 if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) {
14052 // We should prefer to render the fallback of at the last
14053 // suspended level. Ping the last suspended level to try
14054 // rendering it again.
14055 root.lastPingedTime = _lastSuspendedTime;
14056 break;
14057 }
14058
14059 var _msUntilTimeout;
14060
14061 if (workInProgressRootLatestSuspenseTimeout !== Sync) {
14062 // We have processed a suspense config whose expiration time we
14063 // can use as the timeout.
14064 _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now$1();
14065 } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
14066 // This should never normally happen because only new updates
14067 // cause delayed states, so we should have processed something.
14068 // However, this could also happen in an offscreen tree.
14069 _msUntilTimeout = 0;
14070 } else {
14071 // If we don't have a suspense config, we're going to use a
14072 // heuristic to determine how long we can suspend.
14073 var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
14074 var currentTimeMs = now$1();
14075 var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
14076 var timeElapsed = currentTimeMs - eventTimeMs;
14077
14078 if (timeElapsed < 0) {
14079 // We get this wrong some time since we estimate the time.
14080 timeElapsed = 0;
14081 }
14082
14083 _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the
14084 // event time is exact instead of inferred from expiration time
14085 // we don't need this.
14086
14087 if (timeUntilExpirationMs < _msUntilTimeout) {
14088 _msUntilTimeout = timeUntilExpirationMs;
14089 }
14090 } // Don't bother with a very short suspense time.
14091
14092
14093 if (_msUntilTimeout > 10) {
14094 // The render is suspended, it hasn't timed out, and there's no
14095 // lower priority work to do. Instead of committing the fallback
14096 // immediately, wait for more data to arrive.
14097 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
14098 break;
14099 }
14100 } // The work expired. Commit immediately.
14101
14102
14103 commitRoot(root);
14104 break;
14105 }
14106
14107 case RootCompleted:
14108 {
14109 // The work completed. Ready to commit.
14110 if ( // do not delay if we're inside an act() scope
14111 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
14112 // If we have exceeded the minimum loading delay, which probably
14113 // means we have shown a spinner already, we might have to suspend
14114 // a bit longer to ensure that the spinner is shown for
14115 // enough time.
14116 var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
14117
14118 if (_msUntilTimeout2 > 10) {
14119 markRootSuspendedAtTime(root, expirationTime);
14120 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
14121 break;
14122 }
14123 }
14124
14125 commitRoot(root);
14126 break;
14127 }
14128
14129 case RootLocked:
14130 {
14131 // This root has a lock that prevents it from committing. Exit. If
14132 // we begin work on the root again, without any intervening updates,
14133 // it will finish without doing additional work.
14134 markRootSuspendedAtTime(root, expirationTime);
14135 break;
14136 }
14137
14138 default:
14139 {
14140 (function () {
14141 {
14142 {
14143 throw ReactError(Error("Unknown root exit status."));
14144 }
14145 }
14146 })();
14147 }
14148 }
14149} // This is the entry point for synchronous tasks that don't go
14150// through Scheduler
14151
14152
14153function performSyncWorkOnRoot(root) {
14154 // Check if there's expired work on this root. Otherwise, render at Sync.
14155 var lastExpiredTime = root.lastExpiredTime;
14156 var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync;
14157
14158 if (root.finishedExpirationTime === expirationTime) {
14159 // There's already a pending commit at this expiration time.
14160 // TODO: This is poorly factored. This case only exists for the
14161 // batch.commit() API.
14162 commitRoot(root);
14163 } else {
14164 (function () {
14165 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
14166 {
14167 throw ReactError(Error("Should not already be working."));
14168 }
14169 }
14170 })();
14171
14172 flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
14173 // and prepare a fresh one. Otherwise we'll continue where we left off.
14174
14175 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
14176 prepareFreshStack(root, expirationTime);
14177 startWorkOnPendingInteractions(root, expirationTime);
14178 } // If we have a work-in-progress fiber, it means there's still work to do
14179 // in this root.
14180
14181
14182 if (workInProgress !== null) {
14183 var prevExecutionContext = executionContext;
14184 executionContext |= RenderContext;
14185 var prevDispatcher = pushDispatcher(root);
14186 var prevInteractions = pushInteractions(root);
14187 startWorkLoopTimer(workInProgress);
14188
14189 do {
14190 try {
14191 workLoopSync();
14192 break;
14193 } catch (thrownValue) {
14194 handleError(root, thrownValue);
14195 }
14196 } while (true);
14197
14198 resetContextDependencies();
14199 executionContext = prevExecutionContext;
14200 popDispatcher(prevDispatcher);
14201
14202 if (enableSchedulerTracing) {
14203 popInteractions(prevInteractions);
14204 }
14205
14206 if (workInProgressRootExitStatus === RootFatalErrored) {
14207 var fatalError = workInProgressRootFatalError;
14208 stopInterruptedWorkLoopTimer();
14209 prepareFreshStack(root, expirationTime);
14210 markRootSuspendedAtTime(root, expirationTime);
14211 ensureRootIsScheduled(root);
14212 throw fatalError;
14213 }
14214
14215 if (workInProgress !== null) {
14216 // This is a sync render, so we should have finished the whole tree.
14217 (function () {
14218 {
14219 {
14220 throw ReactError(Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue."));
14221 }
14222 }
14223 })();
14224 } else {
14225 // We now have a consistent tree. Because this is a sync render, we
14226 // will commit it even if something suspended. The only exception is
14227 // if the root is locked (using the unstable_createBatch API).
14228 stopFinishedWorkLoopTimer();
14229 root.finishedWork = root.current.alternate;
14230 root.finishedExpirationTime = expirationTime;
14231 resolveLocksOnRoot(root, expirationTime);
14232 finishSyncRender(root, workInProgressRootExitStatus, expirationTime);
14233 } // Before exiting, make sure there's a callback scheduled for the next
14234 // pending level.
14235
14236
14237 ensureRootIsScheduled(root);
14238 }
14239 }
14240
14241 return null;
14242}
14243
14244function finishSyncRender(root, exitStatus, expirationTime) {
14245 if (exitStatus === RootLocked) {
14246 // This root has a lock that prevents it from committing. Exit. If we
14247 // begin work on the root again, without any intervening updates, it
14248 // will finish without doing additional work.
14249 markRootSuspendedAtTime(root, expirationTime);
14250 } else {
14251 // Set this to null to indicate there's no in-progress render.
14252 workInProgressRoot = null;
14253
14254 {
14255 if (exitStatus === RootSuspended || exitStatus === RootSuspendedWithDelay) {
14256 flushSuspensePriorityWarningInDEV();
14257 }
14258 }
14259
14260 commitRoot(root);
14261 }
14262}
14263
14264function flushRoot(root, expirationTime) {
14265 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
14266 (function () {
14267 {
14268 {
14269 throw ReactError(Error("work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method."));
14270 }
14271 }
14272 })();
14273 }
14274
14275 markRootExpiredAtTime(root, expirationTime);
14276 ensureRootIsScheduled(root);
14277 flushSyncCallbackQueue();
14278}
14279function flushDiscreteUpdates() {
14280 // TODO: Should be able to flush inside batchedUpdates, but not inside `act`.
14281 // However, `act` uses `batchedUpdates`, so there's no way to distinguish
14282 // those two cases. Need to fix this before exposing flushDiscreteUpdates
14283 // as a public API.
14284 if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) {
14285 if (true && (executionContext & RenderContext) !== NoContext) {
14286 warning$1(false, 'unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.');
14287 } // We're already rendering, so we can't synchronously flush pending work.
14288 // This is probably a nested event dispatch triggered by a lifecycle/effect,
14289 // like `el.focus()`. Exit.
14290
14291
14292 return;
14293 }
14294
14295 flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that
14296 // they fire before the next serial event.
14297
14298 flushPassiveEffects();
14299}
14300
14301function resolveLocksOnRoot(root, expirationTime) {
14302 var firstBatch = root.firstBatch;
14303
14304 if (firstBatch !== null && firstBatch._defer && firstBatch._expirationTime >= expirationTime) {
14305 scheduleCallback(NormalPriority, function () {
14306 firstBatch._onComplete();
14307
14308 return null;
14309 });
14310 workInProgressRootExitStatus = RootLocked;
14311 }
14312}
14313
14314function deferredUpdates(fn) {
14315 // TODO: Remove in favor of Scheduler.next
14316 return runWithPriority(NormalPriority, fn);
14317}
14318function syncUpdates(fn, a, b, c) {
14319 return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c));
14320}
14321
14322function flushPendingDiscreteUpdates() {
14323 if (rootsWithPendingDiscreteUpdates !== null) {
14324 // For each root with pending discrete updates, schedule a callback to
14325 // immediately flush them.
14326 var roots = rootsWithPendingDiscreteUpdates;
14327 rootsWithPendingDiscreteUpdates = null;
14328 roots.forEach(function (expirationTime, root) {
14329 markRootExpiredAtTime(root, expirationTime);
14330 ensureRootIsScheduled(root);
14331 }); // Now flush the immediate queue.
14332
14333 flushSyncCallbackQueue();
14334 }
14335}
14336
14337function batchedUpdates(fn, a) {
14338 var prevExecutionContext = executionContext;
14339 executionContext |= BatchedContext;
14340
14341 try {
14342 return fn(a);
14343 } finally {
14344 executionContext = prevExecutionContext;
14345
14346 if (executionContext === NoContext) {
14347 // Flush the immediate callbacks that were scheduled during this batch
14348 flushSyncCallbackQueue();
14349 }
14350 }
14351}
14352function batchedEventUpdates(fn, a) {
14353 var prevExecutionContext = executionContext;
14354 executionContext |= EventContext;
14355
14356 try {
14357 return fn(a);
14358 } finally {
14359 executionContext = prevExecutionContext;
14360
14361 if (executionContext === NoContext) {
14362 // Flush the immediate callbacks that were scheduled during this batch
14363 flushSyncCallbackQueue();
14364 }
14365 }
14366}
14367function discreteUpdates(fn, a, b, c) {
14368 var prevExecutionContext = executionContext;
14369 executionContext |= DiscreteEventContext;
14370
14371 try {
14372 // Should this
14373 return runWithPriority(UserBlockingPriority, fn.bind(null, a, b, c));
14374 } finally {
14375 executionContext = prevExecutionContext;
14376
14377 if (executionContext === NoContext) {
14378 // Flush the immediate callbacks that were scheduled during this batch
14379 flushSyncCallbackQueue();
14380 }
14381 }
14382}
14383function unbatchedUpdates(fn, a) {
14384 var prevExecutionContext = executionContext;
14385 executionContext &= ~BatchedContext;
14386 executionContext |= LegacyUnbatchedContext;
14387
14388 try {
14389 return fn(a);
14390 } finally {
14391 executionContext = prevExecutionContext;
14392
14393 if (executionContext === NoContext) {
14394 // Flush the immediate callbacks that were scheduled during this batch
14395 flushSyncCallbackQueue();
14396 }
14397 }
14398}
14399function flushSync(fn, a) {
14400 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
14401 (function () {
14402 {
14403 {
14404 throw ReactError(Error("flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering."));
14405 }
14406 }
14407 })();
14408 }
14409
14410 var prevExecutionContext = executionContext;
14411 executionContext |= BatchedContext;
14412
14413 try {
14414 return runWithPriority(ImmediatePriority, fn.bind(null, a));
14415 } finally {
14416 executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
14417 // Note that this will happen even if batchedUpdates is higher up
14418 // the stack.
14419
14420 flushSyncCallbackQueue();
14421 }
14422}
14423function flushControlled(fn) {
14424 var prevExecutionContext = executionContext;
14425 executionContext |= BatchedContext;
14426
14427 try {
14428 runWithPriority(ImmediatePriority, fn);
14429 } finally {
14430 executionContext = prevExecutionContext;
14431
14432 if (executionContext === NoContext) {
14433 // Flush the immediate callbacks that were scheduled during this batch
14434 flushSyncCallbackQueue();
14435 }
14436 }
14437}
14438
14439function prepareFreshStack(root, expirationTime) {
14440 root.finishedWork = null;
14441 root.finishedExpirationTime = NoWork;
14442 var timeoutHandle = root.timeoutHandle;
14443
14444 if (timeoutHandle !== noTimeout) {
14445 // The root previous suspended and scheduled a timeout to commit a fallback
14446 // state. Now that we have additional work, cancel the timeout.
14447 root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
14448
14449 cancelTimeout(timeoutHandle);
14450 }
14451
14452 if (workInProgress !== null) {
14453 var interruptedWork = workInProgress.return;
14454
14455 while (interruptedWork !== null) {
14456 unwindInterruptedWork(interruptedWork);
14457 interruptedWork = interruptedWork.return;
14458 }
14459 }
14460
14461 workInProgressRoot = root;
14462 workInProgress = createWorkInProgress(root.current, null, expirationTime);
14463 renderExpirationTime = expirationTime;
14464 workInProgressRootExitStatus = RootIncomplete;
14465 workInProgressRootFatalError = null;
14466 workInProgressRootLatestProcessedExpirationTime = Sync;
14467 workInProgressRootLatestSuspenseTimeout = Sync;
14468 workInProgressRootCanSuspendUsingConfig = null;
14469 workInProgressRootNextUnprocessedUpdateTime = NoWork;
14470 workInProgressRootHasPendingPing = false;
14471
14472 if (enableSchedulerTracing) {
14473 spawnedWorkDuringRender = null;
14474 }
14475
14476 {
14477 ReactStrictModeWarnings.discardPendingWarnings();
14478 componentsThatTriggeredHighPriSuspend = null;
14479 }
14480}
14481
14482function handleError(root, thrownValue) {
14483 do {
14484 try {
14485 // Reset module-level state that was set during the render phase.
14486 resetContextDependencies();
14487 resetHooks();
14488
14489 if (workInProgress === null || workInProgress.return === null) {
14490 // Expected to be working on a non-root fiber. This is a fatal error
14491 // because there's no ancestor that can handle it; the root is
14492 // supposed to capture all errors that weren't caught by an error
14493 // boundary.
14494 workInProgressRootExitStatus = RootFatalErrored;
14495 workInProgressRootFatalError = thrownValue;
14496 return null;
14497 }
14498
14499 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
14500 // Record the time spent rendering before an error was thrown. This
14501 // avoids inaccurate Profiler durations in the case of a
14502 // suspended render.
14503 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
14504 }
14505
14506 throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime);
14507 workInProgress = completeUnitOfWork(workInProgress);
14508 } catch (yetAnotherThrownValue) {
14509 // Something in the return path also threw.
14510 thrownValue = yetAnotherThrownValue;
14511 continue;
14512 } // Return to the normal work loop.
14513
14514
14515 return;
14516 } while (true);
14517}
14518
14519function pushDispatcher(root) {
14520 var prevDispatcher = ReactCurrentDispatcher.current;
14521 ReactCurrentDispatcher.current = ContextOnlyDispatcher;
14522
14523 if (prevDispatcher === null) {
14524 // The React isomorphic package does not include a default dispatcher.
14525 // Instead the first renderer will lazily attach one, in order to give
14526 // nicer error messages.
14527 return ContextOnlyDispatcher;
14528 } else {
14529 return prevDispatcher;
14530 }
14531}
14532
14533function popDispatcher(prevDispatcher) {
14534 ReactCurrentDispatcher.current = prevDispatcher;
14535}
14536
14537function pushInteractions(root) {
14538 if (enableSchedulerTracing) {
14539 var prevInteractions = tracing.__interactionsRef.current;
14540 tracing.__interactionsRef.current = root.memoizedInteractions;
14541 return prevInteractions;
14542 }
14543
14544 return null;
14545}
14546
14547function popInteractions(prevInteractions) {
14548 if (enableSchedulerTracing) {
14549 tracing.__interactionsRef.current = prevInteractions;
14550 }
14551}
14552
14553function markCommitTimeOfFallback() {
14554 globalMostRecentFallbackTime = now$1();
14555}
14556function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
14557 if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) {
14558 workInProgressRootLatestProcessedExpirationTime = expirationTime;
14559 }
14560
14561 if (suspenseConfig !== null) {
14562 if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) {
14563 workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad.
14564
14565 workInProgressRootCanSuspendUsingConfig = suspenseConfig;
14566 }
14567 }
14568}
14569function markUnprocessedUpdateTime(expirationTime) {
14570 if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
14571 workInProgressRootNextUnprocessedUpdateTime = expirationTime;
14572 }
14573}
14574function renderDidSuspend() {
14575 if (workInProgressRootExitStatus === RootIncomplete) {
14576 workInProgressRootExitStatus = RootSuspended;
14577 }
14578}
14579function renderDidSuspendDelayIfPossible() {
14580 if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
14581 workInProgressRootExitStatus = RootSuspendedWithDelay;
14582 } // Check if there's a lower priority update somewhere else in the tree.
14583
14584
14585 if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) {
14586 // Mark the current render as suspended, and then mark that there's a
14587 // pending update.
14588 // TODO: This should immediately interrupt the current render, instead
14589 // of waiting until the next time we yield.
14590 markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime);
14591 markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime);
14592 }
14593}
14594function renderDidError() {
14595 if (workInProgressRootExitStatus !== RootCompleted) {
14596 workInProgressRootExitStatus = RootErrored;
14597 }
14598} // Called during render to determine if anything has suspended.
14599// Returns false if we're not sure.
14600
14601function renderHasNotSuspendedYet() {
14602 // If something errored or completed, we can't really be sure,
14603 // so those are false.
14604 return workInProgressRootExitStatus === RootIncomplete;
14605}
14606
14607function inferTimeFromExpirationTime(expirationTime) {
14608 // We don't know exactly when the update was scheduled, but we can infer an
14609 // approximate start time from the expiration time.
14610 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
14611 return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
14612}
14613
14614function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
14615 // We don't know exactly when the update was scheduled, but we can infer an
14616 // approximate start time from the expiration time by subtracting the timeout
14617 // that was added to the event time.
14618 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
14619 return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
14620} // The work loop is an extremely hot path. Tell Closure not to inline it.
14621
14622/** @noinline */
14623
14624
14625function workLoopSync() {
14626 // Already timed out, so perform work without checking if we need to yield.
14627 while (workInProgress !== null) {
14628 workInProgress = performUnitOfWork(workInProgress);
14629 }
14630}
14631/** @noinline */
14632
14633
14634function workLoopConcurrent() {
14635 // Perform work until Scheduler asks us to yield
14636 while (workInProgress !== null && !shouldYield()) {
14637 workInProgress = performUnitOfWork(workInProgress);
14638 }
14639}
14640
14641function performUnitOfWork(unitOfWork) {
14642 // The current, flushed, state of this fiber is the alternate. Ideally
14643 // nothing should rely on this, but relying on it here means that we don't
14644 // need an additional field on the work in progress.
14645 var current$$1 = unitOfWork.alternate;
14646 startWorkTimer(unitOfWork);
14647 setCurrentFiber(unitOfWork);
14648 var next;
14649
14650 if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
14651 startProfilerTimer(unitOfWork);
14652 next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
14653 stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
14654 } else {
14655 next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
14656 }
14657
14658 resetCurrentFiber();
14659 unitOfWork.memoizedProps = unitOfWork.pendingProps;
14660
14661 if (next === null) {
14662 // If this doesn't spawn new work, complete the current work.
14663 next = completeUnitOfWork(unitOfWork);
14664 }
14665
14666 ReactCurrentOwner$1.current = null;
14667 return next;
14668}
14669
14670function completeUnitOfWork(unitOfWork) {
14671 // Attempt to complete the current unit of work, then move to the next
14672 // sibling. If there are no more siblings, return to the parent fiber.
14673 workInProgress = unitOfWork;
14674
14675 do {
14676 // The current, flushed, state of this fiber is the alternate. Ideally
14677 // nothing should rely on this, but relying on it here means that we don't
14678 // need an additional field on the work in progress.
14679 var current$$1 = workInProgress.alternate;
14680 var returnFiber = workInProgress.return; // Check if the work completed or if something threw.
14681
14682 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
14683 setCurrentFiber(workInProgress);
14684 var next = void 0;
14685
14686 if (!enableProfilerTimer || (workInProgress.mode & ProfileMode) === NoMode) {
14687 next = completeWork(current$$1, workInProgress, renderExpirationTime);
14688 } else {
14689 startProfilerTimer(workInProgress);
14690 next = completeWork(current$$1, workInProgress, renderExpirationTime); // Update render duration assuming we didn't error.
14691
14692 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
14693 }
14694
14695 stopWorkTimer(workInProgress);
14696 resetCurrentFiber();
14697 resetChildExpirationTime(workInProgress);
14698
14699 if (next !== null) {
14700 // Completing this fiber spawned new work. Work on that next.
14701 return next;
14702 }
14703
14704 if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
14705 (returnFiber.effectTag & Incomplete) === NoEffect) {
14706 // Append all the effects of the subtree and this fiber onto the effect
14707 // list of the parent. The completion order of the children affects the
14708 // side-effect order.
14709 if (returnFiber.firstEffect === null) {
14710 returnFiber.firstEffect = workInProgress.firstEffect;
14711 }
14712
14713 if (workInProgress.lastEffect !== null) {
14714 if (returnFiber.lastEffect !== null) {
14715 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
14716 }
14717
14718 returnFiber.lastEffect = workInProgress.lastEffect;
14719 } // If this fiber had side-effects, we append it AFTER the children's
14720 // side-effects. We can perform certain side-effects earlier if needed,
14721 // by doing multiple passes over the effect list. We don't want to
14722 // schedule our own side-effect on our own list because if end up
14723 // reusing children we'll schedule this effect onto itself since we're
14724 // at the end.
14725
14726
14727 var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
14728 // list. PerformedWork effect is read by React DevTools but shouldn't be
14729 // committed.
14730
14731 if (effectTag > PerformedWork) {
14732 if (returnFiber.lastEffect !== null) {
14733 returnFiber.lastEffect.nextEffect = workInProgress;
14734 } else {
14735 returnFiber.firstEffect = workInProgress;
14736 }
14737
14738 returnFiber.lastEffect = workInProgress;
14739 }
14740 }
14741 } else {
14742 // This fiber did not complete because something threw. Pop values off
14743 // the stack without entering the complete phase. If this is a boundary,
14744 // capture values if possible.
14745 var _next = unwindWork(workInProgress, renderExpirationTime); // Because this fiber did not complete, don't reset its expiration time.
14746
14747
14748 if (enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode) {
14749 // Record the render duration for the fiber that errored.
14750 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing.
14751
14752 var actualDuration = workInProgress.actualDuration;
14753 var child = workInProgress.child;
14754
14755 while (child !== null) {
14756 actualDuration += child.actualDuration;
14757 child = child.sibling;
14758 }
14759
14760 workInProgress.actualDuration = actualDuration;
14761 }
14762
14763 if (_next !== null) {
14764 // If completing this work spawned new work, do that next. We'll come
14765 // back here again.
14766 // Since we're restarting, remove anything that is not a host effect
14767 // from the effect tag.
14768 // TODO: The name stopFailedWorkTimer is misleading because Suspense
14769 // also captures and restarts.
14770 stopFailedWorkTimer(workInProgress);
14771 _next.effectTag &= HostEffectMask;
14772 return _next;
14773 }
14774
14775 stopWorkTimer(workInProgress);
14776
14777 if (returnFiber !== null) {
14778 // Mark the parent fiber as incomplete and clear its effect list.
14779 returnFiber.firstEffect = returnFiber.lastEffect = null;
14780 returnFiber.effectTag |= Incomplete;
14781 }
14782 }
14783
14784 var siblingFiber = workInProgress.sibling;
14785
14786 if (siblingFiber !== null) {
14787 // If there is more work to do in this returnFiber, do that next.
14788 return siblingFiber;
14789 } // Otherwise, return to the parent
14790
14791
14792 workInProgress = returnFiber;
14793 } while (workInProgress !== null); // We've reached the root.
14794
14795
14796 if (workInProgressRootExitStatus === RootIncomplete) {
14797 workInProgressRootExitStatus = RootCompleted;
14798 }
14799
14800 return null;
14801}
14802
14803function getRemainingExpirationTime(fiber) {
14804 var updateExpirationTime = fiber.expirationTime;
14805 var childExpirationTime = fiber.childExpirationTime;
14806 return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime;
14807}
14808
14809function resetChildExpirationTime(completedWork) {
14810 if (renderExpirationTime !== Never && completedWork.childExpirationTime === Never) {
14811 // The children of this component are hidden. Don't bubble their
14812 // expiration times.
14813 return;
14814 }
14815
14816 var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time.
14817
14818 if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) {
14819 // In profiling mode, resetChildExpirationTime is also used to reset
14820 // profiler durations.
14821 var actualDuration = completedWork.actualDuration;
14822 var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
14823 // only be updated if work is done on the fiber (i.e. it doesn't bailout).
14824 // When work is done, it should bubble to the parent's actualDuration. If
14825 // the fiber has not been cloned though, (meaning no work was done), then
14826 // this value will reflect the amount of time spent working on a previous
14827 // render. In that case it should not bubble. We determine whether it was
14828 // cloned by comparing the child pointer.
14829
14830 var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
14831 var child = completedWork.child;
14832
14833 while (child !== null) {
14834 var childUpdateExpirationTime = child.expirationTime;
14835 var childChildExpirationTime = child.childExpirationTime;
14836
14837 if (childUpdateExpirationTime > newChildExpirationTime) {
14838 newChildExpirationTime = childUpdateExpirationTime;
14839 }
14840
14841 if (childChildExpirationTime > newChildExpirationTime) {
14842 newChildExpirationTime = childChildExpirationTime;
14843 }
14844
14845 if (shouldBubbleActualDurations) {
14846 actualDuration += child.actualDuration;
14847 }
14848
14849 treeBaseDuration += child.treeBaseDuration;
14850 child = child.sibling;
14851 }
14852
14853 completedWork.actualDuration = actualDuration;
14854 completedWork.treeBaseDuration = treeBaseDuration;
14855 } else {
14856 var _child = completedWork.child;
14857
14858 while (_child !== null) {
14859 var _childUpdateExpirationTime = _child.expirationTime;
14860 var _childChildExpirationTime = _child.childExpirationTime;
14861
14862 if (_childUpdateExpirationTime > newChildExpirationTime) {
14863 newChildExpirationTime = _childUpdateExpirationTime;
14864 }
14865
14866 if (_childChildExpirationTime > newChildExpirationTime) {
14867 newChildExpirationTime = _childChildExpirationTime;
14868 }
14869
14870 _child = _child.sibling;
14871 }
14872 }
14873
14874 completedWork.childExpirationTime = newChildExpirationTime;
14875}
14876
14877function commitRoot(root) {
14878 var renderPriorityLevel = getCurrentPriorityLevel();
14879 runWithPriority(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
14880 return null;
14881}
14882
14883function commitRootImpl(root, renderPriorityLevel) {
14884 flushPassiveEffects();
14885 flushRenderPhaseStrictModeWarningsInDEV();
14886
14887 (function () {
14888 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
14889 {
14890 throw ReactError(Error("Should not already be working."));
14891 }
14892 }
14893 })();
14894
14895 var finishedWork = root.finishedWork;
14896 var expirationTime = root.finishedExpirationTime;
14897
14898 if (finishedWork === null) {
14899 return null;
14900 }
14901
14902 root.finishedWork = null;
14903 root.finishedExpirationTime = NoWork;
14904
14905 (function () {
14906 if (!(finishedWork !== root.current)) {
14907 {
14908 throw ReactError(Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue."));
14909 }
14910 }
14911 })(); // commitRoot never returns a continuation; it always finishes synchronously.
14912 // So we can clear these now to allow a new callback to be scheduled.
14913
14914
14915 root.callbackNode = null;
14916 root.callbackExpirationTime = NoWork;
14917 root.callbackPriority = NoPriority;
14918 root.nextKnownPendingLevel = NoWork;
14919 startCommitTimer(); // Update the first and last pending times on this root. The new first
14920 // pending time is whatever is left on the root fiber.
14921
14922 var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork);
14923 markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit);
14924
14925 if (root === workInProgressRoot) {
14926 // We can reset these now that they are finished.
14927 workInProgressRoot = null;
14928 workInProgress = null;
14929 renderExpirationTime = NoWork;
14930 } else {} // This indicates that the last root we worked on is not the same one that
14931 // we're committing now. This most commonly happens when a suspended root
14932 // times out.
14933 // Get the list of effects.
14934
14935
14936 var firstEffect;
14937
14938 if (finishedWork.effectTag > PerformedWork) {
14939 // A fiber's effect list consists only of its children, not itself. So if
14940 // the root has an effect, we need to add it to the end of the list. The
14941 // resulting list is the set that would belong to the root's parent, if it
14942 // had one; that is, all the effects in the tree including the root.
14943 if (finishedWork.lastEffect !== null) {
14944 finishedWork.lastEffect.nextEffect = finishedWork;
14945 firstEffect = finishedWork.firstEffect;
14946 } else {
14947 firstEffect = finishedWork;
14948 }
14949 } else {
14950 // There is no effect on the root.
14951 firstEffect = finishedWork.firstEffect;
14952 }
14953
14954 if (firstEffect !== null) {
14955 var prevExecutionContext = executionContext;
14956 executionContext |= CommitContext;
14957 var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
14958
14959 ReactCurrentOwner$1.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
14960 // of the effect list for each phase: all mutation effects come before all
14961 // layout effects, and so on.
14962 // The first phase a "before mutation" phase. We use this phase to read the
14963 // state of the host tree right before we mutate it. This is where
14964 // getSnapshotBeforeUpdate is called.
14965
14966 startCommitSnapshotEffectsTimer();
14967 prepareForCommit(root.containerInfo);
14968 nextEffect = firstEffect;
14969
14970 do {
14971 {
14972 invokeGuardedCallback(null, commitBeforeMutationEffects, null);
14973
14974 if (hasCaughtError()) {
14975 (function () {
14976 if (!(nextEffect !== null)) {
14977 {
14978 throw ReactError(Error("Should be working on an effect."));
14979 }
14980 }
14981 })();
14982
14983 var error = clearCaughtError();
14984 captureCommitPhaseError(nextEffect, error);
14985 nextEffect = nextEffect.nextEffect;
14986 }
14987 }
14988 } while (nextEffect !== null);
14989
14990 stopCommitSnapshotEffectsTimer();
14991
14992 if (enableProfilerTimer) {
14993 // Mark the current commit time to be shared by all Profilers in this
14994 // batch. This enables them to be grouped later.
14995 recordCommitTime();
14996 } // The next phase is the mutation phase, where we mutate the host tree.
14997
14998
14999 startCommitHostEffectsTimer();
15000 nextEffect = firstEffect;
15001
15002 do {
15003 {
15004 invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
15005
15006 if (hasCaughtError()) {
15007 (function () {
15008 if (!(nextEffect !== null)) {
15009 {
15010 throw ReactError(Error("Should be working on an effect."));
15011 }
15012 }
15013 })();
15014
15015 var _error = clearCaughtError();
15016
15017 captureCommitPhaseError(nextEffect, _error);
15018 nextEffect = nextEffect.nextEffect;
15019 }
15020 }
15021 } while (nextEffect !== null);
15022
15023 stopCommitHostEffectsTimer();
15024 resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
15025 // the mutation phase, so that the previous tree is still current during
15026 // componentWillUnmount, but before the layout phase, so that the finished
15027 // work is current during componentDidMount/Update.
15028
15029 root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
15030 // the host tree after it's been mutated. The idiomatic use case for this is
15031 // layout, but class component lifecycles also fire here for legacy reasons.
15032
15033 startCommitLifeCyclesTimer();
15034 nextEffect = firstEffect;
15035
15036 do {
15037 {
15038 invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
15039
15040 if (hasCaughtError()) {
15041 (function () {
15042 if (!(nextEffect !== null)) {
15043 {
15044 throw ReactError(Error("Should be working on an effect."));
15045 }
15046 }
15047 })();
15048
15049 var _error2 = clearCaughtError();
15050
15051 captureCommitPhaseError(nextEffect, _error2);
15052 nextEffect = nextEffect.nextEffect;
15053 }
15054 }
15055 } while (nextEffect !== null);
15056
15057 stopCommitLifeCyclesTimer();
15058 nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
15059 // opportunity to paint.
15060
15061 requestPaint();
15062
15063 if (enableSchedulerTracing) {
15064 popInteractions(prevInteractions);
15065 }
15066
15067 executionContext = prevExecutionContext;
15068 } else {
15069 // No effects.
15070 root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
15071 // no effects.
15072 // TODO: Maybe there's a better way to report this.
15073
15074 startCommitSnapshotEffectsTimer();
15075 stopCommitSnapshotEffectsTimer();
15076
15077 if (enableProfilerTimer) {
15078 recordCommitTime();
15079 }
15080
15081 startCommitHostEffectsTimer();
15082 stopCommitHostEffectsTimer();
15083 startCommitLifeCyclesTimer();
15084 stopCommitLifeCyclesTimer();
15085 }
15086
15087 stopCommitTimer();
15088 var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
15089
15090 if (rootDoesHavePassiveEffects) {
15091 // This commit has passive effects. Stash a reference to them. But don't
15092 // schedule a callback until after flushing layout work.
15093 rootDoesHavePassiveEffects = false;
15094 rootWithPendingPassiveEffects = root;
15095 pendingPassiveEffectsExpirationTime = expirationTime;
15096 pendingPassiveEffectsRenderPriority = renderPriorityLevel;
15097 } else {
15098 // We are done with the effect chain at this point so let's clear the
15099 // nextEffect pointers to assist with GC. If we have passive effects, we'll
15100 // clear this in flushPassiveEffects.
15101 nextEffect = firstEffect;
15102
15103 while (nextEffect !== null) {
15104 var nextNextEffect = nextEffect.nextEffect;
15105 nextEffect.nextEffect = null;
15106 nextEffect = nextNextEffect;
15107 }
15108 } // Check if there's remaining work on this root
15109
15110
15111 var remainingExpirationTime = root.firstPendingTime;
15112
15113 if (remainingExpirationTime !== NoWork) {
15114 if (enableSchedulerTracing) {
15115 if (spawnedWorkDuringRender !== null) {
15116 var expirationTimes = spawnedWorkDuringRender;
15117 spawnedWorkDuringRender = null;
15118
15119 for (var i = 0; i < expirationTimes.length; i++) {
15120 scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
15121 }
15122 }
15123
15124 schedulePendingInteractions(root, remainingExpirationTime);
15125 }
15126 } else {
15127 // If there's no remaining work, we can clear the set of already failed
15128 // error boundaries.
15129 legacyErrorBoundariesThatAlreadyFailed = null;
15130 }
15131
15132 if (enableSchedulerTracing) {
15133 if (!rootDidHavePassiveEffects) {
15134 // If there are no passive effects, then we can complete the pending interactions.
15135 // Otherwise, we'll wait until after the passive effects are flushed.
15136 // Wait to do this until after remaining work has been scheduled,
15137 // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
15138 finishPendingInteractions(root, expirationTime);
15139 }
15140 }
15141
15142 if (remainingExpirationTime === Sync) {
15143 // Count the number of times the root synchronously re-renders without
15144 // finishing. If there are too many, it indicates an infinite update loop.
15145 if (root === rootWithNestedUpdates) {
15146 nestedUpdateCount++;
15147 } else {
15148 nestedUpdateCount = 0;
15149 rootWithNestedUpdates = root;
15150 }
15151 } else {
15152 nestedUpdateCount = 0;
15153 }
15154
15155 onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any
15156 // additional work on this root is scheduled.
15157
15158 ensureRootIsScheduled(root);
15159
15160 if (hasUncaughtError) {
15161 hasUncaughtError = false;
15162 var _error3 = firstUncaughtError;
15163 firstUncaughtError = null;
15164 throw _error3;
15165 }
15166
15167 if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
15168 // This is a legacy edge case. We just committed the initial mount of
15169 // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
15170 // synchronously, but layout updates should be deferred until the end
15171 // of the batch.
15172 return null;
15173 } // If layout work was scheduled, flush it now.
15174
15175
15176 flushSyncCallbackQueue();
15177 return null;
15178}
15179
15180function commitBeforeMutationEffects() {
15181 while (nextEffect !== null) {
15182 var effectTag = nextEffect.effectTag;
15183
15184 if ((effectTag & Snapshot) !== NoEffect) {
15185 setCurrentFiber(nextEffect);
15186 recordEffect();
15187 var current$$1 = nextEffect.alternate;
15188 commitBeforeMutationLifeCycles(current$$1, nextEffect);
15189 resetCurrentFiber();
15190 }
15191
15192 if ((effectTag & Passive) !== NoEffect) {
15193 // If there are passive effects, schedule a callback to flush at
15194 // the earliest opportunity.
15195 if (!rootDoesHavePassiveEffects) {
15196 rootDoesHavePassiveEffects = true;
15197 scheduleCallback(NormalPriority, function () {
15198 flushPassiveEffects();
15199 return null;
15200 });
15201 }
15202 }
15203
15204 nextEffect = nextEffect.nextEffect;
15205 }
15206}
15207
15208function commitMutationEffects(root, renderPriorityLevel) {
15209 // TODO: Should probably move the bulk of this function to commitWork.
15210 while (nextEffect !== null) {
15211 setCurrentFiber(nextEffect);
15212 var effectTag = nextEffect.effectTag;
15213
15214 if (effectTag & ContentReset) {
15215 commitResetTextContent(nextEffect);
15216 }
15217
15218 if (effectTag & Ref) {
15219 var current$$1 = nextEffect.alternate;
15220
15221 if (current$$1 !== null) {
15222 commitDetachRef(current$$1);
15223 }
15224 } // The following switch statement is only concerned about placement,
15225 // updates, and deletions. To avoid needing to add a case for every possible
15226 // bitmap value, we remove the secondary effects from the effect tag and
15227 // switch on that value.
15228
15229
15230 var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating);
15231
15232 switch (primaryEffectTag) {
15233 case Placement:
15234 {
15235 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
15236 // inserted, before any life-cycles like componentDidMount gets called.
15237 // TODO: findDOMNode doesn't rely on this any more but isMounted does
15238 // and isMounted is deprecated anyway so we should be able to kill this.
15239
15240 nextEffect.effectTag &= ~Placement;
15241 break;
15242 }
15243
15244 case PlacementAndUpdate:
15245 {
15246 // Placement
15247 commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
15248 // inserted, before any life-cycles like componentDidMount gets called.
15249
15250 nextEffect.effectTag &= ~Placement; // Update
15251
15252 var _current = nextEffect.alternate;
15253 commitWork(_current, nextEffect);
15254 break;
15255 }
15256
15257 case Hydrating:
15258 {
15259 nextEffect.effectTag &= ~Hydrating;
15260 break;
15261 }
15262
15263 case HydratingAndUpdate:
15264 {
15265 nextEffect.effectTag &= ~Hydrating; // Update
15266
15267 var _current2 = nextEffect.alternate;
15268 commitWork(_current2, nextEffect);
15269 break;
15270 }
15271
15272 case Update:
15273 {
15274 var _current3 = nextEffect.alternate;
15275 commitWork(_current3, nextEffect);
15276 break;
15277 }
15278
15279 case Deletion:
15280 {
15281 commitDeletion(root, nextEffect, renderPriorityLevel);
15282 break;
15283 }
15284 } // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
15285
15286
15287 recordEffect();
15288 resetCurrentFiber();
15289 nextEffect = nextEffect.nextEffect;
15290 }
15291}
15292
15293function commitLayoutEffects(root, committedExpirationTime) {
15294 // TODO: Should probably move the bulk of this function to commitWork.
15295 while (nextEffect !== null) {
15296 setCurrentFiber(nextEffect);
15297 var effectTag = nextEffect.effectTag;
15298
15299 if (effectTag & (Update | Callback)) {
15300 recordEffect();
15301 var current$$1 = nextEffect.alternate;
15302 commitLifeCycles(root, current$$1, nextEffect, committedExpirationTime);
15303 }
15304
15305 if (effectTag & Ref) {
15306 recordEffect();
15307 commitAttachRef(nextEffect);
15308 }
15309
15310 resetCurrentFiber();
15311 nextEffect = nextEffect.nextEffect;
15312 }
15313}
15314
15315function flushPassiveEffects() {
15316 if (pendingPassiveEffectsRenderPriority !== NoPriority) {
15317 var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority;
15318 pendingPassiveEffectsRenderPriority = NoPriority;
15319 return runWithPriority(priorityLevel, flushPassiveEffectsImpl);
15320 }
15321}
15322
15323function flushPassiveEffectsImpl() {
15324 if (rootWithPendingPassiveEffects === null) {
15325 return false;
15326 }
15327
15328 var root = rootWithPendingPassiveEffects;
15329 var expirationTime = pendingPassiveEffectsExpirationTime;
15330 rootWithPendingPassiveEffects = null;
15331 pendingPassiveEffectsExpirationTime = NoWork;
15332
15333 (function () {
15334 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
15335 {
15336 throw ReactError(Error("Cannot flush passive effects while already rendering."));
15337 }
15338 }
15339 })();
15340
15341 var prevExecutionContext = executionContext;
15342 executionContext |= CommitContext;
15343 var prevInteractions = pushInteractions(root); // Note: This currently assumes there are no passive effects on the root
15344 // fiber, because the root is not part of its own effect list. This could
15345 // change in the future.
15346
15347 var effect = root.current.firstEffect;
15348
15349 while (effect !== null) {
15350 {
15351 setCurrentFiber(effect);
15352 invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
15353
15354 if (hasCaughtError()) {
15355 (function () {
15356 if (!(effect !== null)) {
15357 {
15358 throw ReactError(Error("Should be working on an effect."));
15359 }
15360 }
15361 })();
15362
15363 var error = clearCaughtError();
15364 captureCommitPhaseError(effect, error);
15365 }
15366
15367 resetCurrentFiber();
15368 }
15369
15370 var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC
15371
15372 effect.nextEffect = null;
15373 effect = nextNextEffect;
15374 }
15375
15376 if (enableSchedulerTracing) {
15377 popInteractions(prevInteractions);
15378 finishPendingInteractions(root, expirationTime);
15379 }
15380
15381 executionContext = prevExecutionContext;
15382 flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
15383 // exceeds the limit, we'll fire a warning.
15384
15385 nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
15386 return true;
15387}
15388
15389function isAlreadyFailedLegacyErrorBoundary(instance) {
15390 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
15391}
15392function markLegacyErrorBoundaryAsFailed(instance) {
15393 if (legacyErrorBoundariesThatAlreadyFailed === null) {
15394 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
15395 } else {
15396 legacyErrorBoundariesThatAlreadyFailed.add(instance);
15397 }
15398}
15399
15400function prepareToThrowUncaughtError(error) {
15401 if (!hasUncaughtError) {
15402 hasUncaughtError = true;
15403 firstUncaughtError = error;
15404 }
15405}
15406
15407var onUncaughtError = prepareToThrowUncaughtError;
15408
15409function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
15410 var errorInfo = createCapturedValue(error, sourceFiber);
15411 var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
15412 enqueueUpdate(rootFiber, update);
15413 var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
15414
15415 if (root !== null) {
15416 ensureRootIsScheduled(root);
15417 schedulePendingInteractions(root, Sync);
15418 }
15419}
15420
15421function captureCommitPhaseError(sourceFiber, error) {
15422 if (sourceFiber.tag === HostRoot) {
15423 // Error was thrown at the root. There is no parent, so the root
15424 // itself should capture it.
15425 captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
15426 return;
15427 }
15428
15429 var fiber = sourceFiber.return;
15430
15431 while (fiber !== null) {
15432 if (fiber.tag === HostRoot) {
15433 captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
15434 return;
15435 } else if (fiber.tag === ClassComponent) {
15436 var ctor = fiber.type;
15437 var instance = fiber.stateNode;
15438
15439 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
15440 var errorInfo = createCapturedValue(error, sourceFiber);
15441 var update = createClassErrorUpdate(fiber, errorInfo, // TODO: This is always sync
15442 Sync);
15443 enqueueUpdate(fiber, update);
15444 var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
15445
15446 if (root !== null) {
15447 ensureRootIsScheduled(root);
15448 schedulePendingInteractions(root, Sync);
15449 }
15450
15451 return;
15452 }
15453 }
15454
15455 fiber = fiber.return;
15456 }
15457}
15458function pingSuspendedRoot(root, thenable, suspendedTime) {
15459 var pingCache = root.pingCache;
15460
15461 if (pingCache !== null) {
15462 // The thenable resolved, so we no longer need to memoize, because it will
15463 // never be thrown again.
15464 pingCache.delete(thenable);
15465 }
15466
15467 if (workInProgressRoot === root && renderExpirationTime === suspendedTime) {
15468 // Received a ping at the same priority level at which we're currently
15469 // rendering. We might want to restart this render. This should mirror
15470 // the logic of whether or not a root suspends once it completes.
15471 // TODO: If we're rendering sync either due to Sync, Batched or expired,
15472 // we should probably never restart.
15473 // If we're suspended with delay, we'll always suspend so we can always
15474 // restart. If we're suspended without any updates, it might be a retry.
15475 // If it's early in the retry we can restart. We can't know for sure
15476 // whether we'll eventually process an update during this render pass,
15477 // but it's somewhat unlikely that we get to a ping before that, since
15478 // getting to the root most update is usually very fast.
15479 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now$1() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
15480 // Restart from the root. Don't need to schedule a ping because
15481 // we're already working on this tree.
15482 prepareFreshStack(root, renderExpirationTime);
15483 } else {
15484 // Even though we can't restart right now, we might get an
15485 // opportunity later. So we mark this render as having a ping.
15486 workInProgressRootHasPendingPing = true;
15487 }
15488
15489 return;
15490 }
15491
15492 if (!isRootSuspendedAtTime(root, suspendedTime)) {
15493 // The root is no longer suspended at this time.
15494 return;
15495 }
15496
15497 var lastPingedTime = root.lastPingedTime;
15498
15499 if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
15500 // There's already a lower priority ping scheduled.
15501 return;
15502 } // Mark the time at which this ping was scheduled.
15503
15504
15505 root.lastPingedTime = suspendedTime;
15506
15507 if (root.finishedExpirationTime === suspendedTime) {
15508 // If there's a pending fallback waiting to commit, throw it away.
15509 root.finishedExpirationTime = NoWork;
15510 root.finishedWork = null;
15511 }
15512
15513 ensureRootIsScheduled(root);
15514 schedulePendingInteractions(root, suspendedTime);
15515}
15516
15517function retryTimedOutBoundary(boundaryFiber, retryTime) {
15518 // The boundary fiber (a Suspense component or SuspenseList component)
15519 // previously was rendered in its fallback state. One of the promises that
15520 // suspended it has resolved, which means at least part of the tree was
15521 // likely unblocked. Try rendering again, at a new expiration time.
15522 if (retryTime === Never) {
15523 var suspenseConfig = null; // Retries don't carry over the already committed update.
15524
15525 var currentTime = requestCurrentTime();
15526 retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
15527 } // TODO: Special case idle priority?
15528
15529
15530 var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
15531
15532 if (root !== null) {
15533 ensureRootIsScheduled(root);
15534 schedulePendingInteractions(root, retryTime);
15535 }
15536}
15537
15538function retryDehydratedSuspenseBoundary(boundaryFiber) {
15539 var suspenseState = boundaryFiber.memoizedState;
15540 var retryTime = Never;
15541
15542 if (suspenseState !== null) {
15543 retryTime = suspenseState.retryTime;
15544 }
15545
15546 retryTimedOutBoundary(boundaryFiber, retryTime);
15547}
15548function resolveRetryThenable(boundaryFiber, thenable) {
15549 var retryTime = Never; // Default
15550
15551 var retryCache;
15552
15553 if (enableSuspenseServerRenderer) {
15554 switch (boundaryFiber.tag) {
15555 case SuspenseComponent:
15556 retryCache = boundaryFiber.stateNode;
15557 var suspenseState = boundaryFiber.memoizedState;
15558
15559 if (suspenseState !== null) {
15560 retryTime = suspenseState.retryTime;
15561 }
15562
15563 break;
15564
15565 case SuspenseListComponent:
15566 retryCache = boundaryFiber.stateNode;
15567 break;
15568
15569 default:
15570 (function () {
15571 {
15572 {
15573 throw ReactError(Error("Pinged unknown suspense boundary type. This is probably a bug in React."));
15574 }
15575 }
15576 })();
15577
15578 }
15579 } else {
15580 retryCache = boundaryFiber.stateNode;
15581 }
15582
15583 if (retryCache !== null) {
15584 // The thenable resolved, so we no longer need to memoize, because it will
15585 // never be thrown again.
15586 retryCache.delete(thenable);
15587 }
15588
15589 retryTimedOutBoundary(boundaryFiber, retryTime);
15590} // Computes the next Just Noticeable Difference (JND) boundary.
15591// The theory is that a person can't tell the difference between small differences in time.
15592// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
15593// difference in the experience. However, waiting for longer might mean that we can avoid
15594// showing an intermediate loading state. The longer we have already waited, the harder it
15595// is to tell small differences in time. Therefore, the longer we've already waited,
15596// the longer we can wait additionally. At some point we have to give up though.
15597// We pick a train model where the next boundary commits at a consistent schedule.
15598// These particular numbers are vague estimates. We expect to adjust them based on research.
15599
15600function jnd(timeElapsed) {
15601 return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
15602}
15603
15604function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
15605 var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
15606
15607 if (busyMinDurationMs <= 0) {
15608 return 0;
15609 }
15610
15611 var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
15612
15613 var currentTimeMs = now$1();
15614 var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
15615 var timeElapsed = currentTimeMs - eventTimeMs;
15616
15617 if (timeElapsed <= busyDelayMs) {
15618 // If we haven't yet waited longer than the initial delay, we don't
15619 // have to wait any additional time.
15620 return 0;
15621 }
15622
15623 var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
15624
15625 return msUntilTimeout;
15626}
15627
15628function checkForNestedUpdates() {
15629 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
15630 nestedUpdateCount = 0;
15631 rootWithNestedUpdates = null;
15632
15633 (function () {
15634 {
15635 {
15636 throw ReactError(Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."));
15637 }
15638 }
15639 })();
15640 }
15641
15642 {
15643 if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
15644 nestedPassiveUpdateCount = 0;
15645 warning$1(false, 'Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.');
15646 }
15647 }
15648}
15649
15650function flushRenderPhaseStrictModeWarningsInDEV() {
15651 {
15652 ReactStrictModeWarnings.flushLegacyContextWarning();
15653
15654 if (warnAboutDeprecatedLifecycles) {
15655 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
15656 }
15657 }
15658}
15659
15660function stopFinishedWorkLoopTimer() {
15661 var didCompleteRoot = true;
15662 stopWorkLoopTimer(interruptedBy, didCompleteRoot);
15663 interruptedBy = null;
15664}
15665
15666function stopInterruptedWorkLoopTimer() {
15667 // TODO: Track which fiber caused the interruption.
15668 var didCompleteRoot = false;
15669 stopWorkLoopTimer(interruptedBy, didCompleteRoot);
15670 interruptedBy = null;
15671}
15672
15673function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
15674 if (enableUserTimingAPI && workInProgressRoot !== null && updateExpirationTime > renderExpirationTime) {
15675 interruptedBy = fiberThatReceivedUpdate;
15676 }
15677}
15678
15679var didWarnStateUpdateForUnmountedComponent = null;
15680
15681function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
15682 {
15683 var tag = fiber.tag;
15684
15685 if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
15686 // Only warn for user-defined components, not internal ones like Suspense.
15687 return;
15688 } // We show the whole stack but dedupe on the top component's name because
15689 // the problematic code almost always lies inside that component.
15690
15691
15692 var componentName = getComponentName(fiber.type) || 'ReactComponent';
15693
15694 if (didWarnStateUpdateForUnmountedComponent !== null) {
15695 if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
15696 return;
15697 }
15698
15699 didWarnStateUpdateForUnmountedComponent.add(componentName);
15700 } else {
15701 didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
15702 }
15703
15704 warningWithoutStack$1(false, "Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
15705 }
15706}
15707
15708var beginWork$$1;
15709
15710if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
15711 var dummyFiber = null;
15712
15713 beginWork$$1 = function (current$$1, unitOfWork, expirationTime) {
15714 // If a component throws an error, we replay it again in a synchronously
15715 // dispatched event, so that the debugger will treat it as an uncaught
15716 // error See ReactErrorUtils for more information.
15717 // Before entering the begin phase, copy the work-in-progress onto a dummy
15718 // fiber. If beginWork throws, we'll use this to reset the state.
15719 var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
15720
15721 try {
15722 return beginWork$1(current$$1, unitOfWork, expirationTime);
15723 } catch (originalError) {
15724 if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
15725 // Don't replay promises. Treat everything else like an error.
15726 throw originalError;
15727 } // Keep this code in sync with renderRoot; any changes here must have
15728 // corresponding changes there.
15729
15730
15731 resetContextDependencies();
15732 resetHooks(); // Unwind the failed stack frame
15733
15734 unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
15735
15736 assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
15737
15738 if (enableProfilerTimer && unitOfWork.mode & ProfileMode) {
15739 // Reset the profiler timer.
15740 startProfilerTimer(unitOfWork);
15741 } // Run beginWork again.
15742
15743
15744 invokeGuardedCallback(null, beginWork$1, null, current$$1, unitOfWork, expirationTime);
15745
15746 if (hasCaughtError()) {
15747 var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
15748 // Rethrow this error instead of the original one.
15749
15750 throw replayError;
15751 } else {
15752 // This branch is reachable if the render phase is impure.
15753 throw originalError;
15754 }
15755 }
15756 };
15757} else {
15758 beginWork$$1 = beginWork$1;
15759}
15760
15761var didWarnAboutUpdateInRender = false;
15762var didWarnAboutUpdateInGetChildContext = false;
15763
15764function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
15765 {
15766 if (fiber.tag === ClassComponent) {
15767 switch (phase) {
15768 case 'getChildContext':
15769 if (didWarnAboutUpdateInGetChildContext) {
15770 return;
15771 }
15772
15773 warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
15774 didWarnAboutUpdateInGetChildContext = true;
15775 break;
15776
15777 case 'render':
15778 if (didWarnAboutUpdateInRender) {
15779 return;
15780 }
15781
15782 warningWithoutStack$1(false, 'Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure function of ' + 'props and state.');
15783 didWarnAboutUpdateInRender = true;
15784 break;
15785 }
15786 }
15787 }
15788} // a 'shared' variable that changes when act() opens/closes in tests.
15789
15790
15791var IsThisRendererActing = {
15792 current: false
15793};
15794function warnIfNotScopedWithMatchingAct(fiber) {
15795 {
15796 if (warnsIfNotActing === true && IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
15797 warningWithoutStack$1(false, "It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + "import {act} from 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + "import TestRenderer from 'react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);' + '%s', getStackByFiberInDevAndProd(fiber));
15798 }
15799 }
15800}
15801function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
15802 {
15803 if (warnsIfNotActing === true && (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
15804 warningWithoutStack$1(false, 'An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
15805 }
15806 }
15807}
15808
15809function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
15810 {
15811 if (warnsIfNotActing === true && executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
15812 warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
15813 }
15814 }
15815}
15816
15817var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler.
15818
15819var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
15820// scheduler is the actual recommendation. The alternative could be a testing build,
15821// a new lib, or whatever; we dunno just yet. This message is for early adopters
15822// to get their tests right.
15823
15824function warnIfUnmockedScheduler(fiber) {
15825 {
15826 if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) {
15827 if (fiber.mode & BatchedMode || fiber.mode & ConcurrentMode) {
15828 didWarnAboutUnmockedScheduler = true;
15829 warningWithoutStack$1(false, 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
15830 } else if (warnAboutUnmockedScheduler === true) {
15831 didWarnAboutUnmockedScheduler = true;
15832 warningWithoutStack$1(false, 'Starting from React v17, the "scheduler" module will need to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
15833 }
15834 }
15835 }
15836}
15837var componentsThatTriggeredHighPriSuspend = null;
15838function checkForWrongSuspensePriorityInDEV(sourceFiber) {
15839 {
15840 var currentPriorityLevel = getCurrentPriorityLevel();
15841
15842 if ((sourceFiber.mode & ConcurrentMode) !== NoEffect && (currentPriorityLevel === UserBlockingPriority || currentPriorityLevel === ImmediatePriority)) {
15843 var workInProgressNode = sourceFiber;
15844
15845 while (workInProgressNode !== null) {
15846 // Add the component that triggered the suspense
15847 var current$$1 = workInProgressNode.alternate;
15848
15849 if (current$$1 !== null) {
15850 // TODO: warn component that triggers the high priority
15851 // suspend is the HostRoot
15852 switch (workInProgressNode.tag) {
15853 case ClassComponent:
15854 // Loop through the component's update queue and see whether the component
15855 // has triggered any high priority updates
15856 var updateQueue = current$$1.updateQueue;
15857
15858 if (updateQueue !== null) {
15859 var update = updateQueue.firstUpdate;
15860
15861 while (update !== null) {
15862 var priorityLevel = update.priority;
15863
15864 if (priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority) {
15865 if (componentsThatTriggeredHighPriSuspend === null) {
15866 componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
15867 } else {
15868 componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
15869 }
15870
15871 break;
15872 }
15873
15874 update = update.next;
15875 }
15876 }
15877
15878 break;
15879
15880 case FunctionComponent:
15881 case ForwardRef:
15882 case SimpleMemoComponent:
15883 if (workInProgressNode.memoizedState !== null && workInProgressNode.memoizedState.baseUpdate !== null) {
15884 var _update = workInProgressNode.memoizedState.baseUpdate; // Loop through the functional component's memoized state to see whether
15885 // the component has triggered any high pri updates
15886
15887 while (_update !== null) {
15888 var priority = _update.priority;
15889
15890 if (priority === UserBlockingPriority || priority === ImmediatePriority) {
15891 if (componentsThatTriggeredHighPriSuspend === null) {
15892 componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
15893 } else {
15894 componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
15895 }
15896
15897 break;
15898 }
15899
15900 if (_update.next === workInProgressNode.memoizedState.baseUpdate) {
15901 break;
15902 }
15903
15904 _update = _update.next;
15905 }
15906 }
15907
15908 break;
15909
15910 default:
15911 break;
15912 }
15913 }
15914
15915 workInProgressNode = workInProgressNode.return;
15916 }
15917 }
15918 }
15919}
15920
15921function flushSuspensePriorityWarningInDEV() {
15922 {
15923 if (componentsThatTriggeredHighPriSuspend !== null) {
15924 var componentNames = [];
15925 componentsThatTriggeredHighPriSuspend.forEach(function (name) {
15926 return componentNames.push(name);
15927 });
15928 componentsThatTriggeredHighPriSuspend = null;
15929
15930 if (componentNames.length > 0) {
15931 warningWithoutStack$1(false, '%s triggered a user-blocking update that suspended.' + '\n\n' + 'The fix is to split the update into multiple parts: a user-blocking ' + 'update to provide immediate feedback, and another update that ' + 'triggers the bulk of the changes.' + '\n\n' + 'Refer to the documentation for useSuspenseTransition to learn how ' + 'to implement this pattern.', // TODO: Add link to React docs with more information, once it exists
15932 componentNames.sort().join(', '));
15933 }
15934 }
15935 }
15936}
15937
15938function computeThreadID(root, expirationTime) {
15939 // Interaction threads are unique per root and expiration time.
15940 return expirationTime * 1000 + root.interactionThreadID;
15941}
15942
15943function markSpawnedWork(expirationTime) {
15944 if (!enableSchedulerTracing) {
15945 return;
15946 }
15947
15948 if (spawnedWorkDuringRender === null) {
15949 spawnedWorkDuringRender = [expirationTime];
15950 } else {
15951 spawnedWorkDuringRender.push(expirationTime);
15952 }
15953}
15954
15955function scheduleInteractions(root, expirationTime, interactions) {
15956 if (!enableSchedulerTracing) {
15957 return;
15958 }
15959
15960 if (interactions.size > 0) {
15961 var pendingInteractionMap = root.pendingInteractionMap;
15962 var pendingInteractions = pendingInteractionMap.get(expirationTime);
15963
15964 if (pendingInteractions != null) {
15965 interactions.forEach(function (interaction) {
15966 if (!pendingInteractions.has(interaction)) {
15967 // Update the pending async work count for previously unscheduled interaction.
15968 interaction.__count++;
15969 }
15970
15971 pendingInteractions.add(interaction);
15972 });
15973 } else {
15974 pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions.
15975
15976 interactions.forEach(function (interaction) {
15977 interaction.__count++;
15978 });
15979 }
15980
15981 var subscriber = tracing.__subscriberRef.current;
15982
15983 if (subscriber !== null) {
15984 var threadID = computeThreadID(root, expirationTime);
15985 subscriber.onWorkScheduled(interactions, threadID);
15986 }
15987 }
15988}
15989
15990function schedulePendingInteractions(root, expirationTime) {
15991 // This is called when work is scheduled on a root.
15992 // It associates the current interactions with the newly-scheduled expiration.
15993 // They will be restored when that expiration is later committed.
15994 if (!enableSchedulerTracing) {
15995 return;
15996 }
15997
15998 scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
15999}
16000
16001function startWorkOnPendingInteractions(root, expirationTime) {
16002 // This is called when new work is started on a root.
16003 if (!enableSchedulerTracing) {
16004 return;
16005 } // Determine which interactions this batch of work currently includes, So that
16006 // we can accurately attribute time spent working on it, And so that cascading
16007 // work triggered during the render phase will be associated with it.
16008
16009
16010 var interactions = new Set();
16011 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
16012 if (scheduledExpirationTime >= expirationTime) {
16013 scheduledInteractions.forEach(function (interaction) {
16014 return interactions.add(interaction);
16015 });
16016 }
16017 }); // Store the current set of interactions on the FiberRoot for a few reasons:
16018 // We can re-use it in hot functions like renderRoot() without having to
16019 // recalculate it. We will also use it in commitWork() to pass to any Profiler
16020 // onRender() hooks. This also provides DevTools with a way to access it when
16021 // the onCommitRoot() hook is called.
16022
16023 root.memoizedInteractions = interactions;
16024
16025 if (interactions.size > 0) {
16026 var subscriber = tracing.__subscriberRef.current;
16027
16028 if (subscriber !== null) {
16029 var threadID = computeThreadID(root, expirationTime);
16030
16031 try {
16032 subscriber.onWorkStarted(interactions, threadID);
16033 } catch (error) {
16034 // If the subscriber throws, rethrow it in a separate task
16035 scheduleCallback(ImmediatePriority, function () {
16036 throw error;
16037 });
16038 }
16039 }
16040 }
16041}
16042
16043function finishPendingInteractions(root, committedExpirationTime) {
16044 if (!enableSchedulerTracing) {
16045 return;
16046 }
16047
16048 var earliestRemainingTimeAfterCommit = root.firstPendingTime;
16049 var subscriber;
16050
16051 try {
16052 subscriber = tracing.__subscriberRef.current;
16053
16054 if (subscriber !== null && root.memoizedInteractions.size > 0) {
16055 var threadID = computeThreadID(root, committedExpirationTime);
16056 subscriber.onWorkStopped(root.memoizedInteractions, threadID);
16057 }
16058 } catch (error) {
16059 // If the subscriber throws, rethrow it in a separate task
16060 scheduleCallback(ImmediatePriority, function () {
16061 throw error;
16062 });
16063 } finally {
16064 // Clear completed interactions from the pending Map.
16065 // Unless the render was suspended or cascading work was scheduled,
16066 // In which case– leave pending interactions until the subsequent render.
16067 var pendingInteractionMap = root.pendingInteractionMap;
16068 pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
16069 // Only decrement the pending interaction count if we're done.
16070 // If there's still work at the current priority,
16071 // That indicates that we are waiting for suspense data.
16072 if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
16073 pendingInteractionMap.delete(scheduledExpirationTime);
16074 scheduledInteractions.forEach(function (interaction) {
16075 interaction.__count--;
16076
16077 if (subscriber !== null && interaction.__count === 0) {
16078 try {
16079 subscriber.onInteractionScheduledWorkCompleted(interaction);
16080 } catch (error) {
16081 // If the subscriber throws, rethrow it in a separate task
16082 scheduleCallback(ImmediatePriority, function () {
16083 throw error;
16084 });
16085 }
16086 }
16087 });
16088 }
16089 });
16090 }
16091}
16092
16093var onCommitFiberRoot = null;
16094var onCommitFiberUnmount = null;
16095var hasLoggedError = false;
16096var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
16097function injectInternals(internals) {
16098 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
16099 // No DevTools
16100 return false;
16101 }
16102
16103 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
16104
16105 if (hook.isDisabled) {
16106 // This isn't a real property on the hook, but it can be set to opt out
16107 // of DevTools integration and associated warnings and logs.
16108 // https://github.com/facebook/react/issues/3877
16109 return true;
16110 }
16111
16112 if (!hook.supportsFiber) {
16113 {
16114 warningWithoutStack$1(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
16115 } // DevTools exists, even though it doesn't support Fiber.
16116
16117
16118 return true;
16119 }
16120
16121 try {
16122 var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
16123
16124 onCommitFiberRoot = function (root, expirationTime) {
16125 try {
16126 var didError = (root.current.effectTag & DidCapture) === DidCapture;
16127
16128 if (enableProfilerTimer) {
16129 var currentTime = requestCurrentTime();
16130 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
16131 hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
16132 } else {
16133 hook.onCommitFiberRoot(rendererID, root, undefined, didError);
16134 }
16135 } catch (err) {
16136 if (true && !hasLoggedError) {
16137 hasLoggedError = true;
16138 warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
16139 }
16140 }
16141 };
16142
16143 onCommitFiberUnmount = function (fiber) {
16144 try {
16145 hook.onCommitFiberUnmount(rendererID, fiber);
16146 } catch (err) {
16147 if (true && !hasLoggedError) {
16148 hasLoggedError = true;
16149 warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
16150 }
16151 }
16152 };
16153 } catch (err) {
16154 // Catch all errors because it is unsafe to throw during initialization.
16155 {
16156 warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
16157 }
16158 } // DevTools exists
16159
16160
16161 return true;
16162}
16163function onCommitRoot(root, expirationTime) {
16164 if (typeof onCommitFiberRoot === 'function') {
16165 onCommitFiberRoot(root, expirationTime);
16166 }
16167}
16168function onCommitUnmount(fiber) {
16169 if (typeof onCommitFiberUnmount === 'function') {
16170 onCommitFiberUnmount(fiber);
16171 }
16172}
16173
16174var hasBadMapPolyfill;
16175
16176{
16177 hasBadMapPolyfill = false;
16178
16179 try {
16180 var nonExtensibleObject = Object.preventExtensions({});
16181 var testMap = new Map([[nonExtensibleObject, null]]);
16182 var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused.
16183 // https://github.com/rollup/rollup/issues/1771
16184 // TODO: we can remove these if Rollup fixes the bug.
16185
16186 testMap.set(0, 0);
16187 testSet.add(0);
16188 } catch (e) {
16189 // TODO: Consider warning about bad polyfills
16190 hasBadMapPolyfill = true;
16191 }
16192}
16193
16194var debugCounter = 1;
16195
16196function FiberNode(tag, pendingProps, key, mode) {
16197 // Instance
16198 this.tag = tag;
16199 this.key = key;
16200 this.elementType = null;
16201 this.type = null;
16202 this.stateNode = null; // Fiber
16203
16204 this.return = null;
16205 this.child = null;
16206 this.sibling = null;
16207 this.index = 0;
16208 this.ref = null;
16209 this.pendingProps = pendingProps;
16210 this.memoizedProps = null;
16211 this.updateQueue = null;
16212 this.memoizedState = null;
16213 this.dependencies = null;
16214 this.mode = mode; // Effects
16215
16216 this.effectTag = NoEffect;
16217 this.nextEffect = null;
16218 this.firstEffect = null;
16219 this.lastEffect = null;
16220 this.expirationTime = NoWork;
16221 this.childExpirationTime = NoWork;
16222 this.alternate = null;
16223
16224 if (enableProfilerTimer) {
16225 // Note: The following is done to avoid a v8 performance cliff.
16226 //
16227 // Initializing the fields below to smis and later updating them with
16228 // double values will cause Fibers to end up having separate shapes.
16229 // This behavior/bug has something to do with Object.preventExtension().
16230 // Fortunately this only impacts DEV builds.
16231 // Unfortunately it makes React unusably slow for some applications.
16232 // To work around this, initialize the fields below with doubles.
16233 //
16234 // Learn more about this here:
16235 // https://github.com/facebook/react/issues/14365
16236 // https://bugs.chromium.org/p/v8/issues/detail?id=8538
16237 this.actualDuration = Number.NaN;
16238 this.actualStartTime = Number.NaN;
16239 this.selfBaseDuration = Number.NaN;
16240 this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization.
16241 // This won't trigger the performance cliff mentioned above,
16242 // and it simplifies other profiler code (including DevTools).
16243
16244 this.actualDuration = 0;
16245 this.actualStartTime = -1;
16246 this.selfBaseDuration = 0;
16247 this.treeBaseDuration = 0;
16248 } // This is normally DEV-only except www when it adds listeners.
16249 // TODO: remove the User Timing integration in favor of Root Events.
16250
16251
16252 if (enableUserTimingAPI) {
16253 this._debugID = debugCounter++;
16254 this._debugIsCurrentlyTiming = false;
16255 }
16256
16257 {
16258 this._debugSource = null;
16259 this._debugOwner = null;
16260 this._debugNeedsRemount = false;
16261 this._debugHookTypes = null;
16262
16263 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
16264 Object.preventExtensions(this);
16265 }
16266 }
16267} // This is a constructor function, rather than a POJO constructor, still
16268// please ensure we do the following:
16269// 1) Nobody should add any instance methods on this. Instance methods can be
16270// more difficult to predict when they get optimized and they are almost
16271// never inlined properly in static compilers.
16272// 2) Nobody should rely on `instanceof Fiber` for type testing. We should
16273// always know when it is a fiber.
16274// 3) We might want to experiment with using numeric keys since they are easier
16275// to optimize in a non-JIT environment.
16276// 4) We can easily go from a constructor to a createFiber object literal if that
16277// is faster.
16278// 5) It should be easy to port this to a C struct and keep a C implementation
16279// compatible.
16280
16281
16282var createFiber = function (tag, pendingProps, key, mode) {
16283 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
16284 return new FiberNode(tag, pendingProps, key, mode);
16285};
16286
16287function shouldConstruct(Component) {
16288 var prototype = Component.prototype;
16289 return !!(prototype && prototype.isReactComponent);
16290}
16291
16292function isSimpleFunctionComponent(type) {
16293 return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
16294}
16295function resolveLazyComponentTag(Component) {
16296 if (typeof Component === 'function') {
16297 return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
16298 } else if (Component !== undefined && Component !== null) {
16299 var $$typeof = Component.$$typeof;
16300
16301 if ($$typeof === REACT_FORWARD_REF_TYPE) {
16302 return ForwardRef;
16303 }
16304
16305 if ($$typeof === REACT_MEMO_TYPE) {
16306 return MemoComponent;
16307 }
16308 }
16309
16310 return IndeterminateComponent;
16311} // This is used to create an alternate fiber to do work on.
16312
16313function createWorkInProgress(current, pendingProps, expirationTime) {
16314 var workInProgress = current.alternate;
16315
16316 if (workInProgress === null) {
16317 // We use a double buffering pooling technique because we know that we'll
16318 // only ever need at most two versions of a tree. We pool the "other" unused
16319 // node that we're free to reuse. This is lazily created to avoid allocating
16320 // extra objects for things that are never updated. It also allow us to
16321 // reclaim the extra memory if needed.
16322 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
16323 workInProgress.elementType = current.elementType;
16324 workInProgress.type = current.type;
16325 workInProgress.stateNode = current.stateNode;
16326
16327 {
16328 // DEV-only fields
16329 workInProgress._debugID = current._debugID;
16330 workInProgress._debugSource = current._debugSource;
16331 workInProgress._debugOwner = current._debugOwner;
16332 workInProgress._debugHookTypes = current._debugHookTypes;
16333 }
16334
16335 workInProgress.alternate = current;
16336 current.alternate = workInProgress;
16337 } else {
16338 workInProgress.pendingProps = pendingProps; // We already have an alternate.
16339 // Reset the effect tag.
16340
16341 workInProgress.effectTag = NoEffect; // The effect list is no longer valid.
16342
16343 workInProgress.nextEffect = null;
16344 workInProgress.firstEffect = null;
16345 workInProgress.lastEffect = null;
16346
16347 if (enableProfilerTimer) {
16348 // We intentionally reset, rather than copy, actualDuration & actualStartTime.
16349 // This prevents time from endlessly accumulating in new commits.
16350 // This has the downside of resetting values for different priority renders,
16351 // But works for yielding (the common case) and should support resuming.
16352 workInProgress.actualDuration = 0;
16353 workInProgress.actualStartTime = -1;
16354 }
16355 }
16356
16357 workInProgress.childExpirationTime = current.childExpirationTime;
16358 workInProgress.expirationTime = current.expirationTime;
16359 workInProgress.child = current.child;
16360 workInProgress.memoizedProps = current.memoizedProps;
16361 workInProgress.memoizedState = current.memoizedState;
16362 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
16363 // it cannot be shared with the current fiber.
16364
16365 var currentDependencies = current.dependencies;
16366 workInProgress.dependencies = currentDependencies === null ? null : {
16367 expirationTime: currentDependencies.expirationTime,
16368 firstContext: currentDependencies.firstContext,
16369 responders: currentDependencies.responders
16370 }; // These will be overridden during the parent's reconciliation
16371
16372 workInProgress.sibling = current.sibling;
16373 workInProgress.index = current.index;
16374 workInProgress.ref = current.ref;
16375
16376 if (enableProfilerTimer) {
16377 workInProgress.selfBaseDuration = current.selfBaseDuration;
16378 workInProgress.treeBaseDuration = current.treeBaseDuration;
16379 }
16380
16381 {
16382 workInProgress._debugNeedsRemount = current._debugNeedsRemount;
16383
16384 switch (workInProgress.tag) {
16385 case IndeterminateComponent:
16386 case FunctionComponent:
16387 case SimpleMemoComponent:
16388 workInProgress.type = resolveFunctionForHotReloading(current.type);
16389 break;
16390
16391 case ClassComponent:
16392 workInProgress.type = resolveClassForHotReloading(current.type);
16393 break;
16394
16395 case ForwardRef:
16396 workInProgress.type = resolveForwardRefForHotReloading(current.type);
16397 break;
16398
16399 default:
16400 break;
16401 }
16402 }
16403
16404 return workInProgress;
16405} // Used to reuse a Fiber for a second pass.
16406
16407function resetWorkInProgress(workInProgress, renderExpirationTime) {
16408 // This resets the Fiber to what createFiber or createWorkInProgress would
16409 // have set the values to before during the first pass. Ideally this wouldn't
16410 // be necessary but unfortunately many code paths reads from the workInProgress
16411 // when they should be reading from current and writing to workInProgress.
16412 // We assume pendingProps, index, key, ref, return are still untouched to
16413 // avoid doing another reconciliation.
16414 // Reset the effect tag but keep any Placement tags, since that's something
16415 // that child fiber is setting, not the reconciliation.
16416 workInProgress.effectTag &= Placement; // The effect list is no longer valid.
16417
16418 workInProgress.nextEffect = null;
16419 workInProgress.firstEffect = null;
16420 workInProgress.lastEffect = null;
16421 var current = workInProgress.alternate;
16422
16423 if (current === null) {
16424 // Reset to createFiber's initial values.
16425 workInProgress.childExpirationTime = NoWork;
16426 workInProgress.expirationTime = renderExpirationTime;
16427 workInProgress.child = null;
16428 workInProgress.memoizedProps = null;
16429 workInProgress.memoizedState = null;
16430 workInProgress.updateQueue = null;
16431 workInProgress.dependencies = null;
16432
16433 if (enableProfilerTimer) {
16434 // Note: We don't reset the actualTime counts. It's useful to accumulate
16435 // actual time across multiple render passes.
16436 workInProgress.selfBaseDuration = 0;
16437 workInProgress.treeBaseDuration = 0;
16438 }
16439 } else {
16440 // Reset to the cloned values that createWorkInProgress would've.
16441 workInProgress.childExpirationTime = current.childExpirationTime;
16442 workInProgress.expirationTime = current.expirationTime;
16443 workInProgress.child = current.child;
16444 workInProgress.memoizedProps = current.memoizedProps;
16445 workInProgress.memoizedState = current.memoizedState;
16446 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
16447 // it cannot be shared with the current fiber.
16448
16449 var currentDependencies = current.dependencies;
16450 workInProgress.dependencies = currentDependencies === null ? null : {
16451 expirationTime: currentDependencies.expirationTime,
16452 firstContext: currentDependencies.firstContext,
16453 responders: currentDependencies.responders
16454 };
16455
16456 if (enableProfilerTimer) {
16457 // Note: We don't reset the actualTime counts. It's useful to accumulate
16458 // actual time across multiple render passes.
16459 workInProgress.selfBaseDuration = current.selfBaseDuration;
16460 workInProgress.treeBaseDuration = current.treeBaseDuration;
16461 }
16462 }
16463
16464 return workInProgress;
16465}
16466function createHostRootFiber(tag) {
16467 var mode;
16468
16469 if (tag === ConcurrentRoot) {
16470 mode = ConcurrentMode | BatchedMode | StrictMode;
16471 } else if (tag === BatchedRoot) {
16472 mode = BatchedMode | StrictMode;
16473 } else {
16474 mode = NoMode;
16475 }
16476
16477 if (enableProfilerTimer && isDevToolsPresent) {
16478 // Always collect profile timings when DevTools are present.
16479 // This enables DevTools to start capturing timing at any point–
16480 // Without some nodes in the tree having empty base times.
16481 mode |= ProfileMode;
16482 }
16483
16484 return createFiber(HostRoot, null, null, mode);
16485}
16486function createFiberFromTypeAndProps(type, // React$ElementType
16487key, pendingProps, owner, mode, expirationTime) {
16488 var fiber;
16489 var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
16490
16491 var resolvedType = type;
16492
16493 if (typeof type === 'function') {
16494 if (shouldConstruct(type)) {
16495 fiberTag = ClassComponent;
16496
16497 {
16498 resolvedType = resolveClassForHotReloading(resolvedType);
16499 }
16500 } else {
16501 {
16502 resolvedType = resolveFunctionForHotReloading(resolvedType);
16503 }
16504 }
16505 } else if (typeof type === 'string') {
16506 fiberTag = HostComponent;
16507 } else {
16508 getTag: switch (type) {
16509 case REACT_FRAGMENT_TYPE:
16510 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
16511
16512 case REACT_CONCURRENT_MODE_TYPE:
16513 fiberTag = Mode;
16514 mode |= ConcurrentMode | BatchedMode | StrictMode;
16515 break;
16516
16517 case REACT_STRICT_MODE_TYPE:
16518 fiberTag = Mode;
16519 mode |= StrictMode;
16520 break;
16521
16522 case REACT_PROFILER_TYPE:
16523 return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
16524
16525 case REACT_SUSPENSE_TYPE:
16526 return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
16527
16528 case REACT_SUSPENSE_LIST_TYPE:
16529 return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
16530
16531 default:
16532 {
16533 if (typeof type === 'object' && type !== null) {
16534 switch (type.$$typeof) {
16535 case REACT_PROVIDER_TYPE:
16536 fiberTag = ContextProvider;
16537 break getTag;
16538
16539 case REACT_CONTEXT_TYPE:
16540 // This is a consumer
16541 fiberTag = ContextConsumer;
16542 break getTag;
16543
16544 case REACT_FORWARD_REF_TYPE:
16545 fiberTag = ForwardRef;
16546
16547 {
16548 resolvedType = resolveForwardRefForHotReloading(resolvedType);
16549 }
16550
16551 break getTag;
16552
16553 case REACT_MEMO_TYPE:
16554 fiberTag = MemoComponent;
16555 break getTag;
16556
16557 case REACT_LAZY_TYPE:
16558 fiberTag = LazyComponent;
16559 resolvedType = null;
16560 break getTag;
16561
16562 case REACT_FUNDAMENTAL_TYPE:
16563 if (enableFundamentalAPI) {
16564 return createFiberFromFundamental(type, pendingProps, mode, expirationTime, key);
16565 }
16566
16567 break;
16568
16569 case REACT_SCOPE_TYPE:
16570 if (enableScopeAPI) {
16571 return createFiberFromScope(type, pendingProps, mode, expirationTime, key);
16572 }
16573
16574 }
16575 }
16576
16577 var info = '';
16578
16579 {
16580 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
16581 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.';
16582 }
16583
16584 var ownerName = owner ? getComponentName(owner.type) : null;
16585
16586 if (ownerName) {
16587 info += '\n\nCheck the render method of `' + ownerName + '`.';
16588 }
16589 }
16590
16591 (function () {
16592 {
16593 {
16594 throw ReactError(Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info));
16595 }
16596 }
16597 })();
16598 }
16599 }
16600 }
16601
16602 fiber = createFiber(fiberTag, pendingProps, key, mode);
16603 fiber.elementType = type;
16604 fiber.type = resolvedType;
16605 fiber.expirationTime = expirationTime;
16606 return fiber;
16607}
16608function createFiberFromElement(element, mode, expirationTime) {
16609 var owner = null;
16610
16611 {
16612 owner = element._owner;
16613 }
16614
16615 var type = element.type;
16616 var key = element.key;
16617 var pendingProps = element.props;
16618 var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
16619
16620 {
16621 fiber._debugSource = element._source;
16622 fiber._debugOwner = element._owner;
16623 }
16624
16625 return fiber;
16626}
16627function createFiberFromFragment(elements, mode, expirationTime, key) {
16628 var fiber = createFiber(Fragment, elements, key, mode);
16629 fiber.expirationTime = expirationTime;
16630 return fiber;
16631}
16632function createFiberFromFundamental(fundamentalComponent, pendingProps, mode, expirationTime, key) {
16633 var fiber = createFiber(FundamentalComponent, pendingProps, key, mode);
16634 fiber.elementType = fundamentalComponent;
16635 fiber.type = fundamentalComponent;
16636 fiber.expirationTime = expirationTime;
16637 return fiber;
16638}
16639
16640function createFiberFromScope(scope, pendingProps, mode, expirationTime, key) {
16641 var fiber = createFiber(ScopeComponent, pendingProps, key, mode);
16642 fiber.type = scope;
16643 fiber.elementType = scope;
16644 fiber.expirationTime = expirationTime;
16645 return fiber;
16646}
16647
16648function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
16649 {
16650 if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
16651 warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
16652 }
16653 }
16654
16655 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag.
16656
16657 fiber.elementType = REACT_PROFILER_TYPE;
16658 fiber.type = REACT_PROFILER_TYPE;
16659 fiber.expirationTime = expirationTime;
16660 return fiber;
16661}
16662
16663function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
16664 var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
16665 // This needs to be fixed in getComponentName so that it relies on the tag
16666 // instead.
16667
16668 fiber.type = REACT_SUSPENSE_TYPE;
16669 fiber.elementType = REACT_SUSPENSE_TYPE;
16670 fiber.expirationTime = expirationTime;
16671 return fiber;
16672}
16673function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
16674 var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
16675
16676 {
16677 // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag.
16678 // This needs to be fixed in getComponentName so that it relies on the tag
16679 // instead.
16680 fiber.type = REACT_SUSPENSE_LIST_TYPE;
16681 }
16682
16683 fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
16684 fiber.expirationTime = expirationTime;
16685 return fiber;
16686}
16687function createFiberFromText(content, mode, expirationTime) {
16688 var fiber = createFiber(HostText, content, null, mode);
16689 fiber.expirationTime = expirationTime;
16690 return fiber;
16691}
16692function createFiberFromHostInstanceForDeletion() {
16693 var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type.
16694
16695 fiber.elementType = 'DELETED';
16696 fiber.type = 'DELETED';
16697 return fiber;
16698}
16699function createFiberFromDehydratedFragment(dehydratedNode) {
16700 var fiber = createFiber(DehydratedFragment, null, null, NoMode);
16701 fiber.stateNode = dehydratedNode;
16702 return fiber;
16703}
16704function createFiberFromPortal(portal, mode, expirationTime) {
16705 var pendingProps = portal.children !== null ? portal.children : [];
16706 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
16707 fiber.expirationTime = expirationTime;
16708 fiber.stateNode = {
16709 containerInfo: portal.containerInfo,
16710 pendingChildren: null,
16711 // Used by persistent updates
16712 implementation: portal.implementation
16713 };
16714 return fiber;
16715} // Used for stashing WIP properties to replay failed work in DEV.
16716
16717function assignFiberPropertiesInDEV(target, source) {
16718 if (target === null) {
16719 // This Fiber's initial properties will always be overwritten.
16720 // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
16721 target = createFiber(IndeterminateComponent, null, null, NoMode);
16722 } // This is intentionally written as a list of all properties.
16723 // We tried to use Object.assign() instead but this is called in
16724 // the hottest path, and Object.assign() was too slow:
16725 // https://github.com/facebook/react/issues/12502
16726 // This code is DEV-only so size is not a concern.
16727
16728
16729 target.tag = source.tag;
16730 target.key = source.key;
16731 target.elementType = source.elementType;
16732 target.type = source.type;
16733 target.stateNode = source.stateNode;
16734 target.return = source.return;
16735 target.child = source.child;
16736 target.sibling = source.sibling;
16737 target.index = source.index;
16738 target.ref = source.ref;
16739 target.pendingProps = source.pendingProps;
16740 target.memoizedProps = source.memoizedProps;
16741 target.updateQueue = source.updateQueue;
16742 target.memoizedState = source.memoizedState;
16743 target.dependencies = source.dependencies;
16744 target.mode = source.mode;
16745 target.effectTag = source.effectTag;
16746 target.nextEffect = source.nextEffect;
16747 target.firstEffect = source.firstEffect;
16748 target.lastEffect = source.lastEffect;
16749 target.expirationTime = source.expirationTime;
16750 target.childExpirationTime = source.childExpirationTime;
16751 target.alternate = source.alternate;
16752
16753 if (enableProfilerTimer) {
16754 target.actualDuration = source.actualDuration;
16755 target.actualStartTime = source.actualStartTime;
16756 target.selfBaseDuration = source.selfBaseDuration;
16757 target.treeBaseDuration = source.treeBaseDuration;
16758 }
16759
16760 target._debugID = source._debugID;
16761 target._debugSource = source._debugSource;
16762 target._debugOwner = source._debugOwner;
16763 target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
16764 target._debugNeedsRemount = source._debugNeedsRemount;
16765 target._debugHookTypes = source._debugHookTypes;
16766 return target;
16767}
16768
16769function FiberRootNode(containerInfo, tag, hydrate) {
16770 this.tag = tag;
16771 this.current = null;
16772 this.containerInfo = containerInfo;
16773 this.pendingChildren = null;
16774 this.pingCache = null;
16775 this.finishedExpirationTime = NoWork;
16776 this.finishedWork = null;
16777 this.timeoutHandle = noTimeout;
16778 this.context = null;
16779 this.pendingContext = null;
16780 this.hydrate = hydrate;
16781 this.firstBatch = null;
16782 this.callbackNode = null;
16783 this.callbackPriority = NoPriority;
16784 this.firstPendingTime = NoWork;
16785 this.firstSuspendedTime = NoWork;
16786 this.lastSuspendedTime = NoWork;
16787 this.nextKnownPendingLevel = NoWork;
16788 this.lastPingedTime = NoWork;
16789 this.lastExpiredTime = NoWork;
16790
16791 if (enableSchedulerTracing) {
16792 this.interactionThreadID = tracing.unstable_getThreadID();
16793 this.memoizedInteractions = new Set();
16794 this.pendingInteractionMap = new Map();
16795 }
16796
16797 if (enableSuspenseCallback) {
16798 this.hydrationCallbacks = null;
16799 }
16800}
16801
16802function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
16803 var root = new FiberRootNode(containerInfo, tag, hydrate);
16804
16805 if (enableSuspenseCallback) {
16806 root.hydrationCallbacks = hydrationCallbacks;
16807 } // Cyclic construction. This cheats the type system right now because
16808 // stateNode is any.
16809
16810
16811 var uninitializedFiber = createHostRootFiber(tag);
16812 root.current = uninitializedFiber;
16813 uninitializedFiber.stateNode = root;
16814 return root;
16815}
16816function isRootSuspendedAtTime(root, expirationTime) {
16817 var firstSuspendedTime = root.firstSuspendedTime;
16818 var lastSuspendedTime = root.lastSuspendedTime;
16819 return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime;
16820}
16821function markRootSuspendedAtTime(root, expirationTime) {
16822 var firstSuspendedTime = root.firstSuspendedTime;
16823 var lastSuspendedTime = root.lastSuspendedTime;
16824
16825 if (firstSuspendedTime < expirationTime) {
16826 root.firstSuspendedTime = expirationTime;
16827 }
16828
16829 if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
16830 root.lastSuspendedTime = expirationTime;
16831 }
16832
16833 if (expirationTime <= root.lastPingedTime) {
16834 root.lastPingedTime = NoWork;
16835 }
16836
16837 if (expirationTime <= root.lastExpiredTime) {
16838 root.lastExpiredTime = NoWork;
16839 }
16840}
16841function markRootUpdatedAtTime(root, expirationTime) {
16842 // Update the range of pending times
16843 var firstPendingTime = root.firstPendingTime;
16844
16845 if (expirationTime > firstPendingTime) {
16846 root.firstPendingTime = expirationTime;
16847 } // Update the range of suspended times. Treat everything lower priority or
16848 // equal to this update as unsuspended.
16849
16850
16851 var firstSuspendedTime = root.firstSuspendedTime;
16852
16853 if (firstSuspendedTime !== NoWork) {
16854 if (expirationTime >= firstSuspendedTime) {
16855 // The entire suspended range is now unsuspended.
16856 root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
16857 } else if (expirationTime >= root.lastSuspendedTime) {
16858 root.lastSuspendedTime = expirationTime + 1;
16859 } // This is a pending level. Check if it's higher priority than the next
16860 // known pending level.
16861
16862
16863 if (expirationTime > root.nextKnownPendingLevel) {
16864 root.nextKnownPendingLevel = expirationTime;
16865 }
16866 }
16867}
16868function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) {
16869 // Update the range of pending times
16870 root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or
16871 // equal to this update as unsuspended.
16872
16873 if (finishedExpirationTime <= root.lastSuspendedTime) {
16874 // The entire suspended range is now unsuspended.
16875 root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
16876 } else if (finishedExpirationTime <= root.firstSuspendedTime) {
16877 // Part of the suspended range is now unsuspended. Narrow the range to
16878 // include everything between the unsuspended time (non-inclusive) and the
16879 // last suspended time.
16880 root.firstSuspendedTime = finishedExpirationTime - 1;
16881 }
16882
16883 if (finishedExpirationTime <= root.lastPingedTime) {
16884 // Clear the pinged time
16885 root.lastPingedTime = NoWork;
16886 }
16887
16888 if (finishedExpirationTime <= root.lastExpiredTime) {
16889 // Clear the expired time
16890 root.lastExpiredTime = NoWork;
16891 }
16892}
16893function markRootExpiredAtTime(root, expirationTime) {
16894 var lastExpiredTime = root.lastExpiredTime;
16895
16896 if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
16897 root.lastExpiredTime = expirationTime;
16898 }
16899}
16900
16901// This lets us hook into Fiber to debug what it's doing.
16902// See https://github.com/facebook/react/pull/8033.
16903// This is not part of the public API, not even for React DevTools.
16904// You may only inject a debugTool if you work on React Fiber itself.
16905var ReactFiberInstrumentation = {
16906 debugTool: null
16907};
16908var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
16909
16910var didWarnAboutNestedUpdates;
16911var didWarnAboutFindNodeInStrictMode;
16912
16913{
16914 didWarnAboutNestedUpdates = false;
16915 didWarnAboutFindNodeInStrictMode = {};
16916}
16917
16918function getContextForSubtree(parentComponent) {
16919 if (!parentComponent) {
16920 return emptyContextObject;
16921 }
16922
16923 var fiber = get(parentComponent);
16924 var parentContext = findCurrentUnmaskedContext(fiber);
16925
16926 if (fiber.tag === ClassComponent) {
16927 var Component = fiber.type;
16928
16929 if (isContextProvider(Component)) {
16930 return processChildContext(fiber, Component, parentContext);
16931 }
16932 }
16933
16934 return parentContext;
16935}
16936
16937function scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback) {
16938 {
16939 if (phase === 'render' && current !== null && !didWarnAboutNestedUpdates) {
16940 didWarnAboutNestedUpdates = true;
16941 warningWithoutStack$1(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current.type) || 'Unknown');
16942 }
16943 }
16944
16945 var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property
16946 // being called "element".
16947
16948 update.payload = {
16949 element: element
16950 };
16951 callback = callback === undefined ? null : callback;
16952
16953 if (callback !== null) {
16954 !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
16955 update.callback = callback;
16956 }
16957
16958 enqueueUpdate(current$$1, update);
16959 scheduleWork(current$$1, expirationTime);
16960 return expirationTime;
16961}
16962
16963function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback) {
16964 // TODO: If this is a nested container, this won't be the root.
16965 var current$$1 = container.current;
16966
16967 {
16968 if (ReactFiberInstrumentation_1.debugTool) {
16969 if (current$$1.alternate === null) {
16970 ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
16971 } else if (element === null) {
16972 ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
16973 } else {
16974 ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
16975 }
16976 }
16977 }
16978
16979 var context = getContextForSubtree(parentComponent);
16980
16981 if (container.context === null) {
16982 container.context = context;
16983 } else {
16984 container.pendingContext = context;
16985 }
16986
16987 return scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback);
16988}
16989
16990function findHostInstance(component) {
16991 var fiber = get(component);
16992
16993 if (fiber === undefined) {
16994 if (typeof component.render === 'function') {
16995 (function () {
16996 {
16997 {
16998 throw ReactError(Error("Unable to find node on an unmounted component."));
16999 }
17000 }
17001 })();
17002 } else {
17003 (function () {
17004 {
17005 {
17006 throw ReactError(Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component)));
17007 }
17008 }
17009 })();
17010 }
17011 }
17012
17013 var hostFiber = findCurrentHostFiber(fiber);
17014
17015 if (hostFiber === null) {
17016 return null;
17017 }
17018
17019 return hostFiber.stateNode;
17020}
17021
17022function findHostInstanceWithWarning(component, methodName) {
17023 {
17024 var fiber = get(component);
17025
17026 if (fiber === undefined) {
17027 if (typeof component.render === 'function') {
17028 (function () {
17029 {
17030 {
17031 throw ReactError(Error("Unable to find node on an unmounted component."));
17032 }
17033 }
17034 })();
17035 } else {
17036 (function () {
17037 {
17038 {
17039 throw ReactError(Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component)));
17040 }
17041 }
17042 })();
17043 }
17044 }
17045
17046 var hostFiber = findCurrentHostFiber(fiber);
17047
17048 if (hostFiber === null) {
17049 return null;
17050 }
17051
17052 if (hostFiber.mode & StrictMode) {
17053 var componentName = getComponentName(fiber.type) || 'Component';
17054
17055 if (!didWarnAboutFindNodeInStrictMode[componentName]) {
17056 didWarnAboutFindNodeInStrictMode[componentName] = true;
17057
17058 if (fiber.mode & StrictMode) {
17059 warningWithoutStack$1(false, '%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
17060 } else {
17061 warningWithoutStack$1(false, '%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
17062 }
17063 }
17064 }
17065
17066 return hostFiber.stateNode;
17067 }
17068
17069 return findHostInstance(component);
17070}
17071
17072function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) {
17073 return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks);
17074}
17075function updateContainer(element, container, parentComponent, callback) {
17076 var current$$1 = container.current;
17077 var currentTime = requestCurrentTime();
17078
17079 {
17080 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
17081 if ('undefined' !== typeof jest) {
17082 warnIfUnmockedScheduler(current$$1);
17083 warnIfNotScopedWithMatchingAct(current$$1);
17084 }
17085 }
17086
17087 var suspenseConfig = requestCurrentSuspenseConfig();
17088 var expirationTime = computeExpirationForFiber(currentTime, current$$1, suspenseConfig);
17089 return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback);
17090}
17091function getPublicRootInstance(container) {
17092 var containerFiber = container.current;
17093
17094 if (!containerFiber.child) {
17095 return null;
17096 }
17097
17098 switch (containerFiber.child.tag) {
17099 case HostComponent:
17100 return getPublicInstance(containerFiber.child.stateNode);
17101
17102 default:
17103 return containerFiber.child.stateNode;
17104 }
17105}
17106function attemptSynchronousHydration(fiber) {
17107 switch (fiber.tag) {
17108 case HostRoot:
17109 var root = fiber.stateNode;
17110
17111 if (root.hydrate) {
17112 // Flush the first scheduled "update".
17113 flushRoot(root, root.firstPendingTime);
17114 }
17115
17116 break;
17117
17118 case SuspenseComponent:
17119 flushSync(function () {
17120 return scheduleWork(fiber, Sync);
17121 });
17122 break;
17123 }
17124}
17125function findHostInstanceWithNoPortals(fiber) {
17126 var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
17127
17128 if (hostFiber === null) {
17129 return null;
17130 }
17131
17132 if (hostFiber.tag === FundamentalComponent) {
17133 return hostFiber.stateNode.instance;
17134 }
17135
17136 return hostFiber.stateNode;
17137}
17138
17139var shouldSuspendImpl = function (fiber) {
17140 return false;
17141};
17142
17143function shouldSuspend(fiber) {
17144 return shouldSuspendImpl(fiber);
17145}
17146var overrideHookState = null;
17147var overrideProps = null;
17148var scheduleUpdate = null;
17149var setSuspenseHandler = null;
17150
17151{
17152 var copyWithSetImpl = function (obj, path, idx, value) {
17153 if (idx >= path.length) {
17154 return value;
17155 }
17156
17157 var key = path[idx];
17158 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here
17159
17160 updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
17161 return updated;
17162 };
17163
17164 var copyWithSet = function (obj, path, value) {
17165 return copyWithSetImpl(obj, path, 0, value);
17166 }; // Support DevTools editable values for useState and useReducer.
17167
17168
17169 overrideHookState = function (fiber, id, path, value) {
17170 // For now, the "id" of stateful hooks is just the stateful hook index.
17171 // This may change in the future with e.g. nested hooks.
17172 var currentHook = fiber.memoizedState;
17173
17174 while (currentHook !== null && id > 0) {
17175 currentHook = currentHook.next;
17176 id--;
17177 }
17178
17179 if (currentHook !== null) {
17180 var newState = copyWithSet(currentHook.memoizedState, path, value);
17181 currentHook.memoizedState = newState;
17182 currentHook.baseState = newState; // We aren't actually adding an update to the queue,
17183 // because there is no update we can add for useReducer hooks that won't trigger an error.
17184 // (There's no appropriate action type for DevTools overrides.)
17185 // As a result though, React will see the scheduled update as a noop and bailout.
17186 // Shallow cloning props works as a workaround for now to bypass the bailout check.
17187
17188 fiber.memoizedProps = _assign({}, fiber.memoizedProps);
17189 scheduleWork(fiber, Sync);
17190 }
17191 }; // Support DevTools props for function components, forwardRef, memo, host components, etc.
17192
17193
17194 overrideProps = function (fiber, path, value) {
17195 fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
17196
17197 if (fiber.alternate) {
17198 fiber.alternate.pendingProps = fiber.pendingProps;
17199 }
17200
17201 scheduleWork(fiber, Sync);
17202 };
17203
17204 scheduleUpdate = function (fiber) {
17205 scheduleWork(fiber, Sync);
17206 };
17207
17208 setSuspenseHandler = function (newShouldSuspendImpl) {
17209 shouldSuspendImpl = newShouldSuspendImpl;
17210 };
17211}
17212
17213function injectIntoDevTools(devToolsConfig) {
17214 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
17215 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
17216 return injectInternals(_assign({}, devToolsConfig, {
17217 overrideHookState: overrideHookState,
17218 overrideProps: overrideProps,
17219 setSuspenseHandler: setSuspenseHandler,
17220 scheduleUpdate: scheduleUpdate,
17221 currentDispatcherRef: ReactCurrentDispatcher,
17222 findHostInstanceByFiber: function (fiber) {
17223 var hostFiber = findCurrentHostFiber(fiber);
17224
17225 if (hostFiber === null) {
17226 return null;
17227 }
17228
17229 return hostFiber.stateNode;
17230 },
17231 findFiberByHostInstance: function (instance) {
17232 if (!findFiberByHostInstance) {
17233 // Might not be implemented by the renderer.
17234 return null;
17235 }
17236
17237 return findFiberByHostInstance(instance);
17238 },
17239 // React Refresh
17240 findHostInstancesForRefresh: findHostInstancesForRefresh,
17241 scheduleRefresh: scheduleRefresh,
17242 scheduleRoot: scheduleRoot,
17243 setRefreshHandler: setRefreshHandler,
17244 // Enables DevTools to append owner stacks to error messages in DEV mode.
17245 getCurrentFiber: function () {
17246 return current;
17247 }
17248 }));
17249}
17250
17251var ReactFiberReconciler = Object.freeze({
17252 updateContainerAtExpirationTime: updateContainerAtExpirationTime,
17253 createContainer: createContainer,
17254 updateContainer: updateContainer,
17255 flushRoot: flushRoot,
17256 computeUniqueAsyncExpiration: computeUniqueAsyncExpiration,
17257 batchedEventUpdates: batchedEventUpdates,
17258 batchedUpdates: batchedUpdates,
17259 unbatchedUpdates: unbatchedUpdates,
17260 deferredUpdates: deferredUpdates,
17261 syncUpdates: syncUpdates,
17262 discreteUpdates: discreteUpdates,
17263 flushDiscreteUpdates: flushDiscreteUpdates,
17264 flushControlled: flushControlled,
17265 flushSync: flushSync,
17266 flushPassiveEffects: flushPassiveEffects,
17267 IsThisRendererActing: IsThisRendererActing,
17268 getPublicRootInstance: getPublicRootInstance,
17269 attemptSynchronousHydration: attemptSynchronousHydration,
17270 findHostInstance: findHostInstance,
17271 findHostInstanceWithWarning: findHostInstanceWithWarning,
17272 findHostInstanceWithNoPortals: findHostInstanceWithNoPortals,
17273 shouldSuspend: shouldSuspend,
17274 injectIntoDevTools: injectIntoDevTools
17275});
17276
17277// This entry point is intentionally not typed. It exists only for third-party
17278// renderers. The renderers we ship (such as React DOM) instead import a named
17279// "inline" entry point (for example, `react-reconciler/inline.dom`). It uses
17280// the same code, but the Flow configuration redirects the host config to its
17281// real implementation so we can check it against exact intended host types.
17282//
17283// Only one renderer (the one you passed to `yarn flow <renderer>`) is fully
17284// type-checked at any given time. The Flow config maps the
17285// `react-reconciler/inline.<renderer>` import (which is *not* Flow typed) to
17286// `react-reconciler/inline-typed` (which *is*) for the current renderer.
17287// On CI, we run Flow checks for each renderer separately.
17288
17289
17290 // TODO: decide on the top-level export form.
17291// This is hacky but makes it work with both Rollup and Jest.
17292
17293
17294var reactReconciler = ReactFiberReconciler.default || ReactFiberReconciler;
17295
17296module.exports = reactReconciler;
17297 var $$$renderer = module.exports;
17298 module.exports = $$$reconciler;
17299 return $$$renderer;
17300 };
17301}