UNPKG

63.8 kBJavaScriptView Raw
1/** @license React v16.8.5
2 * react.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12
13
14if (process.env.NODE_ENV !== "production") {
15 (function() {
16'use strict';
17
18var _assign = require('object-assign');
19var checkPropTypes = require('prop-types/checkPropTypes');
20
21// TODO: this is special because it gets imported during build.
22
23var ReactVersion = '16.8.5';
24
25// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
26// nor polyfill, then a plain number is used for performance.
27var hasSymbol = typeof Symbol === 'function' && Symbol.for;
28
29var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
30var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
31var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
32var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
33var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
34var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
35var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
36
37var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
38var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
39var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
40var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
41var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
42
43var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
44var FAUX_ITERATOR_SYMBOL = '@@iterator';
45
46function getIteratorFn(maybeIterable) {
47 if (maybeIterable === null || typeof maybeIterable !== 'object') {
48 return null;
49 }
50 var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
51 if (typeof maybeIterator === 'function') {
52 return maybeIterator;
53 }
54 return null;
55}
56
57/**
58 * Use invariant() to assert state which your program assumes to be true.
59 *
60 * Provide sprintf-style format (only %s is supported) and arguments
61 * to provide information about what broke and what you were
62 * expecting.
63 *
64 * The invariant message will be stripped in production, but the invariant
65 * will remain to ensure logic does not differ in production.
66 */
67
68var validateFormat = function () {};
69
70{
71 validateFormat = function (format) {
72 if (format === undefined) {
73 throw new Error('invariant requires an error message argument');
74 }
75 };
76}
77
78function invariant(condition, format, a, b, c, d, e, f) {
79 validateFormat(format);
80
81 if (!condition) {
82 var error = void 0;
83 if (format === undefined) {
84 error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
85 } else {
86 var args = [a, b, c, d, e, f];
87 var argIndex = 0;
88 error = new Error(format.replace(/%s/g, function () {
89 return args[argIndex++];
90 }));
91 error.name = 'Invariant Violation';
92 }
93
94 error.framesToPop = 1; // we don't care about invariant's own frame
95 throw error;
96 }
97}
98
99// Relying on the `invariant()` implementation lets us
100// preserve the format and params in the www builds.
101
102/**
103 * Forked from fbjs/warning:
104 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
105 *
106 * Only change is we use console.warn instead of console.error,
107 * and do nothing when 'console' is not supported.
108 * This really simplifies the code.
109 * ---
110 * Similar to invariant but only logs a warning if the condition is not met.
111 * This can be used to log issues in development environments in critical
112 * paths. Removing the logging code for production environments will keep the
113 * same logic and follow the same code paths.
114 */
115
116var lowPriorityWarning = function () {};
117
118{
119 var printWarning = function (format) {
120 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
121 args[_key - 1] = arguments[_key];
122 }
123
124 var argIndex = 0;
125 var message = 'Warning: ' + format.replace(/%s/g, function () {
126 return args[argIndex++];
127 });
128 if (typeof console !== 'undefined') {
129 console.warn(message);
130 }
131 try {
132 // --- Welcome to debugging React ---
133 // This error was thrown as a convenience so that you can use this stack
134 // to find the callsite that caused this warning to fire.
135 throw new Error(message);
136 } catch (x) {}
137 };
138
139 lowPriorityWarning = function (condition, format) {
140 if (format === undefined) {
141 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
142 }
143 if (!condition) {
144 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
145 args[_key2 - 2] = arguments[_key2];
146 }
147
148 printWarning.apply(undefined, [format].concat(args));
149 }
150 };
151}
152
153var lowPriorityWarning$1 = lowPriorityWarning;
154
155/**
156 * Similar to invariant but only logs a warning if the condition is not met.
157 * This can be used to log issues in development environments in critical
158 * paths. Removing the logging code for production environments will keep the
159 * same logic and follow the same code paths.
160 */
161
162var warningWithoutStack = function () {};
163
164{
165 warningWithoutStack = function (condition, format) {
166 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
167 args[_key - 2] = arguments[_key];
168 }
169
170 if (format === undefined) {
171 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
172 }
173 if (args.length > 8) {
174 // Check before the condition to catch violations early.
175 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
176 }
177 if (condition) {
178 return;
179 }
180 if (typeof console !== 'undefined') {
181 var argsWithFormat = args.map(function (item) {
182 return '' + item;
183 });
184 argsWithFormat.unshift('Warning: ' + format);
185
186 // We intentionally don't use spread (or .apply) directly because it
187 // breaks IE9: https://github.com/facebook/react/issues/13610
188 Function.prototype.apply.call(console.error, console, argsWithFormat);
189 }
190 try {
191 // --- Welcome to debugging React ---
192 // This error was thrown as a convenience so that you can use this stack
193 // to find the callsite that caused this warning to fire.
194 var argIndex = 0;
195 var message = 'Warning: ' + format.replace(/%s/g, function () {
196 return args[argIndex++];
197 });
198 throw new Error(message);
199 } catch (x) {}
200 };
201}
202
203var warningWithoutStack$1 = warningWithoutStack;
204
205var didWarnStateUpdateForUnmountedComponent = {};
206
207function warnNoop(publicInstance, callerName) {
208 {
209 var _constructor = publicInstance.constructor;
210 var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
211 var warningKey = componentName + '.' + callerName;
212 if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
213 return;
214 }
215 warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
216 didWarnStateUpdateForUnmountedComponent[warningKey] = true;
217 }
218}
219
220/**
221 * This is the abstract API for an update queue.
222 */
223var ReactNoopUpdateQueue = {
224 /**
225 * Checks whether or not this composite component is mounted.
226 * @param {ReactClass} publicInstance The instance we want to test.
227 * @return {boolean} True if mounted, false otherwise.
228 * @protected
229 * @final
230 */
231 isMounted: function (publicInstance) {
232 return false;
233 },
234
235 /**
236 * Forces an update. This should only be invoked when it is known with
237 * certainty that we are **not** in a DOM transaction.
238 *
239 * You may want to call this when you know that some deeper aspect of the
240 * component's state has changed but `setState` was not called.
241 *
242 * This will not invoke `shouldComponentUpdate`, but it will invoke
243 * `componentWillUpdate` and `componentDidUpdate`.
244 *
245 * @param {ReactClass} publicInstance The instance that should rerender.
246 * @param {?function} callback Called after component is updated.
247 * @param {?string} callerName name of the calling function in the public API.
248 * @internal
249 */
250 enqueueForceUpdate: function (publicInstance, callback, callerName) {
251 warnNoop(publicInstance, 'forceUpdate');
252 },
253
254 /**
255 * Replaces all of the state. Always use this or `setState` to mutate state.
256 * You should treat `this.state` as immutable.
257 *
258 * There is no guarantee that `this.state` will be immediately updated, so
259 * accessing `this.state` after calling this method may return the old value.
260 *
261 * @param {ReactClass} publicInstance The instance that should rerender.
262 * @param {object} completeState Next state.
263 * @param {?function} callback Called after component is updated.
264 * @param {?string} callerName name of the calling function in the public API.
265 * @internal
266 */
267 enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
268 warnNoop(publicInstance, 'replaceState');
269 },
270
271 /**
272 * Sets a subset of the state. This only exists because _pendingState is
273 * internal. This provides a merging strategy that is not available to deep
274 * properties which is confusing. TODO: Expose pendingState or don't use it
275 * during the merge.
276 *
277 * @param {ReactClass} publicInstance The instance that should rerender.
278 * @param {object} partialState Next partial state to be merged with state.
279 * @param {?function} callback Called after component is updated.
280 * @param {?string} Name of the calling function in the public API.
281 * @internal
282 */
283 enqueueSetState: function (publicInstance, partialState, callback, callerName) {
284 warnNoop(publicInstance, 'setState');
285 }
286};
287
288var emptyObject = {};
289{
290 Object.freeze(emptyObject);
291}
292
293/**
294 * Base class helpers for the updating state of a component.
295 */
296function Component(props, context, updater) {
297 this.props = props;
298 this.context = context;
299 // If a component has string refs, we will assign a different object later.
300 this.refs = emptyObject;
301 // We initialize the default updater but the real one gets injected by the
302 // renderer.
303 this.updater = updater || ReactNoopUpdateQueue;
304}
305
306Component.prototype.isReactComponent = {};
307
308/**
309 * Sets a subset of the state. Always use this to mutate
310 * state. You should treat `this.state` as immutable.
311 *
312 * There is no guarantee that `this.state` will be immediately updated, so
313 * accessing `this.state` after calling this method may return the old value.
314 *
315 * There is no guarantee that calls to `setState` will run synchronously,
316 * as they may eventually be batched together. You can provide an optional
317 * callback that will be executed when the call to setState is actually
318 * completed.
319 *
320 * When a function is provided to setState, it will be called at some point in
321 * the future (not synchronously). It will be called with the up to date
322 * component arguments (state, props, context). These values can be different
323 * from this.* because your function may be called after receiveProps but before
324 * shouldComponentUpdate, and this new state, props, and context will not yet be
325 * assigned to this.
326 *
327 * @param {object|function} partialState Next partial state or function to
328 * produce next partial state to be merged with current state.
329 * @param {?function} callback Called after state is updated.
330 * @final
331 * @protected
332 */
333Component.prototype.setState = function (partialState, callback) {
334 !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
335 this.updater.enqueueSetState(this, partialState, callback, 'setState');
336};
337
338/**
339 * Forces an update. This should only be invoked when it is known with
340 * certainty that we are **not** in a DOM transaction.
341 *
342 * You may want to call this when you know that some deeper aspect of the
343 * component's state has changed but `setState` was not called.
344 *
345 * This will not invoke `shouldComponentUpdate`, but it will invoke
346 * `componentWillUpdate` and `componentDidUpdate`.
347 *
348 * @param {?function} callback Called after update is complete.
349 * @final
350 * @protected
351 */
352Component.prototype.forceUpdate = function (callback) {
353 this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
354};
355
356/**
357 * Deprecated APIs. These APIs used to exist on classic React classes but since
358 * we would like to deprecate them, we're not going to move them over to this
359 * modern base class. Instead, we define a getter that warns if it's accessed.
360 */
361{
362 var deprecatedAPIs = {
363 isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
364 replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
365 };
366 var defineDeprecationWarning = function (methodName, info) {
367 Object.defineProperty(Component.prototype, methodName, {
368 get: function () {
369 lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
370 return undefined;
371 }
372 });
373 };
374 for (var fnName in deprecatedAPIs) {
375 if (deprecatedAPIs.hasOwnProperty(fnName)) {
376 defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
377 }
378 }
379}
380
381function ComponentDummy() {}
382ComponentDummy.prototype = Component.prototype;
383
384/**
385 * Convenience component with default shallow equality check for sCU.
386 */
387function PureComponent(props, context, updater) {
388 this.props = props;
389 this.context = context;
390 // If a component has string refs, we will assign a different object later.
391 this.refs = emptyObject;
392 this.updater = updater || ReactNoopUpdateQueue;
393}
394
395var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
396pureComponentPrototype.constructor = PureComponent;
397// Avoid an extra prototype jump for these methods.
398_assign(pureComponentPrototype, Component.prototype);
399pureComponentPrototype.isPureReactComponent = true;
400
401// an immutable object with a single mutable value
402function createRef() {
403 var refObject = {
404 current: null
405 };
406 {
407 Object.seal(refObject);
408 }
409 return refObject;
410}
411
412/**
413 * Keeps track of the current dispatcher.
414 */
415var ReactCurrentDispatcher = {
416 /**
417 * @internal
418 * @type {ReactComponent}
419 */
420 current: null
421};
422
423/**
424 * Keeps track of the current owner.
425 *
426 * The current owner is the component who should own any components that are
427 * currently being constructed.
428 */
429var ReactCurrentOwner = {
430 /**
431 * @internal
432 * @type {ReactComponent}
433 */
434 current: null
435};
436
437var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
438
439var describeComponentFrame = function (name, source, ownerName) {
440 var sourceInfo = '';
441 if (source) {
442 var path = source.fileName;
443 var fileName = path.replace(BEFORE_SLASH_RE, '');
444 {
445 // In DEV, include code for a common special case:
446 // prefer "folder/index.js" instead of just "index.js".
447 if (/^index\./.test(fileName)) {
448 var match = path.match(BEFORE_SLASH_RE);
449 if (match) {
450 var pathBeforeSlash = match[1];
451 if (pathBeforeSlash) {
452 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
453 fileName = folderName + '/' + fileName;
454 }
455 }
456 }
457 }
458 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
459 } else if (ownerName) {
460 sourceInfo = ' (created by ' + ownerName + ')';
461 }
462 return '\n in ' + (name || 'Unknown') + sourceInfo;
463};
464
465var Resolved = 1;
466
467
468function refineResolvedLazyComponent(lazyComponent) {
469 return lazyComponent._status === Resolved ? lazyComponent._result : null;
470}
471
472function getWrappedName(outerType, innerType, wrapperName) {
473 var functionName = innerType.displayName || innerType.name || '';
474 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
475}
476
477function getComponentName(type) {
478 if (type == null) {
479 // Host root, text node or just invalid type.
480 return null;
481 }
482 {
483 if (typeof type.tag === 'number') {
484 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
485 }
486 }
487 if (typeof type === 'function') {
488 return type.displayName || type.name || null;
489 }
490 if (typeof type === 'string') {
491 return type;
492 }
493 switch (type) {
494 case REACT_CONCURRENT_MODE_TYPE:
495 return 'ConcurrentMode';
496 case REACT_FRAGMENT_TYPE:
497 return 'Fragment';
498 case REACT_PORTAL_TYPE:
499 return 'Portal';
500 case REACT_PROFILER_TYPE:
501 return 'Profiler';
502 case REACT_STRICT_MODE_TYPE:
503 return 'StrictMode';
504 case REACT_SUSPENSE_TYPE:
505 return 'Suspense';
506 }
507 if (typeof type === 'object') {
508 switch (type.$$typeof) {
509 case REACT_CONTEXT_TYPE:
510 return 'Context.Consumer';
511 case REACT_PROVIDER_TYPE:
512 return 'Context.Provider';
513 case REACT_FORWARD_REF_TYPE:
514 return getWrappedName(type, type.render, 'ForwardRef');
515 case REACT_MEMO_TYPE:
516 return getComponentName(type.type);
517 case REACT_LAZY_TYPE:
518 {
519 var thenable = type;
520 var resolvedThenable = refineResolvedLazyComponent(thenable);
521 if (resolvedThenable) {
522 return getComponentName(resolvedThenable);
523 }
524 }
525 }
526 }
527 return null;
528}
529
530var ReactDebugCurrentFrame = {};
531
532var currentlyValidatingElement = null;
533
534function setCurrentlyValidatingElement(element) {
535 {
536 currentlyValidatingElement = element;
537 }
538}
539
540{
541 // Stack implementation injected by the current renderer.
542 ReactDebugCurrentFrame.getCurrentStack = null;
543
544 ReactDebugCurrentFrame.getStackAddendum = function () {
545 var stack = '';
546
547 // Add an extra top frame while an element is being validated
548 if (currentlyValidatingElement) {
549 var name = getComponentName(currentlyValidatingElement.type);
550 var owner = currentlyValidatingElement._owner;
551 stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
552 }
553
554 // Delegate to the injected renderer-specific implementation
555 var impl = ReactDebugCurrentFrame.getCurrentStack;
556 if (impl) {
557 stack += impl() || '';
558 }
559
560 return stack;
561 };
562}
563
564var ReactSharedInternals = {
565 ReactCurrentDispatcher: ReactCurrentDispatcher,
566 ReactCurrentOwner: ReactCurrentOwner,
567 // Used by renderers to avoid bundling object-assign twice in UMD bundles:
568 assign: _assign
569};
570
571{
572 _assign(ReactSharedInternals, {
573 // These should not be included in production.
574 ReactDebugCurrentFrame: ReactDebugCurrentFrame,
575 // Shim for React DOM 16.0.0 which still destructured (but not used) this.
576 // TODO: remove in React 17.0.
577 ReactComponentTreeHook: {}
578 });
579}
580
581/**
582 * Similar to invariant but only logs a warning if the condition is not met.
583 * This can be used to log issues in development environments in critical
584 * paths. Removing the logging code for production environments will keep the
585 * same logic and follow the same code paths.
586 */
587
588var warning = warningWithoutStack$1;
589
590{
591 warning = function (condition, format) {
592 if (condition) {
593 return;
594 }
595 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
596 var stack = ReactDebugCurrentFrame.getStackAddendum();
597 // eslint-disable-next-line react-internal/warning-and-invariant-args
598
599 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
600 args[_key - 2] = arguments[_key];
601 }
602
603 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
604 };
605}
606
607var warning$1 = warning;
608
609var hasOwnProperty = Object.prototype.hasOwnProperty;
610
611var RESERVED_PROPS = {
612 key: true,
613 ref: true,
614 __self: true,
615 __source: true
616};
617
618var specialPropKeyWarningShown = void 0;
619var specialPropRefWarningShown = void 0;
620
621function hasValidRef(config) {
622 {
623 if (hasOwnProperty.call(config, 'ref')) {
624 var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
625 if (getter && getter.isReactWarning) {
626 return false;
627 }
628 }
629 }
630 return config.ref !== undefined;
631}
632
633function hasValidKey(config) {
634 {
635 if (hasOwnProperty.call(config, 'key')) {
636 var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
637 if (getter && getter.isReactWarning) {
638 return false;
639 }
640 }
641 }
642 return config.key !== undefined;
643}
644
645function defineKeyPropWarningGetter(props, displayName) {
646 var warnAboutAccessingKey = function () {
647 if (!specialPropKeyWarningShown) {
648 specialPropKeyWarningShown = true;
649 warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
650 }
651 };
652 warnAboutAccessingKey.isReactWarning = true;
653 Object.defineProperty(props, 'key', {
654 get: warnAboutAccessingKey,
655 configurable: true
656 });
657}
658
659function defineRefPropWarningGetter(props, displayName) {
660 var warnAboutAccessingRef = function () {
661 if (!specialPropRefWarningShown) {
662 specialPropRefWarningShown = true;
663 warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
664 }
665 };
666 warnAboutAccessingRef.isReactWarning = true;
667 Object.defineProperty(props, 'ref', {
668 get: warnAboutAccessingRef,
669 configurable: true
670 });
671}
672
673/**
674 * Factory method to create a new React element. This no longer adheres to
675 * the class pattern, so do not use new to call it. Also, no instanceof check
676 * will work. Instead test $$typeof field against Symbol.for('react.element') to check
677 * if something is a React Element.
678 *
679 * @param {*} type
680 * @param {*} key
681 * @param {string|object} ref
682 * @param {*} self A *temporary* helper to detect places where `this` is
683 * different from the `owner` when React.createElement is called, so that we
684 * can warn. We want to get rid of owner and replace string `ref`s with arrow
685 * functions, and as long as `this` and owner are the same, there will be no
686 * change in behavior.
687 * @param {*} source An annotation object (added by a transpiler or otherwise)
688 * indicating filename, line number, and/or other information.
689 * @param {*} owner
690 * @param {*} props
691 * @internal
692 */
693var ReactElement = function (type, key, ref, self, source, owner, props) {
694 var element = {
695 // This tag allows us to uniquely identify this as a React Element
696 $$typeof: REACT_ELEMENT_TYPE,
697
698 // Built-in properties that belong on the element
699 type: type,
700 key: key,
701 ref: ref,
702 props: props,
703
704 // Record the component responsible for creating this element.
705 _owner: owner
706 };
707
708 {
709 // The validation flag is currently mutative. We put it on
710 // an external backing store so that we can freeze the whole object.
711 // This can be replaced with a WeakMap once they are implemented in
712 // commonly used development environments.
713 element._store = {};
714
715 // To make comparing ReactElements easier for testing purposes, we make
716 // the validation flag non-enumerable (where possible, which should
717 // include every environment we run tests in), so the test framework
718 // ignores it.
719 Object.defineProperty(element._store, 'validated', {
720 configurable: false,
721 enumerable: false,
722 writable: true,
723 value: false
724 });
725 // self and source are DEV only properties.
726 Object.defineProperty(element, '_self', {
727 configurable: false,
728 enumerable: false,
729 writable: false,
730 value: self
731 });
732 // Two elements created in two different places should be considered
733 // equal for testing purposes and therefore we hide it from enumeration.
734 Object.defineProperty(element, '_source', {
735 configurable: false,
736 enumerable: false,
737 writable: false,
738 value: source
739 });
740 if (Object.freeze) {
741 Object.freeze(element.props);
742 Object.freeze(element);
743 }
744 }
745
746 return element;
747};
748
749/**
750 * Create and return a new ReactElement of the given type.
751 * See https://reactjs.org/docs/react-api.html#createelement
752 */
753function createElement(type, config, children) {
754 var propName = void 0;
755
756 // Reserved names are extracted
757 var props = {};
758
759 var key = null;
760 var ref = null;
761 var self = null;
762 var source = null;
763
764 if (config != null) {
765 if (hasValidRef(config)) {
766 ref = config.ref;
767 }
768 if (hasValidKey(config)) {
769 key = '' + config.key;
770 }
771
772 self = config.__self === undefined ? null : config.__self;
773 source = config.__source === undefined ? null : config.__source;
774 // Remaining properties are added to a new props object
775 for (propName in config) {
776 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
777 props[propName] = config[propName];
778 }
779 }
780 }
781
782 // Children can be more than one argument, and those are transferred onto
783 // the newly allocated props object.
784 var childrenLength = arguments.length - 2;
785 if (childrenLength === 1) {
786 props.children = children;
787 } else if (childrenLength > 1) {
788 var childArray = Array(childrenLength);
789 for (var i = 0; i < childrenLength; i++) {
790 childArray[i] = arguments[i + 2];
791 }
792 {
793 if (Object.freeze) {
794 Object.freeze(childArray);
795 }
796 }
797 props.children = childArray;
798 }
799
800 // Resolve default props
801 if (type && type.defaultProps) {
802 var defaultProps = type.defaultProps;
803 for (propName in defaultProps) {
804 if (props[propName] === undefined) {
805 props[propName] = defaultProps[propName];
806 }
807 }
808 }
809 {
810 if (key || ref) {
811 var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
812 if (key) {
813 defineKeyPropWarningGetter(props, displayName);
814 }
815 if (ref) {
816 defineRefPropWarningGetter(props, displayName);
817 }
818 }
819 }
820 return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
821}
822
823/**
824 * Return a function that produces ReactElements of a given type.
825 * See https://reactjs.org/docs/react-api.html#createfactory
826 */
827
828
829function cloneAndReplaceKey(oldElement, newKey) {
830 var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
831
832 return newElement;
833}
834
835/**
836 * Clone and return a new ReactElement using element as the starting point.
837 * See https://reactjs.org/docs/react-api.html#cloneelement
838 */
839function cloneElement(element, config, children) {
840 !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
841
842 var propName = void 0;
843
844 // Original props are copied
845 var props = _assign({}, element.props);
846
847 // Reserved names are extracted
848 var key = element.key;
849 var ref = element.ref;
850 // Self is preserved since the owner is preserved.
851 var self = element._self;
852 // Source is preserved since cloneElement is unlikely to be targeted by a
853 // transpiler, and the original source is probably a better indicator of the
854 // true owner.
855 var source = element._source;
856
857 // Owner will be preserved, unless ref is overridden
858 var owner = element._owner;
859
860 if (config != null) {
861 if (hasValidRef(config)) {
862 // Silently steal the ref from the parent.
863 ref = config.ref;
864 owner = ReactCurrentOwner.current;
865 }
866 if (hasValidKey(config)) {
867 key = '' + config.key;
868 }
869
870 // Remaining properties override existing props
871 var defaultProps = void 0;
872 if (element.type && element.type.defaultProps) {
873 defaultProps = element.type.defaultProps;
874 }
875 for (propName in config) {
876 if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
877 if (config[propName] === undefined && defaultProps !== undefined) {
878 // Resolve default props
879 props[propName] = defaultProps[propName];
880 } else {
881 props[propName] = config[propName];
882 }
883 }
884 }
885 }
886
887 // Children can be more than one argument, and those are transferred onto
888 // the newly allocated props object.
889 var childrenLength = arguments.length - 2;
890 if (childrenLength === 1) {
891 props.children = children;
892 } else if (childrenLength > 1) {
893 var childArray = Array(childrenLength);
894 for (var i = 0; i < childrenLength; i++) {
895 childArray[i] = arguments[i + 2];
896 }
897 props.children = childArray;
898 }
899
900 return ReactElement(element.type, key, ref, self, source, owner, props);
901}
902
903/**
904 * Verifies the object is a ReactElement.
905 * See https://reactjs.org/docs/react-api.html#isvalidelement
906 * @param {?object} object
907 * @return {boolean} True if `object` is a ReactElement.
908 * @final
909 */
910function isValidElement(object) {
911 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
912}
913
914var SEPARATOR = '.';
915var SUBSEPARATOR = ':';
916
917/**
918 * Escape and wrap key so it is safe to use as a reactid
919 *
920 * @param {string} key to be escaped.
921 * @return {string} the escaped key.
922 */
923function escape(key) {
924 var escapeRegex = /[=:]/g;
925 var escaperLookup = {
926 '=': '=0',
927 ':': '=2'
928 };
929 var escapedString = ('' + key).replace(escapeRegex, function (match) {
930 return escaperLookup[match];
931 });
932
933 return '$' + escapedString;
934}
935
936/**
937 * TODO: Test that a single child and an array with one item have the same key
938 * pattern.
939 */
940
941var didWarnAboutMaps = false;
942
943var userProvidedKeyEscapeRegex = /\/+/g;
944function escapeUserProvidedKey(text) {
945 return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
946}
947
948var POOL_SIZE = 10;
949var traverseContextPool = [];
950function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
951 if (traverseContextPool.length) {
952 var traverseContext = traverseContextPool.pop();
953 traverseContext.result = mapResult;
954 traverseContext.keyPrefix = keyPrefix;
955 traverseContext.func = mapFunction;
956 traverseContext.context = mapContext;
957 traverseContext.count = 0;
958 return traverseContext;
959 } else {
960 return {
961 result: mapResult,
962 keyPrefix: keyPrefix,
963 func: mapFunction,
964 context: mapContext,
965 count: 0
966 };
967 }
968}
969
970function releaseTraverseContext(traverseContext) {
971 traverseContext.result = null;
972 traverseContext.keyPrefix = null;
973 traverseContext.func = null;
974 traverseContext.context = null;
975 traverseContext.count = 0;
976 if (traverseContextPool.length < POOL_SIZE) {
977 traverseContextPool.push(traverseContext);
978 }
979}
980
981/**
982 * @param {?*} children Children tree container.
983 * @param {!string} nameSoFar Name of the key path so far.
984 * @param {!function} callback Callback to invoke with each child found.
985 * @param {?*} traverseContext Used to pass information throughout the traversal
986 * process.
987 * @return {!number} The number of children in this subtree.
988 */
989function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
990 var type = typeof children;
991
992 if (type === 'undefined' || type === 'boolean') {
993 // All of the above are perceived as null.
994 children = null;
995 }
996
997 var invokeCallback = false;
998
999 if (children === null) {
1000 invokeCallback = true;
1001 } else {
1002 switch (type) {
1003 case 'string':
1004 case 'number':
1005 invokeCallback = true;
1006 break;
1007 case 'object':
1008 switch (children.$$typeof) {
1009 case REACT_ELEMENT_TYPE:
1010 case REACT_PORTAL_TYPE:
1011 invokeCallback = true;
1012 }
1013 }
1014 }
1015
1016 if (invokeCallback) {
1017 callback(traverseContext, children,
1018 // If it's the only child, treat the name as if it was wrapped in an array
1019 // so that it's consistent if the number of children grows.
1020 nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
1021 return 1;
1022 }
1023
1024 var child = void 0;
1025 var nextName = void 0;
1026 var subtreeCount = 0; // Count of children found in the current subtree.
1027 var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1028
1029 if (Array.isArray(children)) {
1030 for (var i = 0; i < children.length; i++) {
1031 child = children[i];
1032 nextName = nextNamePrefix + getComponentKey(child, i);
1033 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1034 }
1035 } else {
1036 var iteratorFn = getIteratorFn(children);
1037 if (typeof iteratorFn === 'function') {
1038 {
1039 // Warn about using Maps as children
1040 if (iteratorFn === children.entries) {
1041 !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;
1042 didWarnAboutMaps = true;
1043 }
1044 }
1045
1046 var iterator = iteratorFn.call(children);
1047 var step = void 0;
1048 var ii = 0;
1049 while (!(step = iterator.next()).done) {
1050 child = step.value;
1051 nextName = nextNamePrefix + getComponentKey(child, ii++);
1052 subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
1053 }
1054 } else if (type === 'object') {
1055 var addendum = '';
1056 {
1057 addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
1058 }
1059 var childrenString = '' + children;
1060 invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
1061 }
1062 }
1063
1064 return subtreeCount;
1065}
1066
1067/**
1068 * Traverses children that are typically specified as `props.children`, but
1069 * might also be specified through attributes:
1070 *
1071 * - `traverseAllChildren(this.props.children, ...)`
1072 * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
1073 *
1074 * The `traverseContext` is an optional argument that is passed through the
1075 * entire traversal. It can be used to store accumulations or anything else that
1076 * the callback might find relevant.
1077 *
1078 * @param {?*} children Children tree object.
1079 * @param {!function} callback To invoke upon traversing each child.
1080 * @param {?*} traverseContext Context for traversal.
1081 * @return {!number} The number of children in this subtree.
1082 */
1083function traverseAllChildren(children, callback, traverseContext) {
1084 if (children == null) {
1085 return 0;
1086 }
1087
1088 return traverseAllChildrenImpl(children, '', callback, traverseContext);
1089}
1090
1091/**
1092 * Generate a key string that identifies a component within a set.
1093 *
1094 * @param {*} component A component that could contain a manual key.
1095 * @param {number} index Index that is used if a manual key is not provided.
1096 * @return {string}
1097 */
1098function getComponentKey(component, index) {
1099 // Do some typechecking here since we call this blindly. We want to ensure
1100 // that we don't block potential future ES APIs.
1101 if (typeof component === 'object' && component !== null && component.key != null) {
1102 // Explicit key
1103 return escape(component.key);
1104 }
1105 // Implicit key determined by the index in the set
1106 return index.toString(36);
1107}
1108
1109function forEachSingleChild(bookKeeping, child, name) {
1110 var func = bookKeeping.func,
1111 context = bookKeeping.context;
1112
1113 func.call(context, child, bookKeeping.count++);
1114}
1115
1116/**
1117 * Iterates through children that are typically specified as `props.children`.
1118 *
1119 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
1120 *
1121 * The provided forEachFunc(child, index) will be called for each
1122 * leaf child.
1123 *
1124 * @param {?*} children Children tree container.
1125 * @param {function(*, int)} forEachFunc
1126 * @param {*} forEachContext Context for forEachContext.
1127 */
1128function forEachChildren(children, forEachFunc, forEachContext) {
1129 if (children == null) {
1130 return children;
1131 }
1132 var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
1133 traverseAllChildren(children, forEachSingleChild, traverseContext);
1134 releaseTraverseContext(traverseContext);
1135}
1136
1137function mapSingleChildIntoContext(bookKeeping, child, childKey) {
1138 var result = bookKeeping.result,
1139 keyPrefix = bookKeeping.keyPrefix,
1140 func = bookKeeping.func,
1141 context = bookKeeping.context;
1142
1143
1144 var mappedChild = func.call(context, child, bookKeeping.count++);
1145 if (Array.isArray(mappedChild)) {
1146 mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
1147 return c;
1148 });
1149 } else if (mappedChild != null) {
1150 if (isValidElement(mappedChild)) {
1151 mappedChild = cloneAndReplaceKey(mappedChild,
1152 // Keep both the (mapped) and old keys if they differ, just as
1153 // traverseAllChildren used to do for objects as children
1154 keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
1155 }
1156 result.push(mappedChild);
1157 }
1158}
1159
1160function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
1161 var escapedPrefix = '';
1162 if (prefix != null) {
1163 escapedPrefix = escapeUserProvidedKey(prefix) + '/';
1164 }
1165 var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
1166 traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
1167 releaseTraverseContext(traverseContext);
1168}
1169
1170/**
1171 * Maps children that are typically specified as `props.children`.
1172 *
1173 * See https://reactjs.org/docs/react-api.html#reactchildrenmap
1174 *
1175 * The provided mapFunction(child, key, index) will be called for each
1176 * leaf child.
1177 *
1178 * @param {?*} children Children tree container.
1179 * @param {function(*, int)} func The map function.
1180 * @param {*} context Context for mapFunction.
1181 * @return {object} Object containing the ordered map of results.
1182 */
1183function mapChildren(children, func, context) {
1184 if (children == null) {
1185 return children;
1186 }
1187 var result = [];
1188 mapIntoWithKeyPrefixInternal(children, result, null, func, context);
1189 return result;
1190}
1191
1192/**
1193 * Count the number of children that are typically specified as
1194 * `props.children`.
1195 *
1196 * See https://reactjs.org/docs/react-api.html#reactchildrencount
1197 *
1198 * @param {?*} children Children tree container.
1199 * @return {number} The number of children.
1200 */
1201function countChildren(children) {
1202 return traverseAllChildren(children, function () {
1203 return null;
1204 }, null);
1205}
1206
1207/**
1208 * Flatten a children object (typically specified as `props.children`) and
1209 * return an array with appropriately re-keyed children.
1210 *
1211 * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
1212 */
1213function toArray(children) {
1214 var result = [];
1215 mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
1216 return child;
1217 });
1218 return result;
1219}
1220
1221/**
1222 * Returns the first child in a collection of children and verifies that there
1223 * is only one child in the collection.
1224 *
1225 * See https://reactjs.org/docs/react-api.html#reactchildrenonly
1226 *
1227 * The current implementation of this function assumes that a single child gets
1228 * passed without a wrapper, but the purpose of this helper function is to
1229 * abstract away the particular structure of children.
1230 *
1231 * @param {?object} children Child collection structure.
1232 * @return {ReactElement} The first and only `ReactElement` contained in the
1233 * structure.
1234 */
1235function onlyChild(children) {
1236 !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
1237 return children;
1238}
1239
1240function createContext(defaultValue, calculateChangedBits) {
1241 if (calculateChangedBits === undefined) {
1242 calculateChangedBits = null;
1243 } else {
1244 {
1245 !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
1246 }
1247 }
1248
1249 var context = {
1250 $$typeof: REACT_CONTEXT_TYPE,
1251 _calculateChangedBits: calculateChangedBits,
1252 // As a workaround to support multiple concurrent renderers, we categorize
1253 // some renderers as primary and others as secondary. We only expect
1254 // there to be two concurrent renderers at most: React Native (primary) and
1255 // Fabric (secondary); React DOM (primary) and React ART (secondary).
1256 // Secondary renderers store their context values on separate fields.
1257 _currentValue: defaultValue,
1258 _currentValue2: defaultValue,
1259 // Used to track how many concurrent renderers this context currently
1260 // supports within in a single renderer. Such as parallel server rendering.
1261 _threadCount: 0,
1262 // These are circular
1263 Provider: null,
1264 Consumer: null
1265 };
1266
1267 context.Provider = {
1268 $$typeof: REACT_PROVIDER_TYPE,
1269 _context: context
1270 };
1271
1272 var hasWarnedAboutUsingNestedContextConsumers = false;
1273 var hasWarnedAboutUsingConsumerProvider = false;
1274
1275 {
1276 // A separate object, but proxies back to the original context object for
1277 // backwards compatibility. It has a different $$typeof, so we can properly
1278 // warn for the incorrect usage of Context as a Consumer.
1279 var Consumer = {
1280 $$typeof: REACT_CONTEXT_TYPE,
1281 _context: context,
1282 _calculateChangedBits: context._calculateChangedBits
1283 };
1284 // $FlowFixMe: Flow complains about not setting a value, which is intentional here
1285 Object.defineProperties(Consumer, {
1286 Provider: {
1287 get: function () {
1288 if (!hasWarnedAboutUsingConsumerProvider) {
1289 hasWarnedAboutUsingConsumerProvider = true;
1290 warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
1291 }
1292 return context.Provider;
1293 },
1294 set: function (_Provider) {
1295 context.Provider = _Provider;
1296 }
1297 },
1298 _currentValue: {
1299 get: function () {
1300 return context._currentValue;
1301 },
1302 set: function (_currentValue) {
1303 context._currentValue = _currentValue;
1304 }
1305 },
1306 _currentValue2: {
1307 get: function () {
1308 return context._currentValue2;
1309 },
1310 set: function (_currentValue2) {
1311 context._currentValue2 = _currentValue2;
1312 }
1313 },
1314 _threadCount: {
1315 get: function () {
1316 return context._threadCount;
1317 },
1318 set: function (_threadCount) {
1319 context._threadCount = _threadCount;
1320 }
1321 },
1322 Consumer: {
1323 get: function () {
1324 if (!hasWarnedAboutUsingNestedContextConsumers) {
1325 hasWarnedAboutUsingNestedContextConsumers = true;
1326 warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
1327 }
1328 return context.Consumer;
1329 }
1330 }
1331 });
1332 // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
1333 context.Consumer = Consumer;
1334 }
1335
1336 {
1337 context._currentRenderer = null;
1338 context._currentRenderer2 = null;
1339 }
1340
1341 return context;
1342}
1343
1344function lazy(ctor) {
1345 var lazyType = {
1346 $$typeof: REACT_LAZY_TYPE,
1347 _ctor: ctor,
1348 // React uses these fields to store the result.
1349 _status: -1,
1350 _result: null
1351 };
1352
1353 {
1354 // In production, this would just set it on the object.
1355 var defaultProps = void 0;
1356 var propTypes = void 0;
1357 Object.defineProperties(lazyType, {
1358 defaultProps: {
1359 configurable: true,
1360 get: function () {
1361 return defaultProps;
1362 },
1363 set: function (newDefaultProps) {
1364 warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
1365 defaultProps = newDefaultProps;
1366 // Match production behavior more closely:
1367 Object.defineProperty(lazyType, 'defaultProps', {
1368 enumerable: true
1369 });
1370 }
1371 },
1372 propTypes: {
1373 configurable: true,
1374 get: function () {
1375 return propTypes;
1376 },
1377 set: function (newPropTypes) {
1378 warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
1379 propTypes = newPropTypes;
1380 // Match production behavior more closely:
1381 Object.defineProperty(lazyType, 'propTypes', {
1382 enumerable: true
1383 });
1384 }
1385 }
1386 });
1387 }
1388
1389 return lazyType;
1390}
1391
1392function forwardRef(render) {
1393 {
1394 if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
1395 warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
1396 } else if (typeof render !== 'function') {
1397 warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
1398 } else {
1399 !(
1400 // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
1401 render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0;
1402 }
1403
1404 if (render != null) {
1405 !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
1406 }
1407 }
1408
1409 return {
1410 $$typeof: REACT_FORWARD_REF_TYPE,
1411 render: render
1412 };
1413}
1414
1415function isValidElementType(type) {
1416 return typeof type === 'string' || typeof type === 'function' ||
1417 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1418 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
1419}
1420
1421function memo(type, compare) {
1422 {
1423 if (!isValidElementType(type)) {
1424 warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
1425 }
1426 }
1427 return {
1428 $$typeof: REACT_MEMO_TYPE,
1429 type: type,
1430 compare: compare === undefined ? null : compare
1431 };
1432}
1433
1434function resolveDispatcher() {
1435 var dispatcher = ReactCurrentDispatcher.current;
1436 !(dispatcher !== null) ? invariant(false, 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.') : void 0;
1437 return dispatcher;
1438}
1439
1440function useContext(Context, unstable_observedBits) {
1441 var dispatcher = resolveDispatcher();
1442 {
1443 !(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0;
1444
1445 // TODO: add a more generic warning for invalid values.
1446 if (Context._context !== undefined) {
1447 var realContext = Context._context;
1448 // Don't deduplicate because this legitimately causes bugs
1449 // and nobody should be using this in existing code.
1450 if (realContext.Consumer === Context) {
1451 warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
1452 } else if (realContext.Provider === Context) {
1453 warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
1454 }
1455 }
1456 }
1457 return dispatcher.useContext(Context, unstable_observedBits);
1458}
1459
1460function useState(initialState) {
1461 var dispatcher = resolveDispatcher();
1462 return dispatcher.useState(initialState);
1463}
1464
1465function useReducer(reducer, initialArg, init) {
1466 var dispatcher = resolveDispatcher();
1467 return dispatcher.useReducer(reducer, initialArg, init);
1468}
1469
1470function useRef(initialValue) {
1471 var dispatcher = resolveDispatcher();
1472 return dispatcher.useRef(initialValue);
1473}
1474
1475function useEffect(create, inputs) {
1476 var dispatcher = resolveDispatcher();
1477 return dispatcher.useEffect(create, inputs);
1478}
1479
1480function useLayoutEffect(create, inputs) {
1481 var dispatcher = resolveDispatcher();
1482 return dispatcher.useLayoutEffect(create, inputs);
1483}
1484
1485function useCallback(callback, inputs) {
1486 var dispatcher = resolveDispatcher();
1487 return dispatcher.useCallback(callback, inputs);
1488}
1489
1490function useMemo(create, inputs) {
1491 var dispatcher = resolveDispatcher();
1492 return dispatcher.useMemo(create, inputs);
1493}
1494
1495function useImperativeHandle(ref, create, inputs) {
1496 var dispatcher = resolveDispatcher();
1497 return dispatcher.useImperativeHandle(ref, create, inputs);
1498}
1499
1500function useDebugValue(value, formatterFn) {
1501 {
1502 var dispatcher = resolveDispatcher();
1503 return dispatcher.useDebugValue(value, formatterFn);
1504 }
1505}
1506
1507/**
1508 * ReactElementValidator provides a wrapper around a element factory
1509 * which validates the props passed to the element. This is intended to be
1510 * used only in DEV and could be replaced by a static type checker for languages
1511 * that support it.
1512 */
1513
1514var propTypesMisspellWarningShown = void 0;
1515
1516{
1517 propTypesMisspellWarningShown = false;
1518}
1519
1520function getDeclarationErrorAddendum() {
1521 if (ReactCurrentOwner.current) {
1522 var name = getComponentName(ReactCurrentOwner.current.type);
1523 if (name) {
1524 return '\n\nCheck the render method of `' + name + '`.';
1525 }
1526 }
1527 return '';
1528}
1529
1530function getSourceInfoErrorAddendum(elementProps) {
1531 if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
1532 var source = elementProps.__source;
1533 var fileName = source.fileName.replace(/^.*[\\\/]/, '');
1534 var lineNumber = source.lineNumber;
1535 return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
1536 }
1537 return '';
1538}
1539
1540/**
1541 * Warn if there's no key explicitly set on dynamic arrays of children or
1542 * object keys are not valid. This allows us to keep track of children between
1543 * updates.
1544 */
1545var ownerHasKeyUseWarning = {};
1546
1547function getCurrentComponentErrorInfo(parentType) {
1548 var info = getDeclarationErrorAddendum();
1549
1550 if (!info) {
1551 var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1552 if (parentName) {
1553 info = '\n\nCheck the top-level render call using <' + parentName + '>.';
1554 }
1555 }
1556 return info;
1557}
1558
1559/**
1560 * Warn if the element doesn't have an explicit key assigned to it.
1561 * This element is in an array. The array could grow and shrink or be
1562 * reordered. All children that haven't already been validated are required to
1563 * have a "key" property assigned to it. Error statuses are cached so a warning
1564 * will only be shown once.
1565 *
1566 * @internal
1567 * @param {ReactElement} element Element that requires a key.
1568 * @param {*} parentType element's parent's type.
1569 */
1570function validateExplicitKey(element, parentType) {
1571 if (!element._store || element._store.validated || element.key != null) {
1572 return;
1573 }
1574 element._store.validated = true;
1575
1576 var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1577 if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1578 return;
1579 }
1580 ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
1581
1582 // Usually the current owner is the offender, but if it accepts children as a
1583 // property, it may be the creator of the child that's responsible for
1584 // assigning it a key.
1585 var childOwner = '';
1586 if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
1587 // Give the component that originally created this child.
1588 childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
1589 }
1590
1591 setCurrentlyValidatingElement(element);
1592 {
1593 warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
1594 }
1595 setCurrentlyValidatingElement(null);
1596}
1597
1598/**
1599 * Ensure that every element either is passed in a static location, in an
1600 * array with an explicit keys property defined, or in an object literal
1601 * with valid key property.
1602 *
1603 * @internal
1604 * @param {ReactNode} node Statically passed child of any type.
1605 * @param {*} parentType node's parent's type.
1606 */
1607function validateChildKeys(node, parentType) {
1608 if (typeof node !== 'object') {
1609 return;
1610 }
1611 if (Array.isArray(node)) {
1612 for (var i = 0; i < node.length; i++) {
1613 var child = node[i];
1614 if (isValidElement(child)) {
1615 validateExplicitKey(child, parentType);
1616 }
1617 }
1618 } else if (isValidElement(node)) {
1619 // This element was passed in a valid location.
1620 if (node._store) {
1621 node._store.validated = true;
1622 }
1623 } else if (node) {
1624 var iteratorFn = getIteratorFn(node);
1625 if (typeof iteratorFn === 'function') {
1626 // Entry iterators used to provide implicit keys,
1627 // but now we print a separate warning for them later.
1628 if (iteratorFn !== node.entries) {
1629 var iterator = iteratorFn.call(node);
1630 var step = void 0;
1631 while (!(step = iterator.next()).done) {
1632 if (isValidElement(step.value)) {
1633 validateExplicitKey(step.value, parentType);
1634 }
1635 }
1636 }
1637 }
1638 }
1639}
1640
1641/**
1642 * Given an element, validate that its props follow the propTypes definition,
1643 * provided by the type.
1644 *
1645 * @param {ReactElement} element
1646 */
1647function validatePropTypes(element) {
1648 var type = element.type;
1649 if (type === null || type === undefined || typeof type === 'string') {
1650 return;
1651 }
1652 var name = getComponentName(type);
1653 var propTypes = void 0;
1654 if (typeof type === 'function') {
1655 propTypes = type.propTypes;
1656 } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
1657 // Note: Memo only checks outer props here.
1658 // Inner props are checked in the reconciler.
1659 type.$$typeof === REACT_MEMO_TYPE)) {
1660 propTypes = type.propTypes;
1661 } else {
1662 return;
1663 }
1664 if (propTypes) {
1665 setCurrentlyValidatingElement(element);
1666 checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
1667 setCurrentlyValidatingElement(null);
1668 } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1669 propTypesMisspellWarningShown = true;
1670 warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
1671 }
1672 if (typeof type.getDefaultProps === 'function') {
1673 !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
1674 }
1675}
1676
1677/**
1678 * Given a fragment, validate that it can only be provided with fragment props
1679 * @param {ReactElement} fragment
1680 */
1681function validateFragmentProps(fragment) {
1682 setCurrentlyValidatingElement(fragment);
1683
1684 var keys = Object.keys(fragment.props);
1685 for (var i = 0; i < keys.length; i++) {
1686 var key = keys[i];
1687 if (key !== 'children' && key !== 'key') {
1688 warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1689 break;
1690 }
1691 }
1692
1693 if (fragment.ref !== null) {
1694 warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
1695 }
1696
1697 setCurrentlyValidatingElement(null);
1698}
1699
1700function createElementWithValidation(type, props, children) {
1701 var validType = isValidElementType(type);
1702
1703 // We warn in this case but don't throw. We expect the element creation to
1704 // succeed and there will likely be errors in render.
1705 if (!validType) {
1706 var info = '';
1707 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1708 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.";
1709 }
1710
1711 var sourceInfo = getSourceInfoErrorAddendum(props);
1712 if (sourceInfo) {
1713 info += sourceInfo;
1714 } else {
1715 info += getDeclarationErrorAddendum();
1716 }
1717
1718 var typeString = void 0;
1719 if (type === null) {
1720 typeString = 'null';
1721 } else if (Array.isArray(type)) {
1722 typeString = 'array';
1723 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1724 typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
1725 info = ' Did you accidentally export a JSX literal instead of a component?';
1726 } else {
1727 typeString = typeof type;
1728 }
1729
1730 warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
1731 }
1732
1733 var element = createElement.apply(this, arguments);
1734
1735 // The result can be nullish if a mock or a custom function is used.
1736 // TODO: Drop this when these are no longer allowed as the type argument.
1737 if (element == null) {
1738 return element;
1739 }
1740
1741 // Skip key warning if the type isn't valid since our key validation logic
1742 // doesn't expect a non-string/function type and can throw confusing errors.
1743 // We don't want exception behavior to differ between dev and prod.
1744 // (Rendering will throw with a helpful message and as soon as the type is
1745 // fixed, the key warnings will appear.)
1746 if (validType) {
1747 for (var i = 2; i < arguments.length; i++) {
1748 validateChildKeys(arguments[i], type);
1749 }
1750 }
1751
1752 if (type === REACT_FRAGMENT_TYPE) {
1753 validateFragmentProps(element);
1754 } else {
1755 validatePropTypes(element);
1756 }
1757
1758 return element;
1759}
1760
1761function createFactoryWithValidation(type) {
1762 var validatedFactory = createElementWithValidation.bind(null, type);
1763 validatedFactory.type = type;
1764 // Legacy hook: remove it
1765 {
1766 Object.defineProperty(validatedFactory, 'type', {
1767 enumerable: false,
1768 get: function () {
1769 lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
1770 Object.defineProperty(this, 'type', {
1771 value: type
1772 });
1773 return type;
1774 }
1775 });
1776 }
1777
1778 return validatedFactory;
1779}
1780
1781function cloneElementWithValidation(element, props, children) {
1782 var newElement = cloneElement.apply(this, arguments);
1783 for (var i = 2; i < arguments.length; i++) {
1784 validateChildKeys(arguments[i], newElement.type);
1785 }
1786 validatePropTypes(newElement);
1787 return newElement;
1788}
1789
1790// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
1791
1792
1793// In some cases, StrictMode should also double-render lifecycles.
1794// This can be confusing for tests though,
1795// And it can be bad for performance in production.
1796// This feature flag can be used to control the behavior:
1797
1798
1799// To preserve the "Pause on caught exceptions" behavior of the debugger, we
1800// replay the begin phase of a failed component inside invokeGuardedCallback.
1801
1802
1803// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
1804
1805
1806// Gather advanced timing metrics for Profiler subtrees.
1807
1808
1809// Trace which interactions trigger each commit.
1810
1811
1812// Only used in www builds.
1813 // TODO: true? Here it might just be false.
1814
1815// Only used in www builds.
1816
1817
1818// Only used in www builds.
1819
1820
1821// React Fire: prevent the value and checked attributes from syncing
1822// with their related DOM properties
1823
1824
1825// These APIs will no longer be "unstable" in the upcoming 16.7 release,
1826// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
1827var enableStableConcurrentModeAPIs = false;
1828
1829var React = {
1830 Children: {
1831 map: mapChildren,
1832 forEach: forEachChildren,
1833 count: countChildren,
1834 toArray: toArray,
1835 only: onlyChild
1836 },
1837
1838 createRef: createRef,
1839 Component: Component,
1840 PureComponent: PureComponent,
1841
1842 createContext: createContext,
1843 forwardRef: forwardRef,
1844 lazy: lazy,
1845 memo: memo,
1846
1847 useCallback: useCallback,
1848 useContext: useContext,
1849 useEffect: useEffect,
1850 useImperativeHandle: useImperativeHandle,
1851 useDebugValue: useDebugValue,
1852 useLayoutEffect: useLayoutEffect,
1853 useMemo: useMemo,
1854 useReducer: useReducer,
1855 useRef: useRef,
1856 useState: useState,
1857
1858 Fragment: REACT_FRAGMENT_TYPE,
1859 StrictMode: REACT_STRICT_MODE_TYPE,
1860 Suspense: REACT_SUSPENSE_TYPE,
1861
1862 createElement: createElementWithValidation,
1863 cloneElement: cloneElementWithValidation,
1864 createFactory: createFactoryWithValidation,
1865 isValidElement: isValidElement,
1866
1867 version: ReactVersion,
1868
1869 unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
1870 unstable_Profiler: REACT_PROFILER_TYPE,
1871
1872 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
1873};
1874
1875// Note: some APIs are added with feature flags.
1876// Make sure that stable builds for open source
1877// don't modify the React object to avoid deopts.
1878// Also let's not expose their names in stable builds.
1879
1880if (enableStableConcurrentModeAPIs) {
1881 React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
1882 React.Profiler = REACT_PROFILER_TYPE;
1883 React.unstable_ConcurrentMode = undefined;
1884 React.unstable_Profiler = undefined;
1885}
1886
1887
1888
1889var React$2 = Object.freeze({
1890 default: React
1891});
1892
1893var React$3 = ( React$2 && React ) || React$2;
1894
1895// TODO: decide on the top-level export form.
1896// This is hacky but makes it work with both Rollup and Jest.
1897var react = React$3.default || React$3;
1898
1899module.exports = react;
1900 })();
1901}