UNPKG

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