function n(){return n=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o])}return n},n.apply(this,arguments)}function t(n){return"/"===n.charAt(0)}function e(n,t){for(var e=t,o=e+1,i=n.length;o<i;e+=1,o+=1)n[e]=n[o];n.pop()}function o(n){return n.valueOf?n.valueOf():Object.prototype.valueOf.call(n)}function i(n,t){if(n===t)return!0;if(null==n||null==t)return!1;if(Array.isArray(n))return Array.isArray(t)&&n.length===t.length&&n.every((function(n,e){return i(n,t[e])}));if("object"==typeof n||"object"==typeof t){var e=o(n),r=o(t);return e!==n||r!==t?i(e,r):Object.keys(Object.assign({},n,t)).every((function(e){return i(n[e],t[e])}))}return!1}var r="Invariant failed";function a(n,t){throw new Error(r)}function c(n){return"/"===n.charAt(0)?n:"/"+n}function u(n){return"/"===n.charAt(0)?n.substr(1):n}function f(n,t){return function(n,t){return 0===n.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(n.charAt(t.length))}(n,t)?n.substr(t.length):n}function s(n){return"/"===n.charAt(n.length-1)?n.slice(0,-1):n}function h(n){var t=n.pathname,e=n.search,o=n.hash,i=t||"/";return e&&"?"!==e&&(i+="?"===e.charAt(0)?e:"?"+e),o&&"#"!==o&&(i+="#"===o.charAt(0)?o:"#"+o),i}function l(o,i,r,a){var c;"string"==typeof o?(c=function(n){var t=n||"/",e="",o="",i=t.indexOf("#");-1!==i&&(o=t.substr(i),t=t.substr(0,i));var r=t.indexOf("?");return-1!==r&&(e=t.substr(r),t=t.substr(0,r)),{pathname:t,search:"?"===e?"":e,hash:"#"===o?"":o}}(o),c.state=i):(void 0===(c=n({},o)).pathname&&(c.pathname=""),c.search?"?"!==c.search.charAt(0)&&(c.search="?"+c.search):c.search="",c.hash?"#"!==c.hash.charAt(0)&&(c.hash="#"+c.hash):c.hash="",void 0!==i&&void 0===c.state&&(c.state=i));try{c.pathname=decodeURI(c.pathname)}catch(u){throw u instanceof URIError?new URIError('Pathname "'+c.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):u}return r&&(c.key=r),a?c.pathname?"/"!==c.pathname.charAt(0)&&(c.pathname=function(n,o){void 0===o&&(o="");var i,r=n&&n.split("/")||[],a=o&&o.split("/")||[],c=n&&t(n),u=o&&t(o),f=c||u;if(n&&t(n)?a=r:r.length&&(a.pop(),a=a.concat(r)),!a.length)return"/";if(a.length){var s=a[a.length-1];i="."===s||".."===s||""===s}else i=!1;for(var h=0,l=a.length;l>=0;l--){var d=a[l];"."===d?e(a,l):".."===d?(e(a,l),h++):h&&(e(a,l),h--)}if(!f)for(;h--;h)a.unshift("..");!f||""===a[0]||a[0]&&t(a[0])||a.unshift("");var v=a.join("/");return i&&"/"!==v.substr(-1)&&(v+="/"),v}(c.pathname,a.pathname)):c.pathname=a.pathname:c.pathname||(c.pathname="/"),c}function d(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash&&n.key===t.key&&i(n.state,t.state)}function v(){var n=null;var t=[];return{setPrompt:function(t){return n=t,function(){n===t&&(n=null)}},confirmTransitionTo:function(t,e,o,i){if(null!=n){var r="function"==typeof n?n(t,e):n;"string"==typeof r?"function"==typeof o?o(r,i):i(!0):i(!1!==r)}else i(!0)},appendListener:function(n){var e=!0;function o(){e&&n.apply(void 0,arguments)}return t.push(o),function(){e=!1,t=t.filter((function(n){return n!==o}))}},notifyListeners:function(){for(var n=arguments.length,e=new Array(n),o=0;o<n;o++)e[o]=arguments[o];t.forEach((function(n){return n.apply(void 0,e)}))}}}var p=!("undefined"==typeof window||!window.document||!window.document.createElement);function g(n,t){t(window.confirm(n))}var w="popstate",m="hashchange";function y(){try{return window.history.state||{}}catch(n){return{}}}function O(t){void 0===t&&(t={}),p||a();var e,o=window.history,i=(-1===(e=window.navigator.userAgent).indexOf("Android 2.")&&-1===e.indexOf("Android 4.0")||-1===e.indexOf("Mobile Safari")||-1!==e.indexOf("Chrome")||-1!==e.indexOf("Windows Phone"))&&window.history&&"pushState"in window.history,r=!(-1===window.navigator.userAgent.indexOf("Trident")),u=t,d=u.forceRefresh,O=void 0!==d&&d,P=u.getUserConfirmation,b=void 0===P?g:P,x=u.keyLength,A=void 0===x?6:x,k=t.basename?s(c(t.basename)):"";function T(n){var t=n||{},e=t.key,o=t.state,i=window.location,r=i.pathname+i.search+i.hash;return k&&(r=f(r,k)),l(r,o,e)}function L(){return Math.random().toString(36).substr(2,A)}var E=v();function S(t){n(W,t),W.length=o.length,E.notifyListeners(W.location,W.action)}function C(n){(function(n){return void 0===n.state&&-1===navigator.userAgent.indexOf("CriOS")})(n)||I(T(n.state))}function j(){I(T(y()))}var U=!1;function I(n){if(U)U=!1,S();else{E.confirmTransitionTo(n,"POP",b,(function(t){t?S({action:"POP",location:n}):function(n){var t=W.location,e=H.indexOf(t.key);-1===e&&(e=0);var o=H.indexOf(n.key);-1===o&&(o=0);var i=e-o;i&&(U=!0,F(i))}(n)}))}}var R=T(y()),H=[R.key];function M(n){return k+h(n)}function F(n){o.go(n)}var B=0;function q(n){1===(B+=n)&&1===n?(window.addEventListener(w,C),r&&window.addEventListener(m,j)):0===B&&(window.removeEventListener(w,C),r&&window.removeEventListener(m,j))}var G=!1;var W={length:o.length,action:"POP",location:R,createHref:M,push:function(n,t){var e="PUSH",r=l(n,t,L(),W.location);E.confirmTransitionTo(r,e,b,(function(n){if(n){var t=M(r),a=r.key,c=r.state;if(i)if(o.pushState({key:a,state:c},null,t),O)window.location.href=t;else{var u=H.indexOf(W.location.key),f=H.slice(0,u+1);f.push(r.key),H=f,S({action:e,location:r})}else window.location.href=t}}))},replace:function(n,t){var e="REPLACE",r=l(n,t,L(),W.location);E.confirmTransitionTo(r,e,b,(function(n){if(n){var t=M(r),a=r.key,c=r.state;if(i)if(o.replaceState({key:a,state:c},null,t),O)window.location.replace(t);else{var u=H.indexOf(W.location.key);-1!==u&&(H[u]=r.key),S({action:e,location:r})}else window.location.replace(t)}}))},go:F,goBack:function(){F(-1)},goForward:function(){F(1)},block:function(n){void 0===n&&(n=!1);var t=E.setPrompt(n);return G||(q(1),G=!0),function(){return G&&(G=!1,q(-1)),t()}},listen:function(n){var t=E.appendListener(n);return q(1),function(){q(-1),t()}}};return W}var P="hashchange",b={hashbang:{encodePath:function(n){return"!"===n.charAt(0)?n:"!/"+u(n)},decodePath:function(n){return"!"===n.charAt(0)?n.substr(1):n}},noslash:{encodePath:u,decodePath:c},slash:{encodePath:c,decodePath:c}};function x(n){var t=n.indexOf("#");return-1===t?n:n.slice(0,t)}function A(){var n=window.location.href,t=n.indexOf("#");return-1===t?"":n.substring(t+1)}function k(n){window.location.replace(x(window.location.href)+"#"+n)}function T(t){void 0===t&&(t={}),p||a();var e=window.history;window.navigator.userAgent.indexOf("Firefox");var o=t,i=o.getUserConfirmation,r=void 0===i?g:i,u=o.hashType,d=void 0===u?"slash":u,w=t.basename?s(c(t.basename)):"",m=b[d],y=m.encodePath,O=m.decodePath;function T(){var n=O(A());return w&&(n=f(n,w)),l(n)}var L=v();function E(t){n(G,t),G.length=e.length,L.notifyListeners(G.location,G.action)}var S=!1,C=null;function j(){var n,t,e=A(),o=y(e);if(e!==o)k(o);else{var i=T(),a=G.location;if(!S&&(t=i,(n=a).pathname===t.pathname&&n.search===t.search&&n.hash===t.hash))return;if(C===h(i))return;C=null,function(n){if(S)S=!1,E();else{var t="POP";L.confirmTransitionTo(n,t,r,(function(e){e?E({action:t,location:n}):function(n){var t=G.location,e=H.lastIndexOf(h(t));-1===e&&(e=0);var o=H.lastIndexOf(h(n));-1===o&&(o=0);var i=e-o;i&&(S=!0,M(i))}(n)}))}}(i)}}var U=A(),I=y(U);U!==I&&k(I);var R=T(),H=[h(R)];function M(n){e.go(n)}var F=0;function B(n){1===(F+=n)&&1===n?window.addEventListener(P,j):0===F&&window.removeEventListener(P,j)}var q=!1;var G={length:e.length,action:"POP",location:R,createHref:function(n){var t=document.querySelector("base"),e="";return t&&t.getAttribute("href")&&(e=x(window.location.href)),e+"#"+y(w+h(n))},push:function(n,t){var e="PUSH",o=l(n,void 0,void 0,G.location);L.confirmTransitionTo(o,e,r,(function(n){if(n){var t=h(o),i=y(w+t);if(A()!==i){C=t,function(n){window.location.hash=n}(i);var r=H.lastIndexOf(h(G.location)),a=H.slice(0,r+1);a.push(t),H=a,E({action:e,location:o})}else E()}}))},replace:function(n,t){var e="REPLACE",o=l(n,void 0,void 0,G.location);L.confirmTransitionTo(o,e,r,(function(n){if(n){var t=h(o),i=y(w+t);A()!==i&&(C=t,k(i));var r=H.indexOf(h(G.location));-1!==r&&(H[r]=t),E({action:e,location:o})}}))},go:M,goBack:function(){M(-1)},goForward:function(){M(1)},block:function(n){void 0===n&&(n=!1);var t=L.setPrompt(n);return q||(B(1),q=!0),function(){return q&&(q=!1,B(-1)),t()}},listen:function(n){var t=L.appendListener(n);return B(1),function(){B(-1),t()}}};return G}function L(n,t,e){return Math.min(Math.max(n,t),e)}function E(t){void 0===t&&(t={});var e=t,o=e.getUserConfirmation,i=e.initialEntries,r=void 0===i?["/"]:i,a=e.initialIndex,c=void 0===a?0:a,u=e.keyLength,f=void 0===u?6:u,s=v();function d(t){n(O,t),O.length=O.entries.length,s.notifyListeners(O.location,O.action)}function p(){return Math.random().toString(36).substr(2,f)}var g=L(c,0,r.length-1),w=r.map((function(n){return l(n,void 0,"string"==typeof n?p():n.key||p())})),m=h;function y(n){var t=L(O.index+n,0,O.entries.length-1),e=O.entries[t];s.confirmTransitionTo(e,"POP",o,(function(n){n?d({action:"POP",location:e,index:t}):d()}))}var O={length:w.length,action:"POP",location:w[g],index:g,entries:w,createHref:m,push:function(n,t){var e="PUSH",i=l(n,t,p(),O.location);s.confirmTransitionTo(i,e,o,(function(n){if(n){var t=O.index+1,o=O.entries.slice(0);o.length>t?o.splice(t,o.length-t,i):o.push(i),d({action:e,location:i,index:t,entries:o})}}))},replace:function(n,t){var e="REPLACE",i=l(n,t,p(),O.location);s.confirmTransitionTo(i,e,o,(function(n){n&&(O.entries[O.index]=i,d({action:e,location:i}))}))},go:y,goBack:function(){y(-1)},goForward:function(){y(1)},canGo:function(n){var t=O.index+n;return t>=0&&t<O.entries.length},block:function(n){return void 0===n&&(n=!1),s.setPrompt(n)},listen:function(n){return s.appendListener(n)}};return O}export{n as _,l as a,h as b,E as c,O as d,T as e,a as i,d as l};