CoolFace
Apppublic

Ejdjdososs/fable-ai

sourceHugging Facemitupdated 3mo agoView on Hugging Face
0likes
react.development.js2741 linesDownload Raw Back to cjs
1/**2 * @license React3 * react.development.js4 *5 * Copyright (c) Facebook, Inc. and its affiliates.6 *7 * This source code is licensed under the MIT license found in the8 * LICENSE file in the root directory of this source tree.9 */10 11'use strict';12 13if (process.env.NODE_ENV !== "production") {14  (function() {15 16          'use strict';17 18/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */19if (20  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&21  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===22    'function'23) {24  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());25}26          var ReactVersion = '18.3.1';27 28// ATTENTION29// When adding new symbols to this file,30// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'31// The Symbol used to tag the ReactElement-like types.32var REACT_ELEMENT_TYPE = Symbol.for('react.element');33var REACT_PORTAL_TYPE = Symbol.for('react.portal');34var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');35var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');36var REACT_PROFILER_TYPE = Symbol.for('react.profiler');37var REACT_PROVIDER_TYPE = Symbol.for('react.provider');38var REACT_CONTEXT_TYPE = Symbol.for('react.context');39var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');40var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');41var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');42var REACT_MEMO_TYPE = Symbol.for('react.memo');43var REACT_LAZY_TYPE = Symbol.for('react.lazy');44var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');45var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;46var FAUX_ITERATOR_SYMBOL = '@@iterator';47function getIteratorFn(maybeIterable) {48  if (maybeIterable === null || typeof maybeIterable !== 'object') {49    return null;50  }51 52  var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];53 54  if (typeof maybeIterator === 'function') {55    return maybeIterator;56  }57 58  return null;59}60 61/**62 * Keeps track of the current dispatcher.63 */64var ReactCurrentDispatcher = {65  /**66   * @internal67   * @type {ReactComponent}68   */69  current: null70};71 72/**73 * Keeps track of the current batch's configuration such as how long an update74 * should suspend for if it needs to.75 */76var ReactCurrentBatchConfig = {77  transition: null78};79 80var ReactCurrentActQueue = {81  current: null,82  // Used to reproduce behavior of `batchedUpdates` in legacy mode.83  isBatchingLegacy: false,84  didScheduleLegacyUpdate: false85};86 87/**88 * Keeps track of the current owner.89 *90 * The current owner is the component who should own any components that are91 * currently being constructed.92 */93var ReactCurrentOwner = {94  /**95   * @internal96   * @type {ReactComponent}97   */98  current: null99};100 101var ReactDebugCurrentFrame = {};102var currentExtraStackFrame = null;103function setExtraStackFrame(stack) {104  {105    currentExtraStackFrame = stack;106  }107}108 109{110  ReactDebugCurrentFrame.setExtraStackFrame = function (stack) {111    {112      currentExtraStackFrame = stack;113    }114  }; // Stack implementation injected by the current renderer.115 116 117  ReactDebugCurrentFrame.getCurrentStack = null;118 119  ReactDebugCurrentFrame.getStackAddendum = function () {120    var stack = ''; // Add an extra top frame while an element is being validated121 122    if (currentExtraStackFrame) {123      stack += currentExtraStackFrame;124    } // Delegate to the injected renderer-specific implementation125 126 127    var impl = ReactDebugCurrentFrame.getCurrentStack;128 129    if (impl) {130      stack += impl() || '';131    }132 133    return stack;134  };135}136 137// -----------------------------------------------------------------------------138 139var enableScopeAPI = false; // Experimental Create Event Handle API.140var enableCacheElement = false;141var enableTransitionTracing = false; // No known bugs, but needs performance testing142 143var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber144// stuff. Intended to enable React core members to more easily debug scheduling145// issues in DEV builds.146 147var enableDebugTracing = false; // Track which Fiber(s) schedule render work.148 149var ReactSharedInternals = {150  ReactCurrentDispatcher: ReactCurrentDispatcher,151  ReactCurrentBatchConfig: ReactCurrentBatchConfig,152  ReactCurrentOwner: ReactCurrentOwner153};154 155{156  ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;157  ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;158}159 160// by calls to these methods by a Babel plugin.161//162// In PROD (or in packages without access to React internals),163// they are left as they are instead.164 165function warn(format) {166  {167    {168      for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {169        args[_key - 1] = arguments[_key];170      }171 172      printWarning('warn', format, args);173    }174  }175}176function error(format) {177  {178    {179      for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {180        args[_key2 - 1] = arguments[_key2];181      }182 183      printWarning('error', format, args);184    }185  }186}187 188function printWarning(level, format, args) {189  // When changing this logic, you might want to also190  // update consoleWithStackDev.www.js as well.191  {192    var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;193    var stack = ReactDebugCurrentFrame.getStackAddendum();194 195    if (stack !== '') {196      format += '%s';197      args = args.concat([stack]);198    } // eslint-disable-next-line react-internal/safe-string-coercion199 200 201    var argsWithFormat = args.map(function (item) {202      return String(item);203    }); // Careful: RN currently depends on this prefix204 205    argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it206    // breaks IE9: https://github.com/facebook/react/issues/13610207    // eslint-disable-next-line react-internal/no-production-logging208 209    Function.prototype.apply.call(console[level], console, argsWithFormat);210  }211}212 213var didWarnStateUpdateForUnmountedComponent = {};214 215function warnNoop(publicInstance, callerName) {216  {217    var _constructor = publicInstance.constructor;218    var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';219    var warningKey = componentName + "." + callerName;220 221    if (didWarnStateUpdateForUnmountedComponent[warningKey]) {222      return;223    }224 225    error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);226 227    didWarnStateUpdateForUnmountedComponent[warningKey] = true;228  }229}230/**231 * This is the abstract API for an update queue.232 */233 234 235var ReactNoopUpdateQueue = {236  /**237   * Checks whether or not this composite component is mounted.238   * @param {ReactClass} publicInstance The instance we want to test.239   * @return {boolean} True if mounted, false otherwise.240   * @protected241   * @final242   */243  isMounted: function (publicInstance) {244    return false;245  },246 247  /**248   * Forces an update. This should only be invoked when it is known with249   * certainty that we are **not** in a DOM transaction.250   *251   * You may want to call this when you know that some deeper aspect of the252   * component's state has changed but `setState` was not called.253   *254   * This will not invoke `shouldComponentUpdate`, but it will invoke255   * `componentWillUpdate` and `componentDidUpdate`.256   *257   * @param {ReactClass} publicInstance The instance that should rerender.258   * @param {?function} callback Called after component is updated.259   * @param {?string} callerName name of the calling function in the public API.260   * @internal261   */262  enqueueForceUpdate: function (publicInstance, callback, callerName) {263    warnNoop(publicInstance, 'forceUpdate');264  },265 266  /**267   * Replaces all of the state. Always use this or `setState` to mutate state.268   * You should treat `this.state` as immutable.269   *270   * There is no guarantee that `this.state` will be immediately updated, so271   * accessing `this.state` after calling this method may return the old value.272   *273   * @param {ReactClass} publicInstance The instance that should rerender.274   * @param {object} completeState Next state.275   * @param {?function} callback Called after component is updated.276   * @param {?string} callerName name of the calling function in the public API.277   * @internal278   */279  enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {280    warnNoop(publicInstance, 'replaceState');281  },282 283  /**284   * Sets a subset of the state. This only exists because _pendingState is285   * internal. This provides a merging strategy that is not available to deep286   * properties which is confusing. TODO: Expose pendingState or don't use it287   * during the merge.288   *289   * @param {ReactClass} publicInstance The instance that should rerender.290   * @param {object} partialState Next partial state to be merged with state.291   * @param {?function} callback Called after component is updated.292   * @param {?string} Name of the calling function in the public API.293   * @internal294   */295  enqueueSetState: function (publicInstance, partialState, callback, callerName) {296    warnNoop(publicInstance, 'setState');297  }298};299 300var assign = Object.assign;301 302var emptyObject = {};303 304{305  Object.freeze(emptyObject);306}307/**308 * Base class helpers for the updating state of a component.309 */310 311 312function Component(props, context, updater) {313  this.props = props;314  this.context = context; // If a component has string refs, we will assign a different object later.315 316  this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the317  // renderer.318 319  this.updater = updater || ReactNoopUpdateQueue;320}321 322Component.prototype.isReactComponent = {};323/**324 * Sets a subset of the state. Always use this to mutate325 * state. You should treat `this.state` as immutable.326 *327 * There is no guarantee that `this.state` will be immediately updated, so328 * accessing `this.state` after calling this method may return the old value.329 *330 * There is no guarantee that calls to `setState` will run synchronously,331 * as they may eventually be batched together.  You can provide an optional332 * callback that will be executed when the call to setState is actually333 * completed.334 *335 * When a function is provided to setState, it will be called at some point in336 * the future (not synchronously). It will be called with the up to date337 * component arguments (state, props, context). These values can be different338 * from this.* because your function may be called after receiveProps but before339 * shouldComponentUpdate, and this new state, props, and context will not yet be340 * assigned to this.341 *342 * @param {object|function} partialState Next partial state or function to343 *        produce next partial state to be merged with current state.344 * @param {?function} callback Called after state is updated.345 * @final346 * @protected347 */348 349Component.prototype.setState = function (partialState, callback) {350  if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) {351    throw new Error('setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.');352  }353 354  this.updater.enqueueSetState(this, partialState, callback, 'setState');355};356/**357 * Forces an update. This should only be invoked when it is known with358 * certainty that we are **not** in a DOM transaction.359 *360 * You may want to call this when you know that some deeper aspect of the361 * component's state has changed but `setState` was not called.362 *363 * This will not invoke `shouldComponentUpdate`, but it will invoke364 * `componentWillUpdate` and `componentDidUpdate`.365 *366 * @param {?function} callback Called after update is complete.367 * @final368 * @protected369 */370 371 372Component.prototype.forceUpdate = function (callback) {373  this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');374};375/**376 * Deprecated APIs. These APIs used to exist on classic React classes but since377 * we would like to deprecate them, we're not going to move them over to this378 * modern base class. Instead, we define a getter that warns if it's accessed.379 */380 381 382{383  var deprecatedAPIs = {384    isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],385    replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']386  };387 388  var defineDeprecationWarning = function (methodName, info) {389    Object.defineProperty(Component.prototype, methodName, {390      get: function () {391        warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);392 393        return undefined;394      }395    });396  };397 398  for (var fnName in deprecatedAPIs) {399    if (deprecatedAPIs.hasOwnProperty(fnName)) {400      defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);401    }402  }403}404 405function ComponentDummy() {}406 407ComponentDummy.prototype = Component.prototype;408/**409 * Convenience component with default shallow equality check for sCU.410 */411 412function PureComponent(props, context, updater) {413  this.props = props;414  this.context = context; // If a component has string refs, we will assign a different object later.415 416  this.refs = emptyObject;417  this.updater = updater || ReactNoopUpdateQueue;418}419 420var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();421pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.422 423assign(pureComponentPrototype, Component.prototype);424pureComponentPrototype.isPureReactComponent = true;425 426// an immutable object with a single mutable value427function createRef() {428  var refObject = {429    current: null430  };431 432  {433    Object.seal(refObject);434  }435 436  return refObject;437}438 439var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare440 441function isArray(a) {442  return isArrayImpl(a);443}444 445/*446 * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol447 * and Temporal.* types. See https://github.com/facebook/react/pull/22064.448 *449 * The functions in this module will throw an easier-to-understand,450 * easier-to-debug exception with a clear errors message message explaining the451 * problem. (Instead of a confusing exception thrown inside the implementation452 * of the `value` object).453 */454// $FlowFixMe only called in DEV, so void return is not possible.455function typeName(value) {456  {457    // toStringTag is needed for namespaced types like Temporal.Instant458    var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;459    var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';460    return type;461  }462} // $FlowFixMe only called in DEV, so void return is not possible.463 464 465function willCoercionThrow(value) {466  {467    try {468      testStringCoercion(value);469      return false;470    } catch (e) {471      return true;472    }473  }474}475 476function testStringCoercion(value) {477  // If you ended up here by following an exception call stack, here's what's478  // happened: you supplied an object or symbol value to React (as a prop, key,479  // DOM attribute, CSS property, string ref, etc.) and when React tried to480  // coerce it to a string using `'' + value`, an exception was thrown.481  //482  // The most common types that will cause this exception are `Symbol` instances483  // and Temporal objects like `Temporal.Instant`. But any object that has a484  // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this485  // exception. (Library authors do this to prevent users from using built-in486  // numeric operators like `+` or comparison operators like `>=` because custom487  // methods are needed to perform accurate arithmetic or comparison.)488  //489  // To fix the problem, coerce this object or symbol value to a string before490  // passing it to React. The most reliable way is usually `String(value)`.491  //492  // To find which value is throwing, check the browser or debugger console.493  // Before this exception was thrown, there should be `console.error` output494  // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the495  // problem and how that type was used: key, atrribute, input value prop, etc.496  // In most cases, this console output also shows the component and its497  // ancestor components where the exception happened.498  //499  // eslint-disable-next-line react-internal/safe-string-coercion500  return '' + value;501}502function checkKeyStringCoercion(value) {503  {504    if (willCoercionThrow(value)) {505      error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));506 507      return testStringCoercion(value); // throw (to help callers find troubleshooting comments)508    }509  }510}511 512function getWrappedName(outerType, innerType, wrapperName) {513  var displayName = outerType.displayName;514 515  if (displayName) {516    return displayName;517  }518 519  var functionName = innerType.displayName || innerType.name || '';520  return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;521} // Keep in sync with react-reconciler/getComponentNameFromFiber522 523 524function getContextName(type) {525  return type.displayName || 'Context';526} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.527 528 529function getComponentNameFromType(type) {530  if (type == null) {531    // Host root, text node or just invalid type.532    return null;533  }534 535  {536    if (typeof type.tag === 'number') {537      error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');538    }539  }540 541  if (typeof type === 'function') {542    return type.displayName || type.name || null;543  }544 545  if (typeof type === 'string') {546    return type;547  }548 549  switch (type) {550    case REACT_FRAGMENT_TYPE:551      return 'Fragment';552 553    case REACT_PORTAL_TYPE:554      return 'Portal';555 556    case REACT_PROFILER_TYPE:557      return 'Profiler';558 559    case REACT_STRICT_MODE_TYPE:560      return 'StrictMode';561 562    case REACT_SUSPENSE_TYPE:563      return 'Suspense';564 565    case REACT_SUSPENSE_LIST_TYPE:566      return 'SuspenseList';567 568  }569 570  if (typeof type === 'object') {571    switch (type.$$typeof) {572      case REACT_CONTEXT_TYPE:573        var context = type;574        return getContextName(context) + '.Consumer';575 576      case REACT_PROVIDER_TYPE:577        var provider = type;578        return getContextName(provider._context) + '.Provider';579 580      case REACT_FORWARD_REF_TYPE:581        return getWrappedName(type, type.render, 'ForwardRef');582 583      case REACT_MEMO_TYPE:584        var outerName = type.displayName || null;585 586        if (outerName !== null) {587          return outerName;588        }589 590        return getComponentNameFromType(type.type) || 'Memo';591 592      case REACT_LAZY_TYPE:593        {594          var lazyComponent = type;595          var payload = lazyComponent._payload;596          var init = lazyComponent._init;597 598          try {599            return getComponentNameFromType(init(payload));600          } catch (x) {601            return null;602          }603        }604 605      // eslint-disable-next-line no-fallthrough606    }607  }608 609  return null;610}611 612var hasOwnProperty = Object.prototype.hasOwnProperty;613 614var RESERVED_PROPS = {615  key: true,616  ref: true,617  __self: true,618  __source: true619};620var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;621 622{623  didWarnAboutStringRefs = {};624}625 626function hasValidRef(config) {627  {628    if (hasOwnProperty.call(config, 'ref')) {629      var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;630 631      if (getter && getter.isReactWarning) {632        return false;633      }634    }635  }636 637  return config.ref !== undefined;638}639 640function hasValidKey(config) {641  {642    if (hasOwnProperty.call(config, 'key')) {643      var getter = Object.getOwnPropertyDescriptor(config, 'key').get;644 645      if (getter && getter.isReactWarning) {646        return false;647      }648    }649  }650 651  return config.key !== undefined;652}653 654function defineKeyPropWarningGetter(props, displayName) {655  var warnAboutAccessingKey = function () {656    {657      if (!specialPropKeyWarningShown) {658        specialPropKeyWarningShown = true;659 660        error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);661      }662    }663  };664 665  warnAboutAccessingKey.isReactWarning = true;666  Object.defineProperty(props, 'key', {667    get: warnAboutAccessingKey,668    configurable: true669  });670}671 672function defineRefPropWarningGetter(props, displayName) {673  var warnAboutAccessingRef = function () {674    {675      if (!specialPropRefWarningShown) {676        specialPropRefWarningShown = true;677 678        error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);679      }680    }681  };682 683  warnAboutAccessingRef.isReactWarning = true;684  Object.defineProperty(props, 'ref', {685    get: warnAboutAccessingRef,686    configurable: true687  });688}689 690function warnIfStringRefCannotBeAutoConverted(config) {691  {692    if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {693      var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);694 695      if (!didWarnAboutStringRefs[componentName]) {696        error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);697 698        didWarnAboutStringRefs[componentName] = true;699      }700    }701  }702}703/**704 * Factory method to create a new React element. This no longer adheres to705 * the class pattern, so do not use new to call it. Also, instanceof check706 * will not work. Instead test $$typeof field against Symbol.for('react.element') to check707 * if something is a React Element.708 *709 * @param {*} type710 * @param {*} props711 * @param {*} key712 * @param {string|object} ref713 * @param {*} owner714 * @param {*} self A *temporary* helper to detect places where `this` is715 * different from the `owner` when React.createElement is called, so that we716 * can warn. We want to get rid of owner and replace string `ref`s with arrow717 * functions, and as long as `this` and owner are the same, there will be no718 * change in behavior.719 * @param {*} source An annotation object (added by a transpiler or otherwise)720 * indicating filename, line number, and/or other information.721 * @internal722 */723 724 725var ReactElement = function (type, key, ref, self, source, owner, props) {726  var element = {727    // This tag allows us to uniquely identify this as a React Element728    $$typeof: REACT_ELEMENT_TYPE,729    // Built-in properties that belong on the element730    type: type,731    key: key,732    ref: ref,733    props: props,734    // Record the component responsible for creating this element.735    _owner: owner736  };737 738  {739    // The validation flag is currently mutative. We put it on740    // an external backing store so that we can freeze the whole object.741    // This can be replaced with a WeakMap once they are implemented in742    // commonly used development environments.743    element._store = {}; // To make comparing ReactElements easier for testing purposes, we make744    // the validation flag non-enumerable (where possible, which should745    // include every environment we run tests in), so the test framework746    // ignores it.747 748    Object.defineProperty(element._store, 'validated', {749      configurable: false,750      enumerable: false,751      writable: true,752      value: false753    }); // self and source are DEV only properties.754 755    Object.defineProperty(element, '_self', {756      configurable: false,757      enumerable: false,758      writable: false,759      value: self760    }); // Two elements created in two different places should be considered761    // equal for testing purposes and therefore we hide it from enumeration.762 763    Object.defineProperty(element, '_source', {764      configurable: false,765      enumerable: false,766      writable: false,767      value: source768    });769 770    if (Object.freeze) {771      Object.freeze(element.props);772      Object.freeze(element);773    }774  }775 776  return element;777};778/**779 * Create and return a new ReactElement of the given type.780 * See https://reactjs.org/docs/react-api.html#createelement781 */782 783function createElement(type, config, children) {784  var propName; // Reserved names are extracted785 786  var props = {};787  var key = null;788  var ref = null;789  var self = null;790  var source = null;791 792  if (config != null) {793    if (hasValidRef(config)) {794      ref = config.ref;795 796      {797        warnIfStringRefCannotBeAutoConverted(config);798      }799    }800 801    if (hasValidKey(config)) {802      {803        checkKeyStringCoercion(config.key);804      }805 806      key = '' + config.key;807    }808 809    self = config.__self === undefined ? null : config.__self;810    source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object811 812    for (propName in config) {813      if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {814        props[propName] = config[propName];815      }816    }817  } // Children can be more than one argument, and those are transferred onto818  // the newly allocated props object.819 820 821  var childrenLength = arguments.length - 2;822 823  if (childrenLength === 1) {824    props.children = children;825  } else if (childrenLength > 1) {826    var childArray = Array(childrenLength);827 828    for (var i = 0; i < childrenLength; i++) {829      childArray[i] = arguments[i + 2];830    }831 832    {833      if (Object.freeze) {834        Object.freeze(childArray);835      }836    }837 838    props.children = childArray;839  } // Resolve default props840 841 842  if (type && type.defaultProps) {843    var defaultProps = type.defaultProps;844 845    for (propName in defaultProps) {846      if (props[propName] === undefined) {847        props[propName] = defaultProps[propName];848      }849    }850  }851 852  {853    if (key || ref) {854      var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;855 856      if (key) {857        defineKeyPropWarningGetter(props, displayName);858      }859 860      if (ref) {861        defineRefPropWarningGetter(props, displayName);862      }863    }864  }865 866  return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);867}868function cloneAndReplaceKey(oldElement, newKey) {869  var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);870  return newElement;871}872/**873 * Clone and return a new ReactElement using element as the starting point.874 * See https://reactjs.org/docs/react-api.html#cloneelement875 */876 877function cloneElement(element, config, children) {878  if (element === null || element === undefined) {879    throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");880  }881 882  var propName; // Original props are copied883 884  var props = assign({}, element.props); // Reserved names are extracted885 886  var key = element.key;887  var ref = element.ref; // Self is preserved since the owner is preserved.888 889  var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a890  // transpiler, and the original source is probably a better indicator of the891  // true owner.892 893  var source = element._source; // Owner will be preserved, unless ref is overridden894 895  var owner = element._owner;896 897  if (config != null) {898    if (hasValidRef(config)) {899      // Silently steal the ref from the parent.900      ref = config.ref;901      owner = ReactCurrentOwner.current;902    }903 904    if (hasValidKey(config)) {905      {906        checkKeyStringCoercion(config.key);907      }908 909      key = '' + config.key;910    } // Remaining properties override existing props911 912 913    var defaultProps;914 915    if (element.type && element.type.defaultProps) {916      defaultProps = element.type.defaultProps;917    }918 919    for (propName in config) {920      if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {921        if (config[propName] === undefined && defaultProps !== undefined) {922          // Resolve default props923          props[propName] = defaultProps[propName];924        } else {925          props[propName] = config[propName];926        }927      }928    }929  } // Children can be more than one argument, and those are transferred onto930  // the newly allocated props object.931 932 933  var childrenLength = arguments.length - 2;934 935  if (childrenLength === 1) {936    props.children = children;937  } else if (childrenLength > 1) {938    var childArray = Array(childrenLength);939 940    for (var i = 0; i < childrenLength; i++) {941      childArray[i] = arguments[i + 2];942    }943 944    props.children = childArray;945  }946 947  return ReactElement(element.type, key, ref, self, source, owner, props);948}949/**950 * Verifies the object is a ReactElement.951 * See https://reactjs.org/docs/react-api.html#isvalidelement952 * @param {?object} object953 * @return {boolean} True if `object` is a ReactElement.954 * @final955 */956 957function isValidElement(object) {958  return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;959}960 961var SEPARATOR = '.';962var SUBSEPARATOR = ':';963/**964 * Escape and wrap key so it is safe to use as a reactid965 *966 * @param {string} key to be escaped.967 * @return {string} the escaped key.968 */969 970function escape(key) {971  var escapeRegex = /[=:]/g;972  var escaperLookup = {973    '=': '=0',974    ':': '=2'975  };976  var escapedString = key.replace(escapeRegex, function (match) {977    return escaperLookup[match];978  });979  return '$' + escapedString;980}981/**982 * TODO: Test that a single child and an array with one item have the same key983 * pattern.984 */985 986 987var didWarnAboutMaps = false;988var userProvidedKeyEscapeRegex = /\/+/g;989 990function escapeUserProvidedKey(text) {991  return text.replace(userProvidedKeyEscapeRegex, '$&/');992}993/**994 * Generate a key string that identifies a element within a set.995 *996 * @param {*} element A element that could contain a manual key.997 * @param {number} index Index that is used if a manual key is not provided.998 * @return {string}999 */1000 1001 1002function getElementKey(element, index) {1003  // Do some typechecking here since we call this blindly. We want to ensure1004  // that we don't block potential future ES APIs.1005  if (typeof element === 'object' && element !== null && element.key != null) {1006    // Explicit key1007    {1008      checkKeyStringCoercion(element.key);1009    }1010 1011    return escape('' + element.key);1012  } // Implicit key determined by the index in the set1013 1014 1015  return index.toString(36);1016}1017 1018function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {1019  var type = typeof children;1020 1021  if (type === 'undefined' || type === 'boolean') {1022    // All of the above are perceived as null.1023    children = null;1024  }1025 1026  var invokeCallback = false;1027 1028  if (children === null) {1029    invokeCallback = true;1030  } else {1031    switch (type) {1032      case 'string':1033      case 'number':1034        invokeCallback = true;1035        break;1036 1037      case 'object':1038        switch (children.$$typeof) {1039          case REACT_ELEMENT_TYPE:1040          case REACT_PORTAL_TYPE:1041            invokeCallback = true;1042        }1043 1044    }1045  }1046 1047  if (invokeCallback) {1048    var _child = children;1049    var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array1050    // so that it's consistent if the number of children grows:1051 1052    var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;1053 1054    if (isArray(mappedChild)) {1055      var escapedChildKey = '';1056 1057      if (childKey != null) {1058        escapedChildKey = escapeUserProvidedKey(childKey) + '/';1059      }1060 1061      mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {1062        return c;1063      });1064    } else if (mappedChild != null) {1065      if (isValidElement(mappedChild)) {1066        {1067          // The `if` statement here prevents auto-disabling of the safe1068          // coercion ESLint rule, so we must manually disable it below.1069          // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key1070          if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {1071            checkKeyStringCoercion(mappedChild.key);1072          }1073        }1074 1075        mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as1076        // traverseAllChildren used to do for objects as children1077        escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key1078        mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number1079        // eslint-disable-next-line react-internal/safe-string-coercion1080        escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);1081      }1082 1083      array.push(mappedChild);1084    }1085 1086    return 1;1087  }1088 1089  var child;1090  var nextName;1091  var subtreeCount = 0; // Count of children found in the current subtree.1092 1093  var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;1094 1095  if (isArray(children)) {1096    for (var i = 0; i < children.length; i++) {1097      child = children[i];1098      nextName = nextNamePrefix + getElementKey(child, i);1099      subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);1100    }1101  } else {1102    var iteratorFn = getIteratorFn(children);1103 1104    if (typeof iteratorFn === 'function') {1105      var iterableChildren = children;1106 1107      {1108        // Warn about using Maps as children1109        if (iteratorFn === iterableChildren.entries) {1110          if (!didWarnAboutMaps) {1111            warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');1112          }1113 1114          didWarnAboutMaps = true;1115        }1116      }1117 1118      var iterator = iteratorFn.call(iterableChildren);1119      var step;1120      var ii = 0;1121 1122      while (!(step = iterator.next()).done) {1123        child = step.value;1124        nextName = nextNamePrefix + getElementKey(child, ii++);1125        subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);1126      }1127    } else if (type === 'object') {1128      // eslint-disable-next-line react-internal/safe-string-coercion1129      var childrenString = String(children);1130      throw new Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.');1131    }1132  }1133 1134  return subtreeCount;1135}1136 1137/**1138 * Maps children that are typically specified as `props.children`.1139 *1140 * See https://reactjs.org/docs/react-api.html#reactchildrenmap1141 *1142 * The provided mapFunction(child, index) will be called for each1143 * leaf child.1144 *1145 * @param {?*} children Children tree container.1146 * @param {function(*, int)} func The map function.1147 * @param {*} context Context for mapFunction.1148 * @return {object} Object containing the ordered map of results.1149 */1150function mapChildren(children, func, context) {1151  if (children == null) {1152    return children;1153  }1154 1155  var result = [];1156  var count = 0;1157  mapIntoArray(children, result, '', '', function (child) {1158    return func.call(context, child, count++);1159  });1160  return result;1161}1162/**1163 * Count the number of children that are typically specified as1164 * `props.children`.1165 *1166 * See https://reactjs.org/docs/react-api.html#reactchildrencount1167 *1168 * @param {?*} children Children tree container.1169 * @return {number} The number of children.1170 */1171 1172 1173function countChildren(children) {1174  var n = 0;1175  mapChildren(children, function () {1176    n++; // Don't return anything1177  });1178  return n;1179}1180 1181/**1182 * Iterates through children that are typically specified as `props.children`.1183 *1184 * See https://reactjs.org/docs/react-api.html#reactchildrenforeach1185 *1186 * The provided forEachFunc(child, index) will be called for each1187 * leaf child.1188 *1189 * @param {?*} children Children tree container.1190 * @param {function(*, int)} forEachFunc1191 * @param {*} forEachContext Context for forEachContext.1192 */1193function forEachChildren(children, forEachFunc, forEachContext) {1194  mapChildren(children, function () {1195    forEachFunc.apply(this, arguments); // Don't return anything.1196  }, forEachContext);1197}1198/**1199 * Flatten a children object (typically specified as `props.children`) and1200 * return an array with appropriately re-keyed children.

Showing the first 1,200 of 2741 lines. Download the file for the rest.