react-router-dom.js 130 KB

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