UNPKG

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