Comparing version 0.11.3 to 0.11.4
@@ -62,3 +62,3 @@ "use strict"; | ||
: Resolvable_1.default(maybeResolvable, request, context, function (value) { return getChunks(value, request); }); | ||
return [5 /*yield**/, __values((child ? Matcher_1.concatMatcherIterators(parentIterator, child(request, context)) : parentIterator))]; | ||
return [5 /*yield**/, __values((child ? Matcher_1.concatMatcherIterators(parentIterator, Matcher_1.createMatcherIterator(child, request, context)) : parentIterator))]; | ||
case 3: | ||
@@ -65,0 +65,0 @@ _a.sent(); |
@@ -30,2 +30,13 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var URLTools_1 = require("./URLTools"); | ||
function createMatcherIterator(matcherGenerator, request, context, pattern) { | ||
if (pattern === void 0) { pattern = ''; } | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (typeof matcherGenerator !== 'function') { | ||
console.error("A matcher at the URL \"" + URLTools_1.joinPaths(request.mountpath, pattern) + "\" is invalid. A generator function was expected, but \"" + String(matcherGenerator) + "\" was received."); | ||
} | ||
} | ||
return matcherGenerator(request, context); | ||
} | ||
exports.createMatcherIterator = createMatcherIterator; | ||
function concatMatcherIterators(x, y) { | ||
@@ -32,0 +43,0 @@ var xResult, yResult, xChunks, yChunks; |
@@ -172,5 +172,5 @@ "use strict"; | ||
} | ||
return matcher; | ||
return Object.assign(matcher, { isDeprecatedMatcher: true }); | ||
} | ||
exports.createRedirect = createRedirect; | ||
//# sourceMappingURL=compat.js.map |
@@ -44,2 +44,3 @@ "use strict"; | ||
var Resolvable_1 = __importDefault(require("../Resolvable")); | ||
var Matcher_1 = require("../Matcher"); | ||
function map(resolvableMatcher) { | ||
@@ -49,3 +50,3 @@ return function () { return function mapMatcherGenerator(request, context) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(Resolvable_1.default(resolvableMatcher, request, context, function (childMatcher) { return childMatcher()(request, context); }))]; | ||
case 0: return [5 /*yield**/, __values(Resolvable_1.default(resolvableMatcher, request, context, function (childMatcher) { return Matcher_1.createMatcherIterator(childMatcher(), request, context); }))]; | ||
case 1: | ||
@@ -52,0 +53,0 @@ _a.sent(); |
@@ -32,3 +32,3 @@ "use strict"; | ||
var Mapping_1 = require("../Mapping"); | ||
var URLTools_1 = require("../URLTools"); | ||
var Matcher_1 = require("../Matcher"); | ||
function mount(paths) { | ||
@@ -54,3 +54,3 @@ if (!paths) { | ||
return function mountMatcherGenerator(request, context) { | ||
var chunks, childIterator, childResult, i, mapping, childRequest, matcherGenerator, childChunks; | ||
var chunks, childIterator, childResult, i, mapping, childRequest, childChunks; | ||
return __generator(this, function (_a) { | ||
@@ -66,9 +66,3 @@ switch (_a.label) { | ||
if (childRequest) { | ||
matcherGenerator = mapping.matcher(); | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (typeof matcherGenerator !== 'function') { | ||
console.error("mount(): the pattern \"" + URLTools_1.joinPaths(request.mountpath, mapping.pattern) + "\" is invalid. It's value should be a matcher object."); | ||
} | ||
} | ||
childIterator = matcherGenerator(childRequest, context); | ||
childIterator = Matcher_1.createMatcherIterator(mapping.matcher(), childRequest, context, mapping.pattern); | ||
// The first match is always the only match, as we don't allow | ||
@@ -75,0 +69,0 @@ // for ambiguous patterns. |
@@ -44,2 +44,3 @@ "use strict"; | ||
var Resolvable_1 = __importDefault(require("../Resolvable")); | ||
var Matcher_1 = require("../Matcher"); | ||
function withContext(childContextMaybeResolvable, forceChild) { | ||
@@ -55,3 +56,3 @@ if (process.env.NODE_ENV !== 'production') { | ||
case 0: return [5 /*yield**/, __values(Resolvable_1.default(childContextMaybeResolvable, request, context, function (childContext) { | ||
return child(request, childContext || {}); | ||
return Matcher_1.createMatcherIterator(child, request, childContext || {}); | ||
}))]; | ||
@@ -58,0 +59,0 @@ case 1: |
@@ -40,3 +40,3 @@ var __generator = (this && this.__generator) || function (thisArg, body) { | ||
import { createNotFoundChunk } from './Chunks'; | ||
import { concatMatcherIterators } from './Matcher'; | ||
import { concatMatcherIterators, createMatcherIterator } from './Matcher'; | ||
export function createChunksMatcher(maybeResolvable, forceChildMatcher, getChunks, shouldResolve) { | ||
@@ -58,3 +58,3 @@ function chunksMatcherGenerator(request, context, child) { | ||
: resolveChunks(maybeResolvable, request, context, function (value) { return getChunks(value, request); }); | ||
return [5 /*yield**/, __values((child ? concatMatcherIterators(parentIterator, child(request, context)) : parentIterator))]; | ||
return [5 /*yield**/, __values((child ? concatMatcherIterators(parentIterator, createMatcherIterator(child, request, context)) : parentIterator))]; | ||
case 3: | ||
@@ -61,0 +61,0 @@ _a.sent(); |
@@ -28,2 +28,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) { | ||
}; | ||
import { joinPaths } from './URLTools'; | ||
export function createMatcherIterator(matcherGenerator, request, context, pattern) { | ||
if (pattern === void 0) { pattern = ''; } | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (typeof matcherGenerator !== 'function') { | ||
console.error("A matcher at the URL \"" + joinPaths(request.mountpath, pattern) + "\" is invalid. A generator function was expected, but \"" + String(matcherGenerator) + "\" was received."); | ||
} | ||
} | ||
return matcherGenerator(request, context); | ||
} | ||
export function concatMatcherIterators(x, y) { | ||
@@ -30,0 +40,0 @@ var xResult, yResult, xChunks, yChunks; |
@@ -167,4 +167,4 @@ // | ||
} | ||
return matcher; | ||
return Object.assign(matcher, { isDeprecatedMatcher: true }); | ||
} | ||
//# sourceMappingURL=compat.js.map |
@@ -39,2 +39,3 @@ var __generator = (this && this.__generator) || function (thisArg, body) { | ||
import resolveChunks from '../Resolvable'; | ||
import { createMatcherIterator, } from '../Matcher'; | ||
export function map(resolvableMatcher) { | ||
@@ -44,3 +45,3 @@ return function () { return function mapMatcherGenerator(request, context) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(resolveChunks(resolvableMatcher, request, context, function (childMatcher) { return childMatcher()(request, context); }))]; | ||
case 0: return [5 /*yield**/, __values(resolveChunks(resolvableMatcher, request, context, function (childMatcher) { return createMatcherIterator(childMatcher(), request, context); }))]; | ||
case 1: | ||
@@ -47,0 +48,0 @@ _a.sent(); |
@@ -30,3 +30,3 @@ var __generator = (this && this.__generator) || function (thisArg, body) { | ||
import { createMapping, mappingAgainstPathname } from '../Mapping'; | ||
import { joinPaths } from '../URLTools'; | ||
import { createMatcherIterator } from '../Matcher'; | ||
export function mount(paths) { | ||
@@ -52,3 +52,3 @@ if (!paths) { | ||
return function mountMatcherGenerator(request, context) { | ||
var chunks, childIterator, childResult, i, mapping, childRequest, matcherGenerator, childChunks; | ||
var chunks, childIterator, childResult, i, mapping, childRequest, childChunks; | ||
return __generator(this, function (_a) { | ||
@@ -64,9 +64,3 @@ switch (_a.label) { | ||
if (childRequest) { | ||
matcherGenerator = mapping.matcher(); | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (typeof matcherGenerator !== 'function') { | ||
console.error("mount(): the pattern \"" + joinPaths(request.mountpath, mapping.pattern) + "\" is invalid. It's value should be a matcher object."); | ||
} | ||
} | ||
childIterator = matcherGenerator(childRequest, context); | ||
childIterator = createMatcherIterator(mapping.matcher(), childRequest, context, mapping.pattern); | ||
// The first match is always the only match, as we don't allow | ||
@@ -73,0 +67,0 @@ // for ambiguous patterns. |
@@ -39,2 +39,3 @@ var __generator = (this && this.__generator) || function (thisArg, body) { | ||
import resolveChunks from '../Resolvable'; | ||
import { createMatcherIterator, } from '../Matcher'; | ||
export function withContext(childContextMaybeResolvable, forceChild) { | ||
@@ -50,3 +51,3 @@ if (process.env.NODE_ENV !== 'production') { | ||
case 0: return [5 /*yield**/, __values(resolveChunks(childContextMaybeResolvable, request, context, function (childContext) { | ||
return child(request, childContext || {}); | ||
return createMatcherIterator(child, request, childContext || {}); | ||
}))]; | ||
@@ -53,0 +54,0 @@ case 1: |
@@ -9,2 +9,3 @@ import { Resolvable } from './Resolvable'; | ||
export declare type MatcherIterator = IterableIterator<Chunk[]>; | ||
export declare function createMatcherIterator<Context extends object>(matcherGenerator: MatcherGenerator<Context>, request: NaviRequest, context: Context, pattern?: string): MatcherIterator; | ||
export declare function concatMatcherIterators(x: MatcherIterator, y: MatcherIterator): IterableIterator<Chunk[]>; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("history")):"function"==typeof define&&define.amd?define(["exports","history"],t):t((e=e||self).Navi={},e.History)}(this,function(e,t){"use strict";var r=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},n=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e};function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("composeMatchers() expects at least one matcher.");return 1===e.length?e[0]:e.reduce(function(e,t){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return e(t.apply(void 0,n(r)))}})}function i(e,t){return e==t||!(!e||!t)&&(e.pathname==t.pathname&&e.search==t.search&&e.hash==t.hash&&e.state==t.state)}var a=/((((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;function s(e,t){var r,n,o,i,s,l,h=void 0===t?{}:t,f=h.ensureTrailingSlash,p=void 0===f||f,b=h.removeHash,d=void 0!==b&&b;if("string"==typeof e){var y=a.exec(e);if(!y)throw new Error("Couldn't parse the provided URL.");r="",n=y[2]||"",o=u(i=y[6]||""),s=y[7]||""}else r=e.hostname||"",n=e.pathname||"",o=e.query||(e.search?u(e.search):{}),i=e.search||c(o),s=e.hash||"",l=e.state;return p&&n.length&&"/"!==n.substr(-1)&&(n+="/"),{hostname:r,pathname:n,query:o,search:i,hash:d?"":s,href:n+i+s,state:l}}function u(e,t){if(void 0===t&&(t="?"),!e||e[0]!=t)return{};for(var r={},n=e.slice(1).split("&"),o=0,i=n.length;o<i;o++){var a=n[o].split("=");r[a[0]]=a[1]?decodeURIComponent(a[1]):""}return r}function c(e,t){void 0===t&&(t="?");var r=Object.keys(e);if(0===r.length)return"";for(var n=[],o=0,i=r.length;o<i;o++){var a=r[o],s=String(e[a]);n.push(""===s?a:a+"="+encodeURIComponent(s))}return t+n.join("&")}function l(e,t){return t?("/"===e[e.length-1]&&(e=e.substr(0,e.length-1)),"/"===t[0]&&(t=t.substr(1)),e+"/"+t):e}var h,f=(h=function(e,t){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),p=function(e){function t(t){var r=this,n=this.constructor.prototype;return(r=e.call(this,t)||this).__proto__=n,Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(r,r.constructor):Object.defineProperty(r,"stack",{value:(new Error).stack}),Object.defineProperty(r,"message",{value:t}),r}return f(t,e),t}(Error),b=function(e){function t(t){var r=e.call(this,"URL not found: "+t)||this;return r.pathname=t,r.status=404,r.name="NotFoundError",r}return f(t,e),t}(p),d=function(e){function t(t){var r=e.call(this,"URL not managed by router: "+t.href)||this;return r.url=t,r.name="OutOfRootError",r}return f(t,e),t}(p);function y(e,t,r,n){return void 0===n&&(n=!0),Object.assign({type:e,url:s({pathname:t.mountpath,query:t.query},{ensureTrailingSlash:n})},r)}function v(e){var t=l(e.mountpath,e.path);return{type:"error",url:s({pathname:t,query:e.query}),error:new b(t)}}var m=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},w=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function g(e,t,r,n){var o,i,a,s,u,c,h;return m(this,function(f){switch(f.label){case 0:o="function"==typeof e?e:function(){return e};try{i=o(t,r)}catch(e){i=Promise.reject(e)}return(p=i)&&p.then?[3,1]:(a=n(i),[3,7]);case 1:s=i.then(x),u=function(e){var t={};return e.then(function(e){t.value=e,t.outcome="resolved"},function(e){t.error=e,t.outcome="rejected"}),t}(s),c=[y("busy",t,{promise:s})],f.label=2;case 2:return u.outcome?[3,4]:[4,c];case 3:return f.sent(),[3,2];case 4:return"rejected"!==u.outcome?[3,6]:((h=u.error)instanceof b&&!h.pathname&&(h.pathname=l(t.mountpath,t.path)),[4,[y("error",t,{error:h})]]);case 5:return f.sent(),[3,7];case 6:a=n(u.value),f.label=7;case 7:return a?Array.isArray(a)?[4,a.length?a:[]]:[3,9]:[3,11];case 8:return f.sent(),[3,11];case 9:return[5,w(a)];case 10:f.sent(),f.label=11;case 11:return[2]}var p})}function x(e){return function(e){return e&&"object"==typeof e&&"default"in e}(e)?e.default:e}var S=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};function R(e,t){var r,n,o,i;return S(this,function(a){switch(a.label){case 0:o=[],i=[],a.label=1;case 1:return(r=e.next()).done||(o=r.value||[]),(n=t.next()).done||(i=n.value||[]),[4,o.concat(i)];case 2:a.sent(),a.label=3;case 3:if(!r.done||!n.done)return[3,1];a.label=4;case 4:return[2]}})}var k=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},O=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function P(e,t,r,n){function o(t,o,i){var a,s;return k(this,function(u){switch(u.label){case 0:return a=t.path,i||!a||"/"===a?[3,2]:[4,[v(t)]];case 1:return u.sent(),[3,4];case 2:return s=n&&!n(t)?function(){return k(this,function(e){switch(e.label){case 0:return[4,[]];case 1:return e.sent(),[2]}})}():g(e,t,o,function(e){return r(e,t)}),[5,O(i?R(s,i(t,o)):s)];case 3:u.sent(),u.label=4;case 4:return[2]}})}return function(e){return function(r,n){return o(r,n,t?t():e)}}}function j(e,t){return P(e,t,function(e,t){return e?[y("view",t,{view:e})]:[]},function(e){return"HEAD"!==e.method})}var E=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},C=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function L(e){return function(){return function(t,r){return E(this,function(n){switch(n.label){case 0:return[5,C(g(e,t,r,function(e){return e()(t,r)}))];case 1:return n.sent(),[2]}})}}}function U(e,t){return Object.defineProperties(t,{mountname:{get:function(){return t.mountpath}},pathname:{get:function(){return t.mountpath}},context:{get:function(){return e}}}),t}var I=function(){return(I=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},T="\0";function M(e,t){var r=e;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=[],i=[],a=["^"],s=0;s<n.length;s++){var u=n[s];u.length>1&&":"===u[0]?(o.push(u.slice(1)),i.push(T),a.push("([^/]+)")):(i.push(u),a.push(u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}return{key:i.join("/"),matcher:t,pattern:r,pathParamNames:o.length?o:void 0,regExp:new RegExp(a.join("/"))}}function D(e,t,r){var n=t.regExp.exec(e.path);if(n){var o=n[0],i=e.params;if(t.pathParamNames){i=I({},e.params);for(var a=0;a<t.pathParamNames.length;a++){i[t.pathParamNames[a]]=n[a+1]}}var s=e.path.slice(o.length)||"/",u=l(e.mountpath,o);return U(r,I({},e,{params:i,mountpath:u,path:s,url:s+e.search}))}}var G=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};function q(e){if(!e)throw new Error("mount() must be supplied with a paths object.");var t=Object.keys(e),r=t.map(function(t){return M(t,e[t])}).sort(function(e,t){return r=e.key,n=t.key,r<n?-1:r>n?1:0;var r,n});return function(){return function(e,n){var o,i,a,s,u,c,l,h;return G(this,function(f){switch(f.label){case 0:for(s=r.length-1;s>=0;s--)if(u=r[s],c=D(e,u,n)){l=u.matcher(),i=l(c,n);break}f.label=1;case 1:return!i||a&&a.done||(a=i.next()),o=[y("mount",e,{patterns:t},!1)],(h=a&&a.value)?o=o.concat(h.length?h:[]):o.push(v(e)),[4,o];case 2:f.sent(),f.label=3;case 3:if(o.filter(H).length)return[3,1];f.label=4;case 4:return[2]}})}}}function H(e){return"busy"===e.type}function _(e){return P(e,void 0,function(e,t){var r,n=t.path;return n&&"/"!==n?[v(t)]:("string"==typeof e?r="./"===e.slice(0,2)?l(t.mountpath.split("/").slice(0,-1).join("/"),e.slice(2)):e:e&&(r=s(e).href),r?[y("redirect",t,{to:r})]:[])})}var N=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},A=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function V(e,t){return function(r){return function(n,o){return function(t,r,n){return N(this,function(o){switch(o.label){case 0:return[5,A(g(e,t,r,function(e){return n(t,e||{})}))];case 1:return o.sent(),[2]}})}(n,o,t?t():r)}}}function Q(e,t){return P(e,t,function(e,t){return e?[y("data",t,{data:e})]:[]})}function F(e,t){return P(e,t,function(e,t){return e?[y("title",t,{title:e})]:[]})}var $=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},z=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},B=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r},Y=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function Z(e){return function(t,r){return $(this,void 0,void 0,function(){var n,o,i,a;return z(this,function(s){switch(s.label){case 0:return n=e.getMeta?Promise.resolve(e.getMeta(t,r,void 0)).then(x).then(J):Promise.resolve(e.meta||{}),o=e.getTitle?Promise.resolve(e.getTitle(t,r,n)).then(x):Promise.resolve(e.title),"HEAD"!==t.method&&(i=e.getContent?Promise.resolve(e.getContent(t,r,n)).then(x):Promise.resolve(e.content)),a={},[4,n];case 1:return a.meta=s.sent(),[4,i];case 2:return a.content=s.sent(),[4,o];case 3:return[2,(a.title=s.sent(),a)]}})})}}function J(e){return e||{}}function K(e,t){return P(e,t,function(e,t){return e?[y("head",t,{head:e})]:[]},function(e){return"HEAD"!==e.method})}function W(e,t){return P(e,t,function(e,t){return e?[y("headers",t,{headers:e})]:[]})}function X(e,t){return P(e,t,function(e,t){return e?[y("status",t,{status:e})]:[]})}var ee=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},te=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},re=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r};function ne(e){return e||{}}var oe=function(){function e(e,t){this.close=e,this.observer=t,this.observer.start&&this.observer.start(this)}return e.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this.close(this.observer),delete this.close,delete this.observer)},e}();function ie(e,t,r){return"function"==typeof e?{next:e,error:t,complete:r}:e}function ae(e){return new Promise(function(t,r){e.subscribe({start:function(e){this.subscription=e},next:function(e){this.value=e},complete:function(){t(this.value),this.subscription.unsubscribe()},error:function(e){r(e),this.subscription.unsubscribe()}})})}var se=function(){function e(e,t,r,n){var o=this;this.handleUnsubscribe=function(e){var t=o.observers.indexOf(e);-1!==t&&o.observers.splice(t,1)},this.handleChange=function(e){if(e===o.lastListenId){o.lastListenId++,o.refresh();for(var t=o.result.done||o.result.value.every(function(e){return"busy"!==e.type}),r=0;r<o.observers.length;r++){var n=o.observers[r];n.next(o.result.value),t&&n.complete&&n.complete()}t&&delete o.matcherIterator}},this.refresh=function(){var e=o.matcherIterator.next();if(e.value&&(o.result=e),!o.result.done){var t=++o.lastListenId,r=function(){return o.handleChange(t)};Promise.race(o.result.value.filter(ue).map(ce)).then(r,r)}},this.url=e,this.lastListenId=0,this.observers=[],this.matcherIterator=n(t,r)}return e.prototype.subscribe=function(e,t,r){if(!this.matcherIterator)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=ie(e,t,r);this.observers.push(n);var o=new oe(this.handleUnsubscribe,n);return 1===this.observers.length&&this.handleChange(this.lastListenId),o},e}();function ue(e){return"busy"===e.type}function ce(e){return e.promise}var le=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},he=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},fe=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},pe=function(){function e(e,t,r,n,o,i){var a=this;this.handleUnsubscribe=function(e){var t=a.observers.indexOf(e);-1!==t&&a.observers.splice(t,1)},this.handleResolverUpdate=function(e){e===a.lastListenId&&(a.lastListenId++,a.isRefreshing?a.isRefreshScheduled||(a.isRefreshScheduled=!0):a.refresh())},this.refresh=function(){return le(a,void 0,void 0,function(){var e,t,r,n,o,i,a,s,u,c,h,f,p,b,d,y,v,m,w=this;return he(this,function(g){switch(g.label){case 0:this.isRefreshScheduled=!1,this.isRefreshing=!0,e=[],t=0,r=function(){var r,o,i,a,s,u,c,h,f,p,b;return he(this,function(d){switch(d.label){case 0:r=n.mapItems[t],o=r.pathname,i=r.matcherIterator.next(),r.lastResult&&!i.value||(r.lastResult=i),a=r.lastResult.value,r.chunksCache=a||[],s=a.findIndex(function(e){return"error"===e.type||e.url.href.length>=r.url.href.length&&("mount"===e.type&&r.lastMountPatterns!==e.patterns||"redirect"===e.type&&r.lastRedirectTo!==e.to)}),d.label=1;case 1:if(!(s>=0&&s<a.length))return[3,6];if(u=a[s],s++,"error"===u.type||n.options.predicate&&!n.options.predicate(u,a))return n.removeFromQueue(r),[2,"continue-items"];if("redirect"===u.type&&(r.lastRedirectTo=u.to,n.options.followRedirects&&n.addToQueue(u.to,r.depth+1,r.walkedPatternLists,o,r.order)),"mount"!==u.type)return[3,5];if(c=u.patterns,r.lastMountPatterns=c,h=c.slice(0).sort().join("\n"),!c||r.walkedPatternLists.has(h))return[3,5];r.walkedPatternLists.add(h),f=0,d.label=2;case 2:return f<c.length?[4,n.expandPatterns(l(o,c[f]))]:[3,5];case 3:for(p=d.sent(),b=0;b<p.length;b++)n.addToQueue(p[b],r.depth+1,r.walkedPatternLists,o,r.order.concat(f,b));d.label=4;case 4:return f++,[3,2];case 5:return[3,1];case 6:return a&&(e=e.concat(a)),t++,[2]}})},n=this,g.label=1;case 1:return this.mapItems&&t<this.mapItems.length?[5,r()]:[3,3];case 2:switch(g.sent()){case"continue-items":return[3,1]}return[3,1];case 3:if(!this.mapItems)return[2];for(o=[],i=0;i<this.mapItems.length;i++)a=this.mapItems[i],"mount"===(s=a.chunksCache[a.chunksCache.length-1]).type||"error"===s.type||"busy"!==s.type&&this.options.predicate&&!this.options.predicate(s,a.chunksCache)||o.push([l(a.pathname,"/"),a.chunksCache,a.order]);if(u=++this.lastListenId,c=function(){return w.handleResolverUpdate(u)},Promise.race(e.filter(be).map(de)).then(c,c),o.sort(function(e,t){var r=e[2],n=t[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(h={},f=!0,p=0;p<o.length;p++)b=fe(o[p],2),d=b[0],(y=b[1]).some(function(e){return"busy"===e.type})&&(f=!1),h[d]=y;for(v=0;v<this.observers.length;v++)(m=this.observers[v]).next(h),f&&m.complete&&m.complete();f&&(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=t,this.matcherGeneratorFunction=r,this.rootMapping=n,this.options=i,this.seenPathnames=new Set;var s=e.pathname;"/"===s.substr(-1)&&(s=s.substr(0,s.length-1)),this.addToQueue(s,0,new Set)}return e.prototype.subscribe=function(e,t,r){if(!this.observers)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=ie(e,t,r);this.observers.push(n);var o=new oe(this.handleUnsubscribe,n);return 1===this.observers.length&&this.refresh(),o},e.prototype.expandPatterns=function(e){return le(this,void 0,void 0,function(){var t;return he(this,function(r){switch(r.label){case 0:return this.options.expandPattern?[4,this.options.expandPattern(e,this.router)]:[3,2];case 1:if(t=r.sent())return[2,t];r.label=2;case 2:return[2,[e].filter(function(e){return!/\/:/.test(e)})]}})})},e.prototype.removeFromQueue=function(e){var t=this.mapItems.indexOf(e);-1!==t&&this.mapItems.splice(t,1)},e.prototype.addToQueue=function(e,t,r,n,o){if(void 0===o&&(o=[0]),!this.seenPathnames.has(e)&&(!this.options.maxDepth||t<=this.options.maxDepth)){this.seenPathnames.add(e);var i=s(e,{ensureTrailingSlash:!1,removeHash:!0}),a=D(U(this.rootContext,{body:null,headers:this.options.headers||{},method:this.options.method||"HEAD",params:{},hostname:this.options.hostname||"",mountpath:"",query:i.query,search:i.search,router:this.router,path:i.pathname,url:i.pathname+i.search,originalUrl:i.href}),this.rootMapping,this.rootContext);a&&this.mapItems.push({url:i,fromPathname:n,depth:t,pathname:e,order:o,walkedPatternLists:new Set(r),matcherIterator:this.matcherGeneratorFunction(a,this.rootContext)})}},e}();function be(e){return"busy"===e.type}function de(e){return e.promise}var ye=function(){return(ye=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function ve(e,t){return e=function(e,t){if(e){if("url"===t.type)return ye({},e,{chunks:e.chunks.filter(function(e){return"url"!==e.type}),url:t.url});if("ready"!==e.type)return e}var r={lastChunk:t,chunks:e?e.chunks.concat(t):[t],data:e?e.data:{},headers:e?e.headers:{},heads:e?e.heads:[],status:e?e.status:200,title:e&&e.title,url:e?e.url:t.url,views:e?e.views:[]};switch(t.type){case"busy":return ye({},r,{type:"busy"});case"data":return ye({},r,{type:"ready",data:ye({},r.data,t.data)});case"error":return ye({},r,{type:"error",error:t.error,status:r.status&&r.status>=400?r.status:t.error.status||500});case"head":return ye({},r,{type:"ready",heads:r.heads.concat(t.head)});case"headers":return ye({},r,{type:"ready",headers:ye({},r.headers,t.headers)});case"redirect":return ye({},r,{type:"redirect",to:t.to});case"status":return ye({},r,{type:"ready",status:t.status});case"title":return ye({},r,{type:"ready",title:t.title});case"view":return ye({},r,{type:"ready",views:r.views.concat(t.view)});default:return ye({},r,{type:"ready"})}}(e,t),Object.defineProperties(e,{meta:{configurable:!0,get:function(){return e.data}},content:{configurable:!0,get:function(){return t.view}},segments:{configurable:!0,get:function(){return e.chunks}},lastSegment:{configurable:!0,get:function(){return e.lastChunk}}}),e}var me=function(){function e(e){this.context=e.context||{},this.matcherGenerator=e.routes(),this.reducer=e.reducer||ve;var t,r,n=e.basename;n&&"/"===n.slice(-1)&&(n=n.slice(0,-1)),this.rootMapping=(t=e.routes,void 0===(r=n)&&(r=""),""!==r?M(r,t):{pattern:r,key:"",regExp:new RegExp(""),matcher:t})}return e.prototype.setContext=function(e){this.context=e||{}},e.prototype.createObservable=function(e,t){void 0===t&&(t={}),e.hash&&delete(e=Object.assign({},e)).hash;var r=D(U(this.context,{body:t.body,headers:t.headers||{},method:t.method||"GET",hostname:e.hostname,mountpath:"",params:e.query,query:e.query,search:e.search,router:this,url:e.pathname+e.search,originalUrl:e.href,path:e.pathname}),this.rootMapping,this.context);if(r)return new se(e,r,this.context,this.matcherGenerator)},e.prototype.createMapObservable=function(e,t){return void 0===t&&(t={}),new pe(s(e,{ensureTrailingSlash:!1}),this.context,this.matcherGenerator,this.rootMapping,this,t)},e.prototype.resolve=function(e,t){var r,n=this;if(void 0===t&&(t={}),Array.isArray(e))r=e.map(function(e){return s(e)});else if("string"==typeof e)r=[s(e)];else if(e.url)r=[s((t=e).url)];else{if(!t)throw new Error("You must specify a URL for router.resolve().");r=[s(e)]}if(!r.length)return Promise.resolve([]);var o=r.map(function(e){return n.getPageRoutePromise(e,t)});return Array.isArray(e)?Promise.all(o):o[0]},e.prototype.resolveSiteMap=function(e,t){var r=this;return void 0===t&&(t={}),ae(this.createMapObservable(e,t)).then(function(e){for(var t={},n={},o=Object.keys(e),i=0;i<o.length;i++){var a=o[i],u=e[a],c=u[u.length-1];"redirect"!==c.type?t[a]=[{type:"url",url:s(a)}].concat(u).reduce(r.reducer,void 0):n[a]=c.to}return{routes:t,redirects:n}})},e.prototype.resolveRouteMap=function(e,t){return void 0===t&&(t={}),this.resolveSiteMap(e,t).then(function(e){return e.routes})},e.prototype.getPageRoutePromise=function(e,t){var r=this,n=this.createObservable(e,t);return n?ae(n).then(function(n){for(var o=0;o<n.length;o++){var i=n[o];if("busy"===i.type)break;if("redirect"===i.type&&t.followRedirects)return r.getPageRoutePromise(s(i.to),t);if("error"===i.type)throw i.error}return[{type:"url",url:s(e)}].concat(n).reduce(r.reducer,void 0)}):Promise.reject(new d(e))},e}(),we=function(){return function(){this.promise=new Promise(function(e,t){this.resolve=e,this.reject=t}.bind(this)),Object.freeze(this)}}(),ge=function(){return(ge=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},xe=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Se=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Re=function(){function e(e,t,r,n){var o=this;this.handleUnsubscribe=function(e){var t=o.observers.indexOf(e);-1!==t&&o.observers.splice(t,1)},this.handleChunkList=function(e){for(var t=!0,r=0;r<e.length;r++){var n=e[r];if("busy"===n.type&&(t=!1),"redirect"===n.type)return void o.history.replace(n.to)}o.setRoute([{type:"url",url:o.lastURL}].concat(e).reduce(o.reducer,void 0),t)},this.observers=[],this.isLastRouteSteady=!1,this.router=t,this.history=e,this.reducer=r,this.resolveOptions=n,this.lastURL=s(this.history.location),this.unlisten=this.history.listen(function(e){return o.handleURLChange(s(e))}),this.refresh()}return e.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},e.prototype.refresh=function(){this.handleURLChange(s(this.history.location),!0)},e.prototype.setContext=function(e){this.router.setContext(e),this.refresh()},e.prototype.getValue=function(){return this.lastRoute},e.prototype.getSteadyRoute=function(){return xe(this,void 0,void 0,function(){return Se(this,function(e){return this.isLastRouteSteady?[2,Promise.resolve(this.lastRoute)]:(this.waitUntilSteadyDeferred||(this.waitUntilSteadyDeferred=new we),[2,this.waitUntilSteadyDeferred.promise])})})},e.prototype.subscribe=function(e,t,r){var n=ie(e,t,r);return this.observers.push(n),new oe(this.handleUnsubscribe,n)},e.prototype.handleURLChange=function(e,t){if(!t&&this.lastReceivedURL&&i(this.lastReceivedURL,e))for(var r=0;r<this.observers.length;r++)this.observers[r].next(this.lastRoute);else{if(this.lastReceivedURL=e,"/"!==e.pathname.substr(-1))return e=ge({},e,{pathname:e.pathname+"/"}),void this.history.replace(e);var n,o,a=this.lastURL;if(this.lastURL=e,e&&a&&(n=e.pathname!==a.pathname,o=e.search!==a.search),t||n||o||!this.lastRoute){this.observableSubscription&&this.observableSubscription.unsubscribe();var s=this.router.createObservable(e,this.resolveOptions);if(s)this.observableSubscription=s.subscribe(this.handleChunkList);else if(!a)throw new d(e)}else e.hash!==a.hash&&this.setRoute(this.reducer(this.lastRoute,{type:"url",url:e}),this.isLastRouteSteady)}},e.prototype.setRoute=function(e,t){if(e!==this.lastRoute){this.lastRoute=e,this.isLastRouteSteady=t,t&&this.waitUntilSteadyDeferred&&(this.waitUntilSteadyDeferred.resolve(e),delete this.waitUntilSteadyDeferred);for(var r=0;r<this.observers.length;r++)this.observers[r].next(e)}},e}(),ke=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Oe=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};var Pe=function(){function e(e){e.pages&&(e.routes=e.pages);var r=e.reducer||ve;this.history=e.history||t.createBrowserHistory(),this.router=new me({context:e.context,routes:e.routes,basename:e.basename,reducer:r}),this.currentRouteObservable=new Re(this.history,this.router,r)}return e.prototype.dispose=function(){this.currentRouteObservable.dispose(),delete this.currentRouteObservable,delete this.router,delete this.history},e.prototype.setContext=function(e){this.currentRouteObservable.setContext(e)},e.prototype.getCurrentValue=function(){return this.currentRouteObservable.getValue()},e.prototype.getSteadyValue=function(){return this.currentRouteObservable.getSteadyRoute()},e.prototype.steady=function(){return ke(this,void 0,void 0,function(){return Oe(this,function(e){switch(e.label){case 0:return[4,this.getSteadyValue()];case 1:return e.sent(),[2]}})})},e.prototype.subscribe=function(e,t,r){var n=ie(e,t,r);return this.currentRouteObservable.subscribe(n)},e}(),je=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Ee=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};var Ce=function(){function e(e){e.pages&&(e.routes=e.pages);var r=e.reducer||ve,n=e.url||e.request&&e.request.url;if(!n)throw new Error("createMemoriNavigation() could not find a URL.");this.history=t.createMemoryHistory({initialEntries:[s(n).href]}),this.options=e,this.router=new me({context:e.context,routes:this.options.routes||this.options.pages,basename:this.options.basename,reducer:r}),this.currentRouteObservable=new Re(this.history,this.router,r,e.request)}return e.prototype.dispose=function(){this.currentRouteObservable.dispose(),delete this.currentRouteObservable,delete this.router,delete this.options},e.prototype.setContext=function(e){this.currentRouteObservable.setContext(e)},e.prototype.getCurrentValue=function(){return this.currentRouteObservable.getValue()},e.prototype.getSteadyValue=function(){return this.currentRouteObservable.getSteadyRoute()},e.prototype.steady=function(){return je(this,void 0,void 0,function(){return Ee(this,function(e){switch(e.label){case 0:return[4,this.getSteadyValue()];case 1:return e.sent(),[2]}})})},e.prototype.subscribe=function(e,t,r){var n=ie(e,t,r);return this.currentRouteObservable.subscribe(n)},e}();e.compose=o,e.Router=me,e.createRouter=function(e){return new me(e)},e.defaultRouteReducer=ve,e.concatMatcherIterators=R,e.resolveChunks=g,e.createBrowserNavigation=function(e){return new Pe(e)},e.BrowserNavigation=Pe,e.createMemoryNavigation=function(e){return new Ce(e)},e.MemoryNavigation=Ce,e.lazy=L,e.map=L,e.createPage=function(e){return Object.assign(o(V(Z(e)),Q(function(e,t){return t.meta}),F(function(e,t){return t.title}),j(function(e,t){return t.content})),{isDeprecatedMatcher:!0})},e.createContext=function(e,t){return Object.assign(V(e,t.isDeprecatedMatcher?t:L(t)),{isDeprecatedMatcher:!0})},e.createSwitch=function(e){var t,r,n={};try{for(var i=Y(Object.keys(e.paths)),a=i.next();!a.done;a=i.next()){var s=a.value,u=e.paths[s];n[s]=u.isDeprecatedMatcher?u:L(u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}if(1===Object.keys(e).length)return Object.assign(q(n),{isDeprecatedMatcher:!0});e.paths;var c=B(e,["paths"]);return Object.assign(o(V(Z(c)),Q(function(e,t){return t.meta}),F(function(e,t){return t.title}),j(function(e,t){return t.content}),q(n)),{isDeprecatedMatcher:!0})},e.createRedirect=function(e,t){var r=_(e);return t?o(Q(t),r):r},e.mount=q,e.redirect=_,e.route=function(e){if(void 0===e&&(e={}),"function"!=typeof e){var t=e.data,r=e.getData,n=e.head,i=e.getHead,a=e.headers,s=e.getHeaders,u=e.status,c=e.getStatus,l=e.title,h=e.getTitle,f=e.view,p=e.getView;re(e,["data","getData","head","getHead","headers","getHeaders","status","getStatus","title","getTitle","view","getView"]),e=function(e,o){return ee(this,void 0,void 0,function(){var b,d,y,v,m,w,g;return te(this,function(S){switch(S.label){case 0:return b=r?Promise.resolve(r(e,o,void 0)).then(x).then(ne):Promise.resolve(t||{}),d=s?Promise.resolve(s(e,o,b)).then(x):Promise.resolve(a),y=c?Promise.resolve(c(e,o,b)).then(x):Promise.resolve(u),v=h?Promise.resolve(h(e,o,b)).then(x):Promise.resolve(l),"HEAD"!==e.method&&(m=i?Promise.resolve(i(e,o,b)).then(x):Promise.resolve(n),w=p?Promise.resolve(p(e,o,b)).then(x):Promise.resolve(f)),g={},[4,b];case 1:return g.data=S.sent(),[4,m];case 2:return g.head=S.sent(),[4,d];case 3:return g.headers=S.sent(),[4,y];case 4:return g.status=S.sent(),[4,v];case 5:return g.title=S.sent(),[4,w];case 6:return[2,(g.view=S.sent(),g)]}})})}}return o(V(e),Q(function(e,t){return t.data}),K(function(e,t){return t.head}),W(function(e,t){return t.headers}),X(function(e,t){return t.status}),F(function(e,t){return t.title}),j(function(e,t){return t.view}))},e.withContext=V,e.withData=Q,e.withHead=K,e.withHeaders=W,e.withStatus=X,e.withTitle=F,e.withView=j,e.NaviError=p,e.NotFoundError=b,e.OutOfRootError=d,e.createRequest=U,e.createChunk=y,e.createNotFoundChunk=v,e.areURLDescriptorsEqual=i,e.createURLDescriptor=s,e.parseQuery=u,e.stringifyQuery=c,e.joinPaths=l,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("history")):"function"==typeof define&&define.amd?define(["exports","history"],t):t((e=e||self).Navi={},e.History)}(this,function(e,t){"use strict";var r=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},n=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e};function o(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("composeMatchers() expects at least one matcher.");return 1===e.length?e[0]:e.reduce(function(e,t){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return e(t.apply(void 0,n(r)))}})}function i(e,t){return e==t||!(!e||!t)&&(e.pathname==t.pathname&&e.search==t.search&&e.hash==t.hash&&e.state==t.state)}var a=/((((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;function s(e,t){var r,n,o,i,s,l,h=void 0===t?{}:t,f=h.ensureTrailingSlash,p=void 0===f||f,b=h.removeHash,d=void 0!==b&&b;if("string"==typeof e){var y=a.exec(e);if(!y)throw new Error("Couldn't parse the provided URL.");r="",n=y[2]||"",o=u(i=y[6]||""),s=y[7]||""}else r=e.hostname||"",n=e.pathname||"",o=e.query||(e.search?u(e.search):{}),i=e.search||c(o),s=e.hash||"",l=e.state;return p&&n.length&&"/"!==n.substr(-1)&&(n+="/"),{hostname:r,pathname:n,query:o,search:i,hash:d?"":s,href:n+i+s,state:l}}function u(e,t){if(void 0===t&&(t="?"),!e||e[0]!=t)return{};for(var r={},n=e.slice(1).split("&"),o=0,i=n.length;o<i;o++){var a=n[o].split("=");r[a[0]]=a[1]?decodeURIComponent(a[1]):""}return r}function c(e,t){void 0===t&&(t="?");var r=Object.keys(e);if(0===r.length)return"";for(var n=[],o=0,i=r.length;o<i;o++){var a=r[o],s=String(e[a]);n.push(""===s?a:a+"="+encodeURIComponent(s))}return t+n.join("&")}function l(e,t){return t?("/"===e[e.length-1]&&(e=e.substr(0,e.length-1)),"/"===t[0]&&(t=t.substr(1)),e+"/"+t):e}var h,f=(h=function(e,t){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),p=function(e){function t(t){var r=this,n=this.constructor.prototype;return(r=e.call(this,t)||this).__proto__=n,Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(r,r.constructor):Object.defineProperty(r,"stack",{value:(new Error).stack}),Object.defineProperty(r,"message",{value:t}),r}return f(t,e),t}(Error),b=function(e){function t(t){var r=e.call(this,"URL not found: "+t)||this;return r.pathname=t,r.status=404,r.name="NotFoundError",r}return f(t,e),t}(p),d=function(e){function t(t){var r=e.call(this,"URL not managed by router: "+t.href)||this;return r.url=t,r.name="OutOfRootError",r}return f(t,e),t}(p);function y(e,t,r,n){return void 0===n&&(n=!0),Object.assign({type:e,url:s({pathname:t.mountpath,query:t.query},{ensureTrailingSlash:n})},r)}function v(e){var t=l(e.mountpath,e.path);return{type:"error",url:s({pathname:t,query:e.query}),error:new b(t)}}var m=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},w=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function g(e,t,r,n){var o,i,a,s,u,c,h;return m(this,function(f){switch(f.label){case 0:o="function"==typeof e?e:function(){return e};try{i=o(t,r)}catch(e){i=Promise.reject(e)}return(p=i)&&p.then?[3,1]:(a=n(i),[3,7]);case 1:s=i.then(x),u=function(e){var t={};return e.then(function(e){t.value=e,t.outcome="resolved"},function(e){t.error=e,t.outcome="rejected"}),t}(s),c=[y("busy",t,{promise:s})],f.label=2;case 2:return u.outcome?[3,4]:[4,c];case 3:return f.sent(),[3,2];case 4:return"rejected"!==u.outcome?[3,6]:((h=u.error)instanceof b&&!h.pathname&&(h.pathname=l(t.mountpath,t.path)),[4,[y("error",t,{error:h})]]);case 5:return f.sent(),[3,7];case 6:a=n(u.value),f.label=7;case 7:return a?Array.isArray(a)?[4,a.length?a:[]]:[3,9]:[3,11];case 8:return f.sent(),[3,11];case 9:return[5,w(a)];case 10:f.sent(),f.label=11;case 11:return[2]}var p})}function x(e){return function(e){return e&&"object"==typeof e&&"default"in e}(e)?e.default:e}var S=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};function R(e,t,r,n){return void 0===n&&(n=""),e(t,r)}function k(e,t){var r,n,o,i;return S(this,function(a){switch(a.label){case 0:o=[],i=[],a.label=1;case 1:return(r=e.next()).done||(o=r.value||[]),(n=t.next()).done||(i=n.value||[]),[4,o.concat(i)];case 2:a.sent(),a.label=3;case 3:if(!r.done||!n.done)return[3,1];a.label=4;case 4:return[2]}})}var O=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},P=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function j(e,t,r,n){function o(t,o,i){var a,s;return O(this,function(u){switch(u.label){case 0:return a=t.path,i||!a||"/"===a?[3,2]:[4,[v(t)]];case 1:return u.sent(),[3,4];case 2:return s=n&&!n(t)?function(){return O(this,function(e){switch(e.label){case 0:return[4,[]];case 1:return e.sent(),[2]}})}():g(e,t,o,function(e){return r(e,t)}),[5,P(i?k(s,R(i,t,o)):s)];case 3:u.sent(),u.label=4;case 4:return[2]}})}return function(e){return function(r,n){return o(r,n,t?t():e)}}}function E(e,t){return j(e,t,function(e,t){return e?[y("view",t,{view:e})]:[]},function(e){return"HEAD"!==e.method})}var C=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},L=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function U(e){return function(){return function(t,r){return C(this,function(n){switch(n.label){case 0:return[5,L(g(e,t,r,function(e){return R(e(),t,r)}))];case 1:return n.sent(),[2]}})}}}function I(e,t){return Object.defineProperties(t,{mountname:{get:function(){return t.mountpath}},pathname:{get:function(){return t.mountpath}},context:{get:function(){return e}}}),t}var T=function(){return(T=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},M="\0";function D(e,t){var r=e;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=[],i=[],a=["^"],s=0;s<n.length;s++){var u=n[s];u.length>1&&":"===u[0]?(o.push(u.slice(1)),i.push(M),a.push("([^/]+)")):(i.push(u),a.push(u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}return{key:i.join("/"),matcher:t,pattern:r,pathParamNames:o.length?o:void 0,regExp:new RegExp(a.join("/"))}}function G(e,t,r){var n=t.regExp.exec(e.path);if(n){var o=n[0],i=e.params;if(t.pathParamNames){i=T({},e.params);for(var a=0;a<t.pathParamNames.length;a++){i[t.pathParamNames[a]]=n[a+1]}}var s=e.path.slice(o.length)||"/",u=l(e.mountpath,o);return I(r,T({},e,{params:i,mountpath:u,path:s,url:s+e.search}))}}var q=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};function H(e){if(!e)throw new Error("mount() must be supplied with a paths object.");var t=Object.keys(e),r=t.map(function(t){return D(t,e[t])}).sort(function(e,t){return r=e.key,n=t.key,r<n?-1:r>n?1:0;var r,n});return function(){return function(e,n){var o,i,a,s,u,c,l;return q(this,function(h){switch(h.label){case 0:for(s=r.length-1;s>=0;s--)if(u=r[s],c=G(e,u,n)){i=R(u.matcher(),c,n,u.pattern);break}h.label=1;case 1:return!i||a&&a.done||(a=i.next()),o=[y("mount",e,{patterns:t},!1)],(l=a&&a.value)?o=o.concat(l.length?l:[]):o.push(v(e)),[4,o];case 2:h.sent(),h.label=3;case 3:if(o.filter(_).length)return[3,1];h.label=4;case 4:return[2]}})}}}function _(e){return"busy"===e.type}function N(e){return j(e,void 0,function(e,t){var r,n=t.path;return n&&"/"!==n?[v(t)]:("string"==typeof e?r="./"===e.slice(0,2)?l(t.mountpath.split("/").slice(0,-1).join("/"),e.slice(2)):e:e&&(r=s(e).href),r?[y("redirect",t,{to:r})]:[])})}var A=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},V=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function Q(e,t){return function(r){return function(n,o){return function(t,r,n){return A(this,function(o){switch(o.label){case 0:return[5,V(g(e,t,r,function(e){return R(n,t,e||{})}))];case 1:return o.sent(),[2]}})}(n,o,t?t():r)}}}function F(e,t){return j(e,t,function(e,t){return e?[y("data",t,{data:e})]:[]})}function $(e,t){return j(e,t,function(e,t){return e?[y("title",t,{title:e})]:[]})}var z=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},B=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Y=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r},Z=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};function J(e){return function(t,r){return z(this,void 0,void 0,function(){var n,o,i,a;return B(this,function(s){switch(s.label){case 0:return n=e.getMeta?Promise.resolve(e.getMeta(t,r,void 0)).then(x).then(K):Promise.resolve(e.meta||{}),o=e.getTitle?Promise.resolve(e.getTitle(t,r,n)).then(x):Promise.resolve(e.title),"HEAD"!==t.method&&(i=e.getContent?Promise.resolve(e.getContent(t,r,n)).then(x):Promise.resolve(e.content)),a={},[4,n];case 1:return a.meta=s.sent(),[4,i];case 2:return a.content=s.sent(),[4,o];case 3:return[2,(a.title=s.sent(),a)]}})})}}function K(e){return e||{}}function W(e,t){return j(e,t,function(e,t){return e?[y("head",t,{head:e})]:[]},function(e){return"HEAD"!==e.method})}function X(e,t){return j(e,t,function(e,t){return e?[y("headers",t,{headers:e})]:[]})}function ee(e,t){return j(e,t,function(e,t){return e?[y("status",t,{status:e})]:[]})}var te=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},re=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},ne=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&(r[n[o]]=e[n[o]])}return r};function oe(e){return e||{}}var ie=function(){function e(e,t){this.close=e,this.observer=t,this.observer.start&&this.observer.start(this)}return e.prototype.unsubscribe=function(){this.closed||(this.closed=!0,this.close(this.observer),delete this.close,delete this.observer)},e}();function ae(e,t,r){return"function"==typeof e?{next:e,error:t,complete:r}:e}function se(e){return new Promise(function(t,r){e.subscribe({start:function(e){this.subscription=e},next:function(e){this.value=e},complete:function(){t(this.value),this.subscription.unsubscribe()},error:function(e){r(e),this.subscription.unsubscribe()}})})}var ue=function(){function e(e,t,r,n){var o=this;this.handleUnsubscribe=function(e){var t=o.observers.indexOf(e);-1!==t&&o.observers.splice(t,1)},this.handleChange=function(e){if(e===o.lastListenId){o.lastListenId++,o.refresh();for(var t=o.result.done||o.result.value.every(function(e){return"busy"!==e.type}),r=0;r<o.observers.length;r++){var n=o.observers[r];n.next(o.result.value),t&&n.complete&&n.complete()}t&&delete o.matcherIterator}},this.refresh=function(){var e=o.matcherIterator.next();if(e.value&&(o.result=e),!o.result.done){var t=++o.lastListenId,r=function(){return o.handleChange(t)};Promise.race(o.result.value.filter(ce).map(le)).then(r,r)}},this.url=e,this.lastListenId=0,this.observers=[],this.matcherIterator=n(t,r)}return e.prototype.subscribe=function(e,t,r){if(!this.matcherIterator)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=ae(e,t,r);this.observers.push(n);var o=new ie(this.handleUnsubscribe,n);return 1===this.observers.length&&this.handleChange(this.lastListenId),o},e}();function ce(e){return"busy"===e.type}function le(e){return e.promise}var he=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},fe=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},pe=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},be=function(){function e(e,t,r,n,o,i){var a=this;this.handleUnsubscribe=function(e){var t=a.observers.indexOf(e);-1!==t&&a.observers.splice(t,1)},this.handleResolverUpdate=function(e){e===a.lastListenId&&(a.lastListenId++,a.isRefreshing?a.isRefreshScheduled||(a.isRefreshScheduled=!0):a.refresh())},this.refresh=function(){return he(a,void 0,void 0,function(){var e,t,r,n,o,i,a,s,u,c,h,f,p,b,d,y,v,m,w=this;return fe(this,function(g){switch(g.label){case 0:this.isRefreshScheduled=!1,this.isRefreshing=!0,e=[],t=0,r=function(){var r,o,i,a,s,u,c,h,f,p,b;return fe(this,function(d){switch(d.label){case 0:r=n.mapItems[t],o=r.pathname,i=r.matcherIterator.next(),r.lastResult&&!i.value||(r.lastResult=i),a=r.lastResult.value,r.chunksCache=a||[],s=a.findIndex(function(e){return"error"===e.type||e.url.href.length>=r.url.href.length&&("mount"===e.type&&r.lastMountPatterns!==e.patterns||"redirect"===e.type&&r.lastRedirectTo!==e.to)}),d.label=1;case 1:if(!(s>=0&&s<a.length))return[3,6];if(u=a[s],s++,"error"===u.type||n.options.predicate&&!n.options.predicate(u,a))return n.removeFromQueue(r),[2,"continue-items"];if("redirect"===u.type&&(r.lastRedirectTo=u.to,n.options.followRedirects&&n.addToQueue(u.to,r.depth+1,r.walkedPatternLists,o,r.order)),"mount"!==u.type)return[3,5];if(c=u.patterns,r.lastMountPatterns=c,h=c.slice(0).sort().join("\n"),!c||r.walkedPatternLists.has(h))return[3,5];r.walkedPatternLists.add(h),f=0,d.label=2;case 2:return f<c.length?[4,n.expandPatterns(l(o,c[f]))]:[3,5];case 3:for(p=d.sent(),b=0;b<p.length;b++)n.addToQueue(p[b],r.depth+1,r.walkedPatternLists,o,r.order.concat(f,b));d.label=4;case 4:return f++,[3,2];case 5:return[3,1];case 6:return a&&(e=e.concat(a)),t++,[2]}})},n=this,g.label=1;case 1:return this.mapItems&&t<this.mapItems.length?[5,r()]:[3,3];case 2:switch(g.sent()){case"continue-items":return[3,1]}return[3,1];case 3:if(!this.mapItems)return[2];for(o=[],i=0;i<this.mapItems.length;i++)a=this.mapItems[i],"mount"===(s=a.chunksCache[a.chunksCache.length-1]).type||"error"===s.type||"busy"!==s.type&&this.options.predicate&&!this.options.predicate(s,a.chunksCache)||o.push([l(a.pathname,"/"),a.chunksCache,a.order]);if(u=++this.lastListenId,c=function(){return w.handleResolverUpdate(u)},Promise.race(e.filter(de).map(ye)).then(c,c),o.sort(function(e,t){var r=e[2],n=t[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(h={},f=!0,p=0;p<o.length;p++)b=pe(o[p],2),d=b[0],(y=b[1]).some(function(e){return"busy"===e.type})&&(f=!1),h[d]=y;for(v=0;v<this.observers.length;v++)(m=this.observers[v]).next(h),f&&m.complete&&m.complete();f&&(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=t,this.matcherGeneratorFunction=r,this.rootMapping=n,this.options=i,this.seenPathnames=new Set;var s=e.pathname;"/"===s.substr(-1)&&(s=s.substr(0,s.length-1)),this.addToQueue(s,0,new Set)}return e.prototype.subscribe=function(e,t,r){if(!this.observers)throw new Error("Can't subscribe to an already-complete RoutingObservable.");var n=ae(e,t,r);this.observers.push(n);var o=new ie(this.handleUnsubscribe,n);return 1===this.observers.length&&this.refresh(),o},e.prototype.expandPatterns=function(e){return he(this,void 0,void 0,function(){var t;return fe(this,function(r){switch(r.label){case 0:return this.options.expandPattern?[4,this.options.expandPattern(e,this.router)]:[3,2];case 1:if(t=r.sent())return[2,t];r.label=2;case 2:return[2,[e].filter(function(e){return!/\/:/.test(e)})]}})})},e.prototype.removeFromQueue=function(e){var t=this.mapItems.indexOf(e);-1!==t&&this.mapItems.splice(t,1)},e.prototype.addToQueue=function(e,t,r,n,o){if(void 0===o&&(o=[0]),!this.seenPathnames.has(e)&&(!this.options.maxDepth||t<=this.options.maxDepth)){this.seenPathnames.add(e);var i=s(e,{ensureTrailingSlash:!1,removeHash:!0}),a=G(I(this.rootContext,{body:null,headers:this.options.headers||{},method:this.options.method||"HEAD",params:{},hostname:this.options.hostname||"",mountpath:"",query:i.query,search:i.search,router:this.router,path:i.pathname,url:i.pathname+i.search,originalUrl:i.href}),this.rootMapping,this.rootContext);a&&this.mapItems.push({url:i,fromPathname:n,depth:t,pathname:e,order:o,walkedPatternLists:new Set(r),matcherIterator:this.matcherGeneratorFunction(a,this.rootContext)})}},e}();function de(e){return"busy"===e.type}function ye(e){return e.promise}var ve=function(){return(ve=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function me(e,t){return e=function(e,t){if(e){if("url"===t.type)return ve({},e,{chunks:e.chunks.filter(function(e){return"url"!==e.type}),url:t.url});if("ready"!==e.type)return e}var r={lastChunk:t,chunks:e?e.chunks.concat(t):[t],data:e?e.data:{},headers:e?e.headers:{},heads:e?e.heads:[],status:e?e.status:200,title:e&&e.title,url:e?e.url:t.url,views:e?e.views:[]};switch(t.type){case"busy":return ve({},r,{type:"busy"});case"data":return ve({},r,{type:"ready",data:ve({},r.data,t.data)});case"error":return ve({},r,{type:"error",error:t.error,status:r.status&&r.status>=400?r.status:t.error.status||500});case"head":return ve({},r,{type:"ready",heads:r.heads.concat(t.head)});case"headers":return ve({},r,{type:"ready",headers:ve({},r.headers,t.headers)});case"redirect":return ve({},r,{type:"redirect",to:t.to});case"status":return ve({},r,{type:"ready",status:t.status});case"title":return ve({},r,{type:"ready",title:t.title});case"view":return ve({},r,{type:"ready",views:r.views.concat(t.view)});default:return ve({},r,{type:"ready"})}}(e,t),Object.defineProperties(e,{meta:{configurable:!0,get:function(){return e.data}},content:{configurable:!0,get:function(){return t.view}},segments:{configurable:!0,get:function(){return e.chunks}},lastSegment:{configurable:!0,get:function(){return e.lastChunk}}}),e}var we=function(){function e(e){this.context=e.context||{},this.matcherGenerator=e.routes(),this.reducer=e.reducer||me;var t,r,n=e.basename;n&&"/"===n.slice(-1)&&(n=n.slice(0,-1)),this.rootMapping=(t=e.routes,void 0===(r=n)&&(r=""),""!==r?D(r,t):{pattern:r,key:"",regExp:new RegExp(""),matcher:t})}return e.prototype.setContext=function(e){this.context=e||{}},e.prototype.createObservable=function(e,t){void 0===t&&(t={}),e.hash&&delete(e=Object.assign({},e)).hash;var r=G(I(this.context,{body:t.body,headers:t.headers||{},method:t.method||"GET",hostname:e.hostname,mountpath:"",params:e.query,query:e.query,search:e.search,router:this,url:e.pathname+e.search,originalUrl:e.href,path:e.pathname}),this.rootMapping,this.context);if(r)return new ue(e,r,this.context,this.matcherGenerator)},e.prototype.createMapObservable=function(e,t){return void 0===t&&(t={}),new be(s(e,{ensureTrailingSlash:!1}),this.context,this.matcherGenerator,this.rootMapping,this,t)},e.prototype.resolve=function(e,t){var r,n=this;if(void 0===t&&(t={}),Array.isArray(e))r=e.map(function(e){return s(e)});else if("string"==typeof e)r=[s(e)];else if(e.url)r=[s((t=e).url)];else{if(!t)throw new Error("You must specify a URL for router.resolve().");r=[s(e)]}if(!r.length)return Promise.resolve([]);var o=r.map(function(e){return n.getPageRoutePromise(e,t)});return Array.isArray(e)?Promise.all(o):o[0]},e.prototype.resolveSiteMap=function(e,t){var r=this;return void 0===t&&(t={}),se(this.createMapObservable(e,t)).then(function(e){for(var t={},n={},o=Object.keys(e),i=0;i<o.length;i++){var a=o[i],u=e[a],c=u[u.length-1];"redirect"!==c.type?t[a]=[{type:"url",url:s(a)}].concat(u).reduce(r.reducer,void 0):n[a]=c.to}return{routes:t,redirects:n}})},e.prototype.resolveRouteMap=function(e,t){return void 0===t&&(t={}),this.resolveSiteMap(e,t).then(function(e){return e.routes})},e.prototype.getPageRoutePromise=function(e,t){var r=this,n=this.createObservable(e,t);return n?se(n).then(function(n){for(var o=0;o<n.length;o++){var i=n[o];if("busy"===i.type)break;if("redirect"===i.type&&t.followRedirects)return r.getPageRoutePromise(s(i.to),t);if("error"===i.type)throw i.error}return[{type:"url",url:s(e)}].concat(n).reduce(r.reducer,void 0)}):Promise.reject(new d(e))},e}(),ge=function(){return function(){this.promise=new Promise(function(e,t){this.resolve=e,this.reject=t}.bind(this)),Object.freeze(this)}}(),xe=function(){return(xe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Se=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Re=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},ke=function(){function e(e,t,r,n){var o=this;this.handleUnsubscribe=function(e){var t=o.observers.indexOf(e);-1!==t&&o.observers.splice(t,1)},this.handleChunkList=function(e){for(var t=!0,r=0;r<e.length;r++){var n=e[r];if("busy"===n.type&&(t=!1),"redirect"===n.type)return void o.history.replace(n.to)}o.setRoute([{type:"url",url:o.lastURL}].concat(e).reduce(o.reducer,void 0),t)},this.observers=[],this.isLastRouteSteady=!1,this.router=t,this.history=e,this.reducer=r,this.resolveOptions=n,this.lastURL=s(this.history.location),this.unlisten=this.history.listen(function(e){return o.handleURLChange(s(e))}),this.refresh()}return e.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},e.prototype.refresh=function(){this.handleURLChange(s(this.history.location),!0)},e.prototype.setContext=function(e){this.router.setContext(e),this.refresh()},e.prototype.getValue=function(){return this.lastRoute},e.prototype.getSteadyRoute=function(){return Se(this,void 0,void 0,function(){return Re(this,function(e){return this.isLastRouteSteady?[2,Promise.resolve(this.lastRoute)]:(this.waitUntilSteadyDeferred||(this.waitUntilSteadyDeferred=new ge),[2,this.waitUntilSteadyDeferred.promise])})})},e.prototype.subscribe=function(e,t,r){var n=ae(e,t,r);return this.observers.push(n),new ie(this.handleUnsubscribe,n)},e.prototype.handleURLChange=function(e,t){if(!t&&this.lastReceivedURL&&i(this.lastReceivedURL,e))for(var r=0;r<this.observers.length;r++)this.observers[r].next(this.lastRoute);else{if(this.lastReceivedURL=e,"/"!==e.pathname.substr(-1))return e=xe({},e,{pathname:e.pathname+"/"}),void this.history.replace(e);var n,o,a=this.lastURL;if(this.lastURL=e,e&&a&&(n=e.pathname!==a.pathname,o=e.search!==a.search),t||n||o||!this.lastRoute){this.observableSubscription&&this.observableSubscription.unsubscribe();var s=this.router.createObservable(e,this.resolveOptions);if(s)this.observableSubscription=s.subscribe(this.handleChunkList);else if(!a)throw new d(e)}else e.hash!==a.hash&&this.setRoute(this.reducer(this.lastRoute,{type:"url",url:e}),this.isLastRouteSteady)}},e.prototype.setRoute=function(e,t){if(e!==this.lastRoute){this.lastRoute=e,this.isLastRouteSteady=t,t&&this.waitUntilSteadyDeferred&&(this.waitUntilSteadyDeferred.resolve(e),delete this.waitUntilSteadyDeferred);for(var r=0;r<this.observers.length;r++)this.observers[r].next(e)}},e}(),Oe=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Pe=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};var je=function(){function e(e){e.pages&&(e.routes=e.pages);var r=e.reducer||me;this.history=e.history||t.createBrowserHistory(),this.router=new we({context:e.context,routes:e.routes,basename:e.basename,reducer:r}),this.currentRouteObservable=new ke(this.history,this.router,r)}return e.prototype.dispose=function(){this.currentRouteObservable.dispose(),delete this.currentRouteObservable,delete this.router,delete this.history},e.prototype.setContext=function(e){this.currentRouteObservable.setContext(e)},e.prototype.getCurrentValue=function(){return this.currentRouteObservable.getValue()},e.prototype.getSteadyValue=function(){return this.currentRouteObservable.getSteadyRoute()},e.prototype.steady=function(){return Oe(this,void 0,void 0,function(){return Pe(this,function(e){switch(e.label){case 0:return[4,this.getSteadyValue()];case 1:return e.sent(),[2]}})})},e.prototype.subscribe=function(e,t,r){var n=ae(e,t,r);return this.currentRouteObservable.subscribe(n)},e}(),Ee=function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?o(e.value):new r(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Ce=function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};var Le=function(){function e(e){e.pages&&(e.routes=e.pages);var r=e.reducer||me,n=e.url||e.request&&e.request.url;if(!n)throw new Error("createMemoriNavigation() could not find a URL.");this.history=t.createMemoryHistory({initialEntries:[s(n).href]}),this.options=e,this.router=new we({context:e.context,routes:this.options.routes||this.options.pages,basename:this.options.basename,reducer:r}),this.currentRouteObservable=new ke(this.history,this.router,r,e.request)}return e.prototype.dispose=function(){this.currentRouteObservable.dispose(),delete this.currentRouteObservable,delete this.router,delete this.options},e.prototype.setContext=function(e){this.currentRouteObservable.setContext(e)},e.prototype.getCurrentValue=function(){return this.currentRouteObservable.getValue()},e.prototype.getSteadyValue=function(){return this.currentRouteObservable.getSteadyRoute()},e.prototype.steady=function(){return Ee(this,void 0,void 0,function(){return Ce(this,function(e){switch(e.label){case 0:return[4,this.getSteadyValue()];case 1:return e.sent(),[2]}})})},e.prototype.subscribe=function(e,t,r){var n=ae(e,t,r);return this.currentRouteObservable.subscribe(n)},e}();e.compose=o,e.Router=we,e.createRouter=function(e){return new we(e)},e.defaultRouteReducer=me,e.concatMatcherIterators=k,e.resolveChunks=g,e.createBrowserNavigation=function(e){return new je(e)},e.BrowserNavigation=je,e.createMemoryNavigation=function(e){return new Le(e)},e.MemoryNavigation=Le,e.lazy=U,e.map=U,e.createPage=function(e){return Object.assign(o(Q(J(e)),F(function(e,t){return t.meta}),$(function(e,t){return t.title}),E(function(e,t){return t.content})),{isDeprecatedMatcher:!0})},e.createContext=function(e,t){return Object.assign(Q(e,t.isDeprecatedMatcher?t:U(t)),{isDeprecatedMatcher:!0})},e.createSwitch=function(e){var t,r,n={};try{for(var i=Z(Object.keys(e.paths)),a=i.next();!a.done;a=i.next()){var s=a.value,u=e.paths[s];n[s]=u.isDeprecatedMatcher?u:U(u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}if(1===Object.keys(e).length)return Object.assign(H(n),{isDeprecatedMatcher:!0});e.paths;var c=Y(e,["paths"]);return Object.assign(o(Q(J(c)),F(function(e,t){return t.meta}),$(function(e,t){return t.title}),E(function(e,t){return t.content}),H(n)),{isDeprecatedMatcher:!0})},e.createRedirect=function(e,t){var r=N(e);return t?o(F(t),r):Object.assign(r,{isDeprecatedMatcher:!0})},e.mount=H,e.redirect=N,e.route=function(e){if(void 0===e&&(e={}),"function"!=typeof e){var t=e.data,r=e.getData,n=e.head,i=e.getHead,a=e.headers,s=e.getHeaders,u=e.status,c=e.getStatus,l=e.title,h=e.getTitle,f=e.view,p=e.getView;ne(e,["data","getData","head","getHead","headers","getHeaders","status","getStatus","title","getTitle","view","getView"]),e=function(e,o){return te(this,void 0,void 0,function(){var b,d,y,v,m,w,g;return re(this,function(S){switch(S.label){case 0:return b=r?Promise.resolve(r(e,o,void 0)).then(x).then(oe):Promise.resolve(t||{}),d=s?Promise.resolve(s(e,o,b)).then(x):Promise.resolve(a),y=c?Promise.resolve(c(e,o,b)).then(x):Promise.resolve(u),v=h?Promise.resolve(h(e,o,b)).then(x):Promise.resolve(l),"HEAD"!==e.method&&(m=i?Promise.resolve(i(e,o,b)).then(x):Promise.resolve(n),w=p?Promise.resolve(p(e,o,b)).then(x):Promise.resolve(f)),g={},[4,b];case 1:return g.data=S.sent(),[4,m];case 2:return g.head=S.sent(),[4,d];case 3:return g.headers=S.sent(),[4,y];case 4:return g.status=S.sent(),[4,v];case 5:return g.title=S.sent(),[4,w];case 6:return[2,(g.view=S.sent(),g)]}})})}}return o(Q(e),F(function(e,t){return t.data}),W(function(e,t){return t.head}),X(function(e,t){return t.headers}),ee(function(e,t){return t.status}),$(function(e,t){return t.title}),E(function(e,t){return t.view}))},e.withContext=Q,e.withData=F,e.withHead=W,e.withHeaders=X,e.withStatus=ee,e.withTitle=$,e.withView=E,e.NaviError=p,e.NotFoundError=b,e.OutOfRootError=d,e.createRequest=I,e.createChunk=y,e.createNotFoundChunk=v,e.areURLDescriptorsEqual=i,e.createURLDescriptor=s,e.parseQuery=u,e.stringifyQuery=c,e.joinPaths=l,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "navi", | ||
"version": "0.11.3", | ||
"version": "0.11.4", | ||
"description": "A router-loader for React.", | ||
@@ -59,3 +59,3 @@ "author": "James K Nelson <james@jamesknelson.com>", | ||
}, | ||
"gitHead": "ceb0a0757163e0cee5e7b569c6bb40540492b248" | ||
"gitHead": "a7b3eff8e3d0423a937a5b1c378865b3575770bc" | ||
} |
@@ -7,3 +7,4 @@ import resolveChunks, { Resolvable } from './Resolvable' | ||
MatcherGenerator, | ||
concatMatcherIterators | ||
concatMatcherIterators, | ||
createMatcherIterator | ||
} from './Matcher' | ||
@@ -38,3 +39,3 @@ import { NaviRequest } from './NaviRequest'; | ||
yield* (child ? concatMatcherIterators(parentIterator, child(request, context)) : parentIterator) | ||
yield* (child ? concatMatcherIterators(parentIterator, createMatcherIterator(child, request, context)) : parentIterator) | ||
} | ||
@@ -41,0 +42,0 @@ } |
import { Resolvable } from './Resolvable' | ||
import { Chunk } from './Chunks' | ||
import { NaviRequest } from './NaviRequest' | ||
import { joinPaths } from './URLTools' | ||
@@ -21,3 +22,19 @@ export type Matcher< | ||
export function createMatcherIterator<Context extends object>( | ||
matcherGenerator: MatcherGenerator<Context>, request: NaviRequest, context: Context, pattern = '' | ||
): MatcherIterator { | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (typeof matcherGenerator !== 'function') { | ||
console.error( | ||
`A matcher at the URL "${joinPaths( | ||
request.mountpath, | ||
pattern, | ||
)}" is invalid. A generator function was expected, but "${String(matcherGenerator)}" was received.`, | ||
) | ||
} | ||
} | ||
return matcherGenerator(request, context) | ||
} | ||
export function* concatMatcherIterators(x: MatcherIterator, y: MatcherIterator) { | ||
@@ -24,0 +41,0 @@ let xResult: IteratorResult<Chunk[]> |
@@ -192,3 +192,3 @@ // | ||
} | ||
return matcher | ||
return Object.assign(matcher, { isDeprecatedMatcher: true }) | ||
} |
@@ -6,2 +6,3 @@ import resolveChunks from '../Resolvable' | ||
ResolvableMatcher, | ||
createMatcherIterator, | ||
} from '../Matcher' | ||
@@ -21,5 +22,5 @@ import { NaviRequest } from '../NaviRequest' | ||
context, | ||
(childMatcher) => childMatcher()(request, context) | ||
(childMatcher) => createMatcherIterator(childMatcher(), request, context) | ||
) | ||
} | ||
} |
import { Chunk, createChunk, createNotFoundChunk } from '../Chunks' | ||
import { createMapping, mappingAgainstPathname } from '../Mapping' | ||
import { Matcher, MatcherIterator } from '../Matcher' | ||
import { Matcher, MatcherIterator, createMatcherIterator } from '../Matcher' | ||
import { NaviRequest } from '../NaviRequest' | ||
import { joinPaths } from '../URLTools' | ||
@@ -55,14 +54,3 @@ export function mount< | ||
if (childRequest) { | ||
let matcherGenerator = mapping.matcher() | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (typeof matcherGenerator !== 'function') { | ||
console.error( | ||
`mount(): the pattern "${joinPaths( | ||
request.mountpath, | ||
mapping.pattern, | ||
)}" is invalid. It's value should be a matcher object.`, | ||
) | ||
} | ||
} | ||
childIterator = matcherGenerator(childRequest, context) | ||
childIterator = createMatcherIterator(mapping.matcher(), childRequest, context, mapping.pattern) | ||
@@ -69,0 +57,0 @@ // The first match is always the only match, as we don't allow |
@@ -6,2 +6,3 @@ import resolveChunks, { Resolvable } from '../Resolvable' | ||
MatcherGenerator, | ||
createMatcherIterator, | ||
} from '../Matcher' | ||
@@ -37,3 +38,4 @@ import { NaviRequest } from '../NaviRequest'; | ||
childContext => | ||
child( | ||
createMatcherIterator( | ||
child, | ||
request, | ||
@@ -40,0 +42,0 @@ childContext! || {} |
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 not supported yet
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 not supported yet
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 not supported yet
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 not supported yet
Sorry, the diff of this file is too big to display
638128
10797