UNPKG

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