function m(){m=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b],g;for(g in c)Object.prototype.hasOwnProperty.call(c,g)&&(a[g]=c[g])}return a};return m.apply(this,arguments)}var r,u=r||(r={});u.Pop="POP";u.Push="PUSH";u.Replace="REPLACE";var v="production"!==process.env.NODE_ENV?function(a){return Object.freeze(a)}:function(a){return a};function w(a,b){if(!a){"undefined"!==typeof console&&console.warn(b);try{throw Error(b);}catch(c){}}}
function A(a){a.preventDefault();a.returnValue=""}function B(){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 C(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 D(a){var b={};if(a){var c=a.indexOf("#");0<=c&&(b.hash=a.substr(c),a=a.substr(0,c));c=a.indexOf("?");0<=c&&(b.search=a.substr(c),a=a.substr(0,c));a&&(b.pathname=a)}return b}
var I=function(a){function b(){var a=D(h.location.hash.substr(1)),e=a.pathname,b=a.search;a=a.hash;var c=n.state||{};return[c.idx,v({pathname:void 0===e?"/":e,search:void 0===b?"":b,hash:void 0===a?"":a,state:c.usr||null,key:c.key||"default"})]}function c(){if(t)f.call(t),t=null;else{var a=r.Pop,e=b(),c=e[0];e=e[1];if(f.length)if(null!=c){var x=l-c;x&&(t={action:a,location:e,retry:function(){p(-1*x)}},p(x))}else"production"!==process.env.NODE_ENV?w(!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."):
void 0;else y(a)}}function g(a){var b=document.querySelector("base"),c="";b&&b.getAttribute("href")&&(b=h.location.href,c=b.indexOf("#"),c=-1===c?b:b.slice(0,c));return c+"#"+("string"===typeof a?a:C(a))}function E(a,b){void 0===b&&(b=null);return v(m({},q,{},"string"===typeof a?D(a):a,{state:b,key:Math.random().toString(36).substr(2,8)}))}function y(a){z=a;a=b();l=a[0];q=a[1];F.call({action:z,location:q})}function G(a,b){function c(){G(a,b)}var e=r.Push,d=E(a,b);"production"!==process.env.NODE_ENV?
w("/"===d.pathname.charAt(0),"Relative pathnames are not supported in hash history.push("+JSON.stringify(a)+")"):void 0;if(!f.length||(f.call({action:e,location:d,retry:c}),!1)){var k=[{usr:d.state,key:d.key,idx:l+1},g(d)];d=k[0];k=k[1];try{n.pushState(d,"",k)}catch(J){h.location.assign(k)}y(e)}}function H(a,b){function c(){H(a,b)}var k=r.Replace,d=E(a,b);"production"!==process.env.NODE_ENV?w("/"===d.pathname.charAt(0),"Relative pathnames are not supported in hash history.replace("+JSON.stringify(a)+
")"):void 0;f.length&&(f.call({action:k,location:d,retry:c}),1)||(d=[{usr:d.state,key:d.key,idx:l},g(d)],n.replaceState(d[0],"",d[1]),y(k))}function p(a){n.go(a)}void 0===a&&(a={});a=a.window;var h=void 0===a?document.defaultView:a,n=h.history,t=null;h.addEventListener("popstate",c);h.addEventListener("hashchange",function(){var a=b()[1];C(a)!==C(q)&&c()});var z=r.Pop;a=b();var l=a[0],q=a[1],F=B(),f=B();null==l&&(l=0,n.replaceState(m({},n.state,{idx:l}),""));return{get action(){return z},get location(){return q},
createHref:g,push:G,replace:H,go:p,back:function(){p(-1)},forward:function(){p(1)},listen:function(a){return F.push(a)},block:function(a){var b=f.push(a);1===f.length&&h.addEventListener("beforeunload",A);return function(){b();f.length||h.removeEventListener("beforeunload",A)}}}}();export default I;
//# sourceMappingURL=hash.js.map
