UNPKG

138 kBJavaScriptView Raw
1/** @license React v16.9.0
2 * react-dom-server.browser.development.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';
11
12
13
14if (process.env.NODE_ENV !== "production") {
15 (function() {
16'use strict';
17
18var _assign = require('object-assign');
19var React = require('react');
20var checkPropTypes = require('prop-types/checkPropTypes');
21
22// Do not require this module directly! Use normal `invariant` calls with
23// template literal strings. The messages will be converted to ReactError during
24// build, and in production they will be minified.
25
26// Do not require this module directly! Use normal `invariant` calls with
27// template literal strings. The messages will be converted to ReactError during
28// build, and in production they will be minified.
29
30function ReactError(error) {
31 error.name = 'Invariant Violation';
32 return error;
33}
34
35// TODO: this is special because it gets imported during build.
36
37var ReactVersion = '16.9.0';
38
39/**
40 * Use invariant() to assert state which your program assumes to be true.
41 *
42 * Provide sprintf-style format (only %s is supported) and arguments
43 * to provide information about what broke and what you were
44 * expecting.
45 *
46 * The invariant message will be stripped in production, but the invariant
47 * will remain to ensure logic does not differ in production.
48 */
49
50/**
51 * Similar to invariant but only logs a warning if the condition is not met.
52 * This can be used to log issues in development environments in critical
53 * paths. Removing the logging code for production environments will keep the
54 * same logic and follow the same code paths.
55 */
56
57var warningWithoutStack = function () {};
58
59{
60 warningWithoutStack = function (condition, format) {
61 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
62 args[_key - 2] = arguments[_key];
63 }
64
65 if (format === undefined) {
66 throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
67 }
68 if (args.length > 8) {
69 // Check before the condition to catch violations early.
70 throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
71 }
72 if (condition) {
73 return;
74 }
75 if (typeof console !== 'undefined') {
76 var argsWithFormat = args.map(function (item) {
77 return '' + item;
78 });
79 argsWithFormat.unshift('Warning: ' + format);
80
81 // We intentionally don't use spread (or .apply) directly because it
82 // breaks IE9: https://github.com/facebook/react/issues/13610
83 Function.prototype.apply.call(console.error, console, argsWithFormat);
84 }
85 try {
86 // --- Welcome to debugging React ---
87 // This error was thrown as a convenience so that you can use this stack
88 // to find the callsite that caused this warning to fire.
89 var argIndex = 0;
90 var message = 'Warning: ' + format.replace(/%s/g, function () {
91 return args[argIndex++];
92 });
93 throw new Error(message);
94 } catch (x) {}
95 };
96}
97
98var warningWithoutStack$1 = warningWithoutStack;
99
100// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
101// nor polyfill, then a plain number is used for performance.
102var hasSymbol = typeof Symbol === 'function' && Symbol.for;
103
104
105var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
106var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
107var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
108var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
109var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
110var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
111// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
112// (unstable) APIs that have been removed. Can we remove the symbols?
113
114var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
115var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
116var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
117var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
118var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
119var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
120var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
121
122var Resolved = 1;
123
124
125function refineResolvedLazyComponent(lazyComponent) {
126 return lazyComponent._status === Resolved ? lazyComponent._result : null;
127}
128
129function getWrappedName(outerType, innerType, wrapperName) {
130 var functionName = innerType.displayName || innerType.name || '';
131 return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
132}
133
134function getComponentName(type) {
135 if (type == null) {
136 // Host root, text node or just invalid type.
137 return null;
138 }
139 {
140 if (typeof type.tag === 'number') {
141 warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
142 }
143 }
144 if (typeof type === 'function') {
145 return type.displayName || type.name || null;
146 }
147 if (typeof type === 'string') {
148 return type;
149 }
150 switch (type) {
151 case REACT_FRAGMENT_TYPE:
152 return 'Fragment';
153 case REACT_PORTAL_TYPE:
154 return 'Portal';
155 case REACT_PROFILER_TYPE:
156 return 'Profiler';
157 case REACT_STRICT_MODE_TYPE:
158 return 'StrictMode';
159 case REACT_SUSPENSE_TYPE:
160 return 'Suspense';
161 case REACT_SUSPENSE_LIST_TYPE:
162 return 'SuspenseList';
163 }
164 if (typeof type === 'object') {
165 switch (type.$$typeof) {
166 case REACT_CONTEXT_TYPE:
167 return 'Context.Consumer';
168 case REACT_PROVIDER_TYPE:
169 return 'Context.Provider';
170 case REACT_FORWARD_REF_TYPE:
171 return getWrappedName(type, type.render, 'ForwardRef');
172 case REACT_MEMO_TYPE:
173 return getComponentName(type.type);
174 case REACT_LAZY_TYPE:
175 {
176 var thenable = type;
177 var resolvedThenable = refineResolvedLazyComponent(thenable);
178 if (resolvedThenable) {
179 return getComponentName(resolvedThenable);
180 }
181 break;
182 }
183 }
184 }
185 return null;
186}
187
188/**
189 * Forked from fbjs/warning:
190 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
191 *
192 * Only change is we use console.warn instead of console.error,
193 * and do nothing when 'console' is not supported.
194 * This really simplifies the code.
195 * ---
196 * Similar to invariant but only logs a warning if the condition is not met.
197 * This can be used to log issues in development environments in critical
198 * paths. Removing the logging code for production environments will keep the
199 * same logic and follow the same code paths.
200 */
201
202var lowPriorityWarning = function () {};
203
204{
205 var printWarning = function (format) {
206 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
207 args[_key - 1] = arguments[_key];
208 }
209
210 var argIndex = 0;
211 var message = 'Warning: ' + format.replace(/%s/g, function () {
212 return args[argIndex++];
213 });
214 if (typeof console !== 'undefined') {
215 console.warn(message);
216 }
217 try {
218 // --- Welcome to debugging React ---
219 // This error was thrown as a convenience so that you can use this stack
220 // to find the callsite that caused this warning to fire.
221 throw new Error(message);
222 } catch (x) {}
223 };
224
225 lowPriorityWarning = function (condition, format) {
226 if (format === undefined) {
227 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
228 }
229 if (!condition) {
230 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
231 args[_key2 - 2] = arguments[_key2];
232 }
233
234 printWarning.apply(undefined, [format].concat(args));
235 }
236 };
237}
238
239var lowPriorityWarning$1 = lowPriorityWarning;
240
241var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
242
243// Prevent newer renderers from RTE when used with older react package versions.
244// Current owner and dispatcher used to share the same ref,
245// but PR #14548 split them out to better support the react-debug-tools package.
246if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
247 ReactSharedInternals.ReactCurrentDispatcher = {
248 current: null
249 };
250}
251if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
252 ReactSharedInternals.ReactCurrentBatchConfig = {
253 suspense: null
254 };
255}
256
257/**
258 * Similar to invariant but only logs a warning if the condition is not met.
259 * This can be used to log issues in development environments in critical
260 * paths. Removing the logging code for production environments will keep the
261 * same logic and follow the same code paths.
262 */
263
264var warning = warningWithoutStack$1;
265
266{
267 warning = function (condition, format) {
268 if (condition) {
269 return;
270 }
271 var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
272 var stack = ReactDebugCurrentFrame.getStackAddendum();
273 // eslint-disable-next-line react-internal/warning-and-invariant-args
274
275 for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
276 args[_key - 2] = arguments[_key];
277 }
278
279 warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
280 };
281}
282
283var warning$1 = warning;
284
285var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
286
287var describeComponentFrame = function (name, source, ownerName) {
288 var sourceInfo = '';
289 if (source) {
290 var path = source.fileName;
291 var fileName = path.replace(BEFORE_SLASH_RE, '');
292 {
293 // In DEV, include code for a common special case:
294 // prefer "folder/index.js" instead of just "index.js".
295 if (/^index\./.test(fileName)) {
296 var match = path.match(BEFORE_SLASH_RE);
297 if (match) {
298 var pathBeforeSlash = match[1];
299 if (pathBeforeSlash) {
300 var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
301 fileName = folderName + '/' + fileName;
302 }
303 }
304 }
305 }
306 sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
307 } else if (ownerName) {
308 sourceInfo = ' (created by ' + ownerName + ')';
309 }
310 return '\n in ' + (name || 'Unknown') + sourceInfo;
311};
312
313// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
314
315
316// In some cases, StrictMode should also double-render lifecycles.
317// This can be confusing for tests though,
318// And it can be bad for performance in production.
319// This feature flag can be used to control the behavior:
320
321
322// To preserve the "Pause on caught exceptions" behavior of the debugger, we
323// replay the begin phase of a failed component inside invokeGuardedCallback.
324
325
326// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
327var warnAboutDeprecatedLifecycles = true;
328
329// Gather advanced timing metrics for Profiler subtrees.
330
331
332// Trace which interactions trigger each commit.
333
334
335// Only used in www builds.
336var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
337
338// Only used in www builds.
339
340
341// Only used in www builds.
342
343
344// Disable javascript: URL strings in href for XSS protection.
345var disableJavaScriptURLs = false;
346
347// React Fire: prevent the value and checked attributes from syncing
348// with their related DOM properties
349
350
351// These APIs will no longer be "unstable" in the upcoming 16.7 release,
352// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
353
354
355
356
357// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
358// This is a flag so we can fix warnings in RN core before turning it on
359
360
361// Experimental React Flare event system and event components support.
362var enableFlareAPI = false;
363
364// Experimental Host Component support.
365var enableFundamentalAPI = false;
366
367// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
368
369
370// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
371// Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
372
373// Temporary flag to revert the fix in #15650
374
375
376// For tests, we flush suspense fallbacks in an act scope;
377// *except* in some of our own tests, where we test incremental loading states.
378
379
380// Changes priority of some events like mousemove to user-blocking priority,
381// but without making them discrete. The flag exists in case it causes
382// starvation problems.
383
384
385// Add a callback property to suspense to notify which promises are currently
386// in the update queue. This allows reporting and tracing of what is causing
387// the user to see a loading state.
388
389
390// Part of the simplification of React.createElement so we can eventually move
391// from React.createElement to React.jsx
392// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
393
394
395var disableLegacyContext = false;
396
397var ReactDebugCurrentFrame$1 = void 0;
398var didWarnAboutInvalidateContextType = void 0;
399{
400 ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
401 didWarnAboutInvalidateContextType = new Set();
402}
403
404var emptyObject = {};
405{
406 Object.freeze(emptyObject);
407}
408
409function maskContext(type, context) {
410 var contextTypes = type.contextTypes;
411 if (!contextTypes) {
412 return emptyObject;
413 }
414 var maskedContext = {};
415 for (var contextName in contextTypes) {
416 maskedContext[contextName] = context[contextName];
417 }
418 return maskedContext;
419}
420
421function checkContextTypes(typeSpecs, values, location) {
422 {
423 checkPropTypes(typeSpecs, values, location, 'Component', ReactDebugCurrentFrame$1.getCurrentStack);
424 }
425}
426
427function validateContextBounds(context, threadID) {
428 // If we don't have enough slots in this context to store this threadID,
429 // fill it in without leaving any holes to ensure that the VM optimizes
430 // this as non-holey index properties.
431 // (Note: If `react` package is < 16.6, _threadCount is undefined.)
432 for (var i = context._threadCount | 0; i <= threadID; i++) {
433 // We assume that this is the same as the defaultValue which might not be
434 // true if we're rendering inside a secondary renderer but they are
435 // secondary because these use cases are very rare.
436 context[i] = context._currentValue2;
437 context._threadCount = i + 1;
438 }
439}
440
441function processContext(type, context, threadID, isClass) {
442 if (isClass) {
443 var contextType = type.contextType;
444 {
445 if ('contextType' in type) {
446 var isValid =
447 // Allow null for conditional declaration
448 contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
449
450 if (!isValid && !didWarnAboutInvalidateContextType.has(type)) {
451 didWarnAboutInvalidateContextType.add(type);
452
453 var addendum = '';
454 if (contextType === undefined) {
455 addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
456 } else if (typeof contextType !== 'object') {
457 addendum = ' However, it is set to a ' + typeof contextType + '.';
458 } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
459 addendum = ' Did you accidentally pass the Context.Provider instead?';
460 } else if (contextType._context !== undefined) {
461 // <Context.Consumer>
462 addendum = ' Did you accidentally pass the Context.Consumer instead?';
463 } else {
464 addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
465 }
466 warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(type) || 'Component', addendum);
467 }
468 }
469 }
470 if (typeof contextType === 'object' && contextType !== null) {
471 validateContextBounds(contextType, threadID);
472 return contextType[threadID];
473 }
474 if (disableLegacyContext) {
475 {
476 if (type.contextTypes) {
477 warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with static contextType instead.', getComponentName(type) || 'Unknown');
478 }
479 }
480 return emptyObject;
481 } else {
482 var maskedContext = maskContext(type, context);
483 {
484 if (type.contextTypes) {
485 checkContextTypes(type.contextTypes, maskedContext, 'context');
486 }
487 }
488 return maskedContext;
489 }
490 } else {
491 if (disableLegacyContext) {
492 {
493 if (type.contextTypes) {
494 warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with React.useContext() instead.', getComponentName(type) || 'Unknown');
495 }
496 }
497 return undefined;
498 } else {
499 var _maskedContext = maskContext(type, context);
500 {
501 if (type.contextTypes) {
502 checkContextTypes(type.contextTypes, _maskedContext, 'context');
503 }
504 }
505 return _maskedContext;
506 }
507 }
508}
509
510// Allocates a new index for each request. Tries to stay as compact as possible so that these
511// indices can be used to reference a tightly packaged array. As opposed to being used in a Map.
512// The first allocated index is 1.
513
514var nextAvailableThreadIDs = new Uint16Array(16);
515for (var i = 0; i < 15; i++) {
516 nextAvailableThreadIDs[i] = i + 1;
517}
518nextAvailableThreadIDs[15] = 0;
519
520function growThreadCountAndReturnNextAvailable() {
521 var oldArray = nextAvailableThreadIDs;
522 var oldSize = oldArray.length;
523 var newSize = oldSize * 2;
524 (function () {
525 if (!(newSize <= 0x10000)) {
526 {
527 throw ReactError(Error('Maximum number of concurrent React renderers exceeded. This can happen if you are not properly destroying the Readable provided by React. Ensure that you call .destroy() on it if you no longer want to read from it, and did not read to the end. If you use .pipe() this should be automatic.'));
528 }
529 }
530 })();
531 var newArray = new Uint16Array(newSize);
532 newArray.set(oldArray);
533 nextAvailableThreadIDs = newArray;
534 nextAvailableThreadIDs[0] = oldSize + 1;
535 for (var _i = oldSize; _i < newSize - 1; _i++) {
536 nextAvailableThreadIDs[_i] = _i + 1;
537 }
538 nextAvailableThreadIDs[newSize - 1] = 0;
539 return oldSize;
540}
541
542function allocThreadID() {
543 var nextID = nextAvailableThreadIDs[0];
544 if (nextID === 0) {
545 return growThreadCountAndReturnNextAvailable();
546 }
547 nextAvailableThreadIDs[0] = nextAvailableThreadIDs[nextID];
548 return nextID;
549}
550
551function freeThreadID(id) {
552 nextAvailableThreadIDs[id] = nextAvailableThreadIDs[0];
553 nextAvailableThreadIDs[0] = id;
554}
555
556// A reserved attribute.
557// It is handled by React separately and shouldn't be written to the DOM.
558var RESERVED = 0;
559
560// A simple string attribute.
561// Attributes that aren't in the whitelist are presumed to have this type.
562var STRING = 1;
563
564// A string attribute that accepts booleans in React. In HTML, these are called
565// "enumerated" attributes with "true" and "false" as possible values.
566// When true, it should be set to a "true" string.
567// When false, it should be set to a "false" string.
568var BOOLEANISH_STRING = 2;
569
570// A real boolean attribute.
571// When true, it should be present (set either to an empty string or its name).
572// When false, it should be omitted.
573var BOOLEAN = 3;
574
575// An attribute that can be used as a flag as well as with a value.
576// When true, it should be present (set either to an empty string or its name).
577// When false, it should be omitted.
578// For any other value, should be present with that value.
579var OVERLOADED_BOOLEAN = 4;
580
581// An attribute that must be numeric or parse as a numeric.
582// When falsy, it should be removed.
583var NUMERIC = 5;
584
585// An attribute that must be positive numeric or parse as a positive numeric.
586// When falsy, it should be removed.
587var POSITIVE_NUMERIC = 6;
588
589/* eslint-disable max-len */
590var ATTRIBUTE_NAME_START_CHAR = ':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
591/* eslint-enable max-len */
592var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
593
594
595var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
596var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
597
598var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
599var illegalAttributeNameCache = {};
600var validatedAttributeNameCache = {};
601
602function isAttributeNameSafe(attributeName) {
603 if (hasOwnProperty$1.call(validatedAttributeNameCache, attributeName)) {
604 return true;
605 }
606 if (hasOwnProperty$1.call(illegalAttributeNameCache, attributeName)) {
607 return false;
608 }
609 if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
610 validatedAttributeNameCache[attributeName] = true;
611 return true;
612 }
613 illegalAttributeNameCache[attributeName] = true;
614 {
615 warning$1(false, 'Invalid attribute name: `%s`', attributeName);
616 }
617 return false;
618}
619
620function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
621 if (propertyInfo !== null) {
622 return propertyInfo.type === RESERVED;
623 }
624 if (isCustomComponentTag) {
625 return false;
626 }
627 if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
628 return true;
629 }
630 return false;
631}
632
633function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
634 if (propertyInfo !== null && propertyInfo.type === RESERVED) {
635 return false;
636 }
637 switch (typeof value) {
638 case 'function':
639 // $FlowIssue symbol is perfectly valid here
640 case 'symbol':
641 // eslint-disable-line
642 return true;
643 case 'boolean':
644 {
645 if (isCustomComponentTag) {
646 return false;
647 }
648 if (propertyInfo !== null) {
649 return !propertyInfo.acceptsBooleans;
650 } else {
651 var prefix = name.toLowerCase().slice(0, 5);
652 return prefix !== 'data-' && prefix !== 'aria-';
653 }
654 }
655 default:
656 return false;
657 }
658}
659
660function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
661 if (value === null || typeof value === 'undefined') {
662 return true;
663 }
664 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
665 return true;
666 }
667 if (isCustomComponentTag) {
668 return false;
669 }
670 if (propertyInfo !== null) {
671 switch (propertyInfo.type) {
672 case BOOLEAN:
673 return !value;
674 case OVERLOADED_BOOLEAN:
675 return value === false;
676 case NUMERIC:
677 return isNaN(value);
678 case POSITIVE_NUMERIC:
679 return isNaN(value) || value < 1;
680 }
681 }
682 return false;
683}
684
685function getPropertyInfo(name) {
686 return properties.hasOwnProperty(name) ? properties[name] : null;
687}
688
689function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) {
690 this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
691 this.attributeName = attributeName;
692 this.attributeNamespace = attributeNamespace;
693 this.mustUseProperty = mustUseProperty;
694 this.propertyName = name;
695 this.type = type;
696 this.sanitizeURL = sanitizeURL;
697}
698
699// When adding attributes to this list, be sure to also add them to
700// the `possibleStandardNames` module to ensure casing and incorrect
701// name warnings.
702var properties = {};
703
704// These props are reserved by React. They shouldn't be written to the DOM.
705['children', 'dangerouslySetInnerHTML',
706// TODO: This prevents the assignment of defaultValue to regular
707// elements (not just inputs). Now that ReactDOMInput assigns to the
708// defaultValue property -- do we need this?
709'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) {
710 properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
711 name, // attributeName
712 null, // attributeNamespace
713 false);
714} // sanitizeURL
715);
716
717// A few React string attributes have a different name.
718// This is a mapping from React prop names to the attribute names.
719[['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
720 var name = _ref[0],
721 attributeName = _ref[1];
722
723 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
724 attributeName, // attributeName
725 null, // attributeNamespace
726 false);
727} // sanitizeURL
728);
729
730// These are "enumerated" HTML attributes that accept "true" and "false".
731// In React, we let users pass `true` and `false` even though technically
732// these aren't boolean attributes (they are coerced to strings).
733['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
734 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
735 name.toLowerCase(), // attributeName
736 null, // attributeNamespace
737 false);
738} // sanitizeURL
739);
740
741// These are "enumerated" SVG attributes that accept "true" and "false".
742// In React, we let users pass `true` and `false` even though technically
743// these aren't boolean attributes (they are coerced to strings).
744// Since these are SVG attributes, their attribute names are case-sensitive.
745['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
746 properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
747 name, // attributeName
748 null, // attributeNamespace
749 false);
750} // sanitizeURL
751);
752
753// These are HTML boolean attributes.
754['allowFullScreen', 'async',
755// Note: there is a special case that prevents it from being written to the DOM
756// on the client side because the browsers are inconsistent. Instead we call focus().
757'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless',
758// Microdata
759'itemScope'].forEach(function (name) {
760 properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
761 name.toLowerCase(), // attributeName
762 null, // attributeNamespace
763 false);
764} // sanitizeURL
765);
766
767// These are the few React props that we set as DOM properties
768// rather than attributes. These are all booleans.
769['checked',
770// Note: `option.selected` is not updated if `select.multiple` is
771// disabled with `removeAttribute`. We have special logic for handling this.
772'multiple', 'muted', 'selected'].forEach(function (name) {
773 properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
774 name, // attributeName
775 null, // attributeNamespace
776 false);
777} // sanitizeURL
778);
779
780// These are HTML attributes that are "overloaded booleans": they behave like
781// booleans, but can also accept a string value.
782['capture', 'download'].forEach(function (name) {
783 properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
784 name, // attributeName
785 null, // attributeNamespace
786 false);
787} // sanitizeURL
788);
789
790// These are HTML attributes that must be positive numbers.
791['cols', 'rows', 'size', 'span'].forEach(function (name) {
792 properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
793 name, // attributeName
794 null, // attributeNamespace
795 false);
796} // sanitizeURL
797);
798
799// These are HTML attributes that must be numbers.
800['rowSpan', 'start'].forEach(function (name) {
801 properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
802 name.toLowerCase(), // attributeName
803 null, // attributeNamespace
804 false);
805} // sanitizeURL
806);
807
808var CAMELIZE = /[\-\:]([a-z])/g;
809var capitalize = function (token) {
810 return token[1].toUpperCase();
811};
812
813// This is a list of all SVG attributes that need special casing, namespacing,
814// or boolean value assignment. Regular attributes that just accept strings
815// and have the same names are omitted, just like in the HTML whitelist.
816// Some of these attributes can be hard to find. This list was created by
817// scrapping the MDN documentation.
818['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height'].forEach(function (attributeName) {
819 var name = attributeName.replace(CAMELIZE, capitalize);
820 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
821 attributeName, null, // attributeNamespace
822 false);
823} // sanitizeURL
824);
825
826// String SVG attributes with the xlink namespace.
827['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
828 var name = attributeName.replace(CAMELIZE, capitalize);
829 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
830 attributeName, 'http://www.w3.org/1999/xlink', false);
831} // sanitizeURL
832);
833
834// String SVG attributes with the xml namespace.
835['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) {
836 var name = attributeName.replace(CAMELIZE, capitalize);
837 properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
838 attributeName, 'http://www.w3.org/XML/1998/namespace', false);
839} // sanitizeURL
840);
841
842// These attribute exists both in HTML and SVG.
843// The attribute name is case-sensitive in SVG so we can't just use
844// the React name like we do for attributes that exist only in HTML.
845['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
846 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
847 attributeName.toLowerCase(), // attributeName
848 null, // attributeNamespace
849 false);
850} // sanitizeURL
851);
852
853// These attributes accept URLs. These must not allow javascript: URLS.
854// These will also need to accept Trusted Types object in the future.
855var xlinkHref = 'xlinkHref';
856properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
857'xlink:href', 'http://www.w3.org/1999/xlink', true);
858
859['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
860 properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
861 attributeName.toLowerCase(), // attributeName
862 null, // attributeNamespace
863 true);
864} // sanitizeURL
865);
866
867var ReactDebugCurrentFrame$2 = null;
868{
869 ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame;
870}
871
872// A javascript: URL can contain leading C0 control or \u0020 SPACE,
873// and any newline or tab are filtered out as if they're not part of the URL.
874// https://url.spec.whatwg.org/#url-parsing
875// Tab or newline are defined as \r\n\t:
876// https://infra.spec.whatwg.org/#ascii-tab-or-newline
877// A C0 control is a code point in the range \u0000 NULL to \u001F
878// INFORMATION SEPARATOR ONE, inclusive:
879// https://infra.spec.whatwg.org/#c0-control-or-space
880
881/* eslint-disable max-len */
882var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;
883
884var didWarn = false;
885
886function sanitizeURL(url) {
887 if (disableJavaScriptURLs) {
888 (function () {
889 if (!!isJavaScriptProtocol.test(url)) {
890 {
891 throw ReactError(Error('React has blocked a javascript: URL as a security precaution.' + (ReactDebugCurrentFrame$2.getStackAddendum())));
892 }
893 }
894 })();
895 } else if (true && !didWarn && isJavaScriptProtocol.test(url)) {
896 didWarn = true;
897 warning$1(false, 'A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url));
898 }
899}
900
901// code copied and modified from escape-html
902/**
903 * Module variables.
904 * @private
905 */
906
907var matchHtmlRegExp = /["'&<>]/;
908
909/**
910 * Escapes special characters and HTML entities in a given html string.
911 *
912 * @param {string} string HTML string to escape for later insertion
913 * @return {string}
914 * @public
915 */
916
917function escapeHtml(string) {
918 var str = '' + string;
919 var match = matchHtmlRegExp.exec(str);
920
921 if (!match) {
922 return str;
923 }
924
925 var escape = void 0;
926 var html = '';
927 var index = void 0;
928 var lastIndex = 0;
929
930 for (index = match.index; index < str.length; index++) {
931 switch (str.charCodeAt(index)) {
932 case 34:
933 // "
934 escape = '&quot;';
935 break;
936 case 38:
937 // &
938 escape = '&amp;';
939 break;
940 case 39:
941 // '
942 escape = '&#x27;'; // modified from escape-html; used to be '&#39'
943 break;
944 case 60:
945 // <
946 escape = '&lt;';
947 break;
948 case 62:
949 // >
950 escape = '&gt;';
951 break;
952 default:
953 continue;
954 }
955
956 if (lastIndex !== index) {
957 html += str.substring(lastIndex, index);
958 }
959
960 lastIndex = index + 1;
961 html += escape;
962 }
963
964 return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
965}
966// end code copied and modified from escape-html
967
968/**
969 * Escapes text to prevent scripting attacks.
970 *
971 * @param {*} text Text value to escape.
972 * @return {string} An escaped string.
973 */
974function escapeTextForBrowser(text) {
975 if (typeof text === 'boolean' || typeof text === 'number') {
976 // this shortcircuit helps perf for types that we know will never have
977 // special characters, especially given that this function is used often
978 // for numeric dom ids.
979 return '' + text;
980 }
981 return escapeHtml(text);
982}
983
984/**
985 * Escapes attribute value to prevent scripting attacks.
986 *
987 * @param {*} value Value to escape.
988 * @return {string} An escaped string.
989 */
990function quoteAttributeValueForBrowser(value) {
991 return '"' + escapeTextForBrowser(value) + '"';
992}
993
994/**
995 * Operations for dealing with DOM properties.
996 */
997
998/**
999 * Creates markup for the ID property.
1000 *
1001 * @param {string} id Unescaped ID.
1002 * @return {string} Markup string.
1003 */
1004
1005
1006function createMarkupForRoot() {
1007 return ROOT_ATTRIBUTE_NAME + '=""';
1008}
1009
1010/**
1011 * Creates markup for a property.
1012 *
1013 * @param {string} name
1014 * @param {*} value
1015 * @return {?string} Markup string, or null if the property was invalid.
1016 */
1017function createMarkupForProperty(name, value) {
1018 var propertyInfo = getPropertyInfo(name);
1019 if (name !== 'style' && shouldIgnoreAttribute(name, propertyInfo, false)) {
1020 return '';
1021 }
1022 if (shouldRemoveAttribute(name, value, propertyInfo, false)) {
1023 return '';
1024 }
1025 if (propertyInfo !== null) {
1026 var attributeName = propertyInfo.attributeName;
1027 var type = propertyInfo.type;
1028
1029 if (type === BOOLEAN || type === OVERLOADED_BOOLEAN && value === true) {
1030 return attributeName + '=""';
1031 } else {
1032 if (propertyInfo.sanitizeURL) {
1033 value = '' + value;
1034 sanitizeURL(value);
1035 }
1036 return attributeName + '=' + quoteAttributeValueForBrowser(value);
1037 }
1038 } else if (isAttributeNameSafe(name)) {
1039 return name + '=' + quoteAttributeValueForBrowser(value);
1040 }
1041 return '';
1042}
1043
1044/**
1045 * Creates markup for a custom property.
1046 *
1047 * @param {string} name
1048 * @param {*} value
1049 * @return {string} Markup string, or empty string if the property was invalid.
1050 */
1051function createMarkupForCustomAttribute(name, value) {
1052 if (!isAttributeNameSafe(name) || value == null) {
1053 return '';
1054 }
1055 return name + '=' + quoteAttributeValueForBrowser(value);
1056}
1057
1058/**
1059 * inlined Object.is polyfill to avoid requiring consumers ship their own
1060 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1061 */
1062function is(x, y) {
1063 return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
1064 ;
1065}
1066
1067var currentlyRenderingComponent = null;
1068var firstWorkInProgressHook = null;
1069var workInProgressHook = null;
1070// Whether the work-in-progress hook is a re-rendered hook
1071var isReRender = false;
1072// Whether an update was scheduled during the currently executing render pass.
1073var didScheduleRenderPhaseUpdate = false;
1074// Lazily created map of render-phase updates
1075var renderPhaseUpdates = null;
1076// Counter to prevent infinite loops.
1077var numberOfReRenders = 0;
1078var RE_RENDER_LIMIT = 25;
1079
1080var isInHookUserCodeInDev = false;
1081
1082// In DEV, this is the name of the currently executing primitive hook
1083var currentHookNameInDev = void 0;
1084
1085function resolveCurrentlyRenderingComponent() {
1086 (function () {
1087 if (!(currentlyRenderingComponent !== null)) {
1088 {
1089 throw ReactError(Error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.'));
1090 }
1091 }
1092 })();
1093 {
1094 !!isInHookUserCodeInDev ? warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks') : void 0;
1095 }
1096 return currentlyRenderingComponent;
1097}
1098
1099function areHookInputsEqual(nextDeps, prevDeps) {
1100 if (prevDeps === null) {
1101 {
1102 warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
1103 }
1104 return false;
1105 }
1106
1107 {
1108 // Don't bother comparing lengths in prod because these arrays should be
1109 // passed inline.
1110 if (nextDeps.length !== prevDeps.length) {
1111 warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, '[' + nextDeps.join(', ') + ']', '[' + prevDeps.join(', ') + ']');
1112 }
1113 }
1114 for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
1115 if (is(nextDeps[i], prevDeps[i])) {
1116 continue;
1117 }
1118 return false;
1119 }
1120 return true;
1121}
1122
1123function createHook() {
1124 if (numberOfReRenders > 0) {
1125 (function () {
1126 {
1127 {
1128 throw ReactError(Error('Rendered more hooks than during the previous render'));
1129 }
1130 }
1131 })();
1132 }
1133 return {
1134 memoizedState: null,
1135 queue: null,
1136 next: null
1137 };
1138}
1139
1140function createWorkInProgressHook() {
1141 if (workInProgressHook === null) {
1142 // This is the first hook in the list
1143 if (firstWorkInProgressHook === null) {
1144 isReRender = false;
1145 firstWorkInProgressHook = workInProgressHook = createHook();
1146 } else {
1147 // There's already a work-in-progress. Reuse it.
1148 isReRender = true;
1149 workInProgressHook = firstWorkInProgressHook;
1150 }
1151 } else {
1152 if (workInProgressHook.next === null) {
1153 isReRender = false;
1154 // Append to the end of the list
1155 workInProgressHook = workInProgressHook.next = createHook();
1156 } else {
1157 // There's already a work-in-progress. Reuse it.
1158 isReRender = true;
1159 workInProgressHook = workInProgressHook.next;
1160 }
1161 }
1162 return workInProgressHook;
1163}
1164
1165function prepareToUseHooks(componentIdentity) {
1166 currentlyRenderingComponent = componentIdentity;
1167 {
1168 isInHookUserCodeInDev = false;
1169 }
1170
1171 // The following should have already been reset
1172 // didScheduleRenderPhaseUpdate = false;
1173 // firstWorkInProgressHook = null;
1174 // numberOfReRenders = 0;
1175 // renderPhaseUpdates = null;
1176 // workInProgressHook = null;
1177}
1178
1179function finishHooks(Component, props, children, refOrContext) {
1180 // This must be called after every function component to prevent hooks from
1181 // being used in classes.
1182
1183 while (didScheduleRenderPhaseUpdate) {
1184 // Updates were scheduled during the render phase. They are stored in
1185 // the `renderPhaseUpdates` map. Call the component again, reusing the
1186 // work-in-progress hooks and applying the additional updates on top. Keep
1187 // restarting until no more updates are scheduled.
1188 didScheduleRenderPhaseUpdate = false;
1189 numberOfReRenders += 1;
1190
1191 // Start over from the beginning of the list
1192 workInProgressHook = null;
1193
1194 children = Component(props, refOrContext);
1195 }
1196 currentlyRenderingComponent = null;
1197 firstWorkInProgressHook = null;
1198 numberOfReRenders = 0;
1199 renderPhaseUpdates = null;
1200 workInProgressHook = null;
1201 {
1202 isInHookUserCodeInDev = false;
1203 }
1204
1205 // These were reset above
1206 // currentlyRenderingComponent = null;
1207 // didScheduleRenderPhaseUpdate = false;
1208 // firstWorkInProgressHook = null;
1209 // numberOfReRenders = 0;
1210 // renderPhaseUpdates = null;
1211 // workInProgressHook = null;
1212
1213 return children;
1214}
1215
1216function readContext(context, observedBits) {
1217 var threadID = currentThreadID;
1218 validateContextBounds(context, threadID);
1219 {
1220 !!isInHookUserCodeInDev ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
1221 }
1222 return context[threadID];
1223}
1224
1225function useContext(context, observedBits) {
1226 {
1227 currentHookNameInDev = 'useContext';
1228 }
1229 resolveCurrentlyRenderingComponent();
1230 var threadID = currentThreadID;
1231 validateContextBounds(context, threadID);
1232 return context[threadID];
1233}
1234
1235function basicStateReducer(state, action) {
1236 return typeof action === 'function' ? action(state) : action;
1237}
1238
1239function useState(initialState) {
1240 {
1241 currentHookNameInDev = 'useState';
1242 }
1243 return useReducer(basicStateReducer,
1244 // useReducer has a special case to support lazy useState initializers
1245 initialState);
1246}
1247
1248function useReducer(reducer, initialArg, init) {
1249 {
1250 if (reducer !== basicStateReducer) {
1251 currentHookNameInDev = 'useReducer';
1252 }
1253 }
1254 currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
1255 workInProgressHook = createWorkInProgressHook();
1256 if (isReRender) {
1257 // This is a re-render. Apply the new render phase updates to the previous
1258 var _queue = workInProgressHook.queue;
1259 var _dispatch = _queue.dispatch;
1260 if (renderPhaseUpdates !== null) {
1261 // Render phase updates are stored in a map of queue -> linked list
1262 var firstRenderPhaseUpdate = renderPhaseUpdates.get(_queue);
1263 if (firstRenderPhaseUpdate !== undefined) {
1264 renderPhaseUpdates.delete(_queue);
1265 var newState = workInProgressHook.memoizedState;
1266 var update = firstRenderPhaseUpdate;
1267 do {
1268 // Process this render phase update. We don't have to check the
1269 // priority because it will always be the same as the current
1270 // render's.
1271 var _action = update.action;
1272 {
1273 isInHookUserCodeInDev = true;
1274 }
1275 newState = reducer(newState, _action);
1276 {
1277 isInHookUserCodeInDev = false;
1278 }
1279 update = update.next;
1280 } while (update !== null);
1281
1282 workInProgressHook.memoizedState = newState;
1283
1284 return [newState, _dispatch];
1285 }
1286 }
1287 return [workInProgressHook.memoizedState, _dispatch];
1288 } else {
1289 {
1290 isInHookUserCodeInDev = true;
1291 }
1292 var initialState = void 0;
1293 if (reducer === basicStateReducer) {
1294 // Special case for `useState`.
1295 initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
1296 } else {
1297 initialState = init !== undefined ? init(initialArg) : initialArg;
1298 }
1299 {
1300 isInHookUserCodeInDev = false;
1301 }
1302 workInProgressHook.memoizedState = initialState;
1303 var _queue2 = workInProgressHook.queue = {
1304 last: null,
1305 dispatch: null
1306 };
1307 var _dispatch2 = _queue2.dispatch = dispatchAction.bind(null, currentlyRenderingComponent, _queue2);
1308 return [workInProgressHook.memoizedState, _dispatch2];
1309 }
1310}
1311
1312function useMemo(nextCreate, deps) {
1313 currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
1314 workInProgressHook = createWorkInProgressHook();
1315
1316 var nextDeps = deps === undefined ? null : deps;
1317
1318 if (workInProgressHook !== null) {
1319 var prevState = workInProgressHook.memoizedState;
1320 if (prevState !== null) {
1321 if (nextDeps !== null) {
1322 var prevDeps = prevState[1];
1323 if (areHookInputsEqual(nextDeps, prevDeps)) {
1324 return prevState[0];
1325 }
1326 }
1327 }
1328 }
1329
1330 {
1331 isInHookUserCodeInDev = true;
1332 }
1333 var nextValue = nextCreate();
1334 {
1335 isInHookUserCodeInDev = false;
1336 }
1337 workInProgressHook.memoizedState = [nextValue, nextDeps];
1338 return nextValue;
1339}
1340
1341function useRef(initialValue) {
1342 currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
1343 workInProgressHook = createWorkInProgressHook();
1344 var previousRef = workInProgressHook.memoizedState;
1345 if (previousRef === null) {
1346 var ref = { current: initialValue };
1347 {
1348 Object.seal(ref);
1349 }
1350 workInProgressHook.memoizedState = ref;
1351 return ref;
1352 } else {
1353 return previousRef;
1354 }
1355}
1356
1357function useLayoutEffect(create, inputs) {
1358 {
1359 currentHookNameInDev = 'useLayoutEffect';
1360 }
1361 warning$1(false, 'useLayoutEffect does nothing on the server, because its effect cannot ' + "be encoded into the server renderer's output format. This will lead " + 'to a mismatch between the initial, non-hydrated UI and the intended ' + 'UI. To avoid this, useLayoutEffect should only be used in ' + 'components that render exclusively on the client. ' + 'See https://fb.me/react-uselayouteffect-ssr for common fixes.');
1362}
1363
1364function dispatchAction(componentIdentity, queue, action) {
1365 (function () {
1366 if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
1367 {
1368 throw ReactError(Error('Too many re-renders. React limits the number of renders to prevent an infinite loop.'));
1369 }
1370 }
1371 })();
1372
1373 if (componentIdentity === currentlyRenderingComponent) {
1374 // This is a render phase update. Stash it in a lazily-created map of
1375 // queue -> linked list of updates. After this render pass, we'll restart
1376 // and apply the stashed updates on top of the work-in-progress hook.
1377 didScheduleRenderPhaseUpdate = true;
1378 var update = {
1379 action: action,
1380 next: null
1381 };
1382 if (renderPhaseUpdates === null) {
1383 renderPhaseUpdates = new Map();
1384 }
1385 var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
1386 if (firstRenderPhaseUpdate === undefined) {
1387 renderPhaseUpdates.set(queue, update);
1388 } else {
1389 // Append the update to the end of the list.
1390 var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
1391 while (lastRenderPhaseUpdate.next !== null) {
1392 lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
1393 }
1394 lastRenderPhaseUpdate.next = update;
1395 }
1396 } else {
1397 // This means an update has happened after the function component has
1398 // returned. On the server this is a no-op. In React Fiber, the update
1399 // would be scheduled for a future render.
1400 }
1401}
1402
1403function useCallback(callback, deps) {
1404 // Callbacks are passed as they are in the server environment.
1405 return callback;
1406}
1407
1408function useResponder(responder, props) {
1409 return {
1410 props: props,
1411 responder: responder
1412 };
1413}
1414
1415function noop() {}
1416
1417var currentThreadID = 0;
1418
1419function setCurrentThreadID(threadID) {
1420 currentThreadID = threadID;
1421}
1422
1423var Dispatcher = {
1424 readContext: readContext,
1425 useContext: useContext,
1426 useMemo: useMemo,
1427 useReducer: useReducer,
1428 useRef: useRef,
1429 useState: useState,
1430 useLayoutEffect: useLayoutEffect,
1431 useCallback: useCallback,
1432 // useImperativeHandle is not run in the server environment
1433 useImperativeHandle: noop,
1434 // Effects are not run in the server environment.
1435 useEffect: noop,
1436 // Debugging effect
1437 useDebugValue: noop,
1438 useResponder: useResponder
1439};
1440
1441var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
1442var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1443var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1444
1445var Namespaces = {
1446 html: HTML_NAMESPACE,
1447 mathml: MATH_NAMESPACE,
1448 svg: SVG_NAMESPACE
1449};
1450
1451// Assumes there is no parent namespace.
1452function getIntrinsicNamespace(type) {
1453 switch (type) {
1454 case 'svg':
1455 return SVG_NAMESPACE;
1456 case 'math':
1457 return MATH_NAMESPACE;
1458 default:
1459 return HTML_NAMESPACE;
1460 }
1461}
1462
1463function getChildNamespace(parentNamespace, type) {
1464 if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) {
1465 // No (or default) parent namespace: potential entry point.
1466 return getIntrinsicNamespace(type);
1467 }
1468 if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
1469 // We're leaving SVG.
1470 return HTML_NAMESPACE;
1471 }
1472 // By default, pass namespace below.
1473 return parentNamespace;
1474}
1475
1476var ReactDebugCurrentFrame$3 = null;
1477
1478var ReactControlledValuePropTypes = {
1479 checkPropTypes: null
1480};
1481
1482{
1483 ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame;
1484
1485 var hasReadOnlyValue = {
1486 button: true,
1487 checkbox: true,
1488 image: true,
1489 hidden: true,
1490 radio: true,
1491 reset: true,
1492 submit: true
1493 };
1494
1495 var propTypes = {
1496 value: function (props, propName, componentName) {
1497 if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) {
1498 return null;
1499 }
1500 return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
1501 },
1502 checked: function (props, propName, componentName) {
1503 if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) {
1504 return null;
1505 }
1506 return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
1507 }
1508 };
1509
1510 /**
1511 * Provide a linked `value` attribute for controlled forms. You should not use
1512 * this outside of the ReactDOM controlled form components.
1513 */
1514 ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) {
1515 checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$3.getStackAddendum);
1516 };
1517}
1518
1519// For HTML, certain tags should omit their close tag. We keep a whitelist for
1520// those special-case tags.
1521
1522var omittedCloseTags = {
1523 area: true,
1524 base: true,
1525 br: true,
1526 col: true,
1527 embed: true,
1528 hr: true,
1529 img: true,
1530 input: true,
1531 keygen: true,
1532 link: true,
1533 meta: true,
1534 param: true,
1535 source: true,
1536 track: true,
1537 wbr: true
1538 // NOTE: menuitem's close tag should be omitted, but that causes problems.
1539};
1540
1541// For HTML, certain tags cannot have children. This has the same purpose as
1542// `omittedCloseTags` except that `menuitem` should still have its closing tag.
1543
1544var voidElementTags = _assign({
1545 menuitem: true
1546}, omittedCloseTags);
1547
1548// TODO: We can remove this if we add invariantWithStack()
1549// or add stack by default to invariants where possible.
1550var HTML = '__html';
1551
1552var ReactDebugCurrentFrame$4 = null;
1553{
1554 ReactDebugCurrentFrame$4 = ReactSharedInternals.ReactDebugCurrentFrame;
1555}
1556
1557function assertValidProps(tag, props) {
1558 if (!props) {
1559 return;
1560 }
1561 // Note the use of `==` which checks for null or undefined.
1562 if (voidElementTags[tag]) {
1563 (function () {
1564 if (!(props.children == null && props.dangerouslySetInnerHTML == null)) {
1565 {
1566 throw ReactError(Error(tag + ' is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.' + (ReactDebugCurrentFrame$4.getStackAddendum())));
1567 }
1568 }
1569 })();
1570 }
1571 if (props.dangerouslySetInnerHTML != null) {
1572 (function () {
1573 if (!(props.children == null)) {
1574 {
1575 throw ReactError(Error('Can only set one of `children` or `props.dangerouslySetInnerHTML`.'));
1576 }
1577 }
1578 })();
1579 (function () {
1580 if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) {
1581 {
1582 throw ReactError(Error('`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.'));
1583 }
1584 }
1585 })();
1586 }
1587 {
1588 !(props.suppressContentEditableWarning || !props.contentEditable || props.children == null) ? warning$1(false, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.') : void 0;
1589 }
1590 (function () {
1591 if (!(props.style == null || typeof props.style === 'object')) {
1592 {
1593 throw ReactError(Error('The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.' + (ReactDebugCurrentFrame$4.getStackAddendum())));
1594 }
1595 }
1596 })();
1597}
1598
1599/**
1600 * CSS properties which accept numbers but are not in units of "px".
1601 */
1602var isUnitlessNumber = {
1603 animationIterationCount: true,
1604 borderImageOutset: true,
1605 borderImageSlice: true,
1606 borderImageWidth: true,
1607 boxFlex: true,
1608 boxFlexGroup: true,
1609 boxOrdinalGroup: true,
1610 columnCount: true,
1611 columns: true,
1612 flex: true,
1613 flexGrow: true,
1614 flexPositive: true,
1615 flexShrink: true,
1616 flexNegative: true,
1617 flexOrder: true,
1618 gridArea: true,
1619 gridRow: true,
1620 gridRowEnd: true,
1621 gridRowSpan: true,
1622 gridRowStart: true,
1623 gridColumn: true,
1624 gridColumnEnd: true,
1625 gridColumnSpan: true,
1626 gridColumnStart: true,
1627 fontWeight: true,
1628 lineClamp: true,
1629 lineHeight: true,
1630 opacity: true,
1631 order: true,
1632 orphans: true,
1633 tabSize: true,
1634 widows: true,
1635 zIndex: true,
1636 zoom: true,
1637
1638 // SVG-related properties
1639 fillOpacity: true,
1640 floodOpacity: true,
1641 stopOpacity: true,
1642 strokeDasharray: true,
1643 strokeDashoffset: true,
1644 strokeMiterlimit: true,
1645 strokeOpacity: true,
1646 strokeWidth: true
1647};
1648
1649/**
1650 * @param {string} prefix vendor-specific prefix, eg: Webkit
1651 * @param {string} key style name, eg: transitionDuration
1652 * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
1653 * WebkitTransitionDuration
1654 */
1655function prefixKey(prefix, key) {
1656 return prefix + key.charAt(0).toUpperCase() + key.substring(1);
1657}
1658
1659/**
1660 * Support style names that may come passed in prefixed by adding permutations
1661 * of vendor prefixes.
1662 */
1663var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
1664
1665// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
1666// infinite loop, because it iterates over the newly added props too.
1667Object.keys(isUnitlessNumber).forEach(function (prop) {
1668 prefixes.forEach(function (prefix) {
1669 isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
1670 });
1671});
1672
1673/**
1674 * Convert a value into the proper css writable value. The style name `name`
1675 * should be logical (no hyphens), as specified
1676 * in `CSSProperty.isUnitlessNumber`.
1677 *
1678 * @param {string} name CSS property name such as `topMargin`.
1679 * @param {*} value CSS property value such as `10px`.
1680 * @return {string} Normalized style value with dimensions applied.
1681 */
1682function dangerousStyleValue(name, value, isCustomProperty) {
1683 // Note that we've removed escapeTextForBrowser() calls here since the
1684 // whole string will be escaped when the attribute is injected into
1685 // the markup. If you provide unsafe user data here they can inject
1686 // arbitrary CSS which may be problematic (I couldn't repro this):
1687 // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
1688 // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
1689 // This is not an XSS hole but instead a potential CSS injection issue
1690 // which has lead to a greater discussion about how we're going to
1691 // trust URLs moving forward. See #2115901
1692
1693 var isEmpty = value == null || typeof value === 'boolean' || value === '';
1694 if (isEmpty) {
1695 return '';
1696 }
1697
1698 if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
1699 return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
1700 }
1701
1702 return ('' + value).trim();
1703}
1704
1705var uppercasePattern = /([A-Z])/g;
1706var msPattern = /^ms-/;
1707
1708/**
1709 * Hyphenates a camelcased CSS property name, for example:
1710 *
1711 * > hyphenateStyleName('backgroundColor')
1712 * < "background-color"
1713 * > hyphenateStyleName('MozTransition')
1714 * < "-moz-transition"
1715 * > hyphenateStyleName('msTransition')
1716 * < "-ms-transition"
1717 *
1718 * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
1719 * is converted to `-ms-`.
1720 */
1721function hyphenateStyleName(name) {
1722 return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
1723}
1724
1725function isCustomComponent(tagName, props) {
1726 if (tagName.indexOf('-') === -1) {
1727 return typeof props.is === 'string';
1728 }
1729 switch (tagName) {
1730 // These are reserved SVG and MathML elements.
1731 // We don't mind this whitelist too much because we expect it to never grow.
1732 // The alternative is to track the namespace in a few places which is convoluted.
1733 // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
1734 case 'annotation-xml':
1735 case 'color-profile':
1736 case 'font-face':
1737 case 'font-face-src':
1738 case 'font-face-uri':
1739 case 'font-face-format':
1740 case 'font-face-name':
1741 case 'missing-glyph':
1742 return false;
1743 default:
1744 return true;
1745 }
1746}
1747
1748var warnValidStyle = function () {};
1749
1750{
1751 // 'msTransform' is correct, but the other prefixes should be capitalized
1752 var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
1753 var msPattern$1 = /^-ms-/;
1754 var hyphenPattern = /-(.)/g;
1755
1756 // style values shouldn't contain a semicolon
1757 var badStyleValueWithSemicolonPattern = /;\s*$/;
1758
1759 var warnedStyleNames = {};
1760 var warnedStyleValues = {};
1761 var warnedForNaNValue = false;
1762 var warnedForInfinityValue = false;
1763
1764 var camelize = function (string) {
1765 return string.replace(hyphenPattern, function (_, character) {
1766 return character.toUpperCase();
1767 });
1768 };
1769
1770 var warnHyphenatedStyleName = function (name) {
1771 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
1772 return;
1773 }
1774
1775 warnedStyleNames[name] = true;
1776 warning$1(false, 'Unsupported style property %s. Did you mean %s?', name,
1777 // As Andi Smith suggests
1778 // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
1779 // is converted to lowercase `ms`.
1780 camelize(name.replace(msPattern$1, 'ms-')));
1781 };
1782
1783 var warnBadVendoredStyleName = function (name) {
1784 if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
1785 return;
1786 }
1787
1788 warnedStyleNames[name] = true;
1789 warning$1(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
1790 };
1791
1792 var warnStyleValueWithSemicolon = function (name, value) {
1793 if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
1794 return;
1795 }
1796
1797 warnedStyleValues[value] = true;
1798 warning$1(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
1799 };
1800
1801 var warnStyleValueIsNaN = function (name, value) {
1802 if (warnedForNaNValue) {
1803 return;
1804 }
1805
1806 warnedForNaNValue = true;
1807 warning$1(false, '`NaN` is an invalid value for the `%s` css style property.', name);
1808 };
1809
1810 var warnStyleValueIsInfinity = function (name, value) {
1811 if (warnedForInfinityValue) {
1812 return;
1813 }
1814
1815 warnedForInfinityValue = true;
1816 warning$1(false, '`Infinity` is an invalid value for the `%s` css style property.', name);
1817 };
1818
1819 warnValidStyle = function (name, value) {
1820 if (name.indexOf('-') > -1) {
1821 warnHyphenatedStyleName(name);
1822 } else if (badVendoredStyleNamePattern.test(name)) {
1823 warnBadVendoredStyleName(name);
1824 } else if (badStyleValueWithSemicolonPattern.test(value)) {
1825 warnStyleValueWithSemicolon(name, value);
1826 }
1827
1828 if (typeof value === 'number') {
1829 if (isNaN(value)) {
1830 warnStyleValueIsNaN(name, value);
1831 } else if (!isFinite(value)) {
1832 warnStyleValueIsInfinity(name, value);
1833 }
1834 }
1835 };
1836}
1837
1838var warnValidStyle$1 = warnValidStyle;
1839
1840var ariaProperties = {
1841 'aria-current': 0, // state
1842 'aria-details': 0,
1843 'aria-disabled': 0, // state
1844 'aria-hidden': 0, // state
1845 'aria-invalid': 0, // state
1846 'aria-keyshortcuts': 0,
1847 'aria-label': 0,
1848 'aria-roledescription': 0,
1849 // Widget Attributes
1850 'aria-autocomplete': 0,
1851 'aria-checked': 0,
1852 'aria-expanded': 0,
1853 'aria-haspopup': 0,
1854 'aria-level': 0,
1855 'aria-modal': 0,
1856 'aria-multiline': 0,
1857 'aria-multiselectable': 0,
1858 'aria-orientation': 0,
1859 'aria-placeholder': 0,
1860 'aria-pressed': 0,
1861 'aria-readonly': 0,
1862 'aria-required': 0,
1863 'aria-selected': 0,
1864 'aria-sort': 0,
1865 'aria-valuemax': 0,
1866 'aria-valuemin': 0,
1867 'aria-valuenow': 0,
1868 'aria-valuetext': 0,
1869 // Live Region Attributes
1870 'aria-atomic': 0,
1871 'aria-busy': 0,
1872 'aria-live': 0,
1873 'aria-relevant': 0,
1874 // Drag-and-Drop Attributes
1875 'aria-dropeffect': 0,
1876 'aria-grabbed': 0,
1877 // Relationship Attributes
1878 'aria-activedescendant': 0,
1879 'aria-colcount': 0,
1880 'aria-colindex': 0,
1881 'aria-colspan': 0,
1882 'aria-controls': 0,
1883 'aria-describedby': 0,
1884 'aria-errormessage': 0,
1885 'aria-flowto': 0,
1886 'aria-labelledby': 0,
1887 'aria-owns': 0,
1888 'aria-posinset': 0,
1889 'aria-rowcount': 0,
1890 'aria-rowindex': 0,
1891 'aria-rowspan': 0,
1892 'aria-setsize': 0
1893};
1894
1895var warnedProperties = {};
1896var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
1897var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
1898
1899var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1900
1901function validateProperty(tagName, name) {
1902 if (hasOwnProperty$2.call(warnedProperties, name) && warnedProperties[name]) {
1903 return true;
1904 }
1905
1906 if (rARIACamel.test(name)) {
1907 var ariaName = 'aria-' + name.slice(4).toLowerCase();
1908 var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
1909
1910 // If this is an aria-* attribute, but is not listed in the known DOM
1911 // DOM properties, then it is an invalid aria-* attribute.
1912 if (correctName == null) {
1913 warning$1(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
1914 warnedProperties[name] = true;
1915 return true;
1916 }
1917 // aria-* attributes should be lowercase; suggest the lowercase version.
1918 if (name !== correctName) {
1919 warning$1(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
1920 warnedProperties[name] = true;
1921 return true;
1922 }
1923 }
1924
1925 if (rARIA.test(name)) {
1926 var lowerCasedName = name.toLowerCase();
1927 var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
1928
1929 // If this is an aria-* attribute, but is not listed in the known DOM
1930 // DOM properties, then it is an invalid aria-* attribute.
1931 if (standardName == null) {
1932 warnedProperties[name] = true;
1933 return false;
1934 }
1935 // aria-* attributes should be lowercase; suggest the lowercase version.
1936 if (name !== standardName) {
1937 warning$1(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
1938 warnedProperties[name] = true;
1939 return true;
1940 }
1941 }
1942
1943 return true;
1944}
1945
1946function warnInvalidARIAProps(type, props) {
1947 var invalidProps = [];
1948
1949 for (var key in props) {
1950 var isValid = validateProperty(type, key);
1951 if (!isValid) {
1952 invalidProps.push(key);
1953 }
1954 }
1955
1956 var unknownPropString = invalidProps.map(function (prop) {
1957 return '`' + prop + '`';
1958 }).join(', ');
1959
1960 if (invalidProps.length === 1) {
1961 warning$1(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
1962 } else if (invalidProps.length > 1) {
1963 warning$1(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
1964 }
1965}
1966
1967function validateProperties(type, props) {
1968 if (isCustomComponent(type, props)) {
1969 return;
1970 }
1971 warnInvalidARIAProps(type, props);
1972}
1973
1974var didWarnValueNull = false;
1975
1976function validateProperties$1(type, props) {
1977 if (type !== 'input' && type !== 'textarea' && type !== 'select') {
1978 return;
1979 }
1980
1981 if (props != null && props.value === null && !didWarnValueNull) {
1982 didWarnValueNull = true;
1983 if (type === 'select' && props.multiple) {
1984 warning$1(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.', type);
1985 } else {
1986 warning$1(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type);
1987 }
1988 }
1989}
1990
1991/**
1992 * Registers plugins so that they can extract and dispatch events.
1993 *
1994 * @see {EventPluginHub}
1995 */
1996
1997/**
1998 * Ordered list of injected plugins.
1999 */
2000
2001
2002/**
2003 * Mapping from event name to dispatch config
2004 */
2005
2006
2007/**
2008 * Mapping from registration name to plugin module
2009 */
2010var registrationNameModules = {};
2011
2012/**
2013 * Mapping from registration name to event name
2014 */
2015
2016
2017/**
2018 * Mapping from lowercase registration names to the properly cased version,
2019 * used to warn in the case of missing event handlers. Available
2020 * only in true.
2021 * @type {Object}
2022 */
2023var possibleRegistrationNames = {};
2024// Trust the developer to only use possibleRegistrationNames in true
2025
2026/**
2027 * Injects an ordering of plugins (by plugin name). This allows the ordering
2028 * to be decoupled from injection of the actual plugins so that ordering is
2029 * always deterministic regardless of packaging, on-the-fly injection, etc.
2030 *
2031 * @param {array} InjectedEventPluginOrder
2032 * @internal
2033 * @see {EventPluginHub.injection.injectEventPluginOrder}
2034 */
2035
2036
2037/**
2038 * Injects plugins to be used by `EventPluginHub`. The plugin names must be
2039 * in the ordering injected by `injectEventPluginOrder`.
2040 *
2041 * Plugins can be injected as part of page initialization or on-the-fly.
2042 *
2043 * @param {object} injectedNamesToPlugins Map from names to plugin modules.
2044 * @internal
2045 * @see {EventPluginHub.injection.injectEventPluginsByName}
2046 */
2047
2048// When adding attributes to the HTML or SVG whitelist, be sure to
2049// also add them to this module to ensure casing and incorrect name
2050// warnings.
2051var possibleStandardNames = {
2052 // HTML
2053 accept: 'accept',
2054 acceptcharset: 'acceptCharset',
2055 'accept-charset': 'acceptCharset',
2056 accesskey: 'accessKey',
2057 action: 'action',
2058 allowfullscreen: 'allowFullScreen',
2059 alt: 'alt',
2060 as: 'as',
2061 async: 'async',
2062 autocapitalize: 'autoCapitalize',
2063 autocomplete: 'autoComplete',
2064 autocorrect: 'autoCorrect',
2065 autofocus: 'autoFocus',
2066 autoplay: 'autoPlay',
2067 autosave: 'autoSave',
2068 capture: 'capture',
2069 cellpadding: 'cellPadding',
2070 cellspacing: 'cellSpacing',
2071 challenge: 'challenge',
2072 charset: 'charSet',
2073 checked: 'checked',
2074 children: 'children',
2075 cite: 'cite',
2076 class: 'className',
2077 classid: 'classID',
2078 classname: 'className',
2079 cols: 'cols',
2080 colspan: 'colSpan',
2081 content: 'content',
2082 contenteditable: 'contentEditable',
2083 contextmenu: 'contextMenu',
2084 controls: 'controls',
2085 controlslist: 'controlsList',
2086 coords: 'coords',
2087 crossorigin: 'crossOrigin',
2088 dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
2089 data: 'data',
2090 datetime: 'dateTime',
2091 default: 'default',
2092 defaultchecked: 'defaultChecked',
2093 defaultvalue: 'defaultValue',
2094 defer: 'defer',
2095 dir: 'dir',
2096 disabled: 'disabled',
2097 disablepictureinpicture: 'disablePictureInPicture',
2098 download: 'download',
2099 draggable: 'draggable',
2100 enctype: 'encType',
2101 for: 'htmlFor',
2102 form: 'form',
2103 formmethod: 'formMethod',
2104 formaction: 'formAction',
2105 formenctype: 'formEncType',
2106 formnovalidate: 'formNoValidate',
2107 formtarget: 'formTarget',
2108 frameborder: 'frameBorder',
2109 headers: 'headers',
2110 height: 'height',
2111 hidden: 'hidden',
2112 high: 'high',
2113 href: 'href',
2114 hreflang: 'hrefLang',
2115 htmlfor: 'htmlFor',
2116 httpequiv: 'httpEquiv',
2117 'http-equiv': 'httpEquiv',
2118 icon: 'icon',
2119 id: 'id',
2120 innerhtml: 'innerHTML',
2121 inputmode: 'inputMode',
2122 integrity: 'integrity',
2123 is: 'is',
2124 itemid: 'itemID',
2125 itemprop: 'itemProp',
2126 itemref: 'itemRef',
2127 itemscope: 'itemScope',
2128 itemtype: 'itemType',
2129 keyparams: 'keyParams',
2130 keytype: 'keyType',
2131 kind: 'kind',
2132 label: 'label',
2133 lang: 'lang',
2134 list: 'list',
2135 loop: 'loop',
2136 low: 'low',
2137 manifest: 'manifest',
2138 marginwidth: 'marginWidth',
2139 marginheight: 'marginHeight',
2140 max: 'max',
2141 maxlength: 'maxLength',
2142 media: 'media',
2143 mediagroup: 'mediaGroup',
2144 method: 'method',
2145 min: 'min',
2146 minlength: 'minLength',
2147 multiple: 'multiple',
2148 muted: 'muted',
2149 name: 'name',
2150 nomodule: 'noModule',
2151 nonce: 'nonce',
2152 novalidate: 'noValidate',
2153 open: 'open',
2154 optimum: 'optimum',
2155 pattern: 'pattern',
2156 placeholder: 'placeholder',
2157 playsinline: 'playsInline',
2158 poster: 'poster',
2159 preload: 'preload',
2160 profile: 'profile',
2161 radiogroup: 'radioGroup',
2162 readonly: 'readOnly',
2163 referrerpolicy: 'referrerPolicy',
2164 rel: 'rel',
2165 required: 'required',
2166 reversed: 'reversed',
2167 role: 'role',
2168 rows: 'rows',
2169 rowspan: 'rowSpan',
2170 sandbox: 'sandbox',
2171 scope: 'scope',
2172 scoped: 'scoped',
2173 scrolling: 'scrolling',
2174 seamless: 'seamless',
2175 selected: 'selected',
2176 shape: 'shape',
2177 size: 'size',
2178 sizes: 'sizes',
2179 span: 'span',
2180 spellcheck: 'spellCheck',
2181 src: 'src',
2182 srcdoc: 'srcDoc',
2183 srclang: 'srcLang',
2184 srcset: 'srcSet',
2185 start: 'start',
2186 step: 'step',
2187 style: 'style',
2188 summary: 'summary',
2189 tabindex: 'tabIndex',
2190 target: 'target',
2191 title: 'title',
2192 type: 'type',
2193 usemap: 'useMap',
2194 value: 'value',
2195 width: 'width',
2196 wmode: 'wmode',
2197 wrap: 'wrap',
2198
2199 // SVG
2200 about: 'about',
2201 accentheight: 'accentHeight',
2202 'accent-height': 'accentHeight',
2203 accumulate: 'accumulate',
2204 additive: 'additive',
2205 alignmentbaseline: 'alignmentBaseline',
2206 'alignment-baseline': 'alignmentBaseline',
2207 allowreorder: 'allowReorder',
2208 alphabetic: 'alphabetic',
2209 amplitude: 'amplitude',
2210 arabicform: 'arabicForm',
2211 'arabic-form': 'arabicForm',
2212 ascent: 'ascent',
2213 attributename: 'attributeName',
2214 attributetype: 'attributeType',
2215 autoreverse: 'autoReverse',
2216 azimuth: 'azimuth',
2217 basefrequency: 'baseFrequency',
2218 baselineshift: 'baselineShift',
2219 'baseline-shift': 'baselineShift',
2220 baseprofile: 'baseProfile',
2221 bbox: 'bbox',
2222 begin: 'begin',
2223 bias: 'bias',
2224 by: 'by',
2225 calcmode: 'calcMode',
2226 capheight: 'capHeight',
2227 'cap-height': 'capHeight',
2228 clip: 'clip',
2229 clippath: 'clipPath',
2230 'clip-path': 'clipPath',
2231 clippathunits: 'clipPathUnits',
2232 cliprule: 'clipRule',
2233 'clip-rule': 'clipRule',
2234 color: 'color',
2235 colorinterpolation: 'colorInterpolation',
2236 'color-interpolation': 'colorInterpolation',
2237 colorinterpolationfilters: 'colorInterpolationFilters',
2238 'color-interpolation-filters': 'colorInterpolationFilters',
2239 colorprofile: 'colorProfile',
2240 'color-profile': 'colorProfile',
2241 colorrendering: 'colorRendering',
2242 'color-rendering': 'colorRendering',
2243 contentscripttype: 'contentScriptType',
2244 contentstyletype: 'contentStyleType',
2245 cursor: 'cursor',
2246 cx: 'cx',
2247 cy: 'cy',
2248 d: 'd',
2249 datatype: 'datatype',
2250 decelerate: 'decelerate',
2251 descent: 'descent',
2252 diffuseconstant: 'diffuseConstant',
2253 direction: 'direction',
2254 display: 'display',
2255 divisor: 'divisor',
2256 dominantbaseline: 'dominantBaseline',
2257 'dominant-baseline': 'dominantBaseline',
2258 dur: 'dur',
2259 dx: 'dx',
2260 dy: 'dy',
2261 edgemode: 'edgeMode',
2262 elevation: 'elevation',
2263 enablebackground: 'enableBackground',
2264 'enable-background': 'enableBackground',
2265 end: 'end',
2266 exponent: 'exponent',
2267 externalresourcesrequired: 'externalResourcesRequired',
2268 fill: 'fill',
2269 fillopacity: 'fillOpacity',
2270 'fill-opacity': 'fillOpacity',
2271 fillrule: 'fillRule',
2272 'fill-rule': 'fillRule',
2273 filter: 'filter',
2274 filterres: 'filterRes',
2275 filterunits: 'filterUnits',
2276 floodopacity: 'floodOpacity',
2277 'flood-opacity': 'floodOpacity',
2278 floodcolor: 'floodColor',
2279 'flood-color': 'floodColor',
2280 focusable: 'focusable',
2281 fontfamily: 'fontFamily',
2282 'font-family': 'fontFamily',
2283 fontsize: 'fontSize',
2284 'font-size': 'fontSize',
2285 fontsizeadjust: 'fontSizeAdjust',
2286 'font-size-adjust': 'fontSizeAdjust',
2287 fontstretch: 'fontStretch',
2288 'font-stretch': 'fontStretch',
2289 fontstyle: 'fontStyle',
2290 'font-style': 'fontStyle',
2291 fontvariant: 'fontVariant',
2292 'font-variant': 'fontVariant',
2293 fontweight: 'fontWeight',
2294 'font-weight': 'fontWeight',
2295 format: 'format',
2296 from: 'from',
2297 fx: 'fx',
2298 fy: 'fy',
2299 g1: 'g1',
2300 g2: 'g2',
2301 glyphname: 'glyphName',
2302 'glyph-name': 'glyphName',
2303 glyphorientationhorizontal: 'glyphOrientationHorizontal',
2304 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
2305 glyphorientationvertical: 'glyphOrientationVertical',
2306 'glyph-orientation-vertical': 'glyphOrientationVertical',
2307 glyphref: 'glyphRef',
2308 gradienttransform: 'gradientTransform',
2309 gradientunits: 'gradientUnits',
2310 hanging: 'hanging',
2311 horizadvx: 'horizAdvX',
2312 'horiz-adv-x': 'horizAdvX',
2313 horizoriginx: 'horizOriginX',
2314 'horiz-origin-x': 'horizOriginX',
2315 ideographic: 'ideographic',
2316 imagerendering: 'imageRendering',
2317 'image-rendering': 'imageRendering',
2318 in2: 'in2',
2319 in: 'in',
2320 inlist: 'inlist',
2321 intercept: 'intercept',
2322 k1: 'k1',
2323 k2: 'k2',
2324 k3: 'k3',
2325 k4: 'k4',
2326 k: 'k',
2327 kernelmatrix: 'kernelMatrix',
2328 kernelunitlength: 'kernelUnitLength',
2329 kerning: 'kerning',
2330 keypoints: 'keyPoints',
2331 keysplines: 'keySplines',
2332 keytimes: 'keyTimes',
2333 lengthadjust: 'lengthAdjust',
2334 letterspacing: 'letterSpacing',
2335 'letter-spacing': 'letterSpacing',
2336 lightingcolor: 'lightingColor',
2337 'lighting-color': 'lightingColor',
2338 limitingconeangle: 'limitingConeAngle',
2339 local: 'local',
2340 markerend: 'markerEnd',
2341 'marker-end': 'markerEnd',
2342 markerheight: 'markerHeight',
2343 markermid: 'markerMid',
2344 'marker-mid': 'markerMid',
2345 markerstart: 'markerStart',
2346 'marker-start': 'markerStart',
2347 markerunits: 'markerUnits',
2348 markerwidth: 'markerWidth',
2349 mask: 'mask',
2350 maskcontentunits: 'maskContentUnits',
2351 maskunits: 'maskUnits',
2352 mathematical: 'mathematical',
2353 mode: 'mode',
2354 numoctaves: 'numOctaves',
2355 offset: 'offset',
2356 opacity: 'opacity',
2357 operator: 'operator',
2358 order: 'order',
2359 orient: 'orient',
2360 orientation: 'orientation',
2361 origin: 'origin',
2362 overflow: 'overflow',
2363 overlineposition: 'overlinePosition',
2364 'overline-position': 'overlinePosition',
2365 overlinethickness: 'overlineThickness',
2366 'overline-thickness': 'overlineThickness',
2367 paintorder: 'paintOrder',
2368 'paint-order': 'paintOrder',
2369 panose1: 'panose1',
2370 'panose-1': 'panose1',
2371 pathlength: 'pathLength',
2372 patterncontentunits: 'patternContentUnits',
2373 patterntransform: 'patternTransform',
2374 patternunits: 'patternUnits',
2375 pointerevents: 'pointerEvents',
2376 'pointer-events': 'pointerEvents',
2377 points: 'points',
2378 pointsatx: 'pointsAtX',
2379 pointsaty: 'pointsAtY',
2380 pointsatz: 'pointsAtZ',
2381 prefix: 'prefix',
2382 preservealpha: 'preserveAlpha',
2383 preserveaspectratio: 'preserveAspectRatio',
2384 primitiveunits: 'primitiveUnits',
2385 property: 'property',
2386 r: 'r',
2387 radius: 'radius',
2388 refx: 'refX',
2389 refy: 'refY',
2390 renderingintent: 'renderingIntent',
2391 'rendering-intent': 'renderingIntent',
2392 repeatcount: 'repeatCount',
2393 repeatdur: 'repeatDur',
2394 requiredextensions: 'requiredExtensions',
2395 requiredfeatures: 'requiredFeatures',
2396 resource: 'resource',
2397 restart: 'restart',
2398 result: 'result',
2399 results: 'results',
2400 rotate: 'rotate',
2401 rx: 'rx',
2402 ry: 'ry',
2403 scale: 'scale',
2404 security: 'security',
2405 seed: 'seed',
2406 shaperendering: 'shapeRendering',
2407 'shape-rendering': 'shapeRendering',
2408 slope: 'slope',
2409 spacing: 'spacing',
2410 specularconstant: 'specularConstant',
2411 specularexponent: 'specularExponent',
2412 speed: 'speed',
2413 spreadmethod: 'spreadMethod',
2414 startoffset: 'startOffset',
2415 stddeviation: 'stdDeviation',
2416 stemh: 'stemh',
2417 stemv: 'stemv',
2418 stitchtiles: 'stitchTiles',
2419 stopcolor: 'stopColor',
2420 'stop-color': 'stopColor',
2421 stopopacity: 'stopOpacity',
2422 'stop-opacity': 'stopOpacity',
2423 strikethroughposition: 'strikethroughPosition',
2424 'strikethrough-position': 'strikethroughPosition',
2425 strikethroughthickness: 'strikethroughThickness',
2426 'strikethrough-thickness': 'strikethroughThickness',
2427 string: 'string',
2428 stroke: 'stroke',
2429 strokedasharray: 'strokeDasharray',
2430 'stroke-dasharray': 'strokeDasharray',
2431 strokedashoffset: 'strokeDashoffset',
2432 'stroke-dashoffset': 'strokeDashoffset',
2433 strokelinecap: 'strokeLinecap',
2434 'stroke-linecap': 'strokeLinecap',
2435 strokelinejoin: 'strokeLinejoin',
2436 'stroke-linejoin': 'strokeLinejoin',
2437 strokemiterlimit: 'strokeMiterlimit',
2438 'stroke-miterlimit': 'strokeMiterlimit',
2439 strokewidth: 'strokeWidth',
2440 'stroke-width': 'strokeWidth',
2441 strokeopacity: 'strokeOpacity',
2442 'stroke-opacity': 'strokeOpacity',
2443 suppresscontenteditablewarning: 'suppressContentEditableWarning',
2444 suppresshydrationwarning: 'suppressHydrationWarning',
2445 surfacescale: 'surfaceScale',
2446 systemlanguage: 'systemLanguage',
2447 tablevalues: 'tableValues',
2448 targetx: 'targetX',
2449 targety: 'targetY',
2450 textanchor: 'textAnchor',
2451 'text-anchor': 'textAnchor',
2452 textdecoration: 'textDecoration',
2453 'text-decoration': 'textDecoration',
2454 textlength: 'textLength',
2455 textrendering: 'textRendering',
2456 'text-rendering': 'textRendering',
2457 to: 'to',
2458 transform: 'transform',
2459 typeof: 'typeof',
2460 u1: 'u1',
2461 u2: 'u2',
2462 underlineposition: 'underlinePosition',
2463 'underline-position': 'underlinePosition',
2464 underlinethickness: 'underlineThickness',
2465 'underline-thickness': 'underlineThickness',
2466 unicode: 'unicode',
2467 unicodebidi: 'unicodeBidi',
2468 'unicode-bidi': 'unicodeBidi',
2469 unicoderange: 'unicodeRange',
2470 'unicode-range': 'unicodeRange',
2471 unitsperem: 'unitsPerEm',
2472 'units-per-em': 'unitsPerEm',
2473 unselectable: 'unselectable',
2474 valphabetic: 'vAlphabetic',
2475 'v-alphabetic': 'vAlphabetic',
2476 values: 'values',
2477 vectoreffect: 'vectorEffect',
2478 'vector-effect': 'vectorEffect',
2479 version: 'version',
2480 vertadvy: 'vertAdvY',
2481 'vert-adv-y': 'vertAdvY',
2482 vertoriginx: 'vertOriginX',
2483 'vert-origin-x': 'vertOriginX',
2484 vertoriginy: 'vertOriginY',
2485 'vert-origin-y': 'vertOriginY',
2486 vhanging: 'vHanging',
2487 'v-hanging': 'vHanging',
2488 videographic: 'vIdeographic',
2489 'v-ideographic': 'vIdeographic',
2490 viewbox: 'viewBox',
2491 viewtarget: 'viewTarget',
2492 visibility: 'visibility',
2493 vmathematical: 'vMathematical',
2494 'v-mathematical': 'vMathematical',
2495 vocab: 'vocab',
2496 widths: 'widths',
2497 wordspacing: 'wordSpacing',
2498 'word-spacing': 'wordSpacing',
2499 writingmode: 'writingMode',
2500 'writing-mode': 'writingMode',
2501 x1: 'x1',
2502 x2: 'x2',
2503 x: 'x',
2504 xchannelselector: 'xChannelSelector',
2505 xheight: 'xHeight',
2506 'x-height': 'xHeight',
2507 xlinkactuate: 'xlinkActuate',
2508 'xlink:actuate': 'xlinkActuate',
2509 xlinkarcrole: 'xlinkArcrole',
2510 'xlink:arcrole': 'xlinkArcrole',
2511 xlinkhref: 'xlinkHref',
2512 'xlink:href': 'xlinkHref',
2513 xlinkrole: 'xlinkRole',
2514 'xlink:role': 'xlinkRole',
2515 xlinkshow: 'xlinkShow',
2516 'xlink:show': 'xlinkShow',
2517 xlinktitle: 'xlinkTitle',
2518 'xlink:title': 'xlinkTitle',
2519 xlinktype: 'xlinkType',
2520 'xlink:type': 'xlinkType',
2521 xmlbase: 'xmlBase',
2522 'xml:base': 'xmlBase',
2523 xmllang: 'xmlLang',
2524 'xml:lang': 'xmlLang',
2525 xmlns: 'xmlns',
2526 'xml:space': 'xmlSpace',
2527 xmlnsxlink: 'xmlnsXlink',
2528 'xmlns:xlink': 'xmlnsXlink',
2529 xmlspace: 'xmlSpace',
2530 y1: 'y1',
2531 y2: 'y2',
2532 y: 'y',
2533 ychannelselector: 'yChannelSelector',
2534 z: 'z',
2535 zoomandpan: 'zoomAndPan'
2536};
2537
2538var validateProperty$1 = function () {};
2539
2540{
2541 var warnedProperties$1 = {};
2542 var _hasOwnProperty = Object.prototype.hasOwnProperty;
2543 var EVENT_NAME_REGEX = /^on./;
2544 var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
2545 var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
2546 var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
2547
2548 validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
2549 if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
2550 return true;
2551 }
2552
2553 var lowerCasedName = name.toLowerCase();
2554 if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
2555 warning$1(false, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.');
2556 warnedProperties$1[name] = true;
2557 return true;
2558 }
2559
2560 // We can't rely on the event system being injected on the server.
2561 if (canUseEventSystem) {
2562 if (registrationNameModules.hasOwnProperty(name)) {
2563 return true;
2564 }
2565 var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
2566 if (registrationName != null) {
2567 warning$1(false, 'Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
2568 warnedProperties$1[name] = true;
2569 return true;
2570 }
2571 if (EVENT_NAME_REGEX.test(name)) {
2572 warning$1(false, 'Unknown event handler property `%s`. It will be ignored.', name);
2573 warnedProperties$1[name] = true;
2574 return true;
2575 }
2576 } else if (EVENT_NAME_REGEX.test(name)) {
2577 // If no event plugins have been injected, we are in a server environment.
2578 // So we can't tell if the event name is correct for sure, but we can filter
2579 // out known bad ones like `onclick`. We can't suggest a specific replacement though.
2580 if (INVALID_EVENT_NAME_REGEX.test(name)) {
2581 warning$1(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
2582 }
2583 warnedProperties$1[name] = true;
2584 return true;
2585 }
2586
2587 // Let the ARIA attribute hook validate ARIA attributes
2588 if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
2589 return true;
2590 }
2591
2592 if (lowerCasedName === 'innerhtml') {
2593 warning$1(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
2594 warnedProperties$1[name] = true;
2595 return true;
2596 }
2597
2598 if (lowerCasedName === 'aria') {
2599 warning$1(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
2600 warnedProperties$1[name] = true;
2601 return true;
2602 }
2603
2604 if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
2605 warning$1(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
2606 warnedProperties$1[name] = true;
2607 return true;
2608 }
2609
2610 if (typeof value === 'number' && isNaN(value)) {
2611 warning$1(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
2612 warnedProperties$1[name] = true;
2613 return true;
2614 }
2615
2616 var propertyInfo = getPropertyInfo(name);
2617 var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED;
2618
2619 // Known attributes should match the casing specified in the property config.
2620 if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
2621 var standardName = possibleStandardNames[lowerCasedName];
2622 if (standardName !== name) {
2623 warning$1(false, 'Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
2624 warnedProperties$1[name] = true;
2625 return true;
2626 }
2627 } else if (!isReserved && name !== lowerCasedName) {
2628 // Unknown attributes should have lowercase casing since that's how they
2629 // will be cased anyway with server rendering.
2630 warning$1(false, 'React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.', name, lowerCasedName);
2631 warnedProperties$1[name] = true;
2632 return true;
2633 }
2634
2635 if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
2636 if (value) {
2637 warning$1(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.', value, name, name, value, name);
2638 } else {
2639 warning$1(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name);
2640 }
2641 warnedProperties$1[name] = true;
2642 return true;
2643 }
2644
2645 // Now that we've validated casing, do not validate
2646 // data types for reserved props
2647 if (isReserved) {
2648 return true;
2649 }
2650
2651 // Warn when a known attribute is a bad type
2652 if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
2653 warnedProperties$1[name] = true;
2654 return false;
2655 }
2656
2657 // Warn when passing the strings 'false' or 'true' into a boolean prop
2658 if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
2659 warning$1(false, 'Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value);
2660 warnedProperties$1[name] = true;
2661 return true;
2662 }
2663
2664 return true;
2665 };
2666}
2667
2668var warnUnknownProperties = function (type, props, canUseEventSystem) {
2669 var unknownProps = [];
2670 for (var key in props) {
2671 var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
2672 if (!isValid) {
2673 unknownProps.push(key);
2674 }
2675 }
2676
2677 var unknownPropString = unknownProps.map(function (prop) {
2678 return '`' + prop + '`';
2679 }).join(', ');
2680 if (unknownProps.length === 1) {
2681 warning$1(false, 'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior', unknownPropString, type);
2682 } else if (unknownProps.length > 1) {
2683 warning$1(false, 'Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior', unknownPropString, type);
2684 }
2685};
2686
2687function validateProperties$2(type, props, canUseEventSystem) {
2688 if (isCustomComponent(type, props)) {
2689 return;
2690 }
2691 warnUnknownProperties(type, props, canUseEventSystem);
2692}
2693
2694function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2695
2696// Based on reading the React.Children implementation. TODO: type this somewhere?
2697
2698var toArray = React.Children.toArray;
2699
2700// This is only used in DEV.
2701// Each entry is `this.stack` from a currently executing renderer instance.
2702// (There may be more than one because ReactDOMServer is reentrant).
2703// Each stack is an array of frames which may contain nested stacks of elements.
2704var currentDebugStacks = [];
2705
2706var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
2707var ReactDebugCurrentFrame = void 0;
2708var prevGetCurrentStackImpl = null;
2709var getCurrentServerStackImpl = function () {
2710 return '';
2711};
2712var describeStackFrame = function (element) {
2713 return '';
2714};
2715
2716var validatePropertiesInDevelopment = function (type, props) {};
2717var pushCurrentDebugStack = function (stack) {};
2718var pushElementToDebugStack = function (element) {};
2719var popCurrentDebugStack = function () {};
2720var hasWarnedAboutUsingContextAsConsumer = false;
2721
2722{
2723 ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
2724
2725 validatePropertiesInDevelopment = function (type, props) {
2726 validateProperties(type, props);
2727 validateProperties$1(type, props);
2728 validateProperties$2(type, props, /* canUseEventSystem */false);
2729 };
2730
2731 describeStackFrame = function (element) {
2732 var source = element._source;
2733 var type = element.type;
2734 var name = getComponentName(type);
2735 var ownerName = null;
2736 return describeComponentFrame(name, source, ownerName);
2737 };
2738
2739 pushCurrentDebugStack = function (stack) {
2740 currentDebugStacks.push(stack);
2741
2742 if (currentDebugStacks.length === 1) {
2743 // We are entering a server renderer.
2744 // Remember the previous (e.g. client) global stack implementation.
2745 prevGetCurrentStackImpl = ReactDebugCurrentFrame.getCurrentStack;
2746 ReactDebugCurrentFrame.getCurrentStack = getCurrentServerStackImpl;
2747 }
2748 };
2749
2750 pushElementToDebugStack = function (element) {
2751 // For the innermost executing ReactDOMServer call,
2752 var stack = currentDebugStacks[currentDebugStacks.length - 1];
2753 // Take the innermost executing frame (e.g. <Foo>),
2754 var frame = stack[stack.length - 1];
2755 // and record that it has one more element associated with it.
2756 frame.debugElementStack.push(element);
2757 // We only need this because we tail-optimize single-element
2758 // children and directly handle them in an inner loop instead of
2759 // creating separate frames for them.
2760 };
2761
2762 popCurrentDebugStack = function () {
2763 currentDebugStacks.pop();
2764
2765 if (currentDebugStacks.length === 0) {
2766 // We are exiting the server renderer.
2767 // Restore the previous (e.g. client) global stack implementation.
2768 ReactDebugCurrentFrame.getCurrentStack = prevGetCurrentStackImpl;
2769 prevGetCurrentStackImpl = null;
2770 }
2771 };
2772
2773 getCurrentServerStackImpl = function () {
2774 if (currentDebugStacks.length === 0) {
2775 // Nothing is currently rendering.
2776 return '';
2777 }
2778 // ReactDOMServer is reentrant so there may be multiple calls at the same time.
2779 // Take the frames from the innermost call which is the last in the array.
2780 var frames = currentDebugStacks[currentDebugStacks.length - 1];
2781 var stack = '';
2782 // Go through every frame in the stack from the innermost one.
2783 for (var i = frames.length - 1; i >= 0; i--) {
2784 var frame = frames[i];
2785 // Every frame might have more than one debug element stack entry associated with it.
2786 // This is because single-child nesting doesn't create materialized frames.
2787 // Instead it would push them through `pushElementToDebugStack()`.
2788 var _debugElementStack = frame.debugElementStack;
2789 for (var ii = _debugElementStack.length - 1; ii >= 0; ii--) {
2790 stack += describeStackFrame(_debugElementStack[ii]);
2791 }
2792 }
2793 return stack;
2794 };
2795}
2796
2797var didWarnDefaultInputValue = false;
2798var didWarnDefaultChecked = false;
2799var didWarnDefaultSelectValue = false;
2800var didWarnDefaultTextareaValue = false;
2801var didWarnInvalidOptionChildren = false;
2802var didWarnAboutNoopUpdateForComponent = {};
2803var didWarnAboutBadClass = {};
2804var didWarnAboutModulePatternComponent = {};
2805var didWarnAboutDeprecatedWillMount = {};
2806var didWarnAboutUndefinedDerivedState = {};
2807var didWarnAboutUninitializedState = {};
2808var valuePropNames = ['value', 'defaultValue'];
2809var newlineEatingTags = {
2810 listing: true,
2811 pre: true,
2812 textarea: true
2813};
2814
2815// We accept any tag to be rendered but since this gets injected into arbitrary
2816// HTML, we want to make sure that it's a safe tag.
2817// http://www.w3.org/TR/REC-xml/#NT-Name
2818var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
2819var validatedTagCache = {};
2820function validateDangerousTag(tag) {
2821 if (!validatedTagCache.hasOwnProperty(tag)) {
2822 (function () {
2823 if (!VALID_TAG_REGEX.test(tag)) {
2824 {
2825 throw ReactError(Error('Invalid tag: ' + tag));
2826 }
2827 }
2828 })();
2829 validatedTagCache[tag] = true;
2830 }
2831}
2832
2833var styleNameCache = {};
2834var processStyleName = function (styleName) {
2835 if (styleNameCache.hasOwnProperty(styleName)) {
2836 return styleNameCache[styleName];
2837 }
2838 var result = hyphenateStyleName(styleName);
2839 styleNameCache[styleName] = result;
2840 return result;
2841};
2842
2843function createMarkupForStyles(styles) {
2844 var serialized = '';
2845 var delimiter = '';
2846 for (var styleName in styles) {
2847 if (!styles.hasOwnProperty(styleName)) {
2848 continue;
2849 }
2850 var isCustomProperty = styleName.indexOf('--') === 0;
2851 var styleValue = styles[styleName];
2852 {
2853 if (!isCustomProperty) {
2854 warnValidStyle$1(styleName, styleValue);
2855 }
2856 }
2857 if (styleValue != null) {
2858 serialized += delimiter + (isCustomProperty ? styleName : processStyleName(styleName)) + ':';
2859 serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
2860
2861 delimiter = ';';
2862 }
2863 }
2864 return serialized || null;
2865}
2866
2867function warnNoop(publicInstance, callerName) {
2868 {
2869 var _constructor = publicInstance.constructor;
2870 var componentName = _constructor && getComponentName(_constructor) || 'ReactClass';
2871 var warningKey = componentName + '.' + callerName;
2872 if (didWarnAboutNoopUpdateForComponent[warningKey]) {
2873 return;
2874 }
2875
2876 warningWithoutStack$1(false, '%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName);
2877 didWarnAboutNoopUpdateForComponent[warningKey] = true;
2878 }
2879}
2880
2881function shouldConstruct(Component) {
2882 return Component.prototype && Component.prototype.isReactComponent;
2883}
2884
2885function getNonChildrenInnerMarkup(props) {
2886 var innerHTML = props.dangerouslySetInnerHTML;
2887 if (innerHTML != null) {
2888 if (innerHTML.__html != null) {
2889 return innerHTML.__html;
2890 }
2891 } else {
2892 var content = props.children;
2893 if (typeof content === 'string' || typeof content === 'number') {
2894 return escapeTextForBrowser(content);
2895 }
2896 }
2897 return null;
2898}
2899
2900function flattenTopLevelChildren(children) {
2901 if (!React.isValidElement(children)) {
2902 return toArray(children);
2903 }
2904 var element = children;
2905 if (element.type !== REACT_FRAGMENT_TYPE) {
2906 return [element];
2907 }
2908 var fragmentChildren = element.props.children;
2909 if (!React.isValidElement(fragmentChildren)) {
2910 return toArray(fragmentChildren);
2911 }
2912 var fragmentChildElement = fragmentChildren;
2913 return [fragmentChildElement];
2914}
2915
2916function flattenOptionChildren(children) {
2917 if (children === undefined || children === null) {
2918 return children;
2919 }
2920 var content = '';
2921 // Flatten children and warn if they aren't strings or numbers;
2922 // invalid types are ignored.
2923 React.Children.forEach(children, function (child) {
2924 if (child == null) {
2925 return;
2926 }
2927 content += child;
2928 {
2929 if (!didWarnInvalidOptionChildren && typeof child !== 'string' && typeof child !== 'number') {
2930 didWarnInvalidOptionChildren = true;
2931 warning$1(false, 'Only strings and numbers are supported as <option> children.');
2932 }
2933 }
2934 });
2935 return content;
2936}
2937
2938var hasOwnProperty = Object.prototype.hasOwnProperty;
2939var STYLE = 'style';
2940var RESERVED_PROPS = {
2941 children: null,
2942 dangerouslySetInnerHTML: null,
2943 suppressContentEditableWarning: null,
2944 suppressHydrationWarning: null
2945};
2946
2947function createOpenTagMarkup(tagVerbatim, tagLowercase, props, namespace, makeStaticMarkup, isRootElement) {
2948 var ret = '<' + tagVerbatim;
2949
2950 for (var propKey in props) {
2951 if (!hasOwnProperty.call(props, propKey)) {
2952 continue;
2953 }
2954 if (enableFlareAPI && propKey === 'listeners') {
2955 continue;
2956 }
2957 var propValue = props[propKey];
2958 if (propValue == null) {
2959 continue;
2960 }
2961 if (propKey === STYLE) {
2962 propValue = createMarkupForStyles(propValue);
2963 }
2964 var markup = null;
2965 if (isCustomComponent(tagLowercase, props)) {
2966 if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
2967 markup = createMarkupForCustomAttribute(propKey, propValue);
2968 }
2969 } else {
2970 markup = createMarkupForProperty(propKey, propValue);
2971 }
2972 if (markup) {
2973 ret += ' ' + markup;
2974 }
2975 }
2976
2977 // For static pages, no need to put React ID and checksum. Saves lots of
2978 // bytes.
2979 if (makeStaticMarkup) {
2980 return ret;
2981 }
2982
2983 if (isRootElement) {
2984 ret += ' ' + createMarkupForRoot();
2985 }
2986 return ret;
2987}
2988
2989function validateRenderResult(child, type) {
2990 if (child === undefined) {
2991 (function () {
2992 {
2993 {
2994 throw ReactError(Error((getComponentName(type) || 'Component') + '(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.'));
2995 }
2996 }
2997 })();
2998 }
2999}
3000
3001function resolve(child, context, threadID) {
3002 while (React.isValidElement(child)) {
3003 // Safe because we just checked it's an element.
3004 var element = child;
3005 var Component = element.type;
3006 {
3007 pushElementToDebugStack(element);
3008 }
3009 if (typeof Component !== 'function') {
3010 break;
3011 }
3012 processChild(element, Component);
3013 }
3014
3015 // Extra closure so queue and replace can be captured properly
3016 function processChild(element, Component) {
3017 var isClass = shouldConstruct(Component);
3018 var publicContext = processContext(Component, context, threadID, isClass);
3019
3020 var queue = [];
3021 var replace = false;
3022 var updater = {
3023 isMounted: function (publicInstance) {
3024 return false;
3025 },
3026 enqueueForceUpdate: function (publicInstance) {
3027 if (queue === null) {
3028 warnNoop(publicInstance, 'forceUpdate');
3029 return null;
3030 }
3031 },
3032 enqueueReplaceState: function (publicInstance, completeState) {
3033 replace = true;
3034 queue = [completeState];
3035 },
3036 enqueueSetState: function (publicInstance, currentPartialState) {
3037 if (queue === null) {
3038 warnNoop(publicInstance, 'setState');
3039 return null;
3040 }
3041 queue.push(currentPartialState);
3042 }
3043 };
3044
3045 var inst = void 0;
3046 if (isClass) {
3047 inst = new Component(element.props, publicContext, updater);
3048
3049 if (typeof Component.getDerivedStateFromProps === 'function') {
3050 {
3051 if (inst.state === null || inst.state === undefined) {
3052 var componentName = getComponentName(Component) || 'Unknown';
3053 if (!didWarnAboutUninitializedState[componentName]) {
3054 warningWithoutStack$1(false, '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, inst.state === null ? 'null' : 'undefined', componentName);
3055 didWarnAboutUninitializedState[componentName] = true;
3056 }
3057 }
3058 }
3059
3060 var partialState = Component.getDerivedStateFromProps.call(null, element.props, inst.state);
3061
3062 {
3063 if (partialState === undefined) {
3064 var _componentName = getComponentName(Component) || 'Unknown';
3065 if (!didWarnAboutUndefinedDerivedState[_componentName]) {
3066 warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', _componentName);
3067 didWarnAboutUndefinedDerivedState[_componentName] = true;
3068 }
3069 }
3070 }
3071
3072 if (partialState != null) {
3073 inst.state = _assign({}, inst.state, partialState);
3074 }
3075 }
3076 } else {
3077 {
3078 if (Component.prototype && typeof Component.prototype.render === 'function') {
3079 var _componentName2 = getComponentName(Component) || 'Unknown';
3080
3081 if (!didWarnAboutBadClass[_componentName2]) {
3082 warningWithoutStack$1(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', _componentName2, _componentName2);
3083 didWarnAboutBadClass[_componentName2] = true;
3084 }
3085 }
3086 }
3087 var componentIdentity = {};
3088 prepareToUseHooks(componentIdentity);
3089 inst = Component(element.props, publicContext, updater);
3090 inst = finishHooks(Component, element.props, inst, publicContext);
3091
3092 if (inst == null || inst.render == null) {
3093 child = inst;
3094 validateRenderResult(child, Component);
3095 return;
3096 }
3097
3098 {
3099 var _componentName3 = getComponentName(Component) || 'Unknown';
3100 if (!didWarnAboutModulePatternComponent[_componentName3]) {
3101 warningWithoutStack$1(false, 'The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName3, _componentName3, _componentName3);
3102 didWarnAboutModulePatternComponent[_componentName3] = true;
3103 }
3104 }
3105 }
3106
3107 inst.props = element.props;
3108 inst.context = publicContext;
3109 inst.updater = updater;
3110
3111 var initialState = inst.state;
3112 if (initialState === undefined) {
3113 inst.state = initialState = null;
3114 }
3115 if (typeof inst.UNSAFE_componentWillMount === 'function' || typeof inst.componentWillMount === 'function') {
3116 if (typeof inst.componentWillMount === 'function') {
3117 {
3118 if (warnAboutDeprecatedLifecycles && inst.componentWillMount.__suppressDeprecationWarning !== true) {
3119 var _componentName4 = getComponentName(Component) || 'Unknown';
3120
3121 if (!didWarnAboutDeprecatedWillMount[_componentName4]) {
3122 lowPriorityWarning$1(false,
3123 // keep this warning in sync with ReactStrictModeWarning.js
3124 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-async-component-lifecycle-hooks for details.\n\n' + '* Move code from componentWillMount to componentDidMount (preferred in most cases) ' + 'or the constructor.\n' + '\nPlease update the following components: %s', _componentName4);
3125 didWarnAboutDeprecatedWillMount[_componentName4] = true;
3126 }
3127 }
3128 }
3129
3130 // In order to support react-lifecycles-compat polyfilled components,
3131 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
3132 if (typeof Component.getDerivedStateFromProps !== 'function') {
3133 inst.componentWillMount();
3134 }
3135 }
3136 if (typeof inst.UNSAFE_componentWillMount === 'function' && typeof Component.getDerivedStateFromProps !== 'function') {
3137 // In order to support react-lifecycles-compat polyfilled components,
3138 // Unsafe lifecycles should not be invoked for any component with the new gDSFP.
3139 inst.UNSAFE_componentWillMount();
3140 }
3141 if (queue.length) {
3142 var oldQueue = queue;
3143 var oldReplace = replace;
3144 queue = null;
3145 replace = false;
3146
3147 if (oldReplace && oldQueue.length === 1) {
3148 inst.state = oldQueue[0];
3149 } else {
3150 var nextState = oldReplace ? oldQueue[0] : inst.state;
3151 var dontMutate = true;
3152 for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) {
3153 var partial = oldQueue[i];
3154 var _partialState = typeof partial === 'function' ? partial.call(inst, nextState, element.props, publicContext) : partial;
3155 if (_partialState != null) {
3156 if (dontMutate) {
3157 dontMutate = false;
3158 nextState = _assign({}, nextState, _partialState);
3159 } else {
3160 _assign(nextState, _partialState);
3161 }
3162 }
3163 }
3164 inst.state = nextState;
3165 }
3166 } else {
3167 queue = null;
3168 }
3169 }
3170 child = inst.render();
3171
3172 {
3173 if (child === undefined && inst.render._isMockFunction) {
3174 // This is probably bad practice. Consider warning here and
3175 // deprecating this convenience.
3176 child = null;
3177 }
3178 }
3179 validateRenderResult(child, Component);
3180
3181 var childContext = void 0;
3182 if (disableLegacyContext) {
3183 {
3184 var childContextTypes = Component.childContextTypes;
3185 if (childContextTypes !== undefined) {
3186 warningWithoutStack$1(false, '%s uses the legacy childContextTypes API which is no longer supported. ' + 'Use React.createContext() instead.', getComponentName(Component) || 'Unknown');
3187 }
3188 }
3189 } else {
3190 if (typeof inst.getChildContext === 'function') {
3191 var _childContextTypes = Component.childContextTypes;
3192 if (typeof _childContextTypes === 'object') {
3193 childContext = inst.getChildContext();
3194 for (var contextKey in childContext) {
3195 (function () {
3196 if (!(contextKey in _childContextTypes)) {
3197 {
3198 throw ReactError(Error((getComponentName(Component) || 'Unknown') + '.getChildContext(): key "' + contextKey + '" is not defined in childContextTypes.'));
3199 }
3200 }
3201 })();
3202 }
3203 } else {
3204 warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(Component) || 'Unknown');
3205 }
3206 }
3207 if (childContext) {
3208 context = _assign({}, context, childContext);
3209 }
3210 }
3211 }
3212 return { child: child, context: context };
3213}
3214
3215var ReactDOMServerRenderer = function () {
3216 // DEV-only
3217
3218 // TODO: type this more strictly:
3219 function ReactDOMServerRenderer(children, makeStaticMarkup) {
3220 _classCallCheck(this, ReactDOMServerRenderer);
3221
3222 var flatChildren = flattenTopLevelChildren(children);
3223
3224 var topFrame = {
3225 type: null,
3226 // Assume all trees start in the HTML namespace (not totally true, but
3227 // this is what we did historically)
3228 domNamespace: Namespaces.html,
3229 children: flatChildren,
3230 childIndex: 0,
3231 context: emptyObject,
3232 footer: ''
3233 };
3234 {
3235 topFrame.debugElementStack = [];
3236 }
3237 this.threadID = allocThreadID();
3238 this.stack = [topFrame];
3239 this.exhausted = false;
3240 this.currentSelectValue = null;
3241 this.previousWasTextNode = false;
3242 this.makeStaticMarkup = makeStaticMarkup;
3243 this.suspenseDepth = 0;
3244
3245 // Context (new API)
3246 this.contextIndex = -1;
3247 this.contextStack = [];
3248 this.contextValueStack = [];
3249 {
3250 this.contextProviderStack = [];
3251 }
3252 }
3253
3254 ReactDOMServerRenderer.prototype.destroy = function destroy() {
3255 if (!this.exhausted) {
3256 this.exhausted = true;
3257 this.clearProviders();
3258 freeThreadID(this.threadID);
3259 }
3260 };
3261
3262 /**
3263 * Note: We use just two stacks regardless of how many context providers you have.
3264 * Providers are always popped in the reverse order to how they were pushed
3265 * so we always know on the way down which provider you'll encounter next on the way up.
3266 * On the way down, we push the current provider, and its context value *before*
3267 * we mutated it, onto the stacks. Therefore, on the way up, we always know which
3268 * provider needs to be "restored" to which value.
3269 * https://github.com/facebook/react/pull/12985#issuecomment-396301248
3270 */
3271
3272 ReactDOMServerRenderer.prototype.pushProvider = function pushProvider(provider) {
3273 var index = ++this.contextIndex;
3274 var context = provider.type._context;
3275 var threadID = this.threadID;
3276 validateContextBounds(context, threadID);
3277 var previousValue = context[threadID];
3278
3279 // Remember which value to restore this context to on our way up.
3280 this.contextStack[index] = context;
3281 this.contextValueStack[index] = previousValue;
3282 {
3283 // Only used for push/pop mismatch warnings.
3284 this.contextProviderStack[index] = provider;
3285 }
3286
3287 // Mutate the current value.
3288 context[threadID] = provider.props.value;
3289 };
3290
3291 ReactDOMServerRenderer.prototype.popProvider = function popProvider(provider) {
3292 var index = this.contextIndex;
3293 {
3294 !(index > -1 && provider === this.contextProviderStack[index]) ? warningWithoutStack$1(false, 'Unexpected pop.') : void 0;
3295 }
3296
3297 var context = this.contextStack[index];
3298 var previousValue = this.contextValueStack[index];
3299
3300 // "Hide" these null assignments from Flow by using `any`
3301 // because conceptually they are deletions--as long as we
3302 // promise to never access values beyond `this.contextIndex`.
3303 this.contextStack[index] = null;
3304 this.contextValueStack[index] = null;
3305 {
3306 this.contextProviderStack[index] = null;
3307 }
3308 this.contextIndex--;
3309
3310 // Restore to the previous value we stored as we were walking down.
3311 // We've already verified that this context has been expanded to accommodate
3312 // this thread id, so we don't need to do it again.
3313 context[this.threadID] = previousValue;
3314 };
3315
3316 ReactDOMServerRenderer.prototype.clearProviders = function clearProviders() {
3317 // Restore any remaining providers on the stack to previous values
3318 for (var index = this.contextIndex; index >= 0; index--) {
3319 var _context = this.contextStack[index];
3320 var previousValue = this.contextValueStack[index];
3321 _context[this.threadID] = previousValue;
3322 }
3323 };
3324
3325 ReactDOMServerRenderer.prototype.read = function read(bytes) {
3326 if (this.exhausted) {
3327 return null;
3328 }
3329
3330 var prevThreadID = currentThreadID;
3331 setCurrentThreadID(this.threadID);
3332 var prevDispatcher = ReactCurrentDispatcher.current;
3333 ReactCurrentDispatcher.current = Dispatcher;
3334 try {
3335 // Markup generated within <Suspense> ends up buffered until we know
3336 // nothing in that boundary suspended
3337 var out = [''];
3338 var suspended = false;
3339 while (out[0].length < bytes) {
3340 if (this.stack.length === 0) {
3341 this.exhausted = true;
3342 freeThreadID(this.threadID);
3343 break;
3344 }
3345 var frame = this.stack[this.stack.length - 1];
3346 if (suspended || frame.childIndex >= frame.children.length) {
3347 var _footer = frame.footer;
3348 if (_footer !== '') {
3349 this.previousWasTextNode = false;
3350 }
3351 this.stack.pop();
3352 if (frame.type === 'select') {
3353 this.currentSelectValue = null;
3354 } else if (frame.type != null && frame.type.type != null && frame.type.type.$$typeof === REACT_PROVIDER_TYPE) {
3355 var provider = frame.type;
3356 this.popProvider(provider);
3357 } else if (frame.type === REACT_SUSPENSE_TYPE) {
3358 this.suspenseDepth--;
3359 var buffered = out.pop();
3360
3361 if (suspended) {
3362 suspended = false;
3363 // If rendering was suspended at this boundary, render the fallbackFrame
3364 var _fallbackFrame = frame.fallbackFrame;
3365 (function () {
3366 if (!_fallbackFrame) {
3367 {
3368 throw ReactError(Error('suspense fallback not found, something is broken'));
3369 }
3370 }
3371 })();
3372 this.stack.push(_fallbackFrame);
3373 out[this.suspenseDepth] += '<!--$!-->';
3374 // Skip flushing output since we're switching to the fallback
3375 continue;
3376 } else {
3377 out[this.suspenseDepth] += buffered;
3378 }
3379 }
3380
3381 // Flush output
3382 out[this.suspenseDepth] += _footer;
3383 continue;
3384 }
3385 var child = frame.children[frame.childIndex++];
3386
3387 var outBuffer = '';
3388 {
3389 pushCurrentDebugStack(this.stack);
3390 // We're starting work on this frame, so reset its inner stack.
3391 frame.debugElementStack.length = 0;
3392 }
3393 try {
3394 outBuffer += this.render(child, frame.context, frame.domNamespace);
3395 } catch (err) {
3396 if (enableSuspenseServerRenderer && typeof err.then === 'function') {
3397 suspended = true;
3398 } else {
3399 throw err;
3400 }
3401 } finally {
3402 {
3403 popCurrentDebugStack();
3404 }
3405 }
3406 if (out.length <= this.suspenseDepth) {
3407 out.push('');
3408 }
3409 out[this.suspenseDepth] += outBuffer;
3410 }
3411 return out[0];
3412 } finally {
3413 ReactCurrentDispatcher.current = prevDispatcher;
3414 setCurrentThreadID(prevThreadID);
3415 }
3416 };
3417
3418 ReactDOMServerRenderer.prototype.render = function render(child, context, parentNamespace) {
3419 if (typeof child === 'string' || typeof child === 'number') {
3420 var text = '' + child;
3421 if (text === '') {
3422 return '';
3423 }
3424 if (this.makeStaticMarkup) {
3425 return escapeTextForBrowser(text);
3426 }
3427 if (this.previousWasTextNode) {
3428 return '<!-- -->' + escapeTextForBrowser(text);
3429 }
3430 this.previousWasTextNode = true;
3431 return escapeTextForBrowser(text);
3432 } else {
3433 var nextChild = void 0;
3434
3435 var _resolve = resolve(child, context, this.threadID);
3436
3437 nextChild = _resolve.child;
3438 context = _resolve.context;
3439
3440 if (nextChild === null || nextChild === false) {
3441 return '';
3442 } else if (!React.isValidElement(nextChild)) {
3443 if (nextChild != null && nextChild.$$typeof != null) {
3444 // Catch unexpected special types early.
3445 var $$typeof = nextChild.$$typeof;
3446 (function () {
3447 if (!($$typeof !== REACT_PORTAL_TYPE)) {
3448 {
3449 throw ReactError(Error('Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render.'));
3450 }
3451 }
3452 })();
3453 // Catch-all to prevent an infinite loop if React.Children.toArray() supports some new type.
3454 (function () {
3455 {
3456 {
3457 throw ReactError(Error('Unknown element-like object type: ' + $$typeof.toString() + '. This is likely a bug in React. Please file an issue.'));
3458 }
3459 }
3460 })();
3461 }
3462 var nextChildren = toArray(nextChild);
3463 var frame = {
3464 type: null,
3465 domNamespace: parentNamespace,
3466 children: nextChildren,
3467 childIndex: 0,
3468 context: context,
3469 footer: ''
3470 };
3471 {
3472 frame.debugElementStack = [];
3473 }
3474 this.stack.push(frame);
3475 return '';
3476 }
3477 // Safe because we just checked it's an element.
3478 var nextElement = nextChild;
3479 var elementType = nextElement.type;
3480
3481 if (typeof elementType === 'string') {
3482 return this.renderDOM(nextElement, context, parentNamespace);
3483 }
3484
3485 switch (elementType) {
3486 case REACT_STRICT_MODE_TYPE:
3487 case REACT_CONCURRENT_MODE_TYPE:
3488 case REACT_PROFILER_TYPE:
3489 case REACT_SUSPENSE_LIST_TYPE:
3490 case REACT_FRAGMENT_TYPE:
3491 {
3492 var _nextChildren = toArray(nextChild.props.children);
3493 var _frame = {
3494 type: null,
3495 domNamespace: parentNamespace,
3496 children: _nextChildren,
3497 childIndex: 0,
3498 context: context,
3499 footer: ''
3500 };
3501 {
3502 _frame.debugElementStack = [];
3503 }
3504 this.stack.push(_frame);
3505 return '';
3506 }
3507 case REACT_SUSPENSE_TYPE:
3508 {
3509 if (enableSuspenseServerRenderer) {
3510 var fallback = nextChild.props.fallback;
3511 if (fallback === undefined) {
3512 // If there is no fallback, then this just behaves as a fragment.
3513 var _nextChildren3 = toArray(nextChild.props.children);
3514 var _frame3 = {
3515 type: null,
3516 domNamespace: parentNamespace,
3517 children: _nextChildren3,
3518 childIndex: 0,
3519 context: context,
3520 footer: ''
3521 };
3522 {
3523 _frame3.debugElementStack = [];
3524 }
3525 this.stack.push(_frame3);
3526 return '';
3527 }
3528 var fallbackChildren = toArray(fallback);
3529 var _nextChildren2 = toArray(nextChild.props.children);
3530 var _fallbackFrame2 = {
3531 type: null,
3532 domNamespace: parentNamespace,
3533 children: fallbackChildren,
3534 childIndex: 0,
3535 context: context,
3536 footer: '<!--/$-->'
3537 };
3538 var _frame2 = {
3539 fallbackFrame: _fallbackFrame2,
3540 type: REACT_SUSPENSE_TYPE,
3541 domNamespace: parentNamespace,
3542 children: _nextChildren2,
3543 childIndex: 0,
3544 context: context,
3545 footer: '<!--/$-->'
3546 };
3547 {
3548 _frame2.debugElementStack = [];
3549 _fallbackFrame2.debugElementStack = [];
3550 }
3551 this.stack.push(_frame2);
3552 this.suspenseDepth++;
3553 return '<!--$-->';
3554 } else {
3555 (function () {
3556 {
3557 {
3558 throw ReactError(Error('ReactDOMServer does not yet support Suspense.'));
3559 }
3560 }
3561 })();
3562 }
3563 }
3564 // eslint-disable-next-line-no-fallthrough
3565 default:
3566 break;
3567 }
3568 if (typeof elementType === 'object' && elementType !== null) {
3569 switch (elementType.$$typeof) {
3570 case REACT_FORWARD_REF_TYPE:
3571 {
3572 var element = nextChild;
3573 var _nextChildren4 = void 0;
3574 var componentIdentity = {};
3575 prepareToUseHooks(componentIdentity);
3576 _nextChildren4 = elementType.render(element.props, element.ref);
3577 _nextChildren4 = finishHooks(elementType.render, element.props, _nextChildren4, element.ref);
3578 _nextChildren4 = toArray(_nextChildren4);
3579 var _frame4 = {
3580 type: null,
3581 domNamespace: parentNamespace,
3582 children: _nextChildren4,
3583 childIndex: 0,
3584 context: context,
3585 footer: ''
3586 };
3587 {
3588 _frame4.debugElementStack = [];
3589 }
3590 this.stack.push(_frame4);
3591 return '';
3592 }
3593 case REACT_MEMO_TYPE:
3594 {
3595 var _element = nextChild;
3596 var _nextChildren5 = [React.createElement(elementType.type, _assign({ ref: _element.ref }, _element.props))];
3597 var _frame5 = {
3598 type: null,
3599 domNamespace: parentNamespace,
3600 children: _nextChildren5,
3601 childIndex: 0,
3602 context: context,
3603 footer: ''
3604 };
3605 {
3606 _frame5.debugElementStack = [];
3607 }
3608 this.stack.push(_frame5);
3609 return '';
3610 }
3611 case REACT_PROVIDER_TYPE:
3612 {
3613 var provider = nextChild;
3614 var nextProps = provider.props;
3615 var _nextChildren6 = toArray(nextProps.children);
3616 var _frame6 = {
3617 type: provider,
3618 domNamespace: parentNamespace,
3619 children: _nextChildren6,
3620 childIndex: 0,
3621 context: context,
3622 footer: ''
3623 };
3624 {
3625 _frame6.debugElementStack = [];
3626 }
3627
3628 this.pushProvider(provider);
3629
3630 this.stack.push(_frame6);
3631 return '';
3632 }
3633 case REACT_CONTEXT_TYPE:
3634 {
3635 var reactContext = nextChild.type;
3636 // The logic below for Context differs depending on PROD or DEV mode. In
3637 // DEV mode, we create a separate object for Context.Consumer that acts
3638 // like a proxy to Context. This proxy object adds unnecessary code in PROD
3639 // so we use the old behaviour (Context.Consumer references Context) to
3640 // reduce size and overhead. The separate object references context via
3641 // a property called "_context", which also gives us the ability to check
3642 // in DEV mode if this property exists or not and warn if it does not.
3643 {
3644 if (reactContext._context === undefined) {
3645 // This may be because it's a Context (rather than a Consumer).
3646 // Or it may be because it's older React where they're the same thing.
3647 // We only want to warn if we're sure it's a new React.
3648 if (reactContext !== reactContext.Consumer) {
3649 if (!hasWarnedAboutUsingContextAsConsumer) {
3650 hasWarnedAboutUsingContextAsConsumer = true;
3651 warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
3652 }
3653 }
3654 } else {
3655 reactContext = reactContext._context;
3656 }
3657 }
3658 var _nextProps = nextChild.props;
3659 var threadID = this.threadID;
3660 validateContextBounds(reactContext, threadID);
3661 var nextValue = reactContext[threadID];
3662
3663 var _nextChildren7 = toArray(_nextProps.children(nextValue));
3664 var _frame7 = {
3665 type: nextChild,
3666 domNamespace: parentNamespace,
3667 children: _nextChildren7,
3668 childIndex: 0,
3669 context: context,
3670 footer: ''
3671 };
3672 {
3673 _frame7.debugElementStack = [];
3674 }
3675 this.stack.push(_frame7);
3676 return '';
3677 }
3678 // eslint-disable-next-line-no-fallthrough
3679 case REACT_FUNDAMENTAL_TYPE:
3680 {
3681 if (enableFundamentalAPI) {
3682 var fundamentalImpl = elementType.impl;
3683 var open = fundamentalImpl.getServerSideString(null, nextElement.props);
3684 var getServerSideStringClose = fundamentalImpl.getServerSideStringClose;
3685 var close = getServerSideStringClose !== undefined ? getServerSideStringClose(null, nextElement.props) : '';
3686 var _nextChildren8 = fundamentalImpl.reconcileChildren !== false ? toArray(nextChild.props.children) : [];
3687 var _frame8 = {
3688 type: null,
3689 domNamespace: parentNamespace,
3690 children: _nextChildren8,
3691 childIndex: 0,
3692 context: context,
3693 footer: close
3694 };
3695 {
3696 _frame8.debugElementStack = [];
3697 }
3698 this.stack.push(_frame8);
3699 return open;
3700 }
3701 (function () {
3702 {
3703 {
3704 throw ReactError(Error('ReactDOMServer does not yet support the fundamental API.'));
3705 }
3706 }
3707 })();
3708 }
3709 // eslint-disable-next-line-no-fallthrough
3710 case REACT_LAZY_TYPE:
3711 (function () {
3712 {
3713 {
3714 throw ReactError(Error('ReactDOMServer does not yet support lazy-loaded components.'));
3715 }
3716 }
3717 })();
3718 }
3719 }
3720
3721 var info = '';
3722 {
3723 var owner = nextElement._owner;
3724 if (elementType === undefined || typeof elementType === 'object' && elementType !== null && Object.keys(elementType).length === 0) {
3725 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.';
3726 }
3727 var ownerName = owner ? getComponentName(owner) : null;
3728 if (ownerName) {
3729 info += '\n\nCheck the render method of `' + ownerName + '`.';
3730 }
3731 }
3732 (function () {
3733 {
3734 {
3735 throw ReactError(Error('Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: ' + (elementType == null ? elementType : typeof elementType) + '.' + info));
3736 }
3737 }
3738 })();
3739 }
3740 };
3741
3742 ReactDOMServerRenderer.prototype.renderDOM = function renderDOM(element, context, parentNamespace) {
3743 var tag = element.type.toLowerCase();
3744
3745 var namespace = parentNamespace;
3746 if (parentNamespace === Namespaces.html) {
3747 namespace = getIntrinsicNamespace(tag);
3748 }
3749
3750 {
3751 if (namespace === Namespaces.html) {
3752 // Should this check be gated by parent namespace? Not sure we want to
3753 // allow <SVG> or <mATH>.
3754 !(tag === element.type) ? warning$1(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', element.type) : void 0;
3755 }
3756 }
3757
3758 validateDangerousTag(tag);
3759
3760 var props = element.props;
3761 if (tag === 'input') {
3762 {
3763 ReactControlledValuePropTypes.checkPropTypes('input', props);
3764
3765 if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnDefaultChecked) {
3766 warning$1(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', 'A component', props.type);
3767 didWarnDefaultChecked = true;
3768 }
3769 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultInputValue) {
3770 warning$1(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', 'A component', props.type);
3771 didWarnDefaultInputValue = true;
3772 }
3773 }
3774
3775 props = _assign({
3776 type: undefined
3777 }, props, {
3778 defaultChecked: undefined,
3779 defaultValue: undefined,
3780 value: props.value != null ? props.value : props.defaultValue,
3781 checked: props.checked != null ? props.checked : props.defaultChecked
3782 });
3783 } else if (tag === 'textarea') {
3784 {
3785 ReactControlledValuePropTypes.checkPropTypes('textarea', props);
3786 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultTextareaValue) {
3787 warning$1(false, 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
3788 didWarnDefaultTextareaValue = true;
3789 }
3790 }
3791
3792 var initialValue = props.value;
3793 if (initialValue == null) {
3794 var defaultValue = props.defaultValue;
3795 // TODO (yungsters): Remove support for children content in <textarea>.
3796 var textareaChildren = props.children;
3797 if (textareaChildren != null) {
3798 {
3799 warning$1(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
3800 }
3801 (function () {
3802 if (!(defaultValue == null)) {
3803 {
3804 throw ReactError(Error('If you supply `defaultValue` on a <textarea>, do not pass children.'));
3805 }
3806 }
3807 })();
3808 if (Array.isArray(textareaChildren)) {
3809 (function () {
3810 if (!(textareaChildren.length <= 1)) {
3811 {
3812 throw ReactError(Error('<textarea> can only have at most one child.'));
3813 }
3814 }
3815 })();
3816 textareaChildren = textareaChildren[0];
3817 }
3818
3819 defaultValue = '' + textareaChildren;
3820 }
3821 if (defaultValue == null) {
3822 defaultValue = '';
3823 }
3824 initialValue = defaultValue;
3825 }
3826
3827 props = _assign({}, props, {
3828 value: undefined,
3829 children: '' + initialValue
3830 });
3831 } else if (tag === 'select') {
3832 {
3833 ReactControlledValuePropTypes.checkPropTypes('select', props);
3834
3835 for (var i = 0; i < valuePropNames.length; i++) {
3836 var propName = valuePropNames[i];
3837 if (props[propName] == null) {
3838 continue;
3839 }
3840 var isArray = Array.isArray(props[propName]);
3841 if (props.multiple && !isArray) {
3842 warning$1(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.', propName);
3843 } else if (!props.multiple && isArray) {
3844 warning$1(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.', propName);
3845 }
3846 }
3847
3848 if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultSelectValue) {
3849 warning$1(false, 'Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
3850 didWarnDefaultSelectValue = true;
3851 }
3852 }
3853 this.currentSelectValue = props.value != null ? props.value : props.defaultValue;
3854 props = _assign({}, props, {
3855 value: undefined
3856 });
3857 } else if (tag === 'option') {
3858 var selected = null;
3859 var selectValue = this.currentSelectValue;
3860 var optionChildren = flattenOptionChildren(props.children);
3861 if (selectValue != null) {
3862 var value = void 0;
3863 if (props.value != null) {
3864 value = props.value + '';
3865 } else {
3866 value = optionChildren;
3867 }
3868 selected = false;
3869 if (Array.isArray(selectValue)) {
3870 // multiple
3871 for (var j = 0; j < selectValue.length; j++) {
3872 if ('' + selectValue[j] === value) {
3873 selected = true;
3874 break;
3875 }
3876 }
3877 } else {
3878 selected = '' + selectValue === value;
3879 }
3880
3881 props = _assign({
3882 selected: undefined,
3883 children: undefined
3884 }, props, {
3885 selected: selected,
3886 children: optionChildren
3887 });
3888 }
3889 }
3890
3891 {
3892 validatePropertiesInDevelopment(tag, props);
3893 }
3894
3895 assertValidProps(tag, props);
3896
3897 var out = createOpenTagMarkup(element.type, tag, props, namespace, this.makeStaticMarkup, this.stack.length === 1);
3898 var footer = '';
3899 if (omittedCloseTags.hasOwnProperty(tag)) {
3900 out += '/>';
3901 } else {
3902 out += '>';
3903 footer = '</' + element.type + '>';
3904 }
3905 var children = void 0;
3906 var innerMarkup = getNonChildrenInnerMarkup(props);
3907 if (innerMarkup != null) {
3908 children = [];
3909 if (newlineEatingTags[tag] && innerMarkup.charAt(0) === '\n') {
3910 // text/html ignores the first character in these tags if it's a newline
3911 // Prefer to break application/xml over text/html (for now) by adding
3912 // a newline specifically to get eaten by the parser. (Alternately for
3913 // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
3914 // \r is normalized out by HTMLTextAreaElement#value.)
3915 // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
3916 // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
3917 // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
3918 // See: Parsing of "textarea" "listing" and "pre" elements
3919 // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
3920 out += '\n';
3921 }
3922 out += innerMarkup;
3923 } else {
3924 children = toArray(props.children);
3925 }
3926 var frame = {
3927 domNamespace: getChildNamespace(parentNamespace, element.type),
3928 type: tag,
3929 children: children,
3930 childIndex: 0,
3931 context: context,
3932 footer: footer
3933 };
3934 {
3935 frame.debugElementStack = [];
3936 }
3937 this.stack.push(frame);
3938 this.previousWasTextNode = false;
3939 return out;
3940 };
3941
3942 return ReactDOMServerRenderer;
3943}();
3944
3945/**
3946 * Render a ReactElement to its initial HTML. This should only be used on the
3947 * server.
3948 * See https://reactjs.org/docs/react-dom-server.html#rendertostring
3949 */
3950function renderToString(element) {
3951 var renderer = new ReactDOMServerRenderer(element, false);
3952 try {
3953 var markup = renderer.read(Infinity);
3954 return markup;
3955 } finally {
3956 renderer.destroy();
3957 }
3958}
3959
3960/**
3961 * Similar to renderToString, except this doesn't create extra DOM attributes
3962 * such as data-react-id that React uses internally.
3963 * See https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup
3964 */
3965function renderToStaticMarkup(element) {
3966 var renderer = new ReactDOMServerRenderer(element, true);
3967 try {
3968 var markup = renderer.read(Infinity);
3969 return markup;
3970 } finally {
3971 renderer.destroy();
3972 }
3973}
3974
3975function renderToNodeStream() {
3976 (function () {
3977 {
3978 {
3979 throw ReactError(Error('ReactDOMServer.renderToNodeStream(): The streaming API is not available in the browser. Use ReactDOMServer.renderToString() instead.'));
3980 }
3981 }
3982 })();
3983}
3984
3985function renderToStaticNodeStream() {
3986 (function () {
3987 {
3988 {
3989 throw ReactError(Error('ReactDOMServer.renderToStaticNodeStream(): The streaming API is not available in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.'));
3990 }
3991 }
3992 })();
3993}
3994
3995// Note: when changing this, also consider https://github.com/facebook/react/issues/11526
3996var ReactDOMServerBrowser = {
3997 renderToString: renderToString,
3998 renderToStaticMarkup: renderToStaticMarkup,
3999 renderToNodeStream: renderToNodeStream,
4000 renderToStaticNodeStream: renderToStaticNodeStream,
4001 version: ReactVersion
4002};
4003
4004var ReactDOMServerBrowser$1 = Object.freeze({
4005 default: ReactDOMServerBrowser
4006});
4007
4008var ReactDOMServer = ( ReactDOMServerBrowser$1 && ReactDOMServerBrowser ) || ReactDOMServerBrowser$1;
4009
4010// TODO: decide on the top-level export form.
4011// This is hacky but makes it work with both Rollup and Jest
4012var server_browser = ReactDOMServer.default || ReactDOMServer;
4013
4014module.exports = server_browser;
4015 })();
4016}