react-router.js 101 KB

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