react-router-dom 4.2.1 → 4.2.2

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,19 +1,10 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-router/es/Router'), require('react-router/es/MemoryRouter'), require('react-router/es/Route'), require('react-router/es/Prompt'), require('react-router/es/Redirect'), require('react-router/es/StaticRouter'), require('react-router/es/Switch'), require('react-router/es/matchPath'), require('react-router/es/withRouter')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-router/es/Router', 'react-router/es/MemoryRouter', 'react-router/es/Route', 'react-router/es/Prompt', 'react-router/es/Redirect', 'react-router/es/StaticRouter', 'react-router/es/Switch', 'react-router/es/matchPath', 'react-router/es/withRouter'], factory) :
4
- (factory((global.ReactRouterDOM = {}),global.React,global.Router,global.MemoryRouter,global.Route,global.Prompt,global.Redirect,global.StaticRouter,global.Switch,global.matchPath,global.withRouter));
5
- }(this, (function (exports,React,Router,MemoryRouter,Route,Prompt,Redirect,StaticRouter,Switch,matchPath,withRouter) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
4
+ (factory((global.ReactRouterDOM = {}),global.React));
5
+ }(this, (function (exports,React) { 'use strict';
6
6
 
7
7
  React = React && React.hasOwnProperty('default') ? React['default'] : React;
8
- Router = Router && Router.hasOwnProperty('default') ? Router['default'] : Router;
9
- MemoryRouter = MemoryRouter && MemoryRouter.hasOwnProperty('default') ? MemoryRouter['default'] : MemoryRouter;
10
- Route = Route && Route.hasOwnProperty('default') ? Route['default'] : Route;
11
- Prompt = Prompt && Prompt.hasOwnProperty('default') ? Prompt['default'] : Prompt;
12
- Redirect = Redirect && Redirect.hasOwnProperty('default') ? Redirect['default'] : Redirect;
13
- StaticRouter = StaticRouter && StaticRouter.hasOwnProperty('default') ? StaticRouter['default'] : StaticRouter;
14
- Switch = Switch && Switch.hasOwnProperty('default') ? Switch['default'] : Switch;
15
- matchPath = matchPath && matchPath.hasOwnProperty('default') ? matchPath['default'] : matchPath;
16
- withRouter = withRouter && withRouter.hasOwnProperty('default') ? withRouter['default'] : withRouter;
17
8
 
18
9
  /**
19
10
  * Copyright 2014-2015, Facebook, Inc.
@@ -1591,669 +1582,3525 @@ exports.default = createBrowserHistory;
1591
1582
 
1592
1583
  var createHistory = unwrapExports(createBrowserHistory_1);
1593
1584
 
1585
+ /**
1586
+ * Copyright 2014-2015, Facebook, Inc.
1587
+ * All rights reserved.
1588
+ *
1589
+ * This source code is licensed under the BSD-style license found in the
1590
+ * LICENSE file in the root directory of this source tree. An additional grant
1591
+ * of patent rights can be found in the PATENTS file in the same directory.
1592
+ */
1593
+
1594
+ /**
1595
+ * Similar to invariant but only logs a warning if the condition is not met.
1596
+ * This can be used to log issues in development environments in critical
1597
+ * paths. Removing the logging code for production environments will keep the
1598
+ * same logic and follow the same code paths.
1599
+ */
1600
+
1601
+ var __DEV__$1 = "development" !== 'production';
1602
+
1603
+ var warning$4 = function () {};
1604
+
1605
+ if (__DEV__$1) {
1606
+ warning$4 = function (condition, format, args) {
1607
+ var len = arguments.length;
1608
+ args = new Array(len > 2 ? len - 2 : 0);
1609
+ for (var key = 2; key < len; key++) {
1610
+ args[key - 2] = arguments[key];
1611
+ }
1612
+ if (format === undefined) {
1613
+ throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
1614
+ }
1615
+
1616
+ if (format.length < 10 || /^[s\W]*$/.test(format)) {
1617
+ throw new Error('The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format);
1618
+ }
1619
+
1620
+ if (!condition) {
1621
+ var argIndex = 0;
1622
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
1623
+ return args[argIndex++];
1624
+ });
1625
+ if (typeof console !== 'undefined') {
1626
+ console.error(message);
1627
+ }
1628
+ try {
1629
+ // This error was thrown as a convenience so that you can use this stack
1630
+ // to find the callsite that caused this warning to fire.
1631
+ throw new Error(message);
1632
+ } catch (x) {}
1633
+ }
1634
+ };
1635
+ }
1636
+
1637
+ var warning_1$3 = warning$4;
1638
+
1639
+ /**
1640
+ * Copyright 2013-2015, Facebook, Inc.
1641
+ * All rights reserved.
1642
+ *
1643
+ * This source code is licensed under the BSD-style license found in the
1644
+ * LICENSE file in the root directory of this source tree. An additional grant
1645
+ * of patent rights can be found in the PATENTS file in the same directory.
1646
+ */
1647
+
1648
+ /**
1649
+ * Use invariant() to assert state which your program assumes to be true.
1650
+ *
1651
+ * Provide sprintf-style format (only %s is supported) and arguments
1652
+ * to provide information about what broke and what you were
1653
+ * expecting.
1654
+ *
1655
+ * The invariant message will be stripped in production, but the invariant
1656
+ * will remain to ensure logic does not differ in production.
1657
+ */
1658
+
1659
+ var NODE_ENV$1 = "development";
1660
+
1661
+ var invariant$5 = function (condition, format, a, b, c, d, e, f) {
1662
+ if (NODE_ENV$1 !== 'production') {
1663
+ if (format === undefined) {
1664
+ throw new Error('invariant requires an error message argument');
1665
+ }
1666
+ }
1667
+
1668
+ if (!condition) {
1669
+ var error;
1670
+ if (format === undefined) {
1671
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
1672
+ } else {
1673
+ var args = [a, b, c, d, e, f];
1674
+ var argIndex = 0;
1675
+ error = new Error(format.replace(/%s/g, function () {
1676
+ return args[argIndex++];
1677
+ }));
1678
+ error.name = 'Invariant Violation';
1679
+ }
1680
+
1681
+ error.framesToPop = 1; // we don't care about invariant's own frame
1682
+ throw error;
1683
+ }
1684
+ };
1685
+
1686
+ var invariant_1$3 = invariant$5;
1687
+
1688
+ /**
1689
+ * Copyright (c) 2013-present, Facebook, Inc.
1690
+ * All rights reserved.
1691
+ *
1692
+ * This source code is licensed under the BSD-style license found in the
1693
+ * LICENSE file in the root directory of this source tree. An additional grant
1694
+ * of patent rights can be found in the PATENTS file in the same directory.
1695
+ *
1696
+ *
1697
+ */
1698
+
1699
+ function makeEmptyFunction$1(arg) {
1700
+ return function () {
1701
+ return arg;
1702
+ };
1703
+ }
1704
+
1705
+ /**
1706
+ * This function accepts and discards inputs; it has no side effects. This is
1707
+ * primarily useful idiomatically for overridable function endpoints which
1708
+ * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
1709
+ */
1710
+ var emptyFunction$2 = function emptyFunction() {};
1711
+
1712
+ emptyFunction$2.thatReturns = makeEmptyFunction$1;
1713
+ emptyFunction$2.thatReturnsFalse = makeEmptyFunction$1(false);
1714
+ emptyFunction$2.thatReturnsTrue = makeEmptyFunction$1(true);
1715
+ emptyFunction$2.thatReturnsNull = makeEmptyFunction$1(null);
1716
+ emptyFunction$2.thatReturnsThis = function () {
1717
+ return this;
1718
+ };
1719
+ emptyFunction$2.thatReturnsArgument = function (arg) {
1720
+ return arg;
1721
+ };
1722
+
1723
+ var emptyFunction_1$2 = emptyFunction$2;
1724
+
1725
+ /**
1726
+ * Copyright (c) 2013-present, Facebook, Inc.
1727
+ * All rights reserved.
1728
+ *
1729
+ * This source code is licensed under the BSD-style license found in the
1730
+ * LICENSE file in the root directory of this source tree. An additional grant
1731
+ * of patent rights can be found in the PATENTS file in the same directory.
1732
+ *
1733
+ */
1734
+
1735
+ /**
1736
+ * Use invariant() to assert state which your program assumes to be true.
1737
+ *
1738
+ * Provide sprintf-style format (only %s is supported) and arguments
1739
+ * to provide information about what broke and what you were
1740
+ * expecting.
1741
+ *
1742
+ * The invariant message will be stripped in production, but the invariant
1743
+ * will remain to ensure logic does not differ in production.
1744
+ */
1745
+
1746
+ var validateFormat$1 = function validateFormat(format) {};
1747
+
1748
+ {
1749
+ validateFormat$1 = function validateFormat(format) {
1750
+ if (format === undefined) {
1751
+ throw new Error('invariant requires an error message argument');
1752
+ }
1753
+ };
1754
+ }
1755
+
1756
+ function invariant$7(condition, format, a, b, c, d, e, f) {
1757
+ validateFormat$1(format);
1758
+
1759
+ if (!condition) {
1760
+ var error;
1761
+ if (format === undefined) {
1762
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
1763
+ } else {
1764
+ var args = [a, b, c, d, e, f];
1765
+ var argIndex = 0;
1766
+ error = new Error(format.replace(/%s/g, function () {
1767
+ return args[argIndex++];
1768
+ }));
1769
+ error.name = 'Invariant Violation';
1770
+ }
1771
+
1772
+ error.framesToPop = 1; // we don't care about invariant's own frame
1773
+ throw error;
1774
+ }
1775
+ }
1776
+
1777
+ var invariant_1$4 = invariant$7;
1778
+
1779
+ /**
1780
+ * Similar to invariant but only logs a warning if the condition is not met.
1781
+ * This can be used to log issues in development environments in critical
1782
+ * paths. Removing the logging code for production environments will keep the
1783
+ * same logic and follow the same code paths.
1784
+ */
1785
+
1786
+ var warning$6 = emptyFunction_1$2;
1787
+
1788
+ {
1789
+ var printWarning$1 = function printWarning(format) {
1790
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1791
+ args[_key - 1] = arguments[_key];
1792
+ }
1793
+
1794
+ var argIndex = 0;
1795
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
1796
+ return args[argIndex++];
1797
+ });
1798
+ if (typeof console !== 'undefined') {
1799
+ console.error(message);
1800
+ }
1801
+ try {
1802
+ // --- Welcome to debugging React ---
1803
+ // This error was thrown as a convenience so that you can use this stack
1804
+ // to find the callsite that caused this warning to fire.
1805
+ throw new Error(message);
1806
+ } catch (x) {}
1807
+ };
1808
+
1809
+ warning$6 = function warning(condition, format) {
1810
+ if (format === undefined) {
1811
+ throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
1812
+ }
1813
+
1814
+ if (format.indexOf('Failed Composite propType: ') === 0) {
1815
+ return; // Ignore CompositeComponent proptype check.
1816
+ }
1817
+
1818
+ if (!condition) {
1819
+ for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
1820
+ args[_key2 - 2] = arguments[_key2];
1821
+ }
1822
+
1823
+ printWarning$1.apply(undefined, [format].concat(args));
1824
+ }
1825
+ };
1826
+ }
1827
+
1828
+ var warning_1$4 = warning$6;
1829
+
1830
+ /**
1831
+ * Copyright 2013-present, Facebook, Inc.
1832
+ * All rights reserved.
1833
+ *
1834
+ * This source code is licensed under the BSD-style license found in the
1835
+ * LICENSE file in the root directory of this source tree. An additional grant
1836
+ * of patent rights can be found in the PATENTS file in the same directory.
1837
+ */
1838
+
1839
+ var ReactPropTypesSecret$3 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1840
+
1841
+ var ReactPropTypesSecret_1$2 = ReactPropTypesSecret$3;
1842
+
1843
+ {
1844
+ var invariant$8 = invariant_1$4;
1845
+ var warning$7 = warning_1$4;
1846
+ var ReactPropTypesSecret$4 = ReactPropTypesSecret_1$2;
1847
+ var loggedTypeFailures$1 = {};
1848
+ }
1849
+
1850
+ /**
1851
+ * Assert that the values match with the type specs.
1852
+ * Error messages are memorized and will only be shown once.
1853
+ *
1854
+ * @param {object} typeSpecs Map of name to a ReactPropType
1855
+ * @param {object} values Runtime values that need to be type-checked
1856
+ * @param {string} location e.g. "prop", "context", "child context"
1857
+ * @param {string} componentName Name of the component for error messages.
1858
+ * @param {?Function} getStack Returns the component stack.
1859
+ * @private
1860
+ */
1861
+ function checkPropTypes$2(typeSpecs, values, location, componentName, getStack) {
1862
+ {
1863
+ for (var typeSpecName in typeSpecs) {
1864
+ if (typeSpecs.hasOwnProperty(typeSpecName)) {
1865
+ var error;
1866
+ // Prop type validation may throw. In case they do, we don't want to
1867
+ // fail the render phase where it didn't fail before. So we log it.
1868
+ // After these have been cleaned up, we'll let them throw.
1869
+ try {
1870
+ // This is intentionally an invariant that gets caught. It's the same
1871
+ // behavior as without this statement except with a better message.
1872
+ invariant$8(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName);
1873
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$4);
1874
+ } catch (ex) {
1875
+ error = ex;
1876
+ }
1877
+ warning$7(!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);
1878
+ if (error instanceof Error && !(error.message in loggedTypeFailures$1)) {
1879
+ // Only monitor this failure once because there tends to be a lot of the
1880
+ // same error.
1881
+ loggedTypeFailures$1[error.message] = true;
1882
+
1883
+ var stack = getStack ? getStack() : '';
1884
+
1885
+ warning$7(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
1886
+ }
1887
+ }
1888
+ }
1889
+ }
1890
+ }
1891
+
1892
+ var checkPropTypes_1$2 = checkPropTypes$2;
1893
+
1894
+ var factoryWithTypeCheckers$2 = function (isValidElement, throwOnDirectAccess) {
1895
+ /* global Symbol */
1896
+ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
1897
+ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
1898
+
1899
+ /**
1900
+ * Returns the iterator method function contained on the iterable object.
1901
+ *
1902
+ * Be sure to invoke the function with the iterable as context:
1903
+ *
1904
+ * var iteratorFn = getIteratorFn(myIterable);
1905
+ * if (iteratorFn) {
1906
+ * var iterator = iteratorFn.call(myIterable);
1907
+ * ...
1908
+ * }
1909
+ *
1910
+ * @param {?object} maybeIterable
1911
+ * @return {?function}
1912
+ */
1913
+ function getIteratorFn(maybeIterable) {
1914
+ var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
1915
+ if (typeof iteratorFn === 'function') {
1916
+ return iteratorFn;
1917
+ }
1918
+ }
1919
+
1920
+ /**
1921
+ * Collection of methods that allow declaration and validation of props that are
1922
+ * supplied to React components. Example usage:
1923
+ *
1924
+ * var Props = require('ReactPropTypes');
1925
+ * var MyArticle = React.createClass({
1926
+ * propTypes: {
1927
+ * // An optional string prop named "description".
1928
+ * description: Props.string,
1929
+ *
1930
+ * // A required enum prop named "category".
1931
+ * category: Props.oneOf(['News','Photos']).isRequired,
1932
+ *
1933
+ * // A prop named "dialog" that requires an instance of Dialog.
1934
+ * dialog: Props.instanceOf(Dialog).isRequired
1935
+ * },
1936
+ * render: function() { ... }
1937
+ * });
1938
+ *
1939
+ * A more formal specification of how these methods are used:
1940
+ *
1941
+ * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
1942
+ * decl := ReactPropTypes.{type}(.isRequired)?
1943
+ *
1944
+ * Each and every declaration produces a function with the same signature. This
1945
+ * allows the creation of custom validation functions. For example:
1946
+ *
1947
+ * var MyLink = React.createClass({
1948
+ * propTypes: {
1949
+ * // An optional string or URI prop named "href".
1950
+ * href: function(props, propName, componentName) {
1951
+ * var propValue = props[propName];
1952
+ * if (propValue != null && typeof propValue !== 'string' &&
1953
+ * !(propValue instanceof URI)) {
1954
+ * return new Error(
1955
+ * 'Expected a string or an URI for ' + propName + ' in ' +
1956
+ * componentName
1957
+ * );
1958
+ * }
1959
+ * }
1960
+ * },
1961
+ * render: function() {...}
1962
+ * });
1963
+ *
1964
+ * @internal
1965
+ */
1966
+
1967
+ var ANONYMOUS = '<<anonymous>>';
1968
+
1969
+ // Important!
1970
+ // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
1971
+ var ReactPropTypes = {
1972
+ array: createPrimitiveTypeChecker('array'),
1973
+ bool: createPrimitiveTypeChecker('boolean'),
1974
+ func: createPrimitiveTypeChecker('function'),
1975
+ number: createPrimitiveTypeChecker('number'),
1976
+ object: createPrimitiveTypeChecker('object'),
1977
+ string: createPrimitiveTypeChecker('string'),
1978
+ symbol: createPrimitiveTypeChecker('symbol'),
1979
+
1980
+ any: createAnyTypeChecker(),
1981
+ arrayOf: createArrayOfTypeChecker,
1982
+ element: createElementTypeChecker(),
1983
+ instanceOf: createInstanceTypeChecker,
1984
+ node: createNodeChecker(),
1985
+ objectOf: createObjectOfTypeChecker,
1986
+ oneOf: createEnumTypeChecker,
1987
+ oneOfType: createUnionTypeChecker,
1988
+ shape: createShapeTypeChecker
1989
+ };
1990
+
1991
+ /**
1992
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
1993
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1994
+ */
1995
+ /*eslint-disable no-self-compare*/
1996
+ function is(x, y) {
1997
+ // SameValue algorithm
1998
+ if (x === y) {
1999
+ // Steps 1-5, 7-10
2000
+ // Steps 6.b-6.e: +0 != -0
2001
+ return x !== 0 || 1 / x === 1 / y;
2002
+ } else {
2003
+ // Step 6.a: NaN == NaN
2004
+ return x !== x && y !== y;
2005
+ }
2006
+ }
2007
+ /*eslint-enable no-self-compare*/
2008
+
2009
+ /**
2010
+ * We use an Error-like object for backward compatibility as people may call
2011
+ * PropTypes directly and inspect their output. However, we don't use real
2012
+ * Errors anymore. We don't inspect their stack anyway, and creating them
2013
+ * is prohibitively expensive if they are created too often, such as what
2014
+ * happens in oneOfType() for any type before the one that matched.
2015
+ */
2016
+ function PropTypeError(message) {
2017
+ this.message = message;
2018
+ this.stack = '';
2019
+ }
2020
+ // Make `instanceof Error` still work for returned errors.
2021
+ PropTypeError.prototype = Error.prototype;
2022
+
2023
+ function createChainableTypeChecker(validate) {
2024
+ {
2025
+ var manualPropTypeCallCache = {};
2026
+ var manualPropTypeWarningCount = 0;
2027
+ }
2028
+ function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
2029
+ componentName = componentName || ANONYMOUS;
2030
+ propFullName = propFullName || propName;
2031
+
2032
+ if (secret !== ReactPropTypesSecret_1$2) {
2033
+ if (throwOnDirectAccess) {
2034
+ // New behavior only for users of `prop-types` package
2035
+ invariant_1$4(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
2036
+ } else if ("development" !== 'production' && typeof console !== 'undefined') {
2037
+ // Old behavior for people using React.PropTypes
2038
+ var cacheKey = componentName + ':' + propName;
2039
+ if (!manualPropTypeCallCache[cacheKey] &&
2040
+ // Avoid spamming the console because they are often not actionable except for lib authors
2041
+ manualPropTypeWarningCount < 3) {
2042
+ warning_1$4(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName);
2043
+ manualPropTypeCallCache[cacheKey] = true;
2044
+ manualPropTypeWarningCount++;
2045
+ }
2046
+ }
2047
+ }
2048
+ if (props[propName] == null) {
2049
+ if (isRequired) {
2050
+ if (props[propName] === null) {
2051
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
2052
+ }
2053
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
2054
+ }
2055
+ return null;
2056
+ } else {
2057
+ return validate(props, propName, componentName, location, propFullName);
2058
+ }
2059
+ }
2060
+
2061
+ var chainedCheckType = checkType.bind(null, false);
2062
+ chainedCheckType.isRequired = checkType.bind(null, true);
2063
+
2064
+ return chainedCheckType;
2065
+ }
2066
+
2067
+ function createPrimitiveTypeChecker(expectedType) {
2068
+ function validate(props, propName, componentName, location, propFullName, secret) {
2069
+ var propValue = props[propName];
2070
+ var propType = getPropType(propValue);
2071
+ if (propType !== expectedType) {
2072
+ // `propValue` being instance of, say, date/regexp, pass the 'object'
2073
+ // check, but we can offer a more precise error message here rather than
2074
+ // 'of type `object`'.
2075
+ var preciseType = getPreciseType(propValue);
2076
+
2077
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
2078
+ }
2079
+ return null;
2080
+ }
2081
+ return createChainableTypeChecker(validate);
2082
+ }
2083
+
2084
+ function createAnyTypeChecker() {
2085
+ return createChainableTypeChecker(emptyFunction_1$2.thatReturnsNull);
2086
+ }
2087
+
2088
+ function createArrayOfTypeChecker(typeChecker) {
2089
+ function validate(props, propName, componentName, location, propFullName) {
2090
+ if (typeof typeChecker !== 'function') {
2091
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
2092
+ }
2093
+ var propValue = props[propName];
2094
+ if (!Array.isArray(propValue)) {
2095
+ var propType = getPropType(propValue);
2096
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
2097
+ }
2098
+ for (var i = 0; i < propValue.length; i++) {
2099
+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1$2);
2100
+ if (error instanceof Error) {
2101
+ return error;
2102
+ }
2103
+ }
2104
+ return null;
2105
+ }
2106
+ return createChainableTypeChecker(validate);
2107
+ }
2108
+
2109
+ function createElementTypeChecker() {
2110
+ function validate(props, propName, componentName, location, propFullName) {
2111
+ var propValue = props[propName];
2112
+ if (!isValidElement(propValue)) {
2113
+ var propType = getPropType(propValue);
2114
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
2115
+ }
2116
+ return null;
2117
+ }
2118
+ return createChainableTypeChecker(validate);
2119
+ }
2120
+
2121
+ function createInstanceTypeChecker(expectedClass) {
2122
+ function validate(props, propName, componentName, location, propFullName) {
2123
+ if (!(props[propName] instanceof expectedClass)) {
2124
+ var expectedClassName = expectedClass.name || ANONYMOUS;
2125
+ var actualClassName = getClassName(props[propName]);
2126
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
2127
+ }
2128
+ return null;
2129
+ }
2130
+ return createChainableTypeChecker(validate);
2131
+ }
2132
+
2133
+ function createEnumTypeChecker(expectedValues) {
2134
+ if (!Array.isArray(expectedValues)) {
2135
+ warning_1$4(false, 'Invalid argument supplied to oneOf, expected an instance of array.');
2136
+ return emptyFunction_1$2.thatReturnsNull;
2137
+ }
2138
+
2139
+ function validate(props, propName, componentName, location, propFullName) {
2140
+ var propValue = props[propName];
2141
+ for (var i = 0; i < expectedValues.length; i++) {
2142
+ if (is(propValue, expectedValues[i])) {
2143
+ return null;
2144
+ }
2145
+ }
2146
+
2147
+ var valuesString = JSON.stringify(expectedValues);
2148
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
2149
+ }
2150
+ return createChainableTypeChecker(validate);
2151
+ }
2152
+
2153
+ function createObjectOfTypeChecker(typeChecker) {
2154
+ function validate(props, propName, componentName, location, propFullName) {
2155
+ if (typeof typeChecker !== 'function') {
2156
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
2157
+ }
2158
+ var propValue = props[propName];
2159
+ var propType = getPropType(propValue);
2160
+ if (propType !== 'object') {
2161
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
2162
+ }
2163
+ for (var key in propValue) {
2164
+ if (propValue.hasOwnProperty(key)) {
2165
+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1$2);
2166
+ if (error instanceof Error) {
2167
+ return error;
2168
+ }
2169
+ }
2170
+ }
2171
+ return null;
2172
+ }
2173
+ return createChainableTypeChecker(validate);
2174
+ }
2175
+
2176
+ function createUnionTypeChecker(arrayOfTypeCheckers) {
2177
+ if (!Array.isArray(arrayOfTypeCheckers)) {
2178
+ warning_1$4(false, 'Invalid argument supplied to oneOfType, expected an instance of array.');
2179
+ return emptyFunction_1$2.thatReturnsNull;
2180
+ }
2181
+
2182
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
2183
+ var checker = arrayOfTypeCheckers[i];
2184
+ if (typeof checker !== 'function') {
2185
+ warning_1$4(false, 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' + 'received %s at index %s.', getPostfixForTypeWarning(checker), i);
2186
+ return emptyFunction_1$2.thatReturnsNull;
2187
+ }
2188
+ }
2189
+
2190
+ function validate(props, propName, componentName, location, propFullName) {
2191
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
2192
+ var checker = arrayOfTypeCheckers[i];
2193
+ if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1$2) == null) {
2194
+ return null;
2195
+ }
2196
+ }
2197
+
2198
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
2199
+ }
2200
+ return createChainableTypeChecker(validate);
2201
+ }
2202
+
2203
+ function createNodeChecker() {
2204
+ function validate(props, propName, componentName, location, propFullName) {
2205
+ if (!isNode(props[propName])) {
2206
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
2207
+ }
2208
+ return null;
2209
+ }
2210
+ return createChainableTypeChecker(validate);
2211
+ }
2212
+
2213
+ function createShapeTypeChecker(shapeTypes) {
2214
+ function validate(props, propName, componentName, location, propFullName) {
2215
+ var propValue = props[propName];
2216
+ var propType = getPropType(propValue);
2217
+ if (propType !== 'object') {
2218
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
2219
+ }
2220
+ for (var key in shapeTypes) {
2221
+ var checker = shapeTypes[key];
2222
+ if (!checker) {
2223
+ continue;
2224
+ }
2225
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1$2);
2226
+ if (error) {
2227
+ return error;
2228
+ }
2229
+ }
2230
+ return null;
2231
+ }
2232
+ return createChainableTypeChecker(validate);
2233
+ }
2234
+
2235
+ function isNode(propValue) {
2236
+ switch (typeof propValue) {
2237
+ case 'number':
2238
+ case 'string':
2239
+ case 'undefined':
2240
+ return true;
2241
+ case 'boolean':
2242
+ return !propValue;
2243
+ case 'object':
2244
+ if (Array.isArray(propValue)) {
2245
+ return propValue.every(isNode);
2246
+ }
2247
+ if (propValue === null || isValidElement(propValue)) {
2248
+ return true;
2249
+ }
2250
+
2251
+ var iteratorFn = getIteratorFn(propValue);
2252
+ if (iteratorFn) {
2253
+ var iterator = iteratorFn.call(propValue);
2254
+ var step;
2255
+ if (iteratorFn !== propValue.entries) {
2256
+ while (!(step = iterator.next()).done) {
2257
+ if (!isNode(step.value)) {
2258
+ return false;
2259
+ }
2260
+ }
2261
+ } else {
2262
+ // Iterator will provide entry [k,v] tuples rather than values.
2263
+ while (!(step = iterator.next()).done) {
2264
+ var entry = step.value;
2265
+ if (entry) {
2266
+ if (!isNode(entry[1])) {
2267
+ return false;
2268
+ }
2269
+ }
2270
+ }
2271
+ }
2272
+ } else {
2273
+ return false;
2274
+ }
2275
+
2276
+ return true;
2277
+ default:
2278
+ return false;
2279
+ }
2280
+ }
2281
+
2282
+ function isSymbol(propType, propValue) {
2283
+ // Native Symbol.
2284
+ if (propType === 'symbol') {
2285
+ return true;
2286
+ }
2287
+
2288
+ // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
2289
+ if (propValue['@@toStringTag'] === 'Symbol') {
2290
+ return true;
2291
+ }
2292
+
2293
+ // Fallback for non-spec compliant Symbols which are polyfilled.
2294
+ if (typeof Symbol === 'function' && propValue instanceof Symbol) {
2295
+ return true;
2296
+ }
2297
+
2298
+ return false;
2299
+ }
2300
+
2301
+ // Equivalent of `typeof` but with special handling for array and regexp.
2302
+ function getPropType(propValue) {
2303
+ var propType = typeof propValue;
2304
+ if (Array.isArray(propValue)) {
2305
+ return 'array';
2306
+ }
2307
+ if (propValue instanceof RegExp) {
2308
+ // Old webkits (at least until Android 4.0) return 'function' rather than
2309
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
2310
+ // passes PropTypes.object.
2311
+ return 'object';
2312
+ }
2313
+ if (isSymbol(propType, propValue)) {
2314
+ return 'symbol';
2315
+ }
2316
+ return propType;
2317
+ }
2318
+
2319
+ // This handles more types than `getPropType`. Only used for error messages.
2320
+ // See `createPrimitiveTypeChecker`.
2321
+ function getPreciseType(propValue) {
2322
+ if (typeof propValue === 'undefined' || propValue === null) {
2323
+ return '' + propValue;
2324
+ }
2325
+ var propType = getPropType(propValue);
2326
+ if (propType === 'object') {
2327
+ if (propValue instanceof Date) {
2328
+ return 'date';
2329
+ } else if (propValue instanceof RegExp) {
2330
+ return 'regexp';
2331
+ }
2332
+ }
2333
+ return propType;
2334
+ }
2335
+
2336
+ // Returns a string that is postfixed to a warning about an invalid type.
2337
+ // For example, "undefined" or "of type array"
2338
+ function getPostfixForTypeWarning(value) {
2339
+ var type = getPreciseType(value);
2340
+ switch (type) {
2341
+ case 'array':
2342
+ case 'object':
2343
+ return 'an ' + type;
2344
+ case 'boolean':
2345
+ case 'date':
2346
+ case 'regexp':
2347
+ return 'a ' + type;
2348
+ default:
2349
+ return type;
2350
+ }
2351
+ }
2352
+
2353
+ // Returns class name of the object, if any.
2354
+ function getClassName(propValue) {
2355
+ if (!propValue.constructor || !propValue.constructor.name) {
2356
+ return ANONYMOUS;
2357
+ }
2358
+ return propValue.constructor.name;
2359
+ }
2360
+
2361
+ ReactPropTypes.checkPropTypes = checkPropTypes_1$2;
2362
+ ReactPropTypes.PropTypes = ReactPropTypes;
2363
+
2364
+ return ReactPropTypes;
2365
+ };
2366
+
2367
+ var propTypes$1 = createCommonjsModule(function (module) {
2368
+ /**
2369
+ * Copyright 2013-present, Facebook, Inc.
2370
+ * All rights reserved.
2371
+ *
2372
+ * This source code is licensed under the BSD-style license found in the
2373
+ * LICENSE file in the root directory of this source tree. An additional grant
2374
+ * of patent rights can be found in the PATENTS file in the same directory.
2375
+ */
2376
+
2377
+ {
2378
+ var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') || 0xeac7;
2379
+
2380
+ var isValidElement = function (object) {
2381
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2382
+ };
2383
+
2384
+ // By explicitly using `prop-types` you are opting into new development behavior.
2385
+ // http://fb.me/prop-types-in-prod
2386
+ var throwOnDirectAccess = true;
2387
+ module.exports = factoryWithTypeCheckers$2(isValidElement, throwOnDirectAccess);
2388
+ }
2389
+ });
2390
+
2391
+ var _extends = Object.assign || function (target) {
2392
+ for (var i = 1; i < arguments.length; i++) {
2393
+ var source = arguments[i];for (var key in source) {
2394
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
2395
+ target[key] = source[key];
2396
+ }
2397
+ }
2398
+ }return target;
2399
+ };
2400
+
2401
+ function _classCallCheck(instance, Constructor) {
2402
+ if (!(instance instanceof Constructor)) {
2403
+ throw new TypeError("Cannot call a class as a function");
2404
+ }
2405
+ }
2406
+
2407
+ function _possibleConstructorReturn(self, call) {
2408
+ if (!self) {
2409
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2410
+ }return call && (typeof call === "object" || typeof call === "function") ? call : self;
2411
+ }
2412
+
2413
+ function _inherits(subClass, superClass) {
2414
+ if (typeof superClass !== "function" && superClass !== null) {
2415
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
2416
+ }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;
2417
+ }
2418
+
2419
+ /**
2420
+ * The public API for putting history on context.
2421
+ */
2422
+
2423
+ var Router$1 = function (_React$Component) {
2424
+ _inherits(Router, _React$Component);
2425
+
2426
+ function Router() {
2427
+ var _temp, _this, _ret;
2428
+
2429
+ _classCallCheck(this, Router);
2430
+
2431
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
2432
+ args[_key] = arguments[_key];
2433
+ }
2434
+
2435
+ return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
2436
+ match: _this.computeMatch(_this.props.history.location.pathname)
2437
+ }, _temp), _possibleConstructorReturn(_this, _ret);
2438
+ }
2439
+
2440
+ Router.prototype.getChildContext = function getChildContext() {
2441
+ return {
2442
+ router: _extends({}, this.context.router, {
2443
+ history: this.props.history,
2444
+ route: {
2445
+ location: this.props.history.location,
2446
+ match: this.state.match
2447
+ }
2448
+ })
2449
+ };
2450
+ };
2451
+
2452
+ Router.prototype.computeMatch = function computeMatch(pathname) {
2453
+ return {
2454
+ path: '/',
2455
+ url: '/',
2456
+ params: {},
2457
+ isExact: pathname === '/'
2458
+ };
2459
+ };
2460
+
2461
+ Router.prototype.componentWillMount = function componentWillMount() {
2462
+ var _this2 = this;
2463
+
2464
+ var _props = this.props,
2465
+ children = _props.children,
2466
+ history = _props.history;
2467
+
2468
+ invariant_1$3(children == null || React.Children.count(children) === 1, 'A <Router> may have only one child element');
2469
+
2470
+ // Do this here so we can setState when a <Redirect> changes the
2471
+ // location in componentWillMount. This happens e.g. when doing
2472
+ // server rendering using a <StaticRouter>.
2473
+ this.unlisten = history.listen(function () {
2474
+ _this2.setState({
2475
+ match: _this2.computeMatch(history.location.pathname)
2476
+ });
2477
+ });
2478
+ };
2479
+
2480
+ Router.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
2481
+ warning_1$3(this.props.history === nextProps.history, 'You cannot change <Router history>');
2482
+ };
2483
+
2484
+ Router.prototype.componentWillUnmount = function componentWillUnmount() {
2485
+ this.unlisten();
2486
+ };
2487
+
2488
+ Router.prototype.render = function render() {
2489
+ var children = this.props.children;
2490
+
2491
+ return children ? React.Children.only(children) : null;
2492
+ };
2493
+
2494
+ return Router;
2495
+ }(React.Component);
2496
+
2497
+ Router$1.propTypes = {
2498
+ history: propTypes$1.object.isRequired,
2499
+ children: propTypes$1.node
2500
+ };
2501
+ Router$1.contextTypes = {
2502
+ router: propTypes$1.object
2503
+ };
2504
+ Router$1.childContextTypes = {
2505
+ router: propTypes$1.object.isRequired
2506
+ };
2507
+
1594
2508
  // Written in this round about way for babel-transform-imports
1595
2509
 
1596
- var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
2510
+ var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
2511
+ return typeof obj;
2512
+ } : function (obj) {
2513
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2514
+ };
2515
+
2516
+
2517
+
2518
+
2519
+
2520
+
2521
+
2522
+
2523
+
2524
+
2525
+
2526
+ var classCallCheck = function (instance, Constructor) {
2527
+ if (!(instance instanceof Constructor)) {
2528
+ throw new TypeError("Cannot call a class as a function");
2529
+ }
2530
+ };
2531
+
2532
+
2533
+
2534
+
2535
+
2536
+
2537
+
2538
+
2539
+
2540
+ var _extends$1 = Object.assign || function (target) {
2541
+ for (var i = 1; i < arguments.length; i++) {
2542
+ var source = arguments[i];
2543
+
2544
+ for (var key in source) {
2545
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
2546
+ target[key] = source[key];
2547
+ }
2548
+ }
2549
+ }
2550
+
2551
+ return target;
2552
+ };
2553
+
2554
+
2555
+
2556
+ var inherits = function (subClass, superClass) {
2557
+ if (typeof superClass !== "function" && superClass !== null) {
2558
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
2559
+ }
2560
+
2561
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
2562
+ constructor: {
2563
+ value: subClass,
2564
+ enumerable: false,
2565
+ writable: true,
2566
+ configurable: true
2567
+ }
2568
+ });
2569
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
2570
+ };
2571
+
2572
+
2573
+
2574
+
2575
+
2576
+
2577
+
2578
+
2579
+
2580
+ var objectWithoutProperties = function (obj, keys) {
2581
+ var target = {};
2582
+
2583
+ for (var i in obj) {
2584
+ if (keys.indexOf(i) >= 0) continue;
2585
+ if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
2586
+ target[i] = obj[i];
2587
+ }
2588
+
2589
+ return target;
2590
+ };
2591
+
2592
+ var possibleConstructorReturn = function (self, call) {
2593
+ if (!self) {
2594
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2595
+ }
2596
+
2597
+ return call && (typeof call === "object" || typeof call === "function") ? call : self;
2598
+ };
2599
+
2600
+ /**
2601
+ * The public API for a <Router> that uses HTML5 history.
2602
+ */
2603
+
2604
+ var BrowserRouter = function (_React$Component) {
2605
+ inherits(BrowserRouter, _React$Component);
2606
+
2607
+ function BrowserRouter() {
2608
+ var _temp, _this, _ret;
2609
+
2610
+ classCallCheck(this, BrowserRouter);
2611
+
2612
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
2613
+ args[_key] = arguments[_key];
2614
+ }
2615
+
2616
+ 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);
2617
+ }
2618
+
2619
+ BrowserRouter.prototype.componentWillMount = function componentWillMount() {
2620
+ warning_1(!this.props.history, '<BrowserRouter> ignores the history prop. To use a custom history, ' + 'use `import { Router }` instead of `import { BrowserRouter as Router }`.');
2621
+ };
2622
+
2623
+ BrowserRouter.prototype.render = function render() {
2624
+ return React.createElement(Router$1, { history: this.history, children: this.props.children });
2625
+ };
2626
+
2627
+ return BrowserRouter;
2628
+ }(React.Component);
2629
+
2630
+ BrowserRouter.propTypes = {
2631
+ basename: propTypes.string,
2632
+ forceRefresh: propTypes.bool,
2633
+ getUserConfirmation: propTypes.func,
2634
+ keyLength: propTypes.number,
2635
+ children: propTypes.node
2636
+ };
2637
+
2638
+ var createHashHistory_1 = createCommonjsModule(function (module, exports) {
2639
+ 'use strict';
2640
+
2641
+ exports.__esModule = true;
2642
+
2643
+ 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; };
2644
+
2645
+
2646
+
2647
+ var _warning2 = _interopRequireDefault(warning_1);
2648
+
2649
+
2650
+
2651
+ var _invariant2 = _interopRequireDefault(invariant_1$2);
2652
+
2653
+
2654
+
2655
+
2656
+
2657
+
2658
+
2659
+ var _createTransitionManager2 = _interopRequireDefault(createTransitionManager_1);
2660
+
2661
+
2662
+
2663
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2664
+
2665
+ var HashChangeEvent = 'hashchange';
2666
+
2667
+ var HashPathCoders = {
2668
+ hashbang: {
2669
+ encodePath: function encodePath(path) {
2670
+ return path.charAt(0) === '!' ? path : '!/' + (0, PathUtils.stripLeadingSlash)(path);
2671
+ },
2672
+ decodePath: function decodePath(path) {
2673
+ return path.charAt(0) === '!' ? path.substr(1) : path;
2674
+ }
2675
+ },
2676
+ noslash: {
2677
+ encodePath: PathUtils.stripLeadingSlash,
2678
+ decodePath: PathUtils.addLeadingSlash
2679
+ },
2680
+ slash: {
2681
+ encodePath: PathUtils.addLeadingSlash,
2682
+ decodePath: PathUtils.addLeadingSlash
2683
+ }
2684
+ };
2685
+
2686
+ var getHashPath = function getHashPath() {
2687
+ // We can't use window.location.hash here because it's not
2688
+ // consistent across browsers - Firefox will pre-decode it!
2689
+ var href = window.location.href;
2690
+ var hashIndex = href.indexOf('#');
2691
+ return hashIndex === -1 ? '' : href.substring(hashIndex + 1);
2692
+ };
2693
+
2694
+ var pushHashPath = function pushHashPath(path) {
2695
+ return window.location.hash = path;
2696
+ };
2697
+
2698
+ var replaceHashPath = function replaceHashPath(path) {
2699
+ var hashIndex = window.location.href.indexOf('#');
2700
+
2701
+ window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);
2702
+ };
2703
+
2704
+ var createHashHistory = function createHashHistory() {
2705
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2706
+
2707
+ (0, _invariant2.default)(DOMUtils.canUseDOM, 'Hash history needs a DOM');
2708
+
2709
+ var globalHistory = window.history;
2710
+ var canGoWithoutReload = (0, DOMUtils.supportsGoWithoutReloadUsingHash)();
2711
+
2712
+ var _props$getUserConfirm = props.getUserConfirmation,
2713
+ getUserConfirmation = _props$getUserConfirm === undefined ? DOMUtils.getConfirmation : _props$getUserConfirm,
2714
+ _props$hashType = props.hashType,
2715
+ hashType = _props$hashType === undefined ? 'slash' : _props$hashType;
2716
+
2717
+ var basename = props.basename ? (0, PathUtils.stripTrailingSlash)((0, PathUtils.addLeadingSlash)(props.basename)) : '';
2718
+
2719
+ var _HashPathCoders$hashT = HashPathCoders[hashType],
2720
+ encodePath = _HashPathCoders$hashT.encodePath,
2721
+ decodePath = _HashPathCoders$hashT.decodePath;
2722
+
2723
+
2724
+ var getDOMLocation = function getDOMLocation() {
2725
+ var path = decodePath(getHashPath());
2726
+
2727
+ (0, _warning2.default)(!basename || (0, PathUtils.hasBasename)(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".');
2728
+
2729
+ if (basename) path = (0, PathUtils.stripBasename)(path, basename);
2730
+
2731
+ return (0, LocationUtils.createLocation)(path);
2732
+ };
2733
+
2734
+ var transitionManager = (0, _createTransitionManager2.default)();
2735
+
2736
+ var setState = function setState(nextState) {
2737
+ _extends(history, nextState);
2738
+
2739
+ history.length = globalHistory.length;
2740
+
2741
+ transitionManager.notifyListeners(history.location, history.action);
2742
+ };
2743
+
2744
+ var forceNextPop = false;
2745
+ var ignorePath = null;
2746
+
2747
+ var handleHashChange = function handleHashChange() {
2748
+ var path = getHashPath();
2749
+ var encodedPath = encodePath(path);
2750
+
2751
+ if (path !== encodedPath) {
2752
+ // Ensure we always have a properly-encoded hash.
2753
+ replaceHashPath(encodedPath);
2754
+ } else {
2755
+ var location = getDOMLocation();
2756
+ var prevLocation = history.location;
2757
+
2758
+ if (!forceNextPop && (0, LocationUtils.locationsAreEqual)(prevLocation, location)) return; // A hashchange doesn't always == location change.
2759
+
2760
+ if (ignorePath === (0, PathUtils.createPath)(location)) return; // Ignore this change; we already setState in push/replace.
2761
+
2762
+ ignorePath = null;
2763
+
2764
+ handlePop(location);
2765
+ }
2766
+ };
2767
+
2768
+ var handlePop = function handlePop(location) {
2769
+ if (forceNextPop) {
2770
+ forceNextPop = false;
2771
+ setState();
2772
+ } else {
2773
+ var action = 'POP';
2774
+
2775
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
2776
+ if (ok) {
2777
+ setState({ action: action, location: location });
2778
+ } else {
2779
+ revertPop(location);
2780
+ }
2781
+ });
2782
+ }
2783
+ };
2784
+
2785
+ var revertPop = function revertPop(fromLocation) {
2786
+ var toLocation = history.location;
2787
+
2788
+ // TODO: We could probably make this more reliable by
2789
+ // keeping a list of paths we've seen in sessionStorage.
2790
+ // Instead, we just default to 0 for paths we don't know.
2791
+
2792
+ var toIndex = allPaths.lastIndexOf((0, PathUtils.createPath)(toLocation));
2793
+
2794
+ if (toIndex === -1) toIndex = 0;
2795
+
2796
+ var fromIndex = allPaths.lastIndexOf((0, PathUtils.createPath)(fromLocation));
2797
+
2798
+ if (fromIndex === -1) fromIndex = 0;
2799
+
2800
+ var delta = toIndex - fromIndex;
2801
+
2802
+ if (delta) {
2803
+ forceNextPop = true;
2804
+ go(delta);
2805
+ }
2806
+ };
2807
+
2808
+ // Ensure the hash is encoded properly before doing anything else.
2809
+ var path = getHashPath();
2810
+ var encodedPath = encodePath(path);
2811
+
2812
+ if (path !== encodedPath) replaceHashPath(encodedPath);
2813
+
2814
+ var initialLocation = getDOMLocation();
2815
+ var allPaths = [(0, PathUtils.createPath)(initialLocation)];
2816
+
2817
+ // Public interface
2818
+
2819
+ var createHref = function createHref(location) {
2820
+ return '#' + encodePath(basename + (0, PathUtils.createPath)(location));
2821
+ };
2822
+
2823
+ var push = function push(path, state) {
2824
+ (0, _warning2.default)(state === undefined, 'Hash history cannot push state; it is ignored');
2825
+
2826
+ var action = 'PUSH';
2827
+ var location = (0, LocationUtils.createLocation)(path, undefined, undefined, history.location);
2828
+
2829
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
2830
+ if (!ok) return;
2831
+
2832
+ var path = (0, PathUtils.createPath)(location);
2833
+ var encodedPath = encodePath(basename + path);
2834
+ var hashChanged = getHashPath() !== encodedPath;
2835
+
2836
+ if (hashChanged) {
2837
+ // We cannot tell if a hashchange was caused by a PUSH, so we'd
2838
+ // rather setState here and ignore the hashchange. The caveat here
2839
+ // is that other hash histories in the page will consider it a POP.
2840
+ ignorePath = path;
2841
+ pushHashPath(encodedPath);
2842
+
2843
+ var prevIndex = allPaths.lastIndexOf((0, PathUtils.createPath)(history.location));
2844
+ var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
2845
+
2846
+ nextPaths.push(path);
2847
+ allPaths = nextPaths;
2848
+
2849
+ setState({ action: action, location: location });
2850
+ } else {
2851
+ (0, _warning2.default)(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack');
2852
+
2853
+ setState();
2854
+ }
2855
+ });
2856
+ };
2857
+
2858
+ var replace = function replace(path, state) {
2859
+ (0, _warning2.default)(state === undefined, 'Hash history cannot replace state; it is ignored');
2860
+
2861
+ var action = 'REPLACE';
2862
+ var location = (0, LocationUtils.createLocation)(path, undefined, undefined, history.location);
2863
+
2864
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
2865
+ if (!ok) return;
2866
+
2867
+ var path = (0, PathUtils.createPath)(location);
2868
+ var encodedPath = encodePath(basename + path);
2869
+ var hashChanged = getHashPath() !== encodedPath;
2870
+
2871
+ if (hashChanged) {
2872
+ // We cannot tell if a hashchange was caused by a REPLACE, so we'd
2873
+ // rather setState here and ignore the hashchange. The caveat here
2874
+ // is that other hash histories in the page will consider it a POP.
2875
+ ignorePath = path;
2876
+ replaceHashPath(encodedPath);
2877
+ }
2878
+
2879
+ var prevIndex = allPaths.indexOf((0, PathUtils.createPath)(history.location));
2880
+
2881
+ if (prevIndex !== -1) allPaths[prevIndex] = path;
2882
+
2883
+ setState({ action: action, location: location });
2884
+ });
2885
+ };
2886
+
2887
+ var go = function go(n) {
2888
+ (0, _warning2.default)(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser');
2889
+
2890
+ globalHistory.go(n);
2891
+ };
2892
+
2893
+ var goBack = function goBack() {
2894
+ return go(-1);
2895
+ };
2896
+
2897
+ var goForward = function goForward() {
2898
+ return go(1);
2899
+ };
2900
+
2901
+ var listenerCount = 0;
2902
+
2903
+ var checkDOMListeners = function checkDOMListeners(delta) {
2904
+ listenerCount += delta;
2905
+
2906
+ if (listenerCount === 1) {
2907
+ (0, DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange);
2908
+ } else if (listenerCount === 0) {
2909
+ (0, DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange);
2910
+ }
2911
+ };
2912
+
2913
+ var isBlocked = false;
2914
+
2915
+ var block = function block() {
2916
+ var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2917
+
2918
+ var unblock = transitionManager.setPrompt(prompt);
2919
+
2920
+ if (!isBlocked) {
2921
+ checkDOMListeners(1);
2922
+ isBlocked = true;
2923
+ }
2924
+
2925
+ return function () {
2926
+ if (isBlocked) {
2927
+ isBlocked = false;
2928
+ checkDOMListeners(-1);
2929
+ }
2930
+
2931
+ return unblock();
2932
+ };
2933
+ };
2934
+
2935
+ var listen = function listen(listener) {
2936
+ var unlisten = transitionManager.appendListener(listener);
2937
+ checkDOMListeners(1);
2938
+
2939
+ return function () {
2940
+ checkDOMListeners(-1);
2941
+ unlisten();
2942
+ };
2943
+ };
2944
+
2945
+ var history = {
2946
+ length: globalHistory.length,
2947
+ action: 'POP',
2948
+ location: initialLocation,
2949
+ createHref: createHref,
2950
+ push: push,
2951
+ replace: replace,
2952
+ go: go,
2953
+ goBack: goBack,
2954
+ goForward: goForward,
2955
+ block: block,
2956
+ listen: listen
2957
+ };
2958
+
2959
+ return history;
2960
+ };
2961
+
2962
+ exports.default = createHashHistory;
2963
+ });
2964
+
2965
+ var createHistory$1 = unwrapExports(createHashHistory_1);
2966
+
2967
+ /**
2968
+ * The public API for a <Router> that uses window.location.hash.
2969
+ */
2970
+
2971
+ var HashRouter = function (_React$Component) {
2972
+ inherits(HashRouter, _React$Component);
2973
+
2974
+ function HashRouter() {
2975
+ var _temp, _this, _ret;
2976
+
2977
+ classCallCheck(this, HashRouter);
2978
+
2979
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
2980
+ args[_key] = arguments[_key];
2981
+ }
2982
+
2983
+ return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.history = createHistory$1(_this.props), _temp), possibleConstructorReturn(_this, _ret);
2984
+ }
2985
+
2986
+ HashRouter.prototype.componentWillMount = function componentWillMount() {
2987
+ warning_1(!this.props.history, '<HashRouter> ignores the history prop. To use a custom history, ' + 'use `import { Router }` instead of `import { HashRouter as Router }`.');
2988
+ };
2989
+
2990
+ HashRouter.prototype.render = function render() {
2991
+ return React.createElement(Router$1, { history: this.history, children: this.props.children });
2992
+ };
2993
+
2994
+ return HashRouter;
2995
+ }(React.Component);
2996
+
2997
+ HashRouter.propTypes = {
2998
+ basename: propTypes.string,
2999
+ getUserConfirmation: propTypes.func,
3000
+ hashType: propTypes.oneOf(['hashbang', 'noslash', 'slash']),
3001
+ children: propTypes.node
3002
+ };
3003
+
3004
+ var isModifiedEvent = function isModifiedEvent(event) {
3005
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
3006
+ };
3007
+
3008
+ /**
3009
+ * The public API for rendering a history-aware <a>.
3010
+ */
3011
+
3012
+ var Link = function (_React$Component) {
3013
+ inherits(Link, _React$Component);
3014
+
3015
+ function Link() {
3016
+ var _temp, _this, _ret;
3017
+
3018
+ classCallCheck(this, Link);
3019
+
3020
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
3021
+ args[_key] = arguments[_key];
3022
+ }
3023
+
3024
+ return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleClick = function (event) {
3025
+ if (_this.props.onClick) _this.props.onClick(event);
3026
+
3027
+ if (!event.defaultPrevented && // onClick prevented default
3028
+ event.button === 0 && // ignore right clicks
3029
+ !_this.props.target && // let browser handle "target=_blank" etc.
3030
+ !isModifiedEvent(event) // ignore clicks with modifier keys
3031
+ ) {
3032
+ event.preventDefault();
3033
+
3034
+ var history = _this.context.router.history;
3035
+ var _this$props = _this.props,
3036
+ replace = _this$props.replace,
3037
+ to = _this$props.to;
3038
+
3039
+
3040
+ if (replace) {
3041
+ history.replace(to);
3042
+ } else {
3043
+ history.push(to);
3044
+ }
3045
+ }
3046
+ }, _temp), possibleConstructorReturn(_this, _ret);
3047
+ }
3048
+
3049
+ Link.prototype.render = function render() {
3050
+ var _props = this.props,
3051
+ replace = _props.replace,
3052
+ to = _props.to,
3053
+ innerRef = _props.innerRef,
3054
+ props = objectWithoutProperties(_props, ['replace', 'to', 'innerRef']); // eslint-disable-line no-unused-vars
3055
+
3056
+ invariant_1$2(this.context.router, 'You should not use <Link> outside a <Router>');
3057
+
3058
+ var href = this.context.router.history.createHref(typeof to === 'string' ? { pathname: to } : to);
3059
+
3060
+ return React.createElement('a', _extends$1({}, props, { onClick: this.handleClick, href: href, ref: innerRef }));
3061
+ };
3062
+
3063
+ return Link;
3064
+ }(React.Component);
3065
+
3066
+ Link.propTypes = {
3067
+ onClick: propTypes.func,
3068
+ target: propTypes.string,
3069
+ replace: propTypes.bool,
3070
+ to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired,
3071
+ innerRef: propTypes.oneOfType([propTypes.string, propTypes.func])
3072
+ };
3073
+ Link.defaultProps = {
3074
+ replace: false
3075
+ };
3076
+ Link.contextTypes = {
3077
+ router: propTypes.shape({
3078
+ history: propTypes.shape({
3079
+ push: propTypes.func.isRequired,
3080
+ replace: propTypes.func.isRequired,
3081
+ createHref: propTypes.func.isRequired
3082
+ }).isRequired
3083
+ }).isRequired
3084
+ };
3085
+
3086
+ var PathUtils$2 = createCommonjsModule(function (module, exports) {
3087
+ 'use strict';
3088
+
3089
+ exports.__esModule = true;
3090
+ var addLeadingSlash = exports.addLeadingSlash = function addLeadingSlash(path) {
3091
+ return path.charAt(0) === '/' ? path : '/' + path;
3092
+ };
3093
+
3094
+ var stripLeadingSlash = exports.stripLeadingSlash = function stripLeadingSlash(path) {
3095
+ return path.charAt(0) === '/' ? path.substr(1) : path;
3096
+ };
3097
+
3098
+ var hasBasename = exports.hasBasename = function hasBasename(path, prefix) {
3099
+ return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
3100
+ };
3101
+
3102
+ var stripBasename = exports.stripBasename = function stripBasename(path, prefix) {
3103
+ return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
3104
+ };
3105
+
3106
+ var stripTrailingSlash = exports.stripTrailingSlash = function stripTrailingSlash(path) {
3107
+ return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
3108
+ };
3109
+
3110
+ var parsePath = exports.parsePath = function parsePath(path) {
3111
+ var pathname = path || '/';
3112
+ var search = '';
3113
+ var hash = '';
3114
+
3115
+ var hashIndex = pathname.indexOf('#');
3116
+ if (hashIndex !== -1) {
3117
+ hash = pathname.substr(hashIndex);
3118
+ pathname = pathname.substr(0, hashIndex);
3119
+ }
3120
+
3121
+ var searchIndex = pathname.indexOf('?');
3122
+ if (searchIndex !== -1) {
3123
+ search = pathname.substr(searchIndex);
3124
+ pathname = pathname.substr(0, searchIndex);
3125
+ }
3126
+
3127
+ return {
3128
+ pathname: pathname,
3129
+ search: search === '?' ? '' : search,
3130
+ hash: hash === '#' ? '' : hash
3131
+ };
3132
+ };
3133
+
3134
+ var createPath = exports.createPath = function createPath(location) {
3135
+ var pathname = location.pathname,
3136
+ search = location.search,
3137
+ hash = location.hash;
3138
+
3139
+ var path = pathname || '/';
3140
+
3141
+ if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search;
3142
+
3143
+ if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash;
3144
+
3145
+ return path;
3146
+ };
3147
+ });
3148
+
3149
+ var PathUtils_1$1 = PathUtils$2.addLeadingSlash;
3150
+ var PathUtils_6$1 = PathUtils$2.parsePath;
3151
+ var PathUtils_7$1 = PathUtils$2.createPath;
3152
+
3153
+ function isAbsolute$1(pathname) {
3154
+ return pathname.charAt(0) === '/';
3155
+ }
3156
+
3157
+ // About 1.5x faster than the two-arg version of Array#splice()
3158
+ function spliceOne$1(list, index) {
3159
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
3160
+ list[i] = list[k];
3161
+ }
3162
+
3163
+ list.pop();
3164
+ }
3165
+
3166
+ // This implementation is based heavily on node's url.parse
3167
+ function resolvePathname$3(to) {
3168
+ var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3169
+
3170
+ var toParts = to && to.split('/') || [];
3171
+ var fromParts = from && from.split('/') || [];
3172
+
3173
+ var isToAbs = to && isAbsolute$1(to);
3174
+ var isFromAbs = from && isAbsolute$1(from);
3175
+ var mustEndAbs = isToAbs || isFromAbs;
3176
+
3177
+ if (to && isAbsolute$1(to)) {
3178
+ // to is absolute
3179
+ fromParts = toParts;
3180
+ } else if (toParts.length) {
3181
+ // to is relative, drop the filename
3182
+ fromParts.pop();
3183
+ fromParts = fromParts.concat(toParts);
3184
+ }
3185
+
3186
+ if (!fromParts.length) return '/';
3187
+
3188
+ var hasTrailingSlash = void 0;
3189
+ if (fromParts.length) {
3190
+ var last = fromParts[fromParts.length - 1];
3191
+ hasTrailingSlash = last === '.' || last === '..' || last === '';
3192
+ } else {
3193
+ hasTrailingSlash = false;
3194
+ }
3195
+
3196
+ var up = 0;
3197
+ for (var i = fromParts.length; i >= 0; i--) {
3198
+ var part = fromParts[i];
3199
+
3200
+ if (part === '.') {
3201
+ spliceOne$1(fromParts, i);
3202
+ } else if (part === '..') {
3203
+ spliceOne$1(fromParts, i);
3204
+ up++;
3205
+ } else if (up) {
3206
+ spliceOne$1(fromParts, i);
3207
+ up--;
3208
+ }
3209
+ }
3210
+
3211
+ if (!mustEndAbs) for (; up--; up) {
3212
+ fromParts.unshift('..');
3213
+ }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute$1(fromParts[0]))) fromParts.unshift('');
3214
+
3215
+ var result = fromParts.join('/');
3216
+
3217
+ if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
3218
+
3219
+ return result;
3220
+ }
3221
+
3222
+
3223
+
3224
+ var resolvePathname$5 = Object.freeze({
3225
+ default: resolvePathname$3
3226
+ });
3227
+
3228
+ var _typeof$2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
3229
+ return typeof obj;
3230
+ } : function (obj) {
3231
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
3232
+ };
3233
+
3234
+ function valueEqual$3(a, b) {
3235
+ if (a === b) return true;
3236
+
3237
+ if (a == null || b == null) return false;
3238
+
3239
+ if (Array.isArray(a)) {
3240
+ return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
3241
+ return valueEqual$3(item, b[index]);
3242
+ });
3243
+ }
3244
+
3245
+ var aType = typeof a === 'undefined' ? 'undefined' : _typeof$2(a);
3246
+ var bType = typeof b === 'undefined' ? 'undefined' : _typeof$2(b);
3247
+
3248
+ if (aType !== bType) return false;
3249
+
3250
+ if (aType === 'object') {
3251
+ var aValue = a.valueOf();
3252
+ var bValue = b.valueOf();
3253
+
3254
+ if (aValue !== a || bValue !== b) return valueEqual$3(aValue, bValue);
3255
+
3256
+ var aKeys = Object.keys(a);
3257
+ var bKeys = Object.keys(b);
3258
+
3259
+ if (aKeys.length !== bKeys.length) return false;
3260
+
3261
+ return aKeys.every(function (key) {
3262
+ return valueEqual$3(a[key], b[key]);
3263
+ });
3264
+ }
3265
+
3266
+ return false;
3267
+ }
3268
+
3269
+
3270
+
3271
+ var valueEqual$5 = Object.freeze({
3272
+ default: valueEqual$3
3273
+ });
3274
+
3275
+ var _resolvePathname$1 = ( resolvePathname$5 && resolvePathname$3 ) || resolvePathname$5;
3276
+
3277
+ var _valueEqual$1 = ( valueEqual$5 && valueEqual$3 ) || valueEqual$5;
3278
+
3279
+ var LocationUtils$2 = createCommonjsModule(function (module, exports) {
3280
+ 'use strict';
3281
+
3282
+ exports.__esModule = true;
3283
+ exports.locationsAreEqual = exports.createLocation = undefined;
3284
+
3285
+ var _extends = Object.assign || function (target) {
3286
+ for (var i = 1; i < arguments.length; i++) {
3287
+ var source = arguments[i];for (var key in source) {
3288
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
3289
+ target[key] = source[key];
3290
+ }
3291
+ }
3292
+ }return target;
3293
+ };
3294
+
3295
+
3296
+
3297
+ var _resolvePathname2 = _interopRequireDefault(_resolvePathname$1);
3298
+
3299
+
3300
+
3301
+ var _valueEqual2 = _interopRequireDefault(_valueEqual$1);
3302
+
3303
+
3304
+
3305
+ function _interopRequireDefault(obj) {
3306
+ return obj && obj.__esModule ? obj : { default: obj };
3307
+ }
3308
+
3309
+ var createLocation = exports.createLocation = function createLocation(path, state, key, currentLocation) {
3310
+ var location = void 0;
3311
+ if (typeof path === 'string') {
3312
+ // Two-arg form: push(path, state)
3313
+ location = (0, PathUtils$2.parsePath)(path);
3314
+ location.state = state;
3315
+ } else {
3316
+ // One-arg form: push(location)
3317
+ location = _extends({}, path);
3318
+
3319
+ if (location.pathname === undefined) location.pathname = '';
3320
+
3321
+ if (location.search) {
3322
+ if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
3323
+ } else {
3324
+ location.search = '';
3325
+ }
3326
+
3327
+ if (location.hash) {
3328
+ if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
3329
+ } else {
3330
+ location.hash = '';
3331
+ }
3332
+
3333
+ if (state !== undefined && location.state === undefined) location.state = state;
3334
+ }
3335
+
3336
+ try {
3337
+ location.pathname = decodeURI(location.pathname);
3338
+ } catch (e) {
3339
+ if (e instanceof URIError) {
3340
+ throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
3341
+ } else {
3342
+ throw e;
3343
+ }
3344
+ }
3345
+
3346
+ if (key) location.key = key;
3347
+
3348
+ if (currentLocation) {
3349
+ // Resolve incomplete/relative pathname relative to current location.
3350
+ if (!location.pathname) {
3351
+ location.pathname = currentLocation.pathname;
3352
+ } else if (location.pathname.charAt(0) !== '/') {
3353
+ location.pathname = (0, _resolvePathname2.default)(location.pathname, currentLocation.pathname);
3354
+ }
3355
+ } else {
3356
+ // When there is no prior location and pathname is empty, set it to /
3357
+ if (!location.pathname) {
3358
+ location.pathname = '/';
3359
+ }
3360
+ }
3361
+
3362
+ return location;
3363
+ };
3364
+
3365
+ var locationsAreEqual = exports.locationsAreEqual = function locationsAreEqual(a, b) {
3366
+ return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && (0, _valueEqual2.default)(a.state, b.state);
3367
+ };
3368
+ });
3369
+
3370
+ var createTransitionManager_1$1 = createCommonjsModule(function (module, exports) {
3371
+ 'use strict';
3372
+
3373
+ exports.__esModule = true;
3374
+
3375
+
3376
+
3377
+ var _warning2 = _interopRequireDefault(warning_1$3);
3378
+
3379
+ function _interopRequireDefault(obj) {
3380
+ return obj && obj.__esModule ? obj : { default: obj };
3381
+ }
3382
+
3383
+ var createTransitionManager = function createTransitionManager() {
3384
+ var prompt = null;
3385
+
3386
+ var setPrompt = function setPrompt(nextPrompt) {
3387
+ (0, _warning2.default)(prompt == null, 'A history supports only one prompt at a time');
3388
+
3389
+ prompt = nextPrompt;
3390
+
3391
+ return function () {
3392
+ if (prompt === nextPrompt) prompt = null;
3393
+ };
3394
+ };
3395
+
3396
+ var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) {
3397
+ // TODO: If another transition starts while we're still confirming
3398
+ // the previous one, we may end up in a weird state. Figure out the
3399
+ // best way to handle this.
3400
+ if (prompt != null) {
3401
+ var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
3402
+
3403
+ if (typeof result === 'string') {
3404
+ if (typeof getUserConfirmation === 'function') {
3405
+ getUserConfirmation(result, callback);
3406
+ } else {
3407
+ (0, _warning2.default)(false, 'A history needs a getUserConfirmation function in order to use a prompt message');
3408
+
3409
+ callback(true);
3410
+ }
3411
+ } else {
3412
+ // Return false from a transition hook to cancel the transition.
3413
+ callback(result !== false);
3414
+ }
3415
+ } else {
3416
+ callback(true);
3417
+ }
3418
+ };
3419
+
3420
+ var listeners = [];
3421
+
3422
+ var appendListener = function appendListener(fn) {
3423
+ var isActive = true;
3424
+
3425
+ var listener = function listener() {
3426
+ if (isActive) fn.apply(undefined, arguments);
3427
+ };
3428
+
3429
+ listeners.push(listener);
3430
+
3431
+ return function () {
3432
+ isActive = false;
3433
+ listeners = listeners.filter(function (item) {
3434
+ return item !== listener;
3435
+ });
3436
+ };
3437
+ };
3438
+
3439
+ var notifyListeners = function notifyListeners() {
3440
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
3441
+ args[_key] = arguments[_key];
3442
+ }
3443
+
3444
+ listeners.forEach(function (listener) {
3445
+ return listener.apply(undefined, args);
3446
+ });
3447
+ };
3448
+
3449
+ return {
3450
+ setPrompt: setPrompt,
3451
+ confirmTransitionTo: confirmTransitionTo,
3452
+ appendListener: appendListener,
3453
+ notifyListeners: notifyListeners
3454
+ };
3455
+ };
3456
+
3457
+ exports.default = createTransitionManager;
3458
+ });
3459
+
3460
+ var createMemoryHistory_1 = createCommonjsModule(function (module, exports) {
3461
+ 'use strict';
3462
+
3463
+ exports.__esModule = true;
3464
+
3465
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
1597
3466
  return typeof obj;
1598
3467
  } : function (obj) {
1599
3468
  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1600
3469
  };
1601
3470
 
3471
+ var _extends = Object.assign || function (target) {
3472
+ for (var i = 1; i < arguments.length; i++) {
3473
+ var source = arguments[i];for (var key in source) {
3474
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
3475
+ target[key] = source[key];
3476
+ }
3477
+ }
3478
+ }return target;
3479
+ };
3480
+
3481
+
3482
+
3483
+ var _warning2 = _interopRequireDefault(warning_1$3);
3484
+
3485
+
3486
+
3487
+
3488
+
3489
+
3490
+
3491
+ var _createTransitionManager2 = _interopRequireDefault(createTransitionManager_1$1);
3492
+
3493
+ function _interopRequireDefault(obj) {
3494
+ return obj && obj.__esModule ? obj : { default: obj };
3495
+ }
3496
+
3497
+ var clamp = function clamp(n, lowerBound, upperBound) {
3498
+ return Math.min(Math.max(n, lowerBound), upperBound);
3499
+ };
3500
+
3501
+ /**
3502
+ * Creates a history object that stores locations in memory.
3503
+ */
3504
+ var createMemoryHistory = function createMemoryHistory() {
3505
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3506
+ var getUserConfirmation = props.getUserConfirmation,
3507
+ _props$initialEntries = props.initialEntries,
3508
+ initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries,
3509
+ _props$initialIndex = props.initialIndex,
3510
+ initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex,
3511
+ _props$keyLength = props.keyLength,
3512
+ keyLength = _props$keyLength === undefined ? 6 : _props$keyLength;
3513
+
3514
+ var transitionManager = (0, _createTransitionManager2.default)();
3515
+
3516
+ var setState = function setState(nextState) {
3517
+ _extends(history, nextState);
3518
+
3519
+ history.length = history.entries.length;
3520
+
3521
+ transitionManager.notifyListeners(history.location, history.action);
3522
+ };
3523
+
3524
+ var createKey = function createKey() {
3525
+ return Math.random().toString(36).substr(2, keyLength);
3526
+ };
3527
+
3528
+ var index = clamp(initialIndex, 0, initialEntries.length - 1);
3529
+ var entries = initialEntries.map(function (entry) {
3530
+ return typeof entry === 'string' ? (0, LocationUtils$2.createLocation)(entry, undefined, createKey()) : (0, LocationUtils$2.createLocation)(entry, undefined, entry.key || createKey());
3531
+ });
3532
+
3533
+ // Public interface
3534
+
3535
+ var createHref = PathUtils$2.createPath;
3536
+
3537
+ var push = function push(path, state) {
3538
+ (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');
3539
+
3540
+ var action = 'PUSH';
3541
+ var location = (0, LocationUtils$2.createLocation)(path, state, createKey(), history.location);
3542
+
3543
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
3544
+ if (!ok) return;
3545
+
3546
+ var prevIndex = history.index;
3547
+ var nextIndex = prevIndex + 1;
3548
+
3549
+ var nextEntries = history.entries.slice(0);
3550
+ if (nextEntries.length > nextIndex) {
3551
+ nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
3552
+ } else {
3553
+ nextEntries.push(location);
3554
+ }
3555
+
3556
+ setState({
3557
+ action: action,
3558
+ location: location,
3559
+ index: nextIndex,
3560
+ entries: nextEntries
3561
+ });
3562
+ });
3563
+ };
3564
+
3565
+ var replace = function replace(path, state) {
3566
+ (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');
3567
+
3568
+ var action = 'REPLACE';
3569
+ var location = (0, LocationUtils$2.createLocation)(path, state, createKey(), history.location);
3570
+
3571
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
3572
+ if (!ok) return;
3573
+
3574
+ history.entries[history.index] = location;
3575
+
3576
+ setState({ action: action, location: location });
3577
+ });
3578
+ };
3579
+
3580
+ var go = function go(n) {
3581
+ var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
3582
+
3583
+ var action = 'POP';
3584
+ var location = history.entries[nextIndex];
3585
+
3586
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
3587
+ if (ok) {
3588
+ setState({
3589
+ action: action,
3590
+ location: location,
3591
+ index: nextIndex
3592
+ });
3593
+ } else {
3594
+ // Mimic the behavior of DOM histories by
3595
+ // causing a render after a cancelled POP.
3596
+ setState();
3597
+ }
3598
+ });
3599
+ };
3600
+
3601
+ var goBack = function goBack() {
3602
+ return go(-1);
3603
+ };
3604
+
3605
+ var goForward = function goForward() {
3606
+ return go(1);
3607
+ };
3608
+
3609
+ var canGo = function canGo(n) {
3610
+ var nextIndex = history.index + n;
3611
+ return nextIndex >= 0 && nextIndex < history.entries.length;
3612
+ };
3613
+
3614
+ var block = function block() {
3615
+ var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
3616
+ return transitionManager.setPrompt(prompt);
3617
+ };
3618
+
3619
+ var listen = function listen(listener) {
3620
+ return transitionManager.appendListener(listener);
3621
+ };
3622
+
3623
+ var history = {
3624
+ length: entries.length,
3625
+ action: 'POP',
3626
+ location: entries[index],
3627
+ index: index,
3628
+ entries: entries,
3629
+ createHref: createHref,
3630
+ push: push,
3631
+ replace: replace,
3632
+ go: go,
3633
+ goBack: goBack,
3634
+ goForward: goForward,
3635
+ canGo: canGo,
3636
+ block: block,
3637
+ listen: listen
3638
+ };
3639
+
3640
+ return history;
3641
+ };
3642
+
3643
+ exports.default = createMemoryHistory;
3644
+ });
3645
+
3646
+ var createHistory$2 = unwrapExports(createMemoryHistory_1);
3647
+
3648
+ function _classCallCheck$1(instance, Constructor) {
3649
+ if (!(instance instanceof Constructor)) {
3650
+ throw new TypeError("Cannot call a class as a function");
3651
+ }
3652
+ }
3653
+
3654
+ function _possibleConstructorReturn$1(self, call) {
3655
+ if (!self) {
3656
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3657
+ }return call && (typeof call === "object" || typeof call === "function") ? call : self;
3658
+ }
3659
+
3660
+ function _inherits$1(subClass, superClass) {
3661
+ if (typeof superClass !== "function" && superClass !== null) {
3662
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
3663
+ }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;
3664
+ }
3665
+
3666
+ /**
3667
+ * The public API for a <Router> that stores location in memory.
3668
+ */
3669
+
3670
+ var MemoryRouter$1 = function (_React$Component) {
3671
+ _inherits$1(MemoryRouter, _React$Component);
3672
+
3673
+ function MemoryRouter() {
3674
+ var _temp, _this, _ret;
3675
+
3676
+ _classCallCheck$1(this, MemoryRouter);
3677
+
3678
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
3679
+ args[_key] = arguments[_key];
3680
+ }
3681
+
3682
+ return _ret = (_temp = (_this = _possibleConstructorReturn$1(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.history = createHistory$2(_this.props), _temp), _possibleConstructorReturn$1(_this, _ret);
3683
+ }
3684
+
3685
+ MemoryRouter.prototype.componentWillMount = function componentWillMount() {
3686
+ warning_1$3(!this.props.history, '<MemoryRouter> ignores the history prop. To use a custom history, ' + 'use `import { Router }` instead of `import { MemoryRouter as Router }`.');
3687
+ };
3688
+
3689
+ MemoryRouter.prototype.render = function render() {
3690
+ return React.createElement(Router$1, { history: this.history, children: this.props.children });
3691
+ };
3692
+
3693
+ return MemoryRouter;
3694
+ }(React.Component);
3695
+
3696
+ MemoryRouter$1.propTypes = {
3697
+ initialEntries: propTypes$1.array,
3698
+ initialIndex: propTypes$1.number,
3699
+ getUserConfirmation: propTypes$1.func,
3700
+ keyLength: propTypes$1.number,
3701
+ children: propTypes$1.node
3702
+ };
3703
+
3704
+ // Written in this round about way for babel-transform-imports
3705
+
3706
+ var isarray = Array.isArray || function (arr) {
3707
+ return Object.prototype.toString.call(arr) == '[object Array]';
3708
+ };
3709
+
3710
+ /**
3711
+ * Expose `pathToRegexp`.
3712
+ */
3713
+ var pathToRegexp_1 = pathToRegexp;
3714
+ var parse_1 = parse;
3715
+ var compile_1 = compile;
3716
+ var tokensToFunction_1 = tokensToFunction;
3717
+ var tokensToRegExp_1 = tokensToRegExp;
3718
+
3719
+ /**
3720
+ * The main path matching regexp utility.
3721
+ *
3722
+ * @type {RegExp}
3723
+ */
3724
+ var PATH_REGEXP = new RegExp([
3725
+ // Match escaped characters that would otherwise appear in future matches.
3726
+ // This allows the user to escape special characters that won't transform.
3727
+ '(\\\\.)',
3728
+ // Match Express-style parameters and un-named parameters with a prefix
3729
+ // and optional suffixes. Matches appear as:
3730
+ //
3731
+ // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
3732
+ // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
3733
+ // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
3734
+ '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'].join('|'), 'g');
3735
+
3736
+ /**
3737
+ * Parse a string for the raw tokens.
3738
+ *
3739
+ * @param {string} str
3740
+ * @param {Object=} options
3741
+ * @return {!Array}
3742
+ */
3743
+ function parse(str, options) {
3744
+ var tokens = [];
3745
+ var key = 0;
3746
+ var index = 0;
3747
+ var path = '';
3748
+ var defaultDelimiter = options && options.delimiter || '/';
3749
+ var res;
3750
+
3751
+ while ((res = PATH_REGEXP.exec(str)) != null) {
3752
+ var m = res[0];
3753
+ var escaped = res[1];
3754
+ var offset = res.index;
3755
+ path += str.slice(index, offset);
3756
+ index = offset + m.length;
3757
+
3758
+ // Ignore already escaped sequences.
3759
+ if (escaped) {
3760
+ path += escaped[1];
3761
+ continue;
3762
+ }
3763
+
3764
+ var next = str[index];
3765
+ var prefix = res[2];
3766
+ var name = res[3];
3767
+ var capture = res[4];
3768
+ var group = res[5];
3769
+ var modifier = res[6];
3770
+ var asterisk = res[7];
3771
+
3772
+ // Push the current path onto the tokens.
3773
+ if (path) {
3774
+ tokens.push(path);
3775
+ path = '';
3776
+ }
3777
+
3778
+ var partial = prefix != null && next != null && next !== prefix;
3779
+ var repeat = modifier === '+' || modifier === '*';
3780
+ var optional = modifier === '?' || modifier === '*';
3781
+ var delimiter = res[2] || defaultDelimiter;
3782
+ var pattern = capture || group;
3783
+
3784
+ tokens.push({
3785
+ name: name || key++,
3786
+ prefix: prefix || '',
3787
+ delimiter: delimiter,
3788
+ optional: optional,
3789
+ repeat: repeat,
3790
+ partial: partial,
3791
+ asterisk: !!asterisk,
3792
+ pattern: pattern ? escapeGroup(pattern) : asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?'
3793
+ });
3794
+ }
3795
+
3796
+ // Match any characters still remaining.
3797
+ if (index < str.length) {
3798
+ path += str.substr(index);
3799
+ }
3800
+
3801
+ // If the path exists, push it onto the end.
3802
+ if (path) {
3803
+ tokens.push(path);
3804
+ }
3805
+
3806
+ return tokens;
3807
+ }
3808
+
3809
+ /**
3810
+ * Compile a string to a template function for the path.
3811
+ *
3812
+ * @param {string} str
3813
+ * @param {Object=} options
3814
+ * @return {!function(Object=, Object=)}
3815
+ */
3816
+ function compile(str, options) {
3817
+ return tokensToFunction(parse(str, options));
3818
+ }
3819
+
3820
+ /**
3821
+ * Prettier encoding of URI path segments.
3822
+ *
3823
+ * @param {string}
3824
+ * @return {string}
3825
+ */
3826
+ function encodeURIComponentPretty(str) {
3827
+ return encodeURI(str).replace(/[\/?#]/g, function (c) {
3828
+ return '%' + c.charCodeAt(0).toString(16).toUpperCase();
3829
+ });
3830
+ }
3831
+
3832
+ /**
3833
+ * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
3834
+ *
3835
+ * @param {string}
3836
+ * @return {string}
3837
+ */
3838
+ function encodeAsterisk(str) {
3839
+ return encodeURI(str).replace(/[?#]/g, function (c) {
3840
+ return '%' + c.charCodeAt(0).toString(16).toUpperCase();
3841
+ });
3842
+ }
3843
+
3844
+ /**
3845
+ * Expose a method for transforming tokens into the path function.
3846
+ */
3847
+ function tokensToFunction(tokens) {
3848
+ // Compile all the tokens into regexps.
3849
+ var matches = new Array(tokens.length);
3850
+
3851
+ // Compile all the patterns before compilation.
3852
+ for (var i = 0; i < tokens.length; i++) {
3853
+ if (typeof tokens[i] === 'object') {
3854
+ matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
3855
+ }
3856
+ }
3857
+
3858
+ return function (obj, opts) {
3859
+ var path = '';
3860
+ var data = obj || {};
3861
+ var options = opts || {};
3862
+ var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
3863
+
3864
+ for (var i = 0; i < tokens.length; i++) {
3865
+ var token = tokens[i];
3866
+
3867
+ if (typeof token === 'string') {
3868
+ path += token;
3869
+
3870
+ continue;
3871
+ }
3872
+
3873
+ var value = data[token.name];
3874
+ var segment;
3875
+
3876
+ if (value == null) {
3877
+ if (token.optional) {
3878
+ // Prepend partial segment prefixes.
3879
+ if (token.partial) {
3880
+ path += token.prefix;
3881
+ }
3882
+
3883
+ continue;
3884
+ } else {
3885
+ throw new TypeError('Expected "' + token.name + '" to be defined');
3886
+ }
3887
+ }
3888
+
3889
+ if (isarray(value)) {
3890
+ if (!token.repeat) {
3891
+ throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`');
3892
+ }
3893
+
3894
+ if (value.length === 0) {
3895
+ if (token.optional) {
3896
+ continue;
3897
+ } else {
3898
+ throw new TypeError('Expected "' + token.name + '" to not be empty');
3899
+ }
3900
+ }
3901
+
3902
+ for (var j = 0; j < value.length; j++) {
3903
+ segment = encode(value[j]);
3904
+
3905
+ if (!matches[i].test(segment)) {
3906
+ throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`');
3907
+ }
3908
+
3909
+ path += (j === 0 ? token.prefix : token.delimiter) + segment;
3910
+ }
3911
+
3912
+ continue;
3913
+ }
3914
+
3915
+ segment = token.asterisk ? encodeAsterisk(value) : encode(value);
3916
+
3917
+ if (!matches[i].test(segment)) {
3918
+ throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"');
3919
+ }
3920
+
3921
+ path += token.prefix + segment;
3922
+ }
3923
+
3924
+ return path;
3925
+ };
3926
+ }
3927
+
3928
+ /**
3929
+ * Escape a regular expression string.
3930
+ *
3931
+ * @param {string} str
3932
+ * @return {string}
3933
+ */
3934
+ function escapeString(str) {
3935
+ return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1');
3936
+ }
3937
+
3938
+ /**
3939
+ * Escape the capturing group by escaping special characters and meaning.
3940
+ *
3941
+ * @param {string} group
3942
+ * @return {string}
3943
+ */
3944
+ function escapeGroup(group) {
3945
+ return group.replace(/([=!:$\/()])/g, '\\$1');
3946
+ }
1602
3947
 
3948
+ /**
3949
+ * Attach the keys as a property of the regexp.
3950
+ *
3951
+ * @param {!RegExp} re
3952
+ * @param {Array} keys
3953
+ * @return {!RegExp}
3954
+ */
3955
+ function attachKeys(re, keys) {
3956
+ re.keys = keys;
3957
+ return re;
3958
+ }
1603
3959
 
3960
+ /**
3961
+ * Get the flags for a regexp from the options.
3962
+ *
3963
+ * @param {Object} options
3964
+ * @return {string}
3965
+ */
3966
+ function flags(options) {
3967
+ return options.sensitive ? '' : 'i';
3968
+ }
1604
3969
 
3970
+ /**
3971
+ * Pull out keys from a regexp.
3972
+ *
3973
+ * @param {!RegExp} path
3974
+ * @param {!Array} keys
3975
+ * @return {!RegExp}
3976
+ */
3977
+ function regexpToRegexp(path, keys) {
3978
+ // Use a negative lookahead to match only capturing groups.
3979
+ var groups = path.source.match(/\((?!\?)/g);
3980
+
3981
+ if (groups) {
3982
+ for (var i = 0; i < groups.length; i++) {
3983
+ keys.push({
3984
+ name: i,
3985
+ prefix: null,
3986
+ delimiter: null,
3987
+ optional: false,
3988
+ repeat: false,
3989
+ partial: false,
3990
+ asterisk: false,
3991
+ pattern: null
3992
+ });
3993
+ }
3994
+ }
1605
3995
 
3996
+ return attachKeys(path, keys);
3997
+ }
1606
3998
 
3999
+ /**
4000
+ * Transform an array into a regexp.
4001
+ *
4002
+ * @param {!Array} path
4003
+ * @param {Array} keys
4004
+ * @param {!Object} options
4005
+ * @return {!RegExp}
4006
+ */
4007
+ function arrayToRegexp(path, keys, options) {
4008
+ var parts = [];
1607
4009
 
4010
+ for (var i = 0; i < path.length; i++) {
4011
+ parts.push(pathToRegexp(path[i], keys, options).source);
4012
+ }
1608
4013
 
4014
+ var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
1609
4015
 
4016
+ return attachKeys(regexp, keys);
4017
+ }
1610
4018
 
4019
+ /**
4020
+ * Create a path regexp from string input.
4021
+ *
4022
+ * @param {string} path
4023
+ * @param {!Array} keys
4024
+ * @param {!Object} options
4025
+ * @return {!RegExp}
4026
+ */
4027
+ function stringToRegexp(path, keys, options) {
4028
+ return tokensToRegExp(parse(path, options), keys, options);
4029
+ }
1611
4030
 
1612
- var classCallCheck = function (instance, Constructor) {
1613
- if (!(instance instanceof Constructor)) {
1614
- throw new TypeError("Cannot call a class as a function");
4031
+ /**
4032
+ * Expose a function for taking tokens and returning a RegExp.
4033
+ *
4034
+ * @param {!Array} tokens
4035
+ * @param {(Array|Object)=} keys
4036
+ * @param {Object=} options
4037
+ * @return {!RegExp}
4038
+ */
4039
+ function tokensToRegExp(tokens, keys, options) {
4040
+ if (!isarray(keys)) {
4041
+ options = /** @type {!Object} */keys || options;
4042
+ keys = [];
1615
4043
  }
1616
- };
1617
4044
 
4045
+ options = options || {};
1618
4046
 
4047
+ var strict = options.strict;
4048
+ var end = options.end !== false;
4049
+ var route = '';
1619
4050
 
4051
+ // Iterate over the tokens and create our regexp string.
4052
+ for (var i = 0; i < tokens.length; i++) {
4053
+ var token = tokens[i];
1620
4054
 
4055
+ if (typeof token === 'string') {
4056
+ route += escapeString(token);
4057
+ } else {
4058
+ var prefix = escapeString(token.prefix);
4059
+ var capture = '(?:' + token.pattern + ')';
1621
4060
 
4061
+ keys.push(token);
1622
4062
 
4063
+ if (token.repeat) {
4064
+ capture += '(?:' + prefix + capture + ')*';
4065
+ }
1623
4066
 
4067
+ if (token.optional) {
4068
+ if (!token.partial) {
4069
+ capture = '(?:' + prefix + '(' + capture + '))?';
4070
+ } else {
4071
+ capture = prefix + '(' + capture + ')?';
4072
+ }
4073
+ } else {
4074
+ capture = prefix + '(' + capture + ')';
4075
+ }
1624
4076
 
4077
+ route += capture;
4078
+ }
4079
+ }
1625
4080
 
1626
- var _extends = Object.assign || function (target) {
1627
- for (var i = 1; i < arguments.length; i++) {
1628
- var source = arguments[i];
4081
+ var delimiter = escapeString(options.delimiter || '/');
4082
+ var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
1629
4083
 
1630
- for (var key in source) {
1631
- if (Object.prototype.hasOwnProperty.call(source, key)) {
1632
- target[key] = source[key];
1633
- }
1634
- }
4084
+ // In non-strict mode we allow a slash at the end of match. If the path to
4085
+ // match already ends with a slash, we remove it for consistency. The slash
4086
+ // is valid at the end of a path match, not in the middle. This is important
4087
+ // in non-ending mode, where "/test/" shouldn't match "/test//route".
4088
+ if (!strict) {
4089
+ route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
1635
4090
  }
1636
4091
 
1637
- return target;
1638
- };
4092
+ if (end) {
4093
+ route += '$';
4094
+ } else {
4095
+ // In non-ending mode, we need the capturing groups to match as much as
4096
+ // possible by using a positive lookahead to the end or next path segment.
4097
+ route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
4098
+ }
1639
4099
 
4100
+ return attachKeys(new RegExp('^' + route, flags(options)), keys);
4101
+ }
1640
4102
 
4103
+ /**
4104
+ * Normalize the given path string, returning a regular expression.
4105
+ *
4106
+ * An empty array can be passed in for the keys, which will hold the
4107
+ * placeholder key descriptions. For example, using `/user/:id`, `keys` will
4108
+ * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
4109
+ *
4110
+ * @param {(string|RegExp|Array)} path
4111
+ * @param {(Array|Object)=} keys
4112
+ * @param {Object=} options
4113
+ * @return {!RegExp}
4114
+ */
4115
+ function pathToRegexp(path, keys, options) {
4116
+ if (!isarray(keys)) {
4117
+ options = /** @type {!Object} */keys || options;
4118
+ keys = [];
4119
+ }
1641
4120
 
1642
- var inherits = function (subClass, superClass) {
1643
- if (typeof superClass !== "function" && superClass !== null) {
1644
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
4121
+ options = options || {};
4122
+
4123
+ if (path instanceof RegExp) {
4124
+ return regexpToRegexp(path, /** @type {!Array} */keys);
1645
4125
  }
1646
4126
 
1647
- subClass.prototype = Object.create(superClass && superClass.prototype, {
1648
- constructor: {
1649
- value: subClass,
1650
- enumerable: false,
1651
- writable: true,
1652
- configurable: true
1653
- }
1654
- });
1655
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
4127
+ if (isarray(path)) {
4128
+ return arrayToRegexp( /** @type {!Array} */path, /** @type {!Array} */keys, options);
4129
+ }
4130
+
4131
+ return stringToRegexp( /** @type {string} */path, /** @type {!Array} */keys, options);
4132
+ }
4133
+
4134
+ pathToRegexp_1.parse = parse_1;
4135
+ pathToRegexp_1.compile = compile_1;
4136
+ pathToRegexp_1.tokensToFunction = tokensToFunction_1;
4137
+ pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
4138
+
4139
+ var patternCache = {};
4140
+ var cacheLimit = 10000;
4141
+ var cacheCount = 0;
4142
+
4143
+ var compilePath = function compilePath(pattern, options) {
4144
+ var cacheKey = '' + options.end + options.strict + options.sensitive;
4145
+ var cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
4146
+
4147
+ if (cache[pattern]) return cache[pattern];
4148
+
4149
+ var keys = [];
4150
+ var re = pathToRegexp_1(pattern, keys, options);
4151
+ var compiledPattern = { re: re, keys: keys };
4152
+
4153
+ if (cacheCount < cacheLimit) {
4154
+ cache[pattern] = compiledPattern;
4155
+ cacheCount++;
4156
+ }
4157
+
4158
+ return compiledPattern;
1656
4159
  };
1657
4160
 
4161
+ /**
4162
+ * Public API for matching a URL pathname to a path pattern.
4163
+ */
4164
+ var matchPath = function matchPath(pathname) {
4165
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1658
4166
 
4167
+ if (typeof options === 'string') options = { path: options };
1659
4168
 
4169
+ var _options = options,
4170
+ _options$path = _options.path,
4171
+ path = _options$path === undefined ? '/' : _options$path,
4172
+ _options$exact = _options.exact,
4173
+ exact = _options$exact === undefined ? false : _options$exact,
4174
+ _options$strict = _options.strict,
4175
+ strict = _options$strict === undefined ? false : _options$strict,
4176
+ _options$sensitive = _options.sensitive,
4177
+ sensitive = _options$sensitive === undefined ? false : _options$sensitive;
1660
4178
 
4179
+ var _compilePath = compilePath(path, { end: exact, strict: strict, sensitive: sensitive }),
4180
+ re = _compilePath.re,
4181
+ keys = _compilePath.keys;
1661
4182
 
4183
+ var match = re.exec(pathname);
1662
4184
 
4185
+ if (!match) return null;
1663
4186
 
4187
+ var url = match[0],
4188
+ values = match.slice(1);
1664
4189
 
4190
+ var isExact = pathname === url;
1665
4191
 
1666
- var objectWithoutProperties = function (obj, keys) {
1667
- var target = {};
4192
+ if (exact && !isExact) return null;
1668
4193
 
1669
- for (var i in obj) {
1670
- if (keys.indexOf(i) >= 0) continue;
1671
- if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
1672
- target[i] = obj[i];
1673
- }
4194
+ return {
4195
+ path: path, // the path pattern used to match
4196
+ url: path === '/' && url === '' ? '/' : url, // the matched portion of the URL
4197
+ isExact: isExact, // whether or not we matched exactly
4198
+ params: keys.reduce(function (memo, key, index) {
4199
+ memo[key.name] = values[index];
4200
+ return memo;
4201
+ }, {})
4202
+ };
4203
+ };
1674
4204
 
1675
- return target;
4205
+ var _extends$2 = Object.assign || function (target) {
4206
+ for (var i = 1; i < arguments.length; i++) {
4207
+ var source = arguments[i];for (var key in source) {
4208
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
4209
+ target[key] = source[key];
4210
+ }
4211
+ }
4212
+ }return target;
1676
4213
  };
1677
4214
 
1678
- var possibleConstructorReturn = function (self, call) {
4215
+ function _classCallCheck$2(instance, Constructor) {
4216
+ if (!(instance instanceof Constructor)) {
4217
+ throw new TypeError("Cannot call a class as a function");
4218
+ }
4219
+ }
4220
+
4221
+ function _possibleConstructorReturn$2(self, call) {
1679
4222
  if (!self) {
1680
4223
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1681
- }
4224
+ }return call && (typeof call === "object" || typeof call === "function") ? call : self;
4225
+ }
1682
4226
 
1683
- return call && (typeof call === "object" || typeof call === "function") ? call : self;
4227
+ function _inherits$2(subClass, superClass) {
4228
+ if (typeof superClass !== "function" && superClass !== null) {
4229
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
4230
+ }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;
4231
+ }
4232
+
4233
+ var isEmptyChildren = function isEmptyChildren(children) {
4234
+ return React.Children.count(children) === 0;
1684
4235
  };
1685
4236
 
1686
4237
  /**
1687
- * The public API for a <Router> that uses HTML5 history.
4238
+ * The public API for matching a single path and rendering.
1688
4239
  */
1689
4240
 
1690
- var BrowserRouter = function (_React$Component) {
1691
- inherits(BrowserRouter, _React$Component);
4241
+ var Route$1 = function (_React$Component) {
4242
+ _inherits$2(Route, _React$Component);
1692
4243
 
1693
- function BrowserRouter() {
4244
+ function Route() {
1694
4245
  var _temp, _this, _ret;
1695
4246
 
1696
- classCallCheck(this, BrowserRouter);
4247
+ _classCallCheck$2(this, Route);
1697
4248
 
1698
4249
  for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
1699
4250
  args[_key] = arguments[_key];
1700
4251
  }
1701
4252
 
1702
- 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);
4253
+ return _ret = (_temp = (_this = _possibleConstructorReturn$2(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
4254
+ match: _this.computeMatch(_this.props, _this.context.router)
4255
+ }, _temp), _possibleConstructorReturn$2(_this, _ret);
1703
4256
  }
1704
4257
 
1705
- BrowserRouter.prototype.componentWillMount = function componentWillMount() {
1706
- warning_1(!this.props.history, '<BrowserRouter> ignores the history prop. To use a custom history, ' + 'use `import { Router }` instead of `import { BrowserRouter as Router }`.');
1707
- };
1708
-
1709
- BrowserRouter.prototype.render = function render() {
1710
- return React.createElement(Router, { history: this.history, children: this.props.children });
4258
+ Route.prototype.getChildContext = function getChildContext() {
4259
+ return {
4260
+ router: _extends$2({}, this.context.router, {
4261
+ route: {
4262
+ location: this.props.location || this.context.router.route.location,
4263
+ match: this.state.match
4264
+ }
4265
+ })
4266
+ };
1711
4267
  };
1712
4268
 
1713
- return BrowserRouter;
1714
- }(React.Component);
1715
-
1716
- BrowserRouter.propTypes = {
1717
- basename: propTypes.string,
1718
- forceRefresh: propTypes.bool,
1719
- getUserConfirmation: propTypes.func,
1720
- keyLength: propTypes.number,
1721
- children: propTypes.node
1722
- };
1723
-
1724
- var createHashHistory_1 = createCommonjsModule(function (module, exports) {
1725
- 'use strict';
1726
-
1727
- exports.__esModule = true;
1728
-
1729
- 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; };
4269
+ Route.prototype.computeMatch = function computeMatch(_ref, router) {
4270
+ var computedMatch = _ref.computedMatch,
4271
+ location = _ref.location,
4272
+ path = _ref.path,
4273
+ strict = _ref.strict,
4274
+ exact = _ref.exact,
4275
+ sensitive = _ref.sensitive;
1730
4276
 
4277
+ if (computedMatch) return computedMatch; // <Switch> already computed the match for us
1731
4278
 
4279
+ invariant_1$3(router, 'You should not use <Route> or withRouter() outside a <Router>');
1732
4280
 
1733
- var _warning2 = _interopRequireDefault(warning_1);
4281
+ var route = router.route;
1734
4282
 
4283
+ var pathname = (location || route.location).pathname;
1735
4284
 
4285
+ return path ? matchPath(pathname, { path: path, strict: strict, exact: exact, sensitive: sensitive }) : route.match;
4286
+ };
1736
4287
 
1737
- var _invariant2 = _interopRequireDefault(invariant_1$2);
4288
+ Route.prototype.componentWillMount = function componentWillMount() {
4289
+ warning_1$3(!(this.props.component && this.props.render), 'You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored');
1738
4290
 
4291
+ warning_1$3(!(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');
1739
4292
 
4293
+ warning_1$3(!(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');
4294
+ };
1740
4295
 
4296
+ Route.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps, nextContext) {
4297
+ warning_1$3(!(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.');
1741
4298
 
4299
+ warning_1$3(!(!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.');
1742
4300
 
4301
+ this.setState({
4302
+ match: this.computeMatch(nextProps, nextContext.router)
4303
+ });
4304
+ };
1743
4305
 
4306
+ Route.prototype.render = function render() {
4307
+ var match = this.state.match;
4308
+ var _props = this.props,
4309
+ children = _props.children,
4310
+ component = _props.component,
4311
+ render = _props.render;
4312
+ var _context$router = this.context.router,
4313
+ history = _context$router.history,
4314
+ route = _context$router.route,
4315
+ staticContext = _context$router.staticContext;
4316
+
4317
+ var location = this.props.location || route.location;
4318
+ var props = { match: match, location: location, history: history, staticContext: staticContext };
4319
+
4320
+ return component ? // component prop gets first priority, only called if there's a match
4321
+ match ? React.createElement(component, props) : null : render ? // render prop is next, only called if there's a match
4322
+ match ? render(props) : null : children ? // children come last, always called
4323
+ typeof children === 'function' ? children(props) : !isEmptyChildren(children) ? React.Children.only(children) : null : null;
4324
+ };
1744
4325
 
1745
- var _createTransitionManager2 = _interopRequireDefault(createTransitionManager_1);
4326
+ return Route;
4327
+ }(React.Component);
1746
4328
 
4329
+ Route$1.propTypes = {
4330
+ computedMatch: propTypes$1.object, // private, from <Switch>
4331
+ path: propTypes$1.string,
4332
+ exact: propTypes$1.bool,
4333
+ strict: propTypes$1.bool,
4334
+ sensitive: propTypes$1.bool,
4335
+ component: propTypes$1.func,
4336
+ render: propTypes$1.func,
4337
+ children: propTypes$1.oneOfType([propTypes$1.func, propTypes$1.node]),
4338
+ location: propTypes$1.object
4339
+ };
4340
+ Route$1.contextTypes = {
4341
+ router: propTypes$1.shape({
4342
+ history: propTypes$1.object.isRequired,
4343
+ route: propTypes$1.object.isRequired,
4344
+ staticContext: propTypes$1.object
4345
+ })
4346
+ };
4347
+ Route$1.childContextTypes = {
4348
+ router: propTypes$1.object.isRequired
4349
+ };
1747
4350
 
4351
+ // Written in this round about way for babel-transform-imports
1748
4352
 
1749
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4353
+ /**
4354
+ * A <Link> wrapper that knows if it's "active" or not.
4355
+ */
4356
+ var NavLink = function NavLink(_ref) {
4357
+ var to = _ref.to,
4358
+ exact = _ref.exact,
4359
+ strict = _ref.strict,
4360
+ location = _ref.location,
4361
+ activeClassName = _ref.activeClassName,
4362
+ className = _ref.className,
4363
+ activeStyle = _ref.activeStyle,
4364
+ style = _ref.style,
4365
+ getIsActive = _ref.isActive,
4366
+ ariaCurrent = _ref.ariaCurrent,
4367
+ rest = objectWithoutProperties(_ref, ['to', 'exact', 'strict', 'location', 'activeClassName', 'className', 'activeStyle', 'style', 'isActive', 'ariaCurrent']);
4368
+ return React.createElement(Route$1, {
4369
+ path: (typeof to === 'undefined' ? 'undefined' : _typeof$1(to)) === 'object' ? to.pathname : to,
4370
+ exact: exact,
4371
+ strict: strict,
4372
+ location: location,
4373
+ children: function children(_ref2) {
4374
+ var location = _ref2.location,
4375
+ match = _ref2.match;
1750
4376
 
1751
- var HashChangeEvent = 'hashchange';
4377
+ var isActive = !!(getIsActive ? getIsActive(match, location) : match);
1752
4378
 
1753
- var HashPathCoders = {
1754
- hashbang: {
1755
- encodePath: function encodePath(path) {
1756
- return path.charAt(0) === '!' ? path : '!/' + (0, PathUtils.stripLeadingSlash)(path);
1757
- },
1758
- decodePath: function decodePath(path) {
1759
- return path.charAt(0) === '!' ? path.substr(1) : path;
4379
+ return React.createElement(Link, _extends$1({
4380
+ to: to,
4381
+ className: isActive ? [className, activeClassName].filter(function (i) {
4382
+ return i;
4383
+ }).join(' ') : className,
4384
+ style: isActive ? _extends$1({}, style, activeStyle) : style,
4385
+ 'aria-current': isActive && ariaCurrent
4386
+ }, rest));
1760
4387
  }
1761
- },
1762
- noslash: {
1763
- encodePath: PathUtils.stripLeadingSlash,
1764
- decodePath: PathUtils.addLeadingSlash
1765
- },
1766
- slash: {
1767
- encodePath: PathUtils.addLeadingSlash,
1768
- decodePath: PathUtils.addLeadingSlash
1769
- }
1770
- };
1771
-
1772
- var getHashPath = function getHashPath() {
1773
- // We can't use window.location.hash here because it's not
1774
- // consistent across browsers - Firefox will pre-decode it!
1775
- var href = window.location.href;
1776
- var hashIndex = href.indexOf('#');
1777
- return hashIndex === -1 ? '' : href.substring(hashIndex + 1);
4388
+ });
1778
4389
  };
1779
4390
 
1780
- var pushHashPath = function pushHashPath(path) {
1781
- return window.location.hash = path;
4391
+ NavLink.propTypes = {
4392
+ to: Link.propTypes.to,
4393
+ exact: propTypes.bool,
4394
+ strict: propTypes.bool,
4395
+ location: propTypes.object,
4396
+ activeClassName: propTypes.string,
4397
+ className: propTypes.string,
4398
+ activeStyle: propTypes.object,
4399
+ style: propTypes.object,
4400
+ isActive: propTypes.func,
4401
+ ariaCurrent: propTypes.oneOf(['page', 'step', 'location', 'true'])
1782
4402
  };
1783
4403
 
1784
- var replaceHashPath = function replaceHashPath(path) {
1785
- var hashIndex = window.location.href.indexOf('#');
1786
-
1787
- window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path);
4404
+ NavLink.defaultProps = {
4405
+ activeClassName: 'active',
4406
+ ariaCurrent: 'true'
1788
4407
  };
1789
4408
 
1790
- var createHashHistory = function createHashHistory() {
1791
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1792
-
1793
- (0, _invariant2.default)(DOMUtils.canUseDOM, 'Hash history needs a DOM');
4409
+ function _classCallCheck$3(instance, Constructor) {
4410
+ if (!(instance instanceof Constructor)) {
4411
+ throw new TypeError("Cannot call a class as a function");
4412
+ }
4413
+ }
1794
4414
 
1795
- var globalHistory = window.history;
1796
- var canGoWithoutReload = (0, DOMUtils.supportsGoWithoutReloadUsingHash)();
4415
+ function _possibleConstructorReturn$3(self, call) {
4416
+ if (!self) {
4417
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4418
+ }return call && (typeof call === "object" || typeof call === "function") ? call : self;
4419
+ }
1797
4420
 
1798
- var _props$getUserConfirm = props.getUserConfirmation,
1799
- getUserConfirmation = _props$getUserConfirm === undefined ? DOMUtils.getConfirmation : _props$getUserConfirm,
1800
- _props$hashType = props.hashType,
1801
- hashType = _props$hashType === undefined ? 'slash' : _props$hashType;
4421
+ function _inherits$3(subClass, superClass) {
4422
+ if (typeof superClass !== "function" && superClass !== null) {
4423
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
4424
+ }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;
4425
+ }
1802
4426
 
1803
- var basename = props.basename ? (0, PathUtils.stripTrailingSlash)((0, PathUtils.addLeadingSlash)(props.basename)) : '';
4427
+ /**
4428
+ * The public API for prompting the user before navigating away
4429
+ * from a screen with a component.
4430
+ */
1804
4431
 
1805
- var _HashPathCoders$hashT = HashPathCoders[hashType],
1806
- encodePath = _HashPathCoders$hashT.encodePath,
1807
- decodePath = _HashPathCoders$hashT.decodePath;
4432
+ var Prompt$1 = function (_React$Component) {
4433
+ _inherits$3(Prompt, _React$Component);
1808
4434
 
4435
+ function Prompt() {
4436
+ _classCallCheck$3(this, Prompt);
1809
4437
 
1810
- var getDOMLocation = function getDOMLocation() {
1811
- var path = decodePath(getHashPath());
4438
+ return _possibleConstructorReturn$3(this, _React$Component.apply(this, arguments));
4439
+ }
1812
4440
 
1813
- (0, _warning2.default)(!basename || (0, PathUtils.hasBasename)(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".');
4441
+ Prompt.prototype.enable = function enable(message) {
4442
+ if (this.unblock) this.unblock();
1814
4443
 
1815
- if (basename) path = (0, PathUtils.stripBasename)(path, basename);
4444
+ this.unblock = this.context.router.history.block(message);
4445
+ };
1816
4446
 
1817
- return (0, LocationUtils.createLocation)(path);
4447
+ Prompt.prototype.disable = function disable() {
4448
+ if (this.unblock) {
4449
+ this.unblock();
4450
+ this.unblock = null;
4451
+ }
1818
4452
  };
1819
4453
 
1820
- var transitionManager = (0, _createTransitionManager2.default)();
4454
+ Prompt.prototype.componentWillMount = function componentWillMount() {
4455
+ invariant_1$3(this.context.router, 'You should not use <Prompt> outside a <Router>');
1821
4456
 
1822
- var setState = function setState(nextState) {
1823
- _extends(history, nextState);
4457
+ if (this.props.when) this.enable(this.props.message);
4458
+ };
1824
4459
 
1825
- history.length = globalHistory.length;
4460
+ Prompt.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
4461
+ if (nextProps.when) {
4462
+ if (!this.props.when || this.props.message !== nextProps.message) this.enable(nextProps.message);
4463
+ } else {
4464
+ this.disable();
4465
+ }
4466
+ };
1826
4467
 
1827
- transitionManager.notifyListeners(history.location, history.action);
4468
+ Prompt.prototype.componentWillUnmount = function componentWillUnmount() {
4469
+ this.disable();
1828
4470
  };
1829
4471
 
1830
- var forceNextPop = false;
1831
- var ignorePath = null;
4472
+ Prompt.prototype.render = function render() {
4473
+ return null;
4474
+ };
1832
4475
 
1833
- var handleHashChange = function handleHashChange() {
1834
- var path = getHashPath();
1835
- var encodedPath = encodePath(path);
4476
+ return Prompt;
4477
+ }(React.Component);
1836
4478
 
1837
- if (path !== encodedPath) {
1838
- // Ensure we always have a properly-encoded hash.
1839
- replaceHashPath(encodedPath);
1840
- } else {
1841
- var location = getDOMLocation();
1842
- var prevLocation = history.location;
4479
+ Prompt$1.propTypes = {
4480
+ when: propTypes$1.bool,
4481
+ message: propTypes$1.oneOfType([propTypes$1.func, propTypes$1.string]).isRequired
4482
+ };
4483
+ Prompt$1.defaultProps = {
4484
+ when: true
4485
+ };
4486
+ Prompt$1.contextTypes = {
4487
+ router: propTypes$1.shape({
4488
+ history: propTypes$1.shape({
4489
+ block: propTypes$1.func.isRequired
4490
+ }).isRequired
4491
+ }).isRequired
4492
+ };
1843
4493
 
1844
- if (!forceNextPop && (0, LocationUtils.locationsAreEqual)(prevLocation, location)) return; // A hashchange doesn't always == location change.
4494
+ // Written in this round about way for babel-transform-imports
1845
4495
 
1846
- if (ignorePath === (0, PathUtils.createPath)(location)) return; // Ignore this change; we already setState in push/replace.
4496
+ var parsePath = function parsePath(path) {
4497
+ var pathname = path || '/';
4498
+ var search = '';
4499
+ var hash = '';
1847
4500
 
1848
- ignorePath = null;
4501
+ var hashIndex = pathname.indexOf('#');
4502
+ if (hashIndex !== -1) {
4503
+ hash = pathname.substr(hashIndex);
4504
+ pathname = pathname.substr(0, hashIndex);
4505
+ }
1849
4506
 
1850
- handlePop(location);
1851
- }
4507
+ var searchIndex = pathname.indexOf('?');
4508
+ if (searchIndex !== -1) {
4509
+ search = pathname.substr(searchIndex);
4510
+ pathname = pathname.substr(0, searchIndex);
4511
+ }
4512
+
4513
+ return {
4514
+ pathname: pathname,
4515
+ search: search === '?' ? '' : search,
4516
+ hash: hash === '#' ? '' : hash
1852
4517
  };
4518
+ };
1853
4519
 
1854
- var handlePop = function handlePop(location) {
1855
- if (forceNextPop) {
1856
- forceNextPop = false;
1857
- setState();
4520
+ var _extends$4 = Object.assign || function (target) {
4521
+ for (var i = 1; i < arguments.length; i++) {
4522
+ var source = arguments[i];for (var key in source) {
4523
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
4524
+ target[key] = source[key];
4525
+ }
4526
+ }
4527
+ }return target;
4528
+ };
4529
+
4530
+ var createLocation = function createLocation(path, state, key, currentLocation) {
4531
+ var location = void 0;
4532
+ if (typeof path === 'string') {
4533
+ // Two-arg form: push(path, state)
4534
+ location = parsePath(path);
4535
+ location.state = state;
4536
+ } else {
4537
+ // One-arg form: push(location)
4538
+ location = _extends$4({}, path);
4539
+
4540
+ if (location.pathname === undefined) location.pathname = '';
4541
+
4542
+ if (location.search) {
4543
+ if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
1858
4544
  } else {
1859
- var action = 'POP';
4545
+ location.search = '';
4546
+ }
1860
4547
 
1861
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1862
- if (ok) {
1863
- setState({ action: action, location: location });
1864
- } else {
1865
- revertPop(location);
1866
- }
1867
- });
4548
+ if (location.hash) {
4549
+ if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
4550
+ } else {
4551
+ location.hash = '';
1868
4552
  }
1869
- };
1870
4553
 
1871
- var revertPop = function revertPop(fromLocation) {
1872
- var toLocation = history.location;
4554
+ if (state !== undefined && location.state === undefined) location.state = state;
4555
+ }
1873
4556
 
1874
- // TODO: We could probably make this more reliable by
1875
- // keeping a list of paths we've seen in sessionStorage.
1876
- // Instead, we just default to 0 for paths we don't know.
4557
+ try {
4558
+ location.pathname = decodeURI(location.pathname);
4559
+ } catch (e) {
4560
+ if (e instanceof URIError) {
4561
+ throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
4562
+ } else {
4563
+ throw e;
4564
+ }
4565
+ }
1877
4566
 
1878
- var toIndex = allPaths.lastIndexOf((0, PathUtils.createPath)(toLocation));
4567
+ if (key) location.key = key;
1879
4568
 
1880
- if (toIndex === -1) toIndex = 0;
4569
+ if (currentLocation) {
4570
+ // Resolve incomplete/relative pathname relative to current location.
4571
+ if (!location.pathname) {
4572
+ location.pathname = currentLocation.pathname;
4573
+ } else if (location.pathname.charAt(0) !== '/') {
4574
+ location.pathname = resolvePathname$3(location.pathname, currentLocation.pathname);
4575
+ }
4576
+ } else {
4577
+ // When there is no prior location and pathname is empty, set it to /
4578
+ if (!location.pathname) {
4579
+ location.pathname = '/';
4580
+ }
4581
+ }
1881
4582
 
1882
- var fromIndex = allPaths.lastIndexOf((0, PathUtils.createPath)(fromLocation));
4583
+ return location;
4584
+ };
1883
4585
 
1884
- if (fromIndex === -1) fromIndex = 0;
4586
+ var locationsAreEqual = function locationsAreEqual(a, b) {
4587
+ return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual$3(a.state, b.state);
4588
+ };
1885
4589
 
1886
- var delta = toIndex - fromIndex;
4590
+ // eslint-disable-line no-alert
1887
4591
 
1888
- if (delta) {
1889
- forceNextPop = true;
1890
- go(delta);
1891
- }
1892
- };
4592
+ /**
4593
+ * Returns true if the HTML5 history API is supported. Taken from Modernizr.
4594
+ *
4595
+ * https://github.com/Modernizr/Modernizr/blob/master/LICENSE
4596
+ * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
4597
+ * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
4598
+ */
1893
4599
 
1894
- // Ensure the hash is encoded properly before doing anything else.
1895
- var path = getHashPath();
1896
- var encodedPath = encodePath(path);
1897
4600
 
1898
- if (path !== encodedPath) replaceHashPath(encodedPath);
4601
+ /**
4602
+ * Returns true if browser fires popstate on hash change.
4603
+ * IE10 and IE11 do not.
4604
+ */
1899
4605
 
1900
- var initialLocation = getDOMLocation();
1901
- var allPaths = [(0, PathUtils.createPath)(initialLocation)];
1902
4606
 
1903
- // Public interface
4607
+ /**
4608
+ * Returns false if using go(n) with hash history causes a full page reload.
4609
+ */
1904
4610
 
1905
- var createHref = function createHref(location) {
1906
- return '#' + encodePath(basename + (0, PathUtils.createPath)(location));
1907
- };
1908
4611
 
1909
- var push = function push(path, state) {
1910
- (0, _warning2.default)(state === undefined, 'Hash history cannot push state; it is ignored');
4612
+ /**
4613
+ * Returns true if a given popstate event is an extraneous WebKit event.
4614
+ * Accounts for the fact that Chrome on iOS fires real popstate events
4615
+ * containing undefined state when pressing the back button.
4616
+ */
1911
4617
 
1912
- var action = 'PUSH';
1913
- var location = (0, LocationUtils.createLocation)(path, undefined, undefined, history.location);
4618
+ function _classCallCheck$4(instance, Constructor) {
4619
+ if (!(instance instanceof Constructor)) {
4620
+ throw new TypeError("Cannot call a class as a function");
4621
+ }
4622
+ }
1914
4623
 
1915
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1916
- if (!ok) return;
4624
+ function _possibleConstructorReturn$4(self, call) {
4625
+ if (!self) {
4626
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4627
+ }return call && (typeof call === "object" || typeof call === "function") ? call : self;
4628
+ }
1917
4629
 
1918
- var path = (0, PathUtils.createPath)(location);
1919
- var encodedPath = encodePath(basename + path);
1920
- var hashChanged = getHashPath() !== encodedPath;
4630
+ function _inherits$4(subClass, superClass) {
4631
+ if (typeof superClass !== "function" && superClass !== null) {
4632
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
4633
+ }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;
4634
+ }
1921
4635
 
1922
- if (hashChanged) {
1923
- // We cannot tell if a hashchange was caused by a PUSH, so we'd
1924
- // rather setState here and ignore the hashchange. The caveat here
1925
- // is that other hash histories in the page will consider it a POP.
1926
- ignorePath = path;
1927
- pushHashPath(encodedPath);
4636
+ /**
4637
+ * The public API for updating the location programmatically
4638
+ * with a component.
4639
+ */
1928
4640
 
1929
- var prevIndex = allPaths.lastIndexOf((0, PathUtils.createPath)(history.location));
1930
- var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);
4641
+ var Redirect$1 = function (_React$Component) {
4642
+ _inherits$4(Redirect, _React$Component);
1931
4643
 
1932
- nextPaths.push(path);
1933
- allPaths = nextPaths;
4644
+ function Redirect() {
4645
+ _classCallCheck$4(this, Redirect);
1934
4646
 
1935
- setState({ action: action, location: location });
1936
- } else {
1937
- (0, _warning2.default)(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack');
4647
+ return _possibleConstructorReturn$4(this, _React$Component.apply(this, arguments));
4648
+ }
1938
4649
 
1939
- setState();
1940
- }
1941
- });
4650
+ Redirect.prototype.isStatic = function isStatic() {
4651
+ return this.context.router && this.context.router.staticContext;
1942
4652
  };
1943
4653
 
1944
- var replace = function replace(path, state) {
1945
- (0, _warning2.default)(state === undefined, 'Hash history cannot replace state; it is ignored');
4654
+ Redirect.prototype.componentWillMount = function componentWillMount() {
4655
+ invariant_1$3(this.context.router, 'You should not use <Redirect> outside a <Router>');
1946
4656
 
1947
- var action = 'REPLACE';
1948
- var location = (0, LocationUtils.createLocation)(path, undefined, undefined, history.location);
4657
+ if (this.isStatic()) this.perform();
4658
+ };
1949
4659
 
1950
- transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
1951
- if (!ok) return;
4660
+ Redirect.prototype.componentDidMount = function componentDidMount() {
4661
+ if (!this.isStatic()) this.perform();
4662
+ };
1952
4663
 
1953
- var path = (0, PathUtils.createPath)(location);
1954
- var encodedPath = encodePath(basename + path);
1955
- var hashChanged = getHashPath() !== encodedPath;
4664
+ Redirect.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
4665
+ var prevTo = createLocation(prevProps.to);
4666
+ var nextTo = createLocation(this.props.to);
1956
4667
 
1957
- if (hashChanged) {
1958
- // We cannot tell if a hashchange was caused by a REPLACE, so we'd
1959
- // rather setState here and ignore the hashchange. The caveat here
1960
- // is that other hash histories in the page will consider it a POP.
1961
- ignorePath = path;
1962
- replaceHashPath(encodedPath);
1963
- }
4668
+ if (locationsAreEqual(prevTo, nextTo)) {
4669
+ warning_1$3(false, 'You tried to redirect to the same route you\'re currently on: ' + ('"' + nextTo.pathname + nextTo.search + '"'));
4670
+ return;
4671
+ }
1964
4672
 
1965
- var prevIndex = allPaths.indexOf((0, PathUtils.createPath)(history.location));
4673
+ this.perform();
4674
+ };
1966
4675
 
1967
- if (prevIndex !== -1) allPaths[prevIndex] = path;
4676
+ Redirect.prototype.perform = function perform() {
4677
+ var history = this.context.router.history;
4678
+ var _props = this.props,
4679
+ push = _props.push,
4680
+ to = _props.to;
1968
4681
 
1969
- setState({ action: action, location: location });
1970
- });
4682
+ if (push) {
4683
+ history.push(to);
4684
+ } else {
4685
+ history.replace(to);
4686
+ }
1971
4687
  };
1972
4688
 
1973
- var go = function go(n) {
1974
- (0, _warning2.default)(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser');
4689
+ Redirect.prototype.render = function render() {
4690
+ return null;
4691
+ };
4692
+
4693
+ return Redirect;
4694
+ }(React.Component);
4695
+
4696
+ Redirect$1.propTypes = {
4697
+ push: propTypes$1.bool,
4698
+ from: propTypes$1.string,
4699
+ to: propTypes$1.oneOfType([propTypes$1.string, propTypes$1.object]).isRequired
4700
+ };
4701
+ Redirect$1.defaultProps = {
4702
+ push: false
4703
+ };
4704
+ Redirect$1.contextTypes = {
4705
+ router: propTypes$1.shape({
4706
+ history: propTypes$1.shape({
4707
+ push: propTypes$1.func.isRequired,
4708
+ replace: propTypes$1.func.isRequired
4709
+ }).isRequired,
4710
+ staticContext: propTypes$1.object
4711
+ }).isRequired
4712
+ };
4713
+
4714
+ // Written in this round about way for babel-transform-imports
4715
+
4716
+ var _extends$7 = Object.assign || function (target) {
4717
+ for (var i = 1; i < arguments.length; i++) {
4718
+ var source = arguments[i];for (var key in source) {
4719
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
4720
+ target[key] = source[key];
4721
+ }
4722
+ }
4723
+ }return target;
4724
+ };
1975
4725
 
1976
- globalHistory.go(n);
1977
- };
4726
+ function _objectWithoutProperties(obj, keys) {
4727
+ var target = {};for (var i in obj) {
4728
+ if (keys.indexOf(i) >= 0) continue;if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;target[i] = obj[i];
4729
+ }return target;
4730
+ }
1978
4731
 
1979
- var goBack = function goBack() {
1980
- return go(-1);
1981
- };
4732
+ function _classCallCheck$5(instance, Constructor) {
4733
+ if (!(instance instanceof Constructor)) {
4734
+ throw new TypeError("Cannot call a class as a function");
4735
+ }
4736
+ }
1982
4737
 
1983
- var goForward = function goForward() {
1984
- return go(1);
1985
- };
4738
+ function _possibleConstructorReturn$5(self, call) {
4739
+ if (!self) {
4740
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4741
+ }return call && (typeof call === "object" || typeof call === "function") ? call : self;
4742
+ }
1986
4743
 
1987
- var listenerCount = 0;
4744
+ function _inherits$5(subClass, superClass) {
4745
+ if (typeof superClass !== "function" && superClass !== null) {
4746
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
4747
+ }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;
4748
+ }
1988
4749
 
1989
- var checkDOMListeners = function checkDOMListeners(delta) {
1990
- listenerCount += delta;
4750
+ var normalizeLocation = function normalizeLocation(object) {
4751
+ var _object$pathname = object.pathname,
4752
+ pathname = _object$pathname === undefined ? '/' : _object$pathname,
4753
+ _object$search = object.search,
4754
+ search = _object$search === undefined ? '' : _object$search,
4755
+ _object$hash = object.hash,
4756
+ hash = _object$hash === undefined ? '' : _object$hash;
1991
4757
 
1992
- if (listenerCount === 1) {
1993
- (0, DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange);
1994
- } else if (listenerCount === 0) {
1995
- (0, DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange);
1996
- }
4758
+ return {
4759
+ pathname: pathname,
4760
+ search: search === '?' ? '' : search,
4761
+ hash: hash === '#' ? '' : hash
1997
4762
  };
4763
+ };
1998
4764
 
1999
- var isBlocked = false;
4765
+ var addBasename = function addBasename(basename, location) {
4766
+ if (!basename) return location;
2000
4767
 
2001
- var block = function block() {
2002
- var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4768
+ return _extends$7({}, location, {
4769
+ pathname: PathUtils_1$1(basename) + location.pathname
4770
+ });
4771
+ };
2003
4772
 
2004
- var unblock = transitionManager.setPrompt(prompt);
4773
+ var stripBasename$1 = function stripBasename(basename, location) {
4774
+ if (!basename) return location;
2005
4775
 
2006
- if (!isBlocked) {
2007
- checkDOMListeners(1);
2008
- isBlocked = true;
2009
- }
4776
+ var base = PathUtils_1$1(basename);
2010
4777
 
2011
- return function () {
2012
- if (isBlocked) {
2013
- isBlocked = false;
2014
- checkDOMListeners(-1);
2015
- }
4778
+ if (location.pathname.indexOf(base) !== 0) return location;
2016
4779
 
2017
- return unblock();
2018
- };
2019
- };
4780
+ return _extends$7({}, location, {
4781
+ pathname: location.pathname.substr(base.length)
4782
+ });
4783
+ };
2020
4784
 
2021
- var listen = function listen(listener) {
2022
- var unlisten = transitionManager.appendListener(listener);
2023
- checkDOMListeners(1);
4785
+ var createLocation$1 = function createLocation(location) {
4786
+ return typeof location === 'string' ? PathUtils_6$1(location) : normalizeLocation(location);
4787
+ };
2024
4788
 
2025
- return function () {
2026
- checkDOMListeners(-1);
2027
- unlisten();
2028
- };
2029
- };
4789
+ var createURL = function createURL(location) {
4790
+ return typeof location === 'string' ? location : PathUtils_7$1(location);
4791
+ };
2030
4792
 
2031
- var history = {
2032
- length: globalHistory.length,
2033
- action: 'POP',
2034
- location: initialLocation,
2035
- createHref: createHref,
2036
- push: push,
2037
- replace: replace,
2038
- go: go,
2039
- goBack: goBack,
2040
- goForward: goForward,
2041
- block: block,
2042
- listen: listen
4793
+ var staticHandler = function staticHandler(methodName) {
4794
+ return function () {
4795
+ invariant_1$3(false, 'You cannot %s with <StaticRouter>', methodName);
2043
4796
  };
2044
-
2045
- return history;
2046
4797
  };
2047
4798
 
2048
- exports.default = createHashHistory;
2049
- });
2050
-
2051
- var createHistory$1 = unwrapExports(createHashHistory_1);
4799
+ var noop = function noop() {};
2052
4800
 
2053
4801
  /**
2054
- * The public API for a <Router> that uses window.location.hash.
4802
+ * The public top-level API for a "static" <Router>, so-called because it
4803
+ * can't actually change the current location. Instead, it just records
4804
+ * location changes in a context object. Useful mainly in testing and
4805
+ * server-rendering scenarios.
2055
4806
  */
2056
4807
 
2057
- var HashRouter = function (_React$Component) {
2058
- inherits(HashRouter, _React$Component);
4808
+ var StaticRouter$1 = function (_React$Component) {
4809
+ _inherits$5(StaticRouter, _React$Component);
2059
4810
 
2060
- function HashRouter() {
4811
+ function StaticRouter() {
2061
4812
  var _temp, _this, _ret;
2062
4813
 
2063
- classCallCheck(this, HashRouter);
4814
+ _classCallCheck$5(this, StaticRouter);
2064
4815
 
2065
4816
  for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
2066
4817
  args[_key] = arguments[_key];
2067
4818
  }
2068
4819
 
2069
- return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.history = createHistory$1(_this.props), _temp), possibleConstructorReturn(_this, _ret);
4820
+ return _ret = (_temp = (_this = _possibleConstructorReturn$5(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.createHref = function (path) {
4821
+ return PathUtils_1$1(_this.props.basename + createURL(path));
4822
+ }, _this.handlePush = function (location) {
4823
+ var _this$props = _this.props,
4824
+ basename = _this$props.basename,
4825
+ context = _this$props.context;
4826
+
4827
+ context.action = 'PUSH';
4828
+ context.location = addBasename(basename, createLocation$1(location));
4829
+ context.url = createURL(context.location);
4830
+ }, _this.handleReplace = function (location) {
4831
+ var _this$props2 = _this.props,
4832
+ basename = _this$props2.basename,
4833
+ context = _this$props2.context;
4834
+
4835
+ context.action = 'REPLACE';
4836
+ context.location = addBasename(basename, createLocation$1(location));
4837
+ context.url = createURL(context.location);
4838
+ }, _this.handleListen = function () {
4839
+ return noop;
4840
+ }, _this.handleBlock = function () {
4841
+ return noop;
4842
+ }, _temp), _possibleConstructorReturn$5(_this, _ret);
2070
4843
  }
2071
4844
 
2072
- HashRouter.prototype.componentWillMount = function componentWillMount() {
2073
- warning_1(!this.props.history, '<HashRouter> ignores the history prop. To use a custom history, ' + 'use `import { Router }` instead of `import { HashRouter as Router }`.');
4845
+ StaticRouter.prototype.getChildContext = function getChildContext() {
4846
+ return {
4847
+ router: {
4848
+ staticContext: this.props.context
4849
+ }
4850
+ };
2074
4851
  };
2075
4852
 
2076
- HashRouter.prototype.render = function render() {
2077
- return React.createElement(Router, { history: this.history, children: this.props.children });
4853
+ StaticRouter.prototype.componentWillMount = function componentWillMount() {
4854
+ warning_1$3(!this.props.history, '<StaticRouter> ignores the history prop. To use a custom history, ' + 'use `import { Router }` instead of `import { StaticRouter as Router }`.');
2078
4855
  };
2079
4856
 
2080
- return HashRouter;
4857
+ StaticRouter.prototype.render = function render() {
4858
+ var _props = this.props,
4859
+ basename = _props.basename,
4860
+ context = _props.context,
4861
+ location = _props.location,
4862
+ props = _objectWithoutProperties(_props, ['basename', 'context', 'location']);
4863
+
4864
+ var history = {
4865
+ createHref: this.createHref,
4866
+ action: 'POP',
4867
+ location: stripBasename$1(basename, createLocation$1(location)),
4868
+ push: this.handlePush,
4869
+ replace: this.handleReplace,
4870
+ go: staticHandler('go'),
4871
+ goBack: staticHandler('goBack'),
4872
+ goForward: staticHandler('goForward'),
4873
+ listen: this.handleListen,
4874
+ block: this.handleBlock
4875
+ };
4876
+
4877
+ return React.createElement(Router$1, _extends$7({}, props, { history: history }));
4878
+ };
4879
+
4880
+ return StaticRouter;
2081
4881
  }(React.Component);
2082
4882
 
2083
- HashRouter.propTypes = {
2084
- basename: propTypes.string,
2085
- getUserConfirmation: propTypes.func,
2086
- hashType: propTypes.oneOf(['hashbang', 'noslash', 'slash']),
2087
- children: propTypes.node
4883
+ StaticRouter$1.propTypes = {
4884
+ basename: propTypes$1.string,
4885
+ context: propTypes$1.object.isRequired,
4886
+ location: propTypes$1.oneOfType([propTypes$1.string, propTypes$1.object])
2088
4887
  };
2089
-
2090
- var isModifiedEvent = function isModifiedEvent(event) {
2091
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
4888
+ StaticRouter$1.defaultProps = {
4889
+ basename: '',
4890
+ location: '/'
2092
4891
  };
4892
+ StaticRouter$1.childContextTypes = {
4893
+ router: propTypes$1.object.isRequired
4894
+ };
4895
+
4896
+ // Written in this round about way for babel-transform-imports
4897
+
4898
+ function _classCallCheck$6(instance, Constructor) {
4899
+ if (!(instance instanceof Constructor)) {
4900
+ throw new TypeError("Cannot call a class as a function");
4901
+ }
4902
+ }
4903
+
4904
+ function _possibleConstructorReturn$6(self, call) {
4905
+ if (!self) {
4906
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4907
+ }return call && (typeof call === "object" || typeof call === "function") ? call : self;
4908
+ }
4909
+
4910
+ function _inherits$6(subClass, superClass) {
4911
+ if (typeof superClass !== "function" && superClass !== null) {
4912
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
4913
+ }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;
4914
+ }
2093
4915
 
2094
4916
  /**
2095
- * The public API for rendering a history-aware <a>.
4917
+ * The public API for rendering the first <Route> that matches.
2096
4918
  */
2097
4919
 
2098
- var Link = function (_React$Component) {
2099
- inherits(Link, _React$Component);
4920
+ var Switch$1 = function (_React$Component) {
4921
+ _inherits$6(Switch, _React$Component);
2100
4922
 
2101
- function Link() {
2102
- var _temp, _this, _ret;
4923
+ function Switch() {
4924
+ _classCallCheck$6(this, Switch);
2103
4925
 
2104
- classCallCheck(this, Link);
4926
+ return _possibleConstructorReturn$6(this, _React$Component.apply(this, arguments));
4927
+ }
2105
4928
 
2106
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
2107
- args[_key] = arguments[_key];
2108
- }
4929
+ Switch.prototype.componentWillMount = function componentWillMount() {
4930
+ invariant_1$3(this.context.router, 'You should not use <Switch> outside a <Router>');
4931
+ };
2109
4932
 
2110
- return _ret = (_temp = (_this = possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleClick = function (event) {
2111
- if (_this.props.onClick) _this.props.onClick(event);
4933
+ Switch.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
4934
+ warning_1$3(!(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.');
2112
4935
 
2113
- if (!event.defaultPrevented && // onClick prevented default
2114
- event.button === 0 && // ignore right clicks
2115
- !_this.props.target && // let browser handle "target=_blank" etc.
2116
- !isModifiedEvent(event) // ignore clicks with modifier keys
2117
- ) {
2118
- event.preventDefault();
4936
+ warning_1$3(!(!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.');
4937
+ };
2119
4938
 
2120
- var history = _this.context.router.history;
2121
- var _this$props = _this.props,
2122
- replace = _this$props.replace,
2123
- to = _this$props.to;
4939
+ Switch.prototype.render = function render() {
4940
+ var route = this.context.router.route;
4941
+ var children = this.props.children;
2124
4942
 
4943
+ var location = this.props.location || route.location;
2125
4944
 
2126
- if (replace) {
2127
- history.replace(to);
2128
- } else {
2129
- history.push(to);
2130
- }
2131
- }
2132
- }, _temp), possibleConstructorReturn(_this, _ret);
2133
- }
4945
+ var match = void 0,
4946
+ child = void 0;
4947
+ React.Children.forEach(children, function (element) {
4948
+ if (!React.isValidElement(element)) return;
2134
4949
 
2135
- Link.prototype.render = function render() {
2136
- var _props = this.props,
2137
- replace = _props.replace,
2138
- to = _props.to,
2139
- innerRef = _props.innerRef,
2140
- props = objectWithoutProperties(_props, ['replace', 'to', 'innerRef']); // eslint-disable-line no-unused-vars
4950
+ var _element$props = element.props,
4951
+ pathProp = _element$props.path,
4952
+ exact = _element$props.exact,
4953
+ strict = _element$props.strict,
4954
+ sensitive = _element$props.sensitive,
4955
+ from = _element$props.from;
2141
4956
 
2142
- invariant_1$2(this.context.router, 'You should not use <Link> outside a <Router>');
4957
+ var path = pathProp || from;
2143
4958
 
2144
- var href = this.context.router.history.createHref(typeof to === 'string' ? { pathname: to } : to);
4959
+ if (match == null) {
4960
+ child = element;
4961
+ match = path ? matchPath(location.pathname, { path: path, exact: exact, strict: strict, sensitive: sensitive }) : route.match;
4962
+ }
4963
+ });
2145
4964
 
2146
- return React.createElement('a', _extends({}, props, { onClick: this.handleClick, href: href, ref: innerRef }));
4965
+ return match ? React.cloneElement(child, { location: location, computedMatch: match }) : null;
2147
4966
  };
2148
4967
 
2149
- return Link;
4968
+ return Switch;
2150
4969
  }(React.Component);
2151
4970
 
2152
- Link.propTypes = {
2153
- onClick: propTypes.func,
2154
- target: propTypes.string,
2155
- replace: propTypes.bool,
2156
- to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired,
2157
- innerRef: propTypes.oneOfType([propTypes.string, propTypes.func])
2158
- };
2159
- Link.defaultProps = {
2160
- replace: false
2161
- };
2162
- Link.contextTypes = {
2163
- router: propTypes.shape({
2164
- history: propTypes.shape({
2165
- push: propTypes.func.isRequired,
2166
- replace: propTypes.func.isRequired,
2167
- createHref: propTypes.func.isRequired
2168
- }).isRequired
4971
+ Switch$1.contextTypes = {
4972
+ router: propTypes$1.shape({
4973
+ route: propTypes$1.object.isRequired
2169
4974
  }).isRequired
2170
4975
  };
4976
+ Switch$1.propTypes = {
4977
+ children: propTypes$1.node,
4978
+ location: propTypes$1.object
4979
+ };
2171
4980
 
2172
4981
  // Written in this round about way for babel-transform-imports
2173
4982
 
2174
4983
  // Written in this round about way for babel-transform-imports
2175
4984
 
2176
4985
  /**
2177
- * A <Link> wrapper that knows if it's "active" or not.
4986
+ * Copyright 2015, Yahoo! Inc.
4987
+ * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
2178
4988
  */
2179
- var NavLink = function NavLink(_ref) {
2180
- var to = _ref.to,
2181
- exact = _ref.exact,
2182
- strict = _ref.strict,
2183
- location = _ref.location,
2184
- activeClassName = _ref.activeClassName,
2185
- className = _ref.className,
2186
- activeStyle = _ref.activeStyle,
2187
- style = _ref.style,
2188
- getIsActive = _ref.isActive,
2189
- ariaCurrent = _ref.ariaCurrent,
2190
- rest = objectWithoutProperties(_ref, ['to', 'exact', 'strict', 'location', 'activeClassName', 'className', 'activeStyle', 'style', 'isActive', 'ariaCurrent']);
2191
- return React.createElement(Route, {
2192
- path: (typeof to === 'undefined' ? 'undefined' : _typeof$1(to)) === 'object' ? to.pathname : to,
2193
- exact: exact,
2194
- strict: strict,
2195
- location: location,
2196
- children: function children(_ref2) {
2197
- var location = _ref2.location,
2198
- match = _ref2.match;
4989
+ var REACT_STATICS = {
4990
+ childContextTypes: true,
4991
+ contextTypes: true,
4992
+ defaultProps: true,
4993
+ displayName: true,
4994
+ getDefaultProps: true,
4995
+ mixins: true,
4996
+ propTypes: true,
4997
+ type: true
4998
+ };
2199
4999
 
2200
- var isActive = !!(getIsActive ? getIsActive(match, location) : match);
5000
+ var KNOWN_STATICS = {
5001
+ name: true,
5002
+ length: true,
5003
+ prototype: true,
5004
+ caller: true,
5005
+ callee: true,
5006
+ arguments: true,
5007
+ arity: true
5008
+ };
2201
5009
 
2202
- return React.createElement(Link, _extends({
2203
- to: to,
2204
- className: isActive ? [className, activeClassName].filter(function (i) {
2205
- return i;
2206
- }).join(' ') : className,
2207
- style: isActive ? _extends({}, style, activeStyle) : style,
2208
- 'aria-current': isActive && ariaCurrent
2209
- }, rest));
5010
+ var defineProperty$1 = Object.defineProperty;
5011
+ var getOwnPropertyNames = Object.getOwnPropertyNames;
5012
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
5013
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
5014
+ var getPrototypeOf = Object.getPrototypeOf;
5015
+ var objectPrototype = getPrototypeOf && getPrototypeOf(Object);
5016
+
5017
+ var hoistNonReactStatics = function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
5018
+ if (typeof sourceComponent !== 'string') {
5019
+ // don't hoist over string (html) components
5020
+
5021
+ if (objectPrototype) {
5022
+ var inheritedComponent = getPrototypeOf(sourceComponent);
5023
+ if (inheritedComponent && inheritedComponent !== objectPrototype) {
5024
+ hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
5025
+ }
5026
+ }
5027
+
5028
+ var keys = getOwnPropertyNames(sourceComponent);
5029
+
5030
+ if (getOwnPropertySymbols) {
5031
+ keys = keys.concat(getOwnPropertySymbols(sourceComponent));
5032
+ }
5033
+
5034
+ for (var i = 0; i < keys.length; ++i) {
5035
+ var key = keys[i];
5036
+ if (!REACT_STATICS[key] && !KNOWN_STATICS[key] && (!blacklist || !blacklist[key])) {
5037
+ var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
5038
+ try {
5039
+ // Avoid failures from read-only properties
5040
+ defineProperty$1(targetComponent, key, descriptor);
5041
+ } catch (e) {}
5042
+ }
5043
+ }
5044
+
5045
+ return targetComponent;
2210
5046
  }
2211
- });
2212
- };
2213
5047
 
2214
- NavLink.propTypes = {
2215
- to: Link.propTypes.to,
2216
- exact: propTypes.bool,
2217
- strict: propTypes.bool,
2218
- location: propTypes.object,
2219
- activeClassName: propTypes.string,
2220
- className: propTypes.string,
2221
- activeStyle: propTypes.object,
2222
- style: propTypes.object,
2223
- isActive: propTypes.func,
2224
- ariaCurrent: propTypes.oneOf(['page', 'step', 'location', 'true'])
5048
+ return targetComponent;
2225
5049
  };
2226
5050
 
2227
- NavLink.defaultProps = {
2228
- activeClassName: 'active',
2229
- ariaCurrent: 'true'
5051
+ var _extends$8 = Object.assign || function (target) {
5052
+ for (var i = 1; i < arguments.length; i++) {
5053
+ var source = arguments[i];for (var key in source) {
5054
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
5055
+ target[key] = source[key];
5056
+ }
5057
+ }
5058
+ }return target;
2230
5059
  };
2231
5060
 
2232
- // Written in this round about way for babel-transform-imports
2233
-
2234
- // Written in this round about way for babel-transform-imports
5061
+ function _objectWithoutProperties$1(obj, keys) {
5062
+ var target = {};for (var i in obj) {
5063
+ if (keys.indexOf(i) >= 0) continue;if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;target[i] = obj[i];
5064
+ }return target;
5065
+ }
2235
5066
 
2236
- // Written in this round about way for babel-transform-imports
5067
+ /**
5068
+ * A public higher-order component to access the imperative API
5069
+ */
5070
+ var withRouter$1 = function withRouter(Component) {
5071
+ var C = function C(props) {
5072
+ var wrappedComponentRef = props.wrappedComponentRef,
5073
+ remainingProps = _objectWithoutProperties$1(props, ['wrappedComponentRef']);
5074
+
5075
+ return React.createElement(Route$1, { render: function render(routeComponentProps) {
5076
+ return React.createElement(Component, _extends$8({}, remainingProps, routeComponentProps, { ref: wrappedComponentRef }));
5077
+ } });
5078
+ };
2237
5079
 
2238
- // Written in this round about way for babel-transform-imports
5080
+ C.displayName = 'withRouter(' + (Component.displayName || Component.name) + ')';
5081
+ C.WrappedComponent = Component;
5082
+ C.propTypes = {
5083
+ wrappedComponentRef: propTypes$1.func
5084
+ };
2239
5085
 
2240
- // Written in this round about way for babel-transform-imports
5086
+ return hoistNonReactStatics(C, Component);
5087
+ };
2241
5088
 
2242
5089
  // Written in this round about way for babel-transform-imports
2243
5090
 
2244
5091
  exports.BrowserRouter = BrowserRouter;
2245
5092
  exports.HashRouter = HashRouter;
2246
5093
  exports.Link = Link;
2247
- exports.MemoryRouter = MemoryRouter;
5094
+ exports.MemoryRouter = MemoryRouter$1;
2248
5095
  exports.NavLink = NavLink;
2249
- exports.Prompt = Prompt;
2250
- exports.Redirect = Redirect;
2251
- exports.Route = Route;
2252
- exports.Router = Router;
2253
- exports.StaticRouter = StaticRouter;
2254
- exports.Switch = Switch;
5096
+ exports.Prompt = Prompt$1;
5097
+ exports.Redirect = Redirect$1;
5098
+ exports.Route = Route$1;
5099
+ exports.Router = Router$1;
5100
+ exports.StaticRouter = StaticRouter$1;
5101
+ exports.Switch = Switch$1;
2255
5102
  exports.matchPath = matchPath;
2256
- exports.withRouter = withRouter;
5103
+ exports.withRouter = withRouter$1;
2257
5104
 
2258
5105
  Object.defineProperty(exports, '__esModule', { value: true });
2259
5106