UNPKG

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