react-router.js 101 KB

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