Comparing version 0.12.9 to 0.12.10
@@ -20,3 +20,3 @@ "use strict"; | ||
if (rootPath === void 0) { rootPath = ''; } | ||
return (rootPath !== '' | ||
return rootPath !== '' | ||
? createMapping(rootPath, matcher) | ||
@@ -28,3 +28,3 @@ : { | ||
matcher: matcher, | ||
}); | ||
}; | ||
} | ||
@@ -91,2 +91,6 @@ exports.createRootMapping = createRootMapping; | ||
var matchedPathname = match[0]; | ||
var unmatchedPath = request.path.slice(matchedPathname.length) || ''; | ||
if (unmatchedPath.length && unmatchedPath[0] !== '/') { | ||
return; | ||
} | ||
// Set path params using RegExp match | ||
@@ -101,3 +105,2 @@ var params = request.params; | ||
} | ||
var unmatchedPath = request.path.slice(matchedPathname.length) || ''; | ||
var mountpath = URLTools_1.joinPaths(request.mountpath, matchedPathname) || '/'; | ||
@@ -111,4 +114,4 @@ return NaviRequest_1.createRequest(__assign({}, request, { params: params, | ||
function escapeRegExp(value) { | ||
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); | ||
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | ||
} | ||
//# sourceMappingURL=Mapping.js.map |
@@ -18,3 +18,3 @@ var __assign = (this && this.__assign) || function () { | ||
if (rootPath === void 0) { rootPath = ''; } | ||
return (rootPath !== '' | ||
return rootPath !== '' | ||
? createMapping(rootPath, matcher) | ||
@@ -26,3 +26,3 @@ : { | ||
matcher: matcher, | ||
}); | ||
}; | ||
} | ||
@@ -87,2 +87,6 @@ export function createMapping(pattern, matcher) { | ||
var matchedPathname = match[0]; | ||
var unmatchedPath = request.path.slice(matchedPathname.length) || ''; | ||
if (unmatchedPath.length && unmatchedPath[0] !== '/') { | ||
return; | ||
} | ||
// Set path params using RegExp match | ||
@@ -97,3 +101,2 @@ var params = request.params; | ||
} | ||
var unmatchedPath = request.path.slice(matchedPathname.length) || ''; | ||
var mountpath = joinPaths(request.mountpath, matchedPathname) || '/'; | ||
@@ -106,4 +109,4 @@ return createRequest(__assign({}, request, { params: params, | ||
function escapeRegExp(value) { | ||
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); | ||
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | ||
} | ||
//# sourceMappingURL=Mapping.js.map |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("history")):"function"==typeof define&&define.amd?define(["exports","history"],e):e((t=t||self).Navi={},t.History)}(this,function(t,e){"use strict";var r=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},n=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t};function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)throw new Error("composeMatchers() expects at least one matcher.");return 1===t.length?t[0]:t.reduce(function(t,e){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return t(e.apply(void 0,n(r)))}})}var a=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},i=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t},u=/((((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;function s(t,e){var r,n,o,a,i,s=void 0===e?{}:e,h=s.removeHash,f=void 0!==h&&h,y=s.trailingSlash,d=void 0===y?null:y;if("string"==typeof t){var b=u.exec(t);if(!b)throw new Error("Couldn't parse the provided URL.");r="",n=p(b[2]||"",d),o=c(a=b[6]||""),i=b[7]||""}else r=t.hostname||"",n=p(t.pathname||"",d),o=t.query||(t.search?c(t.search):{}),a=t.search||l(o),i=t.hash||"";return{hostname:r,pathname:n,query:o,search:a,hash:f?"":i,href:n+a+i}}function c(t,e){if(void 0===e&&(e="?"),!t||t[0]!=e)return{};for(var r={},n=t.slice(1).split("&"),o=0,a=n.length;o<a;o++){var i=n[o].split("=");r[i[0]]=i[1]?decodeURIComponent(i[1]):""}return r}function l(t,e){void 0===e&&(e="?");var r=Object.keys(t);if(0===r.length)return"";for(var n=[],o=0,a=r.length;o<a;o++){var i=r[o],u=String(t[i]);n.push(""===u?i:i+"="+encodeURIComponent(u))}return e+n.join("&")}function h(t){return""===t?[]:t.split("/")}function f(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=h(t),o=0;o<e.length;o++)n.push.apply(n,i(h(e[o])));var a=[],u=n.length-1;for(o=0;o<=u;o++){var s=n[o];".."===s?a.pop():"."===s||""===s&&0!==o&&o!==u||a.push(s)}return a.join("/")}function p(t,e){var r="/"===t.slice(-1);return"add"!==e||r?"remove"===e&&r&&t.length>1?t.slice(0,-1):t:t+"/"}var y,d=(y=function(t,e){return(y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}y(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),b=function(t){function e(e){var r=this,n=this.constructor.prototype;return(r=t.call(this,e)||this).__proto__=n,Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(r,r.constructor):Object.defineProperty(r,"stack",{value:(new Error).stack}),Object.defineProperty(r,"message",{value:e}),r}return d(e,t),e}(Error),v=function(t){function e(e){var r=t.call(this,"URL not found: "+e)||this;return r.pathname=e,r.status=404,r.name="NotFoundError",r}return d(e,t),e}(b),m=function(t){function e(e){var r=t.call(this,"URL not managed by router: "+e.href)||this;return r.url=e,r.name="OutOfRootError",r}return d(e,t),e}(b);function w(t,e,r){return Object.assign({type:t,request:e,url:s({pathname:e.mountpath,query:e.query})},r)}function g(t){var e=f(t.mountpath,t.path);return{type:"error",request:t,url:s({pathname:e,query:t.query}),error:new v(e)}}var x=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},S=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function O(t,e,r){var n,o,a,i,u,s,c;return x(this,function(l){switch(l.label){case 0:n="function"==typeof t?t:function(){return t};try{o=n(e,e.context)}catch(t){o=Promise.reject(t)}return k(o)?[3,1]:(a=r(o),[3,7]);case 1:i=o.then(P),u=function(t){var e={};return t.then(function(t){e.value=t,e.outcome="resolved"},function(t){e.error=t,e.outcome="rejected"}),e}(i),s=[w("busy",e,{promise:i})],l.label=2;case 2:return u.outcome?[3,4]:[4,s];case 3:return l.sent(),[3,2];case 4:return"rejected"!==u.outcome?[3,6]:((c=u.error)instanceof v&&!c.pathname&&(c.pathname=f(e.mountpath,e.path)),[4,[w("error",e,{error:c})]]);case 5:return l.sent(),[3,7];case 6:a=r(u.value),l.label=7;case 7:return a?Array.isArray(a)?[4,a.length?a:[]]:[3,9]:[3,11];case 8:return l.sent(),[3,11];case 9:return[5,S(a)];case 10:l.sent(),l.label=11;case 11:return[2]}})}function k(t){return!!t&&!!t.then}function P(t){return function(t){return t&&"object"==typeof t&&"default"in t}(t)?t.default:t}var j=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function _(t,e,r){return void 0===r&&(r=""),t(e)}function R(t,e){var r,n,o,a;return j(this,function(i){switch(i.label){case 0:o=[],a=[],i.label=1;case 1:return(r=t.next()).done||(o=r.value||[]),(n=e.next()).done||(a=n.value||[]),[4,o.concat(a)];case 2:i.sent(),i.label=3;case 3:if(!r.done||!n.done)return[3,1];i.label=4;case 4:return[2]}})}var E=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},T=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function C(t,e,r,n,o,a){function i(e,i){var u,s;return E(this,function(c){switch(c.label){case 0:return u=e.path,(void 0===n?!i:n)&&u&&"/"!==u?[4,[g(e)]]:[3,2];case 1:return c.sent(),[3,4];case 2:return s=e.crawler&&!o||a&&!a(e)?function(){return E(this,function(t){switch(t.label){case 0:return[4,[]];case 1:return t.sent(),[2]}})}():O(t,e,function(t){return r(t,e)}),[5,T(i?R(s,_(i,e)):s)];case 3:c.sent(),c.label=4;case 4:return[2]}})}return function(t){return function(r){return i(r,e?e(t):t)}}}function L(t,e,r){return C(t,e,function(t,e){return t?[w("view",e,{view:t})]:[]},r,!1,function(t){return"HEAD"!==t.method})}var I=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},D=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function M(t){return function(e){return function(r){return I(this,function(n){switch(n.label){case 0:return[5,D(O(t,r,function(t){return _(t(e),r)}))];case 1:return n.sent(),[2]}})}}}function U(t,e){return Object.defineProperties(t,{mountname:{get:function(){return t.mountpath}},pathname:{get:function(){return t.mountpath}}}),e&&Object.defineProperties(t,{router:{get:function(){return e},enumerable:!1},_router:{value:e}}),t}var q=function(){return(q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},A="\0";function G(t,e){var r=t;if(r.length>1&&"/"===r.substr(-1)&&(r=r.substr(0,r.length-1)),"/"!==r[0]&&(r="/"+r),/\/{2,}/.test(r)&&(r=r.replace(/\/{2,}/g,"/")),/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(r),0===r.length)throw new Error('You cannot use an empty string "" as a pattern!');for(var n=r.split("/").slice(1),o=[],a=[],i=["^"],u=0;u<n.length;u++){var s=n[u];s.length>1&&":"===s[0]?(o.push(s.slice(1)),a.push(A),i.push("([^/]+)")):(a.push(s),i.push(s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}return{key:a.join("/"),matcher:e,pattern:r,pathParamNames:o.length?o:void 0,regExp:"/"===r?/^\/$/:new RegExp(i.join("/"))}}function N(t,e){var r=e.regExp.exec(t.path||"/");if(r){var n=r[0],o=t.params;if(e.pathParamNames){o=q({},t.params);for(var a=0;a<e.pathParamNames.length;a++){o[e.pathParamNames[a]]=r[a+1]}}var i=t.path.slice(n.length)||"",u=f(t.mountpath,n)||"/";return U(q({},t,{params:o,mountpath:u,path:i,url:i+t.search}),t._router)}}function H(t){return[].concat.apply([],t)}var F=function(){return(F=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Q=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},V=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Y=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};function $(t){if(!t)throw new Error("mount() must be supplied with a paths object.");var e=Object.keys(t),r=e.filter(function(t){return"*"!==t}).map(function(e){return G(e,t[e])}).sort(function(t,e){return r=t.key,n=e.key,r<n?-1:r>n?1:0;var r,n});return function(n){return function(o){var a,i,u,s,c,l,h,f,p,y,d,b,v,m,x,S,O;return V(this,function(k){switch(k.label){case 0:if(u=[],s=[],c=[],l=o.crawler,!(h=l&&(""===o.path||"/"===o.path)))return[3,5];(f=function(t,e,r){return Q(this,void 0,void 0,function(){var n;return V(this,function(o){switch(o.label){case 0:return n=H,[4,Promise.all(Object.entries(t).map(function(t){var n,o=Y(t,2),a=o[0],i=o[1];return e("*"===a?"":a,r).then((n=i,function(t){return t.map(function(t){return[n,t]})}))}))];case 1:return[2,n.apply(void 0,[o.sent()])]}})})}(t,l,o)).then(function(t){p=t},function(t){return y=t}),k.label=1;case 1:return[4,[w("busy",o,{promise:f})]];case 2:if(k.sent(),y)throw y;k.label=3;case 3:if(!p)return[3,1];k.label=4;case 4:return i=p.map(function(t,e){var r=Y(t,2),a=r[0],i=r[1],u=F({},o,{mountpath:i.url.pathname,url:"",path:""});return c[e]=u,_(a(n),u,u.mountpath)}),[3,6];case 5:for(S=r.length-1;S>=0;S--)if(d=r[S],b=N(o,d)){i=[_(d.matcher(n),b,d.pattern)];break}i||(v=t["*"])&&(i=[_(v(n),o,"*")]),k.label=6;case 6:if(i)for(S=0;S<i.length;S++)(m=u[S])&&m.done||(m=u[S]=i[S].next()),m&&!m.done&&(s[S]=m.value);for(a=[w("mount",o,{patterns:e})],x=!1,S=0;S<u.length;S++)(O=s[S])&&(x=!0,h&&!O.some(z)&&(a=a.concat(w("crawl",c[S]))),a=a.concat(O));return l||x||a.push(g(o)),[4,a];case 7:k.sent(),k.label=8;case 8:if(a.filter(B).length)return[3,6];k.label=9;case 9:return[2]}})}}}function B(t){return"busy"===t.type}function z(t){return"mount"===t.type}function W(t,e){var r=(void 0===e?{}:e).exact;return C(t,void 0,function(t,e){var r;return"string"==typeof t?r="/"===t[0]?t:f("/",e.mountpath,t):t&&(r=s(t).href),r?[w("redirect",e,{to:r})]:[]},void 0===r||r,!0)}var Z=function(){return(Z=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},J=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},K=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function X(t,e){return function(r){return function(n){return function(e,r){return J(this,function(n){switch(n.label){case 0:return[5,K(O(t,e,function(t){return _(r,Z({},e,{context:t||{}}))}))];case 1:return n.sent(),[2]}})}(n,e?e(r):r)}}}function tt(t,e){return C(t,e,function(t,e){return t?[w("data",e,{data:t})]:[]})}function et(t,e){return C(t,e,function(t,e){return t?[w("title",e,{title:t})]:[]})}var rt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},nt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ot=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},at=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function it(t){return function(e,r){return rt(this,void 0,void 0,function(){var n,o,a,i;return nt(this,function(u){switch(u.label){case 0:return n=t.getMeta?Promise.resolve(t.getMeta(e,r,void 0)).then(P).then(ut):Promise.resolve(t.meta||{}),o=t.getTitle?Promise.resolve(t.getTitle(e,r,n)).then(P):Promise.resolve(t.title),"HEAD"!==e.method&&(a=t.getContent?Promise.resolve(t.getContent(e,r,n)).then(P):Promise.resolve(t.content)),i={},[4,n];case 1:return i.meta=u.sent(),[4,a];case 2:return i.content=u.sent(),[4,o];case 3:return[2,(i.title=u.sent(),i)]}})})}}function ut(t){return t||{}}function st(t,e){return C(t,e,function(t,e){return t?[w("head",e,{head:t})]:[]})}function ct(t,e){return C(t,e,function(t,e){return t?[w("headers",e,{headers:t})]:[]})}var lt=function(){return(lt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},ht=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ft=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function pt(t,e){function r(e,r){return ht(this,function(n){switch(n.label){case 0:return[5,ft(O(t,e,function(t){var n=null===t?e.state:lt({},e.state,t);return R(function(t){return ht(this,function(e){switch(e.label){case 0:return[4,t];case 1:return e.sent(),[2]}})}(null===t?[]:[w("state",e,{state:n})]),_(r,lt({},e,{state:n})))}))];case 1:return n.sent(),[2]}})}return function(t){return function(n){return r(n,e?e(t):t)}}}function yt(t,e){return C(t,e,function(t,e){return t?[w("status",e,{status:t})]:[]})}var dt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},bt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},vt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},mt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};function wt(t){return t||{}}function gt(t,e,r,n){if(e){var o=e(r,n);return k(o)?[o.then(P),!0]:[o,!1]}return[t,!1]}var xt=function(){return(xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},St=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Ot=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},kt=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};var Pt=function(){function t(t,e){this.close=t,this.observer=e,this.observer.start&&this.observer.start(this)}return t.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this.close(this.observer),delete this.close,delete this.observer)},t}();function jt(t,e,r){return"function"==typeof t?{next:t,error:e,complete:r}:t}function _t(t){return new Promise(function(e,r){t.subscribe({start:function(t){this.subscription=t},next:function(t){this.value=t},complete:function(){e(this.value),this.subscription.unsubscribe()},error:function(t){r(t),this.subscription.unsubscribe()}})})}var Rt=function(){function t(t,e,r){var n=this;this.handleUnsubscribe=function(t){var e=n.observers.indexOf(t);-1!==e&&n.observers.splice(e,1)},this.handleChange=function(t){if(t===n.lastListenId){n.lastListenId++,n.refresh();for(var e=n.result.done||n.result.value.every(function(t){return"busy"!==t.type}),r=0;r<n.observers.length;r++){var o=n.observers[r];o.next(n.result.value),e&&o.complete&&o.complete()}e&&delete n.matcherIterator}},this.refresh=function(){var t=n.matcherIterator.next();if(t.value&&(n.result=t),!n.result.done){var e=++n.lastListenId,r=function(){return n.handleChange(e)};Promise.race(n.result.value.filter(Et).map(Tt)).then(r,r)}},this.url=t,this.lastListenId=0,this.observers=[],this.matcherIterator=r(e)}return t.prototype.subscribe=function(t,e,r){if(!this.matcherIterator)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=jt(t,e,r);this.observers.push(n);var o=new Pt(this.handleUnsubscribe,n);return 1===this.observers.length&&this.handleChange(this.lastListenId),o},t}();function Et(t){return"busy"===t.type}function Tt(t){return t.promise}var Ct=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Lt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},It=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},Dt=function(){function t(t,e,r,n,o,a){var i=this;this.handleUnsubscribe=function(t){var e=i.observers.indexOf(t);-1!==e&&i.observers.splice(e,1)},this.handleResolverUpdate=function(t){t===i.lastListenId&&(i.lastListenId++,i.isRefreshing?i.isRefreshScheduled||(i.isRefreshScheduled=!0):i.refresh())},this.refresh=function(){return Ct(i,void 0,void 0,function(){var t,e,r,n,o,a,i,u,s,c,l,h,y,d,b,v,m,w,g=this;return Lt(this,function(x){switch(x.label){case 0:this.isRefreshScheduled=!1,this.isRefreshing=!0,t=[],e=0,r=function(){var r,o,a,i,u,s,c,l,h,p,y;return Lt(this,function(d){switch(d.label){case 0:r=n.mapItems[e],o=r.pathname,a=r.matcherIterator.next(),r.lastResult&&!a.value||(r.lastResult=a),i=r.lastResult.value,r.chunksCache=i||[],u=i.findIndex(function(t){return"error"===t.type||t.url.href.length>=r.url.href.length&&("mount"===t.type&&r.lastMountPatterns!==t.patterns||"redirect"===t.type&&r.lastRedirectTo!==t.to)}),d.label=1;case 1:if(!(u>=0&&u<i.length))return[3,6];if(s=i[u],u++,"error"===s.type||n.options.predicate&&!n.options.predicate(s,i))return n.removeFromQueue(r),[2,"continue-items"];if("redirect"===s.type&&(r.lastRedirectTo=s.to,n.options.followRedirects&&n.addToQueue(s.to,r.depth+1,r.walkedPatternLists,o,r.order)),"mount"!==s.type)return[3,5];if(c=s.patterns,r.lastMountPatterns=c,l=c.slice(0).sort().join("\n"),!c||r.walkedPatternLists.has(l))return[3,5];r.walkedPatternLists.add(l),h=0,d.label=2;case 2:return h<c.length?[4,n.expandPatterns(f(o,c[h]))]:[3,5];case 3:for(p=d.sent(),y=0;y<p.length;y++)n.addToQueue(p[y],r.depth+1,r.walkedPatternLists,o,r.order.concat(h,y));d.label=4;case 4:return h++,[3,2];case 5:return[3,1];case 6:return i&&(t=t.concat(i)),e++,[2]}})},n=this,x.label=1;case 1:return this.mapItems&&e<this.mapItems.length?[5,r()]:[3,3];case 2:switch(x.sent()){case"continue-items":return[3,1]}return[3,1];case 3:if(!this.mapItems)return[2];for(o=[],a=0;a<this.mapItems.length;a++)i=this.mapItems[a],"mount"===(u=i.chunksCache[i.chunksCache.length-1]).type||"error"===u.type||"busy"!==u.type&&this.options.predicate&&!this.options.predicate(u,i.chunksCache)||o.push([f(i.pathname,"/"),i.chunksCache,i.order]);if(s=++this.lastListenId,c=function(){return g.handleResolverUpdate(s)},Promise.race(t.filter(Mt).map(Ut)).then(c,c),o.sort(function(t,e){var r=t[2],n=e[2];if(r.length<n.length)return-1;if(r.length>n.length)return 1;for(var o=0;o<r.length;o++){if(r[o]<n[o])return-1;if(r[o]>n[o])return 1}return 0}),this.isRefreshScheduled)this.refresh();else{for(l={},h=!0,y=0;y<o.length;y++)d=It(o[y],2),b=d[0],(v=d[1]).some(function(t){return"busy"===t.type})&&(h=!1),l[p(b,"remove")]=v;for(m=0;m<this.observers.length;m++)(w=this.observers[m]).next(l),h&&w.complete&&w.complete();h&&(delete this.rootContext,delete this.mapItems,delete this.router,delete this.observers),this.isRefreshing=!1}return[2]}})})},this.observers=[],this.lastListenId=0,this.mapItems=[],this.router=o,this.rootContext=e,this.matcherGeneratorFunction=r,this.rootMapping=n,this.options=a,this.seenPathnames=new Set;var u=t.pathname;"/"===u.substr(-1)&&(u=u.substr(0,u.length-1)),this.addToQueue(u,0,new Set)}return t.prototype.subscribe=function(t,e,r){if(!this.observers)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=jt(t,e,r);this.observers.push(n);var o=new Pt(this.handleUnsubscribe,n);return 1===this.observers.length&&this.refresh(),o},t.prototype.expandPatterns=function(t){return Ct(this,void 0,void 0,function(){var e;return Lt(this,function(r){switch(r.label){case 0:return this.options.expandPattern?[4,this.options.expandPattern(t,this.router)]:[3,2];case 1:if(e=r.sent())return[2,e];r.label=2;case 2:return[2,[t].filter(function(t){return!/\/:/.test(t)})]}})})},t.prototype.removeFromQueue=function(t){var e=this.mapItems.indexOf(t);-1!==e&&this.mapItems.splice(e,1)},t.prototype.addToQueue=function(t,e,r,n,o){if(void 0===o&&(o=[0]),!this.seenPathnames.has(t)&&(!this.options.maxDepth||e<=this.options.maxDepth)){this.seenPathnames.add(t);var a=s(t,{removeHash:!0}),i=N(U({body:null,context:this.rootContext,headers:this.options.headers||{},method:this.options.method||"HEAD",params:{},hostname:this.options.hostname||"",mountpath:"",query:a.query,search:a.search,hash:a.hash,router:this.router,path:a.pathname,url:a.pathname+a.search,originalUrl:a.href,state:{}},this.router),this.rootMapping);i&&this.mapItems.push({url:a,fromPathname:n,depth:e,pathname:t,order:o,walkedPatternLists:new Set(r),matcherIterator:this.matcherGeneratorFunction(i)})}},t}();function Mt(t){return"busy"===t.type}function Ut(t){return t.promise}var qt=function(){return(qt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function At(t,e){return t=function(t,e){if(t){if("url"===e.type)return qt({},t,{chunks:t.chunks.filter(function(t){return"url"!==t.type}),url:e.url});if("ready"!==t.type)return t}var r={lastChunk:e,method:e.request&&e.request.method,chunks:t?t.chunks.concat(e):[e],data:t?t.data:{},headers:t?t.headers:{},heads:t?t.heads:[],state:t?t.state:{},status:t?t.status:200,title:t&&t.title,url:t?t.url:e.url,views:t?t.views:[]};switch(e.type){case"busy":return qt({},r,{type:"busy"});case"data":return qt({},r,{type:"ready",data:qt({},r.data,e.data)});case"error":return qt({},r,{type:"error",error:e.error,status:r.status&&r.status>=400?r.status:e.error.status||500});case"head":return qt({},r,{type:"ready",heads:r.heads.concat(e.head)});case"headers":return qt({},r,{type:"ready",headers:qt({},r.headers,e.headers)});case"redirect":return qt({},r,{type:"redirect",to:e.to});case"state":return qt({},r,{type:"ready",state:qt({},r.state,e.state)});case"status":return qt({},r,{type:"ready",status:e.status});case"title":return qt({},r,{type:"ready",title:e.title});case"view":return qt({},r,{type:"ready",views:r.views.concat(e.view)});default:return qt({},r,{type:"ready"})}}(t,e),Object.defineProperties(t,{meta:{configurable:!0,get:function(){return t.data}},content:{configurable:!0,get:function(){return e.view}},segments:{configurable:!0,get:function(){return t.chunks}},lastSegment:{configurable:!0,get:function(){return t.lastChunk}}}),t}function Gt(t){return new Nt(t)}var Nt=function(){function t(t){this.context=t.context||{},this.matcherGenerator=t.routes();var e,r,n=t.basename;n&&"/"===n.slice(-1)&&(n=n.slice(0,-1)),this.rootMapping=(e=t.routes,void 0===(r=n)&&(r=""),""!==r?G(r,e):{pattern:r,key:"",regExp:new RegExp(""),matcher:e})}return t.prototype.setContext=function(t){this.context=t||{}},t.prototype.createObservable=function(t,e){var r=N(U({body:e.body,context:this.context,headers:e.headers||{},method:e.method||"GET",hostname:t.hostname,hash:t.hash,mountpath:"/",params:t.query,query:t.query,search:t.search,router:this,url:t.pathname+t.search,originalUrl:t.href,path:t.pathname,crawler:e.crawler,state:e.state||{}},this),this.rootMapping);if(r)return new Rt(t,r,this.matcherGenerator)},t.prototype.createMapObservable=function(t,e){return void 0===e&&(e={}),new Dt(s(t),this.context,this.matcherGenerator,this.rootMapping,this,e)},t.prototype.resolve=function(t,e){var r,n=this;if(void 0===e&&(e={}),Array.isArray(t))r=t.map(function(t){return s(t)});else if("string"==typeof t)r=[s(t)];else if(t.url)r=[s((e=t).url)];else{if(!e)throw new Error("You must specify a URL for router.resolve().");r=[s(t)]}if(!r.length)return Promise.resolve([]);var o=r.map(function(t){return n.getPageRoutePromise(t,e)});return Array.isArray(t)?Promise.all(o):o[0]},t.prototype.resolveSiteMap=function(t,e){return void 0===e&&(e={}),_t(this.createMapObservable(t,e)).then(function(t){for(var e={},r={},n=Object.keys(t),o=0;o<n.length;o++){var a=n[o],i=t[a],u=i[i.length-1];"redirect"!==u.type?e[a]=[{type:"url",url:s(a)}].concat(i).reduce(At,void 0):r[a]=u.to}return{routes:e,redirects:r}})},t.prototype.resolveRouteMap=function(t,e){return void 0===e&&(e={}),this.resolveSiteMap(t,e).then(function(t){return t.routes})},t.prototype.getPageRoutePromise=function(t,e){var r=this,n=this.createObservable(t,e);return n?_t(n).then(function(n){for(var o=0;o<n.length;o++){var a=n[o];if("busy"===a.type)break;if("redirect"===a.type&&e.followRedirects)return r.getPageRoutePromise(s(a.to),e);if("error"===a.type)throw a.error}return[{type:"url",url:s(t)}].concat(n).reduce(At,void 0)}):Promise.reject(new m(t))},t}(),Ht=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Ft=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};var Qt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Vt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Yt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r};function $t(t){return Qt(this,void 0,void 0,function(){var e,r,n,o,a,i;return Vt(this,function(u){if(e=t.basename,r=t.context,n=t.routes,o=t.url,a=t.urls,i=Yt(t,["basename","context","routes","url","urls"]),o&&a)throw new Error("You cannot pass both `url` and `urls` options to resolve(). Please pick one!");if(!o&&!a)throw new Error("You must pass one of `url` or `urls` options to resolve().");return[2,Gt({basename:e,context:r,routes:n}).resolve(o||a,i)]})})}var Bt=function(){return function(){this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this)),Object.freeze(this)}}(),zt=function(){return(zt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Wt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Zt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Jt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},Kt=function(){function t(t){var e=this;this.handleUnsubscribe=function(t){var r=e.observers.indexOf(t);-1!==r&&e.observers.splice(r,1)},this.handleChunkList=function(t){for(var r=!0,n=e._history.location,o=0;o<t.length;o++){var a=t[o];if("busy"===a.type&&(r=!1),"state"===a.type&&(e.ignoreNextLocationChange=!0,e._history.replace(zt({},n,{state:te(n.state,a.state)}))),"redirect"===a.type){var i=re(n.state);return void(i?(e.ignoreNextLocationChange=!0,e._history.replace(zt({},n,{state:i})),e._history.push(a.to)):e._history.replace(a.to))}}e.setRoute([{type:"url",url:s(e.lastHandledLocation)}].concat(t).reduce(At,void 0),r)},this._history=t.history,this.observers=[],this.isLastRouteSteady=!1,this.navigationsSinceSteady=0,this.basename=t.basename,this.matcher=t.routes,this._router=new Nt({context:t.context,routes:t.routes,basename:t.basename}),this.trailingSlash=void 0===t.trailingSlash?"remove":t.trailingSlash,this.unlisten=this._history.listen(function(t){return e.handleLocationChange(t,!1)})}return Object.defineProperty(t.prototype,"history",{get:function(){return this._history},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"router",{get:function(){return this._router},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.observers.length=0,this.unlisten(),delete this.unlisten,delete this._history,this.observableSubscription&&this.observableSubscription.unsubscribe(),delete this.observableSubscription,delete this._router,delete this.waitUntilSteadyDeferred,delete this.lastRoute,delete this._router},t.prototype.go=function(t){return Wt(this,void 0,void 0,function(){var e,r=this;return Zt(this,function(n){switch(n.label){case 0:return e=new Promise(function(t){var e=r._history.listen(function(){e(),t()})}),this._history.go(t),[4,e];case 1:return n.sent(),[2,this.getRoute()]}})})},t.prototype.goBack=function(){return this.go(-1)},t.prototype.goForward=function(){return this.go(1)},t.prototype.navigate=function(t,e){var r;if(void 0===e&&(e={}),"string"==typeof t)r=s(t);else if(t.url)r=s((e=t).url);else{if(!t)throw new Error("You must specify a URL or state to navigation.navigate().");r=s(t)}var n=this._history.location,o=e.replace||!1!==e.replace&&n.pathname===r.pathname&&n.search===r.search&&n.hash===r.hash;return this._history[o?"replace":"push"]({pathname:r.pathname,search:r.search,hash:r.hash,state:ee({revertTo:o?n.state:void 0,method:e.method,headers:e.headers,body:e.body,state:e.state})}),this.getRoute()},t.prototype.prefetch=function(t){return Wt(this,void 0,void 0,function(){return Zt(this,function(e){switch(e.label){case 0:return[4,$t({basename:this.basename,routes:this.matcher,context:this._router.context,url:t})];case 1:return e.sent(),[2]}})})},t.prototype.refresh=function(){return this.handleLocationChange(this._history.location,!0),this.getRoute()},t.prototype.setContext=function(t){return this._router.setContext(t),this.refresh()},t.prototype.getCurrentValue=function(){return this.lastRoute},t.prototype.getRoute=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){return this.isLastRouteSteady?[2,this.lastRoute]:(this.waitUntilSteadyDeferred||(this.waitUntilSteadyDeferred=new Bt),[2,this.waitUntilSteadyDeferred.promise])})})},t.prototype.getSteadyValue=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){return[2,this.getRoute()]})})},t.prototype.steady=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){switch(t.label){case 0:return[4,this.getRoute()];case 1:return t.sent(),[2]}})})},t.prototype.extractState=function(){return this._history.location.state},t.prototype.subscribe=function(t,e,r){var n=jt(t,e,r);return this.observers.push(n),new Pt(this.handleUnsubscribe,n)},t.prototype.handleLocationChange=function(t,e){if(this.ignoreNextLocationChange)this.ignoreNextLocationChange=!1;else if(++this.navigationsSinceSteady>100)console.error("Detected possible navigation loop with 100 navigations between steady routes. Bailing.");else{if(null!==this.trailingSlash){var r=p(t.pathname,this.trailingSlash);if(t.pathname!==r)return void this._history.replace(zt({},t,{pathname:r}))}var n=s(t),o=this.lastHandledLocation;this.lastHandledLocation=t,this.observableSubscription&&this.observableSubscription.unsubscribe();var a=this._router.createObservable(n,function(t){void 0===t&&(t={});var e=zt({},t);delete e[Xt];var r=t[Xt]||{};return zt({},r.requestDataWithoutState,{state:Object.keys(e).length?e:void 0})}(t.state));if(a)this.observableSubscription=a.subscribe(this.handleChunkList);else if(!o)throw new m(n)}},t.prototype.setRoute=function(t,e){if(t!==this.lastRoute){this.lastRoute=t,this.isLastRouteSteady=e,e&&(this.navigationsSinceSteady=0);for(var r=0;r<this.observers.length;r++)this.observers[r].next(t);this.isLastRouteSteady&&this.waitUntilSteadyDeferred&&(this.waitUntilSteadyDeferred.resolve(t),delete this.waitUntilSteadyDeferred)}},t}(),Xt="__navi__";function te(t,e){var r;return void 0===t&&(t={}),zt({},e,((r={})[Xt]=t[Xt],r))}function ee(t){var e,r=t.revertTo,n=t.state,o=Jt(t,["revertTo","state"]);return r&&(r=zt({},r))[Xt]&&delete r[Xt].revertTo,zt({},n,((e={})[Xt]={requestDataWithoutState:o,revertTo:r},e))}function re(t){return void 0===t&&(t={}),(t[Xt]||{}).revertTo}var ne=function(){return(ne=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var oe=function(){return(oe=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};t.crawl=function(t){return Ht(this,void 0,void 0,function(){var e,r,n,o,a,i,u,c,l,h,y,d,b,v=this;return Ft(this,function(m){switch(m.label){case 0:return e=Gt({basename:t.basename,context:t.context,routes:t.routes}),r=s(t.root||""),n=t.predicate||function(){return!0},o=t.expandPattern||function(t){return[t||""]},a=function(t,e){return Ht(v,void 0,void 0,function(){return Ft(this,function(r){switch(r.label){case 0:return[4,o(t)];case 1:return[2,(r.sent()||[]).map(function(t){return{headers:e.headers,url:s(f(e.mountpath,t)),context:e.headers}}).filter(n)]}})})},[4,_t(e.createObservable(r,{crawler:a,headers:t.headers,method:"HEAD"}))];case 1:i=m.sent(),u=[],c={};t:for(l=0;l<i.length;l++)if("crawl"===(h=i[l]).type){if(-1!==(y=h.url.pathname).indexOf(":"))continue;for(d=l+1;d<i.length&&"crawl"!==(b=i[d]).type&&"mount"!==b.type;d++,l++)if("redirect"===b.type){c[y]=b.to;continue t}u.push(y)}return[2,{paths:null!==t.trailingSlash?u.map(function(e){return p(e,t.trailingSlash||"remove")}):u,redirects:c}]}})})},t.resolve=$t,t.compose=o,t.Router=Nt,t.createRouter=Gt,t.routeReducer=At,t.concatMatcherIterators=R,t.Navigation=Kt,t.resolveChunks=O,t.createBrowserNavigation=function(t){t.pages&&(t.routes=t.pages),!t.state&&void 0!==typeof window&&window.__NAVI_STATE__&&(t.state=window.__NAVI_STATE__,delete window.__NAVI_STATE__);var r=t.history||e.createBrowserHistory();t.state&&r.replace(ne({},r.location,{state:t.state}));var n=new Kt({history:r,basename:t.basename,context:t.context,routes:t.routes,trailingSlash:t.trailingSlash});return n.refresh(),n},t.createMemoryNavigation=function(t){t.pages&&(t.routes=t.pages);var r=t.url||t.request&&t.request.url;if(!r)throw new Error("createMemoryNavigation() could not find a URL.");var n=e.createMemoryHistory({initialEntries:["/"]}),o=new Kt({history:n,basename:t.basename,context:t.context,routes:t.routes,trailingSlash:t.trailingSlash});return o.navigate(oe({},t.request,{url:r,replace:!0})),o},t.lazy=M,t.map=M,t.createPage=function(t){return Object.assign(o(X(it(t)),tt(function(t,e){return e.meta}),et(function(t,e){return e.title}),L(function(t,e){return e.content})),{isDeprecatedMatcher:!0})},t.createContext=function(t,e){return Object.assign(X(t,e.isDeprecatedMatcher?e:M(e)),{isDeprecatedMatcher:!0})},t.createSwitch=function(t){var e,r,n={};try{for(var a=at(Object.keys(t.paths)),i=a.next();!i.done;i=a.next()){var u=i.value,s=t.paths[u];n[u]=s.isDeprecatedMatcher?s:M(s)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}if(1===Object.keys(t).length)return Object.assign($(n),{isDeprecatedMatcher:!0});t.paths;var c=ot(t,["paths"]);return Object.assign(o(X(it(c)),tt(function(t,e){return e.meta}),et(function(t,e){return e.title}),L(function(t,e){return e.content}),$(n)),{isDeprecatedMatcher:!0})},t.createRedirect=function(t,e){var r=W(t);return e?o(tt(e),r):Object.assign(r,{isDeprecatedMatcher:!0})},t.mount=$,t.redirect=W,t.route=function(t){var e;if(void 0===t&&(t={}),"function"==typeof t)e=t;else{var r=t.data,n=t.getData,a=t.error,i=t.head,u=t.getHead,s=t.headers,c=t.getHeaders,l=t.state,h=t.getState,f=t.status,p=t.getStatus,y=t.title,d=t.getTitle,b=t.view,v=t.getView;vt(t,["data","getData","error","head","getHead","headers","getHeaders","state","getState","status","getStatus","title","getTitle","view","getView"]),e=function(t,e){var o,m=this,w=mt(gt(r,n,t,e),2),g=w[0],x=w[1];g?k(g)&&(g=g.then(wt)):g={};var S,O,P=mt(gt(s,c,t,e),2),j=P[0],_=P[1],R=mt(gt(l,h,t,e),2),E=R[0],T=R[1],C=mt(gt(f,p,t,e),2),L=C[0],I=C[1],D=mt(gt(y,d,t,e),2),M=D[0],U=D[1],q=mt(gt(i,u,t,e),2),A=q[0],G=q[1];return"HEAD"!==t.method&&(o=mt(gt(b,v,t,e),2),S=o[0],O=o[1]),x||_||T||I||U||G||O?dt(m,void 0,void 0,function(){var t;return bt(this,function(e){switch(e.label){case 0:return t={},[4,g];case 1:return t.data=e.sent(),t.error=a,[4,A];case 2:return t.head=e.sent(),[4,j];case 3:return t.headers=e.sent(),[4,E];case 4:return t.state=e.sent(),[4,L];case 5:return t.status=e.sent(),[4,M];case 6:return t.title=e.sent(),[4,S];case 7:return[2,(t.view=e.sent(),t)]}})}):{data:g,error:a,head:A,headers:j,state:E,status:L,title:M,view:S}}}return o(X(function(t,r){return t.crawler?{}:e(t,r)}),tt(function(t){return t.context.data}),st(function(t){return t.context.head}),ct(function(t){return t.context.headers}),pt(function(t){return t.context.state||null}),yt(function(t){return t.context.status}),et(function(t){return t.context.title}),L(function(t){return t.context.view},void 0,!0),C(function(t){return t.context.error},void 0,function(t,e){return t?[w("error",e,{error:t})]:[]}))},t.withContext=X,t.withCrawlerPatterns=function(t,e){var r=this,n=function(e){return function(n,o){return St(r,void 0,void 0,function(){var r,a,i,u;return Ot(this,function(s){switch(s.label){case 0:return r=t[n],o.mountpath===e.mountpath&&r?[3,1]:[2,e.crawler(n,o)];case 1:return Array.isArray(r)?(i=r,[3,4]):[3,2];case 2:return[4,r(e,e.context)];case 3:i=s.sent(),s.label=4;case 4:return a=i,u=H,[4,Promise.all(a.map(function(t){return e.crawler(t,o)}))];case 5:return[2,u.apply(void 0,[s.sent()])]}})})}};return function(t){return function(r){return function(t,e){return Ot(this,function(r){switch(r.label){case 0:return t.crawler?[3,2]:[5,kt(_(e,t))];case 1:return r.sent(),[3,4];case 2:return[5,kt(O(n,t,function(r){return _(e,xt({},t,{crawler:r}))}))];case 3:r.sent(),r.label=4;case 4:return[2]}})}(r,e?e(t):t)}}},t.withData=tt,t.withHead=st,t.withHeaders=ct,t.withState=pt,t.withStatus=yt,t.withTitle=et,t.withView=L,t.NaviError=b,t.NotFoundError=v,t.OutOfRootError=m,t.createRequest=U,t.createChunk=w,t.createNotFoundChunk=g,t.createURLDescriptor=s,t.parseQuery=c,t.stringifyQuery=l,t.joinPaths=f,t.modifyTrailingSlash=p,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("history")):"function"==typeof define&&define.amd?define(["exports","history"],e):e((t=t||self).Navi={},t.History)}(this,function(t,e){"use strict";var r=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},n=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t};function o(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)throw new Error("composeMatchers() expects at least one matcher.");return 1===t.length?t[0]:t.reduce(function(t,e){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return t(e.apply(void 0,n(r)))}})}var a=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},i=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t},u=/((((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;function s(t,e){var r,n,o,a,i,s=void 0===e?{}:e,h=s.removeHash,f=void 0!==h&&h,y=s.trailingSlash,d=void 0===y?null:y;if("string"==typeof t){var v=u.exec(t);if(!v)throw new Error("Couldn't parse the provided URL.");r="",n=p(v[2]||"",d),o=c(a=v[6]||""),i=v[7]||""}else r=t.hostname||"",n=p(t.pathname||"",d),o=t.query||(t.search?c(t.search):{}),a=t.search||l(o),i=t.hash||"";return{hostname:r,pathname:n,query:o,search:a,hash:f?"":i,href:n+a+i}}function c(t,e){if(void 0===e&&(e="?"),!t||t[0]!=e)return{};for(var r={},n=t.slice(1).split("&"),o=0,a=n.length;o<a;o++){var i=n[o].split("=");r[i[0]]=i[1]?decodeURIComponent(i[1]):""}return r}function l(t,e){void 0===e&&(e="?");var r=Object.keys(t);if(0===r.length)return"";for(var n=[],o=0,a=r.length;o<a;o++){var i=r[o],u=String(t[i]);n.push(""===u?i:i+"="+encodeURIComponent(u))}return e+n.join("&")}function h(t){return""===t?[]:t.split("/")}function f(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=h(t),o=0;o<e.length;o++)n.push.apply(n,i(h(e[o])));var a=[],u=n.length-1;for(o=0;o<=u;o++){var s=n[o];".."===s?a.pop():"."===s||""===s&&0!==o&&o!==u||a.push(s)}return a.join("/")}function p(t,e){var r="/"===t.slice(-1);return"add"!==e||r?"remove"===e&&r&&t.length>1?t.slice(0,-1):t:t+"/"}var y,d=(y=function(t,e){return(y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}y(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),v=function(t){function e(e){var r=this,n=this.constructor.prototype;return(r=t.call(this,e)||this).__proto__=n,Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(r,r.constructor):Object.defineProperty(r,"stack",{value:(new Error).stack}),Object.defineProperty(r,"message",{value:e}),r}return d(e,t),e}(Error),b=function(t){function e(e){var r=t.call(this,"URL not found: "+e)||this;return r.pathname=e,r.status=404,r.name="NotFoundError",r}return d(e,t),e}(v),m=function(t){function e(e){var r=t.call(this,"URL not managed by router: "+e.href)||this;return r.url=e,r.name="OutOfRootError",r}return d(e,t),e}(v);function w(t,e,r){return Object.assign({type:t,request:e,url:s({pathname:e.mountpath,query:e.query})},r)}function g(t){var e=f(t.mountpath,t.path);return{type:"error",request:t,url:s({pathname:e,query:t.query}),error:new b(e)}}var x=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},S=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function O(t,e,r){var n,o,a,i,u,s,c;return x(this,function(l){switch(l.label){case 0:n="function"==typeof t?t:function(){return t};try{o=n(e,e.context)}catch(t){o=Promise.reject(t)}return k(o)?[3,1]:(a=r(o),[3,7]);case 1:i=o.then(P),u=function(t){var e={};return t.then(function(t){e.value=t,e.outcome="resolved"},function(t){e.error=t,e.outcome="rejected"}),e}(i),s=[w("busy",e,{promise:i})],l.label=2;case 2:return u.outcome?[3,4]:[4,s];case 3:return l.sent(),[3,2];case 4:return"rejected"!==u.outcome?[3,6]:((c=u.error)instanceof b&&!c.pathname&&(c.pathname=f(e.mountpath,e.path)),[4,[w("error",e,{error:c})]]);case 5:return l.sent(),[3,7];case 6:a=r(u.value),l.label=7;case 7:return a?Array.isArray(a)?[4,a.length?a:[]]:[3,9]:[3,11];case 8:return l.sent(),[3,11];case 9:return[5,S(a)];case 10:l.sent(),l.label=11;case 11:return[2]}})}function k(t){return!!t&&!!t.then}function P(t){return function(t){return t&&"object"==typeof t&&"default"in t}(t)?t.default:t}var j=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};function _(t,e,r){return void 0===r&&(r=""),t(e)}function R(t,e){var r,n,o,a;return j(this,function(i){switch(i.label){case 0:o=[],a=[],i.label=1;case 1:return(r=t.next()).done||(o=r.value||[]),(n=e.next()).done||(a=n.value||[]),[4,o.concat(a)];case 2:i.sent(),i.label=3;case 3:if(!r.done||!n.done)return[3,1];i.label=4;case 4:return[2]}})}var E=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},T=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function C(t,e,r,n,o,a){function i(e,i){var u,s;return E(this,function(c){switch(c.label){case 0:return u=e.path,(void 0===n?!i:n)&&u&&"/"!==u?[4,[g(e)]]:[3,2];case 1:return c.sent(),[3,4];case 2:return s=e.crawler&&!o||a&&!a(e)?function(){return E(this,function(t){switch(t.label){case 0:return[4,[]];case 1:return t.sent(),[2]}})}():O(t,e,function(t){return r(t,e)}),[5,T(i?R(s,_(i,e)):s)];case 3:c.sent(),c.label=4;case 4:return[2]}})}return function(t){return function(r){return i(r,e?e(t):t)}}}function L(t,e,r){return C(t,e,function(t,e){return t?[w("view",e,{view:t})]:[]},r,!1,function(t){return"HEAD"!==t.method})}var I=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},D=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function M(t){return function(e){return function(r){return I(this,function(n){switch(n.label){case 0:return[5,D(O(t,r,function(t){return _(t(e),r)}))];case 1:return n.sent(),[2]}})}}}function U(t,e){return Object.defineProperties(t,{mountname:{get:function(){return t.mountpath}},pathname:{get:function(){return t.mountpath}}}),e&&Object.defineProperties(t,{router:{get:function(){return e},enumerable:!1},_router:{value:e}}),t}var q=function(){return(q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},A="\0";function G(t,e){var r=t;if(r.length>1&&"/"===r.substr(-1)&&(r=r.substr(0,r.length-1)),"/"!==r[0]&&(r="/"+r),/\/{2,}/.test(r)&&(r=r.replace(/\/{2,}/g,"/")),/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(r),0===r.length)throw new Error('You cannot use an empty string "" as a pattern!');for(var n=r.split("/").slice(1),o=[],a=[],i=["^"],u=0;u<n.length;u++){var s=n[u];s.length>1&&":"===s[0]?(o.push(s.slice(1)),a.push(A),i.push("([^/]+)")):(a.push(s),i.push(s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}return{key:a.join("/"),matcher:e,pattern:r,pathParamNames:o.length?o:void 0,regExp:"/"===r?/^\/$/:new RegExp(i.join("/"))}}function N(t,e){var r=e.regExp.exec(t.path||"/");if(r){var n=r[0],o=t.path.slice(n.length)||"";if(!o.length||"/"===o[0]){var a=t.params;if(e.pathParamNames){a=q({},t.params);for(var i=0;i<e.pathParamNames.length;i++){a[e.pathParamNames[i]]=r[i+1]}}var u=f(t.mountpath,n)||"/";return U(q({},t,{params:a,mountpath:u,path:o,url:o+t.search}),t._router)}}}function H(t){return[].concat.apply([],t)}var F=function(){return(F=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Q=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},V=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Y=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};function $(t){if(!t)throw new Error("mount() must be supplied with a paths object.");var e=Object.keys(t),r=e.filter(function(t){return"*"!==t}).map(function(e){return G(e,t[e])}).sort(function(t,e){return r=t.key,n=e.key,r<n?-1:r>n?1:0;var r,n});return function(n){return function(o){var a,i,u,s,c,l,h,f,p,y,d,v,b,m,x,S,O;return V(this,function(k){switch(k.label){case 0:if(u=[],s=[],c=[],l=o.crawler,!(h=l&&(""===o.path||"/"===o.path)))return[3,5];(f=function(t,e,r){return Q(this,void 0,void 0,function(){var n;return V(this,function(o){switch(o.label){case 0:return n=H,[4,Promise.all(Object.entries(t).map(function(t){var n,o=Y(t,2),a=o[0],i=o[1];return e("*"===a?"":a,r).then((n=i,function(t){return t.map(function(t){return[n,t]})}))}))];case 1:return[2,n.apply(void 0,[o.sent()])]}})})}(t,l,o)).then(function(t){p=t},function(t){return y=t}),k.label=1;case 1:return[4,[w("busy",o,{promise:f})]];case 2:if(k.sent(),y)throw y;k.label=3;case 3:if(!p)return[3,1];k.label=4;case 4:return i=p.map(function(t,e){var r=Y(t,2),a=r[0],i=r[1],u=F({},o,{mountpath:i.url.pathname,url:"",path:""});return c[e]=u,_(a(n),u,u.mountpath)}),[3,6];case 5:for(S=r.length-1;S>=0;S--)if(d=r[S],v=N(o,d)){i=[_(d.matcher(n),v,d.pattern)];break}i||(b=t["*"])&&(i=[_(b(n),o,"*")]),k.label=6;case 6:if(i)for(S=0;S<i.length;S++)(m=u[S])&&m.done||(m=u[S]=i[S].next()),m&&!m.done&&(s[S]=m.value);for(a=[w("mount",o,{patterns:e})],x=!1,S=0;S<u.length;S++)(O=s[S])&&(x=!0,h&&!O.some(z)&&(a=a.concat(w("crawl",c[S]))),a=a.concat(O));return l||x||a.push(g(o)),[4,a];case 7:k.sent(),k.label=8;case 8:if(a.filter(B).length)return[3,6];k.label=9;case 9:return[2]}})}}}function B(t){return"busy"===t.type}function z(t){return"mount"===t.type}function W(t,e){var r=(void 0===e?{}:e).exact;return C(t,void 0,function(t,e){var r;return"string"==typeof t?r="/"===t[0]?t:f("/",e.mountpath,t):t&&(r=s(t).href),r?[w("redirect",e,{to:r})]:[]},void 0===r||r,!0)}var Z=function(){return(Z=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},J=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},K=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function X(t,e){return function(r){return function(n){return function(e,r){return J(this,function(n){switch(n.label){case 0:return[5,K(O(t,e,function(t){return _(r,Z({},e,{context:t||{}}))}))];case 1:return n.sent(),[2]}})}(n,e?e(r):r)}}}function tt(t,e){return C(t,e,function(t,e){return t?[w("data",e,{data:t})]:[]})}function et(t,e){return C(t,e,function(t,e){return t?[w("title",e,{title:t})]:[]})}var rt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},nt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ot=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},at=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function it(t){return function(e,r){return rt(this,void 0,void 0,function(){var n,o,a,i;return nt(this,function(u){switch(u.label){case 0:return n=t.getMeta?Promise.resolve(t.getMeta(e,r,void 0)).then(P).then(ut):Promise.resolve(t.meta||{}),o=t.getTitle?Promise.resolve(t.getTitle(e,r,n)).then(P):Promise.resolve(t.title),"HEAD"!==e.method&&(a=t.getContent?Promise.resolve(t.getContent(e,r,n)).then(P):Promise.resolve(t.content)),i={},[4,n];case 1:return i.meta=u.sent(),[4,a];case 2:return i.content=u.sent(),[4,o];case 3:return[2,(i.title=u.sent(),i)]}})})}}function ut(t){return t||{}}function st(t,e){return C(t,e,function(t,e){return t?[w("head",e,{head:t})]:[]})}function ct(t,e){return C(t,e,function(t,e){return t?[w("headers",e,{headers:t})]:[]})}var lt=function(){return(lt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},ht=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ft=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};function pt(t,e){function r(e,r){return ht(this,function(n){switch(n.label){case 0:return[5,ft(O(t,e,function(t){var n=null===t?e.state:lt({},e.state,t);return R(function(t){return ht(this,function(e){switch(e.label){case 0:return[4,t];case 1:return e.sent(),[2]}})}(null===t?[]:[w("state",e,{state:n})]),_(r,lt({},e,{state:n})))}))];case 1:return n.sent(),[2]}})}return function(t){return function(n){return r(n,e?e(t):t)}}}function yt(t,e){return C(t,e,function(t,e){return t?[w("status",e,{status:t})]:[]})}var dt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},vt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},bt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},mt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i};function wt(t){return t||{}}function gt(t,e,r,n){if(e){var o=e(r,n);return k(o)?[o.then(P),!0]:[o,!1]}return[t,!1]}var xt=function(){return(xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},St=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Ot=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},kt=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};var Pt=function(){function t(t,e){this.close=t,this.observer=e,this.observer.start&&this.observer.start(this)}return t.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this.close(this.observer),delete this.close,delete this.observer)},t}();function jt(t,e,r){return"function"==typeof t?{next:t,error:e,complete:r}:t}function _t(t){return new Promise(function(e,r){t.subscribe({start:function(t){this.subscription=t},next:function(t){this.value=t},complete:function(){e(this.value),this.subscription.unsubscribe()},error:function(t){r(t),this.subscription.unsubscribe()}})})}var Rt=function(){function t(t,e,r){var n=this;this.handleUnsubscribe=function(t){var e=n.observers.indexOf(t);-1!==e&&n.observers.splice(e,1)},this.handleChange=function(t){if(t===n.lastListenId){n.lastListenId++,n.refresh();for(var e=n.result.done||n.result.value.every(function(t){return"busy"!==t.type}),r=0;r<n.observers.length;r++){var o=n.observers[r];o.next(n.result.value),e&&o.complete&&o.complete()}e&&delete n.matcherIterator}},this.refresh=function(){var t=n.matcherIterator.next();if(t.value&&(n.result=t),!n.result.done){var e=++n.lastListenId,r=function(){return n.handleChange(e)};Promise.race(n.result.value.filter(Et).map(Tt)).then(r,r)}},this.url=t,this.lastListenId=0,this.observers=[],this.matcherIterator=r(e)}return t.prototype.subscribe=function(t,e,r){if(!this.matcherIterator)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=jt(t,e,r);this.observers.push(n);var o=new Pt(this.handleUnsubscribe,n);return 1===this.observers.length&&this.handleChange(this.lastListenId),o},t}();function Et(t){return"busy"===t.type}function Tt(t){return t.promise}var Ct=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Lt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},It=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i},Dt=function(){function t(t,e,r,n,o,a){var i=this;this.handleUnsubscribe=function(t){var e=i.observers.indexOf(t);-1!==e&&i.observers.splice(e,1)},this.handleResolverUpdate=function(t){t===i.lastListenId&&(i.lastListenId++,i.isRefreshing?i.isRefreshScheduled||(i.isRefreshScheduled=!0):i.refresh())},this.refresh=function(){return Ct(i,void 0,void 0,function(){var t,e,r,n,o,a,i,u,s,c,l,h,y,d,v,b,m,w,g=this;return Lt(this,function(x){switch(x.label){case 0:this.isRefreshScheduled=!1,this.isRefreshing=!0,t=[],e=0,r=function(){var r,o,a,i,u,s,c,l,h,p,y;return Lt(this,function(d){switch(d.label){case 0:r=n.mapItems[e],o=r.pathname,a=r.matcherIterator.next(),r.lastResult&&!a.value||(r.lastResult=a),i=r.lastResult.value,r.chunksCache=i||[],u=i.findIndex(function(t){return"error"===t.type||t.url.href.length>=r.url.href.length&&("mount"===t.type&&r.lastMountPatterns!==t.patterns||"redirect"===t.type&&r.lastRedirectTo!==t.to)}),d.label=1;case 1:if(!(u>=0&&u<i.length))return[3,6];if(s=i[u],u++,"error"===s.type||n.options.predicate&&!n.options.predicate(s,i))return n.removeFromQueue(r),[2,"continue-items"];if("redirect"===s.type&&(r.lastRedirectTo=s.to,n.options.followRedirects&&n.addToQueue(s.to,r.depth+1,r.walkedPatternLists,o,r.order)),"mount"!==s.type)return[3,5];if(c=s.patterns,r.lastMountPatterns=c,l=c.slice(0).sort().join("\n"),!c||r.walkedPatternLists.has(l))return[3,5];r.walkedPatternLists.add(l),h=0,d.label=2;case 2:return h<c.length?[4,n.expandPatterns(f(o,c[h]))]:[3,5];case 3:for(p=d.sent(),y=0;y<p.length;y++)n.addToQueue(p[y],r.depth+1,r.walkedPatternLists,o,r.order.concat(h,y));d.label=4;case 4:return h++,[3,2];case 5:return[3,1];case 6:return i&&(t=t.concat(i)),e++,[2]}})},n=this,x.label=1;case 1:return this.mapItems&&e<this.mapItems.length?[5,r()]:[3,3];case 2:switch(x.sent()){case"continue-items":return[3,1]}return[3,1];case 3:if(!this.mapItems)return[2];for(o=[],a=0;a<this.mapItems.length;a++)i=this.mapItems[a],"mount"===(u=i.chunksCache[i.chunksCache.length-1]).type||"error"===u.type||"busy"!==u.type&&this.options.predicate&&!this.options.predicate(u,i.chunksCache)||o.push([f(i.pathname,"/"),i.chunksCache,i.order]);if(s=++this.lastListenId,c=function(){return g.handleResolverUpdate(s)},Promise.race(t.filter(Mt).map(Ut)).then(c,c),o.sort(function(t,e){var r=t[2],n=e[2];if(r.length<n.length)return-1;if(r.length>n.length)return 1;for(var o=0;o<r.length;o++){if(r[o]<n[o])return-1;if(r[o]>n[o])return 1}return 0}),this.isRefreshScheduled)this.refresh();else{for(l={},h=!0,y=0;y<o.length;y++)d=It(o[y],2),v=d[0],(b=d[1]).some(function(t){return"busy"===t.type})&&(h=!1),l[p(v,"remove")]=b;for(m=0;m<this.observers.length;m++)(w=this.observers[m]).next(l),h&&w.complete&&w.complete();h&&(delete this.rootContext,delete this.mapItems,delete this.router,delete this.observers),this.isRefreshing=!1}return[2]}})})},this.observers=[],this.lastListenId=0,this.mapItems=[],this.router=o,this.rootContext=e,this.matcherGeneratorFunction=r,this.rootMapping=n,this.options=a,this.seenPathnames=new Set;var u=t.pathname;"/"===u.substr(-1)&&(u=u.substr(0,u.length-1)),this.addToQueue(u,0,new Set)}return t.prototype.subscribe=function(t,e,r){if(!this.observers)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=jt(t,e,r);this.observers.push(n);var o=new Pt(this.handleUnsubscribe,n);return 1===this.observers.length&&this.refresh(),o},t.prototype.expandPatterns=function(t){return Ct(this,void 0,void 0,function(){var e;return Lt(this,function(r){switch(r.label){case 0:return this.options.expandPattern?[4,this.options.expandPattern(t,this.router)]:[3,2];case 1:if(e=r.sent())return[2,e];r.label=2;case 2:return[2,[t].filter(function(t){return!/\/:/.test(t)})]}})})},t.prototype.removeFromQueue=function(t){var e=this.mapItems.indexOf(t);-1!==e&&this.mapItems.splice(e,1)},t.prototype.addToQueue=function(t,e,r,n,o){if(void 0===o&&(o=[0]),!this.seenPathnames.has(t)&&(!this.options.maxDepth||e<=this.options.maxDepth)){this.seenPathnames.add(t);var a=s(t,{removeHash:!0}),i=N(U({body:null,context:this.rootContext,headers:this.options.headers||{},method:this.options.method||"HEAD",params:{},hostname:this.options.hostname||"",mountpath:"",query:a.query,search:a.search,hash:a.hash,router:this.router,path:a.pathname,url:a.pathname+a.search,originalUrl:a.href,state:{}},this.router),this.rootMapping);i&&this.mapItems.push({url:a,fromPathname:n,depth:e,pathname:t,order:o,walkedPatternLists:new Set(r),matcherIterator:this.matcherGeneratorFunction(i)})}},t}();function Mt(t){return"busy"===t.type}function Ut(t){return t.promise}var qt=function(){return(qt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function At(t,e){return t=function(t,e){if(t){if("url"===e.type)return qt({},t,{chunks:t.chunks.filter(function(t){return"url"!==t.type}),url:e.url});if("ready"!==t.type)return t}var r={lastChunk:e,method:e.request&&e.request.method,chunks:t?t.chunks.concat(e):[e],data:t?t.data:{},headers:t?t.headers:{},heads:t?t.heads:[],state:t?t.state:{},status:t?t.status:200,title:t&&t.title,url:t?t.url:e.url,views:t?t.views:[]};switch(e.type){case"busy":return qt({},r,{type:"busy"});case"data":return qt({},r,{type:"ready",data:qt({},r.data,e.data)});case"error":return qt({},r,{type:"error",error:e.error,status:r.status&&r.status>=400?r.status:e.error.status||500});case"head":return qt({},r,{type:"ready",heads:r.heads.concat(e.head)});case"headers":return qt({},r,{type:"ready",headers:qt({},r.headers,e.headers)});case"redirect":return qt({},r,{type:"redirect",to:e.to});case"state":return qt({},r,{type:"ready",state:qt({},r.state,e.state)});case"status":return qt({},r,{type:"ready",status:e.status});case"title":return qt({},r,{type:"ready",title:e.title});case"view":return qt({},r,{type:"ready",views:r.views.concat(e.view)});default:return qt({},r,{type:"ready"})}}(t,e),Object.defineProperties(t,{meta:{configurable:!0,get:function(){return t.data}},content:{configurable:!0,get:function(){return e.view}},segments:{configurable:!0,get:function(){return t.chunks}},lastSegment:{configurable:!0,get:function(){return t.lastChunk}}}),t}function Gt(t){return new Nt(t)}var Nt=function(){function t(t){this.context=t.context||{},this.matcherGenerator=t.routes();var e,r,n=t.basename;n&&"/"===n.slice(-1)&&(n=n.slice(0,-1)),this.rootMapping=(e=t.routes,void 0===(r=n)&&(r=""),""!==r?G(r,e):{pattern:r,key:"",regExp:new RegExp(""),matcher:e})}return t.prototype.setContext=function(t){this.context=t||{}},t.prototype.createObservable=function(t,e){var r=N(U({body:e.body,context:this.context,headers:e.headers||{},method:e.method||"GET",hostname:t.hostname,hash:t.hash,mountpath:"/",params:t.query,query:t.query,search:t.search,router:this,url:t.pathname+t.search,originalUrl:t.href,path:t.pathname,crawler:e.crawler,state:e.state||{}},this),this.rootMapping);if(r)return new Rt(t,r,this.matcherGenerator)},t.prototype.createMapObservable=function(t,e){return void 0===e&&(e={}),new Dt(s(t),this.context,this.matcherGenerator,this.rootMapping,this,e)},t.prototype.resolve=function(t,e){var r,n=this;if(void 0===e&&(e={}),Array.isArray(t))r=t.map(function(t){return s(t)});else if("string"==typeof t)r=[s(t)];else if(t.url)r=[s((e=t).url)];else{if(!e)throw new Error("You must specify a URL for router.resolve().");r=[s(t)]}if(!r.length)return Promise.resolve([]);var o=r.map(function(t){return n.getPageRoutePromise(t,e)});return Array.isArray(t)?Promise.all(o):o[0]},t.prototype.resolveSiteMap=function(t,e){return void 0===e&&(e={}),_t(this.createMapObservable(t,e)).then(function(t){for(var e={},r={},n=Object.keys(t),o=0;o<n.length;o++){var a=n[o],i=t[a],u=i[i.length-1];"redirect"!==u.type?e[a]=[{type:"url",url:s(a)}].concat(i).reduce(At,void 0):r[a]=u.to}return{routes:e,redirects:r}})},t.prototype.resolveRouteMap=function(t,e){return void 0===e&&(e={}),this.resolveSiteMap(t,e).then(function(t){return t.routes})},t.prototype.getPageRoutePromise=function(t,e){var r=this,n=this.createObservable(t,e);return n?_t(n).then(function(n){for(var o=0;o<n.length;o++){var a=n[o];if("busy"===a.type)break;if("redirect"===a.type&&e.followRedirects)return r.getPageRoutePromise(s(a.to),e);if("error"===a.type)throw a.error}return[{type:"url",url:s(t)}].concat(n).reduce(At,void 0)}):Promise.reject(new m(t))},t}(),Ht=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Ft=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};var Qt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Vt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Yt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r};function $t(t){return Qt(this,void 0,void 0,function(){var e,r,n,o,a,i;return Vt(this,function(u){if(e=t.basename,r=t.context,n=t.routes,o=t.url,a=t.urls,i=Yt(t,["basename","context","routes","url","urls"]),o&&a)throw new Error("You cannot pass both `url` and `urls` options to resolve(). Please pick one!");if(!o&&!a)throw new Error("You must pass one of `url` or `urls` options to resolve().");return[2,Gt({basename:e,context:r,routes:n}).resolve(o||a,i)]})})}var Bt=function(){return function(){this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this)),Object.freeze(this)}}(),zt=function(){return(zt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Wt=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(i,u)}s((n=n.apply(t,e||[])).next())})},Zt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=e.call(t,i)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Jt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r},Kt=function(){function t(t){var e=this;this.handleUnsubscribe=function(t){var r=e.observers.indexOf(t);-1!==r&&e.observers.splice(r,1)},this.handleChunkList=function(t){for(var r=!0,n=e._history.location,o=0;o<t.length;o++){var a=t[o];if("busy"===a.type&&(r=!1),"state"===a.type&&(e.ignoreNextLocationChange=!0,e._history.replace(zt({},n,{state:te(n.state,a.state)}))),"redirect"===a.type){var i=re(n.state);return void(i?(e.ignoreNextLocationChange=!0,e._history.replace(zt({},n,{state:i})),e._history.push(a.to)):e._history.replace(a.to))}}e.setRoute([{type:"url",url:s(e.lastHandledLocation)}].concat(t).reduce(At,void 0),r)},this._history=t.history,this.observers=[],this.isLastRouteSteady=!1,this.navigationsSinceSteady=0,this.basename=t.basename,this.matcher=t.routes,this._router=new Nt({context:t.context,routes:t.routes,basename:t.basename}),this.trailingSlash=void 0===t.trailingSlash?"remove":t.trailingSlash,this.unlisten=this._history.listen(function(t){return e.handleLocationChange(t,!1)})}return Object.defineProperty(t.prototype,"history",{get:function(){return this._history},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"router",{get:function(){return this._router},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.observers.length=0,this.unlisten(),delete this.unlisten,delete this._history,this.observableSubscription&&this.observableSubscription.unsubscribe(),delete this.observableSubscription,delete this._router,delete this.waitUntilSteadyDeferred,delete this.lastRoute,delete this._router},t.prototype.go=function(t){return Wt(this,void 0,void 0,function(){var e,r=this;return Zt(this,function(n){switch(n.label){case 0:return e=new Promise(function(t){var e=r._history.listen(function(){e(),t()})}),this._history.go(t),[4,e];case 1:return n.sent(),[2,this.getRoute()]}})})},t.prototype.goBack=function(){return this.go(-1)},t.prototype.goForward=function(){return this.go(1)},t.prototype.navigate=function(t,e){var r;if(void 0===e&&(e={}),"string"==typeof t)r=s(t);else if(t.url)r=s((e=t).url);else{if(!t)throw new Error("You must specify a URL or state to navigation.navigate().");r=s(t)}var n=this._history.location,o=e.replace||!1!==e.replace&&n.pathname===r.pathname&&n.search===r.search&&n.hash===r.hash;return this._history[o?"replace":"push"]({pathname:r.pathname,search:r.search,hash:r.hash,state:ee({revertTo:o?n.state:void 0,method:e.method,headers:e.headers,body:e.body,state:e.state})}),this.getRoute()},t.prototype.prefetch=function(t){return Wt(this,void 0,void 0,function(){return Zt(this,function(e){switch(e.label){case 0:return[4,$t({basename:this.basename,routes:this.matcher,context:this._router.context,url:t})];case 1:return e.sent(),[2]}})})},t.prototype.refresh=function(){return this.handleLocationChange(this._history.location,!0),this.getRoute()},t.prototype.setContext=function(t){return this._router.setContext(t),this.refresh()},t.prototype.getCurrentValue=function(){return this.lastRoute},t.prototype.getRoute=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){return this.isLastRouteSteady?[2,this.lastRoute]:(this.waitUntilSteadyDeferred||(this.waitUntilSteadyDeferred=new Bt),[2,this.waitUntilSteadyDeferred.promise])})})},t.prototype.getSteadyValue=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){return[2,this.getRoute()]})})},t.prototype.steady=function(){return Wt(this,void 0,void 0,function(){return Zt(this,function(t){switch(t.label){case 0:return[4,this.getRoute()];case 1:return t.sent(),[2]}})})},t.prototype.extractState=function(){return this._history.location.state},t.prototype.subscribe=function(t,e,r){var n=jt(t,e,r);return this.observers.push(n),new Pt(this.handleUnsubscribe,n)},t.prototype.handleLocationChange=function(t,e){if(this.ignoreNextLocationChange)this.ignoreNextLocationChange=!1;else if(++this.navigationsSinceSteady>100)console.error("Detected possible navigation loop with 100 navigations between steady routes. Bailing.");else{if(null!==this.trailingSlash){var r=p(t.pathname,this.trailingSlash);if(t.pathname!==r)return void this._history.replace(zt({},t,{pathname:r}))}var n=s(t),o=this.lastHandledLocation;this.lastHandledLocation=t,this.observableSubscription&&this.observableSubscription.unsubscribe();var a=this._router.createObservable(n,function(t){void 0===t&&(t={});var e=zt({},t);delete e[Xt];var r=t[Xt]||{};return zt({},r.requestDataWithoutState,{state:Object.keys(e).length?e:void 0})}(t.state));if(a)this.observableSubscription=a.subscribe(this.handleChunkList);else if(!o)throw new m(n)}},t.prototype.setRoute=function(t,e){if(t!==this.lastRoute){this.lastRoute=t,this.isLastRouteSteady=e,e&&(this.navigationsSinceSteady=0);for(var r=0;r<this.observers.length;r++)this.observers[r].next(t);this.isLastRouteSteady&&this.waitUntilSteadyDeferred&&(this.waitUntilSteadyDeferred.resolve(t),delete this.waitUntilSteadyDeferred)}},t}(),Xt="__navi__";function te(t,e){var r;return void 0===t&&(t={}),zt({},e,((r={})[Xt]=t[Xt],r))}function ee(t){var e,r=t.revertTo,n=t.state,o=Jt(t,["revertTo","state"]);return r&&(r=zt({},r))[Xt]&&delete r[Xt].revertTo,zt({},n,((e={})[Xt]={requestDataWithoutState:o,revertTo:r},e))}function re(t){return void 0===t&&(t={}),(t[Xt]||{}).revertTo}var ne=function(){return(ne=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var oe=function(){return(oe=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};t.crawl=function(t){return Ht(this,void 0,void 0,function(){var e,r,n,o,a,i,u,c,l,h,y,d,v,b=this;return Ft(this,function(m){switch(m.label){case 0:return e=Gt({basename:t.basename,context:t.context,routes:t.routes}),r=s(t.root||""),n=t.predicate||function(){return!0},o=t.expandPattern||function(t){return[t||""]},a=function(t,e){return Ht(b,void 0,void 0,function(){return Ft(this,function(r){switch(r.label){case 0:return[4,o(t)];case 1:return[2,(r.sent()||[]).map(function(t){return{headers:e.headers,url:s(f(e.mountpath,t)),context:e.headers}}).filter(n)]}})})},[4,_t(e.createObservable(r,{crawler:a,headers:t.headers,method:"HEAD"}))];case 1:i=m.sent(),u=[],c={};t:for(l=0;l<i.length;l++)if("crawl"===(h=i[l]).type){if(-1!==(y=h.url.pathname).indexOf(":"))continue;for(d=l+1;d<i.length&&"crawl"!==(v=i[d]).type&&"mount"!==v.type;d++,l++)if("redirect"===v.type){c[y]=v.to;continue t}u.push(y)}return[2,{paths:null!==t.trailingSlash?u.map(function(e){return p(e,t.trailingSlash||"remove")}):u,redirects:c}]}})})},t.resolve=$t,t.compose=o,t.Router=Nt,t.createRouter=Gt,t.routeReducer=At,t.concatMatcherIterators=R,t.Navigation=Kt,t.resolveChunks=O,t.createBrowserNavigation=function(t){t.pages&&(t.routes=t.pages),!t.state&&void 0!==typeof window&&window.__NAVI_STATE__&&(t.state=window.__NAVI_STATE__,delete window.__NAVI_STATE__);var r=t.history||e.createBrowserHistory();t.state&&r.replace(ne({},r.location,{state:t.state}));var n=new Kt({history:r,basename:t.basename,context:t.context,routes:t.routes,trailingSlash:t.trailingSlash});return n.refresh(),n},t.createMemoryNavigation=function(t){t.pages&&(t.routes=t.pages);var r=t.url||t.request&&t.request.url;if(!r)throw new Error("createMemoryNavigation() could not find a URL.");var n=e.createMemoryHistory({initialEntries:["/"]}),o=new Kt({history:n,basename:t.basename,context:t.context,routes:t.routes,trailingSlash:t.trailingSlash});return o.navigate(oe({},t.request,{url:r,replace:!0})),o},t.lazy=M,t.map=M,t.createPage=function(t){return Object.assign(o(X(it(t)),tt(function(t,e){return e.meta}),et(function(t,e){return e.title}),L(function(t,e){return e.content})),{isDeprecatedMatcher:!0})},t.createContext=function(t,e){return Object.assign(X(t,e.isDeprecatedMatcher?e:M(e)),{isDeprecatedMatcher:!0})},t.createSwitch=function(t){var e,r,n={};try{for(var a=at(Object.keys(t.paths)),i=a.next();!i.done;i=a.next()){var u=i.value,s=t.paths[u];n[u]=s.isDeprecatedMatcher?s:M(s)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}if(1===Object.keys(t).length)return Object.assign($(n),{isDeprecatedMatcher:!0});t.paths;var c=ot(t,["paths"]);return Object.assign(o(X(it(c)),tt(function(t,e){return e.meta}),et(function(t,e){return e.title}),L(function(t,e){return e.content}),$(n)),{isDeprecatedMatcher:!0})},t.createRedirect=function(t,e){var r=W(t);return e?o(tt(e),r):Object.assign(r,{isDeprecatedMatcher:!0})},t.mount=$,t.redirect=W,t.route=function(t){var e;if(void 0===t&&(t={}),"function"==typeof t)e=t;else{var r=t.data,n=t.getData,a=t.error,i=t.head,u=t.getHead,s=t.headers,c=t.getHeaders,l=t.state,h=t.getState,f=t.status,p=t.getStatus,y=t.title,d=t.getTitle,v=t.view,b=t.getView;bt(t,["data","getData","error","head","getHead","headers","getHeaders","state","getState","status","getStatus","title","getTitle","view","getView"]),e=function(t,e){var o,m=this,w=mt(gt(r,n,t,e),2),g=w[0],x=w[1];g?k(g)&&(g=g.then(wt)):g={};var S,O,P=mt(gt(s,c,t,e),2),j=P[0],_=P[1],R=mt(gt(l,h,t,e),2),E=R[0],T=R[1],C=mt(gt(f,p,t,e),2),L=C[0],I=C[1],D=mt(gt(y,d,t,e),2),M=D[0],U=D[1],q=mt(gt(i,u,t,e),2),A=q[0],G=q[1];return"HEAD"!==t.method&&(o=mt(gt(v,b,t,e),2),S=o[0],O=o[1]),x||_||T||I||U||G||O?dt(m,void 0,void 0,function(){var t;return vt(this,function(e){switch(e.label){case 0:return t={},[4,g];case 1:return t.data=e.sent(),t.error=a,[4,A];case 2:return t.head=e.sent(),[4,j];case 3:return t.headers=e.sent(),[4,E];case 4:return t.state=e.sent(),[4,L];case 5:return t.status=e.sent(),[4,M];case 6:return t.title=e.sent(),[4,S];case 7:return[2,(t.view=e.sent(),t)]}})}):{data:g,error:a,head:A,headers:j,state:E,status:L,title:M,view:S}}}return o(X(function(t,r){return t.crawler?{}:e(t,r)}),tt(function(t){return t.context.data}),st(function(t){return t.context.head}),ct(function(t){return t.context.headers}),pt(function(t){return t.context.state||null}),yt(function(t){return t.context.status}),et(function(t){return t.context.title}),L(function(t){return t.context.view},void 0,!0),C(function(t){return t.context.error},void 0,function(t,e){return t?[w("error",e,{error:t})]:[]}))},t.withContext=X,t.withCrawlerPatterns=function(t,e){var r=this,n=function(e){return function(n,o){return St(r,void 0,void 0,function(){var r,a,i,u;return Ot(this,function(s){switch(s.label){case 0:return r=t[n],o.mountpath===e.mountpath&&r?[3,1]:[2,e.crawler(n,o)];case 1:return Array.isArray(r)?(i=r,[3,4]):[3,2];case 2:return[4,r(e,e.context)];case 3:i=s.sent(),s.label=4;case 4:return a=i,u=H,[4,Promise.all(a.map(function(t){return e.crawler(t,o)}))];case 5:return[2,u.apply(void 0,[s.sent()])]}})})}};return function(t){return function(r){return function(t,e){return Ot(this,function(r){switch(r.label){case 0:return t.crawler?[3,2]:[5,kt(_(e,t))];case 1:return r.sent(),[3,4];case 2:return[5,kt(O(n,t,function(r){return _(e,xt({},t,{crawler:r}))}))];case 3:r.sent(),r.label=4;case 4:return[2]}})}(r,e?e(t):t)}}},t.withData=tt,t.withHead=st,t.withHeaders=ct,t.withState=pt,t.withStatus=yt,t.withTitle=et,t.withView=L,t.NaviError=v,t.NotFoundError=b,t.OutOfRootError=m,t.createRequest=U,t.createChunk=w,t.createNotFoundChunk=g,t.createURLDescriptor=s,t.parseQuery=c,t.stringifyQuery=l,t.joinPaths=f,t.modifyTrailingSlash=p,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "navi", | ||
"version": "0.12.9", | ||
"version": "0.12.10", | ||
"description": "A router-loader for React.", | ||
@@ -60,3 +60,3 @@ "author": "James K Nelson <james@jamesknelson.com>", | ||
}, | ||
"gitHead": "87a356d4d68f6fdc0b40b2beb58cf124d1e8b51c" | ||
"gitHead": "ffa39ff256be1884e010363ad6be65fccf4383af" | ||
} |
@@ -5,7 +5,5 @@ import { Matcher } from './Matcher' | ||
export const KEY_WILDCARD = '\0' | ||
export const MEMO_KEY_PREFIX = '\0' | ||
/** | ||
@@ -16,140 +14,155 @@ * An object that holds information about a path that can be matched | ||
export interface Mapping { | ||
/** | ||
* The relative path of a Map to its parent, with wildcards | ||
* represented by a colon `:`, followed by the name of the param where | ||
* their value should be placed. | ||
*/ | ||
pattern: string, | ||
/** | ||
* A string where wildcards have been replaced with the null character | ||
* '\0', so that no two identical keys will match the same URL. | ||
*/ | ||
key: string, | ||
/** | ||
* The relative path of a Map to its parent, with wildcards | ||
* represented by a colon `:`, followed by the name of the param where | ||
* their value should be placed. | ||
*/ | ||
pattern: string | ||
/** | ||
* A regex that matches the path. | ||
* It should start with ^, but should not end with $.` | ||
*/ | ||
regExp: RegExp, | ||
/** | ||
* A string where wildcards have been replaced with the null character | ||
* '\0', so that no two identical keys will match the same URL. | ||
*/ | ||
key: string | ||
/** | ||
* The names of params that correspond to wildcards in the relative path. | ||
*/ | ||
pathParamNames?: string[], | ||
/** | ||
* A regex that matches the path. | ||
* It should start with ^, but should not end with $.` | ||
*/ | ||
regExp: RegExp | ||
/** | ||
* The node that will be used to handle detailed matching of this path, | ||
* once a tentative match is found. | ||
*/ | ||
matcher: Matcher<any>, | ||
/** | ||
* The names of params that correspond to wildcards in the relative path. | ||
*/ | ||
pathParamNames?: string[] | ||
/** | ||
* The node that will be used to handle detailed matching of this path, | ||
* once a tentative match is found. | ||
*/ | ||
matcher: Matcher<any> | ||
} | ||
export function createRootMapping(matcher: Matcher<any>, rootPath: string = ''): Mapping { | ||
return ( | ||
rootPath !== '' | ||
? createMapping(rootPath, matcher) | ||
: { | ||
pattern: rootPath, | ||
key: '', | ||
regExp: new RegExp(''), | ||
matcher, | ||
} | ||
) | ||
export function createRootMapping( | ||
matcher: Matcher<any>, | ||
rootPath: string = '', | ||
): Mapping { | ||
return rootPath !== '' | ||
? createMapping(rootPath, matcher) | ||
: { | ||
pattern: rootPath, | ||
key: '', | ||
regExp: new RegExp(''), | ||
matcher, | ||
} | ||
} | ||
export function createMapping(pattern: string, matcher: Matcher<any>): Mapping { | ||
let processedPattern = pattern | ||
if (processedPattern.length > 1 && processedPattern.substr(-1) === '/') { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn(`The pattern "${pattern}" ends with the character '/', so it has been automatically removed. To avoid this warning, don't add a final "/" to patterns.`) | ||
} | ||
processedPattern = processedPattern.substr(0, processedPattern.length - 1) | ||
let processedPattern = pattern | ||
if (processedPattern.length > 1 && processedPattern.substr(-1) === '/') { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn( | ||
`The pattern "${pattern}" ends with the character '/', so it has been automatically removed. To avoid this warning, don't add a final "/" to patterns.`, | ||
) | ||
} | ||
processedPattern = processedPattern.substr(0, processedPattern.length - 1) | ||
} | ||
if (processedPattern[0] !== '/') { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn(`The pattern "${pattern}" does not start with the character '/', so it has been automatically added. To avoid this warning, make sure to add the leading "/" to all patterns.`) | ||
} | ||
processedPattern = '/'+processedPattern | ||
if (processedPattern[0] !== '/') { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn( | ||
`The pattern "${pattern}" does not start with the character '/', so it has been automatically added. To avoid this warning, make sure to add the leading "/" to all patterns.`, | ||
) | ||
} | ||
processedPattern = '/' + processedPattern | ||
} | ||
if (/\/{2,}/.test(processedPattern)) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn(`The pattern "${pattern} has adjacent '/' characters, which have been combined into single '/' characters. To avoid this warning, don't use adjacent '/' characters within patterns.`) | ||
} | ||
processedPattern = processedPattern.replace(/\/{2,}/g, '/') | ||
if (/\/{2,}/.test(processedPattern)) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn( | ||
`The pattern "${pattern} has adjacent '/' characters, which have been combined into single '/' characters. To avoid this warning, don't use adjacent '/' characters within patterns.`, | ||
) | ||
} | ||
if (!/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(processedPattern)) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn(`The pattern "${pattern}" uses non-URL safe characters. The URL-safe characters are: A-Z a-z 0-9 $ - _ . + ! * ' ( ) ,`) | ||
} | ||
processedPattern = processedPattern.replace(/\/{2,}/g, '/') | ||
} | ||
if (!/^([A-Za-z0-9\$\-_\.+!*'\(\),\/]|\/:)+$/.test(processedPattern)) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn( | ||
`The pattern "${pattern}" uses non-URL safe characters. The URL-safe characters are: A-Z a-z 0-9 $ - _ . + ! * ' ( ) ,`, | ||
) | ||
} | ||
if (processedPattern.length === 0) { | ||
throw new Error(`You cannot use an empty string "" as a pattern!`) | ||
} | ||
if (processedPattern.length === 0) { | ||
throw new Error(`You cannot use an empty string "" as a pattern!`) | ||
} | ||
let parts = processedPattern.split('/').slice(1) | ||
let pathParams: string[] = [] | ||
let keyParts: string[] = [] | ||
let regExpParts = ['^'] | ||
for (let i = 0; i < parts.length; i++) { | ||
let part = parts[i] | ||
if (part.length > 1 && part[0] === ':') { | ||
pathParams.push(part.slice(1)) | ||
keyParts.push(KEY_WILDCARD) | ||
regExpParts.push('([^/]+)') | ||
} else { | ||
keyParts.push(part) | ||
regExpParts.push(escapeRegExp(part)) | ||
} | ||
let parts = processedPattern.split('/').slice(1) | ||
let pathParams: string[] = [] | ||
let keyParts: string[] = [] | ||
let regExpParts = ['^'] | ||
for (let i = 0; i < parts.length; i++) { | ||
let part = parts[i] | ||
if (part.length > 1 && part[0] === ':') { | ||
pathParams.push(part.slice(1)) | ||
keyParts.push(KEY_WILDCARD) | ||
regExpParts.push('([^/]+)') | ||
} | ||
else { | ||
keyParts.push(part) | ||
regExpParts.push(escapeRegExp(part)) | ||
} | ||
} | ||
return { | ||
key: keyParts.join('/'), | ||
matcher, | ||
pattern: processedPattern, | ||
pathParamNames: pathParams.length ? pathParams : undefined, | ||
regExp: processedPattern === '/' ? /^\/$/ : new RegExp(regExpParts.join('/')), | ||
} | ||
} | ||
return { | ||
key: keyParts.join('/'), | ||
matcher, | ||
pattern: processedPattern, | ||
pathParamNames: pathParams.length ? pathParams : undefined, | ||
regExp: | ||
processedPattern === '/' ? /^\/$/ : new RegExp(regExpParts.join('/')), | ||
} | ||
} | ||
export function matchAgainstPathname( | ||
request: NaviRequest, | ||
mapping: Mapping, | ||
): NaviRequest | undefined { | ||
let match = mapping.regExp.exec(request.path || '/') | ||
if (!match) { | ||
return | ||
} | ||
export function matchAgainstPathname(request: NaviRequest, mapping: Mapping): NaviRequest | undefined { | ||
let match = mapping.regExp.exec(request.path || '/') | ||
if (!match) { | ||
return | ||
} | ||
let matchedPathname = match[0] | ||
let unmatchedPath = request.path.slice(matchedPathname.length) || '' | ||
if (unmatchedPath.length && unmatchedPath[0] !== '/') { | ||
return | ||
} | ||
let matchedPathname = match[0] | ||
// Set path params using RegExp match | ||
let params = request.params | ||
if (mapping.pathParamNames) { | ||
params = { ...request.params } | ||
for (let i = 0; i < mapping.pathParamNames.length; i++) { | ||
let paramName = mapping.pathParamNames[i] | ||
params[paramName] = match[i+1] | ||
} | ||
// Set path params using RegExp match | ||
let params = request.params | ||
if (mapping.pathParamNames) { | ||
params = { ...request.params } | ||
for (let i = 0; i < mapping.pathParamNames.length; i++) { | ||
let paramName = mapping.pathParamNames[i] | ||
params[paramName] = match[i + 1] | ||
} | ||
} | ||
let unmatchedPath = request.path.slice(matchedPathname.length) || '' | ||
let mountpath = joinPaths(request.mountpath, matchedPathname) || '/' | ||
return createRequest({ | ||
...request, | ||
params, | ||
mountpath, | ||
path: unmatchedPath, | ||
url: unmatchedPath+request.search, | ||
}, request['_router']) | ||
let mountpath = joinPaths(request.mountpath, matchedPathname) || '/' | ||
return createRequest( | ||
{ | ||
...request, | ||
params, | ||
mountpath, | ||
path: unmatchedPath, | ||
url: unmatchedPath + request.search, | ||
}, | ||
request['_router'], | ||
) | ||
} | ||
// From http://stackoverflow.com/a/5306111/106302 | ||
// Originally from http://simonwillison.net/2006/Jan/20/escape/ (dead link) | ||
function escapeRegExp(value) { | ||
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") | ||
} | ||
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13609
806545
235