UNPKG

104 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3 typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4 (global = global || self, factory(global.ReactRouter = {}, global.React));
5}(this, function (exports, React) { 'use strict';
6
7 var React__default = 'default' in React ? React['default'] : React;
8
9 function _setPrototypeOf(o, p) {
10 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
11 o.__proto__ = p;
12 return o;
13 };
14
15 return _setPrototypeOf(o, p);
16 }
17
18 function _inheritsLoose(subClass, superClass) {
19 subClass.prototype = Object.create(superClass.prototype);
20 subClass.prototype.constructor = subClass;
21 _setPrototypeOf(subClass, superClass);
22 }
23
24 function unwrapExports (x) {
25 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
26 }
27
28 function createCommonjsModule(fn, module) {
29 return module = { exports: {} }, fn(module, module.exports), module.exports;
30 }
31
32 var reactIs_production_min = createCommonjsModule(function (module, exports) {
33 Object.defineProperty(exports,"__esModule",{value:!0});
34 var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
35 60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118;function x(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case t:case r:case d:return u}}}function y(a){return x(a)===m}exports.typeOf=x;exports.AsyncMode=l;
36 exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
37 exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w)};exports.isAsyncMode=function(a){return y(a)||x(a)===l};exports.isConcurrentMode=y;exports.isContextConsumer=function(a){return x(a)===k};exports.isContextProvider=function(a){return x(a)===h};
38 exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return x(a)===n};exports.isFragment=function(a){return x(a)===e};exports.isLazy=function(a){return x(a)===t};exports.isMemo=function(a){return x(a)===r};exports.isPortal=function(a){return x(a)===d};exports.isProfiler=function(a){return x(a)===g};exports.isStrictMode=function(a){return x(a)===f};exports.isSuspense=function(a){return x(a)===p};
39 });
40
41 unwrapExports(reactIs_production_min);
42 var reactIs_production_min_1 = reactIs_production_min.typeOf;
43 var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
44 var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
45 var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
46 var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
47 var reactIs_production_min_6 = reactIs_production_min.Element;
48 var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
49 var reactIs_production_min_8 = reactIs_production_min.Fragment;
50 var reactIs_production_min_9 = reactIs_production_min.Lazy;
51 var reactIs_production_min_10 = reactIs_production_min.Memo;
52 var reactIs_production_min_11 = reactIs_production_min.Portal;
53 var reactIs_production_min_12 = reactIs_production_min.Profiler;
54 var reactIs_production_min_13 = reactIs_production_min.StrictMode;
55 var reactIs_production_min_14 = reactIs_production_min.Suspense;
56 var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
57 var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
58 var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
59 var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
60 var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
61 var reactIs_production_min_20 = reactIs_production_min.isElement;
62 var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
63 var reactIs_production_min_22 = reactIs_production_min.isFragment;
64 var reactIs_production_min_23 = reactIs_production_min.isLazy;
65 var reactIs_production_min_24 = reactIs_production_min.isMemo;
66 var reactIs_production_min_25 = reactIs_production_min.isPortal;
67 var reactIs_production_min_26 = reactIs_production_min.isProfiler;
68 var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
69 var reactIs_production_min_28 = reactIs_production_min.isSuspense;
70
71 var reactIs_development = createCommonjsModule(function (module, exports) {
72
73
74
75 {
76 (function() {
77
78 Object.defineProperty(exports, '__esModule', { value: true });
79
80 // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
81 // nor polyfill, then a plain number is used for performance.
82 var hasSymbol = typeof Symbol === 'function' && Symbol.for;
83
84 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
85 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
86 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
87 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
88 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
89 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
90 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
91 // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
92 // (unstable) APIs that have been removed. Can we remove the symbols?
93 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
94 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
95 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
96 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
97 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
98 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
99 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
100 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
101 var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
102
103 function isValidElementType(type) {
104 return typeof type === 'string' || typeof type === 'function' ||
105 // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
106 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE);
107 }
108
109 /**
110 * Forked from fbjs/warning:
111 * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
112 *
113 * Only change is we use console.warn instead of console.error,
114 * and do nothing when 'console' is not supported.
115 * This really simplifies the code.
116 * ---
117 * Similar to invariant but only logs a warning if the condition is not met.
118 * This can be used to log issues in development environments in critical
119 * paths. Removing the logging code for production environments will keep the
120 * same logic and follow the same code paths.
121 */
122
123 var lowPriorityWarning = function () {};
124
125 {
126 var printWarning = function (format) {
127 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
128 args[_key - 1] = arguments[_key];
129 }
130
131 var argIndex = 0;
132 var message = 'Warning: ' + format.replace(/%s/g, function () {
133 return args[argIndex++];
134 });
135 if (typeof console !== 'undefined') {
136 console.warn(message);
137 }
138 try {
139 // --- Welcome to debugging React ---
140 // This error was thrown as a convenience so that you can use this stack
141 // to find the callsite that caused this warning to fire.
142 throw new Error(message);
143 } catch (x) {}
144 };
145
146 lowPriorityWarning = function (condition, format) {
147 if (format === undefined) {
148 throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
149 }
150 if (!condition) {
151 for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
152 args[_key2 - 2] = arguments[_key2];
153 }
154
155 printWarning.apply(undefined, [format].concat(args));
156 }
157 };
158 }
159
160 var lowPriorityWarning$1 = lowPriorityWarning;
161
162 function typeOf(object) {
163 if (typeof object === 'object' && object !== null) {
164 var $$typeof = object.$$typeof;
165 switch ($$typeof) {
166 case REACT_ELEMENT_TYPE:
167 var type = object.type;
168
169 switch (type) {
170 case REACT_ASYNC_MODE_TYPE:
171 case REACT_CONCURRENT_MODE_TYPE:
172 case REACT_FRAGMENT_TYPE:
173 case REACT_PROFILER_TYPE:
174 case REACT_STRICT_MODE_TYPE:
175 case REACT_SUSPENSE_TYPE:
176 return type;
177 default:
178 var $$typeofType = type && type.$$typeof;
179
180 switch ($$typeofType) {
181 case REACT_CONTEXT_TYPE:
182 case REACT_FORWARD_REF_TYPE:
183 case REACT_PROVIDER_TYPE:
184 return $$typeofType;
185 default:
186 return $$typeof;
187 }
188 }
189 case REACT_LAZY_TYPE:
190 case REACT_MEMO_TYPE:
191 case REACT_PORTAL_TYPE:
192 return $$typeof;
193 }
194 }
195
196 return undefined;
197 }
198
199 // AsyncMode is deprecated along with isAsyncMode
200 var AsyncMode = REACT_ASYNC_MODE_TYPE;
201 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
202 var ContextConsumer = REACT_CONTEXT_TYPE;
203 var ContextProvider = REACT_PROVIDER_TYPE;
204 var Element = REACT_ELEMENT_TYPE;
205 var ForwardRef = REACT_FORWARD_REF_TYPE;
206 var Fragment = REACT_FRAGMENT_TYPE;
207 var Lazy = REACT_LAZY_TYPE;
208 var Memo = REACT_MEMO_TYPE;
209 var Portal = REACT_PORTAL_TYPE;
210 var Profiler = REACT_PROFILER_TYPE;
211 var StrictMode = REACT_STRICT_MODE_TYPE;
212 var Suspense = REACT_SUSPENSE_TYPE;
213
214 var hasWarnedAboutDeprecatedIsAsyncMode = false;
215
216 // AsyncMode should be deprecated
217 function isAsyncMode(object) {
218 {
219 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
220 hasWarnedAboutDeprecatedIsAsyncMode = true;
221 lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
222 }
223 }
224 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
225 }
226 function isConcurrentMode(object) {
227 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
228 }
229 function isContextConsumer(object) {
230 return typeOf(object) === REACT_CONTEXT_TYPE;
231 }
232 function isContextProvider(object) {
233 return typeOf(object) === REACT_PROVIDER_TYPE;
234 }
235 function isElement(object) {
236 return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
237 }
238 function isForwardRef(object) {
239 return typeOf(object) === REACT_FORWARD_REF_TYPE;
240 }
241 function isFragment(object) {
242 return typeOf(object) === REACT_FRAGMENT_TYPE;
243 }
244 function isLazy(object) {
245 return typeOf(object) === REACT_LAZY_TYPE;
246 }
247 function isMemo(object) {
248 return typeOf(object) === REACT_MEMO_TYPE;
249 }
250 function isPortal(object) {
251 return typeOf(object) === REACT_PORTAL_TYPE;
252 }
253 function isProfiler(object) {
254 return typeOf(object) === REACT_PROFILER_TYPE;
255 }
256 function isStrictMode(object) {
257 return typeOf(object) === REACT_STRICT_MODE_TYPE;
258 }
259 function isSuspense(object) {
260 return typeOf(object) === REACT_SUSPENSE_TYPE;
261 }
262
263 exports.typeOf = typeOf;
264 exports.AsyncMode = AsyncMode;
265 exports.ConcurrentMode = ConcurrentMode;
266 exports.ContextConsumer = ContextConsumer;
267 exports.ContextProvider = ContextProvider;
268 exports.Element = Element;
269 exports.ForwardRef = ForwardRef;
270 exports.Fragment = Fragment;
271 exports.Lazy = Lazy;
272 exports.Memo = Memo;
273 exports.Portal = Portal;
274 exports.Profiler = Profiler;
275 exports.StrictMode = StrictMode;
276 exports.Suspense = Suspense;
277 exports.isValidElementType = isValidElementType;
278 exports.isAsyncMode = isAsyncMode;
279 exports.isConcurrentMode = isConcurrentMode;
280 exports.isContextConsumer = isContextConsumer;
281 exports.isContextProvider = isContextProvider;
282 exports.isElement = isElement;
283 exports.isForwardRef = isForwardRef;
284 exports.isFragment = isFragment;
285 exports.isLazy = isLazy;
286 exports.isMemo = isMemo;
287 exports.isPortal = isPortal;
288 exports.isProfiler = isProfiler;
289 exports.isStrictMode = isStrictMode;
290 exports.isSuspense = isSuspense;
291 })();
292 }
293 });
294
295 unwrapExports(reactIs_development);
296 var reactIs_development_1 = reactIs_development.typeOf;
297 var reactIs_development_2 = reactIs_development.AsyncMode;
298 var reactIs_development_3 = reactIs_development.ConcurrentMode;
299 var reactIs_development_4 = reactIs_development.ContextConsumer;
300 var reactIs_development_5 = reactIs_development.ContextProvider;
301 var reactIs_development_6 = reactIs_development.Element;
302 var reactIs_development_7 = reactIs_development.ForwardRef;
303 var reactIs_development_8 = reactIs_development.Fragment;
304 var reactIs_development_9 = reactIs_development.Lazy;
305 var reactIs_development_10 = reactIs_development.Memo;
306 var reactIs_development_11 = reactIs_development.Portal;
307 var reactIs_development_12 = reactIs_development.Profiler;
308 var reactIs_development_13 = reactIs_development.StrictMode;
309 var reactIs_development_14 = reactIs_development.Suspense;
310 var reactIs_development_15 = reactIs_development.isValidElementType;
311 var reactIs_development_16 = reactIs_development.isAsyncMode;
312 var reactIs_development_17 = reactIs_development.isConcurrentMode;
313 var reactIs_development_18 = reactIs_development.isContextConsumer;
314 var reactIs_development_19 = reactIs_development.isContextProvider;
315 var reactIs_development_20 = reactIs_development.isElement;
316 var reactIs_development_21 = reactIs_development.isForwardRef;
317 var reactIs_development_22 = reactIs_development.isFragment;
318 var reactIs_development_23 = reactIs_development.isLazy;
319 var reactIs_development_24 = reactIs_development.isMemo;
320 var reactIs_development_25 = reactIs_development.isPortal;
321 var reactIs_development_26 = reactIs_development.isProfiler;
322 var reactIs_development_27 = reactIs_development.isStrictMode;
323 var reactIs_development_28 = reactIs_development.isSuspense;
324
325 var reactIs = createCommonjsModule(function (module) {
326
327 {
328 module.exports = reactIs_development;
329 }
330 });
331 var reactIs_1 = reactIs.isValidElementType;
332
333 /*
334 object-assign
335 (c) Sindre Sorhus
336 @license MIT
337 */
338 /* eslint-disable no-unused-vars */
339 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
340 var hasOwnProperty = Object.prototype.hasOwnProperty;
341 var propIsEnumerable = Object.prototype.propertyIsEnumerable;
342
343 function toObject(val) {
344 if (val === null || val === undefined) {
345 throw new TypeError('Object.assign cannot be called with null or undefined');
346 }
347
348 return Object(val);
349 }
350
351 function shouldUseNative() {
352 try {
353 if (!Object.assign) {
354 return false;
355 }
356
357 // Detect buggy property enumeration order in older V8 versions.
358
359 // https://bugs.chromium.org/p/v8/issues/detail?id=4118
360 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
361 test1[5] = 'de';
362 if (Object.getOwnPropertyNames(test1)[0] === '5') {
363 return false;
364 }
365
366 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
367 var test2 = {};
368 for (var i = 0; i < 10; i++) {
369 test2['_' + String.fromCharCode(i)] = i;
370 }
371 var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
372 return test2[n];
373 });
374 if (order2.join('') !== '0123456789') {
375 return false;
376 }
377
378 // https://bugs.chromium.org/p/v8/issues/detail?id=3056
379 var test3 = {};
380 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
381 test3[letter] = letter;
382 });
383 if (Object.keys(Object.assign({}, test3)).join('') !==
384 'abcdefghijklmnopqrst') {
385 return false;
386 }
387
388 return true;
389 } catch (err) {
390 // We don't expect any of the above to throw, but better to be safe.
391 return false;
392 }
393 }
394
395 var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
396 var from;
397 var to = toObject(target);
398 var symbols;
399
400 for (var s = 1; s < arguments.length; s++) {
401 from = Object(arguments[s]);
402
403 for (var key in from) {
404 if (hasOwnProperty.call(from, key)) {
405 to[key] = from[key];
406 }
407 }
408
409 if (getOwnPropertySymbols) {
410 symbols = getOwnPropertySymbols(from);
411 for (var i = 0; i < symbols.length; i++) {
412 if (propIsEnumerable.call(from, symbols[i])) {
413 to[symbols[i]] = from[symbols[i]];
414 }
415 }
416 }
417 }
418
419 return to;
420 };
421
422 /**
423 * Copyright (c) 2013-present, Facebook, Inc.
424 *
425 * This source code is licensed under the MIT license found in the
426 * LICENSE file in the root directory of this source tree.
427 */
428
429 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
430
431 var ReactPropTypesSecret_1 = ReactPropTypesSecret;
432
433 var printWarning = function() {};
434
435 {
436 var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
437 var loggedTypeFailures = {};
438 var has = Function.call.bind(Object.prototype.hasOwnProperty);
439
440 printWarning = function(text) {
441 var message = 'Warning: ' + text;
442 if (typeof console !== 'undefined') {
443 console.error(message);
444 }
445 try {
446 // --- Welcome to debugging React ---
447 // This error was thrown as a convenience so that you can use this stack
448 // to find the callsite that caused this warning to fire.
449 throw new Error(message);
450 } catch (x) {}
451 };
452 }
453
454 /**
455 * Assert that the values match with the type specs.
456 * Error messages are memorized and will only be shown once.
457 *
458 * @param {object} typeSpecs Map of name to a ReactPropType
459 * @param {object} values Runtime values that need to be type-checked
460 * @param {string} location e.g. "prop", "context", "child context"
461 * @param {string} componentName Name of the component for error messages.
462 * @param {?Function} getStack Returns the component stack.
463 * @private
464 */
465 function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
466 {
467 for (var typeSpecName in typeSpecs) {
468 if (has(typeSpecs, typeSpecName)) {
469 var error;
470 // Prop type validation may throw. In case they do, we don't want to
471 // fail the render phase where it didn't fail before. So we log it.
472 // After these have been cleaned up, we'll let them throw.
473 try {
474 // This is intentionally an invariant that gets caught. It's the same
475 // behavior as without this statement except with a better message.
476 if (typeof typeSpecs[typeSpecName] !== 'function') {
477 var err = Error(
478 (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
479 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
480 );
481 err.name = 'Invariant Violation';
482 throw err;
483 }
484 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
485 } catch (ex) {
486 error = ex;
487 }
488 if (error && !(error instanceof Error)) {
489 printWarning(
490 (componentName || 'React class') + ': type specification of ' +
491 location + ' `' + typeSpecName + '` is invalid; the type checker ' +
492 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
493 'You may have forgotten to pass an argument to the type checker ' +
494 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
495 'shape all require an argument).'
496 );
497 }
498 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
499 // Only monitor this failure once because there tends to be a lot of the
500 // same error.
501 loggedTypeFailures[error.message] = true;
502
503 var stack = getStack ? getStack() : '';
504
505 printWarning(
506 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
507 );
508 }
509 }
510 }
511 }
512 }
513
514 /**
515 * Resets warning cache when testing.
516 *
517 * @private
518 */
519 checkPropTypes.resetWarningCache = function() {
520 {
521 loggedTypeFailures = {};
522 }
523 };
524
525 var checkPropTypes_1 = checkPropTypes;
526
527 var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
528 var printWarning$1 = function() {};
529
530 {
531 printWarning$1 = function(text) {
532 var message = 'Warning: ' + text;
533 if (typeof console !== 'undefined') {
534 console.error(message);
535 }
536 try {
537 // --- Welcome to debugging React ---
538 // This error was thrown as a convenience so that you can use this stack
539 // to find the callsite that caused this warning to fire.
540 throw new Error(message);
541 } catch (x) {}
542 };
543 }
544
545 function emptyFunctionThatReturnsNull() {
546 return null;
547 }
548
549 var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
550 /* global Symbol */
551 var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
552 var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
553
554 /**
555 * Returns the iterator method function contained on the iterable object.
556 *
557 * Be sure to invoke the function with the iterable as context:
558 *
559 * var iteratorFn = getIteratorFn(myIterable);
560 * if (iteratorFn) {
561 * var iterator = iteratorFn.call(myIterable);
562 * ...
563 * }
564 *
565 * @param {?object} maybeIterable
566 * @return {?function}
567 */
568 function getIteratorFn(maybeIterable) {
569 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
570 if (typeof iteratorFn === 'function') {
571 return iteratorFn;
572 }
573 }
574
575 /**
576 * Collection of methods that allow declaration and validation of props that are
577 * supplied to React components. Example usage:
578 *
579 * var Props = require('ReactPropTypes');
580 * var MyArticle = React.createClass({
581 * propTypes: {
582 * // An optional string prop named "description".
583 * description: Props.string,
584 *
585 * // A required enum prop named "category".
586 * category: Props.oneOf(['News','Photos']).isRequired,
587 *
588 * // A prop named "dialog" that requires an instance of Dialog.
589 * dialog: Props.instanceOf(Dialog).isRequired
590 * },
591 * render: function() { ... }
592 * });
593 *
594 * A more formal specification of how these methods are used:
595 *
596 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
597 * decl := ReactPropTypes.{type}(.isRequired)?
598 *
599 * Each and every declaration produces a function with the same signature. This
600 * allows the creation of custom validation functions. For example:
601 *
602 * var MyLink = React.createClass({
603 * propTypes: {
604 * // An optional string or URI prop named "href".
605 * href: function(props, propName, componentName) {
606 * var propValue = props[propName];
607 * if (propValue != null && typeof propValue !== 'string' &&
608 * !(propValue instanceof URI)) {
609 * return new Error(
610 * 'Expected a string or an URI for ' + propName + ' in ' +
611 * componentName
612 * );
613 * }
614 * }
615 * },
616 * render: function() {...}
617 * });
618 *
619 * @internal
620 */
621
622 var ANONYMOUS = '<<anonymous>>';
623
624 // Important!
625 // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
626 var ReactPropTypes = {
627 array: createPrimitiveTypeChecker('array'),
628 bool: createPrimitiveTypeChecker('boolean'),
629 func: createPrimitiveTypeChecker('function'),
630 number: createPrimitiveTypeChecker('number'),
631 object: createPrimitiveTypeChecker('object'),
632 string: createPrimitiveTypeChecker('string'),
633 symbol: createPrimitiveTypeChecker('symbol'),
634
635 any: createAnyTypeChecker(),
636 arrayOf: createArrayOfTypeChecker,
637 element: createElementTypeChecker(),
638 elementType: createElementTypeTypeChecker(),
639 instanceOf: createInstanceTypeChecker,
640 node: createNodeChecker(),
641 objectOf: createObjectOfTypeChecker,
642 oneOf: createEnumTypeChecker,
643 oneOfType: createUnionTypeChecker,
644 shape: createShapeTypeChecker,
645 exact: createStrictShapeTypeChecker,
646 };
647
648 /**
649 * inlined Object.is polyfill to avoid requiring consumers ship their own
650 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
651 */
652 /*eslint-disable no-self-compare*/
653 function is(x, y) {
654 // SameValue algorithm
655 if (x === y) {
656 // Steps 1-5, 7-10
657 // Steps 6.b-6.e: +0 != -0
658 return x !== 0 || 1 / x === 1 / y;
659 } else {
660 // Step 6.a: NaN == NaN
661 return x !== x && y !== y;
662 }
663 }
664 /*eslint-enable no-self-compare*/
665
666 /**
667 * We use an Error-like object for backward compatibility as people may call
668 * PropTypes directly and inspect their output. However, we don't use real
669 * Errors anymore. We don't inspect their stack anyway, and creating them
670 * is prohibitively expensive if they are created too often, such as what
671 * happens in oneOfType() for any type before the one that matched.
672 */
673 function PropTypeError(message) {
674 this.message = message;
675 this.stack = '';
676 }
677 // Make `instanceof Error` still work for returned errors.
678 PropTypeError.prototype = Error.prototype;
679
680 function createChainableTypeChecker(validate) {
681 {
682 var manualPropTypeCallCache = {};
683 var manualPropTypeWarningCount = 0;
684 }
685 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
686 componentName = componentName || ANONYMOUS;
687 propFullName = propFullName || propName;
688
689 if (secret !== ReactPropTypesSecret_1) {
690 if (throwOnDirectAccess) {
691 // New behavior only for users of `prop-types` package
692 var err = new Error(
693 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
694 'Use `PropTypes.checkPropTypes()` to call them. ' +
695 'Read more at http://fb.me/use-check-prop-types'
696 );
697 err.name = 'Invariant Violation';
698 throw err;
699 } else if ( typeof console !== 'undefined') {
700 // Old behavior for people using React.PropTypes
701 var cacheKey = componentName + ':' + propName;
702 if (
703 !manualPropTypeCallCache[cacheKey] &&
704 // Avoid spamming the console because they are often not actionable except for lib authors
705 manualPropTypeWarningCount < 3
706 ) {
707 printWarning$1(
708 'You are manually calling a React.PropTypes validation ' +
709 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
710 'and will throw in the standalone `prop-types` package. ' +
711 'You may be seeing this warning due to a third-party PropTypes ' +
712 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
713 );
714 manualPropTypeCallCache[cacheKey] = true;
715 manualPropTypeWarningCount++;
716 }
717 }
718 }
719 if (props[propName] == null) {
720 if (isRequired) {
721 if (props[propName] === null) {
722 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
723 }
724 return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
725 }
726 return null;
727 } else {
728 return validate(props, propName, componentName, location, propFullName);
729 }
730 }
731
732 var chainedCheckType = checkType.bind(null, false);
733 chainedCheckType.isRequired = checkType.bind(null, true);
734
735 return chainedCheckType;
736 }
737
738 function createPrimitiveTypeChecker(expectedType) {
739 function validate(props, propName, componentName, location, propFullName, secret) {
740 var propValue = props[propName];
741 var propType = getPropType(propValue);
742 if (propType !== expectedType) {
743 // `propValue` being instance of, say, date/regexp, pass the 'object'
744 // check, but we can offer a more precise error message here rather than
745 // 'of type `object`'.
746 var preciseType = getPreciseType(propValue);
747
748 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
749 }
750 return null;
751 }
752 return createChainableTypeChecker(validate);
753 }
754
755 function createAnyTypeChecker() {
756 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
757 }
758
759 function createArrayOfTypeChecker(typeChecker) {
760 function validate(props, propName, componentName, location, propFullName) {
761 if (typeof typeChecker !== 'function') {
762 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
763 }
764 var propValue = props[propName];
765 if (!Array.isArray(propValue)) {
766 var propType = getPropType(propValue);
767 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
768 }
769 for (var i = 0; i < propValue.length; i++) {
770 var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
771 if (error instanceof Error) {
772 return error;
773 }
774 }
775 return null;
776 }
777 return createChainableTypeChecker(validate);
778 }
779
780 function createElementTypeChecker() {
781 function validate(props, propName, componentName, location, propFullName) {
782 var propValue = props[propName];
783 if (!isValidElement(propValue)) {
784 var propType = getPropType(propValue);
785 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
786 }
787 return null;
788 }
789 return createChainableTypeChecker(validate);
790 }
791
792 function createElementTypeTypeChecker() {
793 function validate(props, propName, componentName, location, propFullName) {
794 var propValue = props[propName];
795 if (!reactIs.isValidElementType(propValue)) {
796 var propType = getPropType(propValue);
797 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
798 }
799 return null;
800 }
801 return createChainableTypeChecker(validate);
802 }
803
804 function createInstanceTypeChecker(expectedClass) {
805 function validate(props, propName, componentName, location, propFullName) {
806 if (!(props[propName] instanceof expectedClass)) {
807 var expectedClassName = expectedClass.name || ANONYMOUS;
808 var actualClassName = getClassName(props[propName]);
809 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
810 }
811 return null;
812 }
813 return createChainableTypeChecker(validate);
814 }
815
816 function createEnumTypeChecker(expectedValues) {
817 if (!Array.isArray(expectedValues)) {
818 {
819 if (arguments.length > 1) {
820 printWarning$1(
821 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
822 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
823 );
824 } else {
825 printWarning$1('Invalid argument supplied to oneOf, expected an array.');
826 }
827 }
828 return emptyFunctionThatReturnsNull;
829 }
830
831 function validate(props, propName, componentName, location, propFullName) {
832 var propValue = props[propName];
833 for (var i = 0; i < expectedValues.length; i++) {
834 if (is(propValue, expectedValues[i])) {
835 return null;
836 }
837 }
838
839 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
840 var type = getPreciseType(value);
841 if (type === 'symbol') {
842 return String(value);
843 }
844 return value;
845 });
846 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
847 }
848 return createChainableTypeChecker(validate);
849 }
850
851 function createObjectOfTypeChecker(typeChecker) {
852 function validate(props, propName, componentName, location, propFullName) {
853 if (typeof typeChecker !== 'function') {
854 return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
855 }
856 var propValue = props[propName];
857 var propType = getPropType(propValue);
858 if (propType !== 'object') {
859 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
860 }
861 for (var key in propValue) {
862 if (has$1(propValue, key)) {
863 var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
864 if (error instanceof Error) {
865 return error;
866 }
867 }
868 }
869 return null;
870 }
871 return createChainableTypeChecker(validate);
872 }
873
874 function createUnionTypeChecker(arrayOfTypeCheckers) {
875 if (!Array.isArray(arrayOfTypeCheckers)) {
876 printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') ;
877 return emptyFunctionThatReturnsNull;
878 }
879
880 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
881 var checker = arrayOfTypeCheckers[i];
882 if (typeof checker !== 'function') {
883 printWarning$1(
884 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
885 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
886 );
887 return emptyFunctionThatReturnsNull;
888 }
889 }
890
891 function validate(props, propName, componentName, location, propFullName) {
892 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
893 var checker = arrayOfTypeCheckers[i];
894 if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
895 return null;
896 }
897 }
898
899 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
900 }
901 return createChainableTypeChecker(validate);
902 }
903
904 function createNodeChecker() {
905 function validate(props, propName, componentName, location, propFullName) {
906 if (!isNode(props[propName])) {
907 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
908 }
909 return null;
910 }
911 return createChainableTypeChecker(validate);
912 }
913
914 function createShapeTypeChecker(shapeTypes) {
915 function validate(props, propName, componentName, location, propFullName) {
916 var propValue = props[propName];
917 var propType = getPropType(propValue);
918 if (propType !== 'object') {
919 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
920 }
921 for (var key in shapeTypes) {
922 var checker = shapeTypes[key];
923 if (!checker) {
924 continue;
925 }
926 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
927 if (error) {
928 return error;
929 }
930 }
931 return null;
932 }
933 return createChainableTypeChecker(validate);
934 }
935
936 function createStrictShapeTypeChecker(shapeTypes) {
937 function validate(props, propName, componentName, location, propFullName) {
938 var propValue = props[propName];
939 var propType = getPropType(propValue);
940 if (propType !== 'object') {
941 return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
942 }
943 // We need to check all keys in case some are required but missing from
944 // props.
945 var allKeys = objectAssign({}, props[propName], shapeTypes);
946 for (var key in allKeys) {
947 var checker = shapeTypes[key];
948 if (!checker) {
949 return new PropTypeError(
950 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
951 '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
952 '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
953 );
954 }
955 var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
956 if (error) {
957 return error;
958 }
959 }
960 return null;
961 }
962
963 return createChainableTypeChecker(validate);
964 }
965
966 function isNode(propValue) {
967 switch (typeof propValue) {
968 case 'number':
969 case 'string':
970 case 'undefined':
971 return true;
972 case 'boolean':
973 return !propValue;
974 case 'object':
975 if (Array.isArray(propValue)) {
976 return propValue.every(isNode);
977 }
978 if (propValue === null || isValidElement(propValue)) {
979 return true;
980 }
981
982 var iteratorFn = getIteratorFn(propValue);
983 if (iteratorFn) {
984 var iterator = iteratorFn.call(propValue);
985 var step;
986 if (iteratorFn !== propValue.entries) {
987 while (!(step = iterator.next()).done) {
988 if (!isNode(step.value)) {
989 return false;
990 }
991 }
992 } else {
993 // Iterator will provide entry [k,v] tuples rather than values.
994 while (!(step = iterator.next()).done) {
995 var entry = step.value;
996 if (entry) {
997 if (!isNode(entry[1])) {
998 return false;
999 }
1000 }
1001 }
1002 }
1003 } else {
1004 return false;
1005 }
1006
1007 return true;
1008 default:
1009 return false;
1010 }
1011 }
1012
1013 function isSymbol(propType, propValue) {
1014 // Native Symbol.
1015 if (propType === 'symbol') {
1016 return true;
1017 }
1018
1019 // falsy value can't be a Symbol
1020 if (!propValue) {
1021 return false;
1022 }
1023
1024 // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1025 if (propValue['@@toStringTag'] === 'Symbol') {
1026 return true;
1027 }
1028
1029 // Fallback for non-spec compliant Symbols which are polyfilled.
1030 if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1031 return true;
1032 }
1033
1034 return false;
1035 }
1036
1037 // Equivalent of `typeof` but with special handling for array and regexp.
1038 function getPropType(propValue) {
1039 var propType = typeof propValue;
1040 if (Array.isArray(propValue)) {
1041 return 'array';
1042 }
1043 if (propValue instanceof RegExp) {
1044 // Old webkits (at least until Android 4.0) return 'function' rather than
1045 // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1046 // passes PropTypes.object.
1047 return 'object';
1048 }
1049 if (isSymbol(propType, propValue)) {
1050 return 'symbol';
1051 }
1052 return propType;
1053 }
1054
1055 // This handles more types than `getPropType`. Only used for error messages.
1056 // See `createPrimitiveTypeChecker`.
1057 function getPreciseType(propValue) {
1058 if (typeof propValue === 'undefined' || propValue === null) {
1059 return '' + propValue;
1060 }
1061 var propType = getPropType(propValue);
1062 if (propType === 'object') {
1063 if (propValue instanceof Date) {
1064 return 'date';
1065 } else if (propValue instanceof RegExp) {
1066 return 'regexp';
1067 }
1068 }
1069 return propType;
1070 }
1071
1072 // Returns a string that is postfixed to a warning about an invalid type.
1073 // For example, "undefined" or "of type array"
1074 function getPostfixForTypeWarning(value) {
1075 var type = getPreciseType(value);
1076 switch (type) {
1077 case 'array':
1078 case 'object':
1079 return 'an ' + type;
1080 case 'boolean':
1081 case 'date':
1082 case 'regexp':
1083 return 'a ' + type;
1084 default:
1085 return type;
1086 }
1087 }
1088
1089 // Returns class name of the object, if any.
1090 function getClassName(propValue) {
1091 if (!propValue.constructor || !propValue.constructor.name) {
1092 return ANONYMOUS;
1093 }
1094 return propValue.constructor.name;
1095 }
1096
1097 ReactPropTypes.checkPropTypes = checkPropTypes_1;
1098 ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
1099 ReactPropTypes.PropTypes = ReactPropTypes;
1100
1101 return ReactPropTypes;
1102 };
1103
1104 var propTypes = createCommonjsModule(function (module) {
1105 /**
1106 * Copyright (c) 2013-present, Facebook, Inc.
1107 *
1108 * This source code is licensed under the MIT license found in the
1109 * LICENSE file in the root directory of this source tree.
1110 */
1111
1112 {
1113 var ReactIs = reactIs;
1114
1115 // By explicitly using `prop-types` you are opting into new development behavior.
1116 // http://fb.me/prop-types-in-prod
1117 var throwOnDirectAccess = true;
1118 module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
1119 }
1120 });
1121
1122 function _extends() {
1123 _extends = Object.assign || function (target) {
1124 for (var i = 1; i < arguments.length; i++) {
1125 var source = arguments[i];
1126
1127 for (var key in source) {
1128 if (Object.prototype.hasOwnProperty.call(source, key)) {
1129 target[key] = source[key];
1130 }
1131 }
1132 }
1133
1134 return target;
1135 };
1136
1137 return _extends.apply(this, arguments);
1138 }
1139
1140 function isAbsolute(pathname) {
1141 return pathname.charAt(0) === '/';
1142 }
1143
1144 // About 1.5x faster than the two-arg version of Array#splice()
1145 function spliceOne(list, index) {
1146 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
1147 list[i] = list[k];
1148 }
1149
1150 list.pop();
1151 }
1152
1153 // This implementation is based heavily on node's url.parse
1154 function resolvePathname(to) {
1155 var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1156
1157 var toParts = to && to.split('/') || [];
1158 var fromParts = from && from.split('/') || [];
1159
1160 var isToAbs = to && isAbsolute(to);
1161 var isFromAbs = from && isAbsolute(from);
1162 var mustEndAbs = isToAbs || isFromAbs;
1163
1164 if (to && isAbsolute(to)) {
1165 // to is absolute
1166 fromParts = toParts;
1167 } else if (toParts.length) {
1168 // to is relative, drop the filename
1169 fromParts.pop();
1170 fromParts = fromParts.concat(toParts);
1171 }
1172
1173 if (!fromParts.length) return '/';
1174
1175 var hasTrailingSlash = void 0;
1176 if (fromParts.length) {
1177 var last = fromParts[fromParts.length - 1];
1178 hasTrailingSlash = last === '.' || last === '..' || last === '';
1179 } else {
1180 hasTrailingSlash = false;
1181 }
1182
1183 var up = 0;
1184 for (var i = fromParts.length; i >= 0; i--) {
1185 var part = fromParts[i];
1186
1187 if (part === '.') {
1188 spliceOne(fromParts, i);
1189 } else if (part === '..') {
1190 spliceOne(fromParts, i);
1191 up++;
1192 } else if (up) {
1193 spliceOne(fromParts, i);
1194 up--;
1195 }
1196 }
1197
1198 if (!mustEndAbs) for (; up--; up) {
1199 fromParts.unshift('..');
1200 }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift('');
1201
1202 var result = fromParts.join('/');
1203
1204 if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
1205
1206 return result;
1207 }
1208
1209 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1210
1211 function valueEqual(a, b) {
1212 if (a === b) return true;
1213
1214 if (a == null || b == null) return false;
1215
1216 if (Array.isArray(a)) {
1217 return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
1218 return valueEqual(item, b[index]);
1219 });
1220 }
1221
1222 var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a);
1223 var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b);
1224
1225 if (aType !== bType) return false;
1226
1227 if (aType === 'object') {
1228 var aValue = a.valueOf();
1229 var bValue = b.valueOf();
1230
1231 if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
1232
1233 var aKeys = Object.keys(a);
1234 var bKeys = Object.keys(b);
1235
1236 if (aKeys.length !== bKeys.length) return false;
1237
1238 return aKeys.every(function (key) {
1239 return valueEqual(a[key], b[key]);
1240 });
1241 }
1242
1243 return false;
1244 }
1245
1246 function warning(condition, message) {
1247 {
1248 if (condition) {
1249 return;
1250 }
1251
1252 var text = "Warning: " + message;
1253
1254 if (typeof console !== 'undefined') {
1255 console.warn(text);
1256 }
1257
1258 try {
1259 throw Error(text);
1260 } catch (x) {}
1261 }
1262 }
1263
1264 var prefix = 'Invariant failed';
1265 function invariant(condition, message) {
1266 if (condition) {
1267 return;
1268 }
1269
1270 {
1271 throw new Error(prefix + ": " + (message || ''));
1272 }
1273 }
1274
1275 function parsePath(path) {
1276 var pathname = path || '/';
1277 var search = '';
1278 var hash = '';
1279 var hashIndex = pathname.indexOf('#');
1280
1281 if (hashIndex !== -1) {
1282 hash = pathname.substr(hashIndex);
1283 pathname = pathname.substr(0, hashIndex);
1284 }
1285
1286 var searchIndex = pathname.indexOf('?');
1287
1288 if (searchIndex !== -1) {
1289 search = pathname.substr(searchIndex);
1290 pathname = pathname.substr(0, searchIndex);
1291 }
1292
1293 return {
1294 pathname: pathname,
1295 search: search === '?' ? '' : search,
1296 hash: hash === '#' ? '' : hash
1297 };
1298 }
1299 function createPath(location) {
1300 var pathname = location.pathname,
1301 search = location.search,
1302 hash = location.hash;
1303 var path = pathname || '/';
1304 if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
1305 if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
1306 return path;
1307 }
1308
1309 function createLocation(path, state, key, currentLocation) {
1310 var location;
1311
1312 if (typeof path === 'string') {
1313 // Two-arg form: push(path, state)
1314 location = parsePath(path);
1315 location.state = state;
1316 } else {
1317 // One-arg form: push(location)
1318 location = _extends({}, path);
1319 if (location.pathname === undefined) location.pathname = '';
1320
1321 if (location.search) {
1322 if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
1323 } else {
1324 location.search = '';
1325 }
1326
1327 if (location.hash) {
1328 if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
1329 } else {
1330 location.hash = '';
1331 }
1332
1333 if (state !== undefined && location.state === undefined) location.state = state;
1334 }
1335
1336 try {
1337 location.pathname = decodeURI(location.pathname);
1338 } catch (e) {
1339 if (e instanceof URIError) {
1340 throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
1341 } else {
1342 throw e;
1343 }
1344 }
1345
1346 if (key) location.key = key;
1347
1348 if (currentLocation) {
1349 // Resolve incomplete/relative pathname relative to current location.
1350 if (!location.pathname) {
1351 location.pathname = currentLocation.pathname;
1352 } else if (location.pathname.charAt(0) !== '/') {
1353 location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
1354 }
1355 } else {
1356 // When there is no prior location and pathname is empty, set it to /
1357 if (!location.pathname) {
1358 location.pathname = '/';
1359 }
1360 }
1361
1362 return location;
1363 }
1364 function locationsAreEqual(a, b) {
1365 return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);
1366 }
1367
1368 function createTransitionManager() {
1369 var prompt = null;
1370
1371 function setPrompt(nextPrompt) {
1372 warning(prompt == null, 'A history supports only one prompt at a time') ;
1373 prompt = nextPrompt;
1374 return function () {
1375 if (prompt === nextPrompt) prompt = null;
1376 };
1377 }
1378
1379 function confirmTransitionTo(location, action, getUserConfirmation, callback) {
1380 // TODO: If another transition starts while we're still confirming
1381 // the previous one, we may end up in a weird state. Figure out the
1382 // best way to handle this.
1383 if (prompt != null) {
1384 var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
1385
1386 if (typeof result === 'string') {
1387 if (typeof getUserConfirmation === 'function') {
1388 getUserConfirmation(result, callback);
1389 } else {
1390 warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message') ;
1391 callback(true);
1392 }
1393 } else {
1394 // Return false from a transition hook to cancel the transition.
1395 callback(result !== false);
1396 }
1397 } else {
1398 callback(true);
1399 }
1400 }
1401
1402 var listeners = [];
1403
1404 function appendListener(fn) {
1405 var isActive = true;
1406
1407 function listener() {
1408 if (isActive) fn.apply(void 0, arguments);
1409 }
1410
1411 listeners.push(listener);
1412 return function () {
1413 isActive = false;
1414 listeners = listeners.filter(function (item) {
1415 return item !== listener;
1416 });
1417 };
1418 }
1419
1420 function notifyListeners() {
1421 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1422 args[_key] = arguments[_key];
1423 }
1424
1425 listeners.forEach(function (listener) {
1426 return listener.apply(void 0, args);
1427 });
1428 }
1429
1430 return {
1431 setPrompt: setPrompt,
1432 confirmTransitionTo: confirmTransitionTo,
1433 appendListener: appendListener,
1434 notifyListeners: notifyListeners
1435 };
1436 }
1437
1438 var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
1439
1440 function clamp(n, lowerBound, upperBound) {
1441 return Math.min(Math.max(n, lowerBound), upperBound);
1442 }
1443 /**
1444 * Creates a history object that stores locations in memory.
1445 */
1446
1447
1448 function createMemoryHistory(props) {
1449 if (props === void 0) {
1450 props = {};
1451 }
1452
1453 var _props = props,
1454 getUserConfirmation = _props.getUserConfirmation,
1455 _props$initialEntries = _props.initialEntries,
1456 initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,
1457 _props$initialIndex = _props.initialIndex,
1458 initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,
1459 _props$keyLength = _props.keyLength,
1460 keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
1461 var transitionManager = createTransitionManager();
1462
1463 function setState(nextState) {
1464 _extends(history, nextState);
1465
1466 history.length = history.entries.length;
1467 transitionManager.notifyListeners(history.location, history.action);
1468 }
1469
1470 function createKey() {
1471 return Math.random().toString(36).substr(2, keyLength);
1472 }
1473
1474 var index = clamp(initialIndex, 0, initialEntries.length - 1);
1475 var entries = initialEntries.map(function (entry) {
1476 return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());
1477 }); // Public interface
1478
1479 var createHref = createPath;
1480
1481 function push(path, state) {
1482 warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') ;
1483 var action = 'PUSH';
1484 var location = createLocation(path, state, createKey(), history.location);
1485 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1486 if (!ok) return;
1487 var prevIndex = history.index;
1488 var nextIndex = prevIndex + 1;
1489 var nextEntries = history.entries.slice(0);
1490
1491 if (nextEntries.length > nextIndex) {
1492 nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
1493 } else {
1494 nextEntries.push(location);
1495 }
1496
1497 setState({
1498 action: action,
1499 location: location,
1500 index: nextIndex,
1501 entries: nextEntries
1502 });
1503 });
1504 }
1505
1506 function replace(path, state) {
1507 warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') ;
1508 var action = 'REPLACE';
1509 var location = createLocation(path, state, createKey(), history.location);
1510 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1511 if (!ok) return;
1512 history.entries[history.index] = location;
1513 setState({
1514 action: action,
1515 location: location
1516 });
1517 });
1518 }
1519
1520 function go(n) {
1521 var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
1522 var action = 'POP';
1523 var location = history.entries[nextIndex];
1524 transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1525 if (ok) {
1526 setState({
1527 action: action,
1528 location: location,
1529 index: nextIndex
1530 });
1531 } else {
1532 // Mimic the behavior of DOM histories by
1533 // causing a render after a cancelled POP.
1534 setState();
1535 }
1536 });
1537 }
1538
1539 function goBack() {
1540 go(-1);
1541 }
1542
1543 function goForward() {
1544 go(1);
1545 }
1546
1547 function canGo(n) {
1548 var nextIndex = history.index + n;
1549 return nextIndex >= 0 && nextIndex < history.entries.length;
1550 }
1551
1552 function block(prompt) {
1553 if (prompt === void 0) {
1554 prompt = false;
1555 }
1556
1557 return transitionManager.setPrompt(prompt);
1558 }
1559
1560 function listen(listener) {
1561 return transitionManager.appendListener(listener);
1562 }
1563
1564 var history = {
1565 length: entries.length,
1566 action: 'POP',
1567 location: entries[index],
1568 index: index,
1569 entries: entries,
1570 createHref: createHref,
1571 push: push,
1572 replace: replace,
1573 go: go,
1574 goBack: goBack,
1575 goForward: goForward,
1576 canGo: canGo,
1577 block: block,
1578 listen: listen
1579 };
1580 return history;
1581 }
1582
1583 var MAX_SIGNED_31_BIT_INT = 1073741823;
1584 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
1585
1586 function getUniqueId() {
1587 var key = '__global_unique_id__';
1588 return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
1589 }
1590
1591 function objectIs(x, y) {
1592 if (x === y) {
1593 return x !== 0 || 1 / x === 1 / y;
1594 } else {
1595 return x !== x && y !== y;
1596 }
1597 }
1598
1599 function createEventEmitter(value) {
1600 var handlers = [];
1601 return {
1602 on: function on(handler) {
1603 handlers.push(handler);
1604 },
1605 off: function off(handler) {
1606 handlers = handlers.filter(function (h) {
1607 return h !== handler;
1608 });
1609 },
1610 get: function get() {
1611 return value;
1612 },
1613 set: function set(newValue, changedBits) {
1614 value = newValue;
1615 handlers.forEach(function (handler) {
1616 return handler(value, changedBits);
1617 });
1618 }
1619 };
1620 }
1621
1622 function onlyChild(children) {
1623 return Array.isArray(children) ? children[0] : children;
1624 }
1625
1626 function createReactContext(defaultValue, calculateChangedBits) {
1627 var _Provider$childContex, _Consumer$contextType;
1628
1629 var contextProp = '__create-react-context-' + getUniqueId() + '__';
1630
1631 var Provider = /*#__PURE__*/function (_Component) {
1632 _inheritsLoose(Provider, _Component);
1633
1634 function Provider() {
1635 var _this;
1636
1637 _this = _Component.apply(this, arguments) || this;
1638 _this.emitter = createEventEmitter(_this.props.value);
1639 return _this;
1640 }
1641
1642 var _proto = Provider.prototype;
1643
1644 _proto.getChildContext = function getChildContext() {
1645 var _ref;
1646
1647 return _ref = {}, _ref[contextProp] = this.emitter, _ref;
1648 };
1649
1650 _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
1651 if (this.props.value !== nextProps.value) {
1652 var oldValue = this.props.value;
1653 var newValue = nextProps.value;
1654 var changedBits;
1655
1656 if (objectIs(oldValue, newValue)) {
1657 changedBits = 0;
1658 } else {
1659 changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
1660
1661 {
1662 warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);
1663 }
1664
1665 changedBits |= 0;
1666
1667 if (changedBits !== 0) {
1668 this.emitter.set(nextProps.value, changedBits);
1669 }
1670 }
1671 }
1672 };
1673
1674 _proto.render = function render() {
1675 return this.props.children;
1676 };
1677
1678 return Provider;
1679 }(React.Component);
1680
1681 Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = propTypes.object.isRequired, _Provider$childContex);
1682
1683 var Consumer = /*#__PURE__*/function (_Component2) {
1684 _inheritsLoose(Consumer, _Component2);
1685
1686 function Consumer() {
1687 var _this2;
1688
1689 _this2 = _Component2.apply(this, arguments) || this;
1690 _this2.state = {
1691 value: _this2.getValue()
1692 };
1693
1694 _this2.onUpdate = function (newValue, changedBits) {
1695 var observedBits = _this2.observedBits | 0;
1696
1697 if ((observedBits & changedBits) !== 0) {
1698 _this2.setState({
1699 value: _this2.getValue()
1700 });
1701 }
1702 };
1703
1704 return _this2;
1705 }
1706
1707 var _proto2 = Consumer.prototype;
1708
1709 _proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
1710 var observedBits = nextProps.observedBits;
1711 this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
1712 };
1713
1714 _proto2.componentDidMount = function componentDidMount() {
1715 if (this.context[contextProp]) {
1716 this.context[contextProp].on(this.onUpdate);
1717 }
1718
1719 var observedBits = this.props.observedBits;
1720 this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
1721 };
1722
1723 _proto2.componentWillUnmount = function componentWillUnmount() {
1724 if (this.context[contextProp]) {
1725 this.context[contextProp].off(this.onUpdate);
1726 }
1727 };
1728
1729 _proto2.getValue = function getValue() {
1730 if (this.context[contextProp]) {
1731 return this.context[contextProp].get();
1732 } else {
1733 return defaultValue;
1734 }
1735 };
1736
1737 _proto2.render = function render() {
1738 return onlyChild(this.props.children)(this.state.value);
1739 };
1740
1741 return Consumer;
1742 }(React.Component);
1743
1744 Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = propTypes.object, _Consumer$contextType);
1745 return {
1746 Provider: Provider,
1747 Consumer: Consumer
1748 };
1749 }
1750
1751 var index = React__default.createContext || createReactContext;
1752
1753 // TODO: Replace with React.createContext once we can assume React 16+
1754
1755 var createNamedContext = function createNamedContext(name) {
1756 var context = index();
1757 context.displayName = name;
1758 return context;
1759 };
1760
1761 var historyContext = /*#__PURE__*/createNamedContext("Router-History");
1762
1763 var context = /*#__PURE__*/createNamedContext("Router");
1764
1765 /**
1766 * The public API for putting history on context.
1767 */
1768
1769 var Router = /*#__PURE__*/function (_React$Component) {
1770 _inheritsLoose(Router, _React$Component);
1771
1772 Router.computeRootMatch = function computeRootMatch(pathname) {
1773 return {
1774 path: "/",
1775 url: "/",
1776 params: {},
1777 isExact: pathname === "/"
1778 };
1779 };
1780
1781 function Router(props) {
1782 var _this;
1783
1784 _this = _React$Component.call(this, props) || this;
1785 _this.state = {
1786 location: props.history.location
1787 }; // This is a bit of a hack. We have to start listening for location
1788 // changes here in the constructor in case there are any <Redirect>s
1789 // on the initial render. If there are, they will replace/push when
1790 // they mount and since cDM fires in children before parents, we may
1791 // get a new location before the <Router> is mounted.
1792
1793 _this._isMounted = false;
1794 _this._pendingLocation = null;
1795
1796 if (!props.staticContext) {
1797 _this.unlisten = props.history.listen(function (location) {
1798 if (_this._isMounted) {
1799 _this.setState({
1800 location: location
1801 });
1802 } else {
1803 _this._pendingLocation = location;
1804 }
1805 });
1806 }
1807
1808 return _this;
1809 }
1810
1811 var _proto = Router.prototype;
1812
1813 _proto.componentDidMount = function componentDidMount() {
1814 this._isMounted = true;
1815
1816 if (this._pendingLocation) {
1817 this.setState({
1818 location: this._pendingLocation
1819 });
1820 }
1821 };
1822
1823 _proto.componentWillUnmount = function componentWillUnmount() {
1824 if (this.unlisten) {
1825 this.unlisten();
1826 this._isMounted = false;
1827 this._pendingLocation = null;
1828 }
1829 };
1830
1831 _proto.render = function render() {
1832 return /*#__PURE__*/React__default.createElement(context.Provider, {
1833 value: {
1834 history: this.props.history,
1835 location: this.state.location,
1836 match: Router.computeRootMatch(this.state.location.pathname),
1837 staticContext: this.props.staticContext
1838 }
1839 }, /*#__PURE__*/React__default.createElement(historyContext.Provider, {
1840 children: this.props.children || null,
1841 value: this.props.history
1842 }));
1843 };
1844
1845 return Router;
1846 }(React__default.Component);
1847
1848 {
1849 Router.propTypes = {
1850 children: propTypes.node,
1851 history: propTypes.object.isRequired,
1852 staticContext: propTypes.object
1853 };
1854
1855 Router.prototype.componentDidUpdate = function (prevProps) {
1856 warning(prevProps.history === this.props.history, "You cannot change <Router history>") ;
1857 };
1858 }
1859
1860 /**
1861 * The public API for a <Router> that stores location in memory.
1862 */
1863
1864 var MemoryRouter = /*#__PURE__*/function (_React$Component) {
1865 _inheritsLoose(MemoryRouter, _React$Component);
1866
1867 function MemoryRouter() {
1868 var _this;
1869
1870 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1871 args[_key] = arguments[_key];
1872 }
1873
1874 _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
1875 _this.history = createMemoryHistory(_this.props);
1876 return _this;
1877 }
1878
1879 var _proto = MemoryRouter.prototype;
1880
1881 _proto.render = function render() {
1882 return /*#__PURE__*/React__default.createElement(Router, {
1883 history: this.history,
1884 children: this.props.children
1885 });
1886 };
1887
1888 return MemoryRouter;
1889 }(React__default.Component);
1890
1891 {
1892 MemoryRouter.propTypes = {
1893 initialEntries: propTypes.array,
1894 initialIndex: propTypes.number,
1895 getUserConfirmation: propTypes.func,
1896 keyLength: propTypes.number,
1897 children: propTypes.node
1898 };
1899
1900 MemoryRouter.prototype.componentDidMount = function () {
1901 warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.") ;
1902 };
1903 }
1904
1905 var Lifecycle = /*#__PURE__*/function (_React$Component) {
1906 _inheritsLoose(Lifecycle, _React$Component);
1907
1908 function Lifecycle() {
1909 return _React$Component.apply(this, arguments) || this;
1910 }
1911
1912 var _proto = Lifecycle.prototype;
1913
1914 _proto.componentDidMount = function componentDidMount() {
1915 if (this.props.onMount) this.props.onMount.call(this, this);
1916 };
1917
1918 _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1919 if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
1920 };
1921
1922 _proto.componentWillUnmount = function componentWillUnmount() {
1923 if (this.props.onUnmount) this.props.onUnmount.call(this, this);
1924 };
1925
1926 _proto.render = function render() {
1927 return null;
1928 };
1929
1930 return Lifecycle;
1931 }(React__default.Component);
1932
1933 /**
1934 * The public API for prompting the user before navigating away from a screen.
1935 */
1936
1937 function Prompt(_ref) {
1938 var message = _ref.message,
1939 _ref$when = _ref.when,
1940 when = _ref$when === void 0 ? true : _ref$when;
1941 return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
1942 !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
1943 if (!when || context.staticContext) return null;
1944 var method = context.history.block;
1945 return /*#__PURE__*/React__default.createElement(Lifecycle, {
1946 onMount: function onMount(self) {
1947 self.release = method(message);
1948 },
1949 onUpdate: function onUpdate(self, prevProps) {
1950 if (prevProps.message !== message) {
1951 self.release();
1952 self.release = method(message);
1953 }
1954 },
1955 onUnmount: function onUnmount(self) {
1956 self.release();
1957 },
1958 message: message
1959 });
1960 });
1961 }
1962
1963 {
1964 var messageType = propTypes.oneOfType([propTypes.func, propTypes.string]);
1965 Prompt.propTypes = {
1966 when: propTypes.bool,
1967 message: messageType.isRequired
1968 };
1969 }
1970
1971 var isarray = Array.isArray || function (arr) {
1972 return Object.prototype.toString.call(arr) == '[object Array]';
1973 };
1974
1975 /**
1976 * Expose `pathToRegexp`.
1977 */
1978 var pathToRegexp_1 = pathToRegexp;
1979 var parse_1 = parse;
1980 var compile_1 = compile;
1981 var tokensToFunction_1 = tokensToFunction;
1982 var tokensToRegExp_1 = tokensToRegExp;
1983
1984 /**
1985 * The main path matching regexp utility.
1986 *
1987 * @type {RegExp}
1988 */
1989 var PATH_REGEXP = new RegExp([
1990 // Match escaped characters that would otherwise appear in future matches.
1991 // This allows the user to escape special characters that won't transform.
1992 '(\\\\.)',
1993 // Match Express-style parameters and un-named parameters with a prefix
1994 // and optional suffixes. Matches appear as:
1995 //
1996 // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
1997 // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
1998 // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
1999 '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
2000 ].join('|'), 'g');
2001
2002 /**
2003 * Parse a string for the raw tokens.
2004 *
2005 * @param {string} str
2006 * @param {Object=} options
2007 * @return {!Array}
2008 */
2009 function parse (str, options) {
2010 var tokens = [];
2011 var key = 0;
2012 var index = 0;
2013 var path = '';
2014 var defaultDelimiter = options && options.delimiter || '/';
2015 var res;
2016
2017 while ((res = PATH_REGEXP.exec(str)) != null) {
2018 var m = res[0];
2019 var escaped = res[1];
2020 var offset = res.index;
2021 path += str.slice(index, offset);
2022 index = offset + m.length;
2023
2024 // Ignore already escaped sequences.
2025 if (escaped) {
2026 path += escaped[1];
2027 continue
2028 }
2029
2030 var next = str[index];
2031 var prefix = res[2];
2032 var name = res[3];
2033 var capture = res[4];
2034 var group = res[5];
2035 var modifier = res[6];
2036 var asterisk = res[7];
2037
2038 // Push the current path onto the tokens.
2039 if (path) {
2040 tokens.push(path);
2041 path = '';
2042 }
2043
2044 var partial = prefix != null && next != null && next !== prefix;
2045 var repeat = modifier === '+' || modifier === '*';
2046 var optional = modifier === '?' || modifier === '*';
2047 var delimiter = res[2] || defaultDelimiter;
2048 var pattern = capture || group;
2049
2050 tokens.push({
2051 name: name || key++,
2052 prefix: prefix || '',
2053 delimiter: delimiter,
2054 optional: optional,
2055 repeat: repeat,
2056 partial: partial,
2057 asterisk: !!asterisk,
2058 pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
2059 });
2060 }
2061
2062 // Match any characters still remaining.
2063 if (index < str.length) {
2064 path += str.substr(index);
2065 }
2066
2067 // If the path exists, push it onto the end.
2068 if (path) {
2069 tokens.push(path);
2070 }
2071
2072 return tokens
2073 }
2074
2075 /**
2076 * Compile a string to a template function for the path.
2077 *
2078 * @param {string} str
2079 * @param {Object=} options
2080 * @return {!function(Object=, Object=)}
2081 */
2082 function compile (str, options) {
2083 return tokensToFunction(parse(str, options))
2084 }
2085
2086 /**
2087 * Prettier encoding of URI path segments.
2088 *
2089 * @param {string}
2090 * @return {string}
2091 */
2092 function encodeURIComponentPretty (str) {
2093 return encodeURI(str).replace(/[\/?#]/g, function (c) {
2094 return '%' + c.charCodeAt(0).toString(16).toUpperCase()
2095 })
2096 }
2097
2098 /**
2099 * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
2100 *
2101 * @param {string}
2102 * @return {string}
2103 */
2104 function encodeAsterisk (str) {
2105 return encodeURI(str).replace(/[?#]/g, function (c) {
2106 return '%' + c.charCodeAt(0).toString(16).toUpperCase()
2107 })
2108 }
2109
2110 /**
2111 * Expose a method for transforming tokens into the path function.
2112 */
2113 function tokensToFunction (tokens) {
2114 // Compile all the tokens into regexps.
2115 var matches = new Array(tokens.length);
2116
2117 // Compile all the patterns before compilation.
2118 for (var i = 0; i < tokens.length; i++) {
2119 if (typeof tokens[i] === 'object') {
2120 matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
2121 }
2122 }
2123
2124 return function (obj, opts) {
2125 var path = '';
2126 var data = obj || {};
2127 var options = opts || {};
2128 var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
2129
2130 for (var i = 0; i < tokens.length; i++) {
2131 var token = tokens[i];
2132
2133 if (typeof token === 'string') {
2134 path += token;
2135
2136 continue
2137 }
2138
2139 var value = data[token.name];
2140 var segment;
2141
2142 if (value == null) {
2143 if (token.optional) {
2144 // Prepend partial segment prefixes.
2145 if (token.partial) {
2146 path += token.prefix;
2147 }
2148
2149 continue
2150 } else {
2151 throw new TypeError('Expected "' + token.name + '" to be defined')
2152 }
2153 }
2154
2155 if (isarray(value)) {
2156 if (!token.repeat) {
2157 throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
2158 }
2159
2160 if (value.length === 0) {
2161 if (token.optional) {
2162 continue
2163 } else {
2164 throw new TypeError('Expected "' + token.name + '" to not be empty')
2165 }
2166 }
2167
2168 for (var j = 0; j < value.length; j++) {
2169 segment = encode(value[j]);
2170
2171 if (!matches[i].test(segment)) {
2172 throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
2173 }
2174
2175 path += (j === 0 ? token.prefix : token.delimiter) + segment;
2176 }
2177
2178 continue
2179 }
2180
2181 segment = token.asterisk ? encodeAsterisk(value) : encode(value);
2182
2183 if (!matches[i].test(segment)) {
2184 throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
2185 }
2186
2187 path += token.prefix + segment;
2188 }
2189
2190 return path
2191 }
2192 }
2193
2194 /**
2195 * Escape a regular expression string.
2196 *
2197 * @param {string} str
2198 * @return {string}
2199 */
2200 function escapeString (str) {
2201 return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
2202 }
2203
2204 /**
2205 * Escape the capturing group by escaping special characters and meaning.
2206 *
2207 * @param {string} group
2208 * @return {string}
2209 */
2210 function escapeGroup (group) {
2211 return group.replace(/([=!:$\/()])/g, '\\$1')
2212 }
2213
2214 /**
2215 * Attach the keys as a property of the regexp.
2216 *
2217 * @param {!RegExp} re
2218 * @param {Array} keys
2219 * @return {!RegExp}
2220 */
2221 function attachKeys (re, keys) {
2222 re.keys = keys;
2223 return re
2224 }
2225
2226 /**
2227 * Get the flags for a regexp from the options.
2228 *
2229 * @param {Object} options
2230 * @return {string}
2231 */
2232 function flags (options) {
2233 return options.sensitive ? '' : 'i'
2234 }
2235
2236 /**
2237 * Pull out keys from a regexp.
2238 *
2239 * @param {!RegExp} path
2240 * @param {!Array} keys
2241 * @return {!RegExp}
2242 */
2243 function regexpToRegexp (path, keys) {
2244 // Use a negative lookahead to match only capturing groups.
2245 var groups = path.source.match(/\((?!\?)/g);
2246
2247 if (groups) {
2248 for (var i = 0; i < groups.length; i++) {
2249 keys.push({
2250 name: i,
2251 prefix: null,
2252 delimiter: null,
2253 optional: false,
2254 repeat: false,
2255 partial: false,
2256 asterisk: false,
2257 pattern: null
2258 });
2259 }
2260 }
2261
2262 return attachKeys(path, keys)
2263 }
2264
2265 /**
2266 * Transform an array into a regexp.
2267 *
2268 * @param {!Array} path
2269 * @param {Array} keys
2270 * @param {!Object} options
2271 * @return {!RegExp}
2272 */
2273 function arrayToRegexp (path, keys, options) {
2274 var parts = [];
2275
2276 for (var i = 0; i < path.length; i++) {
2277 parts.push(pathToRegexp(path[i], keys, options).source);
2278 }
2279
2280 var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
2281
2282 return attachKeys(regexp, keys)
2283 }
2284
2285 /**
2286 * Create a path regexp from string input.
2287 *
2288 * @param {string} path
2289 * @param {!Array} keys
2290 * @param {!Object} options
2291 * @return {!RegExp}
2292 */
2293 function stringToRegexp (path, keys, options) {
2294 return tokensToRegExp(parse(path, options), keys, options)
2295 }
2296
2297 /**
2298 * Expose a function for taking tokens and returning a RegExp.
2299 *
2300 * @param {!Array} tokens
2301 * @param {(Array|Object)=} keys
2302 * @param {Object=} options
2303 * @return {!RegExp}
2304 */
2305 function tokensToRegExp (tokens, keys, options) {
2306 if (!isarray(keys)) {
2307 options = /** @type {!Object} */ (keys || options);
2308 keys = [];
2309 }
2310
2311 options = options || {};
2312
2313 var strict = options.strict;
2314 var end = options.end !== false;
2315 var route = '';
2316
2317 // Iterate over the tokens and create our regexp string.
2318 for (var i = 0; i < tokens.length; i++) {
2319 var token = tokens[i];
2320
2321 if (typeof token === 'string') {
2322 route += escapeString(token);
2323 } else {
2324 var prefix = escapeString(token.prefix);
2325 var capture = '(?:' + token.pattern + ')';
2326
2327 keys.push(token);
2328
2329 if (token.repeat) {
2330 capture += '(?:' + prefix + capture + ')*';
2331 }
2332
2333 if (token.optional) {
2334 if (!token.partial) {
2335 capture = '(?:' + prefix + '(' + capture + '))?';
2336 } else {
2337 capture = prefix + '(' + capture + ')?';
2338 }
2339 } else {
2340 capture = prefix + '(' + capture + ')';
2341 }
2342
2343 route += capture;
2344 }
2345 }
2346
2347 var delimiter = escapeString(options.delimiter || '/');
2348 var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
2349
2350 // In non-strict mode we allow a slash at the end of match. If the path to
2351 // match already ends with a slash, we remove it for consistency. The slash
2352 // is valid at the end of a path match, not in the middle. This is important
2353 // in non-ending mode, where "/test/" shouldn't match "/test//route".
2354 if (!strict) {
2355 route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
2356 }
2357
2358 if (end) {
2359 route += '$';
2360 } else {
2361 // In non-ending mode, we need the capturing groups to match as much as
2362 // possible by using a positive lookahead to the end or next path segment.
2363 route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
2364 }
2365
2366 return attachKeys(new RegExp('^' + route, flags(options)), keys)
2367 }
2368
2369 /**
2370 * Normalize the given path string, returning a regular expression.
2371 *
2372 * An empty array can be passed in for the keys, which will hold the
2373 * placeholder key descriptions. For example, using `/user/:id`, `keys` will
2374 * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
2375 *
2376 * @param {(string|RegExp|Array)} path
2377 * @param {(Array|Object)=} keys
2378 * @param {Object=} options
2379 * @return {!RegExp}
2380 */
2381 function pathToRegexp (path, keys, options) {
2382 if (!isarray(keys)) {
2383 options = /** @type {!Object} */ (keys || options);
2384 keys = [];
2385 }
2386
2387 options = options || {};
2388
2389 if (path instanceof RegExp) {
2390 return regexpToRegexp(path, /** @type {!Array} */ (keys))
2391 }
2392
2393 if (isarray(path)) {
2394 return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
2395 }
2396
2397 return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
2398 }
2399 pathToRegexp_1.parse = parse_1;
2400 pathToRegexp_1.compile = compile_1;
2401 pathToRegexp_1.tokensToFunction = tokensToFunction_1;
2402 pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
2403
2404 var cache = {};
2405 var cacheLimit = 10000;
2406 var cacheCount = 0;
2407
2408 function compilePath(path) {
2409 if (cache[path]) return cache[path];
2410 var generator = pathToRegexp_1.compile(path);
2411
2412 if (cacheCount < cacheLimit) {
2413 cache[path] = generator;
2414 cacheCount++;
2415 }
2416
2417 return generator;
2418 }
2419 /**
2420 * Public API for generating a URL pathname from a path and parameters.
2421 */
2422
2423
2424 function generatePath(path, params) {
2425 if (path === void 0) {
2426 path = "/";
2427 }
2428
2429 if (params === void 0) {
2430 params = {};
2431 }
2432
2433 return path === "/" ? path : compilePath(path)(params, {
2434 pretty: true
2435 });
2436 }
2437
2438 /**
2439 * The public API for navigating programmatically with a component.
2440 */
2441
2442 function Redirect(_ref) {
2443 var computedMatch = _ref.computedMatch,
2444 to = _ref.to,
2445 _ref$push = _ref.push,
2446 push = _ref$push === void 0 ? false : _ref$push;
2447 return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
2448 !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
2449 var history = context.history,
2450 staticContext = context.staticContext;
2451 var method = push ? history.push : history.replace;
2452 var location = createLocation(computedMatch ? typeof to === "string" ? generatePath(to, computedMatch.params) : _extends({}, to, {
2453 pathname: generatePath(to.pathname, computedMatch.params)
2454 }) : to); // When rendering in a static context,
2455 // set the new location immediately.
2456
2457 if (staticContext) {
2458 method(location);
2459 return null;
2460 }
2461
2462 return /*#__PURE__*/React__default.createElement(Lifecycle, {
2463 onMount: function onMount() {
2464 method(location);
2465 },
2466 onUpdate: function onUpdate(self, prevProps) {
2467 var prevLocation = createLocation(prevProps.to);
2468
2469 if (!locationsAreEqual(prevLocation, _extends({}, location, {
2470 key: prevLocation.key
2471 }))) {
2472 method(location);
2473 }
2474 },
2475 to: to
2476 });
2477 });
2478 }
2479
2480 {
2481 Redirect.propTypes = {
2482 push: propTypes.bool,
2483 from: propTypes.string,
2484 to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired
2485 };
2486 }
2487
2488 var cache$1 = {};
2489 var cacheLimit$1 = 10000;
2490 var cacheCount$1 = 0;
2491
2492 function compilePath$1(path, options) {
2493 var cacheKey = "" + options.end + options.strict + options.sensitive;
2494 var pathCache = cache$1[cacheKey] || (cache$1[cacheKey] = {});
2495 if (pathCache[path]) return pathCache[path];
2496 var keys = [];
2497 var regexp = pathToRegexp_1(path, keys, options);
2498 var result = {
2499 regexp: regexp,
2500 keys: keys
2501 };
2502
2503 if (cacheCount$1 < cacheLimit$1) {
2504 pathCache[path] = result;
2505 cacheCount$1++;
2506 }
2507
2508 return result;
2509 }
2510 /**
2511 * Public API for matching a URL pathname to a path.
2512 */
2513
2514
2515 function matchPath(pathname, options) {
2516 if (options === void 0) {
2517 options = {};
2518 }
2519
2520 if (typeof options === "string" || Array.isArray(options)) {
2521 options = {
2522 path: options
2523 };
2524 }
2525
2526 var _options = options,
2527 path = _options.path,
2528 _options$exact = _options.exact,
2529 exact = _options$exact === void 0 ? false : _options$exact,
2530 _options$strict = _options.strict,
2531 strict = _options$strict === void 0 ? false : _options$strict,
2532 _options$sensitive = _options.sensitive,
2533 sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
2534 var paths = [].concat(path);
2535 return paths.reduce(function (matched, path) {
2536 if (!path && path !== "") return null;
2537 if (matched) return matched;
2538
2539 var _compilePath = compilePath$1(path, {
2540 end: exact,
2541 strict: strict,
2542 sensitive: sensitive
2543 }),
2544 regexp = _compilePath.regexp,
2545 keys = _compilePath.keys;
2546
2547 var match = regexp.exec(pathname);
2548 if (!match) return null;
2549 var url = match[0],
2550 values = match.slice(1);
2551 var isExact = pathname === url;
2552 if (exact && !isExact) return null;
2553 return {
2554 path: path,
2555 // the path used to match
2556 url: path === "/" && url === "" ? "/" : url,
2557 // the matched portion of the URL
2558 isExact: isExact,
2559 // whether or not we matched exactly
2560 params: keys.reduce(function (memo, key, index) {
2561 memo[key.name] = values[index];
2562 return memo;
2563 }, {})
2564 };
2565 }, null);
2566 }
2567
2568 function isEmptyChildren(children) {
2569 return React__default.Children.count(children) === 0;
2570 }
2571
2572 function evalChildrenDev(children, props, path) {
2573 var value = children(props);
2574 warning(value !== undefined, "You returned `undefined` from the `children` function of " + ("<Route" + (path ? " path=\"" + path + "\"" : "") + ">, but you ") + "should have returned a React element or `null`") ;
2575 return value || null;
2576 }
2577 /**
2578 * The public API for matching a single path and rendering.
2579 */
2580
2581
2582 var Route = /*#__PURE__*/function (_React$Component) {
2583 _inheritsLoose(Route, _React$Component);
2584
2585 function Route() {
2586 return _React$Component.apply(this, arguments) || this;
2587 }
2588
2589 var _proto = Route.prototype;
2590
2591 _proto.render = function render() {
2592 var _this = this;
2593
2594 return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context$1) {
2595 !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
2596 var location = _this.props.location || context$1.location;
2597 var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
2598 : _this.props.path ? matchPath(location.pathname, _this.props) : context$1.match;
2599
2600 var props = _extends({}, context$1, {
2601 location: location,
2602 match: match
2603 });
2604
2605 var _this$props = _this.props,
2606 children = _this$props.children,
2607 component = _this$props.component,
2608 render = _this$props.render; // Preact uses an empty array as children by
2609 // default, so use null if that's the case.
2610
2611 if (Array.isArray(children) && isEmptyChildren(children)) {
2612 children = null;
2613 }
2614
2615 return /*#__PURE__*/React__default.createElement(context.Provider, {
2616 value: props
2617 }, props.match ? children ? typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : children : component ? /*#__PURE__*/React__default.createElement(component, props) : render ? render(props) : null : typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : null);
2618 });
2619 };
2620
2621 return Route;
2622 }(React__default.Component);
2623
2624 {
2625 Route.propTypes = {
2626 children: propTypes.oneOfType([propTypes.func, propTypes.node]),
2627 component: function component(props, propName) {
2628 if (props[propName] && !reactIs_1(props[propName])) {
2629 return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
2630 }
2631 },
2632 exact: propTypes.bool,
2633 location: propTypes.object,
2634 path: propTypes.oneOfType([propTypes.string, propTypes.arrayOf(propTypes.string)]),
2635 render: propTypes.func,
2636 sensitive: propTypes.bool,
2637 strict: propTypes.bool
2638 };
2639
2640 Route.prototype.componentDidMount = function () {
2641 warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.component), "You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored") ;
2642 warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.render), "You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored") ;
2643 warning(!(this.props.component && this.props.render), "You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored") ;
2644 };
2645
2646 Route.prototype.componentDidUpdate = function (prevProps) {
2647 warning(!(this.props.location && !prevProps.location), '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') ;
2648 warning(!(!this.props.location && prevProps.location), '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') ;
2649 };
2650 }
2651
2652 function _objectWithoutPropertiesLoose(source, excluded) {
2653 if (source == null) return {};
2654 var target = {};
2655 var sourceKeys = Object.keys(source);
2656 var key, i;
2657
2658 for (i = 0; i < sourceKeys.length; i++) {
2659 key = sourceKeys[i];
2660 if (excluded.indexOf(key) >= 0) continue;
2661 target[key] = source[key];
2662 }
2663
2664 return target;
2665 }
2666
2667 function addLeadingSlash(path) {
2668 return path.charAt(0) === "/" ? path : "/" + path;
2669 }
2670
2671 function addBasename(basename, location) {
2672 if (!basename) return location;
2673 return _extends({}, location, {
2674 pathname: addLeadingSlash(basename) + location.pathname
2675 });
2676 }
2677
2678 function stripBasename(basename, location) {
2679 if (!basename) return location;
2680 var base = addLeadingSlash(basename);
2681 if (location.pathname.indexOf(base) !== 0) return location;
2682 return _extends({}, location, {
2683 pathname: location.pathname.substr(base.length)
2684 });
2685 }
2686
2687 function createURL(location) {
2688 return typeof location === "string" ? location : createPath(location);
2689 }
2690
2691 function staticHandler(methodName) {
2692 return function () {
2693 invariant(false, "You cannot %s with <StaticRouter>") ;
2694 };
2695 }
2696
2697 function noop() {}
2698 /**
2699 * The public top-level API for a "static" <Router>, so-called because it
2700 * can't actually change the current location. Instead, it just records
2701 * location changes in a context object. Useful mainly in testing and
2702 * server-rendering scenarios.
2703 */
2704
2705
2706 var StaticRouter = /*#__PURE__*/function (_React$Component) {
2707 _inheritsLoose(StaticRouter, _React$Component);
2708
2709 function StaticRouter() {
2710 var _this;
2711
2712 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2713 args[_key] = arguments[_key];
2714 }
2715
2716 _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
2717
2718 _this.handlePush = function (location) {
2719 return _this.navigateTo(location, "PUSH");
2720 };
2721
2722 _this.handleReplace = function (location) {
2723 return _this.navigateTo(location, "REPLACE");
2724 };
2725
2726 _this.handleListen = function () {
2727 return noop;
2728 };
2729
2730 _this.handleBlock = function () {
2731 return noop;
2732 };
2733
2734 return _this;
2735 }
2736
2737 var _proto = StaticRouter.prototype;
2738
2739 _proto.navigateTo = function navigateTo(location, action) {
2740 var _this$props = this.props,
2741 _this$props$basename = _this$props.basename,
2742 basename = _this$props$basename === void 0 ? "" : _this$props$basename,
2743 _this$props$context = _this$props.context,
2744 context = _this$props$context === void 0 ? {} : _this$props$context;
2745 context.action = action;
2746 context.location = addBasename(basename, createLocation(location));
2747 context.url = createURL(context.location);
2748 };
2749
2750 _proto.render = function render() {
2751 var _this$props2 = this.props,
2752 _this$props2$basename = _this$props2.basename,
2753 basename = _this$props2$basename === void 0 ? "" : _this$props2$basename,
2754 _this$props2$context = _this$props2.context,
2755 context = _this$props2$context === void 0 ? {} : _this$props2$context,
2756 _this$props2$location = _this$props2.location,
2757 location = _this$props2$location === void 0 ? "/" : _this$props2$location,
2758 rest = _objectWithoutPropertiesLoose(_this$props2, ["basename", "context", "location"]);
2759
2760 var history = {
2761 createHref: function createHref(path) {
2762 return addLeadingSlash(basename + createURL(path));
2763 },
2764 action: "POP",
2765 location: stripBasename(basename, createLocation(location)),
2766 push: this.handlePush,
2767 replace: this.handleReplace,
2768 go: staticHandler(),
2769 goBack: staticHandler(),
2770 goForward: staticHandler(),
2771 listen: this.handleListen,
2772 block: this.handleBlock
2773 };
2774 return /*#__PURE__*/React__default.createElement(Router, _extends({}, rest, {
2775 history: history,
2776 staticContext: context
2777 }));
2778 };
2779
2780 return StaticRouter;
2781 }(React__default.Component);
2782
2783 {
2784 StaticRouter.propTypes = {
2785 basename: propTypes.string,
2786 context: propTypes.object,
2787 location: propTypes.oneOfType([propTypes.string, propTypes.object])
2788 };
2789
2790 StaticRouter.prototype.componentDidMount = function () {
2791 warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.") ;
2792 };
2793 }
2794
2795 /**
2796 * The public API for rendering the first <Route> that matches.
2797 */
2798
2799 var Switch = /*#__PURE__*/function (_React$Component) {
2800 _inheritsLoose(Switch, _React$Component);
2801
2802 function Switch() {
2803 return _React$Component.apply(this, arguments) || this;
2804 }
2805
2806 var _proto = Switch.prototype;
2807
2808 _proto.render = function render() {
2809 var _this = this;
2810
2811 return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
2812 !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
2813 var location = _this.props.location || context.location;
2814 var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
2815 // here because toArray adds keys to all child elements and we do not want
2816 // to trigger an unmount/remount for two <Route>s that render the same
2817 // component at different URLs.
2818
2819 React__default.Children.forEach(_this.props.children, function (child) {
2820 if (match == null && /*#__PURE__*/React__default.isValidElement(child)) {
2821 element = child;
2822 var path = child.props.path || child.props.from;
2823 match = path ? matchPath(location.pathname, _extends({}, child.props, {
2824 path: path
2825 })) : context.match;
2826 }
2827 });
2828 return match ? /*#__PURE__*/React__default.cloneElement(element, {
2829 location: location,
2830 computedMatch: match
2831 }) : null;
2832 });
2833 };
2834
2835 return Switch;
2836 }(React__default.Component);
2837
2838 {
2839 Switch.propTypes = {
2840 children: propTypes.node,
2841 location: propTypes.object
2842 };
2843
2844 Switch.prototype.componentDidUpdate = function (prevProps) {
2845 warning(!(this.props.location && !prevProps.location), '<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') ;
2846 warning(!(!this.props.location && prevProps.location), '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') ;
2847 };
2848 }
2849
2850 /**
2851 * Copyright 2015, Yahoo! Inc.
2852 * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
2853 */
2854
2855 var REACT_STATICS = {
2856 childContextTypes: true,
2857 contextType: true,
2858 contextTypes: true,
2859 defaultProps: true,
2860 displayName: true,
2861 getDefaultProps: true,
2862 getDerivedStateFromError: true,
2863 getDerivedStateFromProps: true,
2864 mixins: true,
2865 propTypes: true,
2866 type: true
2867 };
2868
2869 var KNOWN_STATICS = {
2870 name: true,
2871 length: true,
2872 prototype: true,
2873 caller: true,
2874 callee: true,
2875 arguments: true,
2876 arity: true
2877 };
2878
2879 var FORWARD_REF_STATICS = {
2880 '$$typeof': true,
2881 render: true,
2882 defaultProps: true,
2883 displayName: true,
2884 propTypes: true
2885 };
2886
2887 var MEMO_STATICS = {
2888 '$$typeof': true,
2889 compare: true,
2890 defaultProps: true,
2891 displayName: true,
2892 propTypes: true,
2893 type: true
2894 };
2895
2896 var TYPE_STATICS = {};
2897 TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
2898
2899 function getStatics(component) {
2900 if (reactIs.isMemo(component)) {
2901 return MEMO_STATICS;
2902 }
2903 return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
2904 }
2905
2906 var defineProperty = Object.defineProperty;
2907 var getOwnPropertyNames = Object.getOwnPropertyNames;
2908 var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
2909 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2910 var getPrototypeOf = Object.getPrototypeOf;
2911 var objectPrototype = Object.prototype;
2912
2913 function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
2914 if (typeof sourceComponent !== 'string') {
2915 // don't hoist over string (html) components
2916
2917 if (objectPrototype) {
2918 var inheritedComponent = getPrototypeOf(sourceComponent);
2919 if (inheritedComponent && inheritedComponent !== objectPrototype) {
2920 hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
2921 }
2922 }
2923
2924 var keys = getOwnPropertyNames(sourceComponent);
2925
2926 if (getOwnPropertySymbols$1) {
2927 keys = keys.concat(getOwnPropertySymbols$1(sourceComponent));
2928 }
2929
2930 var targetStatics = getStatics(targetComponent);
2931 var sourceStatics = getStatics(sourceComponent);
2932
2933 for (var i = 0; i < keys.length; ++i) {
2934 var key = keys[i];
2935 if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
2936 var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
2937 try {
2938 // Avoid failures from read-only properties
2939 defineProperty(targetComponent, key, descriptor);
2940 } catch (e) {}
2941 }
2942 }
2943
2944 return targetComponent;
2945 }
2946
2947 return targetComponent;
2948 }
2949
2950 var hoistNonReactStatics_cjs = hoistNonReactStatics;
2951
2952 /**
2953 * A public higher-order component to access the imperative API
2954 */
2955
2956 function withRouter(Component) {
2957 var displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
2958
2959 var C = function C(props) {
2960 var wrappedComponentRef = props.wrappedComponentRef,
2961 remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
2962
2963 return /*#__PURE__*/React__default.createElement(context.Consumer, null, function (context) {
2964 !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
2965 return /*#__PURE__*/React__default.createElement(Component, _extends({}, remainingProps, context, {
2966 ref: wrappedComponentRef
2967 }));
2968 });
2969 };
2970
2971 C.displayName = displayName;
2972 C.WrappedComponent = Component;
2973
2974 {
2975 C.propTypes = {
2976 wrappedComponentRef: propTypes.oneOfType([propTypes.string, propTypes.func, propTypes.object])
2977 };
2978 }
2979
2980 return hoistNonReactStatics_cjs(C, Component);
2981 }
2982
2983 var useContext = React__default.useContext;
2984 function useHistory() {
2985 {
2986 !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
2987 }
2988
2989 return useContext(historyContext);
2990 }
2991 function useLocation() {
2992 {
2993 !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : void 0;
2994 }
2995
2996 return useContext(context).location;
2997 }
2998 function useParams() {
2999 {
3000 !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : void 0;
3001 }
3002
3003 var match = useContext(context).match;
3004 return match ? match.params : {};
3005 }
3006 function useRouteMatch(path) {
3007 {
3008 !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
3009 }
3010
3011 var location = useLocation();
3012 var match = useContext(context).match;
3013 return path ? matchPath(location.pathname, path) : match;
3014 }
3015
3016 {
3017 if (typeof window !== "undefined") {
3018 var global$1 = window;
3019 var key = "__react_router_build__";
3020 var buildNames = {
3021 cjs: "CommonJS",
3022 esm: "ES modules",
3023 umd: "UMD"
3024 };
3025
3026 if (global$1[key] && global$1[key] !== "umd") {
3027 var initialBuildName = buildNames[global$1[key]];
3028 var secondaryBuildName = buildNames["umd"]; // TODO: Add link to article that explains in detail how to avoid
3029 // loading 2 different builds.
3030
3031 throw new Error("You are loading the " + secondaryBuildName + " build of React Router " + ("on a page that is already running the " + initialBuildName + " ") + "build, so things won't work right.");
3032 }
3033
3034 global$1[key] = "umd";
3035 }
3036 }
3037
3038 exports.MemoryRouter = MemoryRouter;
3039 exports.Prompt = Prompt;
3040 exports.Redirect = Redirect;
3041 exports.Route = Route;
3042 exports.Router = Router;
3043 exports.StaticRouter = StaticRouter;
3044 exports.Switch = Switch;
3045 exports.__HistoryContext = historyContext;
3046 exports.__RouterContext = context;
3047 exports.generatePath = generatePath;
3048 exports.matchPath = matchPath;
3049 exports.useHistory = useHistory;
3050 exports.useLocation = useLocation;
3051 exports.useParams = useParams;
3052 exports.useRouteMatch = useRouteMatch;
3053 exports.withRouter = withRouter;
3054
3055 Object.defineProperty(exports, '__esModule', { value: true });
3056
3057}));
3058//# sourceMappingURL=react-router.js.map