'use strict';(function(c,t){"object"===typeof exports&&"undefined"!==typeof module?t(exports):"function"===typeof define&&define.amd?define(["exports"],t):(c=c||self,t(c.HistoryLibrary={}))})(this,function(c){function t(){t=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var f=arguments[b],c;for(c in f)Object.prototype.hasOwnProperty.call(f,c)&&(a[c]=f[c])}return a};return t.apply(this,arguments)}function y(a,b){if(!a){"undefined"!==typeof console&&console.warn(b);try{throw Error(b);
}catch(f){}}}function D(a){a.preventDefault();a.returnValue=""}function z(){var a=[];return{get length(){return a.length},push:function(b){a.push(b);return function(){a=a.filter(function(a){return a!==b})}},call:function(b){a.forEach(function(a){return a&&a(b)})}}}function E(){return Math.random().toString(36).substr(2,8)}function A(a){var b=a.pathname,c=a.search;a=a.hash;return(void 0===b?"/":b)+(void 0===c?"":c)+(void 0===a?"":a)}function B(a){var c={};if(a){var f=a.indexOf("#");0<=f&&(c.hash=a.substr(f),
a=a.substr(0,f));f=a.indexOf("?");0<=f&&(c.search=a.substr(f),a=a.substr(0,f));a&&(c.pathname=a)}return c}(function(a){a.Pop="POP";a.Push="PUSH";a.Replace="REPLACE"})(c.Action||(c.Action={}));c.createBrowserHistory=function(a){function b(){var a=k.location,e=h.state||{};return[e.idx,Object.freeze({pathname:a.pathname,search:a.search,hash:a.hash,state:e.usr||null,key:e.key||"default"})]}function f(a){return"string"===typeof a?a:A(a)}function u(a,e){void 0===e&&(e=null);return Object.freeze(t({},m,
{},"string"===typeof a?B(a):a,{state:e,key:E()}))}function w(a){n=a;a=b();q=a[0];m=a[1];d.call({action:n,location:m})}function x(a,e){function d(){x(a,e)}var l=c.Action.Push,C=u(a,e);if(!g.length||(g.call({action:l,location:C,retry:d}),!1)){var b=[{usr:C.state,key:C.key,idx:q+1},f(C)];C=b[0];b=b[1];try{h.pushState(C,"",b)}catch(F){k.location.assign(b)}w(l)}}function v(a,e){function d(){v(a,e)}var b=c.Action.Replace,l=u(a,e);g.length&&(g.call({action:b,location:l,retry:d}),1)||(l=[{usr:l.state,key:l.key,
idx:q},f(l)],h.replaceState(l[0],"",l[1]),w(b))}function r(a){h.go(a)}void 0===a&&(a={});a=a.window;var k=void 0===a?document.defaultView:a,h=k.history,p=null;k.addEventListener("popstate",function(){if(p)g.call(p),p=null;else{var a=c.Action.Pop,e=b(),d=e[0];e=e[1];if(g.length)if(null!=d){var f=q-d;f&&(p={action:a,location:e,retry:function(){r(-1*f)}},r(f))}else y(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");
else w(a)}});var n=c.Action.Pop;a=b();var q=a[0],m=a[1],d=z(),g=z();null==q&&(q=0,h.replaceState(t({},h.state,{idx:q}),""));return{get action(){return n},get location(){return m},createHref:f,push:x,replace:v,go:r,back:function(){r(-1)},forward:function(){r(1)},listen:function(a){return d.push(a)},block:function(a){var e=g.push(a);1===g.length&&k.addEventListener("beforeunload",D);return function(){e();g.length||k.removeEventListener("beforeunload",D)}}}};c.createHashHistory=function(a){function b(){var a=
B(h.location.hash.substr(1)),d=a.pathname,c=a.search;a=a.hash;var b=p.state||{};return[b.idx,Object.freeze({pathname:void 0===d?"/":d,search:void 0===c?"":c,hash:void 0===a?"":a,state:b.usr||null,key:b.key||"default"})]}function f(){if(n)l.call(n),n=null;else{var a=c.Action.Pop,d=b(),g=d[0];d=d[1];if(l.length)if(null!=g){var f=m-g;f&&(n={action:a,location:d,retry:function(){k(-1*f)}},k(f))}else y(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");
else x(a)}}function u(a){var e=document.querySelector("base"),d="";e&&e.getAttribute("href")&&(e=h.location.href,d=e.indexOf("#"),d=-1===d?e:e.slice(0,d));return d+"#"+("string"===typeof a?a:A(a))}function w(a,c){void 0===c&&(c=null);return Object.freeze(t({},d,{},"string"===typeof a?B(a):a,{state:c,key:E()}))}function x(a){q=a;a=b();m=a[0];d=a[1];g.call({action:q,location:d})}function v(a,d){function e(){v(a,d)}var b=c.Action.Push,g=w(a,d);y("/"===g.pathname.charAt(0),"Relative pathnames are not supported in hash history.push("+
JSON.stringify(a)+")");if(!l.length||(l.call({action:b,location:g,retry:e}),!1)){var f=[{usr:g.state,key:g.key,idx:m+1},u(g)];g=f[0];f=f[1];try{p.pushState(g,"",f)}catch(G){h.location.assign(f)}x(b)}}function r(a,d){function e(){r(a,d)}var g=c.Action.Replace,b=w(a,d);y("/"===b.pathname.charAt(0),"Relative pathnames are not supported in hash history.replace("+JSON.stringify(a)+")");l.length&&(l.call({action:g,location:b,retry:e}),1)||(b=[{usr:b.state,key:b.key,idx:m},u(b)],p.replaceState(b[0],"",b[1]),
x(g))}function k(a){p.go(a)}void 0===a&&(a={});a=a.window;var h=void 0===a?document.defaultView:a,p=h.history,n=null;h.addEventListener("popstate",f);h.addEventListener("hashchange",function(){var a=b()[1];A(a)!==A(d)&&f()});var q=c.Action.Pop;a=b();var m=a[0],d=a[1],g=z(),l=z();null==m&&(m=0,p.replaceState(t({},p.state,{idx:m}),""));return{get action(){return q},get location(){return d},createHref:u,push:v,replace:r,go:k,back:function(){k(-1)},forward:function(){k(1)},listen:function(a){return g.push(a)},
block:function(a){var d=l.push(a);1===l.length&&h.addEventListener("beforeunload",D);return function(){d();l.length||h.removeEventListener("beforeunload",D)}}}};c.createMemoryHistory=function(a){function b(a,b){void 0===b&&(b=null);return Object.freeze(t({},n,{},"string"===typeof a?B(a):a,{state:b,key:E()}))}function f(a,b,c){return!m.length||(m.call({action:a,location:b,retry:c}),!1)}function u(a,b){p=a;n=b;q.call({action:p,location:n})}function w(a,g){var d=c.Action.Push,e=b(a,g);y("/"===n.pathname.charAt(0),
"Relative pathnames are not supported in memory history.push("+JSON.stringify(a)+")");f(d,e,function(){w(a,g)})&&(h+=1,k.splice(h,k.length,e),u(d,e))}function x(a,g){var d=c.Action.Replace,e=b(a,g);y("/"===n.pathname.charAt(0),"Relative pathnames are not supported in memory history.replace("+JSON.stringify(a)+")");f(d,e,function(){x(a,g)})&&(k[h]=e,u(d,e))}function v(a){var b=Math.min(Math.max(h+a,0),k.length-1),d=c.Action.Pop,e=k[b];f(d,e,function(){v(a)})&&(h=b,u(d,e))}void 0===a&&(a={});var r=
a;a=r.initialEntries;r=r.initialIndex;var k=(void 0===a?["/"]:a).map(function(a){var b=Object.freeze(t({pathname:"/",search:"",hash:"",state:null,key:E()},"string"===typeof a?B(a):a));y("/"===b.pathname.charAt(0),"Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(a)+")");return b}),h=Math.min(Math.max(null==r?k.length-1:r,0),k.length-1),p=c.Action.Pop,n=k[h],q=z(),m=z();return{get index(){return h},get action(){return p},get location(){return n},
createHref:function(a){return"string"===typeof a?a:A(a)},push:w,replace:x,go:v,back:function(){v(-1)},forward:function(){v(1)},listen:function(a){return q.push(a)},block:function(a){return m.push(a)}}};c.createPath=A;c.parsePath=B;Object.defineProperty(c,"__esModule",{value:!0})});
//# sourceMappingURL=history.development.js.map
