UNPKG

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