react-router 4.1.2 → 4.2.0

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