UNPKG

591 kBJavaScriptView Raw
1/** @license React v16.9.0-rc.0
2 * react-art.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12
13
14if (process.env.NODE_ENV !== "production") {
15 (function() {
16'use strict';
17
18var _assign = require('object-assign');
19var React = require('react');
20var Transform = require('art/core/transform');
21var Mode = require('art/modes/current');
22var checkPropTypes = require('prop-types/checkPropTypes');
23var Scheduler = require('scheduler');
24var tracing = require('scheduler/tracing');
25var FastNoSideEffects = require('art/modes/fast-noSideEffects');
26
27// TODO: this is special because it gets imported during build.
28
29var ReactVersion = '16.9.0-rc.0';
30
31var LegacyRoot = 0;
32var BatchedRoot = 1;
33var ConcurrentRoot = 2;
34
35// Do not require this module directly! Use normal `invariant` calls with
36// template literal strings. The messages will be converted to ReactError during
37// build, and in production they will be minified.
38
39// Do not require this module directly! Use normal `invariant` calls with
40// template literal strings. The messages will be converted to ReactError during
41// build, and in production they will be minified.
42
43function ReactError(error) {
44 error.name = 'Invariant Violation';
45 return error;
46}
47
48var FunctionComponent = 0;
49var ClassComponent = 1;
50var IndeterminateComponent = 2; // Before we know whether it is function or class
51var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
52var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
53var HostComponent = 5;
54var HostText = 6;
55var Fragment = 7;
56var Mode$1 = 8;
57var ContextConsumer = 9;
58var ContextProvider = 10;
59var ForwardRef = 11;
60var Profiler = 12;
61var SuspenseComponent = 13;
62var MemoComponent = 14;
63var SimpleMemoComponent = 15;
64var LazyComponent = 16;
65var IncompleteClassComponent = 17;
66var DehydratedSuspenseComponent = 18;
67var SuspenseListComponent = 19;
68var FundamentalComponent = 20;
69
70/**
71 * Use invariant() to assert state which your program assumes to be true.
72 *
73 * Provide sprintf-style format (only %s is supported) and arguments
74 * to provide information about what broke and what you were
75 * expecting.
76 *
77 * The invariant message will be stripped in production, but the invariant
78 * will remain to ensure logic does not differ in production.
79 */
80
81/**
82 * Similar to invariant but only logs a warning if the condition is not met.
83 * This can be used to log issues in development environments in critical
84 * paths. Removing the logging code for production environments will keep the
85 * same logic and follow the same code paths.
86 */
87
88var warningWithoutStack = function () {};
89
90{
91 warningWithoutStack = function (condition, format) {
92 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
93 args[_key - 2] = arguments[_key];
94 }
95
96 if (format === undefined) {
97 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
98 }
99 if (args.length > 8) {
100 // Check before the condition to catch violations early.
101 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
102 }
103 if (condition) {
104 return;
105 }
106 if (typeof console !== 'undefined') {
107 var argsWithFormat = args.map(function (item) {
108 return '' + item;
109 });
110 argsWithFormat.unshift('Warning: ' + format);
111
112 // We intentionally don't use spread (or .apply) directly because it
113 // breaks IE9: https://github.com/facebook/react/issues/13610
114 Function.prototype.apply.call(console.error, console, argsWithFormat);
115 }
116 try {
117 // --- Welcome to debugging React ---
118 // This error was thrown as a convenience so that you can use this stack
119 // to find the callsite that caused this warning to fire.
120 var argIndex = 0;
121 var message = 'Warning: ' + format.replace(/%s/g, function () {
122 return args[argIndex++];
123 });
124 throw new Error(message);
125 } catch (x) {}
126 };
127}
128
129var warningWithoutStack$1 = warningWithoutStack;
130
131/**
132 * `ReactInstanceMap` maintains a mapping from a public facing stateful
133 * instance (key) and the internal representation (value). This allows public
134 * methods to accept the user facing instance as an argument and map them back
135 * to internal methods.
136 *
137 * Note that this module is currently shared and assumed to be stateless.
138 * If this becomes an actual Map, that will break.
139 */
140
141/**
142 * This API should be called `delete` but we'd have to make sure to always
143 * transform these to strings for IE support. When this transform is fully
144 * supported we can rename it.
145 */
146
147
148function get(key) {
149 return key._reactInternalFiber;
150}
151
152
153
154function set(key, value) {
155 key._reactInternalFiber = value;
156}
157
158var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
159
160// Prevent newer renderers from RTE when used with older react package versions.
161// Current owner and dispatcher used to share the same ref,
162// but PR #14548 split them out to better support the react-debug-tools package.
163if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
164 ReactSharedInternals.ReactCurrentDispatcher = {
165 current: null
166 };
167}
168if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
169 ReactSharedInternals.ReactCurrentBatchConfig = {
170 suspense: null
171 };
172}
173
174// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
175// nor polyfill, then a plain number is used for performance.
176var hasSymbol = typeof Symbol === 'function' && Symbol.for;
177
178var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
179var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
180var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
181var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
182var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
183var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
184var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
185// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
186// (unstable) APIs that have been removed. Can we remove the symbols?
187
188var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
189var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
190var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
191var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
192var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
193var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
194var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
195var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
196
197var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
198var FAUX_ITERATOR_SYMBOL = '@@iterator';
199
200function getIteratorFn(maybeIterable) {
201 if (maybeIterable === null || typeof maybeIterable !== 'object') {
202 return null;
203 }
204 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
205 if (typeof maybeIterator === 'function') {
206 return maybeIterator;
207 }
208 return null;
209}
210
211var Pending = 0;
212var Resolved = 1;
213var Rejected = 2;
214
215function refineResolvedLazyComponent(lazyComponent) {
216 return lazyComponent._status === Resolved ? lazyComponent._result : null;
217}
218
219function getWrappedName(outerType, innerType, wrapperName) {
220 var functionName = innerType.displayName || innerType.name || '';
221 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
222}
223
224function getComponentName(type) {
225 if (type == null) {
226 // Host root, text node or just invalid type.
227 return null;
228 }
229 {
230 if (typeof type.tag === 'number') {
231 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
232 }
233 }
234 if (typeof type === 'function') {
235 return type.displayName || type.name || null;
236 }
237 if (typeof type === 'string') {
238 return type;
239 }
240 switch (type) {
241 case REACT_FRAGMENT_TYPE:
242 return 'Fragment';
243 case REACT_PORTAL_TYPE:
244 return 'Portal';
245 case REACT_PROFILER_TYPE:
246 return 'Profiler';
247 case REACT_STRICT_MODE_TYPE:
248 return 'StrictMode';
249 case REACT_SUSPENSE_TYPE:
250 return 'Suspense';
251 case REACT_SUSPENSE_LIST_TYPE:
252 return 'SuspenseList';
253 }
254 if (typeof type === 'object') {
255 switch (type.$$typeof) {
256 case REACT_CONTEXT_TYPE:
257 return 'Context.Consumer';
258 case REACT_PROVIDER_TYPE:
259 return 'Context.Provider';
260 case REACT_FORWARD_REF_TYPE:
261 return getWrappedName(type, type.render, 'ForwardRef');
262 case REACT_MEMO_TYPE:
263 return getComponentName(type.type);
264 case REACT_LAZY_TYPE:
265 {
266 var thenable = type;
267 var resolvedThenable = refineResolvedLazyComponent(thenable);
268 if (resolvedThenable) {
269 return getComponentName(resolvedThenable);
270 }
271 break;
272 }
273 }
274 }
275 return null;
276}
277
278// Don't change these two values. They're used by React Dev Tools.
279var NoEffect = /* */0;
280var PerformedWork = /* */1;
281
282// You can change the rest (and add more).
283var Placement = /* */2;
284var Update = /* */4;
285var PlacementAndUpdate = /* */6;
286var Deletion = /* */8;
287var ContentReset = /* */16;
288var Callback = /* */32;
289var DidCapture = /* */64;
290var Ref = /* */128;
291var Snapshot = /* */256;
292var Passive = /* */512;
293
294// Passive & Update & Callback & Ref & Snapshot
295var LifecycleEffectMask = /* */932;
296
297// Union of all host effects
298var HostEffectMask = /* */1023;
299
300var Incomplete = /* */1024;
301var ShouldCapture = /* */2048;
302
303var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
304
305var MOUNTING = 1;
306var MOUNTED = 2;
307var UNMOUNTED = 3;
308
309function isFiberMountedImpl(fiber) {
310 var node = fiber;
311 if (!fiber.alternate) {
312 // If there is no alternate, this might be a new tree that isn't inserted
313 // yet. If it is, then it will have a pending insertion effect on it.
314 if ((node.effectTag & Placement) !== NoEffect) {
315 return MOUNTING;
316 }
317 while (node.return) {
318 node = node.return;
319 if ((node.effectTag & Placement) !== NoEffect) {
320 return MOUNTING;
321 }
322 }
323 } else {
324 while (node.return) {
325 node = node.return;
326 }
327 }
328 if (node.tag === HostRoot) {
329 // TODO: Check if this was a nested HostRoot when used with
330 // renderContainerIntoSubtree.
331 return MOUNTED;
332 }
333 // If we didn't hit the root, that means that we're in an disconnected tree
334 // that has been unmounted.
335 return UNMOUNTED;
336}
337
338function isFiberMounted(fiber) {
339 return isFiberMountedImpl(fiber) === MOUNTED;
340}
341
342function isMounted(component) {
343 {
344 var owner = ReactCurrentOwner.current;
345 if (owner !== null && owner.tag === ClassComponent) {
346 var ownerFiber = owner;
347 var instance = ownerFiber.stateNode;
348 !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;
349 instance._warnedAboutRefsInRender = true;
350 }
351 }
352
353 var fiber = get(component);
354 if (!fiber) {
355 return false;
356 }
357 return isFiberMountedImpl(fiber) === MOUNTED;
358}
359
360function assertIsMounted(fiber) {
361 (function () {
362 if (!(isFiberMountedImpl(fiber) === MOUNTED)) {
363 {
364 throw ReactError(Error('Unable to find node on an unmounted component.'));
365 }
366 }
367 })();
368}
369
370function findCurrentFiberUsingSlowPath(fiber) {
371 var alternate = fiber.alternate;
372 if (!alternate) {
373 // If there is no alternate, then we only need to check if it is mounted.
374 var state = isFiberMountedImpl(fiber);
375 (function () {
376 if (!(state !== UNMOUNTED)) {
377 {
378 throw ReactError(Error('Unable to find node on an unmounted component.'));
379 }
380 }
381 })();
382 if (state === MOUNTING) {
383 return null;
384 }
385 return fiber;
386 }
387 // If we have two possible branches, we'll walk backwards up to the root
388 // to see what path the root points to. On the way we may hit one of the
389 // special cases and we'll deal with them.
390 var a = fiber;
391 var b = alternate;
392 while (true) {
393 var parentA = a.return;
394 if (parentA === null) {
395 // We're at the root.
396 break;
397 }
398 var parentB = parentA.alternate;
399 if (parentB === null) {
400 // There is no alternate. This is an unusual case. Currently, it only
401 // happens when a Suspense component is hidden. An extra fragment fiber
402 // is inserted in between the Suspense fiber and its children. Skip
403 // over this extra fragment fiber and proceed to the next parent.
404 var nextParent = parentA.return;
405 if (nextParent !== null) {
406 a = b = nextParent;
407 continue;
408 }
409 // If there's no parent, we're at the root.
410 break;
411 }
412
413 // If both copies of the parent fiber point to the same child, we can
414 // assume that the child is current. This happens when we bailout on low
415 // priority: the bailed out fiber's child reuses the current child.
416 if (parentA.child === parentB.child) {
417 var child = parentA.child;
418 while (child) {
419 if (child === a) {
420 // We've determined that A is the current branch.
421 assertIsMounted(parentA);
422 return fiber;
423 }
424 if (child === b) {
425 // We've determined that B is the current branch.
426 assertIsMounted(parentA);
427 return alternate;
428 }
429 child = child.sibling;
430 }
431 // We should never have an alternate for any mounting node. So the only
432 // way this could possibly happen is if this was unmounted, if at all.
433 (function () {
434 {
435 {
436 throw ReactError(Error('Unable to find node on an unmounted component.'));
437 }
438 }
439 })();
440 }
441
442 if (a.return !== b.return) {
443 // The return pointer of A and the return pointer of B point to different
444 // fibers. We assume that return pointers never criss-cross, so A must
445 // belong to the child set of A.return, and B must belong to the child
446 // set of B.return.
447 a = parentA;
448 b = parentB;
449 } else {
450 // The return pointers point to the same fiber. We'll have to use the
451 // default, slow path: scan the child sets of each parent alternate to see
452 // which child belongs to which set.
453 //
454 // Search parent A's child set
455 var didFindChild = false;
456 var _child = parentA.child;
457 while (_child) {
458 if (_child === a) {
459 didFindChild = true;
460 a = parentA;
461 b = parentB;
462 break;
463 }
464 if (_child === b) {
465 didFindChild = true;
466 b = parentA;
467 a = parentB;
468 break;
469 }
470 _child = _child.sibling;
471 }
472 if (!didFindChild) {
473 // Search parent B's child set
474 _child = parentB.child;
475 while (_child) {
476 if (_child === a) {
477 didFindChild = true;
478 a = parentB;
479 b = parentA;
480 break;
481 }
482 if (_child === b) {
483 didFindChild = true;
484 b = parentB;
485 a = parentA;
486 break;
487 }
488 _child = _child.sibling;
489 }
490 (function () {
491 if (!didFindChild) {
492 {
493 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.'));
494 }
495 }
496 })();
497 }
498 }
499
500 (function () {
501 if (!(a.alternate === b)) {
502 {
503 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.'));
504 }
505 }
506 })();
507 }
508 // If the root is not a host container, we're in a disconnected tree. I.e.
509 // unmounted.
510 (function () {
511 if (!(a.tag === HostRoot)) {
512 {
513 throw ReactError(Error('Unable to find node on an unmounted component.'));
514 }
515 }
516 })();
517 if (a.stateNode.current === a) {
518 // We've determined that A is the current branch.
519 return fiber;
520 }
521 // Otherwise B has to be current branch.
522 return alternate;
523}
524
525function findCurrentHostFiber(parent) {
526 var currentParent = findCurrentFiberUsingSlowPath(parent);
527 if (!currentParent) {
528 return null;
529 }
530
531 // Next we'll drill down this component to find the first HostComponent/Text.
532 var node = currentParent;
533 while (true) {
534 if (node.tag === HostComponent || node.tag === HostText) {
535 return node;
536 } else if (node.child) {
537 node.child.return = node;
538 node = node.child;
539 continue;
540 }
541 if (node === currentParent) {
542 return null;
543 }
544 while (!node.sibling) {
545 if (!node.return || node.return === currentParent) {
546 return null;
547 }
548 node = node.return;
549 }
550 node.sibling.return = node.return;
551 node = node.sibling;
552 }
553 // Flow needs the return null here, but ESLint complains about it.
554 // eslint-disable-next-line no-unreachable
555 return null;
556}
557
558var TYPES = {
559 CLIPPING_RECTANGLE: 'ClippingRectangle',
560 GROUP: 'Group',
561 SHAPE: 'Shape',
562 TEXT: 'Text'
563};
564
565var EVENT_TYPES = {
566 onClick: 'click',
567 onMouseMove: 'mousemove',
568 onMouseOver: 'mouseover',
569 onMouseOut: 'mouseout',
570 onMouseUp: 'mouseup',
571 onMouseDown: 'mousedown'
572};
573
574function childrenAsString(children) {
575 if (!children) {
576 return '';
577 } else if (typeof children === 'string') {
578 return children;
579 } else if (children.length) {
580 return children.join('');
581 } else {
582 return '';
583 }
584}
585
586// Renderers that don't support persistence
587// can re-export everything from this module.
588
589function shim() {
590 (function () {
591 {
592 {
593 throw ReactError(Error('The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue.'));
594 }
595 }
596 })();
597}
598
599// Persistence (when unsupported)
600var supportsPersistence = false;
601var cloneInstance = shim;
602var cloneFundamentalInstance = shim;
603var createContainerChildSet = shim;
604var appendChildToContainerChildSet = shim;
605var finalizeContainerChildren = shim;
606var replaceContainerChildren = shim;
607var cloneHiddenInstance = shim;
608var cloneHiddenTextInstance = shim;
609
610// Renderers that don't support hydration
611// can re-export everything from this module.
612
613function shim$1() {
614 (function () {
615 {
616 {
617 throw ReactError(Error('The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue.'));
618 }
619 }
620 })();
621}
622
623// Hydration (when unsupported)
624
625var supportsHydration = false;
626var canHydrateInstance = shim$1;
627var canHydrateTextInstance = shim$1;
628var canHydrateSuspenseInstance = shim$1;
629var isSuspenseInstancePending = shim$1;
630var isSuspenseInstanceFallback = shim$1;
631var registerSuspenseInstanceRetry = shim$1;
632var getNextHydratableSibling = shim$1;
633var getFirstHydratableChild = shim$1;
634var hydrateInstance = shim$1;
635var hydrateTextInstance = shim$1;
636var getNextHydratableInstanceAfterSuspenseInstance = shim$1;
637var clearSuspenseBoundary = shim$1;
638var clearSuspenseBoundaryFromContainer = shim$1;
639var didNotMatchHydratedContainerTextInstance = shim$1;
640var didNotMatchHydratedTextInstance = shim$1;
641var didNotHydrateContainerInstance = shim$1;
642var didNotHydrateInstance = shim$1;
643var didNotFindHydratableContainerInstance = shim$1;
644var didNotFindHydratableContainerTextInstance = shim$1;
645var didNotFindHydratableContainerSuspenseInstance = shim$1;
646var didNotFindHydratableInstance = shim$1;
647var didNotFindHydratableTextInstance = shim$1;
648var didNotFindHydratableSuspenseInstance = shim$1;
649
650var pooledTransform = new Transform();
651
652var NO_CONTEXT = {};
653var UPDATE_SIGNAL = {};
654{
655 Object.freeze(NO_CONTEXT);
656 Object.freeze(UPDATE_SIGNAL);
657}
658
659/** Helper Methods */
660
661function addEventListeners(instance, type, listener) {
662 // We need to explicitly unregister before unmount.
663 // For this reason we need to track subscriptions.
664 if (!instance._listeners) {
665 instance._listeners = {};
666 instance._subscriptions = {};
667 }
668
669 instance._listeners[type] = listener;
670
671 if (listener) {
672 if (!instance._subscriptions[type]) {
673 instance._subscriptions[type] = instance.subscribe(type, createEventHandler(instance), instance);
674 }
675 } else {
676 if (instance._subscriptions[type]) {
677 instance._subscriptions[type]();
678 delete instance._subscriptions[type];
679 }
680 }
681}
682
683function createEventHandler(instance) {
684 return function handleEvent(event) {
685 var listener = instance._listeners[event.type];
686
687 if (!listener) {
688 // Noop
689 } else if (typeof listener === 'function') {
690 listener.call(instance, event);
691 } else if (listener.handleEvent) {
692 listener.handleEvent(event);
693 }
694 };
695}
696
697function destroyEventListeners(instance) {
698 if (instance._subscriptions) {
699 for (var type in instance._subscriptions) {
700 instance._subscriptions[type]();
701 }
702 }
703
704 instance._subscriptions = null;
705 instance._listeners = null;
706}
707
708function getScaleX(props) {
709 if (props.scaleX != null) {
710 return props.scaleX;
711 } else if (props.scale != null) {
712 return props.scale;
713 } else {
714 return 1;
715 }
716}
717
718function getScaleY(props) {
719 if (props.scaleY != null) {
720 return props.scaleY;
721 } else if (props.scale != null) {
722 return props.scale;
723 } else {
724 return 1;
725 }
726}
727
728function isSameFont(oldFont, newFont) {
729 if (oldFont === newFont) {
730 return true;
731 } else if (typeof newFont === 'string' || typeof oldFont === 'string') {
732 return false;
733 } else {
734 return newFont.fontSize === oldFont.fontSize && newFont.fontStyle === oldFont.fontStyle && newFont.fontVariant === oldFont.fontVariant && newFont.fontWeight === oldFont.fontWeight && newFont.fontFamily === oldFont.fontFamily;
735 }
736}
737
738/** Render Methods */
739
740function applyClippingRectangleProps(instance, props) {
741 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
742
743 applyNodeProps(instance, props, prevProps);
744
745 instance.width = props.width;
746 instance.height = props.height;
747}
748
749function applyGroupProps(instance, props) {
750 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
751
752 applyNodeProps(instance, props, prevProps);
753
754 instance.width = props.width;
755 instance.height = props.height;
756}
757
758function applyNodeProps(instance, props) {
759 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
760
761 var scaleX = getScaleX(props);
762 var scaleY = getScaleY(props);
763
764 pooledTransform.transformTo(1, 0, 0, 1, 0, 0).move(props.x || 0, props.y || 0).rotate(props.rotation || 0, props.originX, props.originY).scale(scaleX, scaleY, props.originX, props.originY);
765
766 if (props.transform != null) {
767 pooledTransform.transform(props.transform);
768 }
769
770 if (instance.xx !== pooledTransform.xx || instance.yx !== pooledTransform.yx || instance.xy !== pooledTransform.xy || instance.yy !== pooledTransform.yy || instance.x !== pooledTransform.x || instance.y !== pooledTransform.y) {
771 instance.transformTo(pooledTransform);
772 }
773
774 if (props.cursor !== prevProps.cursor || props.title !== prevProps.title) {
775 instance.indicate(props.cursor, props.title);
776 }
777
778 if (instance.blend && props.opacity !== prevProps.opacity) {
779 instance.blend(props.opacity == null ? 1 : props.opacity);
780 }
781
782 if (props.visible !== prevProps.visible) {
783 if (props.visible == null || props.visible) {
784 instance.show();
785 } else {
786 instance.hide();
787 }
788 }
789
790 for (var type in EVENT_TYPES) {
791 addEventListeners(instance, EVENT_TYPES[type], props[type]);
792 }
793}
794
795function applyRenderableNodeProps(instance, props) {
796 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
797
798 applyNodeProps(instance, props, prevProps);
799
800 if (prevProps.fill !== props.fill) {
801 if (props.fill && props.fill.applyFill) {
802 props.fill.applyFill(instance);
803 } else {
804 instance.fill(props.fill);
805 }
806 }
807 if (prevProps.stroke !== props.stroke || prevProps.strokeWidth !== props.strokeWidth || prevProps.strokeCap !== props.strokeCap || prevProps.strokeJoin !== props.strokeJoin ||
808 // TODO: Consider deep check of stokeDash; may benefit VML in IE.
809 prevProps.strokeDash !== props.strokeDash) {
810 instance.stroke(props.stroke, props.strokeWidth, props.strokeCap, props.strokeJoin, props.strokeDash);
811 }
812}
813
814function applyShapeProps(instance, props) {
815 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
816
817 applyRenderableNodeProps(instance, props, prevProps);
818
819 var path = props.d || childrenAsString(props.children);
820
821 var prevDelta = instance._prevDelta;
822 var prevPath = instance._prevPath;
823
824 if (path !== prevPath || path.delta !== prevDelta || prevProps.height !== props.height || prevProps.width !== props.width) {
825 instance.draw(path, props.width, props.height);
826
827 instance._prevDelta = path.delta;
828 instance._prevPath = path;
829 }
830}
831
832function applyTextProps(instance, props) {
833 var prevProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
834
835 applyRenderableNodeProps(instance, props, prevProps);
836
837 var string = props.children;
838
839 if (instance._currentString !== string || !isSameFont(props.font, prevProps.font) || props.alignment !== prevProps.alignment || props.path !== prevProps.path) {
840 instance.draw(string, props.font, props.alignment, props.path);
841
842 instance._currentString = string;
843 }
844}
845
846function appendInitialChild(parentInstance, child) {
847 if (typeof child === 'string') {
848 // Noop for string children of Text (eg <Text>{'foo'}{'bar'}</Text>)
849 (function () {
850 {
851 {
852 throw ReactError(Error('Text children should already be flattened.'));
853 }
854 }
855 })();
856 return;
857 }
858
859 child.inject(parentInstance);
860}
861
862function createInstance(type, props, internalInstanceHandle) {
863 var instance = void 0;
864
865 switch (type) {
866 case TYPES.CLIPPING_RECTANGLE:
867 instance = Mode.ClippingRectangle();
868 instance._applyProps = applyClippingRectangleProps;
869 break;
870 case TYPES.GROUP:
871 instance = Mode.Group();
872 instance._applyProps = applyGroupProps;
873 break;
874 case TYPES.SHAPE:
875 instance = Mode.Shape();
876 instance._applyProps = applyShapeProps;
877 break;
878 case TYPES.TEXT:
879 instance = Mode.Text(props.children, props.font, props.alignment, props.path);
880 instance._applyProps = applyTextProps;
881 break;
882 }
883
884 (function () {
885 if (!instance) {
886 {
887 throw ReactError(Error('ReactART does not support the type "' + type + '"'));
888 }
889 }
890 })();
891
892 instance._applyProps(instance, props);
893
894 return instance;
895}
896
897function createTextInstance(text, rootContainerInstance, internalInstanceHandle) {
898 return text;
899}
900
901function finalizeInitialChildren(domElement, type, props) {
902 return false;
903}
904
905function getPublicInstance(instance) {
906 return instance;
907}
908
909function prepareForCommit() {
910 // Noop
911}
912
913function prepareUpdate(domElement, type, oldProps, newProps) {
914 return UPDATE_SIGNAL;
915}
916
917function resetAfterCommit() {
918 // Noop
919}
920
921function resetTextContent(domElement) {
922 // Noop
923}
924
925function shouldDeprioritizeSubtree(type, props) {
926 return false;
927}
928
929function getRootHostContext() {
930 return NO_CONTEXT;
931}
932
933function getChildHostContext() {
934 return NO_CONTEXT;
935}
936
937var scheduleTimeout = setTimeout;
938var cancelTimeout = clearTimeout;
939var noTimeout = -1;
940
941function shouldSetTextContent(type, props) {
942 return typeof props.children === 'string' || typeof props.children === 'number';
943}
944
945// The ART renderer is secondary to the React DOM renderer.
946var isPrimaryRenderer = false;
947
948// The ART renderer shouldn't trigger missing act() warnings
949var warnsIfNotActing = false;
950
951var supportsMutation = true;
952
953function appendChild(parentInstance, child) {
954 if (child.parentNode === parentInstance) {
955 child.eject();
956 }
957 child.inject(parentInstance);
958}
959
960function appendChildToContainer(parentInstance, child) {
961 if (child.parentNode === parentInstance) {
962 child.eject();
963 }
964 child.inject(parentInstance);
965}
966
967function insertBefore(parentInstance, child, beforeChild) {
968 (function () {
969 if (!(child !== beforeChild)) {
970 {
971 throw ReactError(Error('ReactART: Can not insert node before itself'));
972 }
973 }
974 })();
975 child.injectBefore(beforeChild);
976}
977
978function insertInContainerBefore(parentInstance, child, beforeChild) {
979 (function () {
980 if (!(child !== beforeChild)) {
981 {
982 throw ReactError(Error('ReactART: Can not insert node before itself'));
983 }
984 }
985 })();
986 child.injectBefore(beforeChild);
987}
988
989function removeChild(parentInstance, child) {
990 destroyEventListeners(child);
991 child.eject();
992}
993
994function removeChildFromContainer(parentInstance, child) {
995 destroyEventListeners(child);
996 child.eject();
997}
998
999
1000
1001
1002
1003function commitUpdate(instance, updatePayload, type, oldProps, newProps) {
1004 instance._applyProps(instance, newProps, oldProps);
1005}
1006
1007function hideInstance(instance) {
1008 instance.hide();
1009}
1010
1011
1012
1013function unhideInstance(instance, props) {
1014 if (props.visible == null || props.visible) {
1015 instance.show();
1016 }
1017}
1018
1019function unhideTextInstance(textInstance, text) {
1020 // Noop
1021}
1022
1023function mountResponderInstance(responder, responderInstance, props, state, instance, rootContainerInstance) {
1024 throw new Error('Not yet implemented.');
1025}
1026
1027function unmountResponderInstance(responderInstance) {
1028 throw new Error('Not yet implemented.');
1029}
1030
1031function getFundamentalComponentInstance(fundamentalInstance) {
1032 throw new Error('Not yet implemented.');
1033}
1034
1035function mountFundamentalComponent(fundamentalInstance) {
1036 throw new Error('Not yet implemented.');
1037}
1038
1039function shouldUpdateFundamentalComponent(fundamentalInstance) {
1040 throw new Error('Not yet implemented.');
1041}
1042
1043function updateFundamentalComponent(fundamentalInstance) {
1044 throw new Error('Not yet implemented.');
1045}
1046
1047function unmountFundamentalComponent(fundamentalInstance) {
1048 throw new Error('Not yet implemented.');
1049}
1050
1051var enableUserTimingAPI = true;
1052
1053// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
1054var debugRenderPhaseSideEffects = false;
1055
1056// In some cases, StrictMode should also double-render lifecycles.
1057// This can be confusing for tests though,
1058// And it can be bad for performance in production.
1059// This feature flag can be used to control the behavior:
1060var debugRenderPhaseSideEffectsForStrictMode = true;
1061
1062// To preserve the "Pause on caught exceptions" behavior of the debugger, we
1063// replay the begin phase of a failed component inside invokeGuardedCallback.
1064var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
1065
1066// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
1067var warnAboutDeprecatedLifecycles = true;
1068
1069// Gather advanced timing metrics for Profiler subtrees.
1070var enableProfilerTimer = true;
1071
1072// Trace which interactions trigger each commit.
1073var enableSchedulerTracing = true;
1074
1075// Only used in www builds.
1076var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
1077
1078// Only used in www builds.
1079
1080
1081// Only used in www builds.
1082
1083
1084// Disable javascript: URL strings in href for XSS protection.
1085
1086
1087// React Fire: prevent the value and checked attributes from syncing
1088// with their related DOM properties
1089
1090
1091// These APIs will no longer be "unstable" in the upcoming 16.7 release,
1092// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
1093
1094
1095
1096
1097// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
1098// This is a flag so we can fix warnings in RN core before turning it on
1099
1100
1101// Experimental React Flare event system and event components support.
1102var enableFlareAPI = false;
1103
1104// Experimental Host Component support.
1105var enableFundamentalAPI = false;
1106
1107// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
1108
1109
1110// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
1111// Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
1112var warnAboutUnmockedScheduler = false;
1113// Temporary flag to revert the fix in #15650
1114var revertPassiveEffectsChange = false;
1115
1116// For tests, we flush suspense fallbacks in an act scope;
1117// *except* in some of our own tests, where we test incremental loading states.
1118var flushSuspenseFallbacksInTests = true;
1119
1120// Changes priority of some events like mousemove to user-blocking priority,
1121// but without making them discrete. The flag exists in case it causes
1122// starvation problems.
1123
1124
1125// Add a callback property to suspense to notify which promises are currently
1126// in the update queue. This allows reporting and tracing of what is causing
1127// the user to see a loading state.
1128var enableSuspenseCallback = false;
1129
1130// Part of the simplification of React.createElement so we can eventually move
1131// from React.createElement to React.jsx
1132// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
1133var warnAboutDefaultPropsOnFunctionComponents = false;
1134
1135var disableLegacyContext = false;
1136
1137var disableSchedulerTimeoutBasedOnReactExpirationTime = false;
1138
1139var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
1140
1141var describeComponentFrame = function (name, source, ownerName) {
1142 var sourceInfo = '';
1143 if (source) {
1144 var path = source.fileName;
1145 var fileName = path.replace(BEFORE_SLASH_RE, '');
1146 {
1147 // In DEV, include code for a common special case:
1148 // prefer "folder/index.js" instead of just "index.js".
1149 if (/^index\./.test(fileName)) {
1150 var match = path.match(BEFORE_SLASH_RE);
1151 if (match) {
1152 var pathBeforeSlash = match[1];
1153 if (pathBeforeSlash) {
1154 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
1155 fileName = folderName + '/' + fileName;
1156 }
1157 }
1158 }
1159 }
1160 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
1161 } else if (ownerName) {
1162 sourceInfo = ' (created by ' + ownerName + ')';
1163 }
1164 return '\n in ' + (name || 'Unknown') + sourceInfo;
1165};
1166
1167var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
1168
1169function describeFiber(fiber) {
1170 switch (fiber.tag) {
1171 case HostRoot:
1172 case HostPortal:
1173 case HostText:
1174 case Fragment:
1175 case ContextProvider:
1176 case ContextConsumer:
1177 return '';
1178 default:
1179 var owner = fiber._debugOwner;
1180 var source = fiber._debugSource;
1181 var name = getComponentName(fiber.type);
1182 var ownerName = null;
1183 if (owner) {
1184 ownerName = getComponentName(owner.type);
1185 }
1186 return describeComponentFrame(name, source, ownerName);
1187 }
1188}
1189
1190function getStackByFiberInDevAndProd(workInProgress) {
1191 var info = '';
1192 var node = workInProgress;
1193 do {
1194 info += describeFiber(node);
1195 node = node.return;
1196 } while (node);
1197 return info;
1198}
1199
1200var current = null;
1201var phase = null;
1202
1203function getCurrentFiberOwnerNameInDevOrNull() {
1204 {
1205 if (current === null) {
1206 return null;
1207 }
1208 var owner = current._debugOwner;
1209 if (owner !== null && typeof owner !== 'undefined') {
1210 return getComponentName(owner.type);
1211 }
1212 }
1213 return null;
1214}
1215
1216function getCurrentFiberStackInDev() {
1217 {
1218 if (current === null) {
1219 return '';
1220 }
1221 // Safe because if current fiber exists, we are reconciling,
1222 // and it is guaranteed to be the work-in-progress version.
1223 return getStackByFiberInDevAndProd(current);
1224 }
1225 return '';
1226}
1227
1228function resetCurrentFiber() {
1229 {
1230 ReactDebugCurrentFrame.getCurrentStack = null;
1231 current = null;
1232 phase = null;
1233 }
1234}
1235
1236function setCurrentFiber(fiber) {
1237 {
1238 ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
1239 current = fiber;
1240 phase = null;
1241 }
1242}
1243
1244function setCurrentPhase(lifeCyclePhase) {
1245 {
1246 phase = lifeCyclePhase;
1247 }
1248}
1249
1250// Prefix measurements so that it's possible to filter them.
1251// Longer prefixes are hard to read in DevTools.
1252var reactEmoji = '\u269B';
1253var warningEmoji = '\u26D4';
1254var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
1255
1256// Keep track of current fiber so that we know the path to unwind on pause.
1257// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
1258var currentFiber = null;
1259// If we're in the middle of user code, which fiber and method is it?
1260// Reusing `currentFiber` would be confusing for this because user code fiber
1261// can change during commit phase too, but we don't need to unwind it (since
1262// lifecycles in the commit phase don't resemble a tree).
1263var currentPhase = null;
1264var currentPhaseFiber = null;
1265// Did lifecycle hook schedule an update? This is often a performance problem,
1266// so we will keep track of it, and include it in the report.
1267// Track commits caused by cascading updates.
1268var isCommitting = false;
1269var hasScheduledUpdateInCurrentCommit = false;
1270var hasScheduledUpdateInCurrentPhase = false;
1271var commitCountInCurrentWorkLoop = 0;
1272var effectCountInCurrentCommit = 0;
1273var isWaitingForCallback = false;
1274// During commits, we only show a measurement once per method name
1275// to avoid stretch the commit phase with measurement overhead.
1276var labelsInCurrentCommit = new Set();
1277
1278var formatMarkName = function (markName) {
1279 return reactEmoji + ' ' + markName;
1280};
1281
1282var formatLabel = function (label, warning) {
1283 var prefix = warning ? warningEmoji + ' ' : reactEmoji + ' ';
1284 var suffix = warning ? ' Warning: ' + warning : '';
1285 return '' + prefix + label + suffix;
1286};
1287
1288var beginMark = function (markName) {
1289 performance.mark(formatMarkName(markName));
1290};
1291
1292var clearMark = function (markName) {
1293 performance.clearMarks(formatMarkName(markName));
1294};
1295
1296var endMark = function (label, markName, warning) {
1297 var formattedMarkName = formatMarkName(markName);
1298 var formattedLabel = formatLabel(label, warning);
1299 try {
1300 performance.measure(formattedLabel, formattedMarkName);
1301 } catch (err) {}
1302 // If previous mark was missing for some reason, this will throw.
1303 // This could only happen if React crashed in an unexpected place earlier.
1304 // Don't pile on with more errors.
1305
1306 // Clear marks immediately to avoid growing buffer.
1307 performance.clearMarks(formattedMarkName);
1308 performance.clearMeasures(formattedLabel);
1309};
1310
1311var getFiberMarkName = function (label, debugID) {
1312 return label + ' (#' + debugID + ')';
1313};
1314
1315var getFiberLabel = function (componentName, isMounted, phase) {
1316 if (phase === null) {
1317 // These are composite component total time measurements.
1318 return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']';
1319 } else {
1320 // Composite component methods.
1321 return componentName + '.' + phase;
1322 }
1323};
1324
1325var beginFiberMark = function (fiber, phase) {
1326 var componentName = getComponentName(fiber.type) || 'Unknown';
1327 var debugID = fiber._debugID;
1328 var isMounted = fiber.alternate !== null;
1329 var label = getFiberLabel(componentName, isMounted, phase);
1330
1331 if (isCommitting && labelsInCurrentCommit.has(label)) {
1332 // During the commit phase, we don't show duplicate labels because
1333 // there is a fixed overhead for every measurement, and we don't
1334 // want to stretch the commit phase beyond necessary.
1335 return false;
1336 }
1337 labelsInCurrentCommit.add(label);
1338
1339 var markName = getFiberMarkName(label, debugID);
1340 beginMark(markName);
1341 return true;
1342};
1343
1344var clearFiberMark = function (fiber, phase) {
1345 var componentName = getComponentName(fiber.type) || 'Unknown';
1346 var debugID = fiber._debugID;
1347 var isMounted = fiber.alternate !== null;
1348 var label = getFiberLabel(componentName, isMounted, phase);
1349 var markName = getFiberMarkName(label, debugID);
1350 clearMark(markName);
1351};
1352
1353var endFiberMark = function (fiber, phase, warning) {
1354 var componentName = getComponentName(fiber.type) || 'Unknown';
1355 var debugID = fiber._debugID;
1356 var isMounted = fiber.alternate !== null;
1357 var label = getFiberLabel(componentName, isMounted, phase);
1358 var markName = getFiberMarkName(label, debugID);
1359 endMark(label, markName, warning);
1360};
1361
1362var shouldIgnoreFiber = function (fiber) {
1363 // Host components should be skipped in the timeline.
1364 // We could check typeof fiber.type, but does this work with RN?
1365 switch (fiber.tag) {
1366 case HostRoot:
1367 case HostComponent:
1368 case HostText:
1369 case HostPortal:
1370 case Fragment:
1371 case ContextProvider:
1372 case ContextConsumer:
1373 case Mode$1:
1374 return true;
1375 default:
1376 return false;
1377 }
1378};
1379
1380var clearPendingPhaseMeasurement = function () {
1381 if (currentPhase !== null && currentPhaseFiber !== null) {
1382 clearFiberMark(currentPhaseFiber, currentPhase);
1383 }
1384 currentPhaseFiber = null;
1385 currentPhase = null;
1386 hasScheduledUpdateInCurrentPhase = false;
1387};
1388
1389var pauseTimers = function () {
1390 // Stops all currently active measurements so that they can be resumed
1391 // if we continue in a later deferred loop from the same unit of work.
1392 var fiber = currentFiber;
1393 while (fiber) {
1394 if (fiber._debugIsCurrentlyTiming) {
1395 endFiberMark(fiber, null, null);
1396 }
1397 fiber = fiber.return;
1398 }
1399};
1400
1401var resumeTimersRecursively = function (fiber) {
1402 if (fiber.return !== null) {
1403 resumeTimersRecursively(fiber.return);
1404 }
1405 if (fiber._debugIsCurrentlyTiming) {
1406 beginFiberMark(fiber, null);
1407 }
1408};
1409
1410var resumeTimers = function () {
1411 // Resumes all measurements that were active during the last deferred loop.
1412 if (currentFiber !== null) {
1413 resumeTimersRecursively(currentFiber);
1414 }
1415};
1416
1417function recordEffect() {
1418 if (enableUserTimingAPI) {
1419 effectCountInCurrentCommit++;
1420 }
1421}
1422
1423function recordScheduleUpdate() {
1424 if (enableUserTimingAPI) {
1425 if (isCommitting) {
1426 hasScheduledUpdateInCurrentCommit = true;
1427 }
1428 if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
1429 hasScheduledUpdateInCurrentPhase = true;
1430 }
1431 }
1432}
1433
1434function startRequestCallbackTimer() {
1435 if (enableUserTimingAPI) {
1436 if (supportsUserTiming && !isWaitingForCallback) {
1437 isWaitingForCallback = true;
1438 beginMark('(Waiting for async callback...)');
1439 }
1440 }
1441}
1442
1443function stopRequestCallbackTimer(didExpire) {
1444 if (enableUserTimingAPI) {
1445 if (supportsUserTiming) {
1446 isWaitingForCallback = false;
1447 var warning = didExpire ? 'Update expired; will flush synchronously' : null;
1448 endMark('(Waiting for async callback...)', '(Waiting for async callback...)', warning);
1449 }
1450 }
1451}
1452
1453function startWorkTimer(fiber) {
1454 if (enableUserTimingAPI) {
1455 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1456 return;
1457 }
1458 // If we pause, this is the fiber to unwind from.
1459 currentFiber = fiber;
1460 if (!beginFiberMark(fiber, null)) {
1461 return;
1462 }
1463 fiber._debugIsCurrentlyTiming = true;
1464 }
1465}
1466
1467function cancelWorkTimer(fiber) {
1468 if (enableUserTimingAPI) {
1469 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1470 return;
1471 }
1472 // Remember we shouldn't complete measurement for this fiber.
1473 // Otherwise flamechart will be deep even for small updates.
1474 fiber._debugIsCurrentlyTiming = false;
1475 clearFiberMark(fiber, null);
1476 }
1477}
1478
1479function stopWorkTimer(fiber) {
1480 if (enableUserTimingAPI) {
1481 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1482 return;
1483 }
1484 // If we pause, its parent is the fiber to unwind from.
1485 currentFiber = fiber.return;
1486 if (!fiber._debugIsCurrentlyTiming) {
1487 return;
1488 }
1489 fiber._debugIsCurrentlyTiming = false;
1490 endFiberMark(fiber, null, null);
1491 }
1492}
1493
1494function stopFailedWorkTimer(fiber) {
1495 if (enableUserTimingAPI) {
1496 if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
1497 return;
1498 }
1499 // If we pause, its parent is the fiber to unwind from.
1500 currentFiber = fiber.return;
1501 if (!fiber._debugIsCurrentlyTiming) {
1502 return;
1503 }
1504 fiber._debugIsCurrentlyTiming = false;
1505 var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
1506 endFiberMark(fiber, null, warning);
1507 }
1508}
1509
1510function startPhaseTimer(fiber, phase) {
1511 if (enableUserTimingAPI) {
1512 if (!supportsUserTiming) {
1513 return;
1514 }
1515 clearPendingPhaseMeasurement();
1516 if (!beginFiberMark(fiber, phase)) {
1517 return;
1518 }
1519 currentPhaseFiber = fiber;
1520 currentPhase = phase;
1521 }
1522}
1523
1524function stopPhaseTimer() {
1525 if (enableUserTimingAPI) {
1526 if (!supportsUserTiming) {
1527 return;
1528 }
1529 if (currentPhase !== null && currentPhaseFiber !== null) {
1530 var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
1531 endFiberMark(currentPhaseFiber, currentPhase, warning);
1532 }
1533 currentPhase = null;
1534 currentPhaseFiber = null;
1535 }
1536}
1537
1538function startWorkLoopTimer(nextUnitOfWork) {
1539 if (enableUserTimingAPI) {
1540 currentFiber = nextUnitOfWork;
1541 if (!supportsUserTiming) {
1542 return;
1543 }
1544 commitCountInCurrentWorkLoop = 0;
1545 // This is top level call.
1546 // Any other measurements are performed within.
1547 beginMark('(React Tree Reconciliation)');
1548 // Resume any measurements that were in progress during the last loop.
1549 resumeTimers();
1550 }
1551}
1552
1553function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
1554 if (enableUserTimingAPI) {
1555 if (!supportsUserTiming) {
1556 return;
1557 }
1558 var warning = null;
1559 if (interruptedBy !== null) {
1560 if (interruptedBy.tag === HostRoot) {
1561 warning = 'A top-level update interrupted the previous render';
1562 } else {
1563 var componentName = getComponentName(interruptedBy.type) || 'Unknown';
1564 warning = 'An update to ' + componentName + ' interrupted the previous render';
1565 }
1566 } else if (commitCountInCurrentWorkLoop > 1) {
1567 warning = 'There were cascading updates';
1568 }
1569 commitCountInCurrentWorkLoop = 0;
1570 var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
1571 // Pause any measurements until the next loop.
1572 pauseTimers();
1573 endMark(label, '(React Tree Reconciliation)', warning);
1574 }
1575}
1576
1577function startCommitTimer() {
1578 if (enableUserTimingAPI) {
1579 if (!supportsUserTiming) {
1580 return;
1581 }
1582 isCommitting = true;
1583 hasScheduledUpdateInCurrentCommit = false;
1584 labelsInCurrentCommit.clear();
1585 beginMark('(Committing Changes)');
1586 }
1587}
1588
1589function stopCommitTimer() {
1590 if (enableUserTimingAPI) {
1591 if (!supportsUserTiming) {
1592 return;
1593 }
1594
1595 var warning = null;
1596 if (hasScheduledUpdateInCurrentCommit) {
1597 warning = 'Lifecycle hook scheduled a cascading update';
1598 } else if (commitCountInCurrentWorkLoop > 0) {
1599 warning = 'Caused by a cascading update in earlier commit';
1600 }
1601 hasScheduledUpdateInCurrentCommit = false;
1602 commitCountInCurrentWorkLoop++;
1603 isCommitting = false;
1604 labelsInCurrentCommit.clear();
1605
1606 endMark('(Committing Changes)', '(Committing Changes)', warning);
1607 }
1608}
1609
1610function startCommitSnapshotEffectsTimer() {
1611 if (enableUserTimingAPI) {
1612 if (!supportsUserTiming) {
1613 return;
1614 }
1615 effectCountInCurrentCommit = 0;
1616 beginMark('(Committing Snapshot Effects)');
1617 }
1618}
1619
1620function stopCommitSnapshotEffectsTimer() {
1621 if (enableUserTimingAPI) {
1622 if (!supportsUserTiming) {
1623 return;
1624 }
1625 var count = effectCountInCurrentCommit;
1626 effectCountInCurrentCommit = 0;
1627 endMark('(Committing Snapshot Effects: ' + count + ' Total)', '(Committing Snapshot Effects)', null);
1628 }
1629}
1630
1631function startCommitHostEffectsTimer() {
1632 if (enableUserTimingAPI) {
1633 if (!supportsUserTiming) {
1634 return;
1635 }
1636 effectCountInCurrentCommit = 0;
1637 beginMark('(Committing Host Effects)');
1638 }
1639}
1640
1641function stopCommitHostEffectsTimer() {
1642 if (enableUserTimingAPI) {
1643 if (!supportsUserTiming) {
1644 return;
1645 }
1646 var count = effectCountInCurrentCommit;
1647 effectCountInCurrentCommit = 0;
1648 endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null);
1649 }
1650}
1651
1652function startCommitLifeCyclesTimer() {
1653 if (enableUserTimingAPI) {
1654 if (!supportsUserTiming) {
1655 return;
1656 }
1657 effectCountInCurrentCommit = 0;
1658 beginMark('(Calling Lifecycle Methods)');
1659 }
1660}
1661
1662function stopCommitLifeCyclesTimer() {
1663 if (enableUserTimingAPI) {
1664 if (!supportsUserTiming) {
1665 return;
1666 }
1667 var count = effectCountInCurrentCommit;
1668 effectCountInCurrentCommit = 0;
1669 endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null);
1670 }
1671}
1672
1673var valueStack = [];
1674
1675var fiberStack = void 0;
1676
1677{
1678 fiberStack = [];
1679}
1680
1681var index = -1;
1682
1683function createCursor(defaultValue) {
1684 return {
1685 current: defaultValue
1686 };
1687}
1688
1689function pop(cursor, fiber) {
1690 if (index < 0) {
1691 {
1692 warningWithoutStack$1(false, 'Unexpected pop.');
1693 }
1694 return;
1695 }
1696
1697 {
1698 if (fiber !== fiberStack[index]) {
1699 warningWithoutStack$1(false, 'Unexpected Fiber popped.');
1700 }
1701 }
1702
1703 cursor.current = valueStack[index];
1704
1705 valueStack[index] = null;
1706
1707 {
1708 fiberStack[index] = null;
1709 }
1710
1711 index--;
1712}
1713
1714function push(cursor, value, fiber) {
1715 index++;
1716
1717 valueStack[index] = cursor.current;
1718
1719 {
1720 fiberStack[index] = fiber;
1721 }
1722
1723 cursor.current = value;
1724}
1725
1726var warnedAboutMissingGetChildContext = void 0;
1727
1728{
1729 warnedAboutMissingGetChildContext = {};
1730}
1731
1732var emptyContextObject = {};
1733{
1734 Object.freeze(emptyContextObject);
1735}
1736
1737// A cursor to the current merged context object on the stack.
1738var contextStackCursor = createCursor(emptyContextObject);
1739// A cursor to a boolean indicating whether the context has changed.
1740var didPerformWorkStackCursor = createCursor(false);
1741// Keep track of the previous context object that was on the stack.
1742// We use this to get access to the parent context after we have already
1743// pushed the next context provider, and now need to merge their contexts.
1744var previousContext = emptyContextObject;
1745
1746function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
1747 if (disableLegacyContext) {
1748 return emptyContextObject;
1749 } else {
1750 if (didPushOwnContextIfProvider && isContextProvider(Component)) {
1751 // If the fiber is a context provider itself, when we read its context
1752 // we may have already pushed its own child context on the stack. A context
1753 // provider should not "see" its own child context. Therefore we read the
1754 // previous (parent) context instead for a context provider.
1755 return previousContext;
1756 }
1757 return contextStackCursor.current;
1758 }
1759}
1760
1761function cacheContext(workInProgress, unmaskedContext, maskedContext) {
1762 if (disableLegacyContext) {
1763 return;
1764 } else {
1765 var instance = workInProgress.stateNode;
1766 instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
1767 instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
1768 }
1769}
1770
1771function getMaskedContext(workInProgress, unmaskedContext) {
1772 if (disableLegacyContext) {
1773 return emptyContextObject;
1774 } else {
1775 var type = workInProgress.type;
1776 var contextTypes = type.contextTypes;
1777 if (!contextTypes) {
1778 return emptyContextObject;
1779 }
1780
1781 // Avoid recreating masked context unless unmasked context has changed.
1782 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
1783 // This may trigger infinite loops if componentWillReceiveProps calls setState.
1784 var instance = workInProgress.stateNode;
1785 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
1786 return instance.__reactInternalMemoizedMaskedChildContext;
1787 }
1788
1789 var context = {};
1790 for (var key in contextTypes) {
1791 context[key] = unmaskedContext[key];
1792 }
1793
1794 {
1795 var name = getComponentName(type) || 'Unknown';
1796 checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
1797 }
1798
1799 // Cache unmasked context so we can avoid recreating masked context unless necessary.
1800 // Context is created before the class component is instantiated so check for instance.
1801 if (instance) {
1802 cacheContext(workInProgress, unmaskedContext, context);
1803 }
1804
1805 return context;
1806 }
1807}
1808
1809function hasContextChanged() {
1810 if (disableLegacyContext) {
1811 return false;
1812 } else {
1813 return didPerformWorkStackCursor.current;
1814 }
1815}
1816
1817function isContextProvider(type) {
1818 if (disableLegacyContext) {
1819 return false;
1820 } else {
1821 var childContextTypes = type.childContextTypes;
1822 return childContextTypes !== null && childContextTypes !== undefined;
1823 }
1824}
1825
1826function popContext(fiber) {
1827 if (disableLegacyContext) {
1828 return;
1829 } else {
1830 pop(didPerformWorkStackCursor, fiber);
1831 pop(contextStackCursor, fiber);
1832 }
1833}
1834
1835function popTopLevelContextObject(fiber) {
1836 if (disableLegacyContext) {
1837 return;
1838 } else {
1839 pop(didPerformWorkStackCursor, fiber);
1840 pop(contextStackCursor, fiber);
1841 }
1842}
1843
1844function pushTopLevelContextObject(fiber, context, didChange) {
1845 if (disableLegacyContext) {
1846 return;
1847 } else {
1848 (function () {
1849 if (!(contextStackCursor.current === emptyContextObject)) {
1850 {
1851 throw ReactError(Error('Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.'));
1852 }
1853 }
1854 })();
1855
1856 push(contextStackCursor, context, fiber);
1857 push(didPerformWorkStackCursor, didChange, fiber);
1858 }
1859}
1860
1861function processChildContext(fiber, type, parentContext) {
1862 if (disableLegacyContext) {
1863 return parentContext;
1864 } else {
1865 var instance = fiber.stateNode;
1866 var childContextTypes = type.childContextTypes;
1867
1868 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
1869 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
1870 if (typeof instance.getChildContext !== 'function') {
1871 {
1872 var componentName = getComponentName(type) || 'Unknown';
1873
1874 if (!warnedAboutMissingGetChildContext[componentName]) {
1875 warnedAboutMissingGetChildContext[componentName] = true;
1876 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);
1877 }
1878 }
1879 return parentContext;
1880 }
1881
1882 var childContext = void 0;
1883 {
1884 setCurrentPhase('getChildContext');
1885 }
1886 startPhaseTimer(fiber, 'getChildContext');
1887 childContext = instance.getChildContext();
1888 stopPhaseTimer();
1889 {
1890 setCurrentPhase(null);
1891 }
1892 for (var contextKey in childContext) {
1893 (function () {
1894 if (!(contextKey in childContextTypes)) {
1895 {
1896 throw ReactError(Error((getComponentName(type) || 'Unknown') + '.getChildContext(): key "' + contextKey + '" is not defined in childContextTypes.'));
1897 }
1898 }
1899 })();
1900 }
1901 {
1902 var name = getComponentName(type) || 'Unknown';
1903 checkPropTypes(childContextTypes, childContext, 'child context', name,
1904 // In practice, there is one case in which we won't get a stack. It's when
1905 // somebody calls unstable_renderSubtreeIntoContainer() and we process
1906 // context from the parent component instance. The stack will be missing
1907 // because it's outside of the reconciliation, and so the pointer has not
1908 // been set. This is rare and doesn't matter. We'll also remove that API.
1909 getCurrentFiberStackInDev);
1910 }
1911
1912 return _assign({}, parentContext, childContext);
1913 }
1914}
1915
1916function pushContextProvider(workInProgress) {
1917 if (disableLegacyContext) {
1918 return false;
1919 } else {
1920 var instance = workInProgress.stateNode;
1921 // We push the context as early as possible to ensure stack integrity.
1922 // If the instance does not exist yet, we will push null at first,
1923 // and replace it on the stack later when invalidating the context.
1924 var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
1925
1926 // Remember the parent context so we can merge with it later.
1927 // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
1928 previousContext = contextStackCursor.current;
1929 push(contextStackCursor, memoizedMergedChildContext, workInProgress);
1930 push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
1931
1932 return true;
1933 }
1934}
1935
1936function invalidateContextProvider(workInProgress, type, didChange) {
1937 if (disableLegacyContext) {
1938 return;
1939 } else {
1940 var instance = workInProgress.stateNode;
1941 (function () {
1942 if (!instance) {
1943 {
1944 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.'));
1945 }
1946 }
1947 })();
1948
1949 if (didChange) {
1950 // Merge parent and own context.
1951 // Skip this if we're not updating due to sCU.
1952 // This avoids unnecessarily recomputing memoized values.
1953 var mergedContext = processChildContext(workInProgress, type, previousContext);
1954 instance.__reactInternalMemoizedMergedChildContext = mergedContext;
1955
1956 // Replace the old (or empty) context with the new one.
1957 // It is important to unwind the context in the reverse order.
1958 pop(didPerformWorkStackCursor, workInProgress);
1959 pop(contextStackCursor, workInProgress);
1960 // Now push the new context and mark that it has changed.
1961 push(contextStackCursor, mergedContext, workInProgress);
1962 push(didPerformWorkStackCursor, didChange, workInProgress);
1963 } else {
1964 pop(didPerformWorkStackCursor, workInProgress);
1965 push(didPerformWorkStackCursor, didChange, workInProgress);
1966 }
1967 }
1968}
1969
1970function findCurrentUnmaskedContext(fiber) {
1971 if (disableLegacyContext) {
1972 return emptyContextObject;
1973 } else {
1974 // Currently this is only used with renderSubtreeIntoContainer; not sure if it
1975 // makes sense elsewhere
1976 (function () {
1977 if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
1978 {
1979 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.'));
1980 }
1981 }
1982 })();
1983
1984 var node = fiber;
1985 do {
1986 switch (node.tag) {
1987 case HostRoot:
1988 return node.stateNode.context;
1989 case ClassComponent:
1990 {
1991 var Component = node.type;
1992 if (isContextProvider(Component)) {
1993 return node.stateNode.__reactInternalMemoizedMergedChildContext;
1994 }
1995 break;
1996 }
1997 }
1998 node = node.return;
1999 } while (node !== null);
2000 (function () {
2001 {
2002 {
2003 throw ReactError(Error('Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.'));
2004 }
2005 }
2006 })();
2007 }
2008}
2009
2010/**
2011 * Similar to invariant but only logs a warning if the condition is not met.
2012 * This can be used to log issues in development environments in critical
2013 * paths. Removing the logging code for production environments will keep the
2014 * same logic and follow the same code paths.
2015 */
2016
2017var warning = warningWithoutStack$1;
2018
2019{
2020 warning = function (condition, format) {
2021 if (condition) {
2022 return;
2023 }
2024 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
2025 var stack = ReactDebugCurrentFrame.getStackAddendum();
2026 // eslint-disable-next-line react-internal/warning-and-invariant-args
2027
2028 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2029 args[_key - 2] = arguments[_key];
2030 }
2031
2032 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
2033 };
2034}
2035
2036var warning$1 = warning;
2037
2038// Intentionally not named imports because Rollup would use dynamic dispatch for
2039// CommonJS interop named imports.
2040var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority;
2041var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback;
2042var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback;
2043var Scheduler_shouldYield = Scheduler.unstable_shouldYield;
2044var Scheduler_requestPaint = Scheduler.unstable_requestPaint;
2045var Scheduler_now = Scheduler.unstable_now;
2046var Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel;
2047var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority;
2048var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
2049var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority;
2050var Scheduler_LowPriority = Scheduler.unstable_LowPriority;
2051var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
2052
2053
2054if (enableSchedulerTracing) {
2055 // Provide explicit error message when production+profiling bundle of e.g.
2056 // react-dom is used with production (non-profiling) bundle of
2057 // scheduler/tracing
2058 (function () {
2059 if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
2060 {
2061 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'));
2062 }
2063 }
2064 })();
2065}
2066
2067var fakeCallbackNode = {};
2068
2069// Except for NoPriority, these correspond to Scheduler priorities. We use
2070// ascending numbers so we can compare them like numbers. They start at 90 to
2071// avoid clashing with Scheduler's priorities.
2072var ImmediatePriority = 99;
2073var UserBlockingPriority = 98;
2074var NormalPriority = 97;
2075var LowPriority = 96;
2076var IdlePriority = 95;
2077// NoPriority is the absence of priority. Also React-only.
2078var NoPriority = 90;
2079
2080var shouldYield = Scheduler_shouldYield;
2081var requestPaint =
2082// Fall back gracefully if we're running an older version of Scheduler.
2083Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
2084
2085var syncQueue = null;
2086var immediateQueueCallbackNode = null;
2087var isFlushingSyncQueue = false;
2088var initialTimeMs = Scheduler_now();
2089
2090// If the initial timestamp is reasonably small, use Scheduler's `now` directly.
2091// This will be the case for modern browsers that support `performance.now`. In
2092// older browsers, Scheduler falls back to `Date.now`, which returns a Unix
2093// timestamp. In that case, subtract the module initialization time to simulate
2094// the behavior of performance.now and keep our times small enough to fit
2095// within 32 bits.
2096// TODO: Consider lifting this into Scheduler.
2097var now = initialTimeMs < 10000 ? Scheduler_now : function () {
2098 return Scheduler_now() - initialTimeMs;
2099};
2100
2101function getCurrentPriorityLevel() {
2102 switch (Scheduler_getCurrentPriorityLevel()) {
2103 case Scheduler_ImmediatePriority:
2104 return ImmediatePriority;
2105 case Scheduler_UserBlockingPriority:
2106 return UserBlockingPriority;
2107 case Scheduler_NormalPriority:
2108 return NormalPriority;
2109 case Scheduler_LowPriority:
2110 return LowPriority;
2111 case Scheduler_IdlePriority:
2112 return IdlePriority;
2113 default:
2114 (function () {
2115 {
2116 {
2117 throw ReactError(Error('Unknown priority level.'));
2118 }
2119 }
2120 })();
2121 }
2122}
2123
2124function reactPriorityToSchedulerPriority(reactPriorityLevel) {
2125 switch (reactPriorityLevel) {
2126 case ImmediatePriority:
2127 return Scheduler_ImmediatePriority;
2128 case UserBlockingPriority:
2129 return Scheduler_UserBlockingPriority;
2130 case NormalPriority:
2131 return Scheduler_NormalPriority;
2132 case LowPriority:
2133 return Scheduler_LowPriority;
2134 case IdlePriority:
2135 return Scheduler_IdlePriority;
2136 default:
2137 (function () {
2138 {
2139 {
2140 throw ReactError(Error('Unknown priority level.'));
2141 }
2142 }
2143 })();
2144 }
2145}
2146
2147function runWithPriority(reactPriorityLevel, fn) {
2148 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
2149 return Scheduler_runWithPriority(priorityLevel, fn);
2150}
2151
2152function scheduleCallback(reactPriorityLevel, callback, options) {
2153 var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
2154 return Scheduler_scheduleCallback(priorityLevel, callback, options);
2155}
2156
2157function scheduleSyncCallback(callback) {
2158 // Push this callback into an internal queue. We'll flush these either in
2159 // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
2160 if (syncQueue === null) {
2161 syncQueue = [callback];
2162 // Flush the queue in the next tick, at the earliest.
2163 immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
2164 } else {
2165 // Push onto existing queue. Don't need to schedule a callback because
2166 // we already scheduled one when we created the queue.
2167 syncQueue.push(callback);
2168 }
2169 return fakeCallbackNode;
2170}
2171
2172function cancelCallback(callbackNode) {
2173 if (callbackNode !== fakeCallbackNode) {
2174 Scheduler_cancelCallback(callbackNode);
2175 }
2176}
2177
2178function flushSyncCallbackQueue() {
2179 if (immediateQueueCallbackNode !== null) {
2180 Scheduler_cancelCallback(immediateQueueCallbackNode);
2181 }
2182 flushSyncCallbackQueueImpl();
2183}
2184
2185function flushSyncCallbackQueueImpl() {
2186 if (!isFlushingSyncQueue && syncQueue !== null) {
2187 // Prevent re-entrancy.
2188 isFlushingSyncQueue = true;
2189 var i = 0;
2190 try {
2191 var _isSync = true;
2192 var queue = syncQueue;
2193 runWithPriority(ImmediatePriority, function () {
2194 for (; i < queue.length; i++) {
2195 var callback = queue[i];
2196 do {
2197 callback = callback(_isSync);
2198 } while (callback !== null);
2199 }
2200 });
2201 syncQueue = null;
2202 } catch (error) {
2203 // If something throws, leave the remaining callbacks on the queue.
2204 if (syncQueue !== null) {
2205 syncQueue = syncQueue.slice(i + 1);
2206 }
2207 // Resume flushing in the next tick
2208 Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
2209 throw error;
2210 } finally {
2211 isFlushingSyncQueue = false;
2212 }
2213 }
2214}
2215
2216var NoMode = 0;
2217var StrictMode = 1;
2218// TODO: Remove BatchedMode and ConcurrentMode by reading from the root
2219// tag instead
2220var BatchedMode = 2;
2221var ConcurrentMode = 4;
2222var ProfileMode = 8;
2223
2224// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
2225// Math.pow(2, 30) - 1
2226// 0b111111111111111111111111111111
2227var MAX_SIGNED_31_BIT_INT = 1073741823;
2228
2229var NoWork = 0;
2230var Never = 1;
2231var Sync = MAX_SIGNED_31_BIT_INT;
2232var Batched = Sync - 1;
2233
2234var UNIT_SIZE = 10;
2235var MAGIC_NUMBER_OFFSET = Batched - 1;
2236
2237// 1 unit of expiration time represents 10ms.
2238function msToExpirationTime(ms) {
2239 // Always add an offset so that we don't clash with the magic number for NoWork.
2240 return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
2241}
2242
2243function expirationTimeToMs(expirationTime) {
2244 return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
2245}
2246
2247function ceiling(num, precision) {
2248 return ((num / precision | 0) + 1) * precision;
2249}
2250
2251function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
2252 return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
2253}
2254
2255// TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
2256// the names to reflect.
2257var LOW_PRIORITY_EXPIRATION = 5000;
2258var LOW_PRIORITY_BATCH_SIZE = 250;
2259
2260function computeAsyncExpiration(currentTime) {
2261 return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
2262}
2263
2264function computeSuspenseExpiration(currentTime, timeoutMs) {
2265 // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
2266 return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
2267}
2268
2269// We intentionally set a higher expiration time for interactive updates in
2270// dev than in production.
2271//
2272// If the main thread is being blocked so long that you hit the expiration,
2273// it's a problem that could be solved with better scheduling.
2274//
2275// People will be more likely to notice this and fix it with the long
2276// expiration time in development.
2277//
2278// In production we opt for better UX at the risk of masking scheduling
2279// problems, by expiring fast.
2280var HIGH_PRIORITY_EXPIRATION = 500;
2281var HIGH_PRIORITY_BATCH_SIZE = 100;
2282
2283function computeInteractiveExpiration(currentTime) {
2284 return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
2285}
2286
2287function inferPriorityFromExpirationTime(currentTime, expirationTime) {
2288 if (expirationTime === Sync) {
2289 return ImmediatePriority;
2290 }
2291 if (expirationTime === Never) {
2292 return IdlePriority;
2293 }
2294 var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
2295 if (msUntil <= 0) {
2296 return ImmediatePriority;
2297 }
2298 if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
2299 return UserBlockingPriority;
2300 }
2301 if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
2302 return NormalPriority;
2303 }
2304
2305 // TODO: Handle LowPriority
2306
2307 // Assume anything lower has idle priority
2308 return IdlePriority;
2309}
2310
2311/**
2312 * inlined Object.is polyfill to avoid requiring consumers ship their own
2313 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
2314 */
2315function is(x, y) {
2316 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
2317 ;
2318}
2319
2320var hasOwnProperty = Object.prototype.hasOwnProperty;
2321
2322/**
2323 * Performs equality by iterating through keys on an object and returning false
2324 * when any key has values which are not strictly equal between the arguments.
2325 * Returns true when the values of all keys are strictly equal.
2326 */
2327function shallowEqual(objA, objB) {
2328 if (is(objA, objB)) {
2329 return true;
2330 }
2331
2332 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
2333 return false;
2334 }
2335
2336 var keysA = Object.keys(objA);
2337 var keysB = Object.keys(objB);
2338
2339 if (keysA.length !== keysB.length) {
2340 return false;
2341 }
2342
2343 // Test for A's keys different from B.
2344 for (var i = 0; i < keysA.length; i++) {
2345 if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
2346 return false;
2347 }
2348 }
2349
2350 return true;
2351}
2352
2353/**
2354 * Forked from fbjs/warning:
2355 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
2356 *
2357 * Only change is we use console.warn instead of console.error,
2358 * and do nothing when 'console' is not supported.
2359 * This really simplifies the code.
2360 * ---
2361 * Similar to invariant but only logs a warning if the condition is not met.
2362 * This can be used to log issues in development environments in critical
2363 * paths. Removing the logging code for production environments will keep the
2364 * same logic and follow the same code paths.
2365 */
2366
2367var lowPriorityWarning = function () {};
2368
2369{
2370 var printWarning = function (format) {
2371 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2372 args[_key - 1] = arguments[_key];
2373 }
2374
2375 var argIndex = 0;
2376 var message = 'Warning: ' + format.replace(/%s/g, function () {
2377 return args[argIndex++];
2378 });
2379 if (typeof console !== 'undefined') {
2380 console.warn(message);
2381 }
2382 try {
2383 // --- Welcome to debugging React ---
2384 // This error was thrown as a convenience so that you can use this stack
2385 // to find the callsite that caused this warning to fire.
2386 throw new Error(message);
2387 } catch (x) {}
2388 };
2389
2390 lowPriorityWarning = function (condition, format) {
2391 if (format === undefined) {
2392 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
2393 }
2394 if (!condition) {
2395 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
2396 args[_key2 - 2] = arguments[_key2];
2397 }
2398
2399 printWarning.apply(undefined, [format].concat(args));
2400 }
2401 };
2402}
2403
2404var lowPriorityWarning$1 = lowPriorityWarning;
2405
2406var ReactStrictModeWarnings = {
2407 recordUnsafeLifecycleWarnings: function (fiber, instance) {},
2408 flushPendingUnsafeLifecycleWarnings: function () {},
2409 recordLegacyContextWarning: function (fiber, instance) {},
2410 flushLegacyContextWarning: function () {},
2411 discardPendingWarnings: function () {}
2412};
2413
2414{
2415 var findStrictRoot = function (fiber) {
2416 var maybeStrictRoot = null;
2417
2418 var node = fiber;
2419 while (node !== null) {
2420 if (node.mode & StrictMode) {
2421 maybeStrictRoot = node;
2422 }
2423 node = node.return;
2424 }
2425
2426 return maybeStrictRoot;
2427 };
2428
2429 var setToSortedString = function (set) {
2430 var array = [];
2431 set.forEach(function (value) {
2432 array.push(value);
2433 });
2434 return array.sort().join(', ');
2435 };
2436
2437 var pendingComponentWillMountWarnings = [];
2438 var pendingUNSAFE_ComponentWillMountWarnings = [];
2439 var pendingComponentWillReceivePropsWarnings = [];
2440 var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2441 var pendingComponentWillUpdateWarnings = [];
2442 var pendingUNSAFE_ComponentWillUpdateWarnings = [];
2443
2444 // Tracks components we have already warned about.
2445 var didWarnAboutUnsafeLifecycles = new Set();
2446
2447 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
2448 // Dedup strategy: Warn once per component.
2449 if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
2450 return;
2451 }
2452
2453 if (typeof instance.componentWillMount === 'function' &&
2454 // Don't warn about react-lifecycles-compat polyfilled components.
2455 instance.componentWillMount.__suppressDeprecationWarning !== true) {
2456 pendingComponentWillMountWarnings.push(fiber);
2457 }
2458
2459 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
2460 pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
2461 }
2462
2463 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
2464 pendingComponentWillReceivePropsWarnings.push(fiber);
2465 }
2466
2467 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
2468 pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
2469 }
2470
2471 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
2472 pendingComponentWillUpdateWarnings.push(fiber);
2473 }
2474
2475 if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
2476 pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
2477 }
2478 };
2479
2480 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
2481 // We do an initial pass to gather component names
2482 var componentWillMountUniqueNames = new Set();
2483 if (pendingComponentWillMountWarnings.length > 0) {
2484 pendingComponentWillMountWarnings.forEach(function (fiber) {
2485 componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
2486 didWarnAboutUnsafeLifecycles.add(fiber.type);
2487 });
2488 pendingComponentWillMountWarnings = [];
2489 }
2490
2491 var UNSAFE_componentWillMountUniqueNames = new Set();
2492 if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
2493 pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
2494 UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
2495 didWarnAboutUnsafeLifecycles.add(fiber.type);
2496 });
2497 pendingUNSAFE_ComponentWillMountWarnings = [];
2498 }
2499
2500 var componentWillReceivePropsUniqueNames = new Set();
2501 if (pendingComponentWillReceivePropsWarnings.length > 0) {
2502 pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
2503 componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
2504 didWarnAboutUnsafeLifecycles.add(fiber.type);
2505 });
2506
2507 pendingComponentWillReceivePropsWarnings = [];
2508 }
2509
2510 var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
2511 if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
2512 pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
2513 UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
2514 didWarnAboutUnsafeLifecycles.add(fiber.type);
2515 });
2516
2517 pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2518 }
2519
2520 var componentWillUpdateUniqueNames = new Set();
2521 if (pendingComponentWillUpdateWarnings.length > 0) {
2522 pendingComponentWillUpdateWarnings.forEach(function (fiber) {
2523 componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
2524 didWarnAboutUnsafeLifecycles.add(fiber.type);
2525 });
2526
2527 pendingComponentWillUpdateWarnings = [];
2528 }
2529
2530 var UNSAFE_componentWillUpdateUniqueNames = new Set();
2531 if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
2532 pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
2533 UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
2534 didWarnAboutUnsafeLifecycles.add(fiber.type);
2535 });
2536
2537 pendingUNSAFE_ComponentWillUpdateWarnings = [];
2538 }
2539
2540 // Finally, we flush all the warnings
2541 // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
2542 if (UNSAFE_componentWillMountUniqueNames.size > 0) {
2543 var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
2544 warningWithoutStack$1(false, 'Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-async-component-lifecycle-hooks 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);
2545 }
2546
2547 if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
2548 var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
2549 warningWithoutStack$1(false, 'Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-async-component-lifecycle-hooks 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);
2550 }
2551
2552 if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
2553 var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
2554 warningWithoutStack$1(false, 'Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-async-component-lifecycle-hooks for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
2555 }
2556
2557 if (componentWillMountUniqueNames.size > 0) {
2558 var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
2559
2560 lowPriorityWarning$1(false, 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-async-component-lifecycle-hooks 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);
2561 }
2562
2563 if (componentWillReceivePropsUniqueNames.size > 0) {
2564 var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
2565
2566 lowPriorityWarning$1(false, 'componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-async-component-lifecycle-hooks 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);
2567 }
2568
2569 if (componentWillUpdateUniqueNames.size > 0) {
2570 var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
2571
2572 lowPriorityWarning$1(false, 'componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-async-component-lifecycle-hooks 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);
2573 }
2574 };
2575
2576 var pendingLegacyContextWarning = new Map();
2577
2578 // Tracks components we have already warned about.
2579 var didWarnAboutLegacyContext = new Set();
2580
2581 ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
2582 var strictRoot = findStrictRoot(fiber);
2583 if (strictRoot === null) {
2584 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.');
2585 return;
2586 }
2587
2588 // Dedup strategy: Warn once per component.
2589 if (didWarnAboutLegacyContext.has(fiber.type)) {
2590 return;
2591 }
2592
2593 var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
2594
2595 if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
2596 if (warningsForRoot === undefined) {
2597 warningsForRoot = [];
2598 pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
2599 }
2600 warningsForRoot.push(fiber);
2601 }
2602 };
2603
2604 ReactStrictModeWarnings.flushLegacyContextWarning = function () {
2605 pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
2606 var uniqueNames = new Set();
2607 fiberArray.forEach(function (fiber) {
2608 uniqueNames.add(getComponentName(fiber.type) || 'Component');
2609 didWarnAboutLegacyContext.add(fiber.type);
2610 });
2611
2612 var sortedNames = setToSortedString(uniqueNames);
2613 var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
2614
2615 warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree: %s' + '\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:' + '\nhttps://fb.me/react-legacy-context', strictRootComponentStack, sortedNames);
2616 });
2617 };
2618
2619 ReactStrictModeWarnings.discardPendingWarnings = function () {
2620 pendingComponentWillMountWarnings = [];
2621 pendingUNSAFE_ComponentWillMountWarnings = [];
2622 pendingComponentWillReceivePropsWarnings = [];
2623 pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
2624 pendingComponentWillUpdateWarnings = [];
2625 pendingUNSAFE_ComponentWillUpdateWarnings = [];
2626 pendingLegacyContextWarning = new Map();
2627 };
2628}
2629
2630// Resolves type to a family.
2631
2632
2633// Used by React Refresh runtime through DevTools Global Hook.
2634
2635
2636var resolveFamily = null;
2637// $FlowFixMe Flow gets confused by a WeakSet feature check below.
2638var failedBoundaries = null;
2639
2640var setRefreshHandler = function (handler) {
2641 {
2642 resolveFamily = handler;
2643 }
2644};
2645
2646function resolveFunctionForHotReloading(type) {
2647 {
2648 if (resolveFamily === null) {
2649 // Hot reloading is disabled.
2650 return type;
2651 }
2652 var family = resolveFamily(type);
2653 if (family === undefined) {
2654 return type;
2655 }
2656 // Use the latest known implementation.
2657 return family.current;
2658 }
2659}
2660
2661function resolveClassForHotReloading(type) {
2662 // No implementation differences.
2663 return resolveFunctionForHotReloading(type);
2664}
2665
2666function resolveForwardRefForHotReloading(type) {
2667 {
2668 if (resolveFamily === null) {
2669 // Hot reloading is disabled.
2670 return type;
2671 }
2672 var family = resolveFamily(type);
2673 if (family === undefined) {
2674 // Check if we're dealing with a real forwardRef. Don't want to crash early.
2675 if (type !== null && type !== undefined && typeof type.render === 'function') {
2676 // ForwardRef is special because its resolved .type is an object,
2677 // but it's possible that we only have its inner render function in the map.
2678 // If that inner render function is different, we'll build a new forwardRef type.
2679 var currentRender = resolveFunctionForHotReloading(type.render);
2680 if (type.render !== currentRender) {
2681 var syntheticType = {
2682 $$typeof: REACT_FORWARD_REF_TYPE,
2683 render: currentRender
2684 };
2685 if (type.displayName !== undefined) {
2686 syntheticType.displayName = type.displayName;
2687 }
2688 return syntheticType;
2689 }
2690 }
2691 return type;
2692 }
2693 // Use the latest known implementation.
2694 return family.current;
2695 }
2696}
2697
2698function isCompatibleFamilyForHotReloading(fiber, element) {
2699 {
2700 if (resolveFamily === null) {
2701 // Hot reloading is disabled.
2702 return false;
2703 }
2704
2705 var prevType = fiber.elementType;
2706 var nextType = element.type;
2707
2708 // If we got here, we know types aren't === equal.
2709 var needsCompareFamilies = false;
2710
2711 var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
2712
2713 switch (fiber.tag) {
2714 case ClassComponent:
2715 {
2716 if (typeof nextType === 'function') {
2717 needsCompareFamilies = true;
2718 }
2719 break;
2720 }
2721 case FunctionComponent:
2722 {
2723 if (typeof nextType === 'function') {
2724 needsCompareFamilies = true;
2725 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2726 // We don't know the inner type yet.
2727 // We're going to assume that the lazy inner type is stable,
2728 // and so it is sufficient to avoid reconciling it away.
2729 // We're not going to unwrap or actually use the new lazy type.
2730 needsCompareFamilies = true;
2731 }
2732 break;
2733 }
2734 case ForwardRef:
2735 {
2736 if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
2737 needsCompareFamilies = true;
2738 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2739 needsCompareFamilies = true;
2740 }
2741 break;
2742 }
2743 case MemoComponent:
2744 case SimpleMemoComponent:
2745 {
2746 if ($$typeofNextType === REACT_MEMO_TYPE) {
2747 // TODO: if it was but can no longer be simple,
2748 // we shouldn't set this.
2749 needsCompareFamilies = true;
2750 } else if ($$typeofNextType === REACT_LAZY_TYPE) {
2751 needsCompareFamilies = true;
2752 }
2753 break;
2754 }
2755 default:
2756 return false;
2757 }
2758
2759 // Check if both types have a family and it's the same one.
2760 if (needsCompareFamilies) {
2761 // Note: memo() and forwardRef() we'll compare outer rather than inner type.
2762 // This means both of them need to be registered to preserve state.
2763 // If we unwrapped and compared the inner types for wrappers instead,
2764 // then we would risk falsely saying two separate memo(Foo)
2765 // calls are equivalent because they wrap the same Foo function.
2766 var prevFamily = resolveFamily(prevType);
2767 if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
2768 return true;
2769 }
2770 }
2771 return false;
2772 }
2773}
2774
2775function markFailedErrorBoundaryForHotReloading(fiber) {
2776 {
2777 if (resolveFamily === null) {
2778 // Hot reloading is disabled.
2779 return;
2780 }
2781 if (typeof WeakSet !== 'function') {
2782 return;
2783 }
2784 if (failedBoundaries === null) {
2785 failedBoundaries = new WeakSet();
2786 }
2787 failedBoundaries.add(fiber);
2788 }
2789}
2790
2791var scheduleRefresh = function (root, update) {
2792 {
2793 if (resolveFamily === null) {
2794 // Hot reloading is disabled.
2795 return;
2796 }
2797 var _staleFamilies = update.staleFamilies,
2798 _updatedFamilies = update.updatedFamilies;
2799
2800 flushPassiveEffects();
2801 flushSync(function () {
2802 scheduleFibersWithFamiliesRecursively(root.current, _updatedFamilies, _staleFamilies);
2803 });
2804 }
2805};
2806
2807var scheduleRoot = function (root, element) {
2808 {
2809 if (root.context !== emptyContextObject) {
2810 // Super edge case: root has a legacy _renderSubtree context
2811 // but we don't know the parentComponent so we can't pass it.
2812 // Just ignore. We'll delete this with _renderSubtree code path later.
2813 return;
2814 }
2815 flushPassiveEffects();
2816 updateContainerAtExpirationTime(element, root, null, Sync, null);
2817 }
2818};
2819
2820function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
2821 {
2822 var alternate = fiber.alternate,
2823 child = fiber.child,
2824 sibling = fiber.sibling,
2825 tag = fiber.tag,
2826 type = fiber.type;
2827
2828
2829 var candidateType = null;
2830 switch (tag) {
2831 case FunctionComponent:
2832 case SimpleMemoComponent:
2833 case ClassComponent:
2834 candidateType = type;
2835 break;
2836 case ForwardRef:
2837 candidateType = type.render;
2838 break;
2839 default:
2840 break;
2841 }
2842
2843 if (resolveFamily === null) {
2844 throw new Error('Expected resolveFamily to be set during hot reload.');
2845 }
2846
2847 var needsRender = false;
2848 var needsRemount = false;
2849 if (candidateType !== null) {
2850 var family = resolveFamily(candidateType);
2851 if (family !== undefined) {
2852 if (staleFamilies.has(family)) {
2853 needsRemount = true;
2854 } else if (updatedFamilies.has(family)) {
2855 needsRender = true;
2856 }
2857 }
2858 }
2859 if (failedBoundaries !== null) {
2860 if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
2861 needsRemount = true;
2862 }
2863 }
2864
2865 if (needsRemount) {
2866 fiber._debugNeedsRemount = true;
2867 }
2868 if (needsRemount || needsRender) {
2869 scheduleWork(fiber, Sync);
2870 }
2871 if (child !== null && !needsRemount) {
2872 scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
2873 }
2874 if (sibling !== null) {
2875 scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
2876 }
2877 }
2878}
2879
2880var findHostInstancesForRefresh = function (root, families) {
2881 {
2882 var hostInstances = new Set();
2883 var types = new Set(families.map(function (family) {
2884 return family.current;
2885 }));
2886 findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
2887 return hostInstances;
2888 }
2889};
2890
2891function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
2892 {
2893 var child = fiber.child,
2894 sibling = fiber.sibling,
2895 tag = fiber.tag,
2896 type = fiber.type;
2897
2898
2899 var candidateType = null;
2900 switch (tag) {
2901 case FunctionComponent:
2902 case SimpleMemoComponent:
2903 case ClassComponent:
2904 candidateType = type;
2905 break;
2906 case ForwardRef:
2907 candidateType = type.render;
2908 break;
2909 default:
2910 break;
2911 }
2912
2913 var didMatch = false;
2914 if (candidateType !== null) {
2915 if (types.has(candidateType)) {
2916 didMatch = true;
2917 }
2918 }
2919
2920 if (didMatch) {
2921 // We have a match. This only drills down to the closest host components.
2922 // There's no need to search deeper because for the purpose of giving
2923 // visual feedback, "flashing" outermost parent rectangles is sufficient.
2924 findHostInstancesForFiberShallowly(fiber, hostInstances);
2925 } else {
2926 // If there's no match, maybe there will be one further down in the child tree.
2927 if (child !== null) {
2928 findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
2929 }
2930 }
2931
2932 if (sibling !== null) {
2933 findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
2934 }
2935 }
2936}
2937
2938function findHostInstancesForFiberShallowly(fiber, hostInstances) {
2939 {
2940 var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
2941 if (foundHostInstances) {
2942 return;
2943 }
2944 // If we didn't find any host children, fallback to closest host parent.
2945 var node = fiber;
2946 while (true) {
2947 switch (node.tag) {
2948 case HostComponent:
2949 hostInstances.add(node.stateNode);
2950 return;
2951 case HostPortal:
2952 hostInstances.add(node.stateNode.containerInfo);
2953 return;
2954 case HostRoot:
2955 hostInstances.add(node.stateNode.containerInfo);
2956 return;
2957 }
2958 if (node.return === null) {
2959 throw new Error('Expected to reach root first.');
2960 }
2961 node = node.return;
2962 }
2963 }
2964}
2965
2966function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
2967 {
2968 var node = fiber;
2969 var foundHostInstances = false;
2970 while (true) {
2971 if (node.tag === HostComponent) {
2972 // We got a match.
2973 foundHostInstances = true;
2974 hostInstances.add(node.stateNode);
2975 // There may still be more, so keep searching.
2976 } else if (node.child !== null) {
2977 node.child.return = node;
2978 node = node.child;
2979 continue;
2980 }
2981 if (node === fiber) {
2982 return foundHostInstances;
2983 }
2984 while (node.sibling === null) {
2985 if (node.return === null || node.return === fiber) {
2986 return foundHostInstances;
2987 }
2988 node = node.return;
2989 }
2990 node.sibling.return = node.return;
2991 node = node.sibling;
2992 }
2993 }
2994 return false;
2995}
2996
2997function resolveDefaultProps(Component, baseProps) {
2998 if (Component && Component.defaultProps) {
2999 // Resolve default props. Taken from ReactElement
3000 var props = _assign({}, baseProps);
3001 var defaultProps = Component.defaultProps;
3002 for (var propName in defaultProps) {
3003 if (props[propName] === undefined) {
3004 props[propName] = defaultProps[propName];
3005 }
3006 }
3007 return props;
3008 }
3009 return baseProps;
3010}
3011
3012function readLazyComponentType(lazyComponent) {
3013 var status = lazyComponent._status;
3014 var result = lazyComponent._result;
3015 switch (status) {
3016 case Resolved:
3017 {
3018 var Component = result;
3019 return Component;
3020 }
3021 case Rejected:
3022 {
3023 var error = result;
3024 throw error;
3025 }
3026 case Pending:
3027 {
3028 var thenable = result;
3029 throw thenable;
3030 }
3031 default:
3032 {
3033 lazyComponent._status = Pending;
3034 var ctor = lazyComponent._ctor;
3035 var _thenable = ctor();
3036 _thenable.then(function (moduleObject) {
3037 if (lazyComponent._status === Pending) {
3038 var defaultExport = moduleObject.default;
3039 {
3040 if (defaultExport === undefined) {
3041 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);
3042 }
3043 }
3044 lazyComponent._status = Resolved;
3045 lazyComponent._result = defaultExport;
3046 }
3047 }, function (error) {
3048 if (lazyComponent._status === Pending) {
3049 lazyComponent._status = Rejected;
3050 lazyComponent._result = error;
3051 }
3052 });
3053 // Handle synchronous thenables.
3054 switch (lazyComponent._status) {
3055 case Resolved:
3056 return lazyComponent._result;
3057 case Rejected:
3058 throw lazyComponent._result;
3059 }
3060 lazyComponent._result = _thenable;
3061 throw _thenable;
3062 }
3063 }
3064}
3065
3066var valueCursor = createCursor(null);
3067
3068var rendererSigil = void 0;
3069{
3070 // Use this to detect multiple renderers using the same context
3071 rendererSigil = {};
3072}
3073
3074var currentlyRenderingFiber = null;
3075var lastContextDependency = null;
3076var lastContextWithAllBitsObserved = null;
3077
3078var isDisallowedContextReadInDEV = false;
3079
3080function resetContextDependencies() {
3081 // This is called right before React yields execution, to ensure `readContext`
3082 // cannot be called outside the render phase.
3083 currentlyRenderingFiber = null;
3084 lastContextDependency = null;
3085 lastContextWithAllBitsObserved = null;
3086 {
3087 isDisallowedContextReadInDEV = false;
3088 }
3089}
3090
3091function enterDisallowedContextReadInDEV() {
3092 {
3093 isDisallowedContextReadInDEV = true;
3094 }
3095}
3096
3097function exitDisallowedContextReadInDEV() {
3098 {
3099 isDisallowedContextReadInDEV = false;
3100 }
3101}
3102
3103function pushProvider(providerFiber, nextValue) {
3104 var context = providerFiber.type._context;
3105
3106 if (isPrimaryRenderer) {
3107 push(valueCursor, context._currentValue, providerFiber);
3108
3109 context._currentValue = nextValue;
3110 {
3111 !(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;
3112 context._currentRenderer = rendererSigil;
3113 }
3114 } else {
3115 push(valueCursor, context._currentValue2, providerFiber);
3116
3117 context._currentValue2 = nextValue;
3118 {
3119 !(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;
3120 context._currentRenderer2 = rendererSigil;
3121 }
3122 }
3123}
3124
3125function popProvider(providerFiber) {
3126 var currentValue = valueCursor.current;
3127
3128 pop(valueCursor, providerFiber);
3129
3130 var context = providerFiber.type._context;
3131 if (isPrimaryRenderer) {
3132 context._currentValue = currentValue;
3133 } else {
3134 context._currentValue2 = currentValue;
3135 }
3136}
3137
3138function calculateChangedBits(context, newValue, oldValue) {
3139 if (is(oldValue, newValue)) {
3140 // No change
3141 return 0;
3142 } else {
3143 var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
3144
3145 {
3146 !((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;
3147 }
3148 return changedBits | 0;
3149 }
3150}
3151
3152function scheduleWorkOnParentPath(parent, renderExpirationTime) {
3153 // Update the child expiration time of all the ancestors, including
3154 // the alternates.
3155 var node = parent;
3156 while (node !== null) {
3157 var alternate = node.alternate;
3158 if (node.childExpirationTime < renderExpirationTime) {
3159 node.childExpirationTime = renderExpirationTime;
3160 if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
3161 alternate.childExpirationTime = renderExpirationTime;
3162 }
3163 } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
3164 alternate.childExpirationTime = renderExpirationTime;
3165 } else {
3166 // Neither alternate was updated, which means the rest of the
3167 // ancestor path already has sufficient priority.
3168 break;
3169 }
3170 node = node.return;
3171 }
3172}
3173
3174function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
3175 var fiber = workInProgress.child;
3176 if (fiber !== null) {
3177 // Set the return pointer of the child to the work-in-progress fiber.
3178 fiber.return = workInProgress;
3179 }
3180 while (fiber !== null) {
3181 var nextFiber = void 0;
3182
3183 // Visit this fiber.
3184 var list = fiber.dependencies;
3185 if (list !== null) {
3186 nextFiber = fiber.child;
3187
3188 var dependency = list.firstContext;
3189 while (dependency !== null) {
3190 // Check if the context matches.
3191 if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
3192 // Match! Schedule an update on this fiber.
3193
3194 if (fiber.tag === ClassComponent) {
3195 // Schedule a force update on the work-in-progress.
3196 var update = createUpdate(renderExpirationTime, null);
3197 update.tag = ForceUpdate;
3198 // TODO: Because we don't have a work-in-progress, this will add the
3199 // update to the current fiber, too, which means it will persist even if
3200 // this render is thrown away. Since it's a race condition, not sure it's
3201 // worth fixing.
3202 enqueueUpdate(fiber, update);
3203 }
3204
3205 if (fiber.expirationTime < renderExpirationTime) {
3206 fiber.expirationTime = renderExpirationTime;
3207 }
3208 var alternate = fiber.alternate;
3209 if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
3210 alternate.expirationTime = renderExpirationTime;
3211 }
3212
3213 scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
3214
3215 // Mark the expiration time on the list, too.
3216 if (list.expirationTime < renderExpirationTime) {
3217 list.expirationTime = renderExpirationTime;
3218 }
3219
3220 // Since we already found a match, we can stop traversing the
3221 // dependency list.
3222 break;
3223 }
3224 dependency = dependency.next;
3225 }
3226 } else if (fiber.tag === ContextProvider) {
3227 // Don't scan deeper if this is a matching provider
3228 nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
3229 } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
3230 // If a dehydrated suspense component is in this subtree, we don't know
3231 // if it will have any context consumers in it. The best we can do is
3232 // mark it as having updates on its children.
3233 if (fiber.expirationTime < renderExpirationTime) {
3234 fiber.expirationTime = renderExpirationTime;
3235 }
3236 var _alternate = fiber.alternate;
3237 if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
3238 _alternate.expirationTime = renderExpirationTime;
3239 }
3240 // This is intentionally passing this fiber as the parent
3241 // because we want to schedule this fiber as having work
3242 // on its children. We'll use the childExpirationTime on
3243 // this fiber to indicate that a context has changed.
3244 scheduleWorkOnParentPath(fiber, renderExpirationTime);
3245 nextFiber = fiber.sibling;
3246 } else {
3247 // Traverse down.
3248 nextFiber = fiber.child;
3249 }
3250
3251 if (nextFiber !== null) {
3252 // Set the return pointer of the child to the work-in-progress fiber.
3253 nextFiber.return = fiber;
3254 } else {
3255 // No child. Traverse to next sibling.
3256 nextFiber = fiber;
3257 while (nextFiber !== null) {
3258 if (nextFiber === workInProgress) {
3259 // We're back to the root of this subtree. Exit.
3260 nextFiber = null;
3261 break;
3262 }
3263 var sibling = nextFiber.sibling;
3264 if (sibling !== null) {
3265 // Set the return pointer of the sibling to the work-in-progress fiber.
3266 sibling.return = nextFiber.return;
3267 nextFiber = sibling;
3268 break;
3269 }
3270 // No more siblings. Traverse up.
3271 nextFiber = nextFiber.return;
3272 }
3273 }
3274 fiber = nextFiber;
3275 }
3276}
3277
3278function prepareToReadContext(workInProgress, renderExpirationTime) {
3279 currentlyRenderingFiber = workInProgress;
3280 lastContextDependency = null;
3281 lastContextWithAllBitsObserved = null;
3282
3283 var dependencies = workInProgress.dependencies;
3284 if (dependencies !== null) {
3285 var firstContext = dependencies.firstContext;
3286 if (firstContext !== null) {
3287 if (dependencies.expirationTime >= renderExpirationTime) {
3288 // Context list has a pending update. Mark that this fiber performed work.
3289 markWorkInProgressReceivedUpdate();
3290 }
3291 // Reset the work-in-progress list
3292 dependencies.firstContext = null;
3293 }
3294 }
3295}
3296
3297function readContext(context, observedBits) {
3298 {
3299 // This warning would fire if you read context inside a Hook like useMemo.
3300 // Unlike the class check below, it's not enforced in production for perf.
3301 !!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;
3302 }
3303
3304 if (lastContextWithAllBitsObserved === context) {
3305 // Nothing to do. We already observe everything in this context.
3306 } else if (observedBits === false || observedBits === 0) {
3307 // Do not observe any updates.
3308 } else {
3309 var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types.
3310 if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
3311 // Observe all updates.
3312 lastContextWithAllBitsObserved = context;
3313 resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
3314 } else {
3315 resolvedObservedBits = observedBits;
3316 }
3317
3318 var contextItem = {
3319 context: context,
3320 observedBits: resolvedObservedBits,
3321 next: null
3322 };
3323
3324 if (lastContextDependency === null) {
3325 (function () {
3326 if (!(currentlyRenderingFiber !== null)) {
3327 {
3328 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().'));
3329 }
3330 }
3331 })();
3332
3333 // This is the first dependency for this component. Create a new list.
3334 lastContextDependency = contextItem;
3335 currentlyRenderingFiber.dependencies = {
3336 expirationTime: NoWork,
3337 firstContext: contextItem,
3338 responders: null
3339 };
3340 } else {
3341 // Append a new context item.
3342 lastContextDependency = lastContextDependency.next = contextItem;
3343 }
3344 }
3345 return isPrimaryRenderer ? context._currentValue : context._currentValue2;
3346}
3347
3348// UpdateQueue is a linked list of prioritized updates.
3349//
3350// Like fibers, update queues come in pairs: a current queue, which represents
3351// the visible state of the screen, and a work-in-progress queue, which can be
3352// mutated and processed asynchronously before it is committed — a form of
3353// double buffering. If a work-in-progress render is discarded before finishing,
3354// we create a new work-in-progress by cloning the current queue.
3355//
3356// Both queues share a persistent, singly-linked list structure. To schedule an
3357// update, we append it to the end of both queues. Each queue maintains a
3358// pointer to first update in the persistent list that hasn't been processed.
3359// The work-in-progress pointer always has a position equal to or greater than
3360// the current queue, since we always work on that one. The current queue's
3361// pointer is only updated during the commit phase, when we swap in the
3362// work-in-progress.
3363//
3364// For example:
3365//
3366// Current pointer: A - B - C - D - E - F
3367// Work-in-progress pointer: D - E - F
3368// ^
3369// The work-in-progress queue has
3370// processed more updates than current.
3371//
3372// The reason we append to both queues is because otherwise we might drop
3373// updates without ever processing them. For example, if we only add updates to
3374// the work-in-progress queue, some updates could be lost whenever a work-in
3375// -progress render restarts by cloning from current. Similarly, if we only add
3376// updates to the current queue, the updates will be lost whenever an already
3377// in-progress queue commits and swaps with the current queue. However, by
3378// adding to both queues, we guarantee that the update will be part of the next
3379// work-in-progress. (And because the work-in-progress queue becomes the
3380// current queue once it commits, there's no danger of applying the same
3381// update twice.)
3382//
3383// Prioritization
3384// --------------
3385//
3386// Updates are not sorted by priority, but by insertion; new updates are always
3387// appended to the end of the list.
3388//
3389// The priority is still important, though. When processing the update queue
3390// during the render phase, only the updates with sufficient priority are
3391// included in the result. If we skip an update because it has insufficient
3392// priority, it remains in the queue to be processed later, during a lower
3393// priority render. Crucially, all updates subsequent to a skipped update also
3394// remain in the queue *regardless of their priority*. That means high priority
3395// updates are sometimes processed twice, at two separate priorities. We also
3396// keep track of a base state, that represents the state before the first
3397// update in the queue is applied.
3398//
3399// For example:
3400//
3401// Given a base state of '', and the following queue of updates
3402//
3403// A1 - B2 - C1 - D2
3404//
3405// where the number indicates the priority, and the update is applied to the
3406// previous state by appending a letter, React will process these updates as
3407// two separate renders, one per distinct priority level:
3408//
3409// First render, at priority 1:
3410// Base state: ''
3411// Updates: [A1, C1]
3412// Result state: 'AC'
3413//
3414// Second render, at priority 2:
3415// Base state: 'A' <- The base state does not include C1,
3416// because B2 was skipped.
3417// Updates: [B2, C1, D2] <- C1 was rebased on top of B2
3418// Result state: 'ABCD'
3419//
3420// Because we process updates in insertion order, and rebase high priority
3421// updates when preceding updates are skipped, the final result is deterministic
3422// regardless of priority. Intermediate state may vary according to system
3423// resources, but the final state is always the same.
3424
3425var UpdateState = 0;
3426var ReplaceState = 1;
3427var ForceUpdate = 2;
3428var CaptureUpdate = 3;
3429
3430// Global state that is reset at the beginning of calling `processUpdateQueue`.
3431// It should only be read right after calling `processUpdateQueue`, via
3432// `checkHasForceUpdateAfterProcessing`.
3433var hasForceUpdate = false;
3434
3435var didWarnUpdateInsideUpdate = void 0;
3436var currentlyProcessingQueue = void 0;
3437
3438{
3439 didWarnUpdateInsideUpdate = false;
3440 currentlyProcessingQueue = null;
3441
3442}
3443
3444function createUpdateQueue(baseState) {
3445 var queue = {
3446 baseState: baseState,
3447 firstUpdate: null,
3448 lastUpdate: null,
3449 firstCapturedUpdate: null,
3450 lastCapturedUpdate: null,
3451 firstEffect: null,
3452 lastEffect: null,
3453 firstCapturedEffect: null,
3454 lastCapturedEffect: null
3455 };
3456 return queue;
3457}
3458
3459function cloneUpdateQueue(currentQueue) {
3460 var queue = {
3461 baseState: currentQueue.baseState,
3462 firstUpdate: currentQueue.firstUpdate,
3463 lastUpdate: currentQueue.lastUpdate,
3464
3465 // TODO: With resuming, if we bail out and resuse the child tree, we should
3466 // keep these effects.
3467 firstCapturedUpdate: null,
3468 lastCapturedUpdate: null,
3469
3470 firstEffect: null,
3471 lastEffect: null,
3472
3473 firstCapturedEffect: null,
3474 lastCapturedEffect: null
3475 };
3476 return queue;
3477}
3478
3479function createUpdate(expirationTime, suspenseConfig) {
3480 var update = {
3481 expirationTime: expirationTime,
3482 suspenseConfig: suspenseConfig,
3483
3484 tag: UpdateState,
3485 payload: null,
3486 callback: null,
3487
3488 next: null,
3489 nextEffect: null
3490 };
3491 {
3492 update.priority = getCurrentPriorityLevel();
3493 }
3494 return update;
3495}
3496
3497function appendUpdateToQueue(queue, update) {
3498 // Append the update to the end of the list.
3499 if (queue.lastUpdate === null) {
3500 // Queue is empty
3501 queue.firstUpdate = queue.lastUpdate = update;
3502 } else {
3503 queue.lastUpdate.next = update;
3504 queue.lastUpdate = update;
3505 }
3506}
3507
3508function enqueueUpdate(fiber, update) {
3509 // Update queues are created lazily.
3510 var alternate = fiber.alternate;
3511 var queue1 = void 0;
3512 var queue2 = void 0;
3513 if (alternate === null) {
3514 // There's only one fiber.
3515 queue1 = fiber.updateQueue;
3516 queue2 = null;
3517 if (queue1 === null) {
3518 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
3519 }
3520 } else {
3521 // There are two owners.
3522 queue1 = fiber.updateQueue;
3523 queue2 = alternate.updateQueue;
3524 if (queue1 === null) {
3525 if (queue2 === null) {
3526 // Neither fiber has an update queue. Create new ones.
3527 queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
3528 queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
3529 } else {
3530 // Only one fiber has an update queue. Clone to create a new one.
3531 queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
3532 }
3533 } else {
3534 if (queue2 === null) {
3535 // Only one fiber has an update queue. Clone to create a new one.
3536 queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
3537 } else {
3538 // Both owners have an update queue.
3539 }
3540 }
3541 }
3542 if (queue2 === null || queue1 === queue2) {
3543 // There's only a single queue.
3544 appendUpdateToQueue(queue1, update);
3545 } else {
3546 // There are two queues. We need to append the update to both queues,
3547 // while accounting for the persistent structure of the list — we don't
3548 // want the same update to be added multiple times.
3549 if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
3550 // One of the queues is not empty. We must add the update to both queues.
3551 appendUpdateToQueue(queue1, update);
3552 appendUpdateToQueue(queue2, update);
3553 } else {
3554 // Both queues are non-empty. The last update is the same in both lists,
3555 // because of structural sharing. So, only append to one of the lists.
3556 appendUpdateToQueue(queue1, update);
3557 // But we still need to update the `lastUpdate` pointer of queue2.
3558 queue2.lastUpdate = update;
3559 }
3560 }
3561
3562 {
3563 if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
3564 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.');
3565 didWarnUpdateInsideUpdate = true;
3566 }
3567 }
3568}
3569
3570function enqueueCapturedUpdate(workInProgress, update) {
3571 // Captured updates go into a separate list, and only on the work-in-
3572 // progress queue.
3573 var workInProgressQueue = workInProgress.updateQueue;
3574 if (workInProgressQueue === null) {
3575 workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
3576 } else {
3577 // TODO: I put this here rather than createWorkInProgress so that we don't
3578 // clone the queue unnecessarily. There's probably a better way to
3579 // structure this.
3580 workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
3581 }
3582
3583 // Append the update to the end of the list.
3584 if (workInProgressQueue.lastCapturedUpdate === null) {
3585 // This is the first render phase update
3586 workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
3587 } else {
3588 workInProgressQueue.lastCapturedUpdate.next = update;
3589 workInProgressQueue.lastCapturedUpdate = update;
3590 }
3591}
3592
3593function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
3594 var current = workInProgress.alternate;
3595 if (current !== null) {
3596 // If the work-in-progress queue is equal to the current queue,
3597 // we need to clone it first.
3598 if (queue === current.updateQueue) {
3599 queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
3600 }
3601 }
3602 return queue;
3603}
3604
3605function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
3606 switch (update.tag) {
3607 case ReplaceState:
3608 {
3609 var _payload = update.payload;
3610 if (typeof _payload === 'function') {
3611 // Updater function
3612 {
3613 enterDisallowedContextReadInDEV();
3614 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3615 _payload.call(instance, prevState, nextProps);
3616 }
3617 }
3618 var nextState = _payload.call(instance, prevState, nextProps);
3619 {
3620 exitDisallowedContextReadInDEV();
3621 }
3622 return nextState;
3623 }
3624 // State object
3625 return _payload;
3626 }
3627 case CaptureUpdate:
3628 {
3629 workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
3630 }
3631 // Intentional fallthrough
3632 case UpdateState:
3633 {
3634 var _payload2 = update.payload;
3635 var partialState = void 0;
3636 if (typeof _payload2 === 'function') {
3637 // Updater function
3638 {
3639 enterDisallowedContextReadInDEV();
3640 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3641 _payload2.call(instance, prevState, nextProps);
3642 }
3643 }
3644 partialState = _payload2.call(instance, prevState, nextProps);
3645 {
3646 exitDisallowedContextReadInDEV();
3647 }
3648 } else {
3649 // Partial state object
3650 partialState = _payload2;
3651 }
3652 if (partialState === null || partialState === undefined) {
3653 // Null and undefined are treated as no-ops.
3654 return prevState;
3655 }
3656 // Merge the partial state and the previous state.
3657 return _assign({}, prevState, partialState);
3658 }
3659 case ForceUpdate:
3660 {
3661 hasForceUpdate = true;
3662 return prevState;
3663 }
3664 }
3665 return prevState;
3666}
3667
3668function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
3669 hasForceUpdate = false;
3670
3671 queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
3672
3673 {
3674 currentlyProcessingQueue = queue;
3675 }
3676
3677 // These values may change as we process the queue.
3678 var newBaseState = queue.baseState;
3679 var newFirstUpdate = null;
3680 var newExpirationTime = NoWork;
3681
3682 // Iterate through the list of updates to compute the result.
3683 var update = queue.firstUpdate;
3684 var resultState = newBaseState;
3685 while (update !== null) {
3686 var updateExpirationTime = update.expirationTime;
3687 if (updateExpirationTime < renderExpirationTime) {
3688 // This update does not have sufficient priority. Skip it.
3689 if (newFirstUpdate === null) {
3690 // This is the first skipped update. It will be the first update in
3691 // the new list.
3692 newFirstUpdate = update;
3693 // Since this is the first update that was skipped, the current result
3694 // is the new base state.
3695 newBaseState = resultState;
3696 }
3697 // Since this update will remain in the list, update the remaining
3698 // expiration time.
3699 if (newExpirationTime < updateExpirationTime) {
3700 newExpirationTime = updateExpirationTime;
3701 }
3702 } else {
3703 // This update does have sufficient priority.
3704
3705 // Mark the event time of this update as relevant to this render pass.
3706 // TODO: This should ideally use the true event time of this update rather than
3707 // its priority which is a derived and not reverseable value.
3708 // TODO: We should skip this update if it was already committed but currently
3709 // we have no way of detecting the difference between a committed and suspended
3710 // update here.
3711 markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig);
3712
3713 // Process it and compute a new result.
3714 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
3715 var _callback = update.callback;
3716 if (_callback !== null) {
3717 workInProgress.effectTag |= Callback;
3718 // Set this to null, in case it was mutated during an aborted render.
3719 update.nextEffect = null;
3720 if (queue.lastEffect === null) {
3721 queue.firstEffect = queue.lastEffect = update;
3722 } else {
3723 queue.lastEffect.nextEffect = update;
3724 queue.lastEffect = update;
3725 }
3726 }
3727 }
3728 // Continue to the next update.
3729 update = update.next;
3730 }
3731
3732 // Separately, iterate though the list of captured updates.
3733 var newFirstCapturedUpdate = null;
3734 update = queue.firstCapturedUpdate;
3735 while (update !== null) {
3736 var _updateExpirationTime = update.expirationTime;
3737 if (_updateExpirationTime < renderExpirationTime) {
3738 // This update does not have sufficient priority. Skip it.
3739 if (newFirstCapturedUpdate === null) {
3740 // This is the first skipped captured update. It will be the first
3741 // update in the new list.
3742 newFirstCapturedUpdate = update;
3743 // If this is the first update that was skipped, the current result is
3744 // the new base state.
3745 if (newFirstUpdate === null) {
3746 newBaseState = resultState;
3747 }
3748 }
3749 // Since this update will remain in the list, update the remaining
3750 // expiration time.
3751 if (newExpirationTime < _updateExpirationTime) {
3752 newExpirationTime = _updateExpirationTime;
3753 }
3754 } else {
3755 // This update does have sufficient priority. Process it and compute
3756 // a new result.
3757 resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
3758 var _callback2 = update.callback;
3759 if (_callback2 !== null) {
3760 workInProgress.effectTag |= Callback;
3761 // Set this to null, in case it was mutated during an aborted render.
3762 update.nextEffect = null;
3763 if (queue.lastCapturedEffect === null) {
3764 queue.firstCapturedEffect = queue.lastCapturedEffect = update;
3765 } else {
3766 queue.lastCapturedEffect.nextEffect = update;
3767 queue.lastCapturedEffect = update;
3768 }
3769 }
3770 }
3771 update = update.next;
3772 }
3773
3774 if (newFirstUpdate === null) {
3775 queue.lastUpdate = null;
3776 }
3777 if (newFirstCapturedUpdate === null) {
3778 queue.lastCapturedUpdate = null;
3779 } else {
3780 workInProgress.effectTag |= Callback;
3781 }
3782 if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
3783 // We processed every update, without skipping. That means the new base
3784 // state is the same as the result state.
3785 newBaseState = resultState;
3786 }
3787
3788 queue.baseState = newBaseState;
3789 queue.firstUpdate = newFirstUpdate;
3790 queue.firstCapturedUpdate = newFirstCapturedUpdate;
3791
3792 // Set the remaining expiration time to be whatever is remaining in the queue.
3793 // This should be fine because the only two other things that contribute to
3794 // expiration time are props and context. We're already in the middle of the
3795 // begin phase by the time we start processing the queue, so we've already
3796 // dealt with the props. Context in components that specify
3797 // shouldComponentUpdate is tricky; but we'll have to account for
3798 // that regardless.
3799 workInProgress.expirationTime = newExpirationTime;
3800 workInProgress.memoizedState = resultState;
3801
3802 {
3803 currentlyProcessingQueue = null;
3804 }
3805}
3806
3807function callCallback(callback, context) {
3808 (function () {
3809 if (!(typeof callback === 'function')) {
3810 {
3811 throw ReactError(Error('Invalid argument passed as callback. Expected a function. Instead received: ' + callback));
3812 }
3813 }
3814 })();
3815 callback.call(context);
3816}
3817
3818function resetHasForceUpdateBeforeProcessing() {
3819 hasForceUpdate = false;
3820}
3821
3822function checkHasForceUpdateAfterProcessing() {
3823 return hasForceUpdate;
3824}
3825
3826function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
3827 // If the finished render included captured updates, and there are still
3828 // lower priority updates left over, we need to keep the captured updates
3829 // in the queue so that they are rebased and not dropped once we process the
3830 // queue again at the lower priority.
3831 if (finishedQueue.firstCapturedUpdate !== null) {
3832 // Join the captured update list to the end of the normal list.
3833 if (finishedQueue.lastUpdate !== null) {
3834 finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
3835 finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
3836 }
3837 // Clear the list of captured updates.
3838 finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
3839 }
3840
3841 // Commit the effects
3842 commitUpdateEffects(finishedQueue.firstEffect, instance);
3843 finishedQueue.firstEffect = finishedQueue.lastEffect = null;
3844
3845 commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
3846 finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
3847}
3848
3849function commitUpdateEffects(effect, instance) {
3850 while (effect !== null) {
3851 var _callback3 = effect.callback;
3852 if (_callback3 !== null) {
3853 effect.callback = null;
3854 callCallback(_callback3, instance);
3855 }
3856 effect = effect.nextEffect;
3857 }
3858}
3859
3860var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
3861
3862
3863function requestCurrentSuspenseConfig() {
3864 return ReactCurrentBatchConfig.suspense;
3865}
3866
3867var fakeInternalInstance = {};
3868var isArray$1 = Array.isArray;
3869
3870// React.Component uses a shared frozen object by default.
3871// We'll use it to determine whether we need to initialize legacy refs.
3872var emptyRefsObject = new React.Component().refs;
3873
3874var didWarnAboutStateAssignmentForComponent = void 0;
3875var didWarnAboutUninitializedState = void 0;
3876var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = void 0;
3877var didWarnAboutLegacyLifecyclesAndDerivedState = void 0;
3878var didWarnAboutUndefinedDerivedState = void 0;
3879var warnOnUndefinedDerivedState = void 0;
3880var warnOnInvalidCallback = void 0;
3881var didWarnAboutDirectlyAssigningPropsToState = void 0;
3882var didWarnAboutContextTypeAndContextTypes = void 0;
3883var didWarnAboutInvalidateContextType = void 0;
3884
3885{
3886 didWarnAboutStateAssignmentForComponent = new Set();
3887 didWarnAboutUninitializedState = new Set();
3888 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
3889 didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
3890 didWarnAboutDirectlyAssigningPropsToState = new Set();
3891 didWarnAboutUndefinedDerivedState = new Set();
3892 didWarnAboutContextTypeAndContextTypes = new Set();
3893 didWarnAboutInvalidateContextType = new Set();
3894
3895 var didWarnOnInvalidCallback = new Set();
3896
3897 warnOnInvalidCallback = function (callback, callerName) {
3898 if (callback === null || typeof callback === 'function') {
3899 return;
3900 }
3901 var key = callerName + '_' + callback;
3902 if (!didWarnOnInvalidCallback.has(key)) {
3903 didWarnOnInvalidCallback.add(key);
3904 warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
3905 }
3906 };
3907
3908 warnOnUndefinedDerivedState = function (type, partialState) {
3909 if (partialState === undefined) {
3910 var componentName = getComponentName(type) || 'Component';
3911 if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
3912 didWarnAboutUndefinedDerivedState.add(componentName);
3913 warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
3914 }
3915 }
3916 };
3917
3918 // This is so gross but it's at least non-critical and can be removed if
3919 // it causes problems. This is meant to give a nicer error message for
3920 // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
3921 // ...)) which otherwise throws a "_processChildContext is not a function"
3922 // exception.
3923 Object.defineProperty(fakeInternalInstance, '_processChildContext', {
3924 enumerable: false,
3925 value: function () {
3926 (function () {
3927 {
3928 {
3929 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).'));
3930 }
3931 }
3932 })();
3933 }
3934 });
3935 Object.freeze(fakeInternalInstance);
3936}
3937
3938function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
3939 var prevState = workInProgress.memoizedState;
3940
3941 {
3942 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
3943 // Invoke the function an extra time to help detect side-effects.
3944 getDerivedStateFromProps(nextProps, prevState);
3945 }
3946 }
3947
3948 var partialState = getDerivedStateFromProps(nextProps, prevState);
3949
3950 {
3951 warnOnUndefinedDerivedState(ctor, partialState);
3952 }
3953 // Merge the partial state and the previous state.
3954 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
3955 workInProgress.memoizedState = memoizedState;
3956
3957 // Once the update queue is empty, persist the derived state onto the
3958 // base state.
3959 var updateQueue = workInProgress.updateQueue;
3960 if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
3961 updateQueue.baseState = memoizedState;
3962 }
3963}
3964
3965var classComponentUpdater = {
3966 isMounted: isMounted,
3967 enqueueSetState: function (inst, payload, callback) {
3968 var fiber = get(inst);
3969 var currentTime = requestCurrentTime();
3970 var suspenseConfig = requestCurrentSuspenseConfig();
3971 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
3972
3973 var update = createUpdate(expirationTime, suspenseConfig);
3974 update.payload = payload;
3975 if (callback !== undefined && callback !== null) {
3976 {
3977 warnOnInvalidCallback(callback, 'setState');
3978 }
3979 update.callback = callback;
3980 }
3981
3982 if (revertPassiveEffectsChange) {
3983 flushPassiveEffects();
3984 }
3985 enqueueUpdate(fiber, update);
3986 scheduleWork(fiber, expirationTime);
3987 },
3988 enqueueReplaceState: function (inst, payload, callback) {
3989 var fiber = get(inst);
3990 var currentTime = requestCurrentTime();
3991 var suspenseConfig = requestCurrentSuspenseConfig();
3992 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
3993
3994 var update = createUpdate(expirationTime, suspenseConfig);
3995 update.tag = ReplaceState;
3996 update.payload = payload;
3997
3998 if (callback !== undefined && callback !== null) {
3999 {
4000 warnOnInvalidCallback(callback, 'replaceState');
4001 }
4002 update.callback = callback;
4003 }
4004
4005 if (revertPassiveEffectsChange) {
4006 flushPassiveEffects();
4007 }
4008 enqueueUpdate(fiber, update);
4009 scheduleWork(fiber, expirationTime);
4010 },
4011 enqueueForceUpdate: function (inst, callback) {
4012 var fiber = get(inst);
4013 var currentTime = requestCurrentTime();
4014 var suspenseConfig = requestCurrentSuspenseConfig();
4015 var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
4016
4017 var update = createUpdate(expirationTime, suspenseConfig);
4018 update.tag = ForceUpdate;
4019
4020 if (callback !== undefined && callback !== null) {
4021 {
4022 warnOnInvalidCallback(callback, 'forceUpdate');
4023 }
4024 update.callback = callback;
4025 }
4026
4027 if (revertPassiveEffectsChange) {
4028 flushPassiveEffects();
4029 }
4030 enqueueUpdate(fiber, update);
4031 scheduleWork(fiber, expirationTime);
4032 }
4033};
4034
4035function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
4036 var instance = workInProgress.stateNode;
4037 if (typeof instance.shouldComponentUpdate === 'function') {
4038 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
4039 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
4040 stopPhaseTimer();
4041
4042 {
4043 !(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;
4044 }
4045
4046 return shouldUpdate;
4047 }
4048
4049 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
4050 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
4051 }
4052
4053 return true;
4054}
4055
4056function checkClassInstance(workInProgress, ctor, newProps) {
4057 var instance = workInProgress.stateNode;
4058 {
4059 var name = getComponentName(ctor) || 'Component';
4060 var renderPresent = instance.render;
4061
4062 if (!renderPresent) {
4063 if (ctor.prototype && typeof ctor.prototype.render === 'function') {
4064 warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
4065 } else {
4066 warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
4067 }
4068 }
4069
4070 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
4071 !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;
4072 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
4073 !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;
4074 var noInstancePropTypes = !instance.propTypes;
4075 !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
4076 var noInstanceContextType = !instance.contextType;
4077 !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
4078
4079 if (disableLegacyContext) {
4080 if (ctor.childContextTypes) {
4081 warningWithoutStack$1(false, '%s uses the legacy childContextTypes API which is no longer supported. ' + 'Use React.createContext() instead.', name);
4082 }
4083 if (ctor.contextTypes) {
4084 warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with static contextType instead.', name);
4085 }
4086 } else {
4087 var noInstanceContextTypes = !instance.contextTypes;
4088 !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
4089
4090 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
4091 didWarnAboutContextTypeAndContextTypes.add(ctor);
4092 warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
4093 }
4094 }
4095
4096 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
4097 !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;
4098 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
4099 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');
4100 }
4101 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
4102 !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
4103 var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
4104 !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;
4105 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
4106 !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
4107 var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
4108 !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
4109 var hasMutatedProps = instance.props !== newProps;
4110 !(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;
4111 var noInstanceDefaultProps = !instance.defaultProps;
4112 !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;
4113
4114 if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
4115 didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
4116 warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
4117 }
4118
4119 var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
4120 !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;
4121 var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
4122 !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;
4123 var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
4124 !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;
4125 var _state = instance.state;
4126 if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
4127 warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
4128 }
4129 if (typeof instance.getChildContext === 'function') {
4130 !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
4131 }
4132 }
4133}
4134
4135function adoptClassInstance(workInProgress, instance) {
4136 instance.updater = classComponentUpdater;
4137 workInProgress.stateNode = instance;
4138 // The instance needs access to the fiber so that it can schedule updates
4139 set(instance, workInProgress);
4140 {
4141 instance._reactInternalInstance = fakeInternalInstance;
4142 }
4143}
4144
4145function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
4146 var isLegacyContextConsumer = false;
4147 var unmaskedContext = emptyContextObject;
4148 var context = emptyContextObject;
4149 var contextType = ctor.contextType;
4150
4151 {
4152 if ('contextType' in ctor) {
4153 var isValid =
4154 // Allow null for conditional declaration
4155 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
4156
4157 if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
4158 didWarnAboutInvalidateContextType.add(ctor);
4159
4160 var addendum = '';
4161 if (contextType === undefined) {
4162 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.';
4163 } else if (typeof contextType !== 'object') {
4164 addendum = ' However, it is set to a ' + typeof contextType + '.';
4165 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
4166 addendum = ' Did you accidentally pass the Context.Provider instead?';
4167 } else if (contextType._context !== undefined) {
4168 // <Context.Consumer>
4169 addendum = ' Did you accidentally pass the Context.Consumer instead?';
4170 } else {
4171 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
4172 }
4173 warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
4174 }
4175 }
4176 }
4177
4178 if (typeof contextType === 'object' && contextType !== null) {
4179 context = readContext(contextType);
4180 } else if (!disableLegacyContext) {
4181 unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4182 var contextTypes = ctor.contextTypes;
4183 isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
4184 context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
4185 }
4186
4187 // Instantiate twice to help detect side-effects.
4188 {
4189 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
4190 new ctor(props, context); // eslint-disable-line no-new
4191 }
4192 }
4193
4194 var instance = new ctor(props, context);
4195 var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
4196 adoptClassInstance(workInProgress, instance);
4197
4198 {
4199 if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
4200 var componentName = getComponentName(ctor) || 'Component';
4201 if (!didWarnAboutUninitializedState.has(componentName)) {
4202 didWarnAboutUninitializedState.add(componentName);
4203 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);
4204 }
4205 }
4206
4207 // If new component APIs are defined, "unsafe" lifecycles won't be called.
4208 // Warn about these lifecycles if they are present.
4209 // Don't warn about react-lifecycles-compat polyfilled methods though.
4210 if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
4211 var foundWillMountName = null;
4212 var foundWillReceivePropsName = null;
4213 var foundWillUpdateName = null;
4214 if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
4215 foundWillMountName = 'componentWillMount';
4216 } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
4217 foundWillMountName = 'UNSAFE_componentWillMount';
4218 }
4219 if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
4220 foundWillReceivePropsName = 'componentWillReceiveProps';
4221 } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4222 foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
4223 }
4224 if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
4225 foundWillUpdateName = 'componentWillUpdate';
4226 } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4227 foundWillUpdateName = 'UNSAFE_componentWillUpdate';
4228 }
4229 if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
4230 var _componentName = getComponentName(ctor) || 'Component';
4231 var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
4232 if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
4233 didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
4234 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-async-component-lifecycle-hooks', _componentName, newApiName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '');
4235 }
4236 }
4237 }
4238 }
4239
4240 // Cache unmasked context so we can avoid recreating masked context unless necessary.
4241 // ReactFiberContext usually updates this cache but can't for newly-created instances.
4242 if (isLegacyContextConsumer) {
4243 cacheContext(workInProgress, unmaskedContext, context);
4244 }
4245
4246 return instance;
4247}
4248
4249function callComponentWillMount(workInProgress, instance) {
4250 startPhaseTimer(workInProgress, 'componentWillMount');
4251 var oldState = instance.state;
4252
4253 if (typeof instance.componentWillMount === 'function') {
4254 instance.componentWillMount();
4255 }
4256 if (typeof instance.UNSAFE_componentWillMount === 'function') {
4257 instance.UNSAFE_componentWillMount();
4258 }
4259
4260 stopPhaseTimer();
4261
4262 if (oldState !== instance.state) {
4263 {
4264 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');
4265 }
4266 classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
4267 }
4268}
4269
4270function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
4271 var oldState = instance.state;
4272 startPhaseTimer(workInProgress, 'componentWillReceiveProps');
4273 if (typeof instance.componentWillReceiveProps === 'function') {
4274 instance.componentWillReceiveProps(newProps, nextContext);
4275 }
4276 if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
4277 instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
4278 }
4279 stopPhaseTimer();
4280
4281 if (instance.state !== oldState) {
4282 {
4283 var componentName = getComponentName(workInProgress.type) || 'Component';
4284 if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
4285 didWarnAboutStateAssignmentForComponent.add(componentName);
4286 warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
4287 }
4288 }
4289 classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
4290 }
4291}
4292
4293// Invokes the mount life-cycles on a previously never rendered instance.
4294function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
4295 {
4296 checkClassInstance(workInProgress, ctor, newProps);
4297 }
4298
4299 var instance = workInProgress.stateNode;
4300 instance.props = newProps;
4301 instance.state = workInProgress.memoizedState;
4302 instance.refs = emptyRefsObject;
4303
4304 var contextType = ctor.contextType;
4305 if (typeof contextType === 'object' && contextType !== null) {
4306 instance.context = readContext(contextType);
4307 } else if (disableLegacyContext) {
4308 instance.context = emptyContextObject;
4309 } else {
4310 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4311 instance.context = getMaskedContext(workInProgress, unmaskedContext);
4312 }
4313
4314 {
4315 if (instance.state === newProps) {
4316 var componentName = getComponentName(ctor) || 'Component';
4317 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
4318 didWarnAboutDirectlyAssigningPropsToState.add(componentName);
4319 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);
4320 }
4321 }
4322
4323 if (workInProgress.mode & StrictMode) {
4324 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
4325 }
4326
4327 if (warnAboutDeprecatedLifecycles) {
4328 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
4329 }
4330 }
4331
4332 var updateQueue = workInProgress.updateQueue;
4333 if (updateQueue !== null) {
4334 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4335 instance.state = workInProgress.memoizedState;
4336 }
4337
4338 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4339 if (typeof getDerivedStateFromProps === 'function') {
4340 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4341 instance.state = workInProgress.memoizedState;
4342 }
4343
4344 // In order to support react-lifecycles-compat polyfilled components,
4345 // Unsafe lifecycles should not be invoked for components using the new APIs.
4346 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
4347 callComponentWillMount(workInProgress, instance);
4348 // If we had additional state updates during this life-cycle, let's
4349 // process them now.
4350 updateQueue = workInProgress.updateQueue;
4351 if (updateQueue !== null) {
4352 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4353 instance.state = workInProgress.memoizedState;
4354 }
4355 }
4356
4357 if (typeof instance.componentDidMount === 'function') {
4358 workInProgress.effectTag |= Update;
4359 }
4360}
4361
4362function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
4363 var instance = workInProgress.stateNode;
4364
4365 var oldProps = workInProgress.memoizedProps;
4366 instance.props = oldProps;
4367
4368 var oldContext = instance.context;
4369 var contextType = ctor.contextType;
4370 var nextContext = emptyContextObject;
4371 if (typeof contextType === 'object' && contextType !== null) {
4372 nextContext = readContext(contextType);
4373 } else if (!disableLegacyContext) {
4374 var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4375 nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
4376 }
4377
4378 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4379 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
4380
4381 // Note: During these life-cycles, instance.props/instance.state are what
4382 // ever the previously attempted to render - not the "current". However,
4383 // during componentDidUpdate we pass the "current" props.
4384
4385 // In order to support react-lifecycles-compat polyfilled components,
4386 // Unsafe lifecycles should not be invoked for components using the new APIs.
4387 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4388 if (oldProps !== newProps || oldContext !== nextContext) {
4389 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4390 }
4391 }
4392
4393 resetHasForceUpdateBeforeProcessing();
4394
4395 var oldState = workInProgress.memoizedState;
4396 var newState = instance.state = oldState;
4397 var updateQueue = workInProgress.updateQueue;
4398 if (updateQueue !== null) {
4399 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4400 newState = workInProgress.memoizedState;
4401 }
4402 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
4403 // If an update was already in progress, we should schedule an Update
4404 // effect even though we're bailing out, so that cWU/cDU are called.
4405 if (typeof instance.componentDidMount === 'function') {
4406 workInProgress.effectTag |= Update;
4407 }
4408 return false;
4409 }
4410
4411 if (typeof getDerivedStateFromProps === 'function') {
4412 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4413 newState = workInProgress.memoizedState;
4414 }
4415
4416 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4417
4418 if (shouldUpdate) {
4419 // In order to support react-lifecycles-compat polyfilled components,
4420 // Unsafe lifecycles should not be invoked for components using the new APIs.
4421 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
4422 startPhaseTimer(workInProgress, 'componentWillMount');
4423 if (typeof instance.componentWillMount === 'function') {
4424 instance.componentWillMount();
4425 }
4426 if (typeof instance.UNSAFE_componentWillMount === 'function') {
4427 instance.UNSAFE_componentWillMount();
4428 }
4429 stopPhaseTimer();
4430 }
4431 if (typeof instance.componentDidMount === 'function') {
4432 workInProgress.effectTag |= Update;
4433 }
4434 } else {
4435 // If an update was already in progress, we should schedule an Update
4436 // effect even though we're bailing out, so that cWU/cDU are called.
4437 if (typeof instance.componentDidMount === 'function') {
4438 workInProgress.effectTag |= Update;
4439 }
4440
4441 // If shouldComponentUpdate returned false, we should still update the
4442 // memoized state to indicate that this work can be reused.
4443 workInProgress.memoizedProps = newProps;
4444 workInProgress.memoizedState = newState;
4445 }
4446
4447 // Update the existing instance's state, props, and context pointers even
4448 // if shouldComponentUpdate returns false.
4449 instance.props = newProps;
4450 instance.state = newState;
4451 instance.context = nextContext;
4452
4453 return shouldUpdate;
4454}
4455
4456// Invokes the update life-cycles and returns false if it shouldn't rerender.
4457function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
4458 var instance = workInProgress.stateNode;
4459
4460 var oldProps = workInProgress.memoizedProps;
4461 instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
4462
4463 var oldContext = instance.context;
4464 var contextType = ctor.contextType;
4465 var nextContext = emptyContextObject;
4466 if (typeof contextType === 'object' && contextType !== null) {
4467 nextContext = readContext(contextType);
4468 } else if (!disableLegacyContext) {
4469 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
4470 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
4471 }
4472
4473 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
4474 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
4475
4476 // Note: During these life-cycles, instance.props/instance.state are what
4477 // ever the previously attempted to render - not the "current". However,
4478 // during componentDidUpdate we pass the "current" props.
4479
4480 // In order to support react-lifecycles-compat polyfilled components,
4481 // Unsafe lifecycles should not be invoked for components using the new APIs.
4482 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
4483 if (oldProps !== newProps || oldContext !== nextContext) {
4484 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
4485 }
4486 }
4487
4488 resetHasForceUpdateBeforeProcessing();
4489
4490 var oldState = workInProgress.memoizedState;
4491 var newState = instance.state = oldState;
4492 var updateQueue = workInProgress.updateQueue;
4493 if (updateQueue !== null) {
4494 processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
4495 newState = workInProgress.memoizedState;
4496 }
4497
4498 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
4499 // If an update was already in progress, we should schedule an Update
4500 // effect even though we're bailing out, so that cWU/cDU are called.
4501 if (typeof instance.componentDidUpdate === 'function') {
4502 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4503 workInProgress.effectTag |= Update;
4504 }
4505 }
4506 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4507 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4508 workInProgress.effectTag |= Snapshot;
4509 }
4510 }
4511 return false;
4512 }
4513
4514 if (typeof getDerivedStateFromProps === 'function') {
4515 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
4516 newState = workInProgress.memoizedState;
4517 }
4518
4519 var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
4520
4521 if (shouldUpdate) {
4522 // In order to support react-lifecycles-compat polyfilled components,
4523 // Unsafe lifecycles should not be invoked for components using the new APIs.
4524 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
4525 startPhaseTimer(workInProgress, 'componentWillUpdate');
4526 if (typeof instance.componentWillUpdate === 'function') {
4527 instance.componentWillUpdate(newProps, newState, nextContext);
4528 }
4529 if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
4530 instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
4531 }
4532 stopPhaseTimer();
4533 }
4534 if (typeof instance.componentDidUpdate === 'function') {
4535 workInProgress.effectTag |= Update;
4536 }
4537 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4538 workInProgress.effectTag |= Snapshot;
4539 }
4540 } else {
4541 // If an update was already in progress, we should schedule an Update
4542 // effect even though we're bailing out, so that cWU/cDU are called.
4543 if (typeof instance.componentDidUpdate === 'function') {
4544 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4545 workInProgress.effectTag |= Update;
4546 }
4547 }
4548 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
4549 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
4550 workInProgress.effectTag |= Snapshot;
4551 }
4552 }
4553
4554 // If shouldComponentUpdate returned false, we should still update the
4555 // memoized props/state to indicate that this work can be reused.
4556 workInProgress.memoizedProps = newProps;
4557 workInProgress.memoizedState = newState;
4558 }
4559
4560 // Update the existing instance's state, props, and context pointers even
4561 // if shouldComponentUpdate returns false.
4562 instance.props = newProps;
4563 instance.state = newState;
4564 instance.context = nextContext;
4565
4566 return shouldUpdate;
4567}
4568
4569var didWarnAboutMaps = void 0;
4570var didWarnAboutGenerators = void 0;
4571var didWarnAboutStringRefInStrictMode = void 0;
4572var ownerHasKeyUseWarning = void 0;
4573var ownerHasFunctionTypeWarning = void 0;
4574var warnForMissingKey = function (child) {};
4575
4576{
4577 didWarnAboutMaps = false;
4578 didWarnAboutGenerators = false;
4579 didWarnAboutStringRefInStrictMode = {};
4580
4581 /**
4582 * Warn if there's no key explicitly set on dynamic arrays of children or
4583 * object keys are not valid. This allows us to keep track of children between
4584 * updates.
4585 */
4586 ownerHasKeyUseWarning = {};
4587 ownerHasFunctionTypeWarning = {};
4588
4589 warnForMissingKey = function (child) {
4590 if (child === null || typeof child !== 'object') {
4591 return;
4592 }
4593 if (!child._store || child._store.validated || child.key != null) {
4594 return;
4595 }
4596 (function () {
4597 if (!(typeof child._store === 'object')) {
4598 {
4599 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.'));
4600 }
4601 }
4602 })();
4603 child._store.validated = true;
4604
4605 var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
4606 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
4607 return;
4608 }
4609 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
4610
4611 warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
4612 };
4613}
4614
4615var isArray = Array.isArray;
4616
4617function coerceRef(returnFiber, current$$1, element) {
4618 var mixedRef = element.ref;
4619 if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
4620 {
4621 if (returnFiber.mode & StrictMode) {
4622 var componentName = getComponentName(returnFiber.type) || 'Component';
4623 if (!didWarnAboutStringRefInStrictMode[componentName]) {
4624 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 createRef() instead.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-string-ref', mixedRef, getStackByFiberInDevAndProd(returnFiber));
4625 didWarnAboutStringRefInStrictMode[componentName] = true;
4626 }
4627 }
4628 }
4629
4630 if (element._owner) {
4631 var owner = element._owner;
4632 var inst = void 0;
4633 if (owner) {
4634 var ownerFiber = owner;
4635 (function () {
4636 if (!(ownerFiber.tag === ClassComponent)) {
4637 {
4638 throw ReactError(Error('Function components cannot have refs. Did you mean to use React.forwardRef()?'));
4639 }
4640 }
4641 })();
4642 inst = ownerFiber.stateNode;
4643 }
4644 (function () {
4645 if (!inst) {
4646 {
4647 throw ReactError(Error('Missing owner for string ref ' + mixedRef + '. This error is likely caused by a bug in React. Please file an issue.'));
4648 }
4649 }
4650 })();
4651 var stringRef = '' + mixedRef;
4652 // Check if previous string ref matches new string ref
4653 if (current$$1 !== null && current$$1.ref !== null && typeof current$$1.ref === 'function' && current$$1.ref._stringRef === stringRef) {
4654 return current$$1.ref;
4655 }
4656 var ref = function (value) {
4657 var refs = inst.refs;
4658 if (refs === emptyRefsObject) {
4659 // This is a lazy pooled frozen object, so we need to initialize.
4660 refs = inst.refs = {};
4661 }
4662 if (value === null) {
4663 delete refs[stringRef];
4664 } else {
4665 refs[stringRef] = value;
4666 }
4667 };
4668 ref._stringRef = stringRef;
4669 return ref;
4670 } else {
4671 (function () {
4672 if (!(typeof mixedRef === 'string')) {
4673 {
4674 throw ReactError(Error('Expected ref to be a function, a string, an object returned by React.createRef(), or null.'));
4675 }
4676 }
4677 })();
4678 (function () {
4679 if (!element._owner) {
4680 {
4681 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.'));
4682 }
4683 }
4684 })();
4685 }
4686 }
4687 return mixedRef;
4688}
4689
4690function throwOnInvalidObjectType(returnFiber, newChild) {
4691 if (returnFiber.type !== 'textarea') {
4692 var addendum = '';
4693 {
4694 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
4695 }
4696 (function () {
4697 {
4698 {
4699 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));
4700 }
4701 }
4702 })();
4703 }
4704}
4705
4706function warnOnFunctionType() {
4707 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();
4708
4709 if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
4710 return;
4711 }
4712 ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
4713
4714 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.');
4715}
4716
4717// This wrapper function exists because I expect to clone the code in each path
4718// to be able to optimize each path individually by branching early. This needs
4719// a compiler or we can do it manually. Helpers that don't need this branching
4720// live outside of this function.
4721function ChildReconciler(shouldTrackSideEffects) {
4722 function deleteChild(returnFiber, childToDelete) {
4723 if (!shouldTrackSideEffects) {
4724 // Noop.
4725 return;
4726 }
4727 // Deletions are added in reversed order so we add it to the front.
4728 // At this point, the return fiber's effect list is empty except for
4729 // deletions, so we can just append the deletion to the list. The remaining
4730 // effects aren't added until the complete phase. Once we implement
4731 // resuming, this may not be true.
4732 var last = returnFiber.lastEffect;
4733 if (last !== null) {
4734 last.nextEffect = childToDelete;
4735 returnFiber.lastEffect = childToDelete;
4736 } else {
4737 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
4738 }
4739 childToDelete.nextEffect = null;
4740 childToDelete.effectTag = Deletion;
4741 }
4742
4743 function deleteRemainingChildren(returnFiber, currentFirstChild) {
4744 if (!shouldTrackSideEffects) {
4745 // Noop.
4746 return null;
4747 }
4748
4749 // TODO: For the shouldClone case, this could be micro-optimized a bit by
4750 // assuming that after the first child we've already added everything.
4751 var childToDelete = currentFirstChild;
4752 while (childToDelete !== null) {
4753 deleteChild(returnFiber, childToDelete);
4754 childToDelete = childToDelete.sibling;
4755 }
4756 return null;
4757 }
4758
4759 function mapRemainingChildren(returnFiber, currentFirstChild) {
4760 // Add the remaining children to a temporary map so that we can find them by
4761 // keys quickly. Implicit (null) keys get added to this set with their index
4762 var existingChildren = new Map();
4763
4764 var existingChild = currentFirstChild;
4765 while (existingChild !== null) {
4766 if (existingChild.key !== null) {
4767 existingChildren.set(existingChild.key, existingChild);
4768 } else {
4769 existingChildren.set(existingChild.index, existingChild);
4770 }
4771 existingChild = existingChild.sibling;
4772 }
4773 return existingChildren;
4774 }
4775
4776 function useFiber(fiber, pendingProps, expirationTime) {
4777 // We currently set sibling to null and index to 0 here because it is easy
4778 // to forget to do before returning it. E.g. for the single child case.
4779 var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
4780 clone.index = 0;
4781 clone.sibling = null;
4782 return clone;
4783 }
4784
4785 function placeChild(newFiber, lastPlacedIndex, newIndex) {
4786 newFiber.index = newIndex;
4787 if (!shouldTrackSideEffects) {
4788 // Noop.
4789 return lastPlacedIndex;
4790 }
4791 var current$$1 = newFiber.alternate;
4792 if (current$$1 !== null) {
4793 var oldIndex = current$$1.index;
4794 if (oldIndex < lastPlacedIndex) {
4795 // This is a move.
4796 newFiber.effectTag = Placement;
4797 return lastPlacedIndex;
4798 } else {
4799 // This item can stay in place.
4800 return oldIndex;
4801 }
4802 } else {
4803 // This is an insertion.
4804 newFiber.effectTag = Placement;
4805 return lastPlacedIndex;
4806 }
4807 }
4808
4809 function placeSingleChild(newFiber) {
4810 // This is simpler for the single child case. We only need to do a
4811 // placement for inserting new children.
4812 if (shouldTrackSideEffects && newFiber.alternate === null) {
4813 newFiber.effectTag = Placement;
4814 }
4815 return newFiber;
4816 }
4817
4818 function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {
4819 if (current$$1 === null || current$$1.tag !== HostText) {
4820 // Insert
4821 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
4822 created.return = returnFiber;
4823 return created;
4824 } else {
4825 // Update
4826 var existing = useFiber(current$$1, textContent, expirationTime);
4827 existing.return = returnFiber;
4828 return existing;
4829 }
4830 }
4831
4832 function updateElement(returnFiber, current$$1, element, expirationTime) {
4833 if (current$$1 !== null && (current$$1.elementType === element.type || (
4834 // Keep this check inline so it only runs on the false path:
4835 isCompatibleFamilyForHotReloading(current$$1, element)))) {
4836 // Move based on index
4837 var existing = useFiber(current$$1, element.props, expirationTime);
4838 existing.ref = coerceRef(returnFiber, current$$1, element);
4839 existing.return = returnFiber;
4840 {
4841 existing._debugSource = element._source;
4842 existing._debugOwner = element._owner;
4843 }
4844 return existing;
4845 } else {
4846 // Insert
4847 var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
4848 created.ref = coerceRef(returnFiber, current$$1, element);
4849 created.return = returnFiber;
4850 return created;
4851 }
4852 }
4853
4854 function updatePortal(returnFiber, current$$1, portal, expirationTime) {
4855 if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {
4856 // Insert
4857 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
4858 created.return = returnFiber;
4859 return created;
4860 } else {
4861 // Update
4862 var existing = useFiber(current$$1, portal.children || [], expirationTime);
4863 existing.return = returnFiber;
4864 return existing;
4865 }
4866 }
4867
4868 function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {
4869 if (current$$1 === null || current$$1.tag !== Fragment) {
4870 // Insert
4871 var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
4872 created.return = returnFiber;
4873 return created;
4874 } else {
4875 // Update
4876 var existing = useFiber(current$$1, fragment, expirationTime);
4877 existing.return = returnFiber;
4878 return existing;
4879 }
4880 }
4881
4882 function createChild(returnFiber, newChild, expirationTime) {
4883 if (typeof newChild === 'string' || typeof newChild === 'number') {
4884 // Text nodes don't have keys. If the previous node is implicitly keyed
4885 // we can continue to replace it without aborting even if it is not a text
4886 // node.
4887 var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
4888 created.return = returnFiber;
4889 return created;
4890 }
4891
4892 if (typeof newChild === 'object' && newChild !== null) {
4893 switch (newChild.$$typeof) {
4894 case REACT_ELEMENT_TYPE:
4895 {
4896 var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
4897 _created.ref = coerceRef(returnFiber, null, newChild);
4898 _created.return = returnFiber;
4899 return _created;
4900 }
4901 case REACT_PORTAL_TYPE:
4902 {
4903 var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
4904 _created2.return = returnFiber;
4905 return _created2;
4906 }
4907 }
4908
4909 if (isArray(newChild) || getIteratorFn(newChild)) {
4910 var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
4911 _created3.return = returnFiber;
4912 return _created3;
4913 }
4914
4915 throwOnInvalidObjectType(returnFiber, newChild);
4916 }
4917
4918 {
4919 if (typeof newChild === 'function') {
4920 warnOnFunctionType();
4921 }
4922 }
4923
4924 return null;
4925 }
4926
4927 function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
4928 // Update the fiber if the keys match, otherwise return null.
4929
4930 var key = oldFiber !== null ? oldFiber.key : null;
4931
4932 if (typeof newChild === 'string' || typeof newChild === 'number') {
4933 // Text nodes don't have keys. If the previous node is implicitly keyed
4934 // we can continue to replace it without aborting even if it is not a text
4935 // node.
4936 if (key !== null) {
4937 return null;
4938 }
4939 return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
4940 }
4941
4942 if (typeof newChild === 'object' && newChild !== null) {
4943 switch (newChild.$$typeof) {
4944 case REACT_ELEMENT_TYPE:
4945 {
4946 if (newChild.key === key) {
4947 if (newChild.type === REACT_FRAGMENT_TYPE) {
4948 return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
4949 }
4950 return updateElement(returnFiber, oldFiber, newChild, expirationTime);
4951 } else {
4952 return null;
4953 }
4954 }
4955 case REACT_PORTAL_TYPE:
4956 {
4957 if (newChild.key === key) {
4958 return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
4959 } else {
4960 return null;
4961 }
4962 }
4963 }
4964
4965 if (isArray(newChild) || getIteratorFn(newChild)) {
4966 if (key !== null) {
4967 return null;
4968 }
4969
4970 return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
4971 }
4972
4973 throwOnInvalidObjectType(returnFiber, newChild);
4974 }
4975
4976 {
4977 if (typeof newChild === 'function') {
4978 warnOnFunctionType();
4979 }
4980 }
4981
4982 return null;
4983 }
4984
4985 function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
4986 if (typeof newChild === 'string' || typeof newChild === 'number') {
4987 // Text nodes don't have keys, so we neither have to check the old nor
4988 // new node for the key. If both are text nodes, they match.
4989 var matchedFiber = existingChildren.get(newIdx) || null;
4990 return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
4991 }
4992
4993 if (typeof newChild === 'object' && newChild !== null) {
4994 switch (newChild.$$typeof) {
4995 case REACT_ELEMENT_TYPE:
4996 {
4997 var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
4998 if (newChild.type === REACT_FRAGMENT_TYPE) {
4999 return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
5000 }
5001 return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
5002 }
5003 case REACT_PORTAL_TYPE:
5004 {
5005 var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
5006 return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
5007 }
5008 }
5009
5010 if (isArray(newChild) || getIteratorFn(newChild)) {
5011 var _matchedFiber3 = existingChildren.get(newIdx) || null;
5012 return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
5013 }
5014
5015 throwOnInvalidObjectType(returnFiber, newChild);
5016 }
5017
5018 {
5019 if (typeof newChild === 'function') {
5020 warnOnFunctionType();
5021 }
5022 }
5023
5024 return null;
5025 }
5026
5027 /**
5028 * Warns if there is a duplicate or missing key
5029 */
5030 function warnOnInvalidKey(child, knownKeys) {
5031 {
5032 if (typeof child !== 'object' || child === null) {
5033 return knownKeys;
5034 }
5035 switch (child.$$typeof) {
5036 case REACT_ELEMENT_TYPE:
5037 case REACT_PORTAL_TYPE:
5038 warnForMissingKey(child);
5039 var key = child.key;
5040 if (typeof key !== 'string') {
5041 break;
5042 }
5043 if (knownKeys === null) {
5044 knownKeys = new Set();
5045 knownKeys.add(key);
5046 break;
5047 }
5048 if (!knownKeys.has(key)) {
5049 knownKeys.add(key);
5050 break;
5051 }
5052 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);
5053 break;
5054 default:
5055 break;
5056 }
5057 }
5058 return knownKeys;
5059 }
5060
5061 function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
5062 // This algorithm can't optimize by searching from both ends since we
5063 // don't have backpointers on fibers. I'm trying to see how far we can get
5064 // with that model. If it ends up not being worth the tradeoffs, we can
5065 // add it later.
5066
5067 // Even with a two ended optimization, we'd want to optimize for the case
5068 // where there are few changes and brute force the comparison instead of
5069 // going for the Map. It'd like to explore hitting that path first in
5070 // forward-only mode and only go for the Map once we notice that we need
5071 // lots of look ahead. This doesn't handle reversal as well as two ended
5072 // search but that's unusual. Besides, for the two ended optimization to
5073 // work on Iterables, we'd need to copy the whole set.
5074
5075 // In this first iteration, we'll just live with hitting the bad case
5076 // (adding everything to a Map) in for every insert/move.
5077
5078 // If you change this code, also update reconcileChildrenIterator() which
5079 // uses the same algorithm.
5080
5081 {
5082 // First, validate keys.
5083 var knownKeys = null;
5084 for (var i = 0; i < newChildren.length; i++) {
5085 var child = newChildren[i];
5086 knownKeys = warnOnInvalidKey(child, knownKeys);
5087 }
5088 }
5089
5090 var resultingFirstChild = null;
5091 var previousNewFiber = null;
5092
5093 var oldFiber = currentFirstChild;
5094 var lastPlacedIndex = 0;
5095 var newIdx = 0;
5096 var nextOldFiber = null;
5097 for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
5098 if (oldFiber.index > newIdx) {
5099 nextOldFiber = oldFiber;
5100 oldFiber = null;
5101 } else {
5102 nextOldFiber = oldFiber.sibling;
5103 }
5104 var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
5105 if (newFiber === null) {
5106 // TODO: This breaks on empty slots like null children. That's
5107 // unfortunate because it triggers the slow path all the time. We need
5108 // a better way to communicate whether this was a miss or null,
5109 // boolean, undefined, etc.
5110 if (oldFiber === null) {
5111 oldFiber = nextOldFiber;
5112 }
5113 break;
5114 }
5115 if (shouldTrackSideEffects) {
5116 if (oldFiber && newFiber.alternate === null) {
5117 // We matched the slot, but we didn't reuse the existing fiber, so we
5118 // need to delete the existing child.
5119 deleteChild(returnFiber, oldFiber);
5120 }
5121 }
5122 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
5123 if (previousNewFiber === null) {
5124 // TODO: Move out of the loop. This only happens for the first run.
5125 resultingFirstChild = newFiber;
5126 } else {
5127 // TODO: Defer siblings if we're not at the right index for this slot.
5128 // I.e. if we had null values before, then we want to defer this
5129 // for each null value. However, we also don't want to call updateSlot
5130 // with the previous one.
5131 previousNewFiber.sibling = newFiber;
5132 }
5133 previousNewFiber = newFiber;
5134 oldFiber = nextOldFiber;
5135 }
5136
5137 if (newIdx === newChildren.length) {
5138 // We've reached the end of the new children. We can delete the rest.
5139 deleteRemainingChildren(returnFiber, oldFiber);
5140 return resultingFirstChild;
5141 }
5142
5143 if (oldFiber === null) {
5144 // If we don't have any more existing children we can choose a fast path
5145 // since the rest will all be insertions.
5146 for (; newIdx < newChildren.length; newIdx++) {
5147 var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
5148 if (_newFiber === null) {
5149 continue;
5150 }
5151 lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
5152 if (previousNewFiber === null) {
5153 // TODO: Move out of the loop. This only happens for the first run.
5154 resultingFirstChild = _newFiber;
5155 } else {
5156 previousNewFiber.sibling = _newFiber;
5157 }
5158 previousNewFiber = _newFiber;
5159 }
5160 return resultingFirstChild;
5161 }
5162
5163 // Add all children to a key map for quick lookups.
5164 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
5165
5166 // Keep scanning and use the map to restore deleted items as moves.
5167 for (; newIdx < newChildren.length; newIdx++) {
5168 var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
5169 if (_newFiber2 !== null) {
5170 if (shouldTrackSideEffects) {
5171 if (_newFiber2.alternate !== null) {
5172 // The new fiber is a work in progress, but if there exists a
5173 // current, that means that we reused the fiber. We need to delete
5174 // it from the child list so that we don't add it to the deletion
5175 // list.
5176 existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
5177 }
5178 }
5179 lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
5180 if (previousNewFiber === null) {
5181 resultingFirstChild = _newFiber2;
5182 } else {
5183 previousNewFiber.sibling = _newFiber2;
5184 }
5185 previousNewFiber = _newFiber2;
5186 }
5187 }
5188
5189 if (shouldTrackSideEffects) {
5190 // Any existing children that weren't consumed above were deleted. We need
5191 // to add them to the deletion list.
5192 existingChildren.forEach(function (child) {
5193 return deleteChild(returnFiber, child);
5194 });
5195 }
5196
5197 return resultingFirstChild;
5198 }
5199
5200 function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
5201 // This is the same implementation as reconcileChildrenArray(),
5202 // but using the iterator instead.
5203
5204 var iteratorFn = getIteratorFn(newChildrenIterable);
5205 (function () {
5206 if (!(typeof iteratorFn === 'function')) {
5207 {
5208 throw ReactError(Error('An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.'));
5209 }
5210 }
5211 })();
5212
5213 {
5214 // We don't support rendering Generators because it's a mutation.
5215 // See https://github.com/facebook/react/issues/12995
5216 if (typeof Symbol === 'function' &&
5217 // $FlowFixMe Flow doesn't know about toStringTag
5218 newChildrenIterable[Symbol.toStringTag] === 'Generator') {
5219 !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;
5220 didWarnAboutGenerators = true;
5221 }
5222
5223 // Warn about using Maps as children
5224 if (newChildrenIterable.entries === iteratorFn) {
5225 !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;
5226 didWarnAboutMaps = true;
5227 }
5228
5229 // First, validate keys.
5230 // We'll get a different iterator later for the main pass.
5231 var _newChildren = iteratorFn.call(newChildrenIterable);
5232 if (_newChildren) {
5233 var knownKeys = null;
5234 var _step = _newChildren.next();
5235 for (; !_step.done; _step = _newChildren.next()) {
5236 var child = _step.value;
5237 knownKeys = warnOnInvalidKey(child, knownKeys);
5238 }
5239 }
5240 }
5241
5242 var newChildren = iteratorFn.call(newChildrenIterable);
5243 (function () {
5244 if (!(newChildren != null)) {
5245 {
5246 throw ReactError(Error('An iterable object provided no iterator.'));
5247 }
5248 }
5249 })();
5250
5251 var resultingFirstChild = null;
5252 var previousNewFiber = null;
5253
5254 var oldFiber = currentFirstChild;
5255 var lastPlacedIndex = 0;
5256 var newIdx = 0;
5257 var nextOldFiber = null;
5258
5259 var step = newChildren.next();
5260 for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
5261 if (oldFiber.index > newIdx) {
5262 nextOldFiber = oldFiber;
5263 oldFiber = null;
5264 } else {
5265 nextOldFiber = oldFiber.sibling;
5266 }
5267 var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
5268 if (newFiber === null) {
5269 // TODO: This breaks on empty slots like null children. That's
5270 // unfortunate because it triggers the slow path all the time. We need
5271 // a better way to communicate whether this was a miss or null,
5272 // boolean, undefined, etc.
5273 if (oldFiber === null) {
5274 oldFiber = nextOldFiber;
5275 }
5276 break;
5277 }
5278 if (shouldTrackSideEffects) {
5279 if (oldFiber && newFiber.alternate === null) {
5280 // We matched the slot, but we didn't reuse the existing fiber, so we
5281 // need to delete the existing child.
5282 deleteChild(returnFiber, oldFiber);
5283 }
5284 }
5285 lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
5286 if (previousNewFiber === null) {
5287 // TODO: Move out of the loop. This only happens for the first run.
5288 resultingFirstChild = newFiber;
5289 } else {
5290 // TODO: Defer siblings if we're not at the right index for this slot.
5291 // I.e. if we had null values before, then we want to defer this
5292 // for each null value. However, we also don't want to call updateSlot
5293 // with the previous one.
5294 previousNewFiber.sibling = newFiber;
5295 }
5296 previousNewFiber = newFiber;
5297 oldFiber = nextOldFiber;
5298 }
5299
5300 if (step.done) {
5301 // We've reached the end of the new children. We can delete the rest.
5302 deleteRemainingChildren(returnFiber, oldFiber);
5303 return resultingFirstChild;
5304 }
5305
5306 if (oldFiber === null) {
5307 // If we don't have any more existing children we can choose a fast path
5308 // since the rest will all be insertions.
5309 for (; !step.done; newIdx++, step = newChildren.next()) {
5310 var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
5311 if (_newFiber3 === null) {
5312 continue;
5313 }
5314 lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
5315 if (previousNewFiber === null) {
5316 // TODO: Move out of the loop. This only happens for the first run.
5317 resultingFirstChild = _newFiber3;
5318 } else {
5319 previousNewFiber.sibling = _newFiber3;
5320 }
5321 previousNewFiber = _newFiber3;
5322 }
5323 return resultingFirstChild;
5324 }
5325
5326 // Add all children to a key map for quick lookups.
5327 var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
5328
5329 // Keep scanning and use the map to restore deleted items as moves.
5330 for (; !step.done; newIdx++, step = newChildren.next()) {
5331 var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
5332 if (_newFiber4 !== null) {
5333 if (shouldTrackSideEffects) {
5334 if (_newFiber4.alternate !== null) {
5335 // The new fiber is a work in progress, but if there exists a
5336 // current, that means that we reused the fiber. We need to delete
5337 // it from the child list so that we don't add it to the deletion
5338 // list.
5339 existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
5340 }
5341 }
5342 lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
5343 if (previousNewFiber === null) {
5344 resultingFirstChild = _newFiber4;
5345 } else {
5346 previousNewFiber.sibling = _newFiber4;
5347 }
5348 previousNewFiber = _newFiber4;
5349 }
5350 }
5351
5352 if (shouldTrackSideEffects) {
5353 // Any existing children that weren't consumed above were deleted. We need
5354 // to add them to the deletion list.
5355 existingChildren.forEach(function (child) {
5356 return deleteChild(returnFiber, child);
5357 });
5358 }
5359
5360 return resultingFirstChild;
5361 }
5362
5363 function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
5364 // There's no need to check for keys on text nodes since we don't have a
5365 // way to define them.
5366 if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
5367 // We already have an existing node so let's just update it and delete
5368 // the rest.
5369 deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
5370 var existing = useFiber(currentFirstChild, textContent, expirationTime);
5371 existing.return = returnFiber;
5372 return existing;
5373 }
5374 // The existing first child is not a text node so we need to create one
5375 // and delete the existing ones.
5376 deleteRemainingChildren(returnFiber, currentFirstChild);
5377 var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
5378 created.return = returnFiber;
5379 return created;
5380 }
5381
5382 function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
5383 var key = element.key;
5384 var child = currentFirstChild;
5385 while (child !== null) {
5386 // TODO: If key === null and child.key === null, then this only applies to
5387 // the first item in the list.
5388 if (child.key === key) {
5389 if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || (
5390 // Keep this check inline so it only runs on the false path:
5391 isCompatibleFamilyForHotReloading(child, element))) {
5392 deleteRemainingChildren(returnFiber, child.sibling);
5393 var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
5394 existing.ref = coerceRef(returnFiber, child, element);
5395 existing.return = returnFiber;
5396 {
5397 existing._debugSource = element._source;
5398 existing._debugOwner = element._owner;
5399 }
5400 return existing;
5401 } else {
5402 deleteRemainingChildren(returnFiber, child);
5403 break;
5404 }
5405 } else {
5406 deleteChild(returnFiber, child);
5407 }
5408 child = child.sibling;
5409 }
5410
5411 if (element.type === REACT_FRAGMENT_TYPE) {
5412 var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
5413 created.return = returnFiber;
5414 return created;
5415 } else {
5416 var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
5417 _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
5418 _created4.return = returnFiber;
5419 return _created4;
5420 }
5421 }
5422
5423 function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
5424 var key = portal.key;
5425 var child = currentFirstChild;
5426 while (child !== null) {
5427 // TODO: If key === null and child.key === null, then this only applies to
5428 // the first item in the list.
5429 if (child.key === key) {
5430 if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
5431 deleteRemainingChildren(returnFiber, child.sibling);
5432 var existing = useFiber(child, portal.children || [], expirationTime);
5433 existing.return = returnFiber;
5434 return existing;
5435 } else {
5436 deleteRemainingChildren(returnFiber, child);
5437 break;
5438 }
5439 } else {
5440 deleteChild(returnFiber, child);
5441 }
5442 child = child.sibling;
5443 }
5444
5445 var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
5446 created.return = returnFiber;
5447 return created;
5448 }
5449
5450 // This API will tag the children with the side-effect of the reconciliation
5451 // itself. They will be added to the side-effect list as we pass through the
5452 // children and the parent.
5453 function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
5454 // This function is not recursive.
5455 // If the top level item is an array, we treat it as a set of children,
5456 // not as a fragment. Nested arrays on the other hand will be treated as
5457 // fragment nodes. Recursion happens at the normal flow.
5458
5459 // Handle top level unkeyed fragments as if they were arrays.
5460 // This leads to an ambiguity between <>{[...]}</> and <>...</>.
5461 // We treat the ambiguous cases above the same.
5462 var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
5463 if (isUnkeyedTopLevelFragment) {
5464 newChild = newChild.props.children;
5465 }
5466
5467 // Handle object types
5468 var isObject = typeof newChild === 'object' && newChild !== null;
5469
5470 if (isObject) {
5471 switch (newChild.$$typeof) {
5472 case REACT_ELEMENT_TYPE:
5473 return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
5474 case REACT_PORTAL_TYPE:
5475 return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
5476 }
5477 }
5478
5479 if (typeof newChild === 'string' || typeof newChild === 'number') {
5480 return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
5481 }
5482
5483 if (isArray(newChild)) {
5484 return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
5485 }
5486
5487 if (getIteratorFn(newChild)) {
5488 return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
5489 }
5490
5491 if (isObject) {
5492 throwOnInvalidObjectType(returnFiber, newChild);
5493 }
5494
5495 {
5496 if (typeof newChild === 'function') {
5497 warnOnFunctionType();
5498 }
5499 }
5500 if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
5501 // If the new child is undefined, and the return fiber is a composite
5502 // component, throw an error. If Fiber return types are disabled,
5503 // we already threw above.
5504 switch (returnFiber.tag) {
5505 case ClassComponent:
5506 {
5507 {
5508 var instance = returnFiber.stateNode;
5509 if (instance.render._isMockFunction) {
5510 // We allow auto-mocks to proceed as if they're returning null.
5511 break;
5512 }
5513 }
5514 }
5515 // Intentionally fall through to the next case, which handles both
5516 // functions and classes
5517 // eslint-disable-next-lined no-fallthrough
5518 case FunctionComponent:
5519 {
5520 var Component = returnFiber.type;
5521 (function () {
5522 {
5523 {
5524 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.'));
5525 }
5526 }
5527 })();
5528 }
5529 }
5530 }
5531
5532 // Remaining cases are all treated as empty.
5533 return deleteRemainingChildren(returnFiber, currentFirstChild);
5534 }
5535
5536 return reconcileChildFibers;
5537}
5538
5539var reconcileChildFibers = ChildReconciler(true);
5540var mountChildFibers = ChildReconciler(false);
5541
5542function cloneChildFibers(current$$1, workInProgress) {
5543 (function () {
5544 if (!(current$$1 === null || workInProgress.child === current$$1.child)) {
5545 {
5546 throw ReactError(Error('Resuming work not yet implemented.'));
5547 }
5548 }
5549 })();
5550
5551 if (workInProgress.child === null) {
5552 return;
5553 }
5554
5555 var currentChild = workInProgress.child;
5556 var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
5557 workInProgress.child = newChild;
5558
5559 newChild.return = workInProgress;
5560 while (currentChild.sibling !== null) {
5561 currentChild = currentChild.sibling;
5562 newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
5563 newChild.return = workInProgress;
5564 }
5565 newChild.sibling = null;
5566}
5567
5568// Reset a workInProgress child set to prepare it for a second pass.
5569function resetChildFibers(workInProgress, renderExpirationTime) {
5570 var child = workInProgress.child;
5571 while (child !== null) {
5572 resetWorkInProgress(child, renderExpirationTime);
5573 child = child.sibling;
5574 }
5575}
5576
5577var NO_CONTEXT$1 = {};
5578
5579var contextStackCursor$1 = createCursor(NO_CONTEXT$1);
5580var contextFiberStackCursor = createCursor(NO_CONTEXT$1);
5581var rootInstanceStackCursor = createCursor(NO_CONTEXT$1);
5582
5583function requiredContext(c) {
5584 (function () {
5585 if (!(c !== NO_CONTEXT$1)) {
5586 {
5587 throw ReactError(Error('Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.'));
5588 }
5589 }
5590 })();
5591 return c;
5592}
5593
5594function getRootHostContainer() {
5595 var rootInstance = requiredContext(rootInstanceStackCursor.current);
5596 return rootInstance;
5597}
5598
5599function pushHostContainer(fiber, nextRootInstance) {
5600 // Push current root instance onto the stack;
5601 // This allows us to reset root when portals are popped.
5602 push(rootInstanceStackCursor, nextRootInstance, fiber);
5603 // Track the context and the Fiber that provided it.
5604 // This enables us to pop only Fibers that provide unique contexts.
5605 push(contextFiberStackCursor, fiber, fiber);
5606
5607 // Finally, we need to push the host context to the stack.
5608 // However, we can't just call getRootHostContext() and push it because
5609 // we'd have a different number of entries on the stack depending on
5610 // whether getRootHostContext() throws somewhere in renderer code or not.
5611 // So we push an empty value first. This lets us safely unwind on errors.
5612 push(contextStackCursor$1, NO_CONTEXT$1, fiber);
5613 var nextRootContext = getRootHostContext(nextRootInstance);
5614 // Now that we know this function doesn't throw, replace it.
5615 pop(contextStackCursor$1, fiber);
5616 push(contextStackCursor$1, nextRootContext, fiber);
5617}
5618
5619function popHostContainer(fiber) {
5620 pop(contextStackCursor$1, fiber);
5621 pop(contextFiberStackCursor, fiber);
5622 pop(rootInstanceStackCursor, fiber);
5623}
5624
5625function getHostContext() {
5626 var context = requiredContext(contextStackCursor$1.current);
5627 return context;
5628}
5629
5630function pushHostContext(fiber) {
5631 var rootInstance = requiredContext(rootInstanceStackCursor.current);
5632 var context = requiredContext(contextStackCursor$1.current);
5633 var nextContext = getChildHostContext(context, fiber.type, rootInstance);
5634
5635 // Don't push this Fiber's context unless it's unique.
5636 if (context === nextContext) {
5637 return;
5638 }
5639
5640 // Track the context and the Fiber that provided it.
5641 // This enables us to pop only Fibers that provide unique contexts.
5642 push(contextFiberStackCursor, fiber, fiber);
5643 push(contextStackCursor$1, nextContext, fiber);
5644}
5645
5646function popHostContext(fiber) {
5647 // Do not pop unless this Fiber provided the current context.
5648 // pushHostContext() only pushes Fibers that provide unique contexts.
5649 if (contextFiberStackCursor.current !== fiber) {
5650 return;
5651 }
5652
5653 pop(contextStackCursor$1, fiber);
5654 pop(contextFiberStackCursor, fiber);
5655}
5656
5657var DefaultSuspenseContext = 0;
5658
5659// The Suspense Context is split into two parts. The lower bits is
5660// inherited deeply down the subtree. The upper bits only affect
5661// this immediate suspense boundary and gets reset each new
5662// boundary or suspense list.
5663var SubtreeSuspenseContextMask = 1;
5664
5665// Subtree Flags:
5666
5667// InvisibleParentSuspenseContext indicates that one of our parent Suspense
5668// boundaries is not currently showing visible main content.
5669// Either because it is already showing a fallback or is not mounted at all.
5670// We can use this to determine if it is desirable to trigger a fallback at
5671// the parent. If not, then we might need to trigger undesirable boundaries
5672// and/or suspend the commit to avoid hiding the parent content.
5673var InvisibleParentSuspenseContext = 1;
5674
5675// Shallow Flags:
5676
5677// ForceSuspenseFallback can be used by SuspenseList to force newly added
5678// items into their fallback state during one of the render passes.
5679var ForceSuspenseFallback = 2;
5680
5681var suspenseStackCursor = createCursor(DefaultSuspenseContext);
5682
5683function hasSuspenseContext(parentContext, flag) {
5684 return (parentContext & flag) !== 0;
5685}
5686
5687function setDefaultShallowSuspenseContext(parentContext) {
5688 return parentContext & SubtreeSuspenseContextMask;
5689}
5690
5691function setShallowSuspenseContext(parentContext, shallowContext) {
5692 return parentContext & SubtreeSuspenseContextMask | shallowContext;
5693}
5694
5695function addSubtreeSuspenseContext(parentContext, subtreeContext) {
5696 return parentContext | subtreeContext;
5697}
5698
5699function pushSuspenseContext(fiber, newContext) {
5700 push(suspenseStackCursor, newContext, fiber);
5701}
5702
5703function popSuspenseContext(fiber) {
5704 pop(suspenseStackCursor, fiber);
5705}
5706
5707// TODO: This is now an empty object. Should we switch this to a boolean?
5708// Alternatively we can make this use an effect tag similar to SuspenseList.
5709
5710
5711function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
5712 // If it was the primary children that just suspended, capture and render the
5713 var nextState = workInProgress.memoizedState;
5714 if (nextState !== null) {
5715 return false;
5716 }
5717 var props = workInProgress.memoizedProps;
5718 // In order to capture, the Suspense component must have a fallback prop.
5719 if (props.fallback === undefined) {
5720 return false;
5721 }
5722 // Regular boundaries always capture.
5723 if (props.unstable_avoidThisFallback !== true) {
5724 return true;
5725 }
5726 // If it's a boundary we should avoid, then we prefer to bubble up to the
5727 // parent boundary if it is currently invisible.
5728 if (hasInvisibleParent) {
5729 return false;
5730 }
5731 // If the parent is not able to handle it, we must handle it.
5732 return true;
5733}
5734
5735function findFirstSuspended(row) {
5736 var node = row;
5737 while (node !== null) {
5738 if (node.tag === SuspenseComponent) {
5739 var state = node.memoizedState;
5740 if (state !== null) {
5741 return node;
5742 }
5743 } else if (node.tag === SuspenseListComponent &&
5744 // revealOrder undefined can't be trusted because it don't
5745 // keep track of whether it suspended or not.
5746 node.memoizedProps.revealOrder !== undefined) {
5747 var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
5748 if (didSuspend) {
5749 return node;
5750 }
5751 } else if (node.child !== null) {
5752 node.child.return = node;
5753 node = node.child;
5754 continue;
5755 }
5756 if (node === row) {
5757 return null;
5758 }
5759 while (node.sibling === null) {
5760 if (node.return === null || node.return === row) {
5761 return null;
5762 }
5763 node = node.return;
5764 }
5765 node.sibling.return = node.return;
5766 node = node.sibling;
5767 }
5768 return null;
5769}
5770
5771function createResponderListener(responder, props) {
5772 var eventResponderListener = {
5773 responder: responder,
5774 props: props
5775 };
5776 {
5777 Object.freeze(eventResponderListener);
5778 }
5779 return eventResponderListener;
5780}
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790function createResponderInstance(responder, responderProps, responderState, target, fiber) {
5791 return {
5792 fiber: fiber,
5793 props: responderProps,
5794 responder: responder,
5795 rootEventTypes: null,
5796 state: responderState,
5797 target: target
5798 };
5799}
5800
5801var NoEffect$1 = /* */0;
5802var UnmountSnapshot = /* */2;
5803var UnmountMutation = /* */4;
5804var MountMutation = /* */8;
5805var UnmountLayout = /* */16;
5806var MountLayout = /* */32;
5807var MountPassive = /* */64;
5808var UnmountPassive = /* */128;
5809
5810var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
5811
5812
5813var didWarnAboutMismatchedHooksForComponent = void 0;
5814{
5815 didWarnAboutMismatchedHooksForComponent = new Set();
5816}
5817
5818// These are set right before calling the component.
5819var renderExpirationTime$1 = NoWork;
5820// The work-in-progress fiber. I've named it differently to distinguish it from
5821// the work-in-progress hook.
5822var currentlyRenderingFiber$1 = null;
5823
5824// Hooks are stored as a linked list on the fiber's memoizedState field. The
5825// current hook list is the list that belongs to the current fiber. The
5826// work-in-progress hook list is a new list that will be added to the
5827// work-in-progress fiber.
5828var currentHook = null;
5829var nextCurrentHook = null;
5830var firstWorkInProgressHook = null;
5831var workInProgressHook = null;
5832var nextWorkInProgressHook = null;
5833
5834var remainingExpirationTime = NoWork;
5835var componentUpdateQueue = null;
5836var sideEffectTag = 0;
5837
5838// Updates scheduled during render will trigger an immediate re-render at the
5839// end of the current pass. We can't store these updates on the normal queue,
5840// because if the work is aborted, they should be discarded. Because this is
5841// a relatively rare case, we also don't want to add an additional field to
5842// either the hook or queue object types. So we store them in a lazily create
5843// map of queue -> render-phase updates, which are discarded once the component
5844// completes without re-rendering.
5845
5846// Whether an update was scheduled during the currently executing render pass.
5847var didScheduleRenderPhaseUpdate = false;
5848// Lazily created map of render-phase updates
5849var renderPhaseUpdates = null;
5850// Counter to prevent infinite loops.
5851var numberOfReRenders = 0;
5852var RE_RENDER_LIMIT = 25;
5853
5854// In DEV, this is the name of the currently executing primitive hook
5855var currentHookNameInDev = null;
5856
5857// In DEV, this list ensures that hooks are called in the same order between renders.
5858// The list stores the order of hooks used during the initial render (mount).
5859// Subsequent renders (updates) reference this list.
5860var hookTypesDev = null;
5861var hookTypesUpdateIndexDev = -1;
5862
5863// In DEV, this tracks whether currently rendering component needs to ignore
5864// the dependencies for Hooks that need them (e.g. useEffect or useMemo).
5865// When true, such Hooks will always be "remounted". Only used during hot reload.
5866var ignorePreviousDependencies = false;
5867
5868function mountHookTypesDev() {
5869 {
5870 var hookName = currentHookNameInDev;
5871
5872 if (hookTypesDev === null) {
5873 hookTypesDev = [hookName];
5874 } else {
5875 hookTypesDev.push(hookName);
5876 }
5877 }
5878}
5879
5880function updateHookTypesDev() {
5881 {
5882 var hookName = currentHookNameInDev;
5883
5884 if (hookTypesDev !== null) {
5885 hookTypesUpdateIndexDev++;
5886 if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
5887 warnOnHookMismatchInDev(hookName);
5888 }
5889 }
5890 }
5891}
5892
5893function checkDepsAreArrayDev(deps) {
5894 {
5895 if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
5896 // Verify deps, but only on mount to avoid extra checks.
5897 // It's unlikely their type would change as usually you define them inline.
5898 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);
5899 }
5900 }
5901}
5902
5903function warnOnHookMismatchInDev(currentHookName) {
5904 {
5905 var componentName = getComponentName(currentlyRenderingFiber$1.type);
5906 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
5907 didWarnAboutMismatchedHooksForComponent.add(componentName);
5908
5909 if (hookTypesDev !== null) {
5910 var table = '';
5911
5912 var secondColumnStart = 30;
5913
5914 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
5915 var oldHookName = hookTypesDev[i];
5916 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
5917
5918 var row = i + 1 + '. ' + oldHookName;
5919
5920 // Extra space so second column lines up
5921 // lol @ IE not supporting String#repeat
5922 while (row.length < secondColumnStart) {
5923 row += ' ';
5924 }
5925
5926 row += newHookName + '\n';
5927
5928 table += row;
5929 }
5930
5931 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);
5932 }
5933 }
5934 }
5935}
5936
5937function throwInvalidHookError() {
5938 (function () {
5939 {
5940 {
5941 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.'));
5942 }
5943 }
5944 })();
5945}
5946
5947function areHookInputsEqual(nextDeps, prevDeps) {
5948 {
5949 if (ignorePreviousDependencies) {
5950 // Only true when this component is being hot reloaded.
5951 return false;
5952 }
5953 }
5954
5955 if (prevDeps === null) {
5956 {
5957 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);
5958 }
5959 return false;
5960 }
5961
5962 {
5963 // Don't bother comparing lengths in prod because these arrays should be
5964 // passed inline.
5965 if (nextDeps.length !== prevDeps.length) {
5966 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(', ') + ']');
5967 }
5968 }
5969 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
5970 if (is(nextDeps[i], prevDeps[i])) {
5971 continue;
5972 }
5973 return false;
5974 }
5975 return true;
5976}
5977
5978function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
5979 renderExpirationTime$1 = nextRenderExpirationTime;
5980 currentlyRenderingFiber$1 = workInProgress;
5981 nextCurrentHook = current !== null ? current.memoizedState : null;
5982
5983 {
5984 hookTypesDev = current !== null ? current._debugHookTypes : null;
5985 hookTypesUpdateIndexDev = -1;
5986 // Used for hot reloading:
5987 ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
5988 }
5989
5990 // The following should have already been reset
5991 // currentHook = null;
5992 // workInProgressHook = null;
5993
5994 // remainingExpirationTime = NoWork;
5995 // componentUpdateQueue = null;
5996
5997 // didScheduleRenderPhaseUpdate = false;
5998 // renderPhaseUpdates = null;
5999 // numberOfReRenders = 0;
6000 // sideEffectTag = 0;
6001
6002 // TODO Warn if no hooks are used at all during mount, then some are used during update.
6003 // Currently we will identify the update render as a mount because nextCurrentHook === null.
6004 // This is tricky because it's valid for certain types of components (e.g. React.lazy)
6005
6006 // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
6007 // Non-stateful hooks (e.g. context) don't get added to memoizedState,
6008 // so nextCurrentHook would be null during updates and mounts.
6009 {
6010 if (nextCurrentHook !== null) {
6011 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
6012 } else if (hookTypesDev !== null) {
6013 // This dispatcher handles an edge case where a component is updating,
6014 // but no stateful hooks have been used.
6015 // We want to match the production code behavior (which will use HooksDispatcherOnMount),
6016 // but with the extra DEV validation to ensure hooks ordering hasn't changed.
6017 // This dispatcher does that.
6018 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
6019 } else {
6020 ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
6021 }
6022 }
6023
6024 var children = Component(props, refOrContext);
6025
6026 if (didScheduleRenderPhaseUpdate) {
6027 do {
6028 didScheduleRenderPhaseUpdate = false;
6029 numberOfReRenders += 1;
6030
6031 // Start over from the beginning of the list
6032 nextCurrentHook = current !== null ? current.memoizedState : null;
6033 nextWorkInProgressHook = firstWorkInProgressHook;
6034
6035 currentHook = null;
6036 workInProgressHook = null;
6037 componentUpdateQueue = null;
6038
6039 {
6040 // Also validate hook order for cascading updates.
6041 hookTypesUpdateIndexDev = -1;
6042 }
6043
6044 ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
6045
6046 children = Component(props, refOrContext);
6047 } while (didScheduleRenderPhaseUpdate);
6048
6049 renderPhaseUpdates = null;
6050 numberOfReRenders = 0;
6051 }
6052
6053 // We can assume the previous dispatcher is always this one, since we set it
6054 // at the beginning of the render phase and there's no re-entrancy.
6055 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
6056
6057 var renderedWork = currentlyRenderingFiber$1;
6058
6059 renderedWork.memoizedState = firstWorkInProgressHook;
6060 renderedWork.expirationTime = remainingExpirationTime;
6061 renderedWork.updateQueue = componentUpdateQueue;
6062 renderedWork.effectTag |= sideEffectTag;
6063
6064 {
6065 renderedWork._debugHookTypes = hookTypesDev;
6066 }
6067
6068 // This check uses currentHook so that it works the same in DEV and prod bundles.
6069 // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
6070 var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
6071
6072 renderExpirationTime$1 = NoWork;
6073 currentlyRenderingFiber$1 = null;
6074
6075 currentHook = null;
6076 nextCurrentHook = null;
6077 firstWorkInProgressHook = null;
6078 workInProgressHook = null;
6079 nextWorkInProgressHook = null;
6080
6081 {
6082 currentHookNameInDev = null;
6083 hookTypesDev = null;
6084 hookTypesUpdateIndexDev = -1;
6085 }
6086
6087 remainingExpirationTime = NoWork;
6088 componentUpdateQueue = null;
6089 sideEffectTag = 0;
6090
6091 // These were reset above
6092 // didScheduleRenderPhaseUpdate = false;
6093 // renderPhaseUpdates = null;
6094 // numberOfReRenders = 0;
6095
6096 (function () {
6097 if (!!didRenderTooFewHooks) {
6098 {
6099 throw ReactError(Error('Rendered fewer hooks than expected. This may be caused by an accidental early return statement.'));
6100 }
6101 }
6102 })();
6103
6104 return children;
6105}
6106
6107function bailoutHooks(current, workInProgress, expirationTime) {
6108 workInProgress.updateQueue = current.updateQueue;
6109 workInProgress.effectTag &= ~(Passive | Update);
6110 if (current.expirationTime <= expirationTime) {
6111 current.expirationTime = NoWork;
6112 }
6113}
6114
6115function resetHooks() {
6116 // We can assume the previous dispatcher is always this one, since we set it
6117 // at the beginning of the render phase and there's no re-entrancy.
6118 ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
6119
6120 // This is used to reset the state of this module when a component throws.
6121 // It's also called inside mountIndeterminateComponent if we determine the
6122 // component is a module-style component.
6123 renderExpirationTime$1 = NoWork;
6124 currentlyRenderingFiber$1 = null;
6125
6126 currentHook = null;
6127 nextCurrentHook = null;
6128 firstWorkInProgressHook = null;
6129 workInProgressHook = null;
6130 nextWorkInProgressHook = null;
6131
6132 {
6133 hookTypesDev = null;
6134 hookTypesUpdateIndexDev = -1;
6135
6136 currentHookNameInDev = null;
6137 }
6138
6139 remainingExpirationTime = NoWork;
6140 componentUpdateQueue = null;
6141 sideEffectTag = 0;
6142
6143 didScheduleRenderPhaseUpdate = false;
6144 renderPhaseUpdates = null;
6145 numberOfReRenders = 0;
6146}
6147
6148function mountWorkInProgressHook() {
6149 var hook = {
6150 memoizedState: null,
6151
6152 baseState: null,
6153 queue: null,
6154 baseUpdate: null,
6155
6156 next: null
6157 };
6158
6159 if (workInProgressHook === null) {
6160 // This is the first hook in the list
6161 firstWorkInProgressHook = workInProgressHook = hook;
6162 } else {
6163 // Append to the end of the list
6164 workInProgressHook = workInProgressHook.next = hook;
6165 }
6166 return workInProgressHook;
6167}
6168
6169function updateWorkInProgressHook() {
6170 // This function is used both for updates and for re-renders triggered by a
6171 // render phase update. It assumes there is either a current hook we can
6172 // clone, or a work-in-progress hook from a previous render pass that we can
6173 // use as a base. When we reach the end of the base list, we must switch to
6174 // the dispatcher used for mounts.
6175 if (nextWorkInProgressHook !== null) {
6176 // There's already a work-in-progress. Reuse it.
6177 workInProgressHook = nextWorkInProgressHook;
6178 nextWorkInProgressHook = workInProgressHook.next;
6179
6180 currentHook = nextCurrentHook;
6181 nextCurrentHook = currentHook !== null ? currentHook.next : null;
6182 } else {
6183 // Clone from the current hook.
6184 (function () {
6185 if (!(nextCurrentHook !== null)) {
6186 {
6187 throw ReactError(Error('Rendered more hooks than during the previous render.'));
6188 }
6189 }
6190 })();
6191 currentHook = nextCurrentHook;
6192
6193 var newHook = {
6194 memoizedState: currentHook.memoizedState,
6195
6196 baseState: currentHook.baseState,
6197 queue: currentHook.queue,
6198 baseUpdate: currentHook.baseUpdate,
6199
6200 next: null
6201 };
6202
6203 if (workInProgressHook === null) {
6204 // This is the first hook in the list.
6205 workInProgressHook = firstWorkInProgressHook = newHook;
6206 } else {
6207 // Append to the end of the list.
6208 workInProgressHook = workInProgressHook.next = newHook;
6209 }
6210 nextCurrentHook = currentHook.next;
6211 }
6212 return workInProgressHook;
6213}
6214
6215function createFunctionComponentUpdateQueue() {
6216 return {
6217 lastEffect: null
6218 };
6219}
6220
6221function basicStateReducer(state, action) {
6222 return typeof action === 'function' ? action(state) : action;
6223}
6224
6225function mountReducer(reducer, initialArg, init) {
6226 var hook = mountWorkInProgressHook();
6227 var initialState = void 0;
6228 if (init !== undefined) {
6229 initialState = init(initialArg);
6230 } else {
6231 initialState = initialArg;
6232 }
6233 hook.memoizedState = hook.baseState = initialState;
6234 var queue = hook.queue = {
6235 last: null,
6236 dispatch: null,
6237 lastRenderedReducer: reducer,
6238 lastRenderedState: initialState
6239 };
6240 var dispatch = queue.dispatch = dispatchAction.bind(null,
6241 // Flow doesn't know this is non-null, but we do.
6242 currentlyRenderingFiber$1, queue);
6243 return [hook.memoizedState, dispatch];
6244}
6245
6246function updateReducer(reducer, initialArg, init) {
6247 var hook = updateWorkInProgressHook();
6248 var queue = hook.queue;
6249 (function () {
6250 if (!(queue !== null)) {
6251 {
6252 throw ReactError(Error('Should have a queue. This is likely a bug in React. Please file an issue.'));
6253 }
6254 }
6255 })();
6256
6257 queue.lastRenderedReducer = reducer;
6258
6259 if (numberOfReRenders > 0) {
6260 // This is a re-render. Apply the new render phase updates to the previous
6261 var _dispatch = queue.dispatch;
6262 if (renderPhaseUpdates !== null) {
6263 // Render phase updates are stored in a map of queue -> linked list
6264 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
6265 if (firstRenderPhaseUpdate !== undefined) {
6266 renderPhaseUpdates.delete(queue);
6267 var newState = hook.memoizedState;
6268 var update = firstRenderPhaseUpdate;
6269 do {
6270 // Process this render phase update. We don't have to check the
6271 // priority because it will always be the same as the current
6272 // render's.
6273 var _action = update.action;
6274 newState = reducer(newState, _action);
6275 update = update.next;
6276 } while (update !== null);
6277
6278 // Mark that the fiber performed work, but only if the new state is
6279 // different from the current state.
6280 if (!is(newState, hook.memoizedState)) {
6281 markWorkInProgressReceivedUpdate();
6282 }
6283
6284 hook.memoizedState = newState;
6285 // Don't persist the state accumulated from the render phase updates to
6286 // the base state unless the queue is empty.
6287 // TODO: Not sure if this is the desired semantics, but it's what we
6288 // do for gDSFP. I can't remember why.
6289 if (hook.baseUpdate === queue.last) {
6290 hook.baseState = newState;
6291 }
6292
6293 queue.lastRenderedState = newState;
6294
6295 return [newState, _dispatch];
6296 }
6297 }
6298 return [hook.memoizedState, _dispatch];
6299 }
6300
6301 // The last update in the entire queue
6302 var last = queue.last;
6303 // The last update that is part of the base state.
6304 var baseUpdate = hook.baseUpdate;
6305 var baseState = hook.baseState;
6306
6307 // Find the first unprocessed update.
6308 var first = void 0;
6309 if (baseUpdate !== null) {
6310 if (last !== null) {
6311 // For the first update, the queue is a circular linked list where
6312 // `queue.last.next = queue.first`. Once the first update commits, and
6313 // the `baseUpdate` is no longer empty, we can unravel the list.
6314 last.next = null;
6315 }
6316 first = baseUpdate.next;
6317 } else {
6318 first = last !== null ? last.next : null;
6319 }
6320 if (first !== null) {
6321 var _newState = baseState;
6322 var newBaseState = null;
6323 var newBaseUpdate = null;
6324 var prevUpdate = baseUpdate;
6325 var _update = first;
6326 var didSkip = false;
6327 do {
6328 var updateExpirationTime = _update.expirationTime;
6329 if (updateExpirationTime < renderExpirationTime$1) {
6330 // Priority is insufficient. Skip this update. If this is the first
6331 // skipped update, the previous update/state is the new base
6332 // update/state.
6333 if (!didSkip) {
6334 didSkip = true;
6335 newBaseUpdate = prevUpdate;
6336 newBaseState = _newState;
6337 }
6338 // Update the remaining priority in the queue.
6339 if (updateExpirationTime > remainingExpirationTime) {
6340 remainingExpirationTime = updateExpirationTime;
6341 }
6342 } else {
6343 // This update does have sufficient priority.
6344
6345 // Mark the event time of this update as relevant to this render pass.
6346 // TODO: This should ideally use the true event time of this update rather than
6347 // its priority which is a derived and not reverseable value.
6348 // TODO: We should skip this update if it was already committed but currently
6349 // we have no way of detecting the difference between a committed and suspended
6350 // update here.
6351 markRenderEventTimeAndConfig(updateExpirationTime, _update.suspenseConfig);
6352
6353 // Process this update.
6354 if (_update.eagerReducer === reducer) {
6355 // If this update was processed eagerly, and its reducer matches the
6356 // current reducer, we can use the eagerly computed state.
6357 _newState = _update.eagerState;
6358 } else {
6359 var _action2 = _update.action;
6360 _newState = reducer(_newState, _action2);
6361 }
6362 }
6363 prevUpdate = _update;
6364 _update = _update.next;
6365 } while (_update !== null && _update !== first);
6366
6367 if (!didSkip) {
6368 newBaseUpdate = prevUpdate;
6369 newBaseState = _newState;
6370 }
6371
6372 // Mark that the fiber performed work, but only if the new state is
6373 // different from the current state.
6374 if (!is(_newState, hook.memoizedState)) {
6375 markWorkInProgressReceivedUpdate();
6376 }
6377
6378 hook.memoizedState = _newState;
6379 hook.baseUpdate = newBaseUpdate;
6380 hook.baseState = newBaseState;
6381
6382 queue.lastRenderedState = _newState;
6383 }
6384
6385 var dispatch = queue.dispatch;
6386 return [hook.memoizedState, dispatch];
6387}
6388
6389function mountState(initialState) {
6390 var hook = mountWorkInProgressHook();
6391 if (typeof initialState === 'function') {
6392 initialState = initialState();
6393 }
6394 hook.memoizedState = hook.baseState = initialState;
6395 var queue = hook.queue = {
6396 last: null,
6397 dispatch: null,
6398 lastRenderedReducer: basicStateReducer,
6399 lastRenderedState: initialState
6400 };
6401 var dispatch = queue.dispatch = dispatchAction.bind(null,
6402 // Flow doesn't know this is non-null, but we do.
6403 currentlyRenderingFiber$1, queue);
6404 return [hook.memoizedState, dispatch];
6405}
6406
6407function updateState(initialState) {
6408 return updateReducer(basicStateReducer, initialState);
6409}
6410
6411function pushEffect(tag, create, destroy, deps) {
6412 var effect = {
6413 tag: tag,
6414 create: create,
6415 destroy: destroy,
6416 deps: deps,
6417 // Circular
6418 next: null
6419 };
6420 if (componentUpdateQueue === null) {
6421 componentUpdateQueue = createFunctionComponentUpdateQueue();
6422 componentUpdateQueue.lastEffect = effect.next = effect;
6423 } else {
6424 var _lastEffect = componentUpdateQueue.lastEffect;
6425 if (_lastEffect === null) {
6426 componentUpdateQueue.lastEffect = effect.next = effect;
6427 } else {
6428 var firstEffect = _lastEffect.next;
6429 _lastEffect.next = effect;
6430 effect.next = firstEffect;
6431 componentUpdateQueue.lastEffect = effect;
6432 }
6433 }
6434 return effect;
6435}
6436
6437function mountRef(initialValue) {
6438 var hook = mountWorkInProgressHook();
6439 var ref = { current: initialValue };
6440 {
6441 Object.seal(ref);
6442 }
6443 hook.memoizedState = ref;
6444 return ref;
6445}
6446
6447function updateRef(initialValue) {
6448 var hook = updateWorkInProgressHook();
6449 return hook.memoizedState;
6450}
6451
6452function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
6453 var hook = mountWorkInProgressHook();
6454 var nextDeps = deps === undefined ? null : deps;
6455 sideEffectTag |= fiberEffectTag;
6456 hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
6457}
6458
6459function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
6460 var hook = updateWorkInProgressHook();
6461 var nextDeps = deps === undefined ? null : deps;
6462 var destroy = undefined;
6463
6464 if (currentHook !== null) {
6465 var prevEffect = currentHook.memoizedState;
6466 destroy = prevEffect.destroy;
6467 if (nextDeps !== null) {
6468 var prevDeps = prevEffect.deps;
6469 if (areHookInputsEqual(nextDeps, prevDeps)) {
6470 pushEffect(NoEffect$1, create, destroy, nextDeps);
6471 return;
6472 }
6473 }
6474 }
6475
6476 sideEffectTag |= fiberEffectTag;
6477 hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
6478}
6479
6480function mountEffect(create, deps) {
6481 {
6482 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6483 if ('undefined' !== typeof jest) {
6484 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
6485 }
6486 }
6487 return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
6488}
6489
6490function updateEffect(create, deps) {
6491 {
6492 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6493 if ('undefined' !== typeof jest) {
6494 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
6495 }
6496 }
6497 return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
6498}
6499
6500function mountLayoutEffect(create, deps) {
6501 return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
6502}
6503
6504function updateLayoutEffect(create, deps) {
6505 return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
6506}
6507
6508function imperativeHandleEffect(create, ref) {
6509 if (typeof ref === 'function') {
6510 var refCallback = ref;
6511 var _inst = create();
6512 refCallback(_inst);
6513 return function () {
6514 refCallback(null);
6515 };
6516 } else if (ref !== null && ref !== undefined) {
6517 var refObject = ref;
6518 {
6519 !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;
6520 }
6521 var _inst2 = create();
6522 refObject.current = _inst2;
6523 return function () {
6524 refObject.current = null;
6525 };
6526 }
6527}
6528
6529function mountImperativeHandle(ref, create, deps) {
6530 {
6531 !(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;
6532 }
6533
6534 // TODO: If deps are provided, should we skip comparing the ref itself?
6535 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
6536
6537 return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
6538}
6539
6540function updateImperativeHandle(ref, create, deps) {
6541 {
6542 !(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;
6543 }
6544
6545 // TODO: If deps are provided, should we skip comparing the ref itself?
6546 var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
6547
6548 return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
6549}
6550
6551function mountDebugValue(value, formatterFn) {
6552 // This hook is normally a no-op.
6553 // The react-debug-hooks package injects its own implementation
6554 // so that e.g. DevTools can display custom hook values.
6555}
6556
6557var updateDebugValue = mountDebugValue;
6558
6559function mountCallback(callback, deps) {
6560 var hook = mountWorkInProgressHook();
6561 var nextDeps = deps === undefined ? null : deps;
6562 hook.memoizedState = [callback, nextDeps];
6563 return callback;
6564}
6565
6566function updateCallback(callback, deps) {
6567 var hook = updateWorkInProgressHook();
6568 var nextDeps = deps === undefined ? null : deps;
6569 var prevState = hook.memoizedState;
6570 if (prevState !== null) {
6571 if (nextDeps !== null) {
6572 var prevDeps = prevState[1];
6573 if (areHookInputsEqual(nextDeps, prevDeps)) {
6574 return prevState[0];
6575 }
6576 }
6577 }
6578 hook.memoizedState = [callback, nextDeps];
6579 return callback;
6580}
6581
6582function mountMemo(nextCreate, deps) {
6583 var hook = mountWorkInProgressHook();
6584 var nextDeps = deps === undefined ? null : deps;
6585 var nextValue = nextCreate();
6586 hook.memoizedState = [nextValue, nextDeps];
6587 return nextValue;
6588}
6589
6590function updateMemo(nextCreate, deps) {
6591 var hook = updateWorkInProgressHook();
6592 var nextDeps = deps === undefined ? null : deps;
6593 var prevState = hook.memoizedState;
6594 if (prevState !== null) {
6595 // Assume these are defined. If they're not, areHookInputsEqual will warn.
6596 if (nextDeps !== null) {
6597 var prevDeps = prevState[1];
6598 if (areHookInputsEqual(nextDeps, prevDeps)) {
6599 return prevState[0];
6600 }
6601 }
6602 }
6603 var nextValue = nextCreate();
6604 hook.memoizedState = [nextValue, nextDeps];
6605 return nextValue;
6606}
6607
6608function dispatchAction(fiber, queue, action) {
6609 (function () {
6610 if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
6611 {
6612 throw ReactError(Error('Too many re-renders. React limits the number of renders to prevent an infinite loop.'));
6613 }
6614 }
6615 })();
6616
6617 {
6618 !(arguments.length <= 3) ? 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;
6619 }
6620
6621 var alternate = fiber.alternate;
6622 if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
6623 // This is a render phase update. Stash it in a lazily-created map of
6624 // queue -> linked list of updates. After this render pass, we'll restart
6625 // and apply the stashed updates on top of the work-in-progress hook.
6626 didScheduleRenderPhaseUpdate = true;
6627 var update = {
6628 expirationTime: renderExpirationTime$1,
6629 suspenseConfig: null,
6630 action: action,
6631 eagerReducer: null,
6632 eagerState: null,
6633 next: null
6634 };
6635 {
6636 update.priority = getCurrentPriorityLevel();
6637 }
6638 if (renderPhaseUpdates === null) {
6639 renderPhaseUpdates = new Map();
6640 }
6641 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
6642 if (firstRenderPhaseUpdate === undefined) {
6643 renderPhaseUpdates.set(queue, update);
6644 } else {
6645 // Append the update to the end of the list.
6646 var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
6647 while (lastRenderPhaseUpdate.next !== null) {
6648 lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
6649 }
6650 lastRenderPhaseUpdate.next = update;
6651 }
6652 } else {
6653 if (revertPassiveEffectsChange) {
6654 flushPassiveEffects();
6655 }
6656
6657 var currentTime = requestCurrentTime();
6658 var _suspenseConfig = requestCurrentSuspenseConfig();
6659 var _expirationTime = computeExpirationForFiber(currentTime, fiber, _suspenseConfig);
6660
6661 var _update2 = {
6662 expirationTime: _expirationTime,
6663 suspenseConfig: _suspenseConfig,
6664 action: action,
6665 eagerReducer: null,
6666 eagerState: null,
6667 next: null
6668 };
6669
6670 {
6671 _update2.priority = getCurrentPriorityLevel();
6672 }
6673
6674 // Append the update to the end of the list.
6675 var _last = queue.last;
6676 if (_last === null) {
6677 // This is the first update. Create a circular list.
6678 _update2.next = _update2;
6679 } else {
6680 var first = _last.next;
6681 if (first !== null) {
6682 // Still circular.
6683 _update2.next = first;
6684 }
6685 _last.next = _update2;
6686 }
6687 queue.last = _update2;
6688
6689 if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
6690 // The queue is currently empty, which means we can eagerly compute the
6691 // next state before entering the render phase. If the new state is the
6692 // same as the current state, we may be able to bail out entirely.
6693 var _lastRenderedReducer = queue.lastRenderedReducer;
6694 if (_lastRenderedReducer !== null) {
6695 var prevDispatcher = void 0;
6696 {
6697 prevDispatcher = ReactCurrentDispatcher$1.current;
6698 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6699 }
6700 try {
6701 var currentState = queue.lastRenderedState;
6702 var _eagerState = _lastRenderedReducer(currentState, action);
6703 // Stash the eagerly computed state, and the reducer used to compute
6704 // it, on the update object. If the reducer hasn't changed by the
6705 // time we enter the render phase, then the eager state can be used
6706 // without calling the reducer again.
6707 _update2.eagerReducer = _lastRenderedReducer;
6708 _update2.eagerState = _eagerState;
6709 if (is(_eagerState, currentState)) {
6710 // Fast path. We can bail out without scheduling React to re-render.
6711 // It's still possible that we'll need to rebase this update later,
6712 // if the component re-renders for a different reason and by that
6713 // time the reducer has changed.
6714 return;
6715 }
6716 } catch (error) {
6717 // Suppress the error. It will throw again in the render phase.
6718 } finally {
6719 {
6720 ReactCurrentDispatcher$1.current = prevDispatcher;
6721 }
6722 }
6723 }
6724 }
6725 {
6726 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
6727 if ('undefined' !== typeof jest) {
6728 warnIfNotScopedWithMatchingAct(fiber);
6729 warnIfNotCurrentlyActingUpdatesInDev(fiber);
6730 }
6731 }
6732 scheduleWork(fiber, _expirationTime);
6733 }
6734}
6735
6736var ContextOnlyDispatcher = {
6737 readContext: readContext,
6738
6739 useCallback: throwInvalidHookError,
6740 useContext: throwInvalidHookError,
6741 useEffect: throwInvalidHookError,
6742 useImperativeHandle: throwInvalidHookError,
6743 useLayoutEffect: throwInvalidHookError,
6744 useMemo: throwInvalidHookError,
6745 useReducer: throwInvalidHookError,
6746 useRef: throwInvalidHookError,
6747 useState: throwInvalidHookError,
6748 useDebugValue: throwInvalidHookError,
6749 useResponder: throwInvalidHookError
6750};
6751
6752var HooksDispatcherOnMountInDEV = null;
6753var HooksDispatcherOnMountWithHookTypesInDEV = null;
6754var HooksDispatcherOnUpdateInDEV = null;
6755var InvalidNestedHooksDispatcherOnMountInDEV = null;
6756var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
6757
6758{
6759 var warnInvalidContextAccess = function () {
6760 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().');
6761 };
6762
6763 var warnInvalidHookAccess = function () {
6764 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');
6765 };
6766
6767 HooksDispatcherOnMountInDEV = {
6768 readContext: function (context, observedBits) {
6769 return readContext(context, observedBits);
6770 },
6771 useCallback: function (callback, deps) {
6772 currentHookNameInDev = 'useCallback';
6773 mountHookTypesDev();
6774 checkDepsAreArrayDev(deps);
6775 return mountCallback(callback, deps);
6776 },
6777 useContext: function (context, observedBits) {
6778 currentHookNameInDev = 'useContext';
6779 mountHookTypesDev();
6780 return readContext(context, observedBits);
6781 },
6782 useEffect: function (create, deps) {
6783 currentHookNameInDev = 'useEffect';
6784 mountHookTypesDev();
6785 checkDepsAreArrayDev(deps);
6786 return mountEffect(create, deps);
6787 },
6788 useImperativeHandle: function (ref, create, deps) {
6789 currentHookNameInDev = 'useImperativeHandle';
6790 mountHookTypesDev();
6791 checkDepsAreArrayDev(deps);
6792 return mountImperativeHandle(ref, create, deps);
6793 },
6794 useLayoutEffect: function (create, deps) {
6795 currentHookNameInDev = 'useLayoutEffect';
6796 mountHookTypesDev();
6797 checkDepsAreArrayDev(deps);
6798 return mountLayoutEffect(create, deps);
6799 },
6800 useMemo: function (create, deps) {
6801 currentHookNameInDev = 'useMemo';
6802 mountHookTypesDev();
6803 checkDepsAreArrayDev(deps);
6804 var prevDispatcher = ReactCurrentDispatcher$1.current;
6805 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6806 try {
6807 return mountMemo(create, deps);
6808 } finally {
6809 ReactCurrentDispatcher$1.current = prevDispatcher;
6810 }
6811 },
6812 useReducer: function (reducer, initialArg, init) {
6813 currentHookNameInDev = 'useReducer';
6814 mountHookTypesDev();
6815 var prevDispatcher = ReactCurrentDispatcher$1.current;
6816 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6817 try {
6818 return mountReducer(reducer, initialArg, init);
6819 } finally {
6820 ReactCurrentDispatcher$1.current = prevDispatcher;
6821 }
6822 },
6823 useRef: function (initialValue) {
6824 currentHookNameInDev = 'useRef';
6825 mountHookTypesDev();
6826 return mountRef(initialValue);
6827 },
6828 useState: function (initialState) {
6829 currentHookNameInDev = 'useState';
6830 mountHookTypesDev();
6831 var prevDispatcher = ReactCurrentDispatcher$1.current;
6832 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6833 try {
6834 return mountState(initialState);
6835 } finally {
6836 ReactCurrentDispatcher$1.current = prevDispatcher;
6837 }
6838 },
6839 useDebugValue: function (value, formatterFn) {
6840 currentHookNameInDev = 'useDebugValue';
6841 mountHookTypesDev();
6842 return mountDebugValue(value, formatterFn);
6843 },
6844 useResponder: function (responder, props) {
6845 currentHookNameInDev = 'useResponder';
6846 mountHookTypesDev();
6847 return createResponderListener(responder, props);
6848 }
6849 };
6850
6851 HooksDispatcherOnMountWithHookTypesInDEV = {
6852 readContext: function (context, observedBits) {
6853 return readContext(context, observedBits);
6854 },
6855 useCallback: function (callback, deps) {
6856 currentHookNameInDev = 'useCallback';
6857 updateHookTypesDev();
6858 return mountCallback(callback, deps);
6859 },
6860 useContext: function (context, observedBits) {
6861 currentHookNameInDev = 'useContext';
6862 updateHookTypesDev();
6863 return readContext(context, observedBits);
6864 },
6865 useEffect: function (create, deps) {
6866 currentHookNameInDev = 'useEffect';
6867 updateHookTypesDev();
6868 return mountEffect(create, deps);
6869 },
6870 useImperativeHandle: function (ref, create, deps) {
6871 currentHookNameInDev = 'useImperativeHandle';
6872 updateHookTypesDev();
6873 return mountImperativeHandle(ref, create, deps);
6874 },
6875 useLayoutEffect: function (create, deps) {
6876 currentHookNameInDev = 'useLayoutEffect';
6877 updateHookTypesDev();
6878 return mountLayoutEffect(create, deps);
6879 },
6880 useMemo: function (create, deps) {
6881 currentHookNameInDev = 'useMemo';
6882 updateHookTypesDev();
6883 var prevDispatcher = ReactCurrentDispatcher$1.current;
6884 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6885 try {
6886 return mountMemo(create, deps);
6887 } finally {
6888 ReactCurrentDispatcher$1.current = prevDispatcher;
6889 }
6890 },
6891 useReducer: function (reducer, initialArg, init) {
6892 currentHookNameInDev = 'useReducer';
6893 updateHookTypesDev();
6894 var prevDispatcher = ReactCurrentDispatcher$1.current;
6895 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6896 try {
6897 return mountReducer(reducer, initialArg, init);
6898 } finally {
6899 ReactCurrentDispatcher$1.current = prevDispatcher;
6900 }
6901 },
6902 useRef: function (initialValue) {
6903 currentHookNameInDev = 'useRef';
6904 updateHookTypesDev();
6905 return mountRef(initialValue);
6906 },
6907 useState: function (initialState) {
6908 currentHookNameInDev = 'useState';
6909 updateHookTypesDev();
6910 var prevDispatcher = ReactCurrentDispatcher$1.current;
6911 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
6912 try {
6913 return mountState(initialState);
6914 } finally {
6915 ReactCurrentDispatcher$1.current = prevDispatcher;
6916 }
6917 },
6918 useDebugValue: function (value, formatterFn) {
6919 currentHookNameInDev = 'useDebugValue';
6920 updateHookTypesDev();
6921 return mountDebugValue(value, formatterFn);
6922 },
6923 useResponder: function (responder, props) {
6924 currentHookNameInDev = 'useResponder';
6925 updateHookTypesDev();
6926 return createResponderListener(responder, props);
6927 }
6928 };
6929
6930 HooksDispatcherOnUpdateInDEV = {
6931 readContext: function (context, observedBits) {
6932 return readContext(context, observedBits);
6933 },
6934 useCallback: function (callback, deps) {
6935 currentHookNameInDev = 'useCallback';
6936 updateHookTypesDev();
6937 return updateCallback(callback, deps);
6938 },
6939 useContext: function (context, observedBits) {
6940 currentHookNameInDev = 'useContext';
6941 updateHookTypesDev();
6942 return readContext(context, observedBits);
6943 },
6944 useEffect: function (create, deps) {
6945 currentHookNameInDev = 'useEffect';
6946 updateHookTypesDev();
6947 return updateEffect(create, deps);
6948 },
6949 useImperativeHandle: function (ref, create, deps) {
6950 currentHookNameInDev = 'useImperativeHandle';
6951 updateHookTypesDev();
6952 return updateImperativeHandle(ref, create, deps);
6953 },
6954 useLayoutEffect: function (create, deps) {
6955 currentHookNameInDev = 'useLayoutEffect';
6956 updateHookTypesDev();
6957 return updateLayoutEffect(create, deps);
6958 },
6959 useMemo: function (create, deps) {
6960 currentHookNameInDev = 'useMemo';
6961 updateHookTypesDev();
6962 var prevDispatcher = ReactCurrentDispatcher$1.current;
6963 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6964 try {
6965 return updateMemo(create, deps);
6966 } finally {
6967 ReactCurrentDispatcher$1.current = prevDispatcher;
6968 }
6969 },
6970 useReducer: function (reducer, initialArg, init) {
6971 currentHookNameInDev = 'useReducer';
6972 updateHookTypesDev();
6973 var prevDispatcher = ReactCurrentDispatcher$1.current;
6974 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6975 try {
6976 return updateReducer(reducer, initialArg, init);
6977 } finally {
6978 ReactCurrentDispatcher$1.current = prevDispatcher;
6979 }
6980 },
6981 useRef: function (initialValue) {
6982 currentHookNameInDev = 'useRef';
6983 updateHookTypesDev();
6984 return updateRef(initialValue);
6985 },
6986 useState: function (initialState) {
6987 currentHookNameInDev = 'useState';
6988 updateHookTypesDev();
6989 var prevDispatcher = ReactCurrentDispatcher$1.current;
6990 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
6991 try {
6992 return updateState(initialState);
6993 } finally {
6994 ReactCurrentDispatcher$1.current = prevDispatcher;
6995 }
6996 },
6997 useDebugValue: function (value, formatterFn) {
6998 currentHookNameInDev = 'useDebugValue';
6999 updateHookTypesDev();
7000 return updateDebugValue(value, formatterFn);
7001 },
7002 useResponder: function (responder, props) {
7003 currentHookNameInDev = 'useResponder';
7004 updateHookTypesDev();
7005 return createResponderListener(responder, props);
7006 }
7007 };
7008
7009 InvalidNestedHooksDispatcherOnMountInDEV = {
7010 readContext: function (context, observedBits) {
7011 warnInvalidContextAccess();
7012 return readContext(context, observedBits);
7013 },
7014 useCallback: function (callback, deps) {
7015 currentHookNameInDev = 'useCallback';
7016 warnInvalidHookAccess();
7017 mountHookTypesDev();
7018 return mountCallback(callback, deps);
7019 },
7020 useContext: function (context, observedBits) {
7021 currentHookNameInDev = 'useContext';
7022 warnInvalidHookAccess();
7023 mountHookTypesDev();
7024 return readContext(context, observedBits);
7025 },
7026 useEffect: function (create, deps) {
7027 currentHookNameInDev = 'useEffect';
7028 warnInvalidHookAccess();
7029 mountHookTypesDev();
7030 return mountEffect(create, deps);
7031 },
7032 useImperativeHandle: function (ref, create, deps) {
7033 currentHookNameInDev = 'useImperativeHandle';
7034 warnInvalidHookAccess();
7035 mountHookTypesDev();
7036 return mountImperativeHandle(ref, create, deps);
7037 },
7038 useLayoutEffect: function (create, deps) {
7039 currentHookNameInDev = 'useLayoutEffect';
7040 warnInvalidHookAccess();
7041 mountHookTypesDev();
7042 return mountLayoutEffect(create, deps);
7043 },
7044 useMemo: function (create, deps) {
7045 currentHookNameInDev = 'useMemo';
7046 warnInvalidHookAccess();
7047 mountHookTypesDev();
7048 var prevDispatcher = ReactCurrentDispatcher$1.current;
7049 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7050 try {
7051 return mountMemo(create, deps);
7052 } finally {
7053 ReactCurrentDispatcher$1.current = prevDispatcher;
7054 }
7055 },
7056 useReducer: function (reducer, initialArg, init) {
7057 currentHookNameInDev = 'useReducer';
7058 warnInvalidHookAccess();
7059 mountHookTypesDev();
7060 var prevDispatcher = ReactCurrentDispatcher$1.current;
7061 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7062 try {
7063 return mountReducer(reducer, initialArg, init);
7064 } finally {
7065 ReactCurrentDispatcher$1.current = prevDispatcher;
7066 }
7067 },
7068 useRef: function (initialValue) {
7069 currentHookNameInDev = 'useRef';
7070 warnInvalidHookAccess();
7071 mountHookTypesDev();
7072 return mountRef(initialValue);
7073 },
7074 useState: function (initialState) {
7075 currentHookNameInDev = 'useState';
7076 warnInvalidHookAccess();
7077 mountHookTypesDev();
7078 var prevDispatcher = ReactCurrentDispatcher$1.current;
7079 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
7080 try {
7081 return mountState(initialState);
7082 } finally {
7083 ReactCurrentDispatcher$1.current = prevDispatcher;
7084 }
7085 },
7086 useDebugValue: function (value, formatterFn) {
7087 currentHookNameInDev = 'useDebugValue';
7088 warnInvalidHookAccess();
7089 mountHookTypesDev();
7090 return mountDebugValue(value, formatterFn);
7091 },
7092 useResponder: function (responder, props) {
7093 currentHookNameInDev = 'useResponder';
7094 warnInvalidHookAccess();
7095 mountHookTypesDev();
7096 return createResponderListener(responder, props);
7097 }
7098 };
7099
7100 InvalidNestedHooksDispatcherOnUpdateInDEV = {
7101 readContext: function (context, observedBits) {
7102 warnInvalidContextAccess();
7103 return readContext(context, observedBits);
7104 },
7105 useCallback: function (callback, deps) {
7106 currentHookNameInDev = 'useCallback';
7107 warnInvalidHookAccess();
7108 updateHookTypesDev();
7109 return updateCallback(callback, deps);
7110 },
7111 useContext: function (context, observedBits) {
7112 currentHookNameInDev = 'useContext';
7113 warnInvalidHookAccess();
7114 updateHookTypesDev();
7115 return readContext(context, observedBits);
7116 },
7117 useEffect: function (create, deps) {
7118 currentHookNameInDev = 'useEffect';
7119 warnInvalidHookAccess();
7120 updateHookTypesDev();
7121 return updateEffect(create, deps);
7122 },
7123 useImperativeHandle: function (ref, create, deps) {
7124 currentHookNameInDev = 'useImperativeHandle';
7125 warnInvalidHookAccess();
7126 updateHookTypesDev();
7127 return updateImperativeHandle(ref, create, deps);
7128 },
7129 useLayoutEffect: function (create, deps) {
7130 currentHookNameInDev = 'useLayoutEffect';
7131 warnInvalidHookAccess();
7132 updateHookTypesDev();
7133 return updateLayoutEffect(create, deps);
7134 },
7135 useMemo: function (create, deps) {
7136 currentHookNameInDev = 'useMemo';
7137 warnInvalidHookAccess();
7138 updateHookTypesDev();
7139 var prevDispatcher = ReactCurrentDispatcher$1.current;
7140 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7141 try {
7142 return updateMemo(create, deps);
7143 } finally {
7144 ReactCurrentDispatcher$1.current = prevDispatcher;
7145 }
7146 },
7147 useReducer: function (reducer, initialArg, init) {
7148 currentHookNameInDev = 'useReducer';
7149 warnInvalidHookAccess();
7150 updateHookTypesDev();
7151 var prevDispatcher = ReactCurrentDispatcher$1.current;
7152 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7153 try {
7154 return updateReducer(reducer, initialArg, init);
7155 } finally {
7156 ReactCurrentDispatcher$1.current = prevDispatcher;
7157 }
7158 },
7159 useRef: function (initialValue) {
7160 currentHookNameInDev = 'useRef';
7161 warnInvalidHookAccess();
7162 updateHookTypesDev();
7163 return updateRef(initialValue);
7164 },
7165 useState: function (initialState) {
7166 currentHookNameInDev = 'useState';
7167 warnInvalidHookAccess();
7168 updateHookTypesDev();
7169 var prevDispatcher = ReactCurrentDispatcher$1.current;
7170 ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
7171 try {
7172 return updateState(initialState);
7173 } finally {
7174 ReactCurrentDispatcher$1.current = prevDispatcher;
7175 }
7176 },
7177 useDebugValue: function (value, formatterFn) {
7178 currentHookNameInDev = 'useDebugValue';
7179 warnInvalidHookAccess();
7180 updateHookTypesDev();
7181 return updateDebugValue(value, formatterFn);
7182 },
7183 useResponder: function (responder, props) {
7184 currentHookNameInDev = 'useResponder';
7185 warnInvalidHookAccess();
7186 updateHookTypesDev();
7187 return createResponderListener(responder, props);
7188 }
7189 };
7190}
7191
7192// Intentionally not named imports because Rollup would use dynamic dispatch for
7193// CommonJS interop named imports.
7194var now$1 = Scheduler.unstable_now;
7195
7196
7197var commitTime = 0;
7198var profilerStartTime = -1;
7199
7200function getCommitTime() {
7201 return commitTime;
7202}
7203
7204function recordCommitTime() {
7205 if (!enableProfilerTimer) {
7206 return;
7207 }
7208 commitTime = now$1();
7209}
7210
7211function startProfilerTimer(fiber) {
7212 if (!enableProfilerTimer) {
7213 return;
7214 }
7215
7216 profilerStartTime = now$1();
7217
7218 if (fiber.actualStartTime < 0) {
7219 fiber.actualStartTime = now$1();
7220 }
7221}
7222
7223function stopProfilerTimerIfRunning(fiber) {
7224 if (!enableProfilerTimer) {
7225 return;
7226 }
7227 profilerStartTime = -1;
7228}
7229
7230function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
7231 if (!enableProfilerTimer) {
7232 return;
7233 }
7234
7235 if (profilerStartTime >= 0) {
7236 var elapsedTime = now$1() - profilerStartTime;
7237 fiber.actualDuration += elapsedTime;
7238 if (overrideBaseTime) {
7239 fiber.selfBaseDuration = elapsedTime;
7240 }
7241 profilerStartTime = -1;
7242 }
7243}
7244
7245// The deepest Fiber on the stack involved in a hydration context.
7246// This may have been an insertion or a hydration.
7247var hydrationParentFiber = null;
7248var nextHydratableInstance = null;
7249var isHydrating = false;
7250
7251function enterHydrationState(fiber) {
7252 if (!supportsHydration) {
7253 return false;
7254 }
7255
7256 var parentInstance = fiber.stateNode.containerInfo;
7257 nextHydratableInstance = getFirstHydratableChild(parentInstance);
7258 hydrationParentFiber = fiber;
7259 isHydrating = true;
7260 return true;
7261}
7262
7263function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
7264 if (!supportsHydration) {
7265 return false;
7266 }
7267
7268 var suspenseInstance = fiber.stateNode;
7269 nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
7270 popToNextHostParent(fiber);
7271 isHydrating = true;
7272 return true;
7273}
7274
7275function deleteHydratableInstance(returnFiber, instance) {
7276 {
7277 switch (returnFiber.tag) {
7278 case HostRoot:
7279 didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
7280 break;
7281 case HostComponent:
7282 didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
7283 break;
7284 }
7285 }
7286
7287 var childToDelete = createFiberFromHostInstanceForDeletion();
7288 childToDelete.stateNode = instance;
7289 childToDelete.return = returnFiber;
7290 childToDelete.effectTag = Deletion;
7291
7292 // This might seem like it belongs on progressedFirstDeletion. However,
7293 // these children are not part of the reconciliation list of children.
7294 // Even if we abort and rereconcile the children, that will try to hydrate
7295 // again and the nodes are still in the host tree so these will be
7296 // recreated.
7297 if (returnFiber.lastEffect !== null) {
7298 returnFiber.lastEffect.nextEffect = childToDelete;
7299 returnFiber.lastEffect = childToDelete;
7300 } else {
7301 returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
7302 }
7303}
7304
7305function insertNonHydratedInstance(returnFiber, fiber) {
7306 fiber.effectTag |= Placement;
7307 {
7308 switch (returnFiber.tag) {
7309 case HostRoot:
7310 {
7311 var parentContainer = returnFiber.stateNode.containerInfo;
7312 switch (fiber.tag) {
7313 case HostComponent:
7314 var type = fiber.type;
7315 var props = fiber.pendingProps;
7316 didNotFindHydratableContainerInstance(parentContainer, type, props);
7317 break;
7318 case HostText:
7319 var text = fiber.pendingProps;
7320 didNotFindHydratableContainerTextInstance(parentContainer, text);
7321 break;
7322 case SuspenseComponent:
7323 didNotFindHydratableContainerSuspenseInstance(parentContainer);
7324 break;
7325 }
7326 break;
7327 }
7328 case HostComponent:
7329 {
7330 var parentType = returnFiber.type;
7331 var parentProps = returnFiber.memoizedProps;
7332 var parentInstance = returnFiber.stateNode;
7333 switch (fiber.tag) {
7334 case HostComponent:
7335 var _type = fiber.type;
7336 var _props = fiber.pendingProps;
7337 didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
7338 break;
7339 case HostText:
7340 var _text = fiber.pendingProps;
7341 didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
7342 break;
7343 case SuspenseComponent:
7344 didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
7345 break;
7346 }
7347 break;
7348 }
7349 default:
7350 return;
7351 }
7352 }
7353}
7354
7355function tryHydrate(fiber, nextInstance) {
7356 switch (fiber.tag) {
7357 case HostComponent:
7358 {
7359 var type = fiber.type;
7360 var props = fiber.pendingProps;
7361 var instance = canHydrateInstance(nextInstance, type, props);
7362 if (instance !== null) {
7363 fiber.stateNode = instance;
7364 return true;
7365 }
7366 return false;
7367 }
7368 case HostText:
7369 {
7370 var text = fiber.pendingProps;
7371 var textInstance = canHydrateTextInstance(nextInstance, text);
7372 if (textInstance !== null) {
7373 fiber.stateNode = textInstance;
7374 return true;
7375 }
7376 return false;
7377 }
7378 case SuspenseComponent:
7379 {
7380 if (enableSuspenseServerRenderer) {
7381 var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
7382 if (suspenseInstance !== null) {
7383 // Downgrade the tag to a dehydrated component until we've hydrated it.
7384 fiber.tag = DehydratedSuspenseComponent;
7385 fiber.stateNode = suspenseInstance;
7386 return true;
7387 }
7388 }
7389 return false;
7390 }
7391 default:
7392 return false;
7393 }
7394}
7395
7396function tryToClaimNextHydratableInstance(fiber) {
7397 if (!isHydrating) {
7398 return;
7399 }
7400 var nextInstance = nextHydratableInstance;
7401 if (!nextInstance) {
7402 // Nothing to hydrate. Make it an insertion.
7403 insertNonHydratedInstance(hydrationParentFiber, fiber);
7404 isHydrating = false;
7405 hydrationParentFiber = fiber;
7406 return;
7407 }
7408 var firstAttemptedInstance = nextInstance;
7409 if (!tryHydrate(fiber, nextInstance)) {
7410 // If we can't hydrate this instance let's try the next one.
7411 // We use this as a heuristic. It's based on intuition and not data so it
7412 // might be flawed or unnecessary.
7413 nextInstance = getNextHydratableSibling(firstAttemptedInstance);
7414 if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
7415 // Nothing to hydrate. Make it an insertion.
7416 insertNonHydratedInstance(hydrationParentFiber, fiber);
7417 isHydrating = false;
7418 hydrationParentFiber = fiber;
7419 return;
7420 }
7421 // We matched the next one, we'll now assume that the first one was
7422 // superfluous and we'll delete it. Since we can't eagerly delete it
7423 // we'll have to schedule a deletion. To do that, this node needs a dummy
7424 // fiber associated with it.
7425 deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
7426 }
7427 hydrationParentFiber = fiber;
7428 nextHydratableInstance = getFirstHydratableChild(nextInstance);
7429}
7430
7431function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
7432 if (!supportsHydration) {
7433 (function () {
7434 {
7435 {
7436 throw ReactError(Error('Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'));
7437 }
7438 }
7439 })();
7440 }
7441
7442 var instance = fiber.stateNode;
7443 var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber);
7444 // TODO: Type this specific to this type of component.
7445 fiber.updateQueue = updatePayload;
7446 // If the update payload indicates that there is a change or if there
7447 // is a new ref we mark this as an update.
7448 if (updatePayload !== null) {
7449 return true;
7450 }
7451 return false;
7452}
7453
7454function prepareToHydrateHostTextInstance(fiber) {
7455 if (!supportsHydration) {
7456 (function () {
7457 {
7458 {
7459 throw ReactError(Error('Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'));
7460 }
7461 }
7462 })();
7463 }
7464
7465 var textInstance = fiber.stateNode;
7466 var textContent = fiber.memoizedProps;
7467 var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
7468 {
7469 if (shouldUpdate) {
7470 // We assume that prepareToHydrateHostTextInstance is called in a context where the
7471 // hydration parent is the parent host component of this host text.
7472 var returnFiber = hydrationParentFiber;
7473 if (returnFiber !== null) {
7474 switch (returnFiber.tag) {
7475 case HostRoot:
7476 {
7477 var parentContainer = returnFiber.stateNode.containerInfo;
7478 didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
7479 break;
7480 }
7481 case HostComponent:
7482 {
7483 var parentType = returnFiber.type;
7484 var parentProps = returnFiber.memoizedProps;
7485 var parentInstance = returnFiber.stateNode;
7486 didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
7487 break;
7488 }
7489 }
7490 }
7491 }
7492 }
7493 return shouldUpdate;
7494}
7495
7496function skipPastDehydratedSuspenseInstance(fiber) {
7497 if (!supportsHydration) {
7498 (function () {
7499 {
7500 {
7501 throw ReactError(Error('Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'));
7502 }
7503 }
7504 })();
7505 }
7506 var suspenseInstance = fiber.stateNode;
7507 (function () {
7508 if (!suspenseInstance) {
7509 {
7510 throw ReactError(Error('Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.'));
7511 }
7512 }
7513 })();
7514 nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
7515}
7516
7517function popToNextHostParent(fiber) {
7518 var parent = fiber.return;
7519 while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
7520 parent = parent.return;
7521 }
7522 hydrationParentFiber = parent;
7523}
7524
7525function popHydrationState(fiber) {
7526 if (!supportsHydration) {
7527 return false;
7528 }
7529 if (fiber !== hydrationParentFiber) {
7530 // We're deeper than the current hydration context, inside an inserted
7531 // tree.
7532 return false;
7533 }
7534 if (!isHydrating) {
7535 // If we're not currently hydrating but we're in a hydration context, then
7536 // we were an insertion and now need to pop up reenter hydration of our
7537 // siblings.
7538 popToNextHostParent(fiber);
7539 isHydrating = true;
7540 return false;
7541 }
7542
7543 var type = fiber.type;
7544
7545 // If we have any remaining hydratable nodes, we need to delete them now.
7546 // We only do this deeper than head and body since they tend to have random
7547 // other nodes in them. We also ignore components with pure text content in
7548 // side of them.
7549 // TODO: Better heuristic.
7550 if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
7551 var nextInstance = nextHydratableInstance;
7552 while (nextInstance) {
7553 deleteHydratableInstance(fiber, nextInstance);
7554 nextInstance = getNextHydratableSibling(nextInstance);
7555 }
7556 }
7557
7558 popToNextHostParent(fiber);
7559 nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
7560 return true;
7561}
7562
7563function resetHydrationState() {
7564 if (!supportsHydration) {
7565 return;
7566 }
7567
7568 hydrationParentFiber = null;
7569 nextHydratableInstance = null;
7570 isHydrating = false;
7571}
7572
7573var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
7574
7575var didReceiveUpdate = false;
7576
7577var didWarnAboutBadClass = void 0;
7578var didWarnAboutModulePatternComponent = void 0;
7579var didWarnAboutContextTypeOnFunctionComponent = void 0;
7580var didWarnAboutGetDerivedStateOnFunctionComponent = void 0;
7581var didWarnAboutFunctionRefs = void 0;
7582var didWarnAboutReassigningProps = void 0;
7583var didWarnAboutMaxDuration = void 0;
7584var didWarnAboutRevealOrder = void 0;
7585var didWarnAboutTailOptions = void 0;
7586var didWarnAboutDefaultPropsOnFunctionComponent = void 0;
7587
7588{
7589 didWarnAboutBadClass = {};
7590 didWarnAboutModulePatternComponent = {};
7591 didWarnAboutContextTypeOnFunctionComponent = {};
7592 didWarnAboutGetDerivedStateOnFunctionComponent = {};
7593 didWarnAboutFunctionRefs = {};
7594 didWarnAboutReassigningProps = false;
7595 didWarnAboutMaxDuration = false;
7596 didWarnAboutRevealOrder = {};
7597 didWarnAboutTailOptions = {};
7598 didWarnAboutDefaultPropsOnFunctionComponent = {};
7599}
7600
7601function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
7602 if (current$$1 === null) {
7603 // If this is a fresh new component that hasn't been rendered yet, we
7604 // won't update its child set by applying minimal side-effects. Instead,
7605 // we will add them all to the child before it gets rendered. That means
7606 // we can optimize this reconciliation pass by not tracking side-effects.
7607 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7608 } else {
7609 // If the current child is the same as the work in progress, it means that
7610 // we haven't yet started any work on these children. Therefore, we use
7611 // the clone algorithm to create a copy of all the current children.
7612
7613 // If we had any progressed work already, that is invalid at this point so
7614 // let's throw it out.
7615 workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, nextChildren, renderExpirationTime);
7616 }
7617}
7618
7619function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
7620 // This function is fork of reconcileChildren. It's used in cases where we
7621 // want to reconcile without matching against the existing set. This has the
7622 // effect of all current children being unmounted; even if the type and key
7623 // are the same, the old child is unmounted and a new child is created.
7624 //
7625 // To do this, we're going to go through the reconcile algorithm twice. In
7626 // the first pass, we schedule a deletion for all the current children by
7627 // passing null.
7628 workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
7629 // In the second pass, we mount the new children. The trick here is that we
7630 // pass null in place of where we usually pass the current child set. This has
7631 // the effect of remounting all children regardless of whether their their
7632 // identity matches.
7633 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
7634}
7635
7636function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
7637 // TODO: current can be non-null here even if the component
7638 // hasn't yet mounted. This happens after the first render suspends.
7639 // We'll need to figure out if this is fine or can cause issues.
7640
7641 {
7642 if (workInProgress.type !== workInProgress.elementType) {
7643 // Lazy component props can't be validated in createElement
7644 // because they're only guaranteed to be resolved here.
7645 var innerPropTypes = Component.propTypes;
7646 if (innerPropTypes) {
7647 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7648 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7649 }
7650 }
7651 }
7652
7653 var render = Component.render;
7654 var ref = workInProgress.ref;
7655
7656 // The rest is a fork of updateFunctionComponent
7657 var nextChildren = void 0;
7658 prepareToReadContext(workInProgress, renderExpirationTime);
7659 {
7660 ReactCurrentOwner$2.current = workInProgress;
7661 setCurrentPhase('render');
7662 nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
7663 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7664 // Only double-render components with Hooks
7665 if (workInProgress.memoizedState !== null) {
7666 nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
7667 }
7668 }
7669 setCurrentPhase(null);
7670 }
7671
7672 if (current$$1 !== null && !didReceiveUpdate) {
7673 bailoutHooks(current$$1, workInProgress, renderExpirationTime);
7674 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7675 }
7676
7677 // React DevTools reads this flag.
7678 workInProgress.effectTag |= PerformedWork;
7679 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7680 return workInProgress.child;
7681}
7682
7683function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
7684 if (current$$1 === null) {
7685 var type = Component.type;
7686 if (isSimpleFunctionComponent(type) && Component.compare === null &&
7687 // SimpleMemoComponent codepath doesn't resolve outer props either.
7688 Component.defaultProps === undefined) {
7689 var resolvedType = type;
7690 {
7691 resolvedType = resolveFunctionForHotReloading(type);
7692 }
7693 // If this is a plain function component without default props,
7694 // and with only the default shallow comparison, we upgrade it
7695 // to a SimpleMemoComponent to allow fast path updates.
7696 workInProgress.tag = SimpleMemoComponent;
7697 workInProgress.type = resolvedType;
7698 {
7699 validateFunctionComponentInDev(workInProgress, type);
7700 }
7701 return updateSimpleMemoComponent(current$$1, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
7702 }
7703 {
7704 var innerPropTypes = type.propTypes;
7705 if (innerPropTypes) {
7706 // Inner memo component props aren't currently validated in createElement.
7707 // We could move it there, but we'd still need this for lazy code path.
7708 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7709 'prop', getComponentName(type), getCurrentFiberStackInDev);
7710 }
7711 }
7712 var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
7713 child.ref = workInProgress.ref;
7714 child.return = workInProgress;
7715 workInProgress.child = child;
7716 return child;
7717 }
7718 {
7719 var _type = Component.type;
7720 var _innerPropTypes = _type.propTypes;
7721 if (_innerPropTypes) {
7722 // Inner memo component props aren't currently validated in createElement.
7723 // We could move it there, but we'd still need this for lazy code path.
7724 checkPropTypes(_innerPropTypes, nextProps, // Resolved props
7725 'prop', getComponentName(_type), getCurrentFiberStackInDev);
7726 }
7727 }
7728 var currentChild = current$$1.child; // This is always exactly one child
7729 if (updateExpirationTime < renderExpirationTime) {
7730 // This will be the props with resolved defaultProps,
7731 // unlike current.memoizedProps which will be the unresolved ones.
7732 var prevProps = currentChild.memoizedProps;
7733 // Default to shallow comparison
7734 var compare = Component.compare;
7735 compare = compare !== null ? compare : shallowEqual;
7736 if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
7737 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7738 }
7739 }
7740 // React DevTools reads this flag.
7741 workInProgress.effectTag |= PerformedWork;
7742 var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
7743 newChild.ref = workInProgress.ref;
7744 newChild.return = workInProgress;
7745 workInProgress.child = newChild;
7746 return newChild;
7747}
7748
7749function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
7750 // TODO: current can be non-null here even if the component
7751 // hasn't yet mounted. This happens when the inner render suspends.
7752 // We'll need to figure out if this is fine or can cause issues.
7753
7754 {
7755 if (workInProgress.type !== workInProgress.elementType) {
7756 // Lazy component props can't be validated in createElement
7757 // because they're only guaranteed to be resolved here.
7758 var outerMemoType = workInProgress.elementType;
7759 if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
7760 // We warn when you define propTypes on lazy()
7761 // so let's just skip over it to find memo() outer wrapper.
7762 // Inner props for memo are validated later.
7763 outerMemoType = refineResolvedLazyComponent(outerMemoType);
7764 }
7765 var outerPropTypes = outerMemoType && outerMemoType.propTypes;
7766 if (outerPropTypes) {
7767 checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
7768 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
7769 }
7770 // Inner propTypes will be validated in the function component path.
7771 }
7772 }
7773 if (current$$1 !== null) {
7774 var prevProps = current$$1.memoizedProps;
7775 if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref && (
7776 // Prevent bailout if the implementation changed due to hot reload:
7777 workInProgress.type === current$$1.type)) {
7778 didReceiveUpdate = false;
7779 if (updateExpirationTime < renderExpirationTime) {
7780 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7781 }
7782 }
7783 }
7784 return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
7785}
7786
7787function updateFragment(current$$1, workInProgress, renderExpirationTime) {
7788 var nextChildren = workInProgress.pendingProps;
7789 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7790 return workInProgress.child;
7791}
7792
7793function updateMode(current$$1, workInProgress, renderExpirationTime) {
7794 var nextChildren = workInProgress.pendingProps.children;
7795 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7796 return workInProgress.child;
7797}
7798
7799function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
7800 if (enableProfilerTimer) {
7801 workInProgress.effectTag |= Update;
7802 }
7803 var nextProps = workInProgress.pendingProps;
7804 var nextChildren = nextProps.children;
7805 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7806 return workInProgress.child;
7807}
7808
7809function markRef(current$$1, workInProgress) {
7810 var ref = workInProgress.ref;
7811 if (current$$1 === null && ref !== null || current$$1 !== null && current$$1.ref !== ref) {
7812 // Schedule a Ref effect
7813 workInProgress.effectTag |= Ref;
7814 }
7815}
7816
7817function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
7818 {
7819 if (workInProgress.type !== workInProgress.elementType) {
7820 // Lazy component props can't be validated in createElement
7821 // because they're only guaranteed to be resolved here.
7822 var innerPropTypes = Component.propTypes;
7823 if (innerPropTypes) {
7824 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7825 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7826 }
7827 }
7828 }
7829
7830 var context = void 0;
7831 if (!disableLegacyContext) {
7832 var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
7833 context = getMaskedContext(workInProgress, unmaskedContext);
7834 }
7835
7836 var nextChildren = void 0;
7837 prepareToReadContext(workInProgress, renderExpirationTime);
7838 {
7839 ReactCurrentOwner$2.current = workInProgress;
7840 setCurrentPhase('render');
7841 nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
7842 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7843 // Only double-render components with Hooks
7844 if (workInProgress.memoizedState !== null) {
7845 nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
7846 }
7847 }
7848 setCurrentPhase(null);
7849 }
7850
7851 if (current$$1 !== null && !didReceiveUpdate) {
7852 bailoutHooks(current$$1, workInProgress, renderExpirationTime);
7853 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7854 }
7855
7856 // React DevTools reads this flag.
7857 workInProgress.effectTag |= PerformedWork;
7858 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7859 return workInProgress.child;
7860}
7861
7862function updateClassComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
7863 {
7864 if (workInProgress.type !== workInProgress.elementType) {
7865 // Lazy component props can't be validated in createElement
7866 // because they're only guaranteed to be resolved here.
7867 var innerPropTypes = Component.propTypes;
7868 if (innerPropTypes) {
7869 checkPropTypes(innerPropTypes, nextProps, // Resolved props
7870 'prop', getComponentName(Component), getCurrentFiberStackInDev);
7871 }
7872 }
7873 }
7874
7875 // Push context providers early to prevent context stack mismatches.
7876 // During mounting we don't know the child context yet as the instance doesn't exist.
7877 // We will invalidate the child context in finishClassComponent() right after rendering.
7878 var hasContext = void 0;
7879 if (isContextProvider(Component)) {
7880 hasContext = true;
7881 pushContextProvider(workInProgress);
7882 } else {
7883 hasContext = false;
7884 }
7885 prepareToReadContext(workInProgress, renderExpirationTime);
7886
7887 var instance = workInProgress.stateNode;
7888 var shouldUpdate = void 0;
7889 if (instance === null) {
7890 if (current$$1 !== null) {
7891 // An class component without an instance only mounts if it suspended
7892 // inside a non- concurrent tree, in an inconsistent state. We want to
7893 // tree it like a new mount, even though an empty version of it already
7894 // committed. Disconnect the alternate pointers.
7895 current$$1.alternate = null;
7896 workInProgress.alternate = null;
7897 // Since this is conceptually a new fiber, schedule a Placement effect
7898 workInProgress.effectTag |= Placement;
7899 }
7900 // In the initial pass we might need to construct the instance.
7901 constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
7902 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
7903 shouldUpdate = true;
7904 } else if (current$$1 === null) {
7905 // In a resume, we'll already have an instance we can reuse.
7906 shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
7907 } else {
7908 shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
7909 }
7910 var nextUnitOfWork = finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
7911 {
7912 var inst = workInProgress.stateNode;
7913 if (inst.props !== nextProps) {
7914 !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;
7915 didWarnAboutReassigningProps = true;
7916 }
7917 }
7918 return nextUnitOfWork;
7919}
7920
7921function finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
7922 // Refs should update even if shouldComponentUpdate returns false
7923 markRef(current$$1, workInProgress);
7924
7925 var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
7926
7927 if (!shouldUpdate && !didCaptureError) {
7928 // Context providers should defer to sCU for rendering
7929 if (hasContext) {
7930 invalidateContextProvider(workInProgress, Component, false);
7931 }
7932
7933 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
7934 }
7935
7936 var instance = workInProgress.stateNode;
7937
7938 // Rerender
7939 ReactCurrentOwner$2.current = workInProgress;
7940 var nextChildren = void 0;
7941 if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
7942 // If we captured an error, but getDerivedStateFrom catch is not defined,
7943 // unmount all the children. componentDidCatch will schedule an update to
7944 // re-render a fallback. This is temporary until we migrate everyone to
7945 // the new API.
7946 // TODO: Warn in a future release.
7947 nextChildren = null;
7948
7949 if (enableProfilerTimer) {
7950 stopProfilerTimerIfRunning(workInProgress);
7951 }
7952 } else {
7953 {
7954 setCurrentPhase('render');
7955 nextChildren = instance.render();
7956 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
7957 instance.render();
7958 }
7959 setCurrentPhase(null);
7960 }
7961 }
7962
7963 // React DevTools reads this flag.
7964 workInProgress.effectTag |= PerformedWork;
7965 if (current$$1 !== null && didCaptureError) {
7966 // If we're recovering from an error, reconcile without reusing any of
7967 // the existing children. Conceptually, the normal children and the children
7968 // that are shown on error are two different sets, so we shouldn't reuse
7969 // normal children even if their identities match.
7970 forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
7971 } else {
7972 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
7973 }
7974
7975 // Memoize state using the values we just used to render.
7976 // TODO: Restructure so we never read values from the instance.
7977 workInProgress.memoizedState = instance.state;
7978
7979 // The context might have changed so we need to recalculate it.
7980 if (hasContext) {
7981 invalidateContextProvider(workInProgress, Component, true);
7982 }
7983
7984 return workInProgress.child;
7985}
7986
7987function pushHostRootContext(workInProgress) {
7988 var root = workInProgress.stateNode;
7989 if (root.pendingContext) {
7990 pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
7991 } else if (root.context) {
7992 // Should always be set
7993 pushTopLevelContextObject(workInProgress, root.context, false);
7994 }
7995 pushHostContainer(workInProgress, root.containerInfo);
7996}
7997
7998function updateHostRoot(current$$1, workInProgress, renderExpirationTime) {
7999 pushHostRootContext(workInProgress);
8000 var updateQueue = workInProgress.updateQueue;
8001 (function () {
8002 if (!(updateQueue !== null)) {
8003 {
8004 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.'));
8005 }
8006 }
8007 })();
8008 var nextProps = workInProgress.pendingProps;
8009 var prevState = workInProgress.memoizedState;
8010 var prevChildren = prevState !== null ? prevState.element : null;
8011 processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
8012 var nextState = workInProgress.memoizedState;
8013 // Caution: React DevTools currently depends on this property
8014 // being called "element".
8015 var nextChildren = nextState.element;
8016 if (nextChildren === prevChildren) {
8017 // If the state is the same as before, that's a bailout because we had
8018 // no work that expires at this time.
8019 resetHydrationState();
8020 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
8021 }
8022 var root = workInProgress.stateNode;
8023 if ((current$$1 === null || current$$1.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
8024 // If we don't have any current children this might be the first pass.
8025 // We always try to hydrate. If this isn't a hydration pass there won't
8026 // be any children to hydrate which is effectively the same thing as
8027 // not hydrating.
8028
8029 // This is a bit of a hack. We track the host root as a placement to
8030 // know that we're currently in a mounting state. That way isMounted
8031 // works as expected. We must reset this before committing.
8032 // TODO: Delete this when we delete isMounted and findDOMNode.
8033 workInProgress.effectTag |= Placement;
8034
8035 // Ensure that children mount into this root without tracking
8036 // side-effects. This ensures that we don't store Placement effects on
8037 // nodes that will be hydrated.
8038 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
8039 } else {
8040 // Otherwise reset hydration state in case we aborted and resumed another
8041 // root.
8042 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8043 resetHydrationState();
8044 }
8045 return workInProgress.child;
8046}
8047
8048function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
8049 pushHostContext(workInProgress);
8050
8051 if (current$$1 === null) {
8052 tryToClaimNextHydratableInstance(workInProgress);
8053 }
8054
8055 var type = workInProgress.type;
8056 var nextProps = workInProgress.pendingProps;
8057 var prevProps = current$$1 !== null ? current$$1.memoizedProps : null;
8058
8059 var nextChildren = nextProps.children;
8060 var isDirectTextChild = shouldSetTextContent(type, nextProps);
8061
8062 if (isDirectTextChild) {
8063 // We special case a direct text child of a host node. This is a common
8064 // case. We won't handle it as a reified child. We will instead handle
8065 // this in the host environment that also have access to this prop. That
8066 // avoids allocating another HostText fiber and traversing it.
8067 nextChildren = null;
8068 } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
8069 // If we're switching from a direct text child to a normal child, or to
8070 // empty, we need to schedule the text content to be reset.
8071 workInProgress.effectTag |= ContentReset;
8072 }
8073
8074 markRef(current$$1, workInProgress);
8075
8076 // Check the host config to see if the children are offscreen/hidden.
8077 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) {
8078 if (enableSchedulerTracing) {
8079 markSpawnedWork(Never);
8080 }
8081 // Schedule this fiber to re-render at offscreen priority. Then bailout.
8082 workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
8083 return null;
8084 }
8085
8086 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
8087 return workInProgress.child;
8088}
8089
8090function updateHostText(current$$1, workInProgress) {
8091 if (current$$1 === null) {
8092 tryToClaimNextHydratableInstance(workInProgress);
8093 }
8094 // Nothing to do here. This is terminal. We'll do the completion step
8095 // immediately after.
8096 return null;
8097}
8098
8099function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
8100 if (_current !== null) {
8101 // An lazy component only mounts if it suspended inside a non-
8102 // concurrent tree, in an inconsistent state. We want to treat it like
8103 // a new mount, even though an empty version of it already committed.
8104 // Disconnect the alternate pointers.
8105 _current.alternate = null;
8106 workInProgress.alternate = null;
8107 // Since this is conceptually a new fiber, schedule a Placement effect
8108 workInProgress.effectTag |= Placement;
8109 }
8110
8111 var props = workInProgress.pendingProps;
8112 // We can't start a User Timing measurement with correct label yet.
8113 // Cancel and resume right after we know the tag.
8114 cancelWorkTimer(workInProgress);
8115 var Component = readLazyComponentType(elementType);
8116 // Store the unwrapped component in the type.
8117 workInProgress.type = Component;
8118 var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
8119 startWorkTimer(workInProgress);
8120 var resolvedProps = resolveDefaultProps(Component, props);
8121 var child = void 0;
8122 switch (resolvedTag) {
8123 case FunctionComponent:
8124 {
8125 {
8126 validateFunctionComponentInDev(workInProgress, Component);
8127 workInProgress.type = Component = resolveFunctionForHotReloading(Component);
8128 }
8129 child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8130 break;
8131 }
8132 case ClassComponent:
8133 {
8134 {
8135 workInProgress.type = Component = resolveClassForHotReloading(Component);
8136 }
8137 child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8138 break;
8139 }
8140 case ForwardRef:
8141 {
8142 {
8143 workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
8144 }
8145 child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
8146 break;
8147 }
8148 case MemoComponent:
8149 {
8150 {
8151 if (workInProgress.type !== workInProgress.elementType) {
8152 var outerPropTypes = Component.propTypes;
8153 if (outerPropTypes) {
8154 checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
8155 'prop', getComponentName(Component), getCurrentFiberStackInDev);
8156 }
8157 }
8158 }
8159 child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
8160 updateExpirationTime, renderExpirationTime);
8161 break;
8162 }
8163 default:
8164 {
8165 var hint = '';
8166 {
8167 if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
8168 hint = ' Did you wrap a component in React.lazy() more than once?';
8169 }
8170 }
8171 // This message intentionally doesn't mention ForwardRef or MemoComponent
8172 // because the fact that it's a separate type of work is an
8173 // implementation detail.
8174 (function () {
8175 {
8176 {
8177 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));
8178 }
8179 }
8180 })();
8181 }
8182 }
8183 return child;
8184}
8185
8186function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
8187 if (_current !== null) {
8188 // An incomplete component only mounts if it suspended inside a non-
8189 // concurrent tree, in an inconsistent state. We want to treat it like
8190 // a new mount, even though an empty version of it already committed.
8191 // Disconnect the alternate pointers.
8192 _current.alternate = null;
8193 workInProgress.alternate = null;
8194 // Since this is conceptually a new fiber, schedule a Placement effect
8195 workInProgress.effectTag |= Placement;
8196 }
8197
8198 // Promote the fiber to a class and try rendering again.
8199 workInProgress.tag = ClassComponent;
8200
8201 // The rest of this function is a fork of `updateClassComponent`
8202
8203 // Push context providers early to prevent context stack mismatches.
8204 // During mounting we don't know the child context yet as the instance doesn't exist.
8205 // We will invalidate the child context in finishClassComponent() right after rendering.
8206 var hasContext = void 0;
8207 if (isContextProvider(Component)) {
8208 hasContext = true;
8209 pushContextProvider(workInProgress);
8210 } else {
8211 hasContext = false;
8212 }
8213 prepareToReadContext(workInProgress, renderExpirationTime);
8214
8215 constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8216 mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
8217
8218 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
8219}
8220
8221function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
8222 if (_current !== null) {
8223 // An indeterminate component only mounts if it suspended inside a non-
8224 // concurrent tree, in an inconsistent state. We want to treat it like
8225 // a new mount, even though an empty version of it already committed.
8226 // Disconnect the alternate pointers.
8227 _current.alternate = null;
8228 workInProgress.alternate = null;
8229 // Since this is conceptually a new fiber, schedule a Placement effect
8230 workInProgress.effectTag |= Placement;
8231 }
8232
8233 var props = workInProgress.pendingProps;
8234 var context = void 0;
8235 if (!disableLegacyContext) {
8236 var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
8237 context = getMaskedContext(workInProgress, unmaskedContext);
8238 }
8239
8240 prepareToReadContext(workInProgress, renderExpirationTime);
8241 var value = void 0;
8242
8243 {
8244 if (Component.prototype && typeof Component.prototype.render === 'function') {
8245 var componentName = getComponentName(Component) || 'Unknown';
8246
8247 if (!didWarnAboutBadClass[componentName]) {
8248 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);
8249 didWarnAboutBadClass[componentName] = true;
8250 }
8251 }
8252
8253 if (workInProgress.mode & StrictMode) {
8254 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
8255 }
8256
8257 ReactCurrentOwner$2.current = workInProgress;
8258 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
8259 }
8260 // React DevTools reads this flag.
8261 workInProgress.effectTag |= PerformedWork;
8262
8263 if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
8264 {
8265 var _componentName = getComponentName(Component) || 'Unknown';
8266 if (!didWarnAboutModulePatternComponent[_componentName]) {
8267 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);
8268 didWarnAboutModulePatternComponent[_componentName] = true;
8269 }
8270 }
8271
8272 // Proceed under the assumption that this is a class instance
8273 workInProgress.tag = ClassComponent;
8274
8275 // Throw out any hooks that were used.
8276 resetHooks();
8277
8278 // Push context providers early to prevent context stack mismatches.
8279 // During mounting we don't know the child context yet as the instance doesn't exist.
8280 // We will invalidate the child context in finishClassComponent() right after rendering.
8281 var hasContext = false;
8282 if (isContextProvider(Component)) {
8283 hasContext = true;
8284 pushContextProvider(workInProgress);
8285 } else {
8286 hasContext = false;
8287 }
8288
8289 workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
8290
8291 var getDerivedStateFromProps = Component.getDerivedStateFromProps;
8292 if (typeof getDerivedStateFromProps === 'function') {
8293 applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
8294 }
8295
8296 adoptClassInstance(workInProgress, value);
8297 mountClassInstance(workInProgress, Component, props, renderExpirationTime);
8298 return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
8299 } else {
8300 // Proceed under the assumption that this is a function component
8301 workInProgress.tag = FunctionComponent;
8302 {
8303 if (disableLegacyContext && Component.contextTypes) {
8304 warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with React.useContext() instead.', getComponentName(Component) || 'Unknown');
8305 }
8306
8307 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8308 // Only double-render components with Hooks
8309 if (workInProgress.memoizedState !== null) {
8310 value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
8311 }
8312 }
8313 }
8314 reconcileChildren(null, workInProgress, value, renderExpirationTime);
8315 {
8316 validateFunctionComponentInDev(workInProgress, Component);
8317 }
8318 return workInProgress.child;
8319 }
8320}
8321
8322function validateFunctionComponentInDev(workInProgress, Component) {
8323 if (Component) {
8324 !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
8325 }
8326 if (workInProgress.ref !== null) {
8327 var info = '';
8328 var ownerName = getCurrentFiberOwnerNameInDevOrNull();
8329 if (ownerName) {
8330 info += '\n\nCheck the render method of `' + ownerName + '`.';
8331 }
8332
8333 var warningKey = ownerName || workInProgress._debugID || '';
8334 var debugSource = workInProgress._debugSource;
8335 if (debugSource) {
8336 warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
8337 }
8338 if (!didWarnAboutFunctionRefs[warningKey]) {
8339 didWarnAboutFunctionRefs[warningKey] = true;
8340 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);
8341 }
8342 }
8343
8344 if (warnAboutDefaultPropsOnFunctionComponents && Component.defaultProps !== undefined) {
8345 var componentName = getComponentName(Component) || 'Unknown';
8346
8347 if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
8348 warningWithoutStack$1(false, '%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
8349 didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
8350 }
8351 }
8352
8353 if (typeof Component.getDerivedStateFromProps === 'function') {
8354 var _componentName2 = getComponentName(Component) || 'Unknown';
8355
8356 if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
8357 warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName2);
8358 didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
8359 }
8360 }
8361
8362 if (typeof Component.contextType === 'object' && Component.contextType !== null) {
8363 var _componentName3 = getComponentName(Component) || 'Unknown';
8364
8365 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
8366 warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName3);
8367 didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
8368 }
8369 }
8370}
8371
8372// TODO: This is now an empty object. Should we just make it a boolean?
8373var SUSPENDED_MARKER = {};
8374
8375function shouldRemainOnFallback(suspenseContext, current$$1, workInProgress) {
8376 // If the context is telling us that we should show a fallback, and we're not
8377 // already showing content, then we should show the fallback instead.
8378 return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current$$1 === null || current$$1.memoizedState !== null);
8379}
8380
8381function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
8382 var mode = workInProgress.mode;
8383 var nextProps = workInProgress.pendingProps;
8384
8385 // This is used by DevTools to force a boundary to suspend.
8386 {
8387 if (shouldSuspend(workInProgress)) {
8388 workInProgress.effectTag |= DidCapture;
8389 }
8390 }
8391
8392 var suspenseContext = suspenseStackCursor.current;
8393
8394 var nextState = null;
8395 var nextDidTimeout = false;
8396
8397 if ((workInProgress.effectTag & DidCapture) !== NoEffect || shouldRemainOnFallback(suspenseContext, current$$1, workInProgress)) {
8398 // Something in this boundary's subtree already suspended. Switch to
8399 // rendering the fallback children.
8400 nextState = SUSPENDED_MARKER;
8401 nextDidTimeout = true;
8402 workInProgress.effectTag &= ~DidCapture;
8403 } else {
8404 // Attempting the main content
8405 if (current$$1 === null || current$$1.memoizedState !== null) {
8406 // This is a new mount or this boundary is already showing a fallback state.
8407 // Mark this subtree context as having at least one invisible parent that could
8408 // handle the fallback state.
8409 // Boundaries without fallbacks or should be avoided are not considered since
8410 // they cannot handle preferred fallback states.
8411 if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
8412 suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
8413 }
8414 }
8415 }
8416
8417 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
8418
8419 pushSuspenseContext(workInProgress, suspenseContext);
8420
8421 {
8422 if ('maxDuration' in nextProps) {
8423 if (!didWarnAboutMaxDuration) {
8424 didWarnAboutMaxDuration = true;
8425 warning$1(false, 'maxDuration has been removed from React. ' + 'Remove the maxDuration prop.');
8426 }
8427 }
8428 }
8429
8430 // This next part is a bit confusing. If the children timeout, we switch to
8431 // showing the fallback children in place of the "primary" children.
8432 // However, we don't want to delete the primary children because then their
8433 // state will be lost (both the React state and the host state, e.g.
8434 // uncontrolled form inputs). Instead we keep them mounted and hide them.
8435 // Both the fallback children AND the primary children are rendered at the
8436 // same time. Once the primary children are un-suspended, we can delete
8437 // the fallback children — don't need to preserve their state.
8438 //
8439 // The two sets of children are siblings in the host environment, but
8440 // semantically, for purposes of reconciliation, they are two separate sets.
8441 // So we store them using two fragment fibers.
8442 //
8443 // However, we want to avoid allocating extra fibers for every placeholder.
8444 // They're only necessary when the children time out, because that's the
8445 // only time when both sets are mounted.
8446 //
8447 // So, the extra fragment fibers are only used if the children time out.
8448 // Otherwise, we render the primary children directly. This requires some
8449 // custom reconciliation logic to preserve the state of the primary
8450 // children. It's essentially a very basic form of re-parenting.
8451
8452 // `child` points to the child fiber. In the normal case, this is the first
8453 // fiber of the primary children set. In the timed-out case, it's a
8454 // a fragment fiber containing the primary children.
8455 var child = void 0;
8456 // `next` points to the next fiber React should render. In the normal case,
8457 // it's the same as `child`: the first fiber of the primary children set.
8458 // In the timed-out case, it's a fragment fiber containing the *fallback*
8459 // children -- we skip over the primary children entirely.
8460 var next = void 0;
8461 if (current$$1 === null) {
8462 if (enableSuspenseServerRenderer) {
8463 // If we're currently hydrating, try to hydrate this boundary.
8464 // But only if this has a fallback.
8465 if (nextProps.fallback !== undefined) {
8466 tryToClaimNextHydratableInstance(workInProgress);
8467 // This could've changed the tag if this was a dehydrated suspense component.
8468 if (workInProgress.tag === DehydratedSuspenseComponent) {
8469 popSuspenseContext(workInProgress);
8470 return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
8471 }
8472 }
8473 }
8474
8475 // This is the initial mount. This branch is pretty simple because there's
8476 // no previous state that needs to be preserved.
8477 if (nextDidTimeout) {
8478 // Mount separate fragments for primary and fallback children.
8479 var nextFallbackChildren = nextProps.fallback;
8480 var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
8481 primaryChildFragment.return = workInProgress;
8482
8483 if ((workInProgress.mode & BatchedMode) === NoMode) {
8484 // Outside of batched mode, we commit the effects from the
8485 var progressedState = workInProgress.memoizedState;
8486 var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
8487 primaryChildFragment.child = progressedPrimaryChild;
8488 var progressedChild = progressedPrimaryChild;
8489 while (progressedChild !== null) {
8490 progressedChild.return = primaryChildFragment;
8491 progressedChild = progressedChild.sibling;
8492 }
8493 }
8494
8495 var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
8496 fallbackChildFragment.return = workInProgress;
8497 primaryChildFragment.sibling = fallbackChildFragment;
8498 child = primaryChildFragment;
8499 // Skip the primary children, and continue working on the
8500 // fallback children.
8501 next = fallbackChildFragment;
8502 } else {
8503 // Mount the primary children without an intermediate fragment fiber.
8504 var nextPrimaryChildren = nextProps.children;
8505 child = next = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
8506 }
8507 } else {
8508 // This is an update. This branch is more complicated because we need to
8509 // ensure the state of the primary children is preserved.
8510 var prevState = current$$1.memoizedState;
8511 var prevDidTimeout = prevState !== null;
8512 if (prevDidTimeout) {
8513 // The current tree already timed out. That means each child set is
8514 var currentPrimaryChildFragment = current$$1.child;
8515 var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
8516 if (nextDidTimeout) {
8517 // Still timed out. Reuse the current primary children by cloning
8518 // its fragment. We're going to skip over these entirely.
8519 var _nextFallbackChildren = nextProps.fallback;
8520 var _primaryChildFragment = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
8521 _primaryChildFragment.return = workInProgress;
8522
8523 if ((workInProgress.mode & BatchedMode) === NoMode) {
8524 // Outside of batched mode, we commit the effects from the
8525 var _progressedState = workInProgress.memoizedState;
8526 var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
8527 if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
8528 _primaryChildFragment.child = _progressedPrimaryChild;
8529 var _progressedChild = _progressedPrimaryChild;
8530 while (_progressedChild !== null) {
8531 _progressedChild.return = _primaryChildFragment;
8532 _progressedChild = _progressedChild.sibling;
8533 }
8534 }
8535 }
8536
8537 // Because primaryChildFragment is a new fiber that we're inserting as the
8538 // parent of a new tree, we need to set its treeBaseDuration.
8539 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8540 // treeBaseDuration is the sum of all the child tree base durations.
8541 var treeBaseDuration = 0;
8542 var hiddenChild = _primaryChildFragment.child;
8543 while (hiddenChild !== null) {
8544 treeBaseDuration += hiddenChild.treeBaseDuration;
8545 hiddenChild = hiddenChild.sibling;
8546 }
8547 _primaryChildFragment.treeBaseDuration = treeBaseDuration;
8548 }
8549
8550 // Clone the fallback child fragment, too. These we'll continue
8551 // working on.
8552 var _fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren, currentFallbackChildFragment.expirationTime);
8553 _fallbackChildFragment.return = workInProgress;
8554 _primaryChildFragment.sibling = _fallbackChildFragment;
8555 child = _primaryChildFragment;
8556 _primaryChildFragment.childExpirationTime = NoWork;
8557 // Skip the primary children, and continue working on the
8558 // fallback children.
8559 next = _fallbackChildFragment;
8560 } else {
8561 // No longer suspended. Switch back to showing the primary children,
8562 // and remove the intermediate fragment fiber.
8563 var _nextPrimaryChildren = nextProps.children;
8564 var currentPrimaryChild = currentPrimaryChildFragment.child;
8565 var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
8566
8567 // If this render doesn't suspend, we need to delete the fallback
8568 // children. Wait until the complete phase, after we've confirmed the
8569 // fallback is no longer needed.
8570 // TODO: Would it be better to store the fallback fragment on
8571 // the stateNode?
8572
8573 // Continue rendering the children, like we normally do.
8574 child = next = primaryChild;
8575 }
8576 } else {
8577 // The current tree has not already timed out. That means the primary
8578 // children are not wrapped in a fragment fiber.
8579 var _currentPrimaryChild = current$$1.child;
8580 if (nextDidTimeout) {
8581 // Timed out. Wrap the children in a fragment fiber to keep them
8582 // separate from the fallback children.
8583 var _nextFallbackChildren2 = nextProps.fallback;
8584 var _primaryChildFragment2 = createFiberFromFragment(
8585 // It shouldn't matter what the pending props are because we aren't
8586 // going to render this fragment.
8587 null, mode, NoWork, null);
8588 _primaryChildFragment2.return = workInProgress;
8589 _primaryChildFragment2.child = _currentPrimaryChild;
8590 if (_currentPrimaryChild !== null) {
8591 _currentPrimaryChild.return = _primaryChildFragment2;
8592 }
8593
8594 // Even though we're creating a new fiber, there are no new children,
8595 // because we're reusing an already mounted tree. So we don't need to
8596 // schedule a placement.
8597 // primaryChildFragment.effectTag |= Placement;
8598
8599 if ((workInProgress.mode & BatchedMode) === NoMode) {
8600 // Outside of batched mode, we commit the effects from the
8601 var _progressedState2 = workInProgress.memoizedState;
8602 var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
8603 _primaryChildFragment2.child = _progressedPrimaryChild2;
8604 var _progressedChild2 = _progressedPrimaryChild2;
8605 while (_progressedChild2 !== null) {
8606 _progressedChild2.return = _primaryChildFragment2;
8607 _progressedChild2 = _progressedChild2.sibling;
8608 }
8609 }
8610
8611 // Because primaryChildFragment is a new fiber that we're inserting as the
8612 // parent of a new tree, we need to set its treeBaseDuration.
8613 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
8614 // treeBaseDuration is the sum of all the child tree base durations.
8615 var _treeBaseDuration = 0;
8616 var _hiddenChild = _primaryChildFragment2.child;
8617 while (_hiddenChild !== null) {
8618 _treeBaseDuration += _hiddenChild.treeBaseDuration;
8619 _hiddenChild = _hiddenChild.sibling;
8620 }
8621 _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
8622 }
8623
8624 // Create a fragment from the fallback children, too.
8625 var _fallbackChildFragment2 = createFiberFromFragment(_nextFallbackChildren2, mode, renderExpirationTime, null);
8626 _fallbackChildFragment2.return = workInProgress;
8627 _primaryChildFragment2.sibling = _fallbackChildFragment2;
8628 _fallbackChildFragment2.effectTag |= Placement;
8629 child = _primaryChildFragment2;
8630 _primaryChildFragment2.childExpirationTime = NoWork;
8631 // Skip the primary children, and continue working on the
8632 // fallback children.
8633 next = _fallbackChildFragment2;
8634 } else {
8635 // Still haven't timed out. Continue rendering the children, like we
8636 // normally do.
8637 var _nextPrimaryChildren2 = nextProps.children;
8638 next = child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
8639 }
8640 }
8641 workInProgress.stateNode = current$$1.stateNode;
8642 }
8643
8644 workInProgress.memoizedState = nextState;
8645 workInProgress.child = child;
8646 return next;
8647}
8648
8649function retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime) {
8650 // Detach from the current dehydrated boundary.
8651 current$$1.alternate = null;
8652 workInProgress.alternate = null;
8653
8654 // Insert a deletion in the effect list.
8655 var returnFiber = workInProgress.return;
8656 (function () {
8657 if (!(returnFiber !== null)) {
8658 {
8659 throw ReactError(Error('Suspense boundaries are never on the root. This is probably a bug in React.'));
8660 }
8661 }
8662 })();
8663 var last = returnFiber.lastEffect;
8664 if (last !== null) {
8665 last.nextEffect = current$$1;
8666 returnFiber.lastEffect = current$$1;
8667 } else {
8668 returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
8669 }
8670 current$$1.nextEffect = null;
8671 current$$1.effectTag = Deletion;
8672
8673 popSuspenseContext(workInProgress);
8674
8675 // Upgrade this work in progress to a real Suspense component.
8676 workInProgress.tag = SuspenseComponent;
8677 workInProgress.stateNode = null;
8678 workInProgress.memoizedState = null;
8679 // This is now an insertion.
8680 workInProgress.effectTag |= Placement;
8681 // Retry as a real Suspense component.
8682 return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
8683}
8684
8685function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
8686 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
8687 var suspenseInstance = workInProgress.stateNode;
8688 if (current$$1 === null) {
8689 // During the first pass, we'll bail out and not drill into the children.
8690 // Instead, we'll leave the content in place and try to hydrate it later.
8691 if (isSuspenseInstanceFallback(suspenseInstance)) {
8692 // This is a client-only boundary. Since we won't get any content from the server
8693 // for this, we need to schedule that at a higher priority based on when it would
8694 // have timed out. In theory we could render it in this pass but it would have the
8695 // wrong priority associated with it and will prevent hydration of parent path.
8696 // Instead, we'll leave work left on it to render it in a separate commit.
8697
8698 // TODO This time should be the time at which the server rendered response that is
8699 // a parent to this boundary was displayed. However, since we currently don't have
8700 // a protocol to transfer that time, we'll just estimate it by using the current
8701 // time. This will mean that Suspense timeouts are slightly shifted to later than
8702 // they should be.
8703 var serverDisplayTime = requestCurrentTime();
8704 // Schedule a normal pri update to render this content.
8705 workInProgress.expirationTime = computeAsyncExpiration(serverDisplayTime);
8706 } else {
8707 // We'll continue hydrating the rest at offscreen priority since we'll already
8708 // be showing the right content coming from the server, it is no rush.
8709 workInProgress.expirationTime = Never;
8710 }
8711 return null;
8712 }
8713 if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
8714 // Something suspended. Leave the existing children in place.
8715 // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
8716 workInProgress.child = null;
8717 return null;
8718 }
8719 if (isSuspenseInstanceFallback(suspenseInstance)) {
8720 // This boundary is in a permanent fallback state. In this case, we'll never
8721 // get an update and we'll never be able to hydrate the final content. Let's just try the
8722 // client side render instead.
8723 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
8724 }
8725 // We use childExpirationTime to indicate that a child might depend on context, so if
8726 // any context has changed, we need to treat is as if the input might have changed.
8727 var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
8728 if (didReceiveUpdate || hasContextChanged$$1) {
8729 // This boundary has changed since the first render. This means that we are now unable to
8730 // hydrate it. We might still be able to hydrate it using an earlier expiration time but
8731 // during this render we can't. Instead, we're going to delete the whole subtree and
8732 // instead inject a new real Suspense boundary to take its place, which may render content
8733 // or fallback. The real Suspense boundary will suspend for a while so we have some time
8734 // to ensure it can produce real content, but all state and pending events will be lost.
8735 return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
8736 } else if (isSuspenseInstancePending(suspenseInstance)) {
8737 // This component is still pending more data from the server, so we can't hydrate its
8738 // content. We treat it as if this component suspended itself. It might seem as if
8739 // we could just try to render it client-side instead. However, this will perform a
8740 // lot of unnecessary work and is unlikely to complete since it often will suspend
8741 // on missing data anyway. Additionally, the server might be able to render more
8742 // than we can on the client yet. In that case we'd end up with more fallback states
8743 // on the client than if we just leave it alone. If the server times out or errors
8744 // these should update this boundary to the permanent Fallback state instead.
8745 // Mark it as having captured (i.e. suspended).
8746 workInProgress.effectTag |= DidCapture;
8747 // Leave the children in place. I.e. empty.
8748 workInProgress.child = null;
8749 // Register a callback to retry this boundary once the server has sent the result.
8750 registerSuspenseInstanceRetry(suspenseInstance, retryTimedOutBoundary.bind(null, current$$1));
8751 return null;
8752 } else {
8753 // This is the first attempt.
8754 reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
8755 var nextProps = workInProgress.pendingProps;
8756 var nextChildren = nextProps.children;
8757 workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
8758 return workInProgress.child;
8759 }
8760}
8761
8762function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
8763 // Mark any Suspense boundaries with fallbacks as having work to do.
8764 // If they were previously forced into fallbacks, they may now be able
8765 // to unblock.
8766 var node = firstChild;
8767 while (node !== null) {
8768 if (node.tag === SuspenseComponent) {
8769 var state = node.memoizedState;
8770 if (state !== null) {
8771 if (node.expirationTime < renderExpirationTime) {
8772 node.expirationTime = renderExpirationTime;
8773 }
8774 var alternate = node.alternate;
8775 if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
8776 alternate.expirationTime = renderExpirationTime;
8777 }
8778 scheduleWorkOnParentPath(node.return, renderExpirationTime);
8779 }
8780 } else if (node.child !== null) {
8781 node.child.return = node;
8782 node = node.child;
8783 continue;
8784 }
8785 if (node === workInProgress) {
8786 return;
8787 }
8788 while (node.sibling === null) {
8789 if (node.return === null || node.return === workInProgress) {
8790 return;
8791 }
8792 node = node.return;
8793 }
8794 node.sibling.return = node.return;
8795 node = node.sibling;
8796 }
8797}
8798
8799function findLastContentRow(firstChild) {
8800 // This is going to find the last row among these children that is already
8801 // showing content on the screen, as opposed to being in fallback state or
8802 // new. If a row has multiple Suspense boundaries, any of them being in the
8803 // fallback state, counts as the whole row being in a fallback state.
8804 // Note that the "rows" will be workInProgress, but any nested children
8805 // will still be current since we haven't rendered them yet. The mounted
8806 // order may not be the same as the new order. We use the new order.
8807 var row = firstChild;
8808 var lastContentRow = null;
8809 while (row !== null) {
8810 var currentRow = row.alternate;
8811 // New rows can't be content rows.
8812 if (currentRow !== null && findFirstSuspended(currentRow) === null) {
8813 lastContentRow = row;
8814 }
8815 row = row.sibling;
8816 }
8817 return lastContentRow;
8818}
8819
8820function validateRevealOrder(revealOrder) {
8821 {
8822 if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
8823 didWarnAboutRevealOrder[revealOrder] = true;
8824 if (typeof revealOrder === 'string') {
8825 switch (revealOrder.toLowerCase()) {
8826 case 'together':
8827 case 'forwards':
8828 case 'backwards':
8829 {
8830 warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
8831 break;
8832 }
8833 case 'forward':
8834 case 'backward':
8835 {
8836 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());
8837 break;
8838 }
8839 default:
8840 warning$1(false, '"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
8841 break;
8842 }
8843 } else {
8844 warning$1(false, '%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
8845 }
8846 }
8847 }
8848}
8849
8850function validateTailOptions(tailMode, revealOrder) {
8851 {
8852 if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
8853 if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
8854 didWarnAboutTailOptions[tailMode] = true;
8855 warning$1(false, '"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
8856 } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
8857 didWarnAboutTailOptions[tailMode] = true;
8858 warning$1(false, '<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
8859 }
8860 }
8861 }
8862}
8863
8864function validateSuspenseListNestedChild(childSlot, index) {
8865 {
8866 var isArray = Array.isArray(childSlot);
8867 var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
8868 if (isArray || isIterable) {
8869 var type = isArray ? 'array' : 'iterable';
8870 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);
8871 return false;
8872 }
8873 }
8874 return true;
8875}
8876
8877function validateSuspenseListChildren(children, revealOrder) {
8878 {
8879 if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
8880 if (Array.isArray(children)) {
8881 for (var i = 0; i < children.length; i++) {
8882 if (!validateSuspenseListNestedChild(children[i], i)) {
8883 return;
8884 }
8885 }
8886 } else {
8887 var iteratorFn = getIteratorFn(children);
8888 if (typeof iteratorFn === 'function') {
8889 var childrenIterator = iteratorFn.call(children);
8890 if (childrenIterator) {
8891 var step = childrenIterator.next();
8892 var _i = 0;
8893 for (; !step.done; step = childrenIterator.next()) {
8894 if (!validateSuspenseListNestedChild(step.value, _i)) {
8895 return;
8896 }
8897 _i++;
8898 }
8899 }
8900 } else {
8901 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);
8902 }
8903 }
8904 }
8905 }
8906}
8907
8908function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode) {
8909 var renderState = workInProgress.memoizedState;
8910 if (renderState === null) {
8911 workInProgress.memoizedState = {
8912 isBackwards: isBackwards,
8913 rendering: null,
8914 last: lastContentRow,
8915 tail: tail,
8916 tailExpiration: 0,
8917 tailMode: tailMode
8918 };
8919 } else {
8920 // We can reuse the existing object from previous renders.
8921 renderState.isBackwards = isBackwards;
8922 renderState.rendering = null;
8923 renderState.last = lastContentRow;
8924 renderState.tail = tail;
8925 renderState.tailExpiration = 0;
8926 renderState.tailMode = tailMode;
8927 }
8928}
8929
8930// This can end up rendering this component multiple passes.
8931// The first pass splits the children fibers into two sets. A head and tail.
8932// We first render the head. If anything is in fallback state, we do another
8933// pass through beginWork to rerender all children (including the tail) with
8934// the force suspend context. If the first render didn't have anything in
8935// in fallback state. Then we render each row in the tail one-by-one.
8936// That happens in the completeWork phase without going back to beginWork.
8937function updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime) {
8938 var nextProps = workInProgress.pendingProps;
8939 var revealOrder = nextProps.revealOrder;
8940 var tailMode = nextProps.tail;
8941 var newChildren = nextProps.children;
8942
8943 validateRevealOrder(revealOrder);
8944 validateTailOptions(tailMode, revealOrder);
8945 validateSuspenseListChildren(newChildren, revealOrder);
8946
8947 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
8948
8949 var suspenseContext = suspenseStackCursor.current;
8950
8951 var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
8952 if (shouldForceFallback) {
8953 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
8954 workInProgress.effectTag |= DidCapture;
8955 } else {
8956 var didSuspendBefore = current$$1 !== null && (current$$1.effectTag & DidCapture) !== NoEffect;
8957 if (didSuspendBefore) {
8958 // If we previously forced a fallback, we need to schedule work
8959 // on any nested boundaries to let them know to try to render
8960 // again. This is the same as context updating.
8961 propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
8962 }
8963 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
8964 }
8965 pushSuspenseContext(workInProgress, suspenseContext);
8966
8967 if ((workInProgress.mode & BatchedMode) === NoMode) {
8968 // Outside of batched mode, SuspenseList doesn't work so we just
8969 // use make it a noop by treating it as the default revealOrder.
8970 workInProgress.memoizedState = null;
8971 } else {
8972 switch (revealOrder) {
8973 case 'forwards':
8974 {
8975 var lastContentRow = findLastContentRow(workInProgress.child);
8976 var tail = void 0;
8977 if (lastContentRow === null) {
8978 // The whole list is part of the tail.
8979 // TODO: We could fast path by just rendering the tail now.
8980 tail = workInProgress.child;
8981 workInProgress.child = null;
8982 } else {
8983 // Disconnect the tail rows after the content row.
8984 // We're going to render them separately later.
8985 tail = lastContentRow.sibling;
8986 lastContentRow.sibling = null;
8987 }
8988 initSuspenseListRenderState(workInProgress, false, // isBackwards
8989 tail, lastContentRow, tailMode);
8990 break;
8991 }
8992 case 'backwards':
8993 {
8994 // We're going to find the first row that has existing content.
8995 // At the same time we're going to reverse the list of everything
8996 // we pass in the meantime. That's going to be our tail in reverse
8997 // order.
8998 var _tail = null;
8999 var row = workInProgress.child;
9000 workInProgress.child = null;
9001 while (row !== null) {
9002 var currentRow = row.alternate;
9003 // New rows can't be content rows.
9004 if (currentRow !== null && findFirstSuspended(currentRow) === null) {
9005 // This is the beginning of the main content.
9006 workInProgress.child = row;
9007 break;
9008 }
9009 var nextRow = row.sibling;
9010 row.sibling = _tail;
9011 _tail = row;
9012 row = nextRow;
9013 }
9014 // TODO: If workInProgress.child is null, we can continue on the tail immediately.
9015 initSuspenseListRenderState(workInProgress, true, // isBackwards
9016 _tail, null, // last
9017 tailMode);
9018 break;
9019 }
9020 case 'together':
9021 {
9022 initSuspenseListRenderState(workInProgress, false, // isBackwards
9023 null, // tail
9024 null, // last
9025 undefined);
9026 break;
9027 }
9028 default:
9029 {
9030 // The default reveal order is the same as not having
9031 // a boundary.
9032 workInProgress.memoizedState = null;
9033 }
9034 }
9035 }
9036 return workInProgress.child;
9037}
9038
9039function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
9040 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
9041 var nextChildren = workInProgress.pendingProps;
9042 if (current$$1 === null) {
9043 // Portals are special because we don't append the children during mount
9044 // but at commit. Therefore we need to track insertions which the normal
9045 // flow doesn't do during mount. This doesn't happen at the root because
9046 // the root always starts with a "current" with a null child.
9047 // TODO: Consider unifying this with how the root works.
9048 workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
9049 } else {
9050 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9051 }
9052 return workInProgress.child;
9053}
9054
9055function updateContextProvider(current$$1, workInProgress, renderExpirationTime) {
9056 var providerType = workInProgress.type;
9057 var context = providerType._context;
9058
9059 var newProps = workInProgress.pendingProps;
9060 var oldProps = workInProgress.memoizedProps;
9061
9062 var newValue = newProps.value;
9063
9064 {
9065 var providerPropTypes = workInProgress.type.propTypes;
9066
9067 if (providerPropTypes) {
9068 checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
9069 }
9070 }
9071
9072 pushProvider(workInProgress, newValue);
9073
9074 if (oldProps !== null) {
9075 var oldValue = oldProps.value;
9076 var changedBits = calculateChangedBits(context, newValue, oldValue);
9077 if (changedBits === 0) {
9078 // No change. Bailout early if children are the same.
9079 if (oldProps.children === newProps.children && !hasContextChanged()) {
9080 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9081 }
9082 } else {
9083 // The context value changed. Search for matching consumers and schedule
9084 // them to update.
9085 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
9086 }
9087 }
9088
9089 var newChildren = newProps.children;
9090 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
9091 return workInProgress.child;
9092}
9093
9094var hasWarnedAboutUsingContextAsConsumer = false;
9095
9096function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
9097 var context = workInProgress.type;
9098 // The logic below for Context differs depending on PROD or DEV mode. In
9099 // DEV mode, we create a separate object for Context.Consumer that acts
9100 // like a proxy to Context. This proxy object adds unnecessary code in PROD
9101 // so we use the old behaviour (Context.Consumer references Context) to
9102 // reduce size and overhead. The separate object references context via
9103 // a property called "_context", which also gives us the ability to check
9104 // in DEV mode if this property exists or not and warn if it does not.
9105 {
9106 if (context._context === undefined) {
9107 // This may be because it's a Context (rather than a Consumer).
9108 // Or it may be because it's older React where they're the same thing.
9109 // We only want to warn if we're sure it's a new React.
9110 if (context !== context.Consumer) {
9111 if (!hasWarnedAboutUsingContextAsConsumer) {
9112 hasWarnedAboutUsingContextAsConsumer = true;
9113 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?');
9114 }
9115 }
9116 } else {
9117 context = context._context;
9118 }
9119 }
9120 var newProps = workInProgress.pendingProps;
9121 var render = newProps.children;
9122
9123 {
9124 !(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;
9125 }
9126
9127 prepareToReadContext(workInProgress, renderExpirationTime);
9128 var newValue = readContext(context, newProps.unstable_observedBits);
9129 var newChildren = void 0;
9130 {
9131 ReactCurrentOwner$2.current = workInProgress;
9132 setCurrentPhase('render');
9133 newChildren = render(newValue);
9134 setCurrentPhase(null);
9135 }
9136
9137 // React DevTools reads this flag.
9138 workInProgress.effectTag |= PerformedWork;
9139 reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
9140 return workInProgress.child;
9141}
9142
9143function updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime) {
9144 var fundamentalImpl = workInProgress.type.impl;
9145 if (fundamentalImpl.reconcileChildren === false) {
9146 return null;
9147 }
9148 var nextProps = workInProgress.pendingProps;
9149 var nextChildren = nextProps.children;
9150
9151 reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
9152 return workInProgress.child;
9153}
9154
9155function markWorkInProgressReceivedUpdate() {
9156 didReceiveUpdate = true;
9157}
9158
9159function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime) {
9160 cancelWorkTimer(workInProgress);
9161
9162 if (current$$1 !== null) {
9163 // Reuse previous dependencies
9164 workInProgress.dependencies = current$$1.dependencies;
9165 }
9166
9167 if (enableProfilerTimer) {
9168 // Don't update "base" render times for bailouts.
9169 stopProfilerTimerIfRunning(workInProgress);
9170 }
9171
9172 // Check if the children have any pending work.
9173 var childExpirationTime = workInProgress.childExpirationTime;
9174 if (childExpirationTime < renderExpirationTime) {
9175 // The children don't have any work either. We can skip them.
9176 // TODO: Once we add back resuming, we should check if the children are
9177 // a work-in-progress set. If so, we need to transfer their effects.
9178 return null;
9179 } else {
9180 // This fiber doesn't have work, but its subtree does. Clone the child
9181 // fibers and continue.
9182 cloneChildFibers(current$$1, workInProgress);
9183 return workInProgress.child;
9184 }
9185}
9186
9187function remountFiber(current$$1, oldWorkInProgress, newWorkInProgress) {
9188 {
9189 var returnFiber = oldWorkInProgress.return;
9190 if (returnFiber === null) {
9191 throw new Error('Cannot swap the root fiber.');
9192 }
9193
9194 // Disconnect from the old current.
9195 // It will get deleted.
9196 current$$1.alternate = null;
9197 oldWorkInProgress.alternate = null;
9198
9199 // Connect to the new tree.
9200 newWorkInProgress.index = oldWorkInProgress.index;
9201 newWorkInProgress.sibling = oldWorkInProgress.sibling;
9202 newWorkInProgress.return = oldWorkInProgress.return;
9203 newWorkInProgress.ref = oldWorkInProgress.ref;
9204
9205 // Replace the child/sibling pointers above it.
9206 if (oldWorkInProgress === returnFiber.child) {
9207 returnFiber.child = newWorkInProgress;
9208 } else {
9209 var prevSibling = returnFiber.child;
9210 if (prevSibling === null) {
9211 throw new Error('Expected parent to have a child.');
9212 }
9213 while (prevSibling.sibling !== oldWorkInProgress) {
9214 prevSibling = prevSibling.sibling;
9215 if (prevSibling === null) {
9216 throw new Error('Expected to find the previous sibling.');
9217 }
9218 }
9219 prevSibling.sibling = newWorkInProgress;
9220 }
9221
9222 // Delete the old fiber and place the new one.
9223 // Since the old fiber is disconnected, we have to schedule it manually.
9224 var last = returnFiber.lastEffect;
9225 if (last !== null) {
9226 last.nextEffect = current$$1;
9227 returnFiber.lastEffect = current$$1;
9228 } else {
9229 returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
9230 }
9231 current$$1.nextEffect = null;
9232 current$$1.effectTag = Deletion;
9233
9234 newWorkInProgress.effectTag |= Placement;
9235
9236 // Restart work from the new fiber.
9237 return newWorkInProgress;
9238 }
9239}
9240
9241function beginWork$1(current$$1, workInProgress, renderExpirationTime) {
9242 var updateExpirationTime = workInProgress.expirationTime;
9243
9244 {
9245 if (workInProgress._debugNeedsRemount && current$$1 !== null) {
9246 // This will restart the begin phase with a new fiber.
9247 return remountFiber(current$$1, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
9248 }
9249 }
9250
9251 if (current$$1 !== null) {
9252 var oldProps = current$$1.memoizedProps;
9253 var newProps = workInProgress.pendingProps;
9254
9255 if (oldProps !== newProps || hasContextChanged() || (
9256 // Force a re-render if the implementation changed due to hot reload:
9257 workInProgress.type !== current$$1.type)) {
9258 // If props or context changed, mark the fiber as having performed work.
9259 // This may be unset if the props are determined to be equal later (memo).
9260 didReceiveUpdate = true;
9261 } else if (updateExpirationTime < renderExpirationTime) {
9262 didReceiveUpdate = false;
9263 // This fiber does not have any pending work. Bailout without entering
9264 // the begin phase. There's still some bookkeeping we that needs to be done
9265 // in this optimized path, mostly pushing stuff onto the stack.
9266 switch (workInProgress.tag) {
9267 case HostRoot:
9268 pushHostRootContext(workInProgress);
9269 resetHydrationState();
9270 break;
9271 case HostComponent:
9272 pushHostContext(workInProgress);
9273 if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
9274 if (enableSchedulerTracing) {
9275 markSpawnedWork(Never);
9276 }
9277 // Schedule this fiber to re-render at offscreen priority. Then bailout.
9278 workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
9279 return null;
9280 }
9281 break;
9282 case ClassComponent:
9283 {
9284 var Component = workInProgress.type;
9285 if (isContextProvider(Component)) {
9286 pushContextProvider(workInProgress);
9287 }
9288 break;
9289 }
9290 case HostPortal:
9291 pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
9292 break;
9293 case ContextProvider:
9294 {
9295 var newValue = workInProgress.memoizedProps.value;
9296 pushProvider(workInProgress, newValue);
9297 break;
9298 }
9299 case Profiler:
9300 if (enableProfilerTimer) {
9301 workInProgress.effectTag |= Update;
9302 }
9303 break;
9304 case SuspenseComponent:
9305 {
9306 var state = workInProgress.memoizedState;
9307 var didTimeout = state !== null;
9308 if (didTimeout) {
9309 // If this boundary is currently timed out, we need to decide
9310 // whether to retry the primary children, or to skip over it and
9311 // go straight to the fallback. Check the priority of the primary
9312 var primaryChildFragment = workInProgress.child;
9313 var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
9314 if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
9315 // The primary children have pending work. Use the normal path
9316 // to attempt to render the primary children again.
9317 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
9318 } else {
9319 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
9320 // The primary children do not have pending work with sufficient
9321 // priority. Bailout.
9322 var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9323 if (child !== null) {
9324 // The fallback children have pending work. Skip over the
9325 // primary children and work on the fallback.
9326 return child.sibling;
9327 } else {
9328 return null;
9329 }
9330 }
9331 } else {
9332 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
9333 }
9334 break;
9335 }
9336 case DehydratedSuspenseComponent:
9337 {
9338 if (enableSuspenseServerRenderer) {
9339 pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
9340 // We know that this component will suspend again because if it has
9341 // been unsuspended it has committed as a regular Suspense component.
9342 // If it needs to be retried, it should have work scheduled on it.
9343 workInProgress.effectTag |= DidCapture;
9344 }
9345 break;
9346 }
9347 case SuspenseListComponent:
9348 {
9349 var didSuspendBefore = (current$$1.effectTag & DidCapture) !== NoEffect;
9350
9351 var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
9352
9353 if (didSuspendBefore) {
9354 if (hasChildWork) {
9355 // If something was in fallback state last time, and we have all the
9356 // same children then we're still in progressive loading state.
9357 // Something might get unblocked by state updates or retries in the
9358 // tree which will affect the tail. So we need to use the normal
9359 // path to compute the correct tail.
9360 return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
9361 }
9362 // If none of the children had any work, that means that none of
9363 // them got retried so they'll still be blocked in the same way
9364 // as before. We can fast bail out.
9365 workInProgress.effectTag |= DidCapture;
9366 }
9367
9368 // If nothing suspended before and we're rendering the same children,
9369 // then the tail doesn't matter. Anything new that suspends will work
9370 // in the "together" mode, so we can continue from the state we had.
9371 var renderState = workInProgress.memoizedState;
9372 if (renderState !== null) {
9373 // Reset to the "together" mode in case we've started a different
9374 // update in the past but didn't complete it.
9375 renderState.rendering = null;
9376 renderState.tail = null;
9377 }
9378 pushSuspenseContext(workInProgress, suspenseStackCursor.current);
9379
9380 if (hasChildWork) {
9381 break;
9382 } else {
9383 // If none of the children had any work, that means that none of
9384 // them got retried so they'll still be blocked in the same way
9385 // as before. We can fast bail out.
9386 return null;
9387 }
9388 }
9389 }
9390 return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
9391 }
9392 } else {
9393 didReceiveUpdate = false;
9394 }
9395
9396 // Before entering the begin phase, clear the expiration time.
9397 workInProgress.expirationTime = NoWork;
9398
9399 switch (workInProgress.tag) {
9400 case IndeterminateComponent:
9401 {
9402 return mountIndeterminateComponent(current$$1, workInProgress, workInProgress.type, renderExpirationTime);
9403 }
9404 case LazyComponent:
9405 {
9406 var elementType = workInProgress.elementType;
9407 return mountLazyComponent(current$$1, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
9408 }
9409 case FunctionComponent:
9410 {
9411 var _Component = workInProgress.type;
9412 var unresolvedProps = workInProgress.pendingProps;
9413 var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
9414 return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
9415 }
9416 case ClassComponent:
9417 {
9418 var _Component2 = workInProgress.type;
9419 var _unresolvedProps = workInProgress.pendingProps;
9420 var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
9421 return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
9422 }
9423 case HostRoot:
9424 return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
9425 case HostComponent:
9426 return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
9427 case HostText:
9428 return updateHostText(current$$1, workInProgress);
9429 case SuspenseComponent:
9430 return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
9431 case HostPortal:
9432 return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
9433 case ForwardRef:
9434 {
9435 var type = workInProgress.type;
9436 var _unresolvedProps2 = workInProgress.pendingProps;
9437 var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
9438 return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
9439 }
9440 case Fragment:
9441 return updateFragment(current$$1, workInProgress, renderExpirationTime);
9442 case Mode$1:
9443 return updateMode(current$$1, workInProgress, renderExpirationTime);
9444 case Profiler:
9445 return updateProfiler(current$$1, workInProgress, renderExpirationTime);
9446 case ContextProvider:
9447 return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
9448 case ContextConsumer:
9449 return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
9450 case MemoComponent:
9451 {
9452 var _type2 = workInProgress.type;
9453 var _unresolvedProps3 = workInProgress.pendingProps;
9454 // Resolve outer props first, then resolve inner props.
9455 var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
9456 {
9457 if (workInProgress.type !== workInProgress.elementType) {
9458 var outerPropTypes = _type2.propTypes;
9459 if (outerPropTypes) {
9460 checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
9461 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
9462 }
9463 }
9464 }
9465 _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
9466 return updateMemoComponent(current$$1, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
9467 }
9468 case SimpleMemoComponent:
9469 {
9470 return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
9471 }
9472 case IncompleteClassComponent:
9473 {
9474 var _Component3 = workInProgress.type;
9475 var _unresolvedProps4 = workInProgress.pendingProps;
9476 var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
9477 return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
9478 }
9479 case DehydratedSuspenseComponent:
9480 {
9481 if (enableSuspenseServerRenderer) {
9482 return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
9483 }
9484 break;
9485 }
9486 case SuspenseListComponent:
9487 {
9488 return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
9489 }
9490 case FundamentalComponent:
9491 {
9492 if (enableFundamentalAPI) {
9493 return updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime);
9494 }
9495 break;
9496 }
9497 }
9498 (function () {
9499 {
9500 {
9501 throw ReactError(Error('Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.'));
9502 }
9503 }
9504 })();
9505}
9506
9507function createFundamentalStateInstance(currentFiber, props, impl, state) {
9508 return {
9509 currentFiber: currentFiber,
9510 impl: impl,
9511 instance: null,
9512 prevProps: null,
9513 props: props,
9514 state: state
9515 };
9516}
9517
9518var emptyObject = {};
9519var isArray$2 = Array.isArray;
9520
9521function markUpdate(workInProgress) {
9522 // Tag the fiber with an update effect. This turns a Placement into
9523 // a PlacementAndUpdate.
9524 workInProgress.effectTag |= Update;
9525}
9526
9527function markRef$1(workInProgress) {
9528 workInProgress.effectTag |= Ref;
9529}
9530
9531var appendAllChildren = void 0;
9532var updateHostContainer = void 0;
9533var updateHostComponent$1 = void 0;
9534var updateHostText$1 = void 0;
9535if (supportsMutation) {
9536 // Mutation mode
9537
9538 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
9539 // We only have the top Fiber that was created but we need recurse down its
9540 // children to find all the terminal nodes.
9541 var node = workInProgress.child;
9542 while (node !== null) {
9543 if (node.tag === HostComponent || node.tag === HostText) {
9544 appendInitialChild(parent, node.stateNode);
9545 } else if (node.tag === FundamentalComponent) {
9546 appendInitialChild(parent, node.stateNode.instance);
9547 } else if (node.tag === HostPortal) {
9548 // If we have a portal child, then we don't want to traverse
9549 // down its children. Instead, we'll get insertions from each child in
9550 // the portal directly.
9551 } else if (node.child !== null) {
9552 node.child.return = node;
9553 node = node.child;
9554 continue;
9555 }
9556 if (node === workInProgress) {
9557 return;
9558 }
9559 while (node.sibling === null) {
9560 if (node.return === null || node.return === workInProgress) {
9561 return;
9562 }
9563 node = node.return;
9564 }
9565 node.sibling.return = node.return;
9566 node = node.sibling;
9567 }
9568 };
9569
9570 updateHostContainer = function (workInProgress) {
9571 // Noop
9572 };
9573 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
9574 // If we have an alternate, that means this is an update and we need to
9575 // schedule a side-effect to do the updates.
9576 var oldProps = current.memoizedProps;
9577 if (oldProps === newProps) {
9578 // In mutation mode, this is sufficient for a bailout because
9579 // we won't touch this node even if children changed.
9580 return;
9581 }
9582
9583 // If we get updated because one of our children updated, we don't
9584 // have newProps so we'll have to reuse them.
9585 // TODO: Split the update API as separate for the props vs. children.
9586 // Even better would be if children weren't special cased at all tho.
9587 var instance = workInProgress.stateNode;
9588 var currentHostContext = getHostContext();
9589 // TODO: Experiencing an error where oldProps is null. Suggests a host
9590 // component is hitting the resume path. Figure out why. Possibly
9591 // related to `hidden`.
9592 var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
9593 // TODO: Type this specific to this type of component.
9594 workInProgress.updateQueue = updatePayload;
9595 // If the update payload indicates that there is a change or if there
9596 // is a new ref we mark this as an update. All the work is done in commitWork.
9597 if (updatePayload) {
9598 markUpdate(workInProgress);
9599 }
9600 };
9601 updateHostText$1 = function (current, workInProgress, oldText, newText) {
9602 // If the text differs, mark it as an update. All the work in done in commitWork.
9603 if (oldText !== newText) {
9604 markUpdate(workInProgress);
9605 }
9606 };
9607} else if (supportsPersistence) {
9608 // Persistent host tree mode
9609
9610 appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
9611 // We only have the top Fiber that was created but we need recurse down its
9612 // children to find all the terminal nodes.
9613 var node = workInProgress.child;
9614 while (node !== null) {
9615 // eslint-disable-next-line no-labels
9616 branches: if (node.tag === HostComponent) {
9617 var instance = node.stateNode;
9618 if (needsVisibilityToggle && isHidden) {
9619 // This child is inside a timed out tree. Hide it.
9620 var props = node.memoizedProps;
9621 var type = node.type;
9622 instance = cloneHiddenInstance(instance, type, props, node);
9623 }
9624 appendInitialChild(parent, instance);
9625 } else if (node.tag === HostText) {
9626 var _instance = node.stateNode;
9627 if (needsVisibilityToggle && isHidden) {
9628 // This child is inside a timed out tree. Hide it.
9629 var text = node.memoizedProps;
9630 _instance = cloneHiddenTextInstance(_instance, text, node);
9631 }
9632 appendInitialChild(parent, _instance);
9633 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
9634 var _instance2 = node.stateNode.instance;
9635 if (needsVisibilityToggle && isHidden) {
9636 // This child is inside a timed out tree. Hide it.
9637 var _props = node.memoizedProps;
9638 var _type = node.type;
9639 _instance2 = cloneHiddenInstance(_instance2, _type, _props, node);
9640 }
9641 appendInitialChild(parent, _instance2);
9642 } else if (node.tag === HostPortal) {
9643 // If we have a portal child, then we don't want to traverse
9644 // down its children. Instead, we'll get insertions from each child in
9645 // the portal directly.
9646 } else if (node.tag === SuspenseComponent) {
9647 if ((node.effectTag & Update) !== NoEffect) {
9648 // Need to toggle the visibility of the primary children.
9649 var newIsHidden = node.memoizedState !== null;
9650 if (newIsHidden) {
9651 var primaryChildParent = node.child;
9652 if (primaryChildParent !== null) {
9653 if (primaryChildParent.child !== null) {
9654 primaryChildParent.child.return = primaryChildParent;
9655 appendAllChildren(parent, primaryChildParent, true, newIsHidden);
9656 }
9657 var fallbackChildParent = primaryChildParent.sibling;
9658 if (fallbackChildParent !== null) {
9659 fallbackChildParent.return = node;
9660 node = fallbackChildParent;
9661 continue;
9662 }
9663 }
9664 }
9665 }
9666 if (node.child !== null) {
9667 // Continue traversing like normal
9668 node.child.return = node;
9669 node = node.child;
9670 continue;
9671 }
9672 } else if (node.child !== null) {
9673 node.child.return = node;
9674 node = node.child;
9675 continue;
9676 }
9677 // $FlowFixMe This is correct but Flow is confused by the labeled break.
9678 node = node;
9679 if (node === workInProgress) {
9680 return;
9681 }
9682 while (node.sibling === null) {
9683 if (node.return === null || node.return === workInProgress) {
9684 return;
9685 }
9686 node = node.return;
9687 }
9688 node.sibling.return = node.return;
9689 node = node.sibling;
9690 }
9691 };
9692
9693 // An unfortunate fork of appendAllChildren because we have two different parent types.
9694 var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
9695 // We only have the top Fiber that was created but we need recurse down its
9696 // children to find all the terminal nodes.
9697 var node = workInProgress.child;
9698 while (node !== null) {
9699 // eslint-disable-next-line no-labels
9700 branches: if (node.tag === HostComponent) {
9701 var instance = node.stateNode;
9702 if (needsVisibilityToggle && isHidden) {
9703 // This child is inside a timed out tree. Hide it.
9704 var props = node.memoizedProps;
9705 var type = node.type;
9706 instance = cloneHiddenInstance(instance, type, props, node);
9707 }
9708 appendChildToContainerChildSet(containerChildSet, instance);
9709 } else if (node.tag === HostText) {
9710 var _instance3 = node.stateNode;
9711 if (needsVisibilityToggle && isHidden) {
9712 // This child is inside a timed out tree. Hide it.
9713 var text = node.memoizedProps;
9714 _instance3 = cloneHiddenTextInstance(_instance3, text, node);
9715 }
9716 appendChildToContainerChildSet(containerChildSet, _instance3);
9717 } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
9718 var _instance4 = node.stateNode.instance;
9719 if (needsVisibilityToggle && isHidden) {
9720 // This child is inside a timed out tree. Hide it.
9721 var _props2 = node.memoizedProps;
9722 var _type2 = node.type;
9723 _instance4 = cloneHiddenInstance(_instance4, _type2, _props2, node);
9724 }
9725 appendChildToContainerChildSet(containerChildSet, _instance4);
9726 } else if (node.tag === HostPortal) {
9727 // If we have a portal child, then we don't want to traverse
9728 // down its children. Instead, we'll get insertions from each child in
9729 // the portal directly.
9730 } else if (node.tag === SuspenseComponent) {
9731 if ((node.effectTag & Update) !== NoEffect) {
9732 // Need to toggle the visibility of the primary children.
9733 var newIsHidden = node.memoizedState !== null;
9734 if (newIsHidden) {
9735 var primaryChildParent = node.child;
9736 if (primaryChildParent !== null) {
9737 if (primaryChildParent.child !== null) {
9738 primaryChildParent.child.return = primaryChildParent;
9739 appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
9740 }
9741 var fallbackChildParent = primaryChildParent.sibling;
9742 if (fallbackChildParent !== null) {
9743 fallbackChildParent.return = node;
9744 node = fallbackChildParent;
9745 continue;
9746 }
9747 }
9748 }
9749 }
9750 if (node.child !== null) {
9751 // Continue traversing like normal
9752 node.child.return = node;
9753 node = node.child;
9754 continue;
9755 }
9756 } else if (node.child !== null) {
9757 node.child.return = node;
9758 node = node.child;
9759 continue;
9760 }
9761 // $FlowFixMe This is correct but Flow is confused by the labeled break.
9762 node = node;
9763 if (node === workInProgress) {
9764 return;
9765 }
9766 while (node.sibling === null) {
9767 if (node.return === null || node.return === workInProgress) {
9768 return;
9769 }
9770 node = node.return;
9771 }
9772 node.sibling.return = node.return;
9773 node = node.sibling;
9774 }
9775 };
9776 updateHostContainer = function (workInProgress) {
9777 var portalOrRoot = workInProgress.stateNode;
9778 var childrenUnchanged = workInProgress.firstEffect === null;
9779 if (childrenUnchanged) {
9780 // No changes, just reuse the existing instance.
9781 } else {
9782 var container = portalOrRoot.containerInfo;
9783 var newChildSet = createContainerChildSet(container);
9784 // If children might have changed, we have to add them all to the set.
9785 appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
9786 portalOrRoot.pendingChildren = newChildSet;
9787 // Schedule an update on the container to swap out the container.
9788 markUpdate(workInProgress);
9789 finalizeContainerChildren(container, newChildSet);
9790 }
9791 };
9792 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
9793 var currentInstance = current.stateNode;
9794 var oldProps = current.memoizedProps;
9795 // If there are no effects associated with this node, then none of our children had any updates.
9796 // This guarantees that we can reuse all of them.
9797 var childrenUnchanged = workInProgress.firstEffect === null;
9798 if (childrenUnchanged && oldProps === newProps) {
9799 // No changes, just reuse the existing instance.
9800 // Note that this might release a previous clone.
9801 workInProgress.stateNode = currentInstance;
9802 return;
9803 }
9804 var recyclableInstance = workInProgress.stateNode;
9805 var currentHostContext = getHostContext();
9806 var updatePayload = null;
9807 if (oldProps !== newProps) {
9808 updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
9809 }
9810 if (childrenUnchanged && updatePayload === null) {
9811 // No changes, just reuse the existing instance.
9812 // Note that this might release a previous clone.
9813 workInProgress.stateNode = currentInstance;
9814 return;
9815 }
9816 var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
9817 if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
9818 markUpdate(workInProgress);
9819 }
9820 workInProgress.stateNode = newInstance;
9821 if (childrenUnchanged) {
9822 // If there are no other effects in this tree, we need to flag this node as having one.
9823 // Even though we're not going to use it for anything.
9824 // Otherwise parents won't know that there are new children to propagate upwards.
9825 markUpdate(workInProgress);
9826 } else {
9827 // If children might have changed, we have to add them all to the set.
9828 appendAllChildren(newInstance, workInProgress, false, false);
9829 }
9830 };
9831 updateHostText$1 = function (current, workInProgress, oldText, newText) {
9832 if (oldText !== newText) {
9833 // If the text content differs, we'll create a new text instance for it.
9834 var rootContainerInstance = getRootHostContainer();
9835 var currentHostContext = getHostContext();
9836 workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress);
9837 // We'll have to mark it as having an effect, even though we won't use the effect for anything.
9838 // This lets the parents know that at least one of their children has changed.
9839 markUpdate(workInProgress);
9840 }
9841 };
9842} else {
9843 // No host operations
9844 updateHostContainer = function (workInProgress) {
9845 // Noop
9846 };
9847 updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
9848 // Noop
9849 };
9850 updateHostText$1 = function (current, workInProgress, oldText, newText) {
9851 // Noop
9852 };
9853}
9854
9855function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
9856 switch (renderState.tailMode) {
9857 case 'hidden':
9858 {
9859 // Any insertions at the end of the tail list after this point
9860 // should be invisible. If there are already mounted boundaries
9861 // anything before them are not considered for collapsing.
9862 // Therefore we need to go through the whole tail to find if
9863 // there are any.
9864 var tailNode = renderState.tail;
9865 var lastTailNode = null;
9866 while (tailNode !== null) {
9867 if (tailNode.alternate !== null) {
9868 lastTailNode = tailNode;
9869 }
9870 tailNode = tailNode.sibling;
9871 }
9872 // Next we're simply going to delete all insertions after the
9873 // last rendered item.
9874 if (lastTailNode === null) {
9875 // All remaining items in the tail are insertions.
9876 renderState.tail = null;
9877 } else {
9878 // Detach the insertion after the last node that was already
9879 // inserted.
9880 lastTailNode.sibling = null;
9881 }
9882 break;
9883 }
9884 case 'collapsed':
9885 {
9886 // Any insertions at the end of the tail list after this point
9887 // should be invisible. If there are already mounted boundaries
9888 // anything before them are not considered for collapsing.
9889 // Therefore we need to go through the whole tail to find if
9890 // there are any.
9891 var _tailNode = renderState.tail;
9892 var _lastTailNode = null;
9893 while (_tailNode !== null) {
9894 if (_tailNode.alternate !== null) {
9895 _lastTailNode = _tailNode;
9896 }
9897 _tailNode = _tailNode.sibling;
9898 }
9899 // Next we're simply going to delete all insertions after the
9900 // last rendered item.
9901 if (_lastTailNode === null) {
9902 // All remaining items in the tail are insertions.
9903 if (!hasRenderedATailFallback && renderState.tail !== null) {
9904 // We suspended during the head. We want to show at least one
9905 // row at the tail. So we'll keep on and cut off the rest.
9906 renderState.tail.sibling = null;
9907 } else {
9908 renderState.tail = null;
9909 }
9910 } else {
9911 // Detach the insertion after the last node that was already
9912 // inserted.
9913 _lastTailNode.sibling = null;
9914 }
9915 break;
9916 }
9917 }
9918}
9919
9920function completeWork(current, workInProgress, renderExpirationTime) {
9921 var newProps = workInProgress.pendingProps;
9922
9923 switch (workInProgress.tag) {
9924 case IndeterminateComponent:
9925 break;
9926 case LazyComponent:
9927 break;
9928 case SimpleMemoComponent:
9929 case FunctionComponent:
9930 break;
9931 case ClassComponent:
9932 {
9933 var Component = workInProgress.type;
9934 if (isContextProvider(Component)) {
9935 popContext(workInProgress);
9936 }
9937 break;
9938 }
9939 case HostRoot:
9940 {
9941 popHostContainer(workInProgress);
9942 popTopLevelContextObject(workInProgress);
9943 var fiberRoot = workInProgress.stateNode;
9944 if (fiberRoot.pendingContext) {
9945 fiberRoot.context = fiberRoot.pendingContext;
9946 fiberRoot.pendingContext = null;
9947 }
9948 if (current === null || current.child === null) {
9949 // If we hydrated, pop so that we can delete any remaining children
9950 // that weren't hydrated.
9951 popHydrationState(workInProgress);
9952 // This resets the hacky state to fix isMounted before committing.
9953 // TODO: Delete this when we delete isMounted and findDOMNode.
9954 workInProgress.effectTag &= ~Placement;
9955 }
9956 updateHostContainer(workInProgress);
9957 break;
9958 }
9959 case HostComponent:
9960 {
9961 popHostContext(workInProgress);
9962 var rootContainerInstance = getRootHostContainer();
9963 var type = workInProgress.type;
9964 if (current !== null && workInProgress.stateNode != null) {
9965 updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
9966
9967 if (enableFlareAPI) {
9968 var prevListeners = current.memoizedProps.listeners;
9969 var nextListeners = newProps.listeners;
9970 var instance = workInProgress.stateNode;
9971 if (prevListeners !== nextListeners) {
9972 updateEventListeners(nextListeners, instance, rootContainerInstance, workInProgress);
9973 }
9974 }
9975
9976 if (current.ref !== workInProgress.ref) {
9977 markRef$1(workInProgress);
9978 }
9979 } else {
9980 if (!newProps) {
9981 (function () {
9982 if (!(workInProgress.stateNode !== null)) {
9983 {
9984 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.'));
9985 }
9986 }
9987 })();
9988 // This can happen when we abort work.
9989 break;
9990 }
9991
9992 var currentHostContext = getHostContext();
9993 // TODO: Move createInstance to beginWork and keep it on a context
9994 // "stack" as the parent. Then append children as we go in beginWork
9995 // or completeWork depending on we want to add then top->down or
9996 // bottom->up. Top->down is faster in IE11.
9997 var wasHydrated = popHydrationState(workInProgress);
9998 if (wasHydrated) {
9999 // TODO: Move this and createInstance step into the beginPhase
10000 // to consolidate.
10001 if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
10002 // If changes to the hydrated node needs to be applied at the
10003 // commit-phase we mark this as such.
10004 markUpdate(workInProgress);
10005 }
10006 } else {
10007 var _instance5 = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
10008
10009 appendAllChildren(_instance5, workInProgress, false, false);
10010
10011 if (enableFlareAPI) {
10012 var listeners = newProps.listeners;
10013 if (listeners != null) {
10014 updateEventListeners(listeners, _instance5, rootContainerInstance, workInProgress);
10015 }
10016 }
10017
10018 // Certain renderers require commit-time effects for initial mount.
10019 // (eg DOM renderer supports auto-focus for certain elements).
10020 // Make sure such renderers get scheduled for later work.
10021 if (finalizeInitialChildren(_instance5, type, newProps, rootContainerInstance, currentHostContext)) {
10022 markUpdate(workInProgress);
10023 }
10024 workInProgress.stateNode = _instance5;
10025 }
10026
10027 if (workInProgress.ref !== null) {
10028 // If there is a ref on a host node we need to schedule a callback
10029 markRef$1(workInProgress);
10030 }
10031 }
10032 break;
10033 }
10034 case HostText:
10035 {
10036 var newText = newProps;
10037 if (current && workInProgress.stateNode != null) {
10038 var oldText = current.memoizedProps;
10039 // If we have an alternate, that means this is an update and we need
10040 // to schedule a side-effect to do the updates.
10041 updateHostText$1(current, workInProgress, oldText, newText);
10042 } else {
10043 if (typeof newText !== 'string') {
10044 (function () {
10045 if (!(workInProgress.stateNode !== null)) {
10046 {
10047 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.'));
10048 }
10049 }
10050 })();
10051 // This can happen when we abort work.
10052 }
10053 var _rootContainerInstance = getRootHostContainer();
10054 var _currentHostContext = getHostContext();
10055 var _wasHydrated = popHydrationState(workInProgress);
10056 if (_wasHydrated) {
10057 if (prepareToHydrateHostTextInstance(workInProgress)) {
10058 markUpdate(workInProgress);
10059 }
10060 } else {
10061 workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
10062 }
10063 }
10064 break;
10065 }
10066 case ForwardRef:
10067 break;
10068 case SuspenseComponent:
10069 {
10070 popSuspenseContext(workInProgress);
10071 var nextState = workInProgress.memoizedState;
10072 if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
10073 // Something suspended. Re-render with the fallback children.
10074 workInProgress.expirationTime = renderExpirationTime;
10075 // Do not reset the effect list.
10076 return workInProgress;
10077 }
10078
10079 var nextDidTimeout = nextState !== null;
10080 var prevDidTimeout = false;
10081 if (current === null) {
10082 // In cases where we didn't find a suitable hydration boundary we never
10083 // downgraded this to a DehydratedSuspenseComponent, but we still need to
10084 // pop the hydration state since we might be inside the insertion tree.
10085 popHydrationState(workInProgress);
10086 } else {
10087 var prevState = current.memoizedState;
10088 prevDidTimeout = prevState !== null;
10089 if (!nextDidTimeout && prevState !== null) {
10090 // We just switched from the fallback to the normal children.
10091 // Delete the fallback.
10092 // TODO: Would it be better to store the fallback fragment on
10093 var currentFallbackChild = current.child.sibling;
10094 if (currentFallbackChild !== null) {
10095 // Deletions go at the beginning of the return fiber's effect list
10096 var first = workInProgress.firstEffect;
10097 if (first !== null) {
10098 workInProgress.firstEffect = currentFallbackChild;
10099 currentFallbackChild.nextEffect = first;
10100 } else {
10101 workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
10102 currentFallbackChild.nextEffect = null;
10103 }
10104 currentFallbackChild.effectTag = Deletion;
10105 }
10106 }
10107 }
10108
10109 if (nextDidTimeout && !prevDidTimeout) {
10110 // If this subtreee is running in batched mode we can suspend,
10111 // otherwise we won't suspend.
10112 // TODO: This will still suspend a synchronous tree if anything
10113 // in the concurrent tree already suspended during this render.
10114 // This is a known bug.
10115 if ((workInProgress.mode & BatchedMode) !== NoMode) {
10116 // TODO: Move this back to throwException because this is too late
10117 // if this is a large tree which is common for initial loads. We
10118 // don't know if we should restart a render or not until we get
10119 // this marker, and this is too late.
10120 // If this render already had a ping or lower pri updates,
10121 // and this is the first time we know we're going to suspend we
10122 // should be able to immediately restart from within throwException.
10123 var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
10124 if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
10125 // If this was in an invisible tree or a new render, then showing
10126 // this boundary is ok.
10127 renderDidSuspend();
10128 } else {
10129 // Otherwise, we're going to have to hide content so we should
10130 // suspend for longer if possible.
10131 renderDidSuspendDelayIfPossible();
10132 }
10133 }
10134 }
10135
10136 if (supportsPersistence) {
10137 // TODO: Only schedule updates if not prevDidTimeout.
10138 if (nextDidTimeout) {
10139 // If this boundary just timed out, schedule an effect to attach a
10140 // retry listener to the proimse. This flag is also used to hide the
10141 // primary children.
10142 workInProgress.effectTag |= Update;
10143 }
10144 }
10145 if (supportsMutation) {
10146 // TODO: Only schedule updates if these values are non equal, i.e. it changed.
10147 if (nextDidTimeout || prevDidTimeout) {
10148 // If this boundary just timed out, schedule an effect to attach a
10149 // retry listener to the proimse. This flag is also used to hide the
10150 // primary children. In mutation mode, we also need the flag to
10151 // *unhide* children that were previously hidden, so check if the
10152 // is currently timed out, too.
10153 workInProgress.effectTag |= Update;
10154 }
10155 }
10156 if (enableSuspenseCallback && workInProgress.updateQueue !== null && workInProgress.memoizedProps.suspenseCallback != null) {
10157 // Always notify the callback
10158 workInProgress.effectTag |= Update;
10159 }
10160 break;
10161 }
10162 case Fragment:
10163 break;
10164 case Mode$1:
10165 break;
10166 case Profiler:
10167 break;
10168 case HostPortal:
10169 popHostContainer(workInProgress);
10170 updateHostContainer(workInProgress);
10171 break;
10172 case ContextProvider:
10173 // Pop provider fiber
10174 popProvider(workInProgress);
10175 break;
10176 case ContextConsumer:
10177 break;
10178 case MemoComponent:
10179 break;
10180 case IncompleteClassComponent:
10181 {
10182 // Same as class component case. I put it down here so that the tags are
10183 // sequential to ensure this switch is compiled to a jump table.
10184 var _Component = workInProgress.type;
10185 if (isContextProvider(_Component)) {
10186 popContext(workInProgress);
10187 }
10188 break;
10189 }
10190 case DehydratedSuspenseComponent:
10191 {
10192 if (enableSuspenseServerRenderer) {
10193 popSuspenseContext(workInProgress);
10194 if (current === null) {
10195 var _wasHydrated2 = popHydrationState(workInProgress);
10196 (function () {
10197 if (!_wasHydrated2) {
10198 {
10199 throw ReactError(Error('A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.'));
10200 }
10201 }
10202 })();
10203 if (enableSchedulerTracing) {
10204 markSpawnedWork(Never);
10205 }
10206 skipPastDehydratedSuspenseInstance(workInProgress);
10207 } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
10208 // This boundary did not suspend so it's now hydrated.
10209 // To handle any future suspense cases, we're going to now upgrade it
10210 // to a Suspense component. We detach it from the existing current fiber.
10211 current.alternate = null;
10212 workInProgress.alternate = null;
10213 workInProgress.tag = SuspenseComponent;
10214 workInProgress.memoizedState = null;
10215 workInProgress.stateNode = null;
10216 }
10217 }
10218 break;
10219 }
10220 case SuspenseListComponent:
10221 {
10222 popSuspenseContext(workInProgress);
10223
10224 var renderState = workInProgress.memoizedState;
10225
10226 if (renderState === null) {
10227 // We're running in the default, "independent" mode. We don't do anything
10228 // in this mode.
10229 break;
10230 }
10231
10232 var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
10233
10234 var renderedTail = renderState.rendering;
10235 if (renderedTail === null) {
10236 // We just rendered the head.
10237 if (!didSuspendAlready) {
10238 // This is the first pass. We need to figure out if anything is still
10239 // suspended in the rendered set.
10240
10241 // If new content unsuspended, but there's still some content that
10242 // didn't. Then we need to do a second pass that forces everything
10243 // to keep showing their fallbacks.
10244
10245 // We might be suspended if something in this render pass suspended, or
10246 // something in the previous committed pass suspended. Otherwise,
10247 // there's no chance so we can skip the expensive call to
10248 // findFirstSuspended.
10249 var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
10250 if (!cannotBeSuspended) {
10251 var row = workInProgress.child;
10252 while (row !== null) {
10253 var suspended = findFirstSuspended(row);
10254 if (suspended !== null) {
10255 didSuspendAlready = true;
10256 workInProgress.effectTag |= DidCapture;
10257 cutOffTailIfNeeded(renderState, false);
10258
10259 // If this is a newly suspended tree, it might not get committed as
10260 // part of the second pass. In that case nothing will subscribe to
10261 // its thennables. Instead, we'll transfer its thennables to the
10262 // SuspenseList so that it can retry if they resolve.
10263 // There might be multiple of these in the list but since we're
10264 // going to wait for all of them anyway, it doesn't really matter
10265 // which ones gets to ping. In theory we could get clever and keep
10266 // track of how many dependencies remain but it gets tricky because
10267 // in the meantime, we can add/remove/change items and dependencies.
10268 // We might bail out of the loop before finding any but that
10269 // doesn't matter since that means that the other boundaries that
10270 // we did find already has their listeners attached.
10271 var newThennables = suspended.updateQueue;
10272 if (newThennables !== null) {
10273 workInProgress.updateQueue = newThennables;
10274 workInProgress.effectTag |= Update;
10275 }
10276
10277 // Rerender the whole list, but this time, we'll force fallbacks
10278 // to stay in place.
10279 // Reset the effect list before doing the second pass since that's now invalid.
10280 workInProgress.firstEffect = workInProgress.lastEffect = null;
10281 // Reset the child fibers to their original state.
10282 resetChildFibers(workInProgress, renderExpirationTime);
10283
10284 // Set up the Suspense Context to force suspense and immediately
10285 // rerender the children.
10286 pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
10287 return workInProgress.child;
10288 }
10289 row = row.sibling;
10290 }
10291 }
10292 } else {
10293 cutOffTailIfNeeded(renderState, false);
10294 }
10295 // Next we're going to render the tail.
10296 } else {
10297 // Append the rendered row to the child list.
10298 if (!didSuspendAlready) {
10299 var _suspended = findFirstSuspended(renderedTail);
10300 if (_suspended !== null) {
10301 workInProgress.effectTag |= DidCapture;
10302 didSuspendAlready = true;
10303 cutOffTailIfNeeded(renderState, true);
10304 // This might have been modified.
10305 if (renderState.tail === null && renderState.tailMode === 'hidden') {
10306 // We need to delete the row we just rendered.
10307 // Ensure we transfer the update queue to the parent.
10308 var _newThennables = _suspended.updateQueue;
10309 if (_newThennables !== null) {
10310 workInProgress.updateQueue = _newThennables;
10311 workInProgress.effectTag |= Update;
10312 }
10313 // Reset the effect list to what it w as before we rendered this
10314 // child. The nested children have already appended themselves.
10315 var lastEffect = workInProgress.lastEffect = renderState.lastEffect;
10316 // Remove any effects that were appended after this point.
10317 if (lastEffect !== null) {
10318 lastEffect.nextEffect = null;
10319 }
10320 // We're done.
10321 return null;
10322 }
10323 } else if (now() > renderState.tailExpiration && renderExpirationTime > Never) {
10324 // We have now passed our CPU deadline and we'll just give up further
10325 // attempts to render the main content and only render fallbacks.
10326 // The assumption is that this is usually faster.
10327 workInProgress.effectTag |= DidCapture;
10328 didSuspendAlready = true;
10329
10330 cutOffTailIfNeeded(renderState, false);
10331
10332 // Since nothing actually suspended, there will nothing to ping this
10333 // to get it started back up to attempt the next item. If we can show
10334 // them, then they really have the same priority as this render.
10335 // So we'll pick it back up the very next render pass once we've had
10336 // an opportunity to yield for paint.
10337
10338 var nextPriority = renderExpirationTime - 1;
10339 workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
10340 if (enableSchedulerTracing) {
10341 markSpawnedWork(nextPriority);
10342 }
10343 }
10344 }
10345 if (renderState.isBackwards) {
10346 // The effect list of the backwards tail will have been added
10347 // to the end. This breaks the guarantee that life-cycles fire in
10348 // sibling order but that isn't a strong guarantee promised by React.
10349 // Especially since these might also just pop in during future commits.
10350 // Append to the beginning of the list.
10351 renderedTail.sibling = workInProgress.child;
10352 workInProgress.child = renderedTail;
10353 } else {
10354 var previousSibling = renderState.last;
10355 if (previousSibling !== null) {
10356 previousSibling.sibling = renderedTail;
10357 } else {
10358 workInProgress.child = renderedTail;
10359 }
10360 renderState.last = renderedTail;
10361 }
10362 }
10363
10364 if (renderState.tail !== null) {
10365 // We still have tail rows to render.
10366 if (renderState.tailExpiration === 0) {
10367 // Heuristic for how long we're willing to spend rendering rows
10368 // until we just give up and show what we have so far.
10369 var TAIL_EXPIRATION_TIMEOUT_MS = 500;
10370 renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS;
10371 }
10372 // Pop a row.
10373 var next = renderState.tail;
10374 renderState.rendering = next;
10375 renderState.tail = next.sibling;
10376 renderState.lastEffect = workInProgress.lastEffect;
10377 next.sibling = null;
10378
10379 // Restore the context.
10380 // TODO: We can probably just avoid popping it instead and only
10381 // setting it the first time we go from not suspended to suspended.
10382 var suspenseContext = suspenseStackCursor.current;
10383 if (didSuspendAlready) {
10384 suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
10385 } else {
10386 suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
10387 }
10388 pushSuspenseContext(workInProgress, suspenseContext);
10389 // Do a pass over the next row.
10390 return next;
10391 }
10392 break;
10393 }
10394 case FundamentalComponent:
10395 {
10396 if (enableFundamentalAPI) {
10397 var fundamentalImpl = workInProgress.type.impl;
10398 var fundamentalInstance = workInProgress.stateNode;
10399
10400 if (fundamentalInstance === null) {
10401 var getInitialState = fundamentalImpl.getInitialState;
10402 var fundamentalState = void 0;
10403 if (getInitialState !== undefined) {
10404 fundamentalState = getInitialState(newProps);
10405 }
10406 fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance(workInProgress, newProps, fundamentalImpl, fundamentalState || {});
10407 var _instance6 = getFundamentalComponentInstance(fundamentalInstance);
10408 fundamentalInstance.instance = _instance6;
10409 if (fundamentalImpl.reconcileChildren === false) {
10410 return null;
10411 }
10412 appendAllChildren(_instance6, workInProgress, false, false);
10413 mountFundamentalComponent(fundamentalInstance);
10414 } else {
10415 // We fire update in commit phase
10416 var prevProps = fundamentalInstance.props;
10417 fundamentalInstance.prevProps = prevProps;
10418 fundamentalInstance.props = newProps;
10419 fundamentalInstance.currentFiber = workInProgress;
10420 if (supportsPersistence) {
10421 var _instance7 = cloneFundamentalInstance(fundamentalInstance);
10422 fundamentalInstance.instance = _instance7;
10423 appendAllChildren(_instance7, workInProgress, false, false);
10424 }
10425 var shouldUpdate = shouldUpdateFundamentalComponent(fundamentalInstance);
10426 if (shouldUpdate) {
10427 markUpdate(workInProgress);
10428 }
10429 }
10430 }
10431 break;
10432 }
10433 default:
10434 (function () {
10435 {
10436 {
10437 throw ReactError(Error('Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.'));
10438 }
10439 }
10440 })();
10441 }
10442
10443 return null;
10444}
10445
10446function mountEventResponder(responder, responderProps, instance, rootContainerInstance, fiber, respondersMap) {
10447 var responderState = emptyObject;
10448 var getInitialState = responder.getInitialState;
10449 if (getInitialState !== null) {
10450 responderState = getInitialState(responderProps);
10451 }
10452 var responderInstance = createResponderInstance(responder, responderProps, responderState, instance, fiber);
10453 mountResponderInstance(responder, responderInstance, responderProps, responderState, instance, rootContainerInstance);
10454 respondersMap.set(responder, responderInstance);
10455}
10456
10457function updateEventListener(listener, fiber, visistedResponders, respondersMap, instance, rootContainerInstance) {
10458 var responder = void 0;
10459 var props = void 0;
10460
10461 if (listener) {
10462 responder = listener.responder;
10463 props = listener.props;
10464 }
10465 (function () {
10466 if (!(responder && responder.$$typeof === REACT_RESPONDER_TYPE)) {
10467 {
10468 throw ReactError(Error('An invalid value was used as an event listener. Expect one or many event listeners created via React.unstable_useResponer().'));
10469 }
10470 }
10471 })();
10472 var listenerProps = props;
10473 if (visistedResponders.has(responder)) {
10474 // show warning
10475 {
10476 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);
10477 }
10478 return;
10479 }
10480 visistedResponders.add(responder);
10481 var responderInstance = respondersMap.get(responder);
10482
10483 if (responderInstance === undefined) {
10484 // Mount
10485 mountEventResponder(responder, listenerProps, instance, rootContainerInstance, fiber, respondersMap);
10486 } else {
10487 // Update
10488 responderInstance.props = listenerProps;
10489 responderInstance.fiber = fiber;
10490 }
10491}
10492
10493function updateEventListeners(listeners, instance, rootContainerInstance, fiber) {
10494 var visistedResponders = new Set();
10495 var dependencies = fiber.dependencies;
10496 if (listeners != null) {
10497 if (dependencies === null) {
10498 dependencies = fiber.dependencies = {
10499 expirationTime: NoWork,
10500 firstContext: null,
10501 responders: new Map()
10502 };
10503 }
10504 var respondersMap = dependencies.responders;
10505 if (respondersMap === null) {
10506 respondersMap = new Map();
10507 }
10508 if (isArray$2(listeners)) {
10509 for (var i = 0, length = listeners.length; i < length; i++) {
10510 var listener = listeners[i];
10511 updateEventListener(listener, fiber, visistedResponders, respondersMap, instance, rootContainerInstance);
10512 }
10513 } else {
10514 updateEventListener(listeners, fiber, visistedResponders, respondersMap, instance, rootContainerInstance);
10515 }
10516 }
10517 if (dependencies !== null) {
10518 var _respondersMap = dependencies.responders;
10519 if (_respondersMap !== null) {
10520 // Unmount
10521 var mountedResponders = Array.from(_respondersMap.keys());
10522 for (var _i = 0, _length = mountedResponders.length; _i < _length; _i++) {
10523 var mountedResponder = mountedResponders[_i];
10524 if (!visistedResponders.has(mountedResponder)) {
10525 var responderInstance = _respondersMap.get(mountedResponder);
10526 unmountResponderInstance(responderInstance);
10527 _respondersMap.delete(mountedResponder);
10528 }
10529 }
10530 }
10531 }
10532}
10533
10534function unwindWork(workInProgress, renderExpirationTime) {
10535 switch (workInProgress.tag) {
10536 case ClassComponent:
10537 {
10538 var Component = workInProgress.type;
10539 if (isContextProvider(Component)) {
10540 popContext(workInProgress);
10541 }
10542 var effectTag = workInProgress.effectTag;
10543 if (effectTag & ShouldCapture) {
10544 workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
10545 return workInProgress;
10546 }
10547 return null;
10548 }
10549 case HostRoot:
10550 {
10551 popHostContainer(workInProgress);
10552 popTopLevelContextObject(workInProgress);
10553 var _effectTag = workInProgress.effectTag;
10554 (function () {
10555 if (!((_effectTag & DidCapture) === NoEffect)) {
10556 {
10557 throw ReactError(Error('The root failed to unmount after an error. This is likely a bug in React. Please file an issue.'));
10558 }
10559 }
10560 })();
10561 workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
10562 return workInProgress;
10563 }
10564 case HostComponent:
10565 {
10566 // TODO: popHydrationState
10567 popHostContext(workInProgress);
10568 return null;
10569 }
10570 case SuspenseComponent:
10571 {
10572 popSuspenseContext(workInProgress);
10573 var _effectTag2 = workInProgress.effectTag;
10574 if (_effectTag2 & ShouldCapture) {
10575 workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
10576 // Captured a suspense effect. Re-render the boundary.
10577 return workInProgress;
10578 }
10579 return null;
10580 }
10581 case DehydratedSuspenseComponent:
10582 {
10583 if (enableSuspenseServerRenderer) {
10584 // TODO: popHydrationState
10585 popSuspenseContext(workInProgress);
10586 var _effectTag3 = workInProgress.effectTag;
10587 if (_effectTag3 & ShouldCapture) {
10588 workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
10589 // Captured a suspense effect. Re-render the boundary.
10590 return workInProgress;
10591 }
10592 }
10593 return null;
10594 }
10595 case SuspenseListComponent:
10596 {
10597 popSuspenseContext(workInProgress);
10598 // SuspenseList doesn't actually catch anything. It should've been
10599 // caught by a nested boundary. If not, it should bubble through.
10600 return null;
10601 }
10602 case HostPortal:
10603 popHostContainer(workInProgress);
10604 return null;
10605 case ContextProvider:
10606 popProvider(workInProgress);
10607 return null;
10608 default:
10609 return null;
10610 }
10611}
10612
10613function unwindInterruptedWork(interruptedWork) {
10614 switch (interruptedWork.tag) {
10615 case ClassComponent:
10616 {
10617 var childContextTypes = interruptedWork.type.childContextTypes;
10618 if (childContextTypes !== null && childContextTypes !== undefined) {
10619 popContext(interruptedWork);
10620 }
10621 break;
10622 }
10623 case HostRoot:
10624 {
10625 popHostContainer(interruptedWork);
10626 popTopLevelContextObject(interruptedWork);
10627 break;
10628 }
10629 case HostComponent:
10630 {
10631 popHostContext(interruptedWork);
10632 break;
10633 }
10634 case HostPortal:
10635 popHostContainer(interruptedWork);
10636 break;
10637 case SuspenseComponent:
10638 popSuspenseContext(interruptedWork);
10639 break;
10640 case DehydratedSuspenseComponent:
10641 if (enableSuspenseServerRenderer) {
10642 // TODO: popHydrationState
10643 popSuspenseContext(interruptedWork);
10644 }
10645 break;
10646 case SuspenseListComponent:
10647 popSuspenseContext(interruptedWork);
10648 break;
10649 case ContextProvider:
10650 popProvider(interruptedWork);
10651 break;
10652 default:
10653 break;
10654 }
10655}
10656
10657function createCapturedValue(value, source) {
10658 // If the value is an error, call this function immediately after it is thrown
10659 // so the stack is accurate.
10660 return {
10661 value: value,
10662 source: source,
10663 stack: getStackByFiberInDevAndProd(source)
10664 };
10665}
10666
10667var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
10668 var funcArgs = Array.prototype.slice.call(arguments, 3);
10669 try {
10670 func.apply(context, funcArgs);
10671 } catch (error) {
10672 this.onError(error);
10673 }
10674};
10675
10676{
10677 // In DEV mode, we swap out invokeGuardedCallback for a special version
10678 // that plays more nicely with the browser's DevTools. The idea is to preserve
10679 // "Pause on exceptions" behavior. Because React wraps all user-provided
10680 // functions in invokeGuardedCallback, and the production version of
10681 // invokeGuardedCallback uses a try-catch, all user exceptions are treated
10682 // like caught exceptions, and the DevTools won't pause unless the developer
10683 // takes the extra step of enabling pause on caught exceptions. This is
10684 // unintuitive, though, because even though React has caught the error, from
10685 // the developer's perspective, the error is uncaught.
10686 //
10687 // To preserve the expected "Pause on exceptions" behavior, we don't use a
10688 // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
10689 // DOM node, and call the user-provided callback from inside an event handler
10690 // for that fake event. If the callback throws, the error is "captured" using
10691 // a global event handler. But because the error happens in a different
10692 // event loop context, it does not interrupt the normal program flow.
10693 // Effectively, this gives us try-catch behavior without actually using
10694 // try-catch. Neat!
10695
10696 // Check that the browser supports the APIs we need to implement our special
10697 // DEV version of invokeGuardedCallback
10698 if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
10699 var fakeNode = document.createElement('react');
10700
10701 var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
10702 // If document doesn't exist we know for sure we will crash in this method
10703 // when we call document.createEvent(). However this can cause confusing
10704 // errors: https://github.com/facebookincubator/create-react-app/issues/3482
10705 // So we preemptively throw with a better message instead.
10706 (function () {
10707 if (!(typeof document !== 'undefined')) {
10708 {
10709 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.'));
10710 }
10711 }
10712 })();
10713 var evt = document.createEvent('Event');
10714
10715 // Keeps track of whether the user-provided callback threw an error. We
10716 // set this to true at the beginning, then set it to false right after
10717 // calling the function. If the function errors, `didError` will never be
10718 // set to false. This strategy works even if the browser is flaky and
10719 // fails to call our global error handler, because it doesn't rely on
10720 // the error event at all.
10721 var didError = true;
10722
10723 // Keeps track of the value of window.event so that we can reset it
10724 // during the callback to let user code access window.event in the
10725 // browsers that support it.
10726 var windowEvent = window.event;
10727
10728 // Keeps track of the descriptor of window.event to restore it after event
10729 // dispatching: https://github.com/facebook/react/issues/13688
10730 var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
10731
10732 // Create an event handler for our fake event. We will synchronously
10733 // dispatch our fake event using `dispatchEvent`. Inside the handler, we
10734 // call the user-provided callback.
10735 var funcArgs = Array.prototype.slice.call(arguments, 3);
10736 function callCallback() {
10737 // We immediately remove the callback from event listeners so that
10738 // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
10739 // nested call would trigger the fake event handlers of any call higher
10740 // in the stack.
10741 fakeNode.removeEventListener(evtType, callCallback, false);
10742
10743 // We check for window.hasOwnProperty('event') to prevent the
10744 // window.event assignment in both IE <= 10 as they throw an error
10745 // "Member not found" in strict mode, and in Firefox which does not
10746 // support window.event.
10747 if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
10748 window.event = windowEvent;
10749 }
10750
10751 func.apply(context, funcArgs);
10752 didError = false;
10753 }
10754
10755 // Create a global error event handler. We use this to capture the value
10756 // that was thrown. It's possible that this error handler will fire more
10757 // than once; for example, if non-React code also calls `dispatchEvent`
10758 // and a handler for that event throws. We should be resilient to most of
10759 // those cases. Even if our error event handler fires more than once, the
10760 // last error event is always used. If the callback actually does error,
10761 // we know that the last error event is the correct one, because it's not
10762 // possible for anything else to have happened in between our callback
10763 // erroring and the code that follows the `dispatchEvent` call below. If
10764 // the callback doesn't error, but the error event was fired, we know to
10765 // ignore it because `didError` will be false, as described above.
10766 var error = void 0;
10767 // Use this to track whether the error event is ever called.
10768 var didSetError = false;
10769 var isCrossOriginError = false;
10770
10771 function handleWindowError(event) {
10772 error = event.error;
10773 didSetError = true;
10774 if (error === null && event.colno === 0 && event.lineno === 0) {
10775 isCrossOriginError = true;
10776 }
10777 if (event.defaultPrevented) {
10778 // Some other error handler has prevented default.
10779 // Browsers silence the error report if this happens.
10780 // We'll remember this to later decide whether to log it or not.
10781 if (error != null && typeof error === 'object') {
10782 try {
10783 error._suppressLogging = true;
10784 } catch (inner) {
10785 // Ignore.
10786 }
10787 }
10788 }
10789 }
10790
10791 // Create a fake event type.
10792 var evtType = 'react-' + (name ? name : 'invokeguardedcallback');
10793
10794 // Attach our event handlers
10795 window.addEventListener('error', handleWindowError);
10796 fakeNode.addEventListener(evtType, callCallback, false);
10797
10798 // Synchronously dispatch our fake event. If the user-provided function
10799 // errors, it will trigger our global error handler.
10800 evt.initEvent(evtType, false, false);
10801 fakeNode.dispatchEvent(evt);
10802
10803 if (windowEventDescriptor) {
10804 Object.defineProperty(window, 'event', windowEventDescriptor);
10805 }
10806
10807 if (didError) {
10808 if (!didSetError) {
10809 // The callback errored, but the error event never fired.
10810 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.');
10811 } else if (isCrossOriginError) {
10812 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.');
10813 }
10814 this.onError(error);
10815 }
10816
10817 // Remove our event listeners
10818 window.removeEventListener('error', handleWindowError);
10819 };
10820
10821 invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
10822 }
10823}
10824
10825var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
10826
10827// Used by Fiber to simulate a try-catch.
10828var hasError = false;
10829var caughtError = null;
10830
10831var reporter = {
10832 onError: function (error) {
10833 hasError = true;
10834 caughtError = error;
10835 }
10836};
10837
10838/**
10839 * Call a function while guarding against errors that happens within it.
10840 * Returns an error if it throws, otherwise null.
10841 *
10842 * In production, this is implemented using a try-catch. The reason we don't
10843 * use a try-catch directly is so that we can swap out a different
10844 * implementation in DEV mode.
10845 *
10846 * @param {String} name of the guard to use for logging or debugging
10847 * @param {Function} func The function to invoke
10848 * @param {*} context The context to use when calling the function
10849 * @param {...*} args Arguments for function
10850 */
10851function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
10852 hasError = false;
10853 caughtError = null;
10854 invokeGuardedCallbackImpl$1.apply(reporter, arguments);
10855}
10856
10857/**
10858 * Same as invokeGuardedCallback, but instead of returning an error, it stores
10859 * it in a global so it can be rethrown by `rethrowCaughtError` later.
10860 * TODO: See if caughtError and rethrowError can be unified.
10861 *
10862 * @param {String} name of the guard to use for logging or debugging
10863 * @param {Function} func The function to invoke
10864 * @param {*} context The context to use when calling the function
10865 * @param {...*} args Arguments for function
10866 */
10867
10868
10869/**
10870 * During execution of guarded functions we will capture the first error which
10871 * we will rethrow to be handled by the top level error handler.
10872 */
10873
10874
10875function hasCaughtError() {
10876 return hasError;
10877}
10878
10879function clearCaughtError() {
10880 if (hasError) {
10881 var error = caughtError;
10882 hasError = false;
10883 caughtError = null;
10884 return error;
10885 } else {
10886 (function () {
10887 {
10888 {
10889 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.'));
10890 }
10891 }
10892 })();
10893 }
10894}
10895
10896// This module is forked in different environments.
10897// By default, return `true` to log errors to the console.
10898// Forks can return `false` if this isn't desirable.
10899function showErrorDialog(capturedError) {
10900 return true;
10901}
10902
10903function logCapturedError(capturedError) {
10904 var logError = showErrorDialog(capturedError);
10905
10906 // Allow injected showErrorDialog() to prevent default console.error logging.
10907 // This enables renderers like ReactNative to better manage redbox behavior.
10908 if (logError === false) {
10909 return;
10910 }
10911
10912 var error = capturedError.error;
10913 {
10914 var componentName = capturedError.componentName,
10915 componentStack = capturedError.componentStack,
10916 errorBoundaryName = capturedError.errorBoundaryName,
10917 errorBoundaryFound = capturedError.errorBoundaryFound,
10918 willRetry = capturedError.willRetry;
10919
10920 // Browsers support silencing uncaught errors by calling
10921 // `preventDefault()` in window `error` handler.
10922 // We record this information as an expando on the error.
10923
10924 if (error != null && error._suppressLogging) {
10925 if (errorBoundaryFound && willRetry) {
10926 // The error is recoverable and was silenced.
10927 // Ignore it and don't print the stack addendum.
10928 // This is handy for testing error boundaries without noise.
10929 return;
10930 }
10931 // The error is fatal. Since the silencing might have
10932 // been accidental, we'll surface it anyway.
10933 // However, the browser would have silenced the original error
10934 // so we'll print it first, and then print the stack addendum.
10935 console.error(error);
10936 // For a more detailed description of this block, see:
10937 // https://github.com/facebook/react/pull/13384
10938 }
10939
10940 var componentNameMessage = componentName ? 'The above error occurred in the <' + componentName + '> component:' : 'The above error occurred in one of your React components:';
10941
10942 var errorBoundaryMessage = void 0;
10943 // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
10944 if (errorBoundaryFound && errorBoundaryName) {
10945 if (willRetry) {
10946 errorBoundaryMessage = 'React will try to recreate this component tree from scratch ' + ('using the error boundary you provided, ' + errorBoundaryName + '.');
10947 } else {
10948 errorBoundaryMessage = 'This error was initially handled by the error boundary ' + errorBoundaryName + '.\n' + 'Recreating the tree from scratch failed so React will unmount the tree.';
10949 }
10950 } else {
10951 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.';
10952 }
10953 var combinedMessage = '' + componentNameMessage + componentStack + '\n\n' + ('' + errorBoundaryMessage);
10954
10955 // In development, we provide our own message with just the component stack.
10956 // We don't include the original error message and JS stack because the browser
10957 // has already printed it. Even if the application swallows the error, it is still
10958 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
10959 console.error(combinedMessage);
10960 }
10961}
10962
10963var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
10964{
10965 didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
10966}
10967
10968var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
10969
10970function logError(boundary, errorInfo) {
10971 var source = errorInfo.source;
10972 var stack = errorInfo.stack;
10973 if (stack === null && source !== null) {
10974 stack = getStackByFiberInDevAndProd(source);
10975 }
10976
10977 var capturedError = {
10978 componentName: source !== null ? getComponentName(source.type) : null,
10979 componentStack: stack !== null ? stack : '',
10980 error: errorInfo.value,
10981 errorBoundary: null,
10982 errorBoundaryName: null,
10983 errorBoundaryFound: false,
10984 willRetry: false
10985 };
10986
10987 if (boundary !== null && boundary.tag === ClassComponent) {
10988 capturedError.errorBoundary = boundary.stateNode;
10989 capturedError.errorBoundaryName = getComponentName(boundary.type);
10990 capturedError.errorBoundaryFound = true;
10991 capturedError.willRetry = true;
10992 }
10993
10994 try {
10995 logCapturedError(capturedError);
10996 } catch (e) {
10997 // This method must not throw, or React internal state will get messed up.
10998 // If console.error is overridden, or logCapturedError() shows a dialog that throws,
10999 // we want to report this error outside of the normal stack as a last resort.
11000 // https://github.com/facebook/react/issues/13188
11001 setTimeout(function () {
11002 throw e;
11003 });
11004 }
11005}
11006
11007var callComponentWillUnmountWithTimer = function (current$$1, instance) {
11008 startPhaseTimer(current$$1, 'componentWillUnmount');
11009 instance.props = current$$1.memoizedProps;
11010 instance.state = current$$1.memoizedState;
11011 instance.componentWillUnmount();
11012 stopPhaseTimer();
11013};
11014
11015// Capture errors so they don't interrupt unmounting.
11016function safelyCallComponentWillUnmount(current$$1, instance) {
11017 {
11018 invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
11019 if (hasCaughtError()) {
11020 var unmountError = clearCaughtError();
11021 captureCommitPhaseError(current$$1, unmountError);
11022 }
11023 }
11024}
11025
11026function safelyDetachRef(current$$1) {
11027 var ref = current$$1.ref;
11028 if (ref !== null) {
11029 if (typeof ref === 'function') {
11030 {
11031 invokeGuardedCallback(null, ref, null, null);
11032 if (hasCaughtError()) {
11033 var refError = clearCaughtError();
11034 captureCommitPhaseError(current$$1, refError);
11035 }
11036 }
11037 } else {
11038 ref.current = null;
11039 }
11040 }
11041}
11042
11043function safelyCallDestroy(current$$1, destroy) {
11044 {
11045 invokeGuardedCallback(null, destroy, null);
11046 if (hasCaughtError()) {
11047 var error = clearCaughtError();
11048 captureCommitPhaseError(current$$1, error);
11049 }
11050 }
11051}
11052
11053function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
11054 switch (finishedWork.tag) {
11055 case FunctionComponent:
11056 case ForwardRef:
11057 case SimpleMemoComponent:
11058 {
11059 commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
11060 return;
11061 }
11062 case ClassComponent:
11063 {
11064 if (finishedWork.effectTag & Snapshot) {
11065 if (current$$1 !== null) {
11066 var prevProps = current$$1.memoizedProps;
11067 var prevState = current$$1.memoizedState;
11068 startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
11069 var instance = finishedWork.stateNode;
11070 // We could update instance props and state here,
11071 // but instead we rely on them being set during last render.
11072 // TODO: revisit this when we implement resuming.
11073 {
11074 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11075 !(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;
11076 !(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;
11077 }
11078 }
11079 var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
11080 {
11081 var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
11082 if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
11083 didWarnSet.add(finishedWork.type);
11084 warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
11085 }
11086 }
11087 instance.__reactInternalSnapshotBeforeUpdate = snapshot;
11088 stopPhaseTimer();
11089 }
11090 }
11091 return;
11092 }
11093 case HostRoot:
11094 case HostComponent:
11095 case HostText:
11096 case HostPortal:
11097 case IncompleteClassComponent:
11098 // Nothing to do for these component types
11099 return;
11100 default:
11101 {
11102 (function () {
11103 {
11104 {
11105 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.'));
11106 }
11107 }
11108 })();
11109 }
11110 }
11111}
11112
11113function commitHookEffectList(unmountTag, mountTag, finishedWork) {
11114 var updateQueue = finishedWork.updateQueue;
11115 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
11116 if (lastEffect !== null) {
11117 var firstEffect = lastEffect.next;
11118 var effect = firstEffect;
11119 do {
11120 if ((effect.tag & unmountTag) !== NoEffect$1) {
11121 // Unmount
11122 var destroy = effect.destroy;
11123 effect.destroy = undefined;
11124 if (destroy !== undefined) {
11125 destroy();
11126 }
11127 }
11128 if ((effect.tag & mountTag) !== NoEffect$1) {
11129 // Mount
11130 var create = effect.create;
11131 effect.destroy = create();
11132
11133 {
11134 var _destroy = effect.destroy;
11135 if (_destroy !== undefined && typeof _destroy !== 'function') {
11136 var addendum = void 0;
11137 if (_destroy === null) {
11138 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
11139 } else if (typeof _destroy.then === 'function') {
11140 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';
11141 } else {
11142 addendum = ' You returned: ' + _destroy;
11143 }
11144 warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
11145 }
11146 }
11147 }
11148 effect = effect.next;
11149 } while (effect !== firstEffect);
11150 }
11151}
11152
11153function commitPassiveHookEffects(finishedWork) {
11154 if ((finishedWork.effectTag & Passive) !== NoEffect) {
11155 switch (finishedWork.tag) {
11156 case FunctionComponent:
11157 case ForwardRef:
11158 case SimpleMemoComponent:
11159 {
11160 commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
11161 commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
11162 break;
11163 }
11164 default:
11165 break;
11166 }
11167 }
11168}
11169
11170function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
11171 switch (finishedWork.tag) {
11172 case FunctionComponent:
11173 case ForwardRef:
11174 case SimpleMemoComponent:
11175 {
11176 commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
11177 break;
11178 }
11179 case ClassComponent:
11180 {
11181 var instance = finishedWork.stateNode;
11182 if (finishedWork.effectTag & Update) {
11183 if (current$$1 === null) {
11184 startPhaseTimer(finishedWork, 'componentDidMount');
11185 // We could update instance props and state here,
11186 // but instead we rely on them being set during last render.
11187 // TODO: revisit this when we implement resuming.
11188 {
11189 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11190 !(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;
11191 !(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;
11192 }
11193 }
11194 instance.componentDidMount();
11195 stopPhaseTimer();
11196 } else {
11197 var prevProps = finishedWork.elementType === finishedWork.type ? current$$1.memoizedProps : resolveDefaultProps(finishedWork.type, current$$1.memoizedProps);
11198 var prevState = current$$1.memoizedState;
11199 startPhaseTimer(finishedWork, 'componentDidUpdate');
11200 // We could update instance props and state here,
11201 // but instead we rely on them being set during last render.
11202 // TODO: revisit this when we implement resuming.
11203 {
11204 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11205 !(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;
11206 !(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;
11207 }
11208 }
11209 instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
11210 stopPhaseTimer();
11211 }
11212 }
11213 var updateQueue = finishedWork.updateQueue;
11214 if (updateQueue !== null) {
11215 {
11216 if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
11217 !(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;
11218 !(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;
11219 }
11220 }
11221 // We could update instance props and state here,
11222 // but instead we rely on them being set during last render.
11223 // TODO: revisit this when we implement resuming.
11224 commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
11225 }
11226 return;
11227 }
11228 case HostRoot:
11229 {
11230 var _updateQueue = finishedWork.updateQueue;
11231 if (_updateQueue !== null) {
11232 var _instance = null;
11233 if (finishedWork.child !== null) {
11234 switch (finishedWork.child.tag) {
11235 case HostComponent:
11236 _instance = getPublicInstance(finishedWork.child.stateNode);
11237 break;
11238 case ClassComponent:
11239 _instance = finishedWork.child.stateNode;
11240 break;
11241 }
11242 }
11243 commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
11244 }
11245 return;
11246 }
11247 case HostComponent:
11248 {
11249 var _instance2 = finishedWork.stateNode;
11250
11251 // Renderers may schedule work to be done after host components are mounted
11252 // (eg DOM renderer may schedule auto-focus for inputs and form controls).
11253 // These effects should only be committed when components are first mounted,
11254 // aka when there is no current/alternate.
11255 if (current$$1 === null && finishedWork.effectTag & Update) {
11256 var type = finishedWork.type;
11257 var props = finishedWork.memoizedProps;
11258
11259 }
11260
11261 return;
11262 }
11263 case HostText:
11264 {
11265 // We have no life-cycles associated with text.
11266 return;
11267 }
11268 case HostPortal:
11269 {
11270 // We have no life-cycles associated with portals.
11271 return;
11272 }
11273 case Profiler:
11274 {
11275 if (enableProfilerTimer) {
11276 var onRender = finishedWork.memoizedProps.onRender;
11277
11278 if (typeof onRender === 'function') {
11279 if (enableSchedulerTracing) {
11280 onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
11281 } else {
11282 onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
11283 }
11284 }
11285 }
11286 return;
11287 }
11288 case SuspenseComponent:
11289 case SuspenseListComponent:
11290 case IncompleteClassComponent:
11291 case FundamentalComponent:
11292 return;
11293 default:
11294 {
11295 (function () {
11296 {
11297 {
11298 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.'));
11299 }
11300 }
11301 })();
11302 }
11303 }
11304}
11305
11306function hideOrUnhideAllChildren(finishedWork, isHidden) {
11307 if (supportsMutation) {
11308 // We only have the top Fiber that was inserted but we need to recurse down its
11309 var node = finishedWork;
11310 while (true) {
11311 if (node.tag === HostComponent) {
11312 var instance = node.stateNode;
11313 if (isHidden) {
11314 hideInstance(instance);
11315 } else {
11316 unhideInstance(node.stateNode, node.memoizedProps);
11317 }
11318 } else if (node.tag === HostText) {
11319 var _instance3 = node.stateNode;
11320 if (isHidden) {
11321
11322 } else {
11323 unhideTextInstance(_instance3, node.memoizedProps);
11324 }
11325 } else if (node.tag === SuspenseComponent && node.memoizedState !== null) {
11326 // Found a nested Suspense component that timed out. Skip over the
11327 var fallbackChildFragment = node.child.sibling;
11328 fallbackChildFragment.return = node;
11329 node = fallbackChildFragment;
11330 continue;
11331 } else if (node.child !== null) {
11332 node.child.return = node;
11333 node = node.child;
11334 continue;
11335 }
11336 if (node === finishedWork) {
11337 return;
11338 }
11339 while (node.sibling === null) {
11340 if (node.return === null || node.return === finishedWork) {
11341 return;
11342 }
11343 node = node.return;
11344 }
11345 node.sibling.return = node.return;
11346 node = node.sibling;
11347 }
11348 }
11349}
11350
11351function commitAttachRef(finishedWork) {
11352 var ref = finishedWork.ref;
11353 if (ref !== null) {
11354 var instance = finishedWork.stateNode;
11355 var instanceToUse = void 0;
11356 switch (finishedWork.tag) {
11357 case HostComponent:
11358 instanceToUse = getPublicInstance(instance);
11359 break;
11360 default:
11361 instanceToUse = instance;
11362 }
11363 if (typeof ref === 'function') {
11364 ref(instanceToUse);
11365 } else {
11366 {
11367 if (!ref.hasOwnProperty('current')) {
11368 warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
11369 }
11370 }
11371
11372 ref.current = instanceToUse;
11373 }
11374 }
11375}
11376
11377function commitDetachRef(current$$1) {
11378 var currentRef = current$$1.ref;
11379 if (currentRef !== null) {
11380 if (typeof currentRef === 'function') {
11381 currentRef(null);
11382 } else {
11383 currentRef.current = null;
11384 }
11385 }
11386}
11387
11388// User-originating errors (lifecycles and refs) should not interrupt
11389// deletion, so don't let them throw. Host-originating errors should
11390// interrupt deletion, so it's okay
11391function commitUnmount(current$$1, renderPriorityLevel) {
11392 onCommitUnmount(current$$1);
11393
11394 switch (current$$1.tag) {
11395 case FunctionComponent:
11396 case ForwardRef:
11397 case MemoComponent:
11398 case SimpleMemoComponent:
11399 {
11400 var updateQueue = current$$1.updateQueue;
11401 if (updateQueue !== null) {
11402 var lastEffect = updateQueue.lastEffect;
11403 if (lastEffect !== null) {
11404 var firstEffect = lastEffect.next;
11405
11406 // When the owner fiber is deleted, the destroy function of a passive
11407 // effect hook is called during the synchronous commit phase. This is
11408 // a concession to implementation complexity. Calling it in the
11409 // passive effect phase (like they usually are, when dependencies
11410 // change during an update) would require either traversing the
11411 // children of the deleted fiber again, or including unmount effects
11412 // as part of the fiber effect list.
11413 //
11414 // Because this is during the sync commit phase, we need to change
11415 // the priority.
11416 //
11417 // TODO: Reconsider this implementation trade off.
11418 var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
11419 runWithPriority(priorityLevel, function () {
11420 var effect = firstEffect;
11421 do {
11422 var destroy = effect.destroy;
11423 if (destroy !== undefined) {
11424 safelyCallDestroy(current$$1, destroy);
11425 }
11426 effect = effect.next;
11427 } while (effect !== firstEffect);
11428 });
11429 }
11430 }
11431 break;
11432 }
11433 case ClassComponent:
11434 {
11435 safelyDetachRef(current$$1);
11436 var instance = current$$1.stateNode;
11437 if (typeof instance.componentWillUnmount === 'function') {
11438 safelyCallComponentWillUnmount(current$$1, instance);
11439 }
11440 return;
11441 }
11442 case HostComponent:
11443 {
11444 if (enableFlareAPI) {
11445 var dependencies = current$$1.dependencies;
11446
11447 if (dependencies !== null) {
11448 var respondersMap = dependencies.responders;
11449 if (respondersMap !== null) {
11450 var responderInstances = Array.from(respondersMap.values());
11451 for (var i = 0, length = responderInstances.length; i < length; i++) {
11452 var responderInstance = responderInstances[i];
11453 unmountResponderInstance(responderInstance);
11454 }
11455 dependencies.responders = null;
11456 }
11457 }
11458 }
11459 safelyDetachRef(current$$1);
11460 return;
11461 }
11462 case HostPortal:
11463 {
11464 // TODO: this is recursive.
11465 // We are also not using this parent because
11466 // the portal will get pushed immediately.
11467 if (supportsMutation) {
11468 unmountHostComponents(current$$1, renderPriorityLevel);
11469 } else if (supportsPersistence) {
11470 emptyPortalContainer(current$$1);
11471 }
11472 return;
11473 }
11474 case FundamentalComponent:
11475 {
11476 if (enableFundamentalAPI) {
11477 var fundamentalInstance = current$$1.stateNode;
11478 if (fundamentalInstance !== null) {
11479 unmountFundamentalComponent(fundamentalInstance);
11480 current$$1.stateNode = null;
11481 }
11482 }
11483 }
11484 }
11485}
11486
11487function commitNestedUnmounts(root, renderPriorityLevel) {
11488 // While we're inside a removed host node we don't want to call
11489 // removeChild on the inner nodes because they're removed by the top
11490 // call anyway. We also want to call componentWillUnmount on all
11491 // composites before this host node is removed from the tree. Therefore
11492 var node = root;
11493 while (true) {
11494 commitUnmount(node, renderPriorityLevel);
11495 // Visit children because they may contain more composite or host nodes.
11496 // Skip portals because commitUnmount() currently visits them recursively.
11497 if (node.child !== null && (
11498 // If we use mutation we drill down into portals using commitUnmount above.
11499 // If we don't use mutation we drill down into portals here instead.
11500 !supportsMutation || node.tag !== HostPortal)) {
11501 node.child.return = node;
11502 node = node.child;
11503 continue;
11504 }
11505 if (node === root) {
11506 return;
11507 }
11508 while (node.sibling === null) {
11509 if (node.return === null || node.return === root) {
11510 return;
11511 }
11512 node = node.return;
11513 }
11514 node.sibling.return = node.return;
11515 node = node.sibling;
11516 }
11517}
11518
11519function detachFiber(current$$1) {
11520 // Cut off the return pointers to disconnect it from the tree. Ideally, we
11521 // should clear the child pointer of the parent alternate to let this
11522 // get GC:ed but we don't know which for sure which parent is the current
11523 // one so we'll settle for GC:ing the subtree of this child. This child
11524 // itself will be GC:ed when the parent updates the next time.
11525 current$$1.return = null;
11526 current$$1.child = null;
11527 current$$1.memoizedState = null;
11528 current$$1.updateQueue = null;
11529 current$$1.dependencies = null;
11530 var alternate = current$$1.alternate;
11531 if (alternate !== null) {
11532 alternate.return = null;
11533 alternate.child = null;
11534 alternate.memoizedState = null;
11535 alternate.updateQueue = null;
11536 alternate.dependencies = null;
11537 }
11538}
11539
11540function emptyPortalContainer(current$$1) {
11541 if (!supportsPersistence) {
11542 return;
11543 }
11544
11545 var portal = current$$1.stateNode;
11546 var containerInfo = portal.containerInfo;
11547
11548 var emptyChildSet = createContainerChildSet(containerInfo);
11549 replaceContainerChildren(containerInfo, emptyChildSet);
11550}
11551
11552function commitContainer(finishedWork) {
11553 if (!supportsPersistence) {
11554 return;
11555 }
11556
11557 switch (finishedWork.tag) {
11558 case ClassComponent:
11559 case HostComponent:
11560 case HostText:
11561 case FundamentalComponent:
11562 {
11563 return;
11564 }
11565 case HostRoot:
11566 case HostPortal:
11567 {
11568 var portalOrRoot = finishedWork.stateNode;
11569 var containerInfo = portalOrRoot.containerInfo,
11570 _pendingChildren = portalOrRoot.pendingChildren;
11571
11572 replaceContainerChildren(containerInfo, _pendingChildren);
11573 return;
11574 }
11575 default:
11576 {
11577 (function () {
11578 {
11579 {
11580 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.'));
11581 }
11582 }
11583 })();
11584 }
11585 }
11586}
11587
11588function getHostParentFiber(fiber) {
11589 var parent = fiber.return;
11590 while (parent !== null) {
11591 if (isHostParent(parent)) {
11592 return parent;
11593 }
11594 parent = parent.return;
11595 }
11596 (function () {
11597 {
11598 {
11599 throw ReactError(Error('Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.'));
11600 }
11601 }
11602 })();
11603}
11604
11605function isHostParent(fiber) {
11606 return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
11607}
11608
11609function getHostSibling(fiber) {
11610 // We're going to search forward into the tree until we find a sibling host
11611 // node. Unfortunately, if multiple insertions are done in a row we have to
11612 // search past them. This leads to exponential search for the next sibling.
11613 var node = fiber;
11614 siblings: while (true) {
11615 // If we didn't find anything, let's try the next sibling.
11616 while (node.sibling === null) {
11617 if (node.return === null || isHostParent(node.return)) {
11618 // If we pop out of the root or hit the parent the fiber we are the
11619 // last sibling.
11620 return null;
11621 }
11622 node = node.return;
11623 }
11624 node.sibling.return = node.return;
11625 node = node.sibling;
11626 while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
11627 // If it is not host node and, we might have a host node inside it.
11628 // Try to search down until we find one.
11629 if (node.effectTag & Placement) {
11630 // If we don't have a child, try the siblings instead.
11631 continue siblings;
11632 }
11633 // If we don't have a child, try the siblings instead.
11634 // We also skip portals because they are not part of this host tree.
11635 if (node.child === null || node.tag === HostPortal) {
11636 continue siblings;
11637 } else {
11638 node.child.return = node;
11639 node = node.child;
11640 }
11641 }
11642 // Check if this host node is stable or about to be placed.
11643 if (!(node.effectTag & Placement)) {
11644 // Found it!
11645 return node.stateNode;
11646 }
11647 }
11648}
11649
11650function commitPlacement(finishedWork) {
11651 if (!supportsMutation) {
11652 return;
11653 }
11654
11655 // Recursively insert all host nodes into the parent.
11656 var parentFiber = getHostParentFiber(finishedWork);
11657
11658 // Note: these two variables *must* always be updated together.
11659 var parent = void 0;
11660 var isContainer = void 0;
11661 var parentStateNode = parentFiber.stateNode;
11662 switch (parentFiber.tag) {
11663 case HostComponent:
11664 parent = parentStateNode;
11665 isContainer = false;
11666 break;
11667 case HostRoot:
11668 parent = parentStateNode.containerInfo;
11669 isContainer = true;
11670 break;
11671 case HostPortal:
11672 parent = parentStateNode.containerInfo;
11673 isContainer = true;
11674 break;
11675 case FundamentalComponent:
11676 if (enableFundamentalAPI) {
11677 parent = parentStateNode.instance;
11678 isContainer = false;
11679 }
11680 // eslint-disable-next-line-no-fallthrough
11681 default:
11682 (function () {
11683 {
11684 {
11685 throw ReactError(Error('Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.'));
11686 }
11687 }
11688 })();
11689 }
11690 if (parentFiber.effectTag & ContentReset) {
11691 // Reset the text content of the parent before doing any insertions
11692 parentFiber.effectTag &= ~ContentReset;
11693 }
11694
11695 var before = getHostSibling(finishedWork);
11696 // We only have the top Fiber that was inserted but we need to recurse down its
11697 // children to find all the terminal nodes.
11698 var node = finishedWork;
11699 while (true) {
11700 var isHost = node.tag === HostComponent || node.tag === HostText;
11701 if (isHost || node.tag === FundamentalComponent) {
11702 var stateNode = isHost ? node.stateNode : node.stateNode.instance;
11703 if (before) {
11704 if (isContainer) {
11705 insertInContainerBefore(parent, stateNode, before);
11706 } else {
11707 insertBefore(parent, stateNode, before);
11708 }
11709 } else {
11710 if (isContainer) {
11711 appendChildToContainer(parent, stateNode);
11712 } else {
11713 appendChild(parent, stateNode);
11714 }
11715 }
11716 } else if (node.tag === HostPortal) {
11717 // If the insertion itself is a portal, then we don't want to traverse
11718 // down its children. Instead, we'll get insertions from each child in
11719 // the portal directly.
11720 } else if (node.child !== null) {
11721 node.child.return = node;
11722 node = node.child;
11723 continue;
11724 }
11725 if (node === finishedWork) {
11726 return;
11727 }
11728 while (node.sibling === null) {
11729 if (node.return === null || node.return === finishedWork) {
11730 return;
11731 }
11732 node = node.return;
11733 }
11734 node.sibling.return = node.return;
11735 node = node.sibling;
11736 }
11737}
11738
11739function unmountHostComponents(current$$1, renderPriorityLevel) {
11740 // We only have the top Fiber that was deleted but we need to recurse down its
11741 var node = current$$1;
11742
11743 // Each iteration, currentParent is populated with node's host parent if not
11744 // currentParentIsValid.
11745 var currentParentIsValid = false;
11746
11747 // Note: these two variables *must* always be updated together.
11748 var currentParent = void 0;
11749 var currentParentIsContainer = void 0;
11750
11751 while (true) {
11752 if (!currentParentIsValid) {
11753 var parent = node.return;
11754 findParent: while (true) {
11755 (function () {
11756 if (!(parent !== null)) {
11757 {
11758 throw ReactError(Error('Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.'));
11759 }
11760 }
11761 })();
11762 var parentStateNode = parent.stateNode;
11763 switch (parent.tag) {
11764 case HostComponent:
11765 currentParent = parentStateNode;
11766 currentParentIsContainer = false;
11767 break findParent;
11768 case HostRoot:
11769 currentParent = parentStateNode.containerInfo;
11770 currentParentIsContainer = true;
11771 break findParent;
11772 case HostPortal:
11773 currentParent = parentStateNode.containerInfo;
11774 currentParentIsContainer = true;
11775 break findParent;
11776 case FundamentalComponent:
11777 if (enableFundamentalAPI) {
11778 currentParent = parentStateNode.instance;
11779 currentParentIsContainer = false;
11780 }
11781 }
11782 parent = parent.return;
11783 }
11784 currentParentIsValid = true;
11785 }
11786
11787 if (node.tag === HostComponent || node.tag === HostText) {
11788 commitNestedUnmounts(node, renderPriorityLevel);
11789 // After all the children have unmounted, it is now safe to remove the
11790 // node from the tree.
11791 if (currentParentIsContainer) {
11792 removeChildFromContainer(currentParent, node.stateNode);
11793 } else {
11794 removeChild(currentParent, node.stateNode);
11795 }
11796 // Don't visit children because we already visited them.
11797 } else if (node.tag === FundamentalComponent) {
11798 var fundamentalNode = node.stateNode.instance;
11799 commitNestedUnmounts(node, renderPriorityLevel);
11800 // After all the children have unmounted, it is now safe to remove the
11801 // node from the tree.
11802 if (currentParentIsContainer) {
11803 removeChildFromContainer(currentParent, fundamentalNode);
11804 } else {
11805 removeChild(currentParent, fundamentalNode);
11806 }
11807 } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
11808 // Delete the dehydrated suspense boundary and all of its content.
11809 if (currentParentIsContainer) {
11810 clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
11811 } else {
11812 clearSuspenseBoundary(currentParent, node.stateNode);
11813 }
11814 } else if (node.tag === HostPortal) {
11815 if (node.child !== null) {
11816 // When we go into a portal, it becomes the parent to remove from.
11817 // We will reassign it back when we pop the portal on the way up.
11818 currentParent = node.stateNode.containerInfo;
11819 currentParentIsContainer = true;
11820 // Visit children because portals might contain host components.
11821 node.child.return = node;
11822 node = node.child;
11823 continue;
11824 }
11825 } else {
11826 commitUnmount(node, renderPriorityLevel);
11827 // Visit children because we may find more host components below.
11828 if (node.child !== null) {
11829 node.child.return = node;
11830 node = node.child;
11831 continue;
11832 }
11833 }
11834 if (node === current$$1) {
11835 return;
11836 }
11837 while (node.sibling === null) {
11838 if (node.return === null || node.return === current$$1) {
11839 return;
11840 }
11841 node = node.return;
11842 if (node.tag === HostPortal) {
11843 // When we go out of the portal, we need to restore the parent.
11844 // Since we don't keep a stack of them, we will search for it.
11845 currentParentIsValid = false;
11846 }
11847 }
11848 node.sibling.return = node.return;
11849 node = node.sibling;
11850 }
11851}
11852
11853function commitDeletion(current$$1, renderPriorityLevel) {
11854 if (supportsMutation) {
11855 // Recursively delete all host nodes from the parent.
11856 // Detach refs and call componentWillUnmount() on the whole subtree.
11857 unmountHostComponents(current$$1, renderPriorityLevel);
11858 } else {
11859 // Detach refs and call componentWillUnmount() on the whole subtree.
11860 commitNestedUnmounts(current$$1, renderPriorityLevel);
11861 }
11862 detachFiber(current$$1);
11863}
11864
11865function commitWork(current$$1, finishedWork) {
11866 if (!supportsMutation) {
11867 switch (finishedWork.tag) {
11868 case FunctionComponent:
11869 case ForwardRef:
11870 case MemoComponent:
11871 case SimpleMemoComponent:
11872 {
11873 // Note: We currently never use MountMutation, but useLayout uses
11874 // UnmountMutation.
11875 commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
11876 return;
11877 }
11878 case Profiler:
11879 {
11880 return;
11881 }
11882 case SuspenseComponent:
11883 {
11884 commitSuspenseComponent(finishedWork);
11885 attachSuspenseRetryListeners(finishedWork);
11886 return;
11887 }
11888 case SuspenseListComponent:
11889 {
11890 attachSuspenseRetryListeners(finishedWork);
11891 return;
11892 }
11893 }
11894
11895 commitContainer(finishedWork);
11896 return;
11897 }
11898
11899 switch (finishedWork.tag) {
11900 case FunctionComponent:
11901 case ForwardRef:
11902 case MemoComponent:
11903 case SimpleMemoComponent:
11904 {
11905 // Note: We currently never use MountMutation, but useLayout uses
11906 // UnmountMutation.
11907 commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
11908 return;
11909 }
11910 case ClassComponent:
11911 {
11912 return;
11913 }
11914 case HostComponent:
11915 {
11916 var instance = finishedWork.stateNode;
11917 if (instance != null) {
11918 // Commit the work prepared earlier.
11919 var newProps = finishedWork.memoizedProps;
11920 // For hydration we reuse the update path but we treat the oldProps
11921 // as the newProps. The updatePayload will contain the real change in
11922 // this case.
11923 var oldProps = current$$1 !== null ? current$$1.memoizedProps : newProps;
11924 var type = finishedWork.type;
11925 // TODO: Type the updateQueue to be specific to host components.
11926 var updatePayload = finishedWork.updateQueue;
11927 finishedWork.updateQueue = null;
11928 if (updatePayload !== null) {
11929 commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
11930 }
11931 }
11932 return;
11933 }
11934 case HostText:
11935 {
11936 (function () {
11937 if (!(finishedWork.stateNode !== null)) {
11938 {
11939 throw ReactError(Error('This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.'));
11940 }
11941 }
11942 })();
11943 var textInstance = finishedWork.stateNode;
11944 var newText = finishedWork.memoizedProps;
11945 // For hydration we reuse the update path but we treat the oldProps
11946 // as the newProps. The updatePayload will contain the real change in
11947 // this case.
11948 var oldText = current$$1 !== null ? current$$1.memoizedProps : newText;
11949 return;
11950 }
11951 case HostRoot:
11952 {
11953 return;
11954 }
11955 case Profiler:
11956 {
11957 return;
11958 }
11959 case SuspenseComponent:
11960 {
11961 commitSuspenseComponent(finishedWork);
11962 attachSuspenseRetryListeners(finishedWork);
11963 return;
11964 }
11965 case SuspenseListComponent:
11966 {
11967 attachSuspenseRetryListeners(finishedWork);
11968 return;
11969 }
11970 case IncompleteClassComponent:
11971 {
11972 return;
11973 }
11974 case FundamentalComponent:
11975 {
11976 if (enableFundamentalAPI) {
11977 var fundamentalInstance = finishedWork.stateNode;
11978 updateFundamentalComponent(fundamentalInstance);
11979 }
11980 return;
11981 }
11982 default:
11983 {
11984 (function () {
11985 {
11986 {
11987 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.'));
11988 }
11989 }
11990 })();
11991 }
11992 }
11993}
11994
11995function commitSuspenseComponent(finishedWork) {
11996 var newState = finishedWork.memoizedState;
11997
11998 var newDidTimeout = void 0;
11999 var primaryChildParent = finishedWork;
12000 if (newState === null) {
12001 newDidTimeout = false;
12002 } else {
12003 newDidTimeout = true;
12004 primaryChildParent = finishedWork.child;
12005 markCommitTimeOfFallback();
12006 }
12007
12008 if (supportsMutation && primaryChildParent !== null) {
12009 hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
12010 }
12011
12012 if (enableSuspenseCallback && newState !== null) {
12013 var suspenseCallback = finishedWork.memoizedProps.suspenseCallback;
12014 if (typeof suspenseCallback === 'function') {
12015 var thenables = finishedWork.updateQueue;
12016 if (thenables !== null) {
12017 suspenseCallback(new Set(thenables));
12018 }
12019 } else {
12020 if (suspenseCallback !== undefined) {
12021 warning$1(false, 'Unexpected type for suspenseCallback.');
12022 }
12023 }
12024 }
12025}
12026
12027function attachSuspenseRetryListeners(finishedWork) {
12028 // If this boundary just timed out, then it will have a set of thenables.
12029 // For each thenable, attach a listener so that when it resolves, React
12030 var thenables = finishedWork.updateQueue;
12031 if (thenables !== null) {
12032 finishedWork.updateQueue = null;
12033 var retryCache = finishedWork.stateNode;
12034 if (retryCache === null) {
12035 retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
12036 }
12037 thenables.forEach(function (thenable) {
12038 // Memoize using the boundary fiber to prevent redundant listeners.
12039 var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
12040 if (!retryCache.has(thenable)) {
12041 if (enableSchedulerTracing) {
12042 retry = tracing.unstable_wrap(retry);
12043 }
12044 retryCache.add(thenable);
12045 thenable.then(retry, retry);
12046 }
12047 });
12048 }
12049}
12050
12051function commitResetTextContent(current$$1) {
12052 if (!supportsMutation) {
12053 return;
12054 }
12055 resetTextContent(current$$1.stateNode);
12056}
12057
12058var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
12059var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
12060
12061function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
12062 var update = createUpdate(expirationTime, null);
12063 // Unmount the root by rendering null.
12064 update.tag = CaptureUpdate;
12065 // Caution: React DevTools currently depends on this property
12066 // being called "element".
12067 update.payload = { element: null };
12068 var error = errorInfo.value;
12069 update.callback = function () {
12070 onUncaughtError(error);
12071 logError(fiber, errorInfo);
12072 };
12073 return update;
12074}
12075
12076function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
12077 var update = createUpdate(expirationTime, null);
12078 update.tag = CaptureUpdate;
12079 var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
12080 if (typeof getDerivedStateFromError === 'function') {
12081 var error = errorInfo.value;
12082 update.payload = function () {
12083 logError(fiber, errorInfo);
12084 return getDerivedStateFromError(error);
12085 };
12086 }
12087
12088 var inst = fiber.stateNode;
12089 if (inst !== null && typeof inst.componentDidCatch === 'function') {
12090 update.callback = function callback() {
12091 {
12092 markFailedErrorBoundaryForHotReloading(fiber);
12093 }
12094 if (typeof getDerivedStateFromError !== 'function') {
12095 // To preserve the preexisting retry behavior of error boundaries,
12096 // we keep track of which ones already failed during this batch.
12097 // This gets reset before we yield back to the browser.
12098 // TODO: Warn in strict mode if getDerivedStateFromError is
12099 // not defined.
12100 markLegacyErrorBoundaryAsFailed(this);
12101
12102 // Only log here if componentDidCatch is the only error boundary method defined
12103 logError(fiber, errorInfo);
12104 }
12105 var error = errorInfo.value;
12106 var stack = errorInfo.stack;
12107 this.componentDidCatch(error, {
12108 componentStack: stack !== null ? stack : ''
12109 });
12110 {
12111 if (typeof getDerivedStateFromError !== 'function') {
12112 // If componentDidCatch is the only error boundary method defined,
12113 // then it needs to call setState to recover from errors.
12114 // If no state update is scheduled then the boundary will swallow the error.
12115 !(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;
12116 }
12117 }
12118 };
12119 } else {
12120 update.callback = function () {
12121 markFailedErrorBoundaryForHotReloading(fiber);
12122 };
12123 }
12124 return update;
12125}
12126
12127function attachPingListener(root, renderExpirationTime, thenable) {
12128 // Attach a listener to the promise to "ping" the root and retry. But
12129 // only if one does not already exist for the current render expiration
12130 // time (which acts like a "thread ID" here).
12131 var pingCache = root.pingCache;
12132 var threadIDs = void 0;
12133 if (pingCache === null) {
12134 pingCache = root.pingCache = new PossiblyWeakMap();
12135 threadIDs = new Set();
12136 pingCache.set(thenable, threadIDs);
12137 } else {
12138 threadIDs = pingCache.get(thenable);
12139 if (threadIDs === undefined) {
12140 threadIDs = new Set();
12141 pingCache.set(thenable, threadIDs);
12142 }
12143 }
12144 if (!threadIDs.has(renderExpirationTime)) {
12145 // Memoize using the thread ID to prevent redundant listeners.
12146 threadIDs.add(renderExpirationTime);
12147 var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
12148 if (enableSchedulerTracing) {
12149 ping = tracing.unstable_wrap(ping);
12150 }
12151 thenable.then(ping, ping);
12152 }
12153}
12154
12155function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
12156 // The source fiber did not complete.
12157 sourceFiber.effectTag |= Incomplete;
12158 // Its effect list is no longer valid.
12159 sourceFiber.firstEffect = sourceFiber.lastEffect = null;
12160
12161 if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
12162 // This is a thenable.
12163 var thenable = value;
12164
12165 checkForWrongSuspensePriorityInDEV(sourceFiber);
12166
12167 var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext);
12168
12169 // Schedule the nearest Suspense to re-render the timed out view.
12170 var _workInProgress = returnFiber;
12171 do {
12172 if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
12173 // Found the nearest boundary.
12174
12175 // Stash the promise on the boundary fiber. If the boundary times out, we'll
12176 var thenables = _workInProgress.updateQueue;
12177 if (thenables === null) {
12178 var updateQueue = new Set();
12179 updateQueue.add(thenable);
12180 _workInProgress.updateQueue = updateQueue;
12181 } else {
12182 thenables.add(thenable);
12183 }
12184
12185 // If the boundary is outside of batched mode, we should *not*
12186 // suspend the commit. Pretend as if the suspended component rendered
12187 // null and keep rendering. In the commit phase, we'll schedule a
12188 // subsequent synchronous update to re-render the Suspense.
12189 //
12190 // Note: It doesn't matter whether the component that suspended was
12191 // inside a batched mode tree. If the Suspense is outside of it, we
12192 // should *not* suspend the commit.
12193 if ((_workInProgress.mode & BatchedMode) === NoMode) {
12194 _workInProgress.effectTag |= DidCapture;
12195
12196 // We're going to commit this fiber even though it didn't complete.
12197 // But we shouldn't call any lifecycle methods or callbacks. Remove
12198 // all lifecycle effect tags.
12199 sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
12200
12201 if (sourceFiber.tag === ClassComponent) {
12202 var currentSourceFiber = sourceFiber.alternate;
12203 if (currentSourceFiber === null) {
12204 // This is a new mount. Change the tag so it's not mistaken for a
12205 // completed class component. For example, we should not call
12206 // componentWillUnmount if it is deleted.
12207 sourceFiber.tag = IncompleteClassComponent;
12208 } else {
12209 // When we try rendering again, we should not reuse the current fiber,
12210 // since it's known to be in an inconsistent state. Use a force update to
12211 // prevent a bail out.
12212 var update = createUpdate(Sync, null);
12213 update.tag = ForceUpdate;
12214 enqueueUpdate(sourceFiber, update);
12215 }
12216 }
12217
12218 // The source fiber did not complete. Mark it with Sync priority to
12219 // indicate that it still has pending work.
12220 sourceFiber.expirationTime = Sync;
12221
12222 // Exit without suspending.
12223 return;
12224 }
12225
12226 // Confirmed that the boundary is in a concurrent mode tree. Continue
12227 // with the normal suspend path.
12228 //
12229 // After this we'll use a set of heuristics to determine whether this
12230 // render pass will run to completion or restart or "suspend" the commit.
12231 // The actual logic for this is spread out in different places.
12232 //
12233 // This first principle is that if we're going to suspend when we complete
12234 // a root, then we should also restart if we get an update or ping that
12235 // might unsuspend it, and vice versa. The only reason to suspend is
12236 // because you think you might want to restart before committing. However,
12237 // it doesn't make sense to restart only while in the period we're suspended.
12238 //
12239 // Restarting too aggressively is also not good because it starves out any
12240 // intermediate loading state. So we use heuristics to determine when.
12241
12242 // Suspense Heuristics
12243 //
12244 // If nothing threw a Promise or all the same fallbacks are already showing,
12245 // then don't suspend/restart.
12246 //
12247 // If this is an initial render of a new tree of Suspense boundaries and
12248 // those trigger a fallback, then don't suspend/restart. We want to ensure
12249 // that we can show the initial loading state as quickly as possible.
12250 //
12251 // If we hit a "Delayed" case, such as when we'd switch from content back into
12252 // a fallback, then we should always suspend/restart. SuspenseConfig applies to
12253 // this case. If none is defined, JND is used instead.
12254 //
12255 // If we're already showing a fallback and it gets "retried", allowing us to show
12256 // another level, but there's still an inner boundary that would show a fallback,
12257 // then we suspend/restart for 500ms since the last time we showed a fallback
12258 // anywhere in the tree. This effectively throttles progressive loading into a
12259 // consistent train of commits. This also gives us an opportunity to restart to
12260 // get to the completed state slightly earlier.
12261 //
12262 // If there's ambiguity due to batching it's resolved in preference of:
12263 // 1) "delayed", 2) "initial render", 3) "retry".
12264 //
12265 // We want to ensure that a "busy" state doesn't get force committed. We want to
12266 // ensure that new initial loading states can commit as soon as possible.
12267
12268 attachPingListener(root, renderExpirationTime, thenable);
12269
12270 _workInProgress.effectTag |= ShouldCapture;
12271 _workInProgress.expirationTime = renderExpirationTime;
12272
12273 return;
12274 } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
12275 attachPingListener(root, renderExpirationTime, thenable);
12276
12277 // Since we already have a current fiber, we can eagerly add a retry listener.
12278 var retryCache = _workInProgress.memoizedState;
12279 if (retryCache === null) {
12280 retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
12281 var current$$1 = _workInProgress.alternate;
12282 (function () {
12283 if (!current$$1) {
12284 {
12285 throw ReactError(Error('A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.'));
12286 }
12287 }
12288 })();
12289 current$$1.memoizedState = retryCache;
12290 }
12291 // Memoize using the boundary fiber to prevent redundant listeners.
12292 if (!retryCache.has(thenable)) {
12293 retryCache.add(thenable);
12294 var retry = resolveRetryThenable.bind(null, _workInProgress, thenable);
12295 if (enableSchedulerTracing) {
12296 retry = tracing.unstable_wrap(retry);
12297 }
12298 thenable.then(retry, retry);
12299 }
12300 _workInProgress.effectTag |= ShouldCapture;
12301 _workInProgress.expirationTime = renderExpirationTime;
12302 return;
12303 }
12304 // This boundary already captured during this render. Continue to the next
12305 // boundary.
12306 _workInProgress = _workInProgress.return;
12307 } while (_workInProgress !== null);
12308 // No boundary was found. Fallthrough to error mode.
12309 // TODO: Use invariant so the message is stripped in prod?
12310 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));
12311 }
12312
12313 // We didn't find a boundary that could handle this type of exception. Start
12314 // over and traverse parent path again, this time treating the exception
12315 // as an error.
12316 renderDidError();
12317 value = createCapturedValue(value, sourceFiber);
12318 var workInProgress = returnFiber;
12319 do {
12320 switch (workInProgress.tag) {
12321 case HostRoot:
12322 {
12323 var _errorInfo = value;
12324 workInProgress.effectTag |= ShouldCapture;
12325 workInProgress.expirationTime = renderExpirationTime;
12326 var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
12327 enqueueCapturedUpdate(workInProgress, _update);
12328 return;
12329 }
12330 case ClassComponent:
12331 // Capture and retry
12332 var errorInfo = value;
12333 var ctor = workInProgress.type;
12334 var instance = workInProgress.stateNode;
12335 if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
12336 workInProgress.effectTag |= ShouldCapture;
12337 workInProgress.expirationTime = renderExpirationTime;
12338 // Schedule the error boundary to re-render using updated state
12339 var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
12340 enqueueCapturedUpdate(workInProgress, _update2);
12341 return;
12342 }
12343 break;
12344 default:
12345 break;
12346 }
12347 workInProgress = workInProgress.return;
12348 } while (workInProgress !== null);
12349}
12350
12351// The scheduler is imported here *only* to detect whether it's been mocked
12352// DEV stuff
12353var ceil = Math.ceil;
12354
12355var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
12356var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
12357var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
12358
12359
12360var NoContext = /* */0;
12361var BatchedContext = /* */1;
12362var DiscreteEventContext = /* */4;
12363var LegacyUnbatchedContext = /* */8;
12364var RenderContext = /* */16;
12365var CommitContext = /* */32;
12366
12367var RootIncomplete = 0;
12368var RootErrored = 1;
12369var RootSuspended = 2;
12370var RootSuspendedWithDelay = 3;
12371var RootCompleted = 4;
12372
12373// Describes where we are in the React execution stack
12374var executionContext = NoContext;
12375// The root we're working on
12376var workInProgressRoot = null;
12377// The fiber we're working on
12378var workInProgress = null;
12379// The expiration time we're rendering
12380var renderExpirationTime = NoWork;
12381// Whether to root completed, errored, suspended, etc.
12382var workInProgressRootExitStatus = RootIncomplete;
12383// Most recent event time among processed updates during this render.
12384// This is conceptually a time stamp but expressed in terms of an ExpirationTime
12385// because we deal mostly with expiration times in the hot path, so this avoids
12386// the conversion happening in the hot path.
12387var workInProgressRootLatestProcessedExpirationTime = Sync;
12388var workInProgressRootLatestSuspenseTimeout = Sync;
12389var workInProgressRootCanSuspendUsingConfig = null;
12390// If we're pinged while rendering we don't always restart immediately.
12391// This flag determines if it might be worthwhile to restart if an opportunity
12392// happens latere.
12393var workInProgressRootHasPendingPing = false;
12394// The most recent time we committed a fallback. This lets us ensure a train
12395// model where we don't commit new loading states in too quick succession.
12396var globalMostRecentFallbackTime = 0;
12397var FALLBACK_THROTTLE_MS = 500;
12398
12399var nextEffect = null;
12400var hasUncaughtError = false;
12401var firstUncaughtError = null;
12402var legacyErrorBoundariesThatAlreadyFailed = null;
12403
12404var rootDoesHavePassiveEffects = false;
12405var rootWithPendingPassiveEffects = null;
12406var pendingPassiveEffectsRenderPriority = NoPriority;
12407var pendingPassiveEffectsExpirationTime = NoWork;
12408
12409var rootsWithPendingDiscreteUpdates = null;
12410
12411// Use these to prevent an infinite loop of nested updates
12412var NESTED_UPDATE_LIMIT = 50;
12413var nestedUpdateCount = 0;
12414var rootWithNestedUpdates = null;
12415
12416var NESTED_PASSIVE_UPDATE_LIMIT = 50;
12417var nestedPassiveUpdateCount = 0;
12418
12419var interruptedBy = null;
12420
12421// Marks the need to reschedule pending interactions at these expiration times
12422// during the commit phase. This enables them to be traced across components
12423// that spawn new work during render. E.g. hidden boundaries, suspended SSR
12424// hydration or SuspenseList.
12425var spawnedWorkDuringRender = null;
12426
12427// Expiration times are computed by adding to the current time (the start
12428// time). However, if two updates are scheduled within the same event, we
12429// should treat their start times as simultaneous, even if the actual clock
12430// time has advanced between the first and second call.
12431
12432// In other words, because expiration times determine how updates are batched,
12433// we want all updates of like priority that occur within the same event to
12434// receive the same expiration time. Otherwise we get tearing.
12435var currentEventTime = NoWork;
12436
12437function requestCurrentTime() {
12438 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
12439 // We're inside React, so it's fine to read the actual time.
12440 return msToExpirationTime(now());
12441 }
12442 // We're not inside React, so we may be in the middle of a browser event.
12443 if (currentEventTime !== NoWork) {
12444 // Use the same start time for all updates until we enter React again.
12445 return currentEventTime;
12446 }
12447 // This is the first update since React yielded. Compute a new start time.
12448 currentEventTime = msToExpirationTime(now());
12449 return currentEventTime;
12450}
12451
12452function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
12453 var mode = fiber.mode;
12454 if ((mode & BatchedMode) === NoMode) {
12455 return Sync;
12456 }
12457
12458 var priorityLevel = getCurrentPriorityLevel();
12459 if ((mode & ConcurrentMode) === NoMode) {
12460 return priorityLevel === ImmediatePriority ? Sync : Batched;
12461 }
12462
12463 if ((executionContext & RenderContext) !== NoContext) {
12464 // Use whatever time we're already rendering
12465 return renderExpirationTime;
12466 }
12467
12468 var expirationTime = void 0;
12469 if (suspenseConfig !== null) {
12470 // Compute an expiration time based on the Suspense timeout.
12471 expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
12472 } else {
12473 // Compute an expiration time based on the Scheduler priority.
12474 switch (priorityLevel) {
12475 case ImmediatePriority:
12476 expirationTime = Sync;
12477 break;
12478 case UserBlockingPriority:
12479 // TODO: Rename this to computeUserBlockingExpiration
12480 expirationTime = computeInteractiveExpiration(currentTime);
12481 break;
12482 case NormalPriority:
12483 case LowPriority:
12484 // TODO: Handle LowPriority
12485 // TODO: Rename this to... something better.
12486 expirationTime = computeAsyncExpiration(currentTime);
12487 break;
12488 case IdlePriority:
12489 expirationTime = Never;
12490 break;
12491 default:
12492 (function () {
12493 {
12494 {
12495 throw ReactError(Error('Expected a valid priority level'));
12496 }
12497 }
12498 })();
12499 }
12500 }
12501
12502 // If we're in the middle of rendering a tree, do not update at the same
12503 // expiration time that is already rendering.
12504 // TODO: We shouldn't have to do this if the update is on a different root.
12505 // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
12506 // the root when we check for this condition.
12507 if (workInProgressRoot !== null && expirationTime === renderExpirationTime) {
12508 // This is a trick to move this update into a separate batch
12509 expirationTime -= 1;
12510 }
12511
12512 return expirationTime;
12513}
12514
12515
12516
12517function scheduleUpdateOnFiber(fiber, expirationTime) {
12518 checkForNestedUpdates();
12519 warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber);
12520
12521 var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
12522 if (root === null) {
12523 warnAboutUpdateOnUnmountedFiberInDEV(fiber);
12524 return;
12525 }
12526
12527 root.pingTime = NoWork;
12528
12529 checkForInterruption(fiber, expirationTime);
12530 recordScheduleUpdate();
12531
12532 // TODO: computeExpirationForFiber also reads the priority. Pass the
12533 // priority as an argument to that function and this one.
12534 var priorityLevel = getCurrentPriorityLevel();
12535
12536 if (expirationTime === Sync) {
12537 if (
12538 // Check if we're inside unbatchedUpdates
12539 (executionContext & LegacyUnbatchedContext) !== NoContext &&
12540 // Check if we're not already rendering
12541 (executionContext & (RenderContext | CommitContext)) === NoContext) {
12542 // Register pending interactions on the root to avoid losing traced interaction data.
12543 schedulePendingInteractions(root, expirationTime);
12544
12545 // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
12546 // root inside of batchedUpdates should be synchronous, but layout updates
12547 // should be deferred until the end of the batch.
12548 var callback = renderRoot(root, Sync, true);
12549 while (callback !== null) {
12550 callback = callback(true);
12551 }
12552 } else {
12553 scheduleCallbackForRoot(root, ImmediatePriority, Sync);
12554 if (executionContext === NoContext) {
12555 // Flush the synchronous work now, wnless we're already working or inside
12556 // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
12557 // scheduleCallbackForFiber to preserve the ability to schedule a callback
12558 // without immediately flushing it. We only do this for user-initiated
12559 // updates, to preserve historical behavior of sync mode.
12560 flushSyncCallbackQueue();
12561 }
12562 }
12563 } else {
12564 scheduleCallbackForRoot(root, priorityLevel, expirationTime);
12565 }
12566
12567 if ((executionContext & DiscreteEventContext) !== NoContext && (
12568 // Only updates at user-blocking priority or greater are considered
12569 // discrete, even inside a discrete event.
12570 priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority)) {
12571 // This is the result of a discrete event. Track the lowest priority
12572 // discrete update per root so we can flush them early, if needed.
12573 if (rootsWithPendingDiscreteUpdates === null) {
12574 rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
12575 } else {
12576 var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
12577 if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
12578 rootsWithPendingDiscreteUpdates.set(root, expirationTime);
12579 }
12580 }
12581 }
12582}
12583var scheduleWork = scheduleUpdateOnFiber;
12584
12585// This is split into a separate function so we can mark a fiber with pending
12586// work without treating it as a typical update that originates from an event;
12587// e.g. retrying a Suspense boundary isn't an update, but it does schedule work
12588// on a fiber.
12589function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
12590 // Update the source fiber's expiration time
12591 if (fiber.expirationTime < expirationTime) {
12592 fiber.expirationTime = expirationTime;
12593 }
12594 var alternate = fiber.alternate;
12595 if (alternate !== null && alternate.expirationTime < expirationTime) {
12596 alternate.expirationTime = expirationTime;
12597 }
12598 // Walk the parent path to the root and update the child expiration time.
12599 var node = fiber.return;
12600 var root = null;
12601 if (node === null && fiber.tag === HostRoot) {
12602 root = fiber.stateNode;
12603 } else {
12604 while (node !== null) {
12605 alternate = node.alternate;
12606 if (node.childExpirationTime < expirationTime) {
12607 node.childExpirationTime = expirationTime;
12608 if (alternate !== null && alternate.childExpirationTime < expirationTime) {
12609 alternate.childExpirationTime = expirationTime;
12610 }
12611 } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
12612 alternate.childExpirationTime = expirationTime;
12613 }
12614 if (node.return === null && node.tag === HostRoot) {
12615 root = node.stateNode;
12616 break;
12617 }
12618 node = node.return;
12619 }
12620 }
12621
12622 if (root !== null) {
12623 // Update the first and last pending expiration times in this root
12624 var firstPendingTime = root.firstPendingTime;
12625 if (expirationTime > firstPendingTime) {
12626 root.firstPendingTime = expirationTime;
12627 }
12628 var lastPendingTime = root.lastPendingTime;
12629 if (lastPendingTime === NoWork || expirationTime < lastPendingTime) {
12630 root.lastPendingTime = expirationTime;
12631 }
12632 }
12633
12634 return root;
12635}
12636
12637// Use this function, along with runRootCallback, to ensure that only a single
12638// callback per root is scheduled. It's still possible to call renderRoot
12639// directly, but scheduling via this function helps avoid excessive callbacks.
12640// It works by storing the callback node and expiration time on the root. When a
12641// new callback comes in, it compares the expiration time to determine if it
12642// should cancel the previous one. It also relies on commitRoot scheduling a
12643// callback to render the next level, because that means we don't need a
12644// separate callback per expiration time.
12645function scheduleCallbackForRoot(root, priorityLevel, expirationTime) {
12646 var existingCallbackExpirationTime = root.callbackExpirationTime;
12647 if (existingCallbackExpirationTime < expirationTime) {
12648 // New callback has higher priority than the existing one.
12649 var existingCallbackNode = root.callbackNode;
12650 if (existingCallbackNode !== null) {
12651 cancelCallback(existingCallbackNode);
12652 }
12653 root.callbackExpirationTime = expirationTime;
12654
12655 if (expirationTime === Sync) {
12656 // Sync React callbacks are scheduled on a special internal queue
12657 root.callbackNode = scheduleSyncCallback(runRootCallback.bind(null, root, renderRoot.bind(null, root, expirationTime)));
12658 } else {
12659 var options = null;
12660 if (!disableSchedulerTimeoutBasedOnReactExpirationTime && expirationTime !== Never) {
12661 var timeout = expirationTimeToMs(expirationTime) - now();
12662 options = { timeout: timeout };
12663 }
12664
12665 root.callbackNode = scheduleCallback(priorityLevel, runRootCallback.bind(null, root, renderRoot.bind(null, root, expirationTime)), options);
12666 if (enableUserTimingAPI && expirationTime !== Sync && (executionContext & (RenderContext | CommitContext)) === NoContext) {
12667 // Scheduled an async callback, and we're not already working. Add an
12668 // entry to the flamegraph that shows we're waiting for a callback
12669 // to fire.
12670 startRequestCallbackTimer();
12671 }
12672 }
12673 }
12674
12675 // Associate the current interactions with this new root+priority.
12676 schedulePendingInteractions(root, expirationTime);
12677}
12678
12679function runRootCallback(root, callback, isSync) {
12680 var prevCallbackNode = root.callbackNode;
12681 var continuation = null;
12682 try {
12683 continuation = callback(isSync);
12684 if (continuation !== null) {
12685 return runRootCallback.bind(null, root, continuation);
12686 } else {
12687 return null;
12688 }
12689 } finally {
12690 // If the callback exits without returning a continuation, remove the
12691 // corresponding callback node from the root. Unless the callback node
12692 // has changed, which implies that it was already cancelled by a high
12693 // priority update.
12694 if (continuation === null && prevCallbackNode === root.callbackNode) {
12695 root.callbackNode = null;
12696 root.callbackExpirationTime = NoWork;
12697 }
12698 }
12699}
12700
12701
12702
12703
12704
12705function resolveLocksOnRoot(root, expirationTime) {
12706 var firstBatch = root.firstBatch;
12707 if (firstBatch !== null && firstBatch._defer && firstBatch._expirationTime >= expirationTime) {
12708 scheduleCallback(NormalPriority, function () {
12709 firstBatch._onComplete();
12710 return null;
12711 });
12712 return true;
12713 } else {
12714 return false;
12715 }
12716}
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730function flushSync(fn, a) {
12731 if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
12732 (function () {
12733 {
12734 {
12735 throw ReactError(Error('flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.'));
12736 }
12737 }
12738 })();
12739 }
12740 var prevExecutionContext = executionContext;
12741 executionContext |= BatchedContext;
12742 try {
12743 return runWithPriority(ImmediatePriority, fn.bind(null, a));
12744 } finally {
12745 executionContext = prevExecutionContext;
12746 // Flush the immediate callbacks that were scheduled during this batch.
12747 // Note that this will happen even if batchedUpdates is higher up
12748 // the stack.
12749 flushSyncCallbackQueue();
12750 }
12751}
12752
12753
12754
12755function prepareFreshStack(root, expirationTime) {
12756 root.finishedWork = null;
12757 root.finishedExpirationTime = NoWork;
12758
12759 var timeoutHandle = root.timeoutHandle;
12760 if (timeoutHandle !== noTimeout) {
12761 // The root previous suspended and scheduled a timeout to commit a fallback
12762 // state. Now that we have additional work, cancel the timeout.
12763 root.timeoutHandle = noTimeout;
12764 // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
12765 cancelTimeout(timeoutHandle);
12766 }
12767
12768 if (workInProgress !== null) {
12769 var interruptedWork = workInProgress.return;
12770 while (interruptedWork !== null) {
12771 unwindInterruptedWork(interruptedWork);
12772 interruptedWork = interruptedWork.return;
12773 }
12774 }
12775 workInProgressRoot = root;
12776 workInProgress = createWorkInProgress(root.current, null, expirationTime);
12777 renderExpirationTime = expirationTime;
12778 workInProgressRootExitStatus = RootIncomplete;
12779 workInProgressRootLatestProcessedExpirationTime = Sync;
12780 workInProgressRootLatestSuspenseTimeout = Sync;
12781 workInProgressRootCanSuspendUsingConfig = null;
12782 workInProgressRootHasPendingPing = false;
12783
12784 if (enableSchedulerTracing) {
12785 spawnedWorkDuringRender = null;
12786 }
12787
12788 {
12789 ReactStrictModeWarnings.discardPendingWarnings();
12790 componentsThatTriggeredHighPriSuspend = null;
12791 }
12792}
12793
12794function renderRoot(root, expirationTime, isSync) {
12795 (function () {
12796 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
12797 {
12798 throw ReactError(Error('Should not already be working.'));
12799 }
12800 }
12801 })();
12802
12803 if (enableUserTimingAPI && expirationTime !== Sync) {
12804 var didExpire = isSync;
12805 stopRequestCallbackTimer(didExpire);
12806 }
12807
12808 if (root.firstPendingTime < expirationTime) {
12809 // If there's no work left at this expiration time, exit immediately. This
12810 // happens when multiple callbacks are scheduled for a single root, but an
12811 // earlier callback flushes the work of a later one.
12812 return null;
12813 }
12814
12815 if (isSync && root.finishedExpirationTime === expirationTime) {
12816 // There's already a pending commit at this expiration time.
12817 // TODO: This is poorly factored. This case only exists for the
12818 // batch.commit() API.
12819 return commitRoot.bind(null, root);
12820 }
12821
12822 flushPassiveEffects();
12823
12824 // If the root or expiration time have changed, throw out the existing stack
12825 // and prepare a fresh one. Otherwise we'll continue where we left off.
12826 if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
12827 prepareFreshStack(root, expirationTime);
12828 startWorkOnPendingInteractions(root, expirationTime);
12829 } else if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
12830 // We could've received an update at a lower priority while we yielded.
12831 // We're suspended in a delayed state. Once we complete this render we're
12832 // just going to try to recover at the last pending time anyway so we might
12833 // as well start doing that eagerly.
12834 // Ideally we should be able to do this even for retries but we don't yet
12835 // know if we're going to process an update which wants to commit earlier,
12836 // and this path happens very early so it would happen too often. Instead,
12837 // for that case, we'll wait until we complete.
12838 if (workInProgressRootHasPendingPing) {
12839 // We have a ping at this expiration. Let's restart to see if we get unblocked.
12840 prepareFreshStack(root, expirationTime);
12841 } else {
12842 var lastPendingTime = root.lastPendingTime;
12843 if (lastPendingTime < expirationTime) {
12844 // There's lower priority work. It might be unsuspended. Try rendering
12845 // at that level immediately, while preserving the position in the queue.
12846 return renderRoot.bind(null, root, lastPendingTime);
12847 }
12848 }
12849 }
12850
12851 // If we have a work-in-progress fiber, it means there's still work to do
12852 // in this root.
12853 if (workInProgress !== null) {
12854 var prevExecutionContext = executionContext;
12855 executionContext |= RenderContext;
12856 var prevDispatcher = ReactCurrentDispatcher.current;
12857 if (prevDispatcher === null) {
12858 // The React isomorphic package does not include a default dispatcher.
12859 // Instead the first renderer will lazily attach one, in order to give
12860 // nicer error messages.
12861 prevDispatcher = ContextOnlyDispatcher;
12862 }
12863 ReactCurrentDispatcher.current = ContextOnlyDispatcher;
12864 var prevInteractions = null;
12865 if (enableSchedulerTracing) {
12866 prevInteractions = tracing.__interactionsRef.current;
12867 tracing.__interactionsRef.current = root.memoizedInteractions;
12868 }
12869
12870 startWorkLoopTimer(workInProgress);
12871
12872 // TODO: Fork renderRoot into renderRootSync and renderRootAsync
12873 if (isSync) {
12874 if (expirationTime !== Sync) {
12875 // An async update expired. There may be other expired updates on
12876 // this root. We should render all the expired work in a
12877 // single batch.
12878 var currentTime = requestCurrentTime();
12879 if (currentTime < expirationTime) {
12880 // Restart at the current time.
12881 executionContext = prevExecutionContext;
12882 resetContextDependencies();
12883 ReactCurrentDispatcher.current = prevDispatcher;
12884 if (enableSchedulerTracing) {
12885 tracing.__interactionsRef.current = prevInteractions;
12886 }
12887 return renderRoot.bind(null, root, currentTime);
12888 }
12889 }
12890 } else {
12891 // Since we know we're in a React event, we can clear the current
12892 // event time. The next update will compute a new event time.
12893 currentEventTime = NoWork;
12894 }
12895
12896 do {
12897 try {
12898 if (isSync) {
12899 workLoopSync();
12900 } else {
12901 workLoop();
12902 }
12903 break;
12904 } catch (thrownValue) {
12905 // Reset module-level state that was set during the render phase.
12906 resetContextDependencies();
12907 resetHooks();
12908
12909 var sourceFiber = workInProgress;
12910 if (sourceFiber === null || sourceFiber.return === null) {
12911 // Expected to be working on a non-root fiber. This is a fatal error
12912 // because there's no ancestor that can handle it; the root is
12913 // supposed to capture all errors that weren't caught by an error
12914 // boundary.
12915 prepareFreshStack(root, expirationTime);
12916 executionContext = prevExecutionContext;
12917 throw thrownValue;
12918 }
12919
12920 if (enableProfilerTimer && sourceFiber.mode & ProfileMode) {
12921 // Record the time spent rendering before an error was thrown. This
12922 // avoids inaccurate Profiler durations in the case of a
12923 // suspended render.
12924 stopProfilerTimerIfRunningAndRecordDelta(sourceFiber, true);
12925 }
12926
12927 var returnFiber = sourceFiber.return;
12928 throwException(root, returnFiber, sourceFiber, thrownValue, renderExpirationTime);
12929 workInProgress = completeUnitOfWork(sourceFiber);
12930 }
12931 } while (true);
12932
12933 executionContext = prevExecutionContext;
12934 resetContextDependencies();
12935 ReactCurrentDispatcher.current = prevDispatcher;
12936 if (enableSchedulerTracing) {
12937 tracing.__interactionsRef.current = prevInteractions;
12938 }
12939
12940 if (workInProgress !== null) {
12941 // There's still work left over. Return a continuation.
12942 stopInterruptedWorkLoopTimer();
12943 if (expirationTime !== Sync) {
12944 startRequestCallbackTimer();
12945 }
12946 return renderRoot.bind(null, root, expirationTime);
12947 }
12948 }
12949
12950 // We now have a consistent tree. The next step is either to commit it, or, if
12951 // something suspended, wait to commit it after a timeout.
12952 stopFinishedWorkLoopTimer();
12953
12954 root.finishedWork = root.current.alternate;
12955 root.finishedExpirationTime = expirationTime;
12956
12957 var isLocked = resolveLocksOnRoot(root, expirationTime);
12958 if (isLocked) {
12959 // This root has a lock that prevents it from committing. Exit. If we begin
12960 // work on the root again, without any intervening updates, it will finish
12961 // without doing additional work.
12962 return null;
12963 }
12964
12965 // Set this to null to indicate there's no in-progress render.
12966 workInProgressRoot = null;
12967
12968 switch (workInProgressRootExitStatus) {
12969 case RootIncomplete:
12970 {
12971 (function () {
12972 {
12973 {
12974 throw ReactError(Error('Should have a work-in-progress.'));
12975 }
12976 }
12977 })();
12978 }
12979 // Flow knows about invariant, so it complains if I add a break statement,
12980 // but eslint doesn't know about invariant, so it complains if I do.
12981 // eslint-disable-next-line no-fallthrough
12982 case RootErrored:
12983 {
12984 // An error was thrown. First check if there is lower priority work
12985 // scheduled on this root.
12986 var _lastPendingTime = root.lastPendingTime;
12987 if (_lastPendingTime < expirationTime) {
12988 // There's lower priority work. Before raising the error, try rendering
12989 // at the lower priority to see if it fixes it. Use a continuation to
12990 // maintain the existing priority and position in the queue.
12991 return renderRoot.bind(null, root, _lastPendingTime);
12992 }
12993 if (!isSync) {
12994 // If we're rendering asynchronously, it's possible the error was
12995 // caused by tearing due to a mutation during an event. Try rendering
12996 // one more time without yiedling to events.
12997 prepareFreshStack(root, expirationTime);
12998 scheduleSyncCallback(renderRoot.bind(null, root, expirationTime));
12999 return null;
13000 }
13001 // If we're already rendering synchronously, commit the root in its
13002 // errored state.
13003 return commitRoot.bind(null, root);
13004 }
13005 case RootSuspended:
13006 {
13007 flushSuspensePriorityWarningInDEV();
13008
13009 // We have an acceptable loading state. We need to figure out if we should
13010 // immediately commit it or wait a bit.
13011
13012 // If we have processed new updates during this render, we may now have a
13013 // new loading state ready. We want to ensure that we commit that as soon as
13014 // possible.
13015 var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
13016 if (hasNotProcessedNewUpdates && !isSync &&
13017 // do not delay if we're inside an act() scope
13018 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
13019 // If we have not processed any new updates during this pass, then this is
13020 // either a retry of an existing fallback state or a hidden tree.
13021 // Hidden trees shouldn't be batched with other work and after that's
13022 // fixed it can only be a retry.
13023 // We're going to throttle committing retries so that we don't show too
13024 // many loading states too quickly.
13025 var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now();
13026 // Don't bother with a very short suspense time.
13027 if (msUntilTimeout > 10) {
13028 if (workInProgressRootHasPendingPing) {
13029 // This render was pinged but we didn't get to restart earlier so try
13030 // restarting now instead.
13031 prepareFreshStack(root, expirationTime);
13032 return renderRoot.bind(null, root, expirationTime);
13033 }
13034 var _lastPendingTime2 = root.lastPendingTime;
13035 if (_lastPendingTime2 < expirationTime) {
13036 // There's lower priority work. It might be unsuspended. Try rendering
13037 // at that level.
13038 return renderRoot.bind(null, root, _lastPendingTime2);
13039 }
13040 // The render is suspended, it hasn't timed out, and there's no lower
13041 // priority work to do. Instead of committing the fallback
13042 // immediately, wait for more data to arrive.
13043 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
13044 return null;
13045 }
13046 }
13047 // The work expired. Commit immediately.
13048 return commitRoot.bind(null, root);
13049 }
13050 case RootSuspendedWithDelay:
13051 {
13052 flushSuspensePriorityWarningInDEV();
13053
13054 if (!isSync &&
13055 // do not delay if we're inside an act() scope
13056 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
13057 // We're suspended in a state that should be avoided. We'll try to avoid committing
13058 // it for as long as the timeouts let us.
13059 if (workInProgressRootHasPendingPing) {
13060 // This render was pinged but we didn't get to restart earlier so try
13061 // restarting now instead.
13062 prepareFreshStack(root, expirationTime);
13063 return renderRoot.bind(null, root, expirationTime);
13064 }
13065 var _lastPendingTime3 = root.lastPendingTime;
13066 if (_lastPendingTime3 < expirationTime) {
13067 // There's lower priority work. It might be unsuspended. Try rendering
13068 // at that level immediately.
13069 return renderRoot.bind(null, root, _lastPendingTime3);
13070 }
13071
13072 var _msUntilTimeout = void 0;
13073 if (workInProgressRootLatestSuspenseTimeout !== Sync) {
13074 // We have processed a suspense config whose expiration time we can use as
13075 // the timeout.
13076 _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
13077 } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
13078 // This should never normally happen because only new updates cause
13079 // delayed states, so we should have processed something. However,
13080 // this could also happen in an offscreen tree.
13081 _msUntilTimeout = 0;
13082 } else {
13083 // If we don't have a suspense config, we're going to use a heuristic to
13084 var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
13085 var currentTimeMs = now();
13086 var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
13087 var timeElapsed = currentTimeMs - eventTimeMs;
13088 if (timeElapsed < 0) {
13089 // We get this wrong some time since we estimate the time.
13090 timeElapsed = 0;
13091 }
13092
13093 _msUntilTimeout = jnd(timeElapsed) - timeElapsed;
13094
13095 // Clamp the timeout to the expiration time.
13096 // TODO: Once the event time is exact instead of inferred from expiration time
13097 // we don't need this.
13098 if (timeUntilExpirationMs < _msUntilTimeout) {
13099 _msUntilTimeout = timeUntilExpirationMs;
13100 }
13101 }
13102
13103 // Don't bother with a very short suspense time.
13104 if (_msUntilTimeout > 10) {
13105 // The render is suspended, it hasn't timed out, and there's no lower
13106 // priority work to do. Instead of committing the fallback
13107 // immediately, wait for more data to arrive.
13108 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
13109 return null;
13110 }
13111 }
13112 // The work expired. Commit immediately.
13113 return commitRoot.bind(null, root);
13114 }
13115 case RootCompleted:
13116 {
13117 // The work completed. Ready to commit.
13118 if (!isSync &&
13119 // do not delay if we're inside an act() scope
13120 !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
13121 // If we have exceeded the minimum loading delay, which probably
13122 // means we have shown a spinner already, we might have to suspend
13123 // a bit longer to ensure that the spinner is shown for enough time.
13124 var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
13125 if (_msUntilTimeout2 > 10) {
13126 root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
13127 return null;
13128 }
13129 }
13130 return commitRoot.bind(null, root);
13131 }
13132 default:
13133 {
13134 (function () {
13135 {
13136 {
13137 throw ReactError(Error('Unknown root exit status.'));
13138 }
13139 }
13140 })();
13141 }
13142 }
13143}
13144
13145function markCommitTimeOfFallback() {
13146 globalMostRecentFallbackTime = now();
13147}
13148
13149function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
13150 if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Never) {
13151 workInProgressRootLatestProcessedExpirationTime = expirationTime;
13152 }
13153 if (suspenseConfig !== null) {
13154 if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Never) {
13155 workInProgressRootLatestSuspenseTimeout = expirationTime;
13156 // Most of the time we only have one config and getting wrong is not bad.
13157 workInProgressRootCanSuspendUsingConfig = suspenseConfig;
13158 }
13159 }
13160}
13161
13162function renderDidSuspend() {
13163 if (workInProgressRootExitStatus === RootIncomplete) {
13164 workInProgressRootExitStatus = RootSuspended;
13165 }
13166}
13167
13168function renderDidSuspendDelayIfPossible() {
13169 if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
13170 workInProgressRootExitStatus = RootSuspendedWithDelay;
13171 }
13172}
13173
13174function renderDidError() {
13175 if (workInProgressRootExitStatus !== RootCompleted) {
13176 workInProgressRootExitStatus = RootErrored;
13177 }
13178}
13179
13180// Called during render to determine if anything has suspended.
13181// Returns false if we're not sure.
13182function renderHasNotSuspendedYet() {
13183 // If something errored or completed, we can't really be sure,
13184 // so those are false.
13185 return workInProgressRootExitStatus === RootIncomplete;
13186}
13187
13188function inferTimeFromExpirationTime(expirationTime) {
13189 // We don't know exactly when the update was scheduled, but we can infer an
13190 // approximate start time from the expiration time.
13191 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
13192 return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
13193}
13194
13195function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
13196 // We don't know exactly when the update was scheduled, but we can infer an
13197 // approximate start time from the expiration time by subtracting the timeout
13198 // that was added to the event time.
13199 var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
13200 return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
13201}
13202
13203function workLoopSync() {
13204 // Already timed out, so perform work without checking if we need to yield.
13205 while (workInProgress !== null) {
13206 workInProgress = performUnitOfWork(workInProgress);
13207 }
13208}
13209
13210function workLoop() {
13211 // Perform work until Scheduler asks us to yield
13212 while (workInProgress !== null && !shouldYield()) {
13213 workInProgress = performUnitOfWork(workInProgress);
13214 }
13215}
13216
13217function performUnitOfWork(unitOfWork) {
13218 // The current, flushed, state of this fiber is the alternate. Ideally
13219 // nothing should rely on this, but relying on it here means that we don't
13220 // need an additional field on the work in progress.
13221 var current$$1 = unitOfWork.alternate;
13222
13223 startWorkTimer(unitOfWork);
13224 setCurrentFiber(unitOfWork);
13225
13226 var next = void 0;
13227 if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
13228 startProfilerTimer(unitOfWork);
13229 next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
13230 stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
13231 } else {
13232 next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
13233 }
13234
13235 resetCurrentFiber();
13236 unitOfWork.memoizedProps = unitOfWork.pendingProps;
13237 if (next === null) {
13238 // If this doesn't spawn new work, complete the current work.
13239 next = completeUnitOfWork(unitOfWork);
13240 }
13241
13242 ReactCurrentOwner$1.current = null;
13243 return next;
13244}
13245
13246function completeUnitOfWork(unitOfWork) {
13247 // Attempt to complete the current unit of work, then move to the next
13248 // sibling. If there are no more siblings, return to the parent fiber.
13249 workInProgress = unitOfWork;
13250 do {
13251 // The current, flushed, state of this fiber is the alternate. Ideally
13252 // nothing should rely on this, but relying on it here means that we don't
13253 // need an additional field on the work in progress.
13254 var current$$1 = workInProgress.alternate;
13255 var returnFiber = workInProgress.return;
13256
13257 // Check if the work completed or if something threw.
13258 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
13259 setCurrentFiber(workInProgress);
13260 var next = void 0;
13261 if (!enableProfilerTimer || (workInProgress.mode & ProfileMode) === NoMode) {
13262 next = completeWork(current$$1, workInProgress, renderExpirationTime);
13263 } else {
13264 startProfilerTimer(workInProgress);
13265 next = completeWork(current$$1, workInProgress, renderExpirationTime);
13266 // Update render duration assuming we didn't error.
13267 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
13268 }
13269 stopWorkTimer(workInProgress);
13270 resetCurrentFiber();
13271 resetChildExpirationTime(workInProgress);
13272
13273 if (next !== null) {
13274 // Completing this fiber spawned new work. Work on that next.
13275 return next;
13276 }
13277
13278 if (returnFiber !== null &&
13279 // Do not append effects to parents if a sibling failed to complete
13280 (returnFiber.effectTag & Incomplete) === NoEffect) {
13281 // Append all the effects of the subtree and this fiber onto the effect
13282 // list of the parent. The completion order of the children affects the
13283 // side-effect order.
13284 if (returnFiber.firstEffect === null) {
13285 returnFiber.firstEffect = workInProgress.firstEffect;
13286 }
13287 if (workInProgress.lastEffect !== null) {
13288 if (returnFiber.lastEffect !== null) {
13289 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
13290 }
13291 returnFiber.lastEffect = workInProgress.lastEffect;
13292 }
13293
13294 // If this fiber had side-effects, we append it AFTER the children's
13295 // side-effects. We can perform certain side-effects earlier if needed,
13296 // by doing multiple passes over the effect list. We don't want to
13297 // schedule our own side-effect on our own list because if end up
13298 // reusing children we'll schedule this effect onto itself since we're
13299 // at the end.
13300 var effectTag = workInProgress.effectTag;
13301
13302 // Skip both NoWork and PerformedWork tags when creating the effect
13303 // list. PerformedWork effect is read by React DevTools but shouldn't be
13304 // committed.
13305 if (effectTag > PerformedWork) {
13306 if (returnFiber.lastEffect !== null) {
13307 returnFiber.lastEffect.nextEffect = workInProgress;
13308 } else {
13309 returnFiber.firstEffect = workInProgress;
13310 }
13311 returnFiber.lastEffect = workInProgress;
13312 }
13313 }
13314 } else {
13315 // This fiber did not complete because something threw. Pop values off
13316 // the stack without entering the complete phase. If this is a boundary,
13317 // capture values if possible.
13318 var _next = unwindWork(workInProgress, renderExpirationTime);
13319
13320 // Because this fiber did not complete, don't reset its expiration time.
13321
13322 if (enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode) {
13323 // Record the render duration for the fiber that errored.
13324 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
13325
13326 // Include the time spent working on failed children before continuing.
13327 var actualDuration = workInProgress.actualDuration;
13328 var child = workInProgress.child;
13329 while (child !== null) {
13330 actualDuration += child.actualDuration;
13331 child = child.sibling;
13332 }
13333 workInProgress.actualDuration = actualDuration;
13334 }
13335
13336 if (_next !== null) {
13337 // If completing this work spawned new work, do that next. We'll come
13338 // back here again.
13339 // Since we're restarting, remove anything that is not a host effect
13340 // from the effect tag.
13341 // TODO: The name stopFailedWorkTimer is misleading because Suspense
13342 // also captures and restarts.
13343 stopFailedWorkTimer(workInProgress);
13344 _next.effectTag &= HostEffectMask;
13345 return _next;
13346 }
13347 stopWorkTimer(workInProgress);
13348
13349 if (returnFiber !== null) {
13350 // Mark the parent fiber as incomplete and clear its effect list.
13351 returnFiber.firstEffect = returnFiber.lastEffect = null;
13352 returnFiber.effectTag |= Incomplete;
13353 }
13354 }
13355
13356 var siblingFiber = workInProgress.sibling;
13357 if (siblingFiber !== null) {
13358 // If there is more work to do in this returnFiber, do that next.
13359 return siblingFiber;
13360 }
13361 // Otherwise, return to the parent
13362 workInProgress = returnFiber;
13363 } while (workInProgress !== null);
13364
13365 // We've reached the root.
13366 if (workInProgressRootExitStatus === RootIncomplete) {
13367 workInProgressRootExitStatus = RootCompleted;
13368 }
13369 return null;
13370}
13371
13372function resetChildExpirationTime(completedWork) {
13373 if (renderExpirationTime !== Never && completedWork.childExpirationTime === Never) {
13374 // The children of this component are hidden. Don't bubble their
13375 // expiration times.
13376 return;
13377 }
13378
13379 var newChildExpirationTime = NoWork;
13380
13381 // Bubble up the earliest expiration time.
13382 if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) {
13383 // In profiling mode, resetChildExpirationTime is also used to reset
13384 // profiler durations.
13385 var actualDuration = completedWork.actualDuration;
13386 var treeBaseDuration = completedWork.selfBaseDuration;
13387
13388 // When a fiber is cloned, its actualDuration is reset to 0. This value will
13389 // only be updated if work is done on the fiber (i.e. it doesn't bailout).
13390 // When work is done, it should bubble to the parent's actualDuration. If
13391 // the fiber has not been cloned though, (meaning no work was done), then
13392 // this value will reflect the amount of time spent working on a previous
13393 // render. In that case it should not bubble. We determine whether it was
13394 // cloned by comparing the child pointer.
13395 var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
13396
13397 var child = completedWork.child;
13398 while (child !== null) {
13399 var childUpdateExpirationTime = child.expirationTime;
13400 var childChildExpirationTime = child.childExpirationTime;
13401 if (childUpdateExpirationTime > newChildExpirationTime) {
13402 newChildExpirationTime = childUpdateExpirationTime;
13403 }
13404 if (childChildExpirationTime > newChildExpirationTime) {
13405 newChildExpirationTime = childChildExpirationTime;
13406 }
13407 if (shouldBubbleActualDurations) {
13408 actualDuration += child.actualDuration;
13409 }
13410 treeBaseDuration += child.treeBaseDuration;
13411 child = child.sibling;
13412 }
13413 completedWork.actualDuration = actualDuration;
13414 completedWork.treeBaseDuration = treeBaseDuration;
13415 } else {
13416 var _child = completedWork.child;
13417 while (_child !== null) {
13418 var _childUpdateExpirationTime = _child.expirationTime;
13419 var _childChildExpirationTime = _child.childExpirationTime;
13420 if (_childUpdateExpirationTime > newChildExpirationTime) {
13421 newChildExpirationTime = _childUpdateExpirationTime;
13422 }
13423 if (_childChildExpirationTime > newChildExpirationTime) {
13424 newChildExpirationTime = _childChildExpirationTime;
13425 }
13426 _child = _child.sibling;
13427 }
13428 }
13429
13430 completedWork.childExpirationTime = newChildExpirationTime;
13431}
13432
13433function commitRoot(root) {
13434 var renderPriorityLevel = getCurrentPriorityLevel();
13435 runWithPriority(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
13436 // If there are passive effects, schedule a callback to flush them. This goes
13437 // outside commitRootImpl so that it inherits the priority of the render.
13438 if (rootWithPendingPassiveEffects !== null) {
13439 scheduleCallback(NormalPriority, function () {
13440 flushPassiveEffects();
13441 return null;
13442 });
13443 }
13444 return null;
13445}
13446
13447function commitRootImpl(root, renderPriorityLevel) {
13448 flushPassiveEffects();
13449 flushRenderPhaseStrictModeWarningsInDEV();
13450
13451 (function () {
13452 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
13453 {
13454 throw ReactError(Error('Should not already be working.'));
13455 }
13456 }
13457 })();
13458
13459 var finishedWork = root.finishedWork;
13460 var expirationTime = root.finishedExpirationTime;
13461 if (finishedWork === null) {
13462 return null;
13463 }
13464 root.finishedWork = null;
13465 root.finishedExpirationTime = NoWork;
13466
13467 (function () {
13468 if (!(finishedWork !== root.current)) {
13469 {
13470 throw ReactError(Error('Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.'));
13471 }
13472 }
13473 })();
13474
13475 // commitRoot never returns a continuation; it always finishes synchronously.
13476 // So we can clear these now to allow a new callback to be scheduled.
13477 root.callbackNode = null;
13478 root.callbackExpirationTime = NoWork;
13479
13480 startCommitTimer();
13481
13482 // Update the first and last pending times on this root. The new first
13483 // pending time is whatever is left on the root fiber.
13484 var updateExpirationTimeBeforeCommit = finishedWork.expirationTime;
13485 var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime;
13486 var firstPendingTimeBeforeCommit = childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit;
13487 root.firstPendingTime = firstPendingTimeBeforeCommit;
13488 if (firstPendingTimeBeforeCommit < root.lastPendingTime) {
13489 // This usually means we've finished all the work, but it can also happen
13490 // when something gets downprioritized during render, like a hidden tree.
13491 root.lastPendingTime = firstPendingTimeBeforeCommit;
13492 }
13493
13494 if (root === workInProgressRoot) {
13495 // We can reset these now that they are finished.
13496 workInProgressRoot = null;
13497 workInProgress = null;
13498 renderExpirationTime = NoWork;
13499 } else {}
13500 // This indicates that the last root we worked on is not the same one that
13501 // we're committing now. This most commonly happens when a suspended root
13502 // times out.
13503
13504
13505 // Get the list of effects.
13506 var firstEffect = void 0;
13507 if (finishedWork.effectTag > PerformedWork) {
13508 // A fiber's effect list consists only of its children, not itself. So if
13509 // the root has an effect, we need to add it to the end of the list. The
13510 // resulting list is the set that would belong to the root's parent, if it
13511 // had one; that is, all the effects in the tree including the root.
13512 if (finishedWork.lastEffect !== null) {
13513 finishedWork.lastEffect.nextEffect = finishedWork;
13514 firstEffect = finishedWork.firstEffect;
13515 } else {
13516 firstEffect = finishedWork;
13517 }
13518 } else {
13519 // There is no effect on the root.
13520 firstEffect = finishedWork.firstEffect;
13521 }
13522
13523 if (firstEffect !== null) {
13524 var prevExecutionContext = executionContext;
13525 executionContext |= CommitContext;
13526 var prevInteractions = null;
13527 if (enableSchedulerTracing) {
13528 prevInteractions = tracing.__interactionsRef.current;
13529 tracing.__interactionsRef.current = root.memoizedInteractions;
13530 }
13531
13532 // Reset this to null before calling lifecycles
13533 ReactCurrentOwner$1.current = null;
13534
13535 // The commit phase is broken into several sub-phases. We do a separate pass
13536 // of the effect list for each phase: all mutation effects come before all
13537 // layout effects, and so on.
13538
13539 // The first phase a "before mutation" phase. We use this phase to read the
13540 // state of the host tree right before we mutate it. This is where
13541 // getSnapshotBeforeUpdate is called.
13542 startCommitSnapshotEffectsTimer();
13543 prepareForCommit(root.containerInfo);
13544 nextEffect = firstEffect;
13545 do {
13546 {
13547 invokeGuardedCallback(null, commitBeforeMutationEffects, null);
13548 if (hasCaughtError()) {
13549 (function () {
13550 if (!(nextEffect !== null)) {
13551 {
13552 throw ReactError(Error('Should be working on an effect.'));
13553 }
13554 }
13555 })();
13556 var error = clearCaughtError();
13557 captureCommitPhaseError(nextEffect, error);
13558 nextEffect = nextEffect.nextEffect;
13559 }
13560 }
13561 } while (nextEffect !== null);
13562 stopCommitSnapshotEffectsTimer();
13563
13564 if (enableProfilerTimer) {
13565 // Mark the current commit time to be shared by all Profilers in this
13566 // batch. This enables them to be grouped later.
13567 recordCommitTime();
13568 }
13569
13570 // The next phase is the mutation phase, where we mutate the host tree.
13571 startCommitHostEffectsTimer();
13572 nextEffect = firstEffect;
13573 do {
13574 {
13575 invokeGuardedCallback(null, commitMutationEffects, null, renderPriorityLevel);
13576 if (hasCaughtError()) {
13577 (function () {
13578 if (!(nextEffect !== null)) {
13579 {
13580 throw ReactError(Error('Should be working on an effect.'));
13581 }
13582 }
13583 })();
13584 var _error = clearCaughtError();
13585 captureCommitPhaseError(nextEffect, _error);
13586 nextEffect = nextEffect.nextEffect;
13587 }
13588 }
13589 } while (nextEffect !== null);
13590 stopCommitHostEffectsTimer();
13591 resetAfterCommit(root.containerInfo);
13592
13593 // The work-in-progress tree is now the current tree. This must come after
13594 // the mutation phase, so that the previous tree is still current during
13595 // componentWillUnmount, but before the layout phase, so that the finished
13596 // work is current during componentDidMount/Update.
13597 root.current = finishedWork;
13598
13599 // The next phase is the layout phase, where we call effects that read
13600 // the host tree after it's been mutated. The idiomatic use case for this is
13601 // layout, but class component lifecycles also fire here for legacy reasons.
13602 startCommitLifeCyclesTimer();
13603 nextEffect = firstEffect;
13604 do {
13605 {
13606 invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
13607 if (hasCaughtError()) {
13608 (function () {
13609 if (!(nextEffect !== null)) {
13610 {
13611 throw ReactError(Error('Should be working on an effect.'));
13612 }
13613 }
13614 })();
13615 var _error2 = clearCaughtError();
13616 captureCommitPhaseError(nextEffect, _error2);
13617 nextEffect = nextEffect.nextEffect;
13618 }
13619 }
13620 } while (nextEffect !== null);
13621 stopCommitLifeCyclesTimer();
13622
13623 nextEffect = null;
13624
13625 // Tell Scheduler to yield at the end of the frame, so the browser has an
13626 // opportunity to paint.
13627 requestPaint();
13628
13629 if (enableSchedulerTracing) {
13630 tracing.__interactionsRef.current = prevInteractions;
13631 }
13632 executionContext = prevExecutionContext;
13633 } else {
13634 // No effects.
13635 root.current = finishedWork;
13636 // Measure these anyway so the flamegraph explicitly shows that there were
13637 // no effects.
13638 // TODO: Maybe there's a better way to report this.
13639 startCommitSnapshotEffectsTimer();
13640 stopCommitSnapshotEffectsTimer();
13641 if (enableProfilerTimer) {
13642 recordCommitTime();
13643 }
13644 startCommitHostEffectsTimer();
13645 stopCommitHostEffectsTimer();
13646 startCommitLifeCyclesTimer();
13647 stopCommitLifeCyclesTimer();
13648 }
13649
13650 stopCommitTimer();
13651
13652 var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
13653
13654 if (rootDoesHavePassiveEffects) {
13655 // This commit has passive effects. Stash a reference to them. But don't
13656 // schedule a callback until after flushing layout work.
13657 rootDoesHavePassiveEffects = false;
13658 rootWithPendingPassiveEffects = root;
13659 pendingPassiveEffectsExpirationTime = expirationTime;
13660 pendingPassiveEffectsRenderPriority = renderPriorityLevel;
13661 } else {
13662 // We are done with the effect chain at this point so let's clear the
13663 // nextEffect pointers to assist with GC. If we have passive effects, we'll
13664 // clear this in flushPassiveEffects.
13665 nextEffect = firstEffect;
13666 while (nextEffect !== null) {
13667 var nextNextEffect = nextEffect.nextEffect;
13668 nextEffect.nextEffect = null;
13669 nextEffect = nextNextEffect;
13670 }
13671 }
13672
13673 // Check if there's remaining work on this root
13674 var remainingExpirationTime = root.firstPendingTime;
13675 if (remainingExpirationTime !== NoWork) {
13676 var currentTime = requestCurrentTime();
13677 var priorityLevel = inferPriorityFromExpirationTime(currentTime, remainingExpirationTime);
13678
13679 if (enableSchedulerTracing) {
13680 if (spawnedWorkDuringRender !== null) {
13681 var expirationTimes = spawnedWorkDuringRender;
13682 spawnedWorkDuringRender = null;
13683 for (var i = 0; i < expirationTimes.length; i++) {
13684 scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
13685 }
13686 }
13687 }
13688
13689 scheduleCallbackForRoot(root, priorityLevel, remainingExpirationTime);
13690 } else {
13691 // If there's no remaining work, we can clear the set of already failed
13692 // error boundaries.
13693 legacyErrorBoundariesThatAlreadyFailed = null;
13694 }
13695
13696 if (enableSchedulerTracing) {
13697 if (!rootDidHavePassiveEffects) {
13698 // If there are no passive effects, then we can complete the pending interactions.
13699 // Otherwise, we'll wait until after the passive effects are flushed.
13700 // Wait to do this until after remaining work has been scheduled,
13701 // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
13702 finishPendingInteractions(root, expirationTime);
13703 }
13704 }
13705
13706 onCommitRoot(finishedWork.stateNode, expirationTime);
13707
13708 if (remainingExpirationTime === Sync) {
13709 // Count the number of times the root synchronously re-renders without
13710 // finishing. If there are too many, it indicates an infinite update loop.
13711 if (root === rootWithNestedUpdates) {
13712 nestedUpdateCount++;
13713 } else {
13714 nestedUpdateCount = 0;
13715 rootWithNestedUpdates = root;
13716 }
13717 } else {
13718 nestedUpdateCount = 0;
13719 }
13720
13721 if (hasUncaughtError) {
13722 hasUncaughtError = false;
13723 var _error3 = firstUncaughtError;
13724 firstUncaughtError = null;
13725 throw _error3;
13726 }
13727
13728 if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
13729 // This is a legacy edge case. We just committed the initial mount of
13730 // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
13731 // synchronously, but layout updates should be deferred until the end
13732 // of the batch.
13733 return null;
13734 }
13735
13736 // If layout work was scheduled, flush it now.
13737 flushSyncCallbackQueue();
13738 return null;
13739}
13740
13741function commitBeforeMutationEffects() {
13742 while (nextEffect !== null) {
13743 if ((nextEffect.effectTag & Snapshot) !== NoEffect) {
13744 setCurrentFiber(nextEffect);
13745 recordEffect();
13746
13747 var current$$1 = nextEffect.alternate;
13748 commitBeforeMutationLifeCycles(current$$1, nextEffect);
13749
13750 resetCurrentFiber();
13751 }
13752 nextEffect = nextEffect.nextEffect;
13753 }
13754}
13755
13756function commitMutationEffects(renderPriorityLevel) {
13757 // TODO: Should probably move the bulk of this function to commitWork.
13758 while (nextEffect !== null) {
13759 setCurrentFiber(nextEffect);
13760
13761 var effectTag = nextEffect.effectTag;
13762
13763 if (effectTag & ContentReset) {
13764 commitResetTextContent(nextEffect);
13765 }
13766
13767 if (effectTag & Ref) {
13768 var current$$1 = nextEffect.alternate;
13769 if (current$$1 !== null) {
13770 commitDetachRef(current$$1);
13771 }
13772 }
13773
13774 // The following switch statement is only concerned about placement,
13775 // updates, and deletions. To avoid needing to add a case for every possible
13776 // bitmap value, we remove the secondary effects from the effect tag and
13777 // switch on that value.
13778 var primaryEffectTag = effectTag & (Placement | Update | Deletion);
13779 switch (primaryEffectTag) {
13780 case Placement:
13781 {
13782 commitPlacement(nextEffect);
13783 // Clear the "placement" from effect tag so that we know that this is
13784 // inserted, before any life-cycles like componentDidMount gets called.
13785 // TODO: findDOMNode doesn't rely on this any more but isMounted does
13786 // and isMounted is deprecated anyway so we should be able to kill this.
13787 nextEffect.effectTag &= ~Placement;
13788 break;
13789 }
13790 case PlacementAndUpdate:
13791 {
13792 // Placement
13793 commitPlacement(nextEffect);
13794 // Clear the "placement" from effect tag so that we know that this is
13795 // inserted, before any life-cycles like componentDidMount gets called.
13796 nextEffect.effectTag &= ~Placement;
13797
13798 // Update
13799 var _current = nextEffect.alternate;
13800 commitWork(_current, nextEffect);
13801 break;
13802 }
13803 case Update:
13804 {
13805 var _current2 = nextEffect.alternate;
13806 commitWork(_current2, nextEffect);
13807 break;
13808 }
13809 case Deletion:
13810 {
13811 commitDeletion(nextEffect, renderPriorityLevel);
13812 break;
13813 }
13814 }
13815
13816 // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
13817 recordEffect();
13818
13819 resetCurrentFiber();
13820 nextEffect = nextEffect.nextEffect;
13821 }
13822}
13823
13824function commitLayoutEffects(root, committedExpirationTime) {
13825 // TODO: Should probably move the bulk of this function to commitWork.
13826 while (nextEffect !== null) {
13827 setCurrentFiber(nextEffect);
13828
13829 var effectTag = nextEffect.effectTag;
13830
13831 if (effectTag & (Update | Callback)) {
13832 recordEffect();
13833 var current$$1 = nextEffect.alternate;
13834 commitLifeCycles(root, current$$1, nextEffect, committedExpirationTime);
13835 }
13836
13837 if (effectTag & Ref) {
13838 recordEffect();
13839 commitAttachRef(nextEffect);
13840 }
13841
13842 if (effectTag & Passive) {
13843 rootDoesHavePassiveEffects = true;
13844 }
13845
13846 resetCurrentFiber();
13847 nextEffect = nextEffect.nextEffect;
13848 }
13849}
13850
13851function flushPassiveEffects() {
13852 if (rootWithPendingPassiveEffects === null) {
13853 return false;
13854 }
13855 var root = rootWithPendingPassiveEffects;
13856 var expirationTime = pendingPassiveEffectsExpirationTime;
13857 var renderPriorityLevel = pendingPassiveEffectsRenderPriority;
13858 rootWithPendingPassiveEffects = null;
13859 pendingPassiveEffectsExpirationTime = NoWork;
13860 pendingPassiveEffectsRenderPriority = NoPriority;
13861 var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
13862 return runWithPriority(priorityLevel, flushPassiveEffectsImpl.bind(null, root, expirationTime));
13863}
13864
13865function flushPassiveEffectsImpl(root, expirationTime) {
13866 var prevInteractions = null;
13867 if (enableSchedulerTracing) {
13868 prevInteractions = tracing.__interactionsRef.current;
13869 tracing.__interactionsRef.current = root.memoizedInteractions;
13870 }
13871
13872 (function () {
13873 if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
13874 {
13875 throw ReactError(Error('Cannot flush passive effects while already rendering.'));
13876 }
13877 }
13878 })();
13879 var prevExecutionContext = executionContext;
13880 executionContext |= CommitContext;
13881
13882 // Note: This currently assumes there are no passive effects on the root
13883 // fiber, because the root is not part of its own effect list. This could
13884 // change in the future.
13885 var effect = root.current.firstEffect;
13886 while (effect !== null) {
13887 {
13888 setCurrentFiber(effect);
13889 invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
13890 if (hasCaughtError()) {
13891 (function () {
13892 if (!(effect !== null)) {
13893 {
13894 throw ReactError(Error('Should be working on an effect.'));
13895 }
13896 }
13897 })();
13898 var error = clearCaughtError();
13899 captureCommitPhaseError(effect, error);
13900 }
13901 resetCurrentFiber();
13902 }
13903 var nextNextEffect = effect.nextEffect;
13904 // Remove nextEffect pointer to assist GC
13905 effect.nextEffect = null;
13906 effect = nextNextEffect;
13907 }
13908
13909 if (enableSchedulerTracing) {
13910 tracing.__interactionsRef.current = prevInteractions;
13911 finishPendingInteractions(root, expirationTime);
13912 }
13913
13914 executionContext = prevExecutionContext;
13915 flushSyncCallbackQueue();
13916
13917 // If additional passive effects were scheduled, increment a counter. If this
13918 // exceeds the limit, we'll fire a warning.
13919 nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
13920
13921 return true;
13922}
13923
13924function isAlreadyFailedLegacyErrorBoundary(instance) {
13925 return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
13926}
13927
13928function markLegacyErrorBoundaryAsFailed(instance) {
13929 if (legacyErrorBoundariesThatAlreadyFailed === null) {
13930 legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
13931 } else {
13932 legacyErrorBoundariesThatAlreadyFailed.add(instance);
13933 }
13934}
13935
13936function prepareToThrowUncaughtError(error) {
13937 if (!hasUncaughtError) {
13938 hasUncaughtError = true;
13939 firstUncaughtError = error;
13940 }
13941}
13942var onUncaughtError = prepareToThrowUncaughtError;
13943
13944function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
13945 var errorInfo = createCapturedValue(error, sourceFiber);
13946 var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
13947 enqueueUpdate(rootFiber, update);
13948 var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
13949 if (root !== null) {
13950 scheduleCallbackForRoot(root, ImmediatePriority, Sync);
13951 }
13952}
13953
13954function captureCommitPhaseError(sourceFiber, error) {
13955 if (sourceFiber.tag === HostRoot) {
13956 // Error was thrown at the root. There is no parent, so the root
13957 // itself should capture it.
13958 captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
13959 return;
13960 }
13961
13962 var fiber = sourceFiber.return;
13963 while (fiber !== null) {
13964 if (fiber.tag === HostRoot) {
13965 captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
13966 return;
13967 } else if (fiber.tag === ClassComponent) {
13968 var ctor = fiber.type;
13969 var instance = fiber.stateNode;
13970 if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
13971 var errorInfo = createCapturedValue(error, sourceFiber);
13972 var update = createClassErrorUpdate(fiber, errorInfo,
13973 // TODO: This is always sync
13974 Sync);
13975 enqueueUpdate(fiber, update);
13976 var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
13977 if (root !== null) {
13978 scheduleCallbackForRoot(root, ImmediatePriority, Sync);
13979 }
13980 return;
13981 }
13982 }
13983 fiber = fiber.return;
13984 }
13985}
13986
13987function pingSuspendedRoot(root, thenable, suspendedTime) {
13988 var pingCache = root.pingCache;
13989 if (pingCache !== null) {
13990 // The thenable resolved, so we no longer need to memoize, because it will
13991 // never be thrown again.
13992 pingCache.delete(thenable);
13993 }
13994
13995 if (workInProgressRoot === root && renderExpirationTime === suspendedTime) {
13996 // Received a ping at the same priority level at which we're currently
13997 // rendering. We might want to restart this render. This should mirror
13998 // the logic of whether or not a root suspends once it completes.
13999
14000 // TODO: If we're rendering sync either due to Sync, Batched or expired,
14001 // we should probably never restart.
14002
14003 // If we're suspended with delay, we'll always suspend so we can always
14004 // restart. If we're suspended without any updates, it might be a retry.
14005 // If it's early in the retry we can restart. We can't know for sure
14006 // whether we'll eventually process an update during this render pass,
14007 // but it's somewhat unlikely that we get to a ping before that, since
14008 // getting to the root most update is usually very fast.
14009 if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
14010 // Restart from the root. Don't need to schedule a ping because
14011 // we're already working on this tree.
14012 prepareFreshStack(root, renderExpirationTime);
14013 } else {
14014 // Even though we can't restart right now, we might get an
14015 // opportunity later. So we mark this render as having a ping.
14016 workInProgressRootHasPendingPing = true;
14017 }
14018 return;
14019 }
14020
14021 var lastPendingTime = root.lastPendingTime;
14022 if (lastPendingTime < suspendedTime) {
14023 // The root is no longer suspended at this time.
14024 return;
14025 }
14026
14027 var pingTime = root.pingTime;
14028 if (pingTime !== NoWork && pingTime < suspendedTime) {
14029 // There's already a lower priority ping scheduled.
14030 return;
14031 }
14032
14033 // Mark the time at which this ping was scheduled.
14034 root.pingTime = suspendedTime;
14035
14036 if (root.finishedExpirationTime === suspendedTime) {
14037 // If there's a pending fallback waiting to commit, throw it away.
14038 root.finishedExpirationTime = NoWork;
14039 root.finishedWork = null;
14040 }
14041
14042 var currentTime = requestCurrentTime();
14043 var priorityLevel = inferPriorityFromExpirationTime(currentTime, suspendedTime);
14044 scheduleCallbackForRoot(root, priorityLevel, suspendedTime);
14045}
14046
14047function retryTimedOutBoundary(boundaryFiber) {
14048 // The boundary fiber (a Suspense component or SuspenseList component)
14049 // previously was rendered in its fallback state. One of the promises that
14050 // suspended it has resolved, which means at least part of the tree was
14051 // likely unblocked. Try rendering again, at a new expiration time.
14052 var currentTime = requestCurrentTime();
14053 var suspenseConfig = null; // Retries don't carry over the already committed update.
14054 var retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
14055 // TODO: Special case idle priority?
14056 var priorityLevel = inferPriorityFromExpirationTime(currentTime, retryTime);
14057 var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
14058 if (root !== null) {
14059 scheduleCallbackForRoot(root, priorityLevel, retryTime);
14060 }
14061}
14062
14063function resolveRetryThenable(boundaryFiber, thenable) {
14064 var retryCache = void 0;
14065 if (enableSuspenseServerRenderer) {
14066 switch (boundaryFiber.tag) {
14067 case SuspenseComponent:
14068 retryCache = boundaryFiber.stateNode;
14069 break;
14070 case DehydratedSuspenseComponent:
14071 retryCache = boundaryFiber.memoizedState;
14072 break;
14073 default:
14074 (function () {
14075 {
14076 {
14077 throw ReactError(Error('Pinged unknown suspense boundary type. This is probably a bug in React.'));
14078 }
14079 }
14080 })();
14081 }
14082 } else {
14083 retryCache = boundaryFiber.stateNode;
14084 }
14085
14086 if (retryCache !== null) {
14087 // The thenable resolved, so we no longer need to memoize, because it will
14088 // never be thrown again.
14089 retryCache.delete(thenable);
14090 }
14091
14092 retryTimedOutBoundary(boundaryFiber);
14093}
14094
14095// Computes the next Just Noticeable Difference (JND) boundary.
14096// The theory is that a person can't tell the difference between small differences in time.
14097// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
14098// difference in the experience. However, waiting for longer might mean that we can avoid
14099// showing an intermediate loading state. The longer we have already waited, the harder it
14100// is to tell small differences in time. Therefore, the longer we've already waited,
14101// the longer we can wait additionally. At some point we have to give up though.
14102// We pick a train model where the next boundary commits at a consistent schedule.
14103// These particular numbers are vague estimates. We expect to adjust them based on research.
14104function jnd(timeElapsed) {
14105 return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
14106}
14107
14108function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
14109 var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
14110 if (busyMinDurationMs <= 0) {
14111 return 0;
14112 }
14113 var busyDelayMs = suspenseConfig.busyDelayMs | 0;
14114
14115 // Compute the time until this render pass would expire.
14116 var currentTimeMs = now();
14117 var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
14118 var timeElapsed = currentTimeMs - eventTimeMs;
14119 if (timeElapsed <= busyDelayMs) {
14120 // If we haven't yet waited longer than the initial delay, we don't
14121 // have to wait any additional time.
14122 return 0;
14123 }
14124 var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed;
14125 // This is the value that is passed to `setTimeout`.
14126 return msUntilTimeout;
14127}
14128
14129function checkForNestedUpdates() {
14130 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
14131 nestedUpdateCount = 0;
14132 rootWithNestedUpdates = null;
14133 (function () {
14134 {
14135 {
14136 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.'));
14137 }
14138 }
14139 })();
14140 }
14141
14142 {
14143 if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
14144 nestedPassiveUpdateCount = 0;
14145 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.');
14146 }
14147 }
14148}
14149
14150function flushRenderPhaseStrictModeWarningsInDEV() {
14151 {
14152 ReactStrictModeWarnings.flushLegacyContextWarning();
14153
14154 if (warnAboutDeprecatedLifecycles) {
14155 ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
14156 }
14157 }
14158}
14159
14160function stopFinishedWorkLoopTimer() {
14161 var didCompleteRoot = true;
14162 stopWorkLoopTimer(interruptedBy, didCompleteRoot);
14163 interruptedBy = null;
14164}
14165
14166function stopInterruptedWorkLoopTimer() {
14167 // TODO: Track which fiber caused the interruption.
14168 var didCompleteRoot = false;
14169 stopWorkLoopTimer(interruptedBy, didCompleteRoot);
14170 interruptedBy = null;
14171}
14172
14173function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
14174 if (enableUserTimingAPI && workInProgressRoot !== null && updateExpirationTime > renderExpirationTime) {
14175 interruptedBy = fiberThatReceivedUpdate;
14176 }
14177}
14178
14179var didWarnStateUpdateForUnmountedComponent = null;
14180function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
14181 {
14182 var tag = fiber.tag;
14183 if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
14184 // Only warn for user-defined components, not internal ones like Suspense.
14185 return;
14186 }
14187 // We show the whole stack but dedupe on the top component's name because
14188 // the problematic code almost always lies inside that component.
14189 var componentName = getComponentName(fiber.type) || 'ReactComponent';
14190 if (didWarnStateUpdateForUnmountedComponent !== null) {
14191 if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
14192 return;
14193 }
14194 didWarnStateUpdateForUnmountedComponent.add(componentName);
14195 } else {
14196 didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
14197 }
14198 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));
14199 }
14200}
14201
14202var beginWork$$1 = void 0;
14203if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
14204 var dummyFiber = null;
14205 beginWork$$1 = function (current$$1, unitOfWork, expirationTime) {
14206 // If a component throws an error, we replay it again in a synchronously
14207 // dispatched event, so that the debugger will treat it as an uncaught
14208 // error See ReactErrorUtils for more information.
14209
14210 // Before entering the begin phase, copy the work-in-progress onto a dummy
14211 // fiber. If beginWork throws, we'll use this to reset the state.
14212 var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
14213 try {
14214 return beginWork$1(current$$1, unitOfWork, expirationTime);
14215 } catch (originalError) {
14216 if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
14217 // Don't replay promises. Treat everything else like an error.
14218 throw originalError;
14219 }
14220
14221 // Keep this code in sync with renderRoot; any changes here must have
14222 // corresponding changes there.
14223 resetContextDependencies();
14224 resetHooks();
14225
14226 // Unwind the failed stack frame
14227 unwindInterruptedWork(unitOfWork);
14228
14229 // Restore the original properties of the fiber.
14230 assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
14231
14232 if (enableProfilerTimer && unitOfWork.mode & ProfileMode) {
14233 // Reset the profiler timer.
14234 startProfilerTimer(unitOfWork);
14235 }
14236
14237 // Run beginWork again.
14238 invokeGuardedCallback(null, beginWork$1, null, current$$1, unitOfWork, expirationTime);
14239
14240 if (hasCaughtError()) {
14241 var replayError = clearCaughtError();
14242 // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
14243 // Rethrow this error instead of the original one.
14244 throw replayError;
14245 } else {
14246 // This branch is reachable if the render phase is impure.
14247 throw originalError;
14248 }
14249 }
14250 };
14251} else {
14252 beginWork$$1 = beginWork$1;
14253}
14254
14255var didWarnAboutUpdateInRender = false;
14256var didWarnAboutUpdateInGetChildContext = false;
14257function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
14258 {
14259 if (fiber.tag === ClassComponent) {
14260 switch (phase) {
14261 case 'getChildContext':
14262 if (didWarnAboutUpdateInGetChildContext) {
14263 return;
14264 }
14265 warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
14266 didWarnAboutUpdateInGetChildContext = true;
14267 break;
14268 case 'render':
14269 if (didWarnAboutUpdateInRender) {
14270 return;
14271 }
14272 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.');
14273 didWarnAboutUpdateInRender = true;
14274 break;
14275 }
14276 }
14277 }
14278}
14279
14280// a 'shared' variable that changes when act() opens/closes in tests.
14281var IsThisRendererActing = { current: false };
14282
14283function warnIfNotScopedWithMatchingAct(fiber) {
14284 {
14285 if (warnsIfNotActing === true && IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
14286 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));
14287 }
14288 }
14289}
14290
14291function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
14292 {
14293 if (warnsIfNotActing === true && (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
14294 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));
14295 }
14296 }
14297}
14298
14299function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
14300 {
14301 if (warnsIfNotActing === true && executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
14302 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));
14303 }
14304 }
14305}
14306
14307var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV;
14308
14309// In tests, we want to enforce a mocked scheduler.
14310var didWarnAboutUnmockedScheduler = false;
14311// TODO Before we release concurrent mode, revisit this and decide whether a mocked
14312// scheduler is the actual recommendation. The alternative could be a testing build,
14313// a new lib, or whatever; we dunno just yet. This message is for early adopters
14314// to get their tests right.
14315
14316function warnIfUnmockedScheduler(fiber) {
14317 {
14318 if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) {
14319 if (fiber.mode & BatchedMode || fiber.mode & ConcurrentMode) {
14320 didWarnAboutUnmockedScheduler = true;
14321 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');
14322 } else if (warnAboutUnmockedScheduler === true) {
14323 didWarnAboutUnmockedScheduler = true;
14324 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');
14325 }
14326 }
14327 }
14328}
14329
14330var componentsThatTriggeredHighPriSuspend = null;
14331function checkForWrongSuspensePriorityInDEV(sourceFiber) {
14332 {
14333 var currentPriorityLevel = getCurrentPriorityLevel();
14334 if ((sourceFiber.mode & ConcurrentMode) !== NoEffect && (currentPriorityLevel === UserBlockingPriority || currentPriorityLevel === ImmediatePriority)) {
14335 var workInProgressNode = sourceFiber;
14336 while (workInProgressNode !== null) {
14337 // Add the component that triggered the suspense
14338 var current$$1 = workInProgressNode.alternate;
14339 if (current$$1 !== null) {
14340 // TODO: warn component that triggers the high priority
14341 // suspend is the HostRoot
14342 switch (workInProgressNode.tag) {
14343 case ClassComponent:
14344 // Loop through the component's update queue and see whether the component
14345 // has triggered any high priority updates
14346 var updateQueue = current$$1.updateQueue;
14347 if (updateQueue !== null) {
14348 var update = updateQueue.firstUpdate;
14349 while (update !== null) {
14350 var priorityLevel = update.priority;
14351 if (priorityLevel === UserBlockingPriority || priorityLevel === ImmediatePriority) {
14352 if (componentsThatTriggeredHighPriSuspend === null) {
14353 componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
14354 } else {
14355 componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
14356 }
14357 break;
14358 }
14359 update = update.next;
14360 }
14361 }
14362 break;
14363 case FunctionComponent:
14364 case ForwardRef:
14365 case SimpleMemoComponent:
14366 if (workInProgressNode.memoizedState !== null && workInProgressNode.memoizedState.baseUpdate !== null) {
14367 var _update = workInProgressNode.memoizedState.baseUpdate;
14368 // Loop through the functional component's memoized state to see whether
14369 // the component has triggered any high pri updates
14370 while (_update !== null) {
14371 var priority = _update.priority;
14372 if (priority === UserBlockingPriority || priority === ImmediatePriority) {
14373 if (componentsThatTriggeredHighPriSuspend === null) {
14374 componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
14375 } else {
14376 componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
14377 }
14378 break;
14379 }
14380 if (_update.next === workInProgressNode.memoizedState.baseUpdate) {
14381 break;
14382 }
14383 _update = _update.next;
14384 }
14385 }
14386 break;
14387 default:
14388 break;
14389 }
14390 }
14391 workInProgressNode = workInProgressNode.return;
14392 }
14393 }
14394 }
14395}
14396
14397function flushSuspensePriorityWarningInDEV() {
14398 {
14399 if (componentsThatTriggeredHighPriSuspend !== null) {
14400 var componentNames = [];
14401 componentsThatTriggeredHighPriSuspend.forEach(function (name) {
14402 return componentNames.push(name);
14403 });
14404 componentsThatTriggeredHighPriSuspend = null;
14405
14406 if (componentNames.length > 0) {
14407 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.',
14408 // TODO: Add link to React docs with more information, once it exists
14409 componentNames.sort().join(', '));
14410 }
14411 }
14412 }
14413}
14414
14415function computeThreadID(root, expirationTime) {
14416 // Interaction threads are unique per root and expiration time.
14417 return expirationTime * 1000 + root.interactionThreadID;
14418}
14419
14420function markSpawnedWork(expirationTime) {
14421 if (!enableSchedulerTracing) {
14422 return;
14423 }
14424 if (spawnedWorkDuringRender === null) {
14425 spawnedWorkDuringRender = [expirationTime];
14426 } else {
14427 spawnedWorkDuringRender.push(expirationTime);
14428 }
14429}
14430
14431function scheduleInteractions(root, expirationTime, interactions) {
14432 if (!enableSchedulerTracing) {
14433 return;
14434 }
14435
14436 if (interactions.size > 0) {
14437 var pendingInteractionMap = root.pendingInteractionMap;
14438 var pendingInteractions = pendingInteractionMap.get(expirationTime);
14439 if (pendingInteractions != null) {
14440 interactions.forEach(function (interaction) {
14441 if (!pendingInteractions.has(interaction)) {
14442 // Update the pending async work count for previously unscheduled interaction.
14443 interaction.__count++;
14444 }
14445
14446 pendingInteractions.add(interaction);
14447 });
14448 } else {
14449 pendingInteractionMap.set(expirationTime, new Set(interactions));
14450
14451 // Update the pending async work count for the current interactions.
14452 interactions.forEach(function (interaction) {
14453 interaction.__count++;
14454 });
14455 }
14456
14457 var subscriber = tracing.__subscriberRef.current;
14458 if (subscriber !== null) {
14459 var threadID = computeThreadID(root, expirationTime);
14460 subscriber.onWorkScheduled(interactions, threadID);
14461 }
14462 }
14463}
14464
14465function schedulePendingInteractions(root, expirationTime) {
14466 // This is called when work is scheduled on a root.
14467 // It associates the current interactions with the newly-scheduled expiration.
14468 // They will be restored when that expiration is later committed.
14469 if (!enableSchedulerTracing) {
14470 return;
14471 }
14472
14473 scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
14474}
14475
14476function startWorkOnPendingInteractions(root, expirationTime) {
14477 // This is called when new work is started on a root.
14478 if (!enableSchedulerTracing) {
14479 return;
14480 }
14481
14482 // Determine which interactions this batch of work currently includes, So that
14483 // we can accurately attribute time spent working on it, And so that cascading
14484 // work triggered during the render phase will be associated with it.
14485 var interactions = new Set();
14486 root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
14487 if (scheduledExpirationTime >= expirationTime) {
14488 scheduledInteractions.forEach(function (interaction) {
14489 return interactions.add(interaction);
14490 });
14491 }
14492 });
14493
14494 // Store the current set of interactions on the FiberRoot for a few reasons:
14495 // We can re-use it in hot functions like renderRoot() without having to
14496 // recalculate it. We will also use it in commitWork() to pass to any Profiler
14497 // onRender() hooks. This also provides DevTools with a way to access it when
14498 // the onCommitRoot() hook is called.
14499 root.memoizedInteractions = interactions;
14500
14501 if (interactions.size > 0) {
14502 var subscriber = tracing.__subscriberRef.current;
14503 if (subscriber !== null) {
14504 var threadID = computeThreadID(root, expirationTime);
14505 try {
14506 subscriber.onWorkStarted(interactions, threadID);
14507 } catch (error) {
14508 // If the subscriber throws, rethrow it in a separate task
14509 scheduleCallback(ImmediatePriority, function () {
14510 throw error;
14511 });
14512 }
14513 }
14514 }
14515}
14516
14517function finishPendingInteractions(root, committedExpirationTime) {
14518 if (!enableSchedulerTracing) {
14519 return;
14520 }
14521
14522 var earliestRemainingTimeAfterCommit = root.firstPendingTime;
14523
14524 var subscriber = void 0;
14525
14526 try {
14527 subscriber = tracing.__subscriberRef.current;
14528 if (subscriber !== null && root.memoizedInteractions.size > 0) {
14529 var threadID = computeThreadID(root, committedExpirationTime);
14530 subscriber.onWorkStopped(root.memoizedInteractions, threadID);
14531 }
14532 } catch (error) {
14533 // If the subscriber throws, rethrow it in a separate task
14534 scheduleCallback(ImmediatePriority, function () {
14535 throw error;
14536 });
14537 } finally {
14538 // Clear completed interactions from the pending Map.
14539 // Unless the render was suspended or cascading work was scheduled,
14540 // In which case– leave pending interactions until the subsequent render.
14541 var pendingInteractionMap = root.pendingInteractionMap;
14542 pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
14543 // Only decrement the pending interaction count if we're done.
14544 // If there's still work at the current priority,
14545 // That indicates that we are waiting for suspense data.
14546 if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
14547 pendingInteractionMap.delete(scheduledExpirationTime);
14548
14549 scheduledInteractions.forEach(function (interaction) {
14550 interaction.__count--;
14551
14552 if (subscriber !== null && interaction.__count === 0) {
14553 try {
14554 subscriber.onInteractionScheduledWorkCompleted(interaction);
14555 } catch (error) {
14556 // If the subscriber throws, rethrow it in a separate task
14557 scheduleCallback(ImmediatePriority, function () {
14558 throw error;
14559 });
14560 }
14561 }
14562 });
14563 }
14564 });
14565 }
14566}
14567
14568var onCommitFiberRoot = null;
14569var onCommitFiberUnmount = null;
14570var hasLoggedError = false;
14571
14572var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
14573
14574function injectInternals(internals) {
14575 if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
14576 // No DevTools
14577 return false;
14578 }
14579 var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
14580 if (hook.isDisabled) {
14581 // This isn't a real property on the hook, but it can be set to opt out
14582 // of DevTools integration and associated warnings and logs.
14583 // https://github.com/facebook/react/issues/3877
14584 return true;
14585 }
14586 if (!hook.supportsFiber) {
14587 {
14588 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');
14589 }
14590 // DevTools exists, even though it doesn't support Fiber.
14591 return true;
14592 }
14593 try {
14594 var rendererID = hook.inject(internals);
14595 // We have successfully injected, so now it is safe to set up hooks.
14596 onCommitFiberRoot = function (root, expirationTime) {
14597 try {
14598 var didError = (root.current.effectTag & DidCapture) === DidCapture;
14599 if (enableProfilerTimer) {
14600 var currentTime = requestCurrentTime();
14601 var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
14602 hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
14603 } else {
14604 hook.onCommitFiberRoot(rendererID, root, undefined, didError);
14605 }
14606 } catch (err) {
14607 if (true && !hasLoggedError) {
14608 hasLoggedError = true;
14609 warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
14610 }
14611 }
14612 };
14613 onCommitFiberUnmount = function (fiber) {
14614 try {
14615 hook.onCommitFiberUnmount(rendererID, fiber);
14616 } catch (err) {
14617 if (true && !hasLoggedError) {
14618 hasLoggedError = true;
14619 warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
14620 }
14621 }
14622 };
14623 } catch (err) {
14624 // Catch all errors because it is unsafe to throw during initialization.
14625 {
14626 warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
14627 }
14628 }
14629 // DevTools exists
14630 return true;
14631}
14632
14633function onCommitRoot(root, expirationTime) {
14634 if (typeof onCommitFiberRoot === 'function') {
14635 onCommitFiberRoot(root, expirationTime);
14636 }
14637}
14638
14639function onCommitUnmount(fiber) {
14640 if (typeof onCommitFiberUnmount === 'function') {
14641 onCommitFiberUnmount(fiber);
14642 }
14643}
14644
14645var hasBadMapPolyfill = void 0;
14646
14647{
14648 hasBadMapPolyfill = false;
14649 try {
14650 var nonExtensibleObject = Object.preventExtensions({});
14651 var testMap = new Map([[nonExtensibleObject, null]]);
14652 var testSet = new Set([nonExtensibleObject]);
14653 // This is necessary for Rollup to not consider these unused.
14654 // https://github.com/rollup/rollup/issues/1771
14655 // TODO: we can remove these if Rollup fixes the bug.
14656 testMap.set(0, 0);
14657 testSet.add(0);
14658 } catch (e) {
14659 // TODO: Consider warning about bad polyfills
14660 hasBadMapPolyfill = true;
14661 }
14662}
14663
14664// A Fiber is work on a Component that needs to be done or was done. There can
14665// be more than one per component.
14666
14667
14668var debugCounter = void 0;
14669
14670{
14671 debugCounter = 1;
14672}
14673
14674function FiberNode(tag, pendingProps, key, mode) {
14675 // Instance
14676 this.tag = tag;
14677 this.key = key;
14678 this.elementType = null;
14679 this.type = null;
14680 this.stateNode = null;
14681
14682 // Fiber
14683 this.return = null;
14684 this.child = null;
14685 this.sibling = null;
14686 this.index = 0;
14687
14688 this.ref = null;
14689
14690 this.pendingProps = pendingProps;
14691 this.memoizedProps = null;
14692 this.updateQueue = null;
14693 this.memoizedState = null;
14694 this.dependencies = null;
14695
14696 this.mode = mode;
14697
14698 // Effects
14699 this.effectTag = NoEffect;
14700 this.nextEffect = null;
14701
14702 this.firstEffect = null;
14703 this.lastEffect = null;
14704
14705 this.expirationTime = NoWork;
14706 this.childExpirationTime = NoWork;
14707
14708 this.alternate = null;
14709
14710 if (enableProfilerTimer) {
14711 // Note: The following is done to avoid a v8 performance cliff.
14712 //
14713 // Initializing the fields below to smis and later updating them with
14714 // double values will cause Fibers to end up having separate shapes.
14715 // This behavior/bug has something to do with Object.preventExtension().
14716 // Fortunately this only impacts DEV builds.
14717 // Unfortunately it makes React unusably slow for some applications.
14718 // To work around this, initialize the fields below with doubles.
14719 //
14720 // Learn more about this here:
14721 // https://github.com/facebook/react/issues/14365
14722 // https://bugs.chromium.org/p/v8/issues/detail?id=8538
14723 this.actualDuration = Number.NaN;
14724 this.actualStartTime = Number.NaN;
14725 this.selfBaseDuration = Number.NaN;
14726 this.treeBaseDuration = Number.NaN;
14727
14728 // It's okay to replace the initial doubles with smis after initialization.
14729 // This won't trigger the performance cliff mentioned above,
14730 // and it simplifies other profiler code (including DevTools).
14731 this.actualDuration = 0;
14732 this.actualStartTime = -1;
14733 this.selfBaseDuration = 0;
14734 this.treeBaseDuration = 0;
14735 }
14736
14737 {
14738 this._debugID = debugCounter++;
14739 this._debugSource = null;
14740 this._debugOwner = null;
14741 this._debugIsCurrentlyTiming = false;
14742 this._debugNeedsRemount = false;
14743 this._debugHookTypes = null;
14744 if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
14745 Object.preventExtensions(this);
14746 }
14747 }
14748}
14749
14750// This is a constructor function, rather than a POJO constructor, still
14751// please ensure we do the following:
14752// 1) Nobody should add any instance methods on this. Instance methods can be
14753// more difficult to predict when they get optimized and they are almost
14754// never inlined properly in static compilers.
14755// 2) Nobody should rely on `instanceof Fiber` for type testing. We should
14756// always know when it is a fiber.
14757// 3) We might want to experiment with using numeric keys since they are easier
14758// to optimize in a non-JIT environment.
14759// 4) We can easily go from a constructor to a createFiber object literal if that
14760// is faster.
14761// 5) It should be easy to port this to a C struct and keep a C implementation
14762// compatible.
14763var createFiber = function (tag, pendingProps, key, mode) {
14764 // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
14765 return new FiberNode(tag, pendingProps, key, mode);
14766};
14767
14768function shouldConstruct(Component) {
14769 var prototype = Component.prototype;
14770 return !!(prototype && prototype.isReactComponent);
14771}
14772
14773function isSimpleFunctionComponent(type) {
14774 return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
14775}
14776
14777function resolveLazyComponentTag(Component) {
14778 if (typeof Component === 'function') {
14779 return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
14780 } else if (Component !== undefined && Component !== null) {
14781 var $$typeof = Component.$$typeof;
14782 if ($$typeof === REACT_FORWARD_REF_TYPE) {
14783 return ForwardRef;
14784 }
14785 if ($$typeof === REACT_MEMO_TYPE) {
14786 return MemoComponent;
14787 }
14788 }
14789 return IndeterminateComponent;
14790}
14791
14792// This is used to create an alternate fiber to do work on.
14793function createWorkInProgress(current, pendingProps, expirationTime) {
14794 var workInProgress = current.alternate;
14795 if (workInProgress === null) {
14796 // We use a double buffering pooling technique because we know that we'll
14797 // only ever need at most two versions of a tree. We pool the "other" unused
14798 // node that we're free to reuse. This is lazily created to avoid allocating
14799 // extra objects for things that are never updated. It also allow us to
14800 // reclaim the extra memory if needed.
14801 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
14802 workInProgress.elementType = current.elementType;
14803 workInProgress.type = current.type;
14804 workInProgress.stateNode = current.stateNode;
14805
14806 {
14807 // DEV-only fields
14808 workInProgress._debugID = current._debugID;
14809 workInProgress._debugSource = current._debugSource;
14810 workInProgress._debugOwner = current._debugOwner;
14811 workInProgress._debugHookTypes = current._debugHookTypes;
14812 }
14813
14814 workInProgress.alternate = current;
14815 current.alternate = workInProgress;
14816 } else {
14817 workInProgress.pendingProps = pendingProps;
14818
14819 // We already have an alternate.
14820 // Reset the effect tag.
14821 workInProgress.effectTag = NoEffect;
14822
14823 // The effect list is no longer valid.
14824 workInProgress.nextEffect = null;
14825 workInProgress.firstEffect = null;
14826 workInProgress.lastEffect = null;
14827
14828 if (enableProfilerTimer) {
14829 // We intentionally reset, rather than copy, actualDuration & actualStartTime.
14830 // This prevents time from endlessly accumulating in new commits.
14831 // This has the downside of resetting values for different priority renders,
14832 // But works for yielding (the common case) and should support resuming.
14833 workInProgress.actualDuration = 0;
14834 workInProgress.actualStartTime = -1;
14835 }
14836 }
14837
14838 workInProgress.childExpirationTime = current.childExpirationTime;
14839 workInProgress.expirationTime = current.expirationTime;
14840
14841 workInProgress.child = current.child;
14842 workInProgress.memoizedProps = current.memoizedProps;
14843 workInProgress.memoizedState = current.memoizedState;
14844 workInProgress.updateQueue = current.updateQueue;
14845
14846 // Clone the dependencies object. This is mutated during the render phase, so
14847 // it cannot be shared with the current fiber.
14848 var currentDependencies = current.dependencies;
14849 workInProgress.dependencies = currentDependencies === null ? null : {
14850 expirationTime: currentDependencies.expirationTime,
14851 firstContext: currentDependencies.firstContext,
14852 responders: currentDependencies.responders
14853 };
14854
14855 // These will be overridden during the parent's reconciliation
14856 workInProgress.sibling = current.sibling;
14857 workInProgress.index = current.index;
14858 workInProgress.ref = current.ref;
14859
14860 if (enableProfilerTimer) {
14861 workInProgress.selfBaseDuration = current.selfBaseDuration;
14862 workInProgress.treeBaseDuration = current.treeBaseDuration;
14863 }
14864
14865 {
14866 workInProgress._debugNeedsRemount = current._debugNeedsRemount;
14867 switch (workInProgress.tag) {
14868 case IndeterminateComponent:
14869 case FunctionComponent:
14870 case SimpleMemoComponent:
14871 workInProgress.type = resolveFunctionForHotReloading(current.type);
14872 break;
14873 case ClassComponent:
14874 workInProgress.type = resolveClassForHotReloading(current.type);
14875 break;
14876 case ForwardRef:
14877 workInProgress.type = resolveForwardRefForHotReloading(current.type);
14878 break;
14879 default:
14880 break;
14881 }
14882 }
14883
14884 return workInProgress;
14885}
14886
14887// Used to reuse a Fiber for a second pass.
14888function resetWorkInProgress(workInProgress, renderExpirationTime) {
14889 // This resets the Fiber to what createFiber or createWorkInProgress would
14890 // have set the values to before during the first pass. Ideally this wouldn't
14891 // be necessary but unfortunately many code paths reads from the workInProgress
14892 // when they should be reading from current and writing to workInProgress.
14893
14894 // We assume pendingProps, index, key, ref, return are still untouched to
14895 // avoid doing another reconciliation.
14896
14897 // Reset the effect tag but keep any Placement tags, since that's something
14898 // that child fiber is setting, not the reconciliation.
14899 workInProgress.effectTag &= Placement;
14900
14901 // The effect list is no longer valid.
14902 workInProgress.nextEffect = null;
14903 workInProgress.firstEffect = null;
14904 workInProgress.lastEffect = null;
14905
14906 var current = workInProgress.alternate;
14907 if (current === null) {
14908 // Reset to createFiber's initial values.
14909 workInProgress.childExpirationTime = NoWork;
14910 workInProgress.expirationTime = renderExpirationTime;
14911
14912 workInProgress.child = null;
14913 workInProgress.memoizedProps = null;
14914 workInProgress.memoizedState = null;
14915 workInProgress.updateQueue = null;
14916
14917 workInProgress.dependencies = null;
14918
14919 if (enableProfilerTimer) {
14920 // Note: We don't reset the actualTime counts. It's useful to accumulate
14921 // actual time across multiple render passes.
14922 workInProgress.selfBaseDuration = 0;
14923 workInProgress.treeBaseDuration = 0;
14924 }
14925 } else {
14926 // Reset to the cloned values that createWorkInProgress would've.
14927 workInProgress.childExpirationTime = current.childExpirationTime;
14928 workInProgress.expirationTime = current.expirationTime;
14929
14930 workInProgress.child = current.child;
14931 workInProgress.memoizedProps = current.memoizedProps;
14932 workInProgress.memoizedState = current.memoizedState;
14933 workInProgress.updateQueue = current.updateQueue;
14934
14935 // Clone the dependencies object. This is mutated during the render phase, so
14936 // it cannot be shared with the current fiber.
14937 var currentDependencies = current.dependencies;
14938 workInProgress.dependencies = currentDependencies === null ? null : {
14939 expirationTime: currentDependencies.expirationTime,
14940 firstContext: currentDependencies.firstContext,
14941 responders: currentDependencies.responders
14942 };
14943
14944 if (enableProfilerTimer) {
14945 // Note: We don't reset the actualTime counts. It's useful to accumulate
14946 // actual time across multiple render passes.
14947 workInProgress.selfBaseDuration = current.selfBaseDuration;
14948 workInProgress.treeBaseDuration = current.treeBaseDuration;
14949 }
14950 }
14951
14952 return workInProgress;
14953}
14954
14955function createHostRootFiber(tag) {
14956 var mode = void 0;
14957 if (tag === ConcurrentRoot) {
14958 mode = ConcurrentMode | BatchedMode | StrictMode;
14959 } else if (tag === BatchedRoot) {
14960 mode = BatchedMode | StrictMode;
14961 } else {
14962 mode = NoMode;
14963 }
14964
14965 if (enableProfilerTimer && isDevToolsPresent) {
14966 // Always collect profile timings when DevTools are present.
14967 // This enables DevTools to start capturing timing at any point–
14968 // Without some nodes in the tree having empty base times.
14969 mode |= ProfileMode;
14970 }
14971
14972 return createFiber(HostRoot, null, null, mode);
14973}
14974
14975function createFiberFromTypeAndProps(type, // React$ElementType
14976key, pendingProps, owner, mode, expirationTime) {
14977 var fiber = void 0;
14978
14979 var fiberTag = IndeterminateComponent;
14980 // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
14981 var resolvedType = type;
14982 if (typeof type === 'function') {
14983 if (shouldConstruct(type)) {
14984 fiberTag = ClassComponent;
14985 {
14986 resolvedType = resolveClassForHotReloading(resolvedType);
14987 }
14988 } else {
14989 {
14990 resolvedType = resolveFunctionForHotReloading(resolvedType);
14991 }
14992 }
14993 } else if (typeof type === 'string') {
14994 fiberTag = HostComponent;
14995 } else {
14996 getTag: switch (type) {
14997 case REACT_FRAGMENT_TYPE:
14998 return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
14999 case REACT_CONCURRENT_MODE_TYPE:
15000 fiberTag = Mode$1;
15001 mode |= ConcurrentMode | BatchedMode | StrictMode;
15002 break;
15003 case REACT_STRICT_MODE_TYPE:
15004 fiberTag = Mode$1;
15005 mode |= StrictMode;
15006 break;
15007 case REACT_PROFILER_TYPE:
15008 return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
15009 case REACT_SUSPENSE_TYPE:
15010 return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
15011 case REACT_SUSPENSE_LIST_TYPE:
15012 return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
15013 default:
15014 {
15015 if (typeof type === 'object' && type !== null) {
15016 switch (type.$$typeof) {
15017 case REACT_PROVIDER_TYPE:
15018 fiberTag = ContextProvider;
15019 break getTag;
15020 case REACT_CONTEXT_TYPE:
15021 // This is a consumer
15022 fiberTag = ContextConsumer;
15023 break getTag;
15024 case REACT_FORWARD_REF_TYPE:
15025 fiberTag = ForwardRef;
15026 {
15027 resolvedType = resolveForwardRefForHotReloading(resolvedType);
15028 }
15029 break getTag;
15030 case REACT_MEMO_TYPE:
15031 fiberTag = MemoComponent;
15032 break getTag;
15033 case REACT_LAZY_TYPE:
15034 fiberTag = LazyComponent;
15035 resolvedType = null;
15036 break getTag;
15037 case REACT_FUNDAMENTAL_TYPE:
15038 if (enableFundamentalAPI) {
15039 return createFiberFromFundamental(type, pendingProps, mode, expirationTime, key);
15040 }
15041 break;
15042 }
15043 }
15044 var info = '';
15045 {
15046 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
15047 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.';
15048 }
15049 var ownerName = owner ? getComponentName(owner.type) : null;
15050 if (ownerName) {
15051 info += '\n\nCheck the render method of `' + ownerName + '`.';
15052 }
15053 }
15054 (function () {
15055 {
15056 {
15057 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));
15058 }
15059 }
15060 })();
15061 }
15062 }
15063 }
15064
15065 fiber = createFiber(fiberTag, pendingProps, key, mode);
15066 fiber.elementType = type;
15067 fiber.type = resolvedType;
15068 fiber.expirationTime = expirationTime;
15069
15070 return fiber;
15071}
15072
15073function createFiberFromElement(element, mode, expirationTime) {
15074 var owner = null;
15075 {
15076 owner = element._owner;
15077 }
15078 var type = element.type;
15079 var key = element.key;
15080 var pendingProps = element.props;
15081 var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
15082 {
15083 fiber._debugSource = element._source;
15084 fiber._debugOwner = element._owner;
15085 }
15086 return fiber;
15087}
15088
15089function createFiberFromFragment(elements, mode, expirationTime, key) {
15090 var fiber = createFiber(Fragment, elements, key, mode);
15091 fiber.expirationTime = expirationTime;
15092 return fiber;
15093}
15094
15095function createFiberFromFundamental(fundamentalComponent, pendingProps, mode, expirationTime, key) {
15096 var fiber = createFiber(FundamentalComponent, pendingProps, key, mode);
15097 fiber.elementType = fundamentalComponent;
15098 fiber.type = fundamentalComponent;
15099 fiber.expirationTime = expirationTime;
15100 return fiber;
15101}
15102
15103function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
15104 {
15105 if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
15106 warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
15107 }
15108 }
15109
15110 var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
15111 // TODO: The Profiler fiber shouldn't have a type. It has a tag.
15112 fiber.elementType = REACT_PROFILER_TYPE;
15113 fiber.type = REACT_PROFILER_TYPE;
15114 fiber.expirationTime = expirationTime;
15115
15116 return fiber;
15117}
15118
15119function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
15120 var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
15121
15122 // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
15123 // This needs to be fixed in getComponentName so that it relies on the tag
15124 // instead.
15125 fiber.type = REACT_SUSPENSE_TYPE;
15126 fiber.elementType = REACT_SUSPENSE_TYPE;
15127
15128 fiber.expirationTime = expirationTime;
15129 return fiber;
15130}
15131
15132function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
15133 var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
15134 {
15135 // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag.
15136 // This needs to be fixed in getComponentName so that it relies on the tag
15137 // instead.
15138 fiber.type = REACT_SUSPENSE_LIST_TYPE;
15139 }
15140 fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
15141 fiber.expirationTime = expirationTime;
15142 return fiber;
15143}
15144
15145function createFiberFromText(content, mode, expirationTime) {
15146 var fiber = createFiber(HostText, content, null, mode);
15147 fiber.expirationTime = expirationTime;
15148 return fiber;
15149}
15150
15151function createFiberFromHostInstanceForDeletion() {
15152 var fiber = createFiber(HostComponent, null, null, NoMode);
15153 // TODO: These should not need a type.
15154 fiber.elementType = 'DELETED';
15155 fiber.type = 'DELETED';
15156 return fiber;
15157}
15158
15159function createFiberFromPortal(portal, mode, expirationTime) {
15160 var pendingProps = portal.children !== null ? portal.children : [];
15161 var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
15162 fiber.expirationTime = expirationTime;
15163 fiber.stateNode = {
15164 containerInfo: portal.containerInfo,
15165 pendingChildren: null, // Used by persistent updates
15166 implementation: portal.implementation
15167 };
15168 return fiber;
15169}
15170
15171// Used for stashing WIP properties to replay failed work in DEV.
15172function assignFiberPropertiesInDEV(target, source) {
15173 if (target === null) {
15174 // This Fiber's initial properties will always be overwritten.
15175 // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
15176 target = createFiber(IndeterminateComponent, null, null, NoMode);
15177 }
15178
15179 // This is intentionally written as a list of all properties.
15180 // We tried to use Object.assign() instead but this is called in
15181 // the hottest path, and Object.assign() was too slow:
15182 // https://github.com/facebook/react/issues/12502
15183 // This code is DEV-only so size is not a concern.
15184
15185 target.tag = source.tag;
15186 target.key = source.key;
15187 target.elementType = source.elementType;
15188 target.type = source.type;
15189 target.stateNode = source.stateNode;
15190 target.return = source.return;
15191 target.child = source.child;
15192 target.sibling = source.sibling;
15193 target.index = source.index;
15194 target.ref = source.ref;
15195 target.pendingProps = source.pendingProps;
15196 target.memoizedProps = source.memoizedProps;
15197 target.updateQueue = source.updateQueue;
15198 target.memoizedState = source.memoizedState;
15199 target.dependencies = source.dependencies;
15200 target.mode = source.mode;
15201 target.effectTag = source.effectTag;
15202 target.nextEffect = source.nextEffect;
15203 target.firstEffect = source.firstEffect;
15204 target.lastEffect = source.lastEffect;
15205 target.expirationTime = source.expirationTime;
15206 target.childExpirationTime = source.childExpirationTime;
15207 target.alternate = source.alternate;
15208 if (enableProfilerTimer) {
15209 target.actualDuration = source.actualDuration;
15210 target.actualStartTime = source.actualStartTime;
15211 target.selfBaseDuration = source.selfBaseDuration;
15212 target.treeBaseDuration = source.treeBaseDuration;
15213 }
15214 target._debugID = source._debugID;
15215 target._debugSource = source._debugSource;
15216 target._debugOwner = source._debugOwner;
15217 target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
15218 target._debugNeedsRemount = source._debugNeedsRemount;
15219 target._debugHookTypes = source._debugHookTypes;
15220 return target;
15221}
15222
15223// TODO: This should be lifted into the renderer.
15224
15225
15226// The following attributes are only used by interaction tracing builds.
15227// They enable interactions to be associated with their async work,
15228// And expose interaction metadata to the React DevTools Profiler plugin.
15229// Note that these attributes are only defined when the enableSchedulerTracing flag is enabled.
15230
15231
15232// Exported FiberRoot type includes all properties,
15233// To avoid requiring potentially error-prone :any casts throughout the project.
15234// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true).
15235// The types are defined separately within this file to ensure they stay in sync.
15236// (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
15237
15238
15239function FiberRootNode(containerInfo, tag, hydrate) {
15240 this.tag = tag;
15241 this.current = null;
15242 this.containerInfo = containerInfo;
15243 this.pendingChildren = null;
15244 this.pingCache = null;
15245 this.finishedExpirationTime = NoWork;
15246 this.finishedWork = null;
15247 this.timeoutHandle = noTimeout;
15248 this.context = null;
15249 this.pendingContext = null;
15250 this.hydrate = hydrate;
15251 this.firstBatch = null;
15252 this.callbackNode = null;
15253 this.callbackExpirationTime = NoWork;
15254 this.firstPendingTime = NoWork;
15255 this.lastPendingTime = NoWork;
15256 this.pingTime = NoWork;
15257
15258 if (enableSchedulerTracing) {
15259 this.interactionThreadID = tracing.unstable_getThreadID();
15260 this.memoizedInteractions = new Set();
15261 this.pendingInteractionMap = new Map();
15262 }
15263}
15264
15265function createFiberRoot(containerInfo, tag, hydrate) {
15266 var root = new FiberRootNode(containerInfo, tag, hydrate);
15267
15268 // Cyclic construction. This cheats the type system right now because
15269 // stateNode is any.
15270 var uninitializedFiber = createHostRootFiber(tag);
15271 root.current = uninitializedFiber;
15272 uninitializedFiber.stateNode = root;
15273
15274 return root;
15275}
15276
15277// This lets us hook into Fiber to debug what it's doing.
15278// See https://github.com/facebook/react/pull/8033.
15279// This is not part of the public API, not even for React DevTools.
15280// You may only inject a debugTool if you work on React Fiber itself.
15281var ReactFiberInstrumentation = {
15282 debugTool: null
15283};
15284
15285var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
15286
15287// 0 is PROD, 1 is DEV.
15288// Might add PROFILE later.
15289
15290
15291var didWarnAboutNestedUpdates = void 0;
15292{
15293 didWarnAboutNestedUpdates = false;
15294
15295}
15296
15297function getContextForSubtree(parentComponent) {
15298 if (!parentComponent) {
15299 return emptyContextObject;
15300 }
15301
15302 var fiber = get(parentComponent);
15303 var parentContext = findCurrentUnmaskedContext(fiber);
15304
15305 if (fiber.tag === ClassComponent) {
15306 var Component = fiber.type;
15307 if (isContextProvider(Component)) {
15308 return processChildContext(fiber, Component, parentContext);
15309 }
15310 }
15311
15312 return parentContext;
15313}
15314
15315function scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback) {
15316 {
15317 if (phase === 'render' && current !== null && !didWarnAboutNestedUpdates) {
15318 didWarnAboutNestedUpdates = true;
15319 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');
15320 }
15321 }
15322
15323 var update = createUpdate(expirationTime, suspenseConfig);
15324 // Caution: React DevTools currently depends on this property
15325 // being called "element".
15326 update.payload = { element: element };
15327
15328 callback = callback === undefined ? null : callback;
15329 if (callback !== null) {
15330 !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
15331 update.callback = callback;
15332 }
15333
15334 if (revertPassiveEffectsChange) {
15335 flushPassiveEffects();
15336 }
15337 enqueueUpdate(current$$1, update);
15338 scheduleWork(current$$1, expirationTime);
15339
15340 return expirationTime;
15341}
15342
15343function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback) {
15344 // TODO: If this is a nested container, this won't be the root.
15345 var current$$1 = container.current;
15346
15347 {
15348 if (ReactFiberInstrumentation_1.debugTool) {
15349 if (current$$1.alternate === null) {
15350 ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
15351 } else if (element === null) {
15352 ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
15353 } else {
15354 ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
15355 }
15356 }
15357 }
15358
15359 var context = getContextForSubtree(parentComponent);
15360 if (container.context === null) {
15361 container.context = context;
15362 } else {
15363 container.pendingContext = context;
15364 }
15365
15366 return scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback);
15367}
15368
15369function createContainer(containerInfo, tag, hydrate) {
15370 return createFiberRoot(containerInfo, tag, hydrate);
15371}
15372
15373function updateContainer(element, container, parentComponent, callback) {
15374 var current$$1 = container.current;
15375 var currentTime = requestCurrentTime();
15376 {
15377 // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
15378 if ('undefined' !== typeof jest) {
15379 warnIfUnmockedScheduler(current$$1);
15380 warnIfNotScopedWithMatchingAct(current$$1);
15381 }
15382 }
15383 var suspenseConfig = requestCurrentSuspenseConfig();
15384 var expirationTime = computeExpirationForFiber(currentTime, current$$1, suspenseConfig);
15385 return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback);
15386}
15387
15388
15389
15390
15391
15392var shouldSuspendImpl = function (fiber) {
15393 return false;
15394};
15395
15396function shouldSuspend(fiber) {
15397 return shouldSuspendImpl(fiber);
15398}
15399
15400var overrideHookState = null;
15401var overrideProps = null;
15402var scheduleUpdate = null;
15403var setSuspenseHandler = null;
15404
15405{
15406 var copyWithSetImpl = function (obj, path, idx, value) {
15407 if (idx >= path.length) {
15408 return value;
15409 }
15410 var key = path[idx];
15411 var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
15412 // $FlowFixMe number or string is fine here
15413 updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
15414 return updated;
15415 };
15416
15417 var copyWithSet = function (obj, path, value) {
15418 return copyWithSetImpl(obj, path, 0, value);
15419 };
15420
15421 // Support DevTools editable values for useState and useReducer.
15422 overrideHookState = function (fiber, id, path, value) {
15423 // For now, the "id" of stateful hooks is just the stateful hook index.
15424 // This may change in the future with e.g. nested hooks.
15425 var currentHook = fiber.memoizedState;
15426 while (currentHook !== null && id > 0) {
15427 currentHook = currentHook.next;
15428 id--;
15429 }
15430 if (currentHook !== null) {
15431 if (revertPassiveEffectsChange) {
15432 flushPassiveEffects();
15433 }
15434
15435 var newState = copyWithSet(currentHook.memoizedState, path, value);
15436 currentHook.memoizedState = newState;
15437 currentHook.baseState = newState;
15438
15439 // We aren't actually adding an update to the queue,
15440 // because there is no update we can add for useReducer hooks that won't trigger an error.
15441 // (There's no appropriate action type for DevTools overrides.)
15442 // As a result though, React will see the scheduled update as a noop and bailout.
15443 // Shallow cloning props works as a workaround for now to bypass the bailout check.
15444 fiber.memoizedProps = _assign({}, fiber.memoizedProps);
15445
15446 scheduleWork(fiber, Sync);
15447 }
15448 };
15449
15450 // Support DevTools props for function components, forwardRef, memo, host components, etc.
15451 overrideProps = function (fiber, path, value) {
15452 if (revertPassiveEffectsChange) {
15453 flushPassiveEffects();
15454 }
15455 fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
15456 if (fiber.alternate) {
15457 fiber.alternate.pendingProps = fiber.pendingProps;
15458 }
15459 scheduleWork(fiber, Sync);
15460 };
15461
15462 scheduleUpdate = function (fiber) {
15463 if (revertPassiveEffectsChange) {
15464 flushPassiveEffects();
15465 }
15466 scheduleWork(fiber, Sync);
15467 };
15468
15469 setSuspenseHandler = function (newShouldSuspendImpl) {
15470 shouldSuspendImpl = newShouldSuspendImpl;
15471 };
15472}
15473
15474function injectIntoDevTools(devToolsConfig) {
15475 var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
15476 var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
15477
15478
15479 return injectInternals(_assign({}, devToolsConfig, {
15480 overrideHookState: overrideHookState,
15481 overrideProps: overrideProps,
15482 setSuspenseHandler: setSuspenseHandler,
15483 scheduleUpdate: scheduleUpdate,
15484 currentDispatcherRef: ReactCurrentDispatcher,
15485 findHostInstanceByFiber: function (fiber) {
15486 var hostFiber = findCurrentHostFiber(fiber);
15487 if (hostFiber === null) {
15488 return null;
15489 }
15490 return hostFiber.stateNode;
15491 },
15492 findFiberByHostInstance: function (instance) {
15493 if (!findFiberByHostInstance) {
15494 // Might not be implemented by the renderer.
15495 return null;
15496 }
15497 return findFiberByHostInstance(instance);
15498 },
15499
15500 // React Refresh
15501 findHostInstancesForRefresh: findHostInstancesForRefresh,
15502 scheduleRefresh: scheduleRefresh,
15503 scheduleRoot: scheduleRoot,
15504 setRefreshHandler: setRefreshHandler,
15505 // Enables DevTools to append owner stacks to error messages in DEV mode.
15506 getCurrentFiber: function () {
15507 return current;
15508 }
15509 }));
15510}
15511
15512// This file intentionally does *not* have the Flow annotation.
15513// Don't add it. See `./inline-typed.js` for an explanation.
15514
15515var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
15516
15517function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
15518
15519function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
15520
15521function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15522
15523Mode.setCurrent(
15524// Change to 'art/modes/dom' for easier debugging via SVG
15525FastNoSideEffects);
15526
15527/** Declarative fill-type objects; API design not finalized */
15528
15529var slice = Array.prototype.slice;
15530
15531var LinearGradient = function () {
15532 function LinearGradient(stops, x1, y1, x2, y2) {
15533 _classCallCheck(this, LinearGradient);
15534
15535 this._args = slice.call(arguments);
15536 }
15537
15538 LinearGradient.prototype.applyFill = function applyFill(node) {
15539 node.fillLinear.apply(node, this._args);
15540 };
15541
15542 return LinearGradient;
15543}();
15544
15545var RadialGradient = function () {
15546 function RadialGradient(stops, fx, fy, rx, ry, cx, cy) {
15547 _classCallCheck(this, RadialGradient);
15548
15549 this._args = slice.call(arguments);
15550 }
15551
15552 RadialGradient.prototype.applyFill = function applyFill(node) {
15553 node.fillRadial.apply(node, this._args);
15554 };
15555
15556 return RadialGradient;
15557}();
15558
15559var Pattern = function () {
15560 function Pattern(url, width, height, left, top) {
15561 _classCallCheck(this, Pattern);
15562
15563 this._args = slice.call(arguments);
15564 }
15565
15566 Pattern.prototype.applyFill = function applyFill(node) {
15567 node.fillImage.apply(node, this._args);
15568 };
15569
15570 return Pattern;
15571}();
15572
15573/** React Components */
15574
15575var Surface = function (_React$Component) {
15576 _inherits(Surface, _React$Component);
15577
15578 function Surface() {
15579 _classCallCheck(this, Surface);
15580
15581 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
15582 }
15583
15584 Surface.prototype.componentDidMount = function componentDidMount() {
15585 var _props = this.props,
15586 height = _props.height,
15587 width = _props.width;
15588
15589
15590 this._surface = Mode.Surface(+width, +height, this._tagRef);
15591
15592 this._mountNode = createContainer(this._surface, LegacyRoot, false);
15593 updateContainer(this.props.children, this._mountNode, this);
15594 };
15595
15596 Surface.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
15597 var props = this.props;
15598
15599 if (props.height !== prevProps.height || props.width !== prevProps.width) {
15600 this._surface.resize(+props.width, +props.height);
15601 }
15602
15603 updateContainer(this.props.children, this._mountNode, this);
15604
15605 if (this._surface.render) {
15606 this._surface.render();
15607 }
15608 };
15609
15610 Surface.prototype.componentWillUnmount = function componentWillUnmount() {
15611 updateContainer(null, this._mountNode, this);
15612 };
15613
15614 Surface.prototype.render = function render() {
15615 var _this2 = this;
15616
15617 // This is going to be a placeholder because we don't know what it will
15618 // actually resolve to because ART may render canvas, vml or svg tags here.
15619 // We only allow a subset of properties since others might conflict with
15620 // ART's properties.
15621 var props = this.props;
15622
15623 // TODO: ART's Canvas Mode overrides surface title and cursor
15624 var Tag = Mode.Surface.tagName;
15625
15626 return React.createElement(Tag, {
15627 ref: function (ref) {
15628 return _this2._tagRef = ref;
15629 },
15630 accessKey: props.accessKey,
15631 className: props.className,
15632 draggable: props.draggable,
15633 role: props.role,
15634 style: props.style,
15635 tabIndex: props.tabIndex,
15636 title: props.title
15637 });
15638 };
15639
15640 return Surface;
15641}(React.Component);
15642
15643var Text = function (_React$Component2) {
15644 _inherits(Text, _React$Component2);
15645
15646 function Text(props) {
15647 _classCallCheck(this, Text);
15648
15649 // We allow reading these props. Ideally we could expose the Text node as
15650 // ref directly.
15651 var _this3 = _possibleConstructorReturn(this, _React$Component2.call(this, props));
15652
15653 ['height', 'width', 'x', 'y'].forEach(function (key) {
15654 Object.defineProperty(_this3, key, {
15655 get: function () {
15656 return this._text ? this._text[key] : undefined;
15657 }
15658 });
15659 });
15660 return _this3;
15661 }
15662
15663 Text.prototype.render = function render() {
15664 var _this4 = this;
15665
15666 // This means you can't have children that render into strings...
15667 var T = TYPES.TEXT;
15668 return React.createElement(
15669 T,
15670 _extends({}, this.props, { ref: function (t) {
15671 return _this4._text = t;
15672 } }),
15673 childrenAsString(this.props.children)
15674 );
15675 };
15676
15677 return Text;
15678}(React.Component);
15679
15680injectIntoDevTools({
15681 findFiberByHostInstance: function () {
15682 return null;
15683 },
15684 bundleType: 1,
15685 version: ReactVersion,
15686 rendererPackageName: 'react-art'
15687});
15688
15689/** API */
15690
15691var ClippingRectangle = TYPES.CLIPPING_RECTANGLE;
15692var Group = TYPES.GROUP;
15693var Shape = TYPES.SHAPE;
15694var Path = Mode.Path;
15695
15696
15697var ReactART = Object.freeze({
15698 ClippingRectangle: ClippingRectangle,
15699 Group: Group,
15700 Shape: Shape,
15701 Path: Path,
15702 LinearGradient: LinearGradient,
15703 Pattern: Pattern,
15704 RadialGradient: RadialGradient,
15705 Surface: Surface,
15706 Text: Text,
15707 Transform: Transform
15708});
15709
15710var reactArt = ReactART;
15711
15712module.exports = reactArt;
15713 })();
15714}